@kern0x1b/penstock-cli 26.10.4 → 26.10.5
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/dist/chunk-account-C8EHysMH.js +1 -0
- package/dist/chunk-agentFailure-piRAFLGH.js +1 -0
- package/dist/chunk-agentLaunch-C5Uo40vv.js +1 -0
- package/dist/chunk-agentServe-4O0syoYQ.js +10 -0
- package/dist/chunk-analyze-Brxlb4U1.js +1 -0
- package/dist/chunk-analyze-CUxuBgNS.js +1 -0
- package/dist/chunk-apply-BAMwoXG9.js +1 -0
- package/dist/chunk-atomicWrite-C6J1gDtO.js +1 -0
- package/dist/chunk-baseline-DvS2S0am.js +1 -0
- package/dist/chunk-bot-I4kuhjyv.js +11 -0
- package/dist/chunk-cacheDirectory-7sa0970e.js +1 -0
- package/dist/chunk-codeFactSet-DOOlbIIj.js +1 -0
- package/dist/chunk-codeIndex-CzENd6hG.js +1 -0
- package/dist/chunk-codeLinks-D-gzUjYv.js +1 -0
- package/dist/chunk-codeLinks-DLxEBWPi.js +1 -0
- package/dist/chunk-command-BR4memGJ.js +1 -0
- package/dist/chunk-command-BctoT00W.js +5 -0
- package/dist/chunk-command-Jl1msVwF.js +1 -0
- package/dist/chunk-commands-CeRlfHY-.js +1 -0
- package/dist/chunk-compose-BV9Jg348.js +4 -0
- package/dist/chunk-connectors-CVfz5pSg.js +1 -0
- package/dist/chunk-connectors-eXPldvkc.js +2 -0
- package/dist/chunk-context-DPJmldqg.js +1 -0
- package/dist/chunk-convert-B1sgT9kl.js +1 -0
- package/dist/chunk-deploy-C4KJK-tw.js +1 -0
- package/dist/chunk-deploy-DOXu2-8q.js +2 -0
- package/dist/chunk-diagram-BaVwLa4h.js +1 -0
- package/dist/chunk-diagram-CCA1-fT5.js +1 -0
- package/dist/chunk-diagramDefects-7UG_Iwsr.js +1 -0
- package/dist/chunk-diagrams-6suPQBVQ.js +1 -0
- package/dist/chunk-diff-BC8gZX5w.js +1 -0
- package/dist/chunk-diff-D1m_eKvv.js +1 -0
- package/dist/chunk-diffModels-DYtf3au1.js +3 -0
- package/dist/chunk-dispatch-CW2CJI0C.js +6 -0
- package/dist/chunk-docs-CY6ICsip.js +1 -0
- package/dist/chunk-docs-CwY3Ce9M.js +30 -0
- package/dist/chunk-doctor-m0mnVdDE.js +1 -0
- package/dist/chunk-drawing-shRfnrs9.js +8 -0
- package/dist/chunk-editPreview-BgH1JVOD.js +1 -0
- package/dist/chunk-engine-CxgdJ2wO.js +1 -0
- package/dist/chunk-export-9AWsr5ai.js +1 -0
- package/dist/chunk-export-D5kPD4Or.js +20 -0
- package/dist/chunk-facts-DA3Y-k9a.js +1 -0
- package/dist/chunk-failure-BsimkHy_.js +1 -0
- package/dist/chunk-features-BfRg2kR5.js +1 -0
- package/dist/chunk-features-BwnwB6jL.js +1 -0
- package/dist/chunk-folders-13vx0i0n.js +1 -0
- package/dist/chunk-folders-C1Nes4Ap.js +1 -0
- package/dist/chunk-formChecks-acRgARZ3.js +1 -0
- package/dist/chunk-git-BOKyPQj7.js +3 -0
- package/dist/chunk-help-CFhmAhz8.js +85 -0
- package/dist/chunk-importCommand-5SJxu2k4.js +1 -0
- package/dist/chunk-init-AIh_7yE0.js +227 -0
- package/dist/chunk-license-B_To2110.js +1 -0
- package/dist/chunk-license-x3oHbKe2.js +1 -0
- package/dist/chunk-lint-C_fAcLIg.js +1 -0
- package/dist/chunk-load-BVJUBU5S.js +5 -0
- package/dist/chunk-main-D3S4Xr__.js +1 -0
- package/dist/chunk-mcp-ByMCWlXC.js +76 -0
- package/dist/chunk-mcpLaunch-C13ViiIP.js +592 -0
- package/dist/chunk-migrate-CLQ-hrae.js +1 -0
- package/dist/chunk-migrate-CVUR1K7f.js +1 -0
- package/dist/chunk-moddle-AjPH0QEc.js +1 -0
- package/dist/chunk-moddle-Dlk0NR-u.js +1 -0
- package/dist/chunk-own-CX-3lIbf.js +1 -0
- package/dist/chunk-penstockCli-CqiOKC75.js +1 -0
- package/dist/chunk-placeholderLayout-B18ekWmh.js +1 -0
- package/dist/chunk-plural-Bq_4vgOr.js +1 -0
- package/dist/chunk-pr-tC3-PSNM.js +1 -0
- package/dist/chunk-preferencesFile-F6bAlNrk.js +1 -0
- package/dist/chunk-project-qT-Fk_Rz.js +1 -0
- package/dist/chunk-report-CDz78nCI.js +1 -0
- package/dist/chunk-review-BqZSohXR.js +1 -0
- package/dist/chunk-rules-DJlL7K_Q.js +1 -0
- package/dist/chunk-security-5SU-bq3A.js +18 -0
- package/dist/chunk-share-YSewfw3F.js +239 -0
- package/dist/chunk-src-BLyg_6UX.js +879 -0
- package/dist/chunk-stages-C-nhLoBW.js +3 -0
- package/dist/chunk-status-DgeSOz3A.js +1 -0
- package/dist/chunk-systemError-2me5k57V.js +1 -0
- package/dist/chunk-systemError-B-1nL94i.js +1 -0
- package/dist/chunk-table-CJtiXv0e.js +1 -0
- package/dist/chunk-taskTest-4rIxp0rL.js +2 -0
- package/dist/chunk-taskTest-rng12v_b.js +1 -0
- package/dist/chunk-templates-Bxe3J0qy.js +1 -0
- package/dist/chunk-testCases-CwQ-Mi7L.js +1 -0
- package/dist/chunk-testCases-xculyxH_.js +4 -0
- package/dist/chunk-tests-C-kNQNpq.js +1 -0
- package/dist/chunk-tests-C3XJ9LMT.js +23 -0
- package/dist/chunk-translator-BFUJmSkR.js +21 -0
- package/dist/chunk-trust-u1vZ6Yk0.js +1 -0
- package/dist/chunk-trust-yKw_pXRj.js +1 -0
- package/dist/chunk-version-CdS8_QQd.js +1 -0
- package/dist/chunk-workerVariables-CCLcoR0U.js +1 -0
- package/dist/chunk-wrapper-AJWl6ru-.js +3 -0
- package/dist/chunk-wrapper-Bxz1Lgp5.js +1 -0
- package/dist/locales/de.json +9176 -0
- package/dist/locales/es.json +9176 -0
- package/dist/locales/fr.json +9176 -0
- package/dist/locales/ja.json +9023 -0
- package/dist/locales/ko.json +9023 -0
- package/dist/locales/pt-BR.json +9176 -0
- package/dist/locales/ru.json +9482 -0
- package/dist/locales/zh.json +9023 -0
- package/dist/penstock.js +1 -2363
- package/dist/web/assets/{AgentSettings-BvzT4Itb.js → AgentSettings-C3Er_rlW.js} +1 -1
- package/dist/web/assets/{AgentsDialog-BqY3wKcV.js → AgentsDialog-Bo7kikb6.js} +1 -1
- package/dist/web/assets/{BpmnCanvas-BTdM1l9l.js → BpmnCanvas-Dw5zgCN3.js} +3 -3
- package/dist/web/assets/{BpmnDocument-uifU3NGG.js → BpmnDocument-CuU0biX9.js} +4 -4
- package/dist/web/assets/{ConflictDialog-C4A9-Psr.js → ConflictDialog-GxZ-d8SK.js} +1 -1
- package/dist/web/assets/{DiffDocument-BMTSevd7.js → DiffDocument-Bh3hFmmi.js} +1 -1
- package/dist/web/assets/{DmnDocument-B8wWuhfX.js → DmnDocument-C8HpJAcE.js} +1 -1
- package/dist/web/assets/{FormDocument-bQ5VRsrh.js → FormDocument-CH-4KB3x.js} +1 -1
- package/dist/web/assets/{FormStepView-DbMCFSO1.js → FormStepView-DraPVoAN.js} +1 -1
- package/dist/web/assets/GraphAwareLayoutService-C8J8YHJI.js +21 -0
- package/dist/web/assets/NewFileDialog-j09JqpPj.js +47 -0
- package/dist/web/assets/{QuickOpen-mzlfRqvG.js → QuickOpen-CeBhsCzA.js} +1 -1
- package/dist/web/assets/{ScriptPane-C9q5wLfO.js → ScriptPane-DDikZDv6.js} +2 -2
- package/dist/web/assets/{ScriptRunDialog-Dm-_0H1Z.js → ScriptRunDialog-DdzJ0pvT.js} +1 -1
- package/dist/web/assets/{SettingsDialog-Bhwwtyg7.js → SettingsDialog-JUc5zUR9.js} +1 -1
- package/dist/web/assets/{ShortcutsDialog-BXP0h7Tp.js → ShortcutsDialog-DECqWPNE.js} +1 -1
- package/dist/web/assets/{SourceDocument-DgrNCprS.js → SourceDocument-X8ajUcxM.js} +1 -1
- package/dist/web/assets/{TextDocument-D8N0uaQa.js → TextDocument-0z7qojAh.js} +1 -1
- package/dist/web/assets/{UnreadableFileLayer-D2Rcxnt7.js → UnreadableFileLayer-D3G59F4u.js} +1 -1
- package/dist/web/assets/{UploadDialog-Dinga4TP.js → UploadDialog-CiahYkTc.js} +1 -1
- package/dist/web/assets/{apply-CzXxiRWK.js → apply-HqvoGwLE.js} +1 -1
- package/dist/web/assets/{bpmnTheme-db4tYvop.js → bpmnTheme-cOvp4qFc.js} +1 -1
- package/dist/web/assets/{bridgeInstance-BPwbITOf.js → bridgeInstance-DQk-c8L1.js} +1 -1
- package/dist/web/assets/{commands-BAnBjEk3.js → commands-nPznxvPp.js} +1 -1
- package/dist/web/assets/de-Dj813wjn.js +1 -0
- package/dist/web/assets/{dialog-KVjfqSrB.js → dialog-CtGB1LHI.js} +1 -1
- package/dist/web/assets/{diff-Cw0ENHJR.js → diff-NgYeO98t.js} +1 -1
- package/dist/web/assets/{documentBridge-D5SaBThP.js → documentBridge-QW0IZ9Bq.js} +2 -2
- package/dist/web/assets/{documents-Dkor36oS.js → documents-KeXEdK1U.js} +1 -1
- package/dist/web/assets/{duplicate-ud-StKuO.js → duplicate-DNPpPVse.js} +1 -1
- package/dist/web/assets/{engines-BQRXHtW8.js → engines-DU0BfbYM.js} +1 -1
- package/dist/web/assets/es-CyJDEw4H.js +1 -0
- package/dist/web/assets/{formChecks-DFrCuO4I.js → formChecks-sU20kKkU.js} +1 -1
- package/dist/web/assets/fr-B1lqrd3d.js +1 -0
- package/dist/web/assets/frontend-caI7mOAL.js +1 -0
- package/dist/web/assets/{httpHost-DX-P_FDg.js → httpHost-Dqit__mm.js} +1 -1
- package/dist/web/assets/{index.es-dFUgH_-g.js → index.es-BqVUpGyA.js} +1 -1
- package/dist/web/assets/{index.es-DR-czZl7.js → index.es-DqkfrvWI.js} +1 -1
- package/dist/web/assets/{intelligence-BkxcJMU_.js → intelligence-Ck_Q9upa.js} +1 -1
- package/dist/web/assets/ja-BUAM_DzQ.js +1 -0
- package/dist/web/assets/{jspdf.es.min-BMfOi0te.js → jspdf.es.min-CM3S4IDt.js} +3 -3
- package/dist/web/assets/ko-7l4EjTF9.js +1 -0
- package/dist/web/assets/{lib-C3uYnGWx.js → lib-DAKOOgix.js} +1 -1
- package/dist/web/assets/{platform-zEAtGnYc.js → platform-CkWAyNst.js} +1 -1
- package/dist/web/assets/{preferences-K6VRM9Ah.js → preferences-nBrFGN89.js} +1 -1
- package/dist/web/assets/pt-BR-CxxRL7kF.js +1 -0
- package/dist/web/assets/ru-C4gbkVXL.js +1 -0
- package/dist/web/assets/{run-fV7AmV4q.js → run-B3YvrVeP.js} +1 -1
- package/dist/web/assets/{samples-D-3Bquy_.js → samples-BVuIm-bu.js} +1 -1
- package/dist/web/assets/{testCaseRuns-C-0blM3d.js → testCaseRuns-DYKnccnc.js} +1 -1
- package/dist/web/assets/translator-B2N3PQBL.js +1 -0
- package/dist/web/assets/{ui-TBzvKaKQ.js → ui-3pEQJ50t.js} +1 -1
- package/dist/web/assets/{useTrace-BgpeAcQR.js → useTrace-BAXnn0Bt.js} +1 -1
- package/dist/web/assets/{web-qJCedJJw.js → web-B2zkonPE.js} +5 -5
- package/dist/web/assets/zh-DIYPlVjz.js +1 -0
- package/dist/web/index.html +19 -19
- package/package.json +1 -1
- package/dist/web/assets/GraphAwareLayoutService-CePcz6pL.js +0 -21
- package/dist/web/assets/NewFileDialog-DsoFURD9.js +0 -47
- package/dist/web/assets/de-Cd75cvcZ.js +0 -1
- package/dist/web/assets/es-D2PUEg_Z.js +0 -1
- package/dist/web/assets/fr-DkGYGarc.js +0 -1
- package/dist/web/assets/frontend-B05iyhCp.js +0 -1
- package/dist/web/assets/ja-De4NAvK-.js +0 -1
- package/dist/web/assets/ko-Ci27KQ5n.js +0 -1
- package/dist/web/assets/pt-BR-CNmIseZJ.js +0 -1
- package/dist/web/assets/ru-BtK7W4xW.js +0 -1
- package/dist/web/assets/translator-Dvvasoz-.js +0 -1
- package/dist/web/assets/zh-DxI_A5kC.js +0 -1
|
@@ -0,0 +1,879 @@
|
|
|
1
|
+
import{i as e,r as t,t as n}from"./chunk-translator-BFUJmSkR.js";import{a as r,o as i,r as a,s as o,t as s}from"./chunk-moddle-Dlk0NR-u.js";import{_ as c,b as l,d as u,f as d,h as f,i as p,m,n as h,o as g,r as _,u as v,v as y,y as b}from"./chunk-engine-CxgdJ2wO.js";import{r as x}from"./chunk-docs-CY6ICsip.js";import"./chunk-connectors-eXPldvkc.js";import{Inflate as S,strFromU8 as ee,unzipSync as C}from"fflate";import{migrateDiagram as te}from"@bpmn-io/dmn-migrate";import{Parser as w}from"saxen";function T(e,t){return Object.hasOwn(e,t)?e[t]:void 0}const ne=/(?<![\w.$#])([A-Za-z_]\w*)/g,E=/[$#]\{([\s\S]*?)}/g,re=/"(?:\\.|[^"\\])*"/g,ie=/'(?:\\.|[^'\\])*'/g,ae=/^\.\s*\w+\s*\(/,D=/\b(?:for|some|every)\s+([A-Za-z_]\w*)\s+in\b/g,oe=/* @__PURE__ */ new Set([`true`,`false`,`null`,`and`,`or`,`not`,`if`,`then`,`else`,`for`,`in`,`return`,`some`,`every`,`satisfies`,`instance`,`of`,`between`,`function`,`external`,`item`]),se=/* @__PURE__ */ new Set([`true`,`false`,`null`,`empty`,`not`,`and`,`or`,`eq`,`ne`,`lt`,`gt`,`le`,`ge`,`div`,`mod`,`instanceof`,`execution`,`task`,`variableScope`,`authenticatedUserId`]);function ce(e,t,n){let r=/* @__PURE__ */ new Set;for(let i of e.matchAll(ne)){let a=i[1],o=e.slice((i.index??0)+a.length).trimStart();t.has(a)||o.startsWith(`(`)||!n&&o.startsWith(`:`)&&!o.startsWith(`::`)||n&&ae.test(o)||r.add(a)}return r}function le(e){let t=e?.trim().replace(/^=/,``);if(!t)return/* @__PURE__ */ new Set;let n=t.replace(re,`""`),r=new Set([...n.matchAll(D)].map(e=>e[1]));return new Set([...ce(n,oe,!1)].filter(e=>!r.has(e)))}function ue(e){return e?.trimStart().startsWith(`=`)?le(e):/* @__PURE__ */ new Set}function O(e){if(!e?.trim())return/* @__PURE__ */ new Set;let t=/* @__PURE__ */ new Set;for(let n of e.matchAll(E))ce(n[1].replace(re,`""`).replace(ie,`''`),se,!0).forEach(e=>t.add(e));return t}function k(e){return/* @__PURE__ */ new Set([...ue(e),...O(e)])}const de=/(?<![\w.$#\]])([A-Za-z_]\w*)/g,fe=/^\s*(\[[^[\]]*\]|\.\s*([A-Za-z_]\w*))/,pe=/^\s*\(/;function me(e,t,n){let r=e.replace(re,`""`).replace(ie,`''`),i=[];for(let e of r.matchAll(de)){let a=e[1];if(t.has(a)||n.has(a))continue;let o=(e.index??0)+a.length,s=a,c=0;for(let e=fe.exec(r.slice(o));e&&!(e[2]!==void 0&&pe.test(r.slice(o+e[0].length)));e=fe.exec(r.slice(o)))s+=e[2]===void 0?e[1].replace(/\s+/g,``):`.${e[2]}`,o+=e[0].length,c+=1;c>0&&!pe.test(r.slice(o))&&i.push(s)}return i}function he(e){return e?[...e.matchAll(E)].flatMap(e=>me(e[1],se,/* @__PURE__ */ new Set)):[]}function ge(e){let t=e?.trim().replace(/^=/,``)??``;if(!t)return[];let n=new Set([...t.replace(re,`""`).matchAll(D)].map(e=>e[1]));return me(t,oe,n)}function A(e){let t=e?.trim()??``;return/[$#]\{/.test(t)?he(t):t.startsWith(`=`)?ge(t):[]}function _e(e){let t=/^[A-Za-z_]\w*/.exec(e)?.[0]??``,n=[];for(let r of e.slice(t.length).matchAll(/\[[^\]]*\]|\.([A-Za-z_]\w*)/g))n.push(r[1]===void 0?{kind:`index`}:{kind:`field`,name:r[1]});return{root:t,steps:n}}function ve(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}const ye=/* @__PURE__ */ new Map([[`string`,`String`],[`boolean`,`Boolean`],[`integer`,`Integer`],[`long`,`Long`],[`double`,`Double`],[`float`,`Float`]]);function be(e){let t=ye.get(e);if(t===void 0)throw Error(`no Java type is named for ${e}`);return t}const xe=/\b(?:execution|task)\s*\.\s*setVariable\s*\(\s*(["'])/g,Se=/^[^"'\\\r\n]+$/,Ce=/^[A-Za-z_$][\w$]*$/,we=/^\s*,\s*/,Te=/^(?:'(?:[^'\\\r\n]|\\.)*'|"(?:[^"\\\r\n]|\\.)*")/,Ee=/^(?:true|false)(?![\w$])/,De=/^(-?)(\d+)(\.\d+)?([dDfFlL])?(?![\w$.])/,Oe=/^new\s+((?:[a-z]\w*\.)*[A-Z]\w*(?:\.[A-Z]\w*)*)\s*(?:<[^()\n]*>)?\s*\(/,ke=/^(-?\d+(?:\.\d+)?)(?![\w$.])/,Ae={"\\":`\\`,"'":`'`,'"':`"`,$:`$`,n:`
|
|
2
|
+
`,r:`\r`,t:` `},je=/^\s*[),;\n]|^\s*$/,Me=[`return`,`throw`,`new`,`else`,`case`,`in`,`is`,`as`,`instanceof`,`assert`,`yield`];function Ne(e){let t=e?.trim().toLowerCase();return t===`groovy`?`groovy`:t===`javascript`||t===`js`||t===`ecmascript`?`javascript`:null}function Pe(e){let t=``,n=null;for(let r=0;r<e.length;r+=1){let i=e[r];if(n)i===`\\`&&r+1<e.length?(t+=e[r+1]===`
|
|
3
|
+
`?`
|
|
4
|
+
`:` `,r+=1):i===n||i===`
|
|
5
|
+
`?(n=null,t+=i):t+=` `;else if(i===`"`||i===`'`)n=i,t+=i;else if(i===`/`&&e[r+1]===`/`){let n=e.indexOf(`
|
|
6
|
+
`,r),i=n<0?e.length:n;t+=` `.repeat(i-r),r=i-1}else if(i===`/`&&e[r+1]===`*`){let n=e.indexOf(`*/`,r+2),i=n<0?e.length:n+2;t+=e.slice(r,i).replace(/[^\n]/g,` `),r=i-1}else t+=i}return t}function Fe(e,t){let n=t?`9223372036854775808`:`9223372036854775807`,r=e.replace(/^0+(?=\d)/,``);return r.length<n.length||r.length===n.length&&r<=n}function Ie(e){let[,t,n,r,i]=e,a=t===`-`;if(i){let e=i.toLowerCase();return e===`l`?r===void 0&&Fe(n,a)?be(`long`):null:e===`d`?be(`double`):e===`f`?be(`float`):null}if(r!==void 0)return null;let o=Number(`${t}${n}`);return o>=-2147483648&&o<=2147483647?be(`integer`):Fe(n,a)?be(`long`):null}function Le(e,t){let n=0;for(let r=t;r<e.length;r+=1)if(e[r]===`(`)n+=1;else if(e[r]===`)`&&(--n,n===0))return r;return-1}function Re(e){let t=e.slice(1,-1),n=``;for(let e=0;e<t.length;e+=1){if(t[e]!==`\\`){n+=t[e];continue}let r=Ae[t[e+1]];if(r===void 0)return null;n+=r,e+=1}return n}function ze(e,t){let n=Te.exec(e);if(!n)return null;let r=n[0];if(t===`groovy`&&r.startsWith(`"`)&&r.includes(`$`)||!je.test(e.slice(r.length)))return null;let i=Re(r);return{type:be(`string`),sample:i===null?null:JSON.stringify(i)}}function Be(e,t,n){return je.test(t)?{type:n,sample:e}:null}function Ve(e,t,n,r){let i=e.slice(n),a=ze(i,r);if(a)return a;let o=Ee.exec(i);if(o)return je.test(i.slice(o[0].length))?{type:be(`boolean`),sample:o[0]}:null;if(r===`groovy`){let r=De.exec(i);if(r)return Be(`${r[1]}${r[2]}${r[3]??``}`,i.slice(r[0].length),Ie(r));let a=Oe.exec(i);if(a){let r=Le(t,n+a[0].length-1);return r>=0&&je.test(e.slice(r+1))?{type:a[1],sample:null}:null}return null}let s=ke.exec(i);return s?Be(s[1],i.slice(s[0].length),null):null}function He(e,t){let n=Ne(t);if(!e||!n)return[];let r=Pe(e),i=[];for(let t of r.matchAll(xe)){let a=(t.index??0)+t[0].length,o=r.indexOf(t[1],a);if(o<0)continue;let s=e.slice(a,o);if(!Se.test(s))continue;let c=we.exec(r.slice(o+1));if(!c)continue;let l=Ve(e,r,o+1+c[0].length,n);i.push({name:s,type:l?.type??null,sample:l?.sample??null})}return i}function Ue(e,t){if(!e||!Ce.test(t))return!1;let n=Me.join(`|`);return RegExp(`(?:^|[^\\w$.])(?!(?:${n})\\b)(?:(?:def|var|let|const|final)|[A-Za-z_$][\\w$]*(?:\\.[A-Za-z_$][\\w$]*)*(?:<[^>\\n]*>)?(?:\\[\\])?)\\s+${ve(t)}\\s*[=;]`,`m`).test(Pe(e))}const We=/^[A-Za-z_]\w*$/,Ge={"camunda:assignee":`assignment`,"camunda:candidateUsers":`assignment`,"camunda:candidateGroups":`assignment`,"camunda:dueDate":`assignment`,"camunda:followUpDate":`assignment`,"camunda:priority":`assignment`,"camunda:expression":`expression`},Ke={"camunda:resultVariable":`result`,"camunda:initiator":`initiator`,"camunda:errorCodeVariable":`error`,"camunda:errorMessageVariable":`error`,"camunda:elementVariable":`loop element`};var qe=class{uses=[];forms=[];reads(e,t,n,r){r(n).forEach(n=>this.uses.push({name:n,writes:!1,elementId:e,where:t}))}writes(e,t,n){n&&We.test(n)&&this.uses.push({name:n,writes:!0,elementId:e,where:t})}scripts(e,t,n){He(n,t).forEach(({name:t,type:n,sample:r})=>this.uses.push({name:t,writes:!0,elementId:e,where:`script`,type:n,sample:r}))}};function Je(e,t){let n=e?.get?.(t)??e?.$attrs?.[t];return typeof n==`string`&&n.trim()?n:void 0}function Ye(e){return typeof e?.body==`string`?e.body:void 0}function Xe(e){return e?.extensionElements?.values??[]}function Ze(e,t,n){Object.entries(Ge).forEach(([r,i])=>e.reads(t,i,Je(n,r),O)),Object.entries(Ke).forEach(([r,i])=>e.writes(t,i,Je(n,r)))}function Qe(e,t,n){switch(n.$type){case`zeebe:IoMapping`:(n.inputParameters??[]).forEach(n=>{e.reads(t,`input`,n.source,le),e.writes(t,`input`,n.target)}),(n.outputParameters??[]).forEach(n=>{e.reads(t,`output`,n.source,le),e.writes(t,`output`,n.target)});break;case`zeebe:LoopCharacteristics`:e.reads(t,`loop collection`,n.inputCollection,le),e.writes(t,`loop element`,n.inputElement),e.writes(t,`loop output`,n.outputCollection),e.reads(t,`loop output`,n.outputElement,le);break;case`zeebe:AssignmentDefinition`:[`assignee`,`candidateGroups`,`candidateUsers`].forEach(r=>e.reads(t,`assignment`,n[r],ue));break;case`zeebe:CalledDecision`:e.writes(t,`decision result`,n.resultVariable);break;case`zeebe:Script`:e.reads(t,`script`,n.expression,le),e.writes(t,`script result`,n.resultVariable);break;case`zeebe:CalledElement`:e.reads(t,`called process`,n.processId,ue);break;case`zeebe:TaskDefinition`:e.reads(t,`job type`,n.type,ue);break;case`zeebe:FormDefinition`:n.formId&&e.forms.push({elementId:t,formId:n.formId});break;case`camunda:InputOutput`:(n.inputParameters??[]).forEach(n=>{e.writes(t,`input`,n.name),e.reads(t,`input`,n.value,O)}),(n.outputParameters??[]).forEach(n=>{e.writes(t,`output`,n.name),e.reads(t,`output`,n.value,O)});break;case`camunda:FormData`:(n.fields??[]).forEach(n=>e.writes(t,`form field`,n.id));break;case`camunda:In`:e.reads(t,`call input`,n.source,e=>new Set(e?[e]:[])),e.reads(t,`call input`,n.sourceExpression,O);break;case`camunda:Out`:e.writes(t,`call output`,n.target)}}function $e(e,t,n){(n.eventDefinitions??[]).forEach(n=>{[`timeDuration`,`timeDate`,`timeCycle`].forEach(r=>e.reads(t,`timer`,Ye(n[r]),k)),e.reads(t,`condition`,Ye(n.condition),k),Ze(e,t,n);let r=n.messageRef;Xe(r).filter(e=>e.$type===`zeebe:Subscription`).forEach(n=>e.reads(t,`correlation key`,n.correlationKey,le))})}function et(e,t,n){let r=n.loopCharacteristics;if(!r)return;e.reads(t,`completion condition`,Ye(r.completionCondition),k),e.reads(t,`loop cardinality`,Ye(r.loopCardinality),k);let i=Je(r,`camunda:collection`);e.reads(t,`loop collection`,i,e=>e&&We.test(e)?/* @__PURE__ */ new Set([e]):O(e)),Ze(e,t,r),Xe(r).forEach(n=>Qe(e,t,n))}function tt(e,t,n){n.$type===`bpmn:ScriptTask`&&e.scripts(t,n.scriptFormat,n.script),Xe(n).filter(e=>e.$type===`camunda:ExecutionListener`||e.$type===`camunda:TaskListener`).forEach(n=>e.scripts(t,n.script?.scriptFormat,n.script?.value))}function nt(e,t){let n=t.id;if(!n)return;e.reads(n,`condition`,Ye(t.conditionExpression),k),Ze(e,n,t),Xe(t).forEach(t=>Qe(e,n,t)),tt(e,n,t),$e(e,n,t),et(e,n,t),Xe(t.messageRef).filter(e=>e.$type===`zeebe:Subscription`).forEach(t=>e.reads(n,`correlation key`,t.correlationKey,le));let r=Je(t,`camunda:formRef`);r&&e.forms.push({elementId:n,formId:r}),(t.flowElements??[]).forEach(t=>nt(e,t))}const rt=/^[A-Za-z_]\w*$/,it=[`timeDuration`,`timeDate`,`timeCycle`];function at(e){let t=e?.trim();return t?t.startsWith(`=`)||t.includes("${")||t.includes(`#{`)||rt.test(t):!1}function ot(e){return(typeof e?.name==`string`?e.name.trim():``)||(e?.$type===`bpmn:SequenceFlow`?`Flow ${e.id}`:String(e?.id??``))}var st=class{found=[];add(e,t,n){at(n)&&this.found.push({elementId:String(e.id),label:ot(e),where:t,expression:n.trim()})}};function ct(e,t,n){switch(n.$type){case`zeebe:IoMapping`:(n.inputParameters??[]).forEach(n=>e.add(t,`input`,n.source)),(n.outputParameters??[]).forEach(n=>e.add(t,`output`,n.source));break;case`zeebe:Script`:e.add(t,`script`,n.expression);break;case`zeebe:TaskDefinition`:e.add(t,`job type`,n.type);break;case`zeebe:AssignmentDefinition`:[`assignee`,`candidateGroups`,`candidateUsers`].forEach(r=>e.add(t,`assignment`,n[r]));break;case`zeebe:LoopCharacteristics`:e.add(t,`loop collection`,n.inputCollection),e.add(t,`loop output`,n.outputElement);break;case`zeebe:Subscription`:e.add(t,`correlation key`,n.correlationKey);break;case`camunda:InputOutput`:(n.inputParameters??[]).forEach(n=>e.add(t,`input`,n.value)),(n.outputParameters??[]).forEach(n=>e.add(t,`output`,n.value));break;case`camunda:In`:e.add(t,`call input`,n.source)}}function lt(e,t){let n=t.loopCharacteristics;n&&(e.add(t,`completion condition`,Ye(n.completionCondition)),e.add(t,`loop cardinality`,Ye(n.loopCardinality)),Xe(n).forEach(t=>ct(e,n,t)))}function ut(e,t){e.add(t,`condition`,Ye(t.conditionExpression)),Xe(t).forEach(n=>ct(e,t,n)),(t.eventDefinitions??[]).forEach(n=>{it.forEach(r=>e.add(t,`timer`,Ye(n[r]))),e.add(t,`condition`,Ye(n.condition)),Xe(n.messageRef).filter(e=>e.$type===`zeebe:Subscription`).forEach(n=>ct(e,t,n))}),Xe(t.messageRef).filter(e=>e.$type===`zeebe:Subscription`).forEach(n=>ct(e,t,n)),lt(e,t)}function dt(e){let t=new st,n=/* @__PURE__ */ new Set,r=(e,i)=>{let a=e?.id;a&&!n.has(a)&&(n.add(a),ut(t,e),[...e.outgoing??[],...e.incoming??[]].forEach(e=>r(e,!1)),i&&(e.flowElements??[]).forEach(e=>r(e,!0)))};return(e?.rootElements??[]).filter(e=>e.$type===`bpmn:Process`).forEach(e=>(e.flowElements??[]).forEach(e=>r(e,!0))),t.found}function ft(e){let t=new qe;return(e?.rootElements??[]).filter(e=>e.$type===`bpmn:Process`).forEach(e=>(e.flowElements??[]).forEach(e=>nt(t,e))),{uses:t.uses,forms:t.forms}}var pt=class{name;constructor(e){this.name=e}};function mt(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Set,r=[e];for(;r.length>0;){let e=r.pop();if(e instanceof pt)t.add(e.name);else if(e&&typeof e==`object`&&!n.has(e)){n.add(e);let t=Array.isArray(e)?e.map((e,t)=>[String(t),e]):Object.entries(e);for(let n=t.length-1;n>=0;--n){let[i,a]=t[n];r.push(!Array.isArray(e)&&i===`key`&&typeof a==`string`&&a.trim()?new pt(a):a)}}}return[...t]}function ht(e){let t=e?.id;return typeof t==`string`?t:void 0}const gt=[[/spec\/DMN\/20151101\//,`1.1`],[/spec\/DMN\/20180521\//,`1.2`],[/spec\/DMN\/20191111\//,`1.3`],[/spec\/DMN\/20211108\//,`1.4`],[/spec\/DMN\/20230324\//,`1.5`]],_t=/<((?:\w+:)?)definitions\b([^>]*)>/;function vt(e){let t=_t.exec(e);if(!t)return null;let n=t[1].slice(0,-1),r=RegExp(`\\sxmlns${n?`:${n}`:``}\\s*=\\s*["']([^"']*)["']`).exec(t[2]);return r?gt.find(([e])=>e.test(r[1]))?.[1]??null:null}async function yt(e){let t=vt(e);if(t!==`1.1`&&t!==`1.2`)return{xml:e,from:null};try{let n=await te(e);return vt(n)===`1.3`?{xml:n,from:t}:{xml:e,from:null}}catch{return{xml:e,from:null}}}function bt(e,n){return t(`app.migration.dmn.savedAsNotice`,{name:n,from:e})}const xt=[[/^unclosed tag$/i,`unclosedTag`,[]],[/^closing tag mismatch$/i,`closingTagMismatch`,[]],[/^close tag$/i,`closeTag`,[]],[/^missing start tag$/i,`missingStartTag`,[]],[/^missing open tag$/i,`missingOpenTag`,[]],[/^unexpected end of file$/i,`unexpectedEndOfFile`,[]],[/^unclosed cdata$/i,`unclosedCdata`,[]],[/^unclosed comment$/i,`unclosedComment`,[]],[/^unclosed question$/i,`unclosedQuestion`,[]],[/^illegal first char nodeName$/i,`illegalFirstCharNodeName`,[]],[/^illegal value of xmlns:xml$/i,`illegalValueOfXmlnsXml`,[]],[/^invalid nodeName$/i,`invalidNodeName`,[]],[/^missing namespace on <(.+)>$/i,`missingNamespaceOn`,[`element`]],[/^unparsable content <(.+)> detected$/i,`unparsableContent`,[`element`]],[/^unparsable content <(.+)> detected; this may indicate an invalid BPMN 2\.0 diagram file/i,`unparsableContentHinted`,[`element`]],[/^no diagram to display$/i,`noDiagramToDisplay`,[]],[/^element (.+) referenced by (.+)#(\w+) not yet drawn$/i,`notYetDrawn`,[`element`,`reference`,`property`]]],St=/nested error:\s*(.+)/,Ct=/line:\s*(\d+)/;function wt(e,n){return t(`app.unreadable.reason.${e}`,n)}function Tt(e){for(let[t,n,r]of xt){let i=t.exec(e);if(!i)continue;let a={};return r.forEach((e,t)=>{a[e]=i[t+1]}),wt(n,Object.keys(a).length>0?a:void 0)}return e}function Et(e){let t=e.message,n=St.exec(t)?.[1]?.trim(),r=Ct.exec(t)?.[1],i=t.split(`
|
|
7
|
+
`)[0]?.trim()??``;return{reason:Tt((n||i).replace(/^Error:\s*/,``)),line:r===void 0?null:Number(r)+1}}function Dt({reason:e,line:n}){let r=e.charAt(0).toUpperCase()+e.slice(1);return n===null?`${r}.`:t(`app.unreadable.atLine`,{reason:r,line:n})}var Ot=class extends Error{line;constructor(e,n){super(n===void 0?e:t(`app.dmn.readErrorAtLine`,{reason:e,line:n})),this.name=`DmnReadError`,this.line=n}};function kt(e){let n=String(e?.warnings?.[0]?.message??e?.message??e),r=/line:\s*(\d+)/.exec(n)?.[1],i=/nested error:\s*(.+)$/m.exec(n)?.[1]?.trim();return i?new Ot(t(`app.dmn.notValid`,{reason:Tt(i)}),r===void 0?void 0:Number(r)+1):new Ot(t(`app.dmn.notADocument`))}const At=/\sid\s*=\s*(["'])(.*?)\1/g;function jt(e){let n=/* @__PURE__ */ new Set;for(let r of e.matchAll(At)){let i=r[2];if(i!==``){if(n.has(i))return new Ot(t(`app.dmn.duplicateId`,{id:i}),e.slice(0,r.index).split(`
|
|
8
|
+
`).length);n.add(i)}}return null}async function Mt(e){let t=s(`plain`),{xml:n,from:r}=await yt(e),i=jt(n);if(i)throw i;try{let{rootElement:e}=await t.fromXML(n,`dmn:Definitions`);return{rootElement:e,xml:n,from:r}}catch(e){throw kt(e)}}const Nt={"bpmn:MessageEventDefinition":`message`,"bpmn:TimerEventDefinition":`timer`,"bpmn:ErrorEventDefinition":`error`,"bpmn:SignalEventDefinition":`signal`,"bpmn:EscalationEventDefinition":`escalation`,"bpmn:ConditionalEventDefinition":`conditional`};function Pt(e,t){return e?.extensionElements?.values?.find(e=>e.$type===t)}function j(e,t){try{return e.get?.(t)}catch{return}}function Ft(e){return typeof e==`string`&&e!==``?e:void 0}function It(e){let t={id:e.id??``,type:e.$type};Ft(e.name)&&(t.name=e.name);let n=e.eventDefinitions?.[0];if(n){t.event=Nt[n.$type]??n.$type.replace(`bpmn:`,``),t.message=n.messageRef?.name,t.correlationKey=n.messageRef?Pt(n.messageRef,`zeebe:Subscription`)?.correlationKey:void 0,t.signal=n.signalRef?.name,t.errorCode=n.errorRef?.errorCode;let e=n.timeDuration?`duration`:n.timeCycle?`cycle`:n.timeDate?`date`:void 0;e&&(t.timerKind=e,t.timer=(n.timeDuration??n.timeCycle??n.timeDate)?.body)}if(e.$type===`bpmn:ReceiveTask`){let n=e.messageRef;t.event=`message`,t.message=n?.name,t.correlationKey=n?Pt(n,`zeebe:Subscription`)?.correlationKey:void 0}e.attachedToRef&&(t.host=e.attachedToRef.id,t.interrupting=e.cancelActivity!==!1);let r=(e.outgoing??[]).map(e=>e.targetRef?.id).filter(e=>typeof e==`string`);r.length>0&&(t.follows=r),e.loopCharacteristics&&(t.repeats=!0),t.job=Pt(e,`zeebe:TaskDefinition`)?.type,t.zeebeUserTask=!!Pt(e,`zeebe:UserTask`),t.calledProcess=Pt(e,`zeebe:CalledElement`)?.processId??e.calledElement,t.decision=Pt(e,`zeebe:CalledDecision`)?.decisionId??j(e,`camunda:decisionRef`),t.form=Pt(e,`zeebe:FormDefinition`)?.formId;let i=Ft(Pt(e,`zeebe:CalledDecision`)?.resultVariable)??Ft(j(e,`camunda:resultVariable`));i&&(t.resultVariable=i);let a=Ft(j(e,`camunda:formRef`))??Ft(j(e,`camunda:formKey`))??Ft(Pt(e,`zeebe:FormDefinition`)?.formKey);return a&&(t.formKey=a),j(e,`camunda:type`)===`external`&&(t.external=String(j(e,`camunda:topic`)??``)),t.delegateClass=Ft(j(e,`camunda:class`)),t.delegateExpression=Ft(j(e,`camunda:delegateExpression`)),t.expression=Ft(j(e,`camunda:expression`)),t.delegateExpression&&(t.delegateBean=/^[$#]\{\s*([A-Za-z_]\w*)\s*\}$/.exec(t.delegateExpression)?.[1]),t.asyncBefore=j(e,`camunda:asyncBefore`)===!0,t.asyncAfter=j(e,`camunda:asyncAfter`)===!0,t}function Lt(e,t,n){for(let r of e??[])r?.id&&(n.set(r.id,{...It(r),processId:t}),r.flowElements&&Lt(r.flowElements,t,n))}function Rt(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map;for(let t of e?.rootElements??[])if(t.$type===`bpmn:Process`&&n.set(t.id,t),t.$type===`bpmn:Collaboration`)for(let e of t.participants??[])e.processRef?.id&&n.set(e.processRef.id,e.processRef);return n.forEach((e,n)=>Lt(e.flowElements,n,t)),t}function zt(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map,r=[];for(let t of e?.rootElements??[])if(t.$type===`bpmn:Process`&&r.push(t),t.$type===`bpmn:Collaboration`)for(let e of t.participants??[])e.processRef&&r.push(e.processRef);let i=(e,r,a)=>{for(let o of e??[])o.id&&(o.$type===`bpmn:SequenceFlow`?n.set(o.id,{id:o.id,name:o.name?.replace(/\s+/g,` `).trim()??``,condition:o.conditionExpression?.body?.trim()||void 0,source:o.sourceRef?.id??``,target:o.targetRef?.id??``}):(t.set(o.id,{id:o.id,name:o.name?.replace(/\s+/g,` `).trim()??``,type:o.$type,outgoing:[],incoming:[],defaultFlow:o.default?.id??null,process:r,parent:a}),o.flowElements&&i(o.flowElements,r,o.id)))};for(let e of r)i(e.flowElements,e.id??``,null);for(let e of n.values())t.get(e.source)?.outgoing.push(e.id),t.get(e.target)?.incoming.push(e.id);return{nodes:t,flows:n,steps:Rt(e)}}var Bt=class extends Map{index;constructor(e){super(),this.index=e}has(e){return this.index.nodes.has(e)}get(e){let t=super.get(e);if(t||!this.index.nodes.has(e))return t;let n=Ht(this.index,e);return this.set(e,n),n}};function Vt(e){return new Bt(zt(e))}function Ht(e,t){let n=/* @__PURE__ */ new Set,r=[t];for(let t=0;t<r.length;t+=1)e.nodes.get(r[t])?.outgoing.forEach(t=>{let i=e.flows.get(t)?.target;i&&!n.has(i)&&(n.add(i),r.push(i))});return n}function Ut(e){let t=/* @__PURE__ */ new Map;return e.nodes.forEach(e=>{let n=t.get(e.process)??[];n.push(e.id),t.set(e.process,n)}),[...t.values()].flatMap(t=>Wt(e,t))}function Wt(e,t){let n=[],r=/* @__PURE__ */ new Set;return t.filter(t=>e.nodes.get(t)?.incoming.length===0).forEach(t=>{r.has(t)||Gt(e,t,r,n)}),t.forEach(e=>{r.has(e)||(r.add(e),n.push(e))}),n}function Gt(e,t,n,r){n.add(t),r.push(t);let i=[t];for(let t=0;t<i.length;t+=1)e.nodes.get(i[t])?.outgoing.forEach(t=>{let a=e.flows.get(t)?.target;a&&e.nodes.has(a)&&!n.has(a)&&(n.add(a),r.push(a),i.push(a))})}function Kt(e,t,n){return t===n?!1:e.get(t)?.has(n)??!1}const qt={"camunda:ExecutionListener":`EXECUTION_LISTENER`,"camunda:TaskListener":`TASK_LISTENER`},Jt=2**53-1;function Yt(e){let t=e.split(`:`).pop()??e;return t.charAt(0).toLowerCase()+t.slice(1)}function Xt(e){return typeof e.name==`string`?e.name.replace(/\s+/g,` `).trim():``}function Zt(e,t){let n=e?.get?.(t)??e?.$attrs?.[t];return typeof n==`string`?n:void 0}function Qt(e){let t=e.slice(1);return t.startsWith(` `)?t.slice(1):t}function $t(e){if(!e||e.resource)return null;let t=Ne(e.scriptFormat);return t?{language:t,value:e.value??``}:null}var en=class{drafts=[];names=/* @__PURE__ */ new Map;seq=0;process(e){this.elements(e.flowElements,e.id??``,[])}elements(e,t,n){(e??[]).forEach(e=>{e.id&&(this.names.set(e.id,Xt(e)),e.$type===`bpmn:SequenceFlow`?this.flow(e,t,n):(this.element(e,t,n),this.elements(e.flowElements,t,[...n,e.id])))})}element(e,t,n){let r=e.id??``,i=Yt(e.$type);if(e.$type===`bpmn:ScriptTask`){let a=Ne(e.scriptFormat);a&&this.add(r,`TASK_BODY`,0,{processId:t,containers:n,type:i,language:a,value:typeof e.script==`string`?e.script:``})}let a={};(e.extensionElements?.values??[]).forEach(e=>{let o=qt[e.$type];if(!o)return;let s=a[o]??0;a[o]=s+1;let c=$t(e.script);c&&this.add(r,o,s,{processId:t,containers:n,type:i,...c,event:e.event})});let o=e.extensionElements?.values?.find(e=>e.$type===`camunda:InputOutput`);[...(o?.inputParameters??[]).map(e=>[e,`input`]),...(o?.outputParameters??[]).map(e=>[e,`output`])].forEach(([e,a],o)=>{let s=$t(e.definition);s&&this.add(r,`PARAMETER`,o,{processId:t,containers:n,type:i,...s,parameter:{name:e.name??``,direction:a}})});let s=e.extensionElements?.values?.find(e=>e.$type===`zeebe:IoMapping`),c={processId:t,containers:n,type:i};(s?.inputParameters??[]).forEach((e,t)=>this.mapping(r,`INPUT_MAPPING`,t,e,`input`,c)),(s?.outputParameters??[]).forEach((e,t)=>this.mapping(r,`OUTPUT_MAPPING`,t,e,`output`,c))}mapping(e,t,n,r,i,a){let o=Zt(r,`source`);o?.startsWith(`=`)&&this.add(e,t,n,{...a,language:`feel`,value:Qt(o),parameter:{name:Zt(r,`target`)??``,direction:i}})}flow(e,t,n){let r=e.id??``,i=e.conditionExpression;if(!i)return;let a={source:e.sourceRef?.id??``,target:e.targetRef?.id??``},o={processId:t,containers:n,type:Yt(e.$type)},s=Zt(i,`language`);if(s===void 0&&i.body?.startsWith(`=`)){this.add(r,`FEEL_CONDITION`,0,{...o,language:`feel`,value:Qt(i.body)},a);return}let c=Ne(s);c&&this.add(r,`CONDITION`,0,{...o,language:c,value:i.body??``},a)}add(e,t,n,r,i=null){this.drafts.push({site:{slot:{elementId:e,owner:t,index:n},...r},ends:i,seq:this.seq+=1})}};function tn(e,t){return e.get(t)??Jt}function nn(e,t){let n=e.site.containers.map(e=>[tn(t,e),0]);return e.ends?[...n,[tn(t,e.ends.source),1]]:[...n,[tn(t,e.site.slot.elementId),0]]}function rn(e,t){for(let n=0;n<Math.min(e.length,t.length);n+=1){let[r,i]=e[n],[a,o]=t[n];if(r!==a)return r<a?-1:1;if(i!==o)return i<o?-1:1}return e.length-t.length}function an(e){let t=/* @__PURE__ */ new Map;return e.forEach(e=>{e&&t.set(e,(t.get(e)??0)+1)}),t}function on(e,t,n){let r=e.site.slot.elementId,i=e=>t.get(e)||e,a=t.get(r)??``,o=e.ends?a||`${i(e.ends.source)} -> ${i(e.ends.target)}`:i(r),s=a!==``&&(n.get(a)??0)>1;return{...e.site,name:o,shared:s}}function sn(e){return(e?.rootElements??[]).filter(e=>e.$type===`bpmn:Process`)}function cn(e){let t=new Map(Ut(zt(e)).map((e,t)=>[e,t])),n=new en;sn(e).forEach(e=>n.process(e));let r=an(n.names);return n.drafts.map(e=>({draft:e,path:nn(e,t)})).sort((e,t)=>rn(e.path,t.path)||e.draft.seq-t.draft.seq).map(({draft:e})=>on(e,n.names,r))}const ln=/* @__PURE__ */ new Set([`startEvent`,`intermediateCatchEvent`,`boundaryEvent`,`receiveTask`]),un=/^=|\$\{|#\{/,dn={"zeebe:ExecutionListeners":`execution`,"zeebe:TaskListeners":`task`};function fn(e){let t=/^[$#]\{\s*([A-Za-z_][A-Za-z0-9_]*)/.exec(e.trim());return t?t[1]:null}function pn(){return{processes:[],elements:[],workers:[],calls:[],messages:[],messageUses:[],decisions:[],decisionUses:[],formKeys:[],formUses:[],variables:[],variableForms:[],dynamic:[],embeddedForms:[],errors:[],scripts:[]}}function mn(e){let t=e.split(`:`).pop()??e;return t.charAt(0).toLowerCase()+t.slice(1)}function hn(e,t){return typeof t==`string`&&t.trim()?t:e}function gn(e,t){let n=e?.get?.(t)??e?.$attrs?.[t];return typeof n==`string`&&n.trim()?n:void 0}function _n(e){return e?.extensionElements?.values??[]}function vn(e,t,n){if(!t?.id)return;let r=mn(t.$type),i=t.id;e.elements.push({id:i,name:t.name,type:r,processId:n,label:hn(i,t.name)});let a=(t,n)=>{t&&(un.test(t)?e.dynamic.push(t):n(t))};a(gn(t,`camunda:topic`),t=>e.workers.push({kind:`TOPIC`,value:t,elementId:i})),a(gn(t,`camunda:class`),t=>e.workers.push({kind:`JAVA_CLASS`,value:t,elementId:i}));let o=fn(gn(t,`camunda:delegateExpression`)??``);o&&e.workers.push({kind:`BEAN`,value:o,elementId:i}),a(gn(t,`camunda:decisionRef`),t=>e.decisionUses.push({decisionId:t,elementId:i})),a(gn(t,`camunda:formRef`),t=>e.formUses.push({formId:t,linked:!0,elementId:i})),a(gn(t,`camunda:formKey`),t=>e.formUses.push({formId:t,linked:!1,elementId:i})),a(typeof t.calledElement==`string`?t.calledElement:void 0,t=>e.calls.push({calledProcessId:t,elementId:i})),_n(t).forEach(t=>{switch(t.$type){case`zeebe:TaskDefinition`:a(t.type,t=>e.workers.push({kind:`JOB_TYPE`,value:t,elementId:i}));break;case`zeebe:CalledElement`:a(t.processId,t=>e.calls.push({calledProcessId:t,elementId:i}));break;case`zeebe:CalledDecision`:a(t.decisionId,t=>e.decisionUses.push({decisionId:t,elementId:i}));break;case`zeebe:FormDefinition`:a(t.formId,t=>e.formUses.push({formId:t,linked:!0,elementId:i})),a(t.formKey,t=>e.formUses.push(t.startsWith(`camunda-forms:bpmn:`)?{formId:t.slice(19),linked:!1,embedded:!0,elementId:i}:{formId:t,linked:!1,elementId:i}));break;case`zeebe:ExecutionListeners`:case`zeebe:TaskListeners`:(t.listeners??[]).forEach(n=>a(n.type,n=>{e.workers.push({kind:`JOB_TYPE`,value:n,elementId:i,listener:dn[t.$type]})}))}}),(t.eventDefinitions??[]).filter(e=>e.$type===`bpmn:ErrorEventDefinition`).forEach(t=>{let n=typeof t.errorRef?.errorCode==`string`&&t.errorRef.errorCode.trim()?t.errorRef.errorCode:null;n&&un.test(n)?e.dynamic.push(n):e.errors.push({code:n,catches:ln.has(r),elementId:i})}),[t.messageRef,...(t.eventDefinitions??[]).map(e=>e.messageRef)].filter(e=>e?.id).forEach(t=>{e.messageUses.push({messageId:t.id,catches:ln.has(r),elementId:i})}),(t.flowElements??[]).forEach(t=>vn(e,t,n))}async function yn(e){let t=pn(),n=await r(e);if(!n)return t;let i=/* @__PURE__ */ new Map;(n.rootElements??[]).filter(e=>e.$type===`bpmn:Collaboration`).forEach(e=>{(e.participants??[]).forEach(e=>{e.processRef?.id&&e.name&&i.set(e.processRef.id,e.name)})}),(n.rootElements??[]).forEach(e=>{if(e.$type===`bpmn:Message`&&t.messages.push({id:e.id,name:e.name,label:hn(e.id,e.name)}),e.$type!==`bpmn:Process`)return;let n=e.name?.trim()?e.name:i.get(e.id);t.processes.push({id:e.id,name:n,executable:e.isExecutable===!0,label:hn(e.id,n)}),_n(e).filter(e=>e.$type===`zeebe:UserTaskForm`&&e.id).forEach(e=>t.embeddedForms.push(e.id)),(e.flowElements??[]).forEach(n=>vn(t,n,e.id))});let{uses:a,forms:o}=ft(n);return t.variables=a,t.variableForms=o,t.scripts=cn(n),t}function bn(e){return e.decisionLogic?.$type===`dmn:DecisionTable`?(e.decisionLogic.output??[]).map(e=>typeof e.name==`string`?e.name.trim():``).filter(e=>e!==``):[]}async function xn(e){let t=pn();try{let{rootElement:n}=await Mt(e);(n?.drgElement??[]).filter(e=>e.$type===`dmn:Decision`).forEach(e=>{t.decisions.push({id:e.id,name:e.name,type:`decision`,label:hn(e.id,e.name),outputs:bn(e)})})}catch{return t}return t}function Sn(e){let t=pn();try{let n=JSON.parse(e);t.formId=ht(n),t.formKeys=mt(n)}catch{return t}return t}function Cn(e){let t=e.toLowerCase();return t.endsWith(`.bpmn`)||t.endsWith(`.bpmn.xml`)?`bpmn`:t.endsWith(`.dmn`)?`dmn`:t.endsWith(`.form`)?`form`:null}const wn={bpmn:`BPMN XML`,dmn:`DMN`,form:`JSON`};function Tn(e){return wn[Cn(e)??`bpmn`]}async function En(e,t){switch(Cn(e)){case`bpmn`:return yn(t);case`dmn`:return xn(t);case`form`:return Sn(t);default:return pn()}}const Dn=/[\\/]/,On=/[\\/]+$/,kn=/\.(bpmn\.xml|bpmn|dmn|form)$/i;function M(e){return e.split(Dn).pop()??e}function An(e){return M(e).replace(kn,``)}function jn(e,t){let n=e.replace(On,``);return n!==``&&t.slice(0,n.length)!==n||!Dn.test(t[n.length]??``)?t:t.slice(n.length+1).replace(/\\/g,`/`)}function Mn(e){switch(e){case`JOB_TYPE`:return`JOB_TYPE`;case`TOPIC`:return`TOPIC`;case`JAVA_CLASS`:return`CLASS`;case`BEAN`:return`BEAN`}}function Nn(e){let n=/* @__PURE__ */ new Map;return e.forEach(({model:e})=>{e.formId&&n.set(e.formId,e.formKeys)}),e.flatMap(({path:e,model:r})=>{let i=new Map(r.elements.map(e=>[e.id,e])),a=e=>i.get(e),o=(t,n,r,i={})=>({kind:t,value:n,path:e,label:a(r)?.label??r,elementId:r,elementType:a(r)?.type,...i});return[...r.processes.map(t=>({kind:`PROCESS`,value:t.id,path:e,label:t.label,elementId:t.id,elementType:`process`})),...r.elements.map(e=>o(`ELEMENT`,e.id,e.id)),...r.workers.map(e=>o(Mn(e.kind),e.value,e.elementId)),...r.messages.filter(e=>e.name).map(t=>({kind:`MESSAGE`,value:t.name,path:e,label:t.name,elementType:`message`})),...r.decisions.map(t=>({kind:`DECISION`,value:t.id,path:e,label:t.label,elementId:t.id,elementType:`decision`})),...r.formId?[{kind:`FORM`,value:r.formId,path:e,label:An(e),elementType:`form`}]:[],...r.variables.map(e=>o(`VARIABLE`,e.name,e.elementId,{writes:e.writes,where:e.where})),...r.errors.filter(e=>e.catches).map(e=>o(`ERROR`,e.code??``,e.elementId)),...r.variableForms.flatMap(e=>(n.get(e.formId)??[]).map(n=>o(`VARIABLE`,n,e.elementId,{writes:!0,where:t(`app.targets.onForm`,{form:e.formId})})))]})}const Pn=/* @__PURE__ */ new Set([`task`,`subProcess`,`callActivity`,`transaction`,`adHocSubProcess`]);function Fn(e=[],t=[]){return{elements:new Set(e),flows:new Set(t)}}function In(e,t){return Fn([...e.elements,...t.elements],[...e.flows,...t.flows])}function Ln(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim()!==``):[]}function Rn(e){return Array.isArray(e)?e:[]}function zn(e,t,n,r){if(typeof t!=`string`||!t)return;let i=e.get(t)??{processId:t,all:Fn(),tests:/* @__PURE__ */ new Map};i.all=In(i.all,r),n&&i.tests.set(n,In(i.tests.get(n)??Fn(),r)),e.set(t,i)}function Bn(e){return Fn(Ln(e?.completedElements),Ln(e?.takenSequenceFlows))}function Vn(e){let t=/* @__PURE__ */ new Map;return Rn(e).forEach(e=>{let n=typeof e?.modelKey==`string`?e.modelKey:``,r=t.get(n)??Fn();e?.source===`FLOW_NODE`&&e?.type===`END`&&e.definitionKey&&r.elements.add(e.definitionKey),e?.source===`SEQUENCE_FLOW`&&e.definitionKey&&r.flows.add(e.definitionKey),t.set(n,r)}),t}function Hn(e){let t=/* @__PURE__ */ new Map,n;try{n=JSON.parse(e)}catch{return t}return Rn(n?.suites).forEach(e=>{let n=String(e?.name??``).split(`.`).pop()??``;Rn(e?.runs).forEach(e=>{let r=[n,String(e?.name??``)].filter(e=>e).join(`.`);Rn(e?.processCoverages).forEach(e=>zn(t,e?.processDefinitionId,r,Bn(e))),Vn(e?.events).forEach((e,n)=>zn(t,n,r,e))})}),Rn(n?.processCoverages).forEach(e=>zn(t,e?.processDefinitionId,null,Bn(e))),t}function Un(e){let t=/* @__PURE__ */ new Map;return e.forEach(e=>e.forEach(e=>{zn(t,e.processId,null,e.all),e.tests.forEach((n,r)=>zn(t,e.processId,r,n))})),t}function Wn(e){return e.endsWith(`Task`)||e.endsWith(`Event`)||e.endsWith(`Gateway`)||Pn.has(e)}function Gn(e,t){let n=t.filter(e=>Wn(e.type)),r=t.filter(e=>e.type===`sequenceFlow`),i=n.length+r.length;return i===0?null:(n.filter(t=>e.elements.has(t.id)).length+r.filter(t=>e.flows.has(t.id)).length)/i}function Kn(e,t){return{reach:Un(t.map(e=>Hn(e.text))),reports:t.map(t=>jn(e,t.path)),updatedAt:t.length>0?Math.max(...t.map(e=>e.stamp)):null}}function qn(e,t,n){if(Math.abs(e.length-t.length)>n)return n+1;let r=n+1,i=t.length+1,a=Array(i).fill(r),o=Array(i).fill(r);for(let e=0;e<=Math.min(n,t.length);e+=1)a[e]=e;for(let s=0;s<e.length;s+=1){let c=Math.max(0,s-n),l=Math.min(t.length-1,s+n);c>0&&(o[c]=r),o[0]=s+1<=n?s+1:r;let u=c===0?o[0]:r;for(let n=c;n<=l;n+=1){let i=Math.min(a[n+1]+1,o[n]+1,a[n]+(e[s]===t[n]?0:1),r);o[n+1]=i,i<u&&(u=i)}if(l+2<i&&(o[l+2]=r),u>n)return r;[a,o]=[o,a]}return Math.min(a[t.length],r)}function Jn(e,t){let n=new Set(t),r=e.toLowerCase(),i=[...n].find(t=>t!==e&&t.toLowerCase()===r);if(i)return i;if(e.length<4)return null;let a=null,o=1/0;return n.forEach(t=>{let n=qn(t.toLowerCase(),e.toLowerCase(),2);n>=1&&n<=2&&n<o&&(a=t,o=n)}),a}const Yn=/* @__PURE__ */ new Set([`JOB_TYPE`,`TOPIC`,`CLASS`,`BEAN`]),Xn=/^[\w.-]+:[\w.-]+:\d+$/;function Zn(e){return`${e.kind}:${e.value}`}function Qn(e){return[...new Map(e.map(e=>[Zn(e),e])).values()]}function $n(e){return e.kind===`JOB_TYPE`&&Xn.test(e.value)}function er(e){return Yn.has(e.kind)&&!$n(e)}function tr(e,t){let n=/* @__PURE__ */ new Map,r=e=>n.set(Zn(e),e);return e.forEach(({model:e})=>{e.workers.forEach(e=>r({kind:Mn(e.kind),value:e.value})),e.processes.forEach(e=>r({kind:`PROCESS`,value:e.id})),e.errors.forEach(e=>{e.code&&r({kind:`ERROR`,value:e.code})})}),t.filter(e=>e.kind===`VARIABLE`).forEach(e=>r({kind:`VARIABLE`,value:e.value})),[...n.values()]}function nr(e,t){let n=/* @__PURE__ */ new Map,r=e=>n.set(Zn(e),e);return e.processes.some(e=>e.id===t)&&r({kind:`PROCESS`,value:t}),e.elements.some(e=>e.id===t)&&r({kind:`ELEMENT`,value:t}),e.workers.filter(e=>e.elementId===t).forEach(e=>r({kind:Mn(e.kind),value:e.value})),e.messageUses.filter(e=>e.elementId===t).forEach(t=>{let n=e.messages.find(e=>e.id===t.messageId)?.name;n&&r({kind:`MESSAGE`,value:n})}),e.decisionUses.filter(e=>e.elementId===t).forEach(e=>r({kind:`DECISION`,value:e.decisionId})),e.errors.filter(e=>e.elementId===t&&e.code).forEach(e=>r({kind:`ERROR`,value:e.code??``})),e.decisions.some(e=>e.id===t)&&r({kind:`DECISION`,value:t}),[...n.values()]}const rr=[`8.5`,`8.6`,`8.7`,`8.8`,`8.9`],ir=_[`camunda-7`].platform,ar=`Camunda Cloud`;function N(e,t){let[n,r]=t.split(`.`).map(Number),[i,a]=e.split(`.`).map(Number);return i>n||i===n&&a>=r}const or={ASSERT_DECISION:{required:[`decisionSelector`],allowed:[`decisionSelector`,`output`,`matchedRules`,`notMatchedRules`,`noMatchedRules`]},ASSERT_ELEMENT_INSTANCE:{required:[`processInstanceSelector`,`elementSelector`,`state`],allowed:[`processInstanceSelector`,`elementSelector`,`state`,`amount`]},ASSERT_ELEMENT_INSTANCES:{required:[`processInstanceSelector`,`elementSelectors`,`state`],allowed:[`processInstanceSelector`,`elementSelectors`,`state`]},ASSERT_PROCESS_INSTANCE:{required:[`processInstanceSelector`],allowed:[`processInstanceSelector`,`state`,`hasActiveIncidents`]},ASSERT_PROCESS_INSTANCE_MESSAGE_SUBSCRIPTION:{required:[`processInstanceSelector`,`messageSelector`,`state`],allowed:[`processInstanceSelector`,`messageSelector`,`state`]},ASSERT_USER_TASK:{required:[`userTaskSelector`],allowed:[`userTaskSelector`,`state`,`assignee`,`candidateGroups`,`priority`,`elementId`,`name`,`dueDate`,`followUpDate`]},ASSERT_VARIABLES:{required:[`processInstanceSelector`],allowed:[`processInstanceSelector`,`elementSelector`,`variableNames`,`variables`]},BROADCAST_SIGNAL:{required:[`signalName`],allowed:[`signalName`,`variables`]},COMPLETE_JOB:{required:[`jobSelector`],allowed:[`jobSelector`,`variables`,`useExampleData`]},COMPLETE_JOB_AD_HOC_SUB_PROCESS:{required:[`jobSelector`],allowed:[`jobSelector`,`variables`,`activateElements`,`cancelRemainingInstances`,`completionConditionFulfilled`]},COMPLETE_JOB_USER_TASK_LISTENER:{required:[`jobSelector`],allowed:[`jobSelector`,`denied`,`deniedReason`,`corrections`]},COMPLETE_USER_TASK:{required:[`userTaskSelector`],allowed:[`userTaskSelector`,`variables`,`useExampleData`]},CORRELATE_MESSAGE:{required:[`name`],allowed:[`name`,`correlationKey`,`variables`]},CREATE_PROCESS_INSTANCE:{required:[`processDefinitionSelector`],allowed:[`processDefinitionSelector`,`variables`,`startInstructions`,`runtimeInstructions`]},EVALUATE_CONDITIONAL_START_EVENT:{required:[`variables`],allowed:[`variables`]},EVALUATE_DECISION:{required:[`decisionDefinitionSelector`],allowed:[`decisionDefinitionSelector`,`variables`]},INCREASE_TIME:{required:[`duration`],allowed:[`duration`]},MOCK_CHILD_PROCESS:{required:[`processDefinitionId`],allowed:[`processDefinitionId`,`variables`]},MOCK_DMN_DECISION:{required:[`decisionDefinitionId`],allowed:[`decisionDefinitionId`,`variables`]},MOCK_JOB_WORKER_COMPLETE_JOB:{required:[`jobType`],allowed:[`jobType`,`variables`,`useExampleData`]},MOCK_JOB_WORKER_THROW_BPMN_ERROR:{required:[`jobType`,`errorCode`],allowed:[`jobType`,`errorCode`,`errorMessage`,`variables`]},PUBLISH_MESSAGE:{required:[`name`],allowed:[`name`,`correlationKey`,`variables`,`timeToLive`,`messageId`]},RESOLVE_INCIDENT:{required:[`incidentSelector`],allowed:[`incidentSelector`]},SET_TIME:{required:[`time`],allowed:[`time`]},THROW_BPMN_ERROR_FROM_JOB:{required:[`jobSelector`,`errorCode`],allowed:[`jobSelector`,`errorCode`,`errorMessage`,`variables`]},UPDATE_VARIABLES:{required:[`processInstanceSelector`,`variables`],allowed:[`processInstanceSelector`,`variables`,`elementSelector`]}},sr=/* @__PURE__ */ new Set([`CREATE_PROCESS_INSTANCE`,`MOCK_JOB_WORKER_COMPLETE_JOB`,`MOCK_JOB_WORKER_THROW_BPMN_ERROR`,`COMPLETE_JOB`,`THROW_BPMN_ERROR_FROM_JOB`,`COMPLETE_USER_TASK`,`CORRELATE_MESSAGE`,`PUBLISH_MESSAGE`,`BROADCAST_SIGNAL`,`UPDATE_VARIABLES`,`ASSERT_PROCESS_INSTANCE`,`ASSERT_ELEMENT_INSTANCE`,`ASSERT_ELEMENT_INSTANCES`,`ASSERT_VARIABLES`,`ASSERT_USER_TASK`]),cr=/* @__PURE__ */ new Set([`MOCK_CHILD_PROCESS`,`MOCK_DMN_DECISION`,`ASSERT_DECISION`,`ASSERT_PROCESS_INSTANCE_MESSAGE_SUBSCRIPTION`,`COMPLETE_JOB_AD_HOC_SUB_PROCESS`,`COMPLETE_JOB_USER_TASK_LISTENER`,`EVALUATE_CONDITIONAL_START_EVENT`,`EVALUATE_DECISION`,`RESOLVE_INCIDENT`,`SET_TIME`,`INCREASE_TIME`,`ASSERT_VARIABLE`,`CONDITIONAL_BEHAVIOR`]),lr=/* @__PURE__ */ new Set([...sr,...cr]);function P(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ur(e){let n;try{n=JSON.parse(e)}catch(e){return{file:null,problems:[t(`app.testCases.problem.notJson`,{reason:e instanceof Error?e.message:String(e)})],notJson:!0}}if(!P(n)||!Array.isArray(n.testCases))return{file:null,problems:[t(`app.testCases.problem.noTestCasesList`)]};let r=[];return n.testCases.forEach((e,n)=>{P(e)&&typeof e.name==`string`&&e.name.trim()!==``?!Array.isArray(e.instructions)||e.instructions.length===0?r.push(t(`app.testCases.problem.caseHasNoInstructions`,{name:e.name})):r.push(...hr(e).map(n=>t(`app.testCases.problem.inCase`,{name:e.name,problem:n}))):r.push(t(`app.testCases.problem.caseHasNoName`,{number:n+1}))}),{file:n,problems:r}}const F=e=>typeof e==`string`&&e.trim()!==``,dr={CREATE_PROCESS_INSTANCE:[[`processDefinitionSelector.processDefinitionId`,e=>P(e.processDefinitionSelector)&&F(e.processDefinitionSelector.processDefinitionId)]],MOCK_JOB_WORKER_COMPLETE_JOB:[[`jobType`,e=>F(e.jobType)]],MOCK_JOB_WORKER_THROW_BPMN_ERROR:[[`jobType`,e=>F(e.jobType)],[`errorCode`,e=>F(e.errorCode)]],MOCK_CHILD_PROCESS:[[`processDefinitionId`,e=>F(e.processDefinitionId)]],MOCK_DMN_DECISION:[[`decisionDefinitionId`,e=>F(e.decisionDefinitionId)]],COMPLETE_JOB:[[`jobSelector`,e=>P(e.jobSelector)]],THROW_BPMN_ERROR_FROM_JOB:[[`jobSelector`,e=>P(e.jobSelector)],[`errorCode`,e=>F(e.errorCode)]],COMPLETE_USER_TASK:[[`userTaskSelector`,e=>P(e.userTaskSelector)]],CORRELATE_MESSAGE:[[`name`,e=>F(e.name)]],PUBLISH_MESSAGE:[[`name`,e=>F(e.name)]],BROADCAST_SIGNAL:[[`signalName`,e=>F(e.signalName)]],UPDATE_VARIABLES:[[`variables`,e=>P(e.variables)]],INCREASE_TIME:[[`duration`,e=>F(e.duration)]],ASSERT_ELEMENT_INSTANCES:[[`elementSelectors`,e=>Array.isArray(e.elementSelectors)&&e.elementSelectors.every(P)],[`state`,e=>F(e.state)]],ASSERT_ELEMENT_INSTANCE:[[`elementSelector`,e=>P(e.elementSelector)],[`state`,e=>F(e.state)]],ASSERT_USER_TASK:[[`userTaskSelector`,e=>P(e.userTaskSelector)]]},fr=new Set(p.filter(e=>e!==`classic`)),pr=/* @__PURE__ */ new Set([`complete`,`error`,`fire`,`hold`]);function mr(e){if(!P(e))return[t(`app.testCases.problem.notAnObject`)];let n=typeof e.name==`string`&&e.name.trim()!==``?[]:[t(`app.testCases.problem.hasNoName`)];return!Array.isArray(e.instructions)||e.instructions.length===0?[...n,t(`app.testCases.problem.hasNoInstructions`)]:[...n,...hr(e)]}function hr(e){let n=[];e.instructions.forEach((e,r)=>{if(!P(e)||!F(e.type)){n.push(t(`app.testCases.problem.shapelessInstruction`,{number:r+1}));return}let i=e.type,a=(Object.hasOwn(dr,i)?dr[i]:[]).find(([,t])=>!t(e));if(a){n.push(t(`app.testCases.problem.instructionNeeds`,{number:r+1,type:i,property:a[0]}));return}let o=Object.hasOwn(or,i)?or[i]:void 0;if(!o)return;let s=o.required.find(t=>e[t]===void 0);if(s){n.push(t(`app.testCases.problem.instructionNeeds`,{number:r+1,type:i,property:s}));return}let c=Object.keys(e).find(e=>e!==`type`&&!o.allowed.includes(e));c&&n.push(t(`app.testCases.problem.instructionNotAllowed`,{number:r+1,type:i,property:c}))});let r=e[`x-penstock`];return r===void 0?n:P(r)?(r.engines!==void 0&&!(Array.isArray(r.engines)&&r.engines.every(e=>fr.has(e)))&&n.push(t(`app.testCases.problem.enginesList`,{engines:[...fr].join(`, `)})),r.behaviours!==void 0&&!P(r.behaviours)?n.push(t(`app.testCases.problem.behavioursNotAnObject`)):Object.entries(r.behaviours??{}).forEach(([e,r])=>{!P(r)||!pr.has(r.then)?n.push(t(`app.testCases.problem.behaviourNeedsThen`,{element:e})):r.then===`error`&&!F(r.errorCode)&&n.push(t(`app.testCases.problem.behaviourNeedsErrorCode`,{element:e}))}),n):[...n,t(`app.testCases.problem.blockNotAnObject`)]}function gr(e){let{$schema:t,...n}=e;return`${JSON.stringify({$schema:t??`https://camunda.com/json-schema/cpt-test-cases/8.9/schema.json`,...n},null,2)}\n`}function _r(e,t){let n=e??{$schema:`https://camunda.com/json-schema/cpt-test-cases/8.9/schema.json`,testCases:[]},r=n.testCases.findIndex(e=>e?.name===t.name),i=r<0?[...n.testCases,t]:n.testCases.map((e,n)=>n===r?t:e);return{...n,$schema:n.$schema??`https://camunda.com/json-schema/cpt-test-cases/8.9/schema.json`,testCases:i}}function vr(e,n){let r=null;if(e!==null&&e.trim()!==``){let n=ur(e);if(!n.file)return{problem:n.notJson?t(`app.testCases.problem.fileNotValidJson`):t(`app.testCases.problem.fileLeftAsItIs`,{problems:n.problems.join(`; `)})};r=n.file}let i=new Set((r?.testCases??[]).map(e=>e?.name)),a=[],o=[],s=r;for(let e of n)i.has(e.name)?o.push(e.name):(i.add(e.name),a.push(e.name),s=_r(s,e));return{file:s??{$schema:`https://camunda.com/json-schema/cpt-test-cases/8.9/schema.json`,testCases:[]},added:a,kept:o}}function yr(e){return Object.keys(e[`x-penstock`]?.behaviours??{}).length>0}const br=/\.(bpmn20\.xml|bpmn\.xml|bpmn)$/i;function xr(e,t){let n=e.replace(/\\/g,`/`),r=`${(n.split(`/`).pop()??n).replace(br,``)}.json`,i=n.indexOf(`/src/main/resources/`);if(i>=0)return`${n.slice(0,i)}/src/test/resources/test-cases/${r}`;let a=n.lastIndexOf(`/`),o=a>=0?n.slice(0,a):null,s=e=>o===null?e:`${o}/${e}`;if(!t)return s(`test-cases/${r}`);let c=t.replace(/\\/g,`/`).replace(/\/+$/,``);return`${c.startsWith(`/`)||/^[A-Za-z]:\//.test(c)?c:s(c)}/${r}`}const Sr=`https://raw.githubusercontent.com/kern0x1b/penstock-release/main/docs/schema/penstock.schema.json`;function Cr(e){return e===`camunda-8`?{name:ar,version:`8.9.0`,namespaces:`xmlns:zeebe="http://camunda.org/schema/zeebe/1.0"`}:{name:_[e].platform,version:g[e].version,namespaces:`xmlns:${d(e)}="${_[e].bpmn}"`}}const wr={approve:{attributes:``,extension:`
|
|
9
|
+
<bpmn:extensionElements>
|
|
10
|
+
<zeebe:userTask />
|
|
11
|
+
<zeebe:formDefinition formId="approve-order" />
|
|
12
|
+
</bpmn:extensionElements>`},charge:{attributes:``,extension:`
|
|
13
|
+
<bpmn:extensionElements>
|
|
14
|
+
<zeebe:taskDefinition type="charge-card" />
|
|
15
|
+
</bpmn:extensionElements>`},decide:{attributes:``,extension:`
|
|
16
|
+
<bpmn:extensionElements>
|
|
17
|
+
<zeebe:calledDecision decisionId="shipping-method" resultVariable="shipping" />
|
|
18
|
+
</bpmn:extensionElements>`},receipt:{attributes:``,extension:`
|
|
19
|
+
<bpmn:extensionElements>
|
|
20
|
+
<zeebe:taskDefinition type="send-receipt" />
|
|
21
|
+
</bpmn:extensionElements>`},message:`<bpmn:message id="Message_shipment" name="shipment-confirmed">
|
|
22
|
+
<bpmn:extensionElements>
|
|
23
|
+
<zeebe:subscription correlationKey="=orderId" />
|
|
24
|
+
</bpmn:extensionElements>
|
|
25
|
+
</bpmn:message>`,process:``};function Tr(e){if(e===`camunda-8`)return wr;let t=d(e);return{approve:{attributes:` ${t}:formRef="approve-order" ${t}:formRefBinding="latest"`,extension:``},charge:{attributes:` ${t}:type="external" ${t}:topic="charge-card"`,extension:``},decide:{attributes:` ${t}:decisionRef="shipping-method" ${t}:decisionRefBinding="latest" ${t}:resultVariable="shipping" ${t}:mapDecisionResult="singleEntry"`,extension:``},receipt:{attributes:` ${t}:delegateExpression="\${sendReceipt}"`,extension:``},message:`<bpmn:message id="Message_shipment" name="shipment-confirmed" />`,process:` ${t}:historyTimeToLive="P30D"`}}function Er(e){let t=Cr(e),n=Tr(e);return`<?xml version="1.0" encoding="UTF-8"?>
|
|
26
|
+
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" ${t.namespaces} xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_order" targetNamespace="http://bpmn.io/schema/bpmn" modeler:executionPlatform="${t.name}" modeler:executionPlatformVersion="${t.version}">
|
|
27
|
+
<bpmn:process id="order-process" name="Order" isExecutable="true"${n.process}>
|
|
28
|
+
<bpmn:startEvent id="order_received" name="Order received">
|
|
29
|
+
<bpmn:outgoing>Flow_1</bpmn:outgoing>
|
|
30
|
+
</bpmn:startEvent>
|
|
31
|
+
<bpmn:userTask id="approve_order" name="Approve order"${n.approve.attributes}>${n.approve.extension}
|
|
32
|
+
<bpmn:incoming>Flow_1</bpmn:incoming>
|
|
33
|
+
<bpmn:outgoing>Flow_2</bpmn:outgoing>
|
|
34
|
+
</bpmn:userTask>
|
|
35
|
+
<bpmn:serviceTask id="charge_card" name="Charge card"${n.charge.attributes}>${n.charge.extension}
|
|
36
|
+
<bpmn:incoming>Flow_2</bpmn:incoming>
|
|
37
|
+
<bpmn:outgoing>Flow_3</bpmn:outgoing>
|
|
38
|
+
</bpmn:serviceTask>
|
|
39
|
+
<bpmn:boundaryEvent id="card_declined" name="Card declined" attachedToRef="charge_card">
|
|
40
|
+
<bpmn:outgoing>Flow_7</bpmn:outgoing>
|
|
41
|
+
<bpmn:errorEventDefinition id="ErrorEventDefinition_declined" errorRef="Error_declined" />
|
|
42
|
+
</bpmn:boundaryEvent>
|
|
43
|
+
<bpmn:businessRuleTask id="decide_shipping" name="Decide shipping method"${n.decide.attributes}>${n.decide.extension}
|
|
44
|
+
<bpmn:incoming>Flow_3</bpmn:incoming>
|
|
45
|
+
<bpmn:outgoing>Flow_4</bpmn:outgoing>
|
|
46
|
+
</bpmn:businessRuleTask>
|
|
47
|
+
<bpmn:intermediateCatchEvent id="shipment_confirmed" name="Shipment confirmed">
|
|
48
|
+
<bpmn:incoming>Flow_4</bpmn:incoming>
|
|
49
|
+
<bpmn:outgoing>Flow_5</bpmn:outgoing>
|
|
50
|
+
<bpmn:messageEventDefinition id="MessageEventDefinition_shipment" messageRef="Message_shipment" />
|
|
51
|
+
</bpmn:intermediateCatchEvent>
|
|
52
|
+
<bpmn:serviceTask id="send_receipt" name="Send receipt"${n.receipt.attributes}>${n.receipt.extension}
|
|
53
|
+
<bpmn:incoming>Flow_5</bpmn:incoming>
|
|
54
|
+
<bpmn:outgoing>Flow_6</bpmn:outgoing>
|
|
55
|
+
</bpmn:serviceTask>
|
|
56
|
+
<bpmn:endEvent id="order_completed" name="Order completed">
|
|
57
|
+
<bpmn:incoming>Flow_6</bpmn:incoming>
|
|
58
|
+
</bpmn:endEvent>
|
|
59
|
+
<bpmn:endEvent id="payment_declined" name="Payment declined">
|
|
60
|
+
<bpmn:incoming>Flow_7</bpmn:incoming>
|
|
61
|
+
</bpmn:endEvent>
|
|
62
|
+
<bpmn:sequenceFlow id="Flow_1" sourceRef="order_received" targetRef="approve_order" />
|
|
63
|
+
<bpmn:sequenceFlow id="Flow_2" sourceRef="approve_order" targetRef="charge_card" />
|
|
64
|
+
<bpmn:sequenceFlow id="Flow_3" sourceRef="charge_card" targetRef="decide_shipping" />
|
|
65
|
+
<bpmn:sequenceFlow id="Flow_4" sourceRef="decide_shipping" targetRef="shipment_confirmed" />
|
|
66
|
+
<bpmn:sequenceFlow id="Flow_5" sourceRef="shipment_confirmed" targetRef="send_receipt" />
|
|
67
|
+
<bpmn:sequenceFlow id="Flow_6" sourceRef="send_receipt" targetRef="order_completed" />
|
|
68
|
+
<bpmn:sequenceFlow id="Flow_7" sourceRef="card_declined" targetRef="payment_declined" />
|
|
69
|
+
</bpmn:process>
|
|
70
|
+
<bpmn:error id="Error_declined" name="Card declined" errorCode="CARD_DECLINED" />
|
|
71
|
+
${n.message}
|
|
72
|
+
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
|
73
|
+
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="order-process">
|
|
74
|
+
<bpmndi:BPMNShape id="order_received_di" bpmnElement="order_received">
|
|
75
|
+
<dc:Bounds x="152" y="102" width="36" height="36" />
|
|
76
|
+
<bpmndi:BPMNLabel>
|
|
77
|
+
<dc:Bounds x="132" y="145" width="76" height="27" />
|
|
78
|
+
</bpmndi:BPMNLabel>
|
|
79
|
+
</bpmndi:BPMNShape>
|
|
80
|
+
<bpmndi:BPMNShape id="approve_order_di" bpmnElement="approve_order">
|
|
81
|
+
<dc:Bounds x="240" y="80" width="100" height="80" />
|
|
82
|
+
</bpmndi:BPMNShape>
|
|
83
|
+
<bpmndi:BPMNShape id="charge_card_di" bpmnElement="charge_card">
|
|
84
|
+
<dc:Bounds x="400" y="80" width="100" height="80" />
|
|
85
|
+
</bpmndi:BPMNShape>
|
|
86
|
+
<bpmndi:BPMNShape id="decide_shipping_di" bpmnElement="decide_shipping">
|
|
87
|
+
<dc:Bounds x="560" y="80" width="100" height="80" />
|
|
88
|
+
</bpmndi:BPMNShape>
|
|
89
|
+
<bpmndi:BPMNShape id="shipment_confirmed_di" bpmnElement="shipment_confirmed">
|
|
90
|
+
<dc:Bounds x="712" y="102" width="36" height="36" />
|
|
91
|
+
<bpmndi:BPMNLabel>
|
|
92
|
+
<dc:Bounds x="691" y="145" width="78" height="27" />
|
|
93
|
+
</bpmndi:BPMNLabel>
|
|
94
|
+
</bpmndi:BPMNShape>
|
|
95
|
+
<bpmndi:BPMNShape id="send_receipt_di" bpmnElement="send_receipt">
|
|
96
|
+
<dc:Bounds x="800" y="80" width="100" height="80" />
|
|
97
|
+
</bpmndi:BPMNShape>
|
|
98
|
+
<bpmndi:BPMNShape id="order_completed_di" bpmnElement="order_completed">
|
|
99
|
+
<dc:Bounds x="952" y="102" width="36" height="36" />
|
|
100
|
+
<bpmndi:BPMNLabel>
|
|
101
|
+
<dc:Bounds x="930" y="145" width="80" height="27" />
|
|
102
|
+
</bpmndi:BPMNLabel>
|
|
103
|
+
</bpmndi:BPMNShape>
|
|
104
|
+
<bpmndi:BPMNShape id="payment_declined_di" bpmnElement="payment_declined">
|
|
105
|
+
<dc:Bounds x="432" y="232" width="36" height="36" />
|
|
106
|
+
<bpmndi:BPMNLabel>
|
|
107
|
+
<dc:Bounds x="410" y="275" width="80" height="27" />
|
|
108
|
+
</bpmndi:BPMNLabel>
|
|
109
|
+
</bpmndi:BPMNShape>
|
|
110
|
+
<bpmndi:BPMNShape id="card_declined_di" bpmnElement="card_declined">
|
|
111
|
+
<dc:Bounds x="432" y="142" width="36" height="36" />
|
|
112
|
+
<bpmndi:BPMNLabel>
|
|
113
|
+
<dc:Bounds x="474" y="185" width="52" height="27" />
|
|
114
|
+
</bpmndi:BPMNLabel>
|
|
115
|
+
</bpmndi:BPMNShape>
|
|
116
|
+
<bpmndi:BPMNEdge id="Flow_1_di" bpmnElement="Flow_1">
|
|
117
|
+
<di:waypoint x="188" y="120" />
|
|
118
|
+
<di:waypoint x="240" y="120" />
|
|
119
|
+
</bpmndi:BPMNEdge>
|
|
120
|
+
<bpmndi:BPMNEdge id="Flow_2_di" bpmnElement="Flow_2">
|
|
121
|
+
<di:waypoint x="340" y="120" />
|
|
122
|
+
<di:waypoint x="400" y="120" />
|
|
123
|
+
</bpmndi:BPMNEdge>
|
|
124
|
+
<bpmndi:BPMNEdge id="Flow_3_di" bpmnElement="Flow_3">
|
|
125
|
+
<di:waypoint x="500" y="120" />
|
|
126
|
+
<di:waypoint x="560" y="120" />
|
|
127
|
+
</bpmndi:BPMNEdge>
|
|
128
|
+
<bpmndi:BPMNEdge id="Flow_4_di" bpmnElement="Flow_4">
|
|
129
|
+
<di:waypoint x="660" y="120" />
|
|
130
|
+
<di:waypoint x="712" y="120" />
|
|
131
|
+
</bpmndi:BPMNEdge>
|
|
132
|
+
<bpmndi:BPMNEdge id="Flow_5_di" bpmnElement="Flow_5">
|
|
133
|
+
<di:waypoint x="748" y="120" />
|
|
134
|
+
<di:waypoint x="800" y="120" />
|
|
135
|
+
</bpmndi:BPMNEdge>
|
|
136
|
+
<bpmndi:BPMNEdge id="Flow_6_di" bpmnElement="Flow_6">
|
|
137
|
+
<di:waypoint x="900" y="120" />
|
|
138
|
+
<di:waypoint x="952" y="120" />
|
|
139
|
+
</bpmndi:BPMNEdge>
|
|
140
|
+
<bpmndi:BPMNEdge id="Flow_7_di" bpmnElement="Flow_7">
|
|
141
|
+
<di:waypoint x="450" y="178" />
|
|
142
|
+
<di:waypoint x="450" y="232" />
|
|
143
|
+
</bpmndi:BPMNEdge>
|
|
144
|
+
</bpmndi:BPMNPlane>
|
|
145
|
+
</bpmndi:BPMNDiagram>
|
|
146
|
+
</bpmn:definitions>
|
|
147
|
+
`}function Dr(e){return _[e===`camunda-8`?`camunda-7`:e].dmn}function Or(e){if(e===`camunda-8`)return{namespace:``,attribute:``};let t=d(e);return{namespace:` xmlns:${t}="${Dr(e)}"`,attribute:` ${t}:historyTimeToLive="P30D"`}}function kr(e){let t=Cr(e),n=Or(e);return`<?xml version="1.0" encoding="UTF-8"?>
|
|
148
|
+
<definitions xmlns="https://www.omg.org/spec/DMN/20191111/MODEL/" xmlns:dmndi="https://www.omg.org/spec/DMN/20191111/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/"${n.namespace} xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_shipping" name="Shipping" namespace="${Dr(e)}" modeler:executionPlatform="${t.name}" modeler:executionPlatformVersion="${t.version}">
|
|
149
|
+
<decision id="shipping-method" name="Shipping method"${n.attribute}>
|
|
150
|
+
<decisionTable id="DecisionTable_shipping" hitPolicy="FIRST">
|
|
151
|
+
<input id="Input_country" label="Country">
|
|
152
|
+
<inputExpression id="InputExpression_country" typeRef="string">
|
|
153
|
+
<text>country</text>
|
|
154
|
+
</inputExpression>
|
|
155
|
+
</input>
|
|
156
|
+
<input id="Input_amount" label="Amount">
|
|
157
|
+
<inputExpression id="InputExpression_amount" typeRef="number">
|
|
158
|
+
<text>amount</text>
|
|
159
|
+
</inputExpression>
|
|
160
|
+
</input>
|
|
161
|
+
<output id="Output_shipping" label="Shipping" name="shipping" typeRef="string" />
|
|
162
|
+
<rule id="Rule_express">
|
|
163
|
+
<description>Big orders always go express</description>
|
|
164
|
+
<inputEntry id="Rule_express_country">
|
|
165
|
+
<text></text>
|
|
166
|
+
</inputEntry>
|
|
167
|
+
<inputEntry id="Rule_express_amount">
|
|
168
|
+
<text>>= 100</text>
|
|
169
|
+
</inputEntry>
|
|
170
|
+
<outputEntry id="Rule_express_shipping">
|
|
171
|
+
<text>"express"</text>
|
|
172
|
+
</outputEntry>
|
|
173
|
+
</rule>
|
|
174
|
+
<rule id="Rule_standard">
|
|
175
|
+
<description>Home market</description>
|
|
176
|
+
<inputEntry id="Rule_standard_country">
|
|
177
|
+
<text>"DE"</text>
|
|
178
|
+
</inputEntry>
|
|
179
|
+
<inputEntry id="Rule_standard_amount">
|
|
180
|
+
<text></text>
|
|
181
|
+
</inputEntry>
|
|
182
|
+
<outputEntry id="Rule_standard_shipping">
|
|
183
|
+
<text>"standard"</text>
|
|
184
|
+
</outputEntry>
|
|
185
|
+
</rule>
|
|
186
|
+
<rule id="Rule_international">
|
|
187
|
+
<description>Everything else</description>
|
|
188
|
+
<inputEntry id="Rule_international_country">
|
|
189
|
+
<text></text>
|
|
190
|
+
</inputEntry>
|
|
191
|
+
<inputEntry id="Rule_international_amount">
|
|
192
|
+
<text></text>
|
|
193
|
+
</inputEntry>
|
|
194
|
+
<outputEntry id="Rule_international_shipping">
|
|
195
|
+
<text>"international"</text>
|
|
196
|
+
</outputEntry>
|
|
197
|
+
</rule>
|
|
198
|
+
</decisionTable>
|
|
199
|
+
</decision>
|
|
200
|
+
<dmndi:DMNDI>
|
|
201
|
+
<dmndi:DMNDiagram id="DMNDiagram_shipping">
|
|
202
|
+
<dmndi:DMNShape id="DMNShape_shipping" dmnElementRef="shipping-method">
|
|
203
|
+
<dc:Bounds height="80" width="180" x="160" y="100" />
|
|
204
|
+
</dmndi:DMNShape>
|
|
205
|
+
</dmndi:DMNDiagram>
|
|
206
|
+
</dmndi:DMNDI>
|
|
207
|
+
</definitions>
|
|
208
|
+
`}function Ar(e){let t=Cr(e);return`${JSON.stringify({components:[{text:`# Approve order
|
|
209
|
+
Check the order and decide whether it goes ahead.`,type:`text`,id:`Field_intro`},{label:`Order`,type:`textfield`,id:`Field_order`,key:`orderId`,readonly:!0},{label:`Amount`,type:`number`,id:`Field_amount`,key:`amount`,readonly:!0},{label:`Approved`,type:`checkbox`,id:`Field_approved`,key:`approved`}],type:`default`,id:`approve-order`,executionPlatform:t.name,executionPlatformVersion:t.version,schemaVersion:18},null,2)}\n`}const jr={orderId:`A-1001`,amount:40,country:`DE`};function Mr(e){let t={processDefinitionId:`order-process`},n=e=>({type:`CREATE_PROCESS_INSTANCE`,processDefinitionSelector:t,variables:e}),r={type:`COMPLETE_USER_TASK`,userTaskSelector:{elementId:`approve_order`},variables:{approved:!0}},i={type:`MOCK_JOB_WORKER_COMPLETE_JOB`,jobType:`charge-card`,variables:{paymentId:`pay-1`}},a={type:`CORRELATE_MESSAGE`,name:`shipment-confirmed`,...e===`camunda-8`?{correlationKey:`A-1001`}:{}},o={type:`MOCK_JOB_WORKER_COMPLETE_JOB`,jobType:`send-receipt`},s=e=>({type:`ASSERT_PROCESS_INSTANCE`,processInstanceSelector:t,state:e}),c=e=>({type:`ASSERT_VARIABLES`,processInstanceSelector:t,variables:{shipping:e}}),l=e===`camunda-8`?[o]:[];return`${JSON.stringify({$schema:`https://camunda.com/json-schema/cpt-test-cases/8.9/schema.json`,testCases:[{name:`A home order is approved, paid, shipped standard and completed`,description:`The whole way through, with the workers mocked`,instructions:[n(jr),r,i,a,...l,c(`standard`),s(`IS_COMPLETED`)]},{name:`An order from abroad ships internationally`,instructions:[n({...jr,country:`US`}),r,i,a,...l,c(`international`),s(`IS_COMPLETED`)]},{name:`A declined card ends the order without a shipment`,instructions:[n({...jr,amount:5e3}),r,{type:`MOCK_JOB_WORKER_THROW_BPMN_ERROR`,jobType:`charge-card`,errorCode:`CARD_DECLINED`,errorMessage:`The card was declined`},{type:`ASSERT_ELEMENT_INSTANCE`,processInstanceSelector:t,elementSelector:{elementId:`payment_declined`},state:`IS_COMPLETED`},{type:`ASSERT_ELEMENT_INSTANCES`,processInstanceSelector:t,elementSelectors:[{elementId:`decide_shipping`}],state:`IS_NOT_ACTIVATED`},s(`IS_COMPLETED`)]}]},null,2)}\n`}const Nr=`# yaml-language-server: $schema=${Sr}
|
|
210
|
+
# What this project is. Commit it.
|
|
211
|
+
|
|
212
|
+
engine: camunda-8
|
|
213
|
+
|
|
214
|
+
deployment:
|
|
215
|
+
url: http://localhost:8080/v2
|
|
216
|
+
name: order-example
|
|
217
|
+
`,Pr=`${JSON.stringify({name:`order-node-worker`,version:`1.0.0`,private:!0,type:`module`,scripts:{start:`node index.js`},engines:{node:`>=20`},dependencies:{"@camunda8/sdk":`8.8.13`}},null,2)}\n`;function Fr(){return{"penstock.yaml":Nr,"README.md":`# Order process on Camunda 8
|
|
218
|
+
|
|
219
|
+
A small order process that runs from the first minute: a user task with a Camunda Form approves the order, a service task
|
|
220
|
+
charges the card (and ends the order when the card is declined), a decision picks the shipping method, the process waits for
|
|
221
|
+
a message that the parcel has shipped, and a second service task sends the receipt.
|
|
222
|
+
|
|
223
|
+
| File | What it is |
|
|
224
|
+
|---|---|
|
|
225
|
+
| \`src/main/resources/order-process.bpmn\` | the process |
|
|
226
|
+
| \`src/main/resources/shipping-method.dmn\` | the decision |
|
|
227
|
+
| \`src/main/resources/approve-order.form\` | the Camunda Form of the user task |
|
|
228
|
+
| \`src/main/java/io/penstock/example/ChargeCardWorker.java\` | the \`charge-card\` job worker, Spring Boot |
|
|
229
|
+
| \`node-worker/index.js\` | the \`send-receipt\` job worker, Node |
|
|
230
|
+
| \`src/test/resources/test-cases/order-process.json\` | test cases in the Camunda test-case format |
|
|
231
|
+
| \`penstock.yaml\` | what Penstock needs to know: the engine and where to deploy |
|
|
232
|
+
|
|
233
|
+
## You need
|
|
234
|
+
|
|
235
|
+
- Java 17 or newer and Maven 3.9 or newer for the Spring Boot worker, Node 20 or newer for the Node worker
|
|
236
|
+
- a local Camunda 8, for example [Camunda 8 Run](https://github.com/camunda/camunda/tree/main/c8run) (it needs a JDK 21 or newer)
|
|
237
|
+
- Penstock: the plugin in your IDE, or the \`penstock\` command line
|
|
238
|
+
|
|
239
|
+
## Run it
|
|
240
|
+
|
|
241
|
+
1. Start Camunda 8 Run and leave it running: \`./start.sh\` in its folder (\`c8run.exe start\` on Windows). Operate and Tasklist
|
|
242
|
+
open at http://localhost:8080, the login is demo / demo.
|
|
243
|
+
2. Look at the diagrams in the editor, or check them from the terminal: \`penstock check .\`
|
|
244
|
+
3. Deploy the process, the decision and the form: \`penstock deploy .\`
|
|
245
|
+
4. Start the workers, each in its own terminal:
|
|
246
|
+
- \`mvn spring-boot:run\`
|
|
247
|
+
- \`cd node-worker && npm install && npm start\`
|
|
248
|
+
5. Start an order. A home order under 1000 is paid and ships standard; use \`"amount": 5000\` to see the card declined:
|
|
249
|
+
|
|
250
|
+
\`\`\`
|
|
251
|
+
curl -X POST http://localhost:8080/v2/process-instances -H 'Content-Type: application/json' \\
|
|
252
|
+
-d '{"processDefinitionId":"order-process","variables":{"orderId":"A-1001","amount":40,"country":"DE"}}'
|
|
253
|
+
\`\`\`
|
|
254
|
+
|
|
255
|
+
6. Open Tasklist, approve the order, then tell the process the parcel has shipped:
|
|
256
|
+
|
|
257
|
+
\`\`\`
|
|
258
|
+
curl -X POST http://localhost:8080/v2/messages/correlation -H 'Content-Type: application/json' \\
|
|
259
|
+
-d '{"name":"shipment-confirmed","correlationKey":"A-1001"}'
|
|
260
|
+
\`\`\`
|
|
261
|
+
|
|
262
|
+
## Run the test cases
|
|
263
|
+
|
|
264
|
+
\`penstock scenarios run .\` deploys a test build of the process, mocks the job workers and runs the three cases in
|
|
265
|
+
\`src/test/resources/test-cases/order-process.json\` against your local engine. The first run on a local engine asks once
|
|
266
|
+
whether it may. Test-case runs are a Penstock Pro feature and every machine starts with a 30 day Pro trial.
|
|
267
|
+
|
|
268
|
+
## Where the versions come from
|
|
269
|
+
|
|
270
|
+
- Spring Boot worker: \`io.camunda:camunda-spring-boot-starter\` 8.9.21 on Spring Boot 4.0.8,
|
|
271
|
+
see [Camunda Spring Boot Starter](https://docs.camunda.io/docs/apis-tools/camunda-spring-boot-starter/getting-started/).
|
|
272
|
+
Before 8.10 it was published as \`spring-boot-starter-camunda-sdk\`.
|
|
273
|
+
- Node worker: \`@camunda8/sdk\` 8.8.13, see [the Camunda 8 JavaScript SDK](https://github.com/camunda/camunda-8-js-sdk).
|
|
274
|
+
- Local engine: [Camunda 8 Run](https://docs.camunda.io/docs/8.7/self-managed/setup/deploy/local/c8run/) and its
|
|
275
|
+
[readme](https://github.com/camunda/camunda/blob/main/c8run/README.md).
|
|
276
|
+
`,".gitignore":`target/
|
|
277
|
+
node_modules/
|
|
278
|
+
`,"pom.xml":`<?xml version="1.0" encoding="UTF-8"?>
|
|
279
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
280
|
+
<modelVersion>4.0.0</modelVersion>
|
|
281
|
+
<parent>
|
|
282
|
+
<groupId>org.springframework.boot</groupId>
|
|
283
|
+
<artifactId>spring-boot-starter-parent</artifactId>
|
|
284
|
+
<version>4.0.8</version>
|
|
285
|
+
<relativePath/>
|
|
286
|
+
</parent>
|
|
287
|
+
<groupId>io.penstock.example</groupId>
|
|
288
|
+
<artifactId>order-workers</artifactId>
|
|
289
|
+
<version>1.0.0</version>
|
|
290
|
+
<properties>
|
|
291
|
+
<java.version>17</java.version>
|
|
292
|
+
<camunda.version>8.9.21</camunda.version>
|
|
293
|
+
</properties>
|
|
294
|
+
<dependencies>
|
|
295
|
+
<dependency>
|
|
296
|
+
<groupId>io.camunda</groupId>
|
|
297
|
+
<artifactId>camunda-spring-boot-starter</artifactId>
|
|
298
|
+
<version>\${camunda.version}</version>
|
|
299
|
+
</dependency>
|
|
300
|
+
<dependency>
|
|
301
|
+
<groupId>org.springframework.boot</groupId>
|
|
302
|
+
<artifactId>spring-boot-starter</artifactId>
|
|
303
|
+
</dependency>
|
|
304
|
+
</dependencies>
|
|
305
|
+
<build>
|
|
306
|
+
<plugins>
|
|
307
|
+
<plugin>
|
|
308
|
+
<groupId>org.springframework.boot</groupId>
|
|
309
|
+
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
310
|
+
</plugin>
|
|
311
|
+
</plugins>
|
|
312
|
+
</build>
|
|
313
|
+
</project>
|
|
314
|
+
`,"src/main/resources/application.yaml":`camunda:
|
|
315
|
+
client:
|
|
316
|
+
mode: self-managed
|
|
317
|
+
rest-address: http://localhost:8080
|
|
318
|
+
grpc-address: http://localhost:26500
|
|
319
|
+
`,"src/main/resources/order-process.bpmn":Er(`camunda-8`),"src/main/resources/shipping-method.dmn":kr(`camunda-8`),"src/main/resources/approve-order.form":Ar(`camunda-8`),"src/main/java/io/penstock/example/OrderWorkersApplication.java":`package io.penstock.example;
|
|
320
|
+
|
|
321
|
+
import org.springframework.boot.SpringApplication;
|
|
322
|
+
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
323
|
+
|
|
324
|
+
@SpringBootApplication
|
|
325
|
+
public class OrderWorkersApplication {
|
|
326
|
+
|
|
327
|
+
public static void main(String[] args) {
|
|
328
|
+
SpringApplication.run(OrderWorkersApplication.class, args);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
`,"src/main/java/io/penstock/example/ChargeCardWorker.java":`package io.penstock.example;
|
|
332
|
+
|
|
333
|
+
import io.camunda.client.annotation.JobWorker;
|
|
334
|
+
import io.camunda.client.annotation.Variable;
|
|
335
|
+
import io.camunda.client.exception.BpmnError;
|
|
336
|
+
import java.util.Map;
|
|
337
|
+
import java.util.UUID;
|
|
338
|
+
import org.springframework.stereotype.Component;
|
|
339
|
+
|
|
340
|
+
@Component
|
|
341
|
+
public class ChargeCardWorker {
|
|
342
|
+
|
|
343
|
+
private static final double CARD_LIMIT = 1000;
|
|
344
|
+
|
|
345
|
+
@JobWorker(type = "charge-card")
|
|
346
|
+
public Map<String, Object> chargeCard(@Variable String orderId, @Variable Number amount) {
|
|
347
|
+
if (amount.doubleValue() > CARD_LIMIT) {
|
|
348
|
+
throw new BpmnError("CARD_DECLINED", "Order " + orderId + " is over the card limit");
|
|
349
|
+
}
|
|
350
|
+
return Map.of("paymentId", "pay-" + UUID.randomUUID());
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
`,"src/test/resources/test-cases/order-process.json":Mr(`camunda-8`),"node-worker/package.json":Pr,"node-worker/index.js":`import { Camunda8 } from '@camunda8/sdk';
|
|
354
|
+
|
|
355
|
+
const camunda = new Camunda8({
|
|
356
|
+
CAMUNDA_AUTH_STRATEGY: 'NONE',
|
|
357
|
+
ZEEBE_REST_ADDRESS: process.env.ZEEBE_REST_ADDRESS ?? 'http://localhost:8080',
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
camunda.getCamundaRestClient().createJobWorker({
|
|
361
|
+
type: 'send-receipt',
|
|
362
|
+
worker: 'order-node-worker',
|
|
363
|
+
timeout: 30000,
|
|
364
|
+
maxJobsToActivate: 5,
|
|
365
|
+
jobHandler: async (job) => {
|
|
366
|
+
console.log(\`Receipt for order \${job.variables.orderId}, shipped \${job.variables.shipping}\`);
|
|
367
|
+
return job.complete({ receiptSentAt: new Date().toISOString() });
|
|
368
|
+
},
|
|
369
|
+
});
|
|
370
|
+
`}}function Ir(e){return`# yaml-language-server: $schema=${Sr}
|
|
371
|
+
# What this project is. Commit it.
|
|
372
|
+
|
|
373
|
+
engine: ${e}
|
|
374
|
+
|
|
375
|
+
deployment:
|
|
376
|
+
url: http://localhost:8080/engine-rest
|
|
377
|
+
name: order-example
|
|
378
|
+
`}function Lr(e,t){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
379
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
380
|
+
<modelVersion>4.0.0</modelVersion>
|
|
381
|
+
<parent>
|
|
382
|
+
<groupId>org.springframework.boot</groupId>
|
|
383
|
+
<artifactId>spring-boot-starter-parent</artifactId>
|
|
384
|
+
<version>${e.springBoot}</version>
|
|
385
|
+
<relativePath/>
|
|
386
|
+
</parent>
|
|
387
|
+
<groupId>io.penstock.example</groupId>
|
|
388
|
+
<artifactId>order-engine</artifactId>
|
|
389
|
+
<version>1.0.0</version>
|
|
390
|
+
<properties>
|
|
391
|
+
<java.version>17</java.version>
|
|
392
|
+
<${t}.version>${e.version}</${t}.version>
|
|
393
|
+
</properties>
|
|
394
|
+
<dependencies>
|
|
395
|
+
<dependency>
|
|
396
|
+
<groupId>${e.springBootGroup}</groupId>
|
|
397
|
+
<artifactId>${e.rest}</artifactId>
|
|
398
|
+
<version>\${${t}.version}</version>
|
|
399
|
+
</dependency>
|
|
400
|
+
<dependency>
|
|
401
|
+
<groupId>${e.springBootGroup}</groupId>
|
|
402
|
+
<artifactId>${e.webapp}</artifactId>
|
|
403
|
+
<version>\${${t}.version}</version>
|
|
404
|
+
</dependency>
|
|
405
|
+
<dependency>
|
|
406
|
+
<groupId>com.h2database</groupId>
|
|
407
|
+
<artifactId>h2</artifactId>
|
|
408
|
+
<scope>runtime</scope>
|
|
409
|
+
</dependency>
|
|
410
|
+
</dependencies>
|
|
411
|
+
<build>
|
|
412
|
+
<plugins>
|
|
413
|
+
<plugin>
|
|
414
|
+
<groupId>org.springframework.boot</groupId>
|
|
415
|
+
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
416
|
+
</plugin>
|
|
417
|
+
</plugins>
|
|
418
|
+
</build>
|
|
419
|
+
</project>
|
|
420
|
+
`}function Rr(e,t){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
421
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
422
|
+
<modelVersion>4.0.0</modelVersion>
|
|
423
|
+
<groupId>io.penstock.example</groupId>
|
|
424
|
+
<artifactId>order-worker</artifactId>
|
|
425
|
+
<version>1.0.0</version>
|
|
426
|
+
<properties>
|
|
427
|
+
<maven.compiler.release>17</maven.compiler.release>
|
|
428
|
+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
429
|
+
<${t}.version>${e.version}</${t}.version>
|
|
430
|
+
</properties>
|
|
431
|
+
<dependencies>
|
|
432
|
+
<dependency>
|
|
433
|
+
<groupId>${e.bpmGroup}</groupId>
|
|
434
|
+
<artifactId>${e.client}</artifactId>
|
|
435
|
+
<version>\${${t}.version}</version>
|
|
436
|
+
</dependency>
|
|
437
|
+
<dependency>
|
|
438
|
+
<groupId>org.slf4j</groupId>
|
|
439
|
+
<artifactId>slf4j-simple</artifactId>
|
|
440
|
+
<version>2.0.17</version>
|
|
441
|
+
</dependency>
|
|
442
|
+
</dependencies>
|
|
443
|
+
<build>
|
|
444
|
+
<plugins>
|
|
445
|
+
<plugin>
|
|
446
|
+
<groupId>org.codehaus.mojo</groupId>
|
|
447
|
+
<artifactId>exec-maven-plugin</artifactId>
|
|
448
|
+
<version>3.5.0</version>
|
|
449
|
+
<configuration>
|
|
450
|
+
<mainClass>io.penstock.example.worker.ChargeCardWorker</mainClass>
|
|
451
|
+
</configuration>
|
|
452
|
+
</plugin>
|
|
453
|
+
</plugins>
|
|
454
|
+
</build>
|
|
455
|
+
</project>
|
|
456
|
+
`}function zr(e){return`server:
|
|
457
|
+
port: 8080
|
|
458
|
+
|
|
459
|
+
${e}:
|
|
460
|
+
bpm:
|
|
461
|
+
admin-user:
|
|
462
|
+
id: demo
|
|
463
|
+
password: demo
|
|
464
|
+
filter:
|
|
465
|
+
create: All tasks
|
|
466
|
+
`}function Br(e){return`package io.penstock.example;
|
|
467
|
+
|
|
468
|
+
import java.time.Instant;
|
|
469
|
+
import ${e}.bpm.engine.delegate.DelegateExecution;
|
|
470
|
+
import ${e}.bpm.engine.delegate.JavaDelegate;
|
|
471
|
+
import org.slf4j.Logger;
|
|
472
|
+
import org.slf4j.LoggerFactory;
|
|
473
|
+
import org.springframework.stereotype.Component;
|
|
474
|
+
|
|
475
|
+
@Component("sendReceipt")
|
|
476
|
+
public class SendReceiptDelegate implements JavaDelegate {
|
|
477
|
+
|
|
478
|
+
private static final Logger LOG = LoggerFactory.getLogger(SendReceiptDelegate.class);
|
|
479
|
+
|
|
480
|
+
@Override
|
|
481
|
+
public void execute(DelegateExecution execution) {
|
|
482
|
+
LOG.info("Receipt for order {}, shipped {}", execution.getVariable("orderId"), execution.getVariable("shipping"));
|
|
483
|
+
execution.setVariable("receiptSentAt", Instant.now().toString());
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
`}function Vr(e){return`package io.penstock.example.worker;
|
|
487
|
+
|
|
488
|
+
import java.util.Map;
|
|
489
|
+
import java.util.UUID;
|
|
490
|
+
import ${e}.bpm.client.ExternalTaskClient;
|
|
491
|
+
import ${e}.bpm.client.task.ExternalTask;
|
|
492
|
+
import ${e}.bpm.client.task.ExternalTaskService;
|
|
493
|
+
|
|
494
|
+
public class ChargeCardWorker {
|
|
495
|
+
|
|
496
|
+
private static final double CARD_LIMIT = 1000;
|
|
497
|
+
|
|
498
|
+
public static void main(String[] args) {
|
|
499
|
+
String engine = System.getenv().getOrDefault("ENGINE_REST_URL", "http://localhost:8080/engine-rest");
|
|
500
|
+
ExternalTaskClient client = ExternalTaskClient.create()
|
|
501
|
+
.baseUrl(engine)
|
|
502
|
+
.asyncResponseTimeout(10000)
|
|
503
|
+
.build();
|
|
504
|
+
client.subscribe("charge-card")
|
|
505
|
+
.lockDuration(30000)
|
|
506
|
+
.handler(ChargeCardWorker::chargeCard)
|
|
507
|
+
.open();
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
private static void chargeCard(ExternalTask task, ExternalTaskService service) {
|
|
511
|
+
String orderId = task.getVariable("orderId");
|
|
512
|
+
Number amount = task.getVariable("amount");
|
|
513
|
+
if (amount.doubleValue() > CARD_LIMIT) {
|
|
514
|
+
service.handleBpmnError(task, "CARD_DECLINED", "Order " + orderId + " is over the card limit");
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
service.complete(task, Map.of("paymentId", "pay-" + UUID.randomUUID()));
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
`}function Hr(e,t){let n=v(e);return`# Order process on ${n}
|
|
521
|
+
|
|
522
|
+
A small order process that runs from the first minute: a user task with a form approves the order, an external task
|
|
523
|
+
charges the card (and ends the order when the card is declined), a decision picks the shipping method, the process waits for
|
|
524
|
+
a message that the parcel has shipped, and a Java delegate sends the receipt.
|
|
525
|
+
|
|
526
|
+
| File | What it is |
|
|
527
|
+
|---|---|
|
|
528
|
+
| \`src/main/resources/order-process.bpmn\` | the process |
|
|
529
|
+
| \`src/main/resources/shipping-method.dmn\` | the decision |
|
|
530
|
+
| \`src/main/resources/approve-order.form\` | the form of the user task |
|
|
531
|
+
| \`src/main/java/io/penstock/example/SendReceiptDelegate.java\` | the Java delegate behind \`send_receipt\` |
|
|
532
|
+
| \`worker/\` | the external task worker for the topic \`charge-card\`, a plain Java client |
|
|
533
|
+
| \`src/test/resources/test-cases/order-process.json\` | test cases in the Camunda test-case format |
|
|
534
|
+
| \`penstock.yaml\` | what Penstock needs to know: the engine and where to deploy |
|
|
535
|
+
|
|
536
|
+
## You need
|
|
537
|
+
|
|
538
|
+
- Java 17 or newer and Maven 3.9 or newer
|
|
539
|
+
- Penstock: the plugin in your IDE, or the \`penstock\` command line
|
|
540
|
+
|
|
541
|
+
The engine is part of the example: a Spring Boot application with the ${n} engine, its REST API and the web apps,
|
|
542
|
+
on an in-memory H2 database.
|
|
543
|
+
|
|
544
|
+
## Run it
|
|
545
|
+
|
|
546
|
+
1. Start the engine and leave it running: \`mvn spring-boot:run\`. Cockpit and Tasklist are at http://localhost:8080,
|
|
547
|
+
the login is demo / demo. The process, the decision and the form are deployed when it starts.
|
|
548
|
+
2. Look at the diagrams in the editor, or check them from the terminal: \`penstock check .\`
|
|
549
|
+
3. After you change a diagram, deploy it again: \`penstock deploy .\`
|
|
550
|
+
4. Start the external task worker in a second terminal: \`mvn -f worker/pom.xml compile exec:java\`
|
|
551
|
+
5. Start an order. A home order under 1000 is paid and ships standard; use \`"amount": 5000\` to see the card declined:
|
|
552
|
+
|
|
553
|
+
\`\`\`
|
|
554
|
+
curl -X POST http://localhost:8080/engine-rest/process-definition/key/order-process/start -H 'Content-Type: application/json' \\
|
|
555
|
+
-d '{"businessKey":"A-1001","variables":{"orderId":{"value":"A-1001"},"amount":{"value":40},"country":{"value":"DE"}}}'
|
|
556
|
+
\`\`\`
|
|
557
|
+
|
|
558
|
+
6. Open Tasklist, approve the order, then tell the process the parcel has shipped:
|
|
559
|
+
|
|
560
|
+
\`\`\`
|
|
561
|
+
curl -X POST http://localhost:8080/engine-rest/message -H 'Content-Type: application/json' \\
|
|
562
|
+
-d '{"messageName":"shipment-confirmed","businessKey":"A-1001"}'
|
|
563
|
+
\`\`\`
|
|
564
|
+
|
|
565
|
+
## Run the test cases
|
|
566
|
+
|
|
567
|
+
\`penstock scenarios run .\` deploys a test build of the process, mocks the external task and runs the three cases in
|
|
568
|
+
\`src/test/resources/test-cases/order-process.json\` against the running engine. The delegate runs for real, so keep the
|
|
569
|
+
engine from step 1 running. The first run on a local engine asks once whether it may. Test-case runs are a Penstock Pro
|
|
570
|
+
feature and every machine starts with a 30 day Pro trial.
|
|
571
|
+
|
|
572
|
+
## Where the versions come from
|
|
573
|
+
|
|
574
|
+
${[`- Engine: \`${t.rest}\` and \`${t.webapp}\` ${t.version} on Spring Boot ${t.springBoot}, from \`${t.springBootGroup}\`.`,`- Worker: \`${t.client}\` ${t.version}, from \`${t.bpmGroup}\`.`].join(`
|
|
575
|
+
`)}
|
|
576
|
+
${e===`camunda-7`?`
|
|
577
|
+
See the [Spring Boot integration](https://docs.camunda.org/manual/latest/user-guide/spring-boot-integration/) and the
|
|
578
|
+
[External Task Client](https://docs.camunda.org/manual/latest/user-guide/ext-client/) in the Camunda documentation.
|
|
579
|
+
7.24.0 is the last community release on Maven Central.
|
|
580
|
+
`:``}`}function Ur(e,t=`3`){let n=y(e,t);if(!n)throw Error(`${v(e)} has no Spring Boot ${t} starters`);let r=n.client.replace(/-external-task-client$/,``),i=c(e);return{"penstock.yaml":Ir(e),"README.md":Hr(e,n),".gitignore":`target/
|
|
581
|
+
`,"pom.xml":Lr(n,r),"src/main/resources/application.yaml":zr(_[e].settings),"src/main/resources/order-process.bpmn":Er(e),"src/main/resources/shipping-method.dmn":kr(e),"src/main/resources/approve-order.form":Ar(e),"src/main/java/io/penstock/example/OrderApplication.java":`package io.penstock.example;
|
|
582
|
+
|
|
583
|
+
import org.springframework.boot.SpringApplication;
|
|
584
|
+
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
585
|
+
|
|
586
|
+
@SpringBootApplication
|
|
587
|
+
public class OrderApplication {
|
|
588
|
+
|
|
589
|
+
public static void main(String[] args) {
|
|
590
|
+
SpringApplication.run(OrderApplication.class, args);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
`,"src/main/java/io/penstock/example/SendReceiptDelegate.java":Br(i),"src/test/resources/test-cases/order-process.json":Mr(e),"worker/pom.xml":Rr(n,r),"worker/src/main/java/io/penstock/example/worker/ChargeCardWorker.java":Vr(i)}}const Wr={flowable:{group:`org.flowable`,artifact:`flowable-engine`,version:`7.1.0`,name:`flowable`},activiti:{group:`org.activiti`,artifact:`activiti-engine`,version:`7.1.0.M6`,name:`activiti`}};function Gr(e){return`# yaml-language-server: $schema=${Sr}
|
|
594
|
+
# What this project is. Commit it.
|
|
595
|
+
|
|
596
|
+
engine: ${e}
|
|
597
|
+
`}function Kr(e){let{group:t,artifact:n,version:r,name:i}=Wr[e];return`<?xml version="1.0" encoding="UTF-8"?>
|
|
598
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
599
|
+
<modelVersion>4.0.0</modelVersion>
|
|
600
|
+
<groupId>io.penstock.example</groupId>
|
|
601
|
+
<artifactId>order-engine</artifactId>
|
|
602
|
+
<version>1.0.0</version>
|
|
603
|
+
<properties>
|
|
604
|
+
<maven.compiler.release>17</maven.compiler.release>
|
|
605
|
+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
606
|
+
<${i}.version>${r}</${i}.version>
|
|
607
|
+
</properties>
|
|
608
|
+
<dependencies>
|
|
609
|
+
<dependency>
|
|
610
|
+
<groupId>${t}</groupId>
|
|
611
|
+
<artifactId>${n}</artifactId>
|
|
612
|
+
<version>\${${i}.version}</version>
|
|
613
|
+
</dependency>
|
|
614
|
+
<dependency>
|
|
615
|
+
<groupId>com.h2database</groupId>
|
|
616
|
+
<artifactId>h2</artifactId>
|
|
617
|
+
<version>2.3.232</version>
|
|
618
|
+
</dependency>
|
|
619
|
+
<dependency>
|
|
620
|
+
<groupId>org.slf4j</groupId>
|
|
621
|
+
<artifactId>slf4j-simple</artifactId>
|
|
622
|
+
<version>2.0.17</version>
|
|
623
|
+
</dependency>
|
|
624
|
+
</dependencies>
|
|
625
|
+
<build>
|
|
626
|
+
<plugins>
|
|
627
|
+
<plugin>
|
|
628
|
+
<groupId>org.codehaus.mojo</groupId>
|
|
629
|
+
<artifactId>exec-maven-plugin</artifactId>
|
|
630
|
+
<version>3.5.0</version>
|
|
631
|
+
<configuration>
|
|
632
|
+
<mainClass>io.penstock.example.OrderApplication</mainClass>
|
|
633
|
+
</configuration>
|
|
634
|
+
</plugin>
|
|
635
|
+
</plugins>
|
|
636
|
+
</build>
|
|
637
|
+
</project>
|
|
638
|
+
`}function qr(e){return`package io.penstock.example;
|
|
639
|
+
|
|
640
|
+
import java.util.List;
|
|
641
|
+
import java.util.Map;
|
|
642
|
+
import ${e}.engine.ProcessEngine;
|
|
643
|
+
import ${e}.engine.ProcessEngineConfiguration;
|
|
644
|
+
import ${e}.engine.RepositoryService;
|
|
645
|
+
import ${e}.engine.RuntimeService;
|
|
646
|
+
import ${e}.engine.TaskService;
|
|
647
|
+
import ${e}.engine.task.Task;
|
|
648
|
+
|
|
649
|
+
public class OrderApplication {
|
|
650
|
+
|
|
651
|
+
public static void main(String[] args) {
|
|
652
|
+
ProcessEngineConfiguration configuration = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration();
|
|
653
|
+
configuration.setBeans(Map.of("sendReceipt", new SendReceiptDelegate()));
|
|
654
|
+
ProcessEngine engine = configuration.buildProcessEngine();
|
|
655
|
+
try {
|
|
656
|
+
RepositoryService repository = engine.getRepositoryService();
|
|
657
|
+
repository.createDeployment().addClasspathResource("processes/order-process.bpmn").name("order-example").deploy();
|
|
658
|
+
|
|
659
|
+
RuntimeService runtime = engine.getRuntimeService();
|
|
660
|
+
String instance = runtime.startProcessInstanceByKey("order-process", Map.of("orderId", "A-1001", "amount", 40)).getId();
|
|
661
|
+
|
|
662
|
+
TaskService tasks = engine.getTaskService();
|
|
663
|
+
List<Task> waiting = tasks.createTaskQuery().processInstanceId(instance).taskCandidateGroup("managers").list();
|
|
664
|
+
System.out.println("Waiting for approval: " + waiting.get(0).getName());
|
|
665
|
+
tasks.complete(waiting.get(0).getId(), Map.of("approved", true));
|
|
666
|
+
|
|
667
|
+
boolean finished = runtime.createProcessInstanceQuery().processInstanceId(instance).count() == 0;
|
|
668
|
+
System.out.println("Order finished: " + finished);
|
|
669
|
+
} finally {
|
|
670
|
+
engine.close();
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
`}function Jr(e){return`package io.penstock.example;
|
|
675
|
+
|
|
676
|
+
import ${e}.engine.delegate.DelegateExecution;
|
|
677
|
+
import ${e}.engine.delegate.JavaDelegate;
|
|
678
|
+
|
|
679
|
+
public class ChargeCardDelegate implements JavaDelegate {
|
|
680
|
+
|
|
681
|
+
private static final double CARD_LIMIT = 1000;
|
|
682
|
+
|
|
683
|
+
@Override
|
|
684
|
+
public void execute(DelegateExecution execution) {
|
|
685
|
+
Number amount = (Number) execution.getVariable("amount");
|
|
686
|
+
execution.setVariable("paid", amount.doubleValue() <= CARD_LIMIT);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
`}function Yr(e){return`package io.penstock.example;
|
|
690
|
+
|
|
691
|
+
import java.time.Instant;
|
|
692
|
+
import ${e}.engine.delegate.DelegateExecution;
|
|
693
|
+
import ${e}.engine.delegate.JavaDelegate;
|
|
694
|
+
|
|
695
|
+
public class SendReceiptDelegate implements JavaDelegate {
|
|
696
|
+
|
|
697
|
+
@Override
|
|
698
|
+
public void execute(DelegateExecution execution) {
|
|
699
|
+
System.out.println("Receipt for order " + execution.getVariable("orderId"));
|
|
700
|
+
execution.setVariable("receiptSentAt", Instant.now().toString());
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
`}function Xr(e){let t=e;return`<?xml version="1.0" encoding="UTF-8"?>
|
|
704
|
+
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:${t}="${o[e]}" id="Definitions_order" targetNamespace="http://bpmn.io/schema/bpmn">
|
|
705
|
+
<bpmn:process id="order-process" name="Order" isExecutable="true">
|
|
706
|
+
<bpmn:startEvent id="order_received" name="Order received">
|
|
707
|
+
<bpmn:outgoing>Flow_1</bpmn:outgoing>
|
|
708
|
+
</bpmn:startEvent>
|
|
709
|
+
<bpmn:userTask id="approve_order" name="Approve order" ${t}:candidateGroups="managers" ${t}:formKey="approve-order">
|
|
710
|
+
<bpmn:incoming>Flow_1</bpmn:incoming>
|
|
711
|
+
<bpmn:outgoing>Flow_2</bpmn:outgoing>
|
|
712
|
+
</bpmn:userTask>
|
|
713
|
+
<bpmn:exclusiveGateway id="is_approved" name="Approved?" default="Flow_4">
|
|
714
|
+
<bpmn:incoming>Flow_2</bpmn:incoming>
|
|
715
|
+
<bpmn:outgoing>Flow_3</bpmn:outgoing>
|
|
716
|
+
<bpmn:outgoing>Flow_4</bpmn:outgoing>
|
|
717
|
+
</bpmn:exclusiveGateway>
|
|
718
|
+
<bpmn:serviceTask id="charge_card" name="Charge card" ${t}:class="io.penstock.example.ChargeCardDelegate">
|
|
719
|
+
<bpmn:incoming>Flow_3</bpmn:incoming>
|
|
720
|
+
<bpmn:outgoing>Flow_5</bpmn:outgoing>
|
|
721
|
+
</bpmn:serviceTask>
|
|
722
|
+
<bpmn:serviceTask id="send_receipt" name="Send receipt" ${t}:delegateExpression="\${sendReceipt}">
|
|
723
|
+
<bpmn:incoming>Flow_5</bpmn:incoming>
|
|
724
|
+
<bpmn:outgoing>Flow_6</bpmn:outgoing>
|
|
725
|
+
</bpmn:serviceTask>
|
|
726
|
+
<bpmn:endEvent id="order_completed" name="Order completed">
|
|
727
|
+
<bpmn:incoming>Flow_6</bpmn:incoming>
|
|
728
|
+
</bpmn:endEvent>
|
|
729
|
+
<bpmn:endEvent id="order_rejected" name="Order rejected">
|
|
730
|
+
<bpmn:incoming>Flow_4</bpmn:incoming>
|
|
731
|
+
</bpmn:endEvent>
|
|
732
|
+
<bpmn:sequenceFlow id="Flow_1" sourceRef="order_received" targetRef="approve_order" />
|
|
733
|
+
<bpmn:sequenceFlow id="Flow_2" sourceRef="approve_order" targetRef="is_approved" />
|
|
734
|
+
<bpmn:sequenceFlow id="Flow_3" name="Yes" sourceRef="is_approved" targetRef="charge_card">
|
|
735
|
+
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">\${approved}</bpmn:conditionExpression>
|
|
736
|
+
</bpmn:sequenceFlow>
|
|
737
|
+
<bpmn:sequenceFlow id="Flow_4" name="No" sourceRef="is_approved" targetRef="order_rejected" />
|
|
738
|
+
<bpmn:sequenceFlow id="Flow_5" sourceRef="charge_card" targetRef="send_receipt" />
|
|
739
|
+
<bpmn:sequenceFlow id="Flow_6" sourceRef="send_receipt" targetRef="order_completed" />
|
|
740
|
+
</bpmn:process>
|
|
741
|
+
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
|
742
|
+
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="order-process">
|
|
743
|
+
<bpmndi:BPMNShape id="order_received_di" bpmnElement="order_received">
|
|
744
|
+
<dc:Bounds x="152" y="102" width="36" height="36" />
|
|
745
|
+
<bpmndi:BPMNLabel>
|
|
746
|
+
<dc:Bounds x="132" y="145" width="76" height="27" />
|
|
747
|
+
</bpmndi:BPMNLabel>
|
|
748
|
+
</bpmndi:BPMNShape>
|
|
749
|
+
<bpmndi:BPMNShape id="approve_order_di" bpmnElement="approve_order">
|
|
750
|
+
<dc:Bounds x="240" y="80" width="100" height="80" />
|
|
751
|
+
</bpmndi:BPMNShape>
|
|
752
|
+
<bpmndi:BPMNShape id="is_approved_di" bpmnElement="is_approved" isMarkerVisible="true">
|
|
753
|
+
<dc:Bounds x="395" y="95" width="50" height="50" />
|
|
754
|
+
<bpmndi:BPMNLabel>
|
|
755
|
+
<dc:Bounds x="396" y="65" width="48" height="14" />
|
|
756
|
+
</bpmndi:BPMNLabel>
|
|
757
|
+
</bpmndi:BPMNShape>
|
|
758
|
+
<bpmndi:BPMNShape id="charge_card_di" bpmnElement="charge_card">
|
|
759
|
+
<dc:Bounds x="500" y="80" width="100" height="80" />
|
|
760
|
+
</bpmndi:BPMNShape>
|
|
761
|
+
<bpmndi:BPMNShape id="send_receipt_di" bpmnElement="send_receipt">
|
|
762
|
+
<dc:Bounds x="660" y="80" width="100" height="80" />
|
|
763
|
+
</bpmndi:BPMNShape>
|
|
764
|
+
<bpmndi:BPMNShape id="order_completed_di" bpmnElement="order_completed">
|
|
765
|
+
<dc:Bounds x="822" y="102" width="36" height="36" />
|
|
766
|
+
<bpmndi:BPMNLabel>
|
|
767
|
+
<dc:Bounds x="800" y="145" width="80" height="27" />
|
|
768
|
+
</bpmndi:BPMNLabel>
|
|
769
|
+
</bpmndi:BPMNShape>
|
|
770
|
+
<bpmndi:BPMNShape id="order_rejected_di" bpmnElement="order_rejected">
|
|
771
|
+
<dc:Bounds x="402" y="222" width="36" height="36" />
|
|
772
|
+
<bpmndi:BPMNLabel>
|
|
773
|
+
<dc:Bounds x="383" y="265" width="74" height="14" />
|
|
774
|
+
</bpmndi:BPMNLabel>
|
|
775
|
+
</bpmndi:BPMNShape>
|
|
776
|
+
<bpmndi:BPMNEdge id="Flow_1_di" bpmnElement="Flow_1">
|
|
777
|
+
<di:waypoint x="188" y="120" />
|
|
778
|
+
<di:waypoint x="240" y="120" />
|
|
779
|
+
</bpmndi:BPMNEdge>
|
|
780
|
+
<bpmndi:BPMNEdge id="Flow_2_di" bpmnElement="Flow_2">
|
|
781
|
+
<di:waypoint x="340" y="120" />
|
|
782
|
+
<di:waypoint x="395" y="120" />
|
|
783
|
+
</bpmndi:BPMNEdge>
|
|
784
|
+
<bpmndi:BPMNEdge id="Flow_3_di" bpmnElement="Flow_3">
|
|
785
|
+
<di:waypoint x="445" y="120" />
|
|
786
|
+
<di:waypoint x="500" y="120" />
|
|
787
|
+
<bpmndi:BPMNLabel>
|
|
788
|
+
<dc:Bounds x="463" y="102" width="19" height="14" />
|
|
789
|
+
</bpmndi:BPMNLabel>
|
|
790
|
+
</bpmndi:BPMNEdge>
|
|
791
|
+
<bpmndi:BPMNEdge id="Flow_4_di" bpmnElement="Flow_4">
|
|
792
|
+
<di:waypoint x="420" y="145" />
|
|
793
|
+
<di:waypoint x="420" y="222" />
|
|
794
|
+
<bpmndi:BPMNLabel>
|
|
795
|
+
<dc:Bounds x="428" y="180" width="15" height="14" />
|
|
796
|
+
</bpmndi:BPMNLabel>
|
|
797
|
+
</bpmndi:BPMNEdge>
|
|
798
|
+
<bpmndi:BPMNEdge id="Flow_5_di" bpmnElement="Flow_5">
|
|
799
|
+
<di:waypoint x="600" y="120" />
|
|
800
|
+
<di:waypoint x="660" y="120" />
|
|
801
|
+
</bpmndi:BPMNEdge>
|
|
802
|
+
<bpmndi:BPMNEdge id="Flow_6_di" bpmnElement="Flow_6">
|
|
803
|
+
<di:waypoint x="760" y="120" />
|
|
804
|
+
<di:waypoint x="822" y="120" />
|
|
805
|
+
</bpmndi:BPMNEdge>
|
|
806
|
+
</bpmndi:BPMNPlane>
|
|
807
|
+
</bpmndi:BPMNDiagram>
|
|
808
|
+
</bpmn:definitions>
|
|
809
|
+
`}function Zr(e){let t=v(e),{group:n,artifact:r,version:i}=Wr[e];return`# Order process on ${t}
|
|
810
|
+
|
|
811
|
+
A small order process that runs from the first minute: a user task for the managers group approves the order, a gateway
|
|
812
|
+
sends a rejected order to its own end, and an approved one is charged by a Java delegate named by class and receives its
|
|
813
|
+
receipt from a delegate named by expression.
|
|
814
|
+
|
|
815
|
+
| File | What it is |
|
|
816
|
+
|---|---|
|
|
817
|
+
| \`src/main/resources/processes/order-process.bpmn\` | the process, with the \`${e}:\` extensions the engine reads |
|
|
818
|
+
| \`src/main/java/io/penstock/example/OrderApplication.java\` | builds an in-memory engine, deploys the process, starts an order and approves it |
|
|
819
|
+
| \`src/main/java/io/penstock/example/ChargeCardDelegate.java\` | the delegate behind \`charge_card\`, named by class |
|
|
820
|
+
| \`src/main/java/io/penstock/example/SendReceiptDelegate.java\` | the delegate behind \`send_receipt\`, named by expression |
|
|
821
|
+
| \`penstock.yaml\` | what Penstock needs to know: the engine |
|
|
822
|
+
|
|
823
|
+
## You need
|
|
824
|
+
|
|
825
|
+
- Java 17 or newer and Maven 3.9 or newer
|
|
826
|
+
- Penstock: the plugin in your IDE, or the \`penstock\` command line
|
|
827
|
+
|
|
828
|
+
## Run it
|
|
829
|
+
|
|
830
|
+
1. Look at the diagram in the editor, or check it from the terminal: \`penstock check .\`
|
|
831
|
+
2. Run the engine: \`mvn compile exec:java\`. It deploys the process, starts order A-1001, completes the approval and prints
|
|
832
|
+
the result.
|
|
833
|
+
|
|
834
|
+
Penstock reads and checks ${t} diagrams, and its editor has a properties panel for the ${e}: attributes. Deploying
|
|
835
|
+
from Penstock, test-case runs and generated tests are not part of the ${t} profile; deploy with the engine's own tools.
|
|
836
|
+
|
|
837
|
+
## Where the versions come from
|
|
838
|
+
|
|
839
|
+
- Engine: \`${r}\` ${i}, from \`${n}\`, on an in-memory H2 database.
|
|
840
|
+
|
|
841
|
+
${e===`flowable`?`See the [Flowable documentation](https://documentation.flowable.org/latest/) for the BPMN constructs the engine supports.`:`See the [Activiti documentation](https://www.activiti.org/documentation) for the BPMN constructs the engine supports.`}
|
|
842
|
+
`}function Qr(e){let t=c(e);return{"penstock.yaml":Gr(e),"README.md":Zr(e),".gitignore":`target/
|
|
843
|
+
`,"pom.xml":Kr(e),"src/main/resources/processes/order-process.bpmn":Xr(e),"src/main/java/io/penstock/example/OrderApplication.java":qr(t),"src/main/java/io/penstock/example/ChargeCardDelegate.java":Jr(t),"src/main/java/io/penstock/example/SendReceiptDelegate.java":Yr(t)}}const $r=[`camunda-8`,`camunda-7`,`operaton`,`cib-seven`,`flowable`,`activiti`];function ei(e){return $r.includes(e)}function ti(e,t=`3`){return e===`camunda-8`?Fr():e===`flowable`||e===`activiti`?Qr(e):Ur(e,t)}const ni=[`isDefault`,`groups`,`documentationRef`,`metadata`,`deprecated`,`category`,`icon`,`engines`,`keywords`,`entriesVisible`],ri=[`description`,`optional`,`defaultValue`,`group`,`constraints`];function ii(e){let t=e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).split(/[^A-Za-z0-9]+/).filter(Boolean).map(e=>e.toLowerCase());return t.length===0?e:t.map((e,t)=>t===0?e[0].toUpperCase()+e.slice(1):e).join(` `)}function ai(e){return e.value.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).replace(/[^A-Za-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).toLowerCase()||`worker`}function oi(e){return`${ai(e)}.json`}function si(e){return e.engine===`camunda-7`&&e.binding===`topic`?{value:`bpmn:ServiceTask`,"camunda:type":`external`,"camunda:topic":e.value}:e.engine===`camunda-7`?{value:`bpmn:ServiceTask`}:{value:`bpmn:ServiceTask`,"zeebe:taskDefinition":e.value}}function ci(e){return e.engine===`camunda-7`?`camunda:inputOutput`:`zeebe:input`}function li(e,t){return{label:ii(t.name),type:t.type,...t.choices?{choices:[...t.choices]}:{},binding:{type:ci(e),name:t.name}}}function ui(e){return{label:ii(e.name),type:`Hidden`,value:`=`,binding:{type:`zeebe:output`,name:e.name}}}function di(e){let n=e.className?e.packageName?t(`app.templates.workerInPackage`,{class:e.className,package:e.packageName}):e.className:e.file.split(/[\\/]/).pop()??e.file,r=e.outputs.length>0?t(`app.templates.workerSets`,{names:e.outputs.map(e=>e.name).join(`, `)}):``;return`${t(`app.templates.workerDescription`,{worker:e.value,where:n})}${r} ${t(`app.templates.writtenByPenstock`)}`}function fi(e){return{$schema:e.engine===`camunda-7`?`https://unpkg.com/@camunda/element-templates-json-schema/resources/schema.json`:`https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json`,id:ai(e),name:e.name,description:di(e),version:1,appliesTo:[`bpmn:Task`],elementType:si(e),properties:[...e.inputs.map(t=>li(e,t)),...e.engine===`camunda-7`?[]:e.outputs.map(ui)]}}function pi(e){return e.binding?.name??null}function mi(e,t){let n={...t,name:e.name||t.name,description:e.description??t.description,version:(e.version??0)+1};return ni.forEach(t=>{e[t]!==void 0&&(n[t]=e[t])}),n.properties=t.properties.map(t=>{let n=pi(t),r=e.properties.find(e=>pi(e)===n&&n!==null);if(!r)return t;let i={...r,type:t.type,...t.choices?{choices:t.choices}:{},binding:t.binding,value:t.value};return t.choices===void 0&&delete i.choices,t.value===void 0&&delete i.value,ri.forEach(e=>{r[e]===void 0&&delete i[e]}),i}),n}function hi(e,t){let n=/* @__PURE__ */ new Map;for(let t of e.properties){if(t.binding?.type===`zeebe:output`||t.binding?.type===`camunda:taskDefinition`)continue;let e=pi(t);e&&n.set(e,t.type)}let r=new Map(t.inputs.map(e=>[e.name,e.type])),i=[...r.keys()].filter(e=>!n.has(e)),a=[...n.keys()].filter(e=>!r.has(e)),o=[...r.keys()].filter(e=>n.has(e)&&n.get(e)!==r.get(e));return i.length===0&&a.length===0&&o.length===0?null:{missing:i,extra:a,changed:o}}function gi(e){return[...e.missing.map(e=>t(`app.templates.drift.noLongerRead`,{name:e})),...e.extra.map(e=>t(`app.templates.drift.notRead`,{name:e})),...e.changed.map(e=>t(`app.templates.drift.differentType`,{name:e}))].join(`; `)}function _i(e){return`.camunda/element-templates/${oi(e)}`}function vi(e,t){return e.name||t.slice(t.lastIndexOf(`/`)+1).replace(/\.json$/,``)}function yi(e){if(!e)return null;try{let t=JSON.parse(e);return Array.isArray(t)?t[0]??null:t}catch{return null}}function bi(e,t){return JSON.stringify(e)===JSON.stringify(t)}function xi(e,t){return bi({...e,version:0},{...t,version:0})}async function Si(e){let t=/* @__PURE__ */ new Map;for(let n of await e.list()){let r=yi(await e.read(n));r?.id&&t.set(r.id,{path:n,template:r})}return t}async function Ci(e,t){let n=_i(t),r=yi(await e.read(n)),i=fi(t),a=r?mi(r,i):i,o=r?xi(r,a)?`unchanged`:`updated`:`written`;return o===`unchanged`||await e.write(n,`${JSON.stringify(a,null,2)}\n`),{path:n,id:a.id,value:t.value,action:o,contract:t}}async function wi(e,t){let n=[],r=/* @__PURE__ */ new Set;for(let i of t){let t=ai(i);r.has(t)||(r.add(t),n.push(await Ci(e,i)))}return n}async function Ti(e,t){let n=new Map(t.map(e=>[e.value,e])),r=[];for(let{path:t,template:i}of(await Si(e)).values()){let e=i.elementType?.[`zeebe:taskDefinition`]??i.elementType?.[`camunda:topic`]??null,a=e?n.get(e):void 0;if(!e||!a)continue;let o=hi(i,a);o&&r.push({path:t,id:i.id,value:e,drift:o,worker:`${a.file}:${a.line}`})}return r}const Ei={create:`creating`,assignment:`assigning`,update:`updating`,complete:`completing`,delete:`canceling`};function Di(e,n){if(e.role===`taskListener`){let n=T(Ei,e.event??`create`)??e.event??`creating`;return t(`app.migration.worker.becomes.taskListener`,{jobType:e.jobType,event:n})}return e.role===`executionListener`?t(`app.migration.worker.becomes.executionListener`,{jobType:e.jobType,event:e.event??`start`}):e.kind===`topic`||n?.shape===`externalTaskHandler`?t(`app.migration.worker.becomes.topic`,{jobType:e.jobType}):e.kind===`expression`?t(`app.migration.worker.becomes.expression`,{jobType:e.jobType}):t(`app.migration.worker.becomes.class`,{jobType:e.jobType})}function Oi(e){return e?[...e.usesBusinessKey?[t(`app.migration.worker.note.businessKey`)]:[],...e.usesEngineServices.length>0?[t(`app.migration.worker.note.engineServices`,{services:e.usesEngineServices.join(`, `)})]:[],...e.readsAllVariables?[t(`app.migration.worker.note.readsAllVariables`)]:[]]:[]}function ki(e,n={}){switch(e){case`CONDITION`:case`FEEL_CONDITION`:return t(`app.scriptTab.condition`);case`EXECUTION_LISTENER`:return t(`app.scriptTab.executionListener`,{event:n.event??``});case`TASK_LISTENER`:return t(`app.scriptTab.taskListener`,{event:n.event??``});case`PARAMETER`:case`INPUT_MAPPING`:case`OUTPUT_MAPPING`:return n.parameter?.direction===`output`?t(`app.scriptTab.output`,{name:n.parameter.name}):t(`app.scriptTab.input`,{name:n.parameter?.name??``});case`TASK_BODY`:return t(`app.scriptTab.script`)}}function Ai(e,n){return t(`app.scriptTab.title`,{name:e,what:n})}function ji(e){return Ai(e.shared?t(`app.scriptTab.nameWithId`,{name:e.name,id:e.slot.elementId}):e.name,ki(e.slot.owner,e))}var Mi=class e{children;folder;folders=/* @__PURE__ */ new Map;elements=/* @__PURE__ */ new Map;constructor(e,t){this.children=e,this.folder=t}enter(t){let n=this.folders.get(t);if(!n){let r=[],i={kind:`folder`,id:t,count:0,children:r};this.children.push(i),n=new e(r,i),this.folders.set(t,n)}return n.folder&&(n.folder.count+=1),n}add(e){let t=this.elements.get(e.slot.elementId);if(t){t.sites.push(e);return}let n={kind:`element`,elementId:e.slot.elementId,sites:[e],sharedLabel:!1};this.elements.set(e.slot.elementId,n),this.children.push(n)}};function Ni(e){let t=/* @__PURE__ */ new Map;e.forEach(e=>{if(e.kind!==`element`)return;let n=e.sites[0].name;t.set(n,(t.get(n)??0)+1)}),e.forEach(e=>{e.kind===`element`?e.sharedLabel=(t.get(e.sites[0].name)??0)>1:Ni(e.children)})}function Pi(e){let t=new Mi([],null);return e.forEach(e=>{let n=t;e.containers.forEach(e=>{n=n.enter(e)}),n.add(e)}),Ni(t.children),t.children}function Fi(){return[[t(`app.toolWindow.action.createJobWorker`),`spring`],[t(`app.toolWindow.action.createNodeWorker`),`node`],[t(`app.toolWindow.action.createPythonWorker`),`python`]]}function Ii(){return[[t(`app.toolWindow.action.jobWorkerSkeleton`),`spring`],[t(`app.toolWindow.action.nodeWorkerSkeleton`),`node`],[t(`app.toolWindow.action.pythonWorkerSkeleton`),`python`]]}const Li={"camunda-8":{label:`app.toolWindow.examples.camunda8Label`,detail:`app.toolWindow.examples.camunda8Detail`},"camunda-7":{label:`app.toolWindow.examples.camunda7Label`,detail:`app.toolWindow.examples.camunda7Detail`},operaton:{label:`app.toolWindow.examples.operatonLabel`,detail:`app.toolWindow.examples.operatonDetail`},"cib-seven":{label:`app.toolWindow.examples.cibSevenLabel`,detail:`app.toolWindow.examples.cibSevenDetail`},flowable:{label:`app.toolWindow.examples.flowableLabel`,detail:`app.toolWindow.examples.flowableDetail`},activiti:{label:`app.toolWindow.examples.activitiLabel`,detail:`app.toolWindow.examples.activitiDetail`}};function Ri(e){let n=Li[e];return{label:t(n.label),detail:t(n.detail)}}function zi(e){let t=l(e)?.family;return t===`camunda-8`?`JOB_TYPE`:t===`camunda-7`?`TOPIC`:null}function Bi(e,n){return t(`app.toolWindow.count.${n}s`,{count:e})}function Vi(e){return e.slice(e.lastIndexOf(`.`)+1)}function Hi(e){return e?e.endsWith(`Event`)?`event`:e.endsWith(`Gateway`)?`gateway`:`task`:`task`}function Ui(e){let t=e.toLowerCase();return t.endsWith(`.dmn`)?`decision`:t.endsWith(`.form`)?`form`:`process`}function Wi(e){switch(e){case`JOB_TYPE`:return t(`app.toolWindow.kind.jobType`);case`TOPIC`:return t(`app.toolWindow.kind.topic`);case`JAVA_CLASS`:return t(`app.toolWindow.kind.javaClass`);case`BEAN`:return t(`app.toolWindow.kind.bean`)}}function Gi(e){let t=e.split(`
|
|
844
|
+
`).map(e=>e.trim()).find(e=>e!==``);if(t)return t.length>60?`${t.slice(0,59)}…`:t}function Ki(e){return e===`sequenceFlow`?`flow`:Hi(e)}function qi(e){return Math.round(e*100)}function Ji(e){switch(e){case`ready`:return t(`app.toolWindow.migrationStatus.ready`);case`converts`:return t(`app.toolWindow.migrationStatus.converts`);case`needs-work`:return t(`app.toolWindow.migrationStatus.needsWork`);case`blocked`:return t(`app.toolWindow.migrationStatus.blocked`)}}function Yi(e,t){let n=jn(e,t);return n.includes(`/`)?n.slice(0,n.lastIndexOf(`/`)):void 0}function I(e){return e.filter(e=>typeof e==`string`&&e!==``).join(` · `)||void 0}var Xi=class{actions=/* @__PURE__ */ new Map;next=0;input;constructor(e){this.input=e}action(e,t,n,r,i){let a=`a${this.next+=1}`;return this.actions.set(a,t),{id:a,label:e,icon:n,keys:r,selected:i}}open(e){let t=`a${this.next+=1}`;return this.actions.set(t,e),t}links(e){return this.input.code?.links.get(Zn(e))}copy(e){return this.action(t(`app.toolWindow.action.copyId`),{type:`copy`,text:e},`copy`,`COPY`)}usages(e,n){return this.input.code?[this.action(t(`app.toolWindow.action.findUsages`),{type:`findUsages`,subjects:e,title:n},`find`,`FIND_USAGES`)]:[]}testLinks(e,n){return e.length===0?[]:[this.action(t(`app.toolWindow.action.runTests`),{type:`runTests`,handles:e,title:n,debug:!1},`run`),this.action(t(`app.toolWindow.action.debugTests`),{type:`runTests`,handles:e,title:n,debug:!0},`debug`)]}deploy(e,n,r){return this.action(t(`app.toolWindow.action.deploy`),{type:`deploy`,paths:e,profile:n,confirm:r},`deploy`)}model(e){return this.input.files.find(t=>t.path===e)?.model}usageNode(e,t,n){let r=this.model(e),i=r?.processes.find(e=>e.id===t.processId);return{id:`use:${e}#${t.id}:${n??``}`,label:t.label,detail:I([n,i?.label,M(e)]),icon:Hi(t.type),open:this.open({type:`reveal`,path:e,elementId:t.id}),actions:[...r?this.usages(nr(r,t.id),t.label):[],this.copy(t.id)]}}scriptsOf(e,n){let r=e.model.scripts.filter(e=>e.processId===n);if(r.length===0)return[];let i=r.length<=12?`ALWAYS`:`NONE`;return[{id:`scripts:${e.path}#process:${n}`,label:t(`app.toolWindow.section.scripts`),detail:Bi(r.length,`script`),icon:`script`,expand:i,children:Pi(r).map(t=>this.scriptNode(e,t,i))}]}scriptNode(e,t,n){if(t.kind===`folder`)return this.scriptFolder(e,t,n);let[r]=t.sites,i=`scripts:${e.path}#${t.elementId}`;return t.sites.length>1?{id:i,label:r.name,detail:I([t.sharedLabel&&t.elementId,Bi(t.sites.length,`script`)]),icon:Ki(r.type),expand:n,actions:[this.copy(t.elementId)],children:t.sites.map(t=>this.scriptSlot(e,t))}:this.scriptSite(e,r,t,i)}scriptFolder(e,t,n){let r=e.model.elements.find(e=>e.id===t.id)?.label??t.id;return{id:`scripts:${e.path}#container:${t.id}`,label:r,detail:Bi(t.count,`script`),icon:`folder`,expand:n,children:t.children.map(t=>this.scriptNode(e,t,n))}}scriptSite(e,t,n,r){return{id:r,label:t.name,detail:I([n.sharedLabel&&t.slot.elementId,ki(t.slot.owner,t),t.language,Gi(t.value)]),icon:Ki(t.type),open:this.open({type:`script`,path:e.path,slot:t.slot}),actions:[this.copy(t.slot.elementId)]}}scriptSlot(e,t){let{slot:n}=t;return{id:`scripts:${e.path}#${n.elementId}#${n.owner}#${n.index}`,label:ki(t.slot.owner,t),detail:I([t.language,Gi(t.value)]),icon:`script`,open:this.open({type:`script`,path:e.path,slot:n})}}coverageOf(e,t,n){let r=this.input.coverage.get(e),i=n?r?.tests.get(n):r?.all;if(!i)return null;let a=Gn(i,t.elements.filter(t=>t.processId===e));return a===null?null:qi(a)}testNode(e,t,n=Vi(e.declaration??e.label)){return{id:`test:${e.declaration??e.handle}:${n}`,label:n,detail:t,icon:`test`,open:this.open({type:`openCode`,handles:[e.handle],title:n}),actions:this.testLinks([e.handle],n)}}debugSection(){let e=this.input.debug;if(e.length===0)return null;let n=/* @__PURE__ */ new Set;return{id:`debug`,label:t(`app.toolWindow.section.debug`),detail:e[0].source,icon:`debug`,expand:`ALWAYS`,children:e.flatMap(e=>{let r=this.model(e.path);return[...e.current,...e.active].map((e,t)=>({id:e,number:t})).filter(({id:t},r,i)=>{let a=`debug:${e.path}#${t}`;return!n.has(a)&&(n.add(a),i.findIndex(e=>e.id===t)===r)}).map(({id:n,number:i})=>{let a=r?.elements.find(e=>e.id===n),o=r?.processes.find(e=>e.id===a?.processId),s=i<e.current.length;return{id:`debug:${e.path}#${n}`,label:t(s?`app.toolWindow.debug.pausedAt`:`app.toolWindow.debug.activeAt`,{name:a?.label??n}),detail:I([o?.label,e.instance&&t(`app.toolWindow.detail.instance`,{instance:e.instance}),M(e.path)]),icon:s?`paused`:`active`,open:this.open({type:`reveal`,path:e.path,elementId:n}),actions:[this.copy(n)]}})})}}processes(){let e=this.input.files.flatMap(e=>e.model.processes.map(t=>({file:e,process:t}))),n=new Map(e.map(e=>[e.process.id,e]));return{id:`processes`,label:t(`app.toolWindow.section.processes`),detail:String(e.length),icon:`process`,children:e.map(({file:e,process:r})=>{let i={kind:`PROCESS`,value:r.id},a=(this.links(i)??[]).filter(e=>e.test),o=this.coverageOf(r.id,e.model),s=e.model.calls.filter(t=>e.model.elements.find(e=>e.id===t.elementId)?.processId===r.id),c=this.input.files.flatMap(e=>e.model.calls.filter(e=>e.calledProcessId===r.id).map(t=>({other:e,call:t})));return{id:`process:${e.path}#${r.id}`,label:r.label,detail:I([r.id!==r.label&&r.id,M(e.path),a.length>0&&Bi(a.length,`test`),o!==null&&t(`app.toolWindow.detail.percentCovered`,{percent:o})]),icon:`process`,open:this.open({type:`reveal`,path:e.path}),actions:[...this.usages([i],r.label),...a.length>0?this.testLinks(a.map(e=>e.handle),r.label):[],this.deploy([e.path]),this.copy(r.id)],children:[...a.map(n=>{let i=this.coverageOf(r.id,e.model,n.declaration);return this.testNode(n,I([t(`app.toolWindow.detail.test`),i!==null&&`${i}%`]))}),...s.map(r=>{let i=n.get(r.calledProcessId),a=e.model.elements.find(e=>e.id===r.elementId);return{id:`calls:${e.path}#${r.elementId}`,label:t(`app.toolWindow.detail.calls`,{name:i?.process.label??r.calledProcessId}),detail:i?a?.label:t(`app.toolWindow.detail.notInProject`),icon:`calls`,warning:!i,open:this.open(i?{type:`reveal`,path:i.file.path}:{type:`reveal`,path:e.path,elementId:r.elementId})}}),...c.map(({other:e,call:n})=>{let r=e.model.elements.find(e=>e.id===n.elementId),i=e.model.processes.find(e=>e.id===r?.processId);return{id:`calledBy:${e.path}#${n.elementId}`,label:t(`app.toolWindow.detail.calledBy`,{name:i?.label??M(e.path)}),detail:r?.label,icon:`calledBy`,open:this.open({type:`reveal`,path:e.path,elementId:n.elementId})}}),...this.scriptsOf(e,r.id)]}})}}tests(){if(!this.input.code?.precise)return null;let e=/* @__PURE__ */ new Map;this.input.files.forEach(({path:t,model:n})=>n.processes.forEach(r=>{(this.links({kind:`PROCESS`,value:r.id})??[]).filter(e=>e.test).forEach(i=>{let a=i.declaration??i.label,o=e.get(a)??{link:i,uses:[]};o.uses.push({path:t,model:n,processId:r.id,label:r.label}),e.set(a,o)})}));let n=/* @__PURE__ */ new Map;[...e.keys()].forEach(e=>{let r=e.includes(`.`)?e.slice(0,e.lastIndexOf(`.`)):t(`app.toolWindow.detail.testGroup`);n.set(r,[...n.get(r)??[],e])});let r=[...e.values()].map(e=>e.link.handle);return{id:`tests`,label:t(`app.toolWindow.section.tests`),detail:String(e.size),icon:`codeTests`,actions:this.testLinks(r,t(`app.toolWindow.title.theProcessTests`)),children:[...n].map(([t,n])=>({id:`testClass:${t}`,label:t,detail:Bi(n.length,`test`),icon:`class`,actions:this.testLinks(n.flatMap(t=>e.get(t)?.link.handle??[]),t),children:n.flatMap(t=>{let n=e.get(t);if(!n)return[];let r=n.uses.map(e=>{let n=this.coverageOf(e.processId,e.model,t);return n===null?e.label:`${e.label} ${n}%`}).join(`, `);return[this.testNode(n.link,r)]})}))}}workers(){let e=/* @__PURE__ */ new Map;this.input.files.forEach(({path:t,model:n})=>n.workers.forEach(r=>{let i=`${r.kind}:${r.value}`,a=n.elements.find(e=>e.id===r.elementId),o=e.get(i)??{kind:r.kind,value:r.value,uses:[],paths:/* @__PURE__ */ new Set};o.paths.add(t),a&&o.uses.push({path:t,element:a}),e.set(i,o)}));let n=new Map([...e].map(([e,t])=>[e,this.links({kind:Mn(t.kind),value:t.value})?.filter(e=>e.implements&&!e.test)])),r=[...n.values()].some(e=>(e?.length??0)>0),i=this.workerGroups([...e.values()]),a=this.input.workersOnEngine??null,o=(a?.checks??[]).flatMap(e=>e.check.problem?[`${e.where}: ${e.check.problem}`]:[]),s=new Set(i.map(e=>e.where));return{id:`workers`,label:t(`app.toolWindow.section.workers`),detail:I([String(e.size),a&&t(`app.toolWindow.detail.checkedAt`,{where:a.at})]),icon:`worker`,warning:o.length>0,tooltip:o.join(`
|
|
845
|
+
`)||void 0,actions:i.length>0?[this.action(s.size===1?t(`app.toolWindow.action.checkWorkersOn`,{where:[...s][0]}):t(`app.toolWindow.action.checkWorkersOnEngines`),{type:`checkWorkers`,groups:i},`find`)]:[],children:[...e].map(([e,i])=>{let o=n.get(e),s=i.kind===`JAVA_CLASS`&&i.value.includes(`.`)?i.value.slice(0,i.value.lastIndexOf(`.`)):null,c={kind:Mn(i.kind),value:i.value},l=r&&er(c)&&o!==void 0&&o.length===0,u=o&&o.length>0?{type:`openCode`,handles:o.map(e=>e.handle),title:t(`app.toolWindow.title.implementationsOf`,{name:i.value})}:null,d=(a?.checks??[]).flatMap(e=>{if(zi(e.engine)!==i.kind)return[];let t=e.check.statuses.get(i.value);return t?[{...t,where:e.where}]:[]}),f=d.filter(e=>e.waiting),p=d.length>1?d.map(e=>`${e.where}: ${e.text}`).join(`; `):d[0]?.text,m=l?t(`app.toolWindow.detail.nothingHandlesIt`):f.length>0?f.map(e=>t(`app.toolWindow.detail.onWhere`,{where:e.where,text:e.text})).join(`
|
|
846
|
+
`):void 0;return{id:`worker:${e}`,label:s?i.value.slice(s.length+1):i.value,detail:I([Wi(i.kind),s,Bi(i.uses.length,`task`),l&&t(`app.toolWindow.detail.noImplementation`),p]),icon:`worker`,warning:l||f.length>0,tooltip:m,open:u?this.open(u):void 0,actions:[...u?[this.action(t(`app.toolWindow.action.goToImplementation`),u,`implementation`,`GO_TO_IMPLEMENTATION`)]:[],...this.contractOf(i.value)?[this.action(t(`app.toolWindow.action.createElementTemplate`),{type:`workerTemplate`,value:i.value},`implementation`)]:[],...this.usages([c],i.value),this.copy(i.value)],children:[...(o??[]).map(n=>({id:`implementation:${e}:${n.label}`,label:n.label,detail:t(`app.toolWindow.detail.implementation`),icon:n.icon===`METHOD`?`method`:n.icon===`CLASS`?`class`:`file`,open:this.open({type:`openCode`,handles:[n.handle],title:n.label})})),...i.uses.map(e=>this.usageNode(e.path,e.element))]}})}}contractOf(e){return(this.input.contracts??[]).find(t=>t.value===e)??null}templatesNode(){let e=this.input.templates??[];if(e.length===0)return null;let n=e.filter(e=>e.drift!==null).length;return{id:`templates`,label:t(`app.toolWindow.section.templates`),detail:I([Bi(e.length,`template`),n>0&&t(`app.toolWindow.detail.outOfStep`,{number:n})]),icon:`form`,warning:n>0,tooltip:n>0?t(`app.toolWindow.tooltip.templatesOutOfStep`):void 0,children:e.map(({path:e,template:t,drift:n})=>{let r=this.contractOf(t.elementType?.[`zeebe:taskDefinition`]??t.elementType?.[`camunda:topic`]??``);return{id:`template:${e}`,label:vi(t,e),detail:I([e.split(`/`).pop(),r&&`${r.file.split(`/`).pop()}:${r.line}`]),icon:`form`,warning:n!==null,tooltip:n?gi(n):void 0,open:this.open({type:`reveal`,path:e}),actions:Fi().map(([e,n])=>this.action(e,{type:`templateWorker`,id:t.id,language:n,target:`8.8`},`migration`))}})}}variables(){let e=this.input.targets.filter(e=>e.kind===`VARIABLE`);if(e.length===0)return null;let n=/* @__PURE__ */ new Map;e.forEach(e=>n.set(e.value,[...n.get(e.value)??[],e]));let r=new Set(e.filter(e=>e.writes).map(e=>e.value)),i=this.input.code?.precise===!0,a=[...n.keys()].sort();return{id:`variables`,label:t(`app.toolWindow.section.variables`),detail:String(a.length),icon:`variable`,children:a.map(e=>{let a=n.get(e)??[],o=i?this.links({kind:`VARIABLE`,value:e}):void 0,s=r.has(e)||(o??[]).some(e=>e.implements),c=a.some(e=>!e.writes),l=!s&&c?Jn(e,[...r]):null,u=e=>new Set(a.filter(t=>t.writes===e).map(e=>e.elementId)).size;return{id:`variable:${e}`,label:e,detail:I([u(!0)>0&&t(`app.toolWindow.detail.setBy`,{number:u(!0)}),u(!1)>0&&t(`app.toolWindow.detail.readBy`,{number:u(!1)}),o!==void 0&&o.length>0&&t(`app.toolWindow.detail.inCode`,{number:o.length}),!s&&c&&o!==void 0&&!l&&t(`app.toolWindow.detail.neverSet`),l&&t(`app.toolWindow.detail.setAs`,{name:l})]),icon:`variable`,warning:!!l,tooltip:l?t(`app.toolWindow.tooltip.variableTypo`,{name:e,typo:l}):void 0,actions:[...this.usages([{kind:`VARIABLE`,value:e}],e),this.copy(e)],children:[...a.map(n=>({id:`variableUse:${e}:${n.path}#${n.elementId}:${n.writes}:${n.where}`,label:n.label,detail:I([n.writes?t(`app.toolWindow.detail.sets`):t(`app.toolWindow.detail.reads`),n.where,M(n.path)]),icon:Hi(n.elementType),open:this.open({type:`reveal`,path:n.path,elementId:n.elementId})})),...(o??[]).map(n=>({id:`variableCode:${e}:${n.handle}`,label:n.label,detail:n.test?t(`app.toolWindow.detail.test`):n.implements?t(`app.toolWindow.detail.setsInCode`):t(`app.toolWindow.detail.readsInCode`),icon:n.icon===`METHOD`?`method`:n.icon===`CLASS`?`class`:`file`,open:this.open({type:`openCode`,handles:[n.handle],title:n.label})}))]}})}}messages(){let e=this.input.files.flatMap(({path:e,model:t})=>t.messageUses.flatMap(n=>{let r=t.messages.find(e=>e.id===n.messageId),i=t.elements.find(e=>e.id===n.elementId);return r&&i?[{name:r.label,path:e,element:i,catches:n.catches}]:[]})),n=[...new Set(this.input.files.flatMap(({model:e})=>e.messages.map(e=>e.label)))];return{id:`messages`,label:t(`app.toolWindow.section.messages`),detail:String(n.length),icon:`message`,children:n.map(n=>{let r=e.filter(e=>e.name===n),i=r.filter(e=>e.catches).length;return{id:`message:${n}`,label:n,detail:t(`app.toolWindow.detail.caughtThrown`,{caught:i,thrown:r.length-i}),icon:`message`,actions:[...this.usages([{kind:`MESSAGE`,value:n}],n),this.copy(n)],children:r.map(e=>this.usageNode(e.path,e.element,e.catches?t(`app.toolWindow.detail.catches`):t(`app.toolWindow.detail.throws`)))}})}}errors(){let e=this.input.files.flatMap(({path:e,model:t})=>t.errors.flatMap(n=>{let r=t.elements.find(e=>e.id===n.elementId);return r&&n.code?[{code:n.code,path:e,element:r,catches:n.catches}]:[]})),n=[...new Set(e.map(e=>e.code))].sort();if(n.length===0)return null;let r=this.input.files.some(({model:e})=>e.errors.some(e=>e.catches&&!e.code)),i=new Map(n.map(e=>[e,(this.links({kind:`ERROR`,value:e})??[]).filter(e=>e.implements)])),a=this.input.code?.precise===!0&&[...i.values()].some(e=>e.length>0);return{id:`errors`,label:t(`app.toolWindow.section.errors`),detail:String(n.length),icon:`error`,children:n.map(n=>{let o=e.filter(e=>e.code===n),s=o.filter(e=>e.catches).length,c=i.get(n)??[],l=!r&&s===0&&c.length>0,u=a&&s>0&&c.length===0&&o.every(e=>e.catches),d=l?t(`app.toolWindow.tooltip.errorUncaught`):u?t(`app.toolWindow.tooltip.errorNeverThrown`):void 0;return{id:`error:${n}`,label:n,detail:I([t(`app.toolWindow.detail.caught`,{number:s}),t(`app.toolWindow.detail.thrown`,{number:o.length-s+c.length}),l&&t(`app.toolWindow.detail.notCaught`),u&&t(`app.toolWindow.detail.neverThrown`)]),icon:`error`,warning:!!d,tooltip:d,actions:[...this.usages([{kind:`ERROR`,value:n}],n),this.copy(n)],children:[...c.map(e=>({id:`thrower:${n}:${e.handle}`,label:e.label,detail:t(`app.toolWindow.detail.throws`),icon:e.icon===`METHOD`?`method`:e.icon===`CLASS`?`class`:`file`,open:this.open({type:`openCode`,handles:[e.handle],title:e.label})})),...o.map(e=>this.usageNode(e.path,e.element,e.catches?t(`app.toolWindow.detail.catches`):t(`app.toolWindow.detail.throws`)))]}})}}decisions(){let e=this.input.files.flatMap(({path:e,model:t})=>t.decisions.map(t=>({path:e,decision:t}))),n=this.input.files.flatMap(({path:e,model:t})=>t.decisionUses.flatMap(n=>{let r=t.elements.find(e=>e.id===n.elementId);return r?[{path:e,element:r,decisionId:n.decisionId}]:[]})),r=new Set(e.map(e=>e.decision.id)),i=[...new Set(n.map(e=>e.decisionId).filter(e=>!r.has(e)))];return{id:`decisions`,label:t(`app.toolWindow.section.decisions`),detail:String(e.length),icon:`decision`,children:[...e.map(({path:e,decision:t})=>({id:`decision:${e}#${t.id}`,label:t.label,detail:t.id,icon:`decision`,open:this.open({type:`reveal`,path:e}),actions:[...this.usages([{kind:`DECISION`,value:t.id}],t.label),this.copy(t.id)],children:n.filter(e=>e.decisionId===t.id).map(e=>this.usageNode(e.path,e.element))})),...i.map(e=>({id:`decisionMissing:${e}`,label:e,detail:t(`app.toolWindow.detail.notInProject`),icon:`decision`,warning:!0,actions:[this.copy(e)],children:n.filter(t=>t.decisionId===e).map(e=>this.usageNode(e.path,e.element))}))]}}forms(){let e=this.input.files.filter(({path:e})=>e.toLowerCase().endsWith(`.form`)),n=this.input.files.flatMap(({path:e,model:t})=>t.formUses.flatMap(n=>{let r=t.elements.find(e=>e.id===n.elementId);return r?[{path:e,element:r,formId:n.formId,linked:n.linked}]:[]})),r=new Set(e.map(e=>e.model.formId).filter(e=>!!e)),i=[...new Set(n.filter(e=>e.linked&&!r.has(e.formId)).map(e=>e.formId))];return{id:`forms`,label:t(`app.toolWindow.section.forms`),detail:String(e.length),icon:`form`,children:[...e.map(({path:e,model:t})=>({id:`form:${e}`,label:M(e),detail:t.formId&&t.formId!==An(e)?t.formId:void 0,icon:`form`,open:this.open({type:`reveal`,path:e}),actions:t.formId?[this.copy(t.formId)]:[],children:n.filter(e=>e.formId===t.formId).map(e=>this.usageNode(e.path,e.element))})),...i.map(e=>({id:`formMissing:${e}`,label:e,detail:t(`app.toolWindow.detail.notInProject`),icon:`form`,warning:!0,actions:[this.copy(e)],children:n.filter(t=>t.formId===e).map(e=>this.usageNode(e.path,e.element))}))]}}workerGroups(e){let n=/* @__PURE__ */ new Map;return e.forEach(e=>e.paths.forEach(r=>{let i=this.input.fileTargets?.get(r);if(!i?.ready||zi(i.engine)!==e.kind)return;let a=JSON.stringify([i.profile,i.engine,i.url]),o=n.get(a)??{profile:i.profile,resource:r,engine:i.engine,where:i.profile??i.url??t(`app.toolWindow.detail.theEngine`),jobTypes:[]};o.jobTypes.includes(e.value)||o.jobTypes.push(e.value),n.set(a,o)})),[...n.values()]}deployment(){let e=this.input.deploy?.targets??[],n=this.input.files.map(e=>e.path);return{id:`deployment`,label:t(`app.toolWindow.section.deployment`),detail:String(e.length),icon:`deploy`,children:e.map((e,r)=>({id:`profile:${e.profile??``}:${r}`,label:e.profile??t(`app.toolWindow.detail.defaultProfile`),detail:I([e.profile===this.input.deploy?.active&&t(`app.toolWindow.detail.inForce`),e.url??t(`app.toolWindow.detail.noAddress`),e.lastDeploy&&t(`app.toolWindow.detail.lastDeploy`,{when:e.lastDeploy})]),icon:`deploy`,warning:!e.ready,actions:[this.deploy(n,e.profile??void 0,!0)]}))}}fileLeaf(e,t,n){let r=Yi(this.input.root,e.path);return{id:`file:${e.path}`,label:M(e.path),detail:I([n.detail,t&&r]),icon:Ui(e.path),path:e.path,open:this.open({type:`reveal`,path:e.path}),actions:[this.deploy([e.path]),...n.actions??[]],children:n.children}}fileTree(e){if(!this.input.preferences.tree)return this.input.files.map(t=>this.fileLeaf(t,!0,e(t)));let t={name:``,path:``,folders:/* @__PURE__ */ new Map,files:[]};this.input.files.forEach(n=>{let r=jn(this.input.root,n.path).split(`/`).slice(0,-1),i=t;r.forEach(e=>{let t=i.folders.get(e)??{name:e,path:`${i.path}/${e}`,folders:/* @__PURE__ */ new Map,files:[]};i.folders.set(e,t),i=t}),i.files.push(this.fileLeaf(n,!1,e(n)))});let n=e=>{let t=e,r=e.name;for(;t.files.length===0&&t.folders.size===1;)t=[...t.folders.values()][0],r=`${r}/${t.name}`;return{id:`folder:${t.path}`,label:r,icon:`folder`,path:`${this.input.root}${t.path}`,expand:`SINGLE_CHILD`,children:[...[...t.folders.values()].map(n),...t.files]}};return[...[...t.folders.values()].map(n),...t.files]}files(){return{id:`files`,label:t(`app.toolWindow.section.files`),detail:String(this.input.files.length),icon:`folder`,children:this.fileTree(()=>({children:[]}))}}summary(e,n,r){let i=[...n.workers.filter(e=>e.elementId===r.id).map(e=>`${Wi(e.kind)} ${e.value}`),...n.calls.filter(e=>e.elementId===r.id).map(e=>t(`app.toolWindow.detail.calls`,{name:e.calledProcessId})),...n.messageUses.filter(e=>e.elementId===r.id).map(e=>{let r=n.messages.find(t=>t.id===e.messageId)?.label??e.messageId;return e.catches?t(`app.toolWindow.detail.catchesName`,{name:r}):t(`app.toolWindow.detail.throwsName`,{name:r})}),...n.decisionUses.filter(e=>e.elementId===r.id).map(e=>t(`app.toolWindow.detail.decision`,{id:e.decisionId})),...n.formUses.filter(e=>e.elementId===r.id).map(e=>t(`app.toolWindow.detail.form`,{id:e.formId}))];return i.length===0?null:{...this.usageNode(e,r),id:`summary:${e}#${r.id}`,detail:i.join(` · `)}}byFile(){return this.fileTree(e=>{let{path:t,model:n}=e;if(t.toLowerCase().endsWith(`.dmn`))return{children:n.decisions.map(e=>({id:`fileDecision:${t}#${e.id}`,label:e.label,detail:e.id,icon:`decision`,open:this.open({type:`reveal`,path:t}),actions:[this.copy(e.id)]}))};let r=r=>n.elements.filter(e=>e.processId===r).map(e=>this.summary(t,n,e)).filter(e=>e!==null).concat(this.scriptsOf(e,r)),[i,...a]=n.processes;return i&&a.length===0?{children:r(i.id),detail:I([i.label,i.id!==i.label&&i.id]),actions:[this.copy(i.id)]}:{children:n.processes.map(e=>({id:`fileProcess:${t}#${e.id}`,label:e.label,detail:e.id===e.label?void 0:e.id,icon:`process`,open:this.open({type:`reveal`,path:t}),actions:[this.copy(e.id)],children:r(e.id)}))}})}examples(){return this.input.files.length>0?null:{id:`examples`,label:t(`app.toolWindow.section.examples`),detail:t(`app.toolWindow.examples.detail`),icon:`process`,expand:`ALWAYS`,children:$r.map(e=>{let n={type:`createExample`,example:e},r=Ri(e);return{id:`example:${e}`,label:r.label,detail:r.detail,icon:`process`,open:this.open(n),actions:[this.action(t(`app.toolWindow.action.createExample`),n,`file`)]}})}}codeLinks(){return this.input.codeLinks===`locked`?{id:`code-links`,label:t(`app.toolWindow.section.code`),detail:t(`app.toolWindow.codeLinks.detail`),tooltip:t(`app.toolWindow.codeLinks.tooltip`),icon:`worker`,actions:[this.action(t(`app.toolWindow.action.buyOrSignIn`),{type:`unlockCode`},`find`)]}:null}migrationFile(e,n){let r=e.findings.filter(e=>e.severity!==`info`);return{id:`migration:file:${e.path}`,label:M(e.path),detail:I([n,Ji(e.status),I([e.counts.manual>0&&t(`app.toolWindow.detail.toDo`,{number:e.counts.manual}),e.counts.review>0&&t(`app.toolWindow.detail.toCheck`,{number:e.counts.review})])]),icon:Ui(e.path),warning:e.status===`needs-work`||e.status===`blocked`,open:this.open({type:`reveal`,path:e.path}),actions:[this.action(t(`app.toolWindow.action.convertToCamunda8`),{type:`migrationConvert`,paths:[e.path]},`migration`)],children:r.map((n,r)=>({id:`migration:finding:${e.path}#${r}`,label:n.title,detail:I([n.where,n.conversion===`manual`?t(`app.toolWindow.detail.toDoOne`):n.conversion===`review`?t(`app.toolWindow.detail.toCheckOne`):t(`app.toolWindow.detail.converts`)]),tooltip:`${n.detail} ${n.action}`,icon:`task`,warning:n.conversion===`manual`,open:this.open({type:`reveal`,path:e.path,elementId:n.elements[0]}),actions:[this.copy(n.rule)]}))}}migrationCode(e){let n=Ii();return{id:`migration:code:${e.key}`,label:e.kind===`class`?Vi(e.value):e.value,detail:I([e.source?`${e.source.path.split(/[\\/]/).pop()}:${e.source.line}`:t(`app.toolWindow.detail.notInThisProject`),e.role!==`task`&&t(`app.toolWindow.detail.listener`,{event:e.event??``}).trim()]),tooltip:[t(`app.toolWindow.tooltip.becomes`,{what:e.becomes}),...e.notes].join(` `),icon:`worker`,warning:!e.source,...e.source?{open:this.open({type:`reveal`,path:e.source.path})}:{},actions:e.skeleton?n.map(([t,n])=>this.action(t,{type:`migrationWorker`,key:e.key,language:n},`migration`)):[]}}migrationLeads(){let e=this.input.migration;if(!e?.source)return!1;let t=new Set(e.files.map(e=>e.path));return this.input.files.every(e=>t.has(e.path))}migration(){let e=this.input.migration;if(!e?.source)return null;let n=e.totals,r=e.files.map(e=>M(e.path)),i=new Set(r.filter((e,t)=>r.indexOf(e)!==t));return{id:`migration`,label:t(`app.toolWindow.section.migration`),detail:I([Bi(e.files.length,`file`),n[`needs-work`]>0&&t(`app.toolWindow.detail.filesNeedingWork`,{number:n[`needs-work`]}),n.blocked>0&&t(`app.toolWindow.detail.filesBlocked`,{number:n.blocked})]),tooltip:t(`app.toolWindow.tooltip.migration`,{target:e.target}),icon:`migration`,expand:`ALWAYS`,actions:[this.action(t(`app.toolWindow.action.migrationReport`),{type:`migrationReport`},`migration`),this.action(t(`app.toolWindow.action.convertAll`),{type:`migrationConvert`,paths:e.files.map(e=>e.path)},`migration`)],children:[...e.files.map(e=>this.migrationFile(e,i.has(M(e.path))?Yi(this.input.root,e.path):void 0)),...e.code.length>0?[{id:`migration:code`,label:t(`app.toolWindow.section.code`),detail:String(e.code.length),icon:`worker`,children:e.code.map(e=>this.migrationCode(e))}]:[]]}}toolbar(){let e=this.input.files.flatMap(({model:e})=>e.processes.flatMap(e=>(this.links({kind:`PROCESS`,value:e.id})??[]).filter(e=>e.test).map(e=>e.handle)));return[...this.input.code?.precise&&e.length>0?[this.action(t(`app.toolWindow.action.runAllProcessTests`),{type:`runTests`,handles:[...new Set(e)],title:t(`app.toolWindow.title.theProcessTests`),debug:!1},`runAll`)]:[],this.action(t(`app.toolWindow.action.groupByFiles`),{type:`preference`,key:`toolWindowGroupByFiles`,value:!this.input.preferences.groupByFiles},`groupByFiles`,void 0,this.input.preferences.groupByFiles),this.action(t(`app.toolWindow.action.showFolders`),{type:`preference`,key:`toolWindowTree`,value:!this.input.preferences.tree},`folders`,void 0,this.input.preferences.tree)]}};function Zi(e){let t=new Xi(e),n=t.migrationLeads();return{roots:e.preferences.groupByFiles?[t.examples(),...n?[t.migration()]:[],...t.byFile(),t.deployment(),...n?[]:[t.migration()]].filter(e=>e!==null):[t.examples(),t.debugSection(),t.codeLinks(),...n?[t.migration()]:[],t.processes(),t.tests(),t.workers(),t.templatesNode(),t.variables(),t.messages(),t.errors(),t.decisions(),t.forms(),t.deployment(),t.files(),...n?[]:[t.migration()]].filter(e=>e!==null),toolbar:t.toolbar(),actions:t.actions}}const Qi=/* @__PURE__ */ new Set(/* @__PURE__ */ `String.string.str.CharSequence.char.Char.Character.Integer.int.Int.int32.int64.Long.long.Short.short.Byte.byte.Double.double.Float.float.float32.float64.decimal.Decimal.BigDecimal.BigInteger.Number.number.Boolean.boolean.bool.Date.LocalDate.LocalDateTime.LocalTime.OffsetDateTime.ZonedDateTime.Instant.Duration.UUID.Guid.DateTime.DateTimeOffset.TimeSpan.date.datetime.Time`.split(`.`)),$i=/* @__PURE__ */ new Set([`List`,`ArrayList`,`LinkedList`,`Set`,`HashSet`,`LinkedHashSet`,`TreeSet`,`Collection`,`Iterable`,`Array`,`array`,`Optional`,`IList`,`IEnumerable`,`ICollection`,`IReadOnlyList`,`IReadOnlyCollection`,`Sequence`]),ea=/* @__PURE__ */ new Set([`null`,`undefined`,`None`,`nil`,``]);function ta(e,t){let n=[],r=0,i=0;for(let a=0;a<e.length;a+=1){let o=e[a];o===`<`||o===`[`||o===`(`?r+=1:o===`>`||o===`]`||o===`)`?--r:o===t&&r===0&&(n.push(e.slice(i,a)),i=a+1)}return n.push(e.slice(i)),n}function na(e){let t=e.trim().replace(/^readonly\s+/,``).replace(/^[*&]+/,``).replace(/^["']|["']$/g,``).replace(/\?$/,``).trim(),n=t.split(`|`).map(e=>e.trim()).filter(e=>!ea.has(e));return n.length===1?n[0]:n.length===0?``:t}function ra(e){if(e.endsWith(`[]`))return{base:`array`,args:[e.slice(0,-2)]};if(e.startsWith(`[]`))return{base:`array`,args:[e.slice(2)]};let t=/^([A-Za-z_][\w.]*)\s*[<[]([\s\S]*)[>\]]$/.exec(e);return t?{base:t[1],args:ta(t[2],`,`)}:{base:e,args:null}}function ia(e){return{kind:`open`,name:e}}function aa(e,t,n,r){let i=t.get(e);if(!i||n>3||r.includes(e))return ia(e);if(i.kind===`enum`)return{kind:`enum`,name:e,constants:i.constants};if(i.open)return ia(e);let a=i.extends===null?void 0:t.get(i.extends);if(i.extends!==null&&(!a||a.kind!==`class`||a.open||a.extends!==null))return ia(e);let o=i.fields,s=new Set(o.map(e=>e.name)),c=(a?.fields??[]).filter(e=>!s.has(e.name));return{kind:`object`,name:e,fields:[...o,...c].map(i=>({name:i.name,serialised:i.serialised,type:oa(i.type,t,n+1,[...r,e])}))}}function oa(e,t,n=1,r=[]){let i=na(e??``);if(i===``)return ia(``);let{base:a,args:o}=ra(i),s=a.slice(a.lastIndexOf(`.`)+1);return o!==null&&o.length===1&&$i.has(s)?{kind:`collection`,name:s,element:oa(o[0],t,n,r)}:o===null&&Qi.has(s)?{kind:`scalar`,name:s}:aa(s,t,n,r)}function sa(e,t){return e.find(e=>e.name===t)??e.find(e=>/^[A-Z]/.test(e.name)&&e.name.charAt(0).toLowerCase()+e.name.slice(1)===t)}const ca=/* @__PURE__ */ new Set([`input`,`loop element`]);function la(e,t,n,r){return r.wholeProcess?t.elementId===n?ca.has(t.where)||r.includeOwnCode===!0&&t.path!==void 0:!ca.has(t.where)&&Kt(e,t.elementId,n):t.elementId===n&&t.path!==void 0}function ua(e,t,n){let r=t.map(e=>({elementId:e.elementId,where:e.where,type:e.type??null,sample:e.sample??null,path:e.path??null,line:e.line??null,offset:e.offset??null})),i=[...new Set(r.map(e=>e.type))],a=i.filter(e=>e!==null);if(a.length>1)return{name:e,certainty:`ambiguous`,type:null,shape:oa(null,n),writers:r};if(a.length===1&&i.length===1){let t=oa(a[0],n);return{name:e,certainty:t.kind===`open`?`open`:`exact`,type:a[0],shape:t,writers:r}}return{name:e,certainty:`open`,type:null,shape:oa(null,n),writers:r}}function da(e,t,n){let r=new Map(e.types.map(e=>[e.name,e])),i=e.inputs??[],a=e.model.variables.filter(r=>r.writes&&la(e.order,r,t,n));return{variables:[.../* @__PURE__ */ new Set([...a.map(e=>e.name),...n.wholeProcess?i:[]])].sort().map(e=>ua(e,a.filter(t=>t.name===e),r)),startVariablesUnknown:i.length===0}}const fa=/^(serviceTask|sendTask|receiveTask|scriptTask)$/;function pa(e,t,n){let r=t,i=e;for(let e of n){if(e.kind===`index`){if(r.kind!==`collection`)return null;r=r.element,i+=`[]`;continue}if(r.kind!==`object`)return null;let t=sa(r.fields,e.name);if(!t)return{variable:i,field:e.name,type:r.name,fields:r.fields.filter(e=>e.serialised).map(e=>e.name)};if(!t.serialised)return null;r=t.type,i+=`.${e.name}`}return null}function ma(e){let t=e.writers.find(e=>e.path!==null);return t&&t.path!==null?`${t.path}:${t.line??0}`:null}function ha(e){let t={fields:[],names:[]};if(!e.entitled||e.mode===`off`)return t;let{model:n,definitions:r,order:i,types:a,inputs:o,linked:s}=e,c=zt(r),l=e=>c.flows.get(e)?.target??e,u=/* @__PURE__ */ new Map,d=e=>{let t=u.get(e);if(t)return t;let r=new Map(da({model:n,order:i,types:a,inputs:o},e,{wholeProcess:!0}).variables.map(e=>[e.name,e]));return u.set(e,r),r},f=[],p=/* @__PURE__ */ new Set;for(let e of dt(r))for(let t of A(e.expression)){let n=_e(t),r=d(l(e.elementId)).get(n.root);if(!r||r.certainty!==`exact`)continue;let i=pa(n.root,r.shape,n.steps);if(!i)continue;let a=[e.elementId,i.variable,i.field].join(`\0`);p.has(a)||(p.add(a),f.push({elementId:e.elementId,...i,from:ma(r)}))}let m=[];if(e.mode===`names`&&s.size>0){let e=new Set(n.variables.filter(e=>e.writes).map(e=>e.name)),t=new Set(o),r=n.elements.filter(e=>fa.test(e.type)).map(e=>e.id),a=/* @__PURE__ */ new Map;for(let e of n.variables.filter(e=>!e.writes))a.set(e.elementId,/* @__PURE__ */ new Set([...a.get(e.elementId)??[],e.name]));for(let[n,o]of a){let a=l(n);if(!r.some(e=>e!==a&&Kt(i,e,a)&&!s.has(e)))for(let r of o)e.has(r)||t.has(r)||m.push({elementId:n,name:r})}}return{fields:f,names:m}}function ga(e){let t=e?.variables,n=typeof t==`object`&&t&&!Array.isArray(t)?t:{};return{mode:n.check===`off`||n.check===`names`?n.check:`fields`,inputs:Array.isArray(n.inputs)?n.inputs.filter(e=>typeof e==`string`):[]}}function _a(e){return e.fields.length===0?t(`app.code.finding.variableFieldNone`,{variable:e.variable,field:e.field,type:e.type}):t(`app.code.finding.variableField`,{variable:e.variable,field:e.field,type:e.type,fields:e.fields.join(`, `)})}function va(e){return e.from===null?t(`app.code.finding.variableFieldWhereUnknown`):t(`app.code.finding.variableFieldWhere`,{from:e.from})}function ya(e){return t(`app.code.finding.variableUnknown`,{name:e})}function ba(){return t(`app.code.finding.variableUnknownWhere`)}function xa(e,t){let n=ga(t.values);return{...t.codeLinks?e:{...e,fetches:[],implicitJobTypes:[]},variableChecks:{check:n.mode,inputs:n.inputs,entitled:t.entitled}}}const Sa=`JsonIgnore`,Ca=`JsonProperty`,wa=/* @__PURE__ */ new Set([`Data`,`Value`,`Getter`]),Ta=/* @__PURE__ */ new Set([`private`,`protected`]),Ea=/^(get|is)([A-Z]\w*)$/,Da=/* @__PURE__ */ new Set([`Enum`,`StrEnum`,`IntEnum`,`IntFlag`,`Flag`]),Oa=/* @__PURE__ */ new Set([`BaseModel`,`TypedDict`]),ka=/* @__PURE__ */ new Set([`BaseModel`,`TypedDict`,`Enum`,`StrEnum`,`IntEnum`,`IntFlag`,`Flag`,`object`,`Generic`]),Aa=/* @__PURE__ */ new Set([`alias`,`validation_alias`,`serialization_alias`]),ja=/* @__PURE__ */ new Set([`Config`,`model_config`]),Ma=/^(?:typing\.)?ClassVar\b/,Na=/(?:^|\s)json:"([^"]*)"/,Pa=/^I[A-Z]/;function Fa(e){let t=/* @__PURE__ */ new Map;for(let n of e)for(let e of Ia(n))t.set(e.name,[...t.get(e.name)??[],e]);return[...t].map(([e,t])=>t.length===1?t[0]:{name:e,kind:`class`,fields:[],constants:[],extends:null,open:!0})}function Ia(e){return e.declarations.flatMap(t=>{let n=La(t,e.language);return n?[n]:[]})}function La(e,t){return t===`java`||t===`kotlin`?Ua(e,t===`kotlin`):t===`typescript`||t===`javascript`?Wa(e):t===`python`?Ga(e):t===`go`?Ka(e):t===`csharp`?qa(e):null}function Ra(e){return e.split(`.`).pop()??e}function za(e,t){return e.some(e=>Ra(e.name)===t)}function Ba(e,t){return e.find(e=>Ra(e.name)===t)?.arguments.find(e=>e.name===null||e.name===`value`)?.value??void 0}function Va(e){return e.charAt(0).toLowerCase()+e.slice(1)}function Ha(e){let t=/* @__PURE__ */ new Map;for(let n of e){if(n.kind!==`method`||n.arity!==0||n.type===`void`||n.modifiers.includes(`static`)||!n.modifiers.includes(`public`))continue;let e=Ea.exec(n.name);e&&t.set(Va(e[2]),n.type)}return t}function Ua(e,t){if(e.kind===`interface`)return null;if(e.kind===`enum`)return{name:e.name,kind:`enum`,fields:[],constants:e.constants,extends:null,open:!1};let n=e.annotations.some(e=>wa.has(Ra(e.name))),r=t?/* @__PURE__ */ new Map:Ha(e.members),i=[],a=/* @__PURE__ */ new Set;for(let o of e.members){if(o.kind!==`parameter`&&o.kind!==`field`)continue;let e=t?Xa(o,n,r):Ya(o,n,r);e!==null&&(i.push(e),a.add(e.name))}for(let[e,t]of r)a.has(e)||i.push({name:e,type:t,serialised:!0});let o=e.supertypes,s=e.kind===`class`&&!t?o.find(e=>e.relation===`extends`):void 0,c=e.generic||e.members.some(e=>e.annotations.some(e=>Ra(e.name)===`JsonAny`))||t&&o.length>0;return{name:e.name,kind:`class`,fields:i,constants:[],extends:s?Ra(s.name):null,open:c}}function Wa(e){if(e.kind===`enum`)return{name:e.name,kind:`enum`,fields:[],constants:e.constants,extends:null,open:!1};let t=e.members.flatMap(e=>e.kind===`field`||e.kind===`parameter`?[{name:e.name,type:e.type,serialised:!e.modifiers.includes(`static`)&&!e.name.startsWith(`#`)}]:[]),n=e.supertypes.filter(e=>e.relation===`extends`).map(e=>Ra(e.name)),r=e.generic||n.length>1||e.members.some(e=>e.kind===`index`||e.kind===`accessor`);return{name:e.name,kind:`class`,fields:t,constants:[],extends:n.length===1?n[0]:null,open:r}}function Ga(e){let t=e.supertypes.map(e=>Ra(e.name));if(t.some(e=>Da.has(e)))return{name:e.name,kind:`enum`,fields:[],constants:e.constants,extends:null,open:!1};if(!e.annotations.some(e=>Ra(e.name)===`dataclass`)&&!t.some(e=>Oa.has(e)))return null;let n=t.filter(e=>!ka.has(e)),r=e.members.flatMap(e=>e.kind===`field`&&e.type!==null&&!Ma.test(e.type)?[{name:e.name,type:e.type,serialised:!0}]:[]),i=n.length>1||e.members.some(e=>e.kind===`config`&&ja.has(e.name)||e.kind===`method`&&e.name===`__init__`)||e.members.some(e=>e.annotations.some(e=>e.arguments.some(e=>e.name!==null&&Aa.has(e.name))));return{name:e.name,kind:`class`,fields:r,constants:[],extends:n.length===1?n[0]:null,open:i}}function Ka(e){let t=e.members.flatMap(e=>{if(e.kind!==`field`)return[];let t=Na.exec(e.tag??``)?.[1],n=t!==void 0&&t!==`-`?t.split(`,`)[0]:``;return[{name:n===``?e.name:n,type:e.type,serialised:/^[A-Z]/.test(e.name)&&t!==`-`}]});return{name:e.name,kind:`class`,fields:t,constants:[],extends:null,open:e.generic||e.members.some(e=>e.kind===`embedded`)}}function qa(e){if(e.kind===`enum`)return{name:e.name,kind:`enum`,fields:[],constants:e.constants,extends:null,open:!1};let t=e.supertypes.map(e=>Ra(e.name)).filter(e=>!Pa.test(e)),n=e.members.flatMap(e=>{if(e.kind!==`field`&&e.kind!==`parameter`)return[];let t=e.kind===`parameter`||e.modifiers.includes(`public`)&&!e.modifiers.includes(`static`);return[{name:Ba(e.annotations,`JsonPropertyName`)??e.name,type:e.type,serialised:t&&!za(e.annotations,`JsonIgnore`)}]}),r=e.generic||t.length>1||e.members.some(e=>e.annotations.some(e=>Ra(e.name)===`JsonExtensionData`));return{name:e.name,kind:`class`,fields:n,constants:[],extends:t.length===1?t[0]:null,open:r}}function Ja(e){return Ba(e.annotations,Ca)??e.name}function Ya(e,t,n){let r=za(e.annotations,Sa),i=za(e.annotations,Ca);if(e.kind===`parameter`)return{name:Ja(e),type:e.type,serialised:!r};let a=e.modifiers.includes(`static`),o=e.modifiers.includes(`transient`),s=e.modifiers.includes(`public`),c=!a&&!o&&!r&&(s||n.has(e.name)||t||i);return{name:Ja(e),type:e.type,serialised:c}}function Xa(e,t,n){let r=za(e.annotations,Sa),i=e.modifiers.some(e=>Ta.has(e)),a=za(e.annotations,Ca);if(e.kind===`parameter`)return{name:Ja(e),type:e.type,serialised:!r&&!i};let o=!e.modifiers.includes(`const`)&&!r&&(!i||n.has(e.name)||t||a);return{name:Ja(e),type:e.type,serialised:o}}var Za=class{placed;constructor(e,t){this.placed=e.map((e,n)=>({item:e,order:n,start:t(e)})).sort((e,t)=>e.start-t.start||e.order-t.order)}inOrder(e,t){return this.between(e,t).sort((e,t)=>e.order-t.order).map(e=>e.item)}byPosition(e,t){return this.between(e,t).map(e=>e.item)}between(e,t){let n=[];for(let r=this.firstFrom(e);r<this.placed.length&&this.placed[r].start<=t;r+=1)n.push(this.placed[r]);return n}firstFrom(e){let t=0,n=this.placed.length;for(;t<n;){let r=t+n>>>1;this.placed[r].start<e?t=r+1:n=r}return t}};const Qa=/* @__PURE__ */ new WeakMap;function L(e){let t=Qa.get(e);return t===void 0&&(t=to(e),Qa.set(e,t)),t}function $a(e,t){let n=/* @__PURE__ */ new Map;for(let r of e){let e=t(r);n.has(e)||n.set(e,r)}return n}function eo(e,t){return e.from===t.from&&e.to===t.to}function to(e){let t=[...e.accesses,...e.innerAccesses];return{callsBySpan:new Za(e.calls,e=>e.span.from),callsAt:new Za(e.calls,e=>e.at),constructionsBySpan:new Za(e.constructions,e=>e.span.from),callablesBySpan:new Za(e.callables,e=>e.span.from),callablesAt:new Za(e.callables,e=>e.at),parametersAt:new Za(e.callables.flatMap(e=>e.parameters),e=>e.at),localsAt:new Za(e.locals,e=>e.at),membersAt:new Za(e.declarations.flatMap(e=>e.members),e=>e.at),accessesAt:new Za(t,e=>e.at),accessesBySpan:new Za(t,e=>e.span.from),returnsAt:new Za(e.returns,e=>e.at),pairsByObject:no(e.pairs,e=>e.object),callableNamed:$a(e.callables,e=>e.name),enclosingCall:ro(e.calls.flatMap(e=>e.arguments.map(t=>({owner:e,span:t.span}))),e.calls),enclosingReturn:ro(e.returns.map(e=>({owner:e,span:e.span})),e.calls)}}function no(e,t){let n=/* @__PURE__ */ new Map;for(let r of e){let e=t(r),i=n.get(e);i===void 0?n.set(e,[r]):i.push(r)}return n}function ro(e,t){let n=[...e].sort((e,t)=>e.span.from-t.span.from||t.span.to-e.span.to),r=[...t].sort((e,t)=>e.span.from-t.span.from),i=[],a=/* @__PURE__ */ new Map,o=0;for(let e of r){let t=e.span.from;for(;o<n.length&&n[o].span.from<=t;){let e=n[o];for(;i.length>0&&i[i.length-1].span.to<=e.span.from;)i.pop();i.push(e),o+=1}for(;i.length>0&&i[i.length-1].span.to<=t;)i.pop();for(let t=i.length-1;t>=0;--t){let n=i[t].span;if(n.from<=e.span.from&&e.span.to<=n.to){a.set(e,i[t].owner);break}}}return a}function io(e,t){let n=1,r=Math.min(Math.max(t,0),e.length);for(let t=e.indexOf(`
|
|
847
|
+
`);t>=0&&t<r;t=e.indexOf(`
|
|
848
|
+
`,t+1))n+=1;return n}function ao(e){let t=[0];for(let n=e.indexOf(`
|
|
849
|
+
`);n>=0;n=e.indexOf(`
|
|
850
|
+
`,n+1))t.push(n+1);return n=>{let r=Math.min(Math.max(n,0),e.length),i=0,a=t.length-1;for(;i<a;){let e=i+a+1>>1;t[e]<=r?i=e:a=e-1}return i+1}}function oo(e){let t=[0];for(let n=e.indexOf(`
|
|
851
|
+
`);n>=0;n=e.indexOf(`
|
|
852
|
+
`,n+1))t.push(n+1);return t}function so(e,t){let n=0,r=e.length-1;for(;n<r;){let i=n+r+1>>1;e[i]<=t?n=i:r=i-1}return n+1}const co={from:0,to:1/0},lo=/* @__PURE__ */ new Set([`java`,`kotlin`,`groovy`,`scala`]),uo=/* @__PURE__ */ new Set([`JobWorker`,`ZeebeWorker`]),fo=/* @__PURE__ */ new Set([`Component`,`Service`,`Named`,`Repository`,`Controller`]),po=/* @__PURE__ */ new Set([...fo,`RestController`]),mo=/* @__PURE__ */ new Set([`ExternalTaskSubscription`]),ho=/* @__PURE__ */ new Map([[`Variable`,`@Variable`],[`VariablesAsType`,`@VariablesAsType`]]),go=/* @__PURE__ */ new Set([`getVariable`,`getVariableLocal`]),_o=/* @__PURE__ */ new Set([`get`,`getOrDefault`]),vo=/* @__PURE__ */ new Set([`setVariable`,`setVariableLocal`]),yo=/* @__PURE__ */ new Map([[`Map.of`,`arguments`],[`Map.ofEntries`,`entries`],[`Collections.singletonMap`,`arguments`],[`.mapOf`,`pairs`],[`.Map`,`pairs`]]),bo=/* @__PURE__ */ new Set([`complete`,`CompleteJob`,`CompleteAsyncJob`,`completeJob`,`complete_async`]),xo=/* @__PURE__ */ new Set([`variables`,`setVariables`,`SetVariables`,`withVariables`,`Variables`]),So=/* @__PURE__ */ new Set([`worker`,`task`]),Co=/* @__PURE__ */ new Set([`complete`,`completeJob`]),wo=/* @__PURE__ */ new Set([`createWorker`,`subscribe`]),To=/* @__PURE__ */ new Map([[`SubscribeJobType`,`JOB_TYPE`],[`JobType`,`JOB_TYPE`],[`TopicName`,`TOPIC`]]),Eo=/* @__PURE__ */ new Set([`Variables`,`VariablesMap`]),Do=/* @__PURE__ */ new Map([[`TopicName`,`TOPIC`],[`TaskType`,`JOB_TYPE`],[`JobType`,`JOB_TYPE`]]),Oo=/* @__PURE__ */ new Set([`CompleteJob`,`CompleteAsyncJob`]),ko=/* @__PURE__ */ new Set([`Variables`]),Ao=/* @__PURE__ */ new Set([`Value`]),jo=/^[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*$/,Mo=/[A-Za-z_]\w*/g,No=(e,t)=>`${e}:${t}`,Po=e=>e.split(`.`).pop()??e,Fo=e=>e.charAt(0).toLowerCase()+e.slice(1),R=(e,t)=>e.from<=t&&t<e.to,Io=e=>[...e].sort((e,t)=>e.at-t.at),Lo=e=>Io([...e.accesses,...e.innerAccesses]),Ro=(e,t)=>L(e).accessesAt.byPosition(t.from,t.to),zo=(e,t)=>t===void 0?[]:L(e).pairsByObject.get(t.span.from)??[],Bo=(e,t)=>L(e).callsBySpan.inOrder(t.from,t.from).find(e=>eo(e.span,t)),Vo=(e,t)=>L(e).constructionsBySpan.inOrder(t.from,t.from).find(e=>eo(e.span,t));function z(e,t,n,r,i,a){return e==null||e.trim()===``?[]:[{name:e,writes:t,type:n,where:r,at:i,literal:a??i}]}function Ho(e,t){for(let n of t){let t=e.arguments.find(e=>e.name===n)?.value;if(t!=null)return t}}function Uo(e,t){return t.values===null?t.value===null?Bo(e,t.span)?.arguments.flatMap(e=>e.value??[])??[]:[t.value]:t.values}function Wo(e){return e.receiver===null?null:{from:e.span.from,to:e.span.from+e.receiver.length}}function Go(e,t){let n=Wo(t);return n===null?void 0:Bo(e,n)}function Ko(e,t){let n=Wo(t);return n===null?void 0:L(e).accessesBySpan.inOrder(n.from,n.from).find(e=>eo(e.span,n))}function qo(e,t,n){let r=L(e),i=/* @__PURE__ */ new Set,a=e=>{e!=null&&i.add(e.replace(/^\*/,``))};return r.localsAt.inOrder(t.from,t.to).filter(e=>e.name===n&&R(t,e.at)).forEach(e=>a(e.type??e.initializer?.constructs)),r.parametersAt.inOrder(t.from,t.to).filter(e=>e.name===n&&R(t,e.at)).forEach(e=>a(e.type)),r.membersAt.inOrder(t.from,t.to).filter(e=>(e.kind===`field`||e.kind===`parameter`)&&e.name===n&&R(t,e.at)).forEach(e=>a(e.type)),i.size===1?[...i][0]:null}function Jo(e,t,n){return n==null?null:n.identifier===null?n.constructs:qo(e,t,n.identifier)}function Yo(e){return Po(e?.trim()??``).replace(/\[\]/g,``)}function Xo(e){let t=Fa(e.filter(e=>lo.has(e.language)));return new Map(t.filter(e=>e.kind===`class`).map(e=>[e.name,e.fields.filter(e=>e.serialised)]))}function Zo(e,t){return e.callables.flatMap(n=>{let r=n.annotations.find(e=>uo.has(Po(e.name)));if(r===void 0)return[];let i=Ho(r,[`type`,`taskType`]),a=i??n.name;if(!t.has(No(`JOB_TYPE`,a)))return[];let o=r.arguments.find(e=>e.name===`fetchVariables`);return[{kind:`JOB_TYPE`,value:a,span:n.span,fetch:o===void 0?[]:Uo(e,o),fetchAt:r.at,declared:o!==void 0,implicit:i===void 0?{jobType:a,method:n.name}:void 0,implicitAt:r.at}]})}function Qo(e,t){let n=e.filter(e=>fo.has(Po(e.name))).flatMap(e=>Ho(e,[null,`value`])??[]).at(-1);return n===void 0?e.some(e=>po.has(Po(e.name)))?Fo(t):void 0:n}function $o(e){let t=e.find(e=>mo.has(Po(e.name)));return t===void 0?void 0:Ho(t,[`topicName`,null,`value`])}function es(e,t){return e.declarations.filter(e=>e.kind===`class`||e.kind===`record`).flatMap(n=>{let r=e.package===null?n.name:`${e.package}.${n.name}`;return Fs([...[n.name,r].map(e=>({kind:`CLASS`,value:e})),{kind:`BEAN`,value:Qo(n.annotations,n.name)},{kind:`TOPIC`,value:$o(n.annotations)}].flatMap(({kind:e,value:r})=>r===void 0||!t.has(No(e,r))?[]:[{kind:e,value:r,span:n.span,fetch:[],fetchAt:0,declared:!1,implicitAt:0}]),e=>e.kind)})}function ts(e,t,n){let r=L(e).callablesAt.inOrder(t.from,t.to).filter(e=>R(t,e.at)).flatMap(e=>e.parameters);return Io(r.flatMap(e=>e.annotations.flatMap(t=>{let r=ho.get(Po(t.name));return r===`@Variable`?z(Ho(t,[`name`,`value`,null])??e.name,!1,null,r,t.at):r===`@VariablesAsType`?(n.get(Yo(e.type))??[]).flatMap(e=>z(e.name,!1,e.type,r,t.at)):[]})))}function ns(e,t){let n=L(e),r=n.enclosingCall.get(t);return r!==void 0&&bo.has(r.name)?`complete`:r!==void 0&&xo.has(r.name)?`variables`:n.enclosingReturn.has(t)?`return`:null}function rs(e,t,n){let{arguments:r}=t;return n===`pairs`?r.flatMap(t=>zo(e,t).filter(e=>e.quoted).map(e=>({name:e.key,value:e.value,literal:e.at}))):n===`arguments`?r.flatMap((e,t)=>t%2==0?[{name:e.value,value:r[t+1],literal:e.span.from}]:[]):r.map(t=>{let n=Bo(e,t.span)??Vo(e,t.span);return{name:n?.arguments[0]?.value??null,value:n?.arguments[1],literal:n?.arguments[0]?.span.from}})}function is(e,t,n){return[...n.filter(e=>yo.has(`${Po(e.receiver??``)}.${e.name}`))].sort((e,t)=>e.span.from-t.span.from).flatMap(n=>{let r=ns(e,n);return r===null?[]:rs(e,n,yo.get(`${Po(n.receiver??``)}.${n.name}`)??``).flatMap(i=>z(i.name,!0,Jo(e,t,i.value),r,n.span.from,i.literal))})}function as(e,t,n){let r=L(e),i=/* @__PURE__ */ new Map;for(let e of r.localsAt.inOrder(t.from,t.to).filter(e=>R(t,e.at))){let t=Yo(e.type??e.initializer?.constructs);n.has(t)&&i.set(e.name,t)}for(let e of r.callablesAt.inOrder(t.from,t.to).filter(e=>R(t,e.at)).flatMap(e=>e.parameters))e.annotations.some(e=>Po(e.name)===`VariablesAsType`)&&i.set(e.name,Yo(e.type));return r.returnsAt.inOrder(t.from,t.to).filter(e=>R(t,e.at)).flatMap(e=>{let t=i.get(e.expression?.identifier??``);return(n.get(t??``)??[]).flatMap(t=>z(t.name,!0,t.type,`return`,e.at))})}function os(e,t,n){let r=t.span,i=L(e).callsAt.byPosition(r.from,r.to).filter(e=>R(r,e.at)),a=i.filter(e=>_o.has(e.name)).flatMap(t=>{let n=Go(e,t);return n?.name===`getVariablesAsMap`&&n.arguments.length===0?z(t.arguments[0]?.value,!1,null,`variables`,n.at,t.arguments[0]?.span.from):[]});return[...i.filter(e=>go.has(e.name)).flatMap(e=>z(e.arguments[0]?.value,!1,null,`getVariable`,e.at,e.arguments[0]?.span.from)),...a,...i.filter(e=>vo.has(e.name)).flatMap(t=>z(t.arguments[0]?.value,!0,Jo(e,r,t.arguments[1]),`setVariable`,t.at,t.arguments[0]?.span.from)),...ts(e,r,n),...is(e,r,i),...as(e,r,n)]}function ss(e,t){let n=t.span,r=e=>e!==null&&jo.test(e),i=L(e).returnsAt.inOrder(n.from,n.to).filter(e=>R(n,e.at)).flatMap(t=>{let r=t.expression;if(r===null)return[];let i=zo(e,r),a=Bo(e,r.span);return(i.length>0||a?.name!==`complete_job`?i:zo(e,a.arguments.find(e=>e.name===`variables`))).filter(e=>e.quoted).flatMap(r=>z(r.key,!0,Jo(e,n,r.value),`complete`,t.at,r.at))});return[...Ro(e,n).filter(e=>R(n,e.at)&&r(e.receiver)).flatMap(e=>z(e.key,!1,null,`variables`,e.at,e.keyAt)),...L(e).callsAt.byPosition(n.from,n.to).filter(e=>R(n,e.at)&&e.name===`get`&&r(e.receiver)).flatMap(e=>z(e.arguments[0]?.value,!1,null,`variables`,e.span.from,e.arguments[0]?.span.from)),...i]}function cs(e,t){let n=e.pairs.find(e=>e.key===`taskVariables`&&t.includes(e.object));return n===void 0?null:Uo(e,n.value)}function ls(e,t){let n=Io(e.calls),r=e=>e.arguments.map(e=>e.span.from),i=n=>e.pairs.some(e=>e.object===n.arguments[0]?.span.from&&e.key===`type`&&e.value.value===t),a=i=>n.filter(e=>e.name===i&&e.arguments[0]?.value===t).map(t=>({at:t.at,fetch:cs(e,r(t))}));return[Io(e.pairs).filter(e=>e.key===`taskType`&&e.value.value===t).map(t=>({at:t.at,fetch:cs(e,[t.object])})),n.filter(e=>e.name===`createJobWorker`&&i(e)).map(t=>({at:t.at,fetch:cs(e,r(t))})),...[...wo].map(a)]}function us(e,t){return[...t.values()].flatMap(([{kind:t,value:n}])=>{if(t!==`JOB_TYPE`&&t!==`TOPIC`)return[];let r=ls(e,n).find(e=>e.length>0)?.[0];return r===void 0?[]:[{kind:t,value:n,span:co,fetch:r.fetch??[],fetchAt:r.at,declared:r.fetch!==null,implicitAt:0}]})}function ds(e){let t=Lo(e).filter(e=>e.receiver===`job.variables`),n=Io(e.calls).filter(e=>Co.has(e.name)).flatMap(t=>zo(e,t.arguments[1]).flatMap(n=>z(n.key,!0,Jo(e,co,n.value),`complete`,t.at,n.at)));return[...t.flatMap(e=>z(e.key,!1,null,`variables`,e.at,e.keyAt)),...t.flatMap(e=>z(e.name,!1,null,`variables`,e.at)),...e.locals.filter(e=>e.initializer?.text===`job.variables`).flatMap(e=>z(e.key,!1,null,`variables`,e.at)),...n]}function fs(e,t,n){return L(e).callsBySpan.inOrder(t.span.from,t.span.from).filter(e=>e.name===n&&e.span.from===t.span.from&&e.span.to>t.span.to)}function ps(e){return e?.identifier??e?.reference??null}function ms(e,t,n){let r=ps(t),i=r===null?void 0:L(e).callableNamed.get(r);return i===void 0?n===void 0?t?.span??null:n.span:i.span}function hs(e){return e.callables.flatMap(t=>t.annotations.flatMap(n=>{if(!So.has(Po(n.name)))return[];let r=n.arguments.find(e=>(e.name===`task_type`||e.name===`topic_name`)&&e.value!==null),i=r?.value??null;if(r===void 0||i===null)return[];let a=n.arguments.find(e=>e.name?.includes(`variables`)??!1);return[{kind:r.name===`task_type`?`JOB_TYPE`:`TOPIC`,value:i,valueAt:r.span.from,at:n.at,end:t.span.to,span:t.span,fetch:a===void 0?null:Uo(e,a),contract:!0,handler:t.name}]}))}function gs(e){return Io(e.calls).flatMap(t=>{if(!So.has(t.name))return[];let n=t.arguments.find(e=>(e.name===`task_type`||e.name===`topic_name`)&&e.value!==null),r=fs(e,t,t.name)[0];if(n===void 0||n.value===null||r===void 0)return[];let i=t.arguments.find(e=>e.name?.includes(`variables`)??!1),a=r.arguments[0];return[{kind:n.name===`task_type`?`JOB_TYPE`:`TOPIC`,value:n.value,valueAt:n.span.from,at:t.at,end:r.span.to,span:ms(e,a,r)??co,fetch:i===void 0?null:Uo(e,i),contract:!0,handler:ps(a)}]})}function _s(e){let t=e.arguments.slice(1),n=t.map(e=>e.constructs!==null).lastIndexOf(!0),r=t.slice(n+1).flatMap(e=>e.value??[]);return r.length>0?r:null}function vs(e){return Io(e.calls).flatMap(t=>{let n=To.get(t.name),r=t.arguments[0],i=r?.value??null;if(n===void 0||r===void 0||i===null)return[];let a=fs(e,t,`Handler`)[0],o=t.name===`SubscribeJobType`?t.arguments[1]:a?.arguments[0];return[{kind:n,value:i,valueAt:r.span.from,at:t.at,end:t.span.to,span:ms(e,o,a)??co,fetch:_s(t),contract:!0,handler:ps(o)}]})}function ys(e,t){let n=t.span,r=new Set(L(e).localsAt.inOrder(n.from,n.to).filter(e=>R(n,e.at)&&e.initializer?.text===`job.Variables()`).map(e=>e.name)),i=Ro(e,n).filter(e=>R(n,e.at)).flatMap(t=>{let n=Go(e,t);return n!==void 0&&Eo.has(n.name)&&n.arguments.length===0?z(t.key,!1,null,`variables`,n.at,t.keyAt):r.has(t.receiver)?z(t.key,!1,null,`variables`,t.at,t.keyAt):[]}),a=L(e).callsAt.byPosition(n.from,n.to).filter(e=>R(n,e.at)&&e.name===`Variables`&&(e.arguments[0]?.constructs?.startsWith(`map[`)??!1)).flatMap(t=>zo(e,t.arguments[0]).filter(e=>e.quoted).flatMap(r=>z(r.key,!0,Jo(e,n,r.value),`variables`,t.at,r.at)));return[...i,...a]}function bs(e,t){let n=Io(L(e).callsBySpan.inOrder(t.span.from,t.span.from)).filter(e=>ko.has(e.name)&&e.span.from===t.span.from&&e.span.to>t.span.to);return n.length===0?null:n.flatMap(e=>e.arguments.flatMap(e=>e.value??[]))}function xs(e){let t=Io(e.calls),n=[...e.declarations,...e.callables].flatMap(e=>e.annotations.flatMap(e=>e.arguments)),r=(t,r)=>Io([...n.flatMap(e=>e.name===t&&e.value!==null?[{kind:r,value:e.value,valueAt:e.span.from,at:e.at,end:e.span.to,span:co,fetch:null,contract:!1,handler:null}]:[]),...e.pairs.flatMap(e=>e.key===t&&e.value.value!==null?[{kind:r,value:e.value.value,valueAt:e.value.span.from,at:e.at,end:e.value.span.to,span:co,fetch:null,contract:!1,handler:null}]:[])]),i=(n,r)=>t.flatMap(t=>{let i=t.arguments[0],a=i?.value??null;if(t.name!==n||i===void 0||a===null)return[];let o=fs(e,t,`Handler`)[0];return[{kind:r,value:a,valueAt:i.span.from,at:t.at,end:t.span.to,span:ms(e,o?.arguments[0],o)??co,fetch:bs(e,t),contract:!0,handler:ps(o?.arguments[0])}]});return[...Do].flatMap(([e,t])=>[...r(e,t),...i(e,t)])}function Ss(e,t){let n=t.span,r=t=>ko.has(Ko(e,t)?.name??``),i=L(e).callsAt.byPosition(n.from,n.to).filter(e=>R(n,e.at)&&Oo.has(e.name)).flatMap(t=>zo(e,t.arguments[1]).filter(e=>e.quoted).flatMap(r=>z(r.key,!0,Jo(e,n,r.value),`complete`,t.at,r.at)));return[...Ro(e,n).filter(e=>R(n,e.at)&&r(e)).flatMap(e=>z(e.key,!1,null,`variables`,e.at,e.keyAt)),...L(e).callsAt.byPosition(n.from,n.to).filter(e=>R(n,e.at)&&Ao.has(e.name)&&r(e)).flatMap(e=>z(e.arguments[0]?.value,!1,null,`variables`,e.span.from,e.arguments[0]?.span.from)),...i]}function Cs(e){return Io(e.calls).flatMap(t=>{let n=t.arguments[0],r=n?.value??null;if(t.name!==`jobType`||t.receiver===null||n===void 0||r===null)return[];let i=fs(e,t,`handler`)[0],a=fs(e,t,`fetchVariables`);return[{kind:`JOB_TYPE`,value:r,valueAt:n.span.from,at:t.at,end:t.span.to,span:ms(e,i?.arguments[0],i)??t.span,fetch:a.length===0?null:a.flatMap(e=>e.arguments.flatMap(e=>e.value??[])),contract:!0,handler:ps(i?.arguments[0])}]})}const ws={java:Cs,kotlin:Cs,groovy:Cs,scala:Cs,typescript:()=>[],javascript:()=>[],python:e=>[...hs(e),...gs(e)],go:vs,csharp:xs};function Ts(e){return ws[e.language](e)}function Es(e){return{kind:e.kind,value:e.value,span:e.span,fetch:e.fetch??[],fetchAt:e.at,declared:e.fetch!==null,implicitAt:0}}function Ds(e,t){let n=/* @__PURE__ */ new Set;return Ts(e).flatMap(e=>{let r=No(e.kind,e.value);return!t.has(r)||n.has(r)?[]:(n.add(r),[Es(e)])})}function Os(e,t,n){return Ms[e.language].variables(e,Es(t),n)}const ks={regions:(e,t)=>[...Zo(e,t),...es(e,t),...Ds(e,t)],variables:os},As={regions:us,variables:ds},js={regions:Ds},Ms={java:ks,kotlin:ks,groovy:ks,scala:ks,typescript:As,javascript:As,python:{...js,variables:ss},go:{...js,variables:ys},csharp:{...js,variables:Ss}};function Ns(e,t){let n=new Map(e.map(e=>[e.name,e])),r=/* @__PURE__ */ new Map,i=[...t];for(let e=i.pop();e!==void 0;e=i.pop()){let t=n.get(e);t&&!r.has(e)&&(r.set(e,t),t.fields.forEach(e=>i.push(...e.type?.match(Mo)??[])),t.extends!==null&&i.push(t.extends))}return[...r.values()]}function Ps(e,t){let n=t.flatMap(e=>e?.match(Mo)??[]);return n.length===0?[]:Ns(Fa(e),n)}function Fs(e,t){let n=/* @__PURE__ */ new Set;return e.filter(e=>{let r=t(e);return!n.has(r)&&(n.add(r),!0)})}function Is(e,t){if(t.length===0||e.length===0)return{variables:[],fetches:[],implicitJobTypes:[],types:[]};let n=/* @__PURE__ */ new Map;for(let e of t)n.set(No(e.kind,e.value),[...n.get(No(e.kind,e.value))??[],e]);let r=Xo(e),i=[],a=[],o=[];for(let t of e){let e=Ms[t.language];for(let s of e.regions(t,n)){let c=e.variables(t,s,r),l=so(t.lineStarts,s.fetchAt);for(let{elementId:e}of n.get(No(s.kind,s.value))??[])i.push(...c.map(n=>({elementId:e,name:n.name,writes:n.writes,type:n.type,where:n.where,path:t.path,line:so(t.lineStarts,n.at),offset:n.at}))),a.push({elementId:e,names:s.fetch,declared:s.declared,path:t.path,line:l}),s.implicit&&o.push({elementId:e,jobType:s.implicit.jobType,method:s.implicit.method,path:t.path,line:l,offset:s.implicitAt})}}let s=Fs(i,e=>JSON.stringify([e.elementId,e.name,e.writes,e.where]));return{variables:s,fetches:Fs(a,e=>e.elementId),implicitJobTypes:o,types:Ps(e,s.map(e=>e.type))}}function Ls(e){return[e.kind,e.value,e.file,e.line,e.diagram,e.element??``].join(`\0`)}const Rs=/\.(java|kt|kts|groovy|scala|py|js|mjs|cjs|ts|go|cs)$/,zs=/* @__PURE__ */ new Set([`node_modules`,`build`,`target`,`out`,`dist`,`.git`,`.gradle`,`.idea`,`.penstock`]);function Bs(e,t){switch(t.kind){case`JOB_TYPE`:return e.jobTypes.get(t.value)??[];case`TOPIC`:return e.topics.get(t.value)??[];case`CLASS`:return[e.classes.get(t.value)].filter(e=>!!e);case`BEAN`:return[e.beans.get(t.value)].filter(e=>!!e);default:return[]}}function Vs(e,t){return e.references.get(Zn(t))??[]}const Hs=/[\\/]/,Us=/* @__PURE__ */ new Set([`test`,`tests`,`spec`,`specs`,`__tests__`,`__mocks__`]),Ws=/(?:^|[._-]|[a-z0-9])(?:Test|Tests|Spec|Specs)$/,Gs=/(?:^|[._-])(?:test|tests|spec|specs)(?:[._-]|$)/i;function Ks(e){let t=e.split(Hs),n=(t[t.length-1]??``).replace(/\.[^.]+$/,``);return t.slice(0,-1).some(e=>Us.has(e))||Ws.test(n)||Gs.test(n)}const qs={missing:3,ambiguous:2,bound:1,notApplicable:0},Js=/* @__PURE__ */ new WeakMap;function Ys(e){let t=Js.get(e);if(!t){let n=/* @__PURE__ */ new Map;e.classes.forEach((e,t)=>{let r=n.get(e.file);r?r.push({line:e.line,name:t}):n.set(e.file,[{line:e.line,name:t}])}),n.forEach(e=>e.sort((e,t)=>e.line-t.line)),t={byFile:n},Js.set(e,t)}return t}function Xs(e,t){let n=Ys(e).byFile.get(t.file);if(!n)return null;let r=null;for(let e of n){if(e.line>t.line)break;r=e.name}return r}function Zs(e){return e.slice(e.lastIndexOf(`.`)+1)}function Qs(e,t,n){switch(t){case`JOB_TYPE`:case`TOPIC`:case`CLASS`:case`BEAN`:return Bs(e,{kind:t,value:n});case`MESSAGE`:return Vs(e,{kind:t,value:n});default:return[]}}function $s(e){let t=/* @__PURE__ */ new Set;return e.filter(e=>{let n=`${e.file}#${e.line}`;return!t.has(n)&&(t.add(n),!0)})}function ec(e,t){switch(t){case`JOB_TYPE`:return e.jobTypes.size>0;case`TOPIC`:return e.topics.size>0;case`CLASS`:return e.classes.size>0;case`BEAN`:return e.beans.size>0;default:return!0}}function tc(e,t){let n=t===`JOB_TYPE`?e.jobTypes.keys():t===`TOPIC`?e.topics.keys():t===`CLASS`?e.classes.keys():t===`BEAN`?e.beans.keys():[],r=[];for(let e of n)if(r.push(e),r.length>=2e4)break;return r}var nc=class{index;lists=/* @__PURE__ */ new Map;bySimple=/* @__PURE__ */ new Map;answers=/* @__PURE__ */ new Map;constructor(e){this.index=e}of(e,t){let n=`${e}\u0000${t}`;if(this.answers.has(n))return this.answers.get(n)??null;if(this.answers.size>=150)return null;let r=this.lists.get(e);r||(r=tc(this.index,e),this.lists.set(e,r),e===`CLASS`&&r.forEach(e=>{let t=Zs(e);this.bySimple.has(t)||this.bySimple.set(t,e)}));let i=null;if(e===`CLASS`){let e=this.bySimple.get(Zs(t));i=e&&e!==t?e:Jn(t,r)}else i=Jn(t,r);return this.answers.set(n,i),i}};function rc(e,t,n,r){return r.map(r=>({kind:n.kind,value:n.value,file:r.file,line:r.line,symbol:n.kind===`CLASS`?n.value:Xs(e.index,r),diagram:e.diagram,element:t.elementId}))}function ic(e,t,n,r){if(!r)return{...n,state:`notApplicable`,reason:`noAssets`,anchors:[],tests:[],near:null};let i=r.get(n.value);if(!i)return{...n,state:`missing`,reason:null,anchors:[],tests:[],near:Jn(n.value,r.keys())};let a={kind:n.kind,value:n.value,file:i,line:1,symbol:n.value,diagram:e.diagram,element:t.elementId};return{...n,state:`bound`,reason:null,anchors:[a],tests:[],near:null}}function ac(e,t,n,r){let i=e=>({...r,state:`notApplicable`,reason:e,anchors:[],tests:[],near:null});if(r.kind===`PROCESS`)return ic(e,n,r,e.processes);if(r.kind===`DECISION`)return ic(e,n,r,e.decisions);if(r.value.trim()===``)return i(`unnamed`);if(r.kind===`JOB_TYPE`&&$n({kind:`JOB_TYPE`,value:r.value}))return i(`connector`);let a=$s(Qs(e.index,r.kind,r.value)),o=a.filter(e=>!Ks(e.file)),s=a.filter(e=>Ks(e.file)),c=rc(e,n,r,o),l=rc(e,n,r,s);return r.kind===`MESSAGE`?o.length>0?{...r,state:`bound`,reason:null,anchors:c,tests:l,near:null}:{...i(`external`),tests:l}:o.length===1?{...r,state:`bound`,reason:null,anchors:c,tests:l,near:null}:o.length>1?{...r,state:`ambiguous`,reason:null,anchors:c,tests:l,near:null}:ec(e.index,r.kind)?{...r,state:`missing`,reason:null,anchors:[],tests:l,near:t.of(r.kind,r.value)}:{...i(`noCode`),tests:l}}function oc(e,t){let n=`notApplicable`,r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map;for(let e of t)qs[e.state]>qs[n]&&(n=e.state),e.anchors.forEach(e=>r.set(Ls(e),e)),e.tests.forEach(e=>i.set(Ls(e),e));return{elementId:e.elementId,elementType:e.elementType,label:e.label,state:n,reason:n===`notApplicable`?t[0]?.reason??`unnamed`:null,bindings:t,anchors:[...r.values()],tests:[...i.values()],reached:null,paused:!1}}function sc(e,t){let n=new nc(e.index);return t.map(t=>oc(t,t.bindings.map(r=>ac(e,n,t,r))))}const cc=/* @__PURE__ */ new Set([`setVariable`,`setVariableLocal`,`putValue`,`putValueTyped`,`variable`]),lc=new Map([...[`startProcessInstanceByKey`,`createProcessInstanceByKey`,`startProcessInstanceByKeyAndTenantId`,`processDefinitionKey`,`bpmnProcessId`].map(e=>[e,{kind:`PROCESS`}]),...[`isWaitingAt`,`isNotWaitingAt`,`hasPassed`,`hasNotPassed`,`hasPassedInOrder`,`hasPassedElement`,`hasNotPassedElement`,`hasPassedElementsInOrder`,`hasCompletedElements`,`hasCompletedElementsInOrder`,`hasActiveElements`,`hasTerminatedElements`,`hasNotActivatedElements`,`hasActivatedElements`,`isActiveAt`,`byId`,`startBeforeActivity`,`startAfterActivity`,`cancelAllForActivity`,`activityId`,`taskDefinitionKey`,`elementId`,`hasActiveElement`].map(e=>[e,{kind:`ELEMENT`}]),...[`correlateMessage`,`createMessageCorrelation`,`messageName`,`correlateMessageAsync`].map(e=>[e,{kind:`MESSAGE`}]),...[`evaluateDecisionByKey`,`evaluateDecisionTableByKey`,`decisionKey`,`decisionId`,`decisionDefinitionKey`].map(e=>[e,{kind:`DECISION`}]),...[`getVariable`,`getVariableLocal`,`getVariableTyped`,`getVariableLocalTyped`,`setVariable`,`setVariableLocal`,`removeVariable`,`removeVariableLocal`,`hasVariable`,`hasVariableLocal`,`putValue`,`putValueTyped`,`variable`,`hasVariableNames`,`hasLocalVariable`,`hasLocalVariableNames`,`hasVariableWithValue`,`hasVariableSatisfies`].map(e=>[e,{kind:`VARIABLE`,writes:cc.has(e)}]),[`handleBpmnError`,{kind:`ERROR`,at:1}],[`errorCode`,{kind:`ERROR`}],[`bpmnError`,{kind:`ERROR`}]]),uc=/* @__PURE__ */ new Set([`Component`,`Service`,`Named`,`Repository`,`Controller`,`RestController`,`Configuration`]),dc=/* @__PURE__ */ new Set([`class`,`interface`,`enum`,`record`,`struct`]),fc=/* @__PURE__ */ new Set([`JobWorker`,`ZeebeWorker`]),pc=/* @__PURE__ */ new Set([`BpmnError`,`ZeebeBpmnError`]),mc=/^[A-Za-z_]\w*$/,hc=/^[A-Za-z_][\w.]*$/;function gc(){let e={jobTypes:/* @__PURE__ */ new Map,topics:/* @__PURE__ */ new Map,classes:/* @__PURE__ */ new Map,beans:/* @__PURE__ */ new Map,references:/* @__PURE__ */ new Map,unresolved:[]},t=/* @__PURE__ */ new Map,n=[];return{add(r){for(let e of r.facts.constants)t.set(e.name,e.value);n.push(..._c(r,e))},finish(){for(let r of n){let n=t.get(r.raw);n===void 0?e.unresolved.push(r.place):wc(e[r.sink],n,r.place)}return e}}}function _c(e,t){let{facts:n}=e,r=ao(e.text),i=e=>({file:n.path,line:r(e),offset:e}),a=[],o=(e,r,o)=>{if(r.value!==null){wc(t[e],r.value,i(o));return}let s=mc.test(r.text)?Sc(n,r.text,o):null;s===null?a.push({place:i(o),raw:r.text.split(`.`).pop()??r.text,sink:e}):wc(t[e],s,i(o))},s=(e,n,r,a=!1)=>{wc(t.references,Zn({kind:e,value:n}),a?{...i(r),writes:a}:i(r))},c=/* @__PURE__ */ new Map;for(let e of n.declarations){if(!dc.has(e.kind))continue;let r=n.package?`${n.package}.${e.name}`:e.name,a=i(e.at);t.classes.has(r)||t.classes.set(r,a);let o=e.annotations.filter(e=>uc.has(e.name)).at(-1);o!==void 0&&c.set(yc(o)??Cc(e.name),a)}for(let e of n.callables)e.annotations.some(e=>e.name===`Bean`)&&c.set(e.name,i(e.at));for(let[e,n]of c)t.beans.has(e)||t.beans.set(e,n);for(let e of n.callables)for(let n of e.annotations.filter(e=>fc.has(e.name))){let r=n.arguments.find(e=>e.name===`type`);r===void 0?wc(t.jobTypes,e.name,i(n.at)):o(`jobTypes`,r,n.at)}for(let e of n.declarations)for(let t of e.annotations.filter(e=>fc.has(e.name))){let e=t.arguments.find(e=>e.name===`type`);e!==void 0&&o(`jobTypes`,e,t.at)}for(let e of vc(n)){if(e.name===`ExternalTaskSubscription`){let t=e.arguments.find(e=>e.name===`topicName`)??e.arguments.find(e=>e.name===null);t!==void 0&&o(`topics`,t,e.at)}if(e.name===`Variable`){let t=e.arguments.find(e=>e.name===null||e.name===`name`||e.name===`value`);t?.value!=null&&s(`VARIABLE`,t.value,e.at)}}for(let e of n.calls){let r=lc.get(e.name);if(r!==void 0){let t=r.at===void 0?e.arguments:e.arguments.slice(r.at,r.at+1);for(let e of t)e.value!==null&&s(r.kind,e.value,e.at,r.writes)}if(e.name.toLowerCase()===`jobtype`&&e.receiver!==null&&xc(e,0,e=>o(`jobTypes`,e,e.at)),e.name===`subscribe`&&e.receiver!==null&&xc(e,0,e=>{bc(e)&&o(`topics`,e,e.at)}),e.name===`createWorker`&&xc(e,0,e=>{e.value!==null&&wc(t.jobTypes,e.value,i(e.at))}),e.name===`createJobWorker`){let t=n.pairs.find(t=>t.key===`type`&&t.at>=e.span.from&&t.at<e.span.to);t!==void 0&&bc(t.value)&&o(`jobTypes`,t.value,t.at)}for(let t of e.arguments.filter(e=>e.name===`task_type`))bc(t)&&o(`jobTypes`,t,t.at)}for(let e of n.locals.filter(e=>e.name===`task_type`))e.initializer!==null&&bc(e.initializer)&&o(`jobTypes`,e.initializer,e.at);for(let e of n.constants.filter(e=>e.name===`task_type`))wc(t.jobTypes,e.value,i(e.at));for(let e of n.pairs.filter(e=>e.key===`taskType`))bc(e.value)&&o(`jobTypes`,e.value,e.at);for(let e of n.constructions.filter(e=>pc.has(e.type.split(`.`).pop()??e.type)))xc(e,0,e=>{e.value!==null&&s(`ERROR`,e.value,e.at)});return a}function vc(e){return[...e.declarations.flatMap(e=>[...e.annotations,...e.members.filter(e=>e.kind!==`method`).flatMap(e=>e.annotations)]),...e.callables.flatMap(e=>[...e.annotations,...e.parameters.flatMap(e=>e.annotations)])]}function yc(e){return e.arguments.find(e=>e.name===null||e.name===`value`)?.value??null}function bc(e){return e.value!==null||hc.test(e.text)}function xc(e,t,n){let r=e.arguments[t];r!==void 0&&n(r)}function Sc(e,t,n){return e.locals.filter(e=>e.name===t&&e.at<=n&&e.initializer?.value!=null).at(-1)?.initializer?.value??null}function Cc(e){return e.length>1&&e[1]===e[1].toUpperCase()&&/[A-Z]/.test(e[1])?e:e[0].toLowerCase()+e.slice(1)}function wc(e,t,n){let r=e.get(t);r?r.push(n):e.set(t,[n])}function Tc(e,t,n){let r=Number.isNaN(n.getTime())?/* @__PURE__ */ new Date:n;if(e===`CAMUNDA_8`){let e={filter:{from:(/* @__PURE__ */ new Date(r.getTime()-864e5)).toISOString(),to:r.toISOString(),jobType:{$in:t}},page:{limit:Math.max(t.length,1)}};return[{method:`POST`,path:`/jobs/statistics/by-types`,body:JSON.stringify(e)}]}return[{method:`GET`,path:`/external-task/topic-names?withUnlockedTasks=true`},{method:`GET`,path:`/external-task/topic-names?withLockedTasks=true`}]}function Ec(e){try{return JSON.parse(e?.body??``)}catch{return null}}function Dc(e,n){let r=n.find(e=>!(e.status>=200&&e.status<300));return r?e===`CAMUNDA_8`&&r.status===404?t(`app.rules.workers.noJobStatistics`):r.status===401||r.status===403?t(`app.rules.workers.refusedTheQuestion`,{status:r.status}):t(`app.rules.workers.engineAnswered`,{status:r.status}):null}function Oc(e,n,r){let i=Dc(e,r),a=/* @__PURE__ */ new Map;if(i)return{statuses:a,problem:i};if(e===`CAMUNDA_8`){let e=Ec(r[0])?.items,i=(Array.isArray(e)?e:[]).filter(e=>typeof e==`object`&&!!e),o=e=>typeof e==`number`&&Number.isFinite(e)?e:0;return n.forEach(e=>{let n=i.find(t=>t.jobType===e),r=o(n?.workers),s=o(n?.created?.count),c=t(`app.rules.workers.workerCount`,{count:r}),l=t(`app.rules.workers.jobCount`,{count:s});a.set(e,r>0?{waiting:!1,text:t(`app.rules.workers.tookItsJobs`,{workers:c})}:s>0?{waiting:!0,text:t(`app.rules.workers.nobodyTookThem`,{jobs:l})}:{waiting:!1,text:t(`app.rules.workers.noJobs`)})}),{statuses:a,problem:null}}let o=e=>{let t=Ec(e);return new Set((Array.isArray(t)?t:[]).filter(e=>typeof e==`string`))},s=o(r[0]),c=o(r[1]);return n.forEach(e=>{a.set(e,c.has(e)?{waiting:!1,text:t(`app.rules.workers.aWorkerIsWorking`)}:s.has(e)?{waiting:!0,text:t(`app.rules.workers.tasksWait`)}:{waiting:!1,text:t(`app.rules.workers.noOpenTasks`)})}),{statuses:a,problem:null}}const kc=1e3;function Ac(e){return/\.form$/i.test(e)?`application/json`:`application/xml`}function jc(e,t){let n=(e,t)=>({name:e,content:t}),r=[];return e.engine===`CAMUNDA_8`?e.tenantId&&r.push(n(`tenantId`,e.tenantId)):(r.push(n(`deployment-name`,e.name),n(`deployment-source`,e.source)),r.push(n(`enable-duplicate-filtering`,String(e.changedOnly)),n(`deploy-changed-only`,String(e.changedOnly))),e.tenantId&&r.push(n(`tenant-id`,e.tenantId)),e.activationTime&&r.push(n(`deployment-activation-time`,e.activationTime))),t.forEach(t=>r.push({name:e.engine===`CAMUNDA_8`?`resources`:t.name,filename:t.name,contentType:Ac(t.name),content:t.content})),{method:`POST`,path:e.engine===`CAMUNDA_8`?`/deployments`:`/deployment/create`,parts:r}}function Mc(e){let t=Number(e??0);return Number.isFinite(t)?t:0}function Nc(e,t){try{let n=JSON.parse(t);if(e===`CAMUNDA_8`)return(n.deployments??[]).flatMap(e=>[...e.processDefinition?[{kind:`process`,id:String(e.processDefinition.processDefinitionKey??``),key:String(e.processDefinition.processDefinitionId??``),version:Mc(e.processDefinition.processDefinitionVersion)}]:[],...e.decisionDefinition?[{kind:`decision`,id:String(e.decisionDefinition.decisionDefinitionKey??``),key:String(e.decisionDefinition.decisionDefinitionId??``),version:Mc(e.decisionDefinition.version)}]:[]]);let r=(e,t)=>Object.values(n[e]??{}).map(e=>({kind:t,id:String(e?.id??``),key:String(e?.key??``),version:Mc(e?.version)}));return[...r(`deployedProcessDefinitions`,`process`),...r(`deployedDecisionDefinitions`,`decision`)]}catch{return[]}}function Pc(e,t){let n=t.kind===`decision`?`decision`:`process`;return{method:`GET`,path:e===`CAMUNDA_8`?`/${n}-definitions/${encodeURIComponent(t.id)}`:`/${n}-definition/${encodeURIComponent(t.id)}`}}function Fc(e){return typeof e.body==`string`?e.body:``}function Ic(e){return e instanceof Error?e.message:String(e)}function Lc(e){let t=Fc(e);if(e.status===0)return t;try{let e=JSON.parse(t),n=[e.message,e.detail,e.title].find(e=>typeof e==`string`);if(typeof n==`string`)return n}catch{return t}return t}function Rc(e){let t=Lc(e);return t===Fc(e)?t.slice(0,300):t}function zc(e){let t=[],n=null,r=null;for(let i of e.split(`
|
|
853
|
+
`)){let e=i.trim(),a=/^'([^']+)':\s*(.*)$/.exec(e);a&&(n=a[1],r=null,e=a[2]);let o=/^-?\s*Element:\s*(\S+)/.exec(e);if(o){r=o[1];continue}let s=/^-?\s*ERROR:\s*(.+)$/.exec(e);s&&t.push({file:n,element:r,text:s[1].trim(),line:null})}return t}function Bc(e){let t=e.split(`
|
|
854
|
+
`)[0].trim(),n=t.indexOf(`. `);return(n>0?t.slice(0,n):t).replace(/:$/,``)}function Vc(e){try{let t=JSON.parse(e).details??{};return Object.entries(t).flatMap(([e,t])=>(t.errors??[]).map(t=>({file:e,element:null,text:Bc(String(t.message??``)),line:typeof t.line==`number`?t.line:null})))}catch{return[]}}function Hc(e){let t=[];for(let n of e.split(`Warnings:`)[0].split(`
|
|
855
|
+
`)){let e=n.trim();if(!e.startsWith(`*`))continue;let r=e.slice(1).split(`|`).map(e=>e.trim());if(r.length<2||!r[1])continue;let i=/line\s+(\d+)/.exec(r[2]??``);t.push({file:r[1].replace(/^resource\s+/,``),element:null,text:Bc(r[0]),line:i?Number(i[1]):null})}return t}function Uc(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Wc(e,n,r,i=``){let a=e===`CAMUNDA_8`?[]:Vc(i),o=e===`CAMUNDA_8`?zc(r):a.length>0?a:Hc(r),s=n.map(e=>e.name),c=/* @__PURE__ */ new Map;for(let e of o){let t=(e.file&&s.find(t=>t===e.file||e.file?.endsWith(`/${t}`)))??(e.element?n.find(t=>RegExp(`\\bid=["']${Uc(e.element)}["']`).test(t.content))?.name:void 0);t&&c.set(t,[...c.get(t)??[],e])}return[...c].map(([e,n])=>{let[r,...i]=n,a=[r.line===null?``:t(`app.deploy.problemLine`,{line:r.line}),i.length>0?t(`app.deploy.andNMore`,{number:i.length}):``].filter(Boolean),o=`${r.element?`${r.element}: `:``}${r.text}`;return{file:e,reason:a.length>0?`${o} (${a.join(`, `)})`:o}})}async function Gc(e,n,r,i){let a=r.sleep??(e=>new Promise(t=>setTimeout(t,e))),o=r.now??(()=>performance.now());for(let s of n){let n=o()+30*kc,c=!1;for(let t=0;t<30&&!c&&o()<n;t+=1){let t=await r.ask(Pc(e,s)).catch(()=>({status:0,body:``}));c=t.status>=200&&t.status<300,c||await a(kc)}if(i.push(c?t(`app.deploy.definitionIsLive`,{key:s.key,version:s.version}):t(`app.deploy.notConfirmedInTime`,{seconds:30,key:s.key})),!c)return!1}return!0}async function Kc(e,n,r){let i=n.map(e=>e.name),a=[],o=async e=>{if(!r.hook)return{ok:!0,lines:[]};try{return await r.hook(e,i)}catch(e){return{ok:!1,lines:[Ic(e)]}}},s=await o(`preDeploy`);if(a.push(...s.lines),!s.ok)return{ok:!1,status:0,message:t(`app.deploy.preDeployHookFailed`),definitions:[],lines:a};let c;try{c=await r.ask(jc(e,n))}catch(e){return{ok:!1,status:0,message:t(`app.deploy.unableToDeploy`,{reason:Ic(e)}),definitions:[],lines:a}}if(c.status<200||c.status>=300){let r=c.status===0?[]:Wc(e.engine,n,Lc(c),Fc(c)),i=c.status===0?Fc(c):r.length>0?[t(`app.deploy.refusedNothingDeployed`,{count:r.length}),...r.map(e=>`${e.file}: ${e.reason}`)].join(`
|
|
856
|
+
`):t(`app.deploy.answeredStatus`,{status:c.status,reason:Rc(c)});return{ok:!1,status:c.status,message:i,definitions:[],lines:a,refused:r}}let l=Nc(e.engine,Fc(c)),u=!r.wait||await Gc(e.engine,l,r,a);r.hook&&a.push(...(await o(`postDeploy`)).lines);let d=l.map(e=>`${e.key} v${e.version}`).join(`, `);return{ok:u,status:c.status,message:u?d?t(`app.deploy.deployedAs`,{files:i.join(`, `),definitions:d}):t(`app.deploy.deployedFiles`,{files:i.join(`, `)}):t(`app.deploy.definitionsNotShownInTime`),definitions:l,lines:a}}function qc(e){return e==null?{value:null,type:`Null`}:typeof e==`string`?{value:e,type:`String`}:typeof e==`boolean`?{value:e,type:`Boolean`}:typeof e==`number`?{value:e,type:Number.isInteger(e)?Math.abs(e)<=2147483647?`Integer`:`Long`:`Double`}:{value:JSON.stringify(e),type:`Object`,valueInfo:{objectTypeName:Array.isArray(e)?`java.util.ArrayList`:`java.util.LinkedHashMap`,serializationDataFormat:`application/json`}}}function Jc(e){let t={};for(let[n,r]of Object.entries(e))t[n]=qc(r);return t}var B=class extends Error{status;constructor(e,t){super(e),this.status=t}};const Yc=`penstock`;function Xc(){return t(`app.testCases.engines.deployed`)}function Zc(e,n){return t(`app.testCases.engines.refusedTheBuild`,{status:e,reason:n})}const Qc=6e4;function $c(e){if(e.status===0)return e.body;try{let t=JSON.parse(e.body),n=[t.message,t.detail,t.title].find(e=>typeof e==`string`);if(typeof n==`string`)return n}catch{return e.body.slice(0,300)}return e.body.slice(0,300)}async function V(e,n){let r=await e(n);if(r.status<200||r.status>=300){let e=$c(r);throw new B(t(`app.testCases.engines.answered`,{method:n.method,path:n.path,status:r.status,reason:e?t(`app.testCases.engines.reason`,{reason:e}):``}),r.status)}if(!r.body)return null;try{return JSON.parse(r.body)}catch{if(/^\s*[[{]/.test(r.body))throw new B(t(`app.testCases.engines.answered`,{method:n.method,path:n.path,status:r.status,reason:t(`app.testCases.engines.reason`,{reason:r.body.slice(0,80)})}),r.status);return r.body}}function H(e,t){return{method:`POST`,path:e,body:JSON.stringify(t)}}function el(e){if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}}function U(e){return e==null?``:String(e)}function tl(e){let t=async t=>{let n=await V(e,H(`/variables/search`,{filter:{processInstanceKey:t},page:{limit:500}})),r={},i=/* @__PURE__ */ new Map;for(let a of n?.items??[]){let n=a.isTruncated?(await V(e,{method:`GET`,path:`/variables/${encodeURIComponent(U(a.variableKey))}`}))?.value:a.value,o=U(a.scopeKey),s=o===t?r:i.get(o)??{};s[String(a.name)]=el(n),o!==t&&i.set(o,s)}return{variables:r,local:i}};return{kind:`CAMUNDA_8`,ask:e,async deploy(t,n){let r=await e(jc({engine:`CAMUNDA_8`,name:n,source:`penstock`,changedOnly:!1},t));return r.status<200||r.status>=300?{deployment:``,ok:!1,message:Zc(r.status,$c(r))}:{deployment:(el(r.body)?.deployments??[]).map(e=>U(e.processDefinition?.processDefinitionKey??e.decisionRequirements?.decisionRequirementsKey??e.form?.formKey??e.resource?.resourceKey)).filter(Boolean).join(`,`),ok:!0,message:Xc()}},async start(t,n,r,i){let a={processDefinitionId:t,variables:n};return i?.length&&(a.startInstructions=i.map(e=>({elementId:e}))),U((await V(e,H(`/process-instances`,a)))?.processInstanceKey)},async jobs(t){let n=[];for(let r of t){let t=await V(e,H(`/jobs/activation`,{type:r,worker:Yc,timeout:Qc,maxJobsToActivate:10,requestTimeout:-1}));for(let e of t?.jobs??[])n.push({key:U(e.jobKey),type:String(e.type),elementId:String(e.elementId),elementInstance:U(e.elementInstanceKey),instance:U(e.processInstanceKey),root:U(e.rootProcessInstanceKey??e.processInstanceKey),retries:typeof e.retries==`number`?e.retries:3,variables:e.variables??{}})}return n},async complete(t,n){await V(e,H(`/jobs/${encodeURIComponent(t.key)}/completion`,{variables:n}))},async error(t,n,r,i){await V(e,H(`/jobs/${encodeURIComponent(t.key)}/error`,{errorCode:n,errorMessage:r,variables:i}))},async fail(t,n,r){await V(e,H(`/jobs/${encodeURIComponent(t.key)}/failure`,{retries:r,errorMessage:n,retryBackOff:0}))},async extend(t){await V(e,{method:`PATCH`,path:`/jobs/${encodeURIComponent(t.key)}`,body:JSON.stringify({changeset:{timeout:Qc}})})},async userTasks(t){return((await V(e,H(`/user-tasks/search`,{filter:{processInstanceKey:t,state:`CREATED`},page:{limit:500}})))?.items??[]).map(e=>({key:U(e.userTaskKey),elementId:String(e.elementId),name:typeof e.name==`string`?e.name:null}))},async completeTask(t,n){await V(e,H(`/user-tasks/${encodeURIComponent(t.key)}/completion`,{variables:n}))},async correlate(t,n,r,i){await V(e,H(`/messages/correlation`,{name:t,correlationKey:n??``,variables:i}))},async signal(t,n){await V(e,H(`/signals/broadcast`,{signalName:t,variables:n}))},async setVariables(t,n,r){await V(e,{method:`PUT`,path:`/element-instances/${encodeURIComponent(r??t)}/variables`,body:JSON.stringify({variables:n,local:r!==void 0})})},async snapshot(n){let[r,i,a,o]=await Promise.all([V(e,{method:`GET`,path:`/process-instances/${encodeURIComponent(n)}`}),V(e,H(`/element-instances/search`,{filter:{processInstanceKey:n},sort:[{field:`startDate`,order:`asc`}],page:{limit:500}})),V(e,H(`/incidents/search`,{filter:{processInstanceKey:n,state:`ACTIVE`},page:{limit:500}})),t(n)]),s=String(r?.state??`ACTIVE`);return{state:s===`COMPLETED`?`COMPLETED`:s===`TERMINATED`||s===`CANCELED`?`TERMINATED`:`ACTIVE`,elements:(i?.items??[]).filter(sl).map(e=>({key:U(e.elementInstanceKey),elementId:String(e.elementId),type:String(e.type??``),state:e.state===`COMPLETED`?`COMPLETED`:e.state===`TERMINATED`?`TERMINATED`:`ACTIVE`,startedAt:String(e.startDate??``),endedAt:e.endDate?String(e.endDate):null,incident:e.hasIncident===!0})),variables:o.variables,local:o.local,incidents:(a?.items??[]).map(e=>({elementId:String(e.elementId??``),message:String(e.errorMessage??e.errorType??``)}))}},async cancel(t){await V(e,H(`/process-instances/${encodeURIComponent(t)}/cancellation`,{}))},async remove(t){let n=null;for(let r of t.split(`,`).filter(Boolean))try{await V(e,H(`/resources/${encodeURIComponent(r)}/deletion`,{}))}catch(e){e instanceof B&&e.status===404||(n??=e)}if(n)throw n}}}const nl=Jc;function rl(e){let t={},n=typeof e==`object`&&e&&!Array.isArray(e)?e:{};for(let[e,r]of Object.entries(n)){let n=typeof r==`object`&&r?r:{value:r,type:``};Object.defineProperty(t,e,{value:n.type===`Object`||n.type===`Json`?el(n.value):n.value,enumerable:!0,writable:!0,configurable:!0})}return t}function il(e){return e===`COMPLETED`?`COMPLETED`:e===`ACTIVE`||e===`SUSPENDED`?`ACTIVE`:`TERMINATED`}function al(e,n){let r=e=>encodeURIComponent(e);return{kind:e,ask:n,async deploy(t,r){let i=await n(jc({engine:e,name:r,source:`penstock`,changedOnly:!1},t));return i.status<200||i.status>=300?{deployment:``,ok:!1,message:Zc(i.status,$c(i))}:{deployment:U(el(i.body)?.id),ok:!0,message:Xc()}},async start(e,t,i,a){let o={businessKey:i,variables:nl(t)};return a?.length&&(o.startInstructions=a.map(e=>({type:`startBeforeActivity`,activityId:e}))),U((await V(n,H(`/process-definition/key/${r(e)}/start`,o)))?.id)},async jobs(e){if(e.length===0)return[];let t=await V(n,H(`/external-task/fetchAndLock`,{workerId:Yc,maxTasks:10,topics:e.map(e=>({topicName:e,lockDuration:Qc}))}));return(Array.isArray(t)?t:[]).map(e=>({key:U(e.id),type:String(e.topicName),elementId:String(e.activityId),elementInstance:U(e.activityInstanceId),instance:U(e.processInstanceId),retries:typeof e.retries==`number`?e.retries:3,variables:rl(e.variables)}))},async complete(e,t){await V(n,H(`/external-task/${r(e.key)}/complete`,{workerId:Yc,variables:nl(t)}))},async error(e,i,a,o){await V(n,H(`/external-task/${r(e.key)}/bpmnError`,{workerId:Yc,errorCode:i,errorMessage:a||t(`app.testCases.engines.errorThrownByTheTestCase`,{code:i}),variables:nl(o)}))},async fail(e,t,i){await V(n,H(`/external-task/${r(e.key)}/failure`,{workerId:Yc,errorMessage:t,retries:i,retryTimeout:0}))},async extend(e){await V(n,H(`/external-task/${r(e.key)}/extendLock`,{workerId:Yc,newDuration:Qc}))},async userTasks(e){let t=await V(n,{method:`GET`,path:`/task?processInstanceId=${r(e)}`});return(Array.isArray(t)?t:[]).map(e=>({key:U(e.id),elementId:String(e.taskDefinitionKey),name:typeof e.name==`string`?e.name:null}))},async completeTask(e,t){await V(n,H(`/task/${r(e.key)}/complete`,{variables:nl(t)}))},async correlate(e,t,r,i){try{await V(n,H(`/message`,{messageName:e,processInstanceId:r,processVariables:nl(i)}))}catch(e){throw e instanceof B&&e.status===400&&e.message.includes(`MismatchingMessageCorrelationException`)?new B(e.message,404):e}},async signal(e,t){await V(n,H(`/signal`,{name:e,variables:nl(t)}))},async setVariables(e,i,a){if(a===void 0){await V(n,H(`/process-instance/${r(e)}/variables`,{modifications:nl(i)}));return}let o=ol(await V(n,{method:`GET`,path:`/process-instance/${r(e)}/activity-instances`}),a);if(!o)throw new B(t(`app.testCases.engines.activityNotRunning`,{element:a}),404);await V(n,H(`/execution/${r(o)}/localVariables`,{modifications:nl(i)}))},async snapshot(e){let[t,i,a,o]=await Promise.all([V(n,{method:`GET`,path:`/history/process-instance/${r(e)}`}),V(n,{method:`GET`,path:`/history/activity-instance?processInstanceId=${r(e)}&sortBy=occurrence&sortOrder=asc`}),V(n,{method:`GET`,path:`/history/variable-instance?processInstanceId=${r(e)}&deserializeValues=false`}),V(n,{method:`GET`,path:`/incident?processInstanceId=${r(e)}`})]),s=new Set((Array.isArray(o)?o:[]).map(e=>String(e.activityId??``))),c={},l=/* @__PURE__ */ new Map;for(let t of Array.isArray(a)?a:[]){let n=U(t.activityInstanceId),r=rl({[String(t.name)]:{value:t.value,type:String(t.type)}})[String(t.name)];n===e||n===``?c[String(t.name)]=r:l.set(n,{...l.get(n)??{},[String(t.name)]:r})}return{state:il(t?.state),elements:(Array.isArray(i)?i:[]).map(e=>({key:U(e.id),elementId:String(e.activityId),type:String(e.activityType??``),state:e.canceled?`TERMINATED`:e.endTime?`COMPLETED`:`ACTIVE`,startedAt:String(e.startTime??``),endedAt:e.endTime?String(e.endTime):null,incident:s.has(String(e.activityId))})),variables:c,local:l,incidents:(Array.isArray(o)?o:[]).map(e=>({elementId:String(e.activityId??``),message:String(e.incidentMessage??e.incidentType??``)}))}},async cancel(e){await V(n,{method:`DELETE`,path:`/process-instance/${r(e)}?skipCustomListeners=true`})},async remove(e){e&&await V(n,{method:`DELETE`,path:`/deployment/${r(e)}?cascade=true`})}}}function ol(e,t){if(!e||typeof e!=`object`)return null;if(e.id===t)return Array.isArray(e.executionIds)&&e.executionIds.length?String(e.executionIds[0]):null;for(let n of Array.isArray(e.childActivityInstances)?e.childActivityInstances:[]){let e=ol(n,t);if(e)return e}return null}function sl(e){return e.type!==`PROCESS`}function cl(e,t){return e===`CAMUNDA_8`?tl(t):al(e,t)}var ll=class extends Error{};function ul(e){let t=e.indexOf(`:`);return t<0?{prefix:``,local:e}:{prefix:e.slice(0,t),local:e.slice(t+1)}}function W(e){let n=new w,r=[],i=null,a=null;n.on(`openTag`,(e,t,n)=>{let a={},o=t();for(let[e,t]of Object.entries(o))a[e]=n(t);let s=new Map(r.length>0?r[r.length-1].scope:[[`xml`,`http://www.w3.org/XML/1998/namespace`]]);for(let[e,t]of Object.entries(a))e===`xmlns`?s.set(``,t):e.startsWith(`xmlns:`)&&s.set(e.slice(6),t);let{prefix:c,local:l}=ul(e),u={name:e,local:l,prefix:c,ns:s.get(c)??``,attrs:a,children:[],text:``,scope:s};r.length>0?r[r.length-1].node.children.push(u):i||=u,r.push({node:u,scope:s})}),n.on(`closeTag`,()=>{r.pop()}),n.on(`text`,(e,t)=>{r.length>0&&(r[r.length-1].node.text+=t(e))}),n.on(`cdata`,e=>{r.length>0&&(r[r.length-1].node.text+=e)}),n.on(`error`,e=>{a??=e.message});try{n.parse(e)}catch(e){a??=e instanceof Error?e.message:String(e)}if(a)throw new ll(t(`app.xml.notWellFormed`,{reason:a}));if(!i||r.length>0)throw new ll(t(`app.xml.emptyOrNotClosed`));return i}function dl(e,t){let n=[],r=[...e.children].reverse();for(let e=r.pop();e;e=r.pop()){e.local===t&&n.push(e);for(let t=e.children.length-1;t>=0;--t)r.push(e.children[t])}return n}function fl(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}function pl(e){return fl(e).replace(/"/g,`"`)}function ml(e){let t=[],n=[e];for(let e=n.pop();e!==void 0;e=n.pop()){if(typeof e==`string`){t.push(e);continue}let r=Object.entries(e.attrs).map(([e,t])=>` ${e}="${pl(t)}"`).join(``);if(e.children.length===0&&e.text.trim()===``)t.push(`<${e.name}${r}/>`);else if(t.push(`<${e.name}${r}>`),n.push(`</${e.name}>`),e.children.length>0)for(let t=e.children.length-1;t>=0;--t)n.push(e.children[t]);else t.push(pl(e.text))}return t.join(``)}function hl(e,t){try{if(e===`form`){let e=JSON.parse(t).id;return typeof e==`string`?[e]:[]}return dl(W(t),e).map(e=>e.attrs.id).filter(e=>typeof e==`string`&&e!==``)}catch{return[]}}const gl=/\.(bpmn20\.xml|bpmn\.xml|bpmn)$/i,_l=[`camunda:class`,`camunda:delegateExpression`,`camunda:expression`],vl=`Penstock test build`,yl=/(<(?:[\w-]+:)?decision\b[^>]*\sid=")([^"]+)(")/g,bl=/(<(?:[\w-]+:)?definitions\b[^>]*?\sid=")([^"]+)(")/;function xl(e){let t={processes:/* @__PURE__ */ new Set,decisions:/* @__PURE__ */ new Set,forms:/* @__PURE__ */ new Set};for(let n of e)gl.test(n.name)?hl(`process`,n.content).forEach(e=>t.processes.add(e)):/\.dmn$/i.test(n.name)?hl(`decision`,n.content).forEach(e=>t.decisions.add(e)):/\.form$/i.test(n.name)&&hl(`form`,n.content).forEach(e=>t.forms.add(e));return t}function Sl(e,t,n){let r=(e,t)=>t.has(e)?`${n}${e}`:e;if(/\.dmn$/i.test(t.name)){let i=t.content.replace(yl,(t,n,i,a)=>`${n}${r(i,e.decisions)}${a}`).replace(/(href="#)([^"]+)(")/g,(t,n,i,a)=>`${n}${r(i,e.decisions)}${a}`).replace(/(dmnElementRef=")([^"]+)(")/g,(t,n,i,a)=>`${n}${r(i,e.decisions)}${a}`).replace(bl,(e,t,r,i)=>`${t}${n}${r}${i}`);return{...t,content:i}}if(/\.form$/i.test(t.name))try{let n=JSON.parse(t.content);return{...t,content:JSON.stringify({...n,id:r(String(n.id),e.forms)})}}catch{return t}return t}function Cl(e,t){if(/\.form$/i.test(e.name))try{let n=JSON.parse(e.content);return{...e,content:JSON.stringify({...n,exporter:{name:vl,version:t}})}}catch{return{...e,content:`${e.content}\n`}}return{...e,content:`${e.content.trimEnd()}\n<!-- ${vl} ${t} -->\n`}}function wl(e,t){return e?.extensionElements?.values?.find(e=>e.$type===t)}function Tl(e,t){try{return e.get?.(t)}catch{return}}function El(e,t,n){let r=(e,t,r)=>{let i=e?.[t];typeof i==`string`&&r.has(i)&&(e[t]=`${n}${i}`)};r(wl(e,`zeebe:CalledElement`),`processId`,t.processes),r(wl(e,`zeebe:CalledDecision`),`decisionId`,t.decisions),r(wl(e,`zeebe:FormDefinition`),`formId`,t.forms),e.$type===`bpmn:CallActivity`&&r(e,`calledElement`,t.processes);let i=Tl(e,`camunda:decisionRef`);typeof i==`string`&&t.decisions.has(i)&&e.set(`camunda:decisionRef`,`${n}${i}`);let a=Tl(e,`camunda:formRef`);typeof a==`string`&&t.forms.has(a)&&e.set(`camunda:formRef`,`${n}${a}`)}function Dl(e){let t=/* @__PURE__ */ new Set;for(let n of e.instructions){let e=n.type;if((e===`MOCK_JOB_WORKER_COMPLETE_JOB`||e===`MOCK_JOB_WORKER_THROW_BPMN_ERROR`)&&typeof n.jobType==`string`&&t.add(n.jobType),e===`COMPLETE_JOB`||e===`THROW_BPMN_ERROR_FROM_JOB`){let e=n.jobSelector?.jobType;typeof e==`string`&&t.add(e)}}return t}function Ol(e){let t=new Set(Object.keys(e[`x-penstock`]?.behaviours??{}));for(let n of e.instructions){if(n.type!==`COMPLETE_JOB`&&n.type!==`THROW_BPMN_ERROR_FROM_JOB`)continue;let e=n.jobSelector?.elementId;typeof e==`string`&&t.add(e)}return t}function kl(e){let t=[],n=[],r=e=>(e??[]).forEach(e=>{n.push(e),e.flowElements&&r(e.flowElements)});for(let n of e?.rootElements??[])n.$type===`bpmn:Process`&&(t.push(n),r(n.flowElements));return{processes:t,elements:n}}function Al(e){return e?.extensionElements?.values?.find(e=>e.$type===`zeebe:TaskDefinition`)}function jl(e,t){let n=t.eventDefinitions?.find(e=>e.$type===`bpmn:TimerEventDefinition`);n&&(n.timeDate=void 0,n.timeCycle=void 0,n.timeDuration=e.create(`bpmn:FormalExpression`,{body:`PT1S`}))}function Ml(e,t,n,r,i){let a=Al(e),o=typeof a?.type==`string`?a.type:null;if(!o)return;let s=r.has(o);if(!s&&!t&&!n)return;let c=`${i.prefix}${o}`;a.type=c,s&&i.jobTypes.set(o,c),(t||n)&&i.elements.set(e.id,c)}function Nl(e,t,n,r,i){let a=e.get?.(`camunda:type`)===`external`?e.get(`camunda:topic`):null;if(typeof a==`string`&&a!==``){let o=r.has(a);if(!o&&!t&&!n)return;let s=`${i.prefix}${a}`;e.set(`camunda:topic`,s),o&&i.jobTypes.set(a,s),(t||n)&&i.elements.set(e.id,s);return}if(!t&&!n||!_l.some(t=>typeof e.get?.(t)==`string`))return;_l.forEach(t=>e.set(t,void 0));let o=`${i.prefix}${e.id}`;e.set(`camunda:type`,`external`),e.set(`camunda:topic`,o),i.elements.set(e.id,o)}async function Pl(e,t,n,o){let s={resources:[],processes:/* @__PURE__ */ new Map,jobTypes:/* @__PURE__ */ new Map,elements:/* @__PURE__ */ new Map,prefix:`penstock.${o}.`},c=xl(t),l=Dl(n),u=Ol(n),d=n[`x-penstock`]?.behaviours??{};for(let n of t){if(!gl.test(n.name)){s.resources.push(Cl(Sl(c,n,s.prefix),o));continue}let t=await r(n.content,b(e));if(!t)throw Error(`${n.name} is not a BPMN diagram that can be read`);let p=a(t),{processes:h,elements:g}=kl(t);h.forEach(e=>{s.processes.set(e.id,`${s.prefix}${e.id}`),e.id=`${s.prefix}${e.id}`});for(let t of g){El(t,c,s.prefix);let n=d[t.id];n?.then===`fire`&&jl(p,t),(f(e)?Ml:Nl)(t,n?.then===`fire`?void 0:n,u.has(t.id),l,s)}m(e)&&h.forEach(e=>{e.get(`camunda:historyTimeToLive`)||e.set(`camunda:historyTimeToLive`,`P1D`)}),t.set(`exporter`,vl),t.set(`exporterVersion`,o),s.resources.push({name:n.name,content:await i(t)})}return s}var Fl=class extends Error{};function Il(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e):[]}function Ll(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e===null||t===null||Array.isArray(e)!==Array.isArray(t))return!1;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>Ll(e[n],t[n]))}function Rl(e){if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}}function zl(e){return e?Date.parse(e.replace(/([+-]\d\d)(\d\d)$/,`$1:$2`)):NaN}function Bl(){return(/* @__PURE__ */ new Date()).toISOString()}async function Vl(e,n,r){let i=await e(n);if(i.status>=200&&i.status<300)return Rl(i.body);let a=typeof i.body==`string`?i.body:``,o=a.slice(0,300);try{let e=JSON.parse(a);o=String([e.message,e.detail,e.title].find(e=>typeof e==`string`)??o)}catch{o=a.slice(0,300)}throw r.push({at:Bl(),text:t(`app.testCases.trace.couldNotRead`,{path:n.path,status:i.status,reason:o?t(`app.testCases.trace.reason`,{reason:o}):``}),error:!0}),new Fl}async function Hl(e,t){try{return await e}catch(e){if(e instanceof Fl)return t;throw e}}function Ul(e,t){let n=e.findIndex(e=>e.name===t.name);n>=0?e.splice(n,1,t):e.push(t)}async function Wl(e,t,n,r){let i=encodeURIComponent(t),[a,o,s,c]=await Promise.all([Hl(Vl(e,{method:`GET`,path:`/history/process-instance/${i}`},r),null),Hl(Vl(e,{method:`GET`,path:`/history/activity-instance?processInstanceId=${i}&sortBy=occurrence&sortOrder=asc`},r),[]),Hl(Vl(e,{method:`GET`,path:`/history/detail?processInstanceId=${i}&variableUpdates=true&deserializeValues=false&sortBy=occurrence&sortOrder=asc`},r),[]),Hl(Vl(e,{method:`GET`,path:`/incident?processInstanceId=${i}`},r),[])]),l=new Set(Il(c).map(e=>String(e.activityId??``))),u=Il(s).map(e=>({name:String(e.variableName),value:e.variableType===`Object`||e.variableType===`Json`?Rl(e.value):e.value,scope:String(e.activityInstanceId??``),time:zl(e.time)})),d=Il(o).map(e=>{let t=String(e.id),r=zl(e.startTime),i=[],a=[],o=[],s=/* @__PURE__ */ new Map;for(let e of u){if(e.scope===t){let t={name:e.name,value:e.value,source:`history`};Ul(a,t),Ul(o,s.has(e.name)?{...t,before:s.get(e.name)}:t)}else e.time<=r&&Ul(i,{name:e.name,value:e.value,source:`history`});s.set(e.name,e.value)}let c=!!e.endTime,d=e.canceled?`TERMINATED`:c?`COMPLETED`:l.has(String(e.activityId))?`FAILED`:`ACTIVE`;return{elementId:String(e.activityId),elementType:String(e.activityType??``),...t?{instance:t}:{},...e.parentActivityInstanceId?{parent:String(e.parentActivityInstanceId)}:{},state:d,startedAt:String(e.startTime??``),endedAt:c?String(e.endTime):null,mocked:n.mocked?.has(String(e.activityId))??!1,in:i,out:a,changed:o}}),f=String(a?.state??`ACTIVE`),p=Il(c).map(e=>({elementId:String(e.activityId??``),message:String(e.incidentMessage??e.incidentType??``)}));return{state:f===`COMPLETED`?`COMPLETED`:f===`ACTIVE`||f===`SUSPENDED`?p.length>0?`FAILED`:`ACTIVE`:`TERMINATED`,steps:d,incidents:p}}function Gl(e,t){return Object.entries(e).map(([e,n])=>({name:e,value:n,source:t}))}function Kl(e,t,n){return Object.entries(t).filter(([t,n])=>!Object.hasOwn(e,t)||!Ll(e[t],n)).map(([t,r])=>Object.hasOwn(e,t)?{name:t,value:r,before:e[t],source:n}:{name:t,value:r,source:n})}async function ql(e,t,n,r){let i=(e,t)=>({method:`POST`,path:e,body:JSON.stringify(t)}),[a,o,s,c]=await Promise.all([Hl(Vl(e,{method:`GET`,path:`/process-instances/${encodeURIComponent(t)}`},r),null),Hl(Vl(e,i(`/element-instances/search`,{filter:{processInstanceKey:t},sort:[{field:`startDate`,order:`asc`}],page:{limit:500}}),r),null),Hl(Vl(e,i(`/incidents/search`,{filter:{processInstanceKey:t,state:`ACTIVE`},page:{limit:500}}),r),null),Hl(Vl(e,i(`/decision-instances/search`,{filter:{processInstanceKey:t},page:{limit:100}}),r),null)]),l=/* @__PURE__ */ new Map;for(let t of Il(c?.items)){let n=await Hl(Vl(e,{method:`GET`,path:`/decision-instances/${encodeURIComponent(String(t.decisionEvaluationInstanceKey))}`},r),null);if(!n)continue;let i=String(n.elementInstanceKey??t.elementInstanceKey??``),a=l.get(i)??{in:[],out:[]};Il(n.evaluatedInputs).forEach(e=>a.in.push({name:String(e.inputName??e.inputId),value:Rl(e.inputValue),source:`decision`})),Il(n.matchedRules).forEach(e=>Il(e.evaluatedOutputs).forEach(e=>a.out.push({name:String(e.outputName??e.outputId),value:Rl(e.outputValue),source:`decision`}))),l.set(i,a)}let u=new Map((n.mockCalls??[]).map(e=>[e.elementInstance,e])),d=new Set(Il(s?.items).map(e=>String(e.elementId??``))),f=n.snapshots??[],p=/* @__PURE__ */ new Map;for(let e=1;e<f.length;e+=1){let t=f[e].completed.find(e=>!u.has(e)&&!l.has(e));if(!t||p.has(t))continue;let n=f[e].completed.flatMap(e=>Object.entries(u.get(e)?.sent??{})),r=e=>n.some(([t,n])=>t===e.name&&Ll(n,e.value));p.set(t,Kl(f[e-1].variables,f[e].variables,`diff`).filter(e=>!r(e)))}let m=Il(o?.items).filter(sl).map(e=>{let t=String(e.elementInstanceKey),r=e.state===`COMPLETED`?`COMPLETED`:e.state===`TERMINATED`?`TERMINATED`:e.hasIncident||d.has(String(e.elementId))?`FAILED`:`ACTIVE`,i={elementId:String(e.elementId),elementType:String(e.type??``),...t?{instance:t}:{},...e.flowScopeKey?{parent:String(e.flowScopeKey)}:{},state:r,startedAt:String(e.startDate??``),endedAt:e.endDate?String(e.endDate):null,mocked:n.mocked?.has(String(e.elementId))??!1,in:[],out:[],changed:[]},a=u.get(t),o=l.get(t);return a?(i.in=Gl(a.received,`mock`),i.out=Gl(a.sent,`mock`),i.changed=Kl(a.received,a.sent,`mock`)):o?(i.in=o.in,i.out=o.out):i.changed=p.get(t)??[],i}),h=String(a?.state??`ACTIVE`),g=Il(s?.items).map(e=>({elementId:String(e.elementId??``),message:String(e.errorMessage??e.errorType??``)}));return{state:h===`COMPLETED`?`COMPLETED`:h===`ACTIVE`?g.length>0?`FAILED`:`ACTIVE`:`TERMINATED`,steps:m,incidents:g}}async function Jl(e,t,n,r={}){let i=[...r.log??[]],a=e===`CAMUNDA_8`?await ql(t,n,r,i):await Wl(t,n,r,i);return{version:1,runId:r.runId??``,engine:e,testCase:r.testCase??null,instance:n,...a,log:i}}function Yl(e){return String(e).padStart(2,`0`)}function Xl(e){return`${`${e.getUTCFullYear()}${Yl(e.getUTCMonth()+1)}${Yl(e.getUTCDate())}`}-${`${Yl(e.getUTCHours())}${Yl(e.getUTCMinutes())}${Yl(e.getUTCSeconds())}`}-${Math.floor(Math.random()*65536).toString(16).padStart(4,`0`)}`}function Zl(e){let t=2166136261;for(let n of e)t^=n.codePointAt(0)??0,t=Math.imul(t,16777619)>>>0;return t.toString(16).padStart(8,`0`)}function Ql(e){let t=e.normalize(`NFKD`).replace(/[\u0300-\u036f]/g,``),n=t.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);return n?n===`run`?`run-case`:/[^\x20-\x7e]/.test(t)||n.length>100?`${n.slice(0,100).replace(/-+$/,``)}-${Zl(e)}`:n:`case-${Zl(e)}`}function $l(e,t){let n=Ql(e),r=n;for(let e=2;t.has(r);e+=1)r=`${n}-${e}`;return t.add(r),r}var G=class extends Error{},K=class extends G{comparison;constructor(e,t){super(e),this.comparison=t}},eu=class extends Error{};const tu=[`assignee`,`candidateGroups`,`priority`,`name`,`dueDate`,`followUpDate`];function nu(e){return e.length<2?e.join(``):`${e.slice(0,-1).join(`, `)}${t(`app.testCases.listSeparator`)}${e[e.length-1]}`}const ru=2e4,iu=/* @__PURE__ */ new Set([`MOCK_JOB_WORKER_COMPLETE_JOB`,`MOCK_JOB_WORKER_THROW_BPMN_ERROR`,`MOCK_CHILD_PROCESS`,`MOCK_DMN_DECISION`]),au=cr,ou=/\.(bpmn20\.xml|bpmn\.xml|bpmn)$/i;function su(e){let t=e.instructions.findIndex(e=>!iu.has(String(e.type)));return t>=0&&e.instructions[t].type===`CREATE_PROCESS_INSTANCE`?t:-1}function cu(e,t){for(let n of[`processInstanceSelector`,`jobSelector`,`userTaskSelector`,`elementSelector`]){let r=e[n]?.processDefinitionId;if(typeof r==`string`&&r!==t)return r}return null}function lu(e){let n=e.instructions.findIndex(e=>typeof e!=`object`||!e||typeof e.type!=`string`);if(n>=0)return t(`app.testCases.unrunnable.shapelessInstruction`,{number:n+1});let r=e.instructions[su(e)]?.processDefinitionSelector?.processDefinitionId;if(e.instructions.filter(e=>e.type===`CREATE_PROCESS_INSTANCE`).length>1)return t(`app.testCases.unrunnable.oneInstancePerTestCase`);for(let n of e.instructions){let e=String(n.type);if(au.has(e))return t(`app.testCases.unrunnable.notYet`,{type:e});if(!lr.has(e))return t(`app.testCases.unrunnable.unknown`,{type:e});let i=e===`ASSERT_USER_TASK`?tu.filter(e=>e in n):[];if(i.length)return t(`app.testCases.unrunnable.userTaskFields`,{fields:nu(i)});if(n.useExampleData===!0)return t(`app.testCases.unrunnable.exampleData`,{type:e});let a=n.runtimeInstructions;if(Array.isArray(a)&&a.length>0)return t(`app.testCases.unrunnable.runtimeInstructions`,{type:e});let o=cu(n,r);if(o&&r)return t(`app.testCases.unrunnable.foreignProcess`,{type:e,foreign:o,root:r})}return null}function uu(e){return JSON.stringify(e)??`undefined`}function du(e){return uu({state:e.state,elements:e.elements.map(e=>[e.key,e.state,e.incident]),variables:e.variables})}function fu(e,t){let n=e?.correlationKey?.trim();if(!n)return;if(!n.startsWith(`=`))return n;let r=/^=\s*([A-Za-z_]\w*)\s*$/.exec(n)?.[1];return r&&t[r]!==void 0&&t[r]!==null?String(t[r]):void 0}async function pu(e){let t=/* @__PURE__ */ new Map;for(let n of e)ou.test(n.name)&&Rt(await r(n.content)).forEach((e,n)=>t.set(n,e));return t}async function mu(e,n){let r=n.now??Date.now,i=r();try{return await hu(e,n)}catch(a){let o=t(`app.testCases.penstockFailed`,{reason:a instanceof Error?a.message:String(a)});return n.emit?.({kind:`testFinished`,testCase:e.name,outcome:`failed`,message:o,durationMs:r()-i,trace:null}),{outcome:`failed`,message:o,trace:null,recorded:[]}}}async function hu(e,n){let{engine:r,runId:i}=n,a=e.name,o=n.stepTimeoutMs??3e4,s=n.pollMs??500,c=Math.max(n.settleReads??3,1),l=n.sleep??(e=>new Promise(t=>setTimeout(t,e))),d=n.now??Date.now,f=n.emit??(()=>void 0),p=`${Math.round(o/1e3)} s`,m=d(),h=[],g=[],_=[],y=[],b=(e,t)=>{h.push({at:(/* @__PURE__ */ new Date()).toISOString(),text:e,...t?{error:t}:{}}),f({kind:`log`,testCase:a,text:e,...t?{error:t}:{}})},x=(e,t,n,r)=>(f({kind:`testFinished`,testCase:a,outcome:e,...t?{message:t}:{},...r?{comparison:r}:{},durationMs:d()-m,trace:n}),{outcome:e,...t?{message:t}:{},...r?{comparison:r}:{},trace:n,recorded:g});f({kind:`testStarted`,testCase:a});let S=e[`x-penstock`]?.engines;if(S?.length&&!u(S,r.kind))return x(`skipped`,t(`app.testCases.forOtherEngines`,{engines:nu(S.map(e=>v(e)))}),null);let ee=lu(e);if(ee)return x(`failed`,ee,null);let C=su(e);if(C<0)return x(`failed`,t(`app.testCases.needsCreateProcessInstance`),null);let te=e.instructions[C],w=await pu(n.resources),T=e=>w.get(e)?.name??e,ne=e[`x-penstock`]?.behaviours??{},E;try{E=await Pl(r.kind,n.resources,e,i)}catch(e){return x(`failed`,e instanceof Error?e.message:String(e),null)}let re=/* @__PURE__ */ new Set;w.forEach((e,t)=>{let n=e.job??e.external;(n&&E.jobTypes.has(n)||E.elements.has(t))&&re.add(t)});let ie=[.../* @__PURE__ */ new Set([...E.jobTypes.values(),...E.elements.values()])],ae=/* @__PURE__ */ new Map;for(let n of e.instructions)if(n.type===`MOCK_JOB_WORKER_COMPLETE_JOB`||n.type===`MOCK_JOB_WORKER_THROW_BPMN_ERROR`){let e=n,r=E.jobTypes.get(e.jobType);if(!r){b(t(`app.testCases.log.noElementWithJobType`,{jobType:e.jobType}));continue}ae.set(r,e.type===`MOCK_JOB_WORKER_THROW_BPMN_ERROR`?{kind:`error`,variables:e.variables??{},errorCode:e.errorCode,errorMessage:e.errorMessage}:{kind:`complete`,variables:e.variables??{}})}let D=/* @__PURE__ */ new Map,oe=/* @__PURE__ */ new Map,se=async e=>{for(let t of[...D.values()])!e&&d()-(oe.get(t.key)??0)<ru||(await r.extend(t).catch(()=>void 0),oe.set(t.key,d()))},ce=e=>[...D.values()].find(t=>t.elementId===e)??null,le=/* @__PURE__ */ new Map,ue=/* @__PURE__ */ new Map,O=``,k=``,de=null,fe=()=>{if(n.signal?.aborted)throw new eu},pe=async(e,n,i,a,o)=>{n===`error`?await r.error(e,a??`ERROR`,o??``,i):await r.complete(e,i),_.push({elementId:e.elementId,elementInstance:e.elementInstance,received:e.variables,sent:i}),re.add(e.elementId),b(n===`error`?t(`app.testCases.log.mockThrew`,{label:T(e.elementId),code:a}):t(`app.testCases.log.mockCompleted`,{label:T(e.elementId)}))},me=async()=>{if(ie.length===0)return 0;let e=0;for(let n of await r.jobs(ie)){if(n.root&&n.root!==O)continue;let i=ne[n.elementId];if(i&&i.then!==`fire`){if(i.then===`hold`){D.set(n.key,n),oe.set(n.key,d());continue}let a=le.get(n.elementInstance)??0;if(a<(i.fail??0)){le.set(n.elementInstance,a+1),await r.fail(n,t(`app.testCases.failingOnPurpose`,{tried:a+1,total:i.fail}),Math.max(n.retries,1)),b(t(`app.testCases.log.failedOnPurpose`,{label:T(n.elementId),tried:a+1,total:i.fail})),e+=1;continue}await pe(n,i.then===`error`?`error`:`complete`,i.variables??{},i.errorCode,i.errorMessage),e+=1;continue}let a=ae.get(n.type);a?(await pe(n,a.kind,a.variables,a.errorCode,a.errorMessage),e+=1):(D.set(n.key,n),oe.set(n.key,d()))}return e},he=e=>{for(let t of e.elements){let e=t.state===`ACTIVE`&&t.incident?`FAILED`:t.state;ue.get(t.key)!==e&&(ue.set(t.key,e),f({kind:`step`,testCase:a,elementId:t.elementId,state:e,mocked:re.has(t.elementId)}))}},ge=e=>{for(let n of e.elements){if(n.state!==`ACTIVE`||n.incident)continue;let e=w.get(n.elementId);if(!e)continue;let r=T(n.elementId),i=e.job??e.external;if(i){if(ce(n.elementId))continue;return E.jobTypes.has(i)||E.elements.has(n.elementId)?t(`app.testCases.waiting.jobNotHandedOut`,{label:r,seconds:p}):t(`app.testCases.waiting.noWorkerTook`,{type:i,seconds:p})}if(e.event===`timer`&&ne[n.elementId]?.then===`fire`)return t(`app.testCases.waiting.timerDidNotFire`,{label:r,seconds:p});if((e.delegateClass||e.delegateExpression||e.expression)&&(e.asyncBefore||e.asyncAfter))return t(`app.testCases.waiting.engineDidNotRun`,{label:r,seconds:p})}return null},A=async e=>{let n=d(),i=``,a=0,u=e===void 0;for(;;){fe();let f=await me(),m=null;try{m=await r.snapshot(O)}catch(e){if(!(e instanceof B&&e.status===404))throw e}if(m){de=m;let t=m.elements.filter(e=>e.state===`COMPLETED`&&ue.get(e.key)!==`COMPLETED`).map(e=>e.key);y.push({at:(/* @__PURE__ */ new Date()).toISOString(),variables:m.variables,completed:t}),he(m);let r=du(m);r!==e&&(u=!0),f>0||r!==i||!u?(a=0,i=r):a+=1;let s=m.state===`ACTIVE`?ge(m):null;if(a>=c-1&&!s)return m;if(d()-n>o){if(s)throw new G(s);return m}}else if(d()-n>o)throw new G(t(`app.testCases.waiting.instanceNotShown`,{seconds:p}));await l(s)}},_e=async(e,t,r)=>{let i=d();for(;;){fe(),await me();let a=await e();if(a!==null)return a;let c=n.onWait?[...D.values()].find(e=>e.elementId!==r):void 0;if(c)await Te(ve(c)),i=d();else{if(d()-i>o)throw new G(t);await se(!1),await l(s)}}},ve=e=>{let t=w.get(e.elementId);return{kind:`job`,elementId:e.elementId,jobType:t?.job??t?.external??e.type,variables:e.variables}},ye=()=>de?du(de):void 0,be=e=>e.elements.filter(e=>e.state===`ACTIVE`).map(e=>T(e.elementId)),xe=e=>{let n=[...new Set(e)].filter(e=>!w.has(e));if(n.length)throw new G(t(`app.testCases.notInDiagram`,{ids:n.join(`, `),count:n.length}))},Se=e=>{if(e.elementId)return e.elementId;if(e.elementName!==void 0){for(let[t,n]of w)if(n.name===e.elementName)return t}throw new G(t(`app.testCases.noElementNamed`,{name:e.elementName??t(`app.testCases.unknownName`)}))},Ce=e=>{if(e.elementId)return ce(e.elementId);let t=e.jobType?E.jobTypes.get(e.jobType):void 0;for(let e of D.values())if(e.type===t)return e;return null},we=async(e,n,i)=>{let a=ye();return await _e(async()=>{try{return await r.correlate(e,n,O,i),!0}catch(e){if(e instanceof B&&e.status===404)return null;throw e}},t(`app.testCases.waiting.messageFoundNothing`,{message:e,seconds:p})),b(t(`app.testCases.log.correlated`,{message:e})),A(a)},Te=async e=>{let i=n.onWait;f({kind:`waiting`,testCase:a,wait:e});let o=setInterval(()=>void se(!0),n.keepAliveMs??ru),s=await i(e).finally(()=>clearInterval(o));if(fe(),s.kind===`stop`)throw new eu;let c=ye(),l=s.variables;if(e.kind===`job`){let t=ce(e.elementId);return D.delete(t.key),s.kind===`error`?(await pe(t,`error`,l,s.errorCode,s.errorMessage),g.push({type:`THROW_BPMN_ERROR_FROM_JOB`,jobSelector:{elementId:e.elementId},errorCode:s.errorCode,...s.errorMessage?{errorMessage:s.errorMessage}:{},variables:l})):(await pe(t,`complete`,l),g.push({type:`COMPLETE_JOB`,jobSelector:{elementId:e.elementId},variables:l})),A(c)}if(e.kind===`userTask`){let n=(await r.userTasks(O)).find(t=>t.elementId===e.elementId);return n?(await r.completeTask(n,l),b(t(`app.testCases.log.completed`,{label:T(e.elementId)})),g.push({type:`COMPLETE_USER_TASK`,userTaskSelector:{elementId:e.elementId},variables:l}),A(c)):A()}if(e.kind===`message`){let t=fu(w.get(e.elementId),de?.variables??{});return g.push({type:`CORRELATE_MESSAGE`,name:e.name,...t===void 0?{}:{correlationKey:t},variables:l}),we(e.name,t,l)}return await r.signal(e.name,l),g.push({type:`BROADCAST_SIGNAL`,signalName:e.name,variables:l}),A(c)},Ee=async e=>{for(let t of e.elements){if(t.state!==`ACTIVE`)continue;let e=w.get(t.elementId),n=ce(t.elementId);if(n)return ve(n);if(e?.type===`bpmn:UserTask`&&(await r.userTasks(O)).some(e=>e.elementId===t.elementId))return{kind:`userTask`,elementId:t.elementId,name:e.name??null};if(e?.event===`message`&&e.message)return{kind:`message`,elementId:t.elementId,name:e.message};if(e?.event===`signal`&&e.signal)return{kind:`signal`,elementId:t.elementId,name:e.signal}}return null},De=(e,n)=>{let r=e=>n.elements.filter(t=>t.elementId===e),i=n.state===`ACTIVE`&&be(n).length?t(`app.testCases.whereAt`,{elements:be(n).join(`, `)}):``;switch(e.type){case`ASSERT_PROCESS_INSTANCE`:{let r=e.state&&e.state!==`IS_CREATED`?{IS_COMPLETED:`COMPLETED`,IS_ACTIVE:`ACTIVE`,IS_TERMINATED:`TERMINATED`}[e.state]:null;if(r&&n.state!==r)throw new K(t(`app.testCases.mismatch.instanceState`,{expected:r.toLowerCase(),actual:n.state.toLowerCase(),where:i}),{expected:r.toLowerCase(),actual:n.state.toLowerCase()});if(e.hasActiveIncidents!==void 0&&e.hasActiveIncidents!==n.incidents.length>0)throw new K(e.hasActiveIncidents?t(`app.testCases.mismatch.incidentExpected`):t(`app.testCases.mismatch.incidentUnexpected`,{elements:n.incidents.map(e=>T(e.elementId)).join(`, `)}));return}case`ASSERT_ELEMENT_INSTANCES`:{let a=e.elementSelectors.map(Se);xe(a);let o=(e,t)=>r(e).some(e=>e.state===t),s=(e,t)=>{let n=a.filter(e);if(n.length)throw new K(`${n.map(T).join(`, `)} ${t}${i}`)};if(e.state===`IS_ACTIVE`&&s(e=>!o(e,`ACTIVE`),t(`app.testCases.mismatch.isNotActive`)),(e.state===`IS_COMPLETED`||e.state===`IS_COMPLETED_IN_ORDER`)&&s(e=>!o(e,`COMPLETED`),t(`app.testCases.mismatch.hasNotCompleted`)),e.state===`IS_TERMINATED`&&s(e=>!o(e,`TERMINATED`),t(`app.testCases.mismatch.wasNotTerminated`)),e.state===`IS_NOT_ACTIVE`&&s(e=>o(e,`ACTIVE`),t(`app.testCases.mismatch.isActive`)),e.state===`IS_NOT_ACTIVATED`&&s(e=>r(e).length>0,t(`app.testCases.mismatch.wasReached`)),e.state===`IS_ACTIVE_EXACTLY`){let e=[...new Set(n.elements.filter(e=>e.state===`ACTIVE`).map(e=>e.elementId))].sort();if(uu(e)!==uu([...new Set(a)].sort()))throw new K(t(`app.testCases.mismatch.activeExactly`,{active:e.map(T).join(`, `)||t(`app.testCases.nothing`),expected:a.map(T).join(`, `)}))}if(e.state===`IS_COMPLETED_IN_ORDER`){let e=/* @__PURE__ */ new Set,r=a.map(t=>{let r=n.elements.findIndex((n,r)=>!e.has(r)&&n.elementId===t&&n.state===`COMPLETED`);return e.add(r),{id:t,at:Date.parse(n.elements[r]?.endedAt??``)||0,index:r}}).sort((e,t)=>e.at-t.at||e.index-t.index).map(e=>e.id);if(uu(r)!==uu(a))throw new K(t(`app.testCases.mismatch.completedInOrder`,{order:r.map(T).join(`, `),expected:a.map(T).join(`, `)}))}return}case`ASSERT_ELEMENT_INSTANCE`:{let n=Se(e.elementSelector);xe([n]);let a=e.state.replace(`IS_`,``),o=r(n).filter(e=>e.state===a).length;if(e.amount===void 0?o===0:o!==e.amount)throw new K(t(`app.testCases.mismatch.instanceCount`,{label:T(n),count:t(`app.testCases.count.instances`,{count:o,state:a.toLowerCase()}),expected:e.amount??t(`app.testCases.one`),where:i}));return}case`ASSERT_VARIABLES`:{let i=n.variables;if(e.elementSelector){let t=Se(e.elementSelector);i=Object.assign({},...r(t).map(e=>n.local.get(e.key)??{}))}let a=[],o=[];for(let n of e.variableNames??[])n in i||a.push(t(`app.testCases.mismatch.variableNotSet`,{name:n}));for(let[n,r]of Object.entries(e.variables??{}))n in i?Ll(i[n],r)||(a.push(t(`app.testCases.mismatch.variableValue`,{name:n,actual:uu(i[n]),expected:uu(r)})),o.push({expected:uu(r),actual:uu(i[n])})):a.push(t(`app.testCases.mismatch.variableNotSet`,{name:n}));if(a.length)throw new K(a.join(`; `),a.length===1&&o.length===1?o[0]:void 0);return}case`ASSERT_USER_TASK`:{let n=e.userTaskSelector,a=Se(n.elementId?{elementId:n.elementId}:{elementName:n.taskName});if(xe([a]),e.elementId!==void 0&&e.elementId!==a)throw new G(t(`app.testCases.elementIdMismatch`,{label:T(a),actual:a,expected:e.elementId}));let o=r(a);if(e.state===`IS_CREATED`&&!o.some(e=>e.state===`ACTIVE`))throw new K(t(`app.testCases.mismatch.notWaitingForAUser`,{label:T(a),where:i}));if(e.state===`IS_COMPLETED`&&!o.some(e=>e.state===`COMPLETED`))throw new K(t(`app.testCases.mismatch.userTaskNotCompleted`,{label:T(a),where:i}));if(e.state===`IS_CANCELED`&&!o.some(e=>e.state===`TERMINATED`))throw new K(t(`app.testCases.mismatch.wasNotCanceled`,{label:T(a),where:i}));if(e.state===`IS_FAILED`&&!o.some(e=>e.incident))throw new K(t(`app.testCases.mismatch.hasNotFailed`,{label:T(a),where:i}));if(e.state===void 0&&o.length===0)throw new K(t(`app.testCases.mismatch.wasNotReached`,{label:T(a),where:i}));return}default:throw new G(t(`app.testCases.unrunnable.notYet`,{type:e.type}))}},Oe=async()=>{try{let e=await r.snapshot(O);return de=e,he(e),e}catch(e){if(e instanceof B&&e.status===404)return de;throw e}},ke=async(e,t)=>{let n=d(),r=Math.min(5e3,o/4),i=t,a=null,u=du(i),f=0;for(;;){try{return De(e,i),i}catch(e){if(!(e instanceof K)||d()-n>o)throw e;if(i.state===`ACTIVE`)a=null,f=0;else if(a??=d(),f>=c&&d()-a>=r)throw e}fe(),await l(s),await me(),i=await Oe();let t=du(i);t===u?f+=1:(u=t,f=0,a=i.state===`ACTIVE`?null:d())}},Ae=async e=>{for(let t=1;;t+=1)try{await r.remove(e);return}catch(e){if(!(e instanceof B&&(e.status===409||e.status===400))||t>=10)throw e;await l(s)}},je=null,Me,Ne=`passed`,Pe;try{let a=await r.deploy(E.resources,`penstock-test ${i}`);if(!a.ok)throw new G(a.message);k=a.deployment;let o=d();await n.builds?.add({deployment:k,at:o}),b(t(`app.testCases.log.deployedTheBuild`));let s=te;O=await r.start(E.processes.get(s.processDefinitionSelector.processDefinitionId)??s.processDefinitionSelector.processDefinitionId,s.variables??{},i,s.startInstructions?.map(e=>e.elementId)),await n.builds?.add({deployment:k,at:o,instance:O}),b(t(`app.testCases.log.startedInstance`,{instance:O}));let c=await A();for(let n of e.instructions.slice(C+1)){fe();let e=n;switch(e.type){case`MOCK_JOB_WORKER_COMPLETE_JOB`:case`MOCK_JOB_WORKER_THROW_BPMN_ERROR`:break;case`COMPLETE_JOB`:case`THROW_BPMN_ERROR_FROM_JOB`:{let n=e.jobSelector,r=await _e(async()=>Ce(n),t(`app.testCases.waiting.noJobAt`,{where:n.elementId?T(n.elementId):n.jobType,seconds:p}),n.elementId);D.delete(r.key);let i=ye();e.type===`THROW_BPMN_ERROR_FROM_JOB`?await pe(r,`error`,e.variables??{},e.errorCode,e.errorMessage):await pe(r,`complete`,e.variables??{}),c=await A(i);break}case`COMPLETE_USER_TASK`:{let n=e.userTaskSelector,i=await _e(async()=>(await r.userTasks(O)).find(e=>n.elementId?e.elementId===n.elementId:e.name===n.taskName)??null,t(`app.testCases.waiting.noUserTaskAt`,{where:n.elementId?T(n.elementId):n.taskName,seconds:p})),a=ye();await r.completeTask(i,e.variables??{}),b(t(`app.testCases.log.completed`,{label:T(i.elementId)})),c=await A(a);break}case`CORRELATE_MESSAGE`:case`PUBLISH_MESSAGE`:c=await we(e.name,e.correlationKey,e.variables??{});break;case`BROADCAST_SIGNAL`:{let n=ye();await r.signal(e.signalName,e.variables??{}),b(t(`app.testCases.log.broadcast`,{signal:e.signalName})),c=await A(n);break}case`UPDATE_VARIABLES`:{let n=e.elementSelector?c.elements.find(t=>t.elementId===Se(e.elementSelector)&&t.state===`ACTIVE`)?.key:void 0;if(e.elementSelector&&!n)throw new G(t(`app.testCases.notActiveSoNoVariables`,{label:T(Se(e.elementSelector))}));let i=ye();await r.setVariables(O,e.variables,n),c=await A(i);break}default:if(au.has(e.type))throw new G(t(`app.testCases.unrunnable.notYet`,{type:e.type}));c=await ke(e,c)}}for(;n.onWait&&c.state===`ACTIVE`;){let e=await Ee(c);if(!e)break;c=await Te(e)}}catch(e){e instanceof eu?(Ne=`skipped`,Pe=`stopped`):(Ne=`failed`,Pe=e instanceof Error?e.message:String(e),e instanceof K&&(Me=e.comparison),!(e instanceof G)&&!(e instanceof B)&&(Pe=t(`app.testCases.penstockFailed`,{reason:Pe})))}finally{if(O){try{je=await Jl(r.kind,r.ask,O,{runId:i,testCase:a,mocked:re,mockCalls:_,snapshots:y,log:h})}catch(e){b(t(`app.testCases.log.couldNotReadTheTrace`,{reason:e instanceof Error?e.message:String(e)}),!0)}let e=de?.state;e!==`COMPLETED`&&e!==`TERMINATED`&&await r.cancel(O).catch(e=>b(t(`app.testCases.log.couldNotCancel`,{reason:e instanceof Error?e.message:String(e)}),!0))}k&&await Ae(k).then(()=>n.builds?.drop(k)).catch(e=>b(t(`app.testCases.log.couldNotRemoveTheBuild`,{reason:e instanceof Error?e.message:String(e)}),!0))}return x(Ne,Pe,je,Me)}const gu=`penstock-test-case://`;function _u(e){return e.replace(/[|'\n\r[\]]/g,e=>({"|":`||`,"'":`|'`,"\n":`|n`,"\r":`|r`,"[":`|[`,"]":`|]`})[e]??e)}function vu(e,t){return`##teamcity[${e} ${Object.entries(t).map(([e,t])=>`${e}='${_u(t)}'`).join(` `)}]`}function yu(e,t,n){return e===`started`?[vu(`testSuiteStarted`,{name:t,locationHint:`${gu}${n}`})]:[vu(`testSuiteFinished`,{name:t})]}function bu(e,n,r){switch(r.kind){case`testStarted`:return[vu(`testStarted`,{name:r.testCase,locationHint:`${gu}${n}#${r.testCase}`})];case`log`:return[vu(r.error?`testStdErr`:`testStdOut`,{name:r.testCase,out:`${r.text}\n`})];case`step`:{let e=r.mocked?` (${t(`app.runs.mocked`)})`:``;return[vu(r.state===`FAILED`?`testStdErr`:`testStdOut`,{name:r.testCase,out:`${r.elementId}: ${r.state}${e}\n`})]}case`testFinished`:{let e=vu(`testFinished`,{name:r.testCase,duration:String(Math.round(r.durationMs))});if(r.outcome===`failed`){let t=r.comparison?{type:`comparisonFailure`,expected:r.comparison.expected,actual:r.comparison.actual}:{};return[vu(`testFailed`,{name:r.testCase,message:r.message??`failed`,...t}),e]}return r.outcome===`skipped`?[vu(`testIgnored`,{name:r.testCase,message:r.message??`skipped`}),e]:[e]}default:return[]}}function xu(e){return(e/1e3).toFixed(3)}function Su(e){let t=(e,t)=>e.filter(e=>e.outcome===t).length,n=e.flatMap(e=>e.results),r=e=>e.reduce((e,t)=>e+t.durationMs,0),i=[`<?xml version="1.0" encoding="UTF-8"?>`,`<testsuites tests="${n.length}" failures="${t(n,`failed`)}" skipped="${t(n,`skipped`)}" time="${xu(r(n))}">`];for(let n of e){let e=pl(n.name);i.push(` <testsuite name="${e}" tests="${n.results.length}" failures="${t(n.results,`failed`)}" skipped="${t(n.results,`skipped`)}" time="${xu(r(n.results))}">`);for(let t of n.results){let n=` <testcase name="${pl(t.testCase)}" classname="${e}" time="${xu(t.durationMs)}"`;t.outcome===`passed`?i.push(`${n}/>`):(i.push(`${n}>`),i.push(` <${t.outcome===`failed`?`failure`:`skipped`} message="${pl(t.message??``)}"/>`),i.push(` </testcase>`))}i.push(` </testsuite>`)}return i.push(`</testsuites>`,``),i.join(`
|
|
857
|
+
`)}const Cu=/* @__PURE__ */ new Map;function wu(e,t){let n=`${e}:${t}`,r=Cu.get(n);if(!r){try{r=new Intl.ListFormat(e,{style:`long`,type:t})}catch{r=new Intl.ListFormat(`en`,{style:`long`,type:t})}Cu.set(n,r)}return r}function Tu(e,t=`conjunction`){return e.length>0?wu(n(),t).format(e):``}function Eu(){return wu(n(),`conjunction`).format([`aa`,`bb`]).includes(` `)}function Du(e){let n=e.includes(`:`)?e.slice(e.indexOf(`:`)+1):e,r=`app.element.kind.${n.charAt(0).toLowerCase()}${n.slice(1)}`,i=t(r,{count:1});return i===r?n.toLowerCase():i}function Ou(e,n,r){let i=x(e,n);return i?t(`app.rules.${i.id}.${r}`):n}function ku(e,t){return Ou(e,t,`title`)}const Au=/* @__PURE__ */ new Set(/* @__PURE__ */ `and.or.not.true.false.null.if.then.else.for.in.return.some.every.satisfies.instance.of.between.function.execution.task.string.number.date.time.duration.count.sum.min.max.contains.is.defined.now.today.list.context.get.value.length.size.substring.upper.lower.case.matches.replace.split.append.concatenate.flatten.distinct.values.entries.abs.floor.ceiling.round.decimal.odd.even.mean.median.all.any`.split(`.`)),ju=e=>e.replace(`bpmn:`,``).replace(/([a-z])([A-Z])/g,`$1 $2`).toLowerCase();function Mu(e){let n=e.name?.replace(/\s+/g,` `).trim();return n?`"${n}"`:t(`app.rules.flow.theNode`,{node:ju(e.$type)})}function Nu(e){let t=(e?.body??e?.$body??``).trim();if(!t)return null;if(t.startsWith(`=`))return t.slice(1).trim();let n=/^[$#]\{([\s\S]*)\}$/.exec(t);return n?n[1].trim():t}function Pu(e,t){let n=[],r=0,i=null,a=0;for(let o=0;o<e.length;o+=1){let s=e[o];if(i)s===i&&(i=null);else if(s===`"`||s===`'`)i=s;else if(s===`(`)r+=1;else if(s===`)`)--r;else if(r===0){let r=e.slice(o),i=t.exec(r);i&&i.index===0&&(n.push(e.slice(a,o)),o+=i[0].length-1,a=o+1)}}return n.push(e.slice(a)),n.map(e=>e.trim()).filter(Boolean)}function Fu(e){let t=e.trim();for(;t.startsWith(`(`)&&t.endsWith(`)`);){let e=0,n=-1;for(let r=0;r<t.length;r+=1)if(t[r]===`(`&&(e+=1),t[r]===`)`&&--e,e===0){n=r;break}if(n!==t.length-1)break;t=t.slice(1,-1).trim()}return t}const Iu=e=>e&&e[0].toUpperCase()+e.slice(1),Lu={lo:null,hi:null};function Ru(e,t){let n=e.lo?t.lo?e.lo.value>t.lo.value||e.lo.value===t.lo.value&&e.lo.open?e.lo:t.lo:e.lo:t.lo,r=e.hi?t.hi?e.hi.value<t.hi.value||e.hi.value===t.hi.value&&e.hi.open?e.hi:t.hi:e.hi:t.hi;return n&&r&&(n.value>r.value||n.value===r.value&&(n.open||r.open))?null:{lo:n,hi:r}}function zu(e){let t=[...e].sort((e,t)=>!e.lo||!t.lo?e.lo?1:t.lo?-1:0:e.lo.value-t.lo.value||Number(e.lo.open)-Number(t.lo.open)),n=[],r=null,i=!1;for(let e of t){if(!i){if(e.lo&&n.push({lo:null,hi:{value:e.lo.value,open:!e.lo.open}}),i=!0,!e.hi)return n;r=e.hi;continue}let t=r,a=e.lo;if((a.value>t.value||a.value===t.value&&t.open&&a.open)&&n.push({lo:{value:t.value,open:!t.open},hi:{value:a.value,open:!a.open}}),!e.hi)return n;(e.hi.value>t.value||e.hi.value===t.value&&t.open&&!e.hi.open)&&(r=e.hi)}if(!i)return[Lu];let a=r;return n.push({lo:{value:a.value,open:!a.open},hi:null}),n}function Bu(e){let t=/^([A-Za-z_][\w.]*)\s*(<=|>=|!=|==|=|<|>)\s*(-?\d+(?:\.\d+)?|"[^"]*"|'[^']*'|true|false)$/.exec(e)??/^(-?\d+(?:\.\d+)?|"[^"]*"|'[^']*')\s*(<=|>=|!=|==|=|<|>)\s*([A-Za-z_][\w.]*)$/.exec(e);if(!t)return null;let n=/^-?\d|^["']/.test(t[1]),r=n?t[3]:t[1],i=n?t[1]:t[3],a=n?{"<":`>`,">":`<`,"<=":`>=`,">=":`<=`}[t[2]]??t[2]:t[2];if(i===`true`||i===`false`){let e=i===`true`;return a===`=`||a===`==`?{kind:`boolean`,variable:r,values:/* @__PURE__ */ new Set([e])}:a===`!=`?{kind:`boolean`,variable:r,values:/* @__PURE__ */ new Set([!e])}:null}if(/^["']/.test(i)){let e=i.slice(1,-1);return a===`=`||a===`==`?{kind:`string`,variable:r,values:/* @__PURE__ */ new Set([e]),others:!1}:a===`!=`?{kind:`string`,variable:r,values:/* @__PURE__ */ new Set([e]),others:!0}:null}let o=Number(i);return{kind:`number`,variable:r,intervals:{"<":[{lo:null,hi:{value:o,open:!0}}],"<=":[{lo:null,hi:{value:o,open:!1}}],">":[{lo:{value:o,open:!0},hi:null}],">=":[{lo:{value:o,open:!1},hi:null}],"=":[{lo:{value:o,open:!1},hi:{value:o,open:!1}}],"==":[{lo:{value:o,open:!1},hi:{value:o,open:!1}}],"!=":[{lo:null,hi:{value:o,open:!0}},{lo:{value:o,open:!0},hi:null}]}[a]}}function Vu(e){let t=Fu(e),n=Pu(t,/^(\s+or\s+|\s*\|\|\s*)/);if(n.length>1){let e=n.map(Vu);return e.some(e=>!e)||new Set(e.map(e=>`${e?.kind}:${e?.variable}`)).size!==1?null:e.reduce((e,t)=>Hu(e,t))}let r=Pu(t,/^(\s+and\s+|\s*&&\s*)/);if(r.length>1){let e=r.map(Vu);return e.some(e=>!e)||new Set(e.map(e=>`${e?.kind}:${e?.variable}`)).size!==1?null:e.reduce((e,t)=>Uu(e,t))}let i=/^(?:not\s*\(([\s\S]*)\)|!\s*([A-Za-z_][\w.]*))$/.exec(t);if(i){let e=Vu(i[1]??i[2]);return e?Wu(e):null}return/^[A-Za-z_][\w.]*$/.test(t)&&!Au.has(t)?{kind:`boolean`,variable:t,values:/* @__PURE__ */ new Set([!0])}:Bu(t)}function Hu(e,t){if(e.kind===`number`&&t.kind===`number`)return{...e,intervals:[...e.intervals,...t.intervals]};if(e.kind===`boolean`&&t.kind===`boolean`)return{...e,values:/* @__PURE__ */ new Set([...e.values,...t.values])};let n=e,r=t;if(n.others&&r.others)return{...n,values:new Set([...n.values].filter(e=>r.values.has(e))),others:!0};if(n.others||r.others){let[e,t]=n.others?[n,r]:[r,n];return{...e,values:new Set([...e.values].filter(e=>!t.values.has(e))),others:!0}}return{...n,values:/* @__PURE__ */ new Set([...n.values,...r.values]),others:!1}}function Uu(e,t){if(e.kind===`number`&&t.kind===`number`){let n=e.intervals.flatMap(e=>t.intervals.map(t=>Ru(e,t)).filter(e=>!!e));return{...e,intervals:n}}return e.kind===`boolean`&&t.kind===`boolean`?{...e,values:new Set([...e.values].filter(e=>t.values.has(e)))}:Wu(Hu(Wu(e),Wu(t)))}function Wu(e){return e.kind===`number`?{...e,intervals:zu(e.intervals)}:e.kind===`boolean`?{...e,values:new Set([!0,!1].filter(t=>!e.values.has(t)))}:{...e,others:!e.others}}function Gu(e){return String(e.value)}function Ku(e,n){let{lo:r,hi:i}=n;return r&&i&&r.value===i.value?t(`app.rules.flow.isValue`,{variable:e,bound:Gu(r)}):!r&&i?t(`app.rules.flow.isBound`,{variable:e,side:i.open?t(`app.rules.flow.below`):t(`app.rules.flow.atMost`),bound:Gu(i)}):r&&!i?t(`app.rules.flow.isBound`,{variable:e,side:r.open?t(`app.rules.flow.above`):t(`app.rules.flow.atLeast`),bound:Gu(r)}):r&&i?t(`app.rules.flow.isBetween`,{variable:e,lo:Gu(r),hi:Gu(i),exclusive:r.open||i.open?t(`app.rules.flow.exclusive`):``}):t(`app.rules.flow.hasAnyValue`,{variable:e})}function qu(e){let n=e[0];if(n.kind===`number`)return zu(e.flatMap(e=>e.intervals)).map(e=>Ku(n.variable,e));if(n.kind===`boolean`){let r=new Set(e.flatMap(e=>[...e.values]));return[!0,!1].filter(e=>!r.has(e)).map(e=>t(`app.rules.flow.isValue`,{variable:n.variable,bound:e}))}let r=e.reduce((e,t)=>Hu(e,t));return r.kind===`string`?r.others?[...r.values].map(e=>t(`app.rules.flow.isValue`,{variable:n.variable,bound:`"${e}"`})):[t(`app.rules.flow.isAnythingBut`,{variable:n.variable,values:[...r.values].map(e=>`"${e}"`).join(t(`app.rules.flow.comma`))})]:[]}function Ju(e,n){let r=Uu(e,n);return r.kind===`number`?r.intervals[0]?Ku(e.variable,r.intervals[0]):null:r.kind===`boolean`?r.values.size>0?t(`app.rules.flow.isValue`,{variable:e.variable,bound:[...r.values][0]}):null:r.others?t(`app.rules.flow.isSomeOtherValue`,{variable:e.variable}):r.values.size>0?t(`app.rules.flow.isValue`,{variable:e.variable,bound:`"${[...r.values][0]}"`}):null}function*Yu(e){let t=/* @__PURE__ */ new Set,n=[];for(let t of e.rootElements??[])t.$type===`bpmn:Process`&&n.push(t),t.$type===`bpmn:Collaboration`&&t.participants?.forEach(e=>e.processRef&&n.push(e.processRef));for(;n.length>0;){let e=n.pop();if(!t.has(e)){t.add(e);for(let t of e.flowElements??[])yield t,t.flowElements&&n.push(t)}}}function Xu(e,n){if(n.length<2||e.default)return[];let r=n.map(e=>({flow:e,body:Nu(e.conditionExpression)}));if(r.some(e=>e.body===null))return[];let i=e.$type===`bpmn:ExclusiveGateway`,a=r.map(e=>Vu(e.body)),o=a.every(e=>e&&e.kind===a[0]?.kind&&e.variable===a[0]?.variable),s=e.id??``;if(!o)return[{kind:`NO-DEFAULT`,title:ku(`flow`,`NO-DEFAULT`),detail:t(`app.rules.flow.noDefaultFlow`,{gateway:Iu(Mu(e))}),elements:[s],trace:[]}];let c=a,l=[],u=qu(c);if(u.length>0&&l.push({kind:`NO-WAY-OUT`,title:ku(`flow`,`NO-WAY-OUT`),detail:t(`app.rules.flow.noWayOut`,{gateway:Iu(Mu(e)),gaps:u.join(t(`app.rules.flow.orWhen`))}),elements:[s],trace:[]}),i)for(let r=0;r<c.length;r+=1)for(let i=r+1;i<c.length;i+=1){let a=Ju(c[r],c[i]);if(!a)continue;let o=e=>e.name?.trim()?`"${e.name.trim()}"`:t(`app.rules.flow.theFlowTo`,{target:e.targetRef?Mu(e.targetRef):t(`app.rules.flow.theNextStep`)});l.push({kind:`OVERLAP`,title:ku(`flow`,`OVERLAP`),detail:t(`app.rules.flow.bothConditionsHold`,{shared:a,first:o(n[r]),second:o(n[i]),gateway:Mu(e)}),elements:[s,n[r].id??``,n[i].id??``],trace:[]})}return l}function Zu(e){return[...e.replace(/"[^"]*"|'[^']*'/g,` `).matchAll(/[A-Za-z_][\w]*/g)].map(e=>e[0]).filter(e=>!Au.has(e))}function Qu(e){let t=[],n=Nu(e.conditionExpression);n&&t.push(...Zu(n));let r=e.$attrs??{},i=e.resultVariable??r[`camunda:resultVariable`];typeof i==`string`&&t.push(i);let a=e=>{if(!e)return;let n=e.$type??``;if(/zeebe:(input|output)$/.test(n)&&(typeof e.target==`string`&&t.push(e.target),typeof e.source==`string`&&e.source.trim().startsWith(`=`)&&t.push(...Zu(e.source.trim().slice(1)))),/camunda:(inputParameter|outputParameter)$/.test(n)){typeof e.name==`string`&&t.push(e.name);let n=e.$body??e.value;if(typeof n==`string`)for(let e of n.matchAll(/[$#]\{([^}]*)\}/g))t.push(...Zu(e[1]))}for(let t of[`$children`,`values`,`inputParameters`,`outputParameters`,`inputParameter`,`outputParameter`]){let n=e[t];Array.isArray(n)&&n.forEach(e=>a(e))}};return(e.extensionElements?.values??[]).forEach(a),t.map(t=>({name:t.split(`.`)[0],element:e.id??``}))}function $u(e,t){if(e===t||Math.abs(e.length-t.length)>1)return!1;let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n+=1;let r=(e,t)=>e.slice(t);return e.length===t.length?r(e,n+1)===r(t,n+1)||e[n]===t[n+1]&&e[n+1]===t[n]&&r(e,n+2)===r(t,n+2):e.length>t.length?r(e,n+1)===r(t,n):r(e,n)===r(t,n+1)}function ed(e){let n=/* @__PURE__ */ new Map;e.forEach(e=>n.set(e.name,/* @__PURE__ */ new Set([...n.get(e.name)??[],e.element])));let r=[...n.keys()].sort(),i=[];for(let e=0;e<r.length;e+=1)for(let a=e+1;a<r.length;a+=1){let[o,s]=[r[e],r[a]];if(/\d$/.test(o)&&/\d$/.test(s))continue;let c=o.toLowerCase()===s.toLowerCase(),l=Math.min(o.length,s.length)>=5&&$u(o,s);(c||l)&&i.push({kind:`LOOKALIKE`,title:ku(`flow`,`LOOKALIKE`),detail:t(`app.rules.flow.lookalikeNames`,{first:o,second:s,difference:t(c?`app.rules.flow.letterCaseOnly`:`app.rules.flow.oneCharacter`)}),elements:[.../* @__PURE__ */ new Set([...n.get(o)??[],...n.get(s)??[]])].filter(Boolean),trace:[]})}return i}function td(e){let t=e,n=[],r=[],i=[...Yu(t)],a=/* @__PURE__ */ new Map;for(let e of i)e.$type===`bpmn:SequenceFlow`&&e.sourceRef&&a.set(e.sourceRef,[...a.get(e.sourceRef)??[],e]);for(let e of i)(e.$type===`bpmn:ExclusiveGateway`||e.$type===`bpmn:InclusiveGateway`)&&n.push(...Xu(e,a.get(e)??[])),r.push(...Qu(e));return n.push(...ed(r)),n}function nd(e){let t=e.trim();if(t.startsWith(`=`))return t.slice(1).trim();let n=/^[$#]\{([\s\S]*)\}$/.exec(t);return n?n[1].trim():t}function rd(e,t){let n=!e.lo||(e.lo.open?t>e.lo.value:t>=e.lo.value),r=!e.hi||(e.hi.open?t<e.hi.value:t<=e.hi.value);return n&&r}function id(e){if(e.kind===`boolean`)return[...e.values][0];if(e.kind===`string`){if(!e.others)return[...e.values][0];let t=`other`;for(let n=2;e.values.has(t);n+=1)t=`other${n}`;return t}for(let t of e.intervals){let e=[t.lo?t.lo.open?Math.floor(t.lo.value)+1:t.lo.value:null,t.hi?t.hi.open?Math.ceil(t.hi.value)-1:t.hi.value:null,t.lo&&t.hi?(t.lo.value+t.hi.value)/2:null,0].find(e=>e!==null&&rd(t,e));if(e!==void 0)return e}}function ad(e){return e.kind===`number`?e.intervals.length===0:(e.kind===`boolean`||!e.others)&&e.values.size===0}function od(e){let t=/* @__PURE__ */ new Map,n=[],r=[],i=(e,r,i,a=n)=>{let o=t.get(e.variable);if(o&&o.kind!==e.kind){i&&a.push(r);return}let s=o?Uu(o,e):e;ad(s)?i&&a.push(r):t.set(e.variable,s)};for(let t of e)for(let e of t.takes){let t=Vu(nd(e));t?i(t,e,!0):n.push(e)}for(let t of e)for(let e of t.avoids){let n=Vu(nd(e));n?i(Wu(n),e,t.takes.length===0,r):t.takes.length===0&&r.push(e)}let a={};for(let[e,r]of t){let t=id(r);t===void 0?n.push(e):a[e]=t}return{values:a,unresolved:n,avoided:r}}const sd=2e4,cd=e=>ku(`flow`,e),ld=e=>e&&e[0].toUpperCase()+e.slice(1);function ud(e){switch(e.$type){case`bpmn:StartEvent`:return`start`;case`bpmn:EndEvent`:return`end`;case`bpmn:ExclusiveGateway`:case`bpmn:EventBasedGateway`:case`bpmn:ComplexGateway`:return`xor`;case`bpmn:ParallelGateway`:return`and`;case`bpmn:InclusiveGateway`:return`or`;case`bpmn:BoundaryEvent`:return`boundary`;default:return`activity`}}const dd=/* @__PURE__ */ new Set([`bpmn:SequenceFlow`,`bpmn:DataObject`,`bpmn:DataObjectReference`,`bpmn:DataStoreReference`]);function fd(e){let t=[],n=[],r=/* @__PURE__ */ new Set,i=e=>{e&&!r.has(e)&&(r.add(e),n.push(e))};for(let t of e.rootElements??[])t.$type===`bpmn:Process`&&i(t),t.$type===`bpmn:Collaboration`&&t.participants?.forEach(e=>i(e.processRef));for(let e=0;e<n.length;e+=1){let r=n[e],a=r.flowElements??[],o=/* @__PURE__ */ new Map;for(let e of a){if(dd.has(e.$type)||!e.id||(e.$type===`bpmn:SubProcess`||e.$type===`bpmn:Transaction`||e.$type===`bpmn:AdHocSubProcess`)&&(i(e),e.triggeredByEvent))continue;let t=ud(e);o.set(e,{id:e.id,named:!!e.name?.trim(),name:e.name?.replace(/\s+/g,` `).trim()||Du(e.$type),kind:t,incoming:[],outgoing:[],defaultFlow:null,terminate:(e.eventDefinitions??[]).some(e=>e.$type===`bpmn:TerminateEventDefinition`),boundaries:[],interrupting:e.cancelActivity!==!1,outgoingNodes:[],host:null,plain:(e.eventDefinitions??[]).length===0})}let s=[];for(let e of a){if(e.$type!==`bpmn:SequenceFlow`)continue;let t=e.sourceRef&&o.get(e.sourceRef),n=e.targetRef&&o.get(e.targetRef);if(!t||!n||!e.id)continue;let r=s.length;s.push({id:e.id,name:e.name?.replace(/\s+/g,` `).trim()??``,source:t,target:n,conditional:!!e.conditionExpression,condition:e.conditionExpression?.body?.trim()??``}),t.outgoing.push(r),t.outgoingNodes.push(n),n.incoming.push(r)}for(let[e,t]of o){e.default&&(t.defaultFlow=s.findIndex(t=>t.id===e.default?.id)),t.defaultFlow===-1&&(t.defaultFlow=null);let n=t.kind===`boundary`&&e.attachedToRef?o.get(e.attachedToRef):void 0;n&&(n.boundaries.push(t),t.host=n)}o.size>0&&t.push({id:r.id??`scope-${e}`,nodes:[...o.values()],flows:s})}return t}function pd(e){if(e.length===0)return[];if(e.length>4)return[...e.map(e=>[e]),e];let t=[];for(let n=1;n<1<<e.length;n+=1)t.push(e.filter((e,t)=>n&1<<t));return t}function md(e,t){let n=e.outgoing;if(n.length===0)return[[]];if(e.kind===`xor`)return n.map(e=>[e]);if(e.kind===`and`)return[n];let r=n.filter(n=>n!==e.defaultFlow&&(e.kind===`or`||t[n].conditional)),i=e.kind===`or`?[]:n.filter(t=>!r.includes(t)&&t!==e.defaultFlow),a=pd(r).map(e=>[...i,...e]);return e.defaultFlow!==null&&a.push([...i,e.defaultFlow]),r.length===0&&e.defaultFlow===null?[i]:a.length>0?a:[i]}function hd(e){let t=e.flows.length,n=e.flows.map(()=>Array(t).fill(!1));return e.flows.forEach((t,r)=>{let i=[...t.target.outgoing];for(;i.length>0;){let t=i.pop();n[r][t]||(n[r][t]=!0,i.push(...e.flows[t].target.outgoing))}}),n}function gd(e){if(e.named)return`"${e.name}"`;let n=e.outgoingNodes.find(e=>e.named);return n?t(`app.rules.flow.nodeBefore`,{node:e.name,next:n.name}):t(`app.rules.flow.theNode`,{node:e.name})}function _d(e){return e.source.named?`"${e.source.name}"`:t(`app.rules.flow.theBranchThrough`,{node:e.source.name})}function vd(e){let t=/* @__PURE__ */ new Set,n=[...e];for(;n.length>0;){let e=n.pop();if(!t.has(e.id)){t.add(e.id);for(let t of e.boundaries)n.push(t);n.push(...e.outgoingNodes)}}return t}function yd(e,n){let r=hd(e),i=new Set(n.fired),a=[],o=e=>e.join(`,`),s=/* @__PURE__ */ new Map([[o(n.tokens),0]]),c=[n.tokens],l=[{from:-1,fired:n.fired}],u=[],d=[],f=!1,p=/* @__PURE__ */ new Set,m=/* @__PURE__ */ new Set,h=/* @__PURE__ */ new Set,g=t=>m.has(t.id)||h.has(t.id)?!0:(m.add(t.id),h=vd([...m].map(t=>e.nodes.find(e=>e.id===t))),!1),_=e=>{let t=[];for(let n=e;n>=0;n=l[n].from)t.unshift(...l[n].fired);return t};for(let n=0;n<c.length;n+=1){let m=c[n],h=[],v=[],y=(r,u,d,y=!1,b=null)=>{let x=y?m.map(()=>0):[...m];y||(r.forEach(e=>--x[e]),u.forEach(e=>x[e]+=1)),d.forEach(e=>i.add(e));let S=x.findIndex(e=>e>1);if(S>=0){let r=e.flows[S].target;if(g(r))return;a.push({kind:`NO-SYNCHRONIZATION`,title:cd(`NO-SYNCHRONIZATION`),detail:t(`app.rules.flow.twoTokensAtOnce`,{node:gd(r)}),elements:[r.id],trace:[..._(n),...d,r.id]});return}let ee=o(x),C=s.get(ee);if(C===void 0){if(c.length>=sd){f=!0,p.add(n);return}C=c.length,s.set(ee,C),c.push(x),l.push({from:n,fired:d})}h.push(C),v.push({to:C,fired:d,choice:b,produced:y?[]:u.map(t=>e.flows[t].id)})};for(let i of e.nodes){if(i.kind===`boundary`||i.kind===`start`)continue;let o=i.incoming.filter(e=>m[e]>0);if(o.length!==0){if(i.kind===`and`)o.length===i.incoming.length&&y(i.incoming,i.outgoing,[i.id]);else if((i.kind===`activity`||i.kind===`xor`)&&o.length>1&&!g(i)&&a.push({kind:`NO-SYNCHRONIZATION`,title:cd(`NO-SYNCHRONIZATION`),detail:t(`app.rules.flow.twoBranchesAtOnce`,{node:gd(i)}),elements:[i.id],trace:_(n)}),i.kind===`or`){if(i.incoming.filter(e=>m[e]===0).some(e=>m.some((t,n)=>t>0&&!i.incoming.includes(n)&&r[n][e])))continue;let t=md(i,e.flows);for(let e of t)y(o,e,[i.id],!1,t.length>1?{node:i.id,ways:e,boundary:null}:null)}else for(let t of o){if(i.kind===`end`){y([t],[],[i.id],i.terminate);continue}let n=md(i,e.flows);for(let e of n){y([t],e,[i.id],!1,n.length>1?{node:i.id,ways:e,boundary:null}:null);for(let n of i.boundaries){let r=n.interrupting?n.outgoing:[...e,...n.outgoing];y([t],r,[i.id,n.id],!1,{node:i.id,ways:e,boundary:n.id})}}}}}u.push(h),d.push(v)}let v=c.map(()=>[]);u.forEach((e,t)=>e.forEach(e=>v[e].push(t)));let y=e=>{let t=Array(c.length).fill(!1),n=[...e];for(n.forEach(e=>t[e]=!0);n.length>0;){let e=n.pop();for(let r of v[e])t[r]||(t[r]=!0,n.push(r))}return t},b=e=>u[e]!==void 0,x=e=>c[e].some(e=>e>0),S=c.map((e,t)=>t).filter(e=>!x(e)),ee=c.map((e,t)=>t).filter(e=>x(e)&&b(e)&&u[e].length===0&&!p.has(e)),C=y([...S,...p]),te=y(ee),w=t=>[...new Set(t.flatMap((t,n)=>t>0?[e.flows[n].target]:[]))],T=ee.find(e=>!C[e]);if(T!==void 0){let n=c[T],r=w(n),i=_(T),o=new Map(e.nodes.map(e=>[e.id,e])),s=[...i].reverse().map(e=>o.get(e)).find(e=>e&&(e.kind===`xor`||e.kind===`or`||e.kind===`boundary`)),l=s?s.kind===`boundary`?t(`app.rules.flow.leftThroughBoundary`,{host:s.host?gd(s.host):t(`app.rules.flow.anActivity`),event:s.named?` ${gd(s)}`:``}):t(`app.rules.flow.sentDownAnotherBranch`,{turn:ld(gd(s))}):``,u=r.map(r=>{let i=r.incoming.filter(e=>n[e]===0).map(t=>_d(e.flows[t])),a=gd(r);return i.length>0?t(`app.rules.flow.waitsFor`,{who:ld(a),missing:i.join(t(`app.rules.flow.and`)),arrives:i.length===1?t(`app.rules.flow.arrives`):t(`app.rules.flow.arrive`)}):t(`app.rules.flow.waitsAndCannotContinue`,{who:ld(a)})}).join(` `)+l;a.push({kind:`DEADLOCK`,title:cd(`DEADLOCK`),detail:u,elements:r.map(e=>e.id),trace:i})}let ne=c.findIndex((e,t)=>x(t)&&b(t)&&!C[t]&&!te[t]);if(ne>=0&&!f){let e=w(c[ne]);a.push({kind:`NEVER-FINISHES`,title:cd(`NEVER-FINISHES`),detail:t(`app.rules.flow.noPathToAnEnd`,{nodes:e.map(gd).join(t(`app.rules.flow.and`))}),elements:e.map(e=>e.id),trace:_(ne)})}f&&a.push({kind:`TOO-COMPLEX`,title:cd(`TOO-COMPLEX`),detail:t(`app.rules.flow.tooManyStates`,{states:sd}),elements:[],trace:[]});let E=a.filter(e=>e.kind===`DEADLOCK`).flatMap(e=>e.elements),re=vd(e.nodes.filter(e=>E.includes(e.id)));return h.forEach(e=>re.add(e)),{problems:a,fired:i,states:c.length,consequences:re,graph:{tokens:c,edges:d}}}function bd(e){let t=e.nodes.filter(e=>e.kind===`start`),n=e.nodes.filter(e=>e.kind===`activity`&&e.incoming.length===0);return t.length>0?t.map(t=>{let n=e.flows.map(()=>0);return t.outgoing.forEach(e=>n[e]+=1),{fired:[t.id],tokens:n,flows:t.outgoing.map(t=>e.flows[t].id)}}):[{fired:n.map(e=>e.id),tokens:e.flows.map((e,t)=>+!!n.some(e=>e.outgoing.includes(t))),flows:e.flows.filter((e,t)=>n.some(e=>e.outgoing.includes(t))).map(e=>e.id)}]}function xd(e){let n=bd(e),r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Set,a=[],o=0;for(let t of n){let n=yd(e,t);n.fired.forEach(e=>r.add(e)),n.consequences.forEach(e=>i.add(e)),a.push(...n.problems),o+=n.states}for(let n of e.nodes){if(r.has(n.id)||n.kind===`start`||i.has(n.id))continue;let e=n.incoming.length===0&&n.kind!==`boundary`?t(`app.rules.flow.nothingLeadsToIt`):t(`app.rules.flow.noPathReachesIt`);a.push({kind:`DEAD-ELEMENT`,title:cd(`DEAD-ELEMENT`),detail:t(`app.rules.flow.neverRuns`,{node:ld(gd(n)),cause:e}),elements:[n.id],trace:[]})}return{problems:a,fired:r,states:o,consequences:i}}function Sd(e){let t=fd(e),n=[...td(e)],r=0;for(let e of t){let t=xd(e);r+=t.states;for(let e of t.problems)n.some(t=>t.kind===e.kind&&t.elements.join()===e.elements.join())||n.push(e)}return{problems:n,scopes:t.length,states:r}}function Cd(e,t,n){let r=e=>t.get(e)?.name??e;return{decision:r(n.node),way:Tu(n.ways.map(t=>e.flows[t].name||`to "${e.flows[t].target.name}"`)),condition:Tu(n.ways.map(t=>e.flows[t].condition).filter(Boolean)),boundary:n.boundary?r(n.boundary):null,decisionId:n.node,flowIds:n.ways.map(t=>e.flows[t].id),takes:n.ways.map(t=>e.flows[t].condition).filter(Boolean),avoids:(t.get(n.node)?.outgoing??[]).filter(e=>!n.ways.includes(e)).map(t=>e.flows[t].condition).filter(Boolean),boundaryId:n.boundary}}function wd(e,t,n,r,i,a){let o=e=>t.get(e)?.name??e,s=r.filter((e,t)=>r.indexOf(e)===t);return{process:e.id,start:o(n.fired[0]),decisions:a.map(n=>Cd(e,t,n)),steps:s.filter(e=>t.get(e)?.kind===`activity`||t.get(e)?.kind===`boundary`).map(o),ends:s.filter(e=>t.get(e)?.kind===`end`).map(o),startId:n.fired[0],stepIds:s.filter(e=>t.get(e)?.kind===`activity`||t.get(e)?.kind===`boundary`),endIds:s.filter(e=>t.get(e)?.kind===`end`),firedIds:r,flowIds:i}}function Td(e,t,n,r,i){let a=[],o=/* @__PURE__ */ new Set,s=/* @__PURE__ */ new Set,c=2e5,l=!1,u=(d,f,p,m,h)=>{if(a.length>=i||c--<=0){l=!0;return}let g=h.map(e=>`${e.node}:${e.ways.join(`+`)}:${e.boundary??``}`).join(`|`),_=`${d}#${g}`;if(!o.has(_)){if(o.add(_),r.tokens[d].every(e=>e===0)){if(s.has(g))return;s.add(g),a.push(wd(e,t,n,p,m,h))}else for(let e of r.edges[d]??[])f.has(e.to)||(f.add(e.to),u(e.to,f,[...p,...e.fired],[...m,...e.produced],e.choice?[...h,e.choice]:h),f.delete(e.to))}};return u(0,/* @__PURE__ */ new Set([0]),[...n.fired],[...n.flows],[]),{list:a,capped:l}}function Ed(e,t,n,r){let{tokens:i,edges:a}=r,o=e=>i[e].every(e=>e===0),s=i.map(()=>[]);a.forEach((e,t)=>e.forEach(e=>s[e.to].push({from:t,edge:e})));let c=i.map(()=>null),l=i.map((e,t)=>o(t)),u=l.flatMap((e,t)=>e?[t]:[]);for(let e=0;e<u.length;e+=1)for(let{from:t,edge:n}of s[u[e]])l[t]||(l[t]=!0,c[t]=n,u.push(t));let d=i.map(()=>null),f=[0],p=/* @__PURE__ */ new Set([0]);for(let e=0;e<f.length;e+=1)for(let t of a[f[e]]??[])p.has(t.to)||(p.add(t.to),d[t.to]={from:f[e],edge:t},f.push(t.to));let m=/* @__PURE__ */ new Set([...n.fired,...n.flows]),h=/* @__PURE__ */ new Set,g=[];for(let r of f)for(let i of a[r]??[]){if(!l[i.to]||[...i.fired,...i.produced].every(e=>m.has(e)))continue;let a=[];for(let e=r;d[e];e=d[e].from)a.unshift(d[e].edge);a.push(i);for(let e=i.to;!o(e)&&c[e];e=c[e].to)a.push(c[e]);let s=a.filter(e=>e.choice).map(e=>`${e.choice?.node}:${e.choice?.ways.join(`+`)}:${e.choice?.boundary??``}`).join(`|`);a.forEach(e=>[...e.fired,...e.produced].forEach(e=>m.add(e))),!h.has(s)&&(h.add(s),g.push(wd(e,t,n,[...n.fired,...a.flatMap(e=>e.fired)],[...n.flows,...a.flatMap(e=>e.produced)],a.flatMap(e=>e.choice?[e.choice]:[]))))}return g}function Dd(e,t=64){let n=[],r=!1;for(let i of fd(e)){let e=new Map(i.nodes.map(e=>[e.id,e]));for(let a of bd(i)){let{graph:o}=yd(i,a),s=Td(i,e,a,o,t);s.capped?(r=!0,n.push(...Ed(i,e,a,o))):n.push(...s.list)}}return{scenarios:n,capped:r}}function Od(e,t=64){return Dd(e,t).scenarios}const kd=/* @__PURE__ */ new Set([`bpmn:SubProcess`,`bpmn:Transaction`]),Ad=/* @__PURE__ */ new Map([[`bpmn:AdHocSubProcess`,`adhoc`],[`bpmn:CallActivity`,`callActivity`]]);function jd(e){let n=Ad.get(e);return n?t(`app.scenarios.notFollowed.${n}`):void 0}function Md(e){let t=/* @__PURE__ */ new Map,n=e=>{for(let r of e??[])r.id&&(kd.has(r.$type)||Ad.has(r.$type))&&t.set(r.id,{id:r.id,name:r.name?.replace(/\s+/g,` `).trim()??``,type:r.$type,followed:kd.has(r.$type)&&!r.triggeredByEvent,why:jd(r.$type),repeats:!!r.loopCharacteristics}),r.flowElements&&n(r.flowElements)},r=e?.rootElements??[];for(let e of r)if(e.$type===`bpmn:Process`&&n(e.flowElements),e.$type===`bpmn:Collaboration`)for(let t of e.participants??[])n(t.processRef?.flowElements);return t}function Nd(e){return[...new Set(e)]}function Pd(e,t,n){let r=e.firedIds.indexOf(t);if(r<0)return e;let i=[...e.firedIds.slice(0,r+1),...n.firedIds,...e.firedIds.slice(r+1)],a=/* @__PURE__ */ new Map;[e,n].forEach(e=>{e.stepIds.forEach((t,n)=>a.set(t,e.steps[n])),e.endIds.forEach((t,n)=>a.set(t,e.ends[n]))});let o=/* @__PURE__ */ new Set([...e.stepIds,...n.stepIds]),s=/* @__PURE__ */ new Set([...e.endIds,...n.endIds]),c=Nd(i.filter(e=>o.has(e))),l=Nd(i.filter(e=>s.has(e)));return{...e,decisions:[...e.decisions,...n.decisions],stepIds:c,steps:c.map(e=>a.get(e)??e),endIds:l,ends:l.map(e=>a.get(e)??e),firedIds:i,flowIds:[...e.flowIds,...n.flowIds]}}function Fd(e,t,n){let r=Md(e);if(![...r.values()].some(e=>e.followed))return t;let i=n??Dd(e).scenarios,a=/* @__PURE__ */ new Map,o=e=>{let t=a.get(e);if(t)return t;a.set(e,[]);let n=s(i.filter(t=>t.process===e));return a.set(e,n),n},s=e=>{let t=[],n=/* @__PURE__ */ new Set;for(let i of e){let e=Nd(i.firedIds).filter(e=>r.get(e)?.followed&&o(e).length>0),a=i;for(let t of e)a=Pd(a,t,o(t)[0]);t.push(a);for(let r of e)n.has(r)||(n.add(r),o(r).slice(1).forEach(n=>{let a=i;for(let t of e)a=Pd(a,t,t===r?n:o(t)[0]);t.push(a)}))}return t};return s(t)}function Id(e){let t={};for(let[n,r]of Object.entries(e)){let e=n.split(`.`);if(e.includes(`__proto__`))continue;let i=t;e.slice(0,-1).forEach(e=>{Object.hasOwn(i,e)&&typeof i[e]==`object`&&i[e]!==null||(i[e]={}),i=i[e]}),i[e[e.length-1]]=r}return t}function Ld(e){let n=e.decisions.map(e=>e.boundary?t(`app.testCases.scenarioName.boundaryFires`,{boundary:e.boundary}):t(`app.testCases.scenarioName.way`,{decision:e.decision,way:e.way}));return[e.start,...n,...e.ends].join(` → `)}function Rd(e,n){let r=od(e.decisions.map(e=>({takes:e.takes,avoids:e.avoids}))),i=r.values,a=[...r.unresolved.map(e=>t(`app.testCases.unresolved.chooseVariables`,{condition:e})),...r.avoided.map(e=>t(`app.testCases.unresolved.chooseVariablesWithout`,{condition:e}))];e.decisions.filter(e=>!e.boundaryId&&e.takes.length===0&&e.avoids.length===0).forEach(e=>a.push(t(`app.testCases.unresolved.noConditionForTheWay`,{decision:e.decision,way:e.way})));for(let t of[e.startId,...e.stepIds]){let e=n.get(t)?.correlationKey?.replace(/^=/,``).trim();e&&/^[A-Za-z_]\w*$/.test(e)&&i[e]===void 0&&(i[e]=`${e}-1`)}return{values:i,unresolved:a}}function zd(e,t){let n=e.correlationKey?.replace(/^=/,``).trim()??``;return/^[A-Za-z_]\w*$/.test(n)&&t[n]!==void 0?String(t[n]):/^"[^"]*"$/.test(n)?n.slice(1,-1):`correlation-key`}function Bd(e){return!!(e.job||e.external)}function Vd(e){return!!(e.delegateClass||e.delegateExpression||e.expression)}function Hd(e,t){let n=/* @__PURE__ */ new Set,r=[...t];for(;r.length>0;){let t=r.pop();n.has(t)||(n.add(t),r.push(...e.get(t)?.follows??[]))}return n}function Ud(e,t){let n=[...e.stepIds];for(let r of e.stepIds){let e=t.get(r);if(!e?.host||e.interrupting!==!1)continue;let i=e.host,a=Hd(t,t.get(i)?.follows??[]),o=[...Hd(t,e.follows??[])].filter(e=>!a.has(e)&&n.includes(e));if(o.length===0)continue;let s=Math.max(...o.map(e=>n.indexOf(e))),c=n.indexOf(i);c<0||c>s||(n.splice(c,1),n.splice(s,0,i))}return n}const Wd=/* @__PURE__ */ new Set([`message`,`timer`,`signal`]);function Gd(e){return/^[aeiou]/i.test(e)?`an`:`a`}function Kd(e){let n=`app.testCases.kind.${e}`,r=t(n);return r===n?`${Gd(e)} ${e} event`:r}function qd(e,n,r){let i=n.get(e.startId),a=!!i?.event&&i.event!==`none`;if(a&&!Wd.has(i.event)){let e=i.event;return{problem:t(`app.testCases.startsOnAnEvent`,{kind:Kd(e)})}}let{values:o,unresolved:s}=r?{values:r,unresolved:[]}:Rd(e,n),c=new Map(e.decisions.filter(e=>e.boundaryId).map(e=>[e.decisionId,n.get(e.boundaryId)])),l=[{type:`CREATE_PROCESS_INSTANCE`,processDefinitionSelector:{processDefinitionId:e.process},variables:Id(o),...a?{startInstructions:[{elementId:e.startId}]}:{}}],u={},d=[],f=new Set(e.stepIds.map(e=>n.get(e)?.host).filter(e=>!!e)),p=e=>e.job??e.external,m=e=>[...n.values()].filter(t=>p(t)===p(e)).length>1,h=e=>{let t=e?n.get(e):void 0;t&&Bd(t)&&(u[t.id]={then:`hold`})};for(let r of Ud(e,n)){let e=n.get(r);if(!e)continue;if(e.host){e.event===`error`&&l.push({type:`THROW_BPMN_ERROR_FROM_JOB`,jobSelector:{elementId:e.host},errorCode:e.errorCode||`ANY_ERROR`}),e.event===`timer`&&(u[r]={then:`fire`},e.interrupting!==!1&&h(e.host)),e.event===`message`&&e.message&&(l.push({type:`CORRELATE_MESSAGE`,name:e.message,correlationKey:zd(e,o)}),e.interrupting!==!1&&h(e.host)),e.event===`signal`&&e.signal&&(l.push({type:`BROADCAST_SIGNAL`,signalName:e.signal}),e.interrupting!==!1&&h(e.host)),d.push(r);continue}let i=c.get(r);i&&i.interrupting!==!1||(e.type===`bpmn:UserTask`&&!e.job&&!e.external?l.push({type:`COMPLETE_USER_TASK`,userTaskSelector:{elementId:r}}):Bd(e)&&e.repeats&&!f.has(r)&&!m(e)?l.push({type:`MOCK_JOB_WORKER_COMPLETE_JOB`,jobType:p(e)}):Bd(e)?(e.repeats&&s.push(t(`app.testCases.unresolved.runsOncePerItem`,{name:e.name??r})),l.push({type:`COMPLETE_JOB`,jobSelector:{elementId:r}})):Vd(e)?u[r]={then:`complete`}:e.event===`message`&&e.message?l.push({type:`CORRELATE_MESSAGE`,name:e.message,correlationKey:zd(e,o)}):e.event===`timer`?u[r]={then:`fire`}:e.event===`signal`&&e.type.includes(`Catch`)&&e.signal&&l.push({type:`BROADCAST_SIGNAL`,signalName:e.signal}),d.push(r))}d.push(...e.endIds);let g={processDefinitionId:e.process};l.push({type:`ASSERT_ELEMENT_INSTANCES`,processInstanceSelector:g,elementSelectors:d.map(e=>({elementId:e})),state:`IS_COMPLETED`},{type:`ASSERT_PROCESS_INSTANCE`,processInstanceSelector:g,state:`IS_COMPLETED`});let _={name:Ld(e),instructions:l};return s.length&&(_.description=t(`app.testCases.toFillIn`,{unresolved:s.join(`; `)})),Object.keys(u).length&&(_[`x-penstock`]={behaviours:u}),{testCase:_}}function Jd(e,n){let r=Rt(e),i=/* @__PURE__ */ new Map,a=new Set((e?.rootElements??[]).filter(e=>e.$type===`bpmn:Process`&&e.isExecutable!==!1).map(e=>e.id)),o=Dd(e),s=Fd(e,o.scenarios.filter(e=>a.has(e.process)),o.scenarios).filter(e=>!n||e.process===n).map(e=>({scenario:e,outcome:qd(e,r)})),c=s.filter(e=>`problem`in e.outcome).map(({scenario:e,outcome:t})=>({scenario:e,problem:t.problem}));return{items:s.filter(e=>`testCase`in e.outcome).map(({scenario:e,outcome:n})=>{let r=(i.get(n.testCase.name)??0)+1;return i.set(n.testCase.name,r),{scenario:e,testCase:r===1?n.testCase:{...n.testCase,name:t(`app.testCases.numberedCaseName`,{name:n.testCase.name,seen:r})}}}),unplannable:c,capped:o.capped}}const Yd=/* @__PURE__ */ new Set([`localhost`,`127.0.0.1`,`[::1]`,`::1`]);function Xd(e){if(!e)return null;try{return new URL(e).hostname.toLowerCase()}catch{return null}}function Zd(e){if(e.forTests)return`allowed`;let t=Xd(e.url);return t&&(Yd.has(t)||/^127(?:\.\d{1,3}){3}$/.test(t)||t.endsWith(`.localhost`))?`confirm`:`refused`}function Qd(e){let n=Xd(e)??t(`app.testCases.safety.thisEngine`);return t(`app.testCases.safety.refusal`,{where:n})}async function $d(e,t,n){let r=[],i=[];for(let a of await t.list())if(!(n-a.at<=9e5)){a.instance&&await e.cancel(a.instance).catch(()=>void 0);try{await e.remove(a.deployment)}catch(e){if(!(e instanceof B&&e.status===404)){i.push(a.deployment);continue}}await t.drop(a.deployment),r.push(a.deployment)}return{removed:r,kept:i}}function ef(e,t,n){let r=()=>{try{let n=JSON.parse(e.getItem(t)??`{}`);return n&&typeof n==`object`&&!Array.isArray(n)?n:{}}catch{return{}}},i=()=>{let e=r()[n];return Array.isArray(e)?e:[]},a=i=>{let a=r();i.length?a[n]=i:delete a[n],e.setItem(t,JSON.stringify(a))};return{list:async()=>i(),add:async e=>a([...i().filter(t=>t.deployment!==e.deployment),e]),drop:async e=>a(i().filter(t=>t.deployment!==e))}}function tf(e){return t(`app.testCases.count.testBuilds`,{count:e})}function nf(e){return[...e.removed.length?[t(`app.testCases.leftovers.removed`,{builds:tf(e.removed.length)})]:[],...e.kept.length?[t(`app.testCases.leftovers.kept`,{builds:tf(e.kept.length)})]:[]]}const rf=/\.(bpmn20\.xml|bpmn\.xml|bpmn)$/i,af=[`process`,`decision`,`form`];function of(e){return e.replace(/\\/g,`/`)}function sf(e){return of(e).split(`/`).pop()??e}function cf(e){return rf.test(e)?`process`:/\.dmn$/i.test(e)?`decision`:/\.form$/i.test(e)?`form`:null}function lf(e,t){let n=of(e).split(`/`).slice(0,-1),r=of(t).split(`/`).slice(0,-1),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i+=1;return i}async function uf(e){let t=[...Rt(await r(e)).values()],n=e=>[...new Set(t.map(e).filter(e=>!!e))];return{process:n(e=>e.calledProcess),decision:n(e=>e.decision),form:n(e=>e.form)}}async function df(e,t){let n=[{path:e.path,name:sf(e.path),content:e.content}],r=/* @__PURE__ */ new Set([of(e.path)]),i={process:/* @__PURE__ */ new Set,decision:/* @__PURE__ */ new Set,form:/* @__PURE__ */ new Set},a=await uf(e.content);hl(`process`,e.content).forEach(e=>i.process.add(e));let o=/* @__PURE__ */ new Map,s=async e=>{let n=[];for(let i of t){if(cf(i.path)!==e||r.has(of(i.path)))continue;let t=o.get(i.path);if(!t){let n=await i.read().catch(()=>``);t={content:n,ids:hl(e,n)},o.set(i.path,t)}n.push({path:i.path,...t})}return n};for(;af.some(e=>a[e].some(t=>!i[e].has(t)));)for(let t of af){let o=a[t].filter(e=>!i[t].has(e));if(a[t]=[],o.length===0)continue;let c=await s(t);for(let s of o){i[t].add(s);let o=c.filter(e=>e.ids.includes(s)&&!r.has(of(e.path))).sort((t,n)=>lf(e.path,n.path)-lf(e.path,t.path))[0];if(o&&(r.add(of(o.path)),n.push({path:o.path,name:sf(o.path),content:o.content}),o.ids.forEach(e=>i[t].add(e)),t===`process`)){let e=await uf(o.content);af.forEach(t=>a[t].push(...e[t]))}}}return n}function ff(e,t){let n=of(e),r=sf(e).replace(/\.json$/i,``);return t.find(e=>of(xr(e))===n)??t.find(e=>sf(e).replace(rf,``)===r)??null}async function pf(e,t){let n=[],r=/* @__PURE__ */ new Set,i=e=>{let t=of(e.path);r.has(t)||(r.add(t),n.push(e))};for(let n of e)rf.test(n.path)?(await df(n,t)).forEach(i):i({path:n.path,name:sf(n.path),content:n.content});return n}function mf(){return t(`app.testCases.suites.unlicensed`)}function hf(e){return e.split(/[\\/]/).pop()??e}function gf(e){let t=e.replace(/\\/g,`/`).lastIndexOf(`/.penstock/runs/`);return t>=0?e.replace(/\\/g,`/`).slice(t+1):e}function _f(e){switch(e.kind){case`suiteStarted`:return yu(`started`,e.suite,e.file);case`suiteFinished`:return yu(`finished`,e.suite,e.file);case`refused`:return[...bu(e.suite,e.file,{kind:`testStarted`,testCase:e.suite}),...bu(e.suite,e.file,{kind:`testFinished`,testCase:e.suite,outcome:`failed`,message:e.reason,durationMs:0,trace:null})];case`run`:return bu(e.suite,e.file,e.event);case`note`:return[e.text];case`result`:return e.kept?[t(`app.testCases.suites.traceOf`,{name:e.testCase.name,where:gf(e.kept)})]:[]}}function vf(){return{swept:/* @__PURE__ */ new Set,names:/* @__PURE__ */ new Set}}function yf(e,t,n){let r=t.join(`; `);return n?.({kind:`testStarted`,testCase:e}),n?.({kind:`testFinished`,testCase:e,outcome:`failed`,message:r,durationMs:0,trace:null}),{result:{outcome:`failed`,message:r,trace:null,recorded:[]},kept:null,durationMs:0}}async function bf(e,t){let n=mr(e);if(n.length>0)return yf(e.name,n,t.emit);if(!t.session.swept.has(t.key)){t.session.swept.add(t.key);for(let e of nf(await $d(t.engine,t.builds,Date.now())))await t.note?.(e)}let r=0,i=await mu(e,{engine:t.engine,resources:t.resources,runId:t.runId,signal:t.signal,builds:t.builds,onWait:t.onWait,stepTimeoutMs:t.stepTimeoutMs,pollMs:t.pollMs,settleReads:t.settleReads,emit:e=>{e.kind===`testFinished`&&(r=e.durationMs),t.emit?.(e)}});return{result:i,kept:i.trace&&t.keep?await t.keep(i.trace,$l(e.name,t.session.names)):null,durationMs:r}}async function xf(e,n,r,i,a){let o=hf(e),s=async t=>{await r({kind:`refused`,suite:o,file:e,reason:t})},c=await n.read(e).catch(()=>null),l=c===null?null:ur(c),u=l?.file?await n.diagramFor(e):null,d=u?await n.targetOf(u):null,f=l?l.file?u?d?null:t(`app.testCases.suites.noEngineToRunOn`,{diagram:hf(u)}):t(`app.testCases.suites.noDiagram`,{suite:o}):l.problems.join(`; `):n.unreadable?.(e)??t(`app.testCases.suites.cannotBeRead`,{suite:o});if(f||!l?.file||!u||!d)return await s(f??t(`app.testCases.suites.cannotRun`)),`next`;if(!a.licensed&&n.licensed&&!await n.licensed())return await s(mf()),`stop`;a.licensed=!0;let p=await n.refusal(d);if(p)return await s(p),`next`;let m=n.builds(d),h=n.engine(d,u),g=await n.resources(u),_=l.file.testCases.map((e,n)=>typeof e?.name==`string`&&e.name.trim()!==``?e:{...e,name:t(`app.testCases.suites.unnamedCase`,{number:n+1})});for(let t of _.filter(e=>!i.only||e.name===i.only)){if(i.signal?.aborted)break;let s=mr(l.file.testCases[_.indexOf(t)]);if(s.length>0){await r({kind:`result`,suite:o,file:e,testCase:t,result:yf(t.name,s,t=>{r({kind:`run`,suite:o,file:e,event:t})}).result,durationMs:0,kept:null});continue}let{result:c,kept:u,durationMs:f}=await bf(t,{engine:h,resources:g,runId:n.runId,builds:m,key:n.keyOf(d),session:a,signal:i.signal,stepTimeoutMs:i.stepTimeoutMs,pollMs:i.pollMs,settleReads:i.settleReads,note:e=>r({kind:`note`,text:e}),emit:t=>{r({kind:`run`,suite:o,file:e,event:t})},keep:n.keep?(t,r)=>n.keep(t,r,e):void 0});await r({kind:`result`,suite:o,file:e,testCase:t,result:c,durationMs:f,kept:u})}return`next`}async function Sf(e,n,r,i={}){let a={licensed:!1,swept:/* @__PURE__ */ new Set,names:/* @__PURE__ */ new Set};for(let o of e){if(i.signal?.aborted)return{stopped:!0};let e=hf(o);await r({kind:`suiteStarted`,suite:e,file:o});let s=`next`;try{s=await xf(o,n,r,i,a)}catch(n){await r({kind:`refused`,suite:e,file:o,reason:t(`app.testCases.penstockFailed`,{reason:n instanceof Error?n.message:String(n)})})}if(await r({kind:`suiteFinished`,suite:e,file:o}),s===`stop`)return{stopped:!0}}return{stopped:i.signal?.aborted===!0}}function Cf(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function wf(e,t){let n={...e};for(let[e,r]of Object.entries(t)){if(e===`__proto__`)continue;let t=n[e];n[e]=Cf(t)&&Cf(r)?wf(t,r):r}return n}function Tf(e){return!!(e.job||e.external)}function Ef(e){return!!(e.delegateClass||e.delegateExpression||e.expression)}function Df(e,t){let n=e;if((n.jobSelector??n.userTaskSelector)?.elementId===t.id)return!0;let r=t.job??t.external;return n.type===`MOCK_JOB_WORKER_COMPLETE_JOB`&&!!r&&n.jobType===r}function Of(e,n,r){let i={...e[`x-penstock`]?.behaviours??{}},a=e.instructions.filter(e=>Df(e,n)),o=e.instructions.filter(e=>!a.includes(e)),s=n.type===`bpmn:UserTask`&&!Tf(n);if(r.kind===`hold`)Ef(n)&&(i[n.id]={then:`hold`});else if(r.kind===`error`){if(s)return{problem:t(`app.testCases.taskTest.cannotThrow`,{element:n.id})};Tf(n)?o=[...o,{type:`THROW_BPMN_ERROR_FROM_JOB`,jobSelector:{elementId:n.id},errorCode:r.errorCode,...r.variables?{variables:r.variables}:{}}]:i[n.id]={then:`error`,errorCode:r.errorCode,...r.variables?{variables:r.variables}:{}}}else{let e=r.variables&&Object.keys(r.variables).length?{variables:r.variables}:{};s?o=[...o,{type:`COMPLETE_USER_TASK`,userTaskSelector:{elementId:n.id},...e}]:Tf(n)?o=[...o,{type:`COMPLETE_JOB`,jobSelector:{elementId:n.id},...e}]:Ef(n)?i[n.id]={then:`complete`,...e}:o=[...o,...a]}let c={name:e.name,instructions:o};return e.description&&(c.description=e.description),Object.keys(i).length&&(c[`x-penstock`]={behaviours:i}),c}function kf(e,t,n){let r=e.filter(e=>!n||e.process===n).filter(e=>e.startId===t||e.stepIds.includes(t)||e.endIds.includes(t)),i=e=>e.startId===t?0:e.stepIds.indexOf(t)>=0?e.stepIds.indexOf(t):e.stepIds.length;return[...r].sort((e,t)=>i(e)-i(t)||e.decisions.length-t.decisions.length)[0]??null}function Af(e,t){let n=e.stepIds.indexOf(t),r=e.endIds.includes(t);return{...e,stepIds:e.startId===t?[]:n>=0?e.stepIds.slice(0,n+1):e.stepIds,endIds:r?[t]:[]}}function jf(e,n){let r=Rt(e),i=new Set((e?.rootElements??[]).filter(e=>e.$type===`bpmn:Process`&&e.isExecutable!==!1).map(e=>String(e.id)));if(i.size===0)return{problem:t(`app.testCases.taskTest.noProcess`)};let a=Dd(e,256),o=kf(a.scenarios.filter(e=>i.has(e.process)),n.element,n.process);if(!o)return{problem:r.has(n.element)||a.scenarios.some(e=>e.startId===n.element)?t(`app.testCases.taskTest.noWay`,{element:n.element}):t(`app.testCases.taskTest.notFound`,{element:n.element})};let s=Af(o,n.element),c=Rd(o,r).values,l=qd(s,r,wf(Id(c),n.variables??{}));if(`problem`in l)return{problem:l.problem};let u=l.testCase,d={...u,name:t(`app.testCases.taskTest.name`,{element:n.element}),instructions:u.instructions.filter(e=>!String(e.type).startsWith(`ASSERT_`))};delete d.description;let f=r.get(n.element),p=f?Of(d,f,n.mode??{kind:`complete`}):d;return`instructions`in p?{testCase:p,process:o.process,path:[o.startId,...s.stepIds]}:{problem:p.problem}}function Mf(e){let t=/* @__PURE__ */ new Map;for(let n of e.steps)for(let e of[...n.in,...n.out,...n.changed])t.set(e.name,e.value);return[...t].map(([e,t])=>({name:e,value:t}))}function Nf(e,t,n=null){let r=t.trace,i=r?.steps.filter(t=>t.elementId===e)??[],a=i[i.length-1]??null;return{element:e,reached:!!a,elementState:a?.state??null,instanceState:r?.state??null,received:a?.in??[],sent:a?.out??[],variables:r?Mf(r):[],incidents:r?.incidents??[],failed:t.outcome===`failed`,message:t.message??null,trace:n}}function Pf(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function Ff(e,t){return t.x>=e.x&&t.x<=e.x+e.width&&t.y>=e.y&&t.y<=e.y+e.height}function If(e){return e.width*e.height}function Lf(e,t){let n=Math.max(e.x-t.x,0,t.x-(e.x+e.width)),r=Math.max(e.y-t.y,0,t.y-(e.y+e.height));return Math.hypot(n,r)}const Rf=/* @__PURE__ */ new Set([`startEvent`,`endEvent`,`intermediateCatchEvent`,`intermediateThrowEvent`,`boundaryEvent`]);function zf(e){return Rf.has(e.kind)}function Bf(e){return e.kind.endsWith(`Gateway`)}function Vf(e,t){let n=Pf(e),r=t.x-n.x,i=t.y-n.y;if(r===0&&i===0)return n;let a;return a=zf(e)?Math.min(e.width,e.height)/2/Math.hypot(r,i):Bf(e)?1/(Math.abs(r)/(e.width/2)+Math.abs(i)/(e.height/2)):Math.min(r===0?1/0:e.width/2/Math.abs(r),i===0?1/0:e.height/2/Math.abs(i)),{x:n.x+r*a,y:n.y+i*a}}function Hf(e,t){let n=Pf(e),r=Pf(t),i=(e,t,n,r)=>{let i={x:e.x+e.width,y:n.y},a={x:t.x,y:r.y};if(Math.abs(n.y-r.y)<1)return[i,{x:a.x,y:i.y}];let o=(i.x+a.x)/2;return[i,{x:o,y:i.y},{x:o,y:a.y},a]},a=(e,t,n,r)=>{let i={x:n.x,y:e.y+e.height},a={x:r.x,y:t.y};if(Math.abs(n.x-r.x)<1)return[i,{x:i.x,y:a.y}];let o=(i.y+a.y)/2;return[i,{x:i.x,y:o},{x:a.x,y:o},a]};return t.x>=e.x+e.width?i(e,t,n,r):e.x>=t.x+t.width?i(t,e,r,n).reverse():t.y>=e.y+e.height?a(e,t,n,r):e.y>=t.y+t.height?a(t,e,r,n).reverse():null}function Uf(e){let t=e.filter(e=>e.kind===`pool`);for(let e of t)t.some(t=>t!==e&&Ff(t,Pf(e))&&If(t)>If(e))&&(e.kind=`lane`)}const Wf=/* @__PURE__ */ new Set([`subProcess`,`transaction`,`eventSubProcess`]),Gf=/* @__PURE__ */ new Set([`task`,`callActivity`,`subProcess`,`transaction`,`eventSubProcess`]),Kf=/* @__PURE__ */ new Set([`pool`,`lane`,`subProcess`,`transaction`,`eventSubProcess`]),qf=/* @__PURE__ */ new Set([`dataObject`,`dataStore`]),Jf=/* @__PURE__ */ new Set([`startEvent`,`endEvent`,`intermediateCatchEvent`,`intermediateThrowEvent`,`boundaryEvent`]),Yf={task:`task`,user:`userTask`,service:`serviceTask`,script:`scriptTask`,send:`sendTask`,receive:`receiveTask`,manual:`manualTask`,businessRule:`businessRuleTask`},Xf={message:`messageEventDefinition`,timer:`timerEventDefinition`,error:`errorEventDefinition`,escalation:`escalationEventDefinition`,signal:`signalEventDefinition`,conditional:`conditionalEventDefinition`,link:`linkEventDefinition`,compensation:`compensateEventDefinition`,cancel:`cancelEventDefinition`,terminate:`terminateEventDefinition`},Zf={task:`Activity`,callActivity:`Activity`,subProcess:`Activity`,transaction:`Activity`,eventSubProcess:`Activity`,startEvent:`Event`,endEvent:`Event`,intermediateCatchEvent:`Event`,intermediateThrowEvent:`Event`,boundaryEvent:`Event`,exclusiveGateway:`Gateway`,parallelGateway:`Gateway`,inclusiveGateway:`Gateway`,complexGateway:`Gateway`,eventBasedGateway:`Gateway`,dataObject:`DataObjectReference`,dataStore:`DataStoreReference`,textAnnotation:`TextAnnotation`,pool:`Participant`,lane:`Lane`};function Qf(e){return pl(e).replace(/\r/g,``).replace(/\n/g,` `).replace(/\t/g,`	`)}function q(e,t,n=``){let r=Object.entries(t).filter(e=>e[1]!==void 0).map(([e,t])=>` ${e}="${Qf(t)}"`).join(``);return n?`<bpmn:${e}${r}>${n}</bpmn:${e}>`:`<bpmn:${e}${r}/>`}function $f(e){return e?.trim()?`<bpmn:documentation>${fl(e.trim())}</bpmn:documentation>`:``}function ep(e){return String(Math.round(e))}function tp(e){let n=[...e.notes],r=(e,t)=>n.push({level:e,message:t}),i=/* @__PURE__ */ new Set,a=(e,t)=>{let n=`${e}_${t.replace(/[^A-Za-z0-9_.-]/g,`_`)||`1`}`,r=n;for(let e=2;i.has(r);e+=1)r=`${n}_${e}`;return i.add(r),r},o=e=>e.name.replace(/\s+$/g,``),s=e=>e.name.trim()?`"${e.name.replace(/\s+/g,` `).trim()}"`:t(`app.import.note.unnamed`,{kind:t(`app.import.kind.${e.kind}`)}),c=e.nodes.map(e=>({...e,bpmnId:``})),l=new Map(c.map(e=>[e.id,e]));for(let e of c)e.kind===`lane`&&!c.some(t=>t!==e&&(t.kind===`pool`||t.kind===`lane`)&&Ff(t,Pf(e))&&If(t)>If(e))&&!(e.parent&&l.get(e.parent)?.kind===`pool`)&&(e.kind=`pool`,r(`assumed`,t(`app.import.note.laneAsPool`,{node:s(e)})));let u=c.filter(e=>Kf.has(e.kind)),d=e=>{if(e.kind===`pool`)return;let t=e.parent?l.get(e.parent):void 0,n=t=>t===e||!Kf.has(t.kind)?!1:e.kind!==`lane`||t.kind===`pool`||t.kind===`lane`;if(t&&n(t)&&If(t)>If(e))return t;let r=Pf(e);return u.filter(t=>n(t)&&Ff(t,r)&&(!Kf.has(e.kind)||If(t)>If(e))).sort((e,t)=>If(e)-If(t))[0]};for(let e of c)e.owner=d(e);let f=c.filter(e=>Gf.has(e.kind));for(let e of c){if(e.kind!==`boundaryEvent`)continue;let n=e.host?l.get(e.host):void 0,i=Pf(e),a=f.filter(t=>t!==e).map(e=>({candidate:e,distance:Lf(e,i)})).filter(e=>e.distance<=25).sort((e,t)=>e.distance-t.distance)[0],o=n&&Gf.has(n.kind)?n:a?.candidate;o?(e.hostNode=o,e.owner=o.owner):(e.kind=`intermediateCatchEvent`,r(`assumed`,t(`app.import.note.boundaryEvent`,{node:s(e)})))}let p=e=>{for(let t=e;t;t=t.owner)if(t.kind===`pool`)return t},m=c.filter(e=>e.kind===`pool`);if(m.length>0){let e=[];for(let t of c){if(t.kind===`pool`||p(t))continue;let n=m.map(e=>({pool:e,distance:Lf(e,Pf(t))})).sort((e,t)=>e.distance-t.distance)[0].pool;t.owner=t.kind===`lane`?n:t.owner??n,t.kind!==`lane`&&t.owner&&t.owner!==n||e.push(t)}if(e.length>0){let n=e.slice(0,5).map(s).join(`, `);r(`assumed`,t(`app.import.note.outsidePools`,{count:e.length,names:`${n}${e.length>5?`, ...`:``}`}))}}let h=e=>{let t=e.owner;return t?.kind===`lane`?t:void 0},g=e=>{for(let t=e.owner;t;t=t.owner)if(t.kind===`pool`||Wf.has(t.kind))return t};for(let e of c)e.bpmnId=a(e.kind===`pool`?`Participant`:e.kind===`lane`?`Lane`:Zf[e.kind]??`Element`,e.id);let _=[],v=e=>e.name.trim()?`"${e.name.replace(/\s+/g,` `).trim()}"`:t(`app.import.unnamedConnector`);for(let n of e.flows){let e=l.get(n.source),i=l.get(n.target);if(!e||!i){r(`unmapped`,t(`app.import.note.flowNotAttached`,{flow:v(n)}));continue}if(e.kind===`lane`||i.kind===`lane`){r(`unmapped`,t(`app.import.note.flowOnLane`,{flow:v(n)}));continue}let a=n.kind===`sequence`?`sequence`:n.kind===`message`?`message`:`association`,o=qf.has(e.kind),c=qf.has(i.kind);if(e.kind===`textAnnotation`||i.kind===`textAnnotation`)a=`association`;else if(o||c){let n=o?i:e,l=Jf.has(n.kind),u=n.kind===`endEvent`||n.kind===`intermediateThrowEvent`,d=Gf.has(n.kind)||l&&(o?u:!u);o&&c?a=`association`:d&&a!==`message`?a=o?`dataInput`:`dataOutput`:(a=`association`,r(`assumed`,t(`app.import.note.dataAssociation`,{node:s(n)})))}else if(e.kind===`pool`||i.kind===`pool`)a!==`message`&&r(`assumed`,t(`app.import.note.flowToPool`,{flow:v(n)})),a=`message`;else{let o=p(e)!==p(i);a===`sequence`&&o?(a=`message`,r(`assumed`,t(`app.import.note.flowAcrossPools`,{flow:v(n),from:s(e),to:s(i)}))):a===`message`&&!o?(a=`association`,r(`assumed`,t(`app.import.note.messageInsidePool`,{flow:v(n)}))):a===`sequence`&&g(e)!==g(i)&&(a=`association`,r(`assumed`,t(`app.import.note.flowAcrossSubProcess`,{flow:v(n)})))}_.push({flow:n,bpmnId:``,kind:a,source:e,target:i})}for(let e of _){let t={sequence:`Flow`,message:`Flow`,association:`Association`,dataInput:`DataInputAssociation`,dataOutput:`DataOutputAssociation`}[e.kind];if(e.bpmnId=a(t,e.flow.id),e.kind===`sequence`)e.container=g(e.source);else if(e.kind===`association`){let t=g(e.source);e.container=t===g(e.target)?t:void 0}}let y=/* @__PURE__ */ new Map,b=/* @__PURE__ */ new Map;for(let e of _)e.kind===`sequence`&&e.flow.isDefault&&b.set(e.source,e);let x=e=>c.filter(t=>g(t)===e&&t.kind!==`pool`&&t.kind!==`lane`),S=e=>{if(!e.definition)return``;let n=Xf[e.definition];return n?e.definition===`conditional`?`<bpmn:conditionalEventDefinition><bpmn:condition xsi:type="bpmn:tFormalExpression"/></bpmn:conditionalEventDefinition>`:e.definition===`link`?q(n,{name:e.name.trim()||`link`}):q(n,{}):(r(`lost`,t(`app.import.note.multipleEvent`,{node:s(e),kind:e.definition===`multiple`?`multiple`:t(`app.import.parallelMultiple`)})),``)},ee=e=>e.loop===`standard`?`<bpmn:standardLoopCharacteristics/>`:e.loop===`parallel`?`<bpmn:multiInstanceLoopCharacteristics/>`:e.loop===`sequential`?`<bpmn:multiInstanceLoopCharacteristics isSequential="true"/>`:``,C=e=>{let t=_.filter(t=>t.kind===`dataInput`&&t.target===e||t.kind===`dataOutput`&&t.source===e),n=_.filter(t=>t.kind===`dataInput`&&t.target===e),r=_.filter(t=>t.kind===`dataOutput`&&t.source===e);if(t.length===0)return``;let i=n.length>0?a(`Property`,e.id):``;return i&&y.set(e.id,i),(i?`<bpmn:property id="${i}" name="__targetRef_placeholder"/>`:``)+n.map(e=>`<bpmn:dataInputAssociation id="${e.bpmnId}"><bpmn:sourceRef>${e.source.bpmnId}</bpmn:sourceRef><bpmn:targetRef>${i}</bpmn:targetRef></bpmn:dataInputAssociation>`).join(``)+r.map(e=>`<bpmn:dataOutputAssociation id="${e.bpmnId}"><bpmn:targetRef>${e.target.bpmnId}</bpmn:targetRef></bpmn:dataOutputAssociation>`).join(``)},te=e=>{let t={id:e.bpmnId,name:o(e)||void 0},n=b.get(e),r=n?{...t,default:n.bpmnId}:t,i=$f(e.documentation);switch(e.kind){case`task`:return q(Yf[e.taskType??`task`],r,i+C(e)+ee(e));case`callActivity`:return q(`callActivity`,r,i+C(e)+ee(e));case`subProcess`:case`transaction`:case`eventSubProcess`:return q(e.kind===`transaction`?`transaction`:`subProcess`,{...r,triggeredByEvent:e.kind===`eventSubProcess`?`true`:void 0},i+C(e)+ee(e)+ne(e));case`startEvent`:return q(`startEvent`,{...t,isInterrupting:e.interrupting===!1?`false`:void 0},i+C(e)+S(e));case`endEvent`:return q(`endEvent`,t,i+C(e)+S(e));case`intermediateCatchEvent`:return q(`intermediateCatchEvent`,t,i+C(e)+S(e));case`intermediateThrowEvent`:return q(`intermediateThrowEvent`,t,i+C(e)+S(e));case`boundaryEvent`:return q(`boundaryEvent`,{...t,cancelActivity:e.interrupting===!1?`false`:void 0,attachedToRef:e.hostNode?.bpmnId},i+C(e)+S(e));case`exclusiveGateway`:case`parallelGateway`:case`inclusiveGateway`:case`complexGateway`:case`eventBasedGateway`:return q(e.kind,r,i);case`dataObject`:return`${q(`dataObject`,{id:`${e.bpmnId}_object`})}${q(`dataObjectReference`,{...t,dataObjectRef:`${e.bpmnId}_object`},``)}`;case`dataStore`:return q(`dataStoreReference`,t,i);default:return``}},w=e=>{let t=x(e).filter(e=>e.kind===`textAnnotation`),n=_.filter(t=>t.kind===`association`&&t.container===e);return t.map(e=>q(`textAnnotation`,{id:e.bpmnId},`<bpmn:text>${fl(e.name.trim())}</bpmn:text>`)).join(``)+n.map(e=>q(`association`,{id:e.bpmnId,sourceRef:e.source.bpmnId,targetRef:e.target.bpmnId})).join(``)},T=e=>{let t=x(e).filter(e=>e.kind!==`textAnnotation`),n=_.filter(t=>t.kind===`sequence`&&t.container===e);return t.map(te).join(``)+n.map(e=>q(`sequenceFlow`,{id:e.bpmnId,name:e.flow.name.trim()||void 0,sourceRef:e.source.bpmnId,targetRef:e.target.bpmnId})).join(``)};function ne(e){return T(e)+w(e)}let E=e=>{let t=e=>c.filter(t=>t.kind===`lane`&&t.owner===e).map(e=>{let n=c.filter(t=>h(t)===e&&t.kind!==`textAnnotation`&&t.kind!==`pool`&&t.kind!==`lane`&&!qf.has(t.kind)).map(e=>`<bpmn:flowNodeRef>${e.bpmnId}</bpmn:flowNodeRef>`).join(``),r=t(e);return q(`lane`,{id:e.bpmnId,name:o(e)||void 0},n+(r?`<bpmn:childLaneSet id="${e.bpmnId}_children">${r}</bpmn:childLaneSet>`:``))}).join(``),n=t(e);return n?`<bpmn:laneSet id="${e.bpmnId}_lanes">${n}</bpmn:laneSet>`:``},re=m.length>0,ie=/* @__PURE__ */ new Map,ae=``,D=``;if(re){D=a(`Collaboration`,`1`);let e=[];for(let t of m)if(c.some(e=>e!==t&&p(e)===t&&e.kind!==`lane`)||c.some(e=>e.kind===`lane`&&p(e)===t)){let n=a(`Process`,t.id);ie.set(t,n),e.push(q(`participant`,{id:t.bpmnId,name:o(t)||void 0,processRef:n})),ae+=q(`process`,{id:n,isExecutable:`false`},$f(t.documentation)+E(t)+ne(t))}else e.push(q(`participant`,{id:t.bpmnId,name:o(t)||void 0}));let t=_.filter(e=>e.kind===`message`).map(e=>q(`messageFlow`,{id:e.bpmnId,name:e.flow.name.trim()||void 0,sourceRef:e.source.bpmnId,targetRef:e.target.bpmnId})).join(``),n=_.filter(e=>e.kind===`association`&&!e.container).map(e=>q(`association`,{id:e.bpmnId,sourceRef:e.source.bpmnId,targetRef:e.target.bpmnId})).join(``);ae=q(`collaboration`,{id:D},e.join(``)+t+n)+ae}else{let e=a(`Process`,`1`);ie.set(void 0,e),D=e,ae=q(`process`,{id:e,isExecutable:`false`},ne(void 0))}let oe=e=>e.kind===`pool`?0:e.kind===`lane`?1:Wf.has(e.kind)?2:3,se=e=>c.some(t=>t.owner===e),ce=[...c].sort((e,t)=>oe(e)-oe(t)).map(e=>{let t={id:`${e.bpmnId}_di`,bpmnElement:e.bpmnId};(e.kind===`pool`||e.kind===`lane`)&&(t.isHorizontal=e.horizontal===!1?`false`:`true`),Wf.has(e.kind)&&(t.isExpanded=se(e)?`true`:`false`),e.kind===`exclusiveGateway`&&(t.isMarkerVisible=`true`);let n=`<dc:Bounds x="${ep(e.x)}" y="${ep(e.y)}" width="${ep(e.width)}" height="${ep(e.height)}"/>`;return`<bpmndi:BPMNShape${Object.entries(t).filter(e=>e[1]!==void 0).map(([e,t])=>` ${e}="${Qf(t)}"`).join(``)}>${n}</bpmndi:BPMNShape>`}).join(``),le=e=>{let{source:t,target:n,flow:r}=e,i=r.points??[];if(i.length===0&&r.orthogonal){let e=Hf(t,n);if(e)return e}let a=Vf(t,i[0]??Pf(n)),o=Vf(n,i[i.length-1]??Pf(t));return[a,...i,o]},ue=_.map(e=>{let t=le(e).map(e=>`<di:waypoint x="${ep(e.x)}" y="${ep(e.y)}"/>`).join(``);return`<bpmndi:BPMNEdge id="${e.bpmnId}_di" bpmnElement="${e.bpmnId}">${t}</bpmndi:BPMNEdge>`}).join(``),O=D;return{xml:`<?xml version="1.0" encoding="UTF-8"?>\n<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="${a(`Definitions`,`1`)}" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Penstock">\n${ae}\n<bpmndi:BPMNDiagram id="${a(`BPMNDiagram`,`1`)}"><bpmndi:BPMNPlane id="${a(`BPMNPlane`,`1`)}" bpmnElement="${O}">${ce}${ue}</bpmndi:BPMNPlane></bpmndi:BPMNDiagram>\n</bpmn:definitions>\n`,notes:n,summary:{elements:c.filter(e=>e.kind!==`pool`&&e.kind!==`lane`).length,flows:_.length,pools:m.length,lanes:c.filter(e=>e.kind===`lane`).length}}}var np=class extends Error{};const rp=`http://www.omg.org/spec/BPMN/20100524/MODEL`,ip=/* @__PURE__ */ new Set([rp,`http://www.omg.org/spec/BPMN/20100524/DI`,`http://www.omg.org/spec/DD/20100524/DC`,`http://www.omg.org/spec/DD/20100524/DI`,`http://www.w3.org/2001/XMLSchema-instance`,`http://www.w3.org/XML/1998/namespace`,`http://camunda.org/schema/1.0/bpmn`,`http://camunda.org/schema/zeebe/1.0`,`http://camunda.org/schema/modeler/1.0`,`http://bpmn.io/schema/bpmn/biocolor/1.0`,`http://www.omg.org/spec/BPMN/non-normative/color/1.0`]);function ap(e,t){let n=`${t.slice(0,4e3)} ${e.attrs.exporter??``}`.toLowerCase();return n.includes(`signavio`)?`Signavio`:n.includes(`bizagi`)?`Bizagi`:`BPMN 2.0`}function op(e){let t=e.toLowerCase();return t.includes(`signavio`)?`Signavio`:t.includes(`bizagi`)?`Bizagi`:e}function sp(e,t){let n=t.indexOf(`:`);return n<0||t.startsWith(`xmlns`)?null:e.scope.get(t.slice(0,n))??``}function cp(e){return e.text.trim()!==``||e.children.length>0||Object.entries(e.attrs).some(([e,t])=>!e.startsWith(`xmlns`)&&t.trim()!==``)}function lp(e){let n=W(e);if(n.local!==`definitions`||n.ns!==rp)throw new np(t(`app.import.failure.notBpmnXml`));let r=ap(n,e),i=/* @__PURE__ */ new Map,a=(e,t)=>{let n=op(e),r=i.get(n)??/* @__PURE__ */ new Map;r.set(t,(r.get(t)??0)+1),i.set(n,r)},o=e=>{for(let t of Object.keys(e.attrs)){let n=sp(e,t);n===null||ip.has(n)||(e.attrs[t].trim()!==``&&a(n,t),delete e.attrs[t])}e.children=e.children.filter(e=>{if(ip.has(e.ns))return!0;if(e.local===`signavioMetaData`||e.local===`signavioDiagramMetaData`)(e.attrs.metaValue??``).trim()!==``&&a(e.ns,e.attrs.metaKey??e.local);else if(cp(e)){let t=e.children.filter(e=>cp(e)),n=Object.entries(e.attrs).filter(([e,t])=>!e.startsWith(`xmlns`)&&t.trim()!==``).map(([e])=>e);if(n.length>0)for(let t of n)a(e.ns,t.includes(`:`)?t.slice(t.indexOf(`:`)+1):t);else if(t.length>0)for(let n of t)a(e.ns,n.local);else a(e.ns,e.local)}return!1});for(let t of e.children)o(t);e.children=e.children.filter(e=>e.local!==`extensionElements`||e.ns!==rp||e.children.length!==0||e.text.trim()!==``)};o(n);let s=/* @__PURE__ */ new Set,c=e=>{s.add(e.prefix);for(let t of Object.keys(e.attrs))t.includes(`:`)&&!t.startsWith(`xmlns`)&&s.add(t.slice(0,t.indexOf(`:`)));e.children.forEach(c)};c(n);let l=e=>{for(let t of Object.keys(e.attrs))t.startsWith(`xmlns:`)&&!ip.has(e.attrs[t])&&!s.has(t.slice(6))&&delete e.attrs[t];e.children.forEach(l)};l(n);let u=[],d=new Set(dp(n,`BPMNShape`).map(e=>e.attrs.bpmnElement));if(d.size===0||dp(n,`BPMNPlane`).length===0)throw new np(t(`app.import.failure.noPositions`));let f=dp(n,`dataObject`).filter(e=>d.has(e.attrs.id));if(f.length>0){for(let e of f){let t={id:`${e.attrs.id}_reference`,dataObjectRef:e.attrs.id};e.attrs.name&&(t.name=e.attrs.name);let r={...e,name:up(e,`dataObjectReference`),local:`dataObjectReference`,attrs:t,children:[]};delete e.attrs.name;let i=fp(n,e);i?.children.splice(i.children.indexOf(e)+1,0,r);for(let t of dp(n,`BPMNShape`))t.attrs.bpmnElement===e.attrs.id&&(t.attrs.bpmnElement=r.attrs.id);for(let t of[...dp(n,`association`),...dp(n,`sourceRef`),...dp(n,`targetRef`)])t.attrs.sourceRef===e.attrs.id&&(t.attrs.sourceRef=r.attrs.id),t.attrs.targetRef===e.attrs.id&&(t.attrs.targetRef=r.attrs.id),t.text.trim()===e.attrs.id&&(t.text=r.attrs.id)}u.push({level:`assumed`,message:t(`app.import.note.dataObjects`,{count:f.length})})}for(let[e,n]of i){let r=[...n.values()].reduce((e,t)=>e+t,0),i=[...n.entries()].map(([e,t])=>t>1?`${e} (${t})`:e).join(`, `);u.push({level:`lost`,message:t(`app.import.note.vendorData`,{vendor:e,total:r,list:i})})}return n.attrs.id||(n.attrs.id=`Definitions_1`),{xml:`<?xml version="1.0" encoding="UTF-8"?>\n${ml(n)}\n`,format:r,notes:u}}function up(e,t){return e.prefix?`${e.prefix}:${t}`:t}function dp(e,t){let n=[],r=e=>{e.local===t&&n.push(e),e.children.forEach(r)};return r(e),n}function fp(e,t){if(e.children.includes(t))return e;for(let n of e.children){let e=fp(n,t);if(e)return e}}const pp={nbsp:` `,lt:`<`,gt:`>`,quot:`"`,apos:`'`,amp:`&`};function mp(e){return e.replace(/&(#x[0-9a-f]+|#\d+|[a-z]+);/gi,(e,t)=>t.startsWith(`#x`)||t.startsWith(`#X`)?String.fromCodePoint(parseInt(t.slice(2),16)):t.startsWith(`#`)?String.fromCodePoint(parseInt(t.slice(1),10)):pp[t.toLowerCase()]??e)}function hp(e){return mp(e.replace(/<br\s*\/?>/gi,`
|
|
858
|
+
`).replace(/<\/(div|p|li|h[1-6]|tr)>/gi,`
|
|
859
|
+
`).replace(/<[^>]*>/g,``)).replace(/ /g,` `).replace(/[ \t]+\n/g,`
|
|
860
|
+
`).replace(/\n{3,}/g,`
|
|
861
|
+
|
|
862
|
+
`).trim()}function gp(e,t){return t?hp(e):e.trim()}var _p=class extends Error{};function vp(e){let n=[],r=0;new S(e=>{if(r+=e.length,r>33554432)throw new _p(t(`app.import.failure.pageTooLarge`));n.push(e)}).push(e,!0);let i=new Uint8Array(r),a=0;for(let e of n)i.set(e,a),a+=e.length;return i}function yp(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set;for(let r of e.split(`;`)){if(!r.trim())continue;let e=r.indexOf(`=`);e<0?n.add(r.trim().toLowerCase()):t.set(r.slice(0,e).trim(),r.slice(e+1).trim())}return{map:t,tokens:n}}function bp(e){let t=atob(e.replace(/\s+/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);return n}function xp(e){let n=e.children.find(e=>e.local===`mxGraphModel`);if(n)return n;let r=e.text.trim();if(!r)throw new _p(t(`app.import.failure.pageEmpty`));try{return r.startsWith(`<`)?W(r):r.startsWith(`%3C`)?W(decodeURIComponent(r)):W(decodeURIComponent(ee(vp(bp(r)))))}catch(e){throw e instanceof _p?e:new _p(t(`app.import.failure.compressedPage`))}}const Sp=(e,t=0)=>{let n=Number(e);return e!==void 0&&e!==``&&Number.isFinite(n)?n:t};function Cp(e){let n=e.children.find(e=>e.local===`root`);if(!n)throw new _p(t(`app.import.failure.pageNoCells`));let r=[];for(let e of n.children){let t=e.local===`object`||e.local===`UserObject`,n=t?e.children.find(e=>e.local===`mxCell`):e.local===`mxCell`?e:void 0;if(!n)continue;let i=n.children.find(e=>e.local===`mxGeometry`),a=(i?.children.find(e=>e.local===`Array`&&e.attrs.as===`points`)?.children??[]).filter(e=>e.local===`mxPoint`).map(e=>({x:Sp(e.attrs.x),y:Sp(e.attrs.y)})),o={};if(t)for(let[t,n]of Object.entries(e.attrs))[`id`,`label`].includes(t)||(o[t]=n);r.push({id:(t?e.attrs.id:n.attrs.id)??``,value:t?e.attrs.label??n.attrs.value??``:n.attrs.value??``,style:n.attrs.style??``,vertex:n.attrs.vertex===`1`,edge:n.attrs.edge===`1`,parent:n.attrs.parent??``,source:n.attrs.source??``,target:n.attrs.target??``,geometry:{x:Sp(i?.attrs.x),y:Sp(i?.attrs.y),width:Sp(i?.attrs.width),height:Sp(i?.attrs.height),points:a},properties:o,hidden:n.attrs.visible===`0`})}return r}const wp={service:`service`,user:`user`,script:`script`,send:`send`,receive:`receive`,manual:`manual`,businessrule:`businessRule`},Tp={general:void 0,none:void 0,message:`message`,timer:`timer`,escalation:`escalation`,conditional:`conditional`,link:`link`,error:`error`,cancel:`cancel`,compensation:`compensation`,signal:`signal`,multiple:`multiple`,parallelmultiple:`parallelMultiple`,terminate:`terminate`},Ep=/* @__PURE__ */ new Set([``,`rect`,`rectangle`,`ellipse`,`rhombus`,`text`,`note`,`swimlane`,`partialrectangle`,`table`,`tablerow`]);function Dp(e){let t=(e.map.get(`symbol`)??``).toLowerCase(),n=(e.map.get(`outline`)??``).toLowerCase();return t.includes(`parallelmultiple`)||t.includes(`event`)||t.includes(`multiple`)&&n!==`none`?`eventBasedGateway`:t.includes(`exclusive`)?`exclusiveGateway`:t.includes(`parallel`)?`parallelGateway`:t.includes(`complex`)?`complexGateway`:t.includes(`inclusive`)||n===`end`?`inclusiveGateway`:n===`catching`?`eventBasedGateway`:`exclusiveGateway`}function Op(e){let t=(e.map.get(`outline`)??`standard`).toLowerCase(),n=(e.map.get(`symbol`)??`general`).toLowerCase(),r=n in Tp,i=r?Tp[n]:void 0,a={standard:[`startEvent`],eventint:[`startEvent`],eventnonint:[`startEvent`,!1],end:[`endEvent`],throwing:[`intermediateThrowEvent`],catching:[`intermediateCatchEvent`],boundint:[`boundaryEvent`],boundnonint:[`boundaryEvent`,!1]},[o,s]=a[t]??a.standard;return{kind:o,fields:{definition:i,interrupting:s},unknownSymbol:r?void 0:n}}function kp(e){if(e.map.get(`isLoopMultiInstance`)===`1`)return e.map.get(`isSequential`)===`1`?`sequential`:`parallel`;if(e.map.get(`isLoopStandard`)===`1`)return`standard`}function Ap(e,n){let r=(n.map.get(`shape`)??``).toLowerCase(),{tokens:i}=n,a=r.startsWith(`mxgraph.bpmn.`);if(i.has(`swimlane`)||r===`swimlane`||r===`table`)return{kind:`pool`,fields:{horizontal:n.map.get(`horizontal`)===`0`||r===`table`}};if(r===`tablerow`)return{kind:`lane`,fields:{horizontal:!0}};if(r.startsWith(`mxgraph.bpmn.shape`)||r.startsWith(`mxgraph.bpmn.event`)){let e=Op(n);return{kind:e.kind,fields:e.fields,note:e.unknownSymbol?{level:`lost`,message:t(`app.import.note.unknownEvent`,{symbol:e.unknownSymbol})}:void 0}}return r.startsWith(`mxgraph.bpmn.gateway`)?{kind:Dp(n)}:r===`datastore`||a&&/store/.test(r)?{kind:`dataStore`}:a&&r.startsWith(`mxgraph.bpmn.data`)?{kind:`dataObject`,fields:{collection:n.map.get(`isCollection`)===`1`}}:a&&r.startsWith(`mxgraph.bpmn.annotation`)||r===`partialrectangle`?{kind:`textAnnotation`}:a&&r.startsWith(`mxgraph.bpmn.task`)?jp(n):r===`ext`?n.map.get(`double`)===`1`?{kind:`transaction`}:Sp(n.map.get(`strokeWidth`))>=3?{kind:`callActivity`}:n.map.get(`dashed`)===`1`?{kind:`eventSubProcess`}:jp(n):Ep.has(r)?i.has(`rhombus`)||r===`rhombus`?{kind:`exclusiveGateway`,note:{level:`assumed`,message:t(`app.import.note.diamond`,{shape:Mp(e)})}}:i.has(`ellipse`)||r===`ellipse`?{pending:`event`}:i.has(`text`)||r===`text`?{kind:`textAnnotation`,note:{level:`assumed`,message:t(`app.import.note.freeText`,{shape:Mp(e)})}}:r===`note`?{kind:`textAnnotation`,note:{level:`assumed`,message:t(`app.import.note.noteShape`,{shape:Mp(e)})}}:n.map.get(`rounded`)===`1`?jp(n):{kind:`task`,note:{level:`assumed`,message:t(`app.import.note.rectangle`,{shape:Mp(e)})}}:{}}function jp(e){let t=(e.map.get(`bpmnShapeType`)??``).toLowerCase();if(t===`call`)return{kind:`callActivity`,fields:{loop:kp(e)}};if(t===`transaction`)return{kind:`transaction`};if(t===`subprocess`)return{kind:`subProcess`};if(t===`event`)return{kind:`eventSubProcess`};let n=(e.map.get(`taskMarker`)??``).toLowerCase();return{kind:`task`,fields:{taskType:T(wp,n)??`task`,loop:kp(e)}}}function Mp(e){let n=gp(e.value,!0).replace(/\s+/g,` `);return n?`"${n}"`:t(`app.import.note.anUnlabelledShape`)}function Np(e,n){let r=n.map.get(`shape`)??[...n.tokens][0]??`rectangle`,i=gp(e.value,!0).replace(/\s+/g,` `);return i?t(`app.import.note.unmappedLabelled`,{label:i,shape:r}):t(`app.import.note.unlabelledShape`,{shape:r,count:1})}function Pp(e){let t=e.map.get(`dashed`)===`1`,n=e.map.get(`startArrow`)??``,r=e.map.get(`endArrow`)??`classic`;return t&&(n===`oval`||e.map.get(`endFill`)===`0`&&r!==`none`)?`message`:t?`association`:`sequence`}function Fp(e){let n=W(e),r=[],i;if(n.local===`mxGraphModel`)i=n;else{let e=n.children.filter(e=>e.local===`diagram`);if(e.length===0)throw new _p(t(`app.import.failure.noPages`));let a=e.map(e=>({page:e,model:xp(e)})),o=a.find(e=>Cp(e.model).some(e=>e.vertex))??a[0];i=o.model;for(let e of a){if(e===o)continue;let n=Cp(e.model).filter(e=>e.vertex).length;r.push({level:`unmapped`,message:t(`app.import.note.otherPage`,{page:e.page.attrs.name??t(`app.import.note.untitled`),shapes:n,count:n})})}}let a=Cp(i).filter(e=>e.id!==``&&!e.hidden),o=new Map(a.map(e=>[e.id,e])),s=new Map(a.map(e=>[e.id,yp(e.style)])),c=/* @__PURE__ */ new Map,l=(e,t=0)=>{let n=c.get(e.id);if(n)return n;let r=o.get(e.parent),i=r&&r.vertex&&t<50?l(r,t+1):{x:0,y:0},a={x:i.x+e.geometry.x,y:i.y+e.geometry.y};return c.set(e.id,a),a},u=e=>{let t=o.get(e.parent);return t&&t.vertex?l(t):{x:0,y:0}},d=/* @__PURE__ */ new Map,f=/* @__PURE__ */ new Set;for(let e of a){let t=s.get(e.id);e.vertex&&t.tokens.has(`edgelabel`)&&o.get(e.parent)?.edge&&d.set(e.parent,gp(e.value,t.map.get(`html`)===`1`));let n=o.get(e.parent);e.vertex&&n&&(s.get(n.id)?.map.get(`shape`)??``).toLowerCase()===`tablerow`&&f.add(e.id)}let p=[],m=[],h=[],g=/* @__PURE__ */ new Map,_=0;for(let e of a){if(!e.vertex)continue;let t=s.get(e.id);if(t.tokens.has(`edgelabel`)&&o.get(e.parent)?.edge)continue;let n=o.get(e.parent);if(f.has(e.id)&&(s.get(e.id)?.map.get(`shape`)??``).toLowerCase()===`partialrectangle`){let r=p.find(e=>e.id===n?.id);r&&!r.name&&e.value&&(r.name=gp(e.value,t.map.get(`html`)===`1`));continue}let i=Ap(e,t);if(!i.kind&&!i.pending){let n=t.map.get(`shape`)??[...t.tokens][0]??`rectangle`;h.push({text:Np(e,t),shape:n,labelled:gp(e.value,!0)!==``});continue}i.note&&r.push(i.note);let a=l(e),c=t.map.get(`html`)===`1`,u=e.properties.documentation??e.properties.tooltip,d={id:e.id,kind:i.kind??`startEvent`,name:gp(e.value,c),x:a.x,y:a.y,width:e.geometry.width||100,height:e.geometry.height||80,parent:n&&n.vertex?n.id:void 0,documentation:u?gp(u,!1):void 0,...i.fields};p.push(d),i.pending&&m.push(d);let v=Object.keys(e.properties).filter(e=>![`documentation`,`tooltip`,`placeholders`,`link`].includes(e));if(v.length>0){_+=1;for(let e of v)g.set(e,(g.get(e)??0)+1)}}Uf(p);let v=[];for(let e of a){if(!e.edge)continue;let t=s.get(e.id),n=gp(e.value,t.map.get(`html`)===`1`)||d.get(e.id)||``,r=u(e),i=(t.map.get(`edgeStyle`)??``).toLowerCase(),a=t.map.get(`startArrow`)??``;v.push({id:e.id,kind:Pp(t),source:e.source,target:e.target,name:n,points:e.geometry.points.map(e=>({x:e.x+r.x,y:e.y+r.y})),orthogonal:i.includes(`orthogonal`)||i.includes(`elbow`),isDefault:a===`dash`||a===`dashThin`,documentation:e.properties.documentation})}for(let e of m){let n=v.filter(t=>t.target===e.id&&t.kind===`sequence`).length,i=v.filter(t=>t.source===e.id&&t.kind===`sequence`).length;e.kind=n===0&&i>0?`startEvent`:i===0&&n>0?`endEvent`:`intermediateThrowEvent`,(e.width>80||e.height>80)&&(e.width=e.height=36);let a=e.kind===`startEvent`?t(`app.import.note.aStartEvent`):e.kind===`endEvent`?t(`app.import.note.anEndEvent`):t(`app.import.note.anIntermediateEvent`);r.push({level:`assumed`,message:t(`app.import.note.circle`,{shape:e.name?`"${e.name.replace(/\s+/g,` `)}"`:t(`app.import.note.anUnlabelledCircle`),kind:a})})}let y=h.filter(e=>e.labelled);for(let e of y)r.push({level:`unmapped`,message:e.text});let b=h.filter(e=>!e.labelled),x=/* @__PURE__ */ new Map;for(let e of b)x.set(e.shape,(x.get(e.shape)??0)+1);for(let[e,n]of x)r.push({level:`unmapped`,message:t(`app.import.note.unlabelledShape`,{count:n,shape:e})});return g.size>0&&r.push({level:`lost`,message:t(`app.import.note.customData`,{count:_,keys:[...g.keys()].join(`, `)})}),{nodes:p,flows:v,notes:r}}var Ip=class extends Error{};function Lp(e){return e.length>4&&e[0]===80&&e[1]===75&&(e[2]===3||e[2]===5)&&(e[3]===4||e[3]===6)}function Rp(e){return e.length>8&&[208,207,17,224,161,177,26,225].every((t,n)=>e[n]===t)}function zp(e,n){let r=0;try{let i=C(e,{filter(e){if(!n(e.name))return!1;if(e.originalSize>67108864)throw new Ip(t(`app.import.failure.entryTooLarge`,{name:e.name}));if(r+=e.originalSize,r>268435456)throw new Ip(t(`app.import.failure.archiveTooLarge`));return!0}});return new Map(Object.entries(i))}catch(e){throw e instanceof Ip?e:new Ip(t(`app.import.failure.notZip`))}}function Bp(e,t){let n=e.get(t);return n?ee(n).replace(/^/,``):void 0}var Vp=class extends Error{};const Hp=e=>e.toLowerCase().replace(/[^a-z0-9]/g,``);function Up(e){let t=/* @__PURE__ */ new Map;for(let n of e.children){if(n.local!==`Cell`||!n.attrs.N)continue;let e=Number(n.attrs.V);n.attrs.V!==void 0&&n.attrs.V!==``&&Number.isFinite(e)&&t.set(n.attrs.N,e)}return t}function Wp(e){let t=/* @__PURE__ */ new Map;for(let n of e.children.filter(e=>e.local===`Section`&&e.attrs.N===`Property`))for(let e of n.children.filter(e=>e.local===`Row`)){let n=e.children.find(e=>e.local===`Cell`&&e.attrs.N===`Value`);e.attrs.N&&n?.attrs.V!==void 0&&t.set(Hp(e.attrs.N),n.attrs.V)}return t}function Gp(e){let t=e.children.find(e=>e.local===`Section`&&e.attrs.N===`Geometry`);if(!t)return[];let n=[];for(let e of t.children.filter(e=>e.local===`Row`)){let t=e.attrs.T??``;if(!e.attrs.T&&e.attrs.N)continue;if(t!==`MoveTo`&&t!==`LineTo`)return null;let r=Up(e);n.push({type:t,x:r.get(`X`)??0,y:r.get(`Y`)??0})}return n}function Kp(e,t){let n=/* @__PURE__ */ new Map,r=Bp(e,t);if(!r)return n;for(let e of W(r).children.filter(e=>e.local===`Relationship`))e.attrs.Id&&e.attrs.Target&&n.set(e.attrs.Id,e.attrs.Target);return n}function qp(e,t,n,r){if(e)for(let i of e.children.filter(e=>e.local===`Shape`)){let e=Up(i),a={x:(e.get(`PinX`)??0)-(e.get(`LocPinX`)??0),y:(e.get(`PinY`)??0)-(e.get(`LocPinY`)??0)},o=i.attrs.Master??i.attrs.MasterShape,s=i.children.find(e=>e.local===`Shapes`);r.push({id:i.attrs.ID,master:(o?t.get(o):void 0)??(i.attrs.NameU??i.attrs.Name??``).replace(/\.\d+$/,``),text:(i.children.find(e=>e.local===`Text`)?.text??``).replace(/\s+$/g,``).replace(/^\s+/,``),cells:e,props:Wp(i),rows:Gp(i)??[],node:i,origin:n,group:i.attrs.Type===`Group`}),s&&qp(s,t,{x:n.x+a.x,y:n.y+a.y},r)}}const Jp=[[`parallelmultiple`,`parallelMultiple`],[`multiple`,`multiple`],[`message`,`message`],[`timer`,`timer`],[`error`,`error`],[`escalation`,`escalation`],[`cancel`,`cancel`],[`compensation`,`compensation`],[`conditional`,`conditional`],[`rule`,`conditional`],[`link`,`link`],[`signal`,`signal`],[`terminate`,`terminate`]],Yp=[[`service`,`service`],[`send`,`send`],[`receive`,`receive`],[`user`,`user`],[`manual`,`manual`],[`businessrule`,`businessRule`],[`script`,`script`]];function Xp(e,t){for(let n of t){let t=e.get(n);if(t!==void 0)return Hp(t)}return``}function Zp(e){let t=Xp(e,[`looptype`,`loop`,`loopcharacteristics`]);if(t.includes(`multi`)||t.includes(`parallel`))return`parallel`;if(t.includes(`sequential`))return`sequential`;if(t.includes(`standard`)||t===`loop`)return`standard`}function Qp(e,t){let n=Xp(e,[`gatewaytype`,`type`])||Hp(t);return n.includes(`event`)?`eventBasedGateway`:n.includes(`parallel`)?`parallelGateway`:n.includes(`inclusive`)?`inclusiveGateway`:n.includes(`complex`)?`complexGateway`:`exclusiveGateway`}function $p(e){let t=Hp(e.master);if(e.cells.has(`BeginX`)&&e.cells.has(`EndX`))return t.includes(`message`)?{flow:`message`}:t.includes(`association`)?{flow:`association`}:t.includes(`default`)?{flow:`sequence`,isDefault:!0}:t.includes(`sequence`)||t.includes(`conditional`)?{flow:`sequence`}:{flow:`sequence`,generic:!0};if(t.includes(`pool`)||t.includes(`swimlane`))return{kind:`pool`,fields:{horizontal:(e.cells.get(`Width`)??0)>=(e.cells.get(`Height`)??0)}};if(t===`lane`||t.startsWith(`lane`))return{kind:`lane`,fields:{horizontal:!0}};if(t.includes(`startevent`)||t.includes(`intermediateevent`)||t.includes(`endevent`)||t===`event`){let n=Xp(e.props,[`eventtype`,`type`]),r=t.includes(`start`)||n===`start`?`start`:t.includes(`end`)||n===`end`?`end`:`intermediate`,i=Xp(e.props,[`triggerorresult`,`trigger`,`result`,`eventtrigger`,`eventdefinition`]),a=Jp.find(([e])=>i.includes(e))?.[1],o=[...e.props.entries()].some(([e,t])=>(e.includes(`throw`)||Hp(t).includes(`throw`))&&Hp(t)!==`false`&&Hp(t)!==`no`),s=r===`start`?`startEvent`:r===`end`?`endEvent`:o?`intermediateThrowEvent`:`intermediateCatchEvent`,c=Xp(e.props,[`interrupting`,`iscancelactivity`]);return{kind:s,fields:{definition:a,interrupting:c===`false`||c===`no`?!1:void 0}}}if(t.includes(`gateway`))return{kind:Qp(e.props,e.master)};if(t.includes(`callactivity`))return{kind:`callActivity`,fields:{loop:Zp(e.props)}};if(t.includes(`subprocess`)){let t=Xp(e.props,[`subprocesstype`,`type`]);return{kind:t.includes(`transaction`)?`transaction`:t.includes(`event`)?`eventSubProcess`:`subProcess`,fields:{loop:Zp(e.props)}}}if(t===`task`||t.startsWith(`task`)){let t=Xp(e.props,[`tasktype`,`type`]);return{kind:`task`,fields:{taskType:Yp.find(([e])=>t.includes(e))?.[1]??`task`,loop:Zp(e.props)}}}return t.includes(`datastore`)?{kind:`dataStore`}:t.includes(`dataobject`)||t.includes(`datainput`)||t.includes(`dataoutput`)?{kind:`dataObject`,fields:{collection:Xp(e.props,[`iscollection`,`collection`])===`true`}}:t.includes(`annotation`)?{kind:`textAnnotation`}:null}function em(e){return e*96}function tm(e){let n=zp(e,e=>/^visio\/.*\.(xml|rels)$/i.test(e));if(!n.has(`visio/document.xml`))throw new Vp(t(`app.import.failure.notVisio`));let r=Bp(n,`visio/pages/pages.xml`);if(!r)throw new Vp(t(`app.import.failure.noVisioPages`));let i=/* @__PURE__ */ new Map,a=Bp(n,`visio/masters/masters.xml`);if(a)for(let e of W(a).children.filter(e=>e.local===`Master`))i.set(e.attrs.ID,e.attrs.NameU??e.attrs.Name??``);let o=Kp(n,`visio/pages/_rels/pages.xml.rels`),s=W(r).children.filter(e=>e.local===`Page`).map(e=>{let t=e.children.find(e=>e.local===`PageSheet`),n=e.children.find(e=>e.local===`Rel`),r=n?o.get(n.attrs[`r:id`]??n.attrs.id??``):void 0,i=r?`visio/pages/${r.replace(/^\.?\//,``)}`:``;return{name:e.attrs.NameU??e.attrs.Name??`untitled`,height:(t?Up(t).get(`PageHeight`):void 0)??8.5,file:i}}).map(e=>({page:e,text:Bp(n,e.file)})).filter(e=>e.text!==void 0).map(e=>({...e,root:W(e.text)})).map(e=>({...e,shapes:[]}));for(let e of s)qp(e.root.children.find(e=>e.local===`Shapes`),i,{x:0,y:0},e.shapes);let c=s.find(e=>e.shapes.length>0);if(!c)throw new Vp(t(`app.import.failure.noShapes`));let l=[];for(let e of s)e!==c&&e.shapes.length!==0&&l.push({level:`unmapped`,message:t(`app.import.note.otherVisioPage`,{page:e.page.name,shapes:e.shapes.length,count:e.shapes.length})});let u=c.page.height,d=[],f=[],p=/* @__PURE__ */ new Map,m=c.root.children.find(e=>e.local===`Connects`);for(let e of m?.children.filter(e=>e.local===`Connect`)??[]){let t=e.attrs.FromSheet,n=p.get(t)??{};(e.attrs.FromCell??``).startsWith(`Begin`)&&(n.source=e.attrs.ToSheet),(e.attrs.FromCell??``).startsWith(`End`)&&(n.target=e.attrs.ToSheet),p.set(t,n)}let h=0,g=0,_=[],v=e=>e.text.replace(/\s+/g,` `);for(let e of c.shapes){(e.cells.get(`Angle`)??0)!==0&&(g+=1);let n=$p(e);if(n&&`flow`in n){let t={x:em(e.cells.get(`BeginX`)??0),y:em(u-(e.cells.get(`BeginY`)??0))},r={x:em(e.cells.get(`EndX`)??0),y:em(u-(e.cells.get(`EndY`)??0))},i=e.origin.x+(e.cells.get(`PinX`)??0)-(e.cells.get(`LocPinX`)??0),a=e.origin.y+(e.cells.get(`PinY`)??0)-(e.cells.get(`LocPinY`)??0),o=e.rows.slice(1,-1).map(e=>({x:em(i+e.x),y:em(u-(a+e.y))})).filter(e=>!(Math.abs(e.x-t.x)<.5&&Math.abs(e.y-t.y)<.5)&&!(Math.abs(e.x-r.x)<.5&&Math.abs(e.y-r.y)<.5));n.generic&&(h+=1);let s=p.get(e.id)??{};f.push({id:e.id,kind:n.flow,source:s.source??``,target:s.target??``,name:v(e),points:o,isDefault:n.isDefault})}else if(n&&`kind`in n){let t=e.cells.get(`Width`)??1,r=e.cells.get(`Height`)??1,i=e.origin.x+(e.cells.get(`PinX`)??0)-(e.cells.get(`LocPinX`)??t/2),a=e.origin.y+(e.cells.get(`PinY`)??0)-(e.cells.get(`LocPinY`)??r/2);d.push({id:e.id,kind:n.kind,name:v(e),x:em(i),y:em(u-a-r),width:em(t),height:em(r),...n.fields})}else(!e.group||n)&&_.push(v(e)?t(`app.import.note.unmappedLabelled`,{label:v(e),shape:e.master||t(`app.import.note.aShape`)}):t(`app.import.note.unlabelledMaster`,{shape:e.master||t(`app.import.note.shape`)}))}l.push(..._.map(e=>({level:`unmapped`,message:e}))),h>0&&l.push({level:`assumed`,message:t(`app.import.note.genericConnectors`,{count:h})}),g>0&&l.push({level:`lost`,message:t(`app.import.note.rotated`,{count:g})}),Uf(d);let y=d.filter(e=>[`task`,`callActivity`,`subProcess`,`transaction`,`eventSubProcess`].includes(e.kind));for(let e of d){if(e.kind!==`intermediateCatchEvent`||f.some(t=>t.kind===`sequence`&&t.target===e.id))continue;let t=Pf(e),n=y.map(e=>({candidate:e,distance:Lf(e,t)})).filter(e=>e.distance<=25).sort((e,t)=>e.distance-t.distance)[0];n&&(e.kind=`boundaryEvent`,e.host=n.candidate.id)}return{nodes:d,flows:f,notes:l}}function nm(e){return(typeof e==`string`?e:new TextDecoder(`utf-8`).decode(e)).replace(/^/,``)}function rm(e,t=[]){return{ok:!1,message:e,notes:t}}function im(e,n){if(n.nodes.length===0)return rm(t(`app.import.failure.nothingToImport`,{format:e}),n.notes);let r=tp(n);return{ok:!0,bpmn:r.xml,report:{format:e,summary:r.summary,notes:r.notes,needsLayout:!1}}}function am(){return t(`app.import.failure.bizagiPackage`)}const om=/\.(bpmn|bpmn20\.xml)$/i;function sm(e,t=[]){let n=lp(e),r=[...t,...n.notes];return{ok:!0,bpmn:n.xml,report:{format:n.format,summary:cm(n.xml),notes:r,needsLayout:!1}}}function cm(e){let t=W(e),n=e=>dl(t,e).length;return{elements:[`task`,`userTask`,`serviceTask`,`scriptTask`,`sendTask`,`receiveTask`,`manualTask`,`businessRuleTask`,`callActivity`,`subProcess`,`transaction`,`startEvent`,`endEvent`,`intermediateCatchEvent`,`intermediateThrowEvent`,`boundaryEvent`,`exclusiveGateway`,`parallelGateway`,`inclusiveGateway`,`complexGateway`,`eventBasedGateway`].reduce((e,t)=>e+n(t),0),flows:n(`sequenceFlow`)+n(`messageFlow`),pools:n(`participant`),lanes:n(`lane`)}}function lm(e){try{if(typeof e.data!=`string`){if(Rp(e.data))return rm(t(`app.import.failure.visioBinary`,{name:e.name}));if(Lp(e.data)){if(/\.bpm$/i.test(e.name)){let n=zp(e.data,e=>om.test(e)),r=[...n.keys()].sort()[0],i=r?Bp(n,r):void 0;return i?sm(i,[{level:`assumed`,message:t(`app.import.note.packageImported`,{name:r??``})}]):rm(am())}return im(`Visio`,tm(e.data))}}let n=nm(e.data);if(/\.bpm$/i.test(e.name)&&!/^\s*</.test(n))return rm(am());let r=W(n);return r.local===`mxfile`||r.local===`mxGraphModel`?im(`draw.io`,Fp(n)):r.local===`definitions`?sm(n):r.local===`Package`&&r.ns.toLowerCase().includes(`xpdl`)?rm(t(`app.import.failure.xpdl`)):rm(t(`app.import.failure.unknownFormat`,{name:e.name}))}catch(e){if(e instanceof _p||e instanceof Vp||e instanceof np||e instanceof Ip||e instanceof ll)return rm(e.message);throw e}}function um(e){let t=t=>e.notes.filter(e=>e.level===t).map(e=>e.message);return{unmapped:t(`unmapped`),assumed:t(`assumed`),lost:t(`lost`)}}const dm={elements:`element`,flows:`flow`,pools:`pool`,lanes:`lane`};function fm(e){return t(`app.import.noteTitle.${e}`)}function pm(e,n){return t(`app.import.count.${dm[n]}`,{count:e})}function mm(e){let{elements:n,flows:r,pools:i,lanes:a}=e.summary,o=[pm(n,`elements`),pm(r,`flows`)];return i>0&&o.push(pm(i,`pools`)),a>0&&o.push(pm(a,`lanes`)),t(`app.import.summary`,{format:e.format,counts:o.join(`, `)})}function hm(e){let n=um(e),r=[mm(e)];for(let e of[`unmapped`,`assumed`,`lost`])n[e].length!==0&&r.push(``,t(`app.import.noteSection`,{title:fm(e),count:n[e].length}),...n[e].map(e=>` - ${e}`));return r}function gm(e){let n=e.split(/[\\/]/).pop()??``;return/\.bpmn$/i.test(n)?`${n.replace(/\.bpmn$/i,``)}.penstock.bpmn`:`${n.replace(/\.(drawio|dio|vsdx|bpmn20\.xml|bpm|xml|xpdl)$/i,``)||t(`app.import.importedName`)}.bpmn`}const _m=`https://docs.camunda.io/docs/guides/migrating-from-camunda-7/`,vm=`${_m}migration-journey/migrate/`,ym=`${_m}code-conversion/`,bm=`https://docs.camunda.io/docs/components/modeler/bpmn/bpmn-coverage/`,xm=`https://docs.camunda.io/docs/components/concepts/job-workers/`,Sm=`https://docs.camunda.io/docs/components/modeler/feel/what-is-feel/`,Cm=`https://docs.camunda.io/docs/components/concepts/execution-listeners/`,wm=`https://docs.camunda.io/docs/components/concepts/user-task-listeners/`,Tm=`https://docs.camunda.io/docs/components/modeler/forms/camunda-forms-reference/`,Em=`https://docs.camunda.io/docs/components/modeler/bpmn/user-tasks/`,Dm=`https://docs.camunda.io/docs/components/concepts/messages/`,Om=`https://docs.camunda.io/docs/components/modeler/dmn/`,km=`https://docs.camunda.io/docs/guides/migrating-from-camunda-7/migration-tooling/data-migrator/`,Am={"java-class":{severity:`error`,conversion:`automatic`,title:`Java class {className} becomes the job type {jobType}`,detail:`Camunda 8 does not run Java inside the engine. A service task creates a job, and a job worker in your application picks it up.`,action:`Write a job worker for {jobType}; Penstock generates one from the class.`,link:xm},"delegate-expression":{severity:`error`,conversion:`automatic`,title:`Delegate {delegate} becomes the job type {jobType}`,detail:`Camunda 8 cannot look up a Spring bean. The task creates a job, and a job worker picks it up.`,action:`Write a job worker for {jobType}; Penstock generates one from the bean.`,link:xm},"delegate-expression-dynamic":{severity:`error`,conversion:`manual`,title:`The delegate is chosen by the expression {expression}`,detail:`The bean is decided while the process runs, and a Camunda 8 job type is fixed or a FEEL expression over variables.`,action:`Give the task a job type, or a FEEL expression that picks one from a variable.`,link:xm},expression:{severity:`error`,conversion:`automatic`,title:`The expression {expression} becomes the job type {jobType}`,detail:`Camunda 8 cannot call a bean method from the diagram. The call moves into a job worker.`,action:`Write a job worker for {jobType} that makes the call {expression} made.`,link:xm},"expression-unknown":{severity:`error`,conversion:`manual`,title:`The expression {expression} runs code inside the engine`,detail:`Camunda 8 evaluates FEEL and nothing else in the diagram, so this expression has no counterpart.`,action:`Move what it does into a job worker, or into a FEEL output mapping if it only computes a value.`,link:xm},"external-task":{severity:`warning`,conversion:`automatic`,title:`The external task topic {topic} becomes the job type {jobType}`,detail:`External tasks and jobs are the same idea. The worker changes client: the Camunda 7 external task client becomes a Camunda 8 job worker.`,action:`Move the handler for {topic} to a job worker; Penstock generates one from the handler.`,link:ym},"external-task-priority":{severity:`info`,conversion:`automatic`,title:`The external task priority is dropped`,detail:`Camunda 8 jobs of one type are handed out in the order they are created.`,action:`Nothing to do, unless the order mattered; then give urgent work its own job type.`},connector:{severity:`error`,conversion:`manual`,title:`The Camunda 7 connector {connector} has no Camunda 8 counterpart`,detail:`Camunda 7 connectors (http-connector, soap-http-connector) are not part of Camunda 8. Camunda 8 has its own connectors, configured through element templates.`,action:`Apply the Camunda 8 REST or SOAP connector template to the task, or write a job worker.`,link:`https://docs.camunda.io/docs/components/connectors/protocol/rest/`},"field-injection":{severity:`warning`,conversion:`review`,title:`The injected fields {fields} become task headers`,detail:`Camunda 8 has no field injection. Fixed values travel with the job as custom headers, which the worker reads.`,action:`Read them in the worker from the job's custom headers.`,link:xm},"field-injection-expression":{severity:`error`,conversion:`manual`,title:`The injected field {field} is an expression`,detail:`A task header is a fixed text; it cannot be evaluated while the process runs.`,action:`Pass the value as an input mapping with a FEEL expression, and read it in the worker as a variable.`,link:xm},async:{severity:`info`,conversion:`automatic`,title:`Asynchronous continuation is dropped`,detail:`Camunda 8 has no transactions spanning steps: every job and every wait is its own unit, so asyncBefore and asyncAfter mean nothing there.`,action:`Nothing to do.`,link:vm},retries:{severity:`warning`,conversion:`review`,title:`The retry cycle {cycle} becomes {retries} retries`,detail:`Camunda 8 counts retries on the task; how long to wait between them is decided by the worker when it fails the job.`,action:`Set the back-off in the worker's fail command if the interval mattered.`,link:xm},"retries-dropped":{severity:`warning`,conversion:`automatic`,title:`The retry cycle {cycle} is dropped`,detail:`Only tasks that create a job carry retries in Camunda 8.`,action:`Nothing to do, unless this element relied on retrying; then check how it fails on Camunda 8.`},"job-priority":{severity:`info`,conversion:`automatic`,title:`The job priority {priority} is carried over`,detail:`Camunda 8 has job priorities from 8.8.`,action:`Nothing to do.`,since:`8.8`},"job-priority-dropped":{severity:`warning`,conversion:`automatic`,title:`The job priority {priority} is dropped`,detail:`The Camunda 8 version this converts for has no job priorities.`,action:`Nothing to do, unless the order mattered; then give urgent work its own job type.`},"input-output":{severity:`info`,conversion:`automatic`,title:`The input and output mapping becomes a FEEL mapping`,detail:`Camunda 8 maps variables with FEEL expressions; each Camunda 7 parameter becomes one.`,action:`Nothing to do.`,link:`https://docs.camunda.io/docs/components/concepts/variables/`},"input-output-manual":{severity:`error`,conversion:`manual`,title:`The mapping of {name} cannot be converted`,detail:`{reason}`,action:`Write the mapping as a FEEL expression.`,link:Sm},"input-output-script":{severity:`error`,conversion:`manual`,title:`The mapping of {name} runs a {format} script`,detail:`Camunda 8 maps variables with FEEL only.`,action:`Write the mapping as a FEEL expression, or compute the value in a job worker.`,link:Sm},condition:{severity:`info`,conversion:`automatic`,title:`The condition {expression} becomes {feel}`,detail:`Camunda 8 conditions are FEEL expressions.`,action:`Nothing to do.`,link:Sm},"expression-review":{severity:`warning`,conversion:`review`,title:`{expression} became {feel}`,detail:`{reason}`,action:`Check the FEEL expression means the same with the values this process sees.`,link:Sm},"expression-manual":{severity:`error`,conversion:`manual`,title:`The expression {expression} cannot be converted`,detail:`The converter stopped because {reason}.`,action:`Write it as a FEEL expression.`,link:Sm},"script-condition":{severity:`error`,conversion:`manual`,title:`The condition is a {format} script`,detail:`Camunda 8 conditions are FEEL expressions only.`,action:`Write the condition in FEEL.`,link:Sm},"script-task":{severity:`error`,conversion:`manual`,title:`The {format} script cannot run in Camunda 8`,detail:`Camunda 8 runs a script task as a FEEL expression or as a job. Groovy, JavaScript and Python scripts have no engine to run in.`,action:`Rewrite the script as a FEEL expression, or turn the task into a job worker that runs the code.`,link:`https://docs.camunda.io/docs/components/modeler/bpmn/script-tasks/`},"script-task-feel":{severity:`info`,conversion:`automatic`,title:`The FEEL script becomes a FEEL expression`,detail:`Camunda 8 runs a FEEL script task inside the engine, with its result in {variable}.`,action:`Nothing to do.`,link:`https://docs.camunda.io/docs/components/modeler/bpmn/script-tasks/`},"script-resource":{severity:`error`,conversion:`manual`,title:`The script is read from {resource}`,detail:`Camunda 8 does not load scripts from resources.`,action:`Rewrite the script as a FEEL expression, or turn the task into a job worker.`,link:`https://docs.camunda.io/docs/components/modeler/bpmn/script-tasks/`},"execution-listener":{severity:`error`,conversion:`automatic`,title:`The {event} listener {name} becomes the job type {jobType}`,detail:`Camunda 8 execution listeners are jobs as well: the process waits until a worker completes them.`,action:`Write a job worker for {jobType}; it runs before the element continues, so keep it quick.`,since:`8.6`,link:Cm},"execution-listener-unsupported":{severity:`error`,conversion:`manual`,title:`The {event} listener {name} has no Camunda 8 counterpart`,detail:`{reason}`,action:`Move what the listener does into a task of its own or into the worker before it.`,link:Cm},"task-listener":{severity:`error`,conversion:`automatic`,title:`The {event} task listener {name} becomes the job type {jobType}`,detail:`Camunda 8 task listeners are jobs that the user task waits for, and they can correct or deny what happens.`,action:`Write a job worker for {jobType}.`,since:`8.8`,link:wm},"task-listener-unsupported":{severity:`error`,conversion:`manual`,title:`The {event} task listener {name} has no Camunda 8 counterpart`,detail:`{reason}`,action:`Move what the listener does into a job worker around the task, or into the application that works the task.`,link:wm},"user-task":{severity:`info`,conversion:`automatic`,title:`The user task becomes a Camunda user task`,detail:`Camunda 8 manages the task in the engine, with its assignee, candidates, dates and priority.`,action:`Nothing to do in the diagram; the task list application changes to Tasklist or to the Camunda 8 user task API.`,link:Em},"user-task-expression":{severity:`warning`,conversion:`review`,title:`The {name} {expression} became {feel}`,detail:`{reason}`,action:`Check the value on Camunda 8.`,link:Em},"user-task-priority-range":{severity:`warning`,conversion:`review`,title:`The priority {priority} is outside 0 to 100`,detail:`Camunda 8 user task priorities run from 0 to 100.`,action:`Rescale the priority.`,link:Em},"user-task-priority-dropped":{severity:`warning`,conversion:`automatic`,title:`The priority {priority} is dropped`,detail:`The Camunda 8 version this converts for has no user task priority.`,action:`Nothing to do, unless the task list sorted by it.`},"form-embedded":{severity:`error`,conversion:`manual`,title:`The embedded form {formKey} has no Camunda 8 counterpart`,detail:`Camunda 8 Tasklist shows Camunda Forms only; HTML forms and their JavaScript do not carry over.`,action:`Rebuild the form as a Camunda Form and link it, or keep your own task list application and pass the key as an external reference.`,link:Tm},"form-generated":{severity:`warning`,conversion:`review`,title:`The generated form becomes the Camunda Form {form}`,detail:`Penstock writes a Camunda Form with one field per form field, and links it. Validation and properties the form fields had are carried over where Camunda Forms have them.`,action:`Open {form} and check it looks and validates as the old one did.`,link:Tm},"form-generated-partly":{severity:`warning`,conversion:`review`,title:`Part of the generated form did not carry over: {lost}`,detail:`Camunda Forms have no counterpart for it.`,action:`Rebuild that part in the form editor.`,link:Tm},"form-camunda":{severity:`info`,conversion:`automatic`,title:`The Camunda Form {form} is linked by its id`,detail:`Camunda 8 links a form by its id and deploys it with the diagram.`,action:`Deploy the form with the diagram.`,link:Tm},"form-camunda-unknown":{severity:`warning`,conversion:`review`,title:`The Camunda Form {form} was not found in the project`,detail:`Camunda 8 links a form by the id inside it, and Penstock could not read that id. The file name was used instead.`,action:`Check the form id in the diagram matches the id inside the form.`,link:Tm},"form-binding-version":{severity:`error`,conversion:`manual`,title:`The form is bound to version {version}`,detail:`Camunda 8 binds a form by latest, by deployment or by version tag, not by version number.`,action:`Bind it by deployment or give the form a version tag.`,link:Tm},"form-external":{severity:`warning`,conversion:`review`,title:`The form key {formKey} becomes an external reference`,detail:`Camunda 8 passes an external reference through to the task list, as Camunda 7 passed the form key.`,action:`Check your task list application reads the external reference.`,since:`8.4`,link:Tm},"assignment-review":{severity:`warning`,conversion:`review`,title:`The {name} {expression} is a list in Camunda 7`,detail:`Camunda 8 wants candidates as a FEEL list or a comma-separated text.`,action:`Check the expression gives a list or a comma-separated text.`,link:Em},initiator:{severity:`warning`,conversion:`manual`,title:`The starter is kept in {variable} only in Camunda 7`,detail:`Camunda 8 does not record who started an instance in a variable.`,action:`Set {variable} as a variable when the process is started.`,link:vm},"multi-instance":{severity:`info`,conversion:`automatic`,title:`The multi-instance loop over {collection} becomes an input collection`,detail:`Camunda 8 loops over an input collection, with each item in the input element.`,action:`Nothing to do.`,link:`https://docs.camunda.io/docs/components/modeler/bpmn/multi-instance/`},"multi-instance-cardinality":{severity:`warning`,conversion:`review`,title:`The loop cardinality {cardinality} becomes a collection of numbers`,detail:`Camunda 8 has no loop cardinality: it loops over a collection. The converter loops over the numbers 1 to {cardinality}.`,action:`Check the loop runs as often as it did.`,link:`https://docs.camunda.io/docs/components/modeler/bpmn/multi-instance/`},"multi-instance-missing":{severity:`error`,conversion:`manual`,title:`The multi-instance loop has neither a collection nor a cardinality`,detail:`Camunda 8 needs an input collection to loop over.`,action:`Give the loop an input collection.`,link:`https://docs.camunda.io/docs/components/modeler/bpmn/multi-instance/`},"call-activity":{severity:`info`,conversion:`automatic`,title:`The call of {process} carries over`,detail:`Camunda 8 calls the process by its id; the variables passed in and out become mappings.`,action:`Nothing to do.`,link:`https://docs.camunda.io/docs/components/modeler/bpmn/call-activities/`},"call-activity-business-key":{severity:`error`,conversion:`manual`,title:`The business key is passed to {process}`,detail:`Camunda 8 has no business key.`,action:`Pass the value as a variable, and correlate messages on it.`,link:vm},"call-activity-local":{severity:`warning`,conversion:`review`,title:`Only local variables were passed to or from {process}`,detail:`Camunda 8 passes the variables its mappings name; it has no local-only mode.`,action:`Check the mappings pass exactly what the called process needs.`,link:`https://docs.camunda.io/docs/components/modeler/bpmn/call-activities/`},"call-activity-mapping-class":{severity:`error`,conversion:`manual`,title:`Variables for {process} are mapped by Java code`,detail:`Camunda 8 maps variables with FEEL only.`,action:`Write the mapping as FEEL input and output mappings.`,link:Sm},"binding-version":{severity:`error`,conversion:`manual`,title:`{what} is bound to version {version}`,detail:`Camunda 8 binds by latest, by deployment or by version tag, not by version number.`,action:`Bind it by deployment, or give the target a version tag and bind by that.`,since:`8.6`,link:`https://docs.camunda.io/docs/components/best-practices/modeling/choosing-the-resource-binding-type/`},"binding-dropped":{severity:`warning`,conversion:`automatic`,title:`The binding {binding} of {target} is dropped`,detail:`The Camunda 8 version this converts for always takes the latest version.`,action:`Convert for 8.6 or later to keep the binding.`,since:`8.6`},tenant:{severity:`warning`,conversion:`manual`,title:`The tenant {tenant} is fixed in the diagram`,detail:`Camunda 8 decides the tenant from the deployment, not from the diagram.`,action:`Deploy the diagram to the tenant instead.`,link:`https://docs.camunda.io/docs/components/concepts/multi-tenancy/`},cmmn:{severity:`error`,conversion:`manual`,title:`The case {case} is called`,detail:`Camunda 8 has no CMMN.`,action:`Model the case as a process, an ad-hoc subprocess or a set of user tasks.`,link:_m},decision:{severity:`info`,conversion:`automatic`,title:`The decision {decision} is called, its result in {result}`,detail:`Camunda 8 evaluates the decision in the engine and stores the whole result in one variable.`,action:`Nothing to do.`,link:Om},"decision-result":{severity:`warning`,conversion:`review`,title:`The decision result was mapped as {mapping}`,detail:`Camunda 8 stores the result the way the decision gives it: one value for one output of one rule, a context for several outputs, a list for several rules. The Camunda 7 mapping {mapping} may have a different shape.`,action:`Check what reads {result} expects the Camunda 8 shape.`,link:Om},"decision-result-variable":{severity:`warning`,conversion:`review`,title:`The decision result goes to {result}`,detail:`Camunda 8 needs a result variable, and the Camunda 7 task had none.`,action:`Rename {result} if something else should read the result.`,link:Om},"message-catch":{severity:`error`,conversion:`manual`,title:`The message {message} needs a correlation key`,detail:`Camunda 8 correlates a message to a waiting instance by a key the instance computes from its variables. Camunda 7 correlated through the API, with the business key or variables.`,action:`Add a correlation key to the message: a FEEL expression over a variable the sender also knows, such as =orderId.`,link:Dm},"message-name-expression":{severity:`info`,conversion:`automatic`,title:`The message name {name} becomes {feel}`,detail:`Camunda 8 message names can be FEEL expressions.`,action:`Nothing to do.`,link:Dm},"message-throw":{severity:`error`,conversion:`automatic`,title:`The message is sent by {implementation}, which becomes the job type {jobType}`,detail:`Camunda 8 sends a message from a throw event through a job worker, like a send task.`,action:`Write a job worker for {jobType} that publishes the message.`,link:Dm},"message-throw-empty":{severity:`error`,conversion:`manual`,title:`The message throw event has no implementation`,detail:`Camunda 8 needs a job type on a message throw event; a worker sends the message.`,action:`Give the event a job type and write the worker that publishes the message.`,link:Dm},"signal-variables":{severity:`warning`,conversion:`review`,title:`Variables passed with the signal {signal}`,detail:`Camunda 8 broadcasts a signal with the variables its input mappings give it.`,action:`Check the signal carries the variables its catchers read.`,link:`https://docs.camunda.io/docs/components/modeler/bpmn/signal-events/`},timer:{severity:`info`,conversion:`automatic`,title:`The timer {timer} carries over`,detail:`Camunda 8 reads the same ISO 8601 dates, durations and cycles.`,action:`Nothing to do.`,link:`https://docs.camunda.io/docs/components/modeler/bpmn/timer-events/`},"timer-cron":{severity:`warning`,conversion:`review`,title:`The timer cycle {cycle} is a cron expression`,detail:`Camunda 8 reads cron expressions in the Spring format; Camunda 7 read them in the Quartz format, which allows fields Spring does not.`,action:`Check the cron expression is valid Spring cron.`,link:`https://docs.camunda.io/docs/components/modeler/bpmn/timer-events/`},"error-code-variable":{severity:`info`,conversion:`automatic`,title:`The caught error code goes to {variable} through an output mapping`,detail:`Camunda 8 gives a caught error to the output mappings as errorCode and errorMessage.`,action:`Nothing to do.`,link:`https://docs.camunda.io/docs/components/modeler/bpmn/error-events/`},"error-message":{severity:`info`,conversion:`automatic`,title:`The error message {message} is dropped`,detail:`In Camunda 8 the worker that throws the error gives its message.`,action:`Give the message in the worker when it throws the error.`,link:`https://docs.camunda.io/docs/components/modeler/bpmn/error-events/`},"external-error":{severity:`error`,conversion:`manual`,title:`The external task decides errors by the expression {expression}`,detail:`Camunda 8 has no error event definitions on a task; the job worker throws the error itself.`,action:`Throw the BPMN error from the job worker when the condition holds.`,link:xm},"escalation-code-variable":{severity:`warning`,conversion:`manual`,title:`The escalation code was kept in {variable}`,detail:`Camunda 8 does not store a caught escalation code in a variable.`,action:`Pass the value as a variable when the escalation is thrown.`,link:`https://docs.camunda.io/docs/components/modeler/bpmn/escalation-events/`},"unsupported-element":{severity:`error`,conversion:`manual`,title:`Camunda 8 cannot run a {what}`,detail:`{reason}`,action:`{action}`,link:bm},"element-since":{severity:`error`,conversion:`manual`,title:`A {what} needs Camunda {version} or later`,detail:`The Camunda 8 version this converts for, {target}, cannot run it.`,action:`Convert for Camunda {version} or later, or remodel it.`,link:bm},"conditional-event":{severity:`warning`,conversion:`review`,title:`The conditional event waits for {variables}`,detail:`Camunda 8 evaluates a condition when the variables it names change, like Camunda 7 did when variableName was set.`,action:`Check the condition is triggered by the variables you expect.`,since:`8.9`,link:`https://docs.camunda.io/docs/components/modeler/bpmn/conditional-events/`},properties:{severity:`info`,conversion:`automatic`,title:`The extension properties carry over`,detail:`Camunda 8 keeps them as zeebe properties, read the same way by tools.`,action:`Nothing to do.`},"version-tag":{severity:`info`,conversion:`automatic`,title:`The version tag {tag} carries over`,detail:`Camunda 8 keeps version tags from 8.6.`,action:`Nothing to do.`,since:`8.6`},"history-time-to-live":{severity:`info`,conversion:`automatic`,title:`The history time to live {ttl} is dropped`,detail:`Camunda 8 keeps history in its secondary storage, cleaned up by retention settings of the cluster, not of the diagram.`,action:`Set the retention in the cluster configuration if it mattered.`,link:km},"starter-groups":{severity:`warning`,conversion:`manual`,title:`Who may start the process ({groups}) is dropped`,detail:`Camunda 8 decides who may start a process through authorizations, not the diagram.`,action:`Grant the start permission to {groups} in Camunda 8 identity.`,link:`https://docs.camunda.io/docs/components/concepts/access-control/authorizations/`},"startable-in-tasklist":{severity:`info`,conversion:`automatic`,title:`Whether Tasklist may start the process is dropped`,detail:`Camunda 8 Tasklist offers every process a user may start.`,action:`Nothing to do.`},template:{severity:`warning`,conversion:`review`,title:`The element template {template} is a Camunda 7 template`,detail:`The template no longer applies; the converted properties stay.`,action:`Apply the Camunda 8 version of the template, if there is one.`,link:`https://docs.camunda.io/docs/components/modeler/desktop-modeler/element-templates/about-templates/`},"unknown-attribute":{severity:`warning`,conversion:`manual`,title:`The Camunda 7 setting {attribute} is left as it is`,detail:`Penstock does not know what Camunda 8 should do with it, so it stays in the diagram, where Camunda 8 ignores it.`,action:`Check whether anything depended on it, then remove it.`,link:vm},"dmn-version":{severity:`warning`,conversion:`manual`,title:`The decisions are DMN {version}`,detail:`Camunda 8 reads DMN 1.3. Penstock and the DMN editor move an older file to 1.3.`,action:`Open the file in the DMN editor and save it, then convert it.`,link:Om},"dmn-expression-language":{severity:`error`,conversion:`manual`,title:`{what} is written in {language}`,detail:`Camunda 8 evaluates DMN in FEEL only.`,action:`Write it in FEEL.`,link:Om},"dmn-juel":{severity:`info`,conversion:`automatic`,title:`{what} becomes the FEEL expression {feel}`,detail:`Camunda 8 evaluates DMN in FEEL only.`,action:`Nothing to do.`,link:Om},"dmn-input-variable":{severity:`error`,conversion:`manual`,title:`The input {input} names its value {variable}`,detail:`Camunda 8 refers to the input value in a rule as ?, not by a name.`,action:`Replace {variable} with ? in the rules of this input, then remove the name.`,link:`https://docs.camunda.io/docs/components/modeler/feel/language-guide/feel-unary-tests/`},"dmn-history-time-to-live":{severity:`info`,conversion:`automatic`,title:`The history time to live of {decision} is dropped`,detail:`Camunda 8 keeps history in its secondary storage, cleaned up by retention settings of the cluster.`,action:`Nothing to do.`},"dmn-carries-over":{severity:`info`,conversion:`automatic`,title:`The decisions carry over`,detail:`Camunda 8 evaluates DMN 1.3 in FEEL, and these decisions use nothing else.`,action:`Nothing to do.`,link:Om},"form-platform":{severity:`info`,conversion:`automatic`,title:`The form carries over`,detail:`Camunda Forms have the same format on both; only the platform it names changes.`,action:`Nothing to do.`,link:Tm},platform:{severity:`info`,conversion:`automatic`,title:`The diagram names Camunda {target} as its platform`,detail:`Camunda Modeler and Penstock read the platform from the file.`,action:`Nothing to do.`},"data-migration":{severity:`warning`,conversion:`manual`,title:`Running instances and history stay on Camunda 7`,detail:`Converting a diagram does not move its instances. Instances can finish on Camunda 7, or be moved with Camunda's Data Migrator, which needs the element ids to stay as they are; the converter keeps them.`,action:`Decide whether to drain Camunda 7 or to run the Data Migrator.`,link:km}},jm=[`title`,`detail`,`action`];function Mm(e,t,n){return`app.migration.rules.${e}${n?`.${n}`:``}.${t}`}function Nm(n,r,i={},a){let o={},s={};for(let c of jm){s[c]=e(r[c],i);let l=a?Mm(n,c,a):``,u=l?t(l,i):``;o[c]=l&&u!==l?u:t(Mm(n,c),i)}return{text:o,english:s}}var J=class extends Error{};function Y(e,n){return t(`app.migration.juel.${e}`,n)}const Pm={and:`&&`,or:`||`,not:`!`,eq:`==`,ne:`!=`,lt:`<`,gt:`>`,le:`<=`,ge:`>=`,div:`/`,mod:`%`,empty:`empty`},Fm=e=>Object.hasOwn(Pm,e)?Pm[e]:void 0,Im=[`==`,`!=`,`<=`,`>=`,`&&`,`||`,`<`,`>`,`+`,`-`,`*`,`/`,`%`,`!`,`?`,`:`,`(`,`)`,`[`,`]`,`.`,`,`],Lm=/* @__PURE__ */ new Set([`true`,`false`,`null`,`and`,`or`,`not`,`if`,`then`,`else`,`for`,`in`,`return`,`some`,`every`,`satisfies`,`instance`,`of`,`between`,`function`,`external`]),Rm={nrOfInstances:`numberOfInstances`,nrOfActiveInstances:`numberOfActiveInstances`,nrOfCompletedInstances:`numberOfCompletedInstances`},zm=/* @__PURE__ */ new Set([`execution`,`task`,`variableScope`,`externalTask`,`authenticatedUserId`,`dateTime`,`currentUser`,`currentUserGroups`]),Bm=/[$#]\{/;function Vm(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(/\s/.test(r)){n+=1;continue}if(r===`"`||r===`'`){let i=``,a=n+1;for(;a<e.length&&e[a]!==r;)e[a]===`\\`&&a+1<e.length?(i+=e[a+1],a+=2):(i+=e[a],a+=1);if(a>=e.length)throw new J(Y(`stringOpen`));t.push({type:`string`,value:i}),n=a+1;continue}let i=/^(?:\d+\.\d*|\.\d+|\d+)(?:[eE][+-]?\d+)?[lLfFdD]?/.exec(e.slice(n));if(i&&/[\d.]/.test(r)&&(r!==`.`||/\d/.test(e[n+1]??``))){t.push({type:`number`,value:i[0]}),n+=i[0].length;continue}let a=/^[A-Za-z_$][\w$]*/.exec(e.slice(n));if(a){t.push({type:`name`,value:a[0]}),n+=a[0].length;continue}let o=Im.find(t=>e.startsWith(t,n));if(!o)throw new J(Y(`character`,{what:r}));t.push({type:`op`,value:o}),n+=o.length}return t.push({type:`end`,value:``}),t}var Hm=class{at=0;tokens;constructor(e){this.tokens=e}parse(){let e=this.ternary();if(this.peek().type!==`end`)throw new J(Y(`trailing`,{what:this.peek().value}));return e}peek(){return this.tokens[this.at]}operator(){let e=this.peek();return e.type===`op`?e.value:e.type===`name`?Fm(e.value)??null:null}take(){let e=this.tokens[this.at];return this.at+=1,e}expect(e){if(this.operator()!==e)throw new J(Y(`expected`,{what:e,found:this.peek().value||`the end`}));this.take()}ternary(){let e=this.or();if(this.operator()!==`?`)return e;this.take();let t=this.ternary();return this.expect(`:`),{kind:`ternary`,test:e,then:t,otherwise:this.ternary()}}binary(e,t){let n=e();for(let r=this.operator();r!==null&&t.includes(r);r=this.operator())this.take(),n={kind:`binary`,op:r,left:n,right:e()};return n}or(){return this.binary(()=>this.and(),[`||`])}and(){return this.binary(()=>this.equality(),[`&&`])}equality(){return this.binary(()=>this.relational(),[`==`,`!=`])}relational(){return this.binary(()=>this.additive(),[`<`,`>`,`<=`,`>=`])}additive(){return this.binary(()=>this.multiplicative(),[`+`,`-`])}multiplicative(){return this.binary(()=>this.unary(),[`*`,`/`,`%`])}unary(){let e=this.operator();return e===`!`?(this.take(),{kind:`unary`,op:`not`,operand:this.unary()}):e===`-`?(this.take(),{kind:`unary`,op:`minus`,operand:this.unary()}):e===`empty`?(this.take(),{kind:`unary`,op:`empty`,operand:this.unary()}):this.postfix(this.primary())}args(){this.expect(`(`);let e=[];if(this.operator()!==`)`)for(e.push(this.ternary());this.operator()===`,`;)this.take(),e.push(this.ternary());return this.expect(`)`),e}postfix(e){let t=e;for(;;){let e=this.operator();if(e===`.`){this.take();let e=this.take();if(e.type!==`name`)throw new J(Y(`propertyName`));t=this.operator()===`(`?{kind:`call`,target:t,name:e.value,args:this.args()}:{kind:`path`,target:t,name:e.value}}else if(e===`[`){this.take();let e=this.ternary();this.expect(`]`),t={kind:`index`,target:t,index:e}}else return t}}primary(){let e=this.take();if(e.type===`number`)return{kind:`literal`,text:e.value};if(e.type===`string`)return{kind:`literal`,text:JSON.stringify(e.value)};if(e.type===`op`&&e.value===`(`){let e=this.ternary();return this.expect(`)`),e}if(e.type===`name`){if(e.value===`true`||e.value===`false`||e.value===`null`)return{kind:`literal`,text:e.value};if(Fm(e.value))throw new J(Y(`wordAsValue`,{what:e.value}));if(this.operator()===`:`&&this.tokens[this.at+1]?.type===`name`&&this.tokens[this.at+2]?.value===`(`){this.take();let t=this.take().value;return{kind:`function`,prefix:e.value,name:t,args:this.args()}}return this.operator()===`(`?{kind:`call`,target:null,name:e.value,args:this.args()}:{kind:`name`,name:e.value}}throw new J(e.type===`end`?Y(`endsEarly`):Y(`tokenAsValue`,{what:e.value}))}};const Um={ternary:1,"||":2,"&&":3,compare:4,"+":5,"-":5,"*":6,"/":6,unary:7};var Wm=class{review=[];context;constructor(e){this.context=e}note(e){this.review.includes(e)||this.review.push(e)}precedence(e){switch(e.kind){case`ternary`:return Um.ternary;case`binary`:return[`==`,`!=`,`<`,`>`,`<=`,`>=`].includes(e.op)?Um.compare:Um[e.op]??8;case`unary`:return e.op===`minus`?Um.unary:8;default:return 8}}wrap(e,t){let n=this.print(e);return this.precedence(e)<t?`(${n})`:n}name(e){if(this.context.multiInstance&&Object.hasOwn(Rm,e))return Rm[e];if(zm.has(e))throw new J(Y(`contextObject`,{what:e}));if(e.includes(`$`))throw new J(Y(`dollarInName`,{what:e}));if(Lm.has(e))throw new J(Y(`reservedWord`,{what:e}));return e}variableName(e){if(e.kind!==`literal`||!e.text.startsWith(`"`))return null;let t=JSON.parse(e.text);return/^[A-Za-z_][A-Za-z0-9_]*$/.test(t)&&!Lm.has(t)?t:null}executionCall(e,t){let n=t.length===1?this.variableName(t[0]):null;switch(e){case`getVariable`:case`getVariableTyped`:if(n)return n;break;case`getVariableLocal`:case`getVariableLocalTyped`:if(n)return this.note(Y(`localVariable`)),n;break;case`hasVariable`:if(n)return`is defined(${n})`;break;case`getProcessBusinessKey`:case`getBusinessKey`:throw new J(Y(`businessKey`));case`getProcessInstanceId`:case`getId`:case`getActivityInstanceId`:throw new J(Y(`engineId`))}throw new J(Y(`executionCall`,{what:e}))}method(e,t,n){if(e.kind===`name`&&(e.name===`execution`||e.name===`task`||e.name===`variableScope`))return this.executionCall(t,n);let r=this.print(e),i=()=>r,a=()=>{if(n.length!==1)throw new J(Y(`takesOne`,{what:t}));return this.print(n[0])},o=()=>{if(n.length!==0)throw new J(Y(`takesNone`,{what:t}))};switch(t){case`equals`:if(n.length!==1)throw new J(Y(`equalsTakesOne`));return`${this.wrap(e,5)} = ${this.wrap(n[0],5)}`;case`equalsIgnoreCase`:return`lower case(${i()}) = lower case(${a()})`;case`startsWith`:return`starts with(${i()}, ${a()})`;case`endsWith`:return`ends with(${i()}, ${a()})`;case`toUpperCase`:return o(),`upper case(${i()})`;case`toLowerCase`:return o(),`lower case(${i()})`;case`trim`:return o(),`trim(${i()})`;case`length`:return o(),`string length(${i()})`;case`size`:return o(),this.note(Y(`size`,{target:this.print(e)})),`count(${i()})`;case`toString`:return o(),`string(${i()})`}throw new J(Y(`javaCall`,{what:t}))}print(e){switch(e.kind){case`literal`:if(/^\d/.test(e.text)||e.text.startsWith(`.`)){if(/[eE]/.test(e.text))throw new J(Y(`exponent`));let t=e.text.replace(/[lLfFdD]$/,``);return t.startsWith(`.`)?`0${t}`:t.endsWith(`.`)?t.slice(0,-1):t}return e.text;case`name`:return this.name(e.name);case`path`:if(e.target.kind===`name`&&zm.has(e.target.name))throw new J(Y(`enginePath`,{target:e.target.name,what:e.name}));return`${this.wrap(e.target,8)}.${this.name(e.name)}`;case`index`:{let t=this.variableName(e.index);if(t)return`${this.wrap(e.target,8)}.${t}`;if(e.index.kind===`literal`&&/^\d+$/.test(e.index.text))return this.note(Y(`indexShifted`)),`${this.wrap(e.target,8)}[${Number(e.index.text)+1}]`;throw new J(Y(`computedIndex`))}case`call`:if(e.target===null)throw new J(Y(`juelFunction`,{what:e.name}));return this.method(e.target,e.name,e.args);case`function`:throw new J(Y(`namespacedFunction`,{prefix:e.prefix,what:e.name}));case`unary`:if(e.op===`not`)return`not(${this.print(e.operand)})`;if(e.op===`minus`)return`-${this.wrap(e.operand,7)}`;throw new J(Y(`empty`));case`ternary`:return`if ${this.print(e.test)} then ${this.print(e.then)} else ${this.print(e.otherwise)}`;case`binary`:return this.binary(e.op,e.left,e.right)}}binary(e,t,n){if(e===`||`)return`${this.wrap(t,2)} or ${this.wrap(n,3)}`;if(e===`&&`)return`${this.wrap(t,3)} and ${this.wrap(n,4)}`;if([`==`,`!=`,`<`,`>`,`<=`,`>=`].includes(e)){let r=e===`==`?`=`:e;return`${this.wrap(t,5)} ${r} ${this.wrap(n,5)}`}if(e===`%`)return`modulo(${this.print(t)}, ${this.print(n)})`;if(e===`+`&&(this.isString(t)||this.isString(n)))throw new J(Y(`textPlus`));let r=Um[e];return`${this.wrap(t,r)} ${e} ${this.wrap(n,r+1)}`}isString(e){return e.kind===`literal`&&e.text.startsWith(`"`)}};function X(e){return!!e&&Bm.test(e)}function Gm(e){let t=[],n=0;for(;n<e.length;){let r=e.slice(n).search(Bm);if(r<0){t.push({literal:e.slice(n),expression:null});break}let i=n+r,a=0,o=null,s=-1;for(let t=i+2;t<e.length;t+=1){let n=e[t];if(o)n===`\\`?t+=1:n===o&&(o=null);else if(n===`"`||n===`'`)o=n;else if(n===`{`)a+=1;else if(n===`}`){if(a===0){s=t;break}--a}}if(s<0)throw new J(Y(`expressionOpen`));t.push({literal:e.slice(n,i),expression:e.slice(i+2,s)}),n=s+1}return t}function Km(e,t){return t.print(new Hm(Vm(e)).parse())}function qm(e,t={}){let n=new Wm(t);try{if(e.length>2e4)throw new J(Y(`tooComplex`));let t=Gm(e);if(t.length===1&&t[0].literal===``&&t[0].expression!==null)return{ok:!0,feel:`=${Km(t[0].expression,n)}`,review:n.review};if(t.every(e=>e.expression===null))return{ok:!0,feel:e,review:[]};let r=t.flatMap(e=>[...e.literal?[JSON.stringify(e.literal)]:[],...e.expression===null?[]:[`string(${Km(e.expression,n)})`]]);return n.review.push(Y(`joinedStrings`)),{ok:!0,feel:`=${r.join(` + `)}`,review:n.review}}catch(e){if(e instanceof J)return{ok:!1,reason:e.message};if(e instanceof RangeError)return{ok:!1,reason:Y(`tooComplex`)};throw e}}const Jm={ref:`reference`,id:`id`},Ym=[[/\bsub process\b/g,`sub-process`],[/\bad hoc\b/g,`ad-hoc`],[/\bmulti instance\b/g,`multi-instance`],[/\bevent based\b/g,`event-based`]];function Xm(e,t=!1){let n=(e.includes(`:`)?e.slice(e.indexOf(`:`)+1):e).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).toLowerCase().split(/[\s_-]+/).filter(Boolean).map(e=>t?Jm[e]??e:e).join(` `);return Ym.reduce((e,[t,n])=>e.replace(t,n),n)}function Zm(e){return/[^aeiou]y$/.test(e)?`${e.slice(0,-1)}ies`:/(s|x|ch|sh)$/.test(e)?`${e}es`:`${e}s`}function Qm(e){let t=e.includes(`:`)?e.slice(e.indexOf(`:`)+1):e;return t&&t[0].toLowerCase()+t.slice(1)}function $m(e,n){let r=`app.element.kind.${Qm(e)}`,i=t(r,{count:n===`one`?1:2});if(i!==r)return i;let a=Xm(e);return n===`one`?a:Zm(a)}function eh(e){return $m(e,`one`)}const th=/* @__PURE__ */ new Set([`checkbox`,`checklist`,`datetime`,`number`,`radio`,`select`,`taglist`,`expression`,`textfield`,`textarea`,`filepicker`]),nh={DecisionTable:`app.dmn.view.decisionTable`,LiteralExpression:`app.dmn.view.literalExpression`,BoxedExpression:`app.dmn.view.boxedExpression`,RequirementsDiagram:`app.dmn.view.drd`};function rh(e){let n=`app.sections.formKind.${e??``}`,r=t(n);return r===n?e??``:r}function ih(e){return eh(e)}function ah(e){if(!e)return t(`app.sections.noLogic`);let n=nh[e.$type.replace(`dmn:`,``)];return n?t(n):ih(e.$type)}const oh={UNIQUE:`unique`,FIRST:`first`,PRIORITY:`priority`,ANY:`any`,COLLECT:`collect`,"RULE ORDER":`ruleOrder`,"OUTPUT ORDER":`outputOrder`};function sh(e){let n=(e.hitPolicy??`UNIQUE`).toUpperCase(),r=oh[n],i=r?t(`app.sections.hitPolicy.${r}`):n,a=e.aggregation?t(`app.sections.resultsCombinedBy`,{how:e.aggregation.toLowerCase()}):``;return t(`app.sections.hitPolicyText`,{policy:i,aggregation:a})}function ch(e){let n=t=>{let n=(t??``).replace(/^#/,``);return e.find(e=>e.id===n)?.name?.trim()||n},r=e.filter(e=>e.$type===`dmn:Decision`),i=r.map(e=>{let n=e.name?.trim()||e.id||t(`app.sections.decision`),r=e.decisionLogic;if(r?.$type===`dmn:DecisionTable`){let i=r.input??[],a=r.output??[],o=r.rule??[],s=o.some(e=>e.description?.trim());return{title:n,description:e.description?.trim()||void 0,note:sh(r),head:[`#`,...i.map((e,n)=>t(`app.sections.whenInput`,{input:e.label?.trim()||e.inputExpression?.text?.trim()||t(`app.sections.inputOf`,{number:n+1})})),...a.map((e,n)=>t(`app.sections.thenOutput`,{output:e.label?.trim()||e.name?.trim()||t(`app.sections.outputOf`,{number:n+1})})),...s?[t(`app.sections.notes`)]:[]],rows:o.map((e,t)=>[String(t+1),...i.map((t,n)=>e.inputEntry?.[n]?.text?.trim()||`-`),...a.map((t,n)=>e.outputEntry?.[n]?.text?.trim()??``),...s?[e.description?.trim()??``]:[]])}}return r?.$type===`dmn:LiteralExpression`?{title:n,description:e.description?.trim()||void 0,head:[t(`app.sections.result`),t(`app.sections.expression`)],rows:[[e.variable?.name??n,r.text?.trim()??``]]}:{title:n,head:[t(`app.sections.logic`)],rows:[[ah(r)]]}}),a=r.map(e=>[e.name?.trim()||e.id||``,[...(e.informationRequirement??[]).map(e=>n(e.requiredDecision?.href??e.requiredInput?.href)),...(e.knowledgeRequirement??[]).map(e=>n(e.requiredKnowledge?.href))].join(`, `)]).filter(([,e])=>e);return[{title:t(`app.dmn.requirements`),head:[t(`app.sections.decision`),t(`app.sections.needs`)],rows:a},...i]}function lh(e){return{title:t(`app.sections.fieldTable`),head:[t(`app.sections.field`),t(`app.sections.kind`),t(`app.sections.writes`),t(`app.sections.required`),t(`app.sections.options`),t(`app.sections.hiddenWhen`)],rows:e}}const uh=e=>typeof e==`string`?e.trim():``,dh=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function fh(e,n,r=0){return!Array.isArray(e)||r>200?[]:e.filter(dh).flatMap(e=>{if(Array.isArray(e.components)){let t=uh(e.path),i=t?t.split(`.`):[];return fh(e.components,e.type===`dynamiclist`?[...n,...i,`[]`]:[...n,...i],r+1)}let i=typeof e.type==`string`?e.type:``;if(!th.has(i))return[];let a=typeof e.valuesKey==`string`&&e.valuesKey?e.valuesKey:typeof e.valuesExpression==`string`&&e.valuesExpression?e.valuesExpression:``,o=a?t(`app.sections.optionsFrom`,{source:a}):(Array.isArray(e.values)?e.values.filter(e=>typeof e==`object`&&!!e):[]).map(e=>`${typeof e.label==`string`?e.label:``} = ${JSON.stringify(e.value)}`).join(`, `),s=typeof e.key==`string`?e.key:``,c=dh(e.validate)?e.validate:void 0,l=dh(e.conditional)?e.conditional:void 0;return[[uh(e.label),rh(i),s?[...n,s].join(`.`).replace(/\.\[\]\./g,`[].`):``,c?.required?t(`app.sections.yes`):``,o,typeof l?.hide==`string`?l.hide:``]]})}const ph=`textfield`;function mh(e){return typeof e==`string`&&e!==``?e:void 0}function hh(e){let t=Number(e);return e!==void 0&&e.trim()!==``&&Number.isFinite(t)?t:void 0}function gh(e,n){let r=mh(e.id)??`field`,i=mh(e.type)??`string`,a={id:`Field_${r}`,key:r,label:mh(e.label)??r},o={};(e.validation?.constraints??[]).forEach(e=>{let i=mh(e.name)??``,a=hh(mh(e.config));i===`required`?o.required=!0:i===`minlength`&&a!==void 0?o.minLength=a:i===`maxlength`&&a!==void 0?o.maxLength=a:i===`min`&&a!==void 0?o.min=a:i===`max`&&a!==void 0?o.max=a:i===`readonly`?o.readonly=!0:n.push(t(`app.migration.form.keptOut`,{name:i,id:r}))});let s=o.readonly===!0;delete o.readonly;let c={...Object.keys(o).length>0?{validate:o}:{},...s?{readonly:!0}:{}},l=mh(e.defaultValue),u=Object.fromEntries((e.properties?.values??[]).filter(e=>mh(e.name)).map(e=>[e.name,e.value??``]));switch(Object.keys(u).length>0&&(c.properties=u),i){case`string`:return{...a,type:ph,...l?{defaultValue:l}:{},...c};case`long`:return{...a,type:`number`,...hh(l)===void 0?{}:{defaultValue:hh(l)},...c};case`boolean`:return{...a,type:`checkbox`,...l?{defaultValue:l===`true`}:{},...c};case`date`:return{...a,type:`datetime`,subtype:`date`,dateLabel:a.label,...c};case`enum`:return{...a,type:`select`,values:(e.values??[]).map(e=>({label:mh(e.name)??mh(e.id)??``,value:mh(e.id)??``})),...l?{defaultValue:l}:{},...c};default:return n.push(t(`app.migration.form.lostType`,{type:i,id:r})),{...a,type:ph,...c}}}function _h(e,t){let n=[],r={components:(t.fields??[]).map(e=>gh(e,n)),type:`default`,id:e,executionPlatform:ar,executionPlatformVersion:`8.8.0`,schemaVersion:16};return{json:`${JSON.stringify(r,null,2)}\n`,lost:n}}function vh(e,t){if(e===`class`){let e=t.slice(t.lastIndexOf(`.`)+1);return e.charAt(0).toLowerCase()+e.slice(1)}return t}const yh=`http://camunda.org/schema/conversion/1.0`,bh=/* @__PURE__ */ new Set([`bpmn:IntermediateCatchEvent`,`bpmn:BoundaryEvent`,`bpmn:ReceiveTask`]),xh=/* @__PURE__ */ new Set([`bpmn:ServiceTask`,`bpmn:SendTask`,`bpmn:BusinessRuleTask`,`bpmn:ScriptTask`,`bpmn:EndEvent`,`bpmn:IntermediateThrowEvent`]),Sh=/* @__PURE__ */ new Set([...xh,`bpmn:CallActivity`,`bpmn:SubProcess`,`bpmn:UserTask`]),Ch=/* @__PURE__ */ new Set([...Sh,`bpmn:IntermediateCatchEvent`,`bpmn:BoundaryEvent`,`bpmn:StartEvent`,`bpmn:ReceiveTask`]),wh=/^bpmn:(?:\w*Task|SubProcess|CallActivity|Transaction|\w*Event|ExclusiveGateway|InclusiveGateway|ParallelGateway|EventBasedGateway|Process)$/,Th={create:`creating`,assignment:`assigning`,update:`updating`,complete:`completing`,delete:`canceling`},Eh=/* @__PURE__ */ new Set([`camunda:InputOutput`,`camunda:ExecutionListener`,`camunda:TaskListener`,`camunda:Properties`,`camunda:In`,`camunda:Out`,`camunda:FailedJobRetryTimeCycle`,`camunda:Field`,`camunda:FormData`]);function Z(e,n){return t(`app.migration.detail.${e}`,n)}function Dh(e){return(e.split(`:`).pop()??e).replace(/([a-z])([A-Z])/g,`$1 $2`).toLowerCase()}function Oh(e){return(typeof e?.name==`string`?e.name.replace(/\s+/g,` `).trim():``)||e?.id||Dh(e?.$type??`element`)}function Q(e){if(typeof e==`string`)return e.trim()?e:void 0;if(typeof e==`boolean`||typeof e==`number`)return String(e)}function kh(e){let t=/^\s*R(\d+)\//.exec(e);if(t)return t[1];let n=e.split(`,`).map(e=>e.trim()).filter(Boolean);return n.length>0&&n.every(e=>/^P/.test(e))?String(n.length):null}function Ah(e){let t=e.trim().split(/\s+/);return t.length>=5&&t.length<=7&&!e.trim().startsWith(`R`)&&!e.trim().startsWith(`P`)}var jh=class{findings=[];changes=[];extraFiles=[];delegates=[];definitions;moddle;target;options;kept=/* @__PURE__ */ new WeakMap;keptCount=0;keptValues=/* @__PURE__ */ new WeakSet;marks=/* @__PURE__ */ new Map;process=null;constructor(e,t={}){this.definitions=e,this.moddle=a(e),this.options=t,this.target=t.target??`8.8`}run(){this.removeMarkers(this.definitions),this.take(this.definitions,`camunda:diagramRelationId`);let e=this.definitions.rootElements??[];e.filter(e=>e.$type===`bpmn:Error`).forEach(e=>this.error(e)),e.filter(e=>e.$type===`bpmn:Message`).forEach(e=>this.messageName(e)),e.filter(e=>e.$type===`bpmn:Process`).forEach(e=>{this.process=e,this.processAttributes(e),this.common(e),(e.flowElements??[]).forEach(e=>this.flowElement(e)),(e.laneSets??[]).forEach(e=>this.common(e))}),this.process=null,this.leftovers(),this.writeMarkers(),this.platform()}found(e,t,n={},r={}){let{variant:i,...a}=r,o=this.anchor(e),s={...Am[t],...a},{text:c,english:l}=Nm(t,s,n,i),u={rule:`migration/${t}`,severity:s.severity,conversion:s.conversion,title:c.title,detail:c.detail,action:c.action,elements:o?.id?[o.id]:[],where:Oh(o),...s.since?{since:s.since}:{},...s.link?{link:s.link}:{}};return this.findings.push(u),u.conversion!==`automatic`&&o&&this.marks.set(o,[...this.marks.get(o)??[],{conversion:u.conversion,...l}]),u}changed(e,t,n,r){this.changes.push({elementId:e?.id??``,where:Oh(e),before:t,after:n,...r?{plain:r}:{}})}get(e,t){return Q(e?.get?.(t))??Q(e?.$attrs?.[t])}take(e,t){let n=this.get(e,t);if(n!==void 0)return e.$attrs&&t in e.$attrs?delete e.$attrs[t]:e.set(t,void 0),n}keep(e,t){let n=this.kept.get(e)??/* @__PURE__ */ new Set;n.add(t),this.kept.set(e,n),this.keptCount+=1}isKept(e,t){return this.kept.get(e)?.has(t)===!0}anchor(e){let t=e;for(;t?.$parent&&(!t.id||/EventDefinition$|LoopCharacteristics$|^bpmn:(?:Formal)?Expression$|^bpmn:ExtensionElements$/.test(t.$type));)t=t.$parent;return t}values(e){return e?.extensionElements?.values??[]}extensions(e,t){return this.values(e).filter(e=>e.$type===t)}remove(e,t){e.extensionElements&&(e.extensionElements.values=this.values(e).filter(e=>e!==t),e.extensionElements.values.length===0&&(e.extensionElements=void 0))}add(e,t,n={}){e.extensionElements||(e.extensionElements=this.moddle.create(`bpmn:ExtensionElements`,{values:[]}),e.extensionElements.$parent=e);let r=this.moddle.create(t,n);return r.$parent=e.extensionElements,e.extensionElements.values=[...this.values(e),r],r}single(e,t){return this.extensions(e,t)[0]??this.add(e,t)}feel(e,t,n,r={}){if(!X(n))return n;let i=qm(n,r);return i.ok?(i.review.length>0?this.found(e,`expression-review`,{expression:n,feel:i.feel,reason:i.review.join(`; `)}):t===`condition`&&this.found(e,`condition`,{expression:n,feel:i.feel}),i.feel):(this.found(e,`expression-manual`,{expression:n,reason:i.reason}),null)}feelOrLiteral(e,t,n){return n===void 0?`=null`:X(n)?this.feel(e,t,n):`=${JSON.stringify(n)}`}since(e,t,n,r){return N(this.target,n)?!0:(this.found(e,`element-since`,{what:t,version:n,target:this.target},r?{detail:r,variant:`withDetail`}:{}),!1)}delegate(e,t){this.delegates.push({...t,elementId:e.id,where:Oh(e)})}common(e){let n=[`camunda:asyncBefore`,`camunda:asyncAfter`,`camunda:async`].map(t=>this.take(e,t)).some(e=>e===`true`);this.take(e,`camunda:exclusive`),n&&(this.found(e,`async`),this.changed(e,t(`app.migration.change.asyncBefore`),t(`app.migration.change.removed`),t(`app.migration.change.async`)));let r=this.take(e,`camunda:modelerTemplate`);this.take(e,`camunda:modelerTemplateVersion`),r&&this.found(e,`template`,{template:r}),this.executionListeners(e),this.properties(e)}processAttributes(e){let n=this.take(e,`camunda:versionTag`);n&&(N(this.target,`8.6`)?(this.single(e,`zeebe:VersionTag`).value=n,this.found(e,`version-tag`,{tag:n}),this.changed(e,`camunda:versionTag="${n}"`,`zeebe:versionTag value="${n}"`,t(`app.migration.change.versionTag`,{tag:n}))):this.found(e,`version-tag`,{tag:n},{severity:`warning`,variant:`dropped`,title:`The version tag {tag} is dropped`,detail:`Camunda 8 keeps version tags from 8.6.`}));let r=this.take(e,`camunda:historyTimeToLive`);r&&this.found(e,`history-time-to-live`,{ttl:r}),this.take(e,`camunda:isStartableInTasklist`)!==void 0&&this.found(e,`startable-in-tasklist`),[`camunda:candidateStarterGroups`,`camunda:candidateStarterUsers`].forEach(t=>{let n=this.get(e,t);n&&(this.keep(e,t),this.found(e,`starter-groups`,{groups:n}))}),this.priority(e),this.take(e,`camunda:taskPriority`)&&this.found(e,`external-task-priority`)}priority(e){let t=this.take(e,`camunda:jobPriority`);if(t){if(N(this.target,`8.8`)&&(e.$type===`bpmn:Process`||xh.has(e.$type))){let n=this.feelOrLiteral(e,`job priority`,t);if(n===null)return;this.single(e,`zeebe:JobPriorityDefinition`).priority=n.startsWith(`="`)?JSON.parse(n.slice(1)):n,this.found(e,`job-priority`,{priority:t})}else this.found(e,`job-priority-dropped`,{priority:t})}}properties(e){this.extensions(e,`camunda:Properties`).forEach(t=>{let n=this.single(e,`zeebe:Properties`),r=(t.values??[]).map(e=>this.moddle.create(`zeebe:Property`,{name:e.name,value:e.value}));n.properties=[...n.properties??[],...r],this.remove(e,t),this.found(e,`properties`)})}flowElement(e){let t=e.$type;switch(this.common(e),t){case`bpmn:ServiceTask`:case`bpmn:SendTask`:this.implementation(e,e);break;case`bpmn:BusinessRuleTask`:this.get(e,`camunda:decisionRef`)?this.decision(e):this.implementation(e,e);break;case`bpmn:ScriptTask`:this.script(e);break;case`bpmn:UserTask`:this.userTask(e);break;case`bpmn:CallActivity`:this.callActivity(e);break;case`bpmn:ReceiveTask`:e.messageRef&&this.found(e,`message-catch`,{message:Oh(e.messageRef)});break;case`bpmn:ComplexGateway`:this.found(e,`unsupported-element`,{what:ih(`bpmn:ComplexGateway`),reason:Z(`complexGateway`),action:Z(`complexGatewayAction`)});break;case`bpmn:InclusiveGateway`:(e.incoming??[]).length>1&&this.since(e,`joining inclusive gateway`,`8.6`);break;case`bpmn:Transaction`:this.found(e,`unsupported-element`,{what:ih(`bpmn:Transaction`),reason:Z(`transaction`),action:Z(`transactionAction`)});break;case`bpmn:AdHocSubProcess`:this.since(e,ih(`bpmn:AdHocSubProcess`),`8.7`);break;case`bpmn:SequenceFlow`:this.condition(e);break;case`bpmn:StartEvent`:this.startEvent(e)}t.endsWith(`Event`)&&this.event(e),this.loop(e),this.inputOutput(e),this.retries(e),this.fields(e),this.priority(e),this.taskListeners(e),(e.flowElements??[]).forEach(e=>this.flowElement(e))}implementation(e,n){let r=this.values(n).find(e=>e.$type===`camunda:Connector`);if(r)return this.keptValues.add(r),this.found(e,`connector`,{connector:Q(r.connectorId)??`connector`}),!1;let i=this.get(n,`camunda:topic`),a=this.get(n,`camunda:type`)===`external`||i!==void 0;this.values(n).filter(e=>e.$type===`camunda:ErrorEventDefinition`).forEach(t=>{this.keptValues.add(t),this.found(e,`external-error`,{expression:Q(t.expression)??``})});let o=null;if(a){if(!i)return!1;if(X(i)){let t=this.feel(e,`topic`,i);if(t===null)return this.keep(n,`camunda:topic`),!1;o=t}else o=i;this.take(n,`camunda:type`),this.take(n,`camunda:topic`),this.found(e,`external-task`,{topic:i,jobType:o}),this.delegate(e,{kind:`topic`,value:i,role:`task`,jobType:o}),this.take(n,`camunda:taskPriority`)&&this.found(e,`external-task-priority`)}else{let t=this.get(n,`camunda:class`),r=this.get(n,`camunda:delegateExpression`),i=this.get(n,`camunda:expression`),a=this.get(n,`camunda:resultVariable`);if(t)o=vh(`class`,t),this.take(n,`camunda:class`),this.found(e,`java-class`,{className:t,jobType:o}),this.delegate(e,{kind:`class`,value:t,role:`task`,jobType:o});else if(r){let t=/^[$#]\{\s*([A-Za-z_][\w]*)\s*\}$/.exec(r.trim())?.[1];if(!t)return this.keep(n,`camunda:delegateExpression`),this.found(e,`delegate-expression-dynamic`,{expression:r}),!1;o=vh(`bean`,t),this.take(n,`camunda:delegateExpression`),this.found(e,`delegate-expression`,{delegate:r,jobType:o}),this.delegate(e,{kind:`bean`,value:t,role:`task`,jobType:o})}else if(i){let t=/^[$#]\{\s*([A-Za-z_]\w*)\s*\.\s*([A-Za-z_]\w*)\s*\([^]*\)\s*\}$/.exec(i.trim());if(!t||t[1]===`execution`)return this.keep(n,`camunda:expression`),a&&this.keep(n,`camunda:resultVariable`),this.found(e,`expression-unknown`,{expression:i}),!1;o=vh(`expression`,`${t[1]}.${t[2]}`),this.take(n,`camunda:expression`),this.take(n,`camunda:resultVariable`),this.found(e,`expression`,{expression:i,jobType:o},a?{variant:`withResult`,action:`Write a job worker for {jobType} that makes the call {expression} made and completes the job with the variable {result}.`}:{}),this.delegate(e,{kind:`expression`,value:i,role:`task`,jobType:o})}a&&this.get(n,`camunda:resultVariable`)&&this.take(n,`camunda:resultVariable`)}if(!o)return!1;let s=this.single(e,`zeebe:TaskDefinition`);return s.type=o,this.changed(e,t(`app.migration.change.camunda7Implementation`),`zeebe:taskDefinition type="${o}"`,t(`app.migration.change.jobWorkerTask`,{jobType:o})),!0}retries(e){[e,e.loopCharacteristics].filter(Boolean).forEach(n=>{this.extensions(n,`camunda:FailedJobRetryTimeCycle`).forEach(r=>{let i=Q(r.body)??``;this.remove(n,r);let a=this.extensions(e,`zeebe:TaskDefinition`)[0],o=kh(i);a&&o&&n===e?(a.retries=o,this.found(e,`retries`,{cycle:i,retries:o}),this.changed(e,`camunda:failedJobRetryTimeCycle ${i}`,`retries="${o}"`,t(`app.migration.change.retries`,{retries:o}))):this.found(e,`retries-dropped`,{cycle:i})})})}fields(e){let n=this.extensions(e,`camunda:Field`);if(n.length===0)return;let r=this.extensions(e,`zeebe:TaskDefinition`)[0],i=[];n.forEach(t=>{let n=Q(t.stringValue)??Q(t.string),a=Q(t.expression);if(!r||a!==void 0||n===void 0){this.keptValues.add(t),this.found(e,`field-injection-expression`,{field:t.name});return}let o=this.single(e,`zeebe:TaskHeaders`);o.values=[...o.values??[],this.moddle.create(`zeebe:Header`,{key:t.name,value:n})],this.remove(e,t),i.push(t.name)}),i.length>0&&(this.found(e,`field-injection`,{fields:i.join(`, `)}),this.changed(e,`camunda:field ${i.join(`, `)}`,`zeebe:taskHeaders ${i.join(`, `)}`,t(`app.migration.change.fieldHeaders`,{fields:i.join(`, `)})))}parameter(e,t){let n=t.definition;return n?this.definitionValue(e,t.name,n):this.feelOrLiteral(e,`mapping`,Q(t.value))}definitionValue(e,t,n){switch(n.$type){case`camunda:Script`:return this.found(e,`input-output-script`,{name:t,format:Q(n.scriptFormat)??`script`}),null;case`camunda:List`:{let r=(n.items??[]).map(n=>this.item(e,t,n));return r.some(e=>e===null)?null:`=[${r.join(`, `)}]`}case`camunda:Map`:{let r=(n.entries??[]).map(n=>{let r=n.definition?this.definitionValue(e,t,n.definition):this.feelOrLiteral(e,`mapping`,Q(n.value));return r===null?null:`${JSON.stringify(n.key??``)}: ${r.slice(1)}`});return r.some(e=>e===null)?null:`={${r.join(`, `)}}`}default:return this.found(e,`input-output-manual`,{name:t,reason:Z(`mappingValue`,{type:Dh(n.$type)})}),null}}item(e,t,n){if(n.$type===`camunda:Value`){let t=this.feelOrLiteral(e,`mapping`,Q(n.value));return t===null?null:t.slice(1)}let r=this.definitionValue(e,t,n);return r===null?null:r.slice(1)}inputOutput(e){this.extensions(e,`camunda:InputOutput`).forEach(n=>{let r=(t,n,r)=>t.filter(t=>{if(!r)return this.found(e,`input-output-manual`,{name:t.name,reason:Z(`noMapping`,{kind:n,element:Dh(e.$type)})}),!0;let i=this.parameter(e,t);if(i===null)return!0;let a=this.single(e,`zeebe:IoMapping`),o=this.moddle.create(n===`input`?`zeebe:Input`:`zeebe:Output`,{source:i,target:t.name});return n===`input`?a.inputParameters=[...a.inputParameters??[],o]:a.outputParameters=[...a.outputParameters??[],o],!1}),i=r(n.inputParameters??[],`input`,Sh.has(e.$type)),a=r(n.outputParameters??[],`output`,Ch.has(e.$type)),o=(n.inputParameters?.length??0)+(n.outputParameters?.length??0)-i.length-a.length;o>0&&(this.found(e,`input-output`),this.changed(e,`camunda:inputOutput`,`zeebe:ioMapping, ${o} parameter${o===1?``:`s`}`,t(`app.migration.change.ioMapping`,{count:o}))),i.length+a.length===0?this.remove(e,n):(n.inputParameters=i,n.outputParameters=a,this.keptValues.add(n))})}condition(e){let n=e.conditionExpression;if(!n)return;let r=Q(n.language),i=this.get(n,`camunda:resource`);if(i){this.keep(n,`camunda:resource`),this.found(e,`script-resource`,{resource:i});return}if(r&&!/^(juel|feel)$/i.test(r)){this.found(e,`script-condition`,{format:r});return}let a=Q(n.body);if(!a)return;if(r?.toLowerCase()===`feel`){n.body=a.startsWith(`=`)?a:`=${a}`,n.language=void 0,this.changed(e,a,n.body,t(`app.migration.change.conditionFeel`));return}let o=this.feel(e,`condition`,a);o!==null&&(n.body=o,n.language=void 0,this.changed(e,a,o,t(`app.migration.change.conditionRewritten`)))}loop(e){let n=e.loopCharacteristics;if(n?.$type!==`bpmn:MultiInstanceLoopCharacteristics`){n?.$type===`bpmn:StandardLoopCharacteristics`&&this.found(e,`unsupported-element`,{what:`standard loop`,reason:Z(`standardLoop`),action:Z(`standardLoopAction`)});return}this.common(n);let r=this.get(n,`camunda:collection`),i=this.get(n,`camunda:elementVariable`),a=Q(n.loopCardinality?.body),o=()=>this.single(n,`zeebe:LoopCharacteristics`);if(r){let a=X(r)?this.feel(e,`collection`,r,{multiInstance:!0}):`=${r}`;if(a===null)this.keep(n,`camunda:collection`),i&&this.keep(n,`camunda:elementVariable`);else{this.take(n,`camunda:collection`),this.take(n,`camunda:elementVariable`);let s=o();s.inputCollection=a,i&&(s.inputElement=i),this.found(e,`multi-instance`,{collection:r}),this.changed(e,`camunda:collection="${r}"`,`inputCollection="${a}"`,t(`app.migration.change.collection`,{collection:r}))}}else if(a){let r=X(a)?this.feel(e,`cardinality`,a,{multiInstance:!0}):`=${a.trim()}`;if(r!==null){n.loopCardinality=void 0;let i=/^[\w.]+$/.test(r.slice(1))?r.slice(1):`(${r.slice(1)})`;o().inputCollection=`=for i in 1..${i} return i`,this.found(e,`multi-instance-cardinality`,{cardinality:a}),this.changed(e,`loopCardinality ${a}`,`inputCollection="=for i in 1..${i} return i"`,t(`app.migration.change.loopCount`,{cardinality:a}))}}else this.extensions(n,`zeebe:LoopCharacteristics`)[0]?.inputCollection||this.found(e,`multi-instance-missing`);let s=Q(n.completionCondition?.body);if(s&&X(s)){let r=this.feel(e,`completion condition`,s,{multiInstance:!0});r!==null&&(n.completionCondition.body=r,n.completionCondition.language=void 0,this.changed(e,s,r,t(`app.migration.change.completionCondition`)))}}startEvent(e){let t=this.get(e,`camunda:initiator`);t&&(this.keep(e,`camunda:initiator`),this.found(e,`initiator`,{variable:t})),this.form(e)}event(e){(e.eventDefinitions??[]).forEach(t=>{switch(this.common(t),t.$type){case`bpmn:MessageEventDefinition`:this.messageEvent(e,t);break;case`bpmn:TimerEventDefinition`:this.timer(e,t);break;case`bpmn:ErrorEventDefinition`:this.errorEvent(e,t);break;case`bpmn:EscalationEventDefinition`:{let n=this.get(t,`camunda:escalationCodeVariable`);n&&(this.keep(t,`camunda:escalationCodeVariable`),this.found(e,`escalation-code-variable`,{variable:n}));break}case`bpmn:SignalEventDefinition`:this.signal(e,t);break;case`bpmn:ConditionalEventDefinition`:this.conditional(e,t);break;case`bpmn:CompensateEventDefinition`:this.since(e,`compensation event`,`8.5`);break;case`bpmn:CancelEventDefinition`:this.found(e,`unsupported-element`,{what:`cancel event`,reason:Z(`cancelEvent`),action:Z(`cancelEventAction`)})}})}messageEvent(e,t){if(e.$type===`bpmn:EndEvent`||e.$type===`bpmn:IntermediateThrowEvent`){if(![`camunda:class`,`camunda:delegateExpression`,`camunda:expression`,`camunda:topic`].some(e=>this.get(t,e))){this.found(e,`message-throw-empty`);return}let n=this.findings.length;if(this.implementation(e,t)){let t=this.extensions(e,`zeebe:TaskDefinition`)[0]?.type,r=/* @__PURE__ */ new Set([`migration/java-class`,`migration/delegate-expression`,`migration/expression`,`migration/external-task`]),i=this.findings.findIndex((e,t)=>t>=n&&r.has(e.rule));i>=0&&this.findings.splice(i,1);let a=this.delegates[this.delegates.length-1];this.found(e,`message-throw`,{implementation:a?.value??`the implementation`,jobType:t??``})}}else(bh.has(e.$type)||e.$type===`bpmn:StartEvent`&&e.$parent?.$type===`bpmn:SubProcess`)&&t.messageRef&&this.found(e,`message-catch`,{message:Oh(t.messageRef)})}messageName(e){let n=Q(e.name);if(!n||!X(n))return;let r=qm(n);r.ok?(r.review.length>0?this.found(e,`expression-review`,{expression:n,feel:r.feel,reason:r.review.join(`; `)}):this.found(e,`message-name-expression`,{name:n,feel:r.feel}),this.changed(e,n,r.feel,t(`app.migration.change.messageName`,{name:n})),e.name=r.feel):this.found(e,`expression-manual`,{expression:n,reason:r.reason})}timer(e,n){[`timeDate`,`timeDuration`,`timeCycle`].forEach(r=>{let i=n[r],a=Q(i?.body);if(a){if(X(a)){let n=this.feel(e,`timer`,a);if(n===null)return;i.body=n,this.found(e,`timer`,{timer:a}),this.changed(e,a,n,t(`app.migration.change.timer`))}else r===`timeCycle`&&Ah(a)&&this.found(e,`timer-cron`,{cycle:a})}})}errorEvent(e,n){let r=this.take(n,`camunda:errorCodeVariable`),i=this.take(n,`camunda:errorMessageVariable`);[[r,`errorCode`],[i,`errorMessage`]].forEach(([n,r])=>{if(!n||!r)return;let i=this.single(e,`zeebe:IoMapping`);i.outputParameters=[...i.outputParameters??[],this.moddle.create(`zeebe:Output`,{source:`=${r}`,target:n})],this.found(e,`error-code-variable`,{variable:n}),this.changed(e,`camunda:${r}Variable="${n}"`,`zeebe:output source="=${r}" target="${n}"`,t(`app.migration.change.errorVariable`,{source:r,variable:n}))})}error(e){let t=this.take(e,`camunda:errorMessage`);t&&this.found(e,`error-message`,{message:t});let n=Q(e.errorCode);n&&X(n)&&this.found(e,`expression-manual`,{expression:n,reason:Z(`errorCode`)})}signal(e,t){let n=this.extensions(t,`camunda:In`);if(n.length===0)return;let r=e.$type===`bpmn:EndEvent`||e.$type===`bpmn:IntermediateThrowEvent`,i=Oh(t.signalRef);n.forEach(n=>{let i=Q(n.source)??Q(n.sourceExpression),a=Q(n.target);if(!r||!i||!a||Q(n.variables)){this.keptValues.add(n);return}let o=Q(n.sourceExpression)?this.feel(e,`signal variable`,i):`=${i}`;if(o===null){this.keptValues.add(n);return}let s=this.single(e,`zeebe:IoMapping`);s.inputParameters=[...s.inputParameters??[],this.moddle.create(`zeebe:Input`,{source:o,target:a})],this.remove(t,n)}),this.found(e,`signal-variables`,{signal:i})}conditional(e,t){if(!this.since(e,`conditional event`,`8.9`)){this.keep(t,`camunda:variableName`),this.keep(t,`camunda:variableEvents`);return}let n=Q(t.condition?.body),r=this.take(t,`camunda:variableName`),i=this.take(t,`camunda:variableEvents`);if(n){let r=this.feel(e,`condition`,n);r!==null&&(t.condition.body=r,t.condition.language=void 0)}if(r||i){let e=this.single(t,`zeebe:ConditionalFilter`);r&&(e.variableNames=r),i&&(e.variableEvents=i)}this.found(e,`conditional-event`,{variables:r??`any variable`})}script(e){let n=Q(e.scriptFormat)?.toLowerCase(),r=this.get(e,`camunda:resource`),i=this.get(e,`camunda:resultVariable`);if(r){this.keep(e,`camunda:resource`),i&&this.keep(e,`camunda:resultVariable`),this.found(e,`script-resource`,{resource:r});return}let a=Q(e.script);if(n===`feel`&&a){let r=i??`result`;e.scriptFormat=void 0,e.script=void 0,this.take(e,`camunda:resultVariable`);let o=this.single(e,`zeebe:Script`);o.expression=a.trim().startsWith(`=`)?a.trim():`=${a.trim()}`,o.resultVariable=r,this.found(e,`script-task-feel`,{variable:r},i?{}:{severity:`warning`,conversion:`review`,variant:`noResult`,title:`The FEEL script's result goes to {variable}`,detail:`Camunda 8 needs a result variable for a FEEL script task, and the Camunda 7 task had none.`,action:`Rename {variable} if something should read the result.`}),this.changed(e,`${n} script`,`zeebe:script expression`,t(`app.migration.change.feelScript`))}else i&&this.keep(e,`camunda:resultVariable`),this.found(e,`script-task`,{format:n??`script`})}userTask(e){N(this.target,`8.5`)&&this.extensions(e,`zeebe:UserTask`).length===0&&(this.add(e,`zeebe:UserTask`),this.found(e,`user-task`),this.changed(e,t(`app.migration.change.userTaskBefore`),`zeebe:userTask`,t(`app.migration.change.userTask`)));let n={};[`assignee`,`candidateUsers`,`candidateGroups`].forEach(t=>{let r=this.get(e,`camunda:${t}`);if(!r)return;let i=this.userTaskValue(e,t,r,t!==`assignee`);i===null?this.keep(e,`camunda:${t}`):(this.take(e,`camunda:${t}`),n[t]=i)}),Object.keys(n).length>0&&(Object.assign(this.single(e,`zeebe:AssignmentDefinition`),n),this.changed(e,`camunda assignment`,`zeebe:assignmentDefinition ${Object.keys(n).join(`, `)}`,t(`app.migration.change.assignment`)));let r={};[`dueDate`,`followUpDate`].forEach(t=>{let n=this.get(e,`camunda:${t}`);if(!n)return;let i=this.userTaskValue(e,t,n,!1);i===null?this.keep(e,`camunda:${t}`):(this.take(e,`camunda:${t}`),r[t]=i)}),Object.keys(r).length>0&&Object.assign(this.single(e,`zeebe:TaskSchedule`),r);let i=this.get(e,`camunda:priority`);if(i){if(!N(this.target,`8.6`))this.take(e,`camunda:priority`),this.found(e,`user-task-priority-dropped`,{priority:i});else{let t=this.userTaskValue(e,`priority`,i,!1);if(t===null)this.keep(e,`camunda:priority`);else{this.take(e,`camunda:priority`),this.single(e,`zeebe:PriorityDefinition`).priority=t;let n=Number(t);!X(i)&&(!Number.isInteger(n)||n<0||n>100)&&this.found(e,`user-task-priority-range`,{priority:i})}}}this.form(e)}userTaskValue(e,t,n,r){if(!X(n))return n;let i=qm(n);return i.ok?(i.review.length>0?this.found(e,`user-task-expression`,{name:t,expression:n,feel:i.feel,reason:i.review.join(`; `)}):r&&this.found(e,`assignment-review`,{name:t,expression:n}),i.feel):(this.found(e,`expression-manual`,{expression:n,reason:i.reason}),null)}form(e){let n=this.get(e,`camunda:formKey`),r=this.get(e,`camunda:formRef`),i=this.get(e,`camunda:formRefBinding`),a=this.get(e,`camunda:formRefVersion`),o=this.extensions(e,`camunda:FormData`)[0];this.get(e,`camunda:formHandlerClass`)&&this.keep(e,`camunda:formHandlerClass`);let s=e.$type===`bpmn:StartEvent`;if(r){if(i===`version`){this.keep(e,`camunda:formRef`),this.keep(e,`camunda:formRefBinding`),this.keep(e,`camunda:formRefVersion`),this.found(e,`form-binding-version`,{version:a??``});return}let n=this.single(e,`zeebe:FormDefinition`);n.formId=r,i&&i!==`latest`&&N(this.target,`8.6`)&&(n.bindingType=i,i===`versionTag`&&a&&(n.versionTag=a)),[`camunda:formRef`,`camunda:formRefBinding`,`camunda:formRefVersion`].forEach(t=>this.take(e,t)),this.found(e,`form-camunda`,{form:r}),this.changed(e,`camunda:formRef="${r}"`,`zeebe:formDefinition formId="${r}"`,t(`app.migration.change.formRef`,{form:r}))}else if(n){let r=/^camunda-forms:(deployment|app):(.+)$/.exec(n);if(r){let i=r[2],a=i.split(`/`).pop()??i,o=this.options.forms?.get(a)??this.options.forms?.get(i),s=o??a.replace(/\.form$/,``),c=this.single(e,`zeebe:FormDefinition`);c.formId=s,r[1]===`deployment`&&N(this.target,`8.6`)&&(c.bindingType=`deployment`),this.take(e,`camunda:formKey`),this.found(e,o?`form-camunda`:`form-camunda-unknown`,{form:o?s:i}),this.changed(e,`camunda:formKey="${n}"`,`zeebe:formDefinition formId="${s}"`,t(`app.migration.change.formRef`,{form:s}));return}if(/^embedded:/.test(n)){this.keep(e,`camunda:formKey`),this.found(e,`form-embedded`,{formKey:n});return}if(s||!N(this.target,`8.4`)){this.keep(e,`camunda:formKey`),this.found(e,`form-embedded`,{formKey:n},{variant:`here`,title:`The form key {formKey} has no Camunda 8 counterpart here`});return}this.single(e,`zeebe:FormDefinition`).externalReference=n,this.take(e,`camunda:formKey`),this.found(e,`form-external`,{formKey:n}),this.changed(e,`camunda:formKey="${n}"`,`zeebe:formDefinition externalReference="${n}"`,t(`app.migration.change.externalForm`,{formKey:n}))}else if(o){let n=`${this.process?.id??`process`}-${e.id}`,r=_h(n,o);this.extraFiles.push({name:`${n}.form`,content:r.json,reason:t(`app.migration.extraFile.form`,{where:Oh(e)})}),this.single(e,`zeebe:FormDefinition`).formId=n,this.remove(e,o),this.found(e,`form-generated`,{form:`${n}.form`}),r.lost.length>0&&this.found(e,`form-generated-partly`,{lost:r.lost.join(`, `)}),this.changed(e,`camunda:formData`,`zeebe:formDefinition formId="${n}" and ${n}.form`,t(`app.migration.change.generatedForm`,{form:n}))}}decision(e){let n=this.get(e,`camunda:decisionRef`)??``,r=this.get(e,`camunda:decisionRefBinding`),i=this.get(e,`camunda:decisionRefVersion`),a=this.get(e,`camunda:decisionRefTenantId`),o=this.get(e,`camunda:resultVariable`),s=this.get(e,`camunda:mapDecisionResult`);if(r===`version`){this.keep(e,`camunda:decisionRefBinding`),this.keep(e,`camunda:decisionRefVersion`),this.keep(e,`camunda:decisionRef`),this.found(e,`binding-version`,{what:Z(`decisionBound`,{name:n}),version:i??``});return}let c=X(n)?this.feel(e,`decision`,n):n;if(c===null){this.keep(e,`camunda:decisionRef`);return}let l=this.single(e,`zeebe:CalledDecision`);l.decisionId=c,l.resultVariable=o??`result`,r&&r!==`latest`&&(N(this.target,`8.6`)?(l.bindingType=r,r===`versionTag`&&i&&(l.versionTag=i)):this.found(e,`binding-dropped`,{binding:r,target:n})),[`camunda:decisionRef`,`camunda:decisionRefBinding`,`camunda:decisionRefVersion`,`camunda:resultVariable`,`camunda:mapDecisionResult`].forEach(t=>this.take(e,t)),this.found(e,`decision`,{decision:n,result:l.resultVariable}),o||this.found(e,`decision-result-variable`,{result:`result`}),s!==`singleEntry`&&o&&this.found(e,`decision-result`,{mapping:s??`resultList`,result:o}),a&&(this.keep(e,`camunda:decisionRefTenantId`),this.found(e,`tenant`,{tenant:a})),this.changed(e,`camunda:decisionRef="${n}"`,`zeebe:calledDecision decisionId="${c}" resultVariable="${l.resultVariable}"`,t(`app.migration.change.calledDecision`,{decision:c,result:l.resultVariable}))}callActivity(e){let n=Q(e.calledElement),r=this.get(e,`camunda:calledElementBinding`),i=this.get(e,`camunda:calledElementVersion`),a=this.get(e,`camunda:calledElementVersionTag`),o=this.get(e,`camunda:calledElementTenantId`),s=this.get(e,`camunda:caseRef`);s&&([`camunda:caseRef`,`camunda:caseBinding`,`camunda:caseVersion`,`camunda:caseTenantId`].forEach(t=>this.keep(e,t)),this.found(e,`cmmn`,{case:s})),[`camunda:variableMappingClass`,`camunda:variableMappingDelegateExpression`].forEach(t=>{this.get(e,t)&&(this.keep(e,t),this.found(e,`call-activity-mapping-class`,{process:n??`the called process`}))}),o&&(this.keep(e,`camunda:calledElementTenantId`),this.found(e,`tenant`,{tenant:o}));let c=n??this.extensions(e,`zeebe:CalledElement`)[0]?.processId??`the called process`;if(this.extensions(e,`camunda:In`).filter(e=>Q(e.businessKey)).forEach(t=>{this.keptValues.add(t),this.found(e,`call-activity-business-key`,{process:c})}),!n)return;if(r===`version`){this.keep(e,`camunda:calledElementBinding`),this.keep(e,`camunda:calledElementVersion`),this.found(e,`binding-version`,{what:Z(`callBound`,{name:n}),version:i??``});return}let l=X(n)?this.feel(e,`called element`,n):n;if(l===null)return;let u=this.single(e,`zeebe:CalledElement`);u.processId=l,e.calledElement=void 0,r&&r!==`latest`&&(N(this.target,`8.6`)?(u.bindingType=r,r===`versionTag`&&a&&(u.versionTag=a)):this.found(e,`binding-dropped`,{binding:r,target:n})),[`camunda:calledElementBinding`,`camunda:calledElementVersion`,`camunda:calledElementVersionTag`].forEach(t=>this.take(e,t)),this.variables(e,u,n),this.found(e,`call-activity`,{process:n}),this.changed(e,`calledElement="${n}"`,`zeebe:calledElement processId="${l}"`,t(`app.migration.change.calledProcess`,{process:l}))}variables(e,t,n){let r=this.extensions(e,`camunda:In`),i=this.extensions(e,`camunda:Out`),a=e=>e.some(e=>Q(e.variables)===`all`);t.propagateAllParentVariables=a(r),t.propagateAllChildVariables=a(i);let o=(t,r)=>t.forEach(t=>{if(Q(t.variables)===`all`){t.local===!0&&this.found(e,`call-activity-local`,{process:n}),this.remove(e,t);return}if(Q(t.businessKey))return;let i=Q(t.target),a=Q(t.sourceExpression),o=a?this.feel(e,`variable`,a):Q(t.source)?`=${Q(t.source)}`:`=null`;if(!i||o===null){this.keptValues.add(t),i||this.found(e,`input-output-manual`,{name:n,reason:Z(`noTarget`)});return}t.local===!0&&this.found(e,`call-activity-local`,{process:n});let s=this.single(e,`zeebe:IoMapping`),c=this.moddle.create(r===`input`?`zeebe:Input`:`zeebe:Output`,{source:o,target:i});r===`input`?s.inputParameters=[...s.inputParameters??[],c]:s.outputParameters=[...s.outputParameters??[],c],this.remove(e,t)});o(r,`input`),o(i,`output`)}executionListeners(e){let n=this.extensions(e,`camunda:ExecutionListener`);n.length!==0&&n.forEach(n=>{let r=Q(n.event)??`start`,i=Q(n.class)??Q(n.delegateExpression)??Q(n.expression)??(n.script?`${Q(n.script.scriptFormat)??``} script`:`listener`),a=(t,a)=>{this.keptValues.add(n),this.found(e,`execution-listener-unsupported`,{event:r,name:i,reason:Z(t,a)})};if(!N(this.target,`8.6`))return a(`listenersOldTarget`,{target:this.target});if(r===`take`||e.$type===`bpmn:SequenceFlow`)return a(`listenersNoSequenceFlow`);if(!wh.test(e.$type))return a(`listenersNoOn`,{element:Dh(e.$type)});if(r===`start`&&(e.$type===`bpmn:BoundaryEvent`||e.$type===`bpmn:StartEvent`&&e.$parent?.$type!==`bpmn:SubProcess`))return a(`listenersEndOnly`,{element:Dh(e.$type)});if((n.fields??[]).length>0)return a(`listenersFields`);let o=this.listenerJob(e,n,`executionListener`,r);if(!o)return a(`listenersExpression`);let s=this.single(e,`zeebe:ExecutionListeners`);s.listeners=[...s.listeners??[],this.moddle.create(`zeebe:ExecutionListener`,{eventType:r,type:o})],this.remove(e,n),this.found(e,`execution-listener`,{event:r,name:i,jobType:o}),this.changed(e,`camunda:executionListener ${r} ${i}`,`zeebe:executionListener ${r} type="${o}"`,t(`app.migration.change.listener`,{event:r,name:i,jobType:o}))})}taskListeners(e){this.extensions(e,`camunda:TaskListener`).forEach(n=>{let r=Q(n.event)??`create`,i=Q(n.class)??Q(n.delegateExpression)??Q(n.expression)??(n.script?`${Q(n.script.scriptFormat)??``} script`:`listener`),a=(t,a)=>{this.keptValues.add(n),this.found(e,`task-listener-unsupported`,{event:r,name:i,reason:Z(t,a)})},o=T(Th,r);if(!N(this.target,`8.8`))return a(`taskListenersOldTarget`,{target:this.target});if(!o)return a(`taskListenersNoEvent`,{event:r});if((n.fields??[]).length>0)return a(`listenersFields`);let s=this.listenerJob(e,n,`taskListener`,r);if(!s)return a(`listenersExpression`);let c=this.single(e,`zeebe:TaskListeners`);c.listeners=[...c.listeners??[],this.moddle.create(`zeebe:TaskListener`,{eventType:o,type:s})],this.remove(e,n),this.found(e,`task-listener`,{event:r,name:i,jobType:s}),this.changed(e,`camunda:taskListener ${r} ${i}`,`zeebe:taskListener ${o} type="${s}"`,t(`app.migration.change.listener`,{event:r,name:i,jobType:s}))})}listenerJob(e,t,n,r){let i=Q(t.class);if(i){let t=vh(`class`,i);return this.delegate(e,{kind:`class`,value:i,role:n,jobType:t,event:r}),t}let a=/^[$#]\{\s*([A-Za-z_]\w*)\s*\}$/.exec(Q(t.delegateExpression)?.trim()??``)?.[1];if(a){let t=vh(`bean`,a);return this.delegate(e,{kind:`bean`,value:a,role:n,jobType:t,event:r}),t}return null}removeMarkers(e){let t=(e,n)=>{e&&typeof e==`object`&&!n.has(e)&&(n.add(e),e.extensionElements?.values&&(e.extensionElements.values=e.extensionElements.values.filter(e=>e.$type!==`conversion:message`),e.extensionElements.values.length===0&&(e.extensionElements=void 0)),[`rootElements`,`flowElements`,`eventDefinitions`,`laneSets`,`lanes`,`artifacts`].forEach(r=>(e[r]??[]).forEach(e=>t(e,n))),e.loopCharacteristics&&t(e.loopCharacteristics,n))};t(e,/* @__PURE__ */ new Set)}leftovers(){let e=/* @__PURE__ */ new Set,t=n=>{n&&typeof n==`object`&&!e.has(n)&&n.$descriptor&&(e.add(n),(n.$descriptor.properties??[]).forEach(e=>{if(e.ns?.prefix!==`camunda`||!e.isAttr)return;let t=n.get(e.name);t==null||t===``||this.isKept(n,e.ns.name)||(e.default===void 0||t!==e.default)&&(this.found(n,`unknown-attribute`,{attribute:`${e.ns.name}="${String(t)}"`}),this.keep(n,e.ns.name))}),Object.keys(n.$attrs??{}).filter(e=>e.startsWith(`camunda:`)).forEach(e=>{this.isKept(n,e)||(this.found(n,`unknown-attribute`,{attribute:`${e}="${n.$attrs[e]}"`}),this.keep(n,e))}),(n.extensionElements?.values??[]).forEach(e=>{if(typeof e.$type==`string`&&e.$type.startsWith(`camunda:`)&&!this.keptValues.has(e)){let t=Eh.has(e.$type)?`left after conversion`:Dh(e.$type);this.found(n,`unknown-attribute`,{attribute:`camunda:${e.$type.slice(8).replace(/^./,e=>e.toLowerCase())} (${t})`}),this.keptValues.add(e)}}),[`rootElements`,`flowElements`,`eventDefinitions`,`laneSets`,`lanes`,`artifacts`].forEach(e=>(n[e]??[]).forEach(t)),[`loopCharacteristics`,`conditionExpression`,`completionCondition`,`loopCardinality`,`timeDate`,`timeDuration`,`timeCycle`,`condition`].forEach(e=>t(n[e])))};t(this.definitions)}writeMarkers(){this.marks.size!==0&&(this.marks.forEach((e,t)=>{t.extensionElements||(t.extensionElements=this.moddle.create(`bpmn:ExtensionElements`,{values:[]}),t.extensionElements.$parent=t);let n=e.map(e=>{let n=this.moddle.createAny(`conversion:message`,yh,{severity:e.conversion===`manual`?`TASK`:`REVIEW`,$body:`${e.title}. ${e.action}`});return n.$parent=t.extensionElements,n});t.extensionElements.values=[...this.values(t),...n]}),this.definitions.$attrs[`xmlns:conversion`]=yh)}platform(){let e=this.definitions.$attrs??(this.definitions.$attrs={}),n=e[`modeler:executionPlatform`];e[`xmlns:modeler`]=`http://camunda.org/schema/modeler/1.0`,e[`modeler:executionPlatform`]=ar,e[`modeler:executionPlatformVersion`]=`${this.target}.0`,e[`xmlns:zeebe`]=`http://camunda.org/schema/zeebe/1.0`,this.findings.some(e=>e.conversion===`manual`)||this.keptCount>0||delete e[`xmlns:camunda`],this.found(this.definitions,`platform`,{target:this.target}),this.changed(this.definitions,`executionPlatform ${n??`unset`}`,`${ar} ${this.target}.0`,t(`app.migration.change.platform`,{target:this.target}))}};function Mh(e){return e.includes(`executionPlatform="Camunda Cloud"`)?!1:e.includes(`http://camunda.org/schema/1.0/bpmn`)||e.includes(`http://operaton.org/schema/1.0/bpmn`)||e.includes(`executionPlatform="${ir}"`)}function Nh(e){return e.includes(`http://operaton.org/schema/1.0/bpmn`)?e.split(`http://operaton.org/schema/1.0/bpmn`).join(`http://camunda.org/schema/1.0/bpmn`).replace(/<[^>]*>/g,e=>e.replace(/(^<\/?|\s)operaton:(?=[A-Za-z])/g,`$1camunda:`).replace(/xmlns:operaton=/g,`xmlns:camunda=`)):e}async function Ph(e,n={}){if(!Mh(e)&&/<(?:\w+:)?definitions\b/.test(e))return{ok:!0,source:!1,text:e,changes:[],open:[],extraFiles:[],findings:[],delegates:[]};let a=await r(Nh(e),`migration`);if(!a)return{ok:!1,source:!1,text:e,changes:[],open:[],extraFiles:[],findings:[],delegates:[],failure:t(`app.migration.failure.notBpmn`)};if(!Mh(e))return{ok:!0,source:!1,text:e,changes:[],open:[],extraFiles:[],findings:[],delegates:[]};let o=new jh(a,n);return o.run(),{ok:!0,source:!0,text:await i(a),changes:o.changes,open:o.findings.filter(e=>e.conversion!==`automatic`),extraFiles:o.extraFiles,findings:o.findings,delegates:o.delegates}}const Fh={"http://www.omg.org/spec/DMN/20151101/dmn.xsd":`1.1`,"http://www.omg.org/spec/DMN/20180521/MODEL/":`1.2`,"https://www.omg.org/spec/DMN/20180521/MODEL/":`1.2`};function Ih(e,t,n,r,i){let{variant:a,...o}=n,s={...Am[e],...o};return{rule:`migration/${e}`,severity:s.severity,conversion:s.conversion,...Nm(e,s,t,a).text,elements:i?[i]:[],where:r,...s.link?{link:s.link}:{}}}function Lh(e){let t=typeof e?.name==`string`?e.name.replace(/\s+/g,` `).trim():``,n=typeof e?.label==`string`?e.label.trim():``;return t||n||e?.id||`the decisions`}function Rh(e){return typeof e!=`string`||e===``||/feel/i.test(e)}function zh(e){try{let t=W(e);return t.local===`definitions`?t.attrs:{}}catch{return{}}}async function Bh(e,n={}){let r=n.target??`8.8`,i=s(`migration`),{xml:a,from:o}=await yt(e),c=zh(a),l=c.xmlns??``;if(!o&&l&&l!==`https://www.omg.org/spec/DMN/20191111/MODEL/`){let t={id:c.id,name:c.name},n=[];return n.push(Ih(`dmn-version`,{version:T(Fh,l)??l},{},t.name??t.id??`the decisions`,t.id)),{ok:!0,source:!0,text:e,findings:n,changes:[]}}let u;try{({rootElement:u}=await i.fromXML(a,`dmn:Definitions`))}catch{u=null}if(!u)return{ok:!1,source:!1,text:e,findings:[],changes:[],failure:t(`app.migration.failure.notDmn`)};let d=u.$attrs??{},f=d[`modeler:executionPlatform`];if(f!==ir)return{ok:!0,source:!1,text:e,findings:[],changes:[]};let p=[],m=[];o&&(p.push(Ih(`dmn-version`,{version:o},{severity:`info`,conversion:`automatic`,variant:`converted`,detail:`Camunda 8 reads DMN 1.3, so the file is written as DMN 1.3.`,action:`Nothing to do.`},Lh(u),u.id)),m.push({elementId:u.id??``,where:Lh(u),before:`DMN ${o}`,after:`DMN 1.3`,plain:t(`app.migration.change.dmnVersion`)}));let h=(e,t,n={})=>{p.push(Ih(t,n,{},Lh(e),e?.id))},g=(e,t,n,r)=>{m.push({elementId:e?.id??``,where:Lh(e),before:t,after:n,...r?{plain:r}:{}})};Rh(u.expressionLanguage)||h(u,`dmn-expression-language`,{what:`The decision file`,language:String(u.expressionLanguage)});let _=(e,n,r,i)=>{let a=n?.expressionLanguage;if(Rh(a))return;let o=n.text??``;if(i||!/^juel$/i.test(String(a))||!X(o)){h(e,`dmn-expression-language`,{what:r,language:String(a)});return}let s=qm(o);if(!s.ok){h(e,`expression-manual`,{expression:o,reason:s.reason});return}let c=s.feel.replace(/^=/,``);n.text=c,n.expressionLanguage=void 0,h(e,`dmn-juel`,{what:r,feel:c}),g(e,o,c,t(`app.migration.change.expressionRewritten`))};(u.drgElement??[]).filter(e=>e.$type===`dmn:Decision`).forEach(e=>{let n=e.get(`camunda:historyTimeToLive`);n!==void 0&&(e.set(`camunda:historyTimeToLive`,void 0),h(e,`dmn-history-time-to-live`,{decision:Lh(e)}),g(e,`camunda:historyTimeToLive="${n}"`,t(`app.migration.change.removed`),t(`app.migration.change.dmnHistoryTimeToLive`)));let r=e.decisionLogic;r?.$type===`dmn:LiteralExpression`&&_(e,r,t(`app.migration.detail.decisionNamed`,{name:Lh(e)}),!1),r?.$type===`dmn:DecisionTable`&&((r.input??[]).forEach(e=>{let n=e.get(`camunda:inputVariable`);n&&h(e,`dmn-input-variable`,{input:Lh(e),variable:n}),e.inputExpression&&_(e,e.inputExpression,t(`app.migration.detail.inputNamed`,{name:Lh(e)}),!1)}),(r.rule??[]).forEach(e=>{(e.inputEntry??[]).forEach(n=>_(e,n,t(`app.migration.detail.ruleCondition`,{rule:e.id}),!0)),(e.outputEntry??[]).forEach(n=>_(e,n,t(`app.migration.detail.ruleOutput`,{rule:e.id}),!1))}))});let v=p.some(e=>e.conversion===`manual`);p.every(e=>e.rule===`migration/dmn-version`)&&h(u,`dmn-carries-over`),d[`xmlns:modeler`]=d[`xmlns:modeler`]??`http://camunda.org/schema/modeler/1.0`,g(u,`executionPlatform ${f}`,`Camunda Cloud ${r}.0`,t(`app.migration.change.dmnPlatform`,{target:r})),d[`modeler:executionPlatform`]=ar,d[`modeler:executionPlatformVersion`]=`${r}.0`,!v&&u.$attrs?.[`xmlns:camunda`]&&delete u.$attrs[`xmlns:camunda`];let{xml:y}=await i.toXML(u,{format:!0});return{ok:!0,source:!0,text:y,findings:p,changes:m}}function Vh(e,n={}){let r=n.target??`8.8`,i;try{let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`not a form`);i=t}catch{return{ok:!1,source:!1,text:e,findings:[],changes:[],failure:t(`app.migration.failure.notForm`)}}if(i.executionPlatform!==ir)return{ok:!0,source:!1,text:e,findings:[],changes:[]};let a=Am[`form-platform`],o=typeof i.id==`string`?i.id:``,s={rule:`migration/form-platform`,severity:a.severity,conversion:a.conversion,...Nm(`form-platform`,a).text,elements:o?[o]:[],where:o||`the form`,link:a.link},c=/^\{\n( +)"/.exec(e)?.[1].length??2,l={...i,executionPlatform:ar,executionPlatformVersion:`${r}.0`};return{ok:!0,source:!0,text:`${JSON.stringify(l,null,c)}${e.endsWith(`
|
|
863
|
+
`)?`
|
|
864
|
+
`:``}`,findings:[s],changes:[{elementId:o,where:o||`the form`,before:`executionPlatform ${String(i.executionPlatform)}`,after:`Camunda Cloud ${r}.0`,plain:t(`app.migration.change.formPlatform`,{target:r})}]}}function Hh(e){return Cn(e)}async function Uh(e,t,n={}){let r=Hh(e);switch(r){case`bpmn`:{let i=await Ph(t,n);return{path:e,kind:r,ok:i.ok,source:i.source,text:i.text,changes:i.changes,findings:i.findings,open:i.open,delegates:i.delegates,extraFiles:i.extraFiles,failure:i.failure}}case`dmn`:{let i=await Bh(t,n);return{path:e,kind:r,ok:i.ok,source:i.source,text:i.text,changes:i.changes,findings:i.findings,open:i.findings.filter(e=>e.conversion!==`automatic`),delegates:[],extraFiles:[],failure:i.failure}}case`form`:{let i=Vh(t,n);return{path:e,kind:r,ok:i.ok,source:i.source,text:i.text,changes:i.changes,findings:i.findings,open:i.findings.filter(e=>e.conversion!==`automatic`),delegates:[],extraFiles:[],failure:i.failure}}default:return null}}function Wh(e){let t=/^(.*?)((?:\.bpmn(?:20)?\.xml)|\.bpmn|\.dmn|\.form)$/i.exec(e);return t?`${t[1]}.c8${t[2]}`:`${e}.c8`}function Gh(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t<0?``:e.slice(0,t)}function Kh(e,t){let n=Gh(e);return n?`${n}/${t}`:t}async function qh(e,t,n={}){let r=await Uh(e,t,n);return r?{...r,changed:r.ok&&r.source&&r.text!==t,copy:Wh(e),files:r.extraFiles.map(t=>({path:Kh(e,t.name),content:t.content,reason:t.reason}))}:null}function Jh(e){let t=/* @__PURE__ */ new Map;return e.filter(e=>/\.form$/i.test(e.path)).forEach(e=>{try{let n=JSON.parse(e.text).id;typeof n==`string`&&n&&t.set(e.path.split(/[\\/]/).pop()??e.path,n)}catch{return}}),t}const Yh=/* @__PURE__ */ new Set([`getVariable`,`getVariableLocal`,`getVariableTyped`,`getVariableLocalTyped`]),Xh=/* @__PURE__ */ new Set([`setVariable`,`setVariableLocal`]),Zh=/* @__PURE__ */ new Set([`put`,`putValue`,`putValueTyped`]),Qh=/* @__PURE__ */ new Set([`getVariables`,`getVariablesLocal`,`getVariablesTyped`,`getVariablesLocalTyped`]),$h=/* @__PURE__ */ new Set([`getBusinessKey`,`getProcessBusinessKey`]),eg=/* @__PURE__ */ new Set([`RuntimeService`,`TaskService`,`RepositoryService`,`HistoryService`,`ManagementService`,`IdentityService`,`FormService`,`DecisionService`,`ProcessEngine`]),tg=h.map(e=>c(e)),ng=(e,t)=>tg.some(n=>e.startsWith(`${n}.${t}`)),rg=/* @__PURE__ */ new WeakMap,ig=e=>e.split(`.`).pop()??e,$=e=>e?.value??null,ag=(e,t)=>e.from<=t.from&&t.to<=e.to,og=(e,t)=>e.from<=t&&t<e.to;function sg(e){let t=rg.get(e);if(t)return t;let n=e.declarations.filter(e=>e.kind===`class`).map(t=>fg(e,t));return rg.set(e,n),n}function cg(e,t,n){let r=null;for(let i of e)i.path!==t||n<i.offset||n>=i.end||(r===null||i.end-i.offset<r.end-r.offset)&&(r=i);return r}function lg(e){return e.imports.map(e=>e.name).filter(e=>ng(e,`bpm.`)||ng(e,`spin.`))}function ug(e){let t=t=>e.filter(t).length;return[{api:`engine`,count:t(e=>ng(e,`bpm.engine.`)&&!ng(e,`bpm.engine.test`))},{api:`externalTaskClient`,count:t(e=>ng(e,`bpm.client.`))},{api:`springBoot`,count:t(e=>ng(e,`bpm.spring.boot.`))},{api:`test`,count:t(e=>[`bpm.engine.test`,`bpm.extension.junit5`,`bpm.extension.process_test_coverage`,`bpm.scenario`].some(t=>ng(e,t)))},{api:`spin`,count:t(e=>ng(e,`spin.`))}].filter(e=>e.count>0)}function dg(e){return(e.split(`<`)[0].trim().split(`.`).pop()??``).trim()}function fg(e,t){let n=L(e),{from:r,to:i}=t.span,a=n.callsBySpan.inOrder(r,i).filter(e=>ag(t.span,e.span)),o=n.constructionsBySpan.inOrder(r,i).filter(e=>ag(t.span,e.span)),s=n.callablesBySpan.inOrder(r,i).filter(e=>ag(t.span,e.span)),c=pg(t,s),l=vg(gg(a.filter(e=>Yh.has(e.name)))),u=[...gg(a.filter(e=>Xh.has(e.name)))];return c===`externalTaskHandler`&&a.some(e=>e.name===`complete`)&&(u.push(...gg(a.filter(e=>Zh.has(e.name)))),u.push(...a.filter(e=>e.receiver===`Map`&&e.name===`of`).flatMap(e=>_g(e.arguments.filter((e,t)=>t%2==0))))),{path:e.path,offset:t.span.from,end:t.span.to,className:t.name,packageName:e.package,shape:c,reads:l,writes:vg(u),errors:mg(o,a),usesBusinessKey:a.some(e=>$h.has(e.name)),usesEngineServices:hg(e,t,s,a,o),readsAllVariables:a.some(e=>Qh.has(e.name)),line:so(e.lineStarts,t.span.from)}}function pg(e,t){let n=e.supertypes.map(e=>ig(e.name));if(n.some(e=>e===`JavaDelegate`))return`javaDelegate`;if(n.some(e=>e===`ExternalTaskHandler`)||e.annotations.some(e=>e.name===`ExternalTaskSubscription`))return`externalTaskHandler`;if(n.some(e=>e===`ExecutionListener`))return`executionListener`;if(n.some(e=>e===`TaskListener`))return`taskListener`;let r=e=>t.filter(t=>t.name===e),i=e=>e.parameters.map(e=>dg(e.type??``));return r(`execute`).some(e=>i(e)[0]===`DelegateExecution`)?`javaDelegate`:r(`notify`).some(e=>i(e)[0]===`DelegateTask`)?`taskListener`:r(`notify`).some(e=>i(e)[0]===`DelegateExecution`)?`executionListener`:r(`execute`).some(e=>i(e)[0]===`ExternalTask`)||t.some(e=>i(e)[0]===`ExternalTask`&&i(e)[1]===`ExternalTaskService`)?`externalTaskHandler`:`unknown`}function mg(e,t){let n=[...e.filter(e=>ig(e.type)===`BpmnError`&&$(e.arguments[0])!==null).map(e=>({code:$(e.arguments[0])??``,message:$(e.arguments[1])??void 0})),...t.filter(e=>e.name===`handleBpmnError`&&$(e.arguments[1])!==null).map(e=>({code:$(e.arguments[1])??``,message:$(e.arguments[2])??void 0}))],r=/* @__PURE__ */ new Set;return n.filter(e=>!r.has(e.code)&&(r.add(e.code),!0))}function hg(e,t,n,r,i){let a=[],o=(e,t)=>{for(let n of(t??``).split(/[^A-Za-z0-9_$]+/))eg.has(n)&&a.push({at:e,name:n})};return t.supertypes.forEach(e=>o(t.at,e.name)),t.members.forEach(e=>o(e.at,e.type)),n.forEach(e=>{e.parameters.forEach(e=>o(e.at,e.type)),o(e.at,e.returnType)}),L(e).localsAt.inOrder(t.span.from,t.span.to).filter(e=>og(t.span,e.at)).forEach(e=>o(e.at,e.type)),r.forEach(e=>o(e.at,e.receiver)),i.forEach(e=>o(e.at,e.type)),a.sort((e,t)=>e.at-t.at),vg(a.map(e=>e.name))}function gg(e){return _g(e.map(e=>e.arguments[0]))}function _g(e){return e.map($).filter(e=>e!==null)}function vg(e){return[...new Set(e)]}const yg=/* @__PURE__ */ new Set([`migration/unsupported-element`,`migration/cmmn`]),bg=/* @__PURE__ */ new Set([`expression-manual`,`expression-review`,`user-task-expression`,`input-output-manual`,`script-condition`,`dmn-expression-language`,`dmn-input-variable`]),xg=/* @__PURE__ */ new Set([`script-task`,`script-resource`,`input-output-script`]),Sg=/* @__PURE__ */ new Set([`execution-listener`,`execution-listener-unsupported`,`task-listener`,`task-listener-unsupported`]),Cg=/* @__PURE__ */ new Set([`form-embedded`,`form-generated`,`form-generated-partly`,`form-binding-version`,`form-camunda-unknown`,`form-external`]),wg=/* @__PURE__ */ new Set([`decision`,`binding-version`]);function Tg(e){return e.rule.replace(/^migration\//,``)}function Eg(e){let t={error:0,warning:0,info:0,automatic:0,review:0,manual:0};return e.forEach(e=>{t[e.severity]+=1,t[e.conversion]+=1}),t}function Dg(e){return e.some(e=>yg.has(e.rule))?`blocked`:e.some(e=>e.conversion===`manual`)?`needs-work`:e.some(e=>e.severity!==`info`)?`converts`:`ready`}function Og(e){return/^[$#]\{\s*([A-Za-z_]\w*)/.exec(e)?.[1]??null}function kg(e){switch(e.kind){case`class`:return{kind:`CLASS`,value:e.value};case`bean`:return{kind:`BEAN`,value:e.value};case`topic`:return{kind:`TOPIC`,value:e.value};case`expression`:{let t=Og(e.value);return t?{kind:`BEAN`,value:t}:null}}}async function Ag(e,t=`8.8`){let n=Jh(e),r=/* @__PURE__ */ new Map;for(let i of e){let e=await Uh(i.path,i.text,{target:t,forms:n});e&&e.ok&&e.source&&e.delegates.forEach(e=>{let t=kg(e);t&&r.set(Zn(t),t)})}return Qn([...r.values()])}function jg(e,t,n){switch(t){case`class`:return e.classes.get(n)??null;case`bean`:return e.beans.get(n)??null;case`topic`:return e.topics.get(n)?.[0]??null;case`expression`:{let t=Og(n);return t?e.beans.get(t)??null:null}}}async function Mg(e){let t=e.target??`8.8`,n=Jh(e.files),r=[],i=[];for(let a of e.files){let e=await Uh(a.path,a.text,{target:t,forms:n});e&&e.ok&&e.source&&(r.push({path:a.path,kind:e.kind,status:Dg(e.findings),counts:Eg(e.findings),findings:e.findings}),e.delegates.forEach(e=>i.push({path:a.path,use:e})))}let a=r.length>0,o=r.flatMap(e=>e.findings.map(t=>({path:e.path,finding:t}))),s=e=>o.filter(({finding:t})=>e.has(Tg(t))).length,c=e.index,l=/* @__PURE__ */ new Map;i.forEach(({path:t,use:n})=>{let r=`${n.role}:${n.kind}:${n.value}:${n.event??``}`,i={path:t,elementId:n.elementId,where:n.where},a=l.get(r);if(a){a.usedBy.push(i);return}let o=jg(c,n.kind,n.value),s=o?cg(e.classes,o.file,o.offset):null;l.set(r,{key:r,role:n.role,kind:n.kind,value:n.value,jobType:n.jobType,...n.event?{event:n.event}:{},skeleton:!n.jobType.startsWith(`=`),usedBy:[i],...o&&s?{source:{path:o.file,line:o.line,className:s.className,shape:s.shape}}:{},becomes:Di(n,s),notes:Oi(s),reads:s?.reads??[],writes:s?.writes??[],errors:s?.errors.map(e=>e.code)??[]})});let u=[...l.values()],d=/* @__PURE__ */ new Map;e.camunda7Imports.forEach(e=>ug(e.names).forEach(e=>{let t=d.get(e.api)??{api:e.api,files:0,imports:0};t.files+=1,t.imports+=e.count,d.set(e.api,t)}));let f={ready:0,converts:0,"needs-work":0,blocked:0};r.forEach(e=>{f[e.status]+=1});let p=Am[`data-migration`];return{target:t,source:a,files:r,effort:{workers:new Set(u.filter(e=>e.skeleton).map(e=>e.jobType)).size,expressions:s(bg),scripts:s(xg),listeners:s(Sg),forms:s(Cg),calledProcesses:s(/* @__PURE__ */ new Set([`call-activity`])),decisions:s(wg)},blockers:o.filter(({finding:e})=>yg.has(e.rule)),code:u,apis:[...d.values()],dataMigration:a?{rule:`migration/data-migration`,severity:p.severity,conversion:p.conversion,...Nm(`data-migration`,p).text,elements:[],where:`the project`,link:p.link}:null,totals:f}}const Ng=[`ready`,`converts`,`needs-work`,`blocked`],Pg={ready:`ready`,converts:`converts`,"needs-work":`needsWork`,blocked:`blocked`};function Fg(e){return t(`app.migration.report.status.${Pg[e]}`)}function Ig(e){return t(`app.migration.report.meaning.${Pg[e]}`)}const Lg=[`workers`,`expressions`,`scripts`,`listeners`,`forms`,`calledProcesses`,`decisions`];function Rg(e){return t(`app.migration.report.effort.${e}`)}const zg={error:0,warning:1,info:2};function Bg(e){return e.name??e.root.split(/[\\/]/).filter(Boolean).pop()??t(`app.migration.report.theProject`)}function Vg(e){return t(`app.migration.report.heading`,{name:Bg(e)})}function Hg(e,n){return t(n?`app.migration.report.targetDated`:`app.migration.report.target`,{target:e,on:n?t(`app.migration.report.onDate`,{date:n}):``})}function Ug(e){return t(`app.migration.report.fileCount`,{count:e})}function Wg(e){return t(`app.migration.report.automatic`,{count:e})}function Gg(e){let n=[...e.findings].sort((e,t)=>zg[e.severity]-zg[t.severity]);return{sections:[{title:t(`app.migration.report.needsWork`),findings:n.filter(e=>e.conversion===`manual`)},{title:t(`app.migration.report.reviewAfter`),findings:n.filter(e=>e.conversion===`review`)}].filter(e=>e.findings.length>0),automatic:e.findings.filter(e=>e.conversion===`automatic`).length}}function Kg(e,n){return e.source?`${jn(n,e.source.path)}:${e.source.line}`:t(`app.migration.report.notInProject`)}function qg(e){return e.replace(/\|/g,`\\|`).replace(/[\r\n]+/g,` `)}function Jg(e){let t=qg(e);return t.includes("`")?`\`\` ${t} \`\``:`\`${t}\``}function Yg(e,n){let r=[`# ${Vg(n)}`,``];return r.push(`${Hg(e.target,n.date)}`,``),e.source?(r.push(`## ${t(`app.migration.report.scope`)}`,``,`| ${t(`app.migration.report.columnStatus`)} | ${t(`app.migration.report.columnFiles`)} | ${t(`app.migration.report.columnMeaning`)} |`,`|---|---|---|`),Ng.forEach(t=>r.push(`| ${Fg(t)} | ${e.totals[t]} | ${Ig(t)} |`)),r.push(``,`## ${t(`app.migration.report.costs`)}`,``),Lg.forEach(t=>r.push(`- ${Rg(t)}: ${e.effort[t]}`)),r.push(``),e.blockers.length>0&&(r.push(`## ${t(`app.migration.report.blockers`)}`,``,t(`app.migration.report.blockersHint`),``),e.blockers.forEach(({path:e,finding:i})=>r.push(`- **${i.title}** ${t(`app.migration.report.blockerWhere`,{where:i.where,path:jn(n.root,e),action:i.action})}`)),r.push(``)),r.push(`## ${t(`app.migration.report.files`)}`,``,`| ${t(`app.migration.report.columnFile`)} | ${t(`app.migration.report.columnStatus`)} | ${t(`app.migration.report.columnNeedsWork`)} | ${t(`app.migration.report.columnReview`)} | ${t(`app.migration.report.columnConverts`)} |`,`|---|---|---|---|---|`),e.files.forEach(e=>r.push(`| ${qg(jn(n.root,e.path))} | ${Fg(e.status)} | ${e.counts.manual} | ${e.counts.review} | ${e.counts.automatic} |`)),r.push(``),e.files.filter(e=>e.status!==`ready`).forEach(e=>{let{sections:i,automatic:a}=Gg(e);r.push(`### ${qg(jn(n.root,e.path))}`,``),i.forEach(e=>{r.push(`**${e.title}**`,``),e.findings.forEach(e=>r.push(`- ${t(`app.migration.report.finding`,{where:e.where,title:e.title,action:e.action})}`)),r.push(``)}),a>0&&r.push(Wg(a),``)}),e.code.length>0&&(r.push(`## ${t(`app.migration.report.code`)}`,``,t(`app.migration.report.codeHint`),``),r.push(`| ${t(`app.migration.report.columnValue`)} | ${t(`app.migration.report.columnWhere`)} | ${t(`app.migration.report.columnBecomes`)} | ${t(`app.migration.report.columnNotes`)} |`,`|---|---|---|---|`),e.code.forEach(e=>r.push(`| ${Jg(e.value)} | ${qg(Kg(e,n.root))} | ${qg(e.becomes)} | ${qg(e.notes.join(` `))} |`)),r.push(``)),e.apis.length>0&&(r.push(`## ${t(`app.migration.report.apis`)}`,``,t(`app.migration.report.apisHint`),``),e.apis.forEach(e=>r.push(`- ${t(`app.migration.report.apiImports`,{api:e.api,imports:e.imports,files:Ug(e.files)})}`)),r.push(``)),e.dataMigration&&(r.push(`## ${t(`app.migration.report.dataMigration`)}`,``,`${e.dataMigration.detail} ${e.dataMigration.action}`,``),e.dataMigration.link&&r.push(t(`app.migration.report.dataMigrator`,{link:e.dataMigration.link}),``)),`${r.join(`
|
|
865
|
+
`)}`):(r.push(t(`app.migration.report.nothingToMigrate`),``),`${r.join(`
|
|
866
|
+
`)}\n`)}function Xg(e,r){let i=pl,a=[`<!doctype html>`,`<html lang="${n()}">`,`<head>`,`<meta charset="utf-8">`,`<title>${i(Vg(r))}</title>`,`<style>
|
|
867
|
+
:root { color-scheme: light dark; --bg: #f7f8fa; --surface: #fff; --fg: #1e1f22; --muted: #6c707e; --border: #ebecf0; --accent: #3574f0; --error: #db5860; --warn: #c77d0a; --ok: #368746; }
|
|
868
|
+
@media (prefers-color-scheme: dark) { :root { --bg: #1e1f22; --surface: #2b2d30; --fg: #dfe1e5; --muted: #9da0a8; --border: #393b40; --accent: #548af7; --error: #f75464; --warn: #e5a13b; --ok: #57965c; } }
|
|
869
|
+
body { margin: 0; padding: 24px; background: var(--bg); color: var(--fg); font: 13px/1.5 ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace; }
|
|
870
|
+
main { max-width: 960px; margin: 0 auto; }
|
|
871
|
+
h1 { font-size: 20px; margin: 0 0 4px; } h2 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 24px 0 8px; } h3 { font-size: 13px; margin: 16px 0 4px; }
|
|
872
|
+
p, li { margin: 4px 0; } .muted { color: var(--muted); }
|
|
873
|
+
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 8px; } th { text-align: left; font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--border); } th, td { padding: 8px 12px; vertical-align: top; }
|
|
874
|
+
.ready { color: var(--ok); } .converts { color: var(--accent); } .needs-work { color: var(--warn); } .blocked { color: var(--error); font-weight: bold; }
|
|
875
|
+
code { background: var(--surface); padding: 0 4px; border-radius: 4px; }
|
|
876
|
+
</style>`,`</head>`,`<body>`,`<main>`,`<h1>${i(Vg(r))}</h1>`,`<p class="muted">${i(Hg(e.target,r.date))}</p>`];return e.source?(a.push(`<h2>${i(t(`app.migration.report.scope`))}</h2>`,`<table>`,`<tr><th>${i(t(`app.migration.report.columnStatus`))}</th><th>${i(t(`app.migration.report.columnFiles`))}</th><th>${i(t(`app.migration.report.columnMeaning`))}</th></tr>`),Ng.forEach(t=>a.push(`<tr><td class="${t}">${i(Fg(t))}</td><td>${e.totals[t]}</td><td class="muted">${i(Ig(t))}</td></tr>`)),a.push(`</table>`,`<h2>${i(t(`app.migration.report.costs`))}</h2>`,`<ul>`),Lg.forEach(t=>a.push(`<li>${i(Rg(t))}: <strong>${e.effort[t]}</strong></li>`)),a.push(`</ul>`),e.blockers.length>0&&(a.push(`<h2>${i(t(`app.migration.report.blockers`))}</h2>`,`<p>${i(t(`app.migration.report.blockersHint`))}</p>`,`<ul>`),e.blockers.forEach(({path:e,finding:n})=>a.push(`<li class="blocked">${i(n.title)} <span class="muted">${i(t(`app.migration.report.blockerWhere`,{where:n.where,path:jn(r.root,e),action:n.action}))}</span></li>`)),a.push(`</ul>`)),a.push(`<h2>${i(t(`app.migration.report.files`))}</h2>`,`<table>`,`<tr><th>${i(t(`app.migration.report.columnFile`))}</th><th>${i(t(`app.migration.report.columnStatus`))}</th><th>${i(t(`app.migration.report.columnNeedsWork`))}</th><th>${i(t(`app.migration.report.columnReview`))}</th><th>${i(t(`app.migration.report.columnConverts`))}</th></tr>`),e.files.forEach(e=>a.push(`<tr><td>${i(jn(r.root,e.path))}</td><td class="${e.status}">${i(Fg(e.status))}</td><td>${e.counts.manual}</td><td>${e.counts.review}</td><td>${e.counts.automatic}</td></tr>`)),a.push(`</table>`),e.files.filter(e=>e.status!==`ready`).forEach(e=>{let{sections:n,automatic:o}=Gg(e);a.push(`<h3>${i(jn(r.root,e.path))}</h3>`),n.forEach(e=>{a.push(`<p><strong>${e.title}</strong></p>`,`<ul>`),e.findings.forEach(e=>a.push(`<li>${i(t(`app.migration.report.findingWhere`,{where:e.where,title:e.title}))} <span class="muted">${i(e.action)}</span></li>`)),a.push(`</ul>`)}),o>0&&a.push(`<p class="muted">${i(Wg(o))}</p>`)}),e.code.length>0&&(a.push(`<h2>${i(t(`app.migration.report.code`))}</h2>`,`<p>${i(t(`app.migration.report.codeHint`))}</p>`),a.push(`<table>`,`<tr><th>${i(t(`app.migration.report.columnValue`))}</th><th>${i(t(`app.migration.report.columnWhere`))}</th><th>${i(t(`app.migration.report.columnBecomes`))}</th><th>${i(t(`app.migration.report.columnNotes`))}</th></tr>`),e.code.forEach(e=>a.push(`<tr><td><code>${i(e.value)}</code></td><td>${i(Kg(e,r.root))}</td><td>${i(e.becomes)}</td><td class="muted">${i(e.notes.join(` `))}</td></tr>`)),a.push(`</table>`)),e.apis.length>0&&(a.push(`<h2>${i(t(`app.migration.report.apis`))}</h2>`,`<p>${i(t(`app.migration.report.apisHint`))}</p>`,`<ul>`),e.apis.forEach(e=>a.push(`<li>${i(t(`app.migration.report.apiImports`,{api:e.api,imports:e.imports,files:Ug(e.files)}))}</li>`)),a.push(`</ul>`)),e.dataMigration&&(a.push(`<h2>${i(t(`app.migration.report.dataMigration`))}</h2>`,`<p>${i(e.dataMigration.detail)} ${i(e.dataMigration.action)}</p>`),e.dataMigration.link&&a.push(`<p class="muted">${i(t(`app.migration.report.dataMigrator`,{link:e.dataMigration.link}))}</p>`)),a.push(`</main>`,`</body>`,`</html>`),`${a.join(`
|
|
877
|
+
`)}\n`):(a.push(`<p>${i(t(`app.migration.report.nothingToMigrate`))}</p>`,`</main>`,`</body>`,`</html>`),`${a.join(`
|
|
878
|
+
`)}\n`)}function Zg(e){return e.replace(/[\\/]+$/,``)}function Qg(e,t){let n=Zg(e);return`${t?n:Gh(n)}/camunda-8`}function $g(e,t,n){let r=Zg(e),i=n.startsWith(`${r}/`)||n.startsWith(`${r}\\`)?n.slice(r.length+1):n.split(/[\\/]/).pop()??n;return`${Zg(t)}/${i.replace(/\\/g,`/`)}`}function e_(e){return/^[A-Za-z0-9_][A-Za-z0-9_.-]*$/.test(e)&&!/^(null|true|false|yes|no|on|off|y|n|~)$/i.test(e)&&!/^[0-9.eE+-]+$/.test(e)?e:JSON.stringify(e)}function t_(e,t){return[[`name`,e?.name?JSON.stringify(e.name):void 0],[`source`,e?.source?JSON.stringify(e.source):void 0],[`tenantId`,e?.tenantId?JSON.stringify(e.tenantId):void 0],[`changedOnly`,e?.changedOnly]].filter(([,e])=>e!==void 0).map(([e,n])=>`${t}${e}: ${n}`)}function n_(e){let t=t_(e.deployment,` `),n=[`# yaml-language-server: $schema=https://raw.githubusercontent.com/kern0x1b/penstock-release/main/docs/schema/penstock.schema.json`,`# The Camunda 8 version of a Camunda 7 folder, written by penstock migrate. Commit it.`,`# Files here open and are checked as Camunda 8; the folder they came from is untouched.`,``,`engine: camunda-8`,``];t.length>0?n.push(`deployment:`,...t):n.push(`# deployment:`,`# url: http://localhost:8080/v2`),t.length>0&&n.push(` # url: http://localhost:8080/v2`);let r=e.profiles??[];if(r.length>0){n.push(``,`profiles:`);for(let e of r){let t=t_(e.deployment,` `);t.length===0?n.push(` ${e_(e.name)}: {}`):n.push(` ${e_(e.name)}:`,` deployment:`,...t)}}return`${n.join(`
|
|
879
|
+
`)}\n`}const r_=/* @__PURE__ */ new Set([`JobWorker`,`ZeebeWorker`]),i_=/* @__PURE__ */ new Set([`BpmnError`,`CamundaBpmnError`,`ZeebeBpmnError`,`BusinessError`]),a_=/* @__PURE__ */ new Set([`ActivatedJob`,`JobClient`,`JobTask`,`Job`,`JobUpdate`,`CustomHeaders`,`TaskHeaders`,`DelegateExecution`,`DelegateTask`,`VariableScope`,`ExternalTask`,`ExternalTaskService`,`Object`]),o_=/* @__PURE__ */ new Set([`int`,`Integer`,`long`,`Long`,`double`,`Double`,`float`,`Float`,`short`,`Short`,`byte`,`Byte`,`BigDecimal`,`BigInteger`,`Number`,`number`,`Int`,`BigInt`]),s_=/* @__PURE__ */ new Set([`boolean`,`Boolean`,`bool`]),c_=/^[A-Za-z_]\w*(\.[A-Za-z_]\w*)+$/,l_=[`createWorker`,`createJobWorker`],u_=/* @__PURE__ */ new Set([`typescript`,`javascript`]),d_={python:{call:`BPMNError`,code:e=>e.arguments.find(e=>e.name===`error_code`)??e.arguments.find(e=>e.name===null)},go:{call:`ErrorCode`,code:e=>e.arguments[0]},csharp:{call:`ErrorCode`,code:e=>e.arguments[0]},java:{call:`errorCode`,code:e=>e.arguments[0]},kotlin:{call:`errorCode`,code:e=>e.arguments[0]},groovy:{call:`errorCode`,code:e=>e.arguments[0]},scala:{call:`errorCode`,code:e=>e.arguments[0]}};function f_(e){let t=p_(e),n=Xo(e);return e.flatMap(e=>[...m_(e,t),...w_(e),...A_(e,t),...E_(e,t,n)])}function p_(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map;for(let a of e){for(let e of a.declarations)if(e.kind===`enum`)!n.has(e.name)&&e.constants.length>0&&n.set(e.name,e.constants);else if((e.kind===`record`||e.kind===`class`)&&!t.has(e.name)){let n=e.members.filter(e=>(e.kind===`field`||e.kind===`parameter`)&&!e.modifiers.includes(`static`)).map(e=>({name:e.name,type:e.type??``}));n.length>0&&t.set(e.name,n)}for(let e of a.constants)r.set(e.name,e.value),e.owner&&i.set(`${e.owner}.${e.name}`,e.value)}return{records:t,enums:n,constants:r,owned:i}}function m_(e,t){let n=L(e),r=[];for(let i of e.callables){let a=i.annotations.find(e=>r_.has(e.name));if(!a)continue;let o=a.arguments.find(e=>e.name===`type`),s=o?h_(o,t):i.name;if(s===null)continue;let c=n.callsBySpan.inOrder(i.span.from,i.span.to).filter(e=>ag(i.span,e.span)),l=n.constructionsBySpan.inOrder(i.span.from,i.span.to).filter(e=>ag(i.span,e.span)),u=[...v_(c),...y_(c)],d=t.records.get(dg(i.returnType??``))??[];d.length>0&&u.length===0&&u.push(...d.map(e=>C_(e.name,e.type,t))),r.push({binding:`jobType`,value:s,engine:`camunda-8`,source:`spring`,name:M_(s),className:i.owner,packageName:e.package,inputs:N_([...g_(a),...__(i,t)]),outputs:N_(u),errors:[...new Set(l.filter(b_).map(e=>$(e.arguments[0])).filter(e=>e!==null))],valueOffset:null,fetch:null,variables:[],file:e.path,line:so(e.lineStarts,a.at),offset:a.at,end:i.span.to})}return r}function h_(e,t){return e.value===null?e.identifier?t.constants.get(ig(e.identifier))??null:c_.test(e.text)?t.owned.get(e.text.split(`.`).slice(-2).join(`.`))??null:null:e.value}function g_(e){let t=e.arguments.find(e=>e.name===`fetchVariables`);return(t?.values??(t?.value?[t.value]:[])).map(e=>({name:e,type:`String`}))}function __(e,t){let n=[];for(let r of e.parameters){let e=r.type??``,i=dg(e),a=r.annotations.find(e=>e.name===`Variable`);if(a_.has(i)&&!a)continue;let o=x_(e)||(r.annotations.some(e=>e.name===`VariablesAsType`)?i:``),s=o?t.records.get(o)??[]:[];if(s.length>0){n.push(...s.map(e=>C_(e.name,e.type,t)));continue}if(!a)continue;let c=a.arguments.find(e=>e.name===`name`||e.name===`value`);n.push(C_(c?.value??r.name,e,t))}return n}function v_(e){return e.filter(e=>(e.name===`put`||e.name===`putAll`)&&e.arguments.length>=2).map(e=>$(e.arguments[0])).filter(e=>e!==null&&e!==``).map(e=>({name:e,type:`String`}))}function y_(e){return e.filter(e=>e.name===`mapOf`).flatMap(e=>e.arguments.flatMap(e=>{let[t,...n]=e.text.split(` to `);return n.length>0&&t.startsWith(`"`)&&t.endsWith(`"`)&&t.length>2?[{name:t.slice(1,-1),type:`String`}]:[]}))}function b_(e){return i_.has(ig(e.type))}function x_(e){return dg(e)===`Map`?dg(e.slice(e.indexOf(`<`)+1,e.lastIndexOf(`>`)).split(`,`)[1]??``):``}function S_(e,t){let n=dg(e);if(s_.has(n))return{type:`Boolean`};if(o_.has(n))return{type:`Number`};let r=t.enums.get(n);return r&&r.length>0?{type:`Dropdown`,choices:r}:{type:`String`}}function C_(e,t,n){return{...S_(t,n),name:e}}function w_(e){if(!u_.has(e.language))return[];let t=[];for(let n of l_)for(let r of e.calls.filter(e=>e.name===n)){let n=r.arguments[0];if(!n||!n.text.startsWith(`{`))continue;let i=k_(e,n.span.from),a=i.find(e=>(e.key===`taskType`||e.key===`type`)&&$(e.value)!==null),o=a?$(a.value):null,s=i.find(e=>e.key===`taskHandler`);o!==null&&t.push(T_(e,r,o,s?.value.span??n.span))}for(let n of e.calls.filter(e=>e.name===`jobType`)){let r=$(n.arguments[0]);r!==null&&t.push(T_(e,n,r,n.arguments[1]?.span??n.span))}return t}function T_(e,t,n,r){let i=L(e),a=[...i.localsAt.inOrder(r.from,r.to).flatMap(e=>og(r,e.at)&&e.initializer?.text===`job.variables`&&e.key!==null?[{name:e.key,type:`String`}]:[]),...i.accessesAt.inOrder(r.from,r.to).filter(e=>og(r,e.at)&&e.receiver===`job.variables`&&e.name!==null).map(e=>({name:e.name??``,type:`String`}))],o=i.callsBySpan.inOrder(r.from,r.to).filter(e=>ag(r,e.span)&&e.receiver===`job`&&e.name===`complete`).flatMap(t=>{let n=k_(e,t.arguments[0]?.span.from??-1),r=n.find(e=>e.key===`variables`);return(r?k_(e,r.value.span.from):n.filter(e=>e.key!==`variables`)).flatMap(e=>e.key===null?[]:[{name:e.key,type:`String`}])}),s=i.callsBySpan.inOrder(r.from,r.to).filter(e=>ag(r,e.span)&&e.receiver===`job`&&e.name===`error`).map(e=>$(e.arguments[0])).filter(e=>e!==null);return{binding:`jobType`,value:n,engine:`camunda-8`,source:`node`,name:M_(n),className:null,packageName:null,inputs:N_(a),outputs:N_(o),errors:[...new Set(s)],valueOffset:null,fetch:null,variables:[],file:e.path,line:so(e.lineStarts,t.at),offset:t.at,end:t.span.to}}function E_(e,t,n){return Ts(e).filter(e=>e.contract).map(r=>D_(e,r,t,n))}function D_(e,t,n,r){let i=/* @__PURE__ */ new Set,a=Os(e,t,r).filter(e=>{let t=JSON.stringify([e.name,e.writes,e.where,e.literal]);return!i.has(t)&&(i.add(t),!0)}).sort((e,t)=>e.literal-t.literal).map(t=>({name:t.name,writes:t.writes,type:t.type,where:t.where,line:so(e.lineStarts,t.literal),offset:t.literal})),o=a.filter(e=>!e.writes).map(e=>({name:e.name,type:`String`})),s=a.filter(e=>e.writes).map(e=>C_(e.name,e.type??``,n)),c=t.kind===`TOPIC`,l=O_(e,t);return{binding:c?`topic`:`jobType`,value:t.value,engine:c?`camunda-7`:`camunda-8`,source:`client`,name:M_(t.value),className:null,packageName:null,inputs:N_(o),outputs:N_(s),errors:[...new Set(l.map(e=>e.code))],errorSites:l,valueOffset:t.valueAt,handler:t.handler,fetch:{names:t.fetch??[],declared:t.fetch!==null,line:so(e.lineStarts,t.at)},variables:a,file:e.path,line:so(e.lineStarts,t.at),offset:t.at,end:t.end}}function O_(e,t){let n=d_[e.language];if(n===void 0)return[];let r=L(e).callsAt.inOrder(t.span.from,t.span.to).filter(e=>e.name===n.call&&og(t.span,e.at)).flatMap(t=>{let r=n.code(t),i=$(r);return r===void 0||i===null?[]:[{code:i,line:so(e.lineStarts,r.span.from),offset:r.span.from}]}),i=/* @__PURE__ */ new Set;return r.filter(e=>{let t=`${e.code}\0${e.offset}`;return!i.has(t)&&(i.add(t),!0)})}function k_(e,t){return L(e).pairsByObject.get(t)??[]}function A_(e,t){let n=[],r=$a(sg(e),e=>e.offset);for(let i of e.declarations){if(i.kind!==`class`)continue;let a=r.get(i.span.from);if(!a)continue;let o=i.annotations.find(e=>e.name===`ExternalTaskSubscription`&&e.arguments.length>0),s=i.supertypes.map(e=>({name:ig(e.name),relation:e.relation})),c=s.some(e=>e.name===`ExternalTaskHandler`)||o!==void 0,l=s.some(e=>e.name===`JavaDelegate`||e.relation===`implements`&&e.name===`Delegate`);if(!c&&!l)continue;let u=o?j_(o,t):null;if(o&&u===null)continue;let d=e.package?`${e.package}.${i.name}`:i.name;n.push({binding:u?`topic`:`class`,value:u||d,engine:`camunda-7`,source:`delegate`,name:u?M_(u):i.name,className:i.name,packageName:e.package,inputs:a.reads.map(e=>({name:e,type:`String`})),outputs:a.writes.map(e=>({name:e,type:`String`})),errors:a.errors.map(e=>e.code),valueOffset:null,fetch:null,variables:[],file:e.path,line:a.line,offset:i.span.from,end:i.span.to})}return n}function j_(e,t){let n=e.arguments.find(e=>e.name===`topicName`||e.name===`value`||e.name===null);return n?h_(n,t):null}function M_(e){let t=e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).split(/[^A-Za-z0-9]+/).filter(Boolean).map(e=>e.toLowerCase());return t.length===0?e:t.map((e,t)=>t===0?e[0].toUpperCase()+e.slice(1):e).join(` `)}function N_(e){let t=/* @__PURE__ */ new Set;return e.filter(e=>!t.has(e.name)&&(t.add(e.name),!0))}const P_=e=>ku(`table`,e),F_=`\0other`;function I_(e){let t=[],n=0,r=!1,i=0;for(let a=0;a<e.length;a+=1){let o=e[a];r&&o===`\\`?a+=1:(o===`"`&&(r=!r),!r&&((o===`(`||o===`[`)&&(n+=1),(o===`)`||o===`]`)&&--n,o===`,`&&n===0&&(t.push(e.slice(i,a)),i=a+1)))}return t.push(e.slice(i)),t.map(e=>e.trim()).filter(Boolean)}function L_(e){return/^-?\d+(\.\d+)?$/.test(e.trim())?Number(e.trim()):null}const R_=864e5,z_=/^\d{4}-\d{2}-\d{2}(?:T[\d:.]+(?:Z|[+-]\d{2}:?\d{2})?)?$/,B_=/^(?:date\s*\(\s*"([^"]+)"\s*\)|date\s+and\s+time\s*\(\s*"([^"]+)"\s*\)|time\s*\(\s*"([^"]+)"\s*\)|@"([^"]+)"|@([\d:.+\-TZ]+))$/;function V_(e){let t=e.slice(0,10),n=/* @__PURE__ */ new Date(`${t}T00:00:00Z`);return!Number.isNaN(n.getTime())&&n.toISOString().slice(0,10)===t}function H_(e){let t=B_.exec(e.trim());if(!t)return null;let n=t[1]??t[2]??t[3]??t[4]??t[5]??``;return z_.test(n)&&V_(n)?n:null}function U_(e){return typeof e==`string`&&z_.test(e)}function W_(e){return(/* @__PURE__ */ new Date(Date.parse(`${e.slice(0,10)}T00:00:00Z`)-R_)).toISOString().slice(0,10)}function G_(e){return new Date(Date.parse(`${e.slice(0,10)}T00:00:00Z`)+R_).toISOString().slice(0,10)}function K_(e,t){let n=Date.parse(`${e.slice(0,10)}T00:00:00Z`)+(Date.parse(`${t.slice(0,10)}T00:00:00Z`)-Date.parse(`${e.slice(0,10)}T00:00:00Z`))/2;return new Date(n).toISOString().slice(0,10)}function q_(e){return{kind:`date`,test:t=>U_(t)&&t===e,numbers:[],strings:[],moments:[e]}}function J_(e){let t=e.trim(),n=/^not\s*\(([\s\S]*)\)$/.exec(t);if(n){if(n[1].trim()===``)return null;let e=Y_(n[1]);return e?{...e,test:t=>!e.test(t)}:null}if(t===`true`||t===`false`){let e=t===`true`;return{kind:`boolean`,test:t=>t===e,numbers:[],strings:[],moments:[]}}if(t===`null`)return{kind:`null`,test:e=>e===`null`,numbers:[],strings:[],moments:[]};let r=/^"((?:[^"\\]|\\.)*)"$/.exec(t);if(r)return{kind:`string`,test:e=>e===r[1],numbers:[],strings:[r[1]],moments:[]};let i=L_(t);if(i!==null)return{kind:`number`,test:e=>e===i,numbers:[i],strings:[],moments:[]};let a=H_(t);if(a)return q_(a);let o=/^(<=|>=|<|>|=)\s*(-?\d+(?:\.\d+)?)$/.exec(t);if(o){let e=Number(o[2]);return{kind:`number`,test:{"<":t=>typeof t==`number`&&t<e,"<=":t=>typeof t==`number`&&t<=e,">":t=>typeof t==`number`&&t>e,">=":t=>typeof t==`number`&&t>=e,"=":t=>t===e}[o[1]],numbers:[e],strings:[],moments:[]}}let s=/^(<=|>=|<|>|=)\s*((?:date\s*\(\s*"[^"]+"\s*\)|date\s+and\s+time\s*\(\s*"[^"]+"\s*\)|time\s*\(\s*"[^"]+"\s*\)|@"[^"]+"))$/.exec(t);if(s){let e=H_(s[2]);return e===null?null:{kind:`date`,test:{"<":t=>U_(t)&&t<e,"<=":t=>U_(t)&&t<=e,">":t=>U_(t)&&t>e,">=":t=>U_(t)&&t>=e,"=":t=>U_(t)&&t===e}[s[1]],numbers:[],strings:[],moments:[e]}}let c=/^([[\](])\s*(-?\d+(?:\.\d+)?)\s*\.\.\s*(-?\d+(?:\.\d+)?)\s*([[\])])$/.exec(t);if(c){let[e,t]=[Number(c[2]),Number(c[3])],n=c[1]!==`[`,r=c[4]!==`]`;return{kind:`number`,test:i=>typeof i==`number`&&(n?i>e:i>=e)&&(r?i<t:i<=t),numbers:[e,t],strings:[],moments:[]}}let l=/^([[\]()])\s*((?:date\s*\(\s*"[^"]+"\s*\)|date\s+and\s+time\s*\(\s*"[^"]+"\s*\)|time\s*\(\s*"[^"]+"\s*\)|@"[^"]+"))\s*\.\.\s*((?:date\s*\(\s*"[^"]+"\s*\)|date\s+and\s+time\s*\(\s*"[^"]+"\s*\)|time\s*\(\s*"[^"]+"\s*\)|@"[^"]+"))\s*([[\])])$/.exec(t);if(l){let[e,t]=[H_(l[2]),H_(l[3])];if(e===null||t===null)return null;let n=l[1]!==`[`,r=l[4]!==`]`;return{kind:`date`,test:i=>U_(i)&&(n?i>e:i>=e)&&(r?i<t:i<=t),numbers:[],strings:[],moments:[e,t]}}return null}function Y_(e){let t=(e??``).trim();if(t===``||t===`-`)return{kind:`any`,test:()=>!0,numbers:[],strings:[],moments:[]};let n=I_(t);if(n.length>1){let e=n.map(J_);if(e.some(e=>!e))return null;let t=e;return{kind:t.find(e=>e.kind!==`any`)?.kind??`any`,test:e=>t.some(t=>t.test(e)),numbers:t.flatMap(e=>e.numbers),strings:t.flatMap(e=>e.strings),moments:t.flatMap(e=>e.moments)}}return J_(t)}function X_(e,t){let n=new Set(e.map(e=>e.kind).filter(e=>e!==`any`)),r=(t??``).toLowerCase();if(n.size>1)return null;let i=n.size===1?[...n][0]:r===`boolean`?`boolean`:r===`string`?`string`:/int|long|double|number|decimal/.test(r)?`number`:`any`;if(i===`any`)return[F_];if(i===`boolean`)return[!0,!1];if(i===`string`)return[...new Set(e.flatMap(e=>e.strings)),F_];if(i===`date`){let t=[...new Set(e.flatMap(e=>e.moments))].sort();if(t.length===0)return[F_];let n=t.slice(1).map((e,n)=>K_(t[n],e));return[.../* @__PURE__ */ new Set([W_(t[0]),...t.flatMap((e,r)=>[e,...r+1<t.length?[n[r]]:[]]),G_(t[t.length-1])])]}let a=/int|long/.test(r),o=[...new Set(e.flatMap(e=>e.numbers))].sort((e,t)=>e-t);if(o.length===0)return[0];let s=[o[0]-1];return o.forEach((e,t)=>{s.push(e);let n=o[t+1];n!==void 0&&(a?n-e>1&&s.push(e+1):s.push((e+n)/2))}),s.push(o[o.length-1]+1),s}function Z_(e){return e===F_?t(`app.rules.table.someOtherValue`):typeof e==`string`?`"${e}"`:String(e)}function Q_(e,n){let r=e.name?.trim()||e.id||t(`app.rules.table.aDecision`),i=n.input??[],a=n.rule??[];if(a.length===0||i.length===0)return[];let o=a.map(e=>i.map((t,n)=>Y_(e.inputEntry?.[n]?.text)));if(o.some(e=>e.some(e=>!e)))return[{kind:`TABLE-UNREAD`,decision:r,title:P_(`TABLE-UNREAD`),detail:t(`app.rules.table.unread`,{decision:r}),rules:[]}];let s=o,c=i.map((e,t)=>X_(s.map(e=>e[t]),e.inputExpression?.typeRef));if(c.some(e=>!e))return[];let l=c,u=i.map((e,n)=>e.label?.trim()||e.inputExpression?.text?.trim()||t(`app.rules.table.input`,{number:n+1})),d=[],f=(n.hitPolicy??`UNIQUE`).toUpperCase(),p=e=>(a[e].outputEntry??[]).map(e=>(e.text??``).trim()).join(`|`);if(f===`UNIQUE`||f===`ANY`)for(let e=0;e<a.length;e+=1)for(let n=e+1;n<a.length;n+=1){if(f===`ANY`&&p(e)===p(n))continue;let i=l.map((t,r)=>t.find(t=>s[e][r].test(t)&&s[n][r].test(t)));if(i.some(e=>e===void 0))continue;let a=i.map((e,n)=>t(`app.rules.table.whenIs`,{label:u[n],value:Z_(e)})).join(t(`app.rules.table.and`));d.push({kind:`RULE-OVERLAP`,decision:r,title:P_(`RULE-OVERLAP`),detail:t(`app.rules.table.ruleOverlap`,{decision:r,first:e+1,second:n+1,when:a,different:f===`ANY`?t(`app.rules.table.differentResults`):``,policy:f===`ANY`?`Any`:`Unique`}),rules:[e+1,n+1]})}let m=[],h=0,g=(e,t,n)=>{if(!(m.length>=3||h>2e5)){if(h+=1,n.length===0)m.push(t);else if(e!==l.length){for(let r of l[e])if(g(e+1,[...t,r],n.filter(t=>s[t][e].test(r))),m.length>=3)return}}};if(g(0,[],a.map((e,t)=>t)),m.length>0){let e=m.map(e=>e.map((e,n)=>t(`app.rules.table.whenIs`,{label:u[n],value:Z_(e)})).join(t(`app.rules.table.and`))).join(t(`app.rules.table.orWhen`));d.push({kind:`RULE-GAP`,decision:r,title:P_(`RULE-GAP`),detail:t(`app.rules.table.ruleGap`,{decision:r,cases:e}),rules:[]})}return d}function $_(e){let t=e,n=[];for(let e of t.drgElement??[])e.$type===`dmn:Decision`&&e.decisionLogic?.$type===`dmn:DecisionTable`&&n.push(...Q_(e,e.decisionLogic));return n}async function ev(e,n){let r;try{r=(await s(`plain`).fromXML(e)).rootElement}catch{return[]}let i=[];for(let e of r?.drgElement??[]){let r=e.decisionLogic;e.$type===`dmn:Decision`&&r?.$type===`dmn:DecisionTable`&&e.id&&i.push({decisionId:e.id,name:e.name?.trim()||e.id,hitPolicy:(r.hitPolicy??`UNIQUE`).toUpperCase(),aggregation:r.aggregation?.toUpperCase(),file:n,inputs:(r.input??[]).map((e,n)=>({label:e.label?.trim()||e.inputExpression?.text?.trim()||t(`app.scenarios.dmn.unnamedInput`,{number:n+1}),expression:e.inputExpression?.text?.trim()??``,...e.inputExpression?.typeRef?{type:e.inputExpression.typeRef}:{}})),outputs:(r.output??[]).map((e,n)=>({name:e.name?.trim()||e.label?.trim()||t(`app.scenarios.dmn.unnamedOutput`,{number:n+1}),typeRef:e.typeRef,...e.outputValues?.text?{values:tv(e.outputValues.text)}:{}})),rules:(r.rule??[]).map((e,t)=>({id:e.id??`rule-${t+1}`,inputs:(e.inputEntry??[]).map(e=>(e.text??``).trim()),outputs:(e.outputEntry??[]).map(e=>(e.text??``).trim())}))})}return i}function tv(e){return[...e.matchAll(/"(?:[^"\\]|\\.)*"|[^,\s][^,]*/g)].map(e=>e[0].trim())}export{Su as $,$n as $t,lm as A,ji as At,ef as B,kr as Bt,ih as C,ya as Ct,hm as D,ga as Dt,Xm as E,ha as Et,Sf as F,ti as Ft,Id as G,Or as Gt,Qd as H,Ar as Ht,_f as I,ei as It,Od as J,yr as Jt,Rd as K,vr as Kt,ff as L,Xr as Lt,Nf as M,wi as Mt,vf as N,Si as Nt,um as O,da as Ot,bf as P,$r as Pt,Eu as Q,tr as Qt,df as R,Sr as Rt,fh as S,va as St,$m as T,xa as Tt,Ld as U,Cr as Ut,Zd as V,Dr as Vt,Jd as W,Er as Wt,ku as X,xr as Xt,Du as Y,gr as Yt,Tu as Z,rr as Zt,Jh as _,ft as _n,Ps as _t,$g as a,En as an,W as at,ch as b,oo as bt,Rg as c,zt as cn,Oc as ct,Mg as d,Mt as dn,sc as dt,Zn as en,Xl as et,Ag as f,Et as fn,Ks as ft,qh as g,bt as gn,Vs as gt,sg as h,yt as hn,Bs as ht,n_ as i,Cn as in,dl as it,jf as j,Ti as jt,gm as k,Zi as kt,Xg as l,It as ln,Tc as lt,cg as m,Dt as mn,Rs as mt,$_ as n,Nn as nn,fl as nt,Qg as o,cn as on,cl as ot,lg as p,Tt as pn,zs as pt,Sd as q,ur as qt,f_ as r,Tn as rn,pl as rt,Lg as s,Vt as sn,Kc as st,ev as t,Kn as tn,hl as tt,Yg as u,Ot as un,gc as ut,Uh as v,Ue as vn,Is as vt,eh as w,ba as wt,lh as x,_a as xt,th as y,T as yn,io as yt,pf as z,Tr as zt};
|