@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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./BpmnDocument-
|
|
2
|
-
import{i as e}from"./rolldown-runtime-B8BYMn-z.js";import{c as t,d as n,f as r,g as i,h as a,i as o,m as s,o as c,r as l,s as u,t as d,u as f}from"./vendor-NJP34MHU.js";import{c as p,i as m,l as h,n as g,o as _,r as v}from"./translator-Dvvasoz-.js";import{t as y}from"./preload-helper-VRuDKI9K.js";import{n as b,t as x,v as S,x as C}from"./frontend-B05iyhCp.js";import{Vt as w,X as T,Y as E,an as D,in as O,jt as k,r as A,t as j}from"./bridgeInstance-BPwbITOf.js";import{d as M,g as N,p as P}from"./moddle-CGpeSs3G.js";import{Ct as F,n as I,t as L,wt as R}from"./BpmnCanvas-BTdM1l9l.js";import{i as z,n as B,o as V,r as H,s as ee,t as U}from"./platform-zEAtGnYc.js";import{u as te}from"./engines-BQRXHtW8.js";import{s as ne}from"./testCaseRuns-C-0blM3d.js";import{t as re}from"./shortcut-DONH578b.js";import{_ as ie,a as W,c as G,d as ae,f as oe,g as se,h as ce,i as le,l as ue,m as de,o as fe,p as pe,s as me,t as he,u as ge,v as _e}from"./AgentSettings-BvzT4Itb.js";import{t as ve}from"./typing-CXvbBSPr.js";import{a as K}from"./httpHost-DX-P_FDg.js";import{A as ye}from"./bpmnTheme-db4tYvop.js";import{a as be,c as xe,f as q,g as Se,i as Ce,l as we,m as Te,n as J,o as Ee,p as Y,r as X,s as De,t as Oe,u as ke}from"./ui-TBzvKaKQ.js";import{i as Z,n as Ae,o as je,r as Me,t as Ne}from"./preferences-K6VRM9Ah.js";import{a as Pe,d as Fe,f as Ie,i as Q,n as Le,o as Re,p as ze,r as Be,s as Ve,u as He}from"./files-Chpd_QD0.js";import{n as Ue,t as We}from"./documents-Dkor36oS.js";import{Ln as Ge}from"./duplicate-ud-StKuO.js";import{I as Ke}from"./dist-CsBP6QjA.js";import{a as qe,o as Je}from"./dist-Gx7P7Pk_.js";import{a as Ye,i as Xe,o as Ze,r as Qe,t as $e}from"./dockLayout-CxOMo-Nl.js";import{a as et,c as tt,i as $,n as nt,o as rt,r as it,s as at}from"./commands-BAnBjEk3.js";(function polyfill(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))processPreload(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&processPreload(e)}).observe(document,{childList:!0,subtree:!0});function getFetchOpts(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function processPreload(e){if(e.ep)return;e.ep=!0;let t=getFetchOpts(e);fetch(e.href,t)}})();function tabList(e){let t=e.map(e=>e.id),n=t.find((e,n)=>t.indexOf(e)!==n);if(n!==void 0)throw Error(`the tab ${n} is listed twice`);return e}function shownTab(e,t){return e.hidden||t&&e.collapsed?null:e.tab}function droppedTabs(e,t,n,r){let i=e.reduce((e,t)=>e+t.width,0);if(i<=n)return[];let a=i,o=[];for(let i=e.length-1;i>=0&&a+r>n;--i){let n=e[i];n.id!==t&&(o.unshift(n.id),a-=n.width)}return o}var ot=`properties`,st=280,ct=.3,lt=320,ut=480;function initialSidebar(){return{hidden:!1,tab:ot,width:null,collapsed:!1,stacks:{}}}function selectTab(e,t,n){return t.includes(n)?{...e,tab:n,hidden:!1,collapsed:!1}:e}function toggleHidden(e){return{...e,hidden:!e.hidden}}function toggleCollapsed(e){return{...e,collapsed:!e.collapsed}}function stackOf(e,t){return e.stacks&&Object.hasOwn(e.stacks,t)?e.stacks[t]:[]}function pushView(e,t,n){return{...e,stacks:{...e.stacks,[t]:[...stackOf(e,t),n]}}}function popView(e,t){return{...e,stacks:{...e.stacks,[t]:stackOf(e,t).slice(0,-1)}}}function resetViews(e,t){return{...e,stacks:{...e.stacks,[t]:[]}}}function defaultWidth(e){return Number.isFinite(e)?Math.min(ut,Math.max(lt,Math.round(e*ct))):lt}function widthLimits(e){return Number.isFinite(e)?{min:st,max:Math.max(st,Math.floor(e/2))}:{min:st,max:st}}function resolveWidth(e,t){let{min:n,max:r}=widthLimits(t),i=e!==null&&Number.isFinite(e)?e:defaultWidth(t);return Math.min(r,Math.max(n,i))}function isDrawer(e){return e<960}var isRecord=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function sidebarOf(e,t){let n=isRecord(e)?e.sidebarByEditor:void 0,r=isRecord(n)&&Object.hasOwn(n,t)?n[t]:void 0;return isRecord(r)?r:{}}function toPreferences(e,t,n={}){let r=isRecord(n)?n.sidebarByEditor:void 0,i=isRecord(r)?{...r}:{};return delete i[t],{sidebarWidth:e.width,sidebarByEditor:{...i,[t]:{tab:e.tab,hidden:e.hidden,collapsed:e.collapsed}}}}function fromPreferences(e,t,n){let r=sidebarOf(e,n),i=typeof r.tab==`string`&&t.includes(r.tab)?r.tab:t[0]??`properties`,a=isRecord(e)?e.sidebarWidth:void 0;return{...initialSidebar(),tab:i,width:typeof a==`number`&&Number.isFinite(a)?a:null,hidden:r.hidden===!0,collapsed:r.collapsed===!0}}function arrowTab(e,t,n){let r=e.indexOf(t);return r<0||e.length===0?null:n===`ArrowRight`?e[(r+1)%e.length]:n===`ArrowLeft`?e[(r-1+e.length)%e.length]:n===`Home`?e[0]:n===`End`?e[e.length-1]:null}function badgeText(e){return e?e>99?`99+`:String(e):``}function badgeLabel(e){return e?m(e>99?`app.sidebar.moreThan99Findings`:`app.sidebar.findingCount`,{count:e}):``}function isRepeatOfPress(e,t){return e!==null&&t-e<300}function isSidebarShortcut(e,t){return T(e,E,t)}function titleCommit(e,t){let n=t.trim();return n===``||n===e?null:n}function isRenameKey(e){return e===`F2`}var dt=`.bio-properties-panel, .dmn-decision-table-container`;function localisePanel(e){if(e.nodeType!==Node.ELEMENT_NODE)return;let t=e,n=t.closest(dt)===null?[...t.querySelectorAll(dt)]:[t];for(let e of n)F(e),e.querySelectorAll(`[title], [aria-label]`).forEach(F),e.querySelectorAll(`button`).forEach(R)}function translatePanelLabels(){localisePanel(document.body),new MutationObserver(e=>{for(let t of e)t.type===`attributes`?t.target.closest(dt)&&F(t.target):t.addedNodes.forEach(localisePanel)}).observe(document.body,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`title`,`aria-label`]})}function startupFailureMessage(e){if(e instanceof Error)return e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function StartupFailure({message:e}){return l(`div`,{class:`startup-failure`,role:`alert`,children:l(`div`,{class:`startup-failure__inner`,children:[l(De,{title:m(`app.startup.theEditorCouldNotStart`),hint:m(`app.startup.retryingReloadsTheEditorAnd`),actions:[{label:m(`app.common.retry`),run:()=>window.location.reload()}]}),l(`pre`,{class:`startup-failure__message`,children:e})]})})}function showStartupFailure(e,t){if(!e||typeof document>`u`)return;let n=document.createElement(`div`);e.replaceChildren(n),s(l(StartupFailure,{message:startupFailureMessage(t)}),n)}var ft=new Set([`properties`,`appliesTo`]);function isEmpty(e){return Array.isArray(e)?e.length===0:typeof e==`object`&&!!e&&Object.keys(e).length===0}function withoutNulls(e){return typeof e!=`object`||!e||Array.isArray(e)?e:Object.fromEntries(Object.entries(e).filter(([,e])=>e!=null))}function cleanTemplate(e){let t={};for(let[n,r]of Object.entries(e))r!=null&&(!isEmpty(r)||ft.has(n))&&(t[n]=n===`groups`&&Array.isArray(r)?r.map(withoutNulls):r);return t}function cleanTemplates(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e).map(cleanTemplate):[]}var pt=``+new URL(`colors-dark-C7vOziWz.css`,import.meta.url).href,mt=``+new URL(`colors-dracula-CXhMcc1Z.css`,import.meta.url).href,ht=``+new URL(`colors-light-CyT40N4M.css`,import.meta.url).href,gt={light:{isDark:!1},dark:{isDark:!0},dracula:{isDark:!0}},_t=`light`;function themeNameFor(e,t){let n=e?.toLowerCase();return n&&n in gt?n:t?`dark`:_t}function applyTheme(e){document.documentElement.setAttribute(`data-theme`,e);let t=document.createElement(`link`);return t.rel=`stylesheet`,t.href=new URL(Object.assign({"./colors-dark.css":pt,"./colors-dracula.css":mt,"./colors-light.css":ht})[`./colors-${e}.css`],import.meta.url).href,document.querySelectorAll(`link[data-theme-css]`).forEach(e=>e.remove()),t.setAttribute(`data-theme-css`,`true`),document.head.appendChild(t),t}function announceThemeApplied(e,t){let announce=()=>{window.dispatchEvent(new CustomEvent(`bpmn-theme-changed`,{detail:t}))},n=applyTheme(e);announce(),n.addEventListener(`load`,announce,{once:!0})}function getCurrentTheme(){let e=document.documentElement.getAttribute(`data-theme`);return e&&e in gt?e:_t}function toggleDarkMode(){let e=gt[getCurrentTheme()].isDark?`light`:`dark`;return applyTheme(e),e}var vt=`--theme-bg-primary.--theme-bg-secondary.--theme-bg-sidebar.--theme-bg-tertiary.--theme-bg-input.--theme-bg-hover.--theme-bg-hover-strong.--theme-bg-pressed.--theme-bg-selected.--theme-bg-selected-muted.--theme-bg-selected-inactive.--theme-fg-primary.--theme-fg-selected.--theme-fg-secondary.--theme-fg-tertiary.--theme-fg-disabled.--theme-fg-on-accent.--theme-fg-code.--theme-border-primary.--theme-border-secondary.--theme-border-light.--theme-border-strong.--theme-separator.--theme-accent-primary.--theme-accent-hover.--theme-accent-pressed.--theme-accent-subtle.--theme-accent-solid.--theme-accent-solid-hover.--theme-accent-solid-pressed.--theme-on-accent.--theme-icon-default.--theme-icon-muted.--theme-icon-on-accent.--theme-link.--theme-link-hover.--theme-focus-ring.--theme-success.--theme-warning.--theme-error.--theme-error-subtle.--theme-error-subtle-alt.--theme-error-border.--theme-error-dark.--theme-error-critical.--theme-success-subtle.--theme-success-border.--theme-warning-subtle.--theme-warning-border.--theme-badge-bg.--theme-badge-fg.--theme-grid-pattern.--theme-lasso.--theme-white.--theme-white-subtle.--theme-black.--theme-black-subtle-10.--theme-black-subtle-30.--theme-scrim.--theme-shadow-float.--theme-shadow-popup.--theme-shadow-low.--theme-shadow-hairline.--theme-shadow-dialog.--type-size-body.--type-size-small.--type-size-tiny`.split(`.`),yt=/^#[0-9a-f]{6}([0-9a-f]{2})?$/i;function applyIdeTheme(e){clearIdeTheme();let t=new Set(vt),n=document.documentElement,r=e.tokens,i=0;for(let e of Object.keys(r??{})){let a=r[e];t.has(e)&&typeof a==`string`&&yt.test(a)&&(n.style.setProperty(e,a),i+=1)}return i}function clearIdeTheme(){let e=document.documentElement;for(let t of vt)e.style.removeProperty(t)}var bt=[`ide`,`light`,`dark`,`dracula`],xt=null,St=null,Ct=null;function themeChoiceOf(e){return typeof e==`string`&&e!==`ide`&&e in gt?e:`ide`}function currentThemeChoice(){return themeChoiceOf(Z()?.theme)}function nameOf$1(e){let t=e?.toLowerCase();return t&&t in gt?t:null}e(nameOf$1,`nameOf`);function announce(e,t){announceThemeApplied(e,{theme:t});let n=window.appConfig;n&&(n.theme=t)}function showHostTheme(){document.documentElement.removeAttribute(`data-theme-choice`),clearIdeTheme(),xt&&applyIdeTheme(xt);let e=nameOf$1(xt?.theme)??St;e?announce(e,e):window.dispatchEvent(new CustomEvent(`bpmn-theme-changed`,{detail:{theme:null}}))}function applyThemeChoice(){let e=currentThemeChoice();Ct=e,e===`ide`?showHostTheme():(clearIdeTheme(),document.documentElement.setAttribute(`data-theme-choice`,e),announce(e,e))}function chooseTheme(e){je({theme:e}),applyThemeChoice()}function rememberHostTheme(e){St=e}function receiveHostThemeName(e){let t=nameOf$1(e);t?(St=t,xt=null,currentThemeChoice()===`ide`&&(clearIdeTheme(),announce(t,e))):console.warn(`[Theme] Ignoring unknown theme from window.setTheme:`,e)}function followThemeChoice(){return Me(()=>{currentThemeChoice()!==Ct&&applyThemeChoice()})}var wt=`penstock-web`,Tt=`drafts`,Et=`root`,Dt=`penstock-page:`,Ot=250;function draftId(e,t){return`${e}\n${t}`}function request(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error??Error(`IndexedDB request failed`))})}function finished(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error??Error(`IndexedDB transaction failed`)),e.onabort=()=>n(e.error??Error(`IndexedDB transaction aborted`))})}var IndexedDbDrafts=class{opened=null;database(){return this.opened??=new Promise((e,t)=>{let n=indexedDB.open(wt,1);n.onupgradeneeded=()=>{n.result.createObjectStore(Tt,{keyPath:`id`}).createIndex(Et,`root`)},n.onsuccess=()=>{let t=n.result;t.onversionchange=()=>{t.close(),this.opened=null},e(t)},n.onerror=()=>t(n.error??Error(`IndexedDB did not open`)),n.onblocked=()=>t(Error(`IndexedDB is blocked`))}).catch(e=>{throw this.opened=null,e}),this.opened}async write(e,t){let n=(await this.database()).transaction(Tt,`readwrite`),r=n.objectStore(Tt);t.forEach(e=>r.delete(e)),e.forEach(e=>r.put(e)),await finished(n)}async list(e){return request((await this.database()).transaction(Tt,`readonly`).objectStore(Tt).index(Et).getAll(e))}},MemoryDrafts=class{records=new Map;failing=!1;async write(e,t){if(this.failing)throw Error(`the draft store is not available`);t.forEach(e=>this.records.delete(e)),e.forEach(e=>this.records.set(e.id,e))}async list(e){if(this.failing)throw Error(`the draft store is not available`);return[...this.records.values()].filter(t=>t.root===e)}};function pageLock(e){let t=null,take=()=>{if(!t)try{navigator.locks?.request(`${Dt}${e}`,()=>new Promise(e=>{t=e})).then(()=>{t=null})}catch{}};take(),typeof window<`u`&&(window.addEventListener(`pagehide`,()=>{t?.(),t=null}),window.addEventListener(`pageshow`,e=>{e.persisted&&take()}))}var livePages=async()=>{try{let e=(await navigator.locks?.query())?.held??[];return new Set(e.map(e=>e.name??``).filter(e=>e.startsWith(Dt)).map(e=>e.slice(14)))}catch{return new Set}},DraftJournal=class{backend;owner;delay;now;live;pending=new Map;timer=null;writing=Promise.resolve();failures=0;constructor(e,t){this.backend=e,this.owner=t.owner,this.delay=t.delayMs??Ot,this.now=t.now??Date.now,this.live=t.live??livePages}keep(e,t){let n=draftId(e,t.path);this.pending.set(n,{...t,id:n,root:e,owner:this.owner,savedAt:this.now()}),this.schedule()}drop(e,t){this.pending.set(draftId(e,t),null),this.schedule()}schedule(){this.timer||=setTimeout(()=>{this.timer=null,this.flush()},this.delay)}flush(){if(this.timer&&=(clearTimeout(this.timer),null),this.pending.size===0)return this.writing;let e=[...this.pending];this.pending.clear();let t=e.flatMap(([,e])=>e?[e]:[]),n=e.flatMap(([e,t])=>t?[]:[e]);return this.writing=this.writing.then(()=>this.backend.write(t,n)).catch(e=>{this.failures+=1,console.warn(`The unsaved changes could not be kept in this browser:`,e)}),this.writing}async orphans(e){await this.flush();let t;try{t=await this.backend.list(e)}catch(e){return console.warn(`The unsaved changes of the last session could not be read:`,e),[]}let n=await this.live();return t.filter(e=>e.owner!==this.owner&&!n.has(e.owner)&&typeof e.text==`string`&&e.text!==e.baseline).sort((e,t)=>t.savedAt-e.savedAt)}async discard(e){e.forEach(e=>this.pending.set(e.id,null)),await this.flush()}},ICON=e=>`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32" fill="none" stroke="#3574F0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><style>@media (prefers-color-scheme: dark){svg{stroke:#548AF7}}</style><circle cx="6" cy="16" r="3.5"/><rect x="13" y="11" width="8" height="10" rx="2"/><circle cx="27" cy="16" r="2.5" stroke-width="3"/><path d="M9.5 16h3.5M21 16h3.5"/>${e?`<circle cx="25" cy="25" r="6" fill="#E55765" stroke="none"/>`:``}</svg>`;function faviconHref(e){return`data:image/svg+xml,${encodeURIComponent(ICON(e))}`}function titleFor(e,t,n){let r=e?m(`app.web.title.document`,{name:e,project:t}):m(`app.web.title.project`,{project:t});return n?`● ${r}`:r}function ensureLink(e){let t=document.head.querySelector(`link[rel="${e}"][data-penstock]`);if(t)return t;let n=document.createElement(`link`);return n.rel=e,n.dataset.penstock=`true`,document.head.querySelectorAll(`link[rel="${e}"]`).forEach(e=>e.remove()),document.head.appendChild(n),n}function showFavicon(e){let t=ensureLink(`icon`);t.type=`image/svg+xml`;let n=faviconHref(e);t.getAttribute(`href`)!==n&&t.setAttribute(`href`,n)}function showTitle(e){document.title!==e&&(document.title=e)}function showThemeColour(){let e=document.head.querySelector(`meta[name="theme-color"]`);e||(e=document.createElement(`meta`),e.name=`theme-color`,document.head.appendChild(e));let t=getComputedStyle(document.documentElement).getPropertyValue(`--theme-bg-primary`).trim();t&&(e.content=t)}var kt=new Map,At=new Map;function focusSource(e,t){kt.set(e,t),At.get(e)?.forEach(e=>e(t))}function lineWanted(e){return kt.get(e)??null}function onSourceFocus(e,t){let n=At.get(e);return n||(n=new Set,At.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&At.delete(e)}}var jt=2e4,Workspace=class{store;scripts;revealers=new Map;waiting=new Map;constructor(e){this.store=e.store,this.scripts=e.scripts}async openScript(e){await this.openDiagram(e.diagramPath),await this.scripts.open(e.diagramPath,e)}activePath(){return this.store.snapshot().active}root(){return this.store.snapshot().listing.root}async refresh(){await this.store.refresh()}async openSource(e,t){let n=ze(`source`,e);focusSource(n,t??null),await this.store.open(n,`source`)}async openText(e){await this.store.open(ze(`text`,e),`template`)}async openDiagram(e){let t=this.store.snapshot().listing.files.find(t=>t.path===e);t||=(await this.store.refresh(),this.store.snapshot().listing.files.find(t=>t.path===e));let n=t?.kind??Ve(e);n===`bpmn`||n===`dmn`||n===`form`||n===`testCase`||n===`template`?await this.store.open(e,n):await this.openSource(e)}async openDiff(e){let t=ze(`diff`,e),n=m(`app.webHost.compare.tab`,{name:Le(e)});this.store.doc(t)?(this.store.activate(t),await this.store.reload(t)):await this.store.open(t,`diff`,n)}registerRevealer(e,t){this.revealers.set(e,t);let n=this.waiting.get(e);return n&&(clearTimeout(n.timer),this.waiting.delete(e),setTimeout(()=>this.deliver(e,n.elementId),0)),()=>{this.revealers.get(e)===t&&this.revealers.delete(e)}}async revealElement(e,t){if(await this.openDiagram(e),this.store.activate(e),this.revealers.has(e)){setTimeout(()=>this.deliver(e,t),0);return}let n=this.waiting.get(e);n&&clearTimeout(n.timer);let r=setTimeout(()=>this.waiting.delete(e),jt);this.waiting.set(e,{elementId:t,timer:r})}deliver(e,t){try{this.revealers.get(e)?.(t)}catch(e){console.error(`The element could not be revealed:`,e)}}},Mt=100;function slotKey(e){return`${e.elementId}\u0000${e.owner}\u0000${e.index}`}var ScriptSessions=class{byOwner=new Map;byId=new Map;editors;debounceMs;constructor(e,t=Mt){this.editors=e,this.debounceMs=t}async open(e,t,n,r,i,a=[]){let o=this.find(e,t);if(o){o.variables=a,await this.editors.focus(o.id);return}let s=await this.editors.open({title:i,language:n,text:r}),c={id:s,owner:e,slot:t,text:r,known:r,diagramText:null,variables:a,timer:void 0};this.sessionsOf(e).set(slotKey(t),c),this.byId.set(s,c),this.publish(e)}report(e,t,n){let r=this.find(e,t);r&&r.known!==n&&(n===r.text?(r.known=n,this.settle(r)):r.text===r.known?(r.known=n,r.text=n,this.editors.replace(r.id,n)):(r.diagramText=n,this.editors.conflict(r.id,n)))}changed(e,t){let n=this.byId.get(e);n&&(n.text=t,n.diagramText!==null&&t===n.diagramText?(n.known=t,this.settle(n)):this.schedule(n))}resolve(e,t){let n=this.byId.get(e);if(!n||n.diagramText===null)return;let r=n.diagramText;n.diagramText=null,this.editors.conflict(e,null),t===`tab`?this.schedule(n):(n.known=r,n.text=r,this.clearTimer(n),this.editors.replace(e,r))}contextOf(e){return this.byId.get(e)?.variables}ownerOf(e){return this.byId.get(e)?.owner}openSlots(e){return[...this.byOwner.get(e)?.values()??[]].map(e=>e.slot)}closed(e){let t=this.byId.get(e);t&&(this.clearTimer(t),this.flush(t),this.byId.delete(e),this.forget(t),this.publish(t.owner))}async closeAll(e){let t=this.byOwner.get(e);if(t){this.byOwner.delete(e);for(let e of t.values())this.clearTimer(e),this.byId.delete(e.id),await this.editors.close(e.id)}}find(e,t){return this.byOwner.get(e)?.get(slotKey(t))}sessionsOf(e){let t=this.byOwner.get(e);return t||(t=new Map,this.byOwner.set(e,t)),t}forget(e){let t=this.byOwner.get(e.owner);t&&(t.delete(slotKey(e.slot)),t.size===0&&this.byOwner.delete(e.owner))}settle(e){this.clearTimer(e),e.diagramText!==null&&(e.diagramText=null,this.editors.conflict(e.id,null))}schedule(e){this.clearTimer(e),e.timer=setTimeout(()=>this.flush(e),this.debounceMs)}clearTimer(e){e.timer!==void 0&&clearTimeout(e.timer),e.timer=void 0}flush(e){this.clearTimer(e),e.diagramText===null&&e.text!==e.known&&(e.known=e.text,e.owner.post({type:`scriptSlotChanged`,slot:e.slot,value:e.text}))}publish(e){e.post({type:`scriptTabsChanged`,slots:this.openSlots(e)})}},ScriptTabStore=class{state={tabs:[],focus:null};listeners=new Set;snapshot(){return this.state}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}add(e,t){let n={id:e,title:t.title,language:t.language,text:t.text,conflict:null,revision:0};this.publish({tabs:[...this.state.tabs,n],focus:e})}focus(e){this.state.focus!==e&&this.publish({...this.state,focus:e})}edit(e,t){this.state={...this.state,tabs:this.change(e,e=>({...e,text:t}))}}replace(e,t){this.publish({...this.state,tabs:this.change(e,e=>({...e,text:t,revision:e.revision+1}))})}setConflict(e,t){this.publish({...this.state,tabs:this.change(e,e=>({...e,conflict:t}))})}remove(e){let t=this.state.tabs.filter(t=>t.id!==e),n=this.state.focus===e?t.at(-1)?.id??null:this.state.focus;this.publish({tabs:t,focus:n})}change(e,t){return this.state.tabs.map(n=>n.id===e?t(n):n)}publish(e){this.state=e,this.listeners.forEach(e=>e())}},ScriptEditorsPort=class{tabs;serial=0;constructor(e){this.tabs=e}async open(e){this.serial+=1;let t=`script-${this.serial}`;return this.tabs.add(t,e),t}async focus(e){this.tabs.focus(e)}async close(e){this.tabs.remove(e)}replace(e,t){this.tabs.replace(e,t)}conflict(e,t){this.tabs.setConflict(e,t)}};function coreSlotOf(e){return{elementId:e.elementId,owner:e.owner,index:e.index}}function slotOf(e){return{elementId:e.elementId,owner:e.owner,index:e.index}}var ScriptHub=class{tabs=new ScriptTabStore;sessions;owners=new Map;diagrams=new Map;constructor(e){this.sessions=new ScriptSessions(new ScriptEditorsPort(this.tabs),e)}documentScripts(e){return{reportScriptSlot:async(t,n)=>this.sessions.report(this.ownerOf(e),coreSlotOf(t),n),connect:t=>(this.diagrams.set(e,t),t.setOpen(this.sessions.openSlots(this.ownerOf(e)).map(slotOf)),()=>{this.diagrams.get(e)===t&&this.diagrams.delete(e)})}}async open(e,t){await this.sessions.open(this.ownerOf(e),coreSlotOf(t.slot),t.language,t.text,t.title,t.variables)}changed(e,t){this.tabs.edit(e,t),this.sessions.changed(e,t)}resolve(e,t){this.sessions.resolve(e,t)}closed(e){this.sessions.closed(e),this.tabs.remove(e)}diagramOf(e){return this.sessions.ownerOf(e)?.diagram}history(e,t){let n=this.diagramOf(e);n&&this.diagrams.get(n)?.history(t)}contextOf(e){return this.sessions.contextOf(e)??[]}async closeDocument(e){this.diagrams.delete(e);let t=this.owners.get(e);t&&(this.owners.delete(e),await this.sessions.closeAll(t))}ownerOf(e){let t=this.owners.get(e);if(t)return t;let n={post:t=>this.deliver(e,t),diagram:e};return this.owners.set(e,n),n}deliver(e,t){let n=this.diagrams.get(e);n&&(t.type===`scriptTabsChanged`?n.setOpen(t.slots.map(slotOf)):n.applyHostWrite(slotOf(t.slot),t.value))}},Nt={bpmn:()=>y(()=>import(`./BpmnDocument-uifU3NGG.js`).then(e=>e.BpmnDocument),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48]),import.meta.url),dmn:()=>y(()=>import(`./DmnDocument-B8wWuhfX.js`).then(e=>e.DmnDocument),__vite__mapDeps([49,1,2,3,4,5,6,7,8,9,10,11,13,14,15,44,45,43,46,47,28,29,31,16,17,18,19,20,21,22,23,24,25,26,27,39,30,32,50,51]),import.meta.url),form:()=>y(()=>import(`./FormDocument-bQ5VRsrh.js`).then(e=>e.FormDocument),__vite__mapDeps([52,1,2,3,4,6,7,8,9,10,11,13,5,14,15,45,43,46,47,28,29,31,16,17,18,19,20,21,22,23,24,25,26,27,39,32,34,53,41,54,48,50,55]),import.meta.url),text:()=>y(()=>import(`./TextDocument-D8N0uaQa.js`).then(e=>e.TextDocument),__vite__mapDeps([56,1,2,3,4,57,22,18,35,23,24,25,58,59,6,7,8,9,10,11,13,5,14,15]),import.meta.url),code:()=>y(()=>import(`./SourceDocument-DgrNCprS.js`).then(e=>e.SourceDocument),__vite__mapDeps([60,1,2,3,4,57,22,18,35,23,24,25,58,59,6,7,8,9,10,11,13,5,14,15]),import.meta.url),diff:()=>y(()=>import(`./DiffDocument-BMTSevd7.js`).then(e=>e.DiffDocument),__vite__mapDeps([61,1,2,3,4,28,6,7,8,9,10,11,14]),import.meta.url)};function packComparison(e){return JSON.stringify(e)}function unpackComparison(e){try{let t=JSON.parse(e);return typeof t.after==`string`?{before:typeof t.before==`string`?t.before:null,after:t.after,against:typeof t.against==`string`?t.against:``}:null}catch{return null}}function bridgeHost(e,t=null,n=()=>null){return{list:()=>e.listProject?e.listProject():e.getProjectFiles(),read:async t=>{let r=Be(t);if(Ie(t)!==`diff`)return e.readFile(r);let[i,a]=await Promise.all([e.compareWithHead?.(r)??Promise.resolve({tracked:!1,before:null}),e.readFile(r)]);if(!i.tracked)throw Error(m(`app.webHost.compare.notTracked`));return packComparison({before:i.before,after:n(r)??a,against:`HEAD`})},write:async(n,r,i,a)=>{let o=i===`bpmn`?ee(r,t??``):r;return{stored:o,stamp:await e.saveProjectFile(Be(n),o,a)}},create:(t,n)=>e.createProjectFiles(t,n)}}function decodeHandle(e){let t=/^file:\/\/([^#]*)(?:#L(\d+))?$/.exec(e);if(!t)return null;let n;try{n=decodeURIComponent(t[1])}catch{return null}return/^\/[A-Za-z]:/.test(n)&&(n=n.slice(1)),n===``?null:{path:n,line:t[2]?Number(t[2]):1}}function decodeHandles(e){let t=new Set,n=[];for(let r of e){let e=decodeHandle(r);if(!e)continue;let i=`${e.path}#${e.line}`;t.has(i)||(t.add(i),n.push(e))}return n}function showInPage(e,t,n=document.body){return new Promise(r=>{let i=document.createElement(`div`);i.className=`web-dialog-host`,n.appendChild(i);let a=!1,finish=e=>{a||(a=!0,s(null,i),i.remove(),r(e))};try{s(l(Te,{locale:g(),children:e(finish)}),i)}catch(e){console.error(`A dialog could not be shown:`,e),finish(t)}})}function confirmInPage(e,t=document.body){return showInPage(t=>l(q,{title:e.title,size:`small`,destructive:e.warning,onClose:()=>t(!1),onSubmit:()=>t(!0),footer:l(Y,{actions:[{id:`decline`,label:e.decline,role:`cancel`,onClick:()=>t(!1)},{id:`accept`,label:e.accept,role:`primary`,onClick:()=>t(!0)}]}),children:l(`p`,{class:`type-body web-dialog-text`,children:e.text})}),!1,t)}function download(e,t){let n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=e,r.rel=`noopener`,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),3e4)}function safeExternalUrl(e){try{let t=new URL(e,window.location.href);return t.protocol===`http:`||t.protocol===`https:`||t.protocol===`mailto:`?t.href:null}catch{return null}}var Pt=`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./BpmnDocument-CuU0biX9.js","./rolldown-runtime-B8BYMn-z.js","./vendor-NJP34MHU.js","./translator-B2N3PQBL.js","./preload-helper-VRuDKI9K.js","./frontend-caI7mOAL.js","./bridgeInstance-DQk-c8L1.js","./dist-CRJyslwo.js","./dist-DgvQWhKm.js","./moddle-CGpeSs3G.js","./dist-BqwyxNP3.js","./engines-DU0BfbYM.js","./BpmnCanvas-Dw5zgCN3.js","./platform-CkWAyNst.js","./dialog-CtGB1LHI.js","./httpHost-Dqit__mm.js","./bpmnTheme-cOvp4qFc.js","./lib-DAKOOgix.js","./dist-CHluRwHI.js","./dist-TNwbKIWT.js","./Viewer-CZiVl0t6.js","./dist--PmHUHDp.js","./dist-CsBP6QjA.js","./dist-DvFyMwGd.js","./dist-Gx7P7Pk_.js","./dist-DUkRqvKl.js","./dist-BaEGn3tp.js","./dist-CAxViutc.js","./ui-3pEQJ50t.js","./preferences-nBrFGN89.js","./duplicate-DNPpPVse.js","./typing-CXvbBSPr.js","./dist-sl8LIbwu.js","./stackblur-es-Djj-lnDR.js","./array-move-Bc4mVEdq.js","./dist-Km3QNqlU.js","./groovy-DASguM_i.js","./dist-CnDXCEJ_.js","./apply-HqvoGwLE.js","./dockLayout-CxOMo-Nl.js","./samples-BVuIm-bu.js","./dist-CxyFqsL2.js","./syntax-DBcQvmbn.js","./testCaseRuns-DYKnccnc.js","./useTrace-BAXnn0Bt.js","./documentBridge-QW0IZ9Bq.js","./shortcut-DONH578b.js","./AgentSettings-C3Er_rlW.js","./formChecks-sU20kKkU.js","./DmnDocument-C8HpJAcE.js","./UnreadableFileLayer-D3G59F4u.js","./DmnDocument-DdjhA8he.css","./FormDocument-CH-4KB3x.js","./index.es-DqkfrvWI.js","./purify.es-DBLk-NVl.js","./FormDocument-URLcKn84.css","./TextDocument-0z7qojAh.js","./files-Chpd_QD0.js","./source-frame-q4WXS_Md.js","./intelligence-Ck_Q9upa.js","./SourceDocument-X8ajUcxM.js","./DiffDocument-Bh3hFmmi.js","./index.esm-CTLpq4ik.js","./diff-NgYeO98t.js","./ScriptPane-DDikZDv6.js","./NewFileDialog-j09JqpPj.js","./QuickOpen-CeBhsCzA.js","./ShortcutsDialog-DECqWPNE.js","./commands-nPznxvPp.js","./SettingsDialog-JUc5zUR9.js","./AgentsDialog-Bo7kikb6.js","./ConflictDialog-GxZ-d8SK.js","./UploadDialog-CiahYkTc.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e}from"./rolldown-runtime-B8BYMn-z.js";import{c as t,d as n,f as r,g as i,h as a,i as o,m as s,o as c,r as l,s as u,t as d,u as f}from"./vendor-NJP34MHU.js";import{c as p,i as m,l as h,n as g,o as _,r as v}from"./translator-B2N3PQBL.js";import{t as y}from"./preload-helper-VRuDKI9K.js";import{n as b,t as x,v as S,x as C}from"./frontend-caI7mOAL.js";import{Vt as w,X as T,Y as E,an as D,in as O,jt as k,r as A,t as j}from"./bridgeInstance-DQk-c8L1.js";import{d as M,g as N,p as P}from"./moddle-CGpeSs3G.js";import{Ct as F,n as I,t as L,wt as R}from"./BpmnCanvas-Dw5zgCN3.js";import{i as z,n as B,o as V,r as H,s as ee,t as U}from"./platform-CkWAyNst.js";import{u as te}from"./engines-DU0BfbYM.js";import{s as ne}from"./testCaseRuns-DYKnccnc.js";import{t as re}from"./shortcut-DONH578b.js";import{_ as ie,a as W,c as G,d as ae,f as oe,g as se,h as ce,i as le,l as ue,m as de,o as fe,p as pe,s as me,t as he,u as ge,v as _e}from"./AgentSettings-C3Er_rlW.js";import{t as ve}from"./typing-CXvbBSPr.js";import{a as K}from"./httpHost-Dqit__mm.js";import{A as ye}from"./bpmnTheme-cOvp4qFc.js";import{a as be,c as xe,f as q,g as Se,i as Ce,l as we,m as Te,n as J,o as Ee,p as Y,r as X,s as De,t as Oe,u as ke}from"./ui-3pEQJ50t.js";import{i as Z,n as Ae,o as je,r as Me,t as Ne}from"./preferences-nBrFGN89.js";import{a as Pe,d as Fe,f as Ie,i as Q,n as Le,o as Re,p as ze,r as Be,s as Ve,u as He}from"./files-Chpd_QD0.js";import{n as Ue,t as We}from"./documents-KeXEdK1U.js";import{Ln as Ge}from"./duplicate-DNPpPVse.js";import{I as Ke}from"./dist-CsBP6QjA.js";import{a as qe,o as Je}from"./dist-Gx7P7Pk_.js";import{a as Ye,i as Xe,o as Ze,r as Qe,t as $e}from"./dockLayout-CxOMo-Nl.js";import{a as et,c as tt,i as $,n as nt,o as rt,r as it,s as at}from"./commands-nPznxvPp.js";(function polyfill(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))processPreload(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&processPreload(e)}).observe(document,{childList:!0,subtree:!0});function getFetchOpts(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function processPreload(e){if(e.ep)return;e.ep=!0;let t=getFetchOpts(e);fetch(e.href,t)}})();function tabList(e){let t=e.map(e=>e.id),n=t.find((e,n)=>t.indexOf(e)!==n);if(n!==void 0)throw Error(`the tab ${n} is listed twice`);return e}function shownTab(e,t){return e.hidden||t&&e.collapsed?null:e.tab}function droppedTabs(e,t,n,r){let i=e.reduce((e,t)=>e+t.width,0);if(i<=n)return[];let a=i,o=[];for(let i=e.length-1;i>=0&&a+r>n;--i){let n=e[i];n.id!==t&&(o.unshift(n.id),a-=n.width)}return o}var ot=`properties`,st=280,ct=.3,lt=320,ut=480;function initialSidebar(){return{hidden:!1,tab:ot,width:null,collapsed:!1,stacks:{}}}function selectTab(e,t,n){return t.includes(n)?{...e,tab:n,hidden:!1,collapsed:!1}:e}function toggleHidden(e){return{...e,hidden:!e.hidden}}function toggleCollapsed(e){return{...e,collapsed:!e.collapsed}}function stackOf(e,t){return e.stacks&&Object.hasOwn(e.stacks,t)?e.stacks[t]:[]}function pushView(e,t,n){return{...e,stacks:{...e.stacks,[t]:[...stackOf(e,t),n]}}}function popView(e,t){return{...e,stacks:{...e.stacks,[t]:stackOf(e,t).slice(0,-1)}}}function resetViews(e,t){return{...e,stacks:{...e.stacks,[t]:[]}}}function defaultWidth(e){return Number.isFinite(e)?Math.min(ut,Math.max(lt,Math.round(e*ct))):lt}function widthLimits(e){return Number.isFinite(e)?{min:st,max:Math.max(st,Math.floor(e/2))}:{min:st,max:st}}function resolveWidth(e,t){let{min:n,max:r}=widthLimits(t),i=e!==null&&Number.isFinite(e)?e:defaultWidth(t);return Math.min(r,Math.max(n,i))}function isDrawer(e){return e<960}var isRecord=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function sidebarOf(e,t){let n=isRecord(e)?e.sidebarByEditor:void 0,r=isRecord(n)&&Object.hasOwn(n,t)?n[t]:void 0;return isRecord(r)?r:{}}function toPreferences(e,t,n={}){let r=isRecord(n)?n.sidebarByEditor:void 0,i=isRecord(r)?{...r}:{};return delete i[t],{sidebarWidth:e.width,sidebarByEditor:{...i,[t]:{tab:e.tab,hidden:e.hidden,collapsed:e.collapsed}}}}function fromPreferences(e,t,n){let r=sidebarOf(e,n),i=typeof r.tab==`string`&&t.includes(r.tab)?r.tab:t[0]??`properties`,a=isRecord(e)?e.sidebarWidth:void 0;return{...initialSidebar(),tab:i,width:typeof a==`number`&&Number.isFinite(a)?a:null,hidden:r.hidden===!0,collapsed:r.collapsed===!0}}function arrowTab(e,t,n){let r=e.indexOf(t);return r<0||e.length===0?null:n===`ArrowRight`?e[(r+1)%e.length]:n===`ArrowLeft`?e[(r-1+e.length)%e.length]:n===`Home`?e[0]:n===`End`?e[e.length-1]:null}function badgeText(e){return e?e>99?`99+`:String(e):``}function badgeLabel(e){return e?m(e>99?`app.sidebar.moreThan99Findings`:`app.sidebar.findingCount`,{count:e}):``}function isRepeatOfPress(e,t){return e!==null&&t-e<300}function isSidebarShortcut(e,t){return T(e,E,t)}function titleCommit(e,t){let n=t.trim();return n===``||n===e?null:n}function isRenameKey(e){return e===`F2`}var dt=`.bio-properties-panel, .dmn-decision-table-container`;function localisePanel(e){if(e.nodeType!==Node.ELEMENT_NODE)return;let t=e,n=t.closest(dt)===null?[...t.querySelectorAll(dt)]:[t];for(let e of n)F(e),e.querySelectorAll(`[title], [aria-label]`).forEach(F),e.querySelectorAll(`button`).forEach(R)}function translatePanelLabels(){localisePanel(document.body),new MutationObserver(e=>{for(let t of e)t.type===`attributes`?t.target.closest(dt)&&F(t.target):t.addedNodes.forEach(localisePanel)}).observe(document.body,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`title`,`aria-label`]})}function startupFailureMessage(e){if(e instanceof Error)return e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function StartupFailure({message:e}){return l(`div`,{class:`startup-failure`,role:`alert`,children:l(`div`,{class:`startup-failure__inner`,children:[l(De,{title:m(`app.startup.theEditorCouldNotStart`),hint:m(`app.startup.retryingReloadsTheEditorAnd`),actions:[{label:m(`app.common.retry`),run:()=>window.location.reload()}]}),l(`pre`,{class:`startup-failure__message`,children:e})]})})}function showStartupFailure(e,t){if(!e||typeof document>`u`)return;let n=document.createElement(`div`);e.replaceChildren(n),s(l(StartupFailure,{message:startupFailureMessage(t)}),n)}var ft=new Set([`properties`,`appliesTo`]);function isEmpty(e){return Array.isArray(e)?e.length===0:typeof e==`object`&&!!e&&Object.keys(e).length===0}function withoutNulls(e){return typeof e!=`object`||!e||Array.isArray(e)?e:Object.fromEntries(Object.entries(e).filter(([,e])=>e!=null))}function cleanTemplate(e){let t={};for(let[n,r]of Object.entries(e))r!=null&&(!isEmpty(r)||ft.has(n))&&(t[n]=n===`groups`&&Array.isArray(r)?r.map(withoutNulls):r);return t}function cleanTemplates(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e).map(cleanTemplate):[]}var pt=``+new URL(`colors-dark-C7vOziWz.css`,import.meta.url).href,mt=``+new URL(`colors-dracula-CXhMcc1Z.css`,import.meta.url).href,ht=``+new URL(`colors-light-CyT40N4M.css`,import.meta.url).href,gt={light:{isDark:!1},dark:{isDark:!0},dracula:{isDark:!0}},_t=`light`;function themeNameFor(e,t){let n=e?.toLowerCase();return n&&n in gt?n:t?`dark`:_t}function applyTheme(e){document.documentElement.setAttribute(`data-theme`,e);let t=document.createElement(`link`);return t.rel=`stylesheet`,t.href=new URL(Object.assign({"./colors-dark.css":pt,"./colors-dracula.css":mt,"./colors-light.css":ht})[`./colors-${e}.css`],import.meta.url).href,document.querySelectorAll(`link[data-theme-css]`).forEach(e=>e.remove()),t.setAttribute(`data-theme-css`,`true`),document.head.appendChild(t),t}function announceThemeApplied(e,t){let announce=()=>{window.dispatchEvent(new CustomEvent(`bpmn-theme-changed`,{detail:t}))},n=applyTheme(e);announce(),n.addEventListener(`load`,announce,{once:!0})}function getCurrentTheme(){let e=document.documentElement.getAttribute(`data-theme`);return e&&e in gt?e:_t}function toggleDarkMode(){let e=gt[getCurrentTheme()].isDark?`light`:`dark`;return applyTheme(e),e}var vt=`--theme-bg-primary.--theme-bg-secondary.--theme-bg-sidebar.--theme-bg-tertiary.--theme-bg-input.--theme-bg-hover.--theme-bg-hover-strong.--theme-bg-pressed.--theme-bg-selected.--theme-bg-selected-muted.--theme-bg-selected-inactive.--theme-fg-primary.--theme-fg-selected.--theme-fg-secondary.--theme-fg-tertiary.--theme-fg-disabled.--theme-fg-on-accent.--theme-fg-code.--theme-border-primary.--theme-border-secondary.--theme-border-light.--theme-border-strong.--theme-separator.--theme-accent-primary.--theme-accent-hover.--theme-accent-pressed.--theme-accent-subtle.--theme-accent-solid.--theme-accent-solid-hover.--theme-accent-solid-pressed.--theme-on-accent.--theme-icon-default.--theme-icon-muted.--theme-icon-on-accent.--theme-link.--theme-link-hover.--theme-focus-ring.--theme-success.--theme-warning.--theme-error.--theme-error-subtle.--theme-error-subtle-alt.--theme-error-border.--theme-error-dark.--theme-error-critical.--theme-success-subtle.--theme-success-border.--theme-warning-subtle.--theme-warning-border.--theme-badge-bg.--theme-badge-fg.--theme-grid-pattern.--theme-lasso.--theme-white.--theme-white-subtle.--theme-black.--theme-black-subtle-10.--theme-black-subtle-30.--theme-scrim.--theme-shadow-float.--theme-shadow-popup.--theme-shadow-low.--theme-shadow-hairline.--theme-shadow-dialog.--type-size-body.--type-size-small.--type-size-tiny`.split(`.`),yt=/^#[0-9a-f]{6}([0-9a-f]{2})?$/i;function applyIdeTheme(e){clearIdeTheme();let t=new Set(vt),n=document.documentElement,r=e.tokens,i=0;for(let e of Object.keys(r??{})){let a=r[e];t.has(e)&&typeof a==`string`&&yt.test(a)&&(n.style.setProperty(e,a),i+=1)}return i}function clearIdeTheme(){let e=document.documentElement;for(let t of vt)e.style.removeProperty(t)}var bt=[`ide`,`light`,`dark`,`dracula`],xt=null,St=null,Ct=null;function themeChoiceOf(e){return typeof e==`string`&&e!==`ide`&&e in gt?e:`ide`}function currentThemeChoice(){return themeChoiceOf(Z()?.theme)}function nameOf$1(e){let t=e?.toLowerCase();return t&&t in gt?t:null}e(nameOf$1,`nameOf`);function announce(e,t){announceThemeApplied(e,{theme:t});let n=window.appConfig;n&&(n.theme=t)}function showHostTheme(){document.documentElement.removeAttribute(`data-theme-choice`),clearIdeTheme(),xt&&applyIdeTheme(xt);let e=nameOf$1(xt?.theme)??St;e?announce(e,e):window.dispatchEvent(new CustomEvent(`bpmn-theme-changed`,{detail:{theme:null}}))}function applyThemeChoice(){let e=currentThemeChoice();Ct=e,e===`ide`?showHostTheme():(clearIdeTheme(),document.documentElement.setAttribute(`data-theme-choice`,e),announce(e,e))}function chooseTheme(e){je({theme:e}),applyThemeChoice()}function rememberHostTheme(e){St=e}function receiveHostThemeName(e){let t=nameOf$1(e);t?(St=t,xt=null,currentThemeChoice()===`ide`&&(clearIdeTheme(),announce(t,e))):console.warn(`[Theme] Ignoring unknown theme from window.setTheme:`,e)}function followThemeChoice(){return Me(()=>{currentThemeChoice()!==Ct&&applyThemeChoice()})}var wt=`penstock-web`,Tt=`drafts`,Et=`root`,Dt=`penstock-page:`,Ot=250;function draftId(e,t){return`${e}\n${t}`}function request(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error??Error(`IndexedDB request failed`))})}function finished(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error??Error(`IndexedDB transaction failed`)),e.onabort=()=>n(e.error??Error(`IndexedDB transaction aborted`))})}var IndexedDbDrafts=class{opened=null;database(){return this.opened??=new Promise((e,t)=>{let n=indexedDB.open(wt,1);n.onupgradeneeded=()=>{n.result.createObjectStore(Tt,{keyPath:`id`}).createIndex(Et,`root`)},n.onsuccess=()=>{let t=n.result;t.onversionchange=()=>{t.close(),this.opened=null},e(t)},n.onerror=()=>t(n.error??Error(`IndexedDB did not open`)),n.onblocked=()=>t(Error(`IndexedDB is blocked`))}).catch(e=>{throw this.opened=null,e}),this.opened}async write(e,t){let n=(await this.database()).transaction(Tt,`readwrite`),r=n.objectStore(Tt);t.forEach(e=>r.delete(e)),e.forEach(e=>r.put(e)),await finished(n)}async list(e){return request((await this.database()).transaction(Tt,`readonly`).objectStore(Tt).index(Et).getAll(e))}},MemoryDrafts=class{records=new Map;failing=!1;async write(e,t){if(this.failing)throw Error(`the draft store is not available`);t.forEach(e=>this.records.delete(e)),e.forEach(e=>this.records.set(e.id,e))}async list(e){if(this.failing)throw Error(`the draft store is not available`);return[...this.records.values()].filter(t=>t.root===e)}};function pageLock(e){let t=null,take=()=>{if(!t)try{navigator.locks?.request(`${Dt}${e}`,()=>new Promise(e=>{t=e})).then(()=>{t=null})}catch{}};take(),typeof window<`u`&&(window.addEventListener(`pagehide`,()=>{t?.(),t=null}),window.addEventListener(`pageshow`,e=>{e.persisted&&take()}))}var livePages=async()=>{try{let e=(await navigator.locks?.query())?.held??[];return new Set(e.map(e=>e.name??``).filter(e=>e.startsWith(Dt)).map(e=>e.slice(14)))}catch{return new Set}},DraftJournal=class{backend;owner;delay;now;live;pending=new Map;timer=null;writing=Promise.resolve();failures=0;constructor(e,t){this.backend=e,this.owner=t.owner,this.delay=t.delayMs??Ot,this.now=t.now??Date.now,this.live=t.live??livePages}keep(e,t){let n=draftId(e,t.path);this.pending.set(n,{...t,id:n,root:e,owner:this.owner,savedAt:this.now()}),this.schedule()}drop(e,t){this.pending.set(draftId(e,t),null),this.schedule()}schedule(){this.timer||=setTimeout(()=>{this.timer=null,this.flush()},this.delay)}flush(){if(this.timer&&=(clearTimeout(this.timer),null),this.pending.size===0)return this.writing;let e=[...this.pending];this.pending.clear();let t=e.flatMap(([,e])=>e?[e]:[]),n=e.flatMap(([e,t])=>t?[]:[e]);return this.writing=this.writing.then(()=>this.backend.write(t,n)).catch(e=>{this.failures+=1,console.warn(`The unsaved changes could not be kept in this browser:`,e)}),this.writing}async orphans(e){await this.flush();let t;try{t=await this.backend.list(e)}catch(e){return console.warn(`The unsaved changes of the last session could not be read:`,e),[]}let n=await this.live();return t.filter(e=>e.owner!==this.owner&&!n.has(e.owner)&&typeof e.text==`string`&&e.text!==e.baseline).sort((e,t)=>t.savedAt-e.savedAt)}async discard(e){e.forEach(e=>this.pending.set(e.id,null)),await this.flush()}},ICON=e=>`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32" fill="none" stroke="#3574F0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><style>@media (prefers-color-scheme: dark){svg{stroke:#548AF7}}</style><circle cx="6" cy="16" r="3.5"/><rect x="13" y="11" width="8" height="10" rx="2"/><circle cx="27" cy="16" r="2.5" stroke-width="3"/><path d="M9.5 16h3.5M21 16h3.5"/>${e?`<circle cx="25" cy="25" r="6" fill="#E55765" stroke="none"/>`:``}</svg>`;function faviconHref(e){return`data:image/svg+xml,${encodeURIComponent(ICON(e))}`}function titleFor(e,t,n){let r=e?m(`app.web.title.document`,{name:e,project:t}):m(`app.web.title.project`,{project:t});return n?`● ${r}`:r}function ensureLink(e){let t=document.head.querySelector(`link[rel="${e}"][data-penstock]`);if(t)return t;let n=document.createElement(`link`);return n.rel=e,n.dataset.penstock=`true`,document.head.querySelectorAll(`link[rel="${e}"]`).forEach(e=>e.remove()),document.head.appendChild(n),n}function showFavicon(e){let t=ensureLink(`icon`);t.type=`image/svg+xml`;let n=faviconHref(e);t.getAttribute(`href`)!==n&&t.setAttribute(`href`,n)}function showTitle(e){document.title!==e&&(document.title=e)}function showThemeColour(){let e=document.head.querySelector(`meta[name="theme-color"]`);e||(e=document.createElement(`meta`),e.name=`theme-color`,document.head.appendChild(e));let t=getComputedStyle(document.documentElement).getPropertyValue(`--theme-bg-primary`).trim();t&&(e.content=t)}var kt=new Map,At=new Map;function focusSource(e,t){kt.set(e,t),At.get(e)?.forEach(e=>e(t))}function lineWanted(e){return kt.get(e)??null}function onSourceFocus(e,t){let n=At.get(e);return n||(n=new Set,At.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&At.delete(e)}}var jt=2e4,Workspace=class{store;scripts;revealers=new Map;waiting=new Map;constructor(e){this.store=e.store,this.scripts=e.scripts}async openScript(e){await this.openDiagram(e.diagramPath),await this.scripts.open(e.diagramPath,e)}activePath(){return this.store.snapshot().active}root(){return this.store.snapshot().listing.root}async refresh(){await this.store.refresh()}async openSource(e,t){let n=ze(`source`,e);focusSource(n,t??null),await this.store.open(n,`source`)}async openText(e){await this.store.open(ze(`text`,e),`template`)}async openDiagram(e){let t=this.store.snapshot().listing.files.find(t=>t.path===e);t||=(await this.store.refresh(),this.store.snapshot().listing.files.find(t=>t.path===e));let n=t?.kind??Ve(e);n===`bpmn`||n===`dmn`||n===`form`||n===`testCase`||n===`template`?await this.store.open(e,n):await this.openSource(e)}async openDiff(e){let t=ze(`diff`,e),n=m(`app.webHost.compare.tab`,{name:Le(e)});this.store.doc(t)?(this.store.activate(t),await this.store.reload(t)):await this.store.open(t,`diff`,n)}registerRevealer(e,t){this.revealers.set(e,t);let n=this.waiting.get(e);return n&&(clearTimeout(n.timer),this.waiting.delete(e),setTimeout(()=>this.deliver(e,n.elementId),0)),()=>{this.revealers.get(e)===t&&this.revealers.delete(e)}}async revealElement(e,t){if(await this.openDiagram(e),this.store.activate(e),this.revealers.has(e)){setTimeout(()=>this.deliver(e,t),0);return}let n=this.waiting.get(e);n&&clearTimeout(n.timer);let r=setTimeout(()=>this.waiting.delete(e),jt);this.waiting.set(e,{elementId:t,timer:r})}deliver(e,t){try{this.revealers.get(e)?.(t)}catch(e){console.error(`The element could not be revealed:`,e)}}},Mt=100;function slotKey(e){return`${e.elementId}\u0000${e.owner}\u0000${e.index}`}var ScriptSessions=class{byOwner=new Map;byId=new Map;editors;debounceMs;constructor(e,t=Mt){this.editors=e,this.debounceMs=t}async open(e,t,n,r,i,a=[]){let o=this.find(e,t);if(o){o.variables=a,await this.editors.focus(o.id);return}let s=await this.editors.open({title:i,language:n,text:r}),c={id:s,owner:e,slot:t,text:r,known:r,diagramText:null,variables:a,timer:void 0};this.sessionsOf(e).set(slotKey(t),c),this.byId.set(s,c),this.publish(e)}report(e,t,n){let r=this.find(e,t);r&&r.known!==n&&(n===r.text?(r.known=n,this.settle(r)):r.text===r.known?(r.known=n,r.text=n,this.editors.replace(r.id,n)):(r.diagramText=n,this.editors.conflict(r.id,n)))}changed(e,t){let n=this.byId.get(e);n&&(n.text=t,n.diagramText!==null&&t===n.diagramText?(n.known=t,this.settle(n)):this.schedule(n))}resolve(e,t){let n=this.byId.get(e);if(!n||n.diagramText===null)return;let r=n.diagramText;n.diagramText=null,this.editors.conflict(e,null),t===`tab`?this.schedule(n):(n.known=r,n.text=r,this.clearTimer(n),this.editors.replace(e,r))}contextOf(e){return this.byId.get(e)?.variables}ownerOf(e){return this.byId.get(e)?.owner}openSlots(e){return[...this.byOwner.get(e)?.values()??[]].map(e=>e.slot)}closed(e){let t=this.byId.get(e);t&&(this.clearTimer(t),this.flush(t),this.byId.delete(e),this.forget(t),this.publish(t.owner))}async closeAll(e){let t=this.byOwner.get(e);if(t){this.byOwner.delete(e);for(let e of t.values())this.clearTimer(e),this.byId.delete(e.id),await this.editors.close(e.id)}}find(e,t){return this.byOwner.get(e)?.get(slotKey(t))}sessionsOf(e){let t=this.byOwner.get(e);return t||(t=new Map,this.byOwner.set(e,t)),t}forget(e){let t=this.byOwner.get(e.owner);t&&(t.delete(slotKey(e.slot)),t.size===0&&this.byOwner.delete(e.owner))}settle(e){this.clearTimer(e),e.diagramText!==null&&(e.diagramText=null,this.editors.conflict(e.id,null))}schedule(e){this.clearTimer(e),e.timer=setTimeout(()=>this.flush(e),this.debounceMs)}clearTimer(e){e.timer!==void 0&&clearTimeout(e.timer),e.timer=void 0}flush(e){this.clearTimer(e),e.diagramText===null&&e.text!==e.known&&(e.known=e.text,e.owner.post({type:`scriptSlotChanged`,slot:e.slot,value:e.text}))}publish(e){e.post({type:`scriptTabsChanged`,slots:this.openSlots(e)})}},ScriptTabStore=class{state={tabs:[],focus:null};listeners=new Set;snapshot(){return this.state}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}add(e,t){let n={id:e,title:t.title,language:t.language,text:t.text,conflict:null,revision:0};this.publish({tabs:[...this.state.tabs,n],focus:e})}focus(e){this.state.focus!==e&&this.publish({...this.state,focus:e})}edit(e,t){this.state={...this.state,tabs:this.change(e,e=>({...e,text:t}))}}replace(e,t){this.publish({...this.state,tabs:this.change(e,e=>({...e,text:t,revision:e.revision+1}))})}setConflict(e,t){this.publish({...this.state,tabs:this.change(e,e=>({...e,conflict:t}))})}remove(e){let t=this.state.tabs.filter(t=>t.id!==e),n=this.state.focus===e?t.at(-1)?.id??null:this.state.focus;this.publish({tabs:t,focus:n})}change(e,t){return this.state.tabs.map(n=>n.id===e?t(n):n)}publish(e){this.state=e,this.listeners.forEach(e=>e())}},ScriptEditorsPort=class{tabs;serial=0;constructor(e){this.tabs=e}async open(e){this.serial+=1;let t=`script-${this.serial}`;return this.tabs.add(t,e),t}async focus(e){this.tabs.focus(e)}async close(e){this.tabs.remove(e)}replace(e,t){this.tabs.replace(e,t)}conflict(e,t){this.tabs.setConflict(e,t)}};function coreSlotOf(e){return{elementId:e.elementId,owner:e.owner,index:e.index}}function slotOf(e){return{elementId:e.elementId,owner:e.owner,index:e.index}}var ScriptHub=class{tabs=new ScriptTabStore;sessions;owners=new Map;diagrams=new Map;constructor(e){this.sessions=new ScriptSessions(new ScriptEditorsPort(this.tabs),e)}documentScripts(e){return{reportScriptSlot:async(t,n)=>this.sessions.report(this.ownerOf(e),coreSlotOf(t),n),connect:t=>(this.diagrams.set(e,t),t.setOpen(this.sessions.openSlots(this.ownerOf(e)).map(slotOf)),()=>{this.diagrams.get(e)===t&&this.diagrams.delete(e)})}}async open(e,t){await this.sessions.open(this.ownerOf(e),coreSlotOf(t.slot),t.language,t.text,t.title,t.variables)}changed(e,t){this.tabs.edit(e,t),this.sessions.changed(e,t)}resolve(e,t){this.sessions.resolve(e,t)}closed(e){this.sessions.closed(e),this.tabs.remove(e)}diagramOf(e){return this.sessions.ownerOf(e)?.diagram}history(e,t){let n=this.diagramOf(e);n&&this.diagrams.get(n)?.history(t)}contextOf(e){return this.sessions.contextOf(e)??[]}async closeDocument(e){this.diagrams.delete(e);let t=this.owners.get(e);t&&(this.owners.delete(e),await this.sessions.closeAll(t))}ownerOf(e){let t=this.owners.get(e);if(t)return t;let n={post:t=>this.deliver(e,t),diagram:e};return this.owners.set(e,n),n}deliver(e,t){let n=this.diagrams.get(e);n&&(t.type===`scriptTabsChanged`?n.setOpen(t.slots.map(slotOf)):n.applyHostWrite(slotOf(t.slot),t.value))}},Nt={bpmn:()=>y(()=>import(`./BpmnDocument-CuU0biX9.js`).then(e=>e.BpmnDocument),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48]),import.meta.url),dmn:()=>y(()=>import(`./DmnDocument-C8HpJAcE.js`).then(e=>e.DmnDocument),__vite__mapDeps([49,1,2,3,4,5,6,7,8,9,10,11,13,14,15,44,45,43,46,47,28,29,31,16,17,18,19,20,21,22,23,24,25,26,27,39,30,32,50,51]),import.meta.url),form:()=>y(()=>import(`./FormDocument-CH-4KB3x.js`).then(e=>e.FormDocument),__vite__mapDeps([52,1,2,3,4,6,7,8,9,10,11,13,5,14,15,45,43,46,47,28,29,31,16,17,18,19,20,21,22,23,24,25,26,27,39,32,34,53,41,54,48,50,55]),import.meta.url),text:()=>y(()=>import(`./TextDocument-0z7qojAh.js`).then(e=>e.TextDocument),__vite__mapDeps([56,1,2,3,4,57,22,18,35,23,24,25,58,59,6,7,8,9,10,11,13,5,14,15]),import.meta.url),code:()=>y(()=>import(`./SourceDocument-X8ajUcxM.js`).then(e=>e.SourceDocument),__vite__mapDeps([60,1,2,3,4,57,22,18,35,23,24,25,58,59,6,7,8,9,10,11,13,5,14,15]),import.meta.url),diff:()=>y(()=>import(`./DiffDocument-Bh3hFmmi.js`).then(e=>e.DiffDocument),__vite__mapDeps([61,1,2,3,4,28,6,7,8,9,10,11,14]),import.meta.url)};function packComparison(e){return JSON.stringify(e)}function unpackComparison(e){try{let t=JSON.parse(e);return typeof t.after==`string`?{before:typeof t.before==`string`?t.before:null,after:t.after,against:typeof t.against==`string`?t.against:``}:null}catch{return null}}function bridgeHost(e,t=null,n=()=>null){return{list:()=>e.listProject?e.listProject():e.getProjectFiles(),read:async t=>{let r=Be(t);if(Ie(t)!==`diff`)return e.readFile(r);let[i,a]=await Promise.all([e.compareWithHead?.(r)??Promise.resolve({tracked:!1,before:null}),e.readFile(r)]);if(!i.tracked)throw Error(m(`app.webHost.compare.notTracked`));return packComparison({before:i.before,after:n(r)??a,against:`HEAD`})},write:async(n,r,i,a)=>{let o=i===`bpmn`?ee(r,t??``):r;return{stored:o,stamp:await e.saveProjectFile(Be(n),o,a)}},create:(t,n)=>e.createProjectFiles(t,n)}}function decodeHandle(e){let t=/^file:\/\/([^#]*)(?:#L(\d+))?$/.exec(e);if(!t)return null;let n;try{n=decodeURIComponent(t[1])}catch{return null}return/^\/[A-Za-z]:/.test(n)&&(n=n.slice(1)),n===``?null:{path:n,line:t[2]?Number(t[2]):1}}function decodeHandles(e){let t=new Set,n=[];for(let r of e){let e=decodeHandle(r);if(!e)continue;let i=`${e.path}#${e.line}`;t.has(i)||(t.add(i),n.push(e))}return n}function showInPage(e,t,n=document.body){return new Promise(r=>{let i=document.createElement(`div`);i.className=`web-dialog-host`,n.appendChild(i);let a=!1,finish=e=>{a||(a=!0,s(null,i),i.remove(),r(e))};try{s(l(Te,{locale:g(),children:e(finish)}),i)}catch(e){console.error(`A dialog could not be shown:`,e),finish(t)}})}function confirmInPage(e,t=document.body){return showInPage(t=>l(q,{title:e.title,size:`small`,destructive:e.warning,onClose:()=>t(!1),onSubmit:()=>t(!0),footer:l(Y,{actions:[{id:`decline`,label:e.decline,role:`cancel`,onClick:()=>t(!1)},{id:`accept`,label:e.accept,role:`primary`,onClick:()=>t(!0)}]}),children:l(`p`,{class:`type-body web-dialog-text`,children:e.text})}),!1,t)}function download(e,t){let n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=e,r.rel=`noopener`,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),3e4)}function safeExternalUrl(e){try{let t=new URL(e,window.location.href);return t.protocol===`http:`||t.protocol===`https:`||t.protocol===`mailto:`?t.href:null}catch{return null}}var Pt=`
|
|
3
3
|
.bpmn-preview {
|
|
4
4
|
display: flex;
|
|
5
5
|
flex-direction: column;
|
|
@@ -140,9 +140,9 @@ import{i as e}from"./rolldown-runtime-B8BYMn-z.js";import{c as t,d as n,f as r,g
|
|
|
140
140
|
`),open:!1}),o=null):o.body.push(e);continue}let t=Mn.exec(e);if(t){endParagraph(),endList(),o={mark:t[1],lang:t[2],body:[]};continue}if(e.trim()===``){endParagraph(),endList();continue}let n=Nn.exec(e);if(n){endParagraph(),endList(),r.push({kind:`heading`,level:n[1].length,children:inlines(n[2])});continue}let s=Pn.exec(e),c=s?null:Fn.exec(e);if(s||c){endParagraph();let e=!!c;a.list&&a.list.ordered===e||(a.list={kind:`list`,ordered:e,start:c?Number(c[2]):1,items:[]},r.push(a.list)),a.list.items.push({depth:indentOf((s??c)[1]),children:inlines(s?s[2]:c[3])})}else if(a.list&&/^\s+\S/.test(e)&&a.list.items.length>0){let t=a.list.items[a.list.items.length-1];t.children=[...t.children,{kind:`text`,text:` `},...inlines(e.trim())]}else endList(),i.push(e)}return o&&r.push({kind:`code`,lang:o.lang,text:o.body.join(`
|
|
141
141
|
`),open:!0}),endParagraph(),{blocks:r,truncated:t}}var Hn=/\.bpmn(\.xml)?$/i;function reasonOf(e,t,n){return e===`file`?m(`app.assistant.chip.noFile`,{file:n}):m(`app.assistant.chip.noElement`,{id:t,file:n})}function InertChip({id:e,path:t,reason:n}){return l(`span`,{class:`element-chip element-chip--inert type-body`,title:`${t}#${e}`,"aria-busy":n===`loading`?`true`:void 0,children:[l(`span`,{class:`element-chip__icon bpmn-icon-task`,"aria-hidden":`true`}),l(`span`,{class:`element-chip__name`,children:e}),n!==`loading`&&l(`span`,{class:`element-chip__note type-help`,children:reasonOf(n,e,t)})]})}function ElementReference({reference:e,label:t}){let n=useLinks(),r=e.id,i=useFile(e.path),a=Hn.test(e.path),o=useElementFacts(e.path,r);return i?a&&o.state===`found`?l(ElementChip,{id:r,type:o.facts.type,name:t??o.facts.name,onSelect:()=>n.openElement(i.rel,r),onHover:(e,t)=>n.highlight?.(i.rel,e,t)}):a&&o.state===`loading`?l(InertChip,{id:r,path:e.path,reason:`loading`}):a?l(InertChip,{id:r,path:e.path,reason:`element`}):l(FileChip,{name:t??`${baseOf(i.rel)}#${r}`,kind:i.kind,title:`${i.rel}#${r}`,onOpen:()=>n.openFile(i.rel)}):l(InertChip,{id:r,path:e.path,reason:`file`})}function baseOf(e){return e.split(`/`).pop()??e}function FileReference({reference:e,label:t,raw:n,code:r}){let i=useLinks(),o=useFile(e.path);if(!o)return r?l(`code`,{class:`agent-code type-code`,children:n}):l(a,{children:n});let s=o.kind===`bpmn`||o.kind===`dmn`||o.kind===`form`,c=s?null:e.line,u=t??n,d=c===null?m(`app.assistant.openFile`,{path:o.rel}):m(`app.assistant.openAtLine`,{path:o.rel,line:c});return l(FileChip,{name:u,kind:o.kind,title:d,onOpen:()=>c!==null||!s?i.openCode(o.rel,c):i.openFile(o.rel)})}var Un=/"([^"\n]{2,80})"|“([^”\n]{2,80})”|«([^»\n]{2,80})»/g;function isNamed(e,t){return!!e.named?.(t)||!!e.scenario?.(t)}function NamedChip({name:e}){let t=useLinks(),n=t.named?.(e);if(n)return l(ElementChip,{id:n.id,type:n.type,name:n.name,onSelect:e=>{t.openElement(n.file,e),t.flash?.(n.file,[e])},onHover:(e,r)=>t.highlight?.(n.file,e,r)});let r=t.scenario?.(e);return r?l(ScenarioChip,{name:e,onOpen:()=>t.openScenario?.(r.file,r.name)}):null}function QuotedText({text:e}){let t=useLinks();useLinkUpdates();let n=[],r=0;for(let i of e.matchAll(Un)){let a=i[1]??i[2]??i[3];if(!isNamed(t,a))continue;let o=i.index??0;o>r&&n.push(l(`span`,{children:e.slice(r,o)},`t${o}`)),n.push(l(NamedChip,{name:a},`c${o}`)),r=o+i[0].length}return n.length===0?l(a,{children:e}):(r<e.length&&n.push(l(`span`,{children:e.slice(r)},`end`)),l(a,{children:n}))}function NamedText({text:e}){let t=useLinks();return!t.named&&!t.scenario||!e.includes(`"`)&&!e.includes(`“`)&&!e.includes(`«`)?l(a,{children:e}):l(QuotedText,{text:e})}function NamedCode({text:e}){let t=useLinks();return useLinkUpdates(),isNamed(t,e)?l(NamedChip,{name:e}):l(`code`,{class:`agent-code type-code`,children:e})}function InlineView({item:e}){switch(e.kind){case`text`:return l(NamedText,{text:e.text});case`code`:return e.reference?e.reference.id===null?l(FileReference,{reference:e.reference,raw:e.text,code:!0}):l(ElementReference,{reference:e.reference}):l(NamedCode,{text:e.text});case`strong`:return l(`strong`,{class:`agent-strong`,children:e.children.map((e,t)=>l(InlineView,{item:e},t))});case`emphasis`:return l(`em`,{class:`agent-emphasis`,children:e.children.map((e,t)=>l(InlineView,{item:e},t))});case`link`:return l(`a`,{class:`agent-link type-body`,href:e.href,target:`_blank`,rel:`noopener noreferrer`,children:e.label});case`reference`:return e.reference.id===null?l(FileReference,{reference:e.reference,label:e.label,raw:e.raw}):l(ElementReference,{reference:e.reference,label:e.label})}}function idReference(e){return e?(e.kind===`reference`||e.kind===`code`&&!!e.reference)&&e.reference.id!==null:!1}function plainOf(e){return e.map(e=>e.kind===`text`?e.text:e.kind===`strong`||e.kind===`emphasis`?plainOf(e.children):``).join(``)}function segmentsOf(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e[n];if(!idReference(r)){t.push({kind:`item`,item:r});continue}let i=e[n+1],a=``,o=!1,s=``,c=t[t.length-1];if(c?.kind===`item`&&c.item.kind===`text`){let e=/\(\s*$/.exec(c.item.text);e&&i?.kind===`text`&&/^\s*\)/.test(i.text)?(o=!0,a=c.item.text.slice(0,e.index)):a=c.item.text,t.pop()}let l=null,u=t[t.length-1];a.trim()===``&&u?.kind===`item`&&(u.item.kind===`strong`||u.item.kind===`emphasis`)&&(l=u.item,t.pop()),o&&i?.kind===`text`&&(s=i.text.replace(/^\s*\)/,``),n+=1),t.push({kind:`echo`,bearer:l,head:a,ref:r,paren:o,tail:s})}return t}function sameName(e,t){return e.trim().toLocaleLowerCase()===t.trim().toLocaleLowerCase()}function EchoedReference({segment:e}){let{ref:t,bearer:n,head:r,paren:i,tail:o}=e,s=t.reference,c=useElementFacts(s.path,s.id),u=(t.kind===`reference`?t.label:void 0)??(c.state===`found`?c.facts.name:void 0),d=!!u&&!!n&&sameName(plainOf([n]),u),f=r.trimEnd(),p=!!u&&!d&&f.length>=u.length&&sameName(f.slice(f.length-u.length),u)&&!(f.length>u.length&&Wn.test(f[f.length-u.length-1]));return d||p?l(a,{children:[p?f.slice(0,f.length-u.length):r,l(InlineView,{item:t}),o]}):l(a,{children:[n&&l(InlineView,{item:n}),r,i&&`(`,l(InlineView,{item:t}),i&&`)`,o]})}var Wn=/[\p{L}\p{N}_]/u;function Inlines({items:e}){return l(a,{children:segmentsOf(e).map((e,t)=>e.kind===`item`?l(InlineView,{item:e.item},t):l(EchoedReference,{segment:e},t))})}function BlockView({block:e,code:t}){switch(e.kind){case`paragraph`:return l(`p`,{class:`assistant-rich__text type-body`,children:l(Inlines,{items:e.children})});case`heading`:return l(`p`,{class:`assistant-rich__text assistant-rich__heading type-body`,children:l(Inlines,{items:e.children})});case`list`:{let t=e.ordered?`ol`:`ul`;return l(t,{class:`assistant-rich__list type-body`,start:e.ordered&&e.start!==1?e.start:void 0,children:e.items.map((e,t)=>l(`li`,{class:`assistant-rich__item is-depth-${e.depth}`,children:l(Inlines,{items:e.children})},t))})}case`code`:return t?t({text:e.text,lang:e.lang}):l(`pre`,{class:`assistant-rich__code type-code`,"data-lang":e.lang||void 0,children:e.text})}}function RichText({text:e,code:t}){let n=c(()=>parseMarkdown(e),[e]);return l(a,{children:[n.blocks.map((e,n)=>l(BlockView,{block:e,code:t},n)),n.truncated&&l(`p`,{class:`assistant-rich__text type-help`,children:m(`app.assistant.truncated`)})]})}var Gn=16,Kn=120,qn=60;function unionOf(e){if(e.length===0)return{x:0,y:0,width:Kn,height:qn};let t=Math.min(...e.map(e=>e.x))-Gn,n=Math.min(...e.map(e=>e.y))-Gn,r=Math.max(...e.map(e=>e.x+e.width))+Gn,i=Math.max(...e.map(e=>e.y+e.height))+Gn,a=Math.max(Kn,r-t),o=Math.max(qn,i-n);return{x:t-(a-(r-t))/2,y:n-(o-(i-n))/2,width:a,height:o}}function boxOfPoints(e){let t=e.map(e=>e.x),n=e.map(e=>e.y);return{x:Math.min(...t),y:Math.min(...n),width:Math.max(...t)-Math.min(...t),height:Math.max(...n)-Math.min(...n)}}function buildMiniDiff(e,t){let n=new Map,r=new Map,i=new Map,a=new Set,o={added:0,removed:0,changed:0},shape=(e,t,i=e.bounds)=>{i&&(r.set(e.id,{id:e.id,type:e.type,bounds:i,mark:t,...e.name?{name:e.name}:{}}),n.set(e.id,t))},flow=(e,t)=>{e.waypoints&&e.waypoints.length>1&&i.set(e.id,{id:e.id,points:e.waypoints,mark:t,...e.source?{source:e.source}:{},...e.target?{target:e.target}:{}});for(let n of[e.source,e.target])n&&t!==`context`&&a.add(n)};for(let r of t)if(!r.error){for(let e of r.added)shape(e,`added`),o.added+=1;for(let e of r.addedFlows)flow(e,`added`);for(let e of r.removed)e.waypoints?flow(e,`removed`):(shape(e,`removed`),o.removed+=1,a.add(e.id));for(let t of r.moved){let n=e.nodes.find(e=>e.id===t.id);shape({id:t.id,type:n?.type??`bpmn:Task`,...n?.name?{name:n.name}:{}},`changed`,t.to),a.add(t.id),o.changed+=1}for(let t of r.changed){let r=e.nodes.find(e=>e.id===t.id),i=e.flows.find(e=>e.id===t.id);r&&!n.has(r.id)?(shape(r,`changed`),o.changed+=1):i&&(flow(i,`changed`),o.changed+=1),a.add(t.id)}}for(let t of e.flows)if(!i.has(t.id)&&(t.source&&a.has(t.source)||t.target&&a.has(t.target))){flow(t,`context`);for(let n of[t.source,t.target]){let t=e.nodes.find(e=>e.id===n);t&&!r.has(t.id)&&shape(t,`context`)}}for(let t of a){let n=e.nodes.find(e=>e.id===t);n&&!r.has(t)&&shape(n,`context`)}let s=[...r.values()].map(e=>e.bounds).concat([...i.values()].map(e=>boxOfPoints(e.points)));return{shapes:[...r.values()],flows:[...i.values()],viewBox:unionOf(s),counts:o}}function viewOf(e,t){return unionOf(e.map(e=>e.bounds).concat(t.map(e=>boxOfPoints(e.points))))}function narrowDiff(e){let t=new Set(e.shapes.filter(e=>e.mark!==`context`).map(e=>e.id));for(let n of e.flows)n.mark!==`context`&&(n.source&&t.add(n.source),n.target&&t.add(n.target));let n=e.shapes.filter(e=>t.has(e.id)),r=e.flows.filter(e=>e.mark!==`context`||e.source&&e.target&&t.has(e.source)&&t.has(e.target));return n.length===e.shapes.length&&r.length===e.flows.length?e:{...e,shapes:n,flows:r,viewBox:viewOf(n,r)}}var Jn=`Arial, sans-serif`,Yn=11,Xn=1.25,Zn=.58,Qn=200,$n=560,er=2,tr=.55,nr=1.25,isEvent=e=>/Event$/.test(e),isGateway=e=>/Gateway$/.test(e),isOutside=e=>isEvent(e)||isGateway(e);function wrapLabel(e,t,n){let r=Math.max(4,t),i=[],a=``;for(let t of e.split(/\s+/).filter(Boolean)){let e=a?`${a} ${t}`:t;e.length<=r?a=e:(a&&i.push(a),a=t)}a&&i.push(a);let cut=e=>e.length>r?`${e.slice(0,r-1)}…`:e;if(i.length<=n)return i.map(cut);let o=i.slice(0,n);return o[n-1]=cut(`${o[n-1]} ${i.slice(n).join(` `)}`.slice(0,r*2)),o.map(cut)}function labelOf$1(e,t){let n=e.name??(isOutside(e.type)?``:w(e.type));if(!n)return null;let r=isOutside(e.type),i=r?Math.max(e.bounds.width+48,96):e.bounds.width-8;return{lines:wrapLabel(n,Math.floor(i*t/(Yn*Zn)),r?er:Math.max(1,Math.min(3,Math.floor(e.bounds.height*t/(Yn*Xn))-0))),outside:r}}e(labelOf$1,`labelOf`);function fitted(e,t){let n=layoutOf(e,t);if(n.scale>=tr)return{data:e,layout:n};let r=narrowDiff(e);return r===e?{data:e,layout:n}:{data:r,layout:layoutOf(r,t)}}function layoutOf(e,t){let n=e.viewBox,r=Math.min(nr,t/n.width,Qn/n.height),i=n,a=new Map;for(let o=0;o<3;o+=1){let o=Yn/r;a=new Map;let s=n.x,c=n.x+n.width,l=n.y+n.height;for(let t of e.shapes){let e=labelOf$1(t,r);if(!e||(a.set(t.id,e),!e.outside))continue;let n=Math.max(...e.lines.map(e=>e.length))*o*Zn,i=t.bounds.x+t.bounds.width/2;s=Math.min(s,i-n/2-4),c=Math.max(c,i+n/2+4),l=Math.max(l,t.bounds.y+t.bounds.height+4+e.lines.length*o*Xn+4)}i={x:s,y:n.y,width:c-s,height:l-n.y},r=Math.min(nr,t/i.width,Qn/i.height)}return{view:i,scale:r,labels:a,size:Yn/r}}function Label({shape:e,label:t,size:n}){let{x:r,y:i,width:a,height:o}=e.bounds,s=n*Xn,c=t.outside?i+o+4+n:i+o/2-(t.lines.length-1)*s/2+n*.35;return l(`text`,{class:`mini-diff__label`,x:r+a/2,y:c,"text-anchor":`middle`,"font-size":n,"font-family":Jn,children:t.lines.length===1?t.lines[0]:t.lines.map((e,t)=>l(`tspan`,{x:r+a/2,dy:t===0?0:s,children:e},t))})}function Shape({shape:e}){let{x:t,y:n,width:r,height:i}=e.bounds,a=`mini-diff__shape mini-diff__shape--${e.mark}`,o=l(`title`,{children:e.name?`${w(e.type)} · ${e.name}`:w(e.type)});return isEvent(e.type)?l(`circle`,{class:a,cx:t+r/2,cy:n+i/2,r:r/2,children:o}):isGateway(e.type)?l(`polygon`,{class:a,points:`${t+r/2},${n} ${t+r},${n+i/2} ${t+r/2},${n+i} ${t},${n+i/2}`,children:o}):l(`rect`,{class:a,x:t,y:n,width:r,height:i,rx:10,children:o})}var rr=8;function head(e){let t=e.points[e.points.length-1],n=e.points[e.points.length-2],r=Math.hypot(t.x-n.x,t.y-n.y)||1,i=(t.x-n.x)/r,a=(t.y-n.y)/r,o={x:t.x-i*rr,y:t.y-a*rr};return`M${t.x},${t.y} L${o.x-a*rr*.4},${o.y+i*rr*.4} L${o.x+a*rr*.4},${o.y-i*rr*.4} z`}function Flow({flow:e}){let t=e.points.map((e,t)=>`${t===0?`M`:`L`}${e.x},${e.y}`).join(` `);return l(`g`,{class:`mini-diff__flow mini-diff__flow--${e.mark}`,children:[l(`path`,{class:`mini-diff__line`,d:t}),l(`path`,{class:`mini-diff__head`,d:head(e)})]})}function Strike({bounds:e}){return l(`path`,{class:`mini-diff__strike`,d:`M${e.x-3},${e.y+e.height+3} L${e.x+e.width+3},${e.y-3}`})}function summaryOf(e){return m(`app.aiBlocks.diffSummary`,e)}function MiniDiagramDiff({data:e,label:n,lazy:r=!0}){let i=o(null),[a,s]=t(!r||typeof IntersectionObserver>`u`);f(()=>{if(a||!i.current)return;let e=new IntersectionObserver(t=>{t.some(e=>e.isIntersecting)&&(s(!0),e.disconnect())});return e.observe(i.current),()=>e.disconnect()},[a]);let[c,u]=t($n);f(()=>{let e=i.current;if(!e||typeof ResizeObserver>`u`)return;let measure=()=>{let t=getComputedStyle(e),n=e.clientWidth-parseFloat(t.paddingLeft||`0`)-parseFloat(t.paddingRight||`0`);n>0&&u(n)};measure();let t=new ResizeObserver(measure);return t.observe(e),()=>t.disconnect()},[]);let{data:d,layout:p}=fitted(e,c),{view:m}=p,h=summaryOf(e.counts);return l(`figure`,{class:`mini-diff`,ref:i,"aria-label":n??h,"data-lazy":a?void 0:`true`,children:[a?l(`svg`,{class:`mini-diff__svg`,viewBox:`${m.x} ${m.y} ${m.width} ${m.height}`,width:m.width*p.scale,height:m.height*p.scale,role:`img`,"aria-label":h,children:[d.flows.map(e=>l(Flow,{flow:e},e.id)),d.shapes.map(e=>l(Shape,{shape:e},e.id)),d.shapes.map(e=>{let t=p.labels.get(e.id);return t?l(Label,{shape:e,label:t,size:p.size},`label-${e.id}`):null}),d.shapes.filter(e=>e.mark===`removed`).map(e=>l(Strike,{bounds:e.bounds},`strike-${e.id}`))]}):l(`div`,{class:`mini-diff__placeholder`}),l(`figcaption`,{class:`mini-diff__caption type-help`,children:h})]})}var ir=1500,ar=2e5;function split(e){return e===``?[]:e.replace(/\r\n/g,`
|
|
142
142
|
`).split(`
|
|
143
|
-
`)}function shortestEdit(e,t){let n=e.length,r=t.length,i=Math.min(n+r,ir),a=2*i+2,o=i+1,s=new Int32Array(a),c=[],l=-1;for(let a=0;a<=i&&l<0;a+=1){c.push(s.slice());let i=s;for(let s=-a;s<=a;s+=2){let c;c=s===-a||s!==a&&i[o+s-1]<i[o+s+1]?i[o+s+1]:i[o+s-1]+1;let u=c-s;for(;c<n&&u<r&&e[c]===t[u];)c+=1,u+=1;if(i[o+s]=c,c>=n&&u>=r){l=a;break}}s=i}if(l<0)return null;let u=[],d=n,f=r;for(let e=l;e>0;--e){let t=c[e],n=d-f,r=n===-e||n!==e&&t[o+n-1]<t[o+n+1],i=r?n+1:n-1,a=t[o+i],s=a-i;for(;d>a&&f>s;)u.push(`keep`),--d,--f;u.push(r?`add`:`drop`),d=a,f=s}for(;d>0&&f>0;)u.push(`keep`),--d,--f;return{script:u.reverse()}}function compareTexts(e,t){let n=split(e),r=split(t);if(n.length>ar||r.length>ar)return null;let i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i+=1;let a=0;for(;a<n.length-i&&a<r.length-i&&n[n.length-1-a]===r[r.length-1-a];)a+=1;let o=n.slice(i,n.length-a),s=r.slice(i,r.length-a),c=o.length===0&&s.length===0?{script:[]}:shortestEdit(o,s);if(!c)return null;let l=[];for(let e=0;e<i;e+=1)l.push({kind:`same`,text:n[e],mineAt:e+1,theirsAt:e+1});let u=0,d=0;for(let e of c.script)e===`keep`?(l.push({kind:`same`,text:o[u],mineAt:i+u+1,theirsAt:i+d+1}),u+=1,d+=1):e===`drop`?(l.push({kind:`mine`,text:o[u],mineAt:i+u+1,theirsAt:null}),u+=1):(l.push({kind:`theirs`,text:s[d],mineAt:null,theirsAt:i+d+1}),d+=1);for(let e=0;e<a;e+=1){let t=n.length-a+e;l.push({kind:`same`,text:n[t],mineAt:t+1,theirsAt:r.length-a+e+1})}return{lines:l,mine:l.filter(e=>e.kind===`mine`).length,theirs:l.filter(e=>e.kind===`theirs`).length}}function hunksOf(e,t=3){let{lines:n}=e,r=new Uint8Array(n.length);n.forEach((e,i)=>{if(e.kind!==`same`)for(let e=Math.max(0,i-t);e<=Math.min(n.length-1,i+t);e+=1)r[e]=1});let i=[],a=null;return n.forEach((e,t)=>{r[t]?(a||(a=[],i.push({lines:a})),a.push(e)):a=null}),i}function rowOf(e){return e.kind===`mine`?{kind:`del`,text:e.text,at:e.mineAt??0}:e.kind===`theirs`?{kind:`add`,text:e.text,at:e.theirsAt??0}:{kind:`same`,text:e.text,at:e.theirsAt??e.mineAt??0}}function sourceDiff(e,t,n=3){let r=compareTexts(e??``,t);if(!r)return null;let{lines:i}=r,a=new Uint8Array(i.length);i.forEach((e,t)=>{if(e.kind!==`same`)for(let e=Math.max(0,t-n);e<=Math.min(i.length-1,t+n);e+=1)a[e]=1});let o=[],s=[],flush=()=>{s.length!==0&&(s.length===1?o.push(s[0]):o.push({kind:`fold`,from:s[0].kind===`fold`?0:s[0].at,lines:s}),s=[])};return i.forEach((e,t)=>{let n=rowOf(e);a[t]?(flush(),o.push(n)):s.push(n)}),flush(),{rows:o,added:r.theirs,removed:r.mine}}function visibleRows(e,t){let n=[];for(let r of e.rows)r.kind===`fold`&&t.has(r.from)?n.push(...r.lines):n.push(r);return n.slice(0,600)}function SourceView({before:e,after:n,label:r,large:i}){let a=c(()=>sourceDiff(e,n),[e,n]),[o,s]=t(new Set);if(!a)return l(`p`,{class:`assistant-source__big type-help`,children:m(`app.assistant.diffTooLarge`)});let u=visibleRows(a,o);return l(`div`,{class:`assistant-source${i?` is-large`:``}`,role:`region`,"aria-label":r,tabIndex:0,children:u.map((e,t)=>e.kind===`fold`?l(`button`,{type:`button`,class:`assistant-source__fold type-help`,onClick:()=>s(new Set([...o,e.from])),children:m(`app.assistant.view.folded`,{count:e.lines.length})},`fold-${e.from}-${t}`):l(`div`,{class:`assistant-source__row is-${e.kind}`,children:[l(`span`,{class:`assistant-source__at type-code`,"aria-hidden":`true`,children:e.at}),l(`span`,{class:`assistant-source__sign type-code`,"aria-hidden":`true`,children:e.kind===`add`?`+`:e.kind===`del`?`-`:` `}),l(`span`,{class:`assistant-source__text type-code`,children:e.text})]},`${e.kind}-${t}`))})}function DiffDialog({request:e,onClose:t}){return l(q,{title:e.title,subtitle:e.path,size:`large`,onClose:t,class:`assistant-diff-dialog`,footer:l(Y,{actions:[{id:`close`,label:m(`app.common.close`),role:`primary`,onClick:t}]}),children:l(SourceView,{before:e.before,after:e.after,label:m(`app.assistant.view.sourceLabel`),large:!0})})}function initialMode(e){return e?`picture`:`source`}function requestOf(e){let t=pe(e.path);return{title:m(`app.assistant.view.diffTitle`,{name:t}),path:e.path,before:e.oldText,after:e.newText}}function viewer(){try{let e=j();return e.openDiff&&U(e,`diffViewer`)?t=>e.openDiff(t):null}catch{return null}}async function openDiff(e){let t=viewer();if(!t)return!1;try{return await t(e),!0}catch{return!1}}function ChangePanel({diff:e,mini:n,initial:r}){let[i,a]=t(r===void 0?initialMode(n):r),[o,s]=t(null),c=pe(e.path),choose=e=>a(t=>t===e&&r===null?null:e),show=async()=>{let t=requestOf(e);await openDiff(t)||s(t)};return l(`div`,{class:`assistant-change`,children:[l(`div`,{class:`assistant-change__bar`,children:[l(`div`,{class:`assistant-switch-view`,role:`group`,"aria-label":m(`app.assistant.view.label`),children:[n&&l(`button`,{type:`button`,class:`assistant-switch-view__choice type-help`,"aria-pressed":i===`picture`,onClick:()=>choose(`picture`),children:m(`app.assistant.view.picture`)}),l(`button`,{type:`button`,class:`assistant-switch-view__choice type-help`,"aria-pressed":i===`source`,onClick:()=>choose(`source`),children:m(`app.assistant.view.source`)})]}),l(`button`,{type:`button`,class:`assistant-link type-link`,onClick:()=>void show(),children:m(`app.assistant.view.openDiff`)}),l(`span`,{class:`assistant-change__name type-help`,title:e.path,children:c})]}),i===`picture`&&n&&l(MiniDiagramDiff,{data:n,lazy:!1,label:m(`app.assistant.changeLabel`,{name:c})}),i===`source`&&l(SourceView,{before:e.oldText,after:e.newText,label:m(`app.assistant.view.sourceLabel`)}),o&&d(l(DiffDialog,{request:o,onClose:()=>s(null)}),document.body)]})}var or=``,sr=``;function compose(e,t){let n=Object.keys(t),r=e(Object.fromEntries(n.map((e,t)=>[e,`${or}${t}${sr}`]))),i=[],a=RegExp(`${or}(\\d+)${sr}`,`g`),o=0;for(let e of r.matchAll(a))e.index>o&&i.push(r.slice(o,e.index)),i.push(t[n[Number(e[1])]]),o=e.index+e[0].length;return o<r.length&&i.push(r.slice(o)),i}function plain(e){return e.map(e=>typeof e==`string`?e:e.kind===`file`?e.label??e.path.split(/[\\/]/).pop()??e.path:e.name??e.id).join(``)}function endName(e){if(!e)return null;if(e.name)return e.name;if(!e.type)return null;let t=w(e.type);return t?t.charAt(0).toUpperCase()+t.slice(1):null}function flowName(e,t){let n=endName(e),r=endName(t);return n&&r?`${n} → ${r}`:void 0}var cr=/\.bpmn(\.xml)?$/i,lr=120;function isBpmnDiff(e){return cr.test(e.path)}function fingerprint(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t=Math.imul(t^e.charCodeAt(n),16777619)>>>0;return`${e.length}:${t.toString(36)}`}function miniOf(e){let t={index:0,operation:{op:`remove`,id:``},summary:``,added:e.added,addedFlows:e.addedFlows,removed:e.removed,changed:e.changed,moved:e.moved,touched:[]};return buildMiniDiff(e.before,[t])}var ur={element:`app.assistant.loose.element`,attach:`app.assistant.loose.attach`,scope:`app.assistant.loose.scope`,type:`app.assistant.loose.type`,reconnect:`app.assistant.loose.reconnect`,resize:`app.assistant.loose.resize`,property:`app.assistant.loose.property`,event:`app.assistant.loose.event`},dr=3;function notesOf(e){let t=new Map;for(let n of e)t.set(n.kind,[...t.get(n.kind)??[],n]);return[...t].map(([e,t])=>{let n=[...new Set(t.map(e=>e.id))],r=n.slice(0,dr).join(`, `);return m(ur[e],{ids:n.length>dr?`${r}, ...`:r,type:t[0].type?w(t[0].type):``})})}var fr=new Map;async function computeChange(e){if(e.newText.length>2e6||(e.oldText?.length??0)>2e6)return null;try{let{diffDiagrams:t}=await y(async()=>{let{diffDiagrams:e}=await import(`./diff-Cw0ENHJR.js`);return{diffDiagrams:e}},__vite__mapDeps([63,1,9,7,8,38,3,4]),import.meta.url),n=await t(e.oldText,e.newText);return n?{path:e.path,diff:n,mini:miniOf(n),notes:notesOf(n.loose),readable:n.operations.length>0}:null}catch(e){return console.error(`The change to a diagram could not be read:`,e),null}}function changeOf(e){let t=`${e.path}\u0000${fingerprint(e.oldText??``)}\u0000${fingerprint(e.newText)}`,n=fr.get(t);if(n)return fr.delete(t),fr.set(t,n),n;let r=computeChange(e);return fr.set(t,r),fr.size>lr&&fr.delete(fr.keys().next().value),r}var PictureBudget=class{spent=!1;take(){return!this.spent&&(this.spent=!0,!0)}},PictureBudgets=class{answers=new Map;of(e){let t=this.answers.get(e);if(t)return t;let n=new PictureBudget;return this.answers.set(e,n),n}},pr=8;function capital(e){return e.charAt(0).toUpperCase()+e.slice(1)}function chipOf(e,t,n,r=[]){let i=t?.name||(t?.source&&t.target?flowName(r.find(e=>e.id===t.source),r.find(e=>e.id===t.target)):void 0);return{kind:`element`,path:e,id:n,...t?{type:t.type}:{},...i?{name:i}:{}}}function lineOf(e,t){return{mark:e,parts:t,text:plain(t)}}function nodeLine(e,t,n){return lineOf(e,[`${capital(w(n.type))} `,chipOf(t,n,n.id)])}function flowLine(e,t,n,r){let i=r.find(e=>e.id===n.source),a=r.find(e=>e.id===n.target),o={};return n.source&&(o.from=chipOf(t,i,n.source)),n.target&&(o.to=chipOf(t,a,n.target)),lineOf(e,compose(e=>m(`app.assistant.change.flow`,{from:e.from??``,to:e.to??``}),o))}async function diagramLines(e){let t=await changeOf(e);if(!t)return null;let{diff:n}=t,r=[...n.after.nodes,...n.before.nodes],i=[],a=[],o=e.path;for(let e of n.added)i.push(nodeLine(`+`,o,e)),a.push(chipOf(o,e,e.id));for(let e of n.addedFlows)i.push(flowLine(`+`,o,e,r)),a.push(chipOf(o,e,e.id,r));for(let e of n.removed)i.push(e.type.toLowerCase().includes(`flow`)?flowLine(`-`,o,e,r):nodeLine(`-`,o,e));for(let e of n.changed){let t=chipOf(o,r.find(t=>t.id===e.id),e.id,r);a.push(t),i.push(lineOf(`~`,e.keys.length>0?compose(t=>m(`app.assistant.change.changed`,{name:t.name,what:e.keys.join(`, `)}),{name:t}):[t]))}for(let e of n.moved){let t=chipOf(o,r.find(t=>t.id===e.id),e.id,r);a.push(t),i.push(lineOf(`~`,compose(e=>m(`app.assistant.change.moved`,{name:e.name}),{name:t})))}return{lines:i,mini:t.mini.shapes.length+t.mini.flows.length>0&&t.mini.counts.added+t.mini.counts.removed+t.mini.counts.changed>0?t.mini:null,elements:a}}function textLine(e){let t=compareTexts(e.oldText??``,e.newText),n={kind:`file`,path:e.path};return e.oldText===null?lineOf(`+`,compose(e=>m(`app.assistant.change.created`,{name:e.name}),{name:n})):t?lineOf(`~`,compose(e=>m(`app.assistant.change.lines`,{name:e.name,added:t.theirs,removed:t.mine}),{name:n})):lineOf(`~`,compose(e=>m(`app.assistant.change.file`,{name:e.name}),{name:n}))}async function summarise(e){return summariseDiffs(e.tool.diffs)}async function summariseDiffs(e,t=new PictureBudget){let n=[],r=new Set,i=[];for(let a of e){r.add(pe(a.path));let e=isBpmnDiff(a)?await diagramLines(a).catch(()=>null):null;e&&e.lines.length>0?n.push(...e.lines):n.push(textLine(a));let o=e?.mini??null,s=o&&t.take()?o:null;i.push({diff:a,mini:s,drawable:o!==null,elements:e?.elements??[]})}let a=n.length;return{lines:n.slice(0,pr),files:[...r],count:a,diffs:i}}function questionOf(e,t){if(!t||t.count===0)return toolTitle(e.tool);let n=t.files.length===1?t.files[0]:m(`app.assistant.question.files`,{count:t.files.length});return m(`app.assistant.question.apply`,{count:t.count,file:n})}function ChipView({chip:e}){let t=useLinks();return e.kind===`file`?l(FileReference,{reference:{path:e.path,id:null,line:null},raw:e.label??pe(e.path)}):e.type?l(ElementChip,{id:e.id,type:e.type,name:e.name,onSelect:n=>{t.openElement(e.path,n),t.flash?.(e.path,[n])},onHover:(n,r)=>t.highlight?.(e.path,n,r)}):l(ElementReference,{reference:{path:e.path,id:e.id,line:null}})}function PartsView({parts:e}){return l(a,{children:e.map((e,t)=>typeof e==`string`?l(`span`,{children:e},t):l(ChipView,{chip:e},t))})}function ChipRow({chips:e,max:t}){if(e.length===0)return null;let n=e.slice(0,t),r=e.length-n.length;return l(`span`,{class:`assistant-chips`,children:[n.map((e,t)=>l(ChipView,{chip:e},t)),r>0&&l(`span`,{class:`assistant-chips__more type-help`,children:m(`app.assistant.sentence.more`,{count:r})})]})}var mr=new Map,hr=new Set,gr=100;function reportCheck(e,t){mr.delete(e),mr.set(e,t),mr.size>gr&&mr.delete(mr.keys().next().value);for(let e of[...hr])e()}function forgetCheck(e){if(mr.delete(e))for(let e of[...hr])e()}function checkOf(e){let t=`permission:${e}:`,n=null;for(let[e,r]of mr)e.startsWith(t)&&(n=n?{errors:n.errors+r.errors,warnings:n.warnings+r.warnings,resolved:n.resolved+r.resolved}:r);return n}function useProposalCheck(e){let[,n]=t(0);return f(()=>{let listener=()=>n(e=>e+1);return hr.add(listener),()=>{hr.delete(listener)}},[]),e?checkOf(e):null}function proposalId(e,t){return`permission:${e.id}:${t}`}function answerOptions(e){let t=e.tool.diffs.length>0,pick=(n,r)=>e.options.find(e=>e.kind===n)??(t?null:e.options.find(e=>e.kind===r)??null);return{allow:pick(`allow`,`allowAlways`),reject:pick(`reject`,`rejectAlways`)}}function connectReviews(e){let t=new Map,n=!1,withdraw=t=>{for(let n of t.ids)e.canvas.channel.withdraw(n),forgetCheck(n)},offer=async(r,i,a)=>{let o=e.file();if(!o)return;let{allow:s,reject:c}=answerOptions(i);if(s&&c)for(let l of i.tool.diffs){if(!isBpmnDiff(l)||!de(l.path,o))continue;let u=await changeOf(l);if(n||t.get(r)!==a)return;if(!u||u.diff.operations.length===0)continue;let d=proposalId(i,l.path),f={id:d,patch:{operations:u.diff.operations,title:toolTitle(i.tool)},source:`agent`,title:toolTitle(i.tool),createdAt:Date.now(),notes:u.notes,after:u.diff.after,checked:e=>reportCheck(d,e),whole:{accept:()=>void e.store.answer(r,i.id,s.id),reject:()=>void e.store.answer(r,i.id,c.id)}};a.ids.push(d),e.canvas.channel.offer(f)}},sync=()=>{if(n)return;let r=e.store.snapshot().transcripts;for(let[e,n]of[...t])r[e]?.permission?.id!==n.key&&(t.delete(e),withdraw(n));for(let[e,n]of Object.entries(r)){let r=n.permission;if(!r||t.get(e)?.key===r.id)continue;let i={key:r.id,ids:[]};t.set(e,i),offer(e,r,i).catch(e=>console.error(`The change could not be shown on the canvas:`,e))}},r=e.store.subscribe(sync);return sync(),()=>{n=!0,r();for(let e of t.values())withdraw(e);t.clear()}}var _r={allow:`app.assistant.question.allow`,reject:`app.assistant.question.deny`,allowAlways:`app.assistant.question.allowAlways`,rejectAlways:`app.assistant.question.denyAlways`};function labelOf(e){return _r[e.kind]?m(_r[e.kind]):e.label}function useSummary(e){let[n,r]=t(null);return f(()=>{let t=!0;return r(null),summarise(e).then(e=>t&&r(e)).catch(()=>t&&r({lines:[],files:[],count:0,diffs:[]})),()=>{t=!1}},[e.id]),n}function Question({store:e,chatId:t,permission:n,focus:r=!0,onShow:i}){let a=useLinks(),s=useSummary(n),c=useProposalCheck(n.id),u=o(null),d=n.tool.diffs.length>0,{allow:p,reject:h}=answerOptions(n),g=d?[]:n.options.filter(e=>e!==p&&e!==h),_=n.tool.diffs.find(e=>/\.bpmn(\.xml)?$/i.test(e.path))??null;f(()=>{r&&u.current?.focus()},[n.id,r]);let answer=r=>void e.answer(t,n.id,r);return l(`div`,{class:`assistant-question`,role:`group`,"aria-label":m(`app.assistant.question.label`),children:[l(`p`,{class:`assistant-question__title`,children:[l(J,{name:`hand`,class:`assistant-question__mark`}),l(`span`,{children:questionOf(n,s)})]}),s&&s.lines.length>0&&l(`ul`,{class:`assistant-question__changes type-code`,children:s.lines.map((e,t)=>l(`li`,{class:`assistant-question__change is-${e.mark===`+`?`added`:e.mark===`-`?`removed`:`changed`}`,children:[l(`span`,{class:`assistant-question__mark-line`,"aria-hidden":`true`,children:e.mark}),l(`span`,{class:`assistant-question__text`,children:l(PartsView,{parts:e.parts})})]},t))}),c&&l(`p`,{class:`assistant-question__check${c.errors>0?` is-error`:c.warnings>0?` is-warning`:``}`,children:[l(J,{name:c.errors>0||c.warnings>0?`alert`:`check`}),l(`span`,{children:c.errors+c.warnings===0?m(`app.assistant.question.clean`):m(`app.assistant.question.problems`,{count:c.errors+c.warnings})})]}),s&&s.diffs.map(e=>l(ChangePanel,{diff:e.diff,mini:e.mini},e.diff.path)),l(`div`,{class:`assistant-question__actions`,children:[h&&l(`button`,{ref:u,type:`button`,class:`assistant-button assistant-button--secondary`,onClick:()=>answer(h.id),onKeyDown:e=>{e.key===`Enter`&&e.preventDefault()},children:labelOf(h)}),p&&l(`button`,{type:`button`,class:`assistant-button assistant-button--primary`,onClick:()=>answer(p.id),children:labelOf(p)}),g.map(e=>l(`button`,{type:`button`,class:`assistant-button assistant-button--secondary`,onClick:()=>answer(e.id),children:labelOf(e)},e.id)),_&&l(`button`,{type:`button`,class:`assistant-link type-link`,onClick:()=>i?.(_.path)?void 0:a.openFile(_.path),children:m(`app.assistant.question.showOnCanvas`)}),d&&l(`span`,{class:`assistant-question__note type-help`,children:m(`app.assistant.question.undo`)})]})]})}function parsed(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t.startsWith(`[`)&&!t.startsWith(`{`))return e;try{return JSON.parse(t)}catch{return e}}function unwrap(e,t=0){if(t>4)return e;let n=parsed(e);if(Array.isArray(n)){let e=n.filter(e=>!!e&&typeof e==`object`&&e.type===`text`&&typeof e.text==`string`);return e.length>0&&e.length===n.length?unwrap(e.map(e=>e.text).join(`
|
|
143
|
+
`)}function shortestEdit(e,t){let n=e.length,r=t.length,i=Math.min(n+r,ir),a=2*i+2,o=i+1,s=new Int32Array(a),c=[],l=-1;for(let a=0;a<=i&&l<0;a+=1){c.push(s.slice());let i=s;for(let s=-a;s<=a;s+=2){let c;c=s===-a||s!==a&&i[o+s-1]<i[o+s+1]?i[o+s+1]:i[o+s-1]+1;let u=c-s;for(;c<n&&u<r&&e[c]===t[u];)c+=1,u+=1;if(i[o+s]=c,c>=n&&u>=r){l=a;break}}s=i}if(l<0)return null;let u=[],d=n,f=r;for(let e=l;e>0;--e){let t=c[e],n=d-f,r=n===-e||n!==e&&t[o+n-1]<t[o+n+1],i=r?n+1:n-1,a=t[o+i],s=a-i;for(;d>a&&f>s;)u.push(`keep`),--d,--f;u.push(r?`add`:`drop`),d=a,f=s}for(;d>0&&f>0;)u.push(`keep`),--d,--f;return{script:u.reverse()}}function compareTexts(e,t){let n=split(e),r=split(t);if(n.length>ar||r.length>ar)return null;let i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i+=1;let a=0;for(;a<n.length-i&&a<r.length-i&&n[n.length-1-a]===r[r.length-1-a];)a+=1;let o=n.slice(i,n.length-a),s=r.slice(i,r.length-a),c=o.length===0&&s.length===0?{script:[]}:shortestEdit(o,s);if(!c)return null;let l=[];for(let e=0;e<i;e+=1)l.push({kind:`same`,text:n[e],mineAt:e+1,theirsAt:e+1});let u=0,d=0;for(let e of c.script)e===`keep`?(l.push({kind:`same`,text:o[u],mineAt:i+u+1,theirsAt:i+d+1}),u+=1,d+=1):e===`drop`?(l.push({kind:`mine`,text:o[u],mineAt:i+u+1,theirsAt:null}),u+=1):(l.push({kind:`theirs`,text:s[d],mineAt:null,theirsAt:i+d+1}),d+=1);for(let e=0;e<a;e+=1){let t=n.length-a+e;l.push({kind:`same`,text:n[t],mineAt:t+1,theirsAt:r.length-a+e+1})}return{lines:l,mine:l.filter(e=>e.kind===`mine`).length,theirs:l.filter(e=>e.kind===`theirs`).length}}function hunksOf(e,t=3){let{lines:n}=e,r=new Uint8Array(n.length);n.forEach((e,i)=>{if(e.kind!==`same`)for(let e=Math.max(0,i-t);e<=Math.min(n.length-1,i+t);e+=1)r[e]=1});let i=[],a=null;return n.forEach((e,t)=>{r[t]?(a||(a=[],i.push({lines:a})),a.push(e)):a=null}),i}function rowOf(e){return e.kind===`mine`?{kind:`del`,text:e.text,at:e.mineAt??0}:e.kind===`theirs`?{kind:`add`,text:e.text,at:e.theirsAt??0}:{kind:`same`,text:e.text,at:e.theirsAt??e.mineAt??0}}function sourceDiff(e,t,n=3){let r=compareTexts(e??``,t);if(!r)return null;let{lines:i}=r,a=new Uint8Array(i.length);i.forEach((e,t)=>{if(e.kind!==`same`)for(let e=Math.max(0,t-n);e<=Math.min(i.length-1,t+n);e+=1)a[e]=1});let o=[],s=[],flush=()=>{s.length!==0&&(s.length===1?o.push(s[0]):o.push({kind:`fold`,from:s[0].kind===`fold`?0:s[0].at,lines:s}),s=[])};return i.forEach((e,t)=>{let n=rowOf(e);a[t]?(flush(),o.push(n)):s.push(n)}),flush(),{rows:o,added:r.theirs,removed:r.mine}}function visibleRows(e,t){let n=[];for(let r of e.rows)r.kind===`fold`&&t.has(r.from)?n.push(...r.lines):n.push(r);return n.slice(0,600)}function SourceView({before:e,after:n,label:r,large:i}){let a=c(()=>sourceDiff(e,n),[e,n]),[o,s]=t(new Set);if(!a)return l(`p`,{class:`assistant-source__big type-help`,children:m(`app.assistant.diffTooLarge`)});let u=visibleRows(a,o);return l(`div`,{class:`assistant-source${i?` is-large`:``}`,role:`region`,"aria-label":r,tabIndex:0,children:u.map((e,t)=>e.kind===`fold`?l(`button`,{type:`button`,class:`assistant-source__fold type-help`,onClick:()=>s(new Set([...o,e.from])),children:m(`app.assistant.view.folded`,{count:e.lines.length})},`fold-${e.from}-${t}`):l(`div`,{class:`assistant-source__row is-${e.kind}`,children:[l(`span`,{class:`assistant-source__at type-code`,"aria-hidden":`true`,children:e.at}),l(`span`,{class:`assistant-source__sign type-code`,"aria-hidden":`true`,children:e.kind===`add`?`+`:e.kind===`del`?`-`:` `}),l(`span`,{class:`assistant-source__text type-code`,children:e.text})]},`${e.kind}-${t}`))})}function DiffDialog({request:e,onClose:t}){return l(q,{title:e.title,subtitle:e.path,size:`large`,onClose:t,class:`assistant-diff-dialog`,footer:l(Y,{actions:[{id:`close`,label:m(`app.common.close`),role:`primary`,onClick:t}]}),children:l(SourceView,{before:e.before,after:e.after,label:m(`app.assistant.view.sourceLabel`),large:!0})})}function initialMode(e){return e?`picture`:`source`}function requestOf(e){let t=pe(e.path);return{title:m(`app.assistant.view.diffTitle`,{name:t}),path:e.path,before:e.oldText,after:e.newText}}function viewer(){try{let e=j();return e.openDiff&&U(e,`diffViewer`)?t=>e.openDiff(t):null}catch{return null}}async function openDiff(e){let t=viewer();if(!t)return!1;try{return await t(e),!0}catch{return!1}}function ChangePanel({diff:e,mini:n,initial:r}){let[i,a]=t(r===void 0?initialMode(n):r),[o,s]=t(null),c=pe(e.path),choose=e=>a(t=>t===e&&r===null?null:e),show=async()=>{let t=requestOf(e);await openDiff(t)||s(t)};return l(`div`,{class:`assistant-change`,children:[l(`div`,{class:`assistant-change__bar`,children:[l(`div`,{class:`assistant-switch-view`,role:`group`,"aria-label":m(`app.assistant.view.label`),children:[n&&l(`button`,{type:`button`,class:`assistant-switch-view__choice type-help`,"aria-pressed":i===`picture`,onClick:()=>choose(`picture`),children:m(`app.assistant.view.picture`)}),l(`button`,{type:`button`,class:`assistant-switch-view__choice type-help`,"aria-pressed":i===`source`,onClick:()=>choose(`source`),children:m(`app.assistant.view.source`)})]}),l(`button`,{type:`button`,class:`assistant-link type-link`,onClick:()=>void show(),children:m(`app.assistant.view.openDiff`)}),l(`span`,{class:`assistant-change__name type-help`,title:e.path,children:c})]}),i===`picture`&&n&&l(MiniDiagramDiff,{data:n,lazy:!1,label:m(`app.assistant.changeLabel`,{name:c})}),i===`source`&&l(SourceView,{before:e.oldText,after:e.newText,label:m(`app.assistant.view.sourceLabel`)}),o&&d(l(DiffDialog,{request:o,onClose:()=>s(null)}),document.body)]})}var or=``,sr=``;function compose(e,t){let n=Object.keys(t),r=e(Object.fromEntries(n.map((e,t)=>[e,`${or}${t}${sr}`]))),i=[],a=RegExp(`${or}(\\d+)${sr}`,`g`),o=0;for(let e of r.matchAll(a))e.index>o&&i.push(r.slice(o,e.index)),i.push(t[n[Number(e[1])]]),o=e.index+e[0].length;return o<r.length&&i.push(r.slice(o)),i}function plain(e){return e.map(e=>typeof e==`string`?e:e.kind===`file`?e.label??e.path.split(/[\\/]/).pop()??e.path:e.name??e.id).join(``)}function endName(e){if(!e)return null;if(e.name)return e.name;if(!e.type)return null;let t=w(e.type);return t?t.charAt(0).toUpperCase()+t.slice(1):null}function flowName(e,t){let n=endName(e),r=endName(t);return n&&r?`${n} → ${r}`:void 0}var cr=/\.bpmn(\.xml)?$/i,lr=120;function isBpmnDiff(e){return cr.test(e.path)}function fingerprint(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t=Math.imul(t^e.charCodeAt(n),16777619)>>>0;return`${e.length}:${t.toString(36)}`}function miniOf(e){let t={index:0,operation:{op:`remove`,id:``},summary:``,added:e.added,addedFlows:e.addedFlows,removed:e.removed,changed:e.changed,moved:e.moved,touched:[]};return buildMiniDiff(e.before,[t])}var ur={element:`app.assistant.loose.element`,attach:`app.assistant.loose.attach`,scope:`app.assistant.loose.scope`,type:`app.assistant.loose.type`,reconnect:`app.assistant.loose.reconnect`,resize:`app.assistant.loose.resize`,property:`app.assistant.loose.property`,event:`app.assistant.loose.event`},dr=3;function notesOf(e){let t=new Map;for(let n of e)t.set(n.kind,[...t.get(n.kind)??[],n]);return[...t].map(([e,t])=>{let n=[...new Set(t.map(e=>e.id))],r=n.slice(0,dr).join(`, `);return m(ur[e],{ids:n.length>dr?`${r}, ...`:r,type:t[0].type?w(t[0].type):``})})}var fr=new Map;async function computeChange(e){if(e.newText.length>2e6||(e.oldText?.length??0)>2e6)return null;try{let{diffDiagrams:t}=await y(async()=>{let{diffDiagrams:e}=await import(`./diff-NgYeO98t.js`);return{diffDiagrams:e}},__vite__mapDeps([63,1,9,7,8,38,3,4]),import.meta.url),n=await t(e.oldText,e.newText);return n?{path:e.path,diff:n,mini:miniOf(n),notes:notesOf(n.loose),readable:n.operations.length>0}:null}catch(e){return console.error(`The change to a diagram could not be read:`,e),null}}function changeOf(e){let t=`${e.path}\u0000${fingerprint(e.oldText??``)}\u0000${fingerprint(e.newText)}`,n=fr.get(t);if(n)return fr.delete(t),fr.set(t,n),n;let r=computeChange(e);return fr.set(t,r),fr.size>lr&&fr.delete(fr.keys().next().value),r}var PictureBudget=class{spent=!1;take(){return!this.spent&&(this.spent=!0,!0)}},PictureBudgets=class{answers=new Map;of(e){let t=this.answers.get(e);if(t)return t;let n=new PictureBudget;return this.answers.set(e,n),n}},pr=8;function capital(e){return e.charAt(0).toUpperCase()+e.slice(1)}function chipOf(e,t,n,r=[]){let i=t?.name||(t?.source&&t.target?flowName(r.find(e=>e.id===t.source),r.find(e=>e.id===t.target)):void 0);return{kind:`element`,path:e,id:n,...t?{type:t.type}:{},...i?{name:i}:{}}}function lineOf(e,t){return{mark:e,parts:t,text:plain(t)}}function nodeLine(e,t,n){return lineOf(e,[`${capital(w(n.type))} `,chipOf(t,n,n.id)])}function flowLine(e,t,n,r){let i=r.find(e=>e.id===n.source),a=r.find(e=>e.id===n.target),o={};return n.source&&(o.from=chipOf(t,i,n.source)),n.target&&(o.to=chipOf(t,a,n.target)),lineOf(e,compose(e=>m(`app.assistant.change.flow`,{from:e.from??``,to:e.to??``}),o))}async function diagramLines(e){let t=await changeOf(e);if(!t)return null;let{diff:n}=t,r=[...n.after.nodes,...n.before.nodes],i=[],a=[],o=e.path;for(let e of n.added)i.push(nodeLine(`+`,o,e)),a.push(chipOf(o,e,e.id));for(let e of n.addedFlows)i.push(flowLine(`+`,o,e,r)),a.push(chipOf(o,e,e.id,r));for(let e of n.removed)i.push(e.type.toLowerCase().includes(`flow`)?flowLine(`-`,o,e,r):nodeLine(`-`,o,e));for(let e of n.changed){let t=chipOf(o,r.find(t=>t.id===e.id),e.id,r);a.push(t),i.push(lineOf(`~`,e.keys.length>0?compose(t=>m(`app.assistant.change.changed`,{name:t.name,what:e.keys.join(`, `)}),{name:t}):[t]))}for(let e of n.moved){let t=chipOf(o,r.find(t=>t.id===e.id),e.id,r);a.push(t),i.push(lineOf(`~`,compose(e=>m(`app.assistant.change.moved`,{name:e.name}),{name:t})))}return{lines:i,mini:t.mini.shapes.length+t.mini.flows.length>0&&t.mini.counts.added+t.mini.counts.removed+t.mini.counts.changed>0?t.mini:null,elements:a}}function textLine(e){let t=compareTexts(e.oldText??``,e.newText),n={kind:`file`,path:e.path};return e.oldText===null?lineOf(`+`,compose(e=>m(`app.assistant.change.created`,{name:e.name}),{name:n})):t?lineOf(`~`,compose(e=>m(`app.assistant.change.lines`,{name:e.name,added:t.theirs,removed:t.mine}),{name:n})):lineOf(`~`,compose(e=>m(`app.assistant.change.file`,{name:e.name}),{name:n}))}async function summarise(e){return summariseDiffs(e.tool.diffs)}async function summariseDiffs(e,t=new PictureBudget){let n=[],r=new Set,i=[];for(let a of e){r.add(pe(a.path));let e=isBpmnDiff(a)?await diagramLines(a).catch(()=>null):null;e&&e.lines.length>0?n.push(...e.lines):n.push(textLine(a));let o=e?.mini??null,s=o&&t.take()?o:null;i.push({diff:a,mini:s,drawable:o!==null,elements:e?.elements??[]})}let a=n.length;return{lines:n.slice(0,pr),files:[...r],count:a,diffs:i}}function questionOf(e,t){if(!t||t.count===0)return toolTitle(e.tool);let n=t.files.length===1?t.files[0]:m(`app.assistant.question.files`,{count:t.files.length});return m(`app.assistant.question.apply`,{count:t.count,file:n})}function ChipView({chip:e}){let t=useLinks();return e.kind===`file`?l(FileReference,{reference:{path:e.path,id:null,line:null},raw:e.label??pe(e.path)}):e.type?l(ElementChip,{id:e.id,type:e.type,name:e.name,onSelect:n=>{t.openElement(e.path,n),t.flash?.(e.path,[n])},onHover:(n,r)=>t.highlight?.(e.path,n,r)}):l(ElementReference,{reference:{path:e.path,id:e.id,line:null}})}function PartsView({parts:e}){return l(a,{children:e.map((e,t)=>typeof e==`string`?l(`span`,{children:e},t):l(ChipView,{chip:e},t))})}function ChipRow({chips:e,max:t}){if(e.length===0)return null;let n=e.slice(0,t),r=e.length-n.length;return l(`span`,{class:`assistant-chips`,children:[n.map((e,t)=>l(ChipView,{chip:e},t)),r>0&&l(`span`,{class:`assistant-chips__more type-help`,children:m(`app.assistant.sentence.more`,{count:r})})]})}var mr=new Map,hr=new Set,gr=100;function reportCheck(e,t){mr.delete(e),mr.set(e,t),mr.size>gr&&mr.delete(mr.keys().next().value);for(let e of[...hr])e()}function forgetCheck(e){if(mr.delete(e))for(let e of[...hr])e()}function checkOf(e){let t=`permission:${e}:`,n=null;for(let[e,r]of mr)e.startsWith(t)&&(n=n?{errors:n.errors+r.errors,warnings:n.warnings+r.warnings,resolved:n.resolved+r.resolved}:r);return n}function useProposalCheck(e){let[,n]=t(0);return f(()=>{let listener=()=>n(e=>e+1);return hr.add(listener),()=>{hr.delete(listener)}},[]),e?checkOf(e):null}function proposalId(e,t){return`permission:${e.id}:${t}`}function answerOptions(e){let t=e.tool.diffs.length>0,pick=(n,r)=>e.options.find(e=>e.kind===n)??(t?null:e.options.find(e=>e.kind===r)??null);return{allow:pick(`allow`,`allowAlways`),reject:pick(`reject`,`rejectAlways`)}}function connectReviews(e){let t=new Map,n=!1,withdraw=t=>{for(let n of t.ids)e.canvas.channel.withdraw(n),forgetCheck(n)},offer=async(r,i,a)=>{let o=e.file();if(!o)return;let{allow:s,reject:c}=answerOptions(i);if(s&&c)for(let l of i.tool.diffs){if(!isBpmnDiff(l)||!de(l.path,o))continue;let u=await changeOf(l);if(n||t.get(r)!==a)return;if(!u||u.diff.operations.length===0)continue;let d=proposalId(i,l.path),f={id:d,patch:{operations:u.diff.operations,title:toolTitle(i.tool)},source:`agent`,title:toolTitle(i.tool),createdAt:Date.now(),notes:u.notes,after:u.diff.after,checked:e=>reportCheck(d,e),whole:{accept:()=>void e.store.answer(r,i.id,s.id),reject:()=>void e.store.answer(r,i.id,c.id)}};a.ids.push(d),e.canvas.channel.offer(f)}},sync=()=>{if(n)return;let r=e.store.snapshot().transcripts;for(let[e,n]of[...t])r[e]?.permission?.id!==n.key&&(t.delete(e),withdraw(n));for(let[e,n]of Object.entries(r)){let r=n.permission;if(!r||t.get(e)?.key===r.id)continue;let i={key:r.id,ids:[]};t.set(e,i),offer(e,r,i).catch(e=>console.error(`The change could not be shown on the canvas:`,e))}},r=e.store.subscribe(sync);return sync(),()=>{n=!0,r();for(let e of t.values())withdraw(e);t.clear()}}var _r={allow:`app.assistant.question.allow`,reject:`app.assistant.question.deny`,allowAlways:`app.assistant.question.allowAlways`,rejectAlways:`app.assistant.question.denyAlways`};function labelOf(e){return _r[e.kind]?m(_r[e.kind]):e.label}function useSummary(e){let[n,r]=t(null);return f(()=>{let t=!0;return r(null),summarise(e).then(e=>t&&r(e)).catch(()=>t&&r({lines:[],files:[],count:0,diffs:[]})),()=>{t=!1}},[e.id]),n}function Question({store:e,chatId:t,permission:n,focus:r=!0,onShow:i}){let a=useLinks(),s=useSummary(n),c=useProposalCheck(n.id),u=o(null),d=n.tool.diffs.length>0,{allow:p,reject:h}=answerOptions(n),g=d?[]:n.options.filter(e=>e!==p&&e!==h),_=n.tool.diffs.find(e=>/\.bpmn(\.xml)?$/i.test(e.path))??null;f(()=>{r&&u.current?.focus()},[n.id,r]);let answer=r=>void e.answer(t,n.id,r);return l(`div`,{class:`assistant-question`,role:`group`,"aria-label":m(`app.assistant.question.label`),children:[l(`p`,{class:`assistant-question__title`,children:[l(J,{name:`hand`,class:`assistant-question__mark`}),l(`span`,{children:questionOf(n,s)})]}),s&&s.lines.length>0&&l(`ul`,{class:`assistant-question__changes type-code`,children:s.lines.map((e,t)=>l(`li`,{class:`assistant-question__change is-${e.mark===`+`?`added`:e.mark===`-`?`removed`:`changed`}`,children:[l(`span`,{class:`assistant-question__mark-line`,"aria-hidden":`true`,children:e.mark}),l(`span`,{class:`assistant-question__text`,children:l(PartsView,{parts:e.parts})})]},t))}),c&&l(`p`,{class:`assistant-question__check${c.errors>0?` is-error`:c.warnings>0?` is-warning`:``}`,children:[l(J,{name:c.errors>0||c.warnings>0?`alert`:`check`}),l(`span`,{children:c.errors+c.warnings===0?m(`app.assistant.question.clean`):m(`app.assistant.question.problems`,{count:c.errors+c.warnings})})]}),s&&s.diffs.map(e=>l(ChangePanel,{diff:e.diff,mini:e.mini},e.diff.path)),l(`div`,{class:`assistant-question__actions`,children:[h&&l(`button`,{ref:u,type:`button`,class:`assistant-button assistant-button--secondary`,onClick:()=>answer(h.id),onKeyDown:e=>{e.key===`Enter`&&e.preventDefault()},children:labelOf(h)}),p&&l(`button`,{type:`button`,class:`assistant-button assistant-button--primary`,onClick:()=>answer(p.id),children:labelOf(p)}),g.map(e=>l(`button`,{type:`button`,class:`assistant-button assistant-button--secondary`,onClick:()=>answer(e.id),children:labelOf(e)},e.id)),_&&l(`button`,{type:`button`,class:`assistant-link type-link`,onClick:()=>i?.(_.path)?void 0:a.openFile(_.path),children:m(`app.assistant.question.showOnCanvas`)}),d&&l(`span`,{class:`assistant-question__note type-help`,children:m(`app.assistant.question.undo`)})]})]})}function parsed(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t.startsWith(`[`)&&!t.startsWith(`{`))return e;try{return JSON.parse(t)}catch{return e}}function unwrap(e,t=0){if(t>4)return e;let n=parsed(e);if(Array.isArray(n)){let e=n.filter(e=>!!e&&typeof e==`object`&&e.type===`text`&&typeof e.text==`string`);return e.length>0&&e.length===n.length?unwrap(e.map(e=>e.text).join(`
|
|
144
144
|
`),t+1):n}if(n&&typeof n==`object`){let e=n;if(Array.isArray(e.content))return unwrap(e.content,t+1);if(typeof e.text==`string`&&Object.keys(e).length<=2)return unwrap(e.text,t+1);if(`result`in e&&Object.keys(e).length===1)return unwrap(e.result,t+1)}return n}function inputOf(e){let t=parsed(e.raw?.input);return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}function listOf(e){if(e.raw?.output===void 0)return null;let t=unwrap(e.raw.output);return Array.isArray(t)?t:null}function deadEndsOnly(e){return e.every(e=>typeof e==`object`&&!!e&&e.kind===`DEAD-ELEMENT`)}function elementChips(e,t){let n=new Set,r=[];for(let i of e){let e=i&&typeof i==`object`?i:{},a=[...Array.isArray(e.elements)?e.elements:[],...typeof e.elementId==`string`?[e.elementId]:[]];for(let e of a)typeof e!=`string`||n.has(e)||(n.add(e),r.push({kind:`element`,path:t,id:e}))}return r}var key=e=>`app.assistant.sentence.${e}`;function worded(e){return plain(e)}function build(e,t){let{input:n,file:r,list:i,done:a}=t,o=r?{kind:`file`,path:r}:null,withFile=(e,t={})=>o?compose(n=>m(key(e),{...t,file:n.file}),{file:o}):[m(key(e),{...t,file:``}).trim()],say=(e,t={})=>[m(key(e),t)],found=(e,t=[])=>({parts:e,chips:t,failed:!1});switch(e){case`listDiagrams`:return found(a?i?say(`listed`,{count:i.length}):say(`listedPlain`):say(`listing`));case`showDiagram`:return found(withFile(a?`read`:`reading`));case`checkDiagram`:return a?i?found(i.length===0?withFile(`checkedClean`):withFile(`checked`,{count:i.length}),r?elementChips(i,r):[]):found(withFile(`checkedPlain`)):found(withFile(`checking`));case`analyzeFlow`:return a?i?found(i.length===0?say(`analysedClean`):say(deadEndsOnly(i)?`analysedDeadEnds`:`analysed`,{count:i.length}),r?elementChips(i,r):[]):found(withFile(`analysedPlain`)):found(withFile(`analysing`));case`listScenarios`:{if(!a)return found(withFile(`scenariosListing`));if(!i)return found(withFile(`scenariosPlain`));let e=i.filter(e=>!!e&&typeof e==`object`&&typeof e.passed==`boolean`);return i.length>0&&e.length===i.length?found(say(`scenariosRan`,{count:i.length,passed:e.filter(e=>e.passed).length})):found(say(`scenariosListed`,{count:i.length}))}case`checkCodeLinks`:return found(a?i?i.length===0?say(`codeClean`):say(`codeChecked`,{count:i.length}):say(`codePlain`):say(`codeChecking`));default:{let e=n.dryRun===!0;return found(withFile(a?e?`previewed`:`edited`:e?`previewing`:`editing`))}}}function sentenceOf(e){let t=ownToolName(e);if(!t)return null;let n={input:inputOf(e),file:null,list:listOf(e),done:e.status===`done`};if(n.file=typeof n.input.file==`string`?n.input.file:null,e.status===`failed`){let e=worded(build(t,{...n,list:null,done:!1}).parts);return{parts:[m(key(`unfinished`),{step:e})],chips:[],failed:!0}}return build(t,n)}var vr={pending:`app.assistant.tool.pending`,running:`app.assistant.tool.running`,done:`app.assistant.tool.done`,failed:`app.assistant.tool.failed`,stopped:`app.assistant.tool.stopped`};function Mark({status:e}){return e===`running`?l(`span`,{class:`assistant-mark is-running`,children:l(X,{})}):e===`done`?l(`span`,{class:`assistant-mark is-done`,children:l(J,{name:`check`})}):e===`failed`||e===`stopped`?l(`span`,{class:`assistant-mark is-failed`,children:l(J,{name:`failed`})}):l(`span`,{class:`assistant-mark is-pending`,children:l(J,{name:`pending`})})}function linesOf(e){return e.split(`
|
|
145
|
-
`).length}function FoldedCode({text:e,lang:n}){let[r,i]=t(!1);return l(`details`,{class:`assistant-code`,onToggle:e=>i(e.currentTarget.open),children:[l(`summary`,{class:`assistant-code__summary type-help`,children:`${m(`app.assistant.view.showSource`)} · ${linesOf(e)}`}),r&&l(`pre`,{class:`assistant-rich__code type-code`,"data-lang":n||void 0,children:e})]})}function AnswerText({text:e}){return l(RichText,{text:fenceDocument(e),code:e=>l(FoldedCode,{text:e.text,lang:e.lang})})}function ToolStep({tool:e,surface:t}){let n=sentenceOf(e),r=e.status;return l(`li`,{class:`assistant-row is-${r}`,children:[l(Mark,{status:r}),l(`span`,{class:`assistant-row__text`,title:n?plain(n.parts):toolTitle(e),children:n?l(PartsView,{parts:n.parts}):toolTitle(e)}),n&&n.chips.length>0&&l(ChipRow,{chips:n.chips,max:3}),t===`tab`&&l(`span`,{class:`assistant-row__state type-help`,children:m(vr[r])})]})}function StepRow({step:e,surface:t}){switch(e.kind){case`tool`:return t===`card`&&isBookkeeping(e.tool)?null:l(ToolStep,{tool:e.tool,surface:t});case`plan`:return l(a,{children:e.items.map((t,n)=>l(`li`,{class:`assistant-row is-${t.status}`,children:[l(Mark,{status:t.status}),l(`span`,{class:`assistant-row__text`,children:t.text})]},`${e.id}-${n}`))});case`thought`:return t===`card`?null:l(`li`,{class:`assistant-row is-thought`,children:l(`span`,{class:`assistant-row__text type-help`,children:e.text})})}}function currentStep(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.kind===`tool`&&!isBookkeeping(n.tool)){let e=sentenceOf(n.tool);if(e)return plain(e.parts);break}}return stepOf(e)}function WorkRow({steps:e,running:t,surface:n}){let r=countSteps(e,n===`tab`);if(r===0&&!t)return null;let i=e.some(e=>e.kind===`tool`&&e.tool.status===`failed`);return l(`details`,{class:`assistant-work`,open:n===`tab`||void 0,children:[l(`summary`,{class:`assistant-work__summary`,"aria-label":m(`app.assistant.work.label`),children:[l(Mark,{status:t?`running`:i?`failed`:`done`}),l(`span`,{class:`assistant-work__label type-body`,children:t?currentStep(e):m(`app.assistant.work.steps`,{count:r})}),l(J,{name:`chevronDown`,class:`assistant-work__chevron`})]}),l(`ul`,{class:`assistant-rows`,children:e.map(e=>l(StepRow,{step:e,surface:n},e.id))})]})}function distinctElements(e){let t=new Set;return e.filter(e=>{let n=JSON.stringify(e.kind===`element`?[e.path,e.id]:[e.path]);return!t.has(n)&&(t.add(n),!0)})}function AppliedRow({entry:e,pictures:n}){let[r,i]=t(null);f(()=>{let t=!0;return summariseDiffs(e.tool.diffs,n).then(e=>t&&i(e)).catch(()=>t&&i({lines:[],files:[],count:0,diffs:[]})),()=>{t=!1}},[e.id]);let a=distinctElements(r?r.diffs.flatMap(e=>e.elements):[]),o=e.tool.diffs[0];return l(`div`,{class:`assistant-applied`,children:[l(`p`,{class:`assistant-applied__row type-body`,children:[l(Mark,{status:`done`}),l(`span`,{class:`assistant-applied__label`,children:a.length>0?m(`app.assistant.view.applied`,{count:a.length}):l(PartsView,{parts:r?.lines[0]?.parts??[m(`app.assistant.view.appliedFile`,{file:o.path.split(/[\\/]/).pop()??o.path})]})}),a.length>0&&l(ChipRow,{chips:a,max:3})]}),r&&r.diffs.map(e=>l(ChangePanel,{diff:e.diff,mini:e.mini,initial:e.drawable?null:`source`},e.diff.path))]})}function TranscriptView({store:e,chatId:t,entries:n,permission:r,running:i,surface:a,onShow:s,focus:c}){let u=blocksOf(n),d=u[u.length-1],f=i&&!r,p=o(new PictureBudgets).current,h=``;return l(`div`,{class:`assistant-transcript is-${a}`,children:[u.map(e=>{switch(e.kind){case`work`:return l(WorkRow,{steps:e.steps,running:f&&e===d,surface:a},e.id);case`applied`:return l(AppliedRow,{entry:e.entry,pictures:p.of(h)},e.id);case`entry`:{let t=e.entry;return t.kind===`user`?(h=e.id,l(`div`,{class:`assistant-entry is-user`,children:l(RichText,{text:t.text})},e.id)):t.kind===`agent`?l(`div`,{class:`assistant-entry is-agent`,children:l(AnswerText,{text:t.text})},e.id):l(`p`,{class:`assistant-entry is-notice type-help`,children:t.text},e.id)}}}),f&&(!d||d.kind!==`work`)&&l(`p`,{class:`assistant-transcript__working type-help`,children:[l(X,{}),` `,m(`app.assistant.working`)]}),r&&l(Question,{store:e,chatId:t,permission:r,focus:c,onShow:s?e=>s(r,e):void 0})]})}var yr=24,br=2;function useFollow(e,t){let n=o(null),r=o(!0),i=o(null),a=o(!1),s=o(0),anchor=()=>{let e=n.current,t=e?.querySelector(`.assistant-question`);e&&t&&(s.current=t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop,e.scrollTop=s.current)};return u(()=>{let t=n.current;t&&(e?(r.current=!1,i.current!==e&&(i.current=e,a.current=!0,anchor())):(i.current!==null&&(i.current=null,a.current=!1,r.current=!0),r.current&&(t.scrollTop=t.scrollHeight)))},[e,t]),u(()=>{let t=e?n.current?.querySelector(`.assistant-question`):null;if(!t||typeof ResizeObserver>`u`)return;let r=new ResizeObserver(()=>{a.current&&anchor()});return r.observe(t),()=>r.disconnect()},[e]),{ref:n,onScroll:t=>{let n=t.currentTarget;if(e){let e=Math.min(s.current,n.scrollHeight-n.clientHeight);Math.abs(n.scrollTop-e)>br&&(a.current=!1)}else r.current=n.scrollHeight-n.scrollTop-n.clientHeight<yr}}}function agentName(e,t){return e.choices.find(e=>e.id===t.agentId)?.name??t.agentId}function Failure({store:e,state:n,chat:r,transcript:i,onChooseAgent:a,onAgentSettings:o}){let{unlock:s}=useLicence(),[c,u]=t(!1),d=classify(i?.error??null,n.choices,n.loaded),f=installCommand(n.choices,r.agentId),p=failureSummary(i?.error??null,r.detail??``),retry=()=>void e.tryAgain(r.id,()=>s(C.AI_CHAT)),h=d===`signedOut`&&i?.error?.signIn===!0,signIn=()=>{u(!0),e.signIn(r.id,()=>s(C.AI_CHAT)).finally(()=>u(!1))};return d===`noAgent`?l(`div`,{class:`assistant-empty`,children:[l(`p`,{class:`assistant-empty__text`,children:m(`app.assistant.noAgent.text`)}),f&&l(Oe,{command:f}),l(`div`,{class:`assistant-empty__actions`,children:[a&&l(`button`,{type:`button`,class:`assistant-button assistant-button--secondary`,onClick:a,children:m(`app.assistant.noAgent.choose`)}),o&&l(`button`,{type:`button`,class:`assistant-button assistant-button--secondary`,onClick:o,children:m(`app.assistant.noAgent.settings`)})]})]}):l(`div`,{class:`assistant-empty`,children:[l(`p`,{class:`assistant-empty__text`,children:p.text||m(d===`signedOut`?`app.assistant.signedOut.text`:`app.assistant.ended.text`)}),p.details&&l(FailureDetails,{text:p.details}),l(`div`,{class:`assistant-empty__actions`,children:[h&&l(`button`,{type:`button`,class:`assistant-button assistant-button--primary`,disabled:c,onClick:signIn,children:m(`app.assistant.signIn`)}),l(`button`,{type:`button`,class:`assistant-button assistant-button--secondary`,onClick:retry,children:m(`app.assistant.tryAgain`)})]})]})}function AssistantCard({store:e,state:t,editor:n,chat:r,transcript:i,peeking:a,onChooseAgent:o,onAgentSettings:s}){let c=r.state===`failed`,u=c?classify(i?.error??null,t.choices,t.loaded):null,d=i?.permission??null,f=r.state===`connecting`,p=r.state===`working`||r.state===`waiting`||f,h=i?.entries??[],g=expandReason(h),_=h[h.length-1],v=useFollow(d?.id??null,`${h.length}:${_&&`text`in _?_.text.length:0}:${r.state}`),y=u===`noAgent`?m(`app.assistant.noAgent.title`):u===`signedOut`?m(`app.assistant.signedOut.title`,{agent:agentName(t,r)}):u===`ended`?m(`app.assistant.ended.title`):r.title,showHere=(t,i)=>{if(!n.canvas?.channel.has(proposalId(t,i)))return!1;e.setFolded(r.id,!0);let a=n.canvas.channel;return requestAnimationFrame(()=>requestAnimationFrame(()=>a.fit())),!0};return l(`section`,{class:`assistant-card${d?` is-asking`:``}${c?` is-failed`:``}${a&&!d&&!c?` is-peeking`:``}`,"aria-label":m(`app.assistant.card.label`),"data-editor":n.key,children:[l(`header`,{class:`assistant-card__head`,children:[l(J,{name:c?`alert`:`chat`,class:`assistant-card__icon${c?` is-warning`:``}`}),l(`span`,{class:`assistant-card__title`,title:y,children:y}),!c&&l(`span`,{class:`assistant-card__agent type-help`,children:`· ${agentName(t,r)}`}),l(`span`,{class:`assistant-card__buttons`,children:[!c&&l(`button`,{type:`button`,class:`assistant-button assistant-button--icon`,"aria-label":m(`app.assistant.card.newChat`),title:m(`app.assistant.card.newChat`),disabled:p||d!==null,onClick:()=>e.select(n.key,null),children:l(J,{name:`plus`})}),!c&&l(`button`,{type:`button`,class:`assistant-button assistant-button--icon`,"aria-label":m(`app.assistant.card.expand`),title:m(`app.assistant.card.expand`),onClick:()=>e.reveal(n.key),children:l(J,{name:`expand`})}),l(`button`,{type:`button`,class:`assistant-button assistant-button--icon`,"aria-label":m(c?`app.assistant.card.close`:`app.assistant.card.fold`),title:m(c?`app.assistant.card.close`:`app.assistant.card.fold`),onClick:()=>c?e.dismissCard(r.id):e.setFolded(r.id,!0),children:l(J,{name:c?`close`:`chevronDown`})})]})]}),!c&&g&&l(`p`,{class:`assistant-card__suggest type-help`,children:[l(`span`,{children:m(g===`long`?`app.assistant.card.suggestLong`:`app.assistant.card.suggestDocument`)}),l(`button`,{type:`button`,class:`assistant-link type-link`,onClick:()=>e.reveal(n.key),children:m(`app.assistant.card.suggest`)})]}),l(`div`,{class:`assistant-card__body`,ref:v.ref,onScroll:v.onScroll,children:[c&&l(Failure,{store:e,state:t,chat:r,transcript:i,onChooseAgent:o,onAgentSettings:s}),!c&&f&&l(`p`,{class:`assistant-card__status type-help`,role:`status`,children:[l(X,{}),` `,m(`app.assistant.card.connecting`)]}),!c&&!f&&i?.status===`loading`&&h.length===0&&l(`p`,{class:`assistant-card__status type-help`,role:`status`,children:[l(X,{}),` `,m(`app.assistant.card.loading`)]}),!c&&i&&l(TranscriptView,{store:e,chatId:r.id,entries:h,permission:d,running:p,surface:`card`,onShow:showHere})]})]})}var xr=[hn,mn];function FailureNotice({failure:e,choices:t,onRetry:n,onSettings:r}){let i=failureSummary(e,``),a=xr.includes(e.key)?installCommand(t,null):null;return l(`div`,{class:`assistant-empty`,children:[l(`p`,{class:`assistant-empty__text`,children:i.text||m(`app.assistant.ended.text`)}),a&&l(Oe,{command:a}),i.details&&l(FailureDetails,{text:i.details}),l(`div`,{class:`assistant-empty__actions`,children:[l(`button`,{type:`button`,class:`assistant-button assistant-button--secondary`,onClick:n,children:m(`app.assistant.tryAgain`)}),l(`button`,{type:`button`,class:`assistant-button assistant-button--secondary`,onClick:r,children:m(`app.assistant.noAgent.settings`)})]})]})}var Sr=i(!0),Cr=Sr.Provider;function useEditorActive(){return r(Sr)}var wr=i(null),Tr=wr.Provider;function useEditorElement(e){let t=r(wr);return t?t.current?Ze(e,t.current):null:Ze(e)}var ReviewChannel=class{listeners=new Set;withdrawals=new Set;pending=new Map;counter=0;covering=null;coverListeners=new Set;fitListeners=new Set;subscribe(e){this.listeners.add(e);for(let t of[...this.pending.values()])e(t);return()=>{this.listeners.delete(e)}}onWithdraw(e){return this.withdrawals.add(e),()=>{this.withdrawals.delete(e)}}propose(e){let t=Object.hasOwn(e,`patch`)?e:{patch:e};this.counter+=1;let n={id:`channel-${this.counter}`,patch:t.patch,source:t.source??`channel`,createdAt:Date.now(),...t.title?{title:t.title}:{}};return this.offer(n),n}offer(e){this.pending.set(e.id,e);for(let t of[...this.listeners])t(e);this.coverChanged()}withdraw(e){if(this.pending.delete(e)){for(let t of[...this.withdrawals])t(e);this.coverChanged()}}setCover(e){e===this.covering||e!==null&&this.covering!==null&&e.left===this.covering.left&&e.bottom===this.covering.bottom&&(e.right??0)===(this.covering.right??0)||(this.covering=e,this.coverChanged())}cover=()=>this.pending.size>0?this.covering:null;onCover=e=>(this.coverListeners.add(e),()=>{this.coverListeners.delete(e)});fit(){for(let e of[...this.fitListeners])e()}onFit=e=>(this.fitListeners.add(e),()=>{this.fitListeners.delete(e)});coverChanged(){for(let e of[...this.coverListeners])e()}proposedFacts(e){for(let t of this.pending.values()){let n=t.after?.nodes??[],r=[...n,...t.after?.flows??[]].find(t=>t.id===e);if(!r)continue;let i=r.name||(r.source&&r.target?flowName(n.find(e=>e.id===r.source),n.find(e=>e.id===r.target)):void 0);return{type:r.type,...i?{name:i}:{}}}return null}has(e){return this.pending.has(e)}get size(){return this.pending.size}};function motionMs(e){let t=parseFloat(getComputedStyle(document.documentElement).getPropertyValue(e));return Number.isFinite(t)?t:0}function reducedMotion(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}var Er=`penstock-chip-hover`,Dr=`penstock-chip-flash`,Or=new Set([`bpmn:Process`,`bpmn:Collaboration`]);function endOf(e){return e?{name:e.name,type:e.$type}:null}function factsOf(e){let t=e?.businessObject;if(!e||!t||e.type===`label`||!t.$type||Or.has(t.$type))return null;let n=t.name?String(t.name):t.$type===`bpmn:SequenceFlow`?flowName(endOf(t.sourceRef),endOf(t.targetRef)):void 0;return{id:e.id,type:t.$type,...n?{name:n}:{}}}var EditorCanvas=class{channel=new ReviewChannel;feed=this.channel;picked=[];flashing=new Map;modeler=null;listeners=new Set;commenter;constructor(e=()=>void 0){this.commenter=e}onComment=(e,t)=>{this.commenter(e,t)};read=()=>this.picked;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});changed(){for(let e of[...this.listeners])e()}follow=()=>{let e=(this.modeler?.get(`selection`,!1)?.get?.()??[]).map(factsOf).filter(e=>e!==null);e.length===this.picked.length&&e.every((e,t)=>e.id===this.picked[t].id&&e.name===this.picked[t].name&&e.type===this.picked[t].type)||(this.picked=e,this.changed())};attach=e=>{this.detach(),this.modeler=e,(e?.get?.(`eventBus`,!1))?.on([`selection.changed`,`element.changed`,`import.done`],this.follow),this.follow()};detach=()=>{(this.modeler?.get?.(`eventBus`,!1))?.off([`selection.changed`,`element.changed`,`import.done`],this.follow),this.modeler=null,this.picked.length>0&&(this.picked=[],this.changed())};describe(e){let t=factsOf(this.modeler?.get?.(`elementRegistry`,!1)?.get(e));if(t)return t;let n=this.channel.proposedFacts(e);return n?{id:e,...n}:null}elements=()=>{let e=this.modeler?.get?.(`elementRegistry`,!1);return e?(e.getAll?.()??[]).filter(e=>!e.waypoints).map(factsOf).filter(e=>e!==null):[]};mark(e,t){let n=this.modeler?.get?.(`elementRegistry`,!1),r=this.modeler?.get?.(`canvas`,!1);r&&n?.get(e)&&(t?r.addMarker(e,Er):r.removeMarker(e,Er))}flash(e){let t=this.modeler?.get?.(`elementRegistry`,!1),n=this.modeler?.get?.(`canvas`,!1);if(n&&t)for(let r of e)t.get(r)&&(n.addMarker(r,Dr),clearTimeout(this.flashing.get(r)),this.flashing.set(r,setTimeout(()=>{this.flashing.delete(r),n.removeMarker(r,Dr)},motionMs(`--motion-flash`))))}select(e){let t=(this.modeler?.get?.(`elementRegistry`,!1))?.get(e);return t?(this.modeler.get(`selection`,!1)?.select(t),!0):!1}},CanvasRegistry=class{entries=new Map;set(e,t){return this.entries.set(e,t),()=>{this.entries.get(e)===t&&this.entries.delete(e)}}get(e){return this.entries.get(e)}find(e){let t=this.entries.get(e);if(t)return t;let n=e.replace(/\\/g,`/`);for(let[e,t]of this.entries){let r=e.replace(/\\/g,`/`);if(r===n||r.endsWith(`/${n}`)||n.endsWith(`/${r}`))return t}}},kr=new CanvasRegistry,Ar=new Map,jr=new Map,Mr=new Set;function changed(){for(let e of[...Mr])e()}function installScenarioOpener(e,t){return jr.set(e,t),()=>{jr.get(e)===t&&jr.delete(e)}}function requestScenario(e,t){Ar.set(e,t),changed(),jr.get(e)?.()}function takeScenarioRequest(e){let t=Ar.get(e)??null;return t!==null&&(Ar.delete(e),changed()),t}function useScenarioRequest(e){let[,n]=t(0);return f(()=>{let again=()=>n(e=>e+1);return Mr.add(again),()=>{Mr.delete(again)}},[]),e===null?null:Ar.get(e)??null}var Nr=/\.(java|kt|kts|groovy|scala|py|js|mjs|cjs|ts|go|cs)$/,Pr=[[/\.bpmn(\.xml)?$/i,`bpmn`],[/\.dmn$/i,`dmn`],[/\.form$/i,`form`]],Fr=Pr[0][0],Ir=250,Lr=1e3,Rr=/^([A-Za-z]:)?[\\/]/;async function parse(e){let{inspectModel:t}=await y(async()=>{let{inspectModel:e}=await import(`./apply-CzXxiRWK.js`).then(e=>e.n);return{inspectModel:e}},__vite__mapDeps([38,1,3,4,9,7,8]),import.meta.url),n=await t(e,M(e)??`classic`),r=new Map;if(!n)return r;for(let e of n.elements)r.set(e.id,{type:e.type.includes(`:`)?e.type:`bpmn:${e.type}`,...e.name?{name:e.name}:{}});for(let e of n.flows){let t=r.get(e.id);if(!t||t.name)continue;let i=flowName(n.nodes.find(t=>t.id===e.source),n.nodes.find(t=>t.id===e.target));i&&r.set(e.id,{...t,name:i})}return r}function kindOf(e){return Pr.find(([t])=>t.test(e))?.[1]??null}async function projectRootOf(){return(await j().getProjectFiles()).root}function absoluteOf(e,t){return Rr.test(t)||e===``?t:`${e.replace(/[\\/]+$/,``)}/${t}`}async function scenarioNamesOf(e){let t=await j().readFile(e),{parsed:n}=await ne(e,t),r=new Map;for(let e of n.file?.testCases??[])r.set(e.name,(r.get(e.name)??0)+1);return r}function ownElements(e){return kr.find(e)?.elements()??[]}function createBridgeLinks(e,t=projectRootOf){let n=new Map,r=new Map,i=new Map,a=new Map,o=new Map,s=new Set,c=null,l=null,u=null,notify=()=>{c===null&&(c=setTimeout(()=>{c=null;for(let e of[...s])e()},Ir))},settle=()=>(u??=(async()=>{try{l=await t()}catch{l=``}notify()})(),u),absolute=e=>absoluteOf(l??``,e),load=e=>{let t=r.get(e);if(t)return t;let i=(async()=>{try{let t=await j().readFile(e);n.set(e,await parse(t))}catch{n.set(e,null)}notify()})();return r.set(e,i),i.finally(()=>r.delete(e)),i},readScenarioNames=e=>{let t=a.get(e);if(t)return t;let n=scenarioNamesOf(e).catch(()=>new Map).then(t=>{i.set(e,{names:t,at:Date.now()}),notify()});return a.set(e,n),n.finally(()=>a.delete(e)),n},own=t=>{let n=e();return!!n?.file&&de(n.file,t)},liveOf=(e,t)=>own(e)?kr.find(e)?.describe(t):null;return{file(e){let t=kindOf(e);return t?n.get(absolute(e))===null?null:{rel:e,kind:t}:o.get(e)===!0?{rel:e,kind:`source`}:null},async check(e){if(!o.has(e)&&Nr.test(e)){await settle();try{let t=await j().readCodeSnippet?.(absolute(e),1,1);o.set(e,(t?.lines.length??0)>0)}catch{o.set(e,!1)}}},async element(e,t){if(!Fr.test(e))return null;await settle();let r=absolute(e),i=liveOf(r,t);return i?{type:i.type,...i.name?{name:i.name}:{}}:(await load(r),n.get(r)?.get(t)??null)},peek(e,t){if(!Fr.test(e))return null;if(l===null)return;let r=absolute(e),i=liveOf(r,t);if(i)return{type:i.type,...i.name?{name:i.name}:{}};if(n.has(r))return n.get(r)?.get(t)??null},subscribe(e){return s.add(e),()=>{s.delete(e)}},openFile(e){settle().then(()=>j().revealElement(absolute(e))).catch(e=>console.error(`The file could not be opened:`,e))},openElement(e,t){settle().then(async()=>{let n=absolute(e);(own(n)?kr.find(n):void 0)?.select(t)||await j().revealElement(n,t)}).catch(e=>console.error(`The element could not be revealed:`,e))},named(t){let n=e();if(!n?.file||!Fr.test(n.file))return null;let r=ownElements(n.file).filter(e=>e.name===t);return r.length===1?{file:n.file,id:r[0].id,type:r[0].type,name:t}:null},scenario(t){let n=e();return!n?.file||!Fr.test(n.file)||ownElements(n.file).some(e=>e.name===t)?null:i.get(absolute(n.file))?.names.get(t)===1?{file:n.file,name:t}:null},async refreshScenarios(){let t=e();if(!t?.file||!Fr.test(t.file))return;await settle();let n=absolute(t.file),r=i.get(n);r&&Date.now()-r.at<Lr||await readScenarioNames(n)},openScenario(e,t){requestScenario(e,t)},highlight(e,t,n){let r=absolute(e);own(r)&&kr.find(r)?.mark(t,n)},flash(e,t){let n=absolute(e);own(n)&&kr.find(n)?.flash(t)},openCode(e,t){settle().then(()=>j().openAsText(absolute(e),t??void 0)).catch(e=>console.error(`The file could not be opened:`,e))},dispose(){c!==null&&clearTimeout(c),s.clear()}}}var zr=new Map;function useBridgeLinks(e){let t=o(e);t.current=e;let n=c(()=>createBridgeLinks(()=>t.current),[]);return f(()=>()=>n.dispose(),[n]),n}function AssistantRuntime({editor:e}){let t=G(),n=useEditorActive();f(()=>{t&&t.start()},[t]),f(()=>ue(),[]),f(()=>{zr.set(e.key,e);let t=e.canvas?kr.set(e.key,e.canvas):void 0;return()=>{zr.get(e.key)===e&&zr.delete(e.key),t?.()}},[e]);let r=W(t?t.subscribe:()=>()=>void 0,()=>t?.snapshot().loaded??!1);return f(()=>{t&&r&&t.settle(e.key,e.file)},[t,r,e.key,e.file]),f(()=>{t&&n&&t.focus(e.key)},[t,n,e.key]),f(()=>()=>t?.unfocus(e.key),[t,e.key]),f(()=>{if(t&&e.canvas)return connectReviews({store:t,canvas:e.canvas,file:()=>e.file})},[t,e.canvas,e.file]),null}var Br=/\.(bpmn|dmn|form)$/i;function latestDiagramOf(e){return[...e.files].reverse().find(e=>Br.test(e))??null}var Vr={idle:`app.assistant.state.idle`,connecting:`app.assistant.state.connecting`,working:`app.assistant.state.working`,waiting:`app.assistant.state.waiting`,failed:`app.assistant.state.failed`};function stateLine(e,t=Date.now()){return e.detail?e.detail:e.state===`idle`?le(e.updated,t):m(Vr[e.state])}function Dot({state:e}){return e===`working`||e===`connecting`?l(`span`,{class:`assistant-chat__mark`,children:l(X,{})}):l(`span`,{class:`assistant-chat__mark`,children:l(`i`,{class:`assistant-chat__dot is-${e}`})})}async function confirmDelete(e){return j().confirmWithUser({title:m(`app.assistant.delete.title`),text:m(`app.assistant.delete.text`,{title:e.title}),accept:m(`app.assistant.delete.accept`),decline:m(`app.common.cancel`),warning:!0})}function ChatsSection({store:e,editor:n,onOpen:r,onOpenFile:i}){let a=W(e.subscribe,e.snapshot),[o,s]=t(null),[c,u]=t(null),d=n?a.active[n]:null;if(f(()=>{e.start()},[e]),!a.enabled)return null;let open=t=>{if(n)e.select(n,t.id),e.reveal(n);else{let n=latestDiagramOf(t);if(n){let r=[...zr.values()].find(e=>e.file!==null&&de(e.file,n));r?(e.select(r.key,t.id),e.reveal(r.key)):e.expectChat(t.id,n),i?.(n)}}r?.(t)},create=async()=>{await e.create(n)&&n&&e.reveal(n)},remove=async t=>{await confirmDelete(t)&&await e.remove(t.id)},items=e=>[{id:`rename`,label:m(`app.assistant.rename`),run:()=>u(e.id)},{id:`delete`,label:m(`app.assistant.delete.action`),danger:!0,run:()=>void remove(e)}];return l(`section`,{class:`assistant-chats`,"aria-label":m(`app.assistant.chats.label`),children:[l(`div`,{class:`assistant-chats__head`,children:[l(`h2`,{class:`assistant-chats__title type-section-heading`,children:m(`app.assistant.chats.title`)}),l(`span`,{class:`assistant-chats__buttons`,children:[l(`button`,{type:`button`,class:`assistant-button assistant-button--icon`,"aria-label":m(`app.assistant.chats.new`),title:m(`app.assistant.chats.new`),onClick:()=>void create(),children:l(J,{name:`plus`})}),l(`button`,{type:`button`,class:`assistant-button assistant-button--icon`,"aria-label":m(`app.assistant.chats.agents`),title:m(`app.assistant.chats.agents`),onClick:()=>void ce(),children:l(J,{name:`settings`})})]})]}),a.loaded&&a.chats.length===0&&l(`p`,{class:`assistant-chats__empty type-help`,children:m(`app.assistant.chats.empty`)}),l(`ul`,{class:`assistant-chats__list`,children:a.chats.map(t=>l(`li`,{children:c===t.id?l(Rename,{chat:t,onDone:n=>{u(null),n!==null&&n!==t.title&&e.rename(t.id,n)}}):l(`button`,{type:`button`,class:`assistant-chat${d===t.id?` is-selected`:``} is-${t.state}`,"aria-current":d===t.id?`true`:void 0,onClick:()=>open(t),onContextMenu:e=>{e.preventDefault(),s({at:{x:e.clientX,y:e.clientY},chat:t})},onKeyDown:e=>{if(e.key===`F2`)e.preventDefault(),u(t.id);else if(e.key===`Delete`)e.preventDefault(),remove(t);else if(e.key===`ContextMenu`||e.key===`F10`&&e.shiftKey){e.preventDefault();let n=e.currentTarget.getBoundingClientRect();s({at:{x:n.left+24,y:n.bottom},chat:t})}},children:[l(Dot,{state:t.state}),l(`span`,{class:`assistant-chat__body`,children:[l(`span`,{class:`assistant-chat__title type-body`,children:t.title}),l(`span`,{class:`assistant-chat__state type-help`,children:stateLine(t)})]})]})},t.id))}),o&&l(Ce,{label:m(`app.assistant.chats.menu`),at:o.at,items:items(o.chat),onClose:()=>s(null)})]})}function Rename({chat:e,onDone:t}){let n=o(null),r=o(!1),finish=e=>{r.current||(r.current=!0,t(e))};return f(()=>{n.current?.focus(),n.current?.select()},[]),l(`input`,{ref:n,class:`assistant-chat__rename type-input`,"aria-label":m(`app.assistant.rename`),defaultValue:e.title,maxLength:200,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),finish(e.currentTarget.value.trim()||null)):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),finish(null))},onBlur:e=>finish(e.currentTarget.value.trim()||null)})}function ChatSwitcher({store:e,state:n,editor:r,chat:i}){let s=o(null),[c,u]=t(!1),d=i?.title??m(`app.assistant.chats.new`),choose=t=>{e.select(r,t),u(!1),e.focusInput(r)};return l(a,{children:[l(`button`,{ref:s,type:`button`,class:`assistant-switch type-help`,title:d,"aria-label":`${m(`app.assistant.switch.label`)}: ${d}`,"aria-haspopup":`listbox`,"aria-expanded":c,onClick:()=>u(e=>!e),children:[l(J,{name:`chat`,class:`assistant-switch__icon`}),l(`span`,{class:`assistant-switch__title`,children:d}),l(J,{name:`chevronDown`,class:`assistant-switch__chevron`})]}),c&&l(xe,{anchor:s.current,label:m(`app.assistant.switch.list`),onClose:()=>u(!1),width:288,class:`assistant-switch__popover`,children:l(`ul`,{class:`assistant-switch__list`,role:`listbox`,"aria-label":m(`app.assistant.switch.list`),children:[l(`li`,{role:`presentation`,children:l(`button`,{type:`button`,role:`option`,"aria-selected":i===null,class:`assistant-switch__item assistant-switch__item--new type-body`,onClick:()=>choose(null),children:[l(J,{name:`plus`}),l(`span`,{class:`assistant-switch__name`,children:m(`app.assistant.chats.new`)})]})}),n.chats.map(e=>l(`li`,{role:`presentation`,children:l(`button`,{type:`button`,role:`option`,"aria-selected":e.id===i?.id,class:`assistant-switch__item type-body`,onClick:()=>choose(e.id),children:[l(`span`,{class:`assistant-switch__name`,title:e.title,children:e.title}),l(`span`,{class:`assistant-switch__state type-help`,children:stateLine(e)})]})},e.id))]})})]})}var Hr=40;function useFiles(){let[e,n]=t(null);return f(()=>{let e=!0;return j().getProjectFiles().then(t=>e&&n({root:t.root,paths:t.files.map(e=>e.path)})).catch(()=>e&&n({root:``,paths:[]})),()=>{e=!1}},[]),e}function Mentions({store:e,editor:n,anchor:r,onClose:i}){let[a,o]=t(``),s=useFiles(),u=c(()=>n.canvas?n.canvas.elements():n.elements?.()??[],[n]),d=a.trim().toLowerCase(),f=u.filter(e=>!d||`${e.name??``} ${e.id} ${w(e.type)}`.toLowerCase().includes(d)).slice(0,Hr),p=s?.root.replace(/\\/g,`/`).replace(/\/$/,``)??``,h=(s?.paths??[]).map(e=>({path:e,rel:e.replace(/\\/g,`/`).startsWith(`${p}/`)?e.replace(/\\/g,`/`).slice(p.length+1):e})).filter(e=>!d||e.rel.toLowerCase().includes(d)).slice(0,Hr);return l(xe,{anchor:r,label:m(`app.assistant.mention.label`),onClose:i,width:320,class:`assistant-mentions`,children:[l(`input`,{type:`search`,class:`assistant-mentions__search type-input`,"aria-label":m(`app.assistant.mention.search`),placeholder:m(`app.assistant.mention.search`),value:a,onInput:e=>o(e.currentTarget.value)}),l(`div`,{class:`assistant-mentions__list`,children:[u.length>0&&l(`p`,{class:`assistant-mentions__heading type-section-heading`,children:m(`app.assistant.mention.elements`)}),f.map(t=>l(`button`,{type:`button`,class:`assistant-mentions__item type-body`,onClick:()=>{e.mention(n.key,{kind:`element`,id:t.id,type:t.type,...t.name?{name:t.name}:{}}),i()},children:[l(`span`,{class:`assistant-mentions__name`,children:t.name||t.id}),l(`span`,{class:`assistant-mentions__kind type-help`,children:w(t.type)})]},t.id)),l(`p`,{class:`assistant-mentions__heading type-section-heading`,children:m(`app.assistant.mention.files`)}),h.map(t=>l(`button`,{type:`button`,class:`assistant-mentions__item type-body`,title:t.path,onClick:()=>{e.mention(n.key,{kind:`file`,path:t.rel,name:pe(t.rel)}),i()},children:l(`span`,{class:`assistant-mentions__name`,children:t.rel})},t.path)),s!==null&&h.length===0&&f.length===0&&l(`p`,{class:`assistant-mentions__empty type-help`,children:m(`app.assistant.mention.none`)})]})]})}function chooseFit(e){for(let t=0;t<4;t+=1)if(e(t))return t;return 4}function fitRow(e){let t=chooseFit(t=>(e.dataset.fit=String(t),e.scrollWidth<=e.clientWidth+1));return e.dataset.fit=String(t),t}var Ur=[],Wr=4;function sizeField(e){e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`}var sameElements=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>e.id===t[n].id&&e.name===t[n].name&&e.type===t[n].type),noSubscribe=()=>()=>void 0;function isBusy(e){return e?.state===`working`||e?.state===`waiting`||e?.state===`connecting`}function contextOf(e,t,n){let r=[...t.map(e=>e.id),...n.mentions.filter(e=>e.kind===`element`).map(e=>e.id)];return{file:e.file,elementIds:[...new Set(r)]}}function messageOf(e){let t=e.text.trim(),n=e.mentions.filter(e=>e.kind===`file`);return n.length===0?t:`${n.map(e=>`@${e.path}`).join(`
|
|
145
|
+
`).length}function FoldedCode({text:e,lang:n}){let[r,i]=t(!1);return l(`details`,{class:`assistant-code`,onToggle:e=>i(e.currentTarget.open),children:[l(`summary`,{class:`assistant-code__summary type-help`,children:`${m(`app.assistant.view.showSource`)} · ${linesOf(e)}`}),r&&l(`pre`,{class:`assistant-rich__code type-code`,"data-lang":n||void 0,children:e})]})}function AnswerText({text:e}){return l(RichText,{text:fenceDocument(e),code:e=>l(FoldedCode,{text:e.text,lang:e.lang})})}function ToolStep({tool:e,surface:t}){let n=sentenceOf(e),r=e.status;return l(`li`,{class:`assistant-row is-${r}`,children:[l(Mark,{status:r}),l(`span`,{class:`assistant-row__text`,title:n?plain(n.parts):toolTitle(e),children:n?l(PartsView,{parts:n.parts}):toolTitle(e)}),n&&n.chips.length>0&&l(ChipRow,{chips:n.chips,max:3}),t===`tab`&&l(`span`,{class:`assistant-row__state type-help`,children:m(vr[r])})]})}function StepRow({step:e,surface:t}){switch(e.kind){case`tool`:return t===`card`&&isBookkeeping(e.tool)?null:l(ToolStep,{tool:e.tool,surface:t});case`plan`:return l(a,{children:e.items.map((t,n)=>l(`li`,{class:`assistant-row is-${t.status}`,children:[l(Mark,{status:t.status}),l(`span`,{class:`assistant-row__text`,children:t.text})]},`${e.id}-${n}`))});case`thought`:return t===`card`?null:l(`li`,{class:`assistant-row is-thought`,children:l(`span`,{class:`assistant-row__text type-help`,children:e.text})})}}function currentStep(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.kind===`tool`&&!isBookkeeping(n.tool)){let e=sentenceOf(n.tool);if(e)return plain(e.parts);break}}return stepOf(e)}function WorkRow({steps:e,running:t,surface:n}){let r=countSteps(e,n===`tab`);if(r===0&&!t)return null;let i=e.some(e=>e.kind===`tool`&&e.tool.status===`failed`);return l(`details`,{class:`assistant-work`,open:n===`tab`||void 0,children:[l(`summary`,{class:`assistant-work__summary`,"aria-label":m(`app.assistant.work.label`),children:[l(Mark,{status:t?`running`:i?`failed`:`done`}),l(`span`,{class:`assistant-work__label type-body`,children:t?currentStep(e):m(`app.assistant.work.steps`,{count:r})}),l(J,{name:`chevronDown`,class:`assistant-work__chevron`})]}),l(`ul`,{class:`assistant-rows`,children:e.map(e=>l(StepRow,{step:e,surface:n},e.id))})]})}function distinctElements(e){let t=new Set;return e.filter(e=>{let n=JSON.stringify(e.kind===`element`?[e.path,e.id]:[e.path]);return!t.has(n)&&(t.add(n),!0)})}function AppliedRow({entry:e,pictures:n}){let[r,i]=t(null);f(()=>{let t=!0;return summariseDiffs(e.tool.diffs,n).then(e=>t&&i(e)).catch(()=>t&&i({lines:[],files:[],count:0,diffs:[]})),()=>{t=!1}},[e.id]);let a=distinctElements(r?r.diffs.flatMap(e=>e.elements):[]),o=e.tool.diffs[0];return l(`div`,{class:`assistant-applied`,children:[l(`p`,{class:`assistant-applied__row type-body`,children:[l(Mark,{status:`done`}),l(`span`,{class:`assistant-applied__label`,children:a.length>0?m(`app.assistant.view.applied`,{count:a.length}):l(PartsView,{parts:r?.lines[0]?.parts??[m(`app.assistant.view.appliedFile`,{file:o.path.split(/[\\/]/).pop()??o.path})]})}),a.length>0&&l(ChipRow,{chips:a,max:3})]}),r&&r.diffs.map(e=>l(ChangePanel,{diff:e.diff,mini:e.mini,initial:e.drawable?null:`source`},e.diff.path))]})}function TranscriptView({store:e,chatId:t,entries:n,permission:r,running:i,surface:a,onShow:s,focus:c}){let u=blocksOf(n),d=u[u.length-1],f=i&&!r,p=o(new PictureBudgets).current,h=``;return l(`div`,{class:`assistant-transcript is-${a}`,children:[u.map(e=>{switch(e.kind){case`work`:return l(WorkRow,{steps:e.steps,running:f&&e===d,surface:a},e.id);case`applied`:return l(AppliedRow,{entry:e.entry,pictures:p.of(h)},e.id);case`entry`:{let t=e.entry;return t.kind===`user`?(h=e.id,l(`div`,{class:`assistant-entry is-user`,children:l(RichText,{text:t.text})},e.id)):t.kind===`agent`?l(`div`,{class:`assistant-entry is-agent`,children:l(AnswerText,{text:t.text})},e.id):l(`p`,{class:`assistant-entry is-notice type-help`,children:t.text},e.id)}}}),f&&(!d||d.kind!==`work`)&&l(`p`,{class:`assistant-transcript__working type-help`,children:[l(X,{}),` `,m(`app.assistant.working`)]}),r&&l(Question,{store:e,chatId:t,permission:r,focus:c,onShow:s?e=>s(r,e):void 0})]})}var yr=24,br=2;function useFollow(e,t){let n=o(null),r=o(!0),i=o(null),a=o(!1),s=o(0),anchor=()=>{let e=n.current,t=e?.querySelector(`.assistant-question`);e&&t&&(s.current=t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop,e.scrollTop=s.current)};return u(()=>{let t=n.current;t&&(e?(r.current=!1,i.current!==e&&(i.current=e,a.current=!0,anchor())):(i.current!==null&&(i.current=null,a.current=!1,r.current=!0),r.current&&(t.scrollTop=t.scrollHeight)))},[e,t]),u(()=>{let t=e?n.current?.querySelector(`.assistant-question`):null;if(!t||typeof ResizeObserver>`u`)return;let r=new ResizeObserver(()=>{a.current&&anchor()});return r.observe(t),()=>r.disconnect()},[e]),{ref:n,onScroll:t=>{let n=t.currentTarget;if(e){let e=Math.min(s.current,n.scrollHeight-n.clientHeight);Math.abs(n.scrollTop-e)>br&&(a.current=!1)}else r.current=n.scrollHeight-n.scrollTop-n.clientHeight<yr}}}function agentName(e,t){return e.choices.find(e=>e.id===t.agentId)?.name??t.agentId}function Failure({store:e,state:n,chat:r,transcript:i,onChooseAgent:a,onAgentSettings:o}){let{unlock:s}=useLicence(),[c,u]=t(!1),d=classify(i?.error??null,n.choices,n.loaded),f=installCommand(n.choices,r.agentId),p=failureSummary(i?.error??null,r.detail??``),retry=()=>void e.tryAgain(r.id,()=>s(C.AI_CHAT)),h=d===`signedOut`&&i?.error?.signIn===!0,signIn=()=>{u(!0),e.signIn(r.id,()=>s(C.AI_CHAT)).finally(()=>u(!1))};return d===`noAgent`?l(`div`,{class:`assistant-empty`,children:[l(`p`,{class:`assistant-empty__text`,children:m(`app.assistant.noAgent.text`)}),f&&l(Oe,{command:f}),l(`div`,{class:`assistant-empty__actions`,children:[a&&l(`button`,{type:`button`,class:`assistant-button assistant-button--secondary`,onClick:a,children:m(`app.assistant.noAgent.choose`)}),o&&l(`button`,{type:`button`,class:`assistant-button assistant-button--secondary`,onClick:o,children:m(`app.assistant.noAgent.settings`)})]})]}):l(`div`,{class:`assistant-empty`,children:[l(`p`,{class:`assistant-empty__text`,children:p.text||m(d===`signedOut`?`app.assistant.signedOut.text`:`app.assistant.ended.text`)}),p.details&&l(FailureDetails,{text:p.details}),l(`div`,{class:`assistant-empty__actions`,children:[h&&l(`button`,{type:`button`,class:`assistant-button assistant-button--primary`,disabled:c,onClick:signIn,children:m(`app.assistant.signIn`)}),l(`button`,{type:`button`,class:`assistant-button assistant-button--secondary`,onClick:retry,children:m(`app.assistant.tryAgain`)})]})]})}function AssistantCard({store:e,state:t,editor:n,chat:r,transcript:i,peeking:a,onChooseAgent:o,onAgentSettings:s}){let c=r.state===`failed`,u=c?classify(i?.error??null,t.choices,t.loaded):null,d=i?.permission??null,f=r.state===`connecting`,p=r.state===`working`||r.state===`waiting`||f,h=i?.entries??[],g=expandReason(h),_=h[h.length-1],v=useFollow(d?.id??null,`${h.length}:${_&&`text`in _?_.text.length:0}:${r.state}`),y=u===`noAgent`?m(`app.assistant.noAgent.title`):u===`signedOut`?m(`app.assistant.signedOut.title`,{agent:agentName(t,r)}):u===`ended`?m(`app.assistant.ended.title`):r.title,showHere=(t,i)=>{if(!n.canvas?.channel.has(proposalId(t,i)))return!1;e.setFolded(r.id,!0);let a=n.canvas.channel;return requestAnimationFrame(()=>requestAnimationFrame(()=>a.fit())),!0};return l(`section`,{class:`assistant-card${d?` is-asking`:``}${c?` is-failed`:``}${a&&!d&&!c?` is-peeking`:``}`,"aria-label":m(`app.assistant.card.label`),"data-editor":n.key,children:[l(`header`,{class:`assistant-card__head`,children:[l(J,{name:c?`alert`:`chat`,class:`assistant-card__icon${c?` is-warning`:``}`}),l(`span`,{class:`assistant-card__title`,title:y,children:y}),!c&&l(`span`,{class:`assistant-card__agent type-help`,children:`· ${agentName(t,r)}`}),l(`span`,{class:`assistant-card__buttons`,children:[!c&&l(`button`,{type:`button`,class:`assistant-button assistant-button--icon`,"aria-label":m(`app.assistant.card.newChat`),title:m(`app.assistant.card.newChat`),disabled:p||d!==null,onClick:()=>e.select(n.key,null),children:l(J,{name:`plus`})}),!c&&l(`button`,{type:`button`,class:`assistant-button assistant-button--icon`,"aria-label":m(`app.assistant.card.expand`),title:m(`app.assistant.card.expand`),onClick:()=>e.reveal(n.key),children:l(J,{name:`expand`})}),l(`button`,{type:`button`,class:`assistant-button assistant-button--icon`,"aria-label":m(c?`app.assistant.card.close`:`app.assistant.card.fold`),title:m(c?`app.assistant.card.close`:`app.assistant.card.fold`),onClick:()=>c?e.dismissCard(r.id):e.setFolded(r.id,!0),children:l(J,{name:c?`close`:`chevronDown`})})]})]}),!c&&g&&l(`p`,{class:`assistant-card__suggest type-help`,children:[l(`span`,{children:m(g===`long`?`app.assistant.card.suggestLong`:`app.assistant.card.suggestDocument`)}),l(`button`,{type:`button`,class:`assistant-link type-link`,onClick:()=>e.reveal(n.key),children:m(`app.assistant.card.suggest`)})]}),l(`div`,{class:`assistant-card__body`,ref:v.ref,onScroll:v.onScroll,children:[c&&l(Failure,{store:e,state:t,chat:r,transcript:i,onChooseAgent:o,onAgentSettings:s}),!c&&f&&l(`p`,{class:`assistant-card__status type-help`,role:`status`,children:[l(X,{}),` `,m(`app.assistant.card.connecting`)]}),!c&&!f&&i?.status===`loading`&&h.length===0&&l(`p`,{class:`assistant-card__status type-help`,role:`status`,children:[l(X,{}),` `,m(`app.assistant.card.loading`)]}),!c&&i&&l(TranscriptView,{store:e,chatId:r.id,entries:h,permission:d,running:p,surface:`card`,onShow:showHere})]})]})}var xr=[hn,mn];function FailureNotice({failure:e,choices:t,onRetry:n,onSettings:r}){let i=failureSummary(e,``),a=xr.includes(e.key)?installCommand(t,null):null;return l(`div`,{class:`assistant-empty`,children:[l(`p`,{class:`assistant-empty__text`,children:i.text||m(`app.assistant.ended.text`)}),a&&l(Oe,{command:a}),i.details&&l(FailureDetails,{text:i.details}),l(`div`,{class:`assistant-empty__actions`,children:[l(`button`,{type:`button`,class:`assistant-button assistant-button--secondary`,onClick:n,children:m(`app.assistant.tryAgain`)}),l(`button`,{type:`button`,class:`assistant-button assistant-button--secondary`,onClick:r,children:m(`app.assistant.noAgent.settings`)})]})]})}var Sr=i(!0),Cr=Sr.Provider;function useEditorActive(){return r(Sr)}var wr=i(null),Tr=wr.Provider;function useEditorElement(e){let t=r(wr);return t?t.current?Ze(e,t.current):null:Ze(e)}var ReviewChannel=class{listeners=new Set;withdrawals=new Set;pending=new Map;counter=0;covering=null;coverListeners=new Set;fitListeners=new Set;subscribe(e){this.listeners.add(e);for(let t of[...this.pending.values()])e(t);return()=>{this.listeners.delete(e)}}onWithdraw(e){return this.withdrawals.add(e),()=>{this.withdrawals.delete(e)}}propose(e){let t=Object.hasOwn(e,`patch`)?e:{patch:e};this.counter+=1;let n={id:`channel-${this.counter}`,patch:t.patch,source:t.source??`channel`,createdAt:Date.now(),...t.title?{title:t.title}:{}};return this.offer(n),n}offer(e){this.pending.set(e.id,e);for(let t of[...this.listeners])t(e);this.coverChanged()}withdraw(e){if(this.pending.delete(e)){for(let t of[...this.withdrawals])t(e);this.coverChanged()}}setCover(e){e===this.covering||e!==null&&this.covering!==null&&e.left===this.covering.left&&e.bottom===this.covering.bottom&&(e.right??0)===(this.covering.right??0)||(this.covering=e,this.coverChanged())}cover=()=>this.pending.size>0?this.covering:null;onCover=e=>(this.coverListeners.add(e),()=>{this.coverListeners.delete(e)});fit(){for(let e of[...this.fitListeners])e()}onFit=e=>(this.fitListeners.add(e),()=>{this.fitListeners.delete(e)});coverChanged(){for(let e of[...this.coverListeners])e()}proposedFacts(e){for(let t of this.pending.values()){let n=t.after?.nodes??[],r=[...n,...t.after?.flows??[]].find(t=>t.id===e);if(!r)continue;let i=r.name||(r.source&&r.target?flowName(n.find(e=>e.id===r.source),n.find(e=>e.id===r.target)):void 0);return{type:r.type,...i?{name:i}:{}}}return null}has(e){return this.pending.has(e)}get size(){return this.pending.size}};function motionMs(e){let t=parseFloat(getComputedStyle(document.documentElement).getPropertyValue(e));return Number.isFinite(t)?t:0}function reducedMotion(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}var Er=`penstock-chip-hover`,Dr=`penstock-chip-flash`,Or=new Set([`bpmn:Process`,`bpmn:Collaboration`]);function endOf(e){return e?{name:e.name,type:e.$type}:null}function factsOf(e){let t=e?.businessObject;if(!e||!t||e.type===`label`||!t.$type||Or.has(t.$type))return null;let n=t.name?String(t.name):t.$type===`bpmn:SequenceFlow`?flowName(endOf(t.sourceRef),endOf(t.targetRef)):void 0;return{id:e.id,type:t.$type,...n?{name:n}:{}}}var EditorCanvas=class{channel=new ReviewChannel;feed=this.channel;picked=[];flashing=new Map;modeler=null;listeners=new Set;commenter;constructor(e=()=>void 0){this.commenter=e}onComment=(e,t)=>{this.commenter(e,t)};read=()=>this.picked;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});changed(){for(let e of[...this.listeners])e()}follow=()=>{let e=(this.modeler?.get(`selection`,!1)?.get?.()??[]).map(factsOf).filter(e=>e!==null);e.length===this.picked.length&&e.every((e,t)=>e.id===this.picked[t].id&&e.name===this.picked[t].name&&e.type===this.picked[t].type)||(this.picked=e,this.changed())};attach=e=>{this.detach(),this.modeler=e,(e?.get?.(`eventBus`,!1))?.on([`selection.changed`,`element.changed`,`import.done`],this.follow),this.follow()};detach=()=>{(this.modeler?.get?.(`eventBus`,!1))?.off([`selection.changed`,`element.changed`,`import.done`],this.follow),this.modeler=null,this.picked.length>0&&(this.picked=[],this.changed())};describe(e){let t=factsOf(this.modeler?.get?.(`elementRegistry`,!1)?.get(e));if(t)return t;let n=this.channel.proposedFacts(e);return n?{id:e,...n}:null}elements=()=>{let e=this.modeler?.get?.(`elementRegistry`,!1);return e?(e.getAll?.()??[]).filter(e=>!e.waypoints).map(factsOf).filter(e=>e!==null):[]};mark(e,t){let n=this.modeler?.get?.(`elementRegistry`,!1),r=this.modeler?.get?.(`canvas`,!1);r&&n?.get(e)&&(t?r.addMarker(e,Er):r.removeMarker(e,Er))}flash(e){let t=this.modeler?.get?.(`elementRegistry`,!1),n=this.modeler?.get?.(`canvas`,!1);if(n&&t)for(let r of e)t.get(r)&&(n.addMarker(r,Dr),clearTimeout(this.flashing.get(r)),this.flashing.set(r,setTimeout(()=>{this.flashing.delete(r),n.removeMarker(r,Dr)},motionMs(`--motion-flash`))))}select(e){let t=(this.modeler?.get?.(`elementRegistry`,!1))?.get(e);return t?(this.modeler.get(`selection`,!1)?.select(t),!0):!1}},CanvasRegistry=class{entries=new Map;set(e,t){return this.entries.set(e,t),()=>{this.entries.get(e)===t&&this.entries.delete(e)}}get(e){return this.entries.get(e)}find(e){let t=this.entries.get(e);if(t)return t;let n=e.replace(/\\/g,`/`);for(let[e,t]of this.entries){let r=e.replace(/\\/g,`/`);if(r===n||r.endsWith(`/${n}`)||n.endsWith(`/${r}`))return t}}},kr=new CanvasRegistry,Ar=new Map,jr=new Map,Mr=new Set;function changed(){for(let e of[...Mr])e()}function installScenarioOpener(e,t){return jr.set(e,t),()=>{jr.get(e)===t&&jr.delete(e)}}function requestScenario(e,t){Ar.set(e,t),changed(),jr.get(e)?.()}function takeScenarioRequest(e){let t=Ar.get(e)??null;return t!==null&&(Ar.delete(e),changed()),t}function useScenarioRequest(e){let[,n]=t(0);return f(()=>{let again=()=>n(e=>e+1);return Mr.add(again),()=>{Mr.delete(again)}},[]),e===null?null:Ar.get(e)??null}var Nr=/\.(java|kt|kts|groovy|scala|py|js|mjs|cjs|ts|go|cs)$/,Pr=[[/\.bpmn(\.xml)?$/i,`bpmn`],[/\.dmn$/i,`dmn`],[/\.form$/i,`form`]],Fr=Pr[0][0],Ir=250,Lr=1e3,Rr=/^([A-Za-z]:)?[\\/]/;async function parse(e){let{inspectModel:t}=await y(async()=>{let{inspectModel:e}=await import(`./apply-HqvoGwLE.js`).then(e=>e.n);return{inspectModel:e}},__vite__mapDeps([38,1,3,4,9,7,8]),import.meta.url),n=await t(e,M(e)??`classic`),r=new Map;if(!n)return r;for(let e of n.elements)r.set(e.id,{type:e.type.includes(`:`)?e.type:`bpmn:${e.type}`,...e.name?{name:e.name}:{}});for(let e of n.flows){let t=r.get(e.id);if(!t||t.name)continue;let i=flowName(n.nodes.find(t=>t.id===e.source),n.nodes.find(t=>t.id===e.target));i&&r.set(e.id,{...t,name:i})}return r}function kindOf(e){return Pr.find(([t])=>t.test(e))?.[1]??null}async function projectRootOf(){return(await j().getProjectFiles()).root}function absoluteOf(e,t){return Rr.test(t)||e===``?t:`${e.replace(/[\\/]+$/,``)}/${t}`}async function scenarioNamesOf(e){let t=await j().readFile(e),{parsed:n}=await ne(e,t),r=new Map;for(let e of n.file?.testCases??[])r.set(e.name,(r.get(e.name)??0)+1);return r}function ownElements(e){return kr.find(e)?.elements()??[]}function createBridgeLinks(e,t=projectRootOf){let n=new Map,r=new Map,i=new Map,a=new Map,o=new Map,s=new Set,c=null,l=null,u=null,notify=()=>{c===null&&(c=setTimeout(()=>{c=null;for(let e of[...s])e()},Ir))},settle=()=>(u??=(async()=>{try{l=await t()}catch{l=``}notify()})(),u),absolute=e=>absoluteOf(l??``,e),load=e=>{let t=r.get(e);if(t)return t;let i=(async()=>{try{let t=await j().readFile(e);n.set(e,await parse(t))}catch{n.set(e,null)}notify()})();return r.set(e,i),i.finally(()=>r.delete(e)),i},readScenarioNames=e=>{let t=a.get(e);if(t)return t;let n=scenarioNamesOf(e).catch(()=>new Map).then(t=>{i.set(e,{names:t,at:Date.now()}),notify()});return a.set(e,n),n.finally(()=>a.delete(e)),n},own=t=>{let n=e();return!!n?.file&&de(n.file,t)},liveOf=(e,t)=>own(e)?kr.find(e)?.describe(t):null;return{file(e){let t=kindOf(e);return t?n.get(absolute(e))===null?null:{rel:e,kind:t}:o.get(e)===!0?{rel:e,kind:`source`}:null},async check(e){if(!o.has(e)&&Nr.test(e)){await settle();try{let t=await j().readCodeSnippet?.(absolute(e),1,1);o.set(e,(t?.lines.length??0)>0)}catch{o.set(e,!1)}}},async element(e,t){if(!Fr.test(e))return null;await settle();let r=absolute(e),i=liveOf(r,t);return i?{type:i.type,...i.name?{name:i.name}:{}}:(await load(r),n.get(r)?.get(t)??null)},peek(e,t){if(!Fr.test(e))return null;if(l===null)return;let r=absolute(e),i=liveOf(r,t);if(i)return{type:i.type,...i.name?{name:i.name}:{}};if(n.has(r))return n.get(r)?.get(t)??null},subscribe(e){return s.add(e),()=>{s.delete(e)}},openFile(e){settle().then(()=>j().revealElement(absolute(e))).catch(e=>console.error(`The file could not be opened:`,e))},openElement(e,t){settle().then(async()=>{let n=absolute(e);(own(n)?kr.find(n):void 0)?.select(t)||await j().revealElement(n,t)}).catch(e=>console.error(`The element could not be revealed:`,e))},named(t){let n=e();if(!n?.file||!Fr.test(n.file))return null;let r=ownElements(n.file).filter(e=>e.name===t);return r.length===1?{file:n.file,id:r[0].id,type:r[0].type,name:t}:null},scenario(t){let n=e();return!n?.file||!Fr.test(n.file)||ownElements(n.file).some(e=>e.name===t)?null:i.get(absolute(n.file))?.names.get(t)===1?{file:n.file,name:t}:null},async refreshScenarios(){let t=e();if(!t?.file||!Fr.test(t.file))return;await settle();let n=absolute(t.file),r=i.get(n);r&&Date.now()-r.at<Lr||await readScenarioNames(n)},openScenario(e,t){requestScenario(e,t)},highlight(e,t,n){let r=absolute(e);own(r)&&kr.find(r)?.mark(t,n)},flash(e,t){let n=absolute(e);own(n)&&kr.find(n)?.flash(t)},openCode(e,t){settle().then(()=>j().openAsText(absolute(e),t??void 0)).catch(e=>console.error(`The file could not be opened:`,e))},dispose(){c!==null&&clearTimeout(c),s.clear()}}}var zr=new Map;function useBridgeLinks(e){let t=o(e);t.current=e;let n=c(()=>createBridgeLinks(()=>t.current),[]);return f(()=>()=>n.dispose(),[n]),n}function AssistantRuntime({editor:e}){let t=G(),n=useEditorActive();f(()=>{t&&t.start()},[t]),f(()=>ue(),[]),f(()=>{zr.set(e.key,e);let t=e.canvas?kr.set(e.key,e.canvas):void 0;return()=>{zr.get(e.key)===e&&zr.delete(e.key),t?.()}},[e]);let r=W(t?t.subscribe:()=>()=>void 0,()=>t?.snapshot().loaded??!1);return f(()=>{t&&r&&t.settle(e.key,e.file)},[t,r,e.key,e.file]),f(()=>{t&&n&&t.focus(e.key)},[t,n,e.key]),f(()=>()=>t?.unfocus(e.key),[t,e.key]),f(()=>{if(t&&e.canvas)return connectReviews({store:t,canvas:e.canvas,file:()=>e.file})},[t,e.canvas,e.file]),null}var Br=/\.(bpmn|dmn|form)$/i;function latestDiagramOf(e){return[...e.files].reverse().find(e=>Br.test(e))??null}var Vr={idle:`app.assistant.state.idle`,connecting:`app.assistant.state.connecting`,working:`app.assistant.state.working`,waiting:`app.assistant.state.waiting`,failed:`app.assistant.state.failed`};function stateLine(e,t=Date.now()){return e.detail?e.detail:e.state===`idle`?le(e.updated,t):m(Vr[e.state])}function Dot({state:e}){return e===`working`||e===`connecting`?l(`span`,{class:`assistant-chat__mark`,children:l(X,{})}):l(`span`,{class:`assistant-chat__mark`,children:l(`i`,{class:`assistant-chat__dot is-${e}`})})}async function confirmDelete(e){return j().confirmWithUser({title:m(`app.assistant.delete.title`),text:m(`app.assistant.delete.text`,{title:e.title}),accept:m(`app.assistant.delete.accept`),decline:m(`app.common.cancel`),warning:!0})}function ChatsSection({store:e,editor:n,onOpen:r,onOpenFile:i}){let a=W(e.subscribe,e.snapshot),[o,s]=t(null),[c,u]=t(null),d=n?a.active[n]:null;if(f(()=>{e.start()},[e]),!a.enabled)return null;let open=t=>{if(n)e.select(n,t.id),e.reveal(n);else{let n=latestDiagramOf(t);if(n){let r=[...zr.values()].find(e=>e.file!==null&&de(e.file,n));r?(e.select(r.key,t.id),e.reveal(r.key)):e.expectChat(t.id,n),i?.(n)}}r?.(t)},create=async()=>{await e.create(n)&&n&&e.reveal(n)},remove=async t=>{await confirmDelete(t)&&await e.remove(t.id)},items=e=>[{id:`rename`,label:m(`app.assistant.rename`),run:()=>u(e.id)},{id:`delete`,label:m(`app.assistant.delete.action`),danger:!0,run:()=>void remove(e)}];return l(`section`,{class:`assistant-chats`,"aria-label":m(`app.assistant.chats.label`),children:[l(`div`,{class:`assistant-chats__head`,children:[l(`h2`,{class:`assistant-chats__title type-section-heading`,children:m(`app.assistant.chats.title`)}),l(`span`,{class:`assistant-chats__buttons`,children:[l(`button`,{type:`button`,class:`assistant-button assistant-button--icon`,"aria-label":m(`app.assistant.chats.new`),title:m(`app.assistant.chats.new`),onClick:()=>void create(),children:l(J,{name:`plus`})}),l(`button`,{type:`button`,class:`assistant-button assistant-button--icon`,"aria-label":m(`app.assistant.chats.agents`),title:m(`app.assistant.chats.agents`),onClick:()=>void ce(),children:l(J,{name:`settings`})})]})]}),a.loaded&&a.chats.length===0&&l(`p`,{class:`assistant-chats__empty type-help`,children:m(`app.assistant.chats.empty`)}),l(`ul`,{class:`assistant-chats__list`,children:a.chats.map(t=>l(`li`,{children:c===t.id?l(Rename,{chat:t,onDone:n=>{u(null),n!==null&&n!==t.title&&e.rename(t.id,n)}}):l(`button`,{type:`button`,class:`assistant-chat${d===t.id?` is-selected`:``} is-${t.state}`,"aria-current":d===t.id?`true`:void 0,onClick:()=>open(t),onContextMenu:e=>{e.preventDefault(),s({at:{x:e.clientX,y:e.clientY},chat:t})},onKeyDown:e=>{if(e.key===`F2`)e.preventDefault(),u(t.id);else if(e.key===`Delete`)e.preventDefault(),remove(t);else if(e.key===`ContextMenu`||e.key===`F10`&&e.shiftKey){e.preventDefault();let n=e.currentTarget.getBoundingClientRect();s({at:{x:n.left+24,y:n.bottom},chat:t})}},children:[l(Dot,{state:t.state}),l(`span`,{class:`assistant-chat__body`,children:[l(`span`,{class:`assistant-chat__title type-body`,children:t.title}),l(`span`,{class:`assistant-chat__state type-help`,children:stateLine(t)})]})]})},t.id))}),o&&l(Ce,{label:m(`app.assistant.chats.menu`),at:o.at,items:items(o.chat),onClose:()=>s(null)})]})}function Rename({chat:e,onDone:t}){let n=o(null),r=o(!1),finish=e=>{r.current||(r.current=!0,t(e))};return f(()=>{n.current?.focus(),n.current?.select()},[]),l(`input`,{ref:n,class:`assistant-chat__rename type-input`,"aria-label":m(`app.assistant.rename`),defaultValue:e.title,maxLength:200,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),finish(e.currentTarget.value.trim()||null)):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),finish(null))},onBlur:e=>finish(e.currentTarget.value.trim()||null)})}function ChatSwitcher({store:e,state:n,editor:r,chat:i}){let s=o(null),[c,u]=t(!1),d=i?.title??m(`app.assistant.chats.new`),choose=t=>{e.select(r,t),u(!1),e.focusInput(r)};return l(a,{children:[l(`button`,{ref:s,type:`button`,class:`assistant-switch type-help`,title:d,"aria-label":`${m(`app.assistant.switch.label`)}: ${d}`,"aria-haspopup":`listbox`,"aria-expanded":c,onClick:()=>u(e=>!e),children:[l(J,{name:`chat`,class:`assistant-switch__icon`}),l(`span`,{class:`assistant-switch__title`,children:d}),l(J,{name:`chevronDown`,class:`assistant-switch__chevron`})]}),c&&l(xe,{anchor:s.current,label:m(`app.assistant.switch.list`),onClose:()=>u(!1),width:288,class:`assistant-switch__popover`,children:l(`ul`,{class:`assistant-switch__list`,role:`listbox`,"aria-label":m(`app.assistant.switch.list`),children:[l(`li`,{role:`presentation`,children:l(`button`,{type:`button`,role:`option`,"aria-selected":i===null,class:`assistant-switch__item assistant-switch__item--new type-body`,onClick:()=>choose(null),children:[l(J,{name:`plus`}),l(`span`,{class:`assistant-switch__name`,children:m(`app.assistant.chats.new`)})]})}),n.chats.map(e=>l(`li`,{role:`presentation`,children:l(`button`,{type:`button`,role:`option`,"aria-selected":e.id===i?.id,class:`assistant-switch__item type-body`,onClick:()=>choose(e.id),children:[l(`span`,{class:`assistant-switch__name`,title:e.title,children:e.title}),l(`span`,{class:`assistant-switch__state type-help`,children:stateLine(e)})]})},e.id))]})})]})}var Hr=40;function useFiles(){let[e,n]=t(null);return f(()=>{let e=!0;return j().getProjectFiles().then(t=>e&&n({root:t.root,paths:t.files.map(e=>e.path)})).catch(()=>e&&n({root:``,paths:[]})),()=>{e=!1}},[]),e}function Mentions({store:e,editor:n,anchor:r,onClose:i}){let[a,o]=t(``),s=useFiles(),u=c(()=>n.canvas?n.canvas.elements():n.elements?.()??[],[n]),d=a.trim().toLowerCase(),f=u.filter(e=>!d||`${e.name??``} ${e.id} ${w(e.type)}`.toLowerCase().includes(d)).slice(0,Hr),p=s?.root.replace(/\\/g,`/`).replace(/\/$/,``)??``,h=(s?.paths??[]).map(e=>({path:e,rel:e.replace(/\\/g,`/`).startsWith(`${p}/`)?e.replace(/\\/g,`/`).slice(p.length+1):e})).filter(e=>!d||e.rel.toLowerCase().includes(d)).slice(0,Hr);return l(xe,{anchor:r,label:m(`app.assistant.mention.label`),onClose:i,width:320,class:`assistant-mentions`,children:[l(`input`,{type:`search`,class:`assistant-mentions__search type-input`,"aria-label":m(`app.assistant.mention.search`),placeholder:m(`app.assistant.mention.search`),value:a,onInput:e=>o(e.currentTarget.value)}),l(`div`,{class:`assistant-mentions__list`,children:[u.length>0&&l(`p`,{class:`assistant-mentions__heading type-section-heading`,children:m(`app.assistant.mention.elements`)}),f.map(t=>l(`button`,{type:`button`,class:`assistant-mentions__item type-body`,onClick:()=>{e.mention(n.key,{kind:`element`,id:t.id,type:t.type,...t.name?{name:t.name}:{}}),i()},children:[l(`span`,{class:`assistant-mentions__name`,children:t.name||t.id}),l(`span`,{class:`assistant-mentions__kind type-help`,children:w(t.type)})]},t.id)),l(`p`,{class:`assistant-mentions__heading type-section-heading`,children:m(`app.assistant.mention.files`)}),h.map(t=>l(`button`,{type:`button`,class:`assistant-mentions__item type-body`,title:t.path,onClick:()=>{e.mention(n.key,{kind:`file`,path:t.rel,name:pe(t.rel)}),i()},children:l(`span`,{class:`assistant-mentions__name`,children:t.rel})},t.path)),s!==null&&h.length===0&&f.length===0&&l(`p`,{class:`assistant-mentions__empty type-help`,children:m(`app.assistant.mention.none`)})]})]})}function chooseFit(e){for(let t=0;t<4;t+=1)if(e(t))return t;return 4}function fitRow(e){let t=chooseFit(t=>(e.dataset.fit=String(t),e.scrollWidth<=e.clientWidth+1));return e.dataset.fit=String(t),t}var Ur=[],Wr=4;function sizeField(e){e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`}var sameElements=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>e.id===t[n].id&&e.name===t[n].name&&e.type===t[n].type),noSubscribe=()=>()=>void 0;function isBusy(e){return e?.state===`working`||e?.state===`waiting`||e?.state===`connecting`}function contextOf(e,t,n){let r=[...t.map(e=>e.id),...n.mentions.filter(e=>e.kind===`element`).map(e=>e.id)];return{file:e.file,elementIds:[...new Set(r)]}}function messageOf(e){let t=e.text.trim(),n=e.mentions.filter(e=>e.kind===`file`);return n.length===0?t:`${n.map(e=>`@${e.path}`).join(`
|
|
146
146
|
`)}\n\n${t}`}function AssistantInput({store:e,editor:n,chat:r,transcript:i,surface:s,hint:d}){let{unlock:p}=useLicence(),h=W(e.subscribe,e.snapshot),g=h.drafts[n.key]??e.draft(n.key),_=n.selection,v=W(_?_.subscribe:noSubscribe,_?_.read:()=>Ur,sameElements),y=v.map(e=>e.id).join(`
|
|
147
147
|
`);f(()=>e.releaseDismissed(n.key,y===``?[]:y.split(`
|
|
148
|
-
`)),[y]);let b=o(null),x=o(null),S=o(null),[w,T]=t(!1),[E,D]=t(!1),O=isBusy(r),k=g.text.trim()===``,A=c(()=>v.filter(e=>!g.dismissed.includes(`element:${e.id}`)),[v,g.dismissed]),j=Math.max(0,A.length-Wr),M=h.choices.filter(e=>e.available),N=r?.agentId??h.agentId??M[0]?.id??``,P=i?.queue??[],F=oe(h,n.key,r,N),I=s===`dock`&&r!==null&&O&&(h.shown[r.id]!==!0||h.folded[r.id]===!0),L=s===`dock`&&k&&!w&&P.length===0&&!I,R=d??m(s===`tab`?`app.assistant.input.ask`:`app.assistant.input.placeholder`);u(()=>{b.current&&sizeField(b.current)},[g.text]),u(()=>{S.current&&fitRow(S.current)}),f(()=>{let e=S.current;if(!e||typeof ResizeObserver>`u`)return;let t=e.clientWidth,n=new ResizeObserver(()=>{e.clientWidth!==t&&(t=e.clientWidth,fitRow(e),b.current&&sizeField(b.current))});return n.observe(e),()=>n.disconnect()},[]),f(()=>{g.focus>0&&b.current?.focus()},[g.focus]);let submit=async()=>{if(k||E)return;D(!0);let t=g.text;try{let r=await e.send({editor:n.key,text:messageOf(g),context:contextOf(n,A,g),authorize:()=>p(C.AI_CHAT)});(r===`sent`||r===`queued`)&&e.draft(n.key).text===t&&e.clearDraft(n.key)}finally{D(!1)}},stop=()=>{r&&e.stop(r.id)};return l(`form`,{class:`assistant-input${O?` is-busy`:``}${L?` is-resting`:``}`,"aria-label":m(`app.assistant.input.label`),onSubmit:e=>{e.preventDefault(),submit()},children:[I&&r&&l(`button`,{type:`button`,class:`assistant-input__state type-help`,title:m(`app.assistant.input.showCard`),onClick:()=>e.showCard(r.id),children:[r.state===`waiting`||i?.permission?l(J,{name:`hand`,class:`assistant-input__hand`}):l(X,{}),l(`span`,{children:r.state===`waiting`||i?.permission?m(`app.assistant.input.stateWaiting`):m(`app.assistant.input.stateWorking`)})]}),P.length>0&&l(`ul`,{class:`assistant-input__queue`,"aria-label":m(`app.assistant.input.queued`),children:P.map(t=>l(`li`,{class:`assistant-input__queued`,children:[l(J,{name:`queue`}),l(`span`,{class:`assistant-input__queued-text type-help`,title:t.text,children:m(`app.assistant.input.queuedText`,{text:t.text})}),l(`button`,{type:`button`,class:`assistant-button assistant-button--icon`,"aria-label":m(`app.assistant.input.unqueue`),title:m(`app.assistant.input.unqueue`),onClick:()=>r&&void e.unqueue(r.id,t.id,n.key),children:l(J,{name:`close`})})]},t.id))}),l(`div`,{class:`assistant-input__chips`,role:`group`,"aria-label":m(`app.assistant.input.context`),children:[A.slice(0,Wr).map(t=>l(`span`,{class:`assistant-chip assistant-chip--element`,children:[l(ElementChip,{id:t.id,type:t.type,name:t.name,onSelect:e=>n.canvas?.select(e)}),l(`button`,{type:`button`,class:`assistant-chip__remove`,"aria-label":m(`app.assistant.input.removeChip`,{name:t.name||t.id}),title:m(`app.assistant.input.removeChip`,{name:t.name||t.id}),onClick:()=>e.unmention(n.key,`element:${t.id}`),children:l(J,{name:`close`})})]},t.id)),j>0&&l(`span`,{class:`assistant-chip type-help`,children:m(`app.assistant.input.more`,{count:j})}),g.mentions.map(t=>l(`span`,{class:`assistant-chip assistant-chip--${t.kind}`,children:[t.kind===`element`?l(ElementChip,{id:t.id,type:t.type,name:t.name,onSelect:e=>n.canvas?.select(e)}):l(`span`,{class:`assistant-chip__label type-help`,title:t.path,children:t.name}),l(`button`,{type:`button`,class:`assistant-chip__remove`,"aria-label":m(`app.assistant.input.removeChip`,{name:t.kind===`element`?t.name||t.id:t.name}),title:m(`app.assistant.input.removeChip`,{name:t.kind===`element`?t.name||t.id:t.name}),onClick:()=>e.unmention(n.key,ae(t)),children:l(J,{name:`close`})})]},ae(t))),l(`span`,{class:`assistant-chip assistant-chip--file type-help`,title:n.file??n.name,children:n.name})]}),l(`textarea`,{ref:b,class:`assistant-input__text type-input`,rows:1,value:g.text,placeholder:R,"aria-label":m(`app.assistant.input.placeholder`),onInput:t=>e.setText(n.key,t.currentTarget.value),onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||e.altKey||e.isComposing||(e.preventDefault(),submit())}}),L&&l(`span`,{class:`assistant-input__hint type-input`,"aria-hidden":`true`,children:R}),l(`div`,{ref:S,class:`assistant-input__row`,children:[l(ChatSwitcher,{store:e,state:h,editor:n.key,chat:r}),l(`button`,{ref:x,type:`button`,class:`assistant-button assistant-button--icon`,"aria-label":m(`app.assistant.input.add`),title:m(`app.assistant.input.add`),"aria-haspopup":`dialog`,"aria-expanded":w,onClick:()=>T(e=>!e),children:l(J,{name:`plus`})}),w&&l(Mentions,{store:e,editor:n,anchor:x.current,onClose:()=>T(!1)}),l(he,{store:e,state:h,editor:n.key,chat:r,agentId:N,options:F,busy:O,started:r!==null&&(i?.entries.length??0)>0}),l(`span`,{class:`assistant-input__keys type-help`,"aria-hidden":`true`,children:[l(`kbd`,{class:`assistant-key`,children:m(`app.assistant.input.keyEnter`)}),l(`span`,{children:m(O?`app.assistant.input.keyQueue`:`app.assistant.input.keySend`)}),!O&&l(a,{children:[l(`kbd`,{class:`assistant-key`,children:m(`app.assistant.input.keyShiftEnter`)}),l(`span`,{children:m(`app.assistant.input.keyNewline`)})]})]}),O?l(`button`,{type:`button`,class:`assistant-button assistant-button--stop`,"aria-label":m(`app.assistant.input.stop`),title:m(`app.assistant.input.stop`),onClick:stop,children:l(J,{name:`stop`})}):l(`button`,{type:`submit`,class:`assistant-button assistant-button--send`,"aria-label":m(`app.assistant.input.send`),title:m(`app.assistant.input.send`),disabled:k||E,children:E?l(X,{}):l(J,{name:`send`})})]})]})}var Gr=`.djs-palette, .fjs-palette-container`,Kr=`.bjs-powered-by, .fjs-powered-by-link`,qr=`.diagram-check, .bjsl-button, .trace-pill`;function cornerLayout(e){let t=Math.max(0,Math.min(e.coveredLeft??0,e.canvas)),n=Math.max(0,Math.min(e.covered??0,e.canvas-t)),r=e.canvas-n,edge=e=>e>0?16+e:0,i=Math.max(edge(e.palette),edge(e.watermark),t),a=e.cardFull>0,room=e=>r-e-32,o=e.dock&&a&&room(Math.max(i,edge(e.cardFull)))<440,s=r-16,span=e=>s-(e+16),c=Math.max(i,edge(e.card)),l=`full`;e.dock&&e.canvas>0&&span(c)<240&&(span(i)>=240?(c=i,l=`overlap`):l=`collapsed`);let u=i,d=Math.min(e.canvas-16,Math.max(s,u+16+240)),f=Math.max(0,e.canvas-16-d),p=c+16,m=Math.min(600,Math.max(0,s-p)),h=p+(s-p-m)/2;return{inset:c,folded:o,mode:l,overlayInset:u,overlayCovered:f,covered:n,coveredLeft:t,dock:{left:h,right:h+m}}}var Jr=`.assistant-dock`,Yr=`.assistant-input, .assistant-ask`;function insetOf(e,t){return t===null||!Number.isFinite(t)?0:Math.max(0,Math.round(e-t))}function viewportHeight(){return typeof window>`u`?0:window.innerHeight}function shown(e){if(!e)return null;let t=e.getBoundingClientRect();return t.width>0&&t.height>0?t:null}function measureCorner(e){let t=e.getBoundingClientRect(),widthOf=n=>{let r=0;return e.querySelectorAll(n).forEach(e=>{let n=shown(e);n&&(r=Math.max(r,n.right-t.left-16))}),Math.max(0,Math.round(r))},n=[...e.querySelectorAll(qr)].map(shown).filter(e=>e!==null),r=e.querySelector(`.diagram-check:not(.trace-card)`)!==null,i=n.reduce((e,t)=>Math.min(e,t.top),1/0),a=Qe(t,Xe(e).map(e=>e.getBoundingClientRect())),o=Math.max(0,Math.min(460,t.width-32)),s=cornerLayout({canvas:t.width,palette:widthOf(Gr),watermark:widthOf(Kr),card:widthOf(qr),cardFull:Math.max(r?o:0,Math.min(o,fullWidth(e,`.trace-card`)),Math.min(o,fullWidth(e,`.bjsl-button`))),dock:e.querySelector(`.assistant-dock`)!==null,covered:a.right,coveredLeft:a.left});return{inset:Math.round(s.inset),dock:insetOf(t.bottom,shown(e.querySelector(`.assistant-dock`))?.top??null),input:insetOf(t.bottom,shown(e.querySelector(`.assistant-input, .assistant-ask`))?.top??null),height:n.length>0?Math.max(0,Math.round(t.bottom-i))+16:0,folded:s.folded,left:Math.round(t.left),bottom:Math.max(0,Math.round(viewportHeight()-t.bottom)),mode:s.mode,overlayInset:Math.round(s.overlayInset),overlayCovered:Math.round(s.overlayCovered),covered:Math.round(s.covered),coveredLeft:Math.round(s.coveredLeft),traceLeft:traceLeftOf(e,t)}}var Xr=8;function fullWidth(e,t){let n=e.querySelector(t),r=shown(n);return!n||!r?0:(e.classList.contains(`is-corner-folded`)||(n.dataset.fullWidth=String(Math.round(r.width))),Number(n.dataset.fullWidth??Math.round(r.width)))}function traceLeftOf(e,t){let n=shown(e.querySelector(`.bjsl-button`))??shown(e.querySelector(`.trace-pill`));return n?Math.round(n.right-t.left+Xr):16}function observeCorner(e,t,n){let r=0,schedule=()=>{r||=requestAnimationFrame(()=>{r=0,n()})};if(typeof ResizeObserver>`u`)return()=>void 0;let i=new ResizeObserver(schedule);i.observe(e),t.forEach(e=>i.observe(e));let a=new Set,watch=()=>{let t=new Set(e.querySelectorAll(`${Gr}, ${Kr}, ${qr}, ${Jr}, ${Yr}`));for(let e of a)t.has(e)||(a.delete(e),i.unobserve(e));for(let e of t)a.has(e)||(a.add(e),i.observe(e))};watch();let o=new MutationObserver(()=>{watch(),schedule()});return o.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`class`]}),()=>{i.disconnect(),o.disconnect(),r&&cancelAnimationFrame(r)}}var Zr={peeking:!1,over:!1,focused:!1,asking:!1};function peekAfter(e,t){switch(t){case`canvas`:return e.asking||e.over?e:{...e,peeking:!0};case`selection`:return e.asking||e.over||e.focused?e:{...e,peeking:!0};case`hover`:return{...e,over:!0,peeking:!1};case`leave`:return{...e,over:!1};case`focus`:return{...e,focused:!0,peeking:!1};case`blur`:return{...e,focused:!1};case`asking`:return{...e,asking:!0,peeking:!1};case`answered`:return{...e,asking:!1}}}var inside=(e,t)=>t instanceof Node&&e.contains(t);function usePeek(e,n,r,i){let a=o(Zr),[s,c]=t(!1),apply=e=>{let t=peekAfter(a.current,e);a.current=t,c(t.peeking)};return f(()=>{apply(r?`asking`:`answered`)},[r]),f(()=>{let t=e.current,r=t?.closest(`.editor-canvas`);if(!t||!r||!i){a.current=Zr,c(!1);return}let worked=e=>{inside(t,e.target)||apply(`canvas`)},over=e=>{e.target?.closest?.(`.assistant-card`)&&apply(`hover`)},out=e=>{e.relatedTarget?.closest?.(`.assistant-card`)||apply(`leave`)},focus=()=>apply(`focus`),blur=e=>{inside(t,e.relatedTarget)||apply(`blur`)},o=n?.subscribe(()=>apply(`selection`));return r.addEventListener(`pointerdown`,worked,!0),r.addEventListener(`wheel`,worked,{capture:!0,passive:!0}),t.addEventListener(`mouseover`,over),t.addEventListener(`mouseout`,out),t.addEventListener(`focusin`,focus),t.addEventListener(`focusout`,blur),()=>{o?.(),r.removeEventListener(`pointerdown`,worked,!0),r.removeEventListener(`wheel`,worked,!0),t.removeEventListener(`mouseover`,over),t.removeEventListener(`mouseout`,out),t.removeEventListener(`focusin`,focus),t.removeEventListener(`focusout`,blur)}},[e,n,i]),s&&!r}function useStore$1(){let[e]=t(()=>G());return e}e(useStore$1,`useStore`);var Qr=e(()=>()=>void 0,`none`),$r=360;function AssistantDock({editor:e,hidden:n,onAgentSettings:i}){let s=useStore$1(),c=W(s?s.subscribe:Qr,s?s.snapshot:()=>null),u=o(null),d=r(fn),p=useBridgeLinks(e),h=c?.enabled===!0&&c.place===`bottom`&&!n,g=s&&c?s.activeChat(e.key):null,_=!!c&&!!g&&c.shown[g.id]===!0&&c.folded[g.id]!==!0&&c.transcripts[g.id]?.permission!=null,v=!!c&&!!g&&c.transcripts[g.id]?.permission!=null,y=e.canvas?.channel,[b,x]=t(`full`),[S,C]=t(!1),w=v||g?.state===`waiting`,T=b===`collapsed`&&(S||w),E=usePeek(u,e.selection,_,h);if(f(()=>{let e=u.current,t=e?.closest(`.editor-canvas`);if(!e||!t)return;let publish=()=>{let n=e.offsetHeight,r=measureCorner(t),i=r.mode===`collapsed`&&T?r.overlayInset:r.inset,a=r.mode===`collapsed`&&T?r.overlayCovered:r.covered;t.style.setProperty(`--assistant-canvas-height`,`${t.clientHeight}px`),t.style.setProperty(`--assistant-inset-left`,`${i}px`),t.style.setProperty(`--assistant-inset-right`,`${a}px`),e.dataset.narrow=e.offsetWidth<$r?`true`:`false`,e.dataset.coverLeft=r.coveredLeft>0?`true`:`false`,x(r.mode),y?.setCover(v?$e(i,n,a):null)};publish();let n=observeCorner(t,[e],publish),r=Ye(t,publish);return()=>{n(),r(),t.style.removeProperty(`--assistant-canvas-height`),t.style.removeProperty(`--assistant-inset-left`),t.style.removeProperty(`--assistant-inset-right`),y?.setCover(null)}},[h,v,y,T]),f(()=>{if(b!==`collapsed`||!S)return;let away=e=>{let t=e.target;t instanceof Element&&!t.closest(`.assistant-dock, .ui-popover`)&&C(!1)};return document.addEventListener(`pointerdown`,away,!0),()=>document.removeEventListener(`pointerdown`,away,!0)},[b,S]),f(()=>{S&&s&&s.focusInput(e.key)},[S]),!s||!c||!h)return null;let D=s.activeChat(e.key),O=D?c.transcripts[D.id]??null:null,k=D!==null&&c.shown[D.id]===!0&&(D.state===`failed`||c.folded[D.id]!==!0),A=b===`collapsed`&&!T,j=D&&(D.state===`working`||D.state===`connecting`)?`working`:D&&(D.state===`waiting`||O?.permission)?`waiting`:null,collapse=()=>{C(!1),requestAnimationFrame(()=>u.current?.querySelector(`.assistant-ask`)?.focus())};return l(fn.Provider,{value:d===dn?p:d,children:l(`div`,{ref:u,class:`assistant-dock${A?` is-collapsed`:``}${T?` is-overlay`:``}`,onKeyDown:e=>{e.key===`Escape`&&(D&&k&&D.state!==`failed`?(e.stopPropagation(),s.setFolded(D.id,!0)):b===`collapsed`&&S&&!w&&(e.stopPropagation(),collapse()))},children:A?l(`button`,{type:`button`,class:`assistant-ask${j?` is-${j}`:``}`,"aria-label":m(`app.assistant.input.ask`),title:m(`app.assistant.input.ask`),onClick:()=>C(!0),children:j===`working`?l(X,{}):l(J,{name:j===`waiting`?`hand`:`chat`})}):l(a,{children:[D&&k&&l(AssistantCard,{store:s,state:c,editor:e,chat:D,transcript:O,peeking:E,onChooseAgent:()=>u.current?.querySelector(`.assistant-settings`)?.click(),onAgentSettings:i??(()=>void ce())}),!k&&c.failure&&l(`section`,{class:`assistant-card is-failed`,role:`alert`,"aria-label":m(`app.assistant.card.label`),children:[l(`header`,{class:`assistant-card__head`,children:[l(J,{name:`alert`,class:`assistant-card__icon is-warning`}),l(`span`,{class:`assistant-card__title`,children:m(`app.assistant.unreachable`)}),l(`span`,{class:`assistant-card__buttons`,children:l(`button`,{type:`button`,class:`assistant-button assistant-button--icon`,"aria-label":m(`app.assistant.card.close`),title:m(`app.assistant.card.close`),onClick:()=>s.dismissFailure(),children:l(J,{name:`close`})})})]}),l(`div`,{class:`assistant-card__body`,children:l(FailureNotice,{failure:c.failure,choices:c.choices,onRetry:()=>void s.resync(),onSettings:i??(()=>void ce())})})]}),l(AssistantInput,{store:s,editor:e,chat:D,transcript:O,surface:`dock`})]})})})}var ei=i(null);function TranscriptFailure({error:e}){let t=failureSummary(e,``);return l(a,{children:[l(`p`,{class:`assistant-entry is-notice type-help`,role:`alert`,children:t.text}),t.details&&l(FailureDetails,{text:t.details})]})}function ChatTabBody({store:e,editor:t}){let n=W(e.subscribe,e.snapshot),i=r(fn),a=useBridgeLinks(t),o=e.activeChat(t.key),s=o?.id??null,c=s?n.transcripts[s]??null:null,u=c?.entries??[],d=c?.permission??null,p=u[u.length-1],h=useFollow(d?.id??null,`${u.length}:${p&&`text`in p?p.text.length:0}:${o?.state??``}`);f(()=>{s&&e.open(s)},[e,s]);let g=o?.state===`working`||o?.state===`connecting`||o?.state===`waiting`,_=o?.state===`failed`;return l(fn.Provider,{value:i===dn?a:i,children:l(`section`,{class:`assistant-tab`,"aria-label":m(`app.assistant.tab.label`),children:[o&&l(`header`,{class:`assistant-tab__head`,children:[l(`span`,{class:`assistant-tab__title`,title:o.title,children:o.title}),l(`button`,{type:`button`,class:`assistant-button assistant-button--icon`,"aria-label":m(`app.assistant.card.newChat`),title:m(`app.assistant.card.newChat`),disabled:g||d!==null,onClick:()=>e.select(t.key,null),children:l(J,{name:`plus`})})]}),l(`div`,{ref:h.ref,class:`assistant-tab__feed`,role:`log`,"aria-live":`off`,"aria-label":m(`app.assistant.tab.transcript`),onScroll:h.onScroll,children:[!o&&!n.failure&&l(De,{title:m(`app.assistant.tab.empty`),hint:m(`app.assistant.tab.emptyHint`)}),c?.status===`loading`&&u.length===0&&l(`p`,{class:`assistant-card__status type-help`,role:`status`,children:[l(X,{}),` `,m(`app.assistant.card.loading`)]}),s&&c?.status===`failed`&&l(De,{title:m(`app.assistant.tab.unreadable`),hint:m(`app.assistant.tab.unreadableHint`),actions:[{label:m(`app.assistant.tryAgain`),run:()=>void e.retry(s,null)}]}),o&&c?.status===`ready`&&u.length===0&&!d&&l(De,{title:m(`app.assistant.tab.emptyChat`),hint:m(`app.assistant.tab.emptyChatHint`)}),c&&l(TranscriptView,{store:e,chatId:s??``,entries:u,permission:d,running:g,surface:`tab`,onShow:(e,n)=>{if(!t.canvas?.channel.has(proposalId(e,n)))return!1;let r=t.canvas.channel;return requestAnimationFrame(()=>requestAnimationFrame(()=>r.fit())),!0}}),_&&c?.error&&l(TranscriptFailure,{error:c.error}),n.failure&&l(FailureNotice,{failure:n.failure,choices:n.choices,onRetry:()=>void e.resync(),onSettings:()=>void ce()})]}),l(`div`,{class:`assistant-tab__input`,children:l(AssistantInput,{store:e,editor:t,chat:o,transcript:c,surface:`tab`})})]})})}function ChatTab(){let e=r(ei),[n]=t(()=>G());return!n||!e?null:l(ChatTabBody,{store:n,editor:e})}var ti={id:`chat`,icon:`chat`,component:ChatTab,needs:`ai-chat`};function chatStatusOf(e,t){let n=t?e.active[t]:null;if(!n)return null;let r=e.chats.find(e=>e.id===n);return r?r.state===`waiting`||e.transcripts[n]?.permission?`waiting`:r.state===`working`||r.state===`connecting`?`working`:null:null}function useEditorCanvas(e){let t=o(e);return t.current=e,c(()=>{let e=new EditorCanvas((n,r)=>{let i=e.describe(n);G()?.compose(t.current,{kind:`element`,id:n,type:i?.type??`bpmn:Task`,...i?.name?{name:i.name}:{}},r)});return e},[])}function useAssistantEditor({kind:e,file:t,fallbackName:n,selection:r,elements:i}){let a=t??null,o=a??n,s=useEditorCanvas(o),l=e===`bpmn`?s:void 0;return c(()=>({key:o,file:a,name:a?pe(a):n,kind:e,canvas:l,selection:r??l,elements:i??l?.elements}),[o,a,n,e,l,r,i])}var none=()=>()=>void 0;function useAiChatPlace(){let[e]=t(()=>G());return W(e?e.subscribe:none,()=>e?e.snapshot().place:`off`)}function useChatStatus(e){let[n]=t(()=>G());return W(n?n.subscribe:none,()=>n?chatStatusOf(n.snapshot(),e):null)}function useRevealCount(e){let[n]=t(()=>G());return W(n?n.subscribe:none,()=>n&&e?n.snapshot().revealed[e]??0:0)}function useLeaveChatTab(e,t){let n=o(t);f(()=>{n.current&&!t&&e&&G()?.returnToCard(e),n.current=t},[e,t])}function useChatAction(e,t){let n=useAiChatPlace(),r=useChatStatus(e);return{available:_e(n).toolbarButton,open:t===ti.id,status:r}}var ni=null,ri=null,ii=new Set;function sameFacts(e,t){return JSON.stringify(e)===JSON.stringify(t)}function publishFacts(e,t){ni===e&&sameFacts(ri,t)||(ni=e,ri=t,ii.forEach(e=>e()))}function retractFacts(e){ni===e&&(ni=null,ri=null,ii.forEach(e=>e()))}function useEditorFacts(){let[,e]=t(0);return f(()=>{let listener=()=>e(e=>e+1);return ii.add(listener),()=>void ii.delete(listener)},[]),ri}function ToolbarButton({id:e,label:n,icon:r,action:i,disabled:a=!1,tooltip:s,description:c,isActive:u=!1,checked:d,status:p}){let[h,g]=t(!1),_=o(null);f(()=>()=>{_.current!==null&&window.clearTimeout(_.current),_.current=null},[]);let handleClick=()=>{a||(i(),g(!0),_.current!==null&&window.clearTimeout(_.current),_.current=window.setTimeout(()=>{_.current=null,g(!1)},motionMs(`--motion-base`)))},handleKeyDown=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),handleClick())};return l(`button`,{id:e,className:`toolbar-button type-toolbar-button ${a?`disabled`:``} ${u||h?`active`:``}`,onClick:handleClick,onKeyDown:handleKeyDown,disabled:a,title:s||n,"aria-label":n,"aria-description":c??(p?m(`app.sidebar.status.${p}`):void 0),"aria-pressed":d===void 0?void 0:d,type:`button`,children:[l(`span`,{className:`toolbar-button-icon icon-${r}`,role:`presentation`,children:l(`svg`,{className:`toolbar-icon-svg`,viewBox:`0 0 16 16`,width:`16`,height:`16`,stroke:`currentColor`,fill:`none`,"stroke-width":`1`,"stroke-linecap":`round`,"stroke-linejoin":`round`,dangerouslySetInnerHTML:{__html:getIconPath(r)}})}),p===`working`&&l(`span`,{className:`toolbar-button-status is-working`,"aria-hidden":`true`,children:l(X,{})}),p===`waiting`&&l(`span`,{className:`toolbar-button-status is-waiting`,"aria-hidden":`true`})]})}function getIconPath(e){return{refresh:`<path d="M2.5 9V8a5.5 5.5 0 0 1 8.5-4.6"/><path d="M5 12.6A5.5 5.5 0 0 0 13.5 8V7"/><path d="M1.5 7.5l2 2 2-2"/><path d="M10.5 8.5l2-2 2 2"/>`,undo:`<path d="M5 3.5 2.5 6 5 8.5"/><path d="M2.5 6h7a3.5 3.5 0 0 1 0 7h-3"/>`,redo:`<path d="M11 3.5 13.5 6 11 8.5"/><path d="M13.5 6h-7a3.5 3.5 0 0 0 0 7h3"/>`,copy:`<rect x="5.5" y="5.5" width="8" height="8" rx="1.5"/><path d="M10.5 3.5V3a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h.5"/>`,paste:`<path d="M5.5 3h-1A1.5 1.5 0 0 0 3 4.5v8A1.5 1.5 0 0 0 4.5 14h7a1.5 1.5 0 0 0 1.5-1.5v-8A1.5 1.5 0 0 0 11.5 3h-1"/><rect x="5.5" y="1.5" width="5" height="3" rx="1"/>`,"auto-layout":`<rect x="1.5" y="6.5" width="4" height="3" rx="0.5"/><rect x="10.5" y="2.5" width="4" height="3" rx="0.5"/><rect x="10.5" y="10.5" width="4" height="3" rx="0.5"/><path d="M5.5 8h2.5V4h2.5M8 8v4h2.5"/>`,"diagram-check":`<path d="M8 1.5 14.5 8 8 14.5 1.5 8Z"/><path d="M5.5 8.2 7.2 9.9 10.5 6.3"/>`,migration:`<path d="M6 3.5 10.5 8 6 12.5 1.5 8Z"/><path d="M10.5 8h4M13 6.5 14.5 8 13 9.5"/>`,live:`<path d="M1.5 8.5h3l1.5-4 3 8 1.5-4h4"/>`,runs:`<path d="M2.5 4.5l1.5 1.5 3-3"/><path d="M9.5 4.5h4"/><path d="M2.5 11l1.5 1.5 3-3"/><path d="M9.5 11h4"/>`,debug:`<circle cx="4.5" cy="8" r="2"/><path d="M8.5 3.5v9M8.5 8h5M11.5 5.5 14 8l-2.5 2.5"/>`,breakpoint:`<circle cx="8" cy="8" r="5"/><circle cx="8" cy="8" r="2"/>`,coverage:`<rect x="1.5" y="4.5" width="4" height="4" rx="1"/><rect x="10.5" y="4.5" width="4" height="4" rx="1"/><path d="M5.5 6.5h5"/><path d="M1.5 12.5h13" opacity="0.4"/><path d="M1.5 12.5h8"/>`,export:`<path d="M8 2.5v7M5 6.5l3 3 3-3"/><path d="M2.5 10v2A1.5 1.5 0 0 0 4 13.5h8a1.5 1.5 0 0 0 1.5-1.5v-2"/>`,share:`<path d="M9.5 2.5h4v4M13.5 2.5 8 8"/><path d="M12.5 9v3a1.5 1.5 0 0 1-1.5 1.5H4A1.5 1.5 0 0 1 2.5 12V5A1.5 1.5 0 0 1 4 3.5h3"/>`,import:`<path d="M9 2.5H4.5a1 1 0 0 0-1 1v9a1 1 0 0 0 1 1h7a1 1 0 0 0 1-1V6Z"/><path d="M9 2.5V6h3.5"/><path d="M8 8v4M6 10l2 2 2-2"/>`,"token-simulation":`<path d="M5 3.3v9.4a.5.5 0 0 0 .77.42l7.1-4.7a.5.5 0 0 0 0-.84L5.77 2.88A.5.5 0 0 0 5 3.3Z"/>`,minimap:`<path d="M2.5 4 6 2.5l4 1.5 3.5-1.5V12L10 13.5 6 12l-3.5 1.5Z"/><path d="M6 2.5V12M10 4v9.5"/>`,"trace-paths":`<rect x="5.5" y="4.5" width="5" height="7" rx="1"/><path d="M1.5 2H3V6H5.5M1.5 14H3V10H5.5M10.5 6H13V2H14.5M10.5 10H13V14H14.5"/>`,deploy:`<path d="M8 14V7.5M5.5 10 8 7.5l2.5 2.5"/><path d="M5 12h-.75a3 3 0 0 1-.4-5.97 4.5 4.5 0 0 1 8.3 0A3 3 0 0 1 11.75 12H11"/>`,marketplace:`<rect x="2.5" y="2.5" width="4.5" height="4.5" rx="1"/><rect x="9" y="2.5" width="4.5" height="4.5" rx="1"/><rect x="2.5" y="9" width="4.5" height="4.5" rx="1"/><rect x="9" y="9" width="4.5" height="4.5" rx="1"/>`,sketchy:`<path d="M2.5 10.5c1.5-3 3-3 4.5 0s3 3 4.5 0 1.5-2 2-2.5"/><path d="M2.5 6c1-1.5 2-1.5 3 0"/>`,"panel-toggle":`<rect x="2.5" y="2.5" width="11" height="11" rx="2"/><path d="M9.5 2.5v11"/><path d="M11.5 5h.5M11.5 7h.5M11.5 9h.5"/>`,preview:`<path d="M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8Z"/><circle cx="8" cy="8" r="2"/>`,transaction:`<rect x="1.5" y="4.5" width="4" height="7" rx="1"/><rect x="10.5" y="4.5" width="4" height="7" rx="1"/><path d="M8 2.5v11"/>`,fit:`<path d="M2.5 6V2.5H6M10 2.5h3.5V6M13.5 10v3.5H10M6 13.5H2.5V10"/>`,"focus-canvas":`<path d="M2.5 5.5v-2a1 1 0 0 1 1-1h2M10.5 2.5h2a1 1 0 0 1 1 1v2M13.5 10.5v2a1 1 0 0 1-1 1h-2M5.5 13.5h-2a1 1 0 0 1-1-1v-2"/><rect x="5.5" y="5.5" width="5" height="5" rx="1"/>`,"zoom-in":`<circle cx="7" cy="7" r="4.5"/><path d="M10.5 10.5 14 14M5 7h4M7 5v4"/>`,"zoom-out":`<circle cx="7" cy="7" r="4.5"/><path d="M10.5 10.5 14 14M5 7h4"/>`,tour:`<path d="M3.5 14V2.5"/><path d="M3.5 3h9v6h-9"/>`,compare:`<rect x="1.5" y="3.5" width="5" height="9" rx="1"/><rect x="9.5" y="3.5" width="5" height="9" rx="1"/><path d="M6.5 8h3"/>`,licence:`<circle cx="5.5" cy="10.5" r="3"/><path d="M7.7 8.3 13.5 2.5M11 5l1.5 1.5"/>`,documentation:`<path d="M3.5 12.5v-9a1 1 0 0 1 1-1h8v10h-8a1 1 0 0 0-1 1 1 1 0 0 0 1 1h8"/><path d="M6.5 5.5h4"/>`,sun:`<circle cx="8" cy="8" r="2.5"/><path d="M8 1.5V3M8 13v1.5M1.5 8H3M13 8h1.5M3.4 3.4l1.1 1.1M11.5 11.5l1.1 1.1M3.4 12.6l1.1-1.1M11.5 4.5l1.1-1.1"/>`,keyboard:`<rect x="1.5" y="4" width="13" height="8" rx="1.5"/><path d="M4 6.75h.01M6.5 6.75h.01M9 6.75h.01M11.5 6.75h.01M4 9.25h.01M11.5 9.25h.01M6.5 9.25h3"/>`,pin:`<path d="M6 2.5h4M7 2.5v4L4.5 9.5h7L9 6.5v-4M8 9.5v4"/>`,lock:`<rect x="3.5" y="7" width="9" height="6.5" rx="1.5"/><path d="M5.5 7V5a2.5 2.5 0 0 1 5 0v2"/>`,check:`<path d="M3.5 8.5 6.5 11.5 12.5 4.5"/>`,chevron:`<path d="M5 6.5 8 9.5l3-3"/>`,settings:`<path d="M2.5 4.5h6M11.5 4.5h2M2.5 11.5h2M7.5 11.5h6"/><circle cx="10" cy="4.5" r="1.5"/><circle cx="6" cy="11.5" r="1.5"/>`,more:`<circle cx="3.5" cy="8" r="0.75" fill="currentColor"/><circle cx="8" cy="8" r="0.75" fill="currentColor"/><circle cx="12.5" cy="8" r="0.75" fill="currentColor"/>`,delete:`<path d="M2.5 4.5h11M6.5 4.5v-1a1 1 0 0 1 1-1h1a1 1 0 0 1 1 1v1"/><path d="M4 4.5l.6 8.1a1 1 0 0 0 1 .9h4.8a1 1 0 0 0 1-.9l.6-8.1"/><path d="M6.8 7v4M9.2 7v4"/>`,"skip-back":`<path d="M4 3.5v9"/><path d="M12.5 4v8L6.5 8Z"/>`,"step-back":`<path d="M10 3.5 5.5 8l4.5 4.5"/>`,"step-forward":`<path d="M6 3.5 10.5 8 6 12.5"/>`,"skip-forward":`<path d="M12 3.5v9"/><path d="M3.5 4v8L9.5 8Z"/>`,pause:`<path d="M6 3.5v9M10 3.5v9"/>`,close:`<path d="M4 4l8 8M12 4l-8 8"/>`,code:`<path d="M5.5 4L2 8l3.5 4M10.5 4L14 8l-3.5 4"/>`,chat:`<path d="M2.5 2.5h11a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H8.5L5 13.5v-3H2.5a1 1 0 0 1-1-1v-6a1 1 0 0 1 1-1z"/><path d="M5 6.5h.01M8 6.5h.01M11 6.5h.01"/>`,comments:`<path d="M3.5 2.5h9v11h-9z"/><path d="M5.5 6h5M5.5 9h3.5"/>`}[e]||`<circle cx="8" cy="8" r="1"/>`}function Icon({name:e,className:t=`toolbar-icon-svg`}){return l(`svg`,{className:t,viewBox:`0 0 16 16`,width:`16`,height:`16`,stroke:`currentColor`,fill:`none`,"stroke-width":`1`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,dangerouslySetInnerHTML:{__html:getIconPath(e)}})}var ai=`penstock.web.chatsHeight`;function clampChats(e,t){let n=Math.max(96,t-96);return Math.min(n,Math.max(96,Math.round(e)))}function loadChatsHeight(e){try{let t=Number(e?.getItem(ai));return Number.isFinite(t)&&t>=96?Math.round(t):null}catch{return null}}function saveChatsHeight(e,t){try{t===null?e?.removeItem(ai):e?.setItem(ai,String(Math.round(t)))}catch{}}function browserStore(){try{return typeof localStorage>`u`?void 0:localStorage}catch{return}}var oi=16;function clampSidebar(e){return Math.min(400,Math.max(240,Math.round(e)))}var si=[{id:`check`,action:`diagram-check`,icon:`diagram-check`,label:()=>m(`app.web.sidebar.check`)},{id:`scenarios`,action:`runs`,icon:`runs`,label:()=>m(`app.web.sidebar.scenarios`)},{id:`monitor`,action:`live`,icon:`live`,label:()=>m(`app.web.sidebar.monitor`)},{id:`debug`,action:`debug-process`,icon:`debug`,label:()=>m(`app.web.sidebar.debug`)},{id:`layout`,action:`auto-layout`,icon:`auto-layout`,label:()=>m(`app.web.sidebar.layout`)}];function countOf(e,t){return t?e.id===`check`&&t.problems?{text:String(t.problems),title:m(`app.web.sidebar.countProblems`,{count:t.problems}),error:!0}:e.id===`scenarios`&&t.scenarios?{text:`${t.scenarios.passed}/${t.scenarios.all}`,title:m(`app.web.sidebar.countScenarios`,{passed:t.scenarios.passed,all:t.scenarios.all}),error:!1}:e.id===`monitor`&&t.waiting?{text:String(t.waiting),title:m(`app.web.sidebar.countWaiting`,{count:t.waiting}),error:!1}:null:null}function useChatsOn(e){let[n,r]=t(()=>e?.snapshot().enabled===!0);return f(()=>{if(e)return r(e.snapshot().enabled===!0),e.subscribe(()=>r(e.snapshot().enabled===!0))},[e]),n}function ShellSidebar({width:e,onWidth:n,drawer:r,onClose:i,runAction:s,openFile:c,focusedEditor:u,chatsStore:d,children:f}){let p=useEditorFacts(),h=o(null),g=G(),_=o(null),v=o(null),y=o(null),[b,x]=t(()=>loadChatsHeight(d??browserStore())),S=useChatsOn(g),available=()=>(_.current?.querySelector(`.web-sidebar__project`)?.getBoundingClientRect().height??0)+(v.current?.getBoundingClientRect().height??0),resize=(e,t,n=available())=>{let r=e===null?null:clampChats(e,n);x(r),t&&saveChatsHeight(d??browserStore(),r)},current=()=>v.current?.getBoundingClientRect().height??0;return l(a,{children:[r&&l(`div`,{class:`web-sidebar__scrim`,onPointerDown:i}),l(`aside`,{ref:_,class:`web-sidebar${r?` is-drawer`:``}`,style:r?void 0:{width:`${e}px`},"aria-label":m(`app.web.sidebar.label`),children:[l(`h2`,{class:`web-sidebar__heading type-section-heading`,children:m(`app.web.sidebar.actions`)}),l(`nav`,{class:`web-sidebar__actions`,"aria-label":m(`app.web.sidebar.actions`),children:si.map(e=>{let t=!!p&&p.actions.includes(e.action),n=countOf(e,p);return l(`button`,{type:`button`,class:`web-action type-body`,disabled:!t,title:t?void 0:m(`app.web.sidebar.unavailable`),"data-action":e.id,onClick:()=>{s(e.action)&&r&&i()},children:[l(Icon,{name:e.icon,className:`web-action__icon`}),l(`span`,{class:`web-action__label`,children:e.label()}),n&&l(`span`,{class:`web-action__count type-help${n.error?` is-error`:``}`,title:n.title,"aria-label":n.title,children:n.text})]},e.id)})}),l(`section`,{class:`web-sidebar__project`,children:f}),g&&l(`div`,{ref:v,class:`web-sidebar__chats${b===null?``:` is-sized`}`,style:b===null?void 0:{flexBasis:`${b}px`},children:[S&&l(`div`,{class:`web-sidebar__chats-sash`,role:`separator`,"aria-orientation":`horizontal`,"aria-label":m(`app.web.sidebar.resizeChats`),tabIndex:0,onPointerDown:e=>{e.preventDefault(),y.current={y:e.clientY,height:current(),available:available()},e.currentTarget.setPointerCapture?.(e.pointerId)},onPointerMove:e=>{let t=y.current;t&&resize(t.height-(e.clientY-t.y),!1,t.available)},onPointerUp:e=>{let t=y.current;y.current=null,t&&resize(t.height-(e.clientY-t.y),!0,t.available)},onDblClick:()=>resize(null,!0),onKeyDown:e=>{if(e.key===`ArrowUp`)resize(current()+16,!0);else if(e.key===`ArrowDown`)resize(current()-16,!0);else if(e.key===`Home`)resize(null,!0);else return;e.preventDefault()}}),l(ChatsSection,{store:g,editor:u,onOpen:r?i:void 0,onOpenFile:c})]}),!r&&l(`div`,{class:`web-sidebar__sash`,role:`separator`,"aria-orientation":`vertical`,"aria-label":m(`app.web.sidebar.resize`),"aria-valuemin":240,"aria-valuemax":400,"aria-valuenow":e,tabIndex:0,onPointerDown:t=>{t.preventDefault(),h.current={x:t.clientX,width:e},t.currentTarget.setPointerCapture?.(t.pointerId)},onPointerMove:e=>{h.current&&n(clampSidebar(h.current.width+e.clientX-h.current.x))},onPointerUp:()=>{h.current=null},onKeyDown:t=>{if(t.key===`ArrowLeft`)n(clampSidebar(e-oi));else if(t.key===`ArrowRight`)n(clampSidebar(e+oi));else return;t.preventDefault()}})]})]})}function relOf(e){return e.kind===`file`?e.file.rel:e.rel}function parentOf(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}function nameOf(e){return e.slice(e.lastIndexOf(`/`)+1)}function insideFolder(e,t){return e===t||e.startsWith(`${t}/`)}function canMoveInto(e,t){let n=relOf(e);return!(parentOf(n)===t||e.kind===`folder`&&insideFolder(t,n))}var EntryOps=class{store;host;constructor(e,t){this.store=e,this.host=t}async fresh(){await this.store.refresh(),await this.store.refresh()}openIn(e){let t=this.store.snapshot(),n=t.order.map(e=>t.docs.get(e)).filter(e=>!!e);return e.kind===`file`?n.filter(t=>t.path===e.file.path):n.filter(t=>t.rel.startsWith(`${e.rel}/`))}unsavedIn(e){return this.openIn(e).filter(e=>Ue(e))}async park(e){let t=this.openIn(e);for(let e of t)if(Ue(this.store.doc(e.path))&&!await this.store.save(e.path))throw Error(this.store.doc(e.path)?.saveError??e.name);let n=this.store.snapshot().active;for(let e of t)this.store.close(e.path);return{docs:t,active:n}}async restore(e,t){let n=[...e.docs].sort((t,n)=>Number(t.path===e.active)-Number(n.path===e.active));for(let e of n)await this.store.open(t(e),e.kind)}async change(e,t,n){let r=await this.park(e),i;try{i=await t()}catch(e){throw await this.restore(r,e=>e.path),e}await this.fresh();let a=this.store.snapshot().listing.root,o=relOf(e),s=n(i);return await this.restore(r,t=>e.kind===`file`?Re(a,s):Re(a,`${s}${t.rel.slice(o.length)}`)),s}async rename(e,t){let n=relOf(e),r=parentOf(n);return this.change(e,()=>this.host.rename(n,t,null),()=>r===``?t:`${r}/${t}`)}async move(e,t){let n=relOf(e),r=nameOf(n);return this.change(e,()=>this.host.move(n,t,null),()=>t===``?r:`${t}/${r}`)}async duplicate(e){let t=await this.host.duplicate(e.rel);return await this.fresh(),t}async remove(e){await this.fresh();let t=relOf(e),n=e.kind===`file`?this.store.snapshot().listing.files.find(e=>e.rel===t)?.stamp??null:null;await this.host.remove(t,n);for(let t of this.openIn(e))this.store.close(t.path);await this.fresh()}async createFolder(e){await this.host.createFolder(e),await this.fresh()}},ci=/[\\/\0-\u001f:*?"<>|]/;function nameFault(e){return e.trim()===``?m(`app.web.entry.nameEmpty`):ci.test(e)?m(`app.web.entry.nameCharacters`):e===`.`||e===`..`||/[. ]$/.test(e)||/^ /.test(e)?m(`app.web.entry.nameEnds`):null}function messageFrom$1(e){return e instanceof Error&&e.message?e.message:m(`app.web.unknownFailure`)}e(messageFrom$1,`messageFrom`);function NewFolderDialog({parent:e,onCreate:n,onClose:r}){let[i,a]=t(``),[o,s]=t(!1),[c,u]=t(null),d=Ee(),f=nameFault(i),create=async()=>{if(d.submit(),f)requestAnimationFrame(()=>document.querySelector(`.ui-dialog [aria-invalid="true"]`)?.focus());else{s(!0),u(null);try{await n(e===``?i:`${e}/${i}`),r()}catch(e){u(messageFrom$1(e)),s(!1)}}};return l(q,{title:m(`app.web.entry.newFolderTitle`),size:`small`,onClose:r,onSubmit:()=>void create(),footer:l(Y,{actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:r,disabled:o},{id:`create`,label:m(`app.web.entry.createFolder`),role:`primary`,onClick:()=>void create(),busy:o}]}),children:[l(we,{label:m(`app.web.entry.name`),hint:e===``?m(`app.web.entry.insideProject`):m(`app.web.entry.inside`,{folder:e}),error:d.errorOf(`name`,f),children:e=>l(`input`,{...e,value:i,spellcheck:!1,autocomplete:`off`,onInput:e=>a(e.target.value),onBlur:()=>d.touch(`name`)})}),c&&l(ke,{children:c})]})}function RenameDialog({target:e,onRename:n,onClose:r}){let i=e.kind===`file`?e.file.name:e.name,[a,o]=t(i),[s,c]=t(!1),[u,d]=t(null),f=Ee(),p=nameFault(a),rename=async()=>{if(f.submit(),p)requestAnimationFrame(()=>document.querySelector(`.ui-dialog [aria-invalid="true"]`)?.focus());else if(a===i)r();else{c(!0),d(null);try{await n(a),r()}catch(e){d(messageFrom$1(e)),c(!1)}}};return l(q,{title:m(`app.web.entry.renameTitle`,{name:i}),size:`small`,onClose:r,onSubmit:()=>void rename(),footer:l(Y,{actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:r,disabled:s},{id:`rename`,label:m(`app.web.entry.rename`),role:`primary`,onClick:()=>void rename(),busy:s}]}),children:[l(we,{label:m(`app.web.entry.renameLabel`),error:f.errorOf(`name`,p),children:t=>l(`input`,{...t,value:a,spellcheck:!1,autocomplete:`off`,ref:t=>{if(t&&!t.dataset.selected){t.dataset.selected=`yes`;let n=i.lastIndexOf(`.`);t.setSelectionRange(0,n>0&&e.kind===`file`?n:i.length)}},onInput:e=>o(e.target.value),onBlur:()=>f.touch(`name`)})}),u&&l(ke,{children:u})]})}function DeleteDialog({target:e,files:n,unsaved:r,onDelete:i,onClose:a}){let[o,s]=t(!1),[c,u]=t(null),d=e.kind===`file`?e.file.name:e.name,f=e.kind===`folder`,run=async()=>{s(!0),u(null);try{await i(),a()}catch(e){u(messageFrom$1(e)),s(!1)}};return l(q,{title:m(f?`app.web.entry.deleteFolderTitle`:`app.web.entry.deleteFileTitle`,{name:d}),size:`small`,destructive:!0,onClose:a,footer:l(Y,{actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:a,disabled:o},{id:`delete`,label:m(f?`app.web.entry.deleteFolder`:`app.web.entry.deleteFile`),role:`primary`,onClick:()=>void run(),busy:o}]}),children:[l(`p`,{class:`web-dialog-text type-body`,children:f?m(`app.web.entry.deleteFolderText`,{name:d,count:n}):m(`app.web.entry.deleteFileText`,{name:d})}),r>0&&l(`p`,{class:`web-dialog-text type-body`,children:m(`app.web.entry.deleteUnsaved`,{count:r})}),c&&l(ke,{children:c})]})}function MoveDialog({target:e,folders:n,onMove:r,onClose:i}){let a=[``,...n].filter(t=>canMoveInto(e,t)),[o,s]=t(a[0]??``),[c,u]=t(!1),[d,f]=t(null),p=e.kind===`file`?e.file.name:nameOf(e.rel),run=async()=>{u(!0),f(null);try{await r(o),i()}catch(e){f(messageFrom$1(e)),u(!1)}};return l(q,{title:m(`app.web.entry.moveTitle`,{name:p}),size:`small`,onClose:i,onSubmit:()=>void run(),footer:l(Y,{actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:i,disabled:c},{id:`move`,label:m(`app.web.entry.move`),role:`primary`,onClick:()=>void run(),busy:c,disabled:a.length===0}]}),children:[a.length===0?l(`p`,{class:`web-dialog-text type-body`,children:m(`app.web.entry.noFolders`)}):l(we,{label:m(`app.web.entry.moveTo`),children:e=>l(`select`,{...e,value:o,onChange:e=>s(e.target.value),children:a.map(e=>l(`option`,{value:e,children:e===``?m(`app.web.entry.projectFolder`):e},e))})}),d&&l(ke,{children:d})]})}var li=i(null);function useProject(){return r(li)}function targetOfNode(e,t){if(!e.path)return null;if(e.id.startsWith(`file:`)){let n=Be(e.path),r=t.files.find(e=>e.path===n)??t.files.find(e=>e.rel===He(t.root,n));return r?{kind:`file`,file:r}:null}if(e.id.startsWith(`folder:`)){let n=He(t.root,e.path);return n===``?null:{kind:`folder`,rel:n,name:n.slice(n.lastIndexOf(`/`)+1)}}return null}function copyText(e){let t=navigator.clipboard?.writeText?.(e);t?t.then(()=>H.info(m(`app.web.entry.copied`)),()=>H.error(m(`app.web.tree.copyFailed`))):H.error(m(`app.web.tree.copyFailed`))}function useEntryActions(e){let n=useProject(),r=c(()=>n?new EntryOps(n.store,n.entries):null,[n]),[i,o]=t(null),[s,u]=t(null),[d,f]=t(null),[p,h]=t(null);return c(()=>{if(!n||!r)return null;let listing=()=>n.store.snapshot().listing,report=e=>H.error(messageFrom$1(e)),run=e=>void e.catch(report),revealRel=t=>e(Re(listing().root,t)),pathOf=(e,t)=>{let n=e.kind===`file`?e.file.rel:e.rel;return t?n:Re(listing().root,n)},targetOf=e=>targetOfNode(e,listing()),itemsFor=t=>{let i=targetOf(t);if(!i)return[];let a=[];return i.kind===`folder`&&(a.push({id:`new-file`,label:m(`app.web.tree.newFile`),run:()=>n.newFile(i.rel)}),a.push({id:`new-folder`,label:m(`app.web.entry.newFolder`),run:()=>u(i.rel)})),a.push({id:`rename`,label:m(`app.web.entry.rename`),shortcut:`F2`,separated:a.length>0,run:()=>o(i)}),i.kind===`file`&&a.push({id:`duplicate`,label:m(`app.web.entry.duplicate`),run:()=>run(r.duplicate(i.file).then(t=>e(t)))}),a.push({id:`move`,label:m(`app.web.entry.moveAction`),run:()=>h(i)}),a.push({id:`delete`,label:m(`app.web.entry.delete`),shortcut:`Del`,danger:!0,run:()=>f(i)}),a.push({id:`copy-path`,label:m(`app.web.entry.copyPath`),separated:!0,run:()=>copyText(pathOf(i,!1))}),a.push({id:`copy-relative`,label:m(`app.web.entry.copyRelative`),run:()=>copyText(pathOf(i,!0))}),i.kind===`file`&&a.push({id:`download`,label:m(`app.web.entry.download`),run:()=>n.downloadFile(i.file)}),a},backgroundItems=()=>[{id:`new-file`,label:m(`app.web.tree.newFile`),run:()=>n.newFile(``)},{id:`new-folder`,label:m(`app.web.entry.newFolder`),run:()=>u(``)},{id:`refresh`,label:m(`app.web.tree.refresh`),separated:!0,run:()=>run(n.store.refresh())}],headerItems=e=>{let t=e?listing().files.find(t=>t.path===e):void 0;return[{id:`new-folder`,label:m(`app.web.entry.newFolder`),run:()=>u(``)},{id:`upload`,label:m(`app.web.upload.button`),run:n.upload},{id:`download-file`,label:m(`app.web.entry.downloadActive`),disabled:!t,run:()=>t&&n.downloadFile(t)},{id:`download-project`,label:m(`app.web.project.downloadZip`),run:n.downloadArchive},{id:`refresh`,label:m(`app.web.tree.refresh`),separated:!0,run:()=>run(n.store.refresh())}]},dropFolderOf=e=>{let t=targetOf(e);return t?t.kind===`folder`?t.rel:parentOf(t.file.rel):null},drop=(e,t)=>{let n=e.kind===`file`?e.file.name:e.name;r.move(e,t).then(revealRel,e=>H.error(m(`app.web.entry.moveFailed`,{name:n,reason:messageFrom$1(e)})))},t=listing().files;return{targetOf,itemsFor,backgroundItems,headerItems,dropFolderOf,canDrop:canMoveInto,drop,newFile:()=>n.newFile(``),dialogs:i||s!==null||d||p?l(a,{children:[i&&l(RenameDialog,{target:i,onRename:async e=>{revealRel(await r.rename(i,e))},onClose:()=>o(null)}),s!==null&&l(NewFolderDialog,{parent:s,onCreate:async e=>{await r.createFolder(e),revealRel(e)},onClose:()=>u(null)}),d&&l(DeleteDialog,{target:d,files:d.kind===`folder`?t.filter(e=>e.rel.startsWith(`${d.rel}/`)).length:1,unsaved:r.unsavedIn(d).length,onDelete:()=>r.remove(d),onClose:()=>f(null)}),p&&l(MoveDialog,{target:p,folders:listing().folders,onMove:async e=>{revealRel(await r.move(p,e))},onClose:()=>h(null)})]}):null}},[n,r,i,s,d,p,e])}function DraftNotice({count:e,busy:t,onRestore:n,onDiscard:r}){return l(`div`,{class:`web-shell__notice web-pane__banner is-warning`,role:`region`,"aria-label":m(`app.web.drafts.label`),children:[l(Icon$1,{name:`alert`}),l(`span`,{class:`web-pane__banner-text type-body`,children:m(`app.web.drafts.found`,{count:e})}),l(`button`,{type:`button`,class:`ui-button ui-button--primary type-button`,disabled:t,onClick:n,children:m(`app.web.drafts.restore`)}),l(`button`,{type:`button`,class:`ui-button type-button`,disabled:t,onClick:r,children:m(`app.web.drafts.discard`)})]})}function SessionEnded({onRetry:e}){return l(q,{title:m(`app.web.expired.title`),size:`small`,backdrop:`keep`,onClose:e,onSubmit:e,footer:l(Y,{actions:[{id:`retry`,label:m(`app.web.expired.retry`),role:`primary`,onClick:e}]}),children:[l(`p`,{class:`type-body web-dialog-text`,children:m(`app.web.expired.text`)}),l(`p`,{class:`type-help web-dialog-text`,children:m(`app.web.expired.hint`)})]})}function Welcome$1({recent:e,onOpen:t,onQuickOpen:n,onNew:r,quickKeys:i,empty:a}){return l(`div`,{class:`web-welcome`,children:[l(`p`,{class:`ui-empty__title type-body`,children:m(a?`app.web.tree.empty`:`app.web.empty.title`)}),l(`p`,{class:`ui-empty__hint type-help`,children:m(a?`app.web.tree.emptyHint`:`app.web.empty.hint`)}),l(`div`,{class:`ui-empty__actions`,children:[!a&&l(`button`,{type:`button`,class:`ui-button type-button`,onClick:n,children:i?`${m(`app.web.command.quickOpen`)} (${i})`:m(`app.web.command.quickOpen`)}),l(`button`,{type:`button`,class:`ui-button type-button`,onClick:r,children:m(`app.web.tree.newFile`)})]}),e.length>0&&l(`section`,{class:`web-welcome__recent`,"aria-label":m(`app.web.quick.recent`),children:[l(`h3`,{class:`web-welcome__heading type-section-heading`,children:m(`app.web.quick.recent`)}),l(`ul`,{class:`web-welcome__list`,children:e.map(e=>l(`li`,{children:l(`button`,{type:`button`,class:`web-welcome__file type-body`,title:e.rel,onClick:()=>t(e.rel),children:[l(`span`,{class:`web-welcome__name`,children:e.name}),l(`span`,{class:`web-welcome__where type-help`,children:e.rel.includes(`/`)?e.rel.slice(0,e.rel.lastIndexOf(`/`)):``})]})},e.rel))})]})]})}e(Welcome$1,`Welcome`);var ui=[{id:`process`,kinds:[`bpmn`]},{id:`decision`,kinds:[`dmn`]},{id:`form`,kinds:[`form`]},{id:`testCase`,kinds:[`testCase`]},{id:`template`,kinds:[`template`]}];function groupOfKind(e){return ui.find(t=>t.kinds.includes(e))?.id??`process`}var di=8;function placeMenu(e,t,n){let r=Math.max(di,Math.min(e.x,n.width-t.width-di)),i=e.y+t.height+di>n.height?Math.max(di,e.y-t.height):e.y;return{left:r,top:Math.max(di,Math.min(i,n.height-t.height-di))}}function nextEnabled(e,t,n){if(e.every(e=>e.disabled))return-1;let r=t;for(let t=0;t<e.length;t+=1)if(r=(r+n+e.length)%e.length,!e[r].disabled)return r;return-1}function Menu({items:e,label:n,at:r,onClose:i,returnFocusTo:a}){let s=o(null),[c,d]=t(null),[p,m]=t(()=>nextEnabled(e,-1,1)),h=o(i);h.current=i,u(()=>{let e=s.current;e&&d(placeMenu(r,{width:e.offsetWidth,height:e.offsetHeight},{width:window.innerWidth,height:window.innerHeight}))},[r.x,r.y,e.length]),f(()=>{let away=e=>{e.target instanceof Node&&!s.current?.contains(e.target)&&h.current()},blur=()=>h.current();return document.addEventListener(`pointerdown`,away,!0),window.addEventListener(`blur`,blur),window.addEventListener(`resize`,blur),()=>{document.removeEventListener(`pointerdown`,away,!0),window.removeEventListener(`blur`,blur),window.removeEventListener(`resize`,blur);let e=document.activeElement;(e===document.body||e===null||s.current?.contains(e))&&a?.isConnected&&a.focus()}},[]),f(()=>{c&&s.current?.querySelector(`[data-index="${p}"]`)?.focus()},[p,c!==null]);let choose=e=>{e.disabled||(h.current(),setTimeout(e.run,0))},onKeyDown=t=>{t.key===`Escape`?(t.preventDefault(),t.stopPropagation(),h.current()):t.key===`ArrowDown`?(t.preventDefault(),m(t=>nextEnabled(e,t,1))):t.key===`ArrowUp`?(t.preventDefault(),m(t=>nextEnabled(e,t,-1))):t.key===`Home`?(t.preventDefault(),m(nextEnabled(e,-1,1))):t.key===`End`?(t.preventDefault(),m(nextEnabled(e,0,-1))):t.key===`Tab`&&(t.preventDefault(),h.current())};return l(`div`,{ref:s,class:`web-menu`,role:`menu`,"aria-label":n,style:{left:`${c?.left??r.x}px`,top:`${c?.top??r.y}px`,visibility:c?`visible`:`hidden`},onKeyDown,onContextMenu:e=>e.preventDefault(),children:e.map((e,t)=>l(`div`,{role:`none`,children:[e.separatorBefore&&l(`div`,{class:`web-menu__separator`,role:`separator`}),l(`button`,{type:`button`,role:e.marked===void 0?`menuitem`:`menuitemradio`,"aria-checked":e.marked===void 0?void 0:e.marked,class:`web-menu__item type-body`,"data-index":t,tabIndex:t===p?0:-1,disabled:e.disabled,onMouseMove:()=>!e.disabled&&m(t),onClick:()=>choose(e),children:[l(`span`,{class:`web-menu__label`,children:e.label}),e.keys&&l(`span`,{class:`web-menu__keys type-help`,children:e.keys})]})]},e.id))})}function tabLabels(e){let t=new Map;e.forEach(e=>t.set(e.name,(t.get(e.name)??0)+1));let n=new Map;return e.forEach(e=>{let r=e.rel.lastIndexOf(`/`),i=(r<0?``:e.rel.slice(0,r)).split(`/`).pop()??``;n.set(e.path,{name:e.name,where:(t.get(e.name)??0)>1?i:``})}),n}function scriptTabItems(e){return e.map(e=>({id:scriptPanel(e.id),label:e.title,where:``,icon:`script`,title:e.title,tabId:domId(`web-tab`,e.id),controls:domId(`web-pane`,e.id),dirty:!1,saving:!1,failed:!1,problem:e.conflict!==null,closeLabel:m(`app.web.tabs.close`,{name:e.title}),closeTitle:m(`app.web.tabs.close`,{name:e.title}),unsavedLabel:e.title,closable:!0}))}function docTabs(e,t){let n=tabLabels(e);return e.map(e=>({id:docPanel(e.path),label:n.get(e.path)?.name??e.name,where:n.get(e.path)?.where??``,icon:iconOfKind(e.kind,groupOfKind(e.kind)),title:Ue(e)?m(`app.web.tabs.unsaved`,{name:e.rel}):e.rel,tabId:domId(`web-tab`,e.path),controls:domId(`web-pane`,e.path),dirty:Ue(e),saving:e.saving,failed:!!e.saveError,problem:e.disk!==`in-sync`||!!e.saveError,closeLabel:m(`app.web.tabs.close`,{name:e.name}),closeTitle:rt(m(`app.web.tabs.close`,{name:e.name}),`closeTab`,t),unsavedLabel:m(`app.web.tabs.unsaved`,{name:e.name}),closable:!0}))}function dropIndex(e,t,n){let r=n===`before`?t:t+1;return e<r?r-1:r}function domId(e,t){let n=2166136261;for(let e=0;e<t.length;e+=1)n=Math.imul(n^t.charCodeAt(e),16777619)>>>0;return`${e}-${n.toString(36)}`}function TabStrip({tabs:e,active:n,onSelect:r,onClose:i,onDropTab:a,menuFor:s,menuLabel:c,leading:u,trailing:d}){let p=o(null),[h,g]=t(null),[_,v]=t(null),[y,b]=t(!1),[x,S]=t(null);f(()=>{(p.current?.querySelector(`[aria-selected="true"]`))?.scrollIntoView?.({block:`nearest`,inline:`nearest`})},[n,e.length]),f(()=>{let e=p.current;if(!e)return;let measure=()=>b(e.scrollWidth>e.clientWidth+1);if(measure(),typeof ResizeObserver>`u`)return;let t=new ResizeObserver(measure);return t.observe(e),()=>t.disconnect()},[e.length]);let focusTab=e=>requestAnimationFrame(()=>p.current?.querySelector(`[data-panel="${CSS.escape(e)}"]`)?.focus()),openMenu=(t,n,r)=>{let i=s?.(t)??[];i.length>0&&g({items:i,at:n,label:c?.(t)??m(`app.web.tabs.menu`,{name:e.find(e=>e.id===t)?.label??``}),opener:r})},openList=t=>{let i=t.getBoundingClientRect();g({items:e.map(e=>({id:e.id,label:`${e.dirty?`● `:``}${e.label}${e.where?` ${e.where}`:``}`,marked:e.id===n,run:()=>{r(e.id),focusTab(e.id)}})),at:{x:i.right-240,y:i.bottom+4},label:m(`app.web.tabs.all`),opener:t})},move=(t,n)=>{let o=e.length-1;if(t.key===`ContextMenu`||t.shiftKey&&t.key===`F10`){t.preventDefault();let r=t.currentTarget.getBoundingClientRect();openMenu(e[n].id,{x:r.left,y:r.bottom},t.currentTarget);return}if(t.altKey&&t.shiftKey&&(t.key===`ArrowLeft`||t.key===`ArrowRight`)){t.preventDefault(),a?.(e[n].id,t.key===`ArrowLeft`?n-1:n+1),focusTab(e[n].id);return}let s=-1;if(t.key===`ArrowRight`)s=n===o?0:n+1;else if(t.key===`ArrowLeft`)s=n===0?o:n-1;else if(t.key===`Home`)s=0;else if(t.key===`End`)s=o;else if(t.key===`Delete`&&e[n].closable){t.preventDefault(),i(e[n].id);return}else return;t.preventDefault();let c=e[s];c&&(r(c.id),focusTab(c.id))},finish=()=>{S(null),v(null),endDrag()},dropOn=t=>{let n=dragging(),r=_;if(t.preventDefault(),t.stopPropagation(),finish(),!n||!a)return;if(!r){a(n,e.length);return}let i=e.findIndex(e=>e.id===r.id);if(i<0)return;let o=e.findIndex(e=>e.id===n);a(n,o>=0?dropIndex(o,i,r.side):r.side===`before`?i:i+1)};return l(`div`,{class:`web-tabs`,children:[u,l(`div`,{ref:p,class:`web-tabs__list`,role:`tablist`,"aria-label":m(`app.web.tabs.label`),onDragOver:t=>{dragging()&&a&&(t.preventDefault(),t.stopPropagation(),t.target===t.currentTarget&&e.length>0&&v({id:e[e.length-1].id,side:`after`}))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||v(null)},onDrop:dropOn,children:e.map((e,t)=>{let o=e.id===n,c=_?.id===e.id?` is-drop-${_.side}`:``;return l(`div`,{class:`web-tabs__tab${o?` is-selected`:``}${e.problem?` has-problem`:``}${x===e.id?` is-dragging`:``}${c}`,draggable:!!a,onDragStart:t=>{beginDrag(e.id,t),S(e.id)},onDragOver:t=>{if(!dragging()||!a)return;t.preventDefault(),t.stopPropagation();let n=t.currentTarget.getBoundingClientRect(),r=t.clientX<n.left+n.width/2?`before`:`after`;(_?.id!==e.id||_.side!==r)&&v({id:e.id,side:r})},onDragEnd:finish,onContextMenu:t=>{s&&(t.preventDefault(),openMenu(e.id,{x:t.clientX,y:t.clientY},t.currentTarget))},children:[l(`button`,{type:`button`,role:`tab`,id:e.tabId,class:`web-tabs__select type-chrome`,"data-panel":e.id,"aria-selected":o,"aria-controls":e.controls,tabIndex:o?0:-1,title:e.title,onClick:()=>r(e.id),onAuxClick:t=>{t.button===1&&e.closable&&(t.preventDefault(),i(e.id))},onMouseDown:e=>{e.button===1&&e.preventDefault()},onKeyDown:e=>move(e,t),children:[l(Icon$1,{class:`web-tabs__icon`,name:e.icon}),l(`span`,{class:`web-tabs__name`,children:e.label}),e.where&&l(`span`,{class:`web-tabs__where type-chrome-small`,children:e.where})]}),e.saving&&l(`span`,{class:`web-tabs__saving`,role:`img`,"aria-label":m(`app.web.state.saving`),title:m(`app.web.state.saving`)}),!e.saving&&e.failed&&l(Icon$1,{class:`web-tabs__failed`,name:`alert`}),e.dirty&&!e.saving&&l(`span`,{class:`web-tabs__dot`,role:`img`,"aria-label":e.unsavedLabel}),e.closable&&l(`button`,{type:`button`,class:`web-tabs__close`,tabIndex:-1,"aria-label":e.closeLabel,title:e.closeTitle,onClick:()=>i(e.id),children:l(Icon$1,{name:`close`})})]},e.id)})}),y&&l(`button`,{type:`button`,class:`web-tabs__all`,"aria-haspopup":`menu`,"aria-label":m(`app.web.tabs.all`),title:m(`app.web.tabs.all`),onClick:e=>openList(e.currentTarget),children:l(Icon$1,{name:`list`})}),d,h&&l(Menu,{items:h.items,at:h.at,label:h.label,returnFocusTo:h.opener,onClose:()=>g(null)})]})}function handleFor(e,t,n,r,i){return{path:t,get rel(){return e.doc(t)?.rel??t},name:r,kind:n,scriptTabs:i,get initialText(){return e.doc(t)?.current??``},edit:n=>e.edit(t,n),onReload:n=>e.subscribeReload(t,n),save:()=>void e.save(t)}}function LazyEditor({doc:e,loaders:n,handle:r}){let i=Q(e.kind),[a,o]=t(null),[s,c]=t(null),[u,d]=t(0);if(f(()=>{let e=!0;return c(null),n[i]().then(t=>e&&o({component:t}),t=>e&&c(t instanceof Error?t.message:String(t))),()=>{e=!1}},[i,u]),s!==null)return l(De,{title:m(`app.web.pane.editorFailed`),hint:s||m(`app.web.pane.editorFailedHint`),actions:[{label:m(`app.common.retry`),run:()=>d(e=>e+1)}]});if(!a)return l(`p`,{class:`web-pane__status type-help`,role:`status`,children:m(`app.web.pane.loadingEditor`)});let p=a.component;return l(p,{handle:r})}function bannerFor(e,t,n,r){return e.disk===`deleted`?{tone:`error`,text:m(`app.web.banner.deleted`,{name:e.name}),actions:[{label:m(`app.common.save`),run:()=>void t.save(e.path)},{label:m(`app.web.banner.closeTab`),run:n}]}:e.disk===`changed`?{tone:`warning`,text:m(`app.web.banner.changed`,{name:e.name}),actions:[...r&&e.diskText!==null?[{label:m(`app.web.banner.compare`),run:r}]:[],{label:m(`app.web.banner.reload`),run:()=>t.reloadFromDisk(e.path)},{label:m(`app.web.banner.keep`),run:()=>t.keepMine(e.path)}]}:e.saveError?{tone:`error`,text:m(`app.web.banner.saveFailed`,{reason:e.saveError}),actions:[{label:m(`app.common.retry`),run:()=>void t.save(e.path)}]}:null}function DocumentPane({store:e,scripts:n,doc:r,shown:i,focused:a,loaders:s,onClose:u,onCompare:d}){let p=c(()=>handleFor(e,r.path,r.kind,r.name,n.documentScripts(r.path)),[e,n,r.path]),[h,g]=t(0),[_,v]=t(i),y=o(null),b=r.phase===`ready`?bannerFor(r,e,u,d):null;return f(()=>{i&&!_&&v(!0)},[i]),f(()=>{let e=y.current;e&&(e.inert=!i)},[i]),l(`div`,{ref:y,id:domId(`web-pane`,r.path),class:`web-pane`,role:`tabpanel`,"aria-labelledby":domId(`web-tab`,r.path),"data-path":r.path,"data-active":i?`true`:`false`,"data-focused":a?`true`:`false`,"aria-hidden":!i||void 0,children:[b&&l(`div`,{class:`web-pane__banner is-${b.tone}`,role:`alert`,children:[l(`span`,{class:`web-pane__banner-text type-body`,children:b.text}),b.actions.map(e=>l(`button`,{type:`button`,class:`ui-button type-button`,onClick:e.run,children:e.label},e.label))]}),l(`div`,{class:`web-pane__body`,children:[r.phase===`loading`&&l(`p`,{class:`web-pane__status type-help`,role:`status`,children:m(`app.web.pane.opening`,{name:r.name})}),r.phase===`failed`&&l(De,{title:m(`app.web.pane.failed`,{name:r.name}),hint:r.loadError??void 0,actions:[{label:m(`app.common.retry`),run:()=>void e.open(r.path)},{label:m(`app.web.banner.closeTab`),run:u}]}),r.phase===`ready`&&_&&l(be,{onReload:()=>g(e=>e+1),children:l(Cr,{value:i&&a,children:l(LazyEditor,{doc:r,loaders:s,handle:p})})},h)]})]})}function LazyScriptPane(e){let[n,r]=t(null);return f(()=>{let e=!0;return y(()=>import(`./ScriptPane-C9q5wLfO.js`).then(t=>e&&r(()=>t.ScriptPane)),__vite__mapDeps([64,1,2,3,4,6,7,8,9,10,11,13,5,14,15,22,18,23,25,35,24,42,19,58]),import.meta.url),()=>{e=!1}},[]),n?l(n,{...e}):null}var fi=`UTF-8`;function saveStateOf(e){return!e||e.phase!==`ready`?`none`:e.saving?`saving`:e.disk===`changed`?`conflict`:e.disk===`deleted`?`deleted`:e.saveError?`failed`:Ue(e)?`unsaved`:`saved`}function lineEnding(e){let t=(e.match(/\r\n/g)??[]).length;return t>(e.match(/\n/g)??[]).length-t?`CRLF`:`LF`}function saveText(e,t){switch(e){case`saving`:return m(`app.web.state.saving`);case`unsaved`:return t?m(`app.web.state.unsavedAuto`,{seconds:t}):m(`app.web.state.unsaved`);case`failed`:return m(`app.web.state.failed`);case`conflict`:return m(`app.web.state.conflict`);case`deleted`:return m(`app.web.state.deleted`);case`saved`:return m(`app.web.state.saved`);default:return``}}function StatusBar({engine:e,licence:t,connection:n,doc:r,autosave:i,mac:a,onRetry:o,onShortcuts:s,onLicence:c}){let u=saveStateOf(r),d=n===`ok`;return l(`footer`,{class:`web-status`,"aria-label":m(`app.web.status.label`),children:[l(`span`,{class:`web-status__item web-status__connection type-chrome-small${d?``:` is-offline`}`,children:[l(`span`,{class:`web-status__dot`,"aria-hidden":`true`}),l(`span`,{role:`status`,children:m(d?`app.web.status.connected`:n===`denied`?`app.web.status.expired`:`app.web.status.offline`)}),!d&&n===`lost`&&l(`button`,{type:`button`,class:`web-status__link type-link`,onClick:o,children:m(`app.common.retry`)})]}),l(`span`,{class:`web-status__item web-status__item--saved type-chrome-small`,role:`status`,"aria-live":`polite`,"data-state":u,children:saveText(u,i)}),l(`span`,{class:`web-status__spacer`}),e&&l(`span`,{class:`web-status__item web-status__item--engine type-chrome-small`,title:m(`app.web.status.engine`),children:e}),t&&l(`button`,{type:`button`,class:`web-status__item web-status__licence type-chrome-small`,title:m(`app.web.status.licence`),onClick:c,children:t}),r&&r.phase===`ready`&&l(`span`,{class:`web-status__item web-status__item--detail type-chrome-small`,title:m(`app.web.status.encoding`),children:`${fi} · ${lineEnding(r.current)}`}),l(`button`,{type:`button`,class:`web-status__tool`,"aria-label":m(`app.web.shortcuts.open`),title:rt(m(`app.web.shortcuts.open`),`shortcuts`,a),onClick:s,children:l(Icon$1,{name:`keyboard`})})]})}function useSession(e){let[,n]=t(0),r=e.snapshot();return f(()=>{let t=e.subscribe(()=>n(e=>e+1));return e.snapshot()!==r&&n(e=>e+1),t},[e]),r}function ProjectSwitcher({name:e,fallback:t=null}){let n=useProject();return n?l(Switcher,{project:n,name:e}):t}function Switcher({project:e,name:n}){let[r,i]=t(null),[o,s]=t(!1),c=useSession(e.session);f(()=>{o&&e.session.loadRecent().catch(()=>void 0)},[o]);let u=c.project.folder??null,d=(c.recent??[]).filter(e=>e.folder!==u).slice(0,8),close=()=>s(!1);return l(a,{children:[l(`button`,{type:`button`,ref:i,class:`web-switcher type-chrome-title`,"aria-haspopup":`dialog`,"aria-expanded":o,title:u??n,onClick:()=>s(e=>!e),children:[l(`span`,{class:`web-switcher__name`,children:n}),l(Icon$1,{class:`web-switcher__chevron`,name:`chevron`})]}),o&&l(xe,{anchor:r,label:m(`app.web.project.switcher`),onClose:close,width:296,class:`web-switcher__popover`,children:[l(`div`,{class:`web-switcher__current`,children:[l(`span`,{class:`web-switcher__current-name type-body`,children:n}),u&&l(`span`,{class:`web-switcher__current-folder type-help`,children:u})]}),d.length>0&&l(a,{children:[l(`p`,{class:`web-switcher__heading type-section-heading`,children:m(`app.web.project.recent`)}),l(`ul`,{class:`web-switcher__list`,children:d.map(t=>l(`li`,{children:l(`button`,{type:`button`,class:`web-switcher__item type-body`,disabled:!t.present,title:t.present?t.folder:m(`app.web.welcome.missing`,{folder:t.folder}),onClick:()=>{close(),e.switchTo(t.folder)},children:[l(Icon$1,{name:`process`}),l(`span`,{class:`web-switcher__item-name`,children:t.name})]})},t.folder))})]}),l(`div`,{class:`web-switcher__actions`,children:[l(`button`,{type:`button`,class:`web-switcher__item type-body`,onClick:()=>{close(),e.browse()},children:[l(Icon$1,{name:`folder`}),l(`span`,{class:`web-switcher__item-name`,children:m(`app.web.project.openAnother`)})]}),l(`button`,{type:`button`,class:`web-switcher__item type-body`,onClick:()=>{close(),e.closeProject()},children:[l(Icon$1,{name:`close`}),l(`span`,{class:`web-switcher__item-name`,children:m(`app.web.project.close`)})]})]})]})]})}function TitleBar({project:e,file:t,dirty:n,onSettings:r,onSearch:i,searchKeys:a,onToggleSidebar:o,sidebarKeys:s}){return l(`header`,{class:`web-title`,"aria-label":m(`app.web.titleBar.label`),children:[l(`div`,{class:`web-title__brand type-chrome-title`,children:[l(`button`,{type:`button`,class:`web-title__tool`,"aria-label":m(`app.web.sidebar.toggle`),title:s?`${m(`app.web.sidebar.toggle`)} (${s})`:m(`app.web.sidebar.toggle`),onClick:o,children:l(Icon$1,{name:`panel`})}),l(`span`,{class:`web-title__dot`,"aria-hidden":`true`}),l(`span`,{class:`web-title__name`,children:m(`app.name`)})]}),l(`div`,{class:`web-title__centre`,children:[l(ProjectSwitcher,{name:e,fallback:l(`span`,{class:`web-title__project type-chrome-title`,title:e,children:e})}),t&&l(`span`,{class:`web-title__file type-chrome`,title:t,children:[n&&l(`span`,{class:`web-title__unsaved`,"aria-label":m(`app.web.tree.unsaved`)}),t]})]}),l(`div`,{class:`web-title__actions`,children:[l(`button`,{type:`button`,class:`web-title__tool`,"aria-label":m(`app.web.command.quickOpen`),title:a?`${m(`app.web.command.quickOpen`)} (${a})`:m(`app.web.command.quickOpen`),onClick:i,children:l(Icon$1,{name:`search`})}),l(`button`,{type:`button`,class:`web-title__tool`,"aria-label":m(`app.web.settings.title`),title:m(`app.web.settings.title`),onClick:r,children:l(Icon$1,{name:`settings`})})]})]})}function UnsavedDialog({name:e,busy:t,onSave:n,onDiscard:r,onCancel:i}){return l(q,{title:m(`app.web.unsaved.title`,{name:e}),size:`small`,destructive:!0,onClose:i,footer:l(Y,{actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:i,disabled:t},{id:`discard`,label:m(`app.web.unsaved.discard`),role:`secondary`,onClick:r,disabled:t},{id:`save`,label:m(`app.common.save`),role:`primary`,onClick:n,busy:t}]}),children:l(`p`,{class:`type-body`,children:m(`app.web.unsaved.text`,{name:e})})})}var pi={off:S.OFF,bottom:S.BOTTOM,sidebar:S.SIDEBAR};function hostPreferences(){return{aiChat:()=>ie(Z().aiChat),setAiChat:e=>je({aiChat:pi[e]}),subscribe:Me}}function useCloseQueue(e,r){let[i,a]=t([]),[o,s]=t(!1),c=n(t=>{let n=t;for(;n.length>0;){let[t,...i]=n;if(!e.doc(t))n=i;else if(Ue(e.doc(t)))break;else r(t),n=i}a(n)},[e,r]),l=n(e=>c(e),[c]),u=i[0]??null;return{head:u,busy:o,request:l,cancel:()=>a([]),discard:()=>{u!==null&&(r(u),c(i.slice(1)))},save:()=>{u!==null&&(s(!0),e.save(u).then(e=>{s(!1),e?(r(u),c(i.slice(1))):a([])}))}}}function useMedia(e,n=!1){let read=()=>typeof window<`u`&&typeof window.matchMedia==`function`?window.matchMedia(e).matches:n,[r,i]=t(read);return f(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),update=()=>i(t.matches);return update(),t.addEventListener?.(`change`,update),()=>t.removeEventListener?.(`change`,update)},[e]),r}var mi=3e3,hi=3e4;function pollDelay(e,t){return Math.min(e*2**Math.min(t,5),Math.max(e,hi))}function useWindowEvent(e,t,n=!1){let r=o(t);r.current=t,f(()=>{let handler=e=>r.current(e);return window.addEventListener(e,handler,n),()=>window.removeEventListener(e,handler,n)},[e,n])}function usePolling(e,t){f(()=>{let n,r=!1,i=0,visible=()=>document.visibilityState===`visible`,schedule=()=>{!r&&visible()&&(n&&clearTimeout(n),n=setTimeout(tick,pollDelay(t,i)))},tick=async()=>{visible()&&await e.refresh(),i=e.snapshot().connection===`ok`?0:i+1,schedule()},wake=()=>{n&&clearTimeout(n),n=void 0,visible()&&!r&&e.refresh().then(()=>{i=e.snapshot().connection===`ok`?0:i+1,schedule()})};return wake(),document.addEventListener(`visibilitychange`,wake),window.addEventListener(`focus`,wake),()=>{r=!0,n&&clearTimeout(n),document.removeEventListener(`visibilitychange`,wake),window.removeEventListener(`focus`,wake)}},[e,t])}function useStore(e){let[,n]=t(0),r=e.snapshot();return f(()=>{let t=e.subscribe(()=>n(e=>e+1));return e.snapshot()!==r&&n(e=>e+1),t},[e]),r}function suggestsNextBlock(){return Z().suggestNextBlock!==!1}function suggestsFields(){return Z().suggestions!==!1}var gi=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform),_i=!1,vi=new Set;function toggleFocusCanvas(){_i=!_i;for(let e of vi)e(_i)}function useFocusCanvas(){let[e,n]=t(_i);return f(()=>(vi.add(n),n(_i),()=>{vi.delete(n)}),[]),e}function useFocusCanvasShortcut(){let e=o(null),t=useEditorActive();f(()=>{if(!t)return;let onKey=t=>{if(!T(t,`Mod+Alt+Shift+M`,gi))return;t.preventDefault();let n=Date.now();isRepeatOfPress(e.current,n)||(e.current=n,toggleFocusCanvas())};return window.addEventListener(`keydown`,onKey),()=>window.removeEventListener(`keydown`,onKey)},[t])}var yi={newFile:()=>y(()=>import(`./NewFileDialog-DsoFURD9.js`).then(e=>e.NewFileDialog),__vite__mapDeps([65,1,2,3,4,6,7,8,9,10,11,28,14,57]),import.meta.url),quick:()=>y(()=>import(`./QuickOpen-mzlfRqvG.js`).then(e=>e.QuickOpen),__vite__mapDeps([66,1,2,3,4]),import.meta.url),shortcuts:()=>y(()=>import(`./ShortcutsDialog-BXP0h7Tp.js`).then(e=>e.ShortcutsDialog),__vite__mapDeps([67,1,2,3,4,47,6,7,8,9,10,11,15,28,14,29,68,46,31]),import.meta.url),settings:()=>y(()=>import(`./SettingsDialog-Bhwwtyg7.js`).then(e=>e.SettingsDialog),__vite__mapDeps([69,1,2,3,4,28,6,7,8,9,10,11,14]),import.meta.url),agents:()=>y(()=>import(`./AgentsDialog-BqY3wKcV.js`).then(e=>e.AgentsDialog),__vite__mapDeps([70,1,2,3,4,6,7,8,9,10,11,47,15,28,14,29]),import.meta.url),conflict:()=>y(()=>import(`./ConflictDialog-C4A9-Psr.js`).then(e=>e.ConflictDialog),__vite__mapDeps([71,1,2,3,4,28,6,7,8,9,10,11,14]),import.meta.url)};function useLazy(e,n){let[r,i]=t(null);return f(()=>{if(!n||r)return;let t=!0;return yi[e]().then(e=>t&&i({component:e})),()=>{t=!1}},[n]),r?.component??null}var bi=`(width < 900px)`;function groupWidth(e){let t=document.querySelector(`[data-group="${e}"]`)?.getBoundingClientRect().width??0;return t>0?t:void 0}function syncAddress(e){try{let t=new URL(window.location.href);e?t.searchParams.set(`file`,e):t.searchParams.delete(`file`);let n=`${t.pathname}${t.search}${t.hash}`;n!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,n)}catch{}}function engineName(e){if(!e)return null;let t=/^CAMUNDA_(\d+)$/.exec(e);return t?`Camunda ${t[1]}`:e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g,` `)}function WebShell({store:e,scripts:r,loaders:i,engine:a,deepLink:s,toolWindow:u=null,pollMs:d=mi,env:p}){let h=c(()=>({...nn,...p}),[p]),g=useStore(e),_=useStore(r.tabs),v=useMedia(bi),[y,b]=t(!1),[x,S]=t(null),[C,w]=t(null),[T,E]=t(null),[D,O]=t(!1),[k,A]=t(()=>h.sidebar()),[M,N]=t(defaultDock),[P,F]=t(Wt),[I,L]=t([]),[R,z]=t(!1),[B,V]=t(!1),[H,ee]=t(null),[U,te]=t(()=>h.autosave()),[ne,re]=t(()=>h.theme()),[ie,W]=t(null),ae=o(!1),oe=o(new Set),ce=useLazy(`newFile`,y),le=useLazy(`quick`,x!==null||g.listed),ue=useLazy(`shortcuts`,C===`shortcuts`),de=useLazy(`settings`,C===`settings`),pe=useLazy(`agents`,C===`agents`),me=useLazy(`conflict`,T!==null),he=g.order.map(e=>g.docs.get(e)).filter(Boolean),ge=c(()=>new Set(g.order.filter(e=>Ue(g.docs.get(e)))),[g.docs,g.order]),_e=g.listing.root,K=g.active?g.docs.get(g.active)??null:null;usePolling(e,d);let[ye]=t(()=>j().agentsHost?.()??null);f(()=>se(()=>w(`agents`)),[]),f(()=>{e.setAutosave(U)},[e,U]),f(()=>{let e=!0,read=()=>void h.licence().then(t=>e&&W(t));read();let t=onLicenceChange(read);return()=>{e=!1,t()}},[h]),f(()=>{if(ae.current||!g.listed)return;ae.current=!0;let t=h.loadSession(g.listing.root);if(t){let n=restoreSession(e,g.listing,t);n.dock&&N(n.dock),(n.toolOpen.length>0||n.toolShut.length>0)&&F(expansionOf(n.toolOpen,n.toolShut))}let n=s?Fe(s):null;if(n){let t=g.listing.files.find(e=>e.rel===n);e.open(t?.path??Re(g.listing.root,n),t?.kind)}V(!0);let r=h.journal;r&&r.orphans(g.listing.root).then(e=>L(e))},[g.listed]),f(()=>{if(!B)return;let e=oe.current;oe.current=new Set,N(t=>syncDocs(t,g.order,e,groupWidth(t.focus)))},[g.order,B]),f(()=>{let e=g.active;e&&N(t=>activate(t,docPanel(e)))},[g.active,g.order]);let sessionNow=()=>sessionOf(e.snapshot(),{dock:M,tool:P});f(()=>{N(e=>syncScripts(e,_.tabs.map(e=>e.id)))},[_.tabs]),f(()=>{let e=_.focus;e&&N(t=>activate(t,scriptPanel(e)))},[_.focus]);let be=o([]);f(()=>{let e=be.current.filter(e=>!g.order.includes(e));be.current=g.order,e.forEach(e=>void r.closeDocument(e))},[g.order,r]),f(()=>{if(!B||!_e)return;let e=setTimeout(()=>h.saveSession(_e,sessionNow()),h.sessionDelayMs);return()=>clearTimeout(e)},[B,_e,g.order,g.active,g.recent,M,P]),f(()=>{let e=g.active?g.docs.get(g.active):void 0;syncAddress(e?e.rel:null)},[g.active]);let xe=ge.size>0;f(()=>{showTitle(titleFor(g.active?g.docs.get(g.active)?.name??null:null,_e?Le(_e):m(`app.web.tree.project`),xe)),showFavicon(xe)},[g.active,g.docs,_e,xe]),f(()=>(showThemeColour(),window.addEventListener(`bpmn-theme-changed`,showThemeColour),()=>window.removeEventListener(`bpmn-theme-changed`,showThemeColour)),[]),useWindowEvent(`beforeunload`,t=>{e.dirtyPaths().length!==0&&(t.preventDefault(),t.returnValue=``)}),useWindowEvent(`pagehide`,()=>{h.journal?.flush(),B&&_e&&h.saveSession(_e,sessionNow())}),f(()=>{let hidden=()=>{document.visibilityState===`hidden`&&h.journal?.flush()};return document.addEventListener(`visibilitychange`,hidden),()=>document.removeEventListener(`visibilitychange`,hidden)},[h]);let q=useCloseQueue(e,n(t=>e.close(t),[e])),Se=q.head?g.docs.get(q.head):void 0,closeTabs=e=>q.request(e),Ce=n(t=>{N(t);let n=pathOfPanel(focused$1(t)?.active??``);n&&n!==e.snapshot().active&&e.activate(n)},[e]),we=n((t,n=!1)=>{if(n){let e=docPanel(t.path);has(M,e)?N(moveTab(M,e,{group:M.focus,zone:`right`,width:groupWidth(M.focus)})):oe.current.add(t.path)}e.open(t.path,t.kind),v&&O(!1)},[e,v,M]),Te=n(async(t,n)=>{let r=await e.create(t,n);r&&await e.open(r)},[e]),J=n(e=>{A(e),h.setSidebar(e)},[h]),Ee=n(()=>{v?O(e=>!e):J({...k,open:!k.open})},[v,k,J]),Y=useFocusCanvas(),X=n(()=>{let t=e.snapshot().active?e.doc(e.snapshot().active)?.rel??null:null;t&&G()?.focusInput(t)},[e]),De=g.active?g.docs.get(g.active)?.rel??null:null,Oe=n(()=>{let e=focused$1(M),t=e?.active??null;e&&t&&e.tabs.length>1?Ce(moveTab(M,t,{group:e.id,zone:`right`,width:groupWidth(e.id)})):S({initial:``,side:!0})},[M,Ce]),ke=n(()=>{leaves(M.root).length>1?Ce(mergeGroups(M)):Oe()},[M,Ce,Oe]),Z=n(async()=>{let t=e.snapshot().active;t&&!await e.save(t)&&e.doc(t)?.disk===`changed`&&E(t)},[e]),Ae=n(async()=>{await e.saveAll();let t=e.snapshot().order.find(t=>e.doc(t)?.disk===`changed`);t&&E(t)},[e]),Me=n(t=>{let n=focused$1(M);if(!n)return;let r=n.tabs.map(pathOfPanel).filter(e=>e!==null),i=pathOfPanel(n.active??``);if(r.length<2||!i)return;let a=r.indexOf(i);e.activate(r[(a+t+r.length)%r.length])},[e,M]),Ne=n(e=>{v?O(!0):k.open||J({...k,open:!0}),ee(t=>({path:Be(e),serial:(t?.serial??0)+1}))},[v,k,J]),Ie=useEntryActions(Ne),Q=n(t=>{let n=e.snapshot();switch(t){case`quickOpen`:S({initial:``,side:!1});return;case`actions`:h.runEditorAction(`palette`)||S({initial:`>`,side:!1});return;case`save`:Z();return;case`saveAll`:Ae();return;case`closeTab`:n.active&&closeTabs([n.active]);return;case`nextTab`:Me(1);return;case`previousTab`:Me(-1);return;case`toggleSidebar`:Ee();return;case`askAgent`:X();return;case`splitView`:ke();return;case`newFile`:b(!0);return;case`shortcuts`:w(`shortcuts`);return;case`settings`:w(`settings`);return;default:{let n=(focused$1(M)?.tabs??[]).map(pathOfPanel).filter(e=>e!==null),r=et(t,n.length);r!==null&&e.activate(n[r])}}},[e,h,M,Z,Ae,Me,Ee,X,ke]);useWindowEvent(`keydown`,e=>{if(e.isComposing||e.repeat)return;let t=it(e,h.mac);if(t){let n=e.target instanceof Element?e.target:null;if(document.querySelector(`.ui-dialog-overlay, .palette-overlay`)||ve(n)||n?.closest(`.djs-container`))return;runEditCommand(t,{focus:n,textSelected:!1})&&e.preventDefault();return}let n=nt(e,h.mac);n&&(e.preventDefault(),!document.querySelector(`.ui-dialog-overlay, .palette-overlay`)&&Q(n))},!0);let ze=c(()=>[{id:`newFile`,title:m(`app.web.command.newFile`),keys:$(`newFile`,h.mac),run:()=>Q(`newFile`)},{id:`save`,title:m(`app.web.command.save`),keys:$(`save`,h.mac),run:()=>Q(`save`)},{id:`saveAll`,title:m(`app.web.command.saveAll`),keys:$(`saveAll`,h.mac),run:()=>Q(`saveAll`)},{id:`closeTab`,title:m(`app.web.command.closeTab`),keys:$(`closeTab`,h.mac),run:()=>Q(`closeTab`)},{id:`closeAll`,title:m(`app.web.command.closeAll`),run:()=>closeTabs(e.snapshot().order)},{id:`splitView`,title:leaves(M.root).length>1?m(`app.web.command.closeSplit`):m(`app.web.command.splitView`),keys:$(`splitView`,h.mac),run:()=>Q(`splitView`)},{id:`toggleSidebar`,title:m(`app.web.command.toggleSidebar`),keys:$(`toggleSidebar`,h.mac),run:()=>Q(`toggleSidebar`)},...fe()&&De?[{id:`askAgent`,title:m(`app.web.command.askAgent`),keys:$(`askAgent`,h.mac),run:()=>Q(`askAgent`)}]:[],{id:`resetLayout`,title:m(`app.web.command.resetLayout`),run:()=>N(syncDocs(defaultDock(),e.snapshot().order))},{id:`actions`,title:m(`app.web.command.actions`),keys:$(`actions`,h.mac),run:()=>Q(`actions`)},{id:`settings`,title:m(`app.web.command.settings`),run:()=>Q(`settings`)},{id:`agents`,title:m(`app.web.command.agents`),run:()=>w(`agents`)},{id:`shortcuts`,title:m(`app.web.command.shortcuts`),keys:$(`shortcuts`,h.mac),run:()=>Q(`shortcuts`)},{id:`reconnect`,title:m(`app.web.command.reconnect`),run:()=>void e.refresh()}],[h.mac,Q,M,e,De]),Ve=c(()=>new Map([...docTabs(he,h.mac),...scriptTabItems(_.tabs)].map(e=>[e.id,e])),[g.docs,g.order,h.mac,_.tabs]),selectPanel=t=>{let n=pathOfPanel(t),i=scriptIdOf(t);N(e=>activate(e,t)),n&&e.activate(n),i&&r.tabs.focus(i)},closePanelTab=e=>{let t=pathOfPanel(e),n=scriptIdOf(e);t&&closeTabs([t]),n&&r.closed(n)},He=n(t=>{let n=pathOfPanel(t),r=groupOf(M,t),i=r?r.tabs.length>1:!1;if(n===null)return[];let{order:a}=e.snapshot(),o=a.indexOf(n),s=e.doc(n);return[{id:`close`,label:m(`app.web.menu.close`),keys:$(`closeTab`,h.mac),run:()=>closeTabs([n])},{id:`others`,label:m(`app.web.menu.closeOthers`),disabled:a.length<2,run:()=>closeTabs(a.filter(e=>e!==n))},{id:`right`,label:m(`app.web.menu.closeRight`),disabled:o<0||o===a.length-1,run:()=>closeTabs(a.slice(o+1))},{id:`all`,label:m(`app.web.menu.closeAll`),run:()=>closeTabs(a)},{id:`splitRight`,label:m(`app.web.menu.splitRight`),separatorBefore:!0,disabled:!i||!roomToSplit(r?groupWidth(r.id):void 0,`right`),run:()=>r&&Ce(moveTab(M,t,{group:r.id,zone:`right`,width:groupWidth(r.id)}))},{id:`splitDown`,label:m(`app.web.menu.splitDown`),disabled:!i,run:()=>r&&Ce(moveTab(M,t,{group:r.id,zone:`bottom`}))},{id:`reveal`,label:m(`app.web.menu.reveal`),run:()=>Ne(n)},{id:`copyPath`,label:m(`app.web.menu.copyPath`),separatorBefore:!0,run:()=>void h.copy(n).then(e=>h.notify(m(e?`app.web.menu.copied`:`app.web.menu.copyFailed`),!e))},{id:`copyRel`,label:m(`app.web.menu.copyRelative`),run:()=>void h.copy(s?.rel??n).then(e=>h.notify(m(e?`app.web.menu.copied`:`app.web.menu.copyFailed`),!e))}]},[e,h,M,Ce,Ne]),restoreDrafts=async()=>{z(!0);let t=new Map(e.snapshot().listing.files.map(e=>[e.path,e]));for(let n of I){let r=t.get(n.path);r?(await e.open(n.path,r.kind),e.applyDraft(n.path,n)):e.adoptMissing(n.path,n.path.endsWith(`.dmn`)?`dmn`:n.path.endsWith(`.form`)?`form`:`bpmn`,n)}L([]),z(!1)},discardDrafts=async()=>{z(!0),await h.journal?.discard(I),L([]),z(!1)},openPath=t=>{if(!t)return;let n=g.listing.files.find(e=>e.rel===t);e.open(n?.path??Re(g.listing.root,t),n?.kind)};useDesktopCommands({"file.newFile":()=>Q(`newFile`),"file.save":()=>Q(`save`),"file.closeTab":()=>{let t=e.snapshot().active;t?closeTabs([t]):at()?.closeWindow()},"edit.undo":()=>replayEdit(`undo`),"edit.redo":()=>replayEdit(`redo`),"edit.cut":()=>replayEdit(`cut`),"edit.copy":()=>replayEdit(`copy`),"edit.paste":()=>replayEdit(`paste`),"edit.selectAll":()=>replayEdit(`selectAll`),"file.openPath":openPath,"view.toggleTree":()=>Q(`toggleSidebar`),"view.toggleSidebar":()=>{let e=at()?.platform===`darwin`;document.dispatchEvent(new KeyboardEvent(`keydown`,{key:`'`,code:`Quote`,altKey:!0,metaKey:e,ctrlKey:!e,bubbles:!0,cancelable:!0}))},"help.shortcuts":()=>Q(`shortcuts`)});let We=_e?Le(_e):m(`app.web.tree.project`),Ge=T?g.docs.get(T):void 0;f(()=>{T&&g.docs.get(T)?.disk!==`changed`&&E(null)},[T,g.docs]),f(()=>{v||O(!1)},[v]);let Ke=g.recent.map(e=>g.listing.files.find(t=>t.rel===e)).filter(e=>!!e&&!g.docs.has(e.path)).slice(0,6).map(e=>({rel:e.rel,name:e.name})),openRel=e=>{let t=g.listing.files.find(t=>t.rel===e);t&&we(t)},qe=c(()=>new Map(leaves(M.root).map(e=>[e.active,e.id])),[M]),content=t=>{let n=qe.get(t),a=scriptIdOf(t);if(a!==null){let e=_.tabs.find(e=>e.id===a);return e?l(LazyScriptPane,{hub:r,tab:e,shown:!!n,focused:n===M.focus},e.id):null}let o=pathOfPanel(t),s=o?g.docs.get(o):void 0;return s?l(DocumentPane,{store:e,scripts:r,doc:s,shown:!!n,focused:n===M.focus,loaders:i,onClose:()=>closeTabs([s.path]),onCompare:()=>E(s.path)}):null},Je=leaves(M.root).at(-1)?.id??null,header=e=>{let t=e.tabs.map(e=>Ve.get(e)).filter(e=>!!e),n=leaves(M.root).length>1;return l(TabStrip,{tabs:t,active:e.active,onSelect:selectPanel,onClose:closePanelTab,onDropTab:(t,n)=>Ce(moveTab(M,t,{group:e.id,zone:`center`,index:n})),menuFor:He,trailing:e.id===Je&&!v&&he.length>0?l(`button`,{type:`button`,class:`web-tabs__split${n?` is-on`:``}`,"aria-pressed":n,"aria-label":m(n?`app.web.command.closeSplit`:`app.web.command.splitView`),title:rt(m(n?`app.web.command.closeSplit`:`app.web.command.splitView`),`splitView`,h.mac),onClick:ke,children:l(Icon$1,{name:`split`})}):null})},empty=()=>l(Welcome$1,{recent:Ke,onOpen:openRel,onQuickOpen:()=>S({initial:``,side:!1}),onNew:()=>b(!0),quickKeys:$(`quickOpen`,h.mac),empty:g.listed&&g.listing.files.length===0}),label=e=>{let t=pathOfPanel(e);return(t?g.docs.get(t)?.name:null)??``};return l(`div`,{class:`web-app`,children:[l(`a`,{class:`web-skip type-body`,href:`#web-main`,onClick:e=>{e.preventDefault(),document.getElementById(`web-main`)?.focus()},children:m(`app.web.skip`)}),l(TitleBar,{project:We,file:K?.name??null,dirty:!!K&&Ue(K),onSettings:()=>w(`settings`),onSearch:()=>Q(`quickOpen`),searchKeys:$(`quickOpen`,h.mac)??``,onToggleSidebar:Ee,sidebarKeys:$(`toggleSidebar`,h.mac)??``}),l(`div`,{class:`web-shell${v?` is-narrow`:``}`,children:[!Y&&(v?D:k.open)&&l(ShellSidebar,{width:k.width,onWidth:e=>J({...k,width:e}),drawer:v,onClose:()=>O(!1),runAction:h.runEditorAction,focusedEditor:De,openFile:openPath,children:u&&l(ToolPanel,{store:u,expansion:P,onExpansion:F,onUnlock:h.showLicence,mac:h.mac,entries:Ie,activePath:K&&!Pe(K.kind)?Be(K.path):null,reveal:H,newKeys:$(`newFile`,h.mac)})}),l(`main`,{id:`web-main`,class:`web-workspace`,tabIndex:-1,"aria-label":m(`app.web.main.label`),children:[g.connection===`lost`&&l(`div`,{class:`web-shell__connection`,role:`alert`,children:[l(Icon$1,{name:`alert`}),l(`span`,{class:`web-shell__connection-text type-body`,children:m(`app.web.connection.lost`)}),l(`button`,{type:`button`,class:`ui-button type-button`,onClick:()=>void e.refresh(),children:m(`app.common.retry`)})]}),I.length>0&&l(DraftNotice,{count:I.length,busy:R,onRestore:()=>void restoreDrafts(),onDiscard:()=>void discardDrafts()}),l(DockView,{dock:M,onDock:Ce,header,content,empty,label,single:v})]})]}),l(StatusBar,{engine:engineName(a),licence:ie,connection:g.connection,doc:K,autosave:U,mac:h.mac,onRetry:()=>void e.refresh(),onShortcuts:()=>w(`shortcuts`),onLicence:h.showLicence}),y&&ce&&l(ce,{files:g.listing.files,engine:a,onCreate:Te,onClose:()=>b(!1)}),x&&le&&l(le,{files:g.listing.files,recent:g.recent,open:new Set(g.order),commands:ze,initial:x.initial,side:x.side,onClose:()=>S(null),onPick:(e,t)=>{S(null),we(e,t)},onRun:e=>{S(null),setTimeout(e.run,0)}}),C===`shortcuts`&&ue&&l(ue,{mac:h.mac,onClose:()=>w(null)}),C===`settings`&&de&&l(de,{theme:ne,autosave:U,onAgents:()=>w(`agents`),onTheme:e=>{re(e),h.setTheme(e)},onAutosave:e=>{te(e),h.setAutosave(e)},suggestNextBlock:suggestsNextBlock(),onSuggestNextBlock:e=>je({suggestNextBlock:e}),suggestions:suggestsFields(),onSuggestions:e=>je({suggestions:e}),onClose:()=>w(null)}),C===`agents`&&pe&&ye&&l(pe,{host:ye,preferences:hostPreferences(),onClose:()=>w(null)}),Ge&&Ge.diskText!==null&&me&&!y&&!Se&&C===null&&l(me,{name:Ge.name,mine:Ge.current,theirs:Ge.diskText,onClose:()=>E(null),onTakeTheirs:()=>{e.reloadFromDisk(Ge.path),E(null)},onKeepMine:()=>{e.keepMine(Ge.path),E(null)}}),Se&&l(UnsavedDialog,{name:Se.name,busy:q.busy,onCancel:q.cancel,onDiscard:q.discard,onSave:q.save}),g.connection===`denied`&&l(SessionEnded,{onRetry:()=>void e.refresh()})]})}async function answered(e){try{return await e}catch(e){throw Error(await K(e))}}function webHost(e){return{current:()=>answered(e.getCurrentProject()),open:t=>answered(e.openProject({openProjectRequest:{folder:t}})),close:()=>answered(e.closeProject()),recent:async()=>(await answered(e.listRecentProjects())).projects,forget:async t=>(await answered(e.forgetRecentProject({openProjectRequest:{folder:t}}))).projects,folders:(t,n)=>answered(e.listFolders({folderListRequest:{path:t??null,hidden:n}})),createFolder:t=>answered(e.createFolder({createFolderRequest:{path:t}})),rename:async(t,n,r)=>(await answered(e.renameEntry({renameEntryRequest:{path:t,name:n,stamp:r}}))).path,move:async(t,n,r)=>(await answered(e.moveEntry({moveEntryRequest:{path:t,folder:n,stamp:r}}))).path,duplicate:async t=>(await answered(e.duplicateEntry({duplicateEntryRequest:{path:t}}))).path,archiveUrl:async t=>{let n=await e.downloadProjectArchiveRequestOpts({expect:t??void 0}),r=new URLSearchParams;return Object.entries(n.query??{}).forEach(([e,t])=>r.set(e,t)),`${n.path}${r.size>0?`?${r}`:``}`},remove:(t,n)=>answered(e.deleteEntry({deleteEntryRequest:{path:t,stamp:n}}))}}function scriptOf(e){let{path:t,slot:n,language:r,script:i,title:a}=e;return!t||!n||r===void 0||i===void 0||a===void 0?null:{path:t,slot:n,language:r,text:i,title:a,variables:e.variables??[]}}var xi={phase:`loading`,revision:null,roots:[],toolbar:[],codeLinks:`open`,truncated:!1,error:null,busy:null};function statusOf(e){return e?.response?.status??null}var ToolWindowStore=class{state=xi;listeners=new Set;api;effects;pollMs;attached=0;timer;flight=null;again=!1;failures=0;controller=null;constructor(e,t,n=mi){this.api=e,this.effects=t,this.pollMs=n}snapshot(){return this.state}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}set(e){this.state={...this.state,...e},[...this.listeners].forEach(e=>e())}attach(){this.attached+=1,this.attached===1&&(document.addEventListener(`visibilitychange`,this.wake),window.addEventListener(`focus`,this.wake),this.refresh().then(()=>this.schedule()));let e=!1;return()=>{e||(e=!0,--this.attached,!(this.attached>0)&&(document.removeEventListener(`visibilitychange`,this.wake),window.removeEventListener(`focus`,this.wake),this.timer&&clearTimeout(this.timer),this.timer=void 0,this.controller?.abort()))}}wake=()=>{this.attached!==0&&document.visibilityState===`visible`&&(this.timer&&clearTimeout(this.timer),this.timer=void 0,this.refresh().then(()=>this.schedule()))};schedule(){this.attached!==0&&document.visibilityState===`visible`&&(this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.refresh().then(()=>this.schedule())},pollDelay(this.pollMs,this.failures)))}refresh(){if(this.flight)return this.again=!0,this.flight;let e=this.load().finally(()=>{this.flight=null,this.again&&this.attached>0&&(this.again=!1,this.refresh()),this.again=!1});return this.flight=e,e}async load(){let e=new AbortController;this.controller=e;try{let t=await this.api.snapshot(this.state.revision,e.signal);if(this.failures=0,t.unchanged&&this.state.revision===t.revision){(this.state.phase!==`ready`||this.state.error)&&this.set({phase:`ready`,error:null});return}this.set({phase:`ready`,revision:t.revision,roots:t.roots??[],toolbar:t.toolbar??[],codeLinks:t.codeLinks===`locked`?`locked`:`open`,truncated:t.truncated===!0,error:null})}catch(t){if(e.signal.aborted)return;if(this.failures+=1,this.state.revision!==null&&statusOf(t)===null){this.state.error!==null&&this.set({error:null});return}this.set({phase:this.state.revision===null?`error`:`ready`,error:await K(t)})}finally{this.controller===e&&(this.controller=null)}}async run(e){let t=this.state.revision;if(t!==null&&this.state.busy===null){this.set({busy:e});try{let n;try{n=await this.api.perform(e,t)}catch(e){statusOf(e)===409?(await this.refresh(),this.effects.notify(m(`app.web.toolPanel.stale`),!0)):this.effects.notify(await K(e),!0);return}await this.carry(n)}finally{this.set({busy:null})}}}async carry(e){let t=this.effects;try{switch(e.kind){case`reveal`:e.path&&await t.reveal(e.path,e.elementId);return;case`openCode`:case`findUsages`:{let n=e.title??``,r=e.places??[];r.length===0?t.notify(m(`app.webHost.places.none`,{name:n}),!0):await t.openPlaces(n,r);return}case`openScript`:{let n=scriptOf(e);n&&await t.openScript(n);return}case`copy`:await t.copy(e.text??``)?t.notify(m(`app.web.toolPanel.copied`)):t.notify(m(`app.web.tree.copyFailed`),!0);return;case`preference`:case`refresh`:await this.refresh();return;case`deploy`:await t.deploy(e.paths??[],e.profile,e.confirm===!0),await this.refresh();return;case`createExample`:e.example&&await t.createExample(e.example),await this.refresh();return;case`unlockCode`:t.unlock();return;case`notify`:t.notify(e.text??``,e.error===!0);return;case`unsupported`:t.notify(e.reason??m(`app.web.toolPanel.unsupported`),!1);return}}catch(e){t.notify(await K(e),!0)}}};function baseName(e){return e.split(/[\\/]/).pop()??e}function label(e){return e.profile??`default`}async function deployPaths(e,t,n,r){let i=n??m(`app.deploy.profileInForce`);if(r&&!await e.confirmWithUser({title:m(`app.deploy.title`),text:m(`app.deploy.confirm`,{what:t.length===1?baseName(t[0]):m(`app.deploy.files`,{count:t.length}),where:i}),accept:m(`app.deploy.title`),decline:m(`app.common.cancel`)}))return;let a=new Map;for(let r of t){let t=await e.targets(r),i=n===void 0?t.active??null:n,o=t.targets.find(e=>(e.profile??null)===i);if(!o?.ready){await e.notifyUser(m(`app.deploy.notReady`,{name:baseName(r),target:label({profile:i})}),!0);continue}let s=JSON.stringify([o.profile,o.engine,o.url,o.deployment]),c=a.get(s)??{target:o,paths:[]};c.paths.push(r),a.set(s,c)}for(let{target:t,paths:n}of a.values()){let r=await Promise.all(n.map(async t=>({path:t,content:await e.readFile(t)}))),i=(await e.projectFiles()).map(t=>({path:t,read:()=>e.readFile(t)})),a=(await k(r,i)).map(e=>({name:e.name,content:e.content})),o=await e.deploy(t,a,n[0]),s=o.status===401||o.status===403;await e.notifyUser(o.ok?m(`app.deploy.succeededOn`,{message:o.message,target:t.url??label(t)}):s?m(`app.deploy.signInHint`,{message:o.message}):o.message,!o.ok)}}async function createExample(e,t,n){if(!await e.confirmWithUser({title:m(`app.project.startFromAnExample`),text:m(`app.project.writeTheOrderExampleInto`,{example:P(n),root:t}),accept:m(`app.runs.create`),decline:m(`app.common.cancel`)}))return!1;let r=[];for(let[i,a]of Object.entries(O(n)))(i!==`.gitignore`||await e.readFileIfPresent(`${t}/${i}`)===null)&&r.push({path:i,content:a});try{await e.createProjectFiles(t,r)}catch(t){return await e.notifyUser(m(`app.project.theExampleWasNotWritten`,{failure:t instanceof Error?t.message:String(t)}),!0),!1}return await e.notifyUser(m(`app.project.theExampleIsInIts`,{example:P(n),root:t})),!0}function targetLabel(e){return e?.profile??`default`}async function deployWithHost(e,t,n,r){try{let i=j(),a=e?.profile??null;if(!e||!N(String(e.engine))||!e.deployment)return{ok:!1,status:0,message:m(`app.project.chooseCamunda7Camunda8`),definitions:[],lines:[]};let o=Array.isArray(t)?t:[],s=await te({...e.deployment,engine:e.engine},o,{ask:e=>i.askEngine(a,e,n),hook:(e,t)=>i.runHook(e,t,a,n,r),watch:r});if(s.ok)try{await i.recordDeployment(a,o.map(e=>e.name))}catch{}return s}catch(e){return{ok:!1,status:0,message:e instanceof Error?e.message:String(e),definitions:[],lines:[]}}}function toolEnvironment(e,t){return{notify:e.notify,copy:e.copy,showLicence:e.showLicence,files:()=>t.snapshot().listing.files,refreshProject:()=>t.refresh()}}function toolApi(e){return{snapshot:(t,n)=>e.web.getToolWindow({revision:t??void 0},n?{signal:n}:void 0),perform:(t,n)=>e.web.performToolWindowAction({toolWindowPerformRequest:{id:t,revision:n}})}}function toolEffects(e,t){return{reveal:(t,n)=>e.revealElement(t,n),openPlaces:(t,n)=>e.openPlaces(t,n),openScript:t=>e.openScriptFile(t.language,t.text,t.slot,t.title,t.variables,t.path),copy:t.copy,notify:t.notify,unlock:t.showLicence,deploy:async(n,r,i)=>{await deployPaths({confirmWithUser:t=>e.confirmWithUser(t),targets:async t=>e.getDeployTargets(t),notifyUser:async(e,n)=>t.notify(e,n),readFile:t=>e.readFile(t),projectFiles:async()=>t.files().filter(e=>e.kind===`bpmn`||e.kind===`dmn`||e.kind===`form`).map(e=>e.path),deploy:(e,t,n)=>deployWithHost(e,t,n)},n,r,i),await t.refreshProject()},createExample:async n=>{D(n)&&await createExample({readFileIfPresent:t=>e.readFileIfPresent(t),confirmWithUser:t=>e.confirmWithUser(t),notifyUser:async(e,n)=>t.notify(e,n),createProjectFiles:(t,n)=>e.createProjectFiles(t,n)},e.projectRoot(),n)&&await t.refreshProject()}}}var ProjectSession=class{host;identity;reload;listeners=new Set;state;timer=null;running=null;pollMs;constructor(e,t,n={}){this.host=e,this.identity={id:t.id??null,folder:t.folder??null},this.reload=n.reload??(()=>window.location.assign(window.location.pathname)),this.pollMs=n.pollMs??4e3,this.state={project:t,recent:null,gone:t.open&&!t.available,away:!1,moving:!1}}get id(){return this.identity.id}snapshot(){return this.state}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}commit(e){this.state={...this.state,...e},[...this.listeners].forEach(e=>{try{e()}catch(e){console.error(`A session listener failed:`,e)}})}start(){let schedule=()=>{this.timer=setTimeout(()=>{this.check().finally(()=>{this.timer!==null&&schedule()})},this.pollMs)};return schedule(),()=>{this.timer!==null&&clearTimeout(this.timer),this.timer=null}}check(){if(this.running)return this.running;let e=(async()=>{let e;try{e=await this.host.current()}catch{return}if(this.state.moving)return;let t=(e.id??null)!==this.id,n=!t&&e.open&&!e.available;(t!==this.state.away||n!==this.state.gone)&&this.commit({away:t,gone:n})})();return this.running=e.finally(()=>{this.running=null}),this.running}async adopt(){let e;try{e=await this.host.current()}catch{return}let t=e.id??null;e.open&&t!==null&&e.folder===this.identity.folder&&(this.identity={...this.identity,id:t}),await this.check()}noticeProjectId(e){e!==null&&this.id!==null&&e!==this.id&&!this.state.away&&!this.state.moving&&this.check()}async loadRecent(){let e=await this.host.recent();return this.commit({recent:e}),e}async forget(e){this.commit({recent:await this.host.forget(e)})}async open(e){this.commit({moving:!0});try{await this.host.open(e)}catch(e){throw this.commit({moving:!1}),e}this.reload()}async close(){this.commit({moving:!0});try{await this.host.close()}catch(e){throw this.commit({moving:!1}),e}this.reload()}reloadPage(){this.reload()}};function pageTitle({app:e,project:t,file:n,dirty:r}){let i=[];return n&&i.push(`${r?`● `:``}${n}`),t&&i.push(t),i.push(e),i.join(` - `)}function breadcrumbs(e,t){let n=[],r=t===`\\`,i=e.split(t).filter(e=>e!==``),a=``;r&&/^[A-Za-z]:$/.test(i[0]??``)?(a=`${i[0]}\\`,n.push({label:`${i[0]}\\`,path:a}),i.shift()):r||(a=`/`,n.push({label:`/`,path:`/`}));for(let e of i)a=a===``||a.endsWith(t)?`${a}${e}`:`${a}${t}${e}`,n.push({label:e,path:a});return n}function visibleEntries(e,t){return t?[...e]:e.filter(e=>!e.hidden)}function joinFolder(e,t,n){return e.endsWith(n)?`${e}${t}`:`${e}${n}${t}`}var Si=8,Ci=320;function folderWindow(e,t,n){return{start:Math.max(0,Math.floor(e/28)-Si),end:Math.min(n,Math.ceil((e+t)/28)+Si)}}function FolderBrowser({folders:e,recent:r,start:i,onChoose:a,onClose:s}){let[c,d]=t(null),[p,h]=t(!0),[g,_]=t(null),[v,y]=t(!1),[b,x]=t(i??``),[S,C]=t(null),[w,T]=t(!1),[E,D]=t(null),[O,k]=t(0),[A,j]=t(Ci),M=o(null),N=o(0),P=o(`web-folders-${Math.random().toString(36).slice(2,8)}`),F=n(async(t,n)=>{N.current+=1;let r=N.current;h(!0);try{let i=await e(t,n);if(r!==N.current)return;d(i),x(i.path),C(null),_(null),k(0),M.current&&(M.current.scrollTop=0)}catch(e){if(r!==N.current)return;_(e instanceof Error&&e.message?e.message:m(`app.web.unknownFailure`))}finally{r===N.current&&h(!1)}},[e]);f(()=>{F(i,!1)},[]),u(()=>{let e=M.current;if(!e)return;let measure=()=>j(e.clientHeight||Ci);if(measure(),typeof ResizeObserver>`u`)return;let t=new ResizeObserver(measure);return t.observe(e),()=>t.disconnect()},[]);let I=c?visibleEntries(c.entries,v):[],L=c?.separator??`/`,R=S===null?-1:I.findIndex(e=>e.name===S),z=c?S!==null&&R>=0?joinFolder(c.path,S,L):c.path:null,scrollTo=e=>{let t=M.current;if(!t||e<0)return;let n=e*28,r=t.clientHeight||Ci;n<t.scrollTop?t.scrollTop=n:n+28>t.scrollTop+r&&(t.scrollTop=n+28-r),k(t.scrollTop)},descend=e=>{c&&F(joinFolder(c.path,e,L),v)},choose=async()=>{if(!(!z||w||p)){if(c&&b.trim()!==c.path)F(b,v);else{T(!0),D(null);try{await a(z)}catch(e){D(e instanceof Error&&e.message?e.message:m(`app.web.unknownFailure`)),T(!1)}}}},onListKey=e=>{if(e.altKey||e.ctrlKey||e.metaKey)return;let t=Math.max(1,Math.floor((M.current?.clientHeight||Ci)/28)-1),n=null;e.key===`ArrowDown`?n=Math.min(I.length-1,R+1):e.key===`ArrowUp`?n=Math.max(0,R<0?0:R-1):e.key===`Home`?n=0:e.key===`End`?n=I.length-1:e.key===`PageDown`?n=Math.min(I.length-1,R+t):e.key===`PageUp`&&(n=Math.max(0,R-t)),n===null?(e.key===`Enter`||e.key===`ArrowRight`)&&R>=0?(e.preventDefault(),e.stopPropagation(),descend(I[R].name)):(e.key===`Backspace`||e.key===`ArrowLeft`)&&c?.parent&&(e.preventDefault(),F(c.parent,v)):(e.preventDefault(),I[n]&&(C(I[n].name),scrollTo(n)))},{start:B,end:V}=folderWindow(O,A,I.length),H=[];c&&(H.push({id:`home`,label:m(`app.web.folders.home`),path:c.home}),c.roots.forEach(e=>H.push({id:`root:${e}`,label:e===`/`?m(`app.web.folders.computer`):e,path:e})));let ee=r.filter(e=>e.present).slice(0,6),U=c?breadcrumbs(c.path,L):[];return l(q,{title:m(`app.web.folders.title`),size:`large`,body:`split`,onClose:s,onSubmit:()=>void choose(),footer:l(Y,{help:z?m(`app.web.folders.willOpen`,{folder:z}):void 0,actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:s,disabled:w},{id:`open`,label:m(`app.web.folders.open`),role:`primary`,onClick:()=>void choose(),busy:w,disabled:!z}]}),children:[l(`nav`,{class:`web-folders__places`,"aria-label":m(`app.web.folders.places`),children:[l(`p`,{class:`web-folders__heading type-section-heading`,children:m(`app.web.folders.places`)}),H.map(e=>l(`button`,{type:`button`,class:`web-folders__place type-body`,title:e.path,onClick:()=>void F(e.path,v),children:[l(Icon$1,{name:`folder`}),l(`span`,{class:`web-folders__place-name`,children:e.label})]},e.id)),ee.length>0&&l(`p`,{class:`web-folders__heading type-section-heading`,children:m(`app.web.folders.recent`)}),ee.map(e=>l(`button`,{type:`button`,class:`web-folders__place type-body`,title:e.folder,onClick:()=>void F(e.folder,v),children:[l(Icon$1,{name:`process`}),l(`span`,{class:`web-folders__place-name`,children:e.name})]},e.folder))]}),l(`div`,{class:`web-folders__main`,children:[l(we,{label:m(`app.web.folders.path`),layout:`top`,error:g,children:e=>l(`input`,{...e,value:b,spellcheck:!1,autocomplete:`off`,onInput:e=>x(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),F(b,v))},onBlur:()=>{c&&b.trim()!==``&&b!==c.path&&!p&&F(b,v)}})}),c&&l(`ol`,{class:`web-folders__crumbs type-help`,"aria-label":m(`app.web.folders.location`),children:U.map((e,t)=>l(`li`,{class:`web-folders__crumb`,children:l(`button`,{type:`button`,class:`web-folders__crumb-button`,"aria-current":t===U.length-1?`location`:void 0,onClick:()=>void F(e.path,v),children:e.label})},e.path))}),l(`div`,{class:`web-folders__bar`,children:[l(`label`,{class:`web-folders__toggle type-body`,children:[l(`input`,{type:`checkbox`,checked:v,onChange:e=>{let t=e.target.checked;y(t),c&&F(c.path,t)}}),l(`span`,{children:c&&c.hiddenCount>0?m(`app.web.folders.showHiddenCount`,{count:c.hiddenCount}):m(`app.web.folders.showHidden`)})]}),c?.project&&l(`span`,{class:`web-folders__hint type-help`,role:`status`,children:c.project.config?m(`app.web.folders.hereConfig`):m(`app.web.folders.hereDiagrams`,{count:c.project.diagrams})})]}),l(`div`,{ref:M,id:P.current,class:`web-folders__list`,role:`listbox`,tabIndex:0,"aria-label":m(`app.web.folders.list`),"aria-busy":p||void 0,"aria-activedescendant":R>=0?`${P.current}-${R}`:void 0,onKeyDown:onListKey,onScroll:e=>k(e.currentTarget.scrollTop),children:[l(`div`,{class:`web-folders__canvas`,style:{height:`${I.length*28}px`},children:I.slice(B,V).map((e,t)=>{let n=B+t;return l(`div`,{id:`${P.current}-${n}`,role:`option`,"aria-selected":n===R,class:`web-folders__row type-body${n===R?` is-selected`:``}`,style:{top:`${n*28}px`},title:e.link?m(`app.web.folders.link`,{name:e.name}):e.name,onClick:()=>{M.current?.focus({preventScroll:!0}),C(e.name)},onDblClick:()=>descend(e.name),children:[l(Icon$1,{class:`web-folders__icon`,name:`folder`}),l(`span`,{class:`web-folders__name`,children:e.name}),e.link&&l(`span`,{class:`web-folders__tag type-help`,children:m(`app.web.folders.linkTag`)}),e.project&&l(`span`,{class:`web-folders__tag is-project type-help`,children:m(`app.web.folders.projectTag`)})]},e.name)})}),c&&I.length===0&&!p&&l(`p`,{class:`web-folders__empty type-help`,children:m(`app.web.folders.noFolders`)})]}),c?.truncated&&l(`p`,{class:`web-folders__note type-help`,children:m(`app.web.folders.truncated`,{shown:c.entries.length,total:c.total})}),E&&l(ke,{children:E})]})]})}var wi=`.bpmn,.dmn,.form,.xml`;function acceptedUpload(e){let t=Ve(e);return t===`bpmn`||t===`dmn`||t===`form`}function messageFrom(e){return e instanceof Error&&e.message?e.message:m(`app.web.unknownFailure`)}function carriesFiles(e){return Array.from(e.dataTransfer?.types??[]).includes(`Files`)}function ProjectFrame({session:e,store:r,entries:i,readText:a,engine:s,toolWindow:u=null,children:d}){let p=useSession(e),h=useStore(r),[g,_]=t(!1),[v,b]=t(null),[x,S]=t(!1),[C,w]=t(null),[T,E]=t(null),[D,O]=t(!1),[k,A]=t(null),[j,M]=t(null),[N,P]=t(null),F=o(null),I=o(0),L=p.project.name??m(`app.web.tree.project`),R=h.active?h.docs.get(h.active):void 0,z=!!R&&R.phase===`ready`&&R.current!==R.baseline;f(()=>{document.title=pageTitle({app:m(`app.web.pageTitle`),project:p.project.open?L:null,file:R?R.rel:null,dirty:z})},[L,R?.rel,z,p.project.open]),f(()=>e.start(),[e]),useDesktopCommands({"project.refresh":()=>void e.adopt().then(()=>Promise.all([r.refresh(),u?.refresh()]))}),f(()=>{if(!T||k)return;let e=!0;return y(()=>import(`./UploadDialog-Dinga4TP.js`).then(t=>e&&A({component:t.UploadDialog})),__vite__mapDeps([72,1,2,3,4,28,6,7,8,9,10,11,14,57]),import.meta.url),()=>{e=!1}},[T]),f(()=>{if(j===null||N)return;let e=!0;return y(()=>import(`./NewFileDialog-DsoFURD9.js`).then(t=>e&&P({component:t.NewFileDialog})),__vite__mapDeps([65,1,2,3,4,6,7,8,9,10,11,28,14,57]),import.meta.url),()=>{e=!1}},[j]);let B=n(async t=>{for(let e of[...r.snapshot().order])r.close(e);try{t.kind===`open`?await e.open(t.folder):await e.close()}catch(e){H.error(messageFrom(e)),S(!1),b(null)}},[e,r]),V=n(e=>{r.dirtyPaths().length===0?B(e):(w(null),b(e))},[r,B]),ee=n(e=>{let t=e.filter(e=>acceptedUpload(e.name));t.length<e.length&&H.error(m(`app.web.upload.ignored`)),t.length>0&&E(t)},[]);f(()=>{let over=e=>{carriesFiles(e)&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`))},enter=e=>{carriesFiles(e)&&(I.current+=1,O(!0))},exit=e=>{carriesFiles(e)&&(I.current=Math.max(0,I.current-1),I.current===0&&O(!1))},drop=e=>{carriesFiles(e)&&(e.preventDefault(),I.current=0,O(!1),ee(Array.from(e.dataTransfer?.files??[])))};return window.addEventListener(`dragover`,over),window.addEventListener(`dragenter`,enter),window.addEventListener(`dragleave`,exit),window.addEventListener(`drop`,drop),()=>{window.removeEventListener(`dragover`,over),window.removeEventListener(`dragenter`,enter),window.removeEventListener(`dragleave`,exit),window.removeEventListener(`drop`,drop)}},[ee]);let U=c(()=>({session:e,store:r,entries:i,engine:s,browse:()=>_(!0),switchTo:e=>V({kind:`open`,folder:e}),closeProject:()=>V({kind:`close`}),upload:()=>F.current?.click(),newFile:e=>M(e),downloadFile:e=>{let t=r.doc(e.path);(t&&t.phase===`ready`?Promise.resolve(t.current):a(e.path)).then(t=>download(e.name,new Blob([t],{type:`application/octet-stream`})),e=>H.error(messageFrom(e)))},downloadArchive:()=>{i.archiveUrl(e.id).then(e=>{let t=document.createElement(`a`);t.href=e,t.rel=`noopener`,t.download=``,document.body.appendChild(t),t.click(),t.remove()},e=>H.error(messageFrom(e)))}}),[e,r,i,s,V,a]),te=r.dirtyPaths().length,addFiles=async e=>{for(let t of e)await r.create(t.rel,t.content);await r.refresh();let t=r.snapshot().listing.files.find(t=>t.rel===e[0]?.rel);t&&await r.open(t.path,t.kind)};return l(li.Provider,{value:U,children:[d,l(`input`,{ref:F,class:`web-projects__picker`,type:`file`,multiple:!0,accept:wi,tabIndex:-1,"aria-hidden":`true`,onChange:e=>{let t=e.target;ee(Array.from(t.files??[])),t.value=``}}),p.gone&&!p.away&&l(`div`,{class:`web-projects__gone`,role:`alert`,children:[l(Icon$1,{name:`alert`}),l(`span`,{class:`web-projects__gone-text type-body`,children:m(`app.web.project.gone`,{name:L})}),l(`button`,{type:`button`,class:`ui-button type-button`,onClick:()=>_(!0),children:m(`app.web.project.openAnother`)}),l(`button`,{type:`button`,class:`ui-button type-button`,onClick:()=>V({kind:`close`}),children:m(`app.web.project.close`)})]}),D&&l(`div`,{class:`web-projects__drop`,"aria-hidden":`true`,children:l(`p`,{class:`web-projects__drop-text type-body`,children:m(`app.web.upload.drop`)})}),g&&l(FolderBrowser,{folders:e.host.folders,recent:p.recent??[],onChoose:async e=>{e===p.project.folder?_(!1):(_(!1),V({kind:`open`,folder:e}))},onClose:()=>_(!1)}),v&&l(q,{title:v.kind===`open`?m(`app.web.project.unsavedOpenTitle`):m(`app.web.project.unsavedCloseTitle`),size:`small`,destructive:!0,onClose:()=>!x&&b(null),footer:l(Y,{actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:()=>b(null),disabled:x},{id:`discard`,label:m(`app.web.unsaved.discard`),role:`secondary`,onClick:()=>void B(v),disabled:x},{id:`save`,label:m(`app.web.project.saveAll`),role:`primary`,busy:x,onClick:()=>{S(!0),w(null),r.saveAll().then(e=>{e?B(v):(S(!1),w(m(`app.web.project.saveAllFailed`)))})}}]}),children:[l(`p`,{class:`web-dialog-text type-body`,children:m(`app.web.project.unsavedText`,{count:te})}),C&&l(`p`,{class:`web-dialog-text type-error-message`,role:`alert`,children:C})]}),T&&k&&l(k.component,{files:T,existing:h.listing.files,folders:h.listing.folders,onUpload:addFiles,onClose:()=>E(null)}),j!==null&&N&&l(N.component,{files:h.listing.files,engine:s,initialFolder:j,onCreate:(e,t)=>addFiles([{rel:e,content:t}]),onClose:()=>M(null)}),p.away&&l(q,{title:m(`app.web.project.awayTitle`),size:`small`,backdrop:`keep`,onClose:()=>e.reloadPage(),footer:l(Y,{actions:[{id:`reload`,label:m(`app.common.reload`),role:`primary`,onClick:()=>e.reloadPage()}]}),children:l(`p`,{class:`web-dialog-text type-body`,children:m(`app.web.project.awayText`)})})]})}function Welcome({session:e}){let n=useSession(e),[r,i]=t(!1),[a,o]=t(null),[s,c]=t(null),[u,d]=t(!1);f(()=>{e.loadRecent().catch(()=>d(!0))},[e]);let openFolder=async t=>{o(null),c(t);try{await e.open(t)}catch(e){throw o(e instanceof Error&&e.message?e.message:m(`app.web.unknownFailure`)),c(null),e}},p=n.recent??[];return l(`main`,{class:`web-start`,children:[l(`section`,{class:`web-start__card`,"aria-labelledby":`web-start-title`,children:[l(`h1`,{id:`web-start-title`,class:`web-start__title type-dialog-title`,children:m(`app.web.welcome.title`)}),l(`p`,{class:`web-start__text type-body`,children:m(`app.web.welcome.text`)}),l(`div`,{class:`web-start__actions`,children:l(`button`,{type:`button`,class:`ui-button ui-button--primary type-button`,onClick:()=>i(!0),disabled:s!==null,children:m(`app.web.welcome.open`)})}),l(`h2`,{class:`web-start__heading type-section-heading`,children:m(`app.web.welcome.recent`)}),n.recent!==null&&p.length===0&&l(`p`,{class:`web-start__none type-help`,children:m(`app.web.welcome.noRecent`)}),u&&l(`p`,{class:`web-start__none type-help`,children:m(`app.web.welcome.recentFailed`)}),p.length>0&&l(`ul`,{class:`web-start__recent`,"aria-label":m(`app.web.welcome.recent`),children:p.map(t=>l(`li`,{class:`web-start__item`,children:[l(`button`,{type:`button`,class:`web-start__project type-body`,disabled:!t.present||s!==null,title:t.present?t.folder:m(`app.web.welcome.missing`,{folder:t.folder}),onClick:()=>void openFolder(t.folder).catch(()=>void 0),children:[l(Icon$1,{name:`process`}),l(`span`,{class:`web-start__name`,children:t.name}),l(`span`,{class:`web-start__folder type-help`,children:t.present?t.folder:m(`app.web.welcome.notFound`)})]}),l(`button`,{type:`button`,class:`web-start__forget`,"aria-label":m(`app.web.welcome.forget`,{name:t.name}),title:m(`app.web.welcome.forget`,{name:t.name}),disabled:s!==null,onClick:()=>void e.forget(t.folder).catch(()=>void 0),children:l(Icon$1,{name:`close`})})]},t.folder))}),a&&!r&&l(`div`,{role:`alert`,children:l(ke,{children:a})}),l(`p`,{class:`web-start__hint type-help`,children:m(`app.web.welcome.hint`)})]}),r&&l(FolderBrowser,{folders:e.host.folders,recent:p,onChoose:openFolder,onClose:()=>i(!1)})]})}var Ti=null,Ei=null;function setSuggestionProvider(e){Ti=e}function setProjectSuggestionProvider(e){Ei=e}function currentSuggestionProvider(){return Ti??Ei}function webShellEnvironment(e,t){return{...nn,mac:/Mac|iPhone|iPad/.test(navigator.platform),journal:t,loadSession:e=>sessionFrom(Z().webSessions?.[e]),saveSession:(e,t)=>{je({webSessions:{[e]:{...t,dock:t.dock}}})},autosave:()=>Z().webAutosaveSeconds??null,setAutosave:e=>je({webAutosaveSeconds:e}),theme:()=>currentThemeChoice(),setTheme:e=>chooseTheme(e),sidebar:()=>({open:Z().projectTreeHidden!==!0,width:clampSidebar(Z().projectTreeWidth??272)}),setSidebar:e=>je({projectTreeWidth:e.width,projectTreeHidden:!e.open}),runEditorAction:e=>{let t=window.penstockRunAction;return t?(t(e),!0):!1},licence:async()=>{try{let t=await e.getLicense();return t?t.detail||String(t.tier):null}catch{return null}},showLicence:()=>void e.showLicence(),notify:(e,t)=>t?H.error(e):H.info(e),copy:async e=>{try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}}}function startingLocale(e){let t=Z().locale;if(t)return h(t);let n=e?.locale;return n?h(n):p()}function followSystemTheme(e){let t=window.matchMedia?.(`(prefers-color-scheme: dark)`),n=themeNameFor(e?.theme,!!t?.matches);rememberHostTheme(n);try{applyTheme(n)}catch(e){console.error(`[Theme] Failed to initialize theme:`,e),applyTheme(_t)}applyThemeChoice(),followThemeChoice(),e?.theme&&e.theme.toUpperCase()!==`SYSTEM`||t?.addEventListener?.(`change`,e=>receiveHostThemeName(e.matches?`dark`:`light`))}function setupGlobalAppConfig(e){window.appConfig={theme:e?.theme||`light`,engine:e?.engine||null,scriptFormat:e?.scriptType||null,showBrowserToolBar:!1,project:e?.project||`Project`,bpmnFilePath:``,bpmnXml:``,elementTemplatesContent:cleanTemplates(e?.elementTemplatesContent),conventions:e?.conventions||{},pluginVersion:e?.pluginVersion??null,gitUserName:e?.gitUserName??null,get isDarkMode(){return getCurrentTheme()===`dark`},get isDraculaMode(){return getCurrentTheme()===`dracula`},get isSketchyMode(){return Z().rendering===`sketchy`},async fetchConfig(){}},window.setTheme=receiveHostThemeName,window.setSuggestionProvider=setSuggestionProvider}function reloadPage(){window.location.reload()}async function start(){let e=document.getElementById(`app`);try{if(!e)throw Error(`Root element with id "app" not found in HTML`);let t=new WebPlatformBridge;A(t);let n=await ye().bpmn.getConfig();await Ae(),await Se(),Ne();let r=startingLocale(n);await _(r).catch(e=>console.error(`[i18n] The catalogue for`,r,`did not load, English is shown:`,e)),v(r),document.documentElement.lang=g(),translatePanelLabels(),followSystemTheme(n),setupGlobalAppConfig(n);let i=webHost(t.web),a=new ProjectSession(i,await i.current());if(t.bindProject(()=>a.id,e=>a.noticeProjectId(e)),!a.snapshot().project.open){s(l(Te,{locale:g(),children:l(be,{onReload:reloadPage,children:l(Welcome,{session:a})})}),e),document.title=m(`app.web.pageTitle`);return}let o=`p${Date.now().toString(36)}${Math.random().toString(36).slice(2,10)}`;pageLock(o);let c=new DraftJournal(typeof indexedDB>`u`?new MemoryDrafts:new IndexedDbDrafts,{owner:o}),u=webShellEnvironment(t,c),d={store:null},f=new We({host:bridgeHost(t,n?.pluginVersion??null,e=>d.store?.doc(e)?.current??null),notify:u.notify,drafts:c});d.store=f;let p=new ScriptHub;t.bindWorkspace(new Workspace({store:f,scripts:p})),installDesktop(f),t.bindActiveFile(()=>f.snapshot().active),f.subscribe(()=>{let e=f.snapshot().active,n=window.appConfig;n&&(n.bpmnFilePath=e?Be(e):``),t.bindActiveDocument(e?t=>f.edit(e,t):null)});let h=new URLSearchParams(window.location.search).get(`file`),y=me();ge(y),window.addEventListener(`pagehide`,()=>y?.dispose());let b=new ToolWindowStore(toolApi(t),toolEffects(t,toolEnvironment(u,f))),Root=()=>l(ProjectFrame,{session:a,store:f,entries:i,readText:e=>t.readFile(e),engine:n?.engine,toolWindow:b,children:l(WebShell,{store:f,scripts:p,loaders:Nt,engine:n?.engine,deepLink:h,toolWindow:b,env:u})});s(l(Te,{locale:g(),children:l(be,{onReload:reloadPage,children:l(Root,{})})}),e),document.title=m(`app.web.pageTitle`),showFavicon(!1)}catch(t){console.error(`[Init] The web editor could not start:`,t),showStartupFailure(e,t)}}start();export{onSourceFocus as $,observeCorner as A,compareTexts as B,useRevealCount as C,tabList as Ct,AssistantDock as D,toggleHidden as Dt,ti as E,toggleCollapsed as Et,motionMs as F,Icon$1 as G,TabIcon as H,reducedMotion as I,PreviewPane as J,iconOfGroup as K,Tr as L,installScenarioOpener as M,takeScenarioRequest as N,Gr as O,widthLimits as Ot,useScenarioRequest as P,lineWanted as Q,useEditorActive as R,useLeaveChatTab as S,shownTab as St,ei as T,toPreferences as Tt,useLicence as U,hunksOf as V,paidTier as W,ensurePreviewStyle as X,computeChanges as Y,unpackComparison as Z,publishFacts as _,popView as _t,targetLabel as a,getCurrentTheme as at,useChatAction as b,resolveWidth as bt,useFocusCanvasShortcut as c,arrowTab as ct,domId as d,droppedTabs as dt,bt as et,groupOfKind as f,fromPreferences as ft,ToolbarButton as g,isSidebarShortcut as gt,Icon as h,isRepeatOfPress as ht,deployWithHost as i,applyTheme as it,AssistantRuntime as j,measureCorner as k,suggestsFields as l,badgeLabel as lt,nameFault as m,isRenameKey as mt,setProjectSuggestionProvider as n,currentThemeChoice as nt,toggleFocusCanvas as o,toggleDarkMode as ot,messageFrom$1 as p,isDrawer as pt,registerEditCommands as q,acceptedUpload as r,gt as rt,useFocusCanvas as s,cleanTemplates as st,currentSuggestionProvider as t,chooseTheme as tt,suggestsNextBlock as u,badgeText as ut,retractFacts as v,pushView as vt,useAssistantEditor as w,titleCommit as wt,useChatStatus as x,selectTab as xt,useAiChatPlace as y,resetViews as yt,useEditorElement as z};
|
|
148
|
+
`)),[y]);let b=o(null),x=o(null),S=o(null),[w,T]=t(!1),[E,D]=t(!1),O=isBusy(r),k=g.text.trim()===``,A=c(()=>v.filter(e=>!g.dismissed.includes(`element:${e.id}`)),[v,g.dismissed]),j=Math.max(0,A.length-Wr),M=h.choices.filter(e=>e.available),N=r?.agentId??h.agentId??M[0]?.id??``,P=i?.queue??[],F=oe(h,n.key,r,N),I=s===`dock`&&r!==null&&O&&(h.shown[r.id]!==!0||h.folded[r.id]===!0),L=s===`dock`&&k&&!w&&P.length===0&&!I,R=d??m(s===`tab`?`app.assistant.input.ask`:`app.assistant.input.placeholder`);u(()=>{b.current&&sizeField(b.current)},[g.text]),u(()=>{S.current&&fitRow(S.current)}),f(()=>{let e=S.current;if(!e||typeof ResizeObserver>`u`)return;let t=e.clientWidth,n=new ResizeObserver(()=>{e.clientWidth!==t&&(t=e.clientWidth,fitRow(e),b.current&&sizeField(b.current))});return n.observe(e),()=>n.disconnect()},[]),f(()=>{g.focus>0&&b.current?.focus()},[g.focus]);let submit=async()=>{if(k||E)return;D(!0);let t=g.text;try{let r=await e.send({editor:n.key,text:messageOf(g),context:contextOf(n,A,g),authorize:()=>p(C.AI_CHAT)});(r===`sent`||r===`queued`)&&e.draft(n.key).text===t&&e.clearDraft(n.key)}finally{D(!1)}},stop=()=>{r&&e.stop(r.id)};return l(`form`,{class:`assistant-input${O?` is-busy`:``}${L?` is-resting`:``}`,"aria-label":m(`app.assistant.input.label`),onSubmit:e=>{e.preventDefault(),submit()},children:[I&&r&&l(`button`,{type:`button`,class:`assistant-input__state type-help`,title:m(`app.assistant.input.showCard`),onClick:()=>e.showCard(r.id),children:[r.state===`waiting`||i?.permission?l(J,{name:`hand`,class:`assistant-input__hand`}):l(X,{}),l(`span`,{children:r.state===`waiting`||i?.permission?m(`app.assistant.input.stateWaiting`):m(`app.assistant.input.stateWorking`)})]}),P.length>0&&l(`ul`,{class:`assistant-input__queue`,"aria-label":m(`app.assistant.input.queued`),children:P.map(t=>l(`li`,{class:`assistant-input__queued`,children:[l(J,{name:`queue`}),l(`span`,{class:`assistant-input__queued-text type-help`,title:t.text,children:m(`app.assistant.input.queuedText`,{text:t.text})}),l(`button`,{type:`button`,class:`assistant-button assistant-button--icon`,"aria-label":m(`app.assistant.input.unqueue`),title:m(`app.assistant.input.unqueue`),onClick:()=>r&&void e.unqueue(r.id,t.id,n.key),children:l(J,{name:`close`})})]},t.id))}),l(`div`,{class:`assistant-input__chips`,role:`group`,"aria-label":m(`app.assistant.input.context`),children:[A.slice(0,Wr).map(t=>l(`span`,{class:`assistant-chip assistant-chip--element`,children:[l(ElementChip,{id:t.id,type:t.type,name:t.name,onSelect:e=>n.canvas?.select(e)}),l(`button`,{type:`button`,class:`assistant-chip__remove`,"aria-label":m(`app.assistant.input.removeChip`,{name:t.name||t.id}),title:m(`app.assistant.input.removeChip`,{name:t.name||t.id}),onClick:()=>e.unmention(n.key,`element:${t.id}`),children:l(J,{name:`close`})})]},t.id)),j>0&&l(`span`,{class:`assistant-chip type-help`,children:m(`app.assistant.input.more`,{count:j})}),g.mentions.map(t=>l(`span`,{class:`assistant-chip assistant-chip--${t.kind}`,children:[t.kind===`element`?l(ElementChip,{id:t.id,type:t.type,name:t.name,onSelect:e=>n.canvas?.select(e)}):l(`span`,{class:`assistant-chip__label type-help`,title:t.path,children:t.name}),l(`button`,{type:`button`,class:`assistant-chip__remove`,"aria-label":m(`app.assistant.input.removeChip`,{name:t.kind===`element`?t.name||t.id:t.name}),title:m(`app.assistant.input.removeChip`,{name:t.kind===`element`?t.name||t.id:t.name}),onClick:()=>e.unmention(n.key,ae(t)),children:l(J,{name:`close`})})]},ae(t))),l(`span`,{class:`assistant-chip assistant-chip--file type-help`,title:n.file??n.name,children:n.name})]}),l(`textarea`,{ref:b,class:`assistant-input__text type-input`,rows:1,value:g.text,placeholder:R,"aria-label":m(`app.assistant.input.placeholder`),onInput:t=>e.setText(n.key,t.currentTarget.value),onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||e.altKey||e.isComposing||(e.preventDefault(),submit())}}),L&&l(`span`,{class:`assistant-input__hint type-input`,"aria-hidden":`true`,children:R}),l(`div`,{ref:S,class:`assistant-input__row`,children:[l(ChatSwitcher,{store:e,state:h,editor:n.key,chat:r}),l(`button`,{ref:x,type:`button`,class:`assistant-button assistant-button--icon`,"aria-label":m(`app.assistant.input.add`),title:m(`app.assistant.input.add`),"aria-haspopup":`dialog`,"aria-expanded":w,onClick:()=>T(e=>!e),children:l(J,{name:`plus`})}),w&&l(Mentions,{store:e,editor:n,anchor:x.current,onClose:()=>T(!1)}),l(he,{store:e,state:h,editor:n.key,chat:r,agentId:N,options:F,busy:O,started:r!==null&&(i?.entries.length??0)>0}),l(`span`,{class:`assistant-input__keys type-help`,"aria-hidden":`true`,children:[l(`kbd`,{class:`assistant-key`,children:m(`app.assistant.input.keyEnter`)}),l(`span`,{children:m(O?`app.assistant.input.keyQueue`:`app.assistant.input.keySend`)}),!O&&l(a,{children:[l(`kbd`,{class:`assistant-key`,children:m(`app.assistant.input.keyShiftEnter`)}),l(`span`,{children:m(`app.assistant.input.keyNewline`)})]})]}),O?l(`button`,{type:`button`,class:`assistant-button assistant-button--stop`,"aria-label":m(`app.assistant.input.stop`),title:m(`app.assistant.input.stop`),onClick:stop,children:l(J,{name:`stop`})}):l(`button`,{type:`submit`,class:`assistant-button assistant-button--send`,"aria-label":m(`app.assistant.input.send`),title:m(`app.assistant.input.send`),disabled:k||E,children:E?l(X,{}):l(J,{name:`send`})})]})]})}var Gr=`.djs-palette, .fjs-palette-container`,Kr=`.bjs-powered-by, .fjs-powered-by-link`,qr=`.diagram-check, .bjsl-button, .trace-pill`;function cornerLayout(e){let t=Math.max(0,Math.min(e.coveredLeft??0,e.canvas)),n=Math.max(0,Math.min(e.covered??0,e.canvas-t)),r=e.canvas-n,edge=e=>e>0?16+e:0,i=Math.max(edge(e.palette),edge(e.watermark),t),a=e.cardFull>0,room=e=>r-e-32,o=e.dock&&a&&room(Math.max(i,edge(e.cardFull)))<440,s=r-16,span=e=>s-(e+16),c=Math.max(i,edge(e.card)),l=`full`;e.dock&&e.canvas>0&&span(c)<240&&(span(i)>=240?(c=i,l=`overlap`):l=`collapsed`);let u=i,d=Math.min(e.canvas-16,Math.max(s,u+16+240)),f=Math.max(0,e.canvas-16-d),p=c+16,m=Math.min(600,Math.max(0,s-p)),h=p+(s-p-m)/2;return{inset:c,folded:o,mode:l,overlayInset:u,overlayCovered:f,covered:n,coveredLeft:t,dock:{left:h,right:h+m}}}var Jr=`.assistant-dock`,Yr=`.assistant-input, .assistant-ask`;function insetOf(e,t){return t===null||!Number.isFinite(t)?0:Math.max(0,Math.round(e-t))}function viewportHeight(){return typeof window>`u`?0:window.innerHeight}function shown(e){if(!e)return null;let t=e.getBoundingClientRect();return t.width>0&&t.height>0?t:null}function measureCorner(e){let t=e.getBoundingClientRect(),widthOf=n=>{let r=0;return e.querySelectorAll(n).forEach(e=>{let n=shown(e);n&&(r=Math.max(r,n.right-t.left-16))}),Math.max(0,Math.round(r))},n=[...e.querySelectorAll(qr)].map(shown).filter(e=>e!==null),r=e.querySelector(`.diagram-check:not(.trace-card)`)!==null,i=n.reduce((e,t)=>Math.min(e,t.top),1/0),a=Qe(t,Xe(e).map(e=>e.getBoundingClientRect())),o=Math.max(0,Math.min(460,t.width-32)),s=cornerLayout({canvas:t.width,palette:widthOf(Gr),watermark:widthOf(Kr),card:widthOf(qr),cardFull:Math.max(r?o:0,Math.min(o,fullWidth(e,`.trace-card`)),Math.min(o,fullWidth(e,`.bjsl-button`))),dock:e.querySelector(`.assistant-dock`)!==null,covered:a.right,coveredLeft:a.left});return{inset:Math.round(s.inset),dock:insetOf(t.bottom,shown(e.querySelector(`.assistant-dock`))?.top??null),input:insetOf(t.bottom,shown(e.querySelector(`.assistant-input, .assistant-ask`))?.top??null),height:n.length>0?Math.max(0,Math.round(t.bottom-i))+16:0,folded:s.folded,left:Math.round(t.left),bottom:Math.max(0,Math.round(viewportHeight()-t.bottom)),mode:s.mode,overlayInset:Math.round(s.overlayInset),overlayCovered:Math.round(s.overlayCovered),covered:Math.round(s.covered),coveredLeft:Math.round(s.coveredLeft),traceLeft:traceLeftOf(e,t)}}var Xr=8;function fullWidth(e,t){let n=e.querySelector(t),r=shown(n);return!n||!r?0:(e.classList.contains(`is-corner-folded`)||(n.dataset.fullWidth=String(Math.round(r.width))),Number(n.dataset.fullWidth??Math.round(r.width)))}function traceLeftOf(e,t){let n=shown(e.querySelector(`.bjsl-button`))??shown(e.querySelector(`.trace-pill`));return n?Math.round(n.right-t.left+Xr):16}function observeCorner(e,t,n){let r=0,schedule=()=>{r||=requestAnimationFrame(()=>{r=0,n()})};if(typeof ResizeObserver>`u`)return()=>void 0;let i=new ResizeObserver(schedule);i.observe(e),t.forEach(e=>i.observe(e));let a=new Set,watch=()=>{let t=new Set(e.querySelectorAll(`${Gr}, ${Kr}, ${qr}, ${Jr}, ${Yr}`));for(let e of a)t.has(e)||(a.delete(e),i.unobserve(e));for(let e of t)a.has(e)||(a.add(e),i.observe(e))};watch();let o=new MutationObserver(()=>{watch(),schedule()});return o.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`class`]}),()=>{i.disconnect(),o.disconnect(),r&&cancelAnimationFrame(r)}}var Zr={peeking:!1,over:!1,focused:!1,asking:!1};function peekAfter(e,t){switch(t){case`canvas`:return e.asking||e.over?e:{...e,peeking:!0};case`selection`:return e.asking||e.over||e.focused?e:{...e,peeking:!0};case`hover`:return{...e,over:!0,peeking:!1};case`leave`:return{...e,over:!1};case`focus`:return{...e,focused:!0,peeking:!1};case`blur`:return{...e,focused:!1};case`asking`:return{...e,asking:!0,peeking:!1};case`answered`:return{...e,asking:!1}}}var inside=(e,t)=>t instanceof Node&&e.contains(t);function usePeek(e,n,r,i){let a=o(Zr),[s,c]=t(!1),apply=e=>{let t=peekAfter(a.current,e);a.current=t,c(t.peeking)};return f(()=>{apply(r?`asking`:`answered`)},[r]),f(()=>{let t=e.current,r=t?.closest(`.editor-canvas`);if(!t||!r||!i){a.current=Zr,c(!1);return}let worked=e=>{inside(t,e.target)||apply(`canvas`)},over=e=>{e.target?.closest?.(`.assistant-card`)&&apply(`hover`)},out=e=>{e.relatedTarget?.closest?.(`.assistant-card`)||apply(`leave`)},focus=()=>apply(`focus`),blur=e=>{inside(t,e.relatedTarget)||apply(`blur`)},o=n?.subscribe(()=>apply(`selection`));return r.addEventListener(`pointerdown`,worked,!0),r.addEventListener(`wheel`,worked,{capture:!0,passive:!0}),t.addEventListener(`mouseover`,over),t.addEventListener(`mouseout`,out),t.addEventListener(`focusin`,focus),t.addEventListener(`focusout`,blur),()=>{o?.(),r.removeEventListener(`pointerdown`,worked,!0),r.removeEventListener(`wheel`,worked,!0),t.removeEventListener(`mouseover`,over),t.removeEventListener(`mouseout`,out),t.removeEventListener(`focusin`,focus),t.removeEventListener(`focusout`,blur)}},[e,n,i]),s&&!r}function useStore$1(){let[e]=t(()=>G());return e}e(useStore$1,`useStore`);var Qr=e(()=>()=>void 0,`none`),$r=360;function AssistantDock({editor:e,hidden:n,onAgentSettings:i}){let s=useStore$1(),c=W(s?s.subscribe:Qr,s?s.snapshot:()=>null),u=o(null),d=r(fn),p=useBridgeLinks(e),h=c?.enabled===!0&&c.place===`bottom`&&!n,g=s&&c?s.activeChat(e.key):null,_=!!c&&!!g&&c.shown[g.id]===!0&&c.folded[g.id]!==!0&&c.transcripts[g.id]?.permission!=null,v=!!c&&!!g&&c.transcripts[g.id]?.permission!=null,y=e.canvas?.channel,[b,x]=t(`full`),[S,C]=t(!1),w=v||g?.state===`waiting`,T=b===`collapsed`&&(S||w),E=usePeek(u,e.selection,_,h);if(f(()=>{let e=u.current,t=e?.closest(`.editor-canvas`);if(!e||!t)return;let publish=()=>{let n=e.offsetHeight,r=measureCorner(t),i=r.mode===`collapsed`&&T?r.overlayInset:r.inset,a=r.mode===`collapsed`&&T?r.overlayCovered:r.covered;t.style.setProperty(`--assistant-canvas-height`,`${t.clientHeight}px`),t.style.setProperty(`--assistant-inset-left`,`${i}px`),t.style.setProperty(`--assistant-inset-right`,`${a}px`),e.dataset.narrow=e.offsetWidth<$r?`true`:`false`,e.dataset.coverLeft=r.coveredLeft>0?`true`:`false`,x(r.mode),y?.setCover(v?$e(i,n,a):null)};publish();let n=observeCorner(t,[e],publish),r=Ye(t,publish);return()=>{n(),r(),t.style.removeProperty(`--assistant-canvas-height`),t.style.removeProperty(`--assistant-inset-left`),t.style.removeProperty(`--assistant-inset-right`),y?.setCover(null)}},[h,v,y,T]),f(()=>{if(b!==`collapsed`||!S)return;let away=e=>{let t=e.target;t instanceof Element&&!t.closest(`.assistant-dock, .ui-popover`)&&C(!1)};return document.addEventListener(`pointerdown`,away,!0),()=>document.removeEventListener(`pointerdown`,away,!0)},[b,S]),f(()=>{S&&s&&s.focusInput(e.key)},[S]),!s||!c||!h)return null;let D=s.activeChat(e.key),O=D?c.transcripts[D.id]??null:null,k=D!==null&&c.shown[D.id]===!0&&(D.state===`failed`||c.folded[D.id]!==!0),A=b===`collapsed`&&!T,j=D&&(D.state===`working`||D.state===`connecting`)?`working`:D&&(D.state===`waiting`||O?.permission)?`waiting`:null,collapse=()=>{C(!1),requestAnimationFrame(()=>u.current?.querySelector(`.assistant-ask`)?.focus())};return l(fn.Provider,{value:d===dn?p:d,children:l(`div`,{ref:u,class:`assistant-dock${A?` is-collapsed`:``}${T?` is-overlay`:``}`,onKeyDown:e=>{e.key===`Escape`&&(D&&k&&D.state!==`failed`?(e.stopPropagation(),s.setFolded(D.id,!0)):b===`collapsed`&&S&&!w&&(e.stopPropagation(),collapse()))},children:A?l(`button`,{type:`button`,class:`assistant-ask${j?` is-${j}`:``}`,"aria-label":m(`app.assistant.input.ask`),title:m(`app.assistant.input.ask`),onClick:()=>C(!0),children:j===`working`?l(X,{}):l(J,{name:j===`waiting`?`hand`:`chat`})}):l(a,{children:[D&&k&&l(AssistantCard,{store:s,state:c,editor:e,chat:D,transcript:O,peeking:E,onChooseAgent:()=>u.current?.querySelector(`.assistant-settings`)?.click(),onAgentSettings:i??(()=>void ce())}),!k&&c.failure&&l(`section`,{class:`assistant-card is-failed`,role:`alert`,"aria-label":m(`app.assistant.card.label`),children:[l(`header`,{class:`assistant-card__head`,children:[l(J,{name:`alert`,class:`assistant-card__icon is-warning`}),l(`span`,{class:`assistant-card__title`,children:m(`app.assistant.unreachable`)}),l(`span`,{class:`assistant-card__buttons`,children:l(`button`,{type:`button`,class:`assistant-button assistant-button--icon`,"aria-label":m(`app.assistant.card.close`),title:m(`app.assistant.card.close`),onClick:()=>s.dismissFailure(),children:l(J,{name:`close`})})})]}),l(`div`,{class:`assistant-card__body`,children:l(FailureNotice,{failure:c.failure,choices:c.choices,onRetry:()=>void s.resync(),onSettings:i??(()=>void ce())})})]}),l(AssistantInput,{store:s,editor:e,chat:D,transcript:O,surface:`dock`})]})})})}var ei=i(null);function TranscriptFailure({error:e}){let t=failureSummary(e,``);return l(a,{children:[l(`p`,{class:`assistant-entry is-notice type-help`,role:`alert`,children:t.text}),t.details&&l(FailureDetails,{text:t.details})]})}function ChatTabBody({store:e,editor:t}){let n=W(e.subscribe,e.snapshot),i=r(fn),a=useBridgeLinks(t),o=e.activeChat(t.key),s=o?.id??null,c=s?n.transcripts[s]??null:null,u=c?.entries??[],d=c?.permission??null,p=u[u.length-1],h=useFollow(d?.id??null,`${u.length}:${p&&`text`in p?p.text.length:0}:${o?.state??``}`);f(()=>{s&&e.open(s)},[e,s]);let g=o?.state===`working`||o?.state===`connecting`||o?.state===`waiting`,_=o?.state===`failed`;return l(fn.Provider,{value:i===dn?a:i,children:l(`section`,{class:`assistant-tab`,"aria-label":m(`app.assistant.tab.label`),children:[o&&l(`header`,{class:`assistant-tab__head`,children:[l(`span`,{class:`assistant-tab__title`,title:o.title,children:o.title}),l(`button`,{type:`button`,class:`assistant-button assistant-button--icon`,"aria-label":m(`app.assistant.card.newChat`),title:m(`app.assistant.card.newChat`),disabled:g||d!==null,onClick:()=>e.select(t.key,null),children:l(J,{name:`plus`})})]}),l(`div`,{ref:h.ref,class:`assistant-tab__feed`,role:`log`,"aria-live":`off`,"aria-label":m(`app.assistant.tab.transcript`),onScroll:h.onScroll,children:[!o&&!n.failure&&l(De,{title:m(`app.assistant.tab.empty`),hint:m(`app.assistant.tab.emptyHint`)}),c?.status===`loading`&&u.length===0&&l(`p`,{class:`assistant-card__status type-help`,role:`status`,children:[l(X,{}),` `,m(`app.assistant.card.loading`)]}),s&&c?.status===`failed`&&l(De,{title:m(`app.assistant.tab.unreadable`),hint:m(`app.assistant.tab.unreadableHint`),actions:[{label:m(`app.assistant.tryAgain`),run:()=>void e.retry(s,null)}]}),o&&c?.status===`ready`&&u.length===0&&!d&&l(De,{title:m(`app.assistant.tab.emptyChat`),hint:m(`app.assistant.tab.emptyChatHint`)}),c&&l(TranscriptView,{store:e,chatId:s??``,entries:u,permission:d,running:g,surface:`tab`,onShow:(e,n)=>{if(!t.canvas?.channel.has(proposalId(e,n)))return!1;let r=t.canvas.channel;return requestAnimationFrame(()=>requestAnimationFrame(()=>r.fit())),!0}}),_&&c?.error&&l(TranscriptFailure,{error:c.error}),n.failure&&l(FailureNotice,{failure:n.failure,choices:n.choices,onRetry:()=>void e.resync(),onSettings:()=>void ce()})]}),l(`div`,{class:`assistant-tab__input`,children:l(AssistantInput,{store:e,editor:t,chat:o,transcript:c,surface:`tab`})})]})})}function ChatTab(){let e=r(ei),[n]=t(()=>G());return!n||!e?null:l(ChatTabBody,{store:n,editor:e})}var ti={id:`chat`,icon:`chat`,component:ChatTab,needs:`ai-chat`};function chatStatusOf(e,t){let n=t?e.active[t]:null;if(!n)return null;let r=e.chats.find(e=>e.id===n);return r?r.state===`waiting`||e.transcripts[n]?.permission?`waiting`:r.state===`working`||r.state===`connecting`?`working`:null:null}function useEditorCanvas(e){let t=o(e);return t.current=e,c(()=>{let e=new EditorCanvas((n,r)=>{let i=e.describe(n);G()?.compose(t.current,{kind:`element`,id:n,type:i?.type??`bpmn:Task`,...i?.name?{name:i.name}:{}},r)});return e},[])}function useAssistantEditor({kind:e,file:t,fallbackName:n,selection:r,elements:i}){let a=t??null,o=a??n,s=useEditorCanvas(o),l=e===`bpmn`?s:void 0;return c(()=>({key:o,file:a,name:a?pe(a):n,kind:e,canvas:l,selection:r??l,elements:i??l?.elements}),[o,a,n,e,l,r,i])}var none=()=>()=>void 0;function useAiChatPlace(){let[e]=t(()=>G());return W(e?e.subscribe:none,()=>e?e.snapshot().place:`off`)}function useChatStatus(e){let[n]=t(()=>G());return W(n?n.subscribe:none,()=>n?chatStatusOf(n.snapshot(),e):null)}function useRevealCount(e){let[n]=t(()=>G());return W(n?n.subscribe:none,()=>n&&e?n.snapshot().revealed[e]??0:0)}function useLeaveChatTab(e,t){let n=o(t);f(()=>{n.current&&!t&&e&&G()?.returnToCard(e),n.current=t},[e,t])}function useChatAction(e,t){let n=useAiChatPlace(),r=useChatStatus(e);return{available:_e(n).toolbarButton,open:t===ti.id,status:r}}var ni=null,ri=null,ii=new Set;function sameFacts(e,t){return JSON.stringify(e)===JSON.stringify(t)}function publishFacts(e,t){ni===e&&sameFacts(ri,t)||(ni=e,ri=t,ii.forEach(e=>e()))}function retractFacts(e){ni===e&&(ni=null,ri=null,ii.forEach(e=>e()))}function useEditorFacts(){let[,e]=t(0);return f(()=>{let listener=()=>e(e=>e+1);return ii.add(listener),()=>void ii.delete(listener)},[]),ri}function ToolbarButton({id:e,label:n,icon:r,action:i,disabled:a=!1,tooltip:s,description:c,isActive:u=!1,checked:d,status:p}){let[h,g]=t(!1),_=o(null);f(()=>()=>{_.current!==null&&window.clearTimeout(_.current),_.current=null},[]);let handleClick=()=>{a||(i(),g(!0),_.current!==null&&window.clearTimeout(_.current),_.current=window.setTimeout(()=>{_.current=null,g(!1)},motionMs(`--motion-base`)))},handleKeyDown=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),handleClick())};return l(`button`,{id:e,className:`toolbar-button type-toolbar-button ${a?`disabled`:``} ${u||h?`active`:``}`,onClick:handleClick,onKeyDown:handleKeyDown,disabled:a,title:s||n,"aria-label":n,"aria-description":c??(p?m(`app.sidebar.status.${p}`):void 0),"aria-pressed":d===void 0?void 0:d,type:`button`,children:[l(`span`,{className:`toolbar-button-icon icon-${r}`,role:`presentation`,children:l(`svg`,{className:`toolbar-icon-svg`,viewBox:`0 0 16 16`,width:`16`,height:`16`,stroke:`currentColor`,fill:`none`,"stroke-width":`1`,"stroke-linecap":`round`,"stroke-linejoin":`round`,dangerouslySetInnerHTML:{__html:getIconPath(r)}})}),p===`working`&&l(`span`,{className:`toolbar-button-status is-working`,"aria-hidden":`true`,children:l(X,{})}),p===`waiting`&&l(`span`,{className:`toolbar-button-status is-waiting`,"aria-hidden":`true`})]})}function getIconPath(e){return{refresh:`<path d="M2.5 9V8a5.5 5.5 0 0 1 8.5-4.6"/><path d="M5 12.6A5.5 5.5 0 0 0 13.5 8V7"/><path d="M1.5 7.5l2 2 2-2"/><path d="M10.5 8.5l2-2 2 2"/>`,undo:`<path d="M5 3.5 2.5 6 5 8.5"/><path d="M2.5 6h7a3.5 3.5 0 0 1 0 7h-3"/>`,redo:`<path d="M11 3.5 13.5 6 11 8.5"/><path d="M13.5 6h-7a3.5 3.5 0 0 0 0 7h3"/>`,copy:`<rect x="5.5" y="5.5" width="8" height="8" rx="1.5"/><path d="M10.5 3.5V3a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h.5"/>`,paste:`<path d="M5.5 3h-1A1.5 1.5 0 0 0 3 4.5v8A1.5 1.5 0 0 0 4.5 14h7a1.5 1.5 0 0 0 1.5-1.5v-8A1.5 1.5 0 0 0 11.5 3h-1"/><rect x="5.5" y="1.5" width="5" height="3" rx="1"/>`,"auto-layout":`<rect x="1.5" y="6.5" width="4" height="3" rx="0.5"/><rect x="10.5" y="2.5" width="4" height="3" rx="0.5"/><rect x="10.5" y="10.5" width="4" height="3" rx="0.5"/><path d="M5.5 8h2.5V4h2.5M8 8v4h2.5"/>`,"diagram-check":`<path d="M8 1.5 14.5 8 8 14.5 1.5 8Z"/><path d="M5.5 8.2 7.2 9.9 10.5 6.3"/>`,migration:`<path d="M6 3.5 10.5 8 6 12.5 1.5 8Z"/><path d="M10.5 8h4M13 6.5 14.5 8 13 9.5"/>`,live:`<path d="M1.5 8.5h3l1.5-4 3 8 1.5-4h4"/>`,runs:`<path d="M2.5 4.5l1.5 1.5 3-3"/><path d="M9.5 4.5h4"/><path d="M2.5 11l1.5 1.5 3-3"/><path d="M9.5 11h4"/>`,debug:`<circle cx="4.5" cy="8" r="2"/><path d="M8.5 3.5v9M8.5 8h5M11.5 5.5 14 8l-2.5 2.5"/>`,breakpoint:`<circle cx="8" cy="8" r="5"/><circle cx="8" cy="8" r="2"/>`,coverage:`<rect x="1.5" y="4.5" width="4" height="4" rx="1"/><rect x="10.5" y="4.5" width="4" height="4" rx="1"/><path d="M5.5 6.5h5"/><path d="M1.5 12.5h13" opacity="0.4"/><path d="M1.5 12.5h8"/>`,export:`<path d="M8 2.5v7M5 6.5l3 3 3-3"/><path d="M2.5 10v2A1.5 1.5 0 0 0 4 13.5h8a1.5 1.5 0 0 0 1.5-1.5v-2"/>`,share:`<path d="M9.5 2.5h4v4M13.5 2.5 8 8"/><path d="M12.5 9v3a1.5 1.5 0 0 1-1.5 1.5H4A1.5 1.5 0 0 1 2.5 12V5A1.5 1.5 0 0 1 4 3.5h3"/>`,import:`<path d="M9 2.5H4.5a1 1 0 0 0-1 1v9a1 1 0 0 0 1 1h7a1 1 0 0 0 1-1V6Z"/><path d="M9 2.5V6h3.5"/><path d="M8 8v4M6 10l2 2 2-2"/>`,"token-simulation":`<path d="M5 3.3v9.4a.5.5 0 0 0 .77.42l7.1-4.7a.5.5 0 0 0 0-.84L5.77 2.88A.5.5 0 0 0 5 3.3Z"/>`,minimap:`<path d="M2.5 4 6 2.5l4 1.5 3.5-1.5V12L10 13.5 6 12l-3.5 1.5Z"/><path d="M6 2.5V12M10 4v9.5"/>`,"trace-paths":`<rect x="5.5" y="4.5" width="5" height="7" rx="1"/><path d="M1.5 2H3V6H5.5M1.5 14H3V10H5.5M10.5 6H13V2H14.5M10.5 10H13V14H14.5"/>`,deploy:`<path d="M8 14V7.5M5.5 10 8 7.5l2.5 2.5"/><path d="M5 12h-.75a3 3 0 0 1-.4-5.97 4.5 4.5 0 0 1 8.3 0A3 3 0 0 1 11.75 12H11"/>`,marketplace:`<rect x="2.5" y="2.5" width="4.5" height="4.5" rx="1"/><rect x="9" y="2.5" width="4.5" height="4.5" rx="1"/><rect x="2.5" y="9" width="4.5" height="4.5" rx="1"/><rect x="9" y="9" width="4.5" height="4.5" rx="1"/>`,sketchy:`<path d="M2.5 10.5c1.5-3 3-3 4.5 0s3 3 4.5 0 1.5-2 2-2.5"/><path d="M2.5 6c1-1.5 2-1.5 3 0"/>`,"panel-toggle":`<rect x="2.5" y="2.5" width="11" height="11" rx="2"/><path d="M9.5 2.5v11"/><path d="M11.5 5h.5M11.5 7h.5M11.5 9h.5"/>`,preview:`<path d="M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8Z"/><circle cx="8" cy="8" r="2"/>`,transaction:`<rect x="1.5" y="4.5" width="4" height="7" rx="1"/><rect x="10.5" y="4.5" width="4" height="7" rx="1"/><path d="M8 2.5v11"/>`,fit:`<path d="M2.5 6V2.5H6M10 2.5h3.5V6M13.5 10v3.5H10M6 13.5H2.5V10"/>`,"focus-canvas":`<path d="M2.5 5.5v-2a1 1 0 0 1 1-1h2M10.5 2.5h2a1 1 0 0 1 1 1v2M13.5 10.5v2a1 1 0 0 1-1 1h-2M5.5 13.5h-2a1 1 0 0 1-1-1v-2"/><rect x="5.5" y="5.5" width="5" height="5" rx="1"/>`,"zoom-in":`<circle cx="7" cy="7" r="4.5"/><path d="M10.5 10.5 14 14M5 7h4M7 5v4"/>`,"zoom-out":`<circle cx="7" cy="7" r="4.5"/><path d="M10.5 10.5 14 14M5 7h4"/>`,tour:`<path d="M3.5 14V2.5"/><path d="M3.5 3h9v6h-9"/>`,compare:`<rect x="1.5" y="3.5" width="5" height="9" rx="1"/><rect x="9.5" y="3.5" width="5" height="9" rx="1"/><path d="M6.5 8h3"/>`,licence:`<circle cx="5.5" cy="10.5" r="3"/><path d="M7.7 8.3 13.5 2.5M11 5l1.5 1.5"/>`,documentation:`<path d="M3.5 12.5v-9a1 1 0 0 1 1-1h8v10h-8a1 1 0 0 0-1 1 1 1 0 0 0 1 1h8"/><path d="M6.5 5.5h4"/>`,sun:`<circle cx="8" cy="8" r="2.5"/><path d="M8 1.5V3M8 13v1.5M1.5 8H3M13 8h1.5M3.4 3.4l1.1 1.1M11.5 11.5l1.1 1.1M3.4 12.6l1.1-1.1M11.5 4.5l1.1-1.1"/>`,keyboard:`<rect x="1.5" y="4" width="13" height="8" rx="1.5"/><path d="M4 6.75h.01M6.5 6.75h.01M9 6.75h.01M11.5 6.75h.01M4 9.25h.01M11.5 9.25h.01M6.5 9.25h3"/>`,pin:`<path d="M6 2.5h4M7 2.5v4L4.5 9.5h7L9 6.5v-4M8 9.5v4"/>`,lock:`<rect x="3.5" y="7" width="9" height="6.5" rx="1.5"/><path d="M5.5 7V5a2.5 2.5 0 0 1 5 0v2"/>`,check:`<path d="M3.5 8.5 6.5 11.5 12.5 4.5"/>`,chevron:`<path d="M5 6.5 8 9.5l3-3"/>`,settings:`<path d="M2.5 4.5h6M11.5 4.5h2M2.5 11.5h2M7.5 11.5h6"/><circle cx="10" cy="4.5" r="1.5"/><circle cx="6" cy="11.5" r="1.5"/>`,more:`<circle cx="3.5" cy="8" r="0.75" fill="currentColor"/><circle cx="8" cy="8" r="0.75" fill="currentColor"/><circle cx="12.5" cy="8" r="0.75" fill="currentColor"/>`,delete:`<path d="M2.5 4.5h11M6.5 4.5v-1a1 1 0 0 1 1-1h1a1 1 0 0 1 1 1v1"/><path d="M4 4.5l.6 8.1a1 1 0 0 0 1 .9h4.8a1 1 0 0 0 1-.9l.6-8.1"/><path d="M6.8 7v4M9.2 7v4"/>`,"skip-back":`<path d="M4 3.5v9"/><path d="M12.5 4v8L6.5 8Z"/>`,"step-back":`<path d="M10 3.5 5.5 8l4.5 4.5"/>`,"step-forward":`<path d="M6 3.5 10.5 8 6 12.5"/>`,"skip-forward":`<path d="M12 3.5v9"/><path d="M3.5 4v8L9.5 8Z"/>`,pause:`<path d="M6 3.5v9M10 3.5v9"/>`,close:`<path d="M4 4l8 8M12 4l-8 8"/>`,code:`<path d="M5.5 4L2 8l3.5 4M10.5 4L14 8l-3.5 4"/>`,chat:`<path d="M2.5 2.5h11a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H8.5L5 13.5v-3H2.5a1 1 0 0 1-1-1v-6a1 1 0 0 1 1-1z"/><path d="M5 6.5h.01M8 6.5h.01M11 6.5h.01"/>`,comments:`<path d="M3.5 2.5h9v11h-9z"/><path d="M5.5 6h5M5.5 9h3.5"/>`}[e]||`<circle cx="8" cy="8" r="1"/>`}function Icon({name:e,className:t=`toolbar-icon-svg`}){return l(`svg`,{className:t,viewBox:`0 0 16 16`,width:`16`,height:`16`,stroke:`currentColor`,fill:`none`,"stroke-width":`1`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,dangerouslySetInnerHTML:{__html:getIconPath(e)}})}var ai=`penstock.web.chatsHeight`;function clampChats(e,t){let n=Math.max(96,t-96);return Math.min(n,Math.max(96,Math.round(e)))}function loadChatsHeight(e){try{let t=Number(e?.getItem(ai));return Number.isFinite(t)&&t>=96?Math.round(t):null}catch{return null}}function saveChatsHeight(e,t){try{t===null?e?.removeItem(ai):e?.setItem(ai,String(Math.round(t)))}catch{}}function browserStore(){try{return typeof localStorage>`u`?void 0:localStorage}catch{return}}var oi=16;function clampSidebar(e){return Math.min(400,Math.max(240,Math.round(e)))}var si=[{id:`check`,action:`diagram-check`,icon:`diagram-check`,label:()=>m(`app.web.sidebar.check`)},{id:`scenarios`,action:`runs`,icon:`runs`,label:()=>m(`app.web.sidebar.scenarios`)},{id:`monitor`,action:`live`,icon:`live`,label:()=>m(`app.web.sidebar.monitor`)},{id:`debug`,action:`debug-process`,icon:`debug`,label:()=>m(`app.web.sidebar.debug`)},{id:`layout`,action:`auto-layout`,icon:`auto-layout`,label:()=>m(`app.web.sidebar.layout`)}];function countOf(e,t){return t?e.id===`check`&&t.problems?{text:String(t.problems),title:m(`app.web.sidebar.countProblems`,{count:t.problems}),error:!0}:e.id===`scenarios`&&t.scenarios?{text:`${t.scenarios.passed}/${t.scenarios.all}`,title:m(`app.web.sidebar.countScenarios`,{passed:t.scenarios.passed,all:t.scenarios.all}),error:!1}:e.id===`monitor`&&t.waiting?{text:String(t.waiting),title:m(`app.web.sidebar.countWaiting`,{count:t.waiting}),error:!1}:null:null}function useChatsOn(e){let[n,r]=t(()=>e?.snapshot().enabled===!0);return f(()=>{if(e)return r(e.snapshot().enabled===!0),e.subscribe(()=>r(e.snapshot().enabled===!0))},[e]),n}function ShellSidebar({width:e,onWidth:n,drawer:r,onClose:i,runAction:s,openFile:c,focusedEditor:u,chatsStore:d,children:f}){let p=useEditorFacts(),h=o(null),g=G(),_=o(null),v=o(null),y=o(null),[b,x]=t(()=>loadChatsHeight(d??browserStore())),S=useChatsOn(g),available=()=>(_.current?.querySelector(`.web-sidebar__project`)?.getBoundingClientRect().height??0)+(v.current?.getBoundingClientRect().height??0),resize=(e,t,n=available())=>{let r=e===null?null:clampChats(e,n);x(r),t&&saveChatsHeight(d??browserStore(),r)},current=()=>v.current?.getBoundingClientRect().height??0;return l(a,{children:[r&&l(`div`,{class:`web-sidebar__scrim`,onPointerDown:i}),l(`aside`,{ref:_,class:`web-sidebar${r?` is-drawer`:``}`,style:r?void 0:{width:`${e}px`},"aria-label":m(`app.web.sidebar.label`),children:[l(`h2`,{class:`web-sidebar__heading type-section-heading`,children:m(`app.web.sidebar.actions`)}),l(`nav`,{class:`web-sidebar__actions`,"aria-label":m(`app.web.sidebar.actions`),children:si.map(e=>{let t=!!p&&p.actions.includes(e.action),n=countOf(e,p);return l(`button`,{type:`button`,class:`web-action type-body`,disabled:!t,title:t?void 0:m(`app.web.sidebar.unavailable`),"data-action":e.id,onClick:()=>{s(e.action)&&r&&i()},children:[l(Icon,{name:e.icon,className:`web-action__icon`}),l(`span`,{class:`web-action__label`,children:e.label()}),n&&l(`span`,{class:`web-action__count type-help${n.error?` is-error`:``}`,title:n.title,"aria-label":n.title,children:n.text})]},e.id)})}),l(`section`,{class:`web-sidebar__project`,children:f}),g&&l(`div`,{ref:v,class:`web-sidebar__chats${b===null?``:` is-sized`}`,style:b===null?void 0:{flexBasis:`${b}px`},children:[S&&l(`div`,{class:`web-sidebar__chats-sash`,role:`separator`,"aria-orientation":`horizontal`,"aria-label":m(`app.web.sidebar.resizeChats`),tabIndex:0,onPointerDown:e=>{e.preventDefault(),y.current={y:e.clientY,height:current(),available:available()},e.currentTarget.setPointerCapture?.(e.pointerId)},onPointerMove:e=>{let t=y.current;t&&resize(t.height-(e.clientY-t.y),!1,t.available)},onPointerUp:e=>{let t=y.current;y.current=null,t&&resize(t.height-(e.clientY-t.y),!0,t.available)},onDblClick:()=>resize(null,!0),onKeyDown:e=>{if(e.key===`ArrowUp`)resize(current()+16,!0);else if(e.key===`ArrowDown`)resize(current()-16,!0);else if(e.key===`Home`)resize(null,!0);else return;e.preventDefault()}}),l(ChatsSection,{store:g,editor:u,onOpen:r?i:void 0,onOpenFile:c})]}),!r&&l(`div`,{class:`web-sidebar__sash`,role:`separator`,"aria-orientation":`vertical`,"aria-label":m(`app.web.sidebar.resize`),"aria-valuemin":240,"aria-valuemax":400,"aria-valuenow":e,tabIndex:0,onPointerDown:t=>{t.preventDefault(),h.current={x:t.clientX,width:e},t.currentTarget.setPointerCapture?.(t.pointerId)},onPointerMove:e=>{h.current&&n(clampSidebar(h.current.width+e.clientX-h.current.x))},onPointerUp:()=>{h.current=null},onKeyDown:t=>{if(t.key===`ArrowLeft`)n(clampSidebar(e-oi));else if(t.key===`ArrowRight`)n(clampSidebar(e+oi));else return;t.preventDefault()}})]})]})}function relOf(e){return e.kind===`file`?e.file.rel:e.rel}function parentOf(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}function nameOf(e){return e.slice(e.lastIndexOf(`/`)+1)}function insideFolder(e,t){return e===t||e.startsWith(`${t}/`)}function canMoveInto(e,t){let n=relOf(e);return!(parentOf(n)===t||e.kind===`folder`&&insideFolder(t,n))}var EntryOps=class{store;host;constructor(e,t){this.store=e,this.host=t}async fresh(){await this.store.refresh(),await this.store.refresh()}openIn(e){let t=this.store.snapshot(),n=t.order.map(e=>t.docs.get(e)).filter(e=>!!e);return e.kind===`file`?n.filter(t=>t.path===e.file.path):n.filter(t=>t.rel.startsWith(`${e.rel}/`))}unsavedIn(e){return this.openIn(e).filter(e=>Ue(e))}async park(e){let t=this.openIn(e);for(let e of t)if(Ue(this.store.doc(e.path))&&!await this.store.save(e.path))throw Error(this.store.doc(e.path)?.saveError??e.name);let n=this.store.snapshot().active;for(let e of t)this.store.close(e.path);return{docs:t,active:n}}async restore(e,t){let n=[...e.docs].sort((t,n)=>Number(t.path===e.active)-Number(n.path===e.active));for(let e of n)await this.store.open(t(e),e.kind)}async change(e,t,n){let r=await this.park(e),i;try{i=await t()}catch(e){throw await this.restore(r,e=>e.path),e}await this.fresh();let a=this.store.snapshot().listing.root,o=relOf(e),s=n(i);return await this.restore(r,t=>e.kind===`file`?Re(a,s):Re(a,`${s}${t.rel.slice(o.length)}`)),s}async rename(e,t){let n=relOf(e),r=parentOf(n);return this.change(e,()=>this.host.rename(n,t,null),()=>r===``?t:`${r}/${t}`)}async move(e,t){let n=relOf(e),r=nameOf(n);return this.change(e,()=>this.host.move(n,t,null),()=>t===``?r:`${t}/${r}`)}async duplicate(e){let t=await this.host.duplicate(e.rel);return await this.fresh(),t}async remove(e){await this.fresh();let t=relOf(e),n=e.kind===`file`?this.store.snapshot().listing.files.find(e=>e.rel===t)?.stamp??null:null;await this.host.remove(t,n);for(let t of this.openIn(e))this.store.close(t.path);await this.fresh()}async createFolder(e){await this.host.createFolder(e),await this.fresh()}},ci=/[\\/\0-\u001f:*?"<>|]/;function nameFault(e){return e.trim()===``?m(`app.web.entry.nameEmpty`):ci.test(e)?m(`app.web.entry.nameCharacters`):e===`.`||e===`..`||/[. ]$/.test(e)||/^ /.test(e)?m(`app.web.entry.nameEnds`):null}function messageFrom$1(e){return e instanceof Error&&e.message?e.message:m(`app.web.unknownFailure`)}e(messageFrom$1,`messageFrom`);function NewFolderDialog({parent:e,onCreate:n,onClose:r}){let[i,a]=t(``),[o,s]=t(!1),[c,u]=t(null),d=Ee(),f=nameFault(i),create=async()=>{if(d.submit(),f)requestAnimationFrame(()=>document.querySelector(`.ui-dialog [aria-invalid="true"]`)?.focus());else{s(!0),u(null);try{await n(e===``?i:`${e}/${i}`),r()}catch(e){u(messageFrom$1(e)),s(!1)}}};return l(q,{title:m(`app.web.entry.newFolderTitle`),size:`small`,onClose:r,onSubmit:()=>void create(),footer:l(Y,{actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:r,disabled:o},{id:`create`,label:m(`app.web.entry.createFolder`),role:`primary`,onClick:()=>void create(),busy:o}]}),children:[l(we,{label:m(`app.web.entry.name`),hint:e===``?m(`app.web.entry.insideProject`):m(`app.web.entry.inside`,{folder:e}),error:d.errorOf(`name`,f),children:e=>l(`input`,{...e,value:i,spellcheck:!1,autocomplete:`off`,onInput:e=>a(e.target.value),onBlur:()=>d.touch(`name`)})}),c&&l(ke,{children:c})]})}function RenameDialog({target:e,onRename:n,onClose:r}){let i=e.kind===`file`?e.file.name:e.name,[a,o]=t(i),[s,c]=t(!1),[u,d]=t(null),f=Ee(),p=nameFault(a),rename=async()=>{if(f.submit(),p)requestAnimationFrame(()=>document.querySelector(`.ui-dialog [aria-invalid="true"]`)?.focus());else if(a===i)r();else{c(!0),d(null);try{await n(a),r()}catch(e){d(messageFrom$1(e)),c(!1)}}};return l(q,{title:m(`app.web.entry.renameTitle`,{name:i}),size:`small`,onClose:r,onSubmit:()=>void rename(),footer:l(Y,{actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:r,disabled:s},{id:`rename`,label:m(`app.web.entry.rename`),role:`primary`,onClick:()=>void rename(),busy:s}]}),children:[l(we,{label:m(`app.web.entry.renameLabel`),error:f.errorOf(`name`,p),children:t=>l(`input`,{...t,value:a,spellcheck:!1,autocomplete:`off`,ref:t=>{if(t&&!t.dataset.selected){t.dataset.selected=`yes`;let n=i.lastIndexOf(`.`);t.setSelectionRange(0,n>0&&e.kind===`file`?n:i.length)}},onInput:e=>o(e.target.value),onBlur:()=>f.touch(`name`)})}),u&&l(ke,{children:u})]})}function DeleteDialog({target:e,files:n,unsaved:r,onDelete:i,onClose:a}){let[o,s]=t(!1),[c,u]=t(null),d=e.kind===`file`?e.file.name:e.name,f=e.kind===`folder`,run=async()=>{s(!0),u(null);try{await i(),a()}catch(e){u(messageFrom$1(e)),s(!1)}};return l(q,{title:m(f?`app.web.entry.deleteFolderTitle`:`app.web.entry.deleteFileTitle`,{name:d}),size:`small`,destructive:!0,onClose:a,footer:l(Y,{actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:a,disabled:o},{id:`delete`,label:m(f?`app.web.entry.deleteFolder`:`app.web.entry.deleteFile`),role:`primary`,onClick:()=>void run(),busy:o}]}),children:[l(`p`,{class:`web-dialog-text type-body`,children:f?m(`app.web.entry.deleteFolderText`,{name:d,count:n}):m(`app.web.entry.deleteFileText`,{name:d})}),r>0&&l(`p`,{class:`web-dialog-text type-body`,children:m(`app.web.entry.deleteUnsaved`,{count:r})}),c&&l(ke,{children:c})]})}function MoveDialog({target:e,folders:n,onMove:r,onClose:i}){let a=[``,...n].filter(t=>canMoveInto(e,t)),[o,s]=t(a[0]??``),[c,u]=t(!1),[d,f]=t(null),p=e.kind===`file`?e.file.name:nameOf(e.rel),run=async()=>{u(!0),f(null);try{await r(o),i()}catch(e){f(messageFrom$1(e)),u(!1)}};return l(q,{title:m(`app.web.entry.moveTitle`,{name:p}),size:`small`,onClose:i,onSubmit:()=>void run(),footer:l(Y,{actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:i,disabled:c},{id:`move`,label:m(`app.web.entry.move`),role:`primary`,onClick:()=>void run(),busy:c,disabled:a.length===0}]}),children:[a.length===0?l(`p`,{class:`web-dialog-text type-body`,children:m(`app.web.entry.noFolders`)}):l(we,{label:m(`app.web.entry.moveTo`),children:e=>l(`select`,{...e,value:o,onChange:e=>s(e.target.value),children:a.map(e=>l(`option`,{value:e,children:e===``?m(`app.web.entry.projectFolder`):e},e))})}),d&&l(ke,{children:d})]})}var li=i(null);function useProject(){return r(li)}function targetOfNode(e,t){if(!e.path)return null;if(e.id.startsWith(`file:`)){let n=Be(e.path),r=t.files.find(e=>e.path===n)??t.files.find(e=>e.rel===He(t.root,n));return r?{kind:`file`,file:r}:null}if(e.id.startsWith(`folder:`)){let n=He(t.root,e.path);return n===``?null:{kind:`folder`,rel:n,name:n.slice(n.lastIndexOf(`/`)+1)}}return null}function copyText(e){let t=navigator.clipboard?.writeText?.(e);t?t.then(()=>H.info(m(`app.web.entry.copied`)),()=>H.error(m(`app.web.tree.copyFailed`))):H.error(m(`app.web.tree.copyFailed`))}function useEntryActions(e){let n=useProject(),r=c(()=>n?new EntryOps(n.store,n.entries):null,[n]),[i,o]=t(null),[s,u]=t(null),[d,f]=t(null),[p,h]=t(null);return c(()=>{if(!n||!r)return null;let listing=()=>n.store.snapshot().listing,report=e=>H.error(messageFrom$1(e)),run=e=>void e.catch(report),revealRel=t=>e(Re(listing().root,t)),pathOf=(e,t)=>{let n=e.kind===`file`?e.file.rel:e.rel;return t?n:Re(listing().root,n)},targetOf=e=>targetOfNode(e,listing()),itemsFor=t=>{let i=targetOf(t);if(!i)return[];let a=[];return i.kind===`folder`&&(a.push({id:`new-file`,label:m(`app.web.tree.newFile`),run:()=>n.newFile(i.rel)}),a.push({id:`new-folder`,label:m(`app.web.entry.newFolder`),run:()=>u(i.rel)})),a.push({id:`rename`,label:m(`app.web.entry.rename`),shortcut:`F2`,separated:a.length>0,run:()=>o(i)}),i.kind===`file`&&a.push({id:`duplicate`,label:m(`app.web.entry.duplicate`),run:()=>run(r.duplicate(i.file).then(t=>e(t)))}),a.push({id:`move`,label:m(`app.web.entry.moveAction`),run:()=>h(i)}),a.push({id:`delete`,label:m(`app.web.entry.delete`),shortcut:`Del`,danger:!0,run:()=>f(i)}),a.push({id:`copy-path`,label:m(`app.web.entry.copyPath`),separated:!0,run:()=>copyText(pathOf(i,!1))}),a.push({id:`copy-relative`,label:m(`app.web.entry.copyRelative`),run:()=>copyText(pathOf(i,!0))}),i.kind===`file`&&a.push({id:`download`,label:m(`app.web.entry.download`),run:()=>n.downloadFile(i.file)}),a},backgroundItems=()=>[{id:`new-file`,label:m(`app.web.tree.newFile`),run:()=>n.newFile(``)},{id:`new-folder`,label:m(`app.web.entry.newFolder`),run:()=>u(``)},{id:`refresh`,label:m(`app.web.tree.refresh`),separated:!0,run:()=>run(n.store.refresh())}],headerItems=e=>{let t=e?listing().files.find(t=>t.path===e):void 0;return[{id:`new-folder`,label:m(`app.web.entry.newFolder`),run:()=>u(``)},{id:`upload`,label:m(`app.web.upload.button`),run:n.upload},{id:`download-file`,label:m(`app.web.entry.downloadActive`),disabled:!t,run:()=>t&&n.downloadFile(t)},{id:`download-project`,label:m(`app.web.project.downloadZip`),run:n.downloadArchive},{id:`refresh`,label:m(`app.web.tree.refresh`),separated:!0,run:()=>run(n.store.refresh())}]},dropFolderOf=e=>{let t=targetOf(e);return t?t.kind===`folder`?t.rel:parentOf(t.file.rel):null},drop=(e,t)=>{let n=e.kind===`file`?e.file.name:e.name;r.move(e,t).then(revealRel,e=>H.error(m(`app.web.entry.moveFailed`,{name:n,reason:messageFrom$1(e)})))},t=listing().files;return{targetOf,itemsFor,backgroundItems,headerItems,dropFolderOf,canDrop:canMoveInto,drop,newFile:()=>n.newFile(``),dialogs:i||s!==null||d||p?l(a,{children:[i&&l(RenameDialog,{target:i,onRename:async e=>{revealRel(await r.rename(i,e))},onClose:()=>o(null)}),s!==null&&l(NewFolderDialog,{parent:s,onCreate:async e=>{await r.createFolder(e),revealRel(e)},onClose:()=>u(null)}),d&&l(DeleteDialog,{target:d,files:d.kind===`folder`?t.filter(e=>e.rel.startsWith(`${d.rel}/`)).length:1,unsaved:r.unsavedIn(d).length,onDelete:()=>r.remove(d),onClose:()=>f(null)}),p&&l(MoveDialog,{target:p,folders:listing().folders,onMove:async e=>{revealRel(await r.move(p,e))},onClose:()=>h(null)})]}):null}},[n,r,i,s,d,p,e])}function DraftNotice({count:e,busy:t,onRestore:n,onDiscard:r}){return l(`div`,{class:`web-shell__notice web-pane__banner is-warning`,role:`region`,"aria-label":m(`app.web.drafts.label`),children:[l(Icon$1,{name:`alert`}),l(`span`,{class:`web-pane__banner-text type-body`,children:m(`app.web.drafts.found`,{count:e})}),l(`button`,{type:`button`,class:`ui-button ui-button--primary type-button`,disabled:t,onClick:n,children:m(`app.web.drafts.restore`)}),l(`button`,{type:`button`,class:`ui-button type-button`,disabled:t,onClick:r,children:m(`app.web.drafts.discard`)})]})}function SessionEnded({onRetry:e}){return l(q,{title:m(`app.web.expired.title`),size:`small`,backdrop:`keep`,onClose:e,onSubmit:e,footer:l(Y,{actions:[{id:`retry`,label:m(`app.web.expired.retry`),role:`primary`,onClick:e}]}),children:[l(`p`,{class:`type-body web-dialog-text`,children:m(`app.web.expired.text`)}),l(`p`,{class:`type-help web-dialog-text`,children:m(`app.web.expired.hint`)})]})}function Welcome$1({recent:e,onOpen:t,onQuickOpen:n,onNew:r,quickKeys:i,empty:a}){return l(`div`,{class:`web-welcome`,children:[l(`p`,{class:`ui-empty__title type-body`,children:m(a?`app.web.tree.empty`:`app.web.empty.title`)}),l(`p`,{class:`ui-empty__hint type-help`,children:m(a?`app.web.tree.emptyHint`:`app.web.empty.hint`)}),l(`div`,{class:`ui-empty__actions`,children:[!a&&l(`button`,{type:`button`,class:`ui-button type-button`,onClick:n,children:i?`${m(`app.web.command.quickOpen`)} (${i})`:m(`app.web.command.quickOpen`)}),l(`button`,{type:`button`,class:`ui-button type-button`,onClick:r,children:m(`app.web.tree.newFile`)})]}),e.length>0&&l(`section`,{class:`web-welcome__recent`,"aria-label":m(`app.web.quick.recent`),children:[l(`h3`,{class:`web-welcome__heading type-section-heading`,children:m(`app.web.quick.recent`)}),l(`ul`,{class:`web-welcome__list`,children:e.map(e=>l(`li`,{children:l(`button`,{type:`button`,class:`web-welcome__file type-body`,title:e.rel,onClick:()=>t(e.rel),children:[l(`span`,{class:`web-welcome__name`,children:e.name}),l(`span`,{class:`web-welcome__where type-help`,children:e.rel.includes(`/`)?e.rel.slice(0,e.rel.lastIndexOf(`/`)):``})]})},e.rel))})]})]})}e(Welcome$1,`Welcome`);var ui=[{id:`process`,kinds:[`bpmn`]},{id:`decision`,kinds:[`dmn`]},{id:`form`,kinds:[`form`]},{id:`testCase`,kinds:[`testCase`]},{id:`template`,kinds:[`template`]}];function groupOfKind(e){return ui.find(t=>t.kinds.includes(e))?.id??`process`}var di=8;function placeMenu(e,t,n){let r=Math.max(di,Math.min(e.x,n.width-t.width-di)),i=e.y+t.height+di>n.height?Math.max(di,e.y-t.height):e.y;return{left:r,top:Math.max(di,Math.min(i,n.height-t.height-di))}}function nextEnabled(e,t,n){if(e.every(e=>e.disabled))return-1;let r=t;for(let t=0;t<e.length;t+=1)if(r=(r+n+e.length)%e.length,!e[r].disabled)return r;return-1}function Menu({items:e,label:n,at:r,onClose:i,returnFocusTo:a}){let s=o(null),[c,d]=t(null),[p,m]=t(()=>nextEnabled(e,-1,1)),h=o(i);h.current=i,u(()=>{let e=s.current;e&&d(placeMenu(r,{width:e.offsetWidth,height:e.offsetHeight},{width:window.innerWidth,height:window.innerHeight}))},[r.x,r.y,e.length]),f(()=>{let away=e=>{e.target instanceof Node&&!s.current?.contains(e.target)&&h.current()},blur=()=>h.current();return document.addEventListener(`pointerdown`,away,!0),window.addEventListener(`blur`,blur),window.addEventListener(`resize`,blur),()=>{document.removeEventListener(`pointerdown`,away,!0),window.removeEventListener(`blur`,blur),window.removeEventListener(`resize`,blur);let e=document.activeElement;(e===document.body||e===null||s.current?.contains(e))&&a?.isConnected&&a.focus()}},[]),f(()=>{c&&s.current?.querySelector(`[data-index="${p}"]`)?.focus()},[p,c!==null]);let choose=e=>{e.disabled||(h.current(),setTimeout(e.run,0))},onKeyDown=t=>{t.key===`Escape`?(t.preventDefault(),t.stopPropagation(),h.current()):t.key===`ArrowDown`?(t.preventDefault(),m(t=>nextEnabled(e,t,1))):t.key===`ArrowUp`?(t.preventDefault(),m(t=>nextEnabled(e,t,-1))):t.key===`Home`?(t.preventDefault(),m(nextEnabled(e,-1,1))):t.key===`End`?(t.preventDefault(),m(nextEnabled(e,0,-1))):t.key===`Tab`&&(t.preventDefault(),h.current())};return l(`div`,{ref:s,class:`web-menu`,role:`menu`,"aria-label":n,style:{left:`${c?.left??r.x}px`,top:`${c?.top??r.y}px`,visibility:c?`visible`:`hidden`},onKeyDown,onContextMenu:e=>e.preventDefault(),children:e.map((e,t)=>l(`div`,{role:`none`,children:[e.separatorBefore&&l(`div`,{class:`web-menu__separator`,role:`separator`}),l(`button`,{type:`button`,role:e.marked===void 0?`menuitem`:`menuitemradio`,"aria-checked":e.marked===void 0?void 0:e.marked,class:`web-menu__item type-body`,"data-index":t,tabIndex:t===p?0:-1,disabled:e.disabled,onMouseMove:()=>!e.disabled&&m(t),onClick:()=>choose(e),children:[l(`span`,{class:`web-menu__label`,children:e.label}),e.keys&&l(`span`,{class:`web-menu__keys type-help`,children:e.keys})]})]},e.id))})}function tabLabels(e){let t=new Map;e.forEach(e=>t.set(e.name,(t.get(e.name)??0)+1));let n=new Map;return e.forEach(e=>{let r=e.rel.lastIndexOf(`/`),i=(r<0?``:e.rel.slice(0,r)).split(`/`).pop()??``;n.set(e.path,{name:e.name,where:(t.get(e.name)??0)>1?i:``})}),n}function scriptTabItems(e){return e.map(e=>({id:scriptPanel(e.id),label:e.title,where:``,icon:`script`,title:e.title,tabId:domId(`web-tab`,e.id),controls:domId(`web-pane`,e.id),dirty:!1,saving:!1,failed:!1,problem:e.conflict!==null,closeLabel:m(`app.web.tabs.close`,{name:e.title}),closeTitle:m(`app.web.tabs.close`,{name:e.title}),unsavedLabel:e.title,closable:!0}))}function docTabs(e,t){let n=tabLabels(e);return e.map(e=>({id:docPanel(e.path),label:n.get(e.path)?.name??e.name,where:n.get(e.path)?.where??``,icon:iconOfKind(e.kind,groupOfKind(e.kind)),title:Ue(e)?m(`app.web.tabs.unsaved`,{name:e.rel}):e.rel,tabId:domId(`web-tab`,e.path),controls:domId(`web-pane`,e.path),dirty:Ue(e),saving:e.saving,failed:!!e.saveError,problem:e.disk!==`in-sync`||!!e.saveError,closeLabel:m(`app.web.tabs.close`,{name:e.name}),closeTitle:rt(m(`app.web.tabs.close`,{name:e.name}),`closeTab`,t),unsavedLabel:m(`app.web.tabs.unsaved`,{name:e.name}),closable:!0}))}function dropIndex(e,t,n){let r=n===`before`?t:t+1;return e<r?r-1:r}function domId(e,t){let n=2166136261;for(let e=0;e<t.length;e+=1)n=Math.imul(n^t.charCodeAt(e),16777619)>>>0;return`${e}-${n.toString(36)}`}function TabStrip({tabs:e,active:n,onSelect:r,onClose:i,onDropTab:a,menuFor:s,menuLabel:c,leading:u,trailing:d}){let p=o(null),[h,g]=t(null),[_,v]=t(null),[y,b]=t(!1),[x,S]=t(null);f(()=>{(p.current?.querySelector(`[aria-selected="true"]`))?.scrollIntoView?.({block:`nearest`,inline:`nearest`})},[n,e.length]),f(()=>{let e=p.current;if(!e)return;let measure=()=>b(e.scrollWidth>e.clientWidth+1);if(measure(),typeof ResizeObserver>`u`)return;let t=new ResizeObserver(measure);return t.observe(e),()=>t.disconnect()},[e.length]);let focusTab=e=>requestAnimationFrame(()=>p.current?.querySelector(`[data-panel="${CSS.escape(e)}"]`)?.focus()),openMenu=(t,n,r)=>{let i=s?.(t)??[];i.length>0&&g({items:i,at:n,label:c?.(t)??m(`app.web.tabs.menu`,{name:e.find(e=>e.id===t)?.label??``}),opener:r})},openList=t=>{let i=t.getBoundingClientRect();g({items:e.map(e=>({id:e.id,label:`${e.dirty?`● `:``}${e.label}${e.where?` ${e.where}`:``}`,marked:e.id===n,run:()=>{r(e.id),focusTab(e.id)}})),at:{x:i.right-240,y:i.bottom+4},label:m(`app.web.tabs.all`),opener:t})},move=(t,n)=>{let o=e.length-1;if(t.key===`ContextMenu`||t.shiftKey&&t.key===`F10`){t.preventDefault();let r=t.currentTarget.getBoundingClientRect();openMenu(e[n].id,{x:r.left,y:r.bottom},t.currentTarget);return}if(t.altKey&&t.shiftKey&&(t.key===`ArrowLeft`||t.key===`ArrowRight`)){t.preventDefault(),a?.(e[n].id,t.key===`ArrowLeft`?n-1:n+1),focusTab(e[n].id);return}let s=-1;if(t.key===`ArrowRight`)s=n===o?0:n+1;else if(t.key===`ArrowLeft`)s=n===0?o:n-1;else if(t.key===`Home`)s=0;else if(t.key===`End`)s=o;else if(t.key===`Delete`&&e[n].closable){t.preventDefault(),i(e[n].id);return}else return;t.preventDefault();let c=e[s];c&&(r(c.id),focusTab(c.id))},finish=()=>{S(null),v(null),endDrag()},dropOn=t=>{let n=dragging(),r=_;if(t.preventDefault(),t.stopPropagation(),finish(),!n||!a)return;if(!r){a(n,e.length);return}let i=e.findIndex(e=>e.id===r.id);if(i<0)return;let o=e.findIndex(e=>e.id===n);a(n,o>=0?dropIndex(o,i,r.side):r.side===`before`?i:i+1)};return l(`div`,{class:`web-tabs`,children:[u,l(`div`,{ref:p,class:`web-tabs__list`,role:`tablist`,"aria-label":m(`app.web.tabs.label`),onDragOver:t=>{dragging()&&a&&(t.preventDefault(),t.stopPropagation(),t.target===t.currentTarget&&e.length>0&&v({id:e[e.length-1].id,side:`after`}))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||v(null)},onDrop:dropOn,children:e.map((e,t)=>{let o=e.id===n,c=_?.id===e.id?` is-drop-${_.side}`:``;return l(`div`,{class:`web-tabs__tab${o?` is-selected`:``}${e.problem?` has-problem`:``}${x===e.id?` is-dragging`:``}${c}`,draggable:!!a,onDragStart:t=>{beginDrag(e.id,t),S(e.id)},onDragOver:t=>{if(!dragging()||!a)return;t.preventDefault(),t.stopPropagation();let n=t.currentTarget.getBoundingClientRect(),r=t.clientX<n.left+n.width/2?`before`:`after`;(_?.id!==e.id||_.side!==r)&&v({id:e.id,side:r})},onDragEnd:finish,onContextMenu:t=>{s&&(t.preventDefault(),openMenu(e.id,{x:t.clientX,y:t.clientY},t.currentTarget))},children:[l(`button`,{type:`button`,role:`tab`,id:e.tabId,class:`web-tabs__select type-chrome`,"data-panel":e.id,"aria-selected":o,"aria-controls":e.controls,tabIndex:o?0:-1,title:e.title,onClick:()=>r(e.id),onAuxClick:t=>{t.button===1&&e.closable&&(t.preventDefault(),i(e.id))},onMouseDown:e=>{e.button===1&&e.preventDefault()},onKeyDown:e=>move(e,t),children:[l(Icon$1,{class:`web-tabs__icon`,name:e.icon}),l(`span`,{class:`web-tabs__name`,children:e.label}),e.where&&l(`span`,{class:`web-tabs__where type-chrome-small`,children:e.where})]}),e.saving&&l(`span`,{class:`web-tabs__saving`,role:`img`,"aria-label":m(`app.web.state.saving`),title:m(`app.web.state.saving`)}),!e.saving&&e.failed&&l(Icon$1,{class:`web-tabs__failed`,name:`alert`}),e.dirty&&!e.saving&&l(`span`,{class:`web-tabs__dot`,role:`img`,"aria-label":e.unsavedLabel}),e.closable&&l(`button`,{type:`button`,class:`web-tabs__close`,tabIndex:-1,"aria-label":e.closeLabel,title:e.closeTitle,onClick:()=>i(e.id),children:l(Icon$1,{name:`close`})})]},e.id)})}),y&&l(`button`,{type:`button`,class:`web-tabs__all`,"aria-haspopup":`menu`,"aria-label":m(`app.web.tabs.all`),title:m(`app.web.tabs.all`),onClick:e=>openList(e.currentTarget),children:l(Icon$1,{name:`list`})}),d,h&&l(Menu,{items:h.items,at:h.at,label:h.label,returnFocusTo:h.opener,onClose:()=>g(null)})]})}function handleFor(e,t,n,r,i){return{path:t,get rel(){return e.doc(t)?.rel??t},name:r,kind:n,scriptTabs:i,get initialText(){return e.doc(t)?.current??``},edit:n=>e.edit(t,n),onReload:n=>e.subscribeReload(t,n),save:()=>void e.save(t)}}function LazyEditor({doc:e,loaders:n,handle:r}){let i=Q(e.kind),[a,o]=t(null),[s,c]=t(null),[u,d]=t(0);if(f(()=>{let e=!0;return c(null),n[i]().then(t=>e&&o({component:t}),t=>e&&c(t instanceof Error?t.message:String(t))),()=>{e=!1}},[i,u]),s!==null)return l(De,{title:m(`app.web.pane.editorFailed`),hint:s||m(`app.web.pane.editorFailedHint`),actions:[{label:m(`app.common.retry`),run:()=>d(e=>e+1)}]});if(!a)return l(`p`,{class:`web-pane__status type-help`,role:`status`,children:m(`app.web.pane.loadingEditor`)});let p=a.component;return l(p,{handle:r})}function bannerFor(e,t,n,r){return e.disk===`deleted`?{tone:`error`,text:m(`app.web.banner.deleted`,{name:e.name}),actions:[{label:m(`app.common.save`),run:()=>void t.save(e.path)},{label:m(`app.web.banner.closeTab`),run:n}]}:e.disk===`changed`?{tone:`warning`,text:m(`app.web.banner.changed`,{name:e.name}),actions:[...r&&e.diskText!==null?[{label:m(`app.web.banner.compare`),run:r}]:[],{label:m(`app.web.banner.reload`),run:()=>t.reloadFromDisk(e.path)},{label:m(`app.web.banner.keep`),run:()=>t.keepMine(e.path)}]}:e.saveError?{tone:`error`,text:m(`app.web.banner.saveFailed`,{reason:e.saveError}),actions:[{label:m(`app.common.retry`),run:()=>void t.save(e.path)}]}:null}function DocumentPane({store:e,scripts:n,doc:r,shown:i,focused:a,loaders:s,onClose:u,onCompare:d}){let p=c(()=>handleFor(e,r.path,r.kind,r.name,n.documentScripts(r.path)),[e,n,r.path]),[h,g]=t(0),[_,v]=t(i),y=o(null),b=r.phase===`ready`?bannerFor(r,e,u,d):null;return f(()=>{i&&!_&&v(!0)},[i]),f(()=>{let e=y.current;e&&(e.inert=!i)},[i]),l(`div`,{ref:y,id:domId(`web-pane`,r.path),class:`web-pane`,role:`tabpanel`,"aria-labelledby":domId(`web-tab`,r.path),"data-path":r.path,"data-active":i?`true`:`false`,"data-focused":a?`true`:`false`,"aria-hidden":!i||void 0,children:[b&&l(`div`,{class:`web-pane__banner is-${b.tone}`,role:`alert`,children:[l(`span`,{class:`web-pane__banner-text type-body`,children:b.text}),b.actions.map(e=>l(`button`,{type:`button`,class:`ui-button type-button`,onClick:e.run,children:e.label},e.label))]}),l(`div`,{class:`web-pane__body`,children:[r.phase===`loading`&&l(`p`,{class:`web-pane__status type-help`,role:`status`,children:m(`app.web.pane.opening`,{name:r.name})}),r.phase===`failed`&&l(De,{title:m(`app.web.pane.failed`,{name:r.name}),hint:r.loadError??void 0,actions:[{label:m(`app.common.retry`),run:()=>void e.open(r.path)},{label:m(`app.web.banner.closeTab`),run:u}]}),r.phase===`ready`&&_&&l(be,{onReload:()=>g(e=>e+1),children:l(Cr,{value:i&&a,children:l(LazyEditor,{doc:r,loaders:s,handle:p})})},h)]})]})}function LazyScriptPane(e){let[n,r]=t(null);return f(()=>{let e=!0;return y(()=>import(`./ScriptPane-DDikZDv6.js`).then(t=>e&&r(()=>t.ScriptPane)),__vite__mapDeps([64,1,2,3,4,6,7,8,9,10,11,13,5,14,15,22,18,23,25,35,24,42,19,58]),import.meta.url),()=>{e=!1}},[]),n?l(n,{...e}):null}var fi=`UTF-8`;function saveStateOf(e){return!e||e.phase!==`ready`?`none`:e.saving?`saving`:e.disk===`changed`?`conflict`:e.disk===`deleted`?`deleted`:e.saveError?`failed`:Ue(e)?`unsaved`:`saved`}function lineEnding(e){let t=(e.match(/\r\n/g)??[]).length;return t>(e.match(/\n/g)??[]).length-t?`CRLF`:`LF`}function saveText(e,t){switch(e){case`saving`:return m(`app.web.state.saving`);case`unsaved`:return t?m(`app.web.state.unsavedAuto`,{seconds:t}):m(`app.web.state.unsaved`);case`failed`:return m(`app.web.state.failed`);case`conflict`:return m(`app.web.state.conflict`);case`deleted`:return m(`app.web.state.deleted`);case`saved`:return m(`app.web.state.saved`);default:return``}}function StatusBar({engine:e,licence:t,connection:n,doc:r,autosave:i,mac:a,onRetry:o,onShortcuts:s,onLicence:c}){let u=saveStateOf(r),d=n===`ok`;return l(`footer`,{class:`web-status`,"aria-label":m(`app.web.status.label`),children:[l(`span`,{class:`web-status__item web-status__connection type-chrome-small${d?``:` is-offline`}`,children:[l(`span`,{class:`web-status__dot`,"aria-hidden":`true`}),l(`span`,{role:`status`,children:m(d?`app.web.status.connected`:n===`denied`?`app.web.status.expired`:`app.web.status.offline`)}),!d&&n===`lost`&&l(`button`,{type:`button`,class:`web-status__link type-link`,onClick:o,children:m(`app.common.retry`)})]}),l(`span`,{class:`web-status__item web-status__item--saved type-chrome-small`,role:`status`,"aria-live":`polite`,"data-state":u,children:saveText(u,i)}),l(`span`,{class:`web-status__spacer`}),e&&l(`span`,{class:`web-status__item web-status__item--engine type-chrome-small`,title:m(`app.web.status.engine`),children:e}),t&&l(`button`,{type:`button`,class:`web-status__item web-status__licence type-chrome-small`,title:m(`app.web.status.licence`),onClick:c,children:t}),r&&r.phase===`ready`&&l(`span`,{class:`web-status__item web-status__item--detail type-chrome-small`,title:m(`app.web.status.encoding`),children:`${fi} · ${lineEnding(r.current)}`}),l(`button`,{type:`button`,class:`web-status__tool`,"aria-label":m(`app.web.shortcuts.open`),title:rt(m(`app.web.shortcuts.open`),`shortcuts`,a),onClick:s,children:l(Icon$1,{name:`keyboard`})})]})}function useSession(e){let[,n]=t(0),r=e.snapshot();return f(()=>{let t=e.subscribe(()=>n(e=>e+1));return e.snapshot()!==r&&n(e=>e+1),t},[e]),r}function ProjectSwitcher({name:e,fallback:t=null}){let n=useProject();return n?l(Switcher,{project:n,name:e}):t}function Switcher({project:e,name:n}){let[r,i]=t(null),[o,s]=t(!1),c=useSession(e.session);f(()=>{o&&e.session.loadRecent().catch(()=>void 0)},[o]);let u=c.project.folder??null,d=(c.recent??[]).filter(e=>e.folder!==u).slice(0,8),close=()=>s(!1);return l(a,{children:[l(`button`,{type:`button`,ref:i,class:`web-switcher type-chrome-title`,"aria-haspopup":`dialog`,"aria-expanded":o,title:u??n,onClick:()=>s(e=>!e),children:[l(`span`,{class:`web-switcher__name`,children:n}),l(Icon$1,{class:`web-switcher__chevron`,name:`chevron`})]}),o&&l(xe,{anchor:r,label:m(`app.web.project.switcher`),onClose:close,width:296,class:`web-switcher__popover`,children:[l(`div`,{class:`web-switcher__current`,children:[l(`span`,{class:`web-switcher__current-name type-body`,children:n}),u&&l(`span`,{class:`web-switcher__current-folder type-help`,children:u})]}),d.length>0&&l(a,{children:[l(`p`,{class:`web-switcher__heading type-section-heading`,children:m(`app.web.project.recent`)}),l(`ul`,{class:`web-switcher__list`,children:d.map(t=>l(`li`,{children:l(`button`,{type:`button`,class:`web-switcher__item type-body`,disabled:!t.present,title:t.present?t.folder:m(`app.web.welcome.missing`,{folder:t.folder}),onClick:()=>{close(),e.switchTo(t.folder)},children:[l(Icon$1,{name:`process`}),l(`span`,{class:`web-switcher__item-name`,children:t.name})]})},t.folder))})]}),l(`div`,{class:`web-switcher__actions`,children:[l(`button`,{type:`button`,class:`web-switcher__item type-body`,onClick:()=>{close(),e.browse()},children:[l(Icon$1,{name:`folder`}),l(`span`,{class:`web-switcher__item-name`,children:m(`app.web.project.openAnother`)})]}),l(`button`,{type:`button`,class:`web-switcher__item type-body`,onClick:()=>{close(),e.closeProject()},children:[l(Icon$1,{name:`close`}),l(`span`,{class:`web-switcher__item-name`,children:m(`app.web.project.close`)})]})]})]})]})}function TitleBar({project:e,file:t,dirty:n,onSettings:r,onSearch:i,searchKeys:a,onToggleSidebar:o,sidebarKeys:s}){return l(`header`,{class:`web-title`,"aria-label":m(`app.web.titleBar.label`),children:[l(`div`,{class:`web-title__brand type-chrome-title`,children:[l(`button`,{type:`button`,class:`web-title__tool`,"aria-label":m(`app.web.sidebar.toggle`),title:s?`${m(`app.web.sidebar.toggle`)} (${s})`:m(`app.web.sidebar.toggle`),onClick:o,children:l(Icon$1,{name:`panel`})}),l(`span`,{class:`web-title__dot`,"aria-hidden":`true`}),l(`span`,{class:`web-title__name`,children:m(`app.name`)})]}),l(`div`,{class:`web-title__centre`,children:[l(ProjectSwitcher,{name:e,fallback:l(`span`,{class:`web-title__project type-chrome-title`,title:e,children:e})}),t&&l(`span`,{class:`web-title__file type-chrome`,title:t,children:[n&&l(`span`,{class:`web-title__unsaved`,"aria-label":m(`app.web.tree.unsaved`)}),t]})]}),l(`div`,{class:`web-title__actions`,children:[l(`button`,{type:`button`,class:`web-title__tool`,"aria-label":m(`app.web.command.quickOpen`),title:a?`${m(`app.web.command.quickOpen`)} (${a})`:m(`app.web.command.quickOpen`),onClick:i,children:l(Icon$1,{name:`search`})}),l(`button`,{type:`button`,class:`web-title__tool`,"aria-label":m(`app.web.settings.title`),title:m(`app.web.settings.title`),onClick:r,children:l(Icon$1,{name:`settings`})})]})]})}function UnsavedDialog({name:e,busy:t,onSave:n,onDiscard:r,onCancel:i}){return l(q,{title:m(`app.web.unsaved.title`,{name:e}),size:`small`,destructive:!0,onClose:i,footer:l(Y,{actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:i,disabled:t},{id:`discard`,label:m(`app.web.unsaved.discard`),role:`secondary`,onClick:r,disabled:t},{id:`save`,label:m(`app.common.save`),role:`primary`,onClick:n,busy:t}]}),children:l(`p`,{class:`type-body`,children:m(`app.web.unsaved.text`,{name:e})})})}var pi={off:S.OFF,bottom:S.BOTTOM,sidebar:S.SIDEBAR};function hostPreferences(){return{aiChat:()=>ie(Z().aiChat),setAiChat:e=>je({aiChat:pi[e]}),subscribe:Me}}function useCloseQueue(e,r){let[i,a]=t([]),[o,s]=t(!1),c=n(t=>{let n=t;for(;n.length>0;){let[t,...i]=n;if(!e.doc(t))n=i;else if(Ue(e.doc(t)))break;else r(t),n=i}a(n)},[e,r]),l=n(e=>c(e),[c]),u=i[0]??null;return{head:u,busy:o,request:l,cancel:()=>a([]),discard:()=>{u!==null&&(r(u),c(i.slice(1)))},save:()=>{u!==null&&(s(!0),e.save(u).then(e=>{s(!1),e?(r(u),c(i.slice(1))):a([])}))}}}function useMedia(e,n=!1){let read=()=>typeof window<`u`&&typeof window.matchMedia==`function`?window.matchMedia(e).matches:n,[r,i]=t(read);return f(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),update=()=>i(t.matches);return update(),t.addEventListener?.(`change`,update),()=>t.removeEventListener?.(`change`,update)},[e]),r}var mi=3e3,hi=3e4;function pollDelay(e,t){return Math.min(e*2**Math.min(t,5),Math.max(e,hi))}function useWindowEvent(e,t,n=!1){let r=o(t);r.current=t,f(()=>{let handler=e=>r.current(e);return window.addEventListener(e,handler,n),()=>window.removeEventListener(e,handler,n)},[e,n])}function usePolling(e,t){f(()=>{let n,r=!1,i=0,visible=()=>document.visibilityState===`visible`,schedule=()=>{!r&&visible()&&(n&&clearTimeout(n),n=setTimeout(tick,pollDelay(t,i)))},tick=async()=>{visible()&&await e.refresh(),i=e.snapshot().connection===`ok`?0:i+1,schedule()},wake=()=>{n&&clearTimeout(n),n=void 0,visible()&&!r&&e.refresh().then(()=>{i=e.snapshot().connection===`ok`?0:i+1,schedule()})};return wake(),document.addEventListener(`visibilitychange`,wake),window.addEventListener(`focus`,wake),()=>{r=!0,n&&clearTimeout(n),document.removeEventListener(`visibilitychange`,wake),window.removeEventListener(`focus`,wake)}},[e,t])}function useStore(e){let[,n]=t(0),r=e.snapshot();return f(()=>{let t=e.subscribe(()=>n(e=>e+1));return e.snapshot()!==r&&n(e=>e+1),t},[e]),r}function suggestsNextBlock(){return Z().suggestNextBlock!==!1}function suggestsFields(){return Z().suggestions!==!1}var gi=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform),_i=!1,vi=new Set;function toggleFocusCanvas(){_i=!_i;for(let e of vi)e(_i)}function useFocusCanvas(){let[e,n]=t(_i);return f(()=>(vi.add(n),n(_i),()=>{vi.delete(n)}),[]),e}function useFocusCanvasShortcut(){let e=o(null),t=useEditorActive();f(()=>{if(!t)return;let onKey=t=>{if(!T(t,`Mod+Alt+Shift+M`,gi))return;t.preventDefault();let n=Date.now();isRepeatOfPress(e.current,n)||(e.current=n,toggleFocusCanvas())};return window.addEventListener(`keydown`,onKey),()=>window.removeEventListener(`keydown`,onKey)},[t])}var yi={newFile:()=>y(()=>import(`./NewFileDialog-j09JqpPj.js`).then(e=>e.NewFileDialog),__vite__mapDeps([65,1,2,3,4,6,7,8,9,10,11,28,14,57]),import.meta.url),quick:()=>y(()=>import(`./QuickOpen-CeBhsCzA.js`).then(e=>e.QuickOpen),__vite__mapDeps([66,1,2,3,4]),import.meta.url),shortcuts:()=>y(()=>import(`./ShortcutsDialog-DECqWPNE.js`).then(e=>e.ShortcutsDialog),__vite__mapDeps([67,1,2,3,4,47,6,7,8,9,10,11,15,28,14,29,68,46,31]),import.meta.url),settings:()=>y(()=>import(`./SettingsDialog-JUc5zUR9.js`).then(e=>e.SettingsDialog),__vite__mapDeps([69,1,2,3,4,28,6,7,8,9,10,11,14]),import.meta.url),agents:()=>y(()=>import(`./AgentsDialog-Bo7kikb6.js`).then(e=>e.AgentsDialog),__vite__mapDeps([70,1,2,3,4,6,7,8,9,10,11,47,15,28,14,29]),import.meta.url),conflict:()=>y(()=>import(`./ConflictDialog-GxZ-d8SK.js`).then(e=>e.ConflictDialog),__vite__mapDeps([71,1,2,3,4,28,6,7,8,9,10,11,14]),import.meta.url)};function useLazy(e,n){let[r,i]=t(null);return f(()=>{if(!n||r)return;let t=!0;return yi[e]().then(e=>t&&i({component:e})),()=>{t=!1}},[n]),r?.component??null}var bi=`(width < 900px)`;function groupWidth(e){let t=document.querySelector(`[data-group="${e}"]`)?.getBoundingClientRect().width??0;return t>0?t:void 0}function syncAddress(e){try{let t=new URL(window.location.href);e?t.searchParams.set(`file`,e):t.searchParams.delete(`file`);let n=`${t.pathname}${t.search}${t.hash}`;n!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,n)}catch{}}function engineName(e){if(!e)return null;let t=/^CAMUNDA_(\d+)$/.exec(e);return t?`Camunda ${t[1]}`:e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g,` `)}function WebShell({store:e,scripts:r,loaders:i,engine:a,deepLink:s,toolWindow:u=null,pollMs:d=mi,env:p}){let h=c(()=>({...nn,...p}),[p]),g=useStore(e),_=useStore(r.tabs),v=useMedia(bi),[y,b]=t(!1),[x,S]=t(null),[C,w]=t(null),[T,E]=t(null),[D,O]=t(!1),[k,A]=t(()=>h.sidebar()),[M,N]=t(defaultDock),[P,F]=t(Wt),[I,L]=t([]),[R,z]=t(!1),[B,V]=t(!1),[H,ee]=t(null),[U,te]=t(()=>h.autosave()),[ne,re]=t(()=>h.theme()),[ie,W]=t(null),ae=o(!1),oe=o(new Set),ce=useLazy(`newFile`,y),le=useLazy(`quick`,x!==null||g.listed),ue=useLazy(`shortcuts`,C===`shortcuts`),de=useLazy(`settings`,C===`settings`),pe=useLazy(`agents`,C===`agents`),me=useLazy(`conflict`,T!==null),he=g.order.map(e=>g.docs.get(e)).filter(Boolean),ge=c(()=>new Set(g.order.filter(e=>Ue(g.docs.get(e)))),[g.docs,g.order]),_e=g.listing.root,K=g.active?g.docs.get(g.active)??null:null;usePolling(e,d);let[ye]=t(()=>j().agentsHost?.()??null);f(()=>se(()=>w(`agents`)),[]),f(()=>{e.setAutosave(U)},[e,U]),f(()=>{let e=!0,read=()=>void h.licence().then(t=>e&&W(t));read();let t=onLicenceChange(read);return()=>{e=!1,t()}},[h]),f(()=>{if(ae.current||!g.listed)return;ae.current=!0;let t=h.loadSession(g.listing.root);if(t){let n=restoreSession(e,g.listing,t);n.dock&&N(n.dock),(n.toolOpen.length>0||n.toolShut.length>0)&&F(expansionOf(n.toolOpen,n.toolShut))}let n=s?Fe(s):null;if(n){let t=g.listing.files.find(e=>e.rel===n);e.open(t?.path??Re(g.listing.root,n),t?.kind)}V(!0);let r=h.journal;r&&r.orphans(g.listing.root).then(e=>L(e))},[g.listed]),f(()=>{if(!B)return;let e=oe.current;oe.current=new Set,N(t=>syncDocs(t,g.order,e,groupWidth(t.focus)))},[g.order,B]),f(()=>{let e=g.active;e&&N(t=>activate(t,docPanel(e)))},[g.active,g.order]);let sessionNow=()=>sessionOf(e.snapshot(),{dock:M,tool:P});f(()=>{N(e=>syncScripts(e,_.tabs.map(e=>e.id)))},[_.tabs]),f(()=>{let e=_.focus;e&&N(t=>activate(t,scriptPanel(e)))},[_.focus]);let be=o([]);f(()=>{let e=be.current.filter(e=>!g.order.includes(e));be.current=g.order,e.forEach(e=>void r.closeDocument(e))},[g.order,r]),f(()=>{if(!B||!_e)return;let e=setTimeout(()=>h.saveSession(_e,sessionNow()),h.sessionDelayMs);return()=>clearTimeout(e)},[B,_e,g.order,g.active,g.recent,M,P]),f(()=>{let e=g.active?g.docs.get(g.active):void 0;syncAddress(e?e.rel:null)},[g.active]);let xe=ge.size>0;f(()=>{showTitle(titleFor(g.active?g.docs.get(g.active)?.name??null:null,_e?Le(_e):m(`app.web.tree.project`),xe)),showFavicon(xe)},[g.active,g.docs,_e,xe]),f(()=>(showThemeColour(),window.addEventListener(`bpmn-theme-changed`,showThemeColour),()=>window.removeEventListener(`bpmn-theme-changed`,showThemeColour)),[]),useWindowEvent(`beforeunload`,t=>{e.dirtyPaths().length!==0&&(t.preventDefault(),t.returnValue=``)}),useWindowEvent(`pagehide`,()=>{h.journal?.flush(),B&&_e&&h.saveSession(_e,sessionNow())}),f(()=>{let hidden=()=>{document.visibilityState===`hidden`&&h.journal?.flush()};return document.addEventListener(`visibilitychange`,hidden),()=>document.removeEventListener(`visibilitychange`,hidden)},[h]);let q=useCloseQueue(e,n(t=>e.close(t),[e])),Se=q.head?g.docs.get(q.head):void 0,closeTabs=e=>q.request(e),Ce=n(t=>{N(t);let n=pathOfPanel(focused$1(t)?.active??``);n&&n!==e.snapshot().active&&e.activate(n)},[e]),we=n((t,n=!1)=>{if(n){let e=docPanel(t.path);has(M,e)?N(moveTab(M,e,{group:M.focus,zone:`right`,width:groupWidth(M.focus)})):oe.current.add(t.path)}e.open(t.path,t.kind),v&&O(!1)},[e,v,M]),Te=n(async(t,n)=>{let r=await e.create(t,n);r&&await e.open(r)},[e]),J=n(e=>{A(e),h.setSidebar(e)},[h]),Ee=n(()=>{v?O(e=>!e):J({...k,open:!k.open})},[v,k,J]),Y=useFocusCanvas(),X=n(()=>{let t=e.snapshot().active?e.doc(e.snapshot().active)?.rel??null:null;t&&G()?.focusInput(t)},[e]),De=g.active?g.docs.get(g.active)?.rel??null:null,Oe=n(()=>{let e=focused$1(M),t=e?.active??null;e&&t&&e.tabs.length>1?Ce(moveTab(M,t,{group:e.id,zone:`right`,width:groupWidth(e.id)})):S({initial:``,side:!0})},[M,Ce]),ke=n(()=>{leaves(M.root).length>1?Ce(mergeGroups(M)):Oe()},[M,Ce,Oe]),Z=n(async()=>{let t=e.snapshot().active;t&&!await e.save(t)&&e.doc(t)?.disk===`changed`&&E(t)},[e]),Ae=n(async()=>{await e.saveAll();let t=e.snapshot().order.find(t=>e.doc(t)?.disk===`changed`);t&&E(t)},[e]),Me=n(t=>{let n=focused$1(M);if(!n)return;let r=n.tabs.map(pathOfPanel).filter(e=>e!==null),i=pathOfPanel(n.active??``);if(r.length<2||!i)return;let a=r.indexOf(i);e.activate(r[(a+t+r.length)%r.length])},[e,M]),Ne=n(e=>{v?O(!0):k.open||J({...k,open:!0}),ee(t=>({path:Be(e),serial:(t?.serial??0)+1}))},[v,k,J]),Ie=useEntryActions(Ne),Q=n(t=>{let n=e.snapshot();switch(t){case`quickOpen`:S({initial:``,side:!1});return;case`actions`:h.runEditorAction(`palette`)||S({initial:`>`,side:!1});return;case`save`:Z();return;case`saveAll`:Ae();return;case`closeTab`:n.active&&closeTabs([n.active]);return;case`nextTab`:Me(1);return;case`previousTab`:Me(-1);return;case`toggleSidebar`:Ee();return;case`askAgent`:X();return;case`splitView`:ke();return;case`newFile`:b(!0);return;case`shortcuts`:w(`shortcuts`);return;case`settings`:w(`settings`);return;default:{let n=(focused$1(M)?.tabs??[]).map(pathOfPanel).filter(e=>e!==null),r=et(t,n.length);r!==null&&e.activate(n[r])}}},[e,h,M,Z,Ae,Me,Ee,X,ke]);useWindowEvent(`keydown`,e=>{if(e.isComposing||e.repeat)return;let t=it(e,h.mac);if(t){let n=e.target instanceof Element?e.target:null;if(document.querySelector(`.ui-dialog-overlay, .palette-overlay`)||ve(n)||n?.closest(`.djs-container`))return;runEditCommand(t,{focus:n,textSelected:!1})&&e.preventDefault();return}let n=nt(e,h.mac);n&&(e.preventDefault(),!document.querySelector(`.ui-dialog-overlay, .palette-overlay`)&&Q(n))},!0);let ze=c(()=>[{id:`newFile`,title:m(`app.web.command.newFile`),keys:$(`newFile`,h.mac),run:()=>Q(`newFile`)},{id:`save`,title:m(`app.web.command.save`),keys:$(`save`,h.mac),run:()=>Q(`save`)},{id:`saveAll`,title:m(`app.web.command.saveAll`),keys:$(`saveAll`,h.mac),run:()=>Q(`saveAll`)},{id:`closeTab`,title:m(`app.web.command.closeTab`),keys:$(`closeTab`,h.mac),run:()=>Q(`closeTab`)},{id:`closeAll`,title:m(`app.web.command.closeAll`),run:()=>closeTabs(e.snapshot().order)},{id:`splitView`,title:leaves(M.root).length>1?m(`app.web.command.closeSplit`):m(`app.web.command.splitView`),keys:$(`splitView`,h.mac),run:()=>Q(`splitView`)},{id:`toggleSidebar`,title:m(`app.web.command.toggleSidebar`),keys:$(`toggleSidebar`,h.mac),run:()=>Q(`toggleSidebar`)},...fe()&&De?[{id:`askAgent`,title:m(`app.web.command.askAgent`),keys:$(`askAgent`,h.mac),run:()=>Q(`askAgent`)}]:[],{id:`resetLayout`,title:m(`app.web.command.resetLayout`),run:()=>N(syncDocs(defaultDock(),e.snapshot().order))},{id:`actions`,title:m(`app.web.command.actions`),keys:$(`actions`,h.mac),run:()=>Q(`actions`)},{id:`settings`,title:m(`app.web.command.settings`),run:()=>Q(`settings`)},{id:`agents`,title:m(`app.web.command.agents`),run:()=>w(`agents`)},{id:`shortcuts`,title:m(`app.web.command.shortcuts`),keys:$(`shortcuts`,h.mac),run:()=>Q(`shortcuts`)},{id:`reconnect`,title:m(`app.web.command.reconnect`),run:()=>void e.refresh()}],[h.mac,Q,M,e,De]),Ve=c(()=>new Map([...docTabs(he,h.mac),...scriptTabItems(_.tabs)].map(e=>[e.id,e])),[g.docs,g.order,h.mac,_.tabs]),selectPanel=t=>{let n=pathOfPanel(t),i=scriptIdOf(t);N(e=>activate(e,t)),n&&e.activate(n),i&&r.tabs.focus(i)},closePanelTab=e=>{let t=pathOfPanel(e),n=scriptIdOf(e);t&&closeTabs([t]),n&&r.closed(n)},He=n(t=>{let n=pathOfPanel(t),r=groupOf(M,t),i=r?r.tabs.length>1:!1;if(n===null)return[];let{order:a}=e.snapshot(),o=a.indexOf(n),s=e.doc(n);return[{id:`close`,label:m(`app.web.menu.close`),keys:$(`closeTab`,h.mac),run:()=>closeTabs([n])},{id:`others`,label:m(`app.web.menu.closeOthers`),disabled:a.length<2,run:()=>closeTabs(a.filter(e=>e!==n))},{id:`right`,label:m(`app.web.menu.closeRight`),disabled:o<0||o===a.length-1,run:()=>closeTabs(a.slice(o+1))},{id:`all`,label:m(`app.web.menu.closeAll`),run:()=>closeTabs(a)},{id:`splitRight`,label:m(`app.web.menu.splitRight`),separatorBefore:!0,disabled:!i||!roomToSplit(r?groupWidth(r.id):void 0,`right`),run:()=>r&&Ce(moveTab(M,t,{group:r.id,zone:`right`,width:groupWidth(r.id)}))},{id:`splitDown`,label:m(`app.web.menu.splitDown`),disabled:!i,run:()=>r&&Ce(moveTab(M,t,{group:r.id,zone:`bottom`}))},{id:`reveal`,label:m(`app.web.menu.reveal`),run:()=>Ne(n)},{id:`copyPath`,label:m(`app.web.menu.copyPath`),separatorBefore:!0,run:()=>void h.copy(n).then(e=>h.notify(m(e?`app.web.menu.copied`:`app.web.menu.copyFailed`),!e))},{id:`copyRel`,label:m(`app.web.menu.copyRelative`),run:()=>void h.copy(s?.rel??n).then(e=>h.notify(m(e?`app.web.menu.copied`:`app.web.menu.copyFailed`),!e))}]},[e,h,M,Ce,Ne]),restoreDrafts=async()=>{z(!0);let t=new Map(e.snapshot().listing.files.map(e=>[e.path,e]));for(let n of I){let r=t.get(n.path);r?(await e.open(n.path,r.kind),e.applyDraft(n.path,n)):e.adoptMissing(n.path,n.path.endsWith(`.dmn`)?`dmn`:n.path.endsWith(`.form`)?`form`:`bpmn`,n)}L([]),z(!1)},discardDrafts=async()=>{z(!0),await h.journal?.discard(I),L([]),z(!1)},openPath=t=>{if(!t)return;let n=g.listing.files.find(e=>e.rel===t);e.open(n?.path??Re(g.listing.root,t),n?.kind)};useDesktopCommands({"file.newFile":()=>Q(`newFile`),"file.save":()=>Q(`save`),"file.closeTab":()=>{let t=e.snapshot().active;t?closeTabs([t]):at()?.closeWindow()},"edit.undo":()=>replayEdit(`undo`),"edit.redo":()=>replayEdit(`redo`),"edit.cut":()=>replayEdit(`cut`),"edit.copy":()=>replayEdit(`copy`),"edit.paste":()=>replayEdit(`paste`),"edit.selectAll":()=>replayEdit(`selectAll`),"file.openPath":openPath,"view.toggleTree":()=>Q(`toggleSidebar`),"view.toggleSidebar":()=>{let e=at()?.platform===`darwin`;document.dispatchEvent(new KeyboardEvent(`keydown`,{key:`'`,code:`Quote`,altKey:!0,metaKey:e,ctrlKey:!e,bubbles:!0,cancelable:!0}))},"help.shortcuts":()=>Q(`shortcuts`)});let We=_e?Le(_e):m(`app.web.tree.project`),Ge=T?g.docs.get(T):void 0;f(()=>{T&&g.docs.get(T)?.disk!==`changed`&&E(null)},[T,g.docs]),f(()=>{v||O(!1)},[v]);let Ke=g.recent.map(e=>g.listing.files.find(t=>t.rel===e)).filter(e=>!!e&&!g.docs.has(e.path)).slice(0,6).map(e=>({rel:e.rel,name:e.name})),openRel=e=>{let t=g.listing.files.find(t=>t.rel===e);t&&we(t)},qe=c(()=>new Map(leaves(M.root).map(e=>[e.active,e.id])),[M]),content=t=>{let n=qe.get(t),a=scriptIdOf(t);if(a!==null){let e=_.tabs.find(e=>e.id===a);return e?l(LazyScriptPane,{hub:r,tab:e,shown:!!n,focused:n===M.focus},e.id):null}let o=pathOfPanel(t),s=o?g.docs.get(o):void 0;return s?l(DocumentPane,{store:e,scripts:r,doc:s,shown:!!n,focused:n===M.focus,loaders:i,onClose:()=>closeTabs([s.path]),onCompare:()=>E(s.path)}):null},Je=leaves(M.root).at(-1)?.id??null,header=e=>{let t=e.tabs.map(e=>Ve.get(e)).filter(e=>!!e),n=leaves(M.root).length>1;return l(TabStrip,{tabs:t,active:e.active,onSelect:selectPanel,onClose:closePanelTab,onDropTab:(t,n)=>Ce(moveTab(M,t,{group:e.id,zone:`center`,index:n})),menuFor:He,trailing:e.id===Je&&!v&&he.length>0?l(`button`,{type:`button`,class:`web-tabs__split${n?` is-on`:``}`,"aria-pressed":n,"aria-label":m(n?`app.web.command.closeSplit`:`app.web.command.splitView`),title:rt(m(n?`app.web.command.closeSplit`:`app.web.command.splitView`),`splitView`,h.mac),onClick:ke,children:l(Icon$1,{name:`split`})}):null})},empty=()=>l(Welcome$1,{recent:Ke,onOpen:openRel,onQuickOpen:()=>S({initial:``,side:!1}),onNew:()=>b(!0),quickKeys:$(`quickOpen`,h.mac),empty:g.listed&&g.listing.files.length===0}),label=e=>{let t=pathOfPanel(e);return(t?g.docs.get(t)?.name:null)??``};return l(`div`,{class:`web-app`,children:[l(`a`,{class:`web-skip type-body`,href:`#web-main`,onClick:e=>{e.preventDefault(),document.getElementById(`web-main`)?.focus()},children:m(`app.web.skip`)}),l(TitleBar,{project:We,file:K?.name??null,dirty:!!K&&Ue(K),onSettings:()=>w(`settings`),onSearch:()=>Q(`quickOpen`),searchKeys:$(`quickOpen`,h.mac)??``,onToggleSidebar:Ee,sidebarKeys:$(`toggleSidebar`,h.mac)??``}),l(`div`,{class:`web-shell${v?` is-narrow`:``}`,children:[!Y&&(v?D:k.open)&&l(ShellSidebar,{width:k.width,onWidth:e=>J({...k,width:e}),drawer:v,onClose:()=>O(!1),runAction:h.runEditorAction,focusedEditor:De,openFile:openPath,children:u&&l(ToolPanel,{store:u,expansion:P,onExpansion:F,onUnlock:h.showLicence,mac:h.mac,entries:Ie,activePath:K&&!Pe(K.kind)?Be(K.path):null,reveal:H,newKeys:$(`newFile`,h.mac)})}),l(`main`,{id:`web-main`,class:`web-workspace`,tabIndex:-1,"aria-label":m(`app.web.main.label`),children:[g.connection===`lost`&&l(`div`,{class:`web-shell__connection`,role:`alert`,children:[l(Icon$1,{name:`alert`}),l(`span`,{class:`web-shell__connection-text type-body`,children:m(`app.web.connection.lost`)}),l(`button`,{type:`button`,class:`ui-button type-button`,onClick:()=>void e.refresh(),children:m(`app.common.retry`)})]}),I.length>0&&l(DraftNotice,{count:I.length,busy:R,onRestore:()=>void restoreDrafts(),onDiscard:()=>void discardDrafts()}),l(DockView,{dock:M,onDock:Ce,header,content,empty,label,single:v})]})]}),l(StatusBar,{engine:engineName(a),licence:ie,connection:g.connection,doc:K,autosave:U,mac:h.mac,onRetry:()=>void e.refresh(),onShortcuts:()=>w(`shortcuts`),onLicence:h.showLicence}),y&&ce&&l(ce,{files:g.listing.files,engine:a,onCreate:Te,onClose:()=>b(!1)}),x&&le&&l(le,{files:g.listing.files,recent:g.recent,open:new Set(g.order),commands:ze,initial:x.initial,side:x.side,onClose:()=>S(null),onPick:(e,t)=>{S(null),we(e,t)},onRun:e=>{S(null),setTimeout(e.run,0)}}),C===`shortcuts`&&ue&&l(ue,{mac:h.mac,onClose:()=>w(null)}),C===`settings`&&de&&l(de,{theme:ne,autosave:U,onAgents:()=>w(`agents`),onTheme:e=>{re(e),h.setTheme(e)},onAutosave:e=>{te(e),h.setAutosave(e)},suggestNextBlock:suggestsNextBlock(),onSuggestNextBlock:e=>je({suggestNextBlock:e}),suggestions:suggestsFields(),onSuggestions:e=>je({suggestions:e}),onClose:()=>w(null)}),C===`agents`&&pe&&ye&&l(pe,{host:ye,preferences:hostPreferences(),onClose:()=>w(null)}),Ge&&Ge.diskText!==null&&me&&!y&&!Se&&C===null&&l(me,{name:Ge.name,mine:Ge.current,theirs:Ge.diskText,onClose:()=>E(null),onTakeTheirs:()=>{e.reloadFromDisk(Ge.path),E(null)},onKeepMine:()=>{e.keepMine(Ge.path),E(null)}}),Se&&l(UnsavedDialog,{name:Se.name,busy:q.busy,onCancel:q.cancel,onDiscard:q.discard,onSave:q.save}),g.connection===`denied`&&l(SessionEnded,{onRetry:()=>void e.refresh()})]})}async function answered(e){try{return await e}catch(e){throw Error(await K(e))}}function webHost(e){return{current:()=>answered(e.getCurrentProject()),open:t=>answered(e.openProject({openProjectRequest:{folder:t}})),close:()=>answered(e.closeProject()),recent:async()=>(await answered(e.listRecentProjects())).projects,forget:async t=>(await answered(e.forgetRecentProject({openProjectRequest:{folder:t}}))).projects,folders:(t,n)=>answered(e.listFolders({folderListRequest:{path:t??null,hidden:n}})),createFolder:t=>answered(e.createFolder({createFolderRequest:{path:t}})),rename:async(t,n,r)=>(await answered(e.renameEntry({renameEntryRequest:{path:t,name:n,stamp:r}}))).path,move:async(t,n,r)=>(await answered(e.moveEntry({moveEntryRequest:{path:t,folder:n,stamp:r}}))).path,duplicate:async t=>(await answered(e.duplicateEntry({duplicateEntryRequest:{path:t}}))).path,archiveUrl:async t=>{let n=await e.downloadProjectArchiveRequestOpts({expect:t??void 0}),r=new URLSearchParams;return Object.entries(n.query??{}).forEach(([e,t])=>r.set(e,t)),`${n.path}${r.size>0?`?${r}`:``}`},remove:(t,n)=>answered(e.deleteEntry({deleteEntryRequest:{path:t,stamp:n}}))}}function scriptOf(e){let{path:t,slot:n,language:r,script:i,title:a}=e;return!t||!n||r===void 0||i===void 0||a===void 0?null:{path:t,slot:n,language:r,text:i,title:a,variables:e.variables??[]}}var xi={phase:`loading`,revision:null,roots:[],toolbar:[],codeLinks:`open`,truncated:!1,error:null,busy:null};function statusOf(e){return e?.response?.status??null}var ToolWindowStore=class{state=xi;listeners=new Set;api;effects;pollMs;attached=0;timer;flight=null;again=!1;failures=0;controller=null;constructor(e,t,n=mi){this.api=e,this.effects=t,this.pollMs=n}snapshot(){return this.state}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}set(e){this.state={...this.state,...e},[...this.listeners].forEach(e=>e())}attach(){this.attached+=1,this.attached===1&&(document.addEventListener(`visibilitychange`,this.wake),window.addEventListener(`focus`,this.wake),this.refresh().then(()=>this.schedule()));let e=!1;return()=>{e||(e=!0,--this.attached,!(this.attached>0)&&(document.removeEventListener(`visibilitychange`,this.wake),window.removeEventListener(`focus`,this.wake),this.timer&&clearTimeout(this.timer),this.timer=void 0,this.controller?.abort()))}}wake=()=>{this.attached!==0&&document.visibilityState===`visible`&&(this.timer&&clearTimeout(this.timer),this.timer=void 0,this.refresh().then(()=>this.schedule()))};schedule(){this.attached!==0&&document.visibilityState===`visible`&&(this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.refresh().then(()=>this.schedule())},pollDelay(this.pollMs,this.failures)))}refresh(){if(this.flight)return this.again=!0,this.flight;let e=this.load().finally(()=>{this.flight=null,this.again&&this.attached>0&&(this.again=!1,this.refresh()),this.again=!1});return this.flight=e,e}async load(){let e=new AbortController;this.controller=e;try{let t=await this.api.snapshot(this.state.revision,e.signal);if(this.failures=0,t.unchanged&&this.state.revision===t.revision){(this.state.phase!==`ready`||this.state.error)&&this.set({phase:`ready`,error:null});return}this.set({phase:`ready`,revision:t.revision,roots:t.roots??[],toolbar:t.toolbar??[],codeLinks:t.codeLinks===`locked`?`locked`:`open`,truncated:t.truncated===!0,error:null})}catch(t){if(e.signal.aborted)return;if(this.failures+=1,this.state.revision!==null&&statusOf(t)===null){this.state.error!==null&&this.set({error:null});return}this.set({phase:this.state.revision===null?`error`:`ready`,error:await K(t)})}finally{this.controller===e&&(this.controller=null)}}async run(e){let t=this.state.revision;if(t!==null&&this.state.busy===null){this.set({busy:e});try{let n;try{n=await this.api.perform(e,t)}catch(e){statusOf(e)===409?(await this.refresh(),this.effects.notify(m(`app.web.toolPanel.stale`),!0)):this.effects.notify(await K(e),!0);return}await this.carry(n)}finally{this.set({busy:null})}}}async carry(e){let t=this.effects;try{switch(e.kind){case`reveal`:e.path&&await t.reveal(e.path,e.elementId);return;case`openCode`:case`findUsages`:{let n=e.title??``,r=e.places??[];r.length===0?t.notify(m(`app.webHost.places.none`,{name:n}),!0):await t.openPlaces(n,r);return}case`openScript`:{let n=scriptOf(e);n&&await t.openScript(n);return}case`copy`:await t.copy(e.text??``)?t.notify(m(`app.web.toolPanel.copied`)):t.notify(m(`app.web.tree.copyFailed`),!0);return;case`preference`:case`refresh`:await this.refresh();return;case`deploy`:await t.deploy(e.paths??[],e.profile,e.confirm===!0),await this.refresh();return;case`createExample`:e.example&&await t.createExample(e.example),await this.refresh();return;case`unlockCode`:t.unlock();return;case`notify`:t.notify(e.text??``,e.error===!0);return;case`unsupported`:t.notify(e.reason??m(`app.web.toolPanel.unsupported`),!1);return}}catch(e){t.notify(await K(e),!0)}}};function baseName(e){return e.split(/[\\/]/).pop()??e}function label(e){return e.profile??`default`}async function deployPaths(e,t,n,r){let i=n??m(`app.deploy.profileInForce`);if(r&&!await e.confirmWithUser({title:m(`app.deploy.title`),text:m(`app.deploy.confirm`,{what:t.length===1?baseName(t[0]):m(`app.deploy.files`,{count:t.length}),where:i}),accept:m(`app.deploy.title`),decline:m(`app.common.cancel`)}))return;let a=new Map;for(let r of t){let t=await e.targets(r),i=n===void 0?t.active??null:n,o=t.targets.find(e=>(e.profile??null)===i);if(!o?.ready){await e.notifyUser(m(`app.deploy.notReady`,{name:baseName(r),target:label({profile:i})}),!0);continue}let s=JSON.stringify([o.profile,o.engine,o.url,o.deployment]),c=a.get(s)??{target:o,paths:[]};c.paths.push(r),a.set(s,c)}for(let{target:t,paths:n}of a.values()){let r=await Promise.all(n.map(async t=>({path:t,content:await e.readFile(t)}))),i=(await e.projectFiles()).map(t=>({path:t,read:()=>e.readFile(t)})),a=(await k(r,i)).map(e=>({name:e.name,content:e.content})),o=await e.deploy(t,a,n[0]),s=o.status===401||o.status===403;await e.notifyUser(o.ok?m(`app.deploy.succeededOn`,{message:o.message,target:t.url??label(t)}):s?m(`app.deploy.signInHint`,{message:o.message}):o.message,!o.ok)}}async function createExample(e,t,n){if(!await e.confirmWithUser({title:m(`app.project.startFromAnExample`),text:m(`app.project.writeTheOrderExampleInto`,{example:P(n),root:t}),accept:m(`app.runs.create`),decline:m(`app.common.cancel`)}))return!1;let r=[];for(let[i,a]of Object.entries(O(n)))(i!==`.gitignore`||await e.readFileIfPresent(`${t}/${i}`)===null)&&r.push({path:i,content:a});try{await e.createProjectFiles(t,r)}catch(t){return await e.notifyUser(m(`app.project.theExampleWasNotWritten`,{failure:t instanceof Error?t.message:String(t)}),!0),!1}return await e.notifyUser(m(`app.project.theExampleIsInIts`,{example:P(n),root:t})),!0}function targetLabel(e){return e?.profile??`default`}async function deployWithHost(e,t,n,r){try{let i=j(),a=e?.profile??null;if(!e||!N(String(e.engine))||!e.deployment)return{ok:!1,status:0,message:m(`app.project.chooseCamunda7Camunda8`),definitions:[],lines:[]};let o=Array.isArray(t)?t:[],s=await te({...e.deployment,engine:e.engine},o,{ask:e=>i.askEngine(a,e,n),hook:(e,t)=>i.runHook(e,t,a,n,r),watch:r});if(s.ok)try{await i.recordDeployment(a,o.map(e=>e.name))}catch{}return s}catch(e){return{ok:!1,status:0,message:e instanceof Error?e.message:String(e),definitions:[],lines:[]}}}function toolEnvironment(e,t){return{notify:e.notify,copy:e.copy,showLicence:e.showLicence,files:()=>t.snapshot().listing.files,refreshProject:()=>t.refresh()}}function toolApi(e){return{snapshot:(t,n)=>e.web.getToolWindow({revision:t??void 0},n?{signal:n}:void 0),perform:(t,n)=>e.web.performToolWindowAction({toolWindowPerformRequest:{id:t,revision:n}})}}function toolEffects(e,t){return{reveal:(t,n)=>e.revealElement(t,n),openPlaces:(t,n)=>e.openPlaces(t,n),openScript:t=>e.openScriptFile(t.language,t.text,t.slot,t.title,t.variables,t.path),copy:t.copy,notify:t.notify,unlock:t.showLicence,deploy:async(n,r,i)=>{await deployPaths({confirmWithUser:t=>e.confirmWithUser(t),targets:async t=>e.getDeployTargets(t),notifyUser:async(e,n)=>t.notify(e,n),readFile:t=>e.readFile(t),projectFiles:async()=>t.files().filter(e=>e.kind===`bpmn`||e.kind===`dmn`||e.kind===`form`).map(e=>e.path),deploy:(e,t,n)=>deployWithHost(e,t,n)},n,r,i),await t.refreshProject()},createExample:async n=>{D(n)&&await createExample({readFileIfPresent:t=>e.readFileIfPresent(t),confirmWithUser:t=>e.confirmWithUser(t),notifyUser:async(e,n)=>t.notify(e,n),createProjectFiles:(t,n)=>e.createProjectFiles(t,n)},e.projectRoot(),n)&&await t.refreshProject()}}}var ProjectSession=class{host;identity;reload;listeners=new Set;state;timer=null;running=null;pollMs;constructor(e,t,n={}){this.host=e,this.identity={id:t.id??null,folder:t.folder??null},this.reload=n.reload??(()=>window.location.assign(window.location.pathname)),this.pollMs=n.pollMs??4e3,this.state={project:t,recent:null,gone:t.open&&!t.available,away:!1,moving:!1}}get id(){return this.identity.id}snapshot(){return this.state}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}commit(e){this.state={...this.state,...e},[...this.listeners].forEach(e=>{try{e()}catch(e){console.error(`A session listener failed:`,e)}})}start(){let schedule=()=>{this.timer=setTimeout(()=>{this.check().finally(()=>{this.timer!==null&&schedule()})},this.pollMs)};return schedule(),()=>{this.timer!==null&&clearTimeout(this.timer),this.timer=null}}check(){if(this.running)return this.running;let e=(async()=>{let e;try{e=await this.host.current()}catch{return}if(this.state.moving)return;let t=(e.id??null)!==this.id,n=!t&&e.open&&!e.available;(t!==this.state.away||n!==this.state.gone)&&this.commit({away:t,gone:n})})();return this.running=e.finally(()=>{this.running=null}),this.running}async adopt(){let e;try{e=await this.host.current()}catch{return}let t=e.id??null;e.open&&t!==null&&e.folder===this.identity.folder&&(this.identity={...this.identity,id:t}),await this.check()}noticeProjectId(e){e!==null&&this.id!==null&&e!==this.id&&!this.state.away&&!this.state.moving&&this.check()}async loadRecent(){let e=await this.host.recent();return this.commit({recent:e}),e}async forget(e){this.commit({recent:await this.host.forget(e)})}async open(e){this.commit({moving:!0});try{await this.host.open(e)}catch(e){throw this.commit({moving:!1}),e}this.reload()}async close(){this.commit({moving:!0});try{await this.host.close()}catch(e){throw this.commit({moving:!1}),e}this.reload()}reloadPage(){this.reload()}};function pageTitle({app:e,project:t,file:n,dirty:r}){let i=[];return n&&i.push(`${r?`● `:``}${n}`),t&&i.push(t),i.push(e),i.join(` - `)}function breadcrumbs(e,t){let n=[],r=t===`\\`,i=e.split(t).filter(e=>e!==``),a=``;r&&/^[A-Za-z]:$/.test(i[0]??``)?(a=`${i[0]}\\`,n.push({label:`${i[0]}\\`,path:a}),i.shift()):r||(a=`/`,n.push({label:`/`,path:`/`}));for(let e of i)a=a===``||a.endsWith(t)?`${a}${e}`:`${a}${t}${e}`,n.push({label:e,path:a});return n}function visibleEntries(e,t){return t?[...e]:e.filter(e=>!e.hidden)}function joinFolder(e,t,n){return e.endsWith(n)?`${e}${t}`:`${e}${n}${t}`}var Si=8,Ci=320;function folderWindow(e,t,n){return{start:Math.max(0,Math.floor(e/28)-Si),end:Math.min(n,Math.ceil((e+t)/28)+Si)}}function FolderBrowser({folders:e,recent:r,start:i,onChoose:a,onClose:s}){let[c,d]=t(null),[p,h]=t(!0),[g,_]=t(null),[v,y]=t(!1),[b,x]=t(i??``),[S,C]=t(null),[w,T]=t(!1),[E,D]=t(null),[O,k]=t(0),[A,j]=t(Ci),M=o(null),N=o(0),P=o(`web-folders-${Math.random().toString(36).slice(2,8)}`),F=n(async(t,n)=>{N.current+=1;let r=N.current;h(!0);try{let i=await e(t,n);if(r!==N.current)return;d(i),x(i.path),C(null),_(null),k(0),M.current&&(M.current.scrollTop=0)}catch(e){if(r!==N.current)return;_(e instanceof Error&&e.message?e.message:m(`app.web.unknownFailure`))}finally{r===N.current&&h(!1)}},[e]);f(()=>{F(i,!1)},[]),u(()=>{let e=M.current;if(!e)return;let measure=()=>j(e.clientHeight||Ci);if(measure(),typeof ResizeObserver>`u`)return;let t=new ResizeObserver(measure);return t.observe(e),()=>t.disconnect()},[]);let I=c?visibleEntries(c.entries,v):[],L=c?.separator??`/`,R=S===null?-1:I.findIndex(e=>e.name===S),z=c?S!==null&&R>=0?joinFolder(c.path,S,L):c.path:null,scrollTo=e=>{let t=M.current;if(!t||e<0)return;let n=e*28,r=t.clientHeight||Ci;n<t.scrollTop?t.scrollTop=n:n+28>t.scrollTop+r&&(t.scrollTop=n+28-r),k(t.scrollTop)},descend=e=>{c&&F(joinFolder(c.path,e,L),v)},choose=async()=>{if(!(!z||w||p)){if(c&&b.trim()!==c.path)F(b,v);else{T(!0),D(null);try{await a(z)}catch(e){D(e instanceof Error&&e.message?e.message:m(`app.web.unknownFailure`)),T(!1)}}}},onListKey=e=>{if(e.altKey||e.ctrlKey||e.metaKey)return;let t=Math.max(1,Math.floor((M.current?.clientHeight||Ci)/28)-1),n=null;e.key===`ArrowDown`?n=Math.min(I.length-1,R+1):e.key===`ArrowUp`?n=Math.max(0,R<0?0:R-1):e.key===`Home`?n=0:e.key===`End`?n=I.length-1:e.key===`PageDown`?n=Math.min(I.length-1,R+t):e.key===`PageUp`&&(n=Math.max(0,R-t)),n===null?(e.key===`Enter`||e.key===`ArrowRight`)&&R>=0?(e.preventDefault(),e.stopPropagation(),descend(I[R].name)):(e.key===`Backspace`||e.key===`ArrowLeft`)&&c?.parent&&(e.preventDefault(),F(c.parent,v)):(e.preventDefault(),I[n]&&(C(I[n].name),scrollTo(n)))},{start:B,end:V}=folderWindow(O,A,I.length),H=[];c&&(H.push({id:`home`,label:m(`app.web.folders.home`),path:c.home}),c.roots.forEach(e=>H.push({id:`root:${e}`,label:e===`/`?m(`app.web.folders.computer`):e,path:e})));let ee=r.filter(e=>e.present).slice(0,6),U=c?breadcrumbs(c.path,L):[];return l(q,{title:m(`app.web.folders.title`),size:`large`,body:`split`,onClose:s,onSubmit:()=>void choose(),footer:l(Y,{help:z?m(`app.web.folders.willOpen`,{folder:z}):void 0,actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:s,disabled:w},{id:`open`,label:m(`app.web.folders.open`),role:`primary`,onClick:()=>void choose(),busy:w,disabled:!z}]}),children:[l(`nav`,{class:`web-folders__places`,"aria-label":m(`app.web.folders.places`),children:[l(`p`,{class:`web-folders__heading type-section-heading`,children:m(`app.web.folders.places`)}),H.map(e=>l(`button`,{type:`button`,class:`web-folders__place type-body`,title:e.path,onClick:()=>void F(e.path,v),children:[l(Icon$1,{name:`folder`}),l(`span`,{class:`web-folders__place-name`,children:e.label})]},e.id)),ee.length>0&&l(`p`,{class:`web-folders__heading type-section-heading`,children:m(`app.web.folders.recent`)}),ee.map(e=>l(`button`,{type:`button`,class:`web-folders__place type-body`,title:e.folder,onClick:()=>void F(e.folder,v),children:[l(Icon$1,{name:`process`}),l(`span`,{class:`web-folders__place-name`,children:e.name})]},e.folder))]}),l(`div`,{class:`web-folders__main`,children:[l(we,{label:m(`app.web.folders.path`),layout:`top`,error:g,children:e=>l(`input`,{...e,value:b,spellcheck:!1,autocomplete:`off`,onInput:e=>x(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),F(b,v))},onBlur:()=>{c&&b.trim()!==``&&b!==c.path&&!p&&F(b,v)}})}),c&&l(`ol`,{class:`web-folders__crumbs type-help`,"aria-label":m(`app.web.folders.location`),children:U.map((e,t)=>l(`li`,{class:`web-folders__crumb`,children:l(`button`,{type:`button`,class:`web-folders__crumb-button`,"aria-current":t===U.length-1?`location`:void 0,onClick:()=>void F(e.path,v),children:e.label})},e.path))}),l(`div`,{class:`web-folders__bar`,children:[l(`label`,{class:`web-folders__toggle type-body`,children:[l(`input`,{type:`checkbox`,checked:v,onChange:e=>{let t=e.target.checked;y(t),c&&F(c.path,t)}}),l(`span`,{children:c&&c.hiddenCount>0?m(`app.web.folders.showHiddenCount`,{count:c.hiddenCount}):m(`app.web.folders.showHidden`)})]}),c?.project&&l(`span`,{class:`web-folders__hint type-help`,role:`status`,children:c.project.config?m(`app.web.folders.hereConfig`):m(`app.web.folders.hereDiagrams`,{count:c.project.diagrams})})]}),l(`div`,{ref:M,id:P.current,class:`web-folders__list`,role:`listbox`,tabIndex:0,"aria-label":m(`app.web.folders.list`),"aria-busy":p||void 0,"aria-activedescendant":R>=0?`${P.current}-${R}`:void 0,onKeyDown:onListKey,onScroll:e=>k(e.currentTarget.scrollTop),children:[l(`div`,{class:`web-folders__canvas`,style:{height:`${I.length*28}px`},children:I.slice(B,V).map((e,t)=>{let n=B+t;return l(`div`,{id:`${P.current}-${n}`,role:`option`,"aria-selected":n===R,class:`web-folders__row type-body${n===R?` is-selected`:``}`,style:{top:`${n*28}px`},title:e.link?m(`app.web.folders.link`,{name:e.name}):e.name,onClick:()=>{M.current?.focus({preventScroll:!0}),C(e.name)},onDblClick:()=>descend(e.name),children:[l(Icon$1,{class:`web-folders__icon`,name:`folder`}),l(`span`,{class:`web-folders__name`,children:e.name}),e.link&&l(`span`,{class:`web-folders__tag type-help`,children:m(`app.web.folders.linkTag`)}),e.project&&l(`span`,{class:`web-folders__tag is-project type-help`,children:m(`app.web.folders.projectTag`)})]},e.name)})}),c&&I.length===0&&!p&&l(`p`,{class:`web-folders__empty type-help`,children:m(`app.web.folders.noFolders`)})]}),c?.truncated&&l(`p`,{class:`web-folders__note type-help`,children:m(`app.web.folders.truncated`,{shown:c.entries.length,total:c.total})}),E&&l(ke,{children:E})]})]})}var wi=`.bpmn,.dmn,.form,.xml`;function acceptedUpload(e){let t=Ve(e);return t===`bpmn`||t===`dmn`||t===`form`}function messageFrom(e){return e instanceof Error&&e.message?e.message:m(`app.web.unknownFailure`)}function carriesFiles(e){return Array.from(e.dataTransfer?.types??[]).includes(`Files`)}function ProjectFrame({session:e,store:r,entries:i,readText:a,engine:s,toolWindow:u=null,children:d}){let p=useSession(e),h=useStore(r),[g,_]=t(!1),[v,b]=t(null),[x,S]=t(!1),[C,w]=t(null),[T,E]=t(null),[D,O]=t(!1),[k,A]=t(null),[j,M]=t(null),[N,P]=t(null),F=o(null),I=o(0),L=p.project.name??m(`app.web.tree.project`),R=h.active?h.docs.get(h.active):void 0,z=!!R&&R.phase===`ready`&&R.current!==R.baseline;f(()=>{document.title=pageTitle({app:m(`app.web.pageTitle`),project:p.project.open?L:null,file:R?R.rel:null,dirty:z})},[L,R?.rel,z,p.project.open]),f(()=>e.start(),[e]),useDesktopCommands({"project.refresh":()=>void e.adopt().then(()=>Promise.all([r.refresh(),u?.refresh()]))}),f(()=>{if(!T||k)return;let e=!0;return y(()=>import(`./UploadDialog-CiahYkTc.js`).then(t=>e&&A({component:t.UploadDialog})),__vite__mapDeps([72,1,2,3,4,28,6,7,8,9,10,11,14,57]),import.meta.url),()=>{e=!1}},[T]),f(()=>{if(j===null||N)return;let e=!0;return y(()=>import(`./NewFileDialog-j09JqpPj.js`).then(t=>e&&P({component:t.NewFileDialog})),__vite__mapDeps([65,1,2,3,4,6,7,8,9,10,11,28,14,57]),import.meta.url),()=>{e=!1}},[j]);let B=n(async t=>{for(let e of[...r.snapshot().order])r.close(e);try{t.kind===`open`?await e.open(t.folder):await e.close()}catch(e){H.error(messageFrom(e)),S(!1),b(null)}},[e,r]),V=n(e=>{r.dirtyPaths().length===0?B(e):(w(null),b(e))},[r,B]),ee=n(e=>{let t=e.filter(e=>acceptedUpload(e.name));t.length<e.length&&H.error(m(`app.web.upload.ignored`)),t.length>0&&E(t)},[]);f(()=>{let over=e=>{carriesFiles(e)&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`))},enter=e=>{carriesFiles(e)&&(I.current+=1,O(!0))},exit=e=>{carriesFiles(e)&&(I.current=Math.max(0,I.current-1),I.current===0&&O(!1))},drop=e=>{carriesFiles(e)&&(e.preventDefault(),I.current=0,O(!1),ee(Array.from(e.dataTransfer?.files??[])))};return window.addEventListener(`dragover`,over),window.addEventListener(`dragenter`,enter),window.addEventListener(`dragleave`,exit),window.addEventListener(`drop`,drop),()=>{window.removeEventListener(`dragover`,over),window.removeEventListener(`dragenter`,enter),window.removeEventListener(`dragleave`,exit),window.removeEventListener(`drop`,drop)}},[ee]);let U=c(()=>({session:e,store:r,entries:i,engine:s,browse:()=>_(!0),switchTo:e=>V({kind:`open`,folder:e}),closeProject:()=>V({kind:`close`}),upload:()=>F.current?.click(),newFile:e=>M(e),downloadFile:e=>{let t=r.doc(e.path);(t&&t.phase===`ready`?Promise.resolve(t.current):a(e.path)).then(t=>download(e.name,new Blob([t],{type:`application/octet-stream`})),e=>H.error(messageFrom(e)))},downloadArchive:()=>{i.archiveUrl(e.id).then(e=>{let t=document.createElement(`a`);t.href=e,t.rel=`noopener`,t.download=``,document.body.appendChild(t),t.click(),t.remove()},e=>H.error(messageFrom(e)))}}),[e,r,i,s,V,a]),te=r.dirtyPaths().length,addFiles=async e=>{for(let t of e)await r.create(t.rel,t.content);await r.refresh();let t=r.snapshot().listing.files.find(t=>t.rel===e[0]?.rel);t&&await r.open(t.path,t.kind)};return l(li.Provider,{value:U,children:[d,l(`input`,{ref:F,class:`web-projects__picker`,type:`file`,multiple:!0,accept:wi,tabIndex:-1,"aria-hidden":`true`,onChange:e=>{let t=e.target;ee(Array.from(t.files??[])),t.value=``}}),p.gone&&!p.away&&l(`div`,{class:`web-projects__gone`,role:`alert`,children:[l(Icon$1,{name:`alert`}),l(`span`,{class:`web-projects__gone-text type-body`,children:m(`app.web.project.gone`,{name:L})}),l(`button`,{type:`button`,class:`ui-button type-button`,onClick:()=>_(!0),children:m(`app.web.project.openAnother`)}),l(`button`,{type:`button`,class:`ui-button type-button`,onClick:()=>V({kind:`close`}),children:m(`app.web.project.close`)})]}),D&&l(`div`,{class:`web-projects__drop`,"aria-hidden":`true`,children:l(`p`,{class:`web-projects__drop-text type-body`,children:m(`app.web.upload.drop`)})}),g&&l(FolderBrowser,{folders:e.host.folders,recent:p.recent??[],onChoose:async e=>{e===p.project.folder?_(!1):(_(!1),V({kind:`open`,folder:e}))},onClose:()=>_(!1)}),v&&l(q,{title:v.kind===`open`?m(`app.web.project.unsavedOpenTitle`):m(`app.web.project.unsavedCloseTitle`),size:`small`,destructive:!0,onClose:()=>!x&&b(null),footer:l(Y,{actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:()=>b(null),disabled:x},{id:`discard`,label:m(`app.web.unsaved.discard`),role:`secondary`,onClick:()=>void B(v),disabled:x},{id:`save`,label:m(`app.web.project.saveAll`),role:`primary`,busy:x,onClick:()=>{S(!0),w(null),r.saveAll().then(e=>{e?B(v):(S(!1),w(m(`app.web.project.saveAllFailed`)))})}}]}),children:[l(`p`,{class:`web-dialog-text type-body`,children:m(`app.web.project.unsavedText`,{count:te})}),C&&l(`p`,{class:`web-dialog-text type-error-message`,role:`alert`,children:C})]}),T&&k&&l(k.component,{files:T,existing:h.listing.files,folders:h.listing.folders,onUpload:addFiles,onClose:()=>E(null)}),j!==null&&N&&l(N.component,{files:h.listing.files,engine:s,initialFolder:j,onCreate:(e,t)=>addFiles([{rel:e,content:t}]),onClose:()=>M(null)}),p.away&&l(q,{title:m(`app.web.project.awayTitle`),size:`small`,backdrop:`keep`,onClose:()=>e.reloadPage(),footer:l(Y,{actions:[{id:`reload`,label:m(`app.common.reload`),role:`primary`,onClick:()=>e.reloadPage()}]}),children:l(`p`,{class:`web-dialog-text type-body`,children:m(`app.web.project.awayText`)})})]})}function Welcome({session:e}){let n=useSession(e),[r,i]=t(!1),[a,o]=t(null),[s,c]=t(null),[u,d]=t(!1);f(()=>{e.loadRecent().catch(()=>d(!0))},[e]);let openFolder=async t=>{o(null),c(t);try{await e.open(t)}catch(e){throw o(e instanceof Error&&e.message?e.message:m(`app.web.unknownFailure`)),c(null),e}},p=n.recent??[];return l(`main`,{class:`web-start`,children:[l(`section`,{class:`web-start__card`,"aria-labelledby":`web-start-title`,children:[l(`h1`,{id:`web-start-title`,class:`web-start__title type-dialog-title`,children:m(`app.web.welcome.title`)}),l(`p`,{class:`web-start__text type-body`,children:m(`app.web.welcome.text`)}),l(`div`,{class:`web-start__actions`,children:l(`button`,{type:`button`,class:`ui-button ui-button--primary type-button`,onClick:()=>i(!0),disabled:s!==null,children:m(`app.web.welcome.open`)})}),l(`h2`,{class:`web-start__heading type-section-heading`,children:m(`app.web.welcome.recent`)}),n.recent!==null&&p.length===0&&l(`p`,{class:`web-start__none type-help`,children:m(`app.web.welcome.noRecent`)}),u&&l(`p`,{class:`web-start__none type-help`,children:m(`app.web.welcome.recentFailed`)}),p.length>0&&l(`ul`,{class:`web-start__recent`,"aria-label":m(`app.web.welcome.recent`),children:p.map(t=>l(`li`,{class:`web-start__item`,children:[l(`button`,{type:`button`,class:`web-start__project type-body`,disabled:!t.present||s!==null,title:t.present?t.folder:m(`app.web.welcome.missing`,{folder:t.folder}),onClick:()=>void openFolder(t.folder).catch(()=>void 0),children:[l(Icon$1,{name:`process`}),l(`span`,{class:`web-start__name`,children:t.name}),l(`span`,{class:`web-start__folder type-help`,children:t.present?t.folder:m(`app.web.welcome.notFound`)})]}),l(`button`,{type:`button`,class:`web-start__forget`,"aria-label":m(`app.web.welcome.forget`,{name:t.name}),title:m(`app.web.welcome.forget`,{name:t.name}),disabled:s!==null,onClick:()=>void e.forget(t.folder).catch(()=>void 0),children:l(Icon$1,{name:`close`})})]},t.folder))}),a&&!r&&l(`div`,{role:`alert`,children:l(ke,{children:a})}),l(`p`,{class:`web-start__hint type-help`,children:m(`app.web.welcome.hint`)})]}),r&&l(FolderBrowser,{folders:e.host.folders,recent:p,onChoose:openFolder,onClose:()=>i(!1)})]})}var Ti=null,Ei=null;function setSuggestionProvider(e){Ti=e}function setProjectSuggestionProvider(e){Ei=e}function currentSuggestionProvider(){return Ti??Ei}function webShellEnvironment(e,t){return{...nn,mac:/Mac|iPhone|iPad/.test(navigator.platform),journal:t,loadSession:e=>sessionFrom(Z().webSessions?.[e]),saveSession:(e,t)=>{je({webSessions:{[e]:{...t,dock:t.dock}}})},autosave:()=>Z().webAutosaveSeconds??null,setAutosave:e=>je({webAutosaveSeconds:e}),theme:()=>currentThemeChoice(),setTheme:e=>chooseTheme(e),sidebar:()=>({open:Z().projectTreeHidden!==!0,width:clampSidebar(Z().projectTreeWidth??272)}),setSidebar:e=>je({projectTreeWidth:e.width,projectTreeHidden:!e.open}),runEditorAction:e=>{let t=window.penstockRunAction;return t?(t(e),!0):!1},licence:async()=>{try{let t=await e.getLicense();return t?t.detail||String(t.tier):null}catch{return null}},showLicence:()=>void e.showLicence(),notify:(e,t)=>t?H.error(e):H.info(e),copy:async e=>{try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}}}function startingLocale(e){let t=Z().locale;if(t)return h(t);let n=e?.locale;return n?h(n):p()}function followSystemTheme(e){let t=window.matchMedia?.(`(prefers-color-scheme: dark)`),n=themeNameFor(e?.theme,!!t?.matches);rememberHostTheme(n);try{applyTheme(n)}catch(e){console.error(`[Theme] Failed to initialize theme:`,e),applyTheme(_t)}applyThemeChoice(),followThemeChoice(),e?.theme&&e.theme.toUpperCase()!==`SYSTEM`||t?.addEventListener?.(`change`,e=>receiveHostThemeName(e.matches?`dark`:`light`))}function setupGlobalAppConfig(e){window.appConfig={theme:e?.theme||`light`,engine:e?.engine||null,scriptFormat:e?.scriptType||null,showBrowserToolBar:!1,project:e?.project||`Project`,bpmnFilePath:``,bpmnXml:``,elementTemplatesContent:cleanTemplates(e?.elementTemplatesContent),conventions:e?.conventions||{},palette:e?.palette??null,pluginVersion:e?.pluginVersion??null,gitUserName:e?.gitUserName??null,get isDarkMode(){return getCurrentTheme()===`dark`},get isDraculaMode(){return getCurrentTheme()===`dracula`},get isSketchyMode(){return Z().rendering===`sketchy`},async fetchConfig(){}},window.setTheme=receiveHostThemeName,window.setSuggestionProvider=setSuggestionProvider}function reloadPage(){window.location.reload()}async function start(){let e=document.getElementById(`app`);try{if(!e)throw Error(`Root element with id "app" not found in HTML`);let t=new WebPlatformBridge;A(t);let n=await ye().bpmn.getConfig();await Ae(),await Se(),Ne();let r=startingLocale(n);await _(r).catch(e=>console.error(`[i18n] The catalogue for`,r,`did not load, English is shown:`,e)),v(r),document.documentElement.lang=g(),translatePanelLabels(),followSystemTheme(n),setupGlobalAppConfig(n);let i=webHost(t.web),a=new ProjectSession(i,await i.current());if(t.bindProject(()=>a.id,e=>a.noticeProjectId(e)),!a.snapshot().project.open){s(l(Te,{locale:g(),children:l(be,{onReload:reloadPage,children:l(Welcome,{session:a})})}),e),document.title=m(`app.web.pageTitle`);return}let o=`p${Date.now().toString(36)}${Math.random().toString(36).slice(2,10)}`;pageLock(o);let c=new DraftJournal(typeof indexedDB>`u`?new MemoryDrafts:new IndexedDbDrafts,{owner:o}),u=webShellEnvironment(t,c),d={store:null},f=new We({host:bridgeHost(t,n?.pluginVersion??null,e=>d.store?.doc(e)?.current??null),notify:u.notify,drafts:c});d.store=f;let p=new ScriptHub;t.bindWorkspace(new Workspace({store:f,scripts:p})),installDesktop(f),t.bindActiveFile(()=>f.snapshot().active),f.subscribe(()=>{let e=f.snapshot().active,n=window.appConfig;n&&(n.bpmnFilePath=e?Be(e):``),t.bindActiveDocument(e?t=>f.edit(e,t):null)});let h=new URLSearchParams(window.location.search).get(`file`),y=me();ge(y),window.addEventListener(`pagehide`,()=>y?.dispose());let b=new ToolWindowStore(toolApi(t),toolEffects(t,toolEnvironment(u,f))),Root=()=>l(ProjectFrame,{session:a,store:f,entries:i,readText:e=>t.readFile(e),engine:n?.engine,toolWindow:b,children:l(WebShell,{store:f,scripts:p,loaders:Nt,engine:n?.engine,deepLink:h,toolWindow:b,env:u})});s(l(Te,{locale:g(),children:l(be,{onReload:reloadPage,children:l(Root,{})})}),e),document.title=m(`app.web.pageTitle`),showFavicon(!1)}catch(t){console.error(`[Init] The web editor could not start:`,t),showStartupFailure(e,t)}}start();export{onSourceFocus as $,observeCorner as A,compareTexts as B,useRevealCount as C,tabList as Ct,AssistantDock as D,toggleHidden as Dt,ti as E,toggleCollapsed as Et,motionMs as F,Icon$1 as G,TabIcon as H,reducedMotion as I,PreviewPane as J,iconOfGroup as K,Tr as L,installScenarioOpener as M,takeScenarioRequest as N,Gr as O,widthLimits as Ot,useScenarioRequest as P,lineWanted as Q,useEditorActive as R,useLeaveChatTab as S,shownTab as St,ei as T,toPreferences as Tt,useLicence as U,hunksOf as V,paidTier as W,ensurePreviewStyle as X,computeChanges as Y,unpackComparison as Z,publishFacts as _,popView as _t,targetLabel as a,getCurrentTheme as at,useChatAction as b,resolveWidth as bt,useFocusCanvasShortcut as c,arrowTab as ct,domId as d,droppedTabs as dt,bt as et,groupOfKind as f,fromPreferences as ft,ToolbarButton as g,isSidebarShortcut as gt,Icon as h,isRepeatOfPress as ht,deployWithHost as i,applyTheme as it,AssistantRuntime as j,measureCorner as k,suggestsFields as l,badgeLabel as lt,nameFault as m,isRenameKey as mt,setProjectSuggestionProvider as n,currentThemeChoice as nt,toggleFocusCanvas as o,toggleDarkMode as ot,messageFrom$1 as p,isDrawer as pt,registerEditCommands as q,acceptedUpload as r,gt as rt,useFocusCanvas as s,cleanTemplates as st,currentSuggestionProvider as t,chooseTheme as tt,suggestsNextBlock as u,badgeText as ut,retractFacts as v,pushView as vt,useAssistantEditor as w,titleCommit as wt,useChatStatus as x,selectTab as xt,useAiChatPlace as y,resetViews as yt,useEditorElement as z};
|