@smartkomm/plexus-cli 0.1.58 → 0.1.60

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/cli.mjs CHANGED
@@ -5903,7 +5903,7 @@ plexus-cli --env prod demo link delete --allow-prod <code> --confirm # deletes,
5903
5903
 
5904
5904
  ## Related
5905
5905
  - \`plexus-cli demo link stats --json\` for further processing (e.g. \`jq\`).
5906
- `,"references/notifications/debug-mail-delivery.md":'# Debug a mail delivery\n\n**When:** "no mail arrived", a red `deadLastHour` badge in the platform\nconsole, or a `backend:convex` GlitchTip issue tagged `area=notifications`.\n\n## 1. Is the sweeper alive, and is anything dead?\n\n```bash\nplexus-cli --env staging platform notifications sweeper-status\nplexus-cli --env staging platform notifications list --status dead\n```\n\n`ranAt` older than a few minutes \u21D2 the cron is not firing (deploy broke?).\n`deadLastHour > 0` \u21D2 go to step 3 with an id from the list.\n\n## 2. Find the delivery for a person\n\n```bash\nplexus-cli --env staging platform notifications list --to parent@example.org --since 2d\nplexus-cli --env staging platform notifications list --template account.loginLink --since 24h\n```\n\nFor a sign-in problem start with `platform users login-trail` instead \u2014 see\n[Trace why someone could not sign in](./trace-a-login.md).\n\nStatuses: `queued` (waiting / backoff), `sending` (in flight), `sent` (relay\naccepted \u2014 NOT "in the inbox"), `skipped` (a successful non-send: recipient\ngone, precondition no longer true, reserved TLD \u2014 in `live` every RFC 2606\naddress, in `redirect` only `.invalid`), `dead` (gave up).\n\n## 3. Read the evidence\n\n```bash\nplexus-cli --env staging platform notifications show <deliveryId>\n```\n\n| `errorCode` | Means | Do |\n| --- | --- | --- |\n| `delivery_mode_invalid` / `config_missing` | deployment env is incomplete | needs a platform operator: complete the deployment\'s mail settings, then `retry` |\n| `smtp_auth` | relay rejected the credentials | needs a platform operator: rotate the relay password in the deployment\'s settings, then `retry` |\n| `smtp_policy` | relay rejected OUR sender at `MAIL FROM` | `MAIL_FROM_ADDRESS` not allowed for this account \u2014 ask the mail admin |\n| `smtp_content` with 4xx at `DATA` | milter (DKIM) hiccup \u2014 retried automatically | if it stays: the relay\'s DKIM key/permissions \u2014 ask the mail admin |\n| `smtp_recipient_rejected` | 5xx at `RCPT TO` | the address does not exist \u2014 nothing to retry |\n| `recipient_revoked` / `recipient_changed` / `recipient_deleted` | identity changed after enqueue | expected; re-raise the event if still wanted |\n| `never_claimed` | the dispatch action fails BEFORE it can claim | bundle/import problem \u2014 needs a platform operator (deployment logs of the action), fix, `retry` |\n| `unknown_outcome` | action died after SMTP began | the recipient MAY have received it; decide, then `retry` |\n\n`lastSmtpCommand` / `lastSmtpResponseCode` / `lastSmtpResponse` carry the raw\nrelay line. `possibleDuplicate: true` means attempt N may already have landed.\n\n## 4. Prove the configuration end to end\n\n```bash\nplexus-cli --env staging platform notifications self-test --to <your-address>\n```\n\nVerifies the connection + credentials, sends one mail, returns the SMTP\ntranscript. On staging the mail is redirected like every other; on prod it\nreally goes to `--to`.\n\n## 5. Retry\n\n```bash\nplexus-cli --env staging platform notifications retry <deliveryId>\n```\n\nOnly `dead` rows. It is a fresh attempt through the normal claim path \u2014 the\nretry budget is widened by exactly one.\n\n## Gotchas\n\n- `sent` = accepted by the relay. The last hop (relay \u2192 GMX) is invisible; on\n staging the platform operator reads the catch-all mailbox.\n- A `451` is not always transient: the relay says `451 4.7.1` for a\n sender-policy violation and for a broken DKIM key. Look at the COMMAND.\n- Locally nothing is ever sent (`dry`): the mail is in the Dev Rail \u2192\n `notifications:listDevPreviews`.\n',"references/notifications/mail-level.md":'# Choose which mail a school sends (mail level)\n\n> **Version check first.** A deployment on a release older than the mail level\n> ignores `--field mailLevel` WITHOUT an error and keeps reading the retired\n> `tenant.enabledMailCategories` (`[]` = sign-in only, every category = all).\n> If `config export` shows no `mailLevel`, stop and ask the platform operator.\n> The same skew means a tenant scaffolded with a newer CLI against an older\n> deployment starts at sign-in mail only.\n\n**When to use:** a school wants only the sign-in links for FAMILIES for now\n(\u201EAnmeldelinks ja, alles andere nein"), or is ready for every mail.\n\n**The level is family mail only.**\nLetters to the school\'s own staff (`audience: "internal"`: new tasks, passed\ndeadlines, family messages, mentions) go out at BOTH levels; each staff member\ndecides them in \u201EEinstellungen" (personal categories, runbook \u201EWhich mail a\nstaff member wants"). Do not use the level to quiet staff mail.\n\n**Current stance:** every tenant \u2014 prod, staging and the `test` demo tenant \u2014\nruns `loginOnly` until the platform operator decides otherwise. Switching a real\nschool to `all` is that decision, not a routine step. Only a local full seed\nputs the `test` demo tenant at `all`, so locally every admission, family-task and\nschool-chat letter is rendered (a local deployment sends no mail); the template\nstaging and prod apply stays `loginOnly`. On a local deployment that was not\nseeded that way, set it to `all` yourself (`--env local`). Staff letters render\nat both levels.\n\n## What it is\n\n- A school has ONE setting, its **mail level** (`tenant.mailLevel`, required in\n every tenant config):\n - `loginOnly` \u2014 \u201EAn Familien nur Anmeldelinks": to families, sign-in links,\n the access a school hands out, address confirmations (\u201EBewerbung\n begonnen/geparkt" included) and security notices about one\'s own account\n (e.g. a changed login address).\n - `all` \u2014 \u201EAlle E-Mails": to families additionally admission, family task\n reminders and the school\'s chat messages.\n- Every letter still declares a **category** in code (`login`, `security`,\n `admission`, `tasks`, `schoolMessages`; for staff the personal `staffTasks`,\n `staffAppointments`, `staffDeadlines`, `staffWaitlist`, `familyMessages`,\n `mentions`). It names\n the letter in a skipped delivery\'s reason; a school cannot switch single\n categories.\n- The `notifications` module must be enabled for `all`; with the module off only\n sign-in and security mail go out whatever the level says.\n- Refused by `config set` / `config apply`: a missing or unknown level\n (`[notification/mailLevel]`), `all` without the `notifications` module\n (`[notification/levelWithoutModule]`), and the retired spellings\n `tenant.enabledMailCategories` (`[notification/mailCategoriesRetired]`)\n and `tenant.mailEnabled` (`[notification/mailEnabledRetired]`) \u2014 a scratch\n export from before the mail level must be rewritten, not applied.\n- `MAIL_DELIVERY_MODE` of the deployment stays the outer boundary. Never change\n it for this.\n\n## Set it (dry run first)\n\n```bash\n# sign-in mail only\nplexus-cli --env staging config set --tenant <slug> --target tenant \\\n --key <slug> --field mailLevel --value loginOnly\nplexus-cli --env staging config set --tenant <slug> --target tenant \\\n --key <slug> --field mailLevel --value loginOnly --confirm\n\n# everything (what the introduction of the level wrote for every school that sent mail)\nplexus-cli --env staging config set --tenant <slug> --target tenant \\\n --key <slug> --field mailLevel --value all --confirm\n```\n\nThrough a scratch export instead: `config export` \u2192 set\n`"tenant": { \u2026, "mailLevel": "loginOnly" }` \u2192 `config apply --from snapshot:\u2026`.\n\n## Verify\n\n- `plexus-cli --env <env> config export --tenant <slug>` shows `mailLevel`\n (always emitted; an existing snapshot file is replaced only with `--force`).\n- Platform rail \u2192 **Mandanten** (needs `_platform.config.read`): the column\n \u201EE-Mails" says \u201ENur Anmeldelinks" (amber) or \u201EAlle E-Mails" \u2014 as the send\n path answers it, so module off reads \u201ENur Anmeldelinks" too.\n- Dashboard of the school: banner \u201EHinweis zur Konfiguration" on top of the\n page, gap `mailDisabled` (\u201EDiese Schule versendet nur Anmeldelinks \u2026") \u2014\n unless the school hides that notice: `config set --tenant <slug> --target tenant\n --key <slug> --field hideMailLevelNotice --value true --confirm` (mail-module setting, shown under\n \u201Enotifications" in Platform \u2192 Mandanten; the test tenant does). Only this\n notice goes; a configuration error always shows.\n- A suppressed letter is a row: `plexus-cli --env <env> notifications \u2026` lists it\n `skipped`, `tenant_delivery_disabled`, last error\n `the school\'s mail level does not send "<category>" mail`.\n\n## Gotchas\n\n- A skipped delivery is never re-sent when the level goes back to `all` \u2014 the\n setting decides at enqueue AND at send time, not retroactively.\n- `applicant.accessSent` (\u201EZugang versenden \u2192 Per Mail senden") is `login`: it\n goes out at `loginOnly`.\n',"references/notifications/reword-a-letter.md":`# Reword a letter for one school
5906
+ `,"references/notifications/debug-mail-delivery.md":'# Debug a mail delivery\n\n**When:** "no mail arrived", a red `deadLastHour` badge in the platform\nconsole, or a `backend:convex` GlitchTip issue tagged `area=notifications`.\n\n## 1. Is the sweeper alive, and is anything dead?\n\n```bash\nplexus-cli --env staging platform notifications sweeper-status\nplexus-cli --env staging platform notifications list --status dead\n```\n\n`ranAt` older than a few minutes \u21D2 the cron is not firing (deploy broke?).\n`deadLastHour > 0` \u21D2 go to step 3 with an id from the list.\n\n## 2. Find the delivery for a person\n\n```bash\nplexus-cli --env staging platform notifications list --to parent@example.org --since 2d\nplexus-cli --env staging platform notifications list --template account.loginLink --since 24h\n```\n\nFor a sign-in problem start with `platform users login-trail` instead \u2014 see\n[Trace why someone could not sign in](./trace-a-login.md).\n\nStatuses: `queued` (waiting / backoff), `sending` (in flight), `sent` (relay\naccepted \u2014 NOT "in the inbox"), `skipped` (a successful non-send: recipient\ngone, precondition no longer true, reserved TLD \u2014 in `live` every RFC 2606\naddress, in `redirect` only `.invalid`), `dead` (gave up).\n\n## 3. Read the evidence\n\n```bash\nplexus-cli --env staging platform notifications show <deliveryId>\n```\n\n| `errorCode` | Means | Do |\n| --- | --- | --- |\n| `delivery_mode_invalid` / `config_missing` | deployment env is incomplete | needs a platform operator: complete the deployment\'s mail settings, then `retry` |\n| `smtp_auth` | relay rejected the credentials | needs a platform operator: rotate the relay password in the deployment\'s settings, then `retry` |\n| `smtp_policy` | relay rejected OUR sender at `MAIL FROM` | `MAIL_FROM_ADDRESS` not allowed for this account \u2014 ask the mail admin |\n| `smtp_content` with 4xx at `DATA` | milter (DKIM) hiccup \u2014 retried automatically | if it stays: the relay\'s DKIM key/permissions \u2014 ask the mail admin |\n| `smtp_recipient_rejected` | 5xx at `RCPT TO` | the address does not exist \u2014 nothing to retry |\n| `recipient_revoked` / `recipient_changed` / `recipient_deleted` | identity changed after enqueue | expected; re-raise the event if still wanted |\n| `never_claimed` | the dispatch action fails BEFORE it can claim | bundle/import problem \u2014 needs a platform operator (deployment logs of the action), fix, `retry` |\n| `unknown_outcome` | action died after SMTP began | the recipient MAY have received it; decide, then `retry` |\n\n`lastSmtpCommand` / `lastSmtpResponseCode` / `lastSmtpResponse` carry the raw\nrelay line. `possibleDuplicate: true` means attempt N may already have landed.\n\n## 4. Prove the configuration end to end\n\n```bash\nplexus-cli --env staging platform notifications self-test --to <your-address>\n```\n\nVerifies the connection + credentials, sends one mail, returns the SMTP\ntranscript. On staging the mail is redirected like every other; on prod it\nreally goes to `--to`.\n\n## 5. Retry\n\n```bash\nplexus-cli --env staging platform notifications retry <deliveryId>\n```\n\nOnly `dead` rows. It is a fresh attempt through the normal claim path \u2014 the\nretry budget is widened by exactly one.\n\n## Gotchas\n\n- `sent` = accepted by the relay. The last hop (relay \u2192 GMX) is invisible; on\n staging the platform operator reads the catch-all mailbox.\n- A `451` is not always transient: the relay says `451 4.7.1` for a\n sender-policy violation and for a broken DKIM key. Look at the COMMAND.\n- Locally nothing is ever sent (`dry`): the mail is in the Dev Rail \u2192\n `notifications:listDevPreviews`.\n',"references/notifications/mail-level.md":'# Choose which mail a school sends (mail level)\n\n> **Version check first.** A deployment on a release older than the mail level\n> ignores `--field mailLevel` WITHOUT an error and keeps reading the retired\n> `tenant.enabledMailCategories` (`[]` = sign-in only, every category = all).\n> If `config export` shows no `mailLevel`, stop and ask the platform operator.\n> The same skew means a tenant scaffolded with a newer CLI against an older\n> deployment starts at sign-in mail only.\n\n**When to use:** a school wants only the sign-in links for FAMILIES for now\n(\u201EAnmeldelinks ja, alles andere nein"), or is ready for every mail.\n\n**The level is family mail only.**\nLetters to the school\'s own staff (`audience: "internal"`: new tasks, passed\ndeadlines, family messages, mentions) go out at BOTH levels; each staff member\ndecides them in \u201EEinstellungen" (personal categories, runbook \u201EWhich mail a\nstaff member wants"). Do not use the level to quiet staff mail.\n\n**Current stance:** every tenant \u2014 prod, staging and the `test` demo tenant \u2014\nruns `loginOnly` until the platform operator decides otherwise. Switching a real\nschool to `all` is that decision, not a routine step. Only a local full seed\nputs the `test` demo tenant at `all`, so locally every admission, family-task and\nschool-chat letter is rendered (a local deployment sends no mail); the template\nstaging and prod apply stays `loginOnly`. On a local deployment that was not\nseeded that way, set it to `all` yourself (`--env local`). Staff letters render\nat both levels.\n\n## What it is\n\n- A school has ONE setting, its **mail level** (`tenant.mailLevel`, required in\n every tenant config):\n - `loginOnly` \u2014 \u201EAn Familien nur Anmeldelinks": to families, sign-in links,\n the access a school hands out, address confirmations (\u201EBewerbung\n begonnen/geparkt" included), security notices about one\'s own account\n (e.g. a changed login address) and the family\'s deadline letters (the\n reminder before a task\'s due day and the letter after it passed).\n - `all` \u2014 \u201EAlle E-Mails": to families additionally admission, family task\n reminders and the school\'s chat messages.\n- Every letter still declares a **category** in code (`login`, `security`,\n `admission`, `tasks`, `deadlines`, `schoolMessages`; for staff the personal `staffTasks`,\n `staffAppointments`, `staffDeadlines`, `staffWaitlist`, `familyMessages`,\n `mentions`). It names\n the letter in a skipped delivery\'s reason; a school cannot switch single\n categories.\n- The `notifications` module must be enabled for `all`; with the module off only\n sign-in and security mail go out whatever the level says.\n- Refused by `config set` / `config apply`: a missing or unknown level\n (`[notification/mailLevel]`), `all` without the `notifications` module\n (`[notification/levelWithoutModule]`), and the retired spellings\n `tenant.enabledMailCategories` (`[notification/mailCategoriesRetired]`)\n and `tenant.mailEnabled` (`[notification/mailEnabledRetired]`) \u2014 a scratch\n export from before the mail level must be rewritten, not applied.\n- `MAIL_DELIVERY_MODE` of the deployment stays the outer boundary. Never change\n it for this.\n\n## Set it (dry run first)\n\n```bash\n# sign-in mail only\nplexus-cli --env staging config set --tenant <slug> --target tenant \\\n --key <slug> --field mailLevel --value loginOnly\nplexus-cli --env staging config set --tenant <slug> --target tenant \\\n --key <slug> --field mailLevel --value loginOnly --confirm\n\n# everything (what the introduction of the level wrote for every school that sent mail)\nplexus-cli --env staging config set --tenant <slug> --target tenant \\\n --key <slug> --field mailLevel --value all --confirm\n```\n\nThrough a scratch export instead: `config export` \u2192 set\n`"tenant": { \u2026, "mailLevel": "loginOnly" }` \u2192 `config apply --from snapshot:\u2026`.\n\n## Verify\n\n- `plexus-cli --env <env> config export --tenant <slug>` shows `mailLevel`\n (always emitted; an existing snapshot file is replaced only with `--force`).\n- Platform rail \u2192 **Mandanten** (needs `_platform.config.read`): the column\n \u201EE-Mails" says \u201ENur Anmeldelinks" (amber) or \u201EAlle E-Mails" \u2014 as the send\n path answers it, so module off reads \u201ENur Anmeldelinks" too.\n- Dashboard of the school: banner \u201EHinweis zur Konfiguration" on top of the\n page, gap `mailDisabled` (\u201EDiese Schule versendet nur Anmeldelinks \u2026") \u2014\n unless the school hides that notice: `config set --tenant <slug> --target tenant\n --key <slug> --field hideMailLevelNotice --value true --confirm` (mail-module setting, shown under\n \u201Enotifications" in Platform \u2192 Mandanten; the test tenant does). Only this\n notice goes; a configuration error always shows.\n- A suppressed letter is a row: `plexus-cli --env <env> notifications \u2026` lists it\n `skipped`, `tenant_delivery_disabled`, last error\n `the school\'s mail level does not send "<category>" mail`.\n\n## Gotchas\n\n- A skipped delivery is never re-sent when the level goes back to `all` \u2014 the\n setting decides at enqueue AND at send time, not retroactively.\n- `applicant.accessSent` (\u201EZugang versenden \u2192 Per Mail senden") is `login`: it\n goes out at `loginOnly`.\n',"references/notifications/reword-a-letter.md":`# Reword a letter for one school
5907
5907
 
5908
5908
  **When to use:** a school wants one of the mails Plexus sends in its name to say
5909
5909
  something else \u2014 a different opening paragraph, its own sign-off \u2014 and you want
@@ -10198,8 +10198,8 @@ plexus-cli --env prod jobs list --status running # nothing unexpectedly in
10198
10198
  ## Related
10199
10199
  - Command reference: \`plexus-cli jobs list --help\`, \`plexus-cli platform workers reap --help\`,
10200
10200
  \`plexus-cli platform imports cleanup-orphaned --help\`.
10201
- `};var Mu="e6ba1aa3ec616859e2f90fea8f92cb4bd5f5d1490176fbc4983bdfd72a3d8cf5",Sg=K$;var Ag=class extends Se{static{s(this,"AgentToolsCommand")}static paths=[["agent","tools"]];static usage=R.Usage({category:"Agents",description:"Show the shared platform/CLI agent tool schemas and skill revision."});async execute(){return this.print({skillHash:Mu,tools:Ya}),0}},Eg=class extends Se{static{s(this,"AgentInvokeCommand")}static paths=[["agent","invoke"]];static usage=R.Usage({category:"Agents",description:"Invoke a shared agent tool; pipe its JSON input on stdin."});tool=p.String("--tool",{required:!0,description:"plexus|plexus_skill|plexus_workspace"});async execute(){if("isTTY"in this.context.stdin&&this.context.stdin.isTTY===!0)throw new Error("plexus: pipe the tool's JSON input on stdin.");let t=JSON.parse(await xg(this.context.stdin)),n=await this.context.executePlexusAgentTool(this.tool,t);return this.print(n),0}},j$=[Ag,Eg];var Tg=[{key:"fixture_test",email:"test@example.com",firstName:"Test",lastName:"Bewerber"}],xoe=new Set(Tg.map(e=>e.key));function U$(e,t,n,r){let i=e.flatMap(l=>l.angebote).find(l=>l.offerKey===t);if(i===void 0){let l=e.flatMap(d=>d.angebote.map(c=>c.offerKey));throw new Error(`applications start-test: no offer "${t}" (offers: ${l.join(", ")||"none"})`)}let o=i.stages.find(l=>l.stageKey===r||l.stageId===r);if(o===void 0){let l=i.stages.map(d=>`${d.stageKey} (${d.stageId})`);throw new Error(`applications start-test: no level "${r}" in ${t} \u2014 name it by key or id: ${l.join(", ")}`)}let a=o.runs.find(l=>l.runKey===n||l.runId===n);if(a===void 0){let l=o.runs.map(d=>`${d.runKey} (${d.runId})`);throw new Error(`applications start-test: no school year "${n}" for level ${o.stageKey} \u2014 name it by key or id: ${l.join(", ")}`)}if(!a.isOpen)throw new Error(`applications start-test: school year ${a.runKey} is closed for level ${o.stageKey}`);return{programRunId:a.runId,programStageId:o.stageId}}s(U$,"resolveStartTarget");function yV(e){return e.kind==="named"?e.name:`(${e.standIn??e.fallback})`}s(yV,"applicantText");function V$(e){return e.map(t=>({id:t.application._id,status:t.deletedAt?`${t.application.status} (gel\xF6scht)`:t.application.status,state:t.currentProcessStateId??"",applicant:yV(t.applicantName),test:t.application.testMode===!0?"test":""}))}s(V$,"applicationRows");var B$=Tg.map(e=>e.email);function G$(e,t,n,r){if(n===void 0&&r===void 0)throw new Error("applications start-test: name the applicant \u2014 --party <partyId> or --applicant <email>");if(n!==void 0&&r!==void 0)throw new Error("applications start-test: --party or --applicant, not both");if(kg(e,t)&&(r===void 0||!B$.includes(r.trim().toLowerCase())))throw new Error(`applications start-test: on prod only for the test account ${B$.join(", ")} (--applicant) \u2014 never a real family's`)}s(G$,"assertStartApplicant");function z$(e){let t={};for(let{address:n,...r}of e.entries)t[n]=r;return{applicationId:e.applicationId,store:t}}s(z$,"processStoreJson");function wV(e){switch(e.kind){case"form":return`form ${e.formInstanceId} (${e.state})`;case"document":return e.file===null?`document ${e.slotKey} (leer)`:`document ${e.slotKey} \xB7 v${e.file.versionNumber} ${e.file.filename??e.file.artifactId}`;case"contract":return`contract ${e.contractId} \xB7 ${e.revision===null?"keine Fassung":`Fassung ${e.revision.revisionNumber}`} \xB7 ${e.contractStatus}`;case"contracts":return e.contracts.map(t=>`${t.partKey}: contract ${t.contractId} \xB7 ${t.revision===null?"keine Fassung":`Fassung ${t.revision.revisionNumber}`} \xB7 ${t.contractStatus}`).join("; ")}}s(wV,"refText");function kV(e){return e.state!=="present"?e.reason?.de??"":e.ref!==void 0?wV(e.ref):JSON.stringify(e.value)}s(kV,"holds");function W$(e){return e.entries.map(t=>({address:t.address,state:t.state,holds:kV(t),producer:t.producer?.label??"",written:t.writtenAt===void 0?"":new Date(t.writtenAt).toISOString()}))}s(W$,"storeRows");function qu(e){let t={},n={};for(let r of e){let i=r.indexOf("=");if(i<=0)throw new Error(`Expected key=value, got '${r}'.`);let o=r.slice(0,i);if(Object.hasOwn(n,o))throw new Error(`'${o}' is given twice.`);let a=r.slice(i+1);n[o]=a;try{t[o]=JSON.parse(a)}catch{t[o]=a}}return{values:t,raw:n}}s(qu,"parseKv");var Y$="started",Ku="submitted",ju="submitted",H$="load-scenario:";var J$="(Bewerbung)";function Q$(e){return{nodeId:J$,actions:e.map(t=>({id:t.id,label:{de:`${t.label??t.id}${t.count===void 0?"":` (${t.count})`}`,en:`${t.label??t.id}${t.count===void 0?"":` (${t.count})`}`},...t.disabledReason===void 0?{}:{disabledReason:t.disabledReason}}))}}s(Q$,"sharedAsList");function Z$(e){return e.disabledReason===void 0?"":e.disabledCount===void 0?e.disabledReason:`${e.disabledReason} (${e.disabledCount})`}s(Z$,"disabledText");function X$(e){return e.flatMap(({nodeId:t,actions:n})=>n.map(r=>({node:t,action:r.id,label:r.label.de,disabled:Z$(r)})))}s(X$,"actionRows");function eR(e,t,n=[]){let r=e.filter(({actions:d})=>d.some(c=>c.id===t));if(r.length===0){let d=[...new Set(e.flatMap(({actions:c})=>c.map(u=>u.id)))];throw new Error(`test-actions run: no current node offers "${t}" (offered: ${d.join(", ")||"nothing"})`)}if(r.length>1)throw new Error(`test-actions run: "${t}" is offered by ${r.map(d=>d.nodeId).join(", ")} \u2014 pass --node`);let{nodeId:i,actions:o}=r[0],a=o.find(d=>d.id===t);if(a.disabledReason!==void 0)throw new Error(`test-actions run: "${t}" on ${i} is disabled: ${Z$(a)}`);if(i!==J$)return i;let l=n[0];if(l===void 0)throw new Error(`test-actions run: "${t}" needs a current node \u2014 the application has none`);return l}s(eR,"nodeOfferingAction");function tR(e,t,n){if(e.startsWith(H$)){if(Object.hasOwn(n,"autoSubmit"))throw new Error(`test-actions run: ${e}: a scenario's autoSubmit is set by --auto-submit / --no-auto-submit, not --param`);return{autoSubmit:t,...n}}return Object.keys(n).length===0?void 0:{...n}}s(tR,"runParams");async function bV(e,t){let n=await e.query(S.workflow.getInstance,{applicationId:t});if(n===null)throw new Error(`test-actions: application ${t} has no workflow instance`);return n.instance.currentNodeIds}s(bV,"currentNodeIds");function vV(e,t){switch(t){case"notTestApplication":return`${e} is not a test application`;case"completed":case"aborted":case"deleted":return`${e} is ${t} \u2014 test actions run only on an active application`;case"missingPermission":return"the caller lacks bewerbungsmanagement.testActions.run"}}s(vV,"refusalText");async function Bu(e,t,n){let r=await e.query(S.workflow.listSharedTestActions,{applicationId:t});if(!r.permitted)throw new Error(`test-actions: not permitted \u2014 ${vV(t,r.reason)}`);let i=[];for(let o of n){let a=await e.query(S.workflow.listTestActions,{applicationId:t,nodeId:o});if(a===null)throw new Error(`test-actions: node "${o}" is not in this application's workflow (or it has no instance)`);i.push({nodeId:o,actions:a})}return[...i,Q$(r.actions)]}s(Bu,"actionsOf");async function nR(e,t,n){return n!==void 0?[n]:await bV(e,t)}s(nR,"nodesOf");var $g=class extends N{static{s(this,"TestActionsListCommand")}static paths=[["test-actions","list"]];static usage=R.Usage({category:"Admission",description:"List the test-mode actions of the application's current node(s) (scenarios, auto-fill-files, submit, \u2026) and the application-wide ones"});application=p.String("--application",{required:!0,description:"Application id (a test application)"});node=p.String("--node",{description:"Node id (default: the application's current nodes)"});async execute(){let t=await this.caller(),n=await Bu(t,this.application,await nR(t,this.application,this.node));return this.print(n,X$,["node","action","label","disabled"]),0}},Rg=class extends N{static{s(this,"TestActionsRunCommand")}application=p.String("--application",{required:!0,description:"Application id (a test application)"});node=p.String("--node",{description:"Node id (default: the application's current nodes)"});static paths=[["test-actions","run"]];static usage=R.Usage({category:"Admission",description:"Run one test-mode action; a scenario (load-scenario:<id>) also submits unless --no-auto-submit"});action=p.String("--action",{required:!0,description:"Action id, e.g. load-scenario:standard, auto-fill-files, submit-form"});autoSubmit=p.Boolean("--auto-submit",!0,{description:"Scenario only: stub the file fields and submit after loading (default on; --no-auto-submit only loads)"});param=p.Array("--param",{description:"Action parameter key=value (repeatable; the value is JSON where it parses, else text), e.g. --param confirmed=true for an action that asks a question first (upload-signed-document)"});async execute(){let t=tR(this.action,this.autoSubmit,qu(this.param??[]).values),n=await this.caller(),r=this.application,i=await nR(n,this.application,this.node),o=eR(await Bu(n,r,i),this.action,i);return await n.mutation(S.workflow.runTestAction,{applicationId:r,nodeId:o,actionId:this.action,...t===void 0?{}:{params:t}}),this.print({ran:this.action,on:o},a=>[{key:"ran",value:a.ran},{key:"on",value:a.on},{key:"next",value:"test-actions list \u2014 file fills and the submit after them run asynchronously"}]),0}},rR=[$g,Rg];var ze=["de","en"];function cs(e,t){return ze.every(n=>e[n]===t[n])}s(cs,"sameText");function Et(e){if(e===null||typeof e!="object"||Array.isArray(e))return"not-localized";let t=e;return Object.keys(t).some(r=>!ze.includes(r))?"not-localized":ze.filter(r=>{let i=t[r];return typeof i!="string"||i.trim()===""})}s(Et,"missingLocales");function vi(e){let t=Et(e);return t!=="not-localized"&&t.length===0}s(vi,"isLocalizedText");function Ha(e,t){let n={};for(let r of ze){let i=e.map(o=>o[r]);n[r]=i.every(o=>typeof o=="string"&&o.trim()!=="")?t(i,r):""}return n}s(Ha,"composeTexts");var ar=/^[a-z][A-Za-z0-9]*$/;function Ig(e){return typeof e=="string"&&ar.test(e)}s(Ig,"isNodeId");function us(e,t){Ig(e)||C(`[graph/nodeIdFormat] "${e}" cannot name a node: a node id is ${ar.source}.`);let n=new Set(t);if(!n.has(e))return e;let r=2;for(;n.has(`${e}${r}`);)r++;return`${e}${r}`}s(us,"makeNodeId");var xi="$env";function se(e){if(e.scope==="env")return`${xi}.${e.key}`;let t=e.scope==="derived"?`$derived.${e.key}`:`$${e.scope}.${e.owner}.${e.key}`;return e.path===void 0?t:`${t}.${e.path}`}s(se,"formatAddress");var Rr=/^[a-z][a-zA-Z0-9_]*$/,xV=/^[A-Za-z_][A-Za-z0-9_]*$/;function uo(e){return typeof e=="string"&&e.split(".").every(t=>xV.test(t))}s(uo,"isPath");function zr(e){if(!e.startsWith("$"))return null;let t=e.slice(1).split("."),[n,...r]=t;switch(n){case"env":{let i=r.join(".");return r.length>0&&uo(i)?{scope:"env",key:i}:null}case"derived":{let[i,...o]=r;return i===void 0||!Rr.test(i)?null:iR({scope:"derived",key:i},o)}case"node":case"task":{let[i,o,...a]=r;return i===void 0||o===void 0||!Rr.test(o)||(n==="node"?!ar.test(i):!Rr.test(i))?null:iR({scope:n,owner:i,key:o},a)}default:return null}}s(zr,"tryParseAddress");function iR(e,t){if(t.length===0)return e;let n=t.join(".");return uo(n)?{...e,path:n}:null}s(iR,"withPath");function be(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e,n=t.scope==="env"?["scope","key"]:t.scope==="derived"?["scope","key","path"]:["scope","owner","key","path"];if(Object.keys(t).some(r=>!n.includes(r))||t.path!==void 0&&!uo(t.path))return!1;switch(t.scope){case"env":return uo(t.key);case"derived":return typeof t.key=="string"&&Rr.test(t.key);case"node":return typeof t.owner=="string"&&ar.test(t.owner)&&typeof t.key=="string"&&Rr.test(t.key);case"task":return typeof t.owner=="string"&&Rr.test(t.owner)&&typeof t.key=="string"&&Rr.test(t.key);default:return!1}}s(be,"isAddress");var Wr={offer:{key:"string",title:"string"},unit:{key:"string",name:"string"},stage:{key:"string",name:"string",gradeLevel:"number"},run:{key:"string",name:"string",startDate:"date"},applicant:{language:"enum",channel:"enum"}},fs=Object.keys(Wr);function ps(e){return Object.hasOwn(Wr,e)}s(ps,"isEnvKey");var SV=["self-service","staff"];function oR(e,t){return{kind:"fixed",values:e,labels:t}}s(oR,"fixedSet");var Uu={of:"applicant.language",withoutValue:"de"},Yr={"offer.key":{valueSet:{kind:"live"},nullable:!1,label:{de:"Angebot",en:"Offer"}},"offer.title":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Titel des Angebots",en:"Offer title"},nameLanguage:Uu},"unit.key":{valueSet:{kind:"live"},nullable:!1,label:{de:"Einheit",en:"Unit"}},"unit.name":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Name der Einheit",en:"Unit name"},nameLanguage:Uu},"stage.key":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Klassenstufe (Schl\xFCssel)",en:"Grade (key)"},cohortBound:!0},"stage.name":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Name der Klassenstufe",en:"Grade name"},cohortBound:!0,nameLanguage:Uu},"stage.gradeLevel":{valueSet:{kind:"open"},nullable:!0,absent:{de:"Die Stufe hat keine Klassenstufe (Kindergarten).",en:"The stage has no grade level (Kindergarten)."},label:{de:"Klassenstufe",en:"Grade level"},cohortBound:!0},"run.key":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Schuljahr",en:"School year"},cohortBound:!0},"run.name":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Name des Schuljahrs",en:"School year name"},cohortBound:!0,nameLanguage:Uu},"run.startDate":{valueSet:{kind:"open"},nullable:!0,absent:{de:"F\xFCr das Schuljahr ist kein Beginn erfasst.",en:"The school year has no start date."},label:{de:"Beginn des Schuljahrs",en:"School year start"},cohortBound:!0},"applicant.language":{valueSet:oR(ze,{de:{de:"Deutsch",en:"German"},en:{de:"Englisch",en:"English"}}),nullable:!0,absent:{de:"Die Bewerbung hat kein Bewerberkonto (intern angelegt).",en:"The application has no applicant account (started by staff)."},label:{de:"Bewerbersprache",en:"Applicant language"}},"applicant.channel":{valueSet:oR(SV,{staff:{de:"intern",en:"in-house"},"self-service":{de:"online (Familie)",en:"online (family)"}}),nullable:!1,label:{de:"Eingangsweg",en:"Intake channel"}}},Vu={types:Wr,fields:Yr},Gu=fs.flatMap(e=>Object.keys(Wr[e]).map(t=>`${e}.${t}`));function lr(e){return Object.hasOwn(Yr,e)}s(lr,"isEnvLeaf");function zu(e){return`${xi}.${e}`}s(zu,"envIdentifier");function fo(e){let t=Yr[e],[n,r]=e.split("."),i=Wr[n][r];i===void 0&&C(`[env] leaf "${e}" has no type`);let o=t.valueSet;return{leaf:e,type:i,label:t.label,nullable:t.nullable,...t.absent===void 0?{}:{absent:t.absent},...t.nameLanguage===void 0?{}:{nameLanguage:t.nameLanguage},...t.cohortBound===void 0?{}:{cohortBound:t.cohortBound},...o.kind==="fixed"?{enumOptions:o.values.map(a=>{let l=o.labels[a];return l===void 0&&C(`[env] "${e}" names the value "${a}" without a label`),{value:a,label:l}})}:{}}}s(fo,"envLeaf");var sR="staffInput";var AV=["boolean"],Ja=/^[a-z][A-Za-z0-9]*$/;function Wu(e){return e.staffInputs??[]}s(Wu,"staffInputsOf");function Yu(e){return`${sR}.${e}`}s(Yu,"staffInputLeaf");function aR(e){return`${xi}.${Yu(e)}`}s(aR,"staffInputIdentifier");function EV(e){let t=`${sR}.`;return e.startsWith(t)?e.slice(t.length):null}s(EV,"staffInputKeyOfLeaf");function Qa(e,t){let n=EV(t);return n===null?void 0:Wu(e).find(r=>r.key===n)}s(Qa,"declaredStaffInput");function TV(e){return[...Wu(e).map(t=>({leaf:Yu(t.key),type:t.type,label:t.label,valueSet:{kind:"open"},nullable:!1,cohortBound:!1})),...Gu.map(t=>{let n=fo(t);return{leaf:t,type:n.type,label:n.label,valueSet:Yr[t].valueSet,nullable:n.nullable,cohortBound:n.cohortBound===!0}})]}s(TV,"envLeavesFor");function lR(e){return TV(e).filter(t=>!t.cohortBound)}s(lR,"conditionEnvLeaves");function dR(e){let t={},n={};for(let{leaf:r,type:i,valueSet:o,nullable:a}of lR(e)){let[l="",d=""]=r.split(".");t[l]={...t[l]??{},[d]:i},n[r]={valueSet:o,nullable:a}}return{types:t,fields:n}}s(dR,"envConditionSchemaFor");function cR(e){let t=e.staffInputs;if(t===void 0)return[];if(!Array.isArray(t))return[{path:"staffInputs",reason:{de:"[staffInput/shape] graph.staffInputs muss eine Liste sein.",en:"[staffInput/shape] graph.staffInputs must be a list."}}];let n=[],r=new Set;return t.forEach((i,o)=>{let a=`staffInputs[${o}]`,l=i;if(l===null||typeof l!="object"||typeof l.key!="string"){n.push({path:a,reason:{de:"[staffInput/shape] Eine interne Angabe braucht key, type und label ({ de, en }).",en:"[staffInput/shape] An internal entry needs key, type and label ({ de, en })."}});return}let d={de:`Interne Angabe "${l.key}"`,en:`Internal entry "${l.key}"`};Ja.test(l.key)||n.push({path:`${a}.key`,reason:{de:`[staffInput/keyFormat] ${d.de}: Schl\xFCssel beginnt mit einem Kleinbuchstaben und enth\xE4lt nur Buchstaben und Ziffern.`,en:`[staffInput/keyFormat] ${d.en}: the key starts with a lowercase letter and contains only letters and digits.`}}),r.has(l.key)&&n.push({path:`${a}.key`,reason:{de:`[staffInput/duplicateKey] ${d.de}: Schl\xFCssel ist doppelt vergeben.`,en:`[staffInput/duplicateKey] ${d.en}: the key is used twice.`}}),r.add(l.key),AV.includes(l.type)||n.push({path:`${a}.type`,reason:{de:`[staffInput/unknownType] ${d.de}: Typ "${String(l.type)}" \u2014 erlaubt ist nur "boolean" (K\xE4stchen).`,en:`[staffInput/unknownType] ${d.en}: type "${String(l.type)}" \u2014 only "boolean" (checkbox) is allowed.`}});let c=Et(l.label);c==="not-localized"?n.push({path:`${a}.label`,reason:{de:`[staffInput/shape] ${d.de}: label muss { de, en } sein.`,en:`[staffInput/shape] ${d.en}: label must be { de, en }.`}}):c.length>0&&n.push({path:`${a}.label`,reason:{de:`[i18n/missingTranslation] ${d.de}: Beschriftung fehlt in ${c.join(", ")}.`,en:`[i18n/missingTranslation] ${d.en}: label is missing in ${c.join(", ")}.`}})}),n}s(cR,"staffInputIssues");var Mg={required:!0,description:"Offer slug (its offerKey)"},Og=class extends N{static{s(this,"ApplicationsListCommand")}static paths=[["applications","list"]];static usage=R.Usage({category:"Admission",description:"List an offer's applications (id, status, board state, applicant, test)"});offer=p.String("--offer",Mg);testOnly=p.Boolean("--test-only",!1,{description:"Only test applications"});async execute(){let t=await this.caller(),n=await t.query(S.admission.listForAngebot,{client:this.requireTenant(t),offerKey:this.offer}),r=V$(n).filter(i=>!this.testOnly||i.test==="test");return this.print(r,i=>i,["id","status","state","applicant","test"]),0}},Pg=class extends N{static{s(this,"ApplicationsCountsCommand")}static paths=[["applications","counts"]];static usage=R.Usage({category:"Admission",description:"Count an offer's applications per list"});offer=p.String("--offer",Mg);async execute(){let t=await this.caller(),n=await t.query(S.admission.getCountsByListForAngebot,{client:this.requireTenant(t),offerKey:this.offer});return this.print(n,r=>[...Object.entries(r.counts).map(([i,o])=>({list:i,count:String(o)})),{list:"total",count:String(r.total)}],["list","count"]),0}},_g=class extends N{static{s(this,"ApplicationsShowCommand")}static paths=[["applications","show"]];static usage=R.Usage({category:"Admission",description:"One application: status, test flag, offer, current workflow nodes"});application=p.String({required:!0});async execute(){let t=await this.caller(),n=this.application,r=await t.query(S.admission.get,{applicationId:n});if(r===null)throw new Error(`applications show: no application ${n} (or not visible to you)`);let i=await t.query(S.workflow.getInstance,{applicationId:n});return this.print({application:r,currentNodes:i?.instance.currentNodeIds??[]},o=>[{key:"id",value:n},{key:"status",value:o.application.status},{key:"test",value:o.application.testMode?"ja":"nein"},{key:"offer",value:o.application.offerId},{key:"current nodes",value:o.currentNodes.join(", ")}]),0}},Cg=class extends N{static{s(this,"ApplicationsStoreCommand")}static paths=[["applications","store"]];static usage=R.Usage({category:"Admission",description:"One application's process store: every address of its pinned graph, resolved (present / pending / absent)",details:"Staff only (applications.manage). --json prints one object keyed by the canonical address ($node\u2026, $task\u2026, $derived\u2026, $env\u2026). Values are shown whatever their audience \u2014 never hand the output to the family. Recipe: playbooks/applications/inspect-process-store.md."});application=p.String({required:!0});async execute(){let n=await(await this.caller()).query(S.processStoreView.get,{applicationId:this.application});return this.print(z$(n),()=>W$(n),["address","state","holds","producer","written"]),0}},Ng=class extends N{static{s(this,"ApplicationsStartTestCommand")}static paths=[["applications","start-test"]];static usage=R.Usage({category:"Admission",description:"Start a TEST application for an applicant (school year and level by key or id) and show what test mode offers next",details:"Always test mode. --applicant names the account by its login address (on prod only the tenant's test account); --party names the applicant party directly. Without --version it runs on the live generation, like the cockpit."});offer=p.String("--offer",Mg);run=p.String("--run",{required:!0,description:"School year: its key or id (never its name)"});stage=p.String("--stage",{required:!0,description:"Level: its key or id (never its name)"});party=p.String("--party",{description:"Applicant party id"});applicant=p.String("--applicant",{description:"Applicant account login address (e.g. the test account test@example.com)"});version=p.String("--version",{description:"Offer version id to test (default: the live generation)"});staffInput=p.Array("--staff-input",{description:"A staff input the offer declares, as key=true|false \u2014 repeat it once per input; a staff start must set every one"});proxy=p.Boolean("--proxy",{description:"Start in Stellvertretung (--proxy) or not (--no-proxy); left out, the tenant's default applies, as in the cockpit"});async execute(){let t=await this.caller();G$(this.resolvedTarget(),this.prodUrls(),this.party,this.applicant);let n=this.requireTenant(t),r=U$(await t.query(S.admission.listAdmissionTree,{client:n}),this.offer,this.run,this.stage),i=this.party;if(this.applicant!==void 0){let d=await t.query(S.applicants.partyByEmail,{client:n,email:this.applicant});if(d===null)throw new Error(`applications start-test: no applicant account ${this.applicant} at this school (create it in the cockpit first)`);i=d}let o=await t.mutation(S.admission.staffStartApplicationForParty,{client:n,offerKey:this.offer,partyId:i,programRunId:r.programRunId,programStageId:r.programStageId,...this.proxy===void 0?{}:{startInProxy:this.proxy},staffInputs:fR(this.staffInput??[]),testMode:!0,...this.version===void 0?{}:{offerVersionId:this.version}}),a,l;try{let d=await t.query(S.workflow.getInstance,{applicationId:o.applicationId});if(d===null)throw new Error("the started application has no workflow instance");a=d.instance.currentNodeIds,l=(await Bu(t,o.applicationId,a)).flatMap(c=>c.actions.map(u=>u.id))}catch(d){throw new Error(`applications start-test: started ${o.applicationId}, but reading its state failed: ${d instanceof Error?d.message:String(d)}`,{cause:d})}return this.print({applicationId:o.applicationId,currentNodes:a,testActions:l},d=>[{key:"application",value:d.applicationId},{key:"current nodes",value:d.currentNodes.join(", ")},{key:"test actions",value:d.testActions.join(", ")},{key:"next",value:`test-actions run --application ${d.applicationId} --action <id>`}]),0}},Dg=class extends N{static{s(this,"ApplicationsDiscardTestCommand")}static paths=[["applications","discard-test"]];static usage=R.Usage({category:"Admission",description:"Discard a TEST application (the server refuses a real one)"});application=p.String({required:!0});async execute(){return await(await this.caller()).mutation(S.admission.discardTest,{applicationId:this.application}),this.print({discarded:this.application},n=>[{key:"discarded",value:n.discarded}]),0}},Fg=class extends N{static{s(this,"ApplicationsStaffInputListCommand")}static paths=[["applications","staff-input","list"]];static usage=R.Usage({category:"Admission",description:"An application's internal inputs (set at the start): value, and why one can no longer be corrected"});application=p.String({required:!0});async execute(){let n=await(await this.caller()).query(S.admission.staffInputsOfApplication,{applicationId:this.application});return this.print(n,r=>r.map(i=>({key:i.key,label:i.label.de,value:String(i.value),correctable:i.block===null?"ja":i.block.de})),["key","label","value","correctable"]),0}},Lg=class extends N{static{s(this,"ApplicationsStaffInputSetCommand")}static paths=[["applications","staff-input","set"]];static usage=R.Usage({category:"Admission",description:"Correct one internal input of an application, with a reason \u2014 refused once a node that reads it was entered",examples:[["Untick \u201EKind von Mitarbeitenden\u201C",'plexus-cli --env prod --tenant <t> --allow-prod applications staff-input set <id> --input staffApplication=false --reason "falsch angehakt"']]});application=p.String({required:!0});input=p.String("--input",{required:!0,description:"key=true|false"});reason=p.String("--reason",{required:!0,description:"Why \u2014 recorded on the application's activity feed"});async execute(){let t=await this.caller(),[{key:n,value:r}]=fR([this.input]);return await t.mutation(S.admission.correctStaffInput,{applicationId:this.application,key:n,value:r,reason:this.reason}),this.print({application:this.application,key:n,value:r},i=>[{key:"application",value:i.application},{key:i.key,value:String(i.value)}]),0}},uR=[Og,Pg,_g,Cg,Ng,Dg,Fg,Lg];function fR(e){return e.map(t=>{let[n="",r,...i]=t.split("=");if(!Ja.test(n)||r!=="true"&&r!=="false"||i.length>0)throw new Error(`--staff-input "${t}": expected key=true or key=false`);return{key:n,value:r==="true"}})}s(fR,"parseStaffInputs");var Ft="contractGenerator",po="documentTemplate";function Za(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e,n=Object.keys(t);return(t.kind==="generator"||t.kind==="package")&&typeof t.key=="string"&&t.key.length>0&&(t.revision===void 0||typeof t.revision=="number"&&Number.isInteger(t.revision)&&t.revision>0)&&n.every(r=>r==="kind"||r==="key"||r==="revision")}s(Za,"isGeneratorRef");function pR(e,t){let n=e.inputs?.[t];return n?.kind==="literal"?n.value:void 0}s(pR,"literalOf");function Hr(e){let t=pR(e,Ft);return Za(t)?t:null}s(Hr,"generatorRefOfNode");function dr(e){let t=pR(e,po);return typeof t=="string"&&t.length>0?t:null}s(dr,"documentTemplateKeyOfNode");function mR(e){return`${e.kind}:${e.key}${e.revision===void 0?"":`@${e.revision}`}`}s(mR,"generatorRefLabel");var $V=["formExports","generatorStamp"];function hR(e,t,n){let r=e.inputs?.[Ft];(r?.kind!=="literal"||!Za(r.value))&&C(`applyGeneratorStamp: the node names no generator in inputs.${Ft} \u2014 a stamp derives from it`),n.freezeRevision&&t.revision!==void 0&&(e.inputs[Ft]={kind:"literal",value:{...r.value,revision:t.revision}}),e.generatorStamp={inputSchema:t.inputSchema,parties:t.parties,schemaDigest:t.schemaDigest,...t.parts===void 0?{}:{parts:t.parts}}}s(hR,"applyGeneratorStamp");var RV=["reads"];function ms(e){if(e===null||typeof e!="object")return e;let t={...e};return Array.isArray(t.nodes)&&(t.nodes=t.nodes.map(n=>{if(n===null||typeof n!="object")return n;let r={...n};for(let i of $V)delete r[i];for(let i of RV)Array.isArray(r[i])&&r[i].length===0&&delete r[i];return r})),t}s(ms,"comparableWorkflowGraph");var Xa={id:{de:"die Identit\xE4t ist der Slug des Angebots (bundle.yaml slugs.manifest)",en:"the identity is the offer's slug (bundle.yaml slugs.manifest)"},label:{de:"der Titel steht in bundle.yaml `label`",en:"the title is bundle.yaml `label`"},version:{de:"die Revision z\xE4hlt die Datenbank",en:"the database counts the revision"},applicantMode:{de:"von nichts gelesen",en:"read by nothing"},signatureLevel:{de:"von nichts gelesen",en:"read by nothing"},roleInstances:{de:"die Rollen kommen aus den Formular-Effekten",en:"roles come from the form effects"},leistungen:{de:"von nichts gelesen",en:"read by nothing"},capacity:{de:"die Kapazit\xE4t geh\xF6rt der Kohorte (program.runs[].capacities)",en:"capacity belongs to the cohort (program.runs[].capacities)"},progressLayoutId:{de:"von nichts gelesen",en:"read by nothing"},bewerbungsfenster:{de:"die Kohorte besitzt die \xD6ffnung (isOpen / applicationOpensAt)",en:"the cohort owns opening (isOpen / applicationOpensAt)"},selection:{de:"die Reihenfolge ist der Eingang `waitlistOrder` des Wartelistenknotens (automatisches Nachr\xFCcken gibt es nicht mehr; Freigabe-Strategie und Stichtag las nichts)",en:"the order is the waitlist node's input `waitlistOrder` (automatic promotion is gone; release strategy and deadline were read by nothing)"},progressLayout:{de:"das Fortschrittslayout geh\xF6rt zum Workflow: den Block nach workflow.json `progressLayout` verschieben (ohne Workflow l\xF6schen)",en:"the progress layout belongs to the workflow: move the block to workflow.json `progressLayout` (without a workflow: delete it)"}};function Hu(e){return e===null||typeof e!="object"||Array.isArray(e)?["manifest: data must be an object"]:Object.keys(e).map(t=>{let n=Xa[t];return n!==void 0?`manifest: \`${t}\` is no longer part of manifest.json (${n.en}). Delete the line.`:`manifest: unknown key \`${t}\` \u2014 manifest.json carries no key.`})}s(Hu,"manifestIssues");function IV(e){let t=[],n=e.buses;if(!Array.isArray(n))return t;let r=n.find(i=>!!i&&typeof i=="object"&&i.key==="process");if(!r||!Array.isArray(r.states))return t;for(let i of r.states){if(!i||typeof i!="object")continue;let o=i;if(o.terminal!==!0&&(!o.external||typeof o.external!="object")){let a=typeof o.id=="string"?o.id:"?";t.push(`progressLayout: progress state '${a}' is non-terminal but declares no 'external' block (applicant-facing copy) \u2014 resolveStatusPresentation would throw at runtime`)}}return t}s(IV,"validateProgressLayoutExternalCopy");function gR(e){if(e===null||typeof e!="object")return["progressLayout: the full layout object is required"];let t=e.buses;return!Array.isArray(t)||!t.some(n=>!!n&&typeof n=="object"&&n.key==="process")?["progressLayout: the layout must declare the `process` bus"]:IV(e)}s(gR,"progressLayoutIssues");var yR=new Set(["nodes","assignmentRules","channels","processStore","pricingRules","staffInputs"]);var OV=new Set(["sections","effects","outcomes","testScenarios","env"]),Ju={id:{de:"der Schl\xFCssel des Formulars ist sein Slug",en:"the form's key is its slug"},label:{de:"der Name steht in der Formularzeile (createSmartForm.label)",en:"the name is the form row's (createSmartForm.label)"},outcomeIds:{de:"die Ergebnisse sind die ids von outcomes[]",en:"the outcomes are the ids of outcomes[]"},schoolSlug:{de:"von nichts gelesen",en:"read by nothing"}};function wR(e,t){if(e===null||typeof e!="object"||Array.isArray(e))return[{de:`${t}: die Formulardefinition muss ein Objekt sein.`,en:`${t}: the form definition must be an object.`}];let n=[];for(let i of Object.keys(e)){if(OV.has(i))continue;let o=Ju[i];n.push(o!==void 0?{de:`${t}: \`${i}\` geh\xF6rt nicht mehr zur Formulardefinition (${o.de}). Die Zeile l\xF6schen.`,en:`${t}: \`${i}\` is no longer part of the form definition (${o.en}). Delete the line.`}:{de:`${t}: unbekannter Schl\xFCssel \`${i}\`.`,en:`${t}: unknown key \`${i}\`.`})}let r=e;for(let i of["sections","effects","outcomes"])Array.isArray(r[i])||n.push({de:`${t}: \`${i}\` muss eine Liste sein.`,en:`${t}: \`${i}\` must be a list.`});return n}s(wR,"smartFormDefinitionShapeIssues");var wn=["granted","rejected","waitlisted","other"];function Si(e){return typeof e=="string"&&wn.includes(e)}s(Si,"isOutcomeSemantic");var zn=["arrival","manual"],kR={arrival:{de:"Nach Eingang",en:"By arrival"},manual:{de:"Von Hand sortiert",en:"Sorted by hand"}};function PV(e,t){let n=e.inputs?.[t];return n?.kind==="literal"?n.value:void 0}s(PV,"literal");function qg(e){let t=PV(e,"waitlistOrder");return zn.includes(t)?{waitlistOrder:t}:null}s(qg,"waitlistPolicyOrNull");var ht="responsible",Kg="team:";function Qu(e){return`${Kg}${e}`}s(Qu,"teamSlot");function Zu(e){return e.startsWith(Kg)?e.slice(Kg.length):null}s(Zu,"teamKeyOfSlot");function bR(e){return e.kind==="responsible"?ht:Qu(e.groupKey)}s(bR,"slotIdOf");function Xu(e){if(e===ht)return{kind:"responsible"};let t=Zu(e);return t===null||t.length===0?null:{kind:"team",groupKey:t}}s(Xu,"slotOfId");var jg="review",Bg="checkField",vR="reviewed",xR="reviewing",ef=["rejected","waitlisted"];function Ug(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(Ug,"isObject");var _V=new Set(["decision",jg]),SR={approved:"granted",accepted:"granted",admitted:"granted",direkt:"granted",rejected:"rejected",absage:"rejected",declined:"rejected",waitlisted:"waitlisted",warteliste:"waitlisted"};function Vg(e){return Object.hasOwn(SR,e)?SR[e]:void 0}s(Vg,"legacySemanticOfId");function CV(e){return e===jg?wn.filter(t=>!ef.includes(t)):wn}s(CV,"allowedSemanticsFor");var NV="other";function AR(e){return Ug(e)&&_V.has(String(e.type))&&Array.isArray(e.outcomes)?e.outcomes:[]}s(AR,"outcomesOf");function ER(e){return(e?.nodes??[]).some(t=>AR(t).some(n=>Ug(n)&&!("semantic"in n)))}s(ER,"needsOutcomeSemantics");function TR(e,t={}){let n=[],r=[],i=[],o=e.nodes.map(a=>{let l=AR(a);if(l.length===0)return a;let d=a,c=String(d.id),u=String(d.type),f=CV(u),m=!1,y=l.map(k=>{if(!Ug(k))return k;let g=String(k.id);if("semantic"in k)return Si(k.semantic)||i.push({nodeId:c,outcomeId:g,value:String(k.semantic)}),k;let v=`${c}.${g}`,A=Object.hasOwn(t,v)?t[v]:void 0;if(A!==void 0)return f.includes(A)?(n.push({nodeId:c,outcomeId:g,semantic:A,source:"answer"}),m=!0,{...k,semantic:A}):(r.push({nodeId:c,nodeType:u,outcomeId:g,allowed:f,answer:A}),k);let $=Vg(g),E=$??NV;return f.includes(E)?(n.push({nodeId:c,outcomeId:g,semantic:E,source:$===void 0?"formerDefault":"legacyTable"}),m=!0,{...k,semantic:E}):(r.push({nodeId:c,nodeType:u,outcomeId:g,allowed:f}),k)});return m?{...d,outcomes:y}:a});return n.length===0?{graph:e,written:n,refused:r,invalid:i}:{graph:{...e,nodes:o},written:n,refused:r,invalid:i}}s(TR,"addOutcomeSemantics");var cr="bewerbungOffen";function mo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(mo,"isObject");var Gg=["event","effect"];function $R(e){return mo(e)&&e.type==="eventTrigger"}s($R,"isTrigger");function RR(e){let t=mo(e.inputs)?e.inputs:{};return"outcomes"in e||Gg.some(n=>n in e||n in t)}s(RR,"oldShape");function IR(e){return(e?.nodes??[]).some(t=>$R(t)&&RR(t))}s(IR,"needsEventTriggerStartMove");function DV(e){let t=String(e.id),r=(Array.isArray(e.outcomes)?e.outcomes:[]).map(l=>mo(l)?l.id:void 0);if("outcomes"in e&&!(r.length===1&&r[0]===cr))return{unmoved:{nodeId:t,reason:"outcomesNotStart"}};let i=Object.keys(mo(e.next)?e.next:{});if(!(i.length===1&&i[0]===cr))return{unmoved:{nodeId:t,reason:"nextNotStart"}};let o=mo(e.inputs)?{...e.inputs}:{};for(let l of Gg){let d=o[l];if(mo(d)&&d.kind==="binding")return{unmoved:{nodeId:t,reason:"bindingCell"}}}let a={...e};delete a.outcomes;for(let l of Gg)delete a[l],delete o[l];return mo(e.inputs)&&(Object.keys(o).length>0?a.inputs=o:delete a.inputs),{node:a}}s(DV,"moveNode");function OR(e){let t=[],n=[],r=e.nodes.map(i=>{if(!$R(i)||!RR(i))return i;let o=DV(i);return"unmoved"in o?(n.push(o.unmoved),i):(t.push(String(i.id)),o.node)});return t.length===0?{graph:e,moved:t,unmoved:n}:{graph:{...e,nodes:r},moved:t,unmoved:n}}s(OR,"moveEventTriggerStart");function el(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(el,"isObject");var PR={waitlistOrder:"arrival"};function _R(e){return!el(e)||e.type!=="waitlist"?!1:!("waitlistOrder"in(el(e.inputs)?e.inputs:{}))}s(_R,"lacksPolicy");function FV(e){return(e?.nodes??[]).some(_R)}s(FV,"needsWaitlistPolicyMove");function zg(e){return el(e)&&zn.includes(e.waitlistOrder)}s(zg,"isWaitlistPolicy");function LV(e){if(e===void 0)return{policy:PR,stated:!1};if(!el(e))return"malformed";let t=e.waitlistOrder;return t!==void 0&&!zn.includes(t)?"malformed":{policy:{waitlistOrder:t??PR.waitlistOrder},stated:t!==void 0}}s(LV,"policyOfSelection");function CR(e,t,n={}){let r=[],i=[];if(!FV(e))return{graph:e,moved:r,refused:i};let o=LV(t),a=e.nodes.map(l=>{if(!_R(l))return l;let d=l,c=String(d.id),u=el(d.inputs)?{...d.inputs}:{},f=Object.hasOwn(n,c)?n[c]:void 0,m,y;if(f!==void 0)m=f,y="answer";else{if(o==="malformed")return i.push({nodeId:c,reason:"selectionMalformed"}),l;m=o.policy,y=o.stated?"manifest":"formerDefault"}return u.waitlistOrder={kind:"literal",value:m.waitlistOrder},r.push({nodeId:c,policy:m,source:y}),{...d,inputs:u}});return r.length===0?{graph:e,moved:r,refused:i}:{graph:{...e,nodes:a},moved:r,refused:i}}s(CR,"moveWaitlistPolicyToInputs");function ho(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(ho,"isObject");var MV=[Ft,po],qV=["inputSchema","parties","schemaDigest","parts"];function NR(e){return ho(e)&&e.type==="governedDocument"&&("resolver"in e||ho(e.template)&&("key"in e.template||"cockpitFields"in e.template))}s(NR,"oldShape");function DR(e){return(e?.nodes??[]).some(NR)}s(DR,"needsGeneratorInputMove");function KV(e){let t=ho(e.inputs)?{...e.inputs}:{},n={...e},r;if("resolver"in e){let i=e.resolver;if(!ho(i))return{unmoved:"resolverNotObject"};if(Ft in t)return{unmoved:"generatorInputExists"};if(typeof i.key!="string"||i.key.length===0)return{unmoved:"pinWithoutKey"};if(i.kind!=="generator"&&i.kind!=="package")return{unmoved:"pinWithoutKind"};if(i.revision!==void 0&&!(typeof i.revision=="number"&&Number.isInteger(i.revision)&&i.revision>0))return{unmoved:"pinRevisionInvalid"};if((ho(i.inputSchema)&&Array.isArray(i.inputSchema.fields)?i.inputSchema.fields:[]).find(d=>ho(d)&&MV.includes(String(d.key)))!==void 0)return{unmoved:"stampDeclaresReservedKey"};t[Ft]={kind:"literal",value:{kind:i.kind,key:i.key,...i.revision===void 0?{}:{revision:i.revision}}};let l=Object.fromEntries(qV.filter(d=>d in i).map(d=>[d,i[d]]));Object.keys(l).length>0&&(n.generatorStamp=l),r=i.cockpitFields,delete n.resolver}if(ho(e.template)&&("key"in e.template||"cockpitFields"in e.template)){let{key:i,cockpitFields:o,...a}=e.template;if("key"in e.template){if(po in t)return{unmoved:"templateInputExists"};if(typeof i!="string"||i.length===0)return{unmoved:"templateKeyInvalid"};t[po]={kind:"literal",value:i}}if(o!==void 0){if(r!==void 0)return{unmoved:"cockpitFieldsTwice"};r=o}n.template=a}if(r!==void 0){if("cockpitFields"in e)return{unmoved:"cockpitFieldsExist"};n.cockpitFields=r}return n.inputs=t,{node:n}}s(KV,"moveNode");function FR(e){let t=[],n=[],r=e.nodes.map(i=>{if(!NR(i))return i;let o=KV(i);return"unmoved"in o?(n.push({nodeId:String(i.id),reason:o.unmoved}),i):(t.push(String(i.id)),o.node)});return t.length===0?{graph:e,moved:t,unmoved:n}:{graph:{...e,nodes:r},moved:t,unmoved:n}}s(FR,"moveGeneratorPinsToInputs");var LR=/^\d{4}-\d{2}-\d{2}$/;function ur(e,t){return{de:e,en:t}}s(ur,"issue");function go(e){if(typeof e!="object"||e===null)return ur("keine Reduktion","not a reduction");let t=e;if(t.kind==="none")return Object.keys(t).length===1?null:ur('\u201Ekeine Reduktion" tr\xE4gt keine weiteren Angaben','"no reduction" carries no further details');if(t.kind!=="amount")return ur(`unbekannte Art ${JSON.stringify(t.kind)}`,`unknown kind ${JSON.stringify(t.kind)}`);let{amount:n,activeFrom:r,activeTo:i}=t;return typeof n!="number"||!Number.isFinite(n)||n<=0?ur("der Betrag muss gr\xF6\xDFer als 0 \u20AC sein","the amount must be greater than \u20AC0"):Number.isInteger(Number((n*100).toFixed(6)))?typeof r!="string"||!LR.test(r)?ur("der Beginn fehlt (JJJJ-MM-TT)","the start is missing (YYYY-MM-DD)"):typeof i!="string"||!LR.test(i)?ur("das Ende fehlt (JJJJ-MM-TT)","the end is missing (YYYY-MM-DD)"):i<r?ur("das Ende liegt vor dem Beginn","the end is before the start"):t.floorTotal!==void 0&&(typeof t.floorTotal!="number"||!Number.isSafeInteger(t.floorTotal)||t.floorTotal<0)?ur("die Untergrenze muss ein nichtnegativer Centbetrag sein","the floor must be a non-negative amount in cents"):t.pricePeriod!==void 0&&!["month","year","once","unit"].includes(String(t.pricePeriod))?ur("ung\xFCltige Preisperiode","invalid price period"):Object.keys(t).some(o=>!["kind","amount","activeFrom","activeTo","floorTotal","pricePeriod"].includes(o))?ur("unbekannte Angaben","unknown details"):null:ur("der Betrag hat mehr als zwei Nachkommastellen","the amount has more than two decimal places")}s(go,"reductionShapeIssue");function Ai(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.itemKey=="string"&&t.itemKey.length>0&&Array.isArray(t.grantKeys)&&t.grantKeys.every(n=>typeof n=="string"&&n.length>0)&&(t.reduction===void 0||go(t.reduction)===null&&t.reduction.kind==="amount")}s(Ai,"isPricedItemValue");var hs=["freetext","recommendation","choice","pricedItem","record","reduction"],gs=[...hs,"appointment"];function qR(e){return typeof e=="string"&&gs.includes(e)}s(qR,"isTaskResultKind");function Ei(e){return typeof e=="string"&&hs.includes(e)}s(Ei,"isRecordedTaskResultKind");function ys(e){return Ei(e.kind)}s(ys,"isRecordedTaskResult");var tf=["number","boolean","enum"];function Wg(e){return typeof e=="string"&&tf.includes(e)}s(Wg,"isRecordFieldType");var Yg=["form","siblingRank"];var Jr={freetext:{choiceValueType:null,valueType:null,textValueType:"string",label:{de:"Freitext",en:"Free text"}},recommendation:{choiceValueType:"enum",valueType:null,textValueType:"string",label:{de:"Empfehlung",en:"Recommendation"}},choice:{choiceValueType:"enum",valueType:"enum",textValueType:"string",label:{de:"Auswahl",en:"Choice"}},pricedItem:{choiceValueType:"enum",valueType:"pricedItem",textValueType:"string",label:{de:"Preisposition",en:"Priced item"}},reduction:{choiceValueType:null,valueType:"reduction",textValueType:"string",label:{de:"Reduktion",en:"Reduction"}},record:{choiceValueType:null,valueType:null,textValueType:"string",label:{de:"Erfassung",en:"Record"}},appointment:{choiceValueType:null,valueType:null,textValueType:null,label:{de:"Termin",en:"Appointment"}}};function yo(e){return(e.kind==="freetext"||e.kind==="recommendation"||e.kind==="choice")&&e.writes===void 0}s(yo,"isProseResult");function nf(e){return e.kind==="record"?(e.fields??[]).filter(t=>typeof t.writes=="string"&&t.writes.length>0&&Wg(t.type)).map(t=>({key:t.writes,valueType:t.type,field:t})):jV(e)}s(nf,"draftResultStoreWrites");function jV(e){let t=Jr[e.kind].valueType;return e.writes===void 0||t===null?[]:[{key:e.writes,valueType:t}]}s(jV,"singleStoreWrite");var MR="team:";function ws(e){if(e==="all")return{kind:"all"};if(e==="external"||e.length===0)return null;if(e.startsWith(MR)){let t=e.slice(MR.length);return t.length===0?null:{kind:"team",groupKey:t}}return{kind:"channel",channelKey:e}}s(ws,"parseTaskResultChat");var Ye={unknownKind:"[taskResult/unknownKind]",onApproval:"[taskResult/onApproval]",unknownField:"[taskResult/unknownField]",choiceOptions:"[taskResult/choiceOptions]",textRequiredOnFreetext:"[taskResult/textRequiredOnFreetext]",chatMissing:"[taskResult/chatMissing]",chatExternal:"[taskResult/chatExternal]",chatUnknownChannel:"[taskResult/chatUnknownChannel]",appointmentMissingTitle:"[taskResult/appointmentMissingTitle]",pricedItemMissingItem:"[taskResult/pricedItemMissingItem]",pricedItemUnknownItem:"[taskResult/pricedItemUnknownItem]",pricedItemNotInProgram:"[taskResult/pricedItemNotInProgram]",pricedItemOfferWithoutProgram:"[taskResult/pricedItemOfferWithoutProgram]",itemOnNonPricedItem:"[taskResult/itemOnNonPricedItem]",writesOnProse:"[taskResult/writesOnProse]",filesOnKind:"[taskResult/filesOnKind]",labelMissing:"[taskResult/labelMissing]",appointmentInvalidDuration:"[taskResult/appointmentInvalidDuration]",recordFields:"[taskResult/recordFields]",fieldsOnNonRecord:"[taskResult/fieldsOnNonRecord]",recordSuggest:"[taskResult/recordSuggest]",reductionPrices:"[taskResult/reductionPrices]",pricesOnNonReduction:"[taskResult/pricesOnNonReduction]"};var BV=new Set(["if","else","in","true","false","null"]),UV=new Set(["==","!=","<=",">=","&&","||"]);function VV(e){return e>="0"&&e<="9"}s(VV,"isDigit");function GV(e){return/[a-zA-Z_$]/.test(e)}s(GV,"isIdentStart");function zV(e){return/[a-zA-Z0-9_.$]/.test(e)}s(zV,"isIdentCont");function WV(e){let t=[],n=0;for(;n<e.length;){let r=e.charAt(n);if(r===" "||r===" "||r===`
10202
- `||r==="\r"){n++;continue}if(r==="'"){let o=n+1,a="";for(;o<e.length&&e.charAt(o)!=="'";)e.charAt(o)==="\\"&&o+1<e.length?(a+=e.charAt(o+1),o+=2):(a+=e.charAt(o),o++);o>=e.length&&C(`Unterminated string at ${n}`),t.push({t:"str",v:a}),n=o+1;continue}if(VV(r)){let o=n;for(;o<e.length&&/[0-9.]/.test(e.charAt(o));)o++;t.push({t:"num",v:Number(e.slice(n,o))}),n=o;continue}if(GV(r)){let o=n;for(;o<e.length&&zV(e.charAt(o));)o++;let a=e.slice(n,o);BV.has(a)?t.push({t:"kw",v:a}):t.push({t:"ident",v:a}),n=o;continue}let i=e.slice(n,n+2);if(UV.has(i)){t.push({t:"op",v:i}),n+=2;continue}if("<>!".includes(r)){t.push({t:"op",v:r}),n++;continue}if("()[],".includes(r)){t.push({t:"punct",v:r}),n++;continue}C(`Unexpected char '${r}' at ${n}`)}return t}s(WV,"tokenise");var KR=1e4,jR=128;function ks(e){e.depth++,e.depth>jR&&C(`Expression nesting too deep (> ${jR})`)}s(ks,"enterDepth");function WR(e){return e.pos<e.tokens.length?e.tokens[e.pos]:null}s(WR,"peek");function Lt(e){let t=e.tokens[e.pos];return t||C(`Unexpected end at ${e.pos}`),e.pos++,t}s(Lt,"take");function Mt(e,t,n){let r=WR(e);return!(!r||r.t!==t||n!==void 0&&r.v!==n)}s(Mt,"match");function wo(e,t,n){return Mt(e,t,n)||C(`Expected ${t}${n?`:${n}`:""} at ${e.pos}`),Lt(e)}s(wo,"expect");function Zr(e){ks(e);try{return Mt(e,"kw","if")?YV(e):HV(e)}finally{e.depth--}}s(Zr,"parseExpr");function YV(e){wo(e,"kw","if"),wo(e,"punct","(");let t=Zr(e);wo(e,"punct",")");let n=Zr(e);wo(e,"kw","else");let r=Zr(e);return{kind:"if",cond:t,then:n,else:r}}s(YV,"parseIf");function HV(e){let t=BR(e),n=0;try{for(;Mt(e,"op","||");){Lt(e),ks(e),n++;let r=BR(e);t={kind:"binary",op:"||",left:t,right:r}}}finally{e.depth-=n}return t}s(HV,"parseLogicOr");function BR(e){let t=UR(e),n=0;try{for(;Mt(e,"op","&&");){Lt(e),ks(e),n++;let r=UR(e);t={kind:"binary",op:"&&",left:t,right:r}}}finally{e.depth-=n}return t}s(BR,"parseLogicAnd");function UR(e){let t=VR(e),n=0;try{for(;Mt(e,"op","==")||Mt(e,"op","!=");){let r=Lt(e).v;ks(e),n++;let i=VR(e);t={kind:"binary",op:r,left:t,right:i}}}finally{e.depth-=n}return t}s(UR,"parseEquality");function VR(e){let t=Jg(e),n=0;try{for(;Mt(e,"op","<")||Mt(e,"op","<=")||Mt(e,"op",">")||Mt(e,"op",">=")||Mt(e,"kw","in");){let r=Lt(e),i=r.t==="kw"?"in":r.v;ks(e),n++;let o=Jg(e);t={kind:"binary",op:i,left:t,right:o}}}finally{e.depth-=n}return t}s(VR,"parseCompare");function Jg(e){if(Mt(e,"op","!")){Lt(e),ks(e);try{return{kind:"unary",op:"!",operand:Jg(e)}}finally{e.depth--}}return JV(e)}s(Jg,"parseUnary");function JV(e){let t=WR(e);if(t||C("Unexpected end"),t.t==="num")return Lt(e),{kind:"num",value:t.v};if(t.t==="str")return Lt(e),{kind:"str",value:t.v};if(t.t==="kw"&&t.v==="true")return Lt(e),{kind:"bool",value:!0};if(t.t==="kw"&&t.v==="false")return Lt(e),{kind:"bool",value:!1};if(t.t==="kw"&&t.v==="null")return Lt(e),{kind:"null"};if(t.t==="punct"&&t.v==="("){Lt(e);let n=Zr(e);return wo(e,"punct",")"),n}if(t.t==="punct"&&t.v==="["){Lt(e);let n=[];if(!Mt(e,"punct","]"))for(n.push(Zr(e));Mt(e,"punct",",");)Lt(e),n.push(Zr(e));return wo(e,"punct","]"),{kind:"arr",items:n}}if(t.t==="ident"){let n=t.v;if(Lt(e),Mt(e,"punct","(")){Lt(e);let r=[];if(!Mt(e,"punct",")"))for(r.push(Zr(e));Mt(e,"punct",",");)Lt(e),r.push(Zr(e));return wo(e,"punct",")"),{kind:"call",name:n,args:r}}return{kind:"ident",path:n}}C(`Unexpected token at ${e.pos}`)}s(JV,"parsePrimary");function qt(e){e.length>KR&&C(`Expression too long (${e.length} > ${KR})`);let t={tokens:WV(e),pos:0,depth:0},n=Zr(t);return t.pos<t.tokens.length&&C(`Unexpected trailing token at ${t.pos}`),n}s(qt,"parseExpression");var QV=new Map([["today",()=>new Date().toISOString().slice(0,10)],["years_between",(e,t)=>{if(typeof e!="string"||typeof t!="string")return null;let n=new Date(e),r=new Date(t);if(isNaN(n.getTime())||isNaN(r.getTime()))return null;let i=r.getFullYear()-n.getFullYear(),o=r.getMonth()-n.getMonth();return(o<0||o===0&&r.getDate()<n.getDate())&&i--,i}],["length",e=>typeof e=="string"||Array.isArray(e)?e.length:0]]);function gt(e,t){switch(e.kind){case"num":return e.value;case"str":return e.value;case"bool":return e.value;case"null":return null;case"ident":{let n=Object.hasOwn(t.values,e.path)?t.values[e.path]:void 0;return n===void 0?null:n}case"arr":return e.items.map(n=>gt(n,t));case"unary":{let n=gt(e.operand,t);return!Ti(n)}case"call":{let n=t.functions!==void 0&&Object.hasOwn(t.functions,e.name)?t.functions[e.name]:QV.get(e.name);n||C(`Unknown function '${e.name}'`);let r=e.args.map(i=>gt(i,t));return n(...r)}case"binary":return ZV(e.op,e.left,e.right,t);case"if":return Ti(gt(e.cond,t))?gt(e.then,t):gt(e.else,t)}}s(gt,"evaluate");function ZV(e,t,n,r){if(e==="&&"){let a=gt(t,r);return Ti(a)?Ti(gt(n,r)):!1}if(e==="||"){let a=gt(t,r);return Ti(a)?!0:Ti(gt(n,r))}let i=gt(t,r),o=gt(n,r);switch(e){case"==":return Hg(i,o);case"!=":return!Hg(i,o);case"<":{let[a,l]=rf(i,o);return a!==null&&l!==null&&a<l}case"<=":{let[a,l]=rf(i,o);return a!==null&&l!==null&&a<=l}case">":{let[a,l]=rf(i,o);return a!==null&&l!==null&&a>l}case">=":{let[a,l]=rf(i,o);return a!==null&&l!==null&&a>=l}case"in":return Array.isArray(o)?o.some(a=>Hg(a,i)):!1}}s(ZV,"evalBinary");function rf(e,t){return[GR(e),GR(t)]}s(rf,"orderedOperands");function GR(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"){if(e.trim()==="")return null;let t=Number(e);return Number.isFinite(t)?t:null}return null}s(GR,"numericOperand");function Hg(e,t){return e===t?!0:e==null||t==null?!1:typeof e=="number"&&typeof t=="string"?e===Number(t):typeof e=="string"&&typeof t=="number"?Number(e)===t:!1}s(Hg,"looseEq");function Ti(e){return!(e==null||e===!1||e===0||e===""||Array.isArray(e)&&e.length===0)}s(Ti,"truthy");function kt(e){let t=new Set;return Qr(e,t),[...t]}s(kt,"dependencies");function Qr(e,t){switch(e.kind){case"ident":t.add(e.path);return;case"call":e.args.forEach(n=>Qr(n,t));return;case"arr":e.items.forEach(n=>Qr(n,t));return;case"unary":Qr(e.operand,t);return;case"binary":Qr(e.left,t),Qr(e.right,t);return;case"if":Qr(e.cond,t),Qr(e.then,t),Qr(e.else,t);return;default:return}}s(Qr,"walk");var zR=new Map;function fr(e){let t=zR.get(e);return t||(t=qt(e),zR.set(e,t)),t}s(fr,"parseCached");function XV(e,t){return gt(fr(e),t)}s(XV,"evalExpression");function YR(e,t){return Ti(XV(e,t))}s(YR,"evalBoolean");function of(e){let t=e.pricingRules;return t===void 0?[]:(Array.isArray(t)||C("graph.pricingRules must be an array \u2014 the graph validator refuses anything else"),t)}s(of,"pricingRuleSets");function Qg(e){return e.derive!==void 0}s(Qg,"isDerivedKey");function eG(e,t){let n=of(e);return(t.rules??[]).map(r=>{let i=n.find(o=>o.key===r);return i===void 0&&C(`[process] derivation names the unknown rule set "${r}" \u2014 publish refuses that`),i})}s(eG,"ruleSetsOfDerivation");function JR(e){return[...new Set(e.rows.flatMap(t=>kt(fr(t.when))))]}s(JR,"ruleSetDependencies");function QR(e){let t=zr(e);return t!==null&&se(t)===e?t:null}s(QR,"ruleIdentifierAddress");function Zg(e,t){let r=[...new Set(eG(e,t).flatMap(JR))].map(o=>{let a=QR(o);return a===null&&C(`[address/bareIdentifier] rule identifier "${o}" is no address \u2014 publish refuses that`),{address:a,id:o,role:"rule"}}),i=t.reduction;return i===void 0?r:(be(i)||C(`[address/bareIdentifier] derive.reduction ${JSON.stringify(i)} is no address \u2014 publish refuses that`),[...r,{address:i,id:se(i),role:"reduction"}])}s(Zg,"derivationSources");function ZR(e,t){let n=of(e);for(let r of t.rules??[]){let i=n.find(o=>o.key===r);if(i===void 0||i.rows.some(o=>tl(o.when)!==null)||JR(i).some(o=>QR(o)===null))return null}return t.reduction!==void 0&&!be(t.reduction)?null:Zg(e,t)}s(ZR,"draftDerivationSources");function tl(e){if(typeof e!="string"||e.trim().length===0)return"leere Bedingung";try{return fr(e),null}catch(t){return t instanceof Error?t.message:String(t)}}s(tl,"conditionIssue");function HR(e){return e.item!==void 0&&e.group===void 0?{kind:"item",key:e.item}:e.group!==void 0&&e.item===void 0?{kind:"group",key:e.group}:null}s(HR,"rowTarget");function Xg(e){if(e.byStage===void 0){let t=HR(e);return t===null?[]:[{...t,stages:null}]}return e.item!==void 0||e.group!==void 0?[]:e.byStage.flatMap(t=>{let n=HR(t);return n===null?[]:[{...n,stages:t.stages}]})}s(Xg,"derivationTargets");function XR(e,t){t!==null&&(typeof t=="object"||typeof t=="function")&&Object.hasOwn(t,"exports")&&C(`[workflow/registry] node type "${e}": custom spec.exports is unsupported; use artifact-slot exports.`)}s(XR,"assertNoCustomNodeExports");var ey=null;function eI(e){for(let[t,n]of Object.entries(e))XR(t,n);ey=e}s(eI,"setSpecs");function tI(){return ey||C("[workflow/registry] Specs not initialised. Import convex/model/admission/specs before calling specFor()."),ey}s(tI,"requireSpecs");function He(e){let t=tI(),n=t[e.type];return n===void 0&&ae("INVALID",{de:`[workflow/registry] Unbekannter Knotentyp "${String(e.type)}" (Knoten "${String(e.id)}"). Registrierte Typen: ${Object.keys(t).sort().join(", ")}.`,en:`[workflow/registry] Unknown node type "${String(e.type)}" (node "${String(e.id)}"). Registered types: ${Object.keys(t).sort().join(", ")}.`}),n}s(He,"specFor");function nI(){return Object.keys(tI()).sort()}s(nI,"registeredNodeTypes");var rI=Gu.filter(e=>Yr[e].cohortBound!==!0);function ty(e){return lr(e)&&Yr[e].cohortBound!==!0}s(ty,"isEnvAddressLeaf");function ny(e){return fo(e).type}s(ny,"envType");function ry(e){return fo(e).label}s(ry,"envLabel");function sf(e){if(e.scope==="env"||e.path===void 0)return e;switch(e.scope){case"node":return{scope:"node",owner:e.owner,key:e.key};case"task":return{scope:"task",owner:e.owner,key:e.key};case"derived":return{scope:"derived",key:e.key}}}s(sf,"addressBase");function bs(e){return e.scope==="node"&&e.key===tn&&e.path===void 0}s(bs,"isInstanceAddress");function at(e){return be(e)&&e.scope==="node"&&e.key===tn&&e.path!==void 0}s(at,"isFormFieldAddress");function iI(e){return at(e)?{owner:e.owner,path:e.path}:null}s(iI,"formFieldOf");function iy(e){return kt(fr(e)).map(t=>{if(!t.startsWith("$"))return{identifier:t,address:null,reason:"bareIdentifier"};let n=zr(t);return n===null?{identifier:t,address:null,reason:"shape"}:{identifier:t,address:n}})}s(iy,"expressionAddresses");var tn="admission",ol="document",vs="contract",xs="contracts",oI="payment",oy=new Set(["adoptForm","setFlagTarget","form","familyRequestFrom"]);var ln={id:"identity",type:"identity",label:"display",sublabel:"display",library:"display",outcomes:"control",outputLabels:"display",inputs:"input",next:"control",tasks:"config",assign:"reference",optionalActions:"config",artifacts:"config",notifications:"config"},Lae={join:{...ln},end:{...ln},eventTrigger:{...ln},form:{...ln,adoptForm:"address",formExports:"stamp"},roleAssign:{...ln},setFlag:{...ln},if:{...ln,condition:"address"},countersign:{...ln,contract:"address",titles:"display",signing:"config"},engagePush:{...ln,engage:"tenantRef",form:"address",contract:"address",payment:"address"},decision:{...ln,commentRequired:"config",decisionAsTask:"config",reads:"address",requiresOneOf:"config"},review:{...ln,reads:"address",commentRequired:"config",decisionAsTask:"config"},waitlist:{...ln},completenessCheck:{...ln,requires:"address",deadline:"config"},collectPayment:{...ln},governedDocument:{...ln,production:"config",form:"address",generatorStamp:"stamp",templateStamp:"stamp",approval:"config",confirmBeforeIssue:"config",confirmContractTerms:"config",contractTermsQuestionText:"display",responseStrategy:"config",titles:"display",responseLabels:"display",reads:"address"}};function Ir(e){return Array.isArray(e)?e:[]}s(Ir,"listOf");function Kt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}s(Kt,"record");function sI(e){switch(e.type){case"countersign":return["contract"];case"engagePush":return["form","contract","payment"];case"governedDocument":return e.production==="resolver"?["form"]:[];default:return[]}}s(sI,"dataSourceFieldsOf");function aI(e){return e.type==="engagePush"?["form"]:sI(e)}s(aI,"requiredDataSourceFields");var tG={setFlag:{target:"setFlagTarget"}};function sl(e,t={}){let n=[],r=e,i=`nodes.${e.id}`,o=s((d,c,u,f={})=>{n.push({kind:d,at:c,nodeId:e.id,value:u,judgedTogether:null,...f})},"field"),a=new Map(t.slotTypes===!1?[]:(He(e).inputs?.(e)??[]).map(d=>[d.id,d.type])),l=tG[e.type]??{};for(let[d,c]of Object.entries(Kt(r.inputs)??{})){let u=Kt(c);if(u?.kind!=="binding")continue;let f="address"in u?u.address:u.path,m=l[d];if(m!==void 0){o(m,`${i}.inputs.${d}`,f);continue}let y=a.get(d);o("binding",`${i}.inputs.${d}`,f,y!==void 0?{expectedType:y}:{})}for(let[d,c]of Ir(r.reads).entries())o("nodeReads",`${i}.reads.${d}`,c,{judgedTogether:`${i}.reads`});for(let[d,c]of Ir(r.requires).entries())o("requires",`${i}.requires.${d}`,c,{judgedTogether:`${i}.requires`});e.type==="form"&&r.adoptForm!==void 0&&o("adoptForm",`${i}.adoptForm`,r.adoptForm);for(let d of sI(e))r[d]!==void 0&&o(d,`${i}.${d}`,r[d]);e.type==="if"&&r.condition!==void 0&&o("condition",`${i}.condition`,r.condition);for(let[d,c]of Ir(r.tasks).entries())n.push(...lI(e.id,c,d));return n}s(sl,"nodeAddressFields");function lI(e,t,n){let r=Kt(t);if(r===null)return[];let i=[],o=typeof r.key=="string"?r.key:String(n),a=`nodes.${e}.tasks.${o}`,l=s((f,m,y,k={})=>{i.push({kind:f,at:m,nodeId:e,taskKey:o,value:y,judgedTogether:null,...k})},"field"),d=`${a}.evidence`;r.when!==void 0&&l("taskWhen",`${a}.when`,r.when,{expectedType:"boolean",judgedTogether:d});for(let[f,m]of Ir(r.reads).entries())l("taskReads",`${a}.reads.${f}`,m,{judgedTogether:d});for(let[f,m]of Ir(r.documents).entries()){let y=Kt(m);y===null||y.kind==="artifact"||l("taskDocument",`${a}.documents.${f}`,"address"in y?y.address:y.key)}let c=Kt(r.familyRequest);if(c!==null){for(let[f,m]of Ir(c.fields).entries())l("familyRequestFields",`${a}.familyRequest.fields.${f}`,m,{judgedTogether:`${a}.familyRequest.fields`});c.from!==void 0&&l("familyRequestFrom",`${a}.familyRequest.from`,c.from)}let u=Kt(r.result);if(u?.kind==="record")for(let[f,m]of Ir(u.fields).entries()){let y=Kt(Kt(m)?.suggest);if(y?.kind!=="form")continue;let k=Kt(m)?.type;l("suggest",`${a}.result.fields.${f}.suggest`,"address"in y?y.address:y.key,typeof k=="string"?{expectedType:k}:{})}return i}s(lI,"taskAddressFields");function af(e){let t=[];for(let[n,r]of Ir(e.processStore).entries()){let i=Kt(Kt(r)?.derive);if(i?.reduction!==void 0){let o=String(Kt(r)?.key);t.push({kind:"reduction",at:`processStore.${n}.derive.reduction`,nodeId:null,priceKey:o,value:i.reduction,judgedTogether:null})}}for(let[n,r]of Ir(e.pricingRules).entries())for(let[i,o]of Ir(Kt(r)?.rows).entries())t.push({kind:"pricingRule",at:`pricingRules.${n}.rows.${i}.when`,nodeId:null,value:Kt(o)?.when,judgedTogether:null});return t}s(af,"priceAddressFields");function Ss(e){return sy(e)?(lf(e.value)??[]).flatMap(t=>t.address===null?[]:[t.address]):be(e.value)?[e.value]:[]}s(Ss,"addressesInField");function sy(e){return e.kind==="pricingRule"||e.kind==="condition"}s(sy,"isExpressionField");function lf(e){return tl(e)===null?iy(e):null}s(lf,"ruleConditionAddresses");function kn(e){return e.type==="form"&&e.adoptForm!==void 0&&e.adoptForm!==!1}s(kn,"adoptsForm");function dI(e){if(e.type!=="form"||kn({type:e.type,adoptForm:e.adoptForm}))return;let t=e.inputs?.smartForm;return t?.kind==="literal"&&typeof t.value=="string"&&t.value!==""?t.value:void 0}s(dI,"createdSmartFormSlug");function nG(e,t){return e.type!=="governedDocument"||e.production!=="resolver"||t!==ol?t:e.generatorStamp?.parts!==void 0?xs:vs}s(nG,"addressKeyOfPort");function ay(e){let t=e.result;return t===void 0||!ys(t)?[]:nf(t).map(n=>n.key)}s(ay,"storeWritesOf");function rl(e,t){return(Array.isArray(e.processStore)?e.processStore:[]).find(n=>n.key===t)}s(rl,"declaredKey");function Or(e,t){let n=[];if(!kn(t))for(let r of He(t).outputs?.(t)??[])n.push({address:{scope:"node",owner:t.id,key:nG(t,r.name)},type:r.type,...r.label!==void 0?{label:r.label}:{},nodeId:t.id,nodePort:r});for(let r of Array.isArray(t.tasks)?t.tasks:[])for(let i of ay(r)){let o=rl(e,i);n.push({address:{scope:"task",owner:r.key,key:i},type:o?.type??"unknown",...o!==void 0?{label:o.label}:{},nodeId:t.id})}return n}s(Or,"producedAddresses");function cI(e,t,n){for(let r of e.nodes)for(let i of Array.isArray(r.tasks)?r.tasks:[])if(i.key===t&&ay(i).includes(n))return{nodeId:r.id,template:i};return null}s(cI,"taskWriter");function Pr(e,t,n){return cI(e,t,n)?.nodeId??null}s(Pr,"taskOwnerNode");function il(e,t){let n=rl(e,t)?.derive;if(n===void 0)return null;let r=Array.isArray(e.pricingRules)?e.pricingRules:[],i=[];for(let a of n.rules??[]){let l=r.find(d=>d.key===a);if(l===void 0)return null;for(let d of l.rows){let c=lf(d.when);if(c===null)return null;for(let u of c)u.address!==null&&i.push(u.address)}}let o=n.reduction;return be(o)&&i.push(o),rG(i)}s(il,"derivedSources");function rG(e){let t=new Set;return e.filter(n=>{let r=se(n);return t.has(r)?!1:(t.add(r),!0)})}s(rG,"dedupe");function iG(e){return sl(e,{slotTypes:!1}).flatMap(t=>Ss(t).map(n=>({address:n,field:t})))}s(iG,"writtenAddressesOf");function ko(e,t){let n=[],r=new Set,i=s((l,d,c,u)=>{let f=`${se(l)}|${d}|${c.at}|${u===void 0?"":se(u)}`;r.has(f)||(r.add(f),n.push({address:l,origin:d,field:c,...u!==void 0?{via:u}:{}}))},"push"),o=s((l,d,c=new Set)=>{let u=se(l);if(!c.has(u)){if(c.add(u),l.scope==="task"){let f=cI(e,l.owner,l.key);if(f===null)return;for(let m of lI(f.nodeId,f.template))if(!(m.kind!=="taskWhen"&&m.kind!=="taskReads"))for(let y of Ss(m))i(y,"evidence",d,l)}if(l.scope==="derived")for(let f of il(e,l.key)??[])i(f,"derivedSource",d,l),o(f,d,c)}},"carried");for(let{address:l,field:d}of iG(t))i(l,"written",d),o(l,d);let a=new Set((Array.isArray(t.tasks)?t.tasks:[]).flatMap(l=>ay(l).map(d=>`${l.key}.${d}`)));for(let l of af(e))if(!(l.kind!=="reduction"||!be(l.value)||l.value.scope!=="task")&&a.has(`${l.value.owner}.${l.value.key}`))for(let d of il(e,l.priceKey)??[])d.scope==="task"&&a.has(`${d.owner}.${d.key}`)||(i(d,"priceCheck",l,{scope:"derived",key:l.priceKey}),o(d,l));return n}s(ko,"addressReadsOf");function ly(e,t){switch(t.scope){case"env":return lr(t.key)?ny(t.key):Qa(e,t.key)?.type;case"derived":case"task":{if(t.path!==void 0||t.scope==="task"&&Pr(e,t.owner,t.key)===null)return;let n=rl(e,t.key);return n===void 0||t.scope==="derived"!=(n.derive!==void 0)?void 0:n.type}case"node":{let n=e.nodes.find(i=>i.id===t.owner);if(n===void 0)return;let r=Or(e,n).find(i=>i.address.scope==="node"&&i.address.key===t.key);return r===void 0?void 0:t.path===void 0?r.type:r.nodePort?.schema?.find(i=>i.key===t.path)?.type}}}s(ly,"addressType");function nl(e,t){let n=Kt(e)?.[t];return typeof n=="string"&&n.length>0?n:void 0}s(nl,"labelText");function Oe(e,t,n){let r=e.nodes.find(i=>i.id===t);return nl(r?.label,n)??t}s(Oe,"nodeDisplayName");function bo(e,t,n){for(let r of e.nodes){let i=(Array.isArray(r.tasks)?r.tasks:[]).find(o=>o.key===t);if(i!==void 0)return nl(i.title,n)??t}return t}s(bo,"taskDisplayName");function Be(e,t,n){let r=[];switch(t.scope){case"env":r.push(lr(t.key)?ry(t.key)[n]:Qa(e,t.key)?.label[n]??t.key);break;case"derived":r.push(nl(rl(e,t.key)?.label,n)??t.key);break;case"task":r.push(bo(e,t.owner,n),nl(rl(e,t.key)?.label,n)??t.key);break;case"node":{r.push(Oe(e,t.owner,n));let i=e.nodes.find(a=>a.id===t.owner),o=i===void 0?void 0:Or(e,i).find(a=>a.address.scope==="node"&&a.address.key===t.key);r.push(nl(o?.label,n)??t.key);break}}return t.scope!=="env"&&t.path!==void 0&&r.push(t.path),`${r.join(" \u203A ")} (${se(t)})`}s(Be,"displayAddress");var al=["beneficiary","signers"];function uI(e,t){return Array.isArray(e.artifacts)&&e.artifacts.some(n=>n?.key===t)}s(uI,"ownsSlot");function ll(e){let t=[];for(let[n,r]of Object.entries(Kt(e.inputs)??{})){let i=Kt(r);i?.kind==="binding"&&be(i.address)&&t.push({slot:n,address:i.address})}return t}s(ll,"bindingAddresses");function fI(e,t){return ll(e).find(n=>n.slot===t)?.address??null}s(fI,"bindingAddressAt");function pI(e,t){let n=s(i=>i.scope==="node"&&i.owner===t||i.scope==="task"&&Pr(e,i.owner,i.key)===t,"names");return[...e.nodes.filter(i=>i.id!==t).flatMap(i=>sl(i,{slotTypes:!1})),...af(e)].flatMap(i=>Ss(i).filter(n).map(o=>({at:i.at,nodeId:i.nodeId,address:o})))}s(pI,"addressesNaming");var Tt={target:"target",flagKey:"flagKey",value:"value"};function oG(e){return fI(e,Tt.target)}s(oG,"setFlagTarget");function mI(e){let t=oG(e);return t!==null&&bs(t)?t.owner:null}s(mI,"setFlagTargetOwner");function df(e){let t=e.inputs?.[Tt.flagKey];return t?.kind==="literal"&&typeof t.value=="string"&&t.value.length>0?t.value:null}s(df,"setFlagKey");function hI(e){let t=e.inputs?.[Tt.value];if(t===void 0||t.kind==="unset")return!0;if(t.kind==="literal"&&typeof t.value=="boolean")return t.value;C(`[setFlag/valueType] setFlag node "${String(e.id)}": \`${Tt.value}\` is no yes/no literal \u2014 publish refuses that`)}s(hI,"setFlagValue");function gI(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(gI,"isObject");var yI=["target","flagKey","value"];function wI(e){return gI(e)&&e.type==="setFlag"&&yI.some(t=>t in e)}s(wI,"oldShape");function kI(e){return(e?.nodes??[]).some(wI)}s(kI,"needsSetFlagInputMove");function sG(e){let t=gI(e.inputs)?{...e.inputs}:{};if(yI.some(a=>a in e&&Tt[a]in t))return{unmoved:"inputExists"};if("target"in e&&!be(e.target))return{unmoved:"targetNotAddress"};if("flagKey"in e&&typeof e.flagKey!="string")return{unmoved:"flagKeyNotString"};if("value"in e&&typeof e.value!="boolean")return{unmoved:"valueNotBoolean"};let{target:n,flagKey:r,value:i,...o}=e;return n!==void 0&&(t[Tt.target]={kind:"binding",address:n}),typeof r=="string"&&r.length>0&&(t[Tt.flagKey]={kind:"literal",value:r}),i!==void 0&&(t[Tt.value]={kind:"literal",value:i}),{node:{...o,inputs:t}}}s(sG,"moveNode");function bI(e){let t=[],n=[],r=e.nodes.map(i=>{if(!wI(i))return i;let o=sG(i);return"unmoved"in o?(n.push({nodeId:String(i.id),reason:o.unmoved}),i):(t.push(String(i.id)),o.node)});return t.length===0?{graph:e,moved:t,unmoved:n}:{graph:{...e,nodes:r},moved:t,unmoved:n}}s(bI,"moveSetFlagConfigToInputs");function vI(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(vI,"isObject");var dy={countersign:{dueInDays:"number"},decision:{allowSkipInTest:"boolean"},completenessCheck:{guestRole:"string"},governedDocument:{responseDueInDays:"number"}},cy={review:["allowSkipInTest"]};function xI(e){return dy[String(e)]??{}}s(xI,"movesOf");function SI(e){return cy[String(e)]??[]}s(SI,"deadOf");function AI(e){return vI(e)&&[...Object.keys(xI(e.type)),...SI(e.type)].some(t=>t in e)}s(AI,"oldShape");function EI(e){return(e?.nodes??[]).some(AI)}s(EI,"needsScalarInputMove");function aG(e,t){return t==="number"?typeof e=="number"&&Number.isInteger(e)&&e>=1:typeof e===t}s(aG,"wellTyped");function lG(e){let t=vI(e.inputs)?{...e.inputs}:{},n={...e};for(let[r,i]of Object.entries(xI(e.type))){if(!(r in e))continue;let o=e[r];if(r in t)return{unmoved:{nodeId:String(e.id),key:r,reason:"inputExists"}};if(!(i==="string"&&o==="")&&!aG(o,i))return{unmoved:{nodeId:String(e.id),key:r,reason:"valueWrongType"}};o!==""&&(t[r]={kind:"literal",value:o}),delete n[r]}for(let r of SI(e.type))delete n[r];return n.inputs=t,{node:n}}s(lG,"moveNode");function TI(e){let t=[],n=[],r=e.nodes.map(i=>{if(!AI(i))return i;let o=lG(i);return"unmoved"in o?(n.push(o.unmoved),i):(t.push(String(i.id)),o.node)});return t.length===0?{graph:e,moved:t,unmoved:n}:{graph:{...e,nodes:r},moved:t,unmoved:n}}s(TI,"moveScalarConfigToInputs");var As={team:{label:{de:"Team",en:"Team"},optionSource:"tenantTeams",existence:{check:"generic",catalog:"teamKeys"}},roleKey:{label:{de:"Rolle",en:"Role"},optionSource:"tenantRoles",existence:{check:"node",codes:["roleAssign/unknownRoleKey","completenessCheck/unknownRole"]}},article:{label:{de:"Artikel",en:"Article"},optionSource:"programArticles",existence:{check:"node",codes:["collectPayment/unknownArticle"]}},legalEntity:{label:{de:"Tr\xE4ger",en:"Legal entity"},optionSource:"tenantTraeger",existence:{check:"node",codes:["governedDocument/unknownTraeger","collectPayment/unknownPayee"]}},contractGenerator:{label:{de:"Vertragsgenerator",en:"Contract generator"},optionSource:"tenantGenerators",existence:{check:"publish",by:"admittedGeneratorByKey"}},documentTemplate:{label:{de:"Dokumentvorlage",en:"Document template"},optionSource:"tenantDocumentTemplates",existence:{check:"publish",by:"governedDocument/unknownTemplate"}},smartForm:{label:{de:"Formular",en:"Form"},optionSource:"offerSmartForms",existence:{check:"publish",by:"form/unknownSmartForm"}},unit:{label:{de:"Einrichtung",en:"Unit"},optionSource:"tenantUnits",existence:{check:"generic",catalog:"unitKeys"}},formFlag:{label:{de:"Merkmal im Formular",en:"Flag in the form"},optionSource:"targetFormFlags",existence:{check:"node",codes:["setFlag/unknownFlag"]}}};function cf(e){return typeof e=="string"&&Object.hasOwn(As,e)}s(cf,"isResourceType");var Zae=Object.keys(As).filter(e=>As[e].existence.check==="generic");function $I(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.groupKey=="string"&&t.groupKey.length>0&&Array.isArray(t.grantKeys)&&t.grantKeys.every(n=>typeof n=="string"&&n.length>0)&&(t.reduction===void 0||go(t.reduction)===null&&t.reduction.kind==="amount")&&Object.keys(t).every(n=>n==="groupKey"||n==="grantKeys"||n==="reduction")}s($I,"isPricedGroupValue");var uy=["street","hausnr","plz","ort","land"];function RI(e){return uy.includes(e)}s(RI,"isAddressPart");var dG=["municipality","municipalityKey","district","districtKey"],fy=[...uy,...dG],py={string:"text",email:"text",tel:"text",number:"number",date:"date",boolean:"boolean",enum:"option",address:"composite",docRef:"file",party:"edge",personRef:"edge",personList:"edge",roleKey:"roleKey",pricedItem:"pricedItem",pricedGroup:"pricedGroup",reduction:"reduction",article:"article",legalEntity:"legalEntity",contractGenerator:"contractGenerator",documentTemplate:"documentTemplate",localizedText:"localizedText"},Es=Object.keys(py);function $i(e){return typeof e=="string"&&e in py}s($i,"isValueType");function bn(e){return e===void 0?void 0:py[e]}s(bn,"dataTypeOf");function uf(e,t){let n=bn(e),r=bn(t);return n!==void 0&&n===r}s(uf,"valueTypesCompatible");function ff(e){return e===null?"null is not a text in both languages":dl(e,{type:"localizedText"})}s(ff,"completeLocalizedTextIssue");function dl(e,t){if(cf(t.type)&&!$i(t.type))return typeof e=="string"&&e.length>0?null:`${JSON.stringify(e)} is not a ${t.type} key`;let n=bn(t.type),r=JSON.stringify(e),i=`slot type "${t.type}" takes a binding, not a literal`;if(n===void 0||n==="composite"||n==="file"||n==="edge")return i;if(e===null)return null;switch(n){case"text":return typeof e=="string"?null:`${r} is not a text (slot type "${t.type}")`;case"date":return typeof e=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(e)?null:`${r} is not a date YYYY-MM-DD`;case"number":return typeof e=="number"&&Number.isFinite(e)?null:`${r} is not a number`;case"boolean":return typeof e=="boolean"?null:`${r} is not true/false`;case"option":{if(typeof e!="string")return`${r} is not an option value`;let o=(t.enumOptions??[]).map(a=>a.value);return o.length===0||o.includes(e)?null:`${r} is not one of the options ${o.join(", ")}`}case"pricedItem":{let o=e;return typeof o=="object"&&typeof o.itemKey=="string"&&o.itemKey.length>0&&Array.isArray(o.grantKeys)&&o.grantKeys.every(a=>typeof a=="string")?null:`${r} is not a priced item {"itemKey":\u2026,"grantKeys":[\u2026]}`}case"pricedGroup":return $I(e)?null:`${r} is not a priced group {"groupKey":\u2026,"grantKeys":[\u2026]}`;case"article":return typeof e=="string"&&e.length>0?null:`${r} is not an article key`;case"legalEntity":return typeof e=="string"&&e.length>0?null:`${r} is not a legal entity key`;case"contractGenerator":return Za(e)?null:`${r} is not a contract generator {"kind":"generator"|"package","key":\u2026,"revision"?:n}`;case"documentTemplate":return typeof e=="string"&&e.length>0?null:`${r} is not a document template key`;case"roleKey":return typeof e=="string"&&e.length>0?null:`${r} is not a role key`;case"localizedText":{let o=e,a=s(l=>typeof l=="string"&&l.trim().length>0,"filled");return typeof o=="object"&&Object.keys(o).sort().join(",")==="de,en"&&a(o.de)&&a(o.en)?null:`${r} is not a text in both languages {"de":\u2026,"en":\u2026}`}case"reduction":{let o=go(e);return o===null?null:`${r} is not a reduction \u2014 ${o.en}`}}}s(dl,"literalTypeIssue");function II(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(II,"isObject");var cG={collectPayment:{reason:"reason"}},uG={governedDocument:["mockAutoProduce"]},OI={collectPayment:{reason:{de:"`reason` gibt es als Knoteneigenschaft nicht mehr \u2014 der Hinweis f\xFCr die Familie ist der Eingang `inputs.reason` (ein fester Text auf Deutsch und Englisch im Parameter-Bereich).",en:"`reason` no longer exists as a node property \u2014 the note for the family is the input `inputs.reason` (a fixed text in German and English among the parameters)."}},governedDocument:{template:{de:"`template` gibt es am Knoten nicht mehr \u2014 die Parameter geh\xF6ren der Vorlage (ihr Datensatz, `plexus-cli catalog` documentTemplates[].parameters) und werden beim Speichern und Ver\xF6ffentlichen als `templateStamp` \xFCbernommen.",en:"`template` no longer exists on the node \u2014 the parameters belong to the template (its record, `plexus-cli catalog` documentTemplates[].parameters) and are stamped as `templateStamp` on save and publish."},cockpitFields:{de:'`cockpitFields` gibt es nicht mehr \u2014 ein Parameter, der im Cockpit erg\xE4nzt wird, ist sein Eingang `{ kind: "cockpit" }` (im Parameter-Bereich \u201Eim Cockpit erg\xE4nzen").',en:'`cockpitFields` no longer exists \u2014 a parameter completed in the cockpit is its input `{ kind: "cockpit" }` ("complete in the cockpit" among the parameters).'},mockAutoProduce:{de:"`mockAutoProduce` gibt es nicht mehr \u2014 das Muster-Dokument, das ein Upload-Knoten beim Eintritt selbst einstellte, ist entfernt; das Dokument kommt aus einem Upload.",en:"`mockAutoProduce` no longer exists \u2014 the sample document an upload node put on its slot by itself on entry is removed; the document comes from an upload."}}};function my(e){return cG[String(e)]??{}}s(my,"movesOf");function PI(e){return uG[String(e)]??[]}s(PI,"deadOf");function _I(e){return II(e)&&[...Object.keys(my(e.type)),...PI(e.type)].some(t=>t in e)}s(_I,"oldShape");function CI(e){return(e?.nodes??[]).some(_I)}s(CI,"needsNodeConfigInputMove");function fG(e){return ff(e)===null}s(fG,"isCompleteText");function pG(e){let t=II(e.inputs)?{...e.inputs}:{},n={...e};for(let[r,i]of Object.entries(my(e.type)))if(r in e){if(i in t)return{unmoved:{nodeId:String(e.id),key:r,reason:"inputExists"}};if(!fG(e[r]))return{unmoved:{nodeId:String(e.id),key:r,reason:"valueNotLocalized"}};t[i]={kind:"literal",value:e[r]},delete n[r]}for(let r of PI(e.type))delete n[r];return Object.keys(my(e.type)).some(r=>r in e)&&(n.inputs=t),{node:n}}s(pG,"moveNode");function NI(e){let t=[],n=[],r=e.nodes.map(i=>{if(!_I(i))return i;let o=pG(i);return"unmoved"in o?(n.push(o.unmoved),i):(t.push(String(i.id)),o.node)});return t.length===0?{graph:e,moved:t,unmoved:n}:{graph:{...e,nodes:r},moved:t,unmoved:n}}s(NI,"moveNodeConfigToInputs");var hy="collectPayment",Ts=["online","separate"];function pf(e){return Ts.includes(e)}s(pf,"isCollectPaymentSettlement");var $s="paid",gy="skipPayment",Ri="article",Wn="settlement",Ii="reason",Yn="payee",yy=["one_time"];function mf(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(mf,"isObject");function DI(e){if(!mf(e)||e.type!==hy)return!1;let t=mf(e.inputs)?e.inputs:{},n=t[Wn];return!mf(n)||n.kind!=="literal"||n.value!=="online"?!1:!(Yn in t)}s(DI,"isOnlinePaymentWithoutPayee");function FI(e){return(e?.nodes??[]).some(DI)}s(FI,"needsPayee");function LI(e,t={}){let n=[],r=[],i=e.nodes.map(o=>{if(!DI(o))return o;let a=String(o.id),l=Object.hasOwn(t,a)?t[a]:void 0;if(l===void 0||l==="")return r.push(a),o;n.push({nodeId:a,payee:l});let d=mf(o.inputs)?o.inputs:{};return{...o,inputs:{...d,[Yn]:{kind:"literal",value:l}}}});return n.length===0?{graph:e,set:n,refused:r}:{graph:{...e,nodes:i},set:n,refused:r}}s(LI,"setPayeeOnOnlinePayments");function hf(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(hf,"isObject");function wy(e){return hf(e)&&hf(e.assign)&&"userId"in e.assign}s(wy,"namesUser");function gf(e){return(e?.nodes??[]).flatMap(t=>hf(t)&&Array.isArray(t.tasks)?t.tasks.filter(wy).map(n=>({nodeId:String(t.id),taskKey:String(n.key),hasTeam:typeof n.assign.group=="string"&&n.assign.group.length>0})):[])}s(gf,"taskUserAssignments");function MI(e){let t=gf(e);if(t.length===0)return{graph:e,dropped:t};let n=e.nodes.map(r=>{if(!hf(r)||!Array.isArray(r.tasks)||!r.tasks.some(wy))return r;let i=r.tasks.map(o=>{if(!wy(o))return o;let{userId:a,...l}=o.assign,{assign:d,...c}=o;return Object.keys(l).length===0?c:{...c,assign:l}});return{...r,tasks:i}});return{graph:{...e,nodes:n},dropped:t}}s(MI,"dropTaskAssignUserIds");var Rs={"assign{}":{kind:"team",codec:"key",involves:!0,required:!1,what:{de:"Team der Knoten-Aufgabe",en:"team of the node task"},consequence:{de:"beim Betreten des Knotens entsteht die Aufgabe f\xFCr niemanden",en:"entering the node creates the task for nobody"}},"tasks[].assign.group":{kind:"team",codec:"key",involves:!0,required:!0,what:{de:"Team der Aufgabe",en:"team of the task"},consequence:{de:"die Aufgabe kann nicht angelegt werden, und der Prozess bleibt stehen",en:"the task cannot be created and the process stops"}},"tasks[].params.revisionGroup":{kind:"team",codec:"key",involves:!0,required:!1,what:{de:"Team der \xDCberarbeitung",en:"revision team"},consequence:{de:"eine Ablehnung findet niemanden, der \xFCberarbeitet",en:"a rejection finds nobody to revise"}},"tasks[].result.chat":{kind:"team",codec:"chatTarget",involves:!1,required:!1,what:{de:"Chat des Ergebnisses",en:"chat of the result"},consequence:{de:"das Ergebnis l\xE4sst sich nicht im Chat ablegen",en:"the result cannot be posted to the chat"}},"optionalActions[].trigger":{kind:"team",codec:"key",involves:!1,required:!1,what:{de:"Team, das die Aktion ausl\xF6sen darf",en:"team that may trigger the action"},consequence:{de:"niemand au\xDFer der Prozessverantwortung kann die Aktion ausl\xF6sen",en:"nobody but the process owner can trigger the action"}}},ky=s(e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null,"record");function qI(e,t){if(typeof t!="string"||t.length===0)return null;if(e==="key")return t;let n=ws(t);return n?.kind==="team"?n.groupKey:null}s(qI,"decodeKey");function mG(e){let t=/^(tasks|optionalActions)\[\](?:\.([a-zA-Z]+))?\.([a-zA-Z]+)$/.exec(e);return t===null&&C(`[resource] unreadable reference leaf "${e}"`),{list:t[1],field:t[2]??null,key:t[3]}}s(mG,"locate");function yf(e){let t=[],n=e;for(let[r,i]of Object.entries(ky(n.assign)??{})){let o=qI("key",i);t.push({path:`assign.${r}`,leaf:"assign{}",owner:r,key:o,missing:typeof i!="string"||i.length===0})}for(let r of Object.keys(Rs)){if(r==="assign{}")continue;let i=Rs[r],{list:o,field:a,key:l}=mG(r);for(let d of Array.isArray(n[o])?n[o]:[]){let c=ky(d);if(c===null||typeof c.key!="string")continue;let f=(a===null?c:ky(c[a]))?.[l];if(f===void 0&&!i.required)continue;let m=typeof f!="string"||f.length===0;t.push({path:`${o}.${c.key}${a===null?"":`.${a}`}.${l}`,leaf:r,owner:c.key,key:qI(i.codec,f),missing:m})}}return t}s(yf,"nodeResourceReferences");var KI=s(e=>(e??[]).map(t=>`\u201E${t}\u201C`).join(", "),"list"),jI=s(e=>(e??[]).map(t=>`"${t}"`).join(", "),"listEn"),hG={"address/shape":{de:s(e=>({problem:`${e.where}: \u201E${e.address}\u201C ist keine g\xFCltige Adresse.`,remedy:"W\xE4hle die Adresse in der Auswahl neu."}),"de"),en:s(e=>({problem:`${e.where}: "${e.address}" is not a valid address.`,remedy:"Choose the address again from the picker."}),"en")},"address/missing":{de:s(e=>({problem:`${e.where}: Hier fehlt die Adresse, ohne die dieser Schritt nicht arbeiten kann.`,remedy:"W\xE4hle sie in der Auswahl."}),"de"),en:s(e=>({problem:`${e.where}: The address this step cannot work without is missing.`,remedy:"Choose it from the picker."}),"en")},"address/bareIdentifier":{de:s(e=>({problem:`${e.where}: \u201E${e.address}\u201C nennt nur einen Schl\xFCssel, nicht, wer ihn erzeugt.`,remedy:"W\xE4hle in der Auswahl die volle Adresse, z. B. das Feld aus dem Formular, das es erfasst."}),"de"),en:s(e=>({problem:`${e.where}: "${e.address}" names a key only, not who produces it.`,remedy:"Choose the full address from the picker, e.g. the field from the form that collects it."}),"en")},"address/unknownOwner":{de:s(e=>({problem:`${e.where}: ${e.address} nennt einen Knoten oder eine Aufgabe, die es im Ablauf nicht gibt.`,remedy:"W\xE4hle eine Adresse aus der Auswahl."}),"de"),en:s(e=>({problem:`${e.where}: ${e.address} names a node or task the workflow does not have.`,remedy:"Choose an address from the picker."}),"en")},"address/unknownKey":{de:s(e=>({problem:`${e.where}: ${e.producer??"der Erzeuger"} erzeugt ${e.address} nicht.`,remedy:"W\xE4hle einen Wert, den der Erzeuger tats\xE4chlich liefert."}),"de"),en:s(e=>({problem:`${e.where}: ${e.producer??"the producer"} does not produce ${e.address}.`,remedy:"Choose a value the producer actually delivers."}),"en")},"address/envCohortBound":{de:s(e=>({problem:`${e.where}: ${e.address} \xE4ndert sich, wenn Stufe oder Schuljahr gewechselt werden \u2014 ein Dokument, das den Wert druckt, w\xFCrde das nicht bemerken.`,remedy:"Lies den Wert \xFCber ein Formularfeld, das ihn berechnet (z. B. \u201EKlassenstufe\u201C): ein Wechsel friert es neu ein und h\xE4lt ein gedrucktes Dokument an."}),"de"),en:s(e=>({problem:`${e.where}: ${e.address} changes when the application's stage or school year is changed \u2014 a document printing it would not notice.`,remedy:'Read it through a form field that computes it (e.g. "Grade"): a change re-freezes it and holds a printed document.'}),"en")},"address/staffInputConditionOnly":{de:s(e=>({problem:`${e.where}: ${e.address} ist eine interne Angabe beim Anlegen \u2014 sie lenkt eine Weiche (\u201EWenn\u201C-Knoten) oder f\xFCllt einen Parameter eines Knotens.`,remedy:"Lies sie in der Bedingung eines \u201EWenn\u201C-Knotens oder binde einen Parameter des Knotens daran (z. B. im Vertrag); Formulare, Aufgaben und Regeln lesen sie nicht."}),"de"),en:s(e=>({problem:`${e.where}: ${e.address} is a staff input set at the start \u2014 it steers a branch (an "If" node) or fills a node's parameter.`,remedy:'Read it in the condition of an "If" node or bind a node parameter to it (e.g. in the contract); forms, tasks and rules do not read it.'}),"en")},"address/ownerNotWriter":{de:s(e=>({problem:`${e.where}: Die Aufgabe \u201E${e.producer}\u201C schreibt ${e.address} nicht.`,remedy:"W\xE4hle den Wert \xFCber seinen Schl\xFCssel; die schreibende Aufgabe folgt daraus."}),"de"),en:s(e=>({problem:`${e.where}: The task "${e.producer}" does not write ${e.address}.`,remedy:"Choose the value by its key; the writing task follows from it."}),"en")},"address/taskOwnerTaken":{de:s(e=>({problem:`${e.where}: Den Aufgaben-Schl\xFCssel gibt es mehrfach (${KI(e.names)}), und eine dieser Aufgaben schreibt Prozesswerte.`,remedy:"Gib der schreibenden Aufgabe einen Schl\xFCssel, den keine andere Aufgabe tr\xE4gt."}),"de"),en:s(e=>({problem:`${e.where}: The task key is used more than once (${jI(e.names)}), and one of these tasks writes process values.`,remedy:"Give the writing task a key no other task carries."}),"en")},"address/notVisible":{de:s(e=>({problem:e.producerNode!==void 0&&e.producerNode!==e.producer?`${e.where}: ${e.address} \u2014 \u201E${e.producer}\u201C h\xE4ngt an \u201E${e.producerNode}\u201C, das nicht auf jedem Weg vor \u201E${e.reader}\u201C liegt.`:`${e.where}: ${e.address} \u2014 \u201E${e.producer}\u201C liegt nicht auf jedem Weg vor \u201E${e.reader}\u201C.`,remedy:`Lies nur, was auf jedem Weg vor \u201E${e.reader}\u201C entsteht, oder ordne die Schritte so, dass der Erzeuger immer vorher l\xE4uft.`}),"de"),en:s(e=>({problem:e.producerNode!==void 0&&e.producerNode!==e.producer?`${e.where}: ${e.address} \u2014 "${e.producer}" hangs on "${e.producerNode}", which does not lie before "${e.reader}" on every path.`:`${e.where}: ${e.address} \u2014 "${e.producer}" does not lie before "${e.reader}" on every path.`,remedy:`Read only what is produced before "${e.reader}" on every path, or order the steps so the producer always runs first.`}),"en")},"address/pathNotInTarget":{de:s(e=>({problem:`${e.where}: ${e.address} \u2014 ${e.producer??"der Erzeuger"} hat dieses Feld nicht.`,remedy:"W\xE4hle ein Feld, das es dort gibt."}),"de"),en:s(e=>({problem:`${e.where}: ${e.address} \u2014 ${e.producer??"the producer"} has no such field.`,remedy:"Choose a field that exists there."}),"en")},"address/typeMismatch":{de:s(e=>({problem:`${e.where}: erwartet ${e.expected}, ${e.address} ist ${e.actual}.`,remedy:`W\xE4hle einen Wert vom Typ ${e.expected}.`}),"de"),en:s(e=>({problem:`${e.where}: expects ${e.expected}, ${e.address} is ${e.actual}.`,remedy:`Choose a value of type ${e.expected}.`}),"en")},"address/notFormInstance":{de:s(e=>({problem:`${e.where}: ${e.address} ist kein ganzes Formular.`,remedy:"W\xE4hle das Formular des Knotens, der es anlegt \u2014 ohne Feld, nicht den Knoten, der es \xFCbernimmt."}),"de"),en:s(e=>({problem:`${e.where}: ${e.address} is not a whole form.`,remedy:"Choose the form of the node that creates it \u2014 without a field, not the node that continues it."}),"en")},"address/mixedForms":{de:s(e=>({problem:`${e.where}: Die Liste liest Felder aus mehreren Formularen (${KI(e.names)}), beurteilt wird sie aber an einem Formular.`,remedy:"W\xE4hle alle Felder dieser Liste aus demselben Formular."}),"de"),en:s(e=>({problem:`${e.where}: The list reads fields of several forms (${jI(e.names)}) but is judged on one.`,remedy:"Choose every field of this list from the same form."}),"en")},"workItems/keyFormat":{de:s(e=>({problem:`${e.where}: Der Aufgaben-Schl\xFCssel \u201E${e.address}\u201C hat nicht die Form ^[a-z][a-zA-Z0-9_]*$.`,remedy:"Benenne die Aufgabe in camelCase um, z. B. \u201EgeschwisterRang\u201C."}),"de"),en:s(e=>({problem:`${e.where}: The task key "${e.address}" does not match ^[a-z][a-zA-Z0-9_]*$.`,remedy:'Rename the task in camelCase, e.g. "siblingRank".'}),"en")}};function Is(e,t,n){let{problem:r,remedy:i}=hG[e][n](t);return`[${e}] ${r} ${i}`}s(Is,"addressMessage");function Pn(e){let t=[];for(let n of e){let r=n.next;if(r)for(let[i,o]of Object.entries(r))t.push({id:`${n.id}|${i}`,source:n.id,target:o.to,sourceBranchId:i})}return t}s(Pn,"derivedEdges");function wf(e,t,n){if(t===n)return!0;let r=new Map,i=new Set;for(let l of Pn(e.nodes)){let d=r.get(l.source)??[];d.push(l.target),r.set(l.source,d),i.add(l.target)}let o=e.nodes.filter(l=>!i.has(l.id)&&l.id!==t).map(l=>l.id),a=new Set(o);for(;o.length>0;){let l=o.shift();if(l===n)return!1;for(let d of r.get(l)??[])d===t||a.has(d)||(a.add(d),o.push(d))}return!0}s(wf,"dominates");function BI(e,t,n){if(t===n)return!0;let r=new Map;for(let a of Pn(e.nodes)){let l=r.get(a.source)??[];l.push(a.target),r.set(a.source,l)}let i=[t],o=new Set(i);for(;i.length>0;){let a=i.shift();for(let l of r.get(a)??[]){if(l===n)return!0;o.has(l)||(o.add(l),i.push(l))}}return!1}s(BI,"reaches");function by(e,t){let n=[],r=s(a=>({address:a.address,type:a.type,...a.label!==void 0?{label:a.label}:{},nodeId:a.nodeId}),"toVisible");for(let a of e.nodes)if(wf(e,a.id,t))for(let l of Or(e,a))n.push(r(l));for(let a of rI)n.push({address:{scope:"env",key:a},type:ny(a),label:ry(a),nodeId:null});for(let a of Wu(e))n.push({address:{scope:"env",key:Yu(a.key)},type:a.type,label:a.label,nodeId:null});let i=new Set(n.map(a=>se(a.address))),o=(Array.isArray(e.processStore)?e.processStore:[]).filter(a=>a.derive!==void 0);for(let a=!0;a;){a=!1;for(let l of o){let d=se({scope:"derived",key:l.key});if(i.has(d))continue;let c=il(e,l.key);c===null||!c.every(u=>i.has(se(sf(u))))||(n.push({address:{scope:"derived",key:l.key},type:l.type,label:l.label,nodeId:null}),i.add(d),a=!0)}}return n}s(by,"visibleAddressesAt");function _r(e,t){let n=e?.readinessFormFieldsByFormNode?.get(t.owner);if(n!==void 0)return n.get(t.path)??null}s(_r,"formFieldEntryOf");var UI={binding:{de:"Eingang",en:"Input"},condition:{de:"Bedingung",en:"Condition"},nodeReads:{de:"Gelesene Felder",en:"Fields read"},requires:{de:"Geforderte Felder",en:"Required fields"},adoptForm:{de:"\xDCbernommenes Formular",en:"Continued form"},setFlagTarget:{de:"Freizuschaltendes Formular",en:"Form to unlock"},form:{de:"Formular",en:"Form"},contract:{de:"Vertrag",en:"Contract"},payment:{de:"Zahlung",en:"Payment"},taskWhen:{de:"Bedingung",en:"Condition"},taskReads:{de:"Gelesene Felder der Aufgabe",en:"Fields the task reads"},taskDocument:{de:"Dokumente",en:"Documents"},familyRequestFields:{de:"Nachforderbare Felder",en:"Requestable fields"},familyRequestFrom:{de:"Nachforderung aus",en:"Request from"},suggest:{de:"Vorschlag",en:"Suggestion"},reduction:{de:"Erm\xE4\xDFigung des Preises",en:"Reduction of the price"},pricingRule:{de:"Preisregel",en:"Pricing rule"}},gG=new Set(["nodeReads","requires","taskReads","taskDocument","familyRequestFields"]);function yG(e,t,n){let r=[];t.taskKey!==void 0&&r.push(`${n==="de"?"Aufgabe":"task"} \u201E${bo(e,t.taskKey,n)}\u201C`);let i=t.kind==="binding"?` \u201E${t.at.split(".").pop()}\u201C`:"";return r.push(`${UI[t.kind][n]}${i}`),r.join(" \u203A ")}s(yG,"addressFieldWhere");function cl(e,t,n){let r=yG(e,t,n);return t.nodeId===null?r:`\u201E${Oe(e,t.nodeId,n)}\u201C \u203A ${r}`}s(cl,"whereOf");function VI(e,t,n){if(t.scope==="node")return Oe(e,t.owner,n);if(t.scope==="task")return bo(e,t.owner,n)}s(VI,"producerName");function GI(e,t){let n=[],r=new Set,i=s((l,d,c)=>{let u={de:Is(l,c("de"),"de"),en:Is(l,c("en"),"en")},f=`${d}|${u.de}`;r.has(f)||(r.add(f),n.push({layer:"GRAPH",kind:"nodeRule",path:d,reason:u,severity:"error"}))},"report"),o=new Map(e.nodes.map(l=>[l.id,l])),a=[...e.nodes.flatMap(l=>sl(l)),...af(e)];for(let l of a){let d=s(c=>cl(e,l,c),"where");for(let c of wG(e,l,i))bG(e,l,c,i)&&(xG(e,l,c,t,i),oy.has(l.kind)&&!AG(o,c)&&i("address/notFormInstance",l.at,u=>({where:d(u),address:Be(e,c,u)})))}return EG(e,i),TG(e,a,i),OG(e,i),_G(e,i),n}s(GI,"checkAddresses");function wG(e,t,n){let r=s(i=>cl(e,t,i),"where");if(sy(t)){let i=lf(t.value)??[];for(let o of i)o.address===null&&n(o.reason==="bareIdentifier"?"address/bareIdentifier":"address/shape",t.at,a=>({where:r(a),address:o.identifier}));return Ss(t)}return typeof t.value=="string"?(n("address/bareIdentifier",t.at,i=>({where:r(i),address:t.value})),[]):be(t.value)?[t.value]:(n("address/shape",t.at,i=>({where:r(i),address:JSON.stringify(t.value)??"undefined"})),[])}s(wG,"checkFieldShape");function zI(e,t,n,r){let i=VI(e,n,r);return{where:cl(e,t,r),address:Be(e,n,r),...i!==void 0?{producer:i}:{}}}s(zI,"addressParams");function kG(e,t,n){return ty(t)?null:Qa(e,t)!==void 0?n==="condition"||n==="binding"?null:"address/staffInputConditionOnly":lr(t)?"address/envCohortBound":"address/unknownKey"}s(kG,"envAddressRefusal");function bG(e,t,n,r){let i=s(o=>zI(e,t,n,o),"params");switch(n.scope){case"env":{let o=kG(e,n.key,t.kind);return o===null?!0:(r(o,t.at,i),!1)}case"derived":return(e.processStore??[]).find(a=>a.key===n.key)?.derive!==void 0?!0:(r("address/unknownKey",t.at,i),!1);case"task":return e.nodes.some(a=>(a.tasks??[]).some(l=>l.key===n.owner))?(e.processStore??[]).some(a=>a.key===n.key&&a.derive===void 0)?Pr(e,n.owner,n.key)===null?(r("address/ownerNotWriter",t.at,i),!1):!0:(r("address/unknownKey",t.at,i),!1):(r("address/unknownOwner",t.at,i),!1);case"node":{let o=e.nodes.find(a=>a.id===n.owner);return o===void 0?(r("address/unknownOwner",t.at,i),!1):Or(e,o).some(a=>a.address.scope==="node"&&a.address.key===n.key)?!0:(r(oy.has(t.kind)&&kn(o)?"address/notFormInstance":"address/unknownKey",t.at,i),!1)}}}s(bG,"resolves");function vG(e,t){return e===void 0||t===void 0||bn(t)===void 0?!0:bn(e)!==void 0&&uf(e,t)}s(vG,"addressTypeFits");function xG(e,t,n,r,i){let o=s(l=>zI(e,t,n,l),"params");if(n.scope!=="env"&&n.path!==void 0&&!SG(e,t,n,r)){i("address/pathNotInTarget",t.at,o);return}if(t.expectedType===void 0)return;let a=ly(e,n);vG(a,t.expectedType)||i("address/typeMismatch",t.at,l=>({...o(l),expected:t.expectedType,actual:a}))}s(xG,"checkPathAndType");function SG(e,t,n,r){if(n.scope!=="node")return!1;if(ly(e,n)!==void 0)return!0;if(n.key!==tn)return!1;if(!gG.has(t.kind))return e.nodes.find(o=>o.id===n.owner)?.formExports===void 0;let i=r?.readinessFormFieldsByFormNode?.get(n.owner);return i===void 0||i.has(n.path)}s(SG,"pathExists");function AG(e,t){if(!bs(t))return!1;let n=e.get(t.owner);return n!==void 0&&n.type==="form"&&!kn(n)}s(AG,"isCreatingFormInstance");function EG(e,t){for(let n of e.nodes){let r=new Set(sl(n).map(i=>i.kind));for(let i of aI(n))r.has(i)||t("address/missing",`nodes.${n.id}.${i}`,o=>({where:`\u201E${Oe(e,n.id,o)}\u201C \u203A ${UI[i][o]}`}))}}s(EG,"checkRequiredFields");function TG(e,t,n){let r=new Map;for(let i of t)if(i.judgedTogether!==null)for(let o of Ss(i)){if(o.scope!=="node"||o.key!==tn)continue;let a=r.get(i.judgedTogether)??[];a.push({field:i,owner:o.owner}),r.set(i.judgedTogether,a)}for(let[i,o]of r){let a=[...new Set(o.map(l=>l.owner))];a.length<2||n("address/mixedForms",i,l=>({where:cl(e,o[0].field,l),names:a.map(d=>Oe(e,d,l))}))}}s(TG,"checkMixedForms");function $G(e,t){return e.type==="engagePush"&&t.kind==="payment"}s($G,"readSkipsAbsentProducer");function RG(e,t,n){return t!==n&&BI(e,t,n)}s(RG,"precedesOnSomePath");function IG(e,t,n,r){let i=sf(n.address);return r.has(se(i))||!PG(e,i)?!0:n.origin==="written"&&i.scope==="node"&&$G(t,n.field)&&RG(e,i.owner,t.id)}s(IG,"readPassesVisibility");function OG(e,t){for(let n of e.nodes){let r=ko(e,n);if(r.length===0)continue;let i=new Set(by(e,n.id).map(o=>se(o.address)));for(let o of r){let a=sf(o.address);if(IG(e,n,o,i))continue;let l=a.scope==="task"?Pr(e,a.owner,a.key):a.scope==="node"?a.owner:null;t("address/notVisible",o.field.at,d=>({where:cl(e,o.field,d),address:Be(e,o.address,d),producer:VI(e,a,d)??Be(e,a,d),...l!==null?{producerNode:Oe(e,l,d)}:{},reader:Oe(e,n.id,d)}))}}}s(OG,"checkVisibility");function PG(e,t){if(t.scope==="env")return ty(t.key);if(t.scope==="derived")return il(e,t.key)!==null;let n=se(t);return e.nodes.some(r=>Or(e,r).some(i=>se(i.address)===n))}s(PG,"producedSomewhere");function _G(e,t){let n=new Map;for(let r of e.nodes){let i=new Set(Or(e,r).flatMap(o=>o.address.scope==="task"?[o.address.owner]:[]));for(let[o,a]of(r.tasks??[]).entries()){let l=a.key;if(typeof l!="string"||!Rr.test(l)){t("workItems/keyFormat",`nodes.${r.id}.tasks.${o}.key`,c=>({where:`\u201E${Oe(e,r.id,c)}\u201C`,address:String(l)}));continue}let d=n.get(l)??[];d.push({nodeId:r.id,writes:i.has(l)}),n.set(l,d)}}for(let[r,i]of n)if(!(i.length<2||!i.some(o=>o.writes)))for(let o of i)t("address/taskOwnerTaken",`nodes.${o.nodeId}.tasks.${r}`,a=>({where:`\u201E${Oe(e,o.nodeId,a)}\u201C \u203A ${a==="de"?"Aufgabe":"task"} \u201E${bo(e,r,a)}\u201C`,names:i.map(l=>Oe(e,l.nodeId,a))}))}s(_G,"checkTaskKeys");function kf(e,t){return e.label[t]??""}s(kf,"wordingIn");function Oi(e,t){let n=WI(e,t),r=kf(e.qualifier,t);return n===""||r===""&&kf(e.qualifier,"de")!==""?"":r===""?n:`${r} \xB7 ${n}`}s(Oi,"fieldLabelIn");function WI(e,t){return kf(e,t)}s(WI,"fieldOwnLabelIn");function Pi(e){return{key:e.key,kind:e.kind,type:e.kind==="entered"?e.type:null,repeated:e.kind==="entered"&&e.repeated,name:{de:Oi(e,"de"),en:Oi(e,"en")}}}s(Pi,"catalogField");function _i(e,t,n){switch(e){case"nodeReads":return t.repeated?"repeated":n==="review"&&t.kind==="computed"?"computed":null;case"requires":return t.repeated?"repeated":t.kind==="computed"?"computed":t.name.en===""?"untranslated":null;case"taskDocument":return t.repeated?"repeated":t.kind==="entered"&&t.type==="docRef"?null:"notDocument";case"taskReads":case"familyRequestFields":return null}}s(_i,"catalogFieldRefusal");function bf(e,t){let n=e.buses.find(r=>r.key===t);return n||C(`[progress] layout '${e.id}' has no bus '${t}'`),n}s(bf,"progressBus");function ul(e,t){return e.states.some(n=>n.id===t)}s(ul,"isBusState");function YI(e,t){let n=e.terminalSemantics?.[t];return n||C(`[progress] no terminal semantics for state '${t}' on bus '${e.key}'`),n}s(YI,"terminalSemantics");function vf(e,t){return!!e.terminalSemantics&&Object.prototype.hasOwnProperty.call(e.terminalSemantics,t)}s(vf,"hasTerminalSemantics");function CG(e,t){return(e.boards??[]).find(n=>n.audience===t||n.audience==="both")??null}s(CG,"boardForAudience");function HI(e){return CG(bf(e,"process"),"internal")}s(HI,"internalProcessBoard");function Os(e,t,n){let r=null;for(let i of e.mappings)if(i.event===n)if("nodeId"in i.match){if(i.match.nodeId===t.id)return{bus:i.bus,state:i.state}}else i.match.nodeType===t.type&&(r=i);return r?{bus:r.bus,state:r.state}:null}s(Os,"resolveProgressEvent");var Ps={approved:"enrolled",rejected:"declined",withdrawn:"declined",expired:"declined"},Xr=Object.keys(Ps);function vo(e){return Object.hasOwn(Ps,e)}s(vo,"isEndNodeOutcome");var vy={approved:{de:"Angenommen",en:"Admitted"},rejected:{de:"Abgelehnt",en:"Rejected"},withdrawn:{de:"Zur\xFCckgezogen",en:"Withdrawn"},expired:{de:"Abgelaufen",en:"Expired"}};var Ci=["commit","discard"],Hle=w.union(...Ci.map(e=>w.literal(e)));function xf(e){return typeof e=="string"&&Ci.includes(e)}s(xf,"isApplicationDataDecision");function _t(e){return Object.keys(e)}s(_t,"progressEventsOf");var ne=s((e,t)=>({de:e,en:t}),"lt"),Ze=s((e,t,n,r,i=null,o=null)=>({chipLabel:e,tone:t,nextAction:i,affordance:o,title:n,body:r}),"ex"),JI={key:"eingeschrieben",label:ne("Eingeschrieben","Enrolled"),scope:"global",defaultCollapsed:!0},Sf={key:"abgesagt",label:ne("Abgesagt","Declined"),scope:"global",track:"exit",defaultCollapsed:!0},QI={key:"abgelehnt",label:ne("Abgelehnt","Rejected"),scope:"global",track:"exit",defaultCollapsed:!0};var ZI={enrolled:{label:ne("Eingeschrieben","Enrolled"),tone:"green",terminal:{lifecycleStatus:"completed",outcome:"approved"},phase:JI,external:Ze(ne("Eingeschrieben","Enrolled"),"green",ne("Sie sind eingeschrieben!","You are enrolled!"),ne("Ihre Anmeldung ist abgeschlossen und Ihr Platz ist gesichert. Wir freuen uns auf Sie.","Your enrolment is complete and your place is secured. We look forward to welcoming you."))},declined:{label:ne("Abgesagt","Declined"),tone:"red",terminal:{lifecycleStatus:"completed",outcome:"rejected"},phase:Sf,external:Ze(ne("Abgesagt","Declined"),"red",ne("Die Bewerbung wurde beendet","The application has ended"),ne("Ihre Bewerbung wurde nicht fortgef\xFChrt.","Your application was not continued."))}},XI={role:"effect",effect:"pure",progressDefaults:ZI,progressEvents:_t(ZI),inputs:s(()=>[{id:"applicationOutcome",label:{de:"Ergebnis",en:"Outcome"},type:"enum",required:!0,inspector:"literal-only",optionSource:"declared",enumOptions:Xr.map(e=>({value:e,label:vy[e]}))},{id:"dataDecision",label:{de:"Erfasste Daten",en:"Captured data"},type:"enum",required:!0,inspector:"literal-only",optionSource:"declared",enumOptions:[{value:"commit",label:{de:"\xDCbernehmen",en:"Keep"}},{value:"discard",label:{de:"Verwerfen",en:"Discard"}}]}],"inputs"),notificationEvents:s(()=>[{id:"reached",label:{de:"Verfahren abgeschlossen",en:"Process completed"},audience:"external",args:[{key:"applicationId",type:"string",required:!0},{key:"outcome",type:"string",required:!0}]}],"notificationEvents"),validate:s(e=>[...NG(e),...DG(e),...FG(e)],"validate")},_s=s((e,t,n,r)=>({layer:"GRAPH",kind:"nodeRule",path:`node.${e.id}.inputs.${t}`,reason:{de:n,en:r},severity:"error"}),"nodeIssue");function xy(e){let t=e.inputs?.applicationOutcome;return t?.kind==="literal"&&t.value!=null?String(t.value):null}s(xy,"literalOutcome");function NG(e){if(e.type!=="end")return[];let t=e.inputs?.applicationOutcome;if(t===void 0||t.kind==="unset")return[];let n=xy(e);return n===null?[_s(e,"applicationOutcome",`[end/applicationOutcome] ${e.label.de}: das Ergebnis ist kein fester Wert \u2014 die Engine kann den Abschluss nicht ableiten`,`[end/applicationOutcome] ${e.label.en}: the application outcome is no fixed value \u2014 the engine cannot derive the terminal`)]:vo(n)?[]:[_s(e,"applicationOutcome",`[end/applicationOutcome] ${e.label.de}: '${n}' ist kein Ausgang eines Endknotens (${Xr.join("|")}) \u2014 die Warteliste endet \xFCber das closed-Outcome ihres Wartelistenknotens`,`[end/applicationOutcome] ${e.label.en}: '${n}' is not an outcome of an end node (${Xr.join("|")}) \u2014 the waitlist ends through the closed outcome of its waitlist node`)]}s(NG,"checkEndApplicationOutcome");function DG(e){if(e.type!=="end")return[];let t=e.inputs?.dataDecision;return!t||t.kind!=="literal"||t.value==null?[_s(e,"dataDecision",`[end/dataDecision] ${e.label.de}: dataDecision fehlt \u2014 der Endknoten muss festlegen, ob die erfassten Daten \xFCbernommen (commit) oder verworfen (discard) werden`,`[end/dataDecision] ${e.label.en}: dataDecision is missing \u2014 the end node must decide whether the collected data is kept (commit) or discarded (discard)`)]:xf(t.value)?[]:[_s(e,"dataDecision",`[end/dataDecision] ${e.label.de}: dataDecision '${String(t.value)}' ist ung\xFCltig (${Ci.join("|")})`,`[end/dataDecision] ${e.label.en}: dataDecision '${String(t.value)}' is invalid (${Ci.join("|")})`)]}s(DG,"checkEndDataDecision");function FG(e){if(e.type!=="end")return[];let t=xy(e);if(t===null||!vo(t)||t==="approved")return[];let n=e.inputs?.dataDecision;if(n?.kind!=="literal"||n.value!=="commit")return[];let r=vy[t];return[{..._s(e,"dataDecision",`[end/commitWithoutApproval] ${e.label.de}: Ende ohne Zusage \xFCbernimmt die erfassten Daten (commit) \u2014 Personen und Beziehungen bleiben nach dem Ergebnis \u201E${r.de}" bestehen. Gewollt? Sonst discard.`,`[end/commitWithoutApproval] ${e.label.en}: end without admission keeps the captured data (commit) \u2014 persons and relationships remain after the outcome "${r.en}". Intended? Otherwise discard.`),severity:"warning"}]}s(FG,"checkEndCommitWithoutApproval");function eO(e,t){if(!t?.layout||!t.wiring)return[];let n=[];for(let r of e.nodes){if(r.type!=="end")continue;let i=xy(r);if(i===null||!vo(i))continue;let o=Ps[i],a=Os(t.wiring,r,o);if(a===null)continue;let l=t.layout.buses.find(c=>c.key===a.bus);if(l===void 0||!vf(l,a.state))continue;let d=YI(l,a.state).outcome;d!==i&&n.push(_s(r,"applicationOutcome",`[end/outcomeMismatch] ${r.label.de}: das Ergebnis \u201E${i}" passt nicht zum Endzustand \u201E${a.state}" (Bus ${a.bus}), der \u201E${String(d)}" besiegelt \u2014 Ergebnis oder Verdrahtung angleichen.`,`[end/outcomeMismatch] ${r.label.en}: the outcome "${i}" does not match the final state "${a.state}" (bus ${a.bus}), which seals "${String(d)}" \u2014 align the outcome or the wiring.`))}return n}s(eO,"checkEndOutcomeMatchesTerminal");function Cs(e){let t=He(e);return typeof t.inputs=="function"?t.inputs(e):[]}s(Cs,"inputSlots");function LG(e,t){return Cs(e).find(n=>n.id===t)}s(LG,"findInputSlot");function MG(e,t){let n=LG(e,t);if(!n)return{source:"missing",spec:{id:t,label:{de:t,en:t},type:"string"},unknownSlot:!0};let r=e.inputs?.[t]??{kind:"unset"};return r.kind==="binding"&&be(r.address)?{source:"binding",spec:n,address:r.address}:r.kind==="literal"?{source:"literal",spec:n,value:r.value}:r.kind==="cockpit"&&n.deferrable===!0?{source:"cockpit",spec:n}:n.defaultValue!==void 0?{source:"default",spec:n,value:n.defaultValue}:n.required?{source:"missing",spec:n}:{source:"optional",spec:n}}s(MG,"resolveInput");function tO(e){return Cs(e).filter(t=>MG(e,t.id).source==="missing")}s(tO,"missingRequiredInputs");var qG=["personRef","formRef","documentRef","docRef"];function KG(e){let t=He(e);return typeof t.inputs!="function"?[]:t.inputs(e).map(n=>({id:n.id,type:n.type}))}s(KG,"listInputs");function nO(e){let t=[];for(let n of e.nodes)for(let r of KG(n))!qG.includes(r.type)||n.inputs?.[r.id]?.kind!=="literal"||t.push({layer:"GRAPH",kind:"modelError",path:`node.${n.id}.param.${r.id}`,reason:{de:`${n.label.de}: Literal f\xFCr referenztypisierten Slot "${r.id}" ist verboten \u2014 der Slot wird an eine Adresse gebunden`,en:`${n.label.en}: A literal for the reference-typed slot "${r.id}" is not allowed \u2014 the slot is bound to an address`},severity:"error"});return t}s(nO,"findParamValueRefSlotErrors");function rO(e){let t=[];for(let n of e.nodes){let r=He(n);if(typeof r.inputs=="function")for(let i of r.inputs(n)){let o=n.inputs?.[i.id];if(o?.kind==="cockpit"&&i.deferrable!==!0){t.push({layer:"GRAPH",kind:"modelError",path:`nodes.${n.id}.inputs.${i.id}`,reason:{de:`[inputs/notDeferrable] ${n.label.de}: Parameter \u201E${i.label.de}\u201C l\xE4sst sich nicht im Cockpit erg\xE4nzen \u2014 nur Parameter eines Generators oder einer Vorlage.`,en:`[inputs/notDeferrable] ${n.label.en}: Parameter "${i.label.en}" cannot be completed in the cockpit \u2014 only parameters of a generator or a template can.`},severity:"error"});continue}(i.inspector==="literal-only"&&o?.kind==="binding"||i.inspector==="binding-only"&&o?.kind==="literal")&&t.push({layer:"GRAPH",kind:"modelError",path:`nodes.${n.id}.inputs.${i.id}`,reason:i.inspector==="literal-only"?{de:`[inputs/inspectorKind] ${n.label.de}: Parameter \u201E${i.label.de}\u201C ist ein fester Wert \u2014 eine Bindung an eine Adresse ist hier nicht m\xF6glich.`,en:`[inputs/inspectorKind] ${n.label.en}: Parameter "${i.label.en}" is a fixed value \u2014 it cannot be bound to an address.`}:{de:`[inputs/inspectorKind] ${n.label.de}: Parameter \u201E${i.label.de}\u201C wird an eine Adresse gebunden \u2014 ein fester Wert ist hier nicht m\xF6glich.`,en:`[inputs/inspectorKind] ${n.label.en}: Parameter "${i.label.en}" is bound to an address \u2014 a fixed value is not possible here.`},severity:"error"})}}return t}s(rO,"findInspectorKindErrors");function iO(e){let t=[];for(let n of e.nodes)for(let r of tO(n))t.push({layer:"GRAPH",kind:"contractGap",path:`node.${n.id}.input.${r.id}`,reason:{de:`${n.label.de}: Pflicht-Slot "${r.label.de}" nicht gesetzt`,en:`${n.label.en}: Required slot "${r.label.en}" is not set`},severity:"error"});return t}s(iO,"findMissingRequiredInputs");function Af(e){let t=e.processStore;return t===void 0?[]:(Array.isArray(t)||C("graph.processStore must be an array \u2014 the graph validator refuses anything else"),t)}s(Af,"processStoreKeys");function sO(e){let t=[];for(let n of e.tasks??[]){let r=n.result;if(!(r===void 0||!ys(r)))for(let i of nf(r))t.push({key:i.key,nodeId:e.id,taskKey:n.key,template:n,result:r,valueType:i.valueType,...i.field!==void 0?{fieldKey:i.field.key}:{}})}return t}s(sO,"storeWritersOn");function aO(e){let t=new Map;for(let n of e.nodes)for(let r of sO(n)){let i=t.get(r.key)??[];i.push(r),t.set(r.key,i)}return t}s(aO,"processStoreWriters");function jG(e,t,n){for(let r of e.nodes){let i=sO(r).find(o=>o.taskKey===t&&o.key===n);if(i!==void 0)return i}return null}s(jG,"writerAt");function oO(e,t,n){(t.scope!=="task"||t.path!==void 0)&&C(`[process] ${n}: ${se(t)} is no task value`);let r=jG(e,t.owner,t.key);return r===null&&C(`[address/ownerNotWriter] ${n}: task "${t.owner}" writes no "${t.key}" \u2014 publish refuses that`),{key:t.key,nodeId:r.nodeId,taskKey:r.taskKey,...r.fieldKey!==void 0?{fieldKey:r.fieldKey}:{}}}s(oO,"sourceOfAddress");function Sy(e,t){(t.scope!=="task"&&t.scope!=="derived"||t.path!==void 0)&&C(`[process] ${se(t)} is no store address`);let n=Af(e).find(o=>o.key===t.key);n===void 0&&C(`[address/unknownKey] ${se(t)}: "${t.key}" is not declared in processStore`);let r={key:n.key,type:n.type,label:n.label,audience:n.audience};if(t.scope==="task")return Qg(n)&&C(`[address/unknownKey] ${se(t)}: "${t.key}" is a derived price \u2014 read it as $derived`),{...r,sources:[oO(e,t,se(t))]};Qg(n)||C(`[address/unknownKey] ${se(t)}: "${t.key}" is a written value \u2014 read it as $task`);let i=Zg(e,n.derive).map(o=>oO(e,o.address,se(t)));return{...r,sources:i,derive:n.derive}}s(Sy,"processLeafOf");var Ay=new Set(["enum","pricedItem","number","boolean","reduction"]),Ey=new Set(["pricedItem","pricedGroup"]),Ty=new Set(["number","boolean","enum"]),De={invalidKey:"[process/invalidKey]",unknownKey:"[process/unknownKey]",secondWriter:"[process/secondWriter]",noWriter:"[process/noWriter]",writerTypeMismatch:"[process/writerTypeMismatch]",pricedItemWritesNothing:"[process/pricedItemWritesNothing]",ruleSet:"[process/ruleSet]",ruleCondition:"[process/ruleCondition]",ruleSource:"[process/ruleSource]",ruleReadsAbsent:"[process/ruleReadsAbsent]",absentValue:"[process/absentValue]",derive:"[process/derive]",derivedHasWriter:"[process/derivedHasWriter]",ruleGrantUnknown:"[process/ruleGrantUnknown]",ruleGrantUnused:"[process/ruleGrantUnused]",derivePriceUnknown:"[process/derivePriceUnknown]",derivePriceNotInProgram:"[process/derivePriceNotInProgram]",derivePriceOfferWithoutProgram:"[process/derivePriceOfferWithoutProgram]",deriveStageUnknown:"[process/deriveStageUnknown]",deriveStageUncovered:"[process/deriveStageUncovered]",reductionPrices:"[process/reductionPrices]",internalInDocument:"[process/internalInDocument]",writerMustBlock:"[process/writerMustBlock]",absentWithoutDefault:"[process/absentWithoutDefault]",defaultItemMismatch:"[process/defaultItemMismatch]"};function Fe(e,t,n,r){return{layer:"GRAPH",kind:"contractGap",path:e,reason:{de:`${t} ${n}`,en:`${t} ${r}`},severity:"error"}}s(Fe,"err");function lO(e,t={}){let n=[],r=Af(e),i=new Map(r.map(d=>[d.key,d])),o=new Set;for(let[d,c]of r.entries()){let u=`processStore[${d}]`;if(typeof c.key!="string"||!/^[a-z][a-zA-Z0-9_]*$/.test(c.key)){n.push(Fe(u,De.invalidKey,`Vorgangs-Schl\xFCssel ${JSON.stringify(c.key)} \u2014 erlaubt sind Buchstaben, Ziffern und _, beginnend mit einem Kleinbuchstaben.`,`Process key ${JSON.stringify(c.key)} \u2014 letters, digits and _ are allowed, starting with a lowercase letter.`));continue}o.has(c.key)&&n.push(Fe(u,De.invalidKey,`Vorgangs-Schl\xFCssel "${c.key}" ist doppelt deklariert.`,`Process key "${c.key}" is declared twice.`)),o.add(c.key),(c.derive!==void 0?!Ey.has(c.type):!Ay.has(c.type))&&n.push(c.derive!==void 0?Fe(u,De.derive,`Vorgangs-Schl\xFCssel "${c.key}" ist abgeleitet, hat aber den Typ "${c.type}" \u2014 abgeleitet wird nur ein Preis: ${[...Ey].join(", ")}.`,`Process key "${c.key}" is derived but has the type "${c.type}" \u2014 only a price can be derived: ${[...Ey].join(", ")}.`):Fe(u,De.invalidKey,`Vorgangs-Schl\xFCssel "${c.key}" hat den Typ "${c.type}" \u2014 der Vorgang speichert nur Ergebnisse mit Wert: ${[...Ay].join(", ")}${c.type==="pricedGroup"?" (ein Paket wird abgeleitet: derive)":""}.`,`Process key "${c.key}" has the type "${c.type}" \u2014 the process only stores results with a value: ${[...Ay].join(", ")}${c.type==="pricedGroup"?" (a package is derived: derive)":""}.`)),(!c.label?.de?.trim()||!c.label?.en?.trim())&&n.push(Fe(u,De.invalidKey,`Vorgangs-Schl\xFCssel "${c.key}" braucht ein Label in beiden Sprachen.`,`Process key "${c.key}" needs a label in both languages.`)),c.audience!=="internal"&&c.audience!=="printable"&&n.push(Fe(u,De.invalidKey,`Vorgangs-Schl\xFCssel "${c.key}": audience muss 'internal' oder 'printable' sein.`,`Process key "${c.key}": audience must be 'internal' or 'printable'.`))}let a=aO(e);for(let d of e.nodes)for(let c of d.tasks??[]){let u=c.result;u?.kind==="pricedItem"&&u.writes===void 0&&n.push(Fe(`node.${d.id}.tasks.${c.key}.result.writes`,De.pricedItemWritesNothing,`Aufgabe "${c.key}" (Knoten "${d.id}") bepreist einen Artikel, schreibt das Ergebnis aber in keinen Vorgangs-Schl\xFCssel ('result.writes') \u2014 niemand k\xF6nnte den Preis lesen.`,`Task "${c.key}" (node "${d.id}") prices an article but writes the result to no process key ('result.writes') \u2014 nobody could read the price.`))}for(let[d,c]of a){let u=i.get(d);for(let f of c){let m=f.fieldKey===void 0?`node.${f.nodeId}.tasks.${f.taskKey}.result.writes`:`node.${f.nodeId}.tasks.${f.taskKey}.result.fields.${f.fieldKey}.writes`;if(u===void 0){n.push(Fe(m,De.unknownKey,`${f.fieldKey===void 0?"":`Feld "${f.fieldKey}" der `}Aufgabe "${f.taskKey}" schreibt "${d}", aber der Workflow deklariert keinen solchen Vorgangs-Schl\xFCssel (graph.processStore).`,`${f.fieldKey===void 0?"Task":`Field "${f.fieldKey}" of task`} "${f.taskKey}" writes "${d}", but the workflow declares no such process key (graph.processStore).`));continue}if(f.valueType!==u.type){let y=f.fieldKey===void 0?`Aufgabe "${f.taskKey}"`:`Feld "${f.fieldKey}" der Aufgabe "${f.taskKey}"`,k=f.fieldKey===void 0?`Task "${f.taskKey}"`:`Field "${f.fieldKey}" of task "${f.taskKey}"`;n.push(Fe(m,De.writerTypeMismatch,`${y} liefert ${f.valueType}, der Vorgangs-Schl\xFCssel "${d}" ist aber als ${u.type} deklariert.`,`${k} delivers ${f.valueType}, but the process key "${d}" is declared as ${u.type}.`))}}if(c.length>1){let f=c.map(m=>`${m.nodeId}/${m.taskKey}${m.fieldKey===void 0?"":`.${m.fieldKey}`}`).join(", ");n.push(Fe(`processStore.${d}`,De.secondWriter,`Vorgangs-Schl\xFCssel "${d}" wird ${c.length}-mal geschrieben (${f}) \u2014 genau ein Schreiber je Schl\xFCssel.`,`Process key "${d}" is written ${c.length} times (${f}) \u2014 exactly one writer per key.`))}}for(let d of r){if(d.derive!==void 0){if(a.has(d.key)){let c=a.get(d.key).map(u=>`${u.nodeId}/${u.taskKey}`).join(", ");n.push(Fe(`processStore.${d.key}`,De.derivedHasWriter,`Vorgangs-Schl\xFCssel "${d.key}" wird abgeleitet (derive) \u2014 keine Aufgabe darf ihn schreiben (${c}).`,`Process key "${d.key}" is derived (derive) \u2014 no task may write it (${c}).`))}continue}a.has(d.key)||n.push(Fe(`processStore.${d.key}`,De.noWriter,`Vorgangs-Schl\xFCssel "${d.key}" ist deklariert, aber keine Aufgabe schreibt ihn ('result.writes').`,`Process key "${d.key}" is declared, but no task writes it ('result.writes').`))}n.push(...BG(e,r,a,t));let l=new Map;for(let d of e.nodes){let c=He(d),u=typeof c.inputs=="function"?c.inputs(d):[];for(let f of u){let m=d.inputs?.[f.id];if(m?.kind!=="binding")continue;let y=UG(e,m.address);if(y===null)continue;let k=`node.${d.id}.input.${f.id}`,g=se(m.address);for(let A of y.sources){let $=l.get(A.key)??new Set;$.add(d.id),l.set(A.key,$)}if(y.audience==="internal"&&n.push(Fe(k,De.internalInDocument,`${d.label.de}: "${f.id}" liest den internen Vorgangs-Schl\xFCssel "${y.key}" \u2014 ein Dokument dieses Knotens geht an die Familie; nur 'printable'-Schl\xFCssel d\xFCrfen hinein.`,`${d.label.en}: "${f.id}" reads the internal process key "${y.key}" \u2014 a document of this node goes to the family; only 'printable' keys may go in.`)),y.derive!==void 0)continue;let v=VG(a,y.sources[0].key,y.sources[0].taskKey);if(v.template.when!==void 0&&f.required===!0&&f.defaultValue===void 0&&n.push(Fe(k,De.absentWithoutDefault,`${d.label.de}: "${f.id}" ist Pflicht und an ${g} gebunden, aber die schreibende Aufgabe entsteht nur unter einer Bedingung (when: ${Ef(v.template.when)}) \u2014 ohne Vorgabewert bliebe das Feld dann f\xFCr immer leer.`,`${d.label.en}: "${f.id}" is required and bound to ${g}, but the writing task only exists under a condition (when: ${Ef(v.template.when)}) \u2014 without a default value the field would stay empty forever.`)),v.result.kind==="pricedItem"&&f.defaultValue!==void 0){let A=f.defaultValue;(!Ai(A)||A.itemKey!==v.result.item||A.grantKeys.length>0)&&n.push(Fe(k,De.defaultItemMismatch,`${d.label.de}: der Vorgabewert von "${f.id}" muss der Artikel der schreibenden Aufgabe ohne Erm\xE4\xDFigung sein ({ itemKey: '${v.result.item??"?"}', grantKeys: [] }) \u2014 sonst rechnete die Familie ohne Antrag einen anderen Artikel als mit.`,`${d.label.en}: the default value of "${f.id}" must be the article of the writing task without a reduction ({ itemKey: '${v.result.item??"?"}', grantKeys: [] }) \u2014 otherwise the family would be charged a different article without an application than with one.`))}}}for(let[d,c]of l){let u=a.get(d)[0],f=u.template.blocks,m=f===void 0?void 0:f.node??u.nodeId,y=m!==void 0&&c.has(m)&&(()=>{let g=e.nodes.find(v=>v.id===m);return g!==void 0&&He(g).processHoldTemplate?.(g)===f.templateKey})(),k=`node.${u.nodeId}.tasks.${u.taskKey}.blocks`;if(!y){let g=[...c][0],v=e.nodes.find($=>$.id===g),A=He(v).processHoldTemplate?.(v)??"?";n.push(Fe(k,De.writerMustBlock,`Die Aufgabe "${u.taskKey}" schreibt "${d}", h\xE4lt aber keinen der lesenden Knoten (${[...c].join(", ")}) zur\xFCck \u2014 sie muss den ersten blockieren, z. B. blocks: { ${g===u.nodeId?"":`node: '${g}', `}templateKey: '${A}' }, sonst arbeitet er, bevor der Wert existiert.`,`The task "${u.taskKey}" writes "${d}" but holds back none of the reading nodes (${[...c].join(", ")}) \u2014 it must block the first one, e.g. blocks: { ${g===u.nodeId?"":`node: '${g}', `}templateKey: '${A}' }, otherwise it works before the value exists.`));continue}for(let g of c)g===m||wf(e,m,g)||n.push(Fe(k,De.writerMustBlock,`"${g}" liest "${d}", liegt aber nicht hinter dem zur\xFCckgehaltenen Knoten "${m}" \u2014 auf einem Weg an ihm vorbei l\xE4se er den Wert, bevor er feststeht.`,`"${g}" reads "${d}" but does not lie behind the held-back node "${m}" \u2014 on a path past it, it would read the value before it is settled.`))}return n}s(lO,"processBindingIssues");function BG(e,t,n,r){let i=[],o=new Map(t.map(u=>[u.key,u])),a=of(e),l=new Set;for(let[u,f]of a.entries()){let m=`pricingRules[${u}]`;if((typeof f.key!="string"||!/^[a-z][a-zA-Z0-9_]*$/.test(f.key)||l.has(f.key))&&i.push(Fe(m,De.ruleSet,`Regelgruppe ${JSON.stringify(f.key)} \u2014 ein eindeutiger Schl\xFCssel aus Buchstaben, Ziffern und _, beginnend mit einem Kleinbuchstaben.`,`Rule group ${JSON.stringify(f.key)} \u2014 a unique key of letters, digits and _, starting with a lowercase letter.`)),l.add(f.key),(!f.label?.de?.trim()||!f.label?.en?.trim())&&i.push(Fe(m,De.ruleSet,`Regelgruppe "${f.key}" braucht ein Label in beiden Sprachen.`,`Rule group "${f.key}" needs a label in both languages.`)),!Array.isArray(f.rows)||f.rows.length===0){i.push(Fe(m,De.ruleSet,`Regelgruppe "${f.key}" hat keine Zeilen.`,`Rule group "${f.key}" has no rows.`));continue}for(let[y,k]of f.rows.entries()){let g=`${m}.rows[${y}]`;(!Array.isArray(k.grants)||k.grants.length===0||k.grants.some(A=>typeof A!="string"||A.length===0))&&i.push(Fe(g,De.ruleSet,`Regelgruppe "${f.key}", Zeile ${y+1}: nennt keine Rabattvorlage \u2014 eine Zeile ohne Rabatt ist die fehlende Zeile.`,`Rule group "${f.key}", row ${y+1}: names no discount template \u2014 a row without a discount is the missing row.`));let v=tl(k.when);if(v!==null){i.push(Fe(g,De.ruleCondition,`Regelgruppe "${f.key}", Zeile ${y+1}: Bedingung ${JSON.stringify(k.when)} \u2014 ${v}.`,`Rule group "${f.key}", row ${y+1}: condition ${JSON.stringify(k.when)} \u2014 ${v==="leere Bedingung"?"empty condition":v}.`));continue}for(let{identifier:A,address:$}of iy(k.when)){if($===null)continue;let E=GG($,o,n);if(E==="ruleSource")i.push(Fe(g,De.ruleSource,`Regelgruppe "${f.key}", Zeile ${y+1}: liest ${A} \u2014 eine Bedingung liest nur Werte, die eine Aufgabe schreibt ($task.<aufgabe>.<schl\xFCssel>), vom Typ ${[...Ty].join(", ")}.`,`Rule group "${f.key}", row ${y+1}: reads ${A} \u2014 a condition only reads values that a task writes ($task.<task>.<key>), of type ${[...Ty].join(", ")}.`));else if(E==="ruleReadsAbsent"){let I=n.get($.key).find(F=>F.taskKey===$.owner);i.push(Fe(g,De.ruleReadsAbsent,`Regelgruppe "${f.key}" liest ${A}, dessen Aufgabe entfallen kann (${I.template.when!==void 0?`when: ${Ef(I.template.when)}`:"sie endet mit ihrem Knoten"}) \u2014 der Schl\xFCssel muss sagen, wof\xFCr er ohne Aufgabe steht ('absentValue'), sonst entschiede die Regel still \xFCber einen fehlenden Wert.`,`Rule group "${f.key}" reads ${A}, whose task can lapse (${I.template.when!==void 0?`when: ${Ef(I.template.when)}`:"it ends with its node"}) \u2014 the key must say what it stands for without a task ('absentValue'), otherwise the rule would silently decide on a missing value.`))}}}}for(let u of t){if(u.absentValue===void 0)continue;let f=`processStore.${u.key}.absentValue`;if(!(u.type==="number"&&typeof u.absentValue=="number"||u.type==="boolean"&&typeof u.absentValue=="boolean"||u.type==="enum"&&typeof u.absentValue=="string"&&u.absentValue.length>0)){i.push(Fe(f,De.absentValue,`Vorgangs-Schl\xFCssel "${u.key}" (${u.type}): absentValue ${JSON.stringify(u.absentValue)} passt nicht zum Typ.`,`Process key "${u.key}" (${u.type}): absentValue ${JSON.stringify(u.absentValue)} does not fit the type.`));continue}let y=n.get(u.key)?.[0];y!==void 0&&!dO(y)&&i.push(Fe(f,De.absentValue,`Vorgangs-Schl\xFCssel "${u.key}": seine Aufgabe ist immer geschuldet und \xFCberlebt ihren Knoten \u2014 ein absentValue w\xFCrde nie gelesen.`,`Process key "${u.key}": its task is always owed and outlives its node \u2014 an absentValue would never be read.`))}let d=[];for(let u of t){let f=u.derive;if(f===void 0)continue;let m=`processStore.${u.key}.derive`,y=u.type==="pricedGroup"?"group":"item",k=[f.item,f.group,f.byStage].filter(F=>F!==void 0).length,g=Xg(f),v=f.byStage??[];(k!==1||g.length===0||g.length!==Math.max(v.length,1)||g.some(F=>F.kind!==y))&&i.push(Fe(m,De.derive,`"${u.key}" (${u.type}) leitet ${y==="group"?"ein Paket ab: genau 'group' oder 'byStage' mit je einem 'group'":"einen Artikel ab: genau 'item' oder 'byStage' mit je einem 'item'"}.`,`"${u.key}" (${u.type}) derives ${y==="group"?"a package: exactly 'group' or 'byStage' with one 'group' each":"an article: exactly 'item' or 'byStage' with one 'item' each"}.`));let A=new Set;for(let[F,b]of v.entries()){if(!Array.isArray(b.stages)||b.stages.length===0){i.push(Fe(`${m}.byStage[${F}]`,De.derive,`"${u.key}": die Zeile ${F+1} nennt keine Stufe.`,`"${u.key}": row ${F+1} names no stage.`));continue}for(let T of b.stages)A.has(T)&&i.push(Fe(`${m}.byStage[${F}]`,De.derive,`"${u.key}": die Stufe "${T}" steht in mehr als einer Zeile \u2014 welcher Preis gilt, w\xE4re geraten.`,`"${u.key}": the stage "${T}" is in more than one row \u2014 which price applies would be a guess.`)),A.add(T)}let $=new Set;for(let F of f.rules??[]){let b=a.find(T=>T.key===F);if(b===void 0){i.push(Fe(m,De.derive,`"${u.key}" nennt die Regelgruppe "${F}", die der Workflow nicht deklariert (bekannt: ${a.map(T=>T.key).join(", ")||"keine"}).`,`"${u.key}" names the rule group "${F}", which the workflow does not declare (known: ${a.map(T=>T.key).join(", ")||"none"}).`));continue}for(let T of b.rows??[])for(let q of T.grants??[])$.add(q)}let E=f.reduction;be(E)&&(zG(E,o)||i.push(Fe(m,De.derive,`"${u.key}": Reduktion ${se(E)} ist kein von einer Aufgabe geschriebener Wert vom Typ reduction ($task.<aufgabe>.<schl\xFCssel>).`,`"${u.key}": reduction ${se(E)} is not a value of type reduction written by a task ($task.<task>.<key>).`)));for(let F of g)d.push({key:u.key,target:F,grants:$}),(F.kind==="item"?r.billingItemKeys?.has(F.key):r.groupArticleKeys?.has(F.key))===!1?i.push(Fe(m,De.derivePriceUnknown,`"${u.key}": ${F.kind==="item"?"der Artikel":"das Paket"} "${F.key}" ist nicht im Katalog des Mandanten.`,`"${u.key}": the ${F.kind==="item"?"article":"package"} "${F.key}" is not in the school's catalog.`)):r.offerProgram===null?i.push(Fe(m,De.derivePriceOfferWithoutProgram,`"${u.key}": das Angebot ist keinem Programm zugeordnet, also geh\xF6rt ${F.kind==="item"?"kein Artikel":"kein Paket"} zu ihm; dem Angebot ein Programm geben.`,`"${u.key}": the offer is not assigned to a program, so no ${F.kind==="item"?"article":"package"} belongs to it; give the offer a program.`)):r.offerProgram!==void 0&&((F.kind==="item"?r.offerProgram.billingItemKeys:r.offerProgram.groupKeys).has(F.key)||i.push(Fe(m,De.derivePriceNotInProgram,`"${u.key}": ${F.kind==="item"?"der Artikel":"das Paket"} "${F.key}" ist dem Programm \u201E${r.offerProgram.nameDe}\u201C des Angebots nicht zugeordnet${F.kind==="group"?" oder wird nicht angeboten":""} (unter Finanzen \u2192 Artikel zuordnen).`,`"${u.key}": the ${F.kind==="item"?"article":"package"} "${F.key}" is not assigned to the offer's program "${r.offerProgram.nameDe}"${F.kind==="group"?" or is not offered":""} (under Finance \u2192 assign articles).`)));let I=r.offerProgram?.stageKeys;if(f.byStage!==void 0&&I!==void 0){let F=[...A].filter(T=>!I.all.has(T));F.length>0&&i.push(Fe(m,De.deriveStageUnknown,`"${u.key}": ${F.map(T=>`"${T}"`).join(", ")} ist keine Stufe des Programms \u201E${r.offerProgram.nameDe}\u201C (Stufen: ${[...I.all].join(", ")||"keine"}).`,`"${u.key}": ${F.map(T=>`"${T}"`).join(", ")} ${F.length===1?"is not a stage":"are not stages"} of the program "${r.offerProgram.nameDe}" (stages: ${[...I.all].join(", ")||"none"}).`));let b=[...I.active].filter(T=>!A.has(T));b.length>0&&i.push(Fe(m,De.deriveStageUncovered,`"${u.key}": f\xFCr ${b.map(T=>`"${T}"`).join(", ")} nennt byStage keinen ${y==="group"?"Paket":"Artikel"} \u2014 diese Stufe h\xE4tte keinen Preis.`,`"${u.key}": for ${b.map(T=>`"${T}"`).join(", ")} byStage names no ${y==="group"?"package":"article"} \u2014 that stage would have no price.`))}}for(let u of n.values())for(let f of u){if(f.result.kind!=="reduction"||f.result.prices===void 0||f.result.writes===void 0)continue;let m=`node.${f.nodeId}.tasks.${f.taskKey}.result.prices`,k=o.get(f.result.prices)?.derive?.reduction;be(k)&&k.scope==="task"&&k.owner===f.taskKey&&k.key===f.result.writes||i.push(Fe(m,De.reductionPrices,`Aufgabe "${f.taskKey}" senkt "${f.result.prices}" \u2014 das muss ein abgeleiteter Preis sein, dessen derive.reduction $task.${f.taskKey}.${f.result.writes} ist.`,`Task "${f.taskKey}" reduces "${f.result.prices}" \u2014 that must be a derived price whose derive.reduction is $task.${f.taskKey}.${f.result.writes}.`))}let c=r.grantTemplates;if(c!==void 0){let u=new Set(a.flatMap(f=>(f.rows??[]).flatMap(m=>m.grants??[])));for(let f of u){let m=c.get(f);if(m===void 0){i.push(Fe("pricingRules",De.ruleGrantUnknown,`Eine Regelgruppe vergibt "${f}", aber keine Rabattvorlage des Mandanten tr\xE4gt diesen Schl\xFCssel.`,`A rule group grants "${f}", but no discount template of the school has this key.`));continue}d.some(({target:k,grants:g})=>{if(!g.has(f))return!1;if(k.kind==="item")return m.itemKeys.includes(k.key);let v=r.groupArticleKeys?.get(k.key);return m.itemKeys.some(A=>v?.has(A))})||i.push(Fe("pricingRules",De.ruleGrantUnused,`Die Rabattvorlage "${f}" (gebunden an Artikel "${m.itemKeys.join(", ")}") wird vergeben, aber kein abgeleiteter Preis, der ihre Regelgruppe liest, enth\xE4lt ihr Ziel \u2014 sie wirkte nirgends.`,`The discount template "${f}" (bound to article "${m.itemKeys.join(", ")}") is granted, but no derived price reading its rule group contains its target \u2014 it would have no effect anywhere.`))}}return i}s(BG,"derivedPriceIssues");function UG(e,t){if(!be(t)||t.scope!=="task"&&t.scope!=="derived"||t.path!==void 0)return null;let n=Af(e).find(o=>o.key===t.key);if(n===void 0||t.scope==="derived"!=(n.derive!==void 0))return null;if(t.scope==="task")return Pr(e,t.owner,t.key)===null?null:Sy(e,t);let r=ZR(e,n.derive),i=s(o=>o.scope==="task"&&o.path===void 0&&Pr(e,o.owner,o.key)!==null,"resolvable");return r!==null&&r.every(o=>i(o.address))?Sy(e,t):null}s(UG,"draftLeafOf");function VG(e,t,n){let r=e.get(t)?.find(i=>i.taskKey===n);return r===void 0&&C(`[process] the leaf of "${t}" names task "${n}", which does not write it`),r}s(VG,"writerOf");function Ef(e){return be(e)?se(e):JSON.stringify(e)}s(Ef,"shown");function GG(e,t,n){let r=e.scope==="task"&&e.path===void 0?t.get(e.key):void 0;if(e.scope==="task"&&e.path===void 0&&r===void 0)return null;if(e.scope!=="task"||r===void 0||r.derive!==void 0||!Ty.has(r.type))return"ruleSource";let i=n.get(r.key)?.find(o=>o.taskKey===e.owner);return i!==void 0&&dO(i)&&r.absentValue===void 0?"ruleReadsAbsent":null}s(GG,"ruleSourceRefusal");function zG(e,t){let n=e.scope==="task"&&e.path===void 0?t.get(e.key):void 0;return n!==void 0&&n.type==="reduction"&&n.derive===void 0}s(zG,"isReductionValue");function dO(e){return e.template.when!==void 0||e.template.blocks?.node===void 0}s(dO,"writerMayBeNotOwed");function $y(e){let t=He(e);return e.outcomes&&e.outcomes.length>0?[...e.outcomes]:t.outcomes&&t.outcomes.length>0?[...t.outcomes]:null}s($y,"nodeOutcomes");var WG=["documentChangeRequested","documentReturned"];function cO(e){return WG.includes(e)}s(cO,"isNonAdvancingExternalEvent");var Ns=["offer","contract"];function Tf(e){return typeof e=="string"&&Ns.includes(e)}s(Tf,"isArtifactSlotType");var uO="open",Ds="done";function Ry(e){let t={};for(let n of ze)t[n]=e(n);return t}s(Ry,"localized");var fO=[{key:"tenantSlug",type:"string"}];var YG=/^(\d{4})-(\d{2})-(\d{2})$/;function HG(e){return e>=1900&&e<=2100}s(HG,"isSupportedYear");function JG(e,t,n){let r=new Date(Date.UTC(e,t-1,n));return r.getUTCFullYear()===e&&r.getUTCMonth()===t-1&&r.getUTCDate()===n}s(JG,"isRealDate");function Iy(e){if(typeof e!="string")return null;let t=YG.exec(e);if(t===null)return null;let[,n,r,i]=t;return n===void 0||r===void 0||i===void 0||!HG(Number(n))||!JG(Number(n),Number(r),Number(i))?null:{year:n,month:r,day:i}}s(Iy,"isoDateParts");var QG="Europe/Berlin";function mO(){return QG}s(mO,"tenantTimeZone");var pO=new Map;function ZG(e){let t=pO.get(e);if(t)return t;let n;try{n=new Intl.DateTimeFormat("en-US",{timeZone:e,hour12:!1,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{ae("INVALID",{de:`Unbekannte Zeitzone "${e}".`,en:`Unknown time zone "${e}".`})}return pO.set(e,n),n}s(ZG,"formatterFor");function XG(e,t){let n=new Map(ZG(e).formatToParts(new Date(t)).map(a=>[a.type,a.value])),r=s(a=>{let l=n.get(a);return l===void 0&&C(`Zeitzone "${e}" liefert kein Feld ${a}.`),Number(l)},"read"),i=r("hour")%24;return Date.UTC(r("year"),r("month")-1,r("day"),i,r("minute"),r("second"))-Math.floor(t/1e3)*1e3}s(XG,"zoneOffsetAt");function Oy(e,t){let n=e+XG(t,e);return{wallClock:new Date(n).toISOString().slice(0,19),timeZone:t}}s(Oy,"instantToLocalDateTime");var Py=3;function hO(e){return Oy(e,mO()).wallClock.slice(0,10)}s(hO,"localIsoDate");var $f=["login","security","admission","tasks","schoolMessages","staffTasks","staffAppointments","staffDeadlines","staffWaitlist","familyMessages","mentions"],gO=w.union(...$f.map(e=>w.literal(e)));var lce=w.union(w.literal("admission"),w.literal("tasks"),w.literal("staff"),w.literal("chat")),_y=["loginOnly","all"],dce=w.union(w.literal("loginOnly"),w.literal("all"));function yO(e){return typeof e=="string"&&_y.includes(e)}s(yO,"isMailLevel");var fl="subject";function wO(e){return e.category==="login"}s(wO,"isSignInLetter");var dt={key:"schoolName",label:"Name der Schule"},kO={de:"Zu Ihren Bewerbungen",en:"View your applications"},vt={key:"portalLink",label:"Link zum Bewerberportal",required:!0,link:!0,actionLabel:kO},Cy={key:vt.key,label:vt.label,link:!0,actionLabel:kO},bO={key:"authorName",label:"Name der schreibenden Person"},Fs={key:"applicationLink",label:"Link zur Bewerbung",required:!0,link:!0,actionLabel:{de:"Bewerbung \xF6ffnen",en:"Open application"}},pl={key:"anmeldeLink",label:"Anmeldelink",required:!0,link:!0,actionLabel:{de:"Jetzt anmelden",en:"Sign in now"},previewValue:{de:"https://beispiel.plexus.schule/anmelden?token=BEISPIEL",en:"https://beispiel.plexus.schule/anmelden?token=BEISPIEL"}},tz={key:"passwortLink",label:"Link zum neuen Passwort",required:!0,link:!0,actionLabel:{de:"Neues Passwort festlegen",en:"Set a new password"},previewValue:{de:"https://beispiel.plexus.schule/login/reset?token=BEISPIEL",en:"https://beispiel.plexus.schule/login/reset?token=BEISPIEL"}},vO={key:"bestaetigungsLink",label:"Best\xE4tigungslink",required:!0,link:!0,actionLabel:{de:"E-Mail best\xE4tigen",en:"Confirm email address"},previewValue:{de:"https://beispiel.plexus.schule/bestaetigen?token=BEISPIEL",en:"https://beispiel.plexus.schule/bestaetigen?token=BEISPIEL"}},ml={key:"gueltigkeit",label:"G\xFCltigkeitsdauer des Links",previewValue:{de:"15 Minuten",en:"15 minutes"}},xO={key:"gueltigkeit",label:"G\xFCltigkeitsdauer des Links",previewValue:{de:"24 Stunden",en:"24 hours"}},nz={key:"gueltigkeit",label:"G\xFCltigkeitsdauer des Links",previewValue:{de:"60 Minuten",en:"60 minutes"}};function Le(e){return{key:fl,label:"Betreff",default:e}}s(Le,"subjectSlot");var Ni=w.object({de:w.string(),en:w.string()}),$t={tenantSlug:w.string(),applicationId:w.id("applications")},rz=w.object({tenantSlug:w.string()}),iz={id:"applicant.welcome",category:"admission",label:"Willkommen",occasion:{de:"Sobald f\xFCr eine Familie ein Zugang angelegt wurde",en:"As soon as an account has been created for a family"},audience:"external",frame:"letter",timeline:"correspondence",paramsValidator:rz,channels:["email"],portalVisible:!0,placeholders:[dt,vt],slots:[Le({de:"Willkommen \u2014 Ihre Bewerbung bei uns",en:"Welcome \u2014 your application"}),{key:"intro",label:"Einleitung",multiline:!0,default:{de:`vielen Dank f\xFCr Ihre Registrierung bei {{schoolName}}. \xDCber den folgenden Link k\xF6nnen Sie jederzeit Ihre Bewerbungen einsehen und fortsetzen:
10201
+ `};var Mu="8bff4c81de4b378c332c2ada20faa83cf0989fc94fa95c6851f3fe8a580dcffb",Sg=K$;var Ag=class extends Se{static{s(this,"AgentToolsCommand")}static paths=[["agent","tools"]];static usage=R.Usage({category:"Agents",description:"Show the shared platform/CLI agent tool schemas and skill revision."});async execute(){return this.print({skillHash:Mu,tools:Ya}),0}},Eg=class extends Se{static{s(this,"AgentInvokeCommand")}static paths=[["agent","invoke"]];static usage=R.Usage({category:"Agents",description:"Invoke a shared agent tool; pipe its JSON input on stdin."});tool=p.String("--tool",{required:!0,description:"plexus|plexus_skill|plexus_workspace"});async execute(){if("isTTY"in this.context.stdin&&this.context.stdin.isTTY===!0)throw new Error("plexus: pipe the tool's JSON input on stdin.");let t=JSON.parse(await xg(this.context.stdin)),n=await this.context.executePlexusAgentTool(this.tool,t);return this.print(n),0}},j$=[Ag,Eg];var Tg=[{key:"fixture_test",email:"test@example.com",firstName:"Test",lastName:"Bewerber"}],xoe=new Set(Tg.map(e=>e.key));function U$(e,t,n,r){let i=e.flatMap(l=>l.angebote).find(l=>l.offerKey===t);if(i===void 0){let l=e.flatMap(d=>d.angebote.map(c=>c.offerKey));throw new Error(`applications start-test: no offer "${t}" (offers: ${l.join(", ")||"none"})`)}let o=i.stages.find(l=>l.stageKey===r||l.stageId===r);if(o===void 0){let l=i.stages.map(d=>`${d.stageKey} (${d.stageId})`);throw new Error(`applications start-test: no level "${r}" in ${t} \u2014 name it by key or id: ${l.join(", ")}`)}let a=o.runs.find(l=>l.runKey===n||l.runId===n);if(a===void 0){let l=o.runs.map(d=>`${d.runKey} (${d.runId})`);throw new Error(`applications start-test: no school year "${n}" for level ${o.stageKey} \u2014 name it by key or id: ${l.join(", ")}`)}if(!a.isOpen)throw new Error(`applications start-test: school year ${a.runKey} is closed for level ${o.stageKey}`);return{programRunId:a.runId,programStageId:o.stageId}}s(U$,"resolveStartTarget");function yV(e){return e.kind==="named"?e.name:`(${e.standIn??e.fallback})`}s(yV,"applicantText");function V$(e){return e.map(t=>({id:t.application._id,status:t.deletedAt?`${t.application.status} (gel\xF6scht)`:t.application.status,state:t.currentProcessStateId??"",applicant:yV(t.applicantName),test:t.application.testMode===!0?"test":""}))}s(V$,"applicationRows");var B$=Tg.map(e=>e.email);function G$(e,t,n,r){if(n===void 0&&r===void 0)throw new Error("applications start-test: name the applicant \u2014 --party <partyId> or --applicant <email>");if(n!==void 0&&r!==void 0)throw new Error("applications start-test: --party or --applicant, not both");if(kg(e,t)&&(r===void 0||!B$.includes(r.trim().toLowerCase())))throw new Error(`applications start-test: on prod only for the test account ${B$.join(", ")} (--applicant) \u2014 never a real family's`)}s(G$,"assertStartApplicant");function z$(e){let t={};for(let{address:n,...r}of e.entries)t[n]=r;return{applicationId:e.applicationId,store:t}}s(z$,"processStoreJson");function wV(e){switch(e.kind){case"form":return`form ${e.formInstanceId} (${e.state})`;case"document":return e.file===null?`document ${e.slotKey} (leer)`:`document ${e.slotKey} \xB7 v${e.file.versionNumber} ${e.file.filename??e.file.artifactId}`;case"contract":return`contract ${e.contractId} \xB7 ${e.revision===null?"keine Fassung":`Fassung ${e.revision.revisionNumber}`} \xB7 ${e.contractStatus}`;case"contracts":return e.contracts.map(t=>`${t.partKey}: contract ${t.contractId} \xB7 ${t.revision===null?"keine Fassung":`Fassung ${t.revision.revisionNumber}`} \xB7 ${t.contractStatus}`).join("; ")}}s(wV,"refText");function kV(e){return e.state!=="present"?e.reason?.de??"":e.ref!==void 0?wV(e.ref):JSON.stringify(e.value)}s(kV,"holds");function W$(e){return e.entries.map(t=>({address:t.address,state:t.state,holds:kV(t),producer:t.producer?.label??"",written:t.writtenAt===void 0?"":new Date(t.writtenAt).toISOString()}))}s(W$,"storeRows");function qu(e){let t={},n={};for(let r of e){let i=r.indexOf("=");if(i<=0)throw new Error(`Expected key=value, got '${r}'.`);let o=r.slice(0,i);if(Object.hasOwn(n,o))throw new Error(`'${o}' is given twice.`);let a=r.slice(i+1);n[o]=a;try{t[o]=JSON.parse(a)}catch{t[o]=a}}return{values:t,raw:n}}s(qu,"parseKv");var Y$="started",Ku="submitted",ju="submitted",H$="load-scenario:";var J$="(Bewerbung)";function Q$(e){return{nodeId:J$,actions:e.map(t=>({id:t.id,label:{de:`${t.label??t.id}${t.count===void 0?"":` (${t.count})`}`,en:`${t.label??t.id}${t.count===void 0?"":` (${t.count})`}`},...t.disabledReason===void 0?{}:{disabledReason:t.disabledReason}}))}}s(Q$,"sharedAsList");function Z$(e){return e.disabledReason===void 0?"":e.disabledCount===void 0?e.disabledReason:`${e.disabledReason} (${e.disabledCount})`}s(Z$,"disabledText");function X$(e){return e.flatMap(({nodeId:t,actions:n})=>n.map(r=>({node:t,action:r.id,label:r.label.de,disabled:Z$(r)})))}s(X$,"actionRows");function eR(e,t,n=[]){let r=e.filter(({actions:d})=>d.some(c=>c.id===t));if(r.length===0){let d=[...new Set(e.flatMap(({actions:c})=>c.map(u=>u.id)))];throw new Error(`test-actions run: no current node offers "${t}" (offered: ${d.join(", ")||"nothing"})`)}if(r.length>1)throw new Error(`test-actions run: "${t}" is offered by ${r.map(d=>d.nodeId).join(", ")} \u2014 pass --node`);let{nodeId:i,actions:o}=r[0],a=o.find(d=>d.id===t);if(a.disabledReason!==void 0)throw new Error(`test-actions run: "${t}" on ${i} is disabled: ${Z$(a)}`);if(i!==J$)return i;let l=n[0];if(l===void 0)throw new Error(`test-actions run: "${t}" needs a current node \u2014 the application has none`);return l}s(eR,"nodeOfferingAction");function tR(e,t,n){if(e.startsWith(H$)){if(Object.hasOwn(n,"autoSubmit"))throw new Error(`test-actions run: ${e}: a scenario's autoSubmit is set by --auto-submit / --no-auto-submit, not --param`);return{autoSubmit:t,...n}}return Object.keys(n).length===0?void 0:{...n}}s(tR,"runParams");async function bV(e,t){let n=await e.query(S.workflow.getInstance,{applicationId:t});if(n===null)throw new Error(`test-actions: application ${t} has no workflow instance`);return n.instance.currentNodeIds}s(bV,"currentNodeIds");function vV(e,t){switch(t){case"notTestApplication":return`${e} is not a test application`;case"completed":case"aborted":case"deleted":return`${e} is ${t} \u2014 test actions run only on an active application`;case"missingPermission":return"the caller lacks bewerbungsmanagement.testActions.run"}}s(vV,"refusalText");async function Bu(e,t,n){let r=await e.query(S.workflow.listSharedTestActions,{applicationId:t});if(!r.permitted)throw new Error(`test-actions: not permitted \u2014 ${vV(t,r.reason)}`);let i=[];for(let o of n){let a=await e.query(S.workflow.listTestActions,{applicationId:t,nodeId:o});if(a===null)throw new Error(`test-actions: node "${o}" is not in this application's workflow (or it has no instance)`);i.push({nodeId:o,actions:a})}return[...i,Q$(r.actions)]}s(Bu,"actionsOf");async function nR(e,t,n){return n!==void 0?[n]:await bV(e,t)}s(nR,"nodesOf");var $g=class extends N{static{s(this,"TestActionsListCommand")}static paths=[["test-actions","list"]];static usage=R.Usage({category:"Admission",description:"List the test-mode actions of the application's current node(s) (scenarios, auto-fill-files, submit, \u2026) and the application-wide ones"});application=p.String("--application",{required:!0,description:"Application id (a test application)"});node=p.String("--node",{description:"Node id (default: the application's current nodes)"});async execute(){let t=await this.caller(),n=await Bu(t,this.application,await nR(t,this.application,this.node));return this.print(n,X$,["node","action","label","disabled"]),0}},Rg=class extends N{static{s(this,"TestActionsRunCommand")}application=p.String("--application",{required:!0,description:"Application id (a test application)"});node=p.String("--node",{description:"Node id (default: the application's current nodes)"});static paths=[["test-actions","run"]];static usage=R.Usage({category:"Admission",description:"Run one test-mode action; a scenario (load-scenario:<id>) also submits unless --no-auto-submit"});action=p.String("--action",{required:!0,description:"Action id, e.g. load-scenario:standard, auto-fill-files, submit-form"});autoSubmit=p.Boolean("--auto-submit",!0,{description:"Scenario only: stub the file fields and submit after loading (default on; --no-auto-submit only loads)"});param=p.Array("--param",{description:"Action parameter key=value (repeatable; the value is JSON where it parses, else text), e.g. --param confirmed=true for an action that asks a question first (upload-signed-document)"});async execute(){let t=tR(this.action,this.autoSubmit,qu(this.param??[]).values),n=await this.caller(),r=this.application,i=await nR(n,this.application,this.node),o=eR(await Bu(n,r,i),this.action,i);return await n.mutation(S.workflow.runTestAction,{applicationId:r,nodeId:o,actionId:this.action,...t===void 0?{}:{params:t}}),this.print({ran:this.action,on:o},a=>[{key:"ran",value:a.ran},{key:"on",value:a.on},{key:"next",value:"test-actions list \u2014 file fills and the submit after them run asynchronously"}]),0}},rR=[$g,Rg];var ze=["de","en"];function cs(e,t){return ze.every(n=>e[n]===t[n])}s(cs,"sameText");function Et(e){if(e===null||typeof e!="object"||Array.isArray(e))return"not-localized";let t=e;return Object.keys(t).some(r=>!ze.includes(r))?"not-localized":ze.filter(r=>{let i=t[r];return typeof i!="string"||i.trim()===""})}s(Et,"missingLocales");function vi(e){let t=Et(e);return t!=="not-localized"&&t.length===0}s(vi,"isLocalizedText");function Ha(e,t){let n={};for(let r of ze){let i=e.map(o=>o[r]);n[r]=i.every(o=>typeof o=="string"&&o.trim()!=="")?t(i,r):""}return n}s(Ha,"composeTexts");var ar=/^[a-z][A-Za-z0-9]*$/;function Ig(e){return typeof e=="string"&&ar.test(e)}s(Ig,"isNodeId");function us(e,t){Ig(e)||C(`[graph/nodeIdFormat] "${e}" cannot name a node: a node id is ${ar.source}.`);let n=new Set(t);if(!n.has(e))return e;let r=2;for(;n.has(`${e}${r}`);)r++;return`${e}${r}`}s(us,"makeNodeId");var xi="$env";function se(e){if(e.scope==="env")return`${xi}.${e.key}`;let t=e.scope==="derived"?`$derived.${e.key}`:`$${e.scope}.${e.owner}.${e.key}`;return e.path===void 0?t:`${t}.${e.path}`}s(se,"formatAddress");var Rr=/^[a-z][a-zA-Z0-9_]*$/,xV=/^[A-Za-z_][A-Za-z0-9_]*$/;function uo(e){return typeof e=="string"&&e.split(".").every(t=>xV.test(t))}s(uo,"isPath");function zr(e){if(!e.startsWith("$"))return null;let t=e.slice(1).split("."),[n,...r]=t;switch(n){case"env":{let i=r.join(".");return r.length>0&&uo(i)?{scope:"env",key:i}:null}case"derived":{let[i,...o]=r;return i===void 0||!Rr.test(i)?null:iR({scope:"derived",key:i},o)}case"node":case"task":{let[i,o,...a]=r;return i===void 0||o===void 0||!Rr.test(o)||(n==="node"?!ar.test(i):!Rr.test(i))?null:iR({scope:n,owner:i,key:o},a)}default:return null}}s(zr,"tryParseAddress");function iR(e,t){if(t.length===0)return e;let n=t.join(".");return uo(n)?{...e,path:n}:null}s(iR,"withPath");function be(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e,n=t.scope==="env"?["scope","key"]:t.scope==="derived"?["scope","key","path"]:["scope","owner","key","path"];if(Object.keys(t).some(r=>!n.includes(r))||t.path!==void 0&&!uo(t.path))return!1;switch(t.scope){case"env":return uo(t.key);case"derived":return typeof t.key=="string"&&Rr.test(t.key);case"node":return typeof t.owner=="string"&&ar.test(t.owner)&&typeof t.key=="string"&&Rr.test(t.key);case"task":return typeof t.owner=="string"&&Rr.test(t.owner)&&typeof t.key=="string"&&Rr.test(t.key);default:return!1}}s(be,"isAddress");var Wr={offer:{key:"string",title:"string"},unit:{key:"string",name:"string"},stage:{key:"string",name:"string",gradeLevel:"number"},run:{key:"string",name:"string",startDate:"date"},applicant:{language:"enum",channel:"enum"}},fs=Object.keys(Wr);function ps(e){return Object.hasOwn(Wr,e)}s(ps,"isEnvKey");var SV=["self-service","staff"];function oR(e,t){return{kind:"fixed",values:e,labels:t}}s(oR,"fixedSet");var Uu={of:"applicant.language",withoutValue:"de"},Yr={"offer.key":{valueSet:{kind:"live"},nullable:!1,label:{de:"Angebot",en:"Offer"}},"offer.title":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Titel des Angebots",en:"Offer title"},nameLanguage:Uu},"unit.key":{valueSet:{kind:"live"},nullable:!1,label:{de:"Einheit",en:"Unit"}},"unit.name":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Name der Einheit",en:"Unit name"},nameLanguage:Uu},"stage.key":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Klassenstufe (Schl\xFCssel)",en:"Grade (key)"},cohortBound:!0},"stage.name":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Name der Klassenstufe",en:"Grade name"},cohortBound:!0,nameLanguage:Uu},"stage.gradeLevel":{valueSet:{kind:"open"},nullable:!0,absent:{de:"Die Stufe hat keine Klassenstufe (Kindergarten).",en:"The stage has no grade level (Kindergarten)."},label:{de:"Klassenstufe",en:"Grade level"},cohortBound:!0},"run.key":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Schuljahr",en:"School year"},cohortBound:!0},"run.name":{valueSet:{kind:"unstable"},nullable:!1,label:{de:"Name des Schuljahrs",en:"School year name"},cohortBound:!0,nameLanguage:Uu},"run.startDate":{valueSet:{kind:"open"},nullable:!0,absent:{de:"F\xFCr das Schuljahr ist kein Beginn erfasst.",en:"The school year has no start date."},label:{de:"Beginn des Schuljahrs",en:"School year start"},cohortBound:!0},"applicant.language":{valueSet:oR(ze,{de:{de:"Deutsch",en:"German"},en:{de:"Englisch",en:"English"}}),nullable:!0,absent:{de:"Die Bewerbung hat kein Bewerberkonto (intern angelegt).",en:"The application has no applicant account (started by staff)."},label:{de:"Bewerbersprache",en:"Applicant language"}},"applicant.channel":{valueSet:oR(SV,{staff:{de:"intern",en:"in-house"},"self-service":{de:"online (Familie)",en:"online (family)"}}),nullable:!1,label:{de:"Eingangsweg",en:"Intake channel"}}},Vu={types:Wr,fields:Yr},Gu=fs.flatMap(e=>Object.keys(Wr[e]).map(t=>`${e}.${t}`));function lr(e){return Object.hasOwn(Yr,e)}s(lr,"isEnvLeaf");function zu(e){return`${xi}.${e}`}s(zu,"envIdentifier");function fo(e){let t=Yr[e],[n,r]=e.split("."),i=Wr[n][r];i===void 0&&C(`[env] leaf "${e}" has no type`);let o=t.valueSet;return{leaf:e,type:i,label:t.label,nullable:t.nullable,...t.absent===void 0?{}:{absent:t.absent},...t.nameLanguage===void 0?{}:{nameLanguage:t.nameLanguage},...t.cohortBound===void 0?{}:{cohortBound:t.cohortBound},...o.kind==="fixed"?{enumOptions:o.values.map(a=>{let l=o.labels[a];return l===void 0&&C(`[env] "${e}" names the value "${a}" without a label`),{value:a,label:l}})}:{}}}s(fo,"envLeaf");var sR="staffInput";var AV=["boolean"],Ja=/^[a-z][A-Za-z0-9]*$/;function Wu(e){return e.staffInputs??[]}s(Wu,"staffInputsOf");function Yu(e){return`${sR}.${e}`}s(Yu,"staffInputLeaf");function aR(e){return`${xi}.${Yu(e)}`}s(aR,"staffInputIdentifier");function EV(e){let t=`${sR}.`;return e.startsWith(t)?e.slice(t.length):null}s(EV,"staffInputKeyOfLeaf");function Qa(e,t){let n=EV(t);return n===null?void 0:Wu(e).find(r=>r.key===n)}s(Qa,"declaredStaffInput");function TV(e){return[...Wu(e).map(t=>({leaf:Yu(t.key),type:t.type,label:t.label,valueSet:{kind:"open"},nullable:!1,cohortBound:!1})),...Gu.map(t=>{let n=fo(t);return{leaf:t,type:n.type,label:n.label,valueSet:Yr[t].valueSet,nullable:n.nullable,cohortBound:n.cohortBound===!0}})]}s(TV,"envLeavesFor");function lR(e){return TV(e).filter(t=>!t.cohortBound)}s(lR,"conditionEnvLeaves");function dR(e){let t={},n={};for(let{leaf:r,type:i,valueSet:o,nullable:a}of lR(e)){let[l="",d=""]=r.split(".");t[l]={...t[l]??{},[d]:i},n[r]={valueSet:o,nullable:a}}return{types:t,fields:n}}s(dR,"envConditionSchemaFor");function cR(e){let t=e.staffInputs;if(t===void 0)return[];if(!Array.isArray(t))return[{path:"staffInputs",reason:{de:"[staffInput/shape] graph.staffInputs muss eine Liste sein.",en:"[staffInput/shape] graph.staffInputs must be a list."}}];let n=[],r=new Set;return t.forEach((i,o)=>{let a=`staffInputs[${o}]`,l=i;if(l===null||typeof l!="object"||typeof l.key!="string"){n.push({path:a,reason:{de:"[staffInput/shape] Eine interne Angabe braucht key, type und label ({ de, en }).",en:"[staffInput/shape] An internal entry needs key, type and label ({ de, en })."}});return}let d={de:`Interne Angabe "${l.key}"`,en:`Internal entry "${l.key}"`};Ja.test(l.key)||n.push({path:`${a}.key`,reason:{de:`[staffInput/keyFormat] ${d.de}: Schl\xFCssel beginnt mit einem Kleinbuchstaben und enth\xE4lt nur Buchstaben und Ziffern.`,en:`[staffInput/keyFormat] ${d.en}: the key starts with a lowercase letter and contains only letters and digits.`}}),r.has(l.key)&&n.push({path:`${a}.key`,reason:{de:`[staffInput/duplicateKey] ${d.de}: Schl\xFCssel ist doppelt vergeben.`,en:`[staffInput/duplicateKey] ${d.en}: the key is used twice.`}}),r.add(l.key),AV.includes(l.type)||n.push({path:`${a}.type`,reason:{de:`[staffInput/unknownType] ${d.de}: Typ "${String(l.type)}" \u2014 erlaubt ist nur "boolean" (K\xE4stchen).`,en:`[staffInput/unknownType] ${d.en}: type "${String(l.type)}" \u2014 only "boolean" (checkbox) is allowed.`}});let c=Et(l.label);c==="not-localized"?n.push({path:`${a}.label`,reason:{de:`[staffInput/shape] ${d.de}: label muss { de, en } sein.`,en:`[staffInput/shape] ${d.en}: label must be { de, en }.`}}):c.length>0&&n.push({path:`${a}.label`,reason:{de:`[i18n/missingTranslation] ${d.de}: Beschriftung fehlt in ${c.join(", ")}.`,en:`[i18n/missingTranslation] ${d.en}: label is missing in ${c.join(", ")}.`}})}),n}s(cR,"staffInputIssues");var Mg={required:!0,description:"Offer slug (its offerKey)"},Og=class extends N{static{s(this,"ApplicationsListCommand")}static paths=[["applications","list"]];static usage=R.Usage({category:"Admission",description:"List an offer's applications (id, status, board state, applicant, test)"});offer=p.String("--offer",Mg);testOnly=p.Boolean("--test-only",!1,{description:"Only test applications"});async execute(){let t=await this.caller(),n=await t.query(S.admission.listForAngebot,{client:this.requireTenant(t),offerKey:this.offer}),r=V$(n).filter(i=>!this.testOnly||i.test==="test");return this.print(r,i=>i,["id","status","state","applicant","test"]),0}},Pg=class extends N{static{s(this,"ApplicationsCountsCommand")}static paths=[["applications","counts"]];static usage=R.Usage({category:"Admission",description:"Count an offer's applications per list"});offer=p.String("--offer",Mg);async execute(){let t=await this.caller(),n=await t.query(S.admission.getCountsByListForAngebot,{client:this.requireTenant(t),offerKey:this.offer});return this.print(n,r=>[...Object.entries(r.counts).map(([i,o])=>({list:i,count:String(o)})),{list:"total",count:String(r.total)}],["list","count"]),0}},_g=class extends N{static{s(this,"ApplicationsShowCommand")}static paths=[["applications","show"]];static usage=R.Usage({category:"Admission",description:"One application: status, test flag, offer, current workflow nodes"});application=p.String({required:!0});async execute(){let t=await this.caller(),n=this.application,r=await t.query(S.admission.get,{applicationId:n});if(r===null)throw new Error(`applications show: no application ${n} (or not visible to you)`);let i=await t.query(S.workflow.getInstance,{applicationId:n});return this.print({application:r,currentNodes:i?.instance.currentNodeIds??[]},o=>[{key:"id",value:n},{key:"status",value:o.application.status},{key:"test",value:o.application.testMode?"ja":"nein"},{key:"offer",value:o.application.offerId},{key:"current nodes",value:o.currentNodes.join(", ")}]),0}},Cg=class extends N{static{s(this,"ApplicationsStoreCommand")}static paths=[["applications","store"]];static usage=R.Usage({category:"Admission",description:"One application's process store: every address of its pinned graph, resolved (present / pending / absent)",details:"Staff only (applications.manage). --json prints one object keyed by the canonical address ($node\u2026, $task\u2026, $derived\u2026, $env\u2026). Values are shown whatever their audience \u2014 never hand the output to the family. Recipe: playbooks/applications/inspect-process-store.md."});application=p.String({required:!0});async execute(){let n=await(await this.caller()).query(S.processStoreView.get,{applicationId:this.application});return this.print(z$(n),()=>W$(n),["address","state","holds","producer","written"]),0}},Ng=class extends N{static{s(this,"ApplicationsStartTestCommand")}static paths=[["applications","start-test"]];static usage=R.Usage({category:"Admission",description:"Start a TEST application for an applicant (school year and level by key or id) and show what test mode offers next",details:"Always test mode. --applicant names the account by its login address (on prod only the tenant's test account); --party names the applicant party directly. Without --version it runs on the live generation, like the cockpit."});offer=p.String("--offer",Mg);run=p.String("--run",{required:!0,description:"School year: its key or id (never its name)"});stage=p.String("--stage",{required:!0,description:"Level: its key or id (never its name)"});party=p.String("--party",{description:"Applicant party id"});applicant=p.String("--applicant",{description:"Applicant account login address (e.g. the test account test@example.com)"});version=p.String("--version",{description:"Offer version id to test (default: the live generation)"});staffInput=p.Array("--staff-input",{description:"A staff input the offer declares, as key=true|false \u2014 repeat it once per input; a staff start must set every one"});proxy=p.Boolean("--proxy",{description:"Start in Stellvertretung (--proxy) or not (--no-proxy); left out, the tenant's default applies, as in the cockpit"});async execute(){let t=await this.caller();G$(this.resolvedTarget(),this.prodUrls(),this.party,this.applicant);let n=this.requireTenant(t),r=U$(await t.query(S.admission.listAdmissionTree,{client:n}),this.offer,this.run,this.stage),i=this.party;if(this.applicant!==void 0){let d=await t.query(S.applicants.partyByEmail,{client:n,email:this.applicant});if(d===null)throw new Error(`applications start-test: no applicant account ${this.applicant} at this school (create it in the cockpit first)`);i=d}let o=await t.mutation(S.admission.staffStartApplicationForParty,{client:n,offerKey:this.offer,partyId:i,programRunId:r.programRunId,programStageId:r.programStageId,...this.proxy===void 0?{}:{startInProxy:this.proxy},staffInputs:fR(this.staffInput??[]),testMode:!0,...this.version===void 0?{}:{offerVersionId:this.version}}),a,l;try{let d=await t.query(S.workflow.getInstance,{applicationId:o.applicationId});if(d===null)throw new Error("the started application has no workflow instance");a=d.instance.currentNodeIds,l=(await Bu(t,o.applicationId,a)).flatMap(c=>c.actions.map(u=>u.id))}catch(d){throw new Error(`applications start-test: started ${o.applicationId}, but reading its state failed: ${d instanceof Error?d.message:String(d)}`,{cause:d})}return this.print({applicationId:o.applicationId,currentNodes:a,testActions:l},d=>[{key:"application",value:d.applicationId},{key:"current nodes",value:d.currentNodes.join(", ")},{key:"test actions",value:d.testActions.join(", ")},{key:"next",value:`test-actions run --application ${d.applicationId} --action <id>`}]),0}},Dg=class extends N{static{s(this,"ApplicationsDiscardTestCommand")}static paths=[["applications","discard-test"]];static usage=R.Usage({category:"Admission",description:"Discard a TEST application (the server refuses a real one)"});application=p.String({required:!0});async execute(){return await(await this.caller()).mutation(S.admission.discardTest,{applicationId:this.application}),this.print({discarded:this.application},n=>[{key:"discarded",value:n.discarded}]),0}},Fg=class extends N{static{s(this,"ApplicationsStaffInputListCommand")}static paths=[["applications","staff-input","list"]];static usage=R.Usage({category:"Admission",description:"An application's internal inputs (set at the start): value, and why one can no longer be corrected"});application=p.String({required:!0});async execute(){let n=await(await this.caller()).query(S.admission.staffInputsOfApplication,{applicationId:this.application});return this.print(n,r=>r.map(i=>({key:i.key,label:i.label.de,value:String(i.value),correctable:i.block===null?"ja":i.block.de})),["key","label","value","correctable"]),0}},Lg=class extends N{static{s(this,"ApplicationsStaffInputSetCommand")}static paths=[["applications","staff-input","set"]];static usage=R.Usage({category:"Admission",description:"Correct one internal input of an application, with a reason \u2014 refused once a node that reads it was entered",examples:[["Untick \u201EKind von Mitarbeitenden\u201C",'plexus-cli --env prod --tenant <t> --allow-prod applications staff-input set <id> --input staffApplication=false --reason "falsch angehakt"']]});application=p.String({required:!0});input=p.String("--input",{required:!0,description:"key=true|false"});reason=p.String("--reason",{required:!0,description:"Why \u2014 recorded on the application's activity feed"});async execute(){let t=await this.caller(),[{key:n,value:r}]=fR([this.input]);return await t.mutation(S.admission.correctStaffInput,{applicationId:this.application,key:n,value:r,reason:this.reason}),this.print({application:this.application,key:n,value:r},i=>[{key:"application",value:i.application},{key:i.key,value:String(i.value)}]),0}},uR=[Og,Pg,_g,Cg,Ng,Dg,Fg,Lg];function fR(e){return e.map(t=>{let[n="",r,...i]=t.split("=");if(!Ja.test(n)||r!=="true"&&r!=="false"||i.length>0)throw new Error(`--staff-input "${t}": expected key=true or key=false`);return{key:n,value:r==="true"}})}s(fR,"parseStaffInputs");var Ft="contractGenerator",po="documentTemplate";function Za(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e,n=Object.keys(t);return(t.kind==="generator"||t.kind==="package")&&typeof t.key=="string"&&t.key.length>0&&(t.revision===void 0||typeof t.revision=="number"&&Number.isInteger(t.revision)&&t.revision>0)&&n.every(r=>r==="kind"||r==="key"||r==="revision")}s(Za,"isGeneratorRef");function pR(e,t){let n=e.inputs?.[t];return n?.kind==="literal"?n.value:void 0}s(pR,"literalOf");function Hr(e){let t=pR(e,Ft);return Za(t)?t:null}s(Hr,"generatorRefOfNode");function dr(e){let t=pR(e,po);return typeof t=="string"&&t.length>0?t:null}s(dr,"documentTemplateKeyOfNode");function mR(e){return`${e.kind}:${e.key}${e.revision===void 0?"":`@${e.revision}`}`}s(mR,"generatorRefLabel");var $V=["formExports","generatorStamp"];function hR(e,t,n){let r=e.inputs?.[Ft];(r?.kind!=="literal"||!Za(r.value))&&C(`applyGeneratorStamp: the node names no generator in inputs.${Ft} \u2014 a stamp derives from it`),n.freezeRevision&&t.revision!==void 0&&(e.inputs[Ft]={kind:"literal",value:{...r.value,revision:t.revision}}),e.generatorStamp={inputSchema:t.inputSchema,parties:t.parties,schemaDigest:t.schemaDigest,...t.parts===void 0?{}:{parts:t.parts}}}s(hR,"applyGeneratorStamp");var RV=["reads"];function ms(e){if(e===null||typeof e!="object")return e;let t={...e};return Array.isArray(t.nodes)&&(t.nodes=t.nodes.map(n=>{if(n===null||typeof n!="object")return n;let r={...n};for(let i of $V)delete r[i];for(let i of RV)Array.isArray(r[i])&&r[i].length===0&&delete r[i];return r})),t}s(ms,"comparableWorkflowGraph");var Xa={id:{de:"die Identit\xE4t ist der Slug des Angebots (bundle.yaml slugs.manifest)",en:"the identity is the offer's slug (bundle.yaml slugs.manifest)"},label:{de:"der Titel steht in bundle.yaml `label`",en:"the title is bundle.yaml `label`"},version:{de:"die Revision z\xE4hlt die Datenbank",en:"the database counts the revision"},applicantMode:{de:"von nichts gelesen",en:"read by nothing"},signatureLevel:{de:"von nichts gelesen",en:"read by nothing"},roleInstances:{de:"die Rollen kommen aus den Formular-Effekten",en:"roles come from the form effects"},leistungen:{de:"von nichts gelesen",en:"read by nothing"},capacity:{de:"die Kapazit\xE4t geh\xF6rt der Kohorte (program.runs[].capacities)",en:"capacity belongs to the cohort (program.runs[].capacities)"},progressLayoutId:{de:"von nichts gelesen",en:"read by nothing"},bewerbungsfenster:{de:"die Kohorte besitzt die \xD6ffnung (isOpen / applicationOpensAt)",en:"the cohort owns opening (isOpen / applicationOpensAt)"},selection:{de:"die Reihenfolge ist der Eingang `waitlistOrder` des Wartelistenknotens (automatisches Nachr\xFCcken gibt es nicht mehr; Freigabe-Strategie und Stichtag las nichts)",en:"the order is the waitlist node's input `waitlistOrder` (automatic promotion is gone; release strategy and deadline were read by nothing)"},progressLayout:{de:"das Fortschrittslayout geh\xF6rt zum Workflow: den Block nach workflow.json `progressLayout` verschieben (ohne Workflow l\xF6schen)",en:"the progress layout belongs to the workflow: move the block to workflow.json `progressLayout` (without a workflow: delete it)"}};function Hu(e){return e===null||typeof e!="object"||Array.isArray(e)?["manifest: data must be an object"]:Object.keys(e).map(t=>{let n=Xa[t];return n!==void 0?`manifest: \`${t}\` is no longer part of manifest.json (${n.en}). Delete the line.`:`manifest: unknown key \`${t}\` \u2014 manifest.json carries no key.`})}s(Hu,"manifestIssues");function IV(e){let t=[],n=e.buses;if(!Array.isArray(n))return t;let r=n.find(i=>!!i&&typeof i=="object"&&i.key==="process");if(!r||!Array.isArray(r.states))return t;for(let i of r.states){if(!i||typeof i!="object")continue;let o=i;if(o.terminal!==!0&&(!o.external||typeof o.external!="object")){let a=typeof o.id=="string"?o.id:"?";t.push(`progressLayout: progress state '${a}' is non-terminal but declares no 'external' block (applicant-facing copy) \u2014 resolveStatusPresentation would throw at runtime`)}}return t}s(IV,"validateProgressLayoutExternalCopy");function gR(e){if(e===null||typeof e!="object")return["progressLayout: the full layout object is required"];let t=e.buses;return!Array.isArray(t)||!t.some(n=>!!n&&typeof n=="object"&&n.key==="process")?["progressLayout: the layout must declare the `process` bus"]:IV(e)}s(gR,"progressLayoutIssues");var yR=new Set(["nodes","assignmentRules","channels","processStore","pricingRules","staffInputs"]);var OV=new Set(["sections","effects","outcomes","testScenarios","env"]),Ju={id:{de:"der Schl\xFCssel des Formulars ist sein Slug",en:"the form's key is its slug"},label:{de:"der Name steht in der Formularzeile (createSmartForm.label)",en:"the name is the form row's (createSmartForm.label)"},outcomeIds:{de:"die Ergebnisse sind die ids von outcomes[]",en:"the outcomes are the ids of outcomes[]"},schoolSlug:{de:"von nichts gelesen",en:"read by nothing"}};function wR(e,t){if(e===null||typeof e!="object"||Array.isArray(e))return[{de:`${t}: die Formulardefinition muss ein Objekt sein.`,en:`${t}: the form definition must be an object.`}];let n=[];for(let i of Object.keys(e)){if(OV.has(i))continue;let o=Ju[i];n.push(o!==void 0?{de:`${t}: \`${i}\` geh\xF6rt nicht mehr zur Formulardefinition (${o.de}). Die Zeile l\xF6schen.`,en:`${t}: \`${i}\` is no longer part of the form definition (${o.en}). Delete the line.`}:{de:`${t}: unbekannter Schl\xFCssel \`${i}\`.`,en:`${t}: unknown key \`${i}\`.`})}let r=e;for(let i of["sections","effects","outcomes"])Array.isArray(r[i])||n.push({de:`${t}: \`${i}\` muss eine Liste sein.`,en:`${t}: \`${i}\` must be a list.`});return n}s(wR,"smartFormDefinitionShapeIssues");var wn=["granted","rejected","waitlisted","other"];function Si(e){return typeof e=="string"&&wn.includes(e)}s(Si,"isOutcomeSemantic");var zn=["arrival","manual"],kR={arrival:{de:"Nach Eingang",en:"By arrival"},manual:{de:"Von Hand sortiert",en:"Sorted by hand"}};function PV(e,t){let n=e.inputs?.[t];return n?.kind==="literal"?n.value:void 0}s(PV,"literal");function qg(e){let t=PV(e,"waitlistOrder");return zn.includes(t)?{waitlistOrder:t}:null}s(qg,"waitlistPolicyOrNull");var ht="responsible",Kg="team:";function Qu(e){return`${Kg}${e}`}s(Qu,"teamSlot");function Zu(e){return e.startsWith(Kg)?e.slice(Kg.length):null}s(Zu,"teamKeyOfSlot");function bR(e){return e.kind==="responsible"?ht:Qu(e.groupKey)}s(bR,"slotIdOf");function Xu(e){if(e===ht)return{kind:"responsible"};let t=Zu(e);return t===null||t.length===0?null:{kind:"team",groupKey:t}}s(Xu,"slotOfId");var jg="review",Bg="checkField",vR="reviewed",xR="reviewing",ef=["rejected","waitlisted"];function Ug(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(Ug,"isObject");var _V=new Set(["decision",jg]),SR={approved:"granted",accepted:"granted",admitted:"granted",direkt:"granted",rejected:"rejected",absage:"rejected",declined:"rejected",waitlisted:"waitlisted",warteliste:"waitlisted"};function Vg(e){return Object.hasOwn(SR,e)?SR[e]:void 0}s(Vg,"legacySemanticOfId");function CV(e){return e===jg?wn.filter(t=>!ef.includes(t)):wn}s(CV,"allowedSemanticsFor");var NV="other";function AR(e){return Ug(e)&&_V.has(String(e.type))&&Array.isArray(e.outcomes)?e.outcomes:[]}s(AR,"outcomesOf");function ER(e){return(e?.nodes??[]).some(t=>AR(t).some(n=>Ug(n)&&!("semantic"in n)))}s(ER,"needsOutcomeSemantics");function TR(e,t={}){let n=[],r=[],i=[],o=e.nodes.map(a=>{let l=AR(a);if(l.length===0)return a;let d=a,c=String(d.id),u=String(d.type),f=CV(u),m=!1,y=l.map(k=>{if(!Ug(k))return k;let g=String(k.id);if("semantic"in k)return Si(k.semantic)||i.push({nodeId:c,outcomeId:g,value:String(k.semantic)}),k;let v=`${c}.${g}`,A=Object.hasOwn(t,v)?t[v]:void 0;if(A!==void 0)return f.includes(A)?(n.push({nodeId:c,outcomeId:g,semantic:A,source:"answer"}),m=!0,{...k,semantic:A}):(r.push({nodeId:c,nodeType:u,outcomeId:g,allowed:f,answer:A}),k);let $=Vg(g),E=$??NV;return f.includes(E)?(n.push({nodeId:c,outcomeId:g,semantic:E,source:$===void 0?"formerDefault":"legacyTable"}),m=!0,{...k,semantic:E}):(r.push({nodeId:c,nodeType:u,outcomeId:g,allowed:f}),k)});return m?{...d,outcomes:y}:a});return n.length===0?{graph:e,written:n,refused:r,invalid:i}:{graph:{...e,nodes:o},written:n,refused:r,invalid:i}}s(TR,"addOutcomeSemantics");var cr="bewerbungOffen";function mo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(mo,"isObject");var Gg=["event","effect"];function $R(e){return mo(e)&&e.type==="eventTrigger"}s($R,"isTrigger");function RR(e){let t=mo(e.inputs)?e.inputs:{};return"outcomes"in e||Gg.some(n=>n in e||n in t)}s(RR,"oldShape");function IR(e){return(e?.nodes??[]).some(t=>$R(t)&&RR(t))}s(IR,"needsEventTriggerStartMove");function DV(e){let t=String(e.id),r=(Array.isArray(e.outcomes)?e.outcomes:[]).map(l=>mo(l)?l.id:void 0);if("outcomes"in e&&!(r.length===1&&r[0]===cr))return{unmoved:{nodeId:t,reason:"outcomesNotStart"}};let i=Object.keys(mo(e.next)?e.next:{});if(!(i.length===1&&i[0]===cr))return{unmoved:{nodeId:t,reason:"nextNotStart"}};let o=mo(e.inputs)?{...e.inputs}:{};for(let l of Gg){let d=o[l];if(mo(d)&&d.kind==="binding")return{unmoved:{nodeId:t,reason:"bindingCell"}}}let a={...e};delete a.outcomes;for(let l of Gg)delete a[l],delete o[l];return mo(e.inputs)&&(Object.keys(o).length>0?a.inputs=o:delete a.inputs),{node:a}}s(DV,"moveNode");function OR(e){let t=[],n=[],r=e.nodes.map(i=>{if(!$R(i)||!RR(i))return i;let o=DV(i);return"unmoved"in o?(n.push(o.unmoved),i):(t.push(String(i.id)),o.node)});return t.length===0?{graph:e,moved:t,unmoved:n}:{graph:{...e,nodes:r},moved:t,unmoved:n}}s(OR,"moveEventTriggerStart");function el(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(el,"isObject");var PR={waitlistOrder:"arrival"};function _R(e){return!el(e)||e.type!=="waitlist"?!1:!("waitlistOrder"in(el(e.inputs)?e.inputs:{}))}s(_R,"lacksPolicy");function FV(e){return(e?.nodes??[]).some(_R)}s(FV,"needsWaitlistPolicyMove");function zg(e){return el(e)&&zn.includes(e.waitlistOrder)}s(zg,"isWaitlistPolicy");function LV(e){if(e===void 0)return{policy:PR,stated:!1};if(!el(e))return"malformed";let t=e.waitlistOrder;return t!==void 0&&!zn.includes(t)?"malformed":{policy:{waitlistOrder:t??PR.waitlistOrder},stated:t!==void 0}}s(LV,"policyOfSelection");function CR(e,t,n={}){let r=[],i=[];if(!FV(e))return{graph:e,moved:r,refused:i};let o=LV(t),a=e.nodes.map(l=>{if(!_R(l))return l;let d=l,c=String(d.id),u=el(d.inputs)?{...d.inputs}:{},f=Object.hasOwn(n,c)?n[c]:void 0,m,y;if(f!==void 0)m=f,y="answer";else{if(o==="malformed")return i.push({nodeId:c,reason:"selectionMalformed"}),l;m=o.policy,y=o.stated?"manifest":"formerDefault"}return u.waitlistOrder={kind:"literal",value:m.waitlistOrder},r.push({nodeId:c,policy:m,source:y}),{...d,inputs:u}});return r.length===0?{graph:e,moved:r,refused:i}:{graph:{...e,nodes:a},moved:r,refused:i}}s(CR,"moveWaitlistPolicyToInputs");function ho(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(ho,"isObject");var MV=[Ft,po],qV=["inputSchema","parties","schemaDigest","parts"];function NR(e){return ho(e)&&e.type==="governedDocument"&&("resolver"in e||ho(e.template)&&("key"in e.template||"cockpitFields"in e.template))}s(NR,"oldShape");function DR(e){return(e?.nodes??[]).some(NR)}s(DR,"needsGeneratorInputMove");function KV(e){let t=ho(e.inputs)?{...e.inputs}:{},n={...e},r;if("resolver"in e){let i=e.resolver;if(!ho(i))return{unmoved:"resolverNotObject"};if(Ft in t)return{unmoved:"generatorInputExists"};if(typeof i.key!="string"||i.key.length===0)return{unmoved:"pinWithoutKey"};if(i.kind!=="generator"&&i.kind!=="package")return{unmoved:"pinWithoutKind"};if(i.revision!==void 0&&!(typeof i.revision=="number"&&Number.isInteger(i.revision)&&i.revision>0))return{unmoved:"pinRevisionInvalid"};if((ho(i.inputSchema)&&Array.isArray(i.inputSchema.fields)?i.inputSchema.fields:[]).find(d=>ho(d)&&MV.includes(String(d.key)))!==void 0)return{unmoved:"stampDeclaresReservedKey"};t[Ft]={kind:"literal",value:{kind:i.kind,key:i.key,...i.revision===void 0?{}:{revision:i.revision}}};let l=Object.fromEntries(qV.filter(d=>d in i).map(d=>[d,i[d]]));Object.keys(l).length>0&&(n.generatorStamp=l),r=i.cockpitFields,delete n.resolver}if(ho(e.template)&&("key"in e.template||"cockpitFields"in e.template)){let{key:i,cockpitFields:o,...a}=e.template;if("key"in e.template){if(po in t)return{unmoved:"templateInputExists"};if(typeof i!="string"||i.length===0)return{unmoved:"templateKeyInvalid"};t[po]={kind:"literal",value:i}}if(o!==void 0){if(r!==void 0)return{unmoved:"cockpitFieldsTwice"};r=o}n.template=a}if(r!==void 0){if("cockpitFields"in e)return{unmoved:"cockpitFieldsExist"};n.cockpitFields=r}return n.inputs=t,{node:n}}s(KV,"moveNode");function FR(e){let t=[],n=[],r=e.nodes.map(i=>{if(!NR(i))return i;let o=KV(i);return"unmoved"in o?(n.push({nodeId:String(i.id),reason:o.unmoved}),i):(t.push(String(i.id)),o.node)});return t.length===0?{graph:e,moved:t,unmoved:n}:{graph:{...e,nodes:r},moved:t,unmoved:n}}s(FR,"moveGeneratorPinsToInputs");var LR=/^\d{4}-\d{2}-\d{2}$/;function ur(e,t){return{de:e,en:t}}s(ur,"issue");function go(e){if(typeof e!="object"||e===null)return ur("keine Reduktion","not a reduction");let t=e;if(t.kind==="none")return Object.keys(t).length===1?null:ur('\u201Ekeine Reduktion" tr\xE4gt keine weiteren Angaben','"no reduction" carries no further details');if(t.kind!=="amount")return ur(`unbekannte Art ${JSON.stringify(t.kind)}`,`unknown kind ${JSON.stringify(t.kind)}`);let{amount:n,activeFrom:r,activeTo:i}=t;return typeof n!="number"||!Number.isFinite(n)||n<=0?ur("der Betrag muss gr\xF6\xDFer als 0 \u20AC sein","the amount must be greater than \u20AC0"):Number.isInteger(Number((n*100).toFixed(6)))?typeof r!="string"||!LR.test(r)?ur("der Beginn fehlt (JJJJ-MM-TT)","the start is missing (YYYY-MM-DD)"):typeof i!="string"||!LR.test(i)?ur("das Ende fehlt (JJJJ-MM-TT)","the end is missing (YYYY-MM-DD)"):i<r?ur("das Ende liegt vor dem Beginn","the end is before the start"):t.floorTotal!==void 0&&(typeof t.floorTotal!="number"||!Number.isSafeInteger(t.floorTotal)||t.floorTotal<0)?ur("die Untergrenze muss ein nichtnegativer Centbetrag sein","the floor must be a non-negative amount in cents"):t.pricePeriod!==void 0&&!["month","year","once","unit"].includes(String(t.pricePeriod))?ur("ung\xFCltige Preisperiode","invalid price period"):Object.keys(t).some(o=>!["kind","amount","activeFrom","activeTo","floorTotal","pricePeriod"].includes(o))?ur("unbekannte Angaben","unknown details"):null:ur("der Betrag hat mehr als zwei Nachkommastellen","the amount has more than two decimal places")}s(go,"reductionShapeIssue");function Ai(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.itemKey=="string"&&t.itemKey.length>0&&Array.isArray(t.grantKeys)&&t.grantKeys.every(n=>typeof n=="string"&&n.length>0)&&(t.reduction===void 0||go(t.reduction)===null&&t.reduction.kind==="amount")}s(Ai,"isPricedItemValue");var hs=["freetext","recommendation","choice","pricedItem","record","reduction"],gs=[...hs,"appointment"];function qR(e){return typeof e=="string"&&gs.includes(e)}s(qR,"isTaskResultKind");function Ei(e){return typeof e=="string"&&hs.includes(e)}s(Ei,"isRecordedTaskResultKind");function ys(e){return Ei(e.kind)}s(ys,"isRecordedTaskResult");var tf=["number","boolean","enum"];function Wg(e){return typeof e=="string"&&tf.includes(e)}s(Wg,"isRecordFieldType");var Yg=["form","siblingRank"];var Jr={freetext:{choiceValueType:null,valueType:null,textValueType:"string",label:{de:"Freitext",en:"Free text"}},recommendation:{choiceValueType:"enum",valueType:null,textValueType:"string",label:{de:"Empfehlung",en:"Recommendation"}},choice:{choiceValueType:"enum",valueType:"enum",textValueType:"string",label:{de:"Auswahl",en:"Choice"}},pricedItem:{choiceValueType:"enum",valueType:"pricedItem",textValueType:"string",label:{de:"Preisposition",en:"Priced item"}},reduction:{choiceValueType:null,valueType:"reduction",textValueType:"string",label:{de:"Reduktion",en:"Reduction"}},record:{choiceValueType:null,valueType:null,textValueType:"string",label:{de:"Erfassung",en:"Record"}},appointment:{choiceValueType:null,valueType:null,textValueType:null,label:{de:"Termin",en:"Appointment"}}};function yo(e){return(e.kind==="freetext"||e.kind==="recommendation"||e.kind==="choice")&&e.writes===void 0}s(yo,"isProseResult");function nf(e){return e.kind==="record"?(e.fields??[]).filter(t=>typeof t.writes=="string"&&t.writes.length>0&&Wg(t.type)).map(t=>({key:t.writes,valueType:t.type,field:t})):jV(e)}s(nf,"draftResultStoreWrites");function jV(e){let t=Jr[e.kind].valueType;return e.writes===void 0||t===null?[]:[{key:e.writes,valueType:t}]}s(jV,"singleStoreWrite");var MR="team:";function ws(e){if(e==="all")return{kind:"all"};if(e==="external"||e.length===0)return null;if(e.startsWith(MR)){let t=e.slice(MR.length);return t.length===0?null:{kind:"team",groupKey:t}}return{kind:"channel",channelKey:e}}s(ws,"parseTaskResultChat");var Ye={unknownKind:"[taskResult/unknownKind]",onApproval:"[taskResult/onApproval]",unknownField:"[taskResult/unknownField]",choiceOptions:"[taskResult/choiceOptions]",textRequiredOnFreetext:"[taskResult/textRequiredOnFreetext]",chatMissing:"[taskResult/chatMissing]",chatExternal:"[taskResult/chatExternal]",chatUnknownChannel:"[taskResult/chatUnknownChannel]",appointmentMissingTitle:"[taskResult/appointmentMissingTitle]",pricedItemMissingItem:"[taskResult/pricedItemMissingItem]",pricedItemUnknownItem:"[taskResult/pricedItemUnknownItem]",pricedItemNotInProgram:"[taskResult/pricedItemNotInProgram]",pricedItemOfferWithoutProgram:"[taskResult/pricedItemOfferWithoutProgram]",itemOnNonPricedItem:"[taskResult/itemOnNonPricedItem]",writesOnProse:"[taskResult/writesOnProse]",filesOnKind:"[taskResult/filesOnKind]",labelMissing:"[taskResult/labelMissing]",appointmentInvalidDuration:"[taskResult/appointmentInvalidDuration]",recordFields:"[taskResult/recordFields]",fieldsOnNonRecord:"[taskResult/fieldsOnNonRecord]",recordSuggest:"[taskResult/recordSuggest]",reductionPrices:"[taskResult/reductionPrices]",pricesOnNonReduction:"[taskResult/pricesOnNonReduction]"};var BV=new Set(["if","else","in","true","false","null"]),UV=new Set(["==","!=","<=",">=","&&","||"]);function VV(e){return e>="0"&&e<="9"}s(VV,"isDigit");function GV(e){return/[a-zA-Z_$]/.test(e)}s(GV,"isIdentStart");function zV(e){return/[a-zA-Z0-9_.$]/.test(e)}s(zV,"isIdentCont");function WV(e){let t=[],n=0;for(;n<e.length;){let r=e.charAt(n);if(r===" "||r===" "||r===`
10202
+ `||r==="\r"){n++;continue}if(r==="'"){let o=n+1,a="";for(;o<e.length&&e.charAt(o)!=="'";)e.charAt(o)==="\\"&&o+1<e.length?(a+=e.charAt(o+1),o+=2):(a+=e.charAt(o),o++);o>=e.length&&C(`Unterminated string at ${n}`),t.push({t:"str",v:a}),n=o+1;continue}if(VV(r)){let o=n;for(;o<e.length&&/[0-9.]/.test(e.charAt(o));)o++;t.push({t:"num",v:Number(e.slice(n,o))}),n=o;continue}if(GV(r)){let o=n;for(;o<e.length&&zV(e.charAt(o));)o++;let a=e.slice(n,o);BV.has(a)?t.push({t:"kw",v:a}):t.push({t:"ident",v:a}),n=o;continue}let i=e.slice(n,n+2);if(UV.has(i)){t.push({t:"op",v:i}),n+=2;continue}if("<>!".includes(r)){t.push({t:"op",v:r}),n++;continue}if("()[],".includes(r)){t.push({t:"punct",v:r}),n++;continue}C(`Unexpected char '${r}' at ${n}`)}return t}s(WV,"tokenise");var KR=1e4,jR=128;function ks(e){e.depth++,e.depth>jR&&C(`Expression nesting too deep (> ${jR})`)}s(ks,"enterDepth");function WR(e){return e.pos<e.tokens.length?e.tokens[e.pos]:null}s(WR,"peek");function Lt(e){let t=e.tokens[e.pos];return t||C(`Unexpected end at ${e.pos}`),e.pos++,t}s(Lt,"take");function Mt(e,t,n){let r=WR(e);return!(!r||r.t!==t||n!==void 0&&r.v!==n)}s(Mt,"match");function wo(e,t,n){return Mt(e,t,n)||C(`Expected ${t}${n?`:${n}`:""} at ${e.pos}`),Lt(e)}s(wo,"expect");function Zr(e){ks(e);try{return Mt(e,"kw","if")?YV(e):HV(e)}finally{e.depth--}}s(Zr,"parseExpr");function YV(e){wo(e,"kw","if"),wo(e,"punct","(");let t=Zr(e);wo(e,"punct",")");let n=Zr(e);wo(e,"kw","else");let r=Zr(e);return{kind:"if",cond:t,then:n,else:r}}s(YV,"parseIf");function HV(e){let t=BR(e),n=0;try{for(;Mt(e,"op","||");){Lt(e),ks(e),n++;let r=BR(e);t={kind:"binary",op:"||",left:t,right:r}}}finally{e.depth-=n}return t}s(HV,"parseLogicOr");function BR(e){let t=UR(e),n=0;try{for(;Mt(e,"op","&&");){Lt(e),ks(e),n++;let r=UR(e);t={kind:"binary",op:"&&",left:t,right:r}}}finally{e.depth-=n}return t}s(BR,"parseLogicAnd");function UR(e){let t=VR(e),n=0;try{for(;Mt(e,"op","==")||Mt(e,"op","!=");){let r=Lt(e).v;ks(e),n++;let i=VR(e);t={kind:"binary",op:r,left:t,right:i}}}finally{e.depth-=n}return t}s(UR,"parseEquality");function VR(e){let t=Jg(e),n=0;try{for(;Mt(e,"op","<")||Mt(e,"op","<=")||Mt(e,"op",">")||Mt(e,"op",">=")||Mt(e,"kw","in");){let r=Lt(e),i=r.t==="kw"?"in":r.v;ks(e),n++;let o=Jg(e);t={kind:"binary",op:i,left:t,right:o}}}finally{e.depth-=n}return t}s(VR,"parseCompare");function Jg(e){if(Mt(e,"op","!")){Lt(e),ks(e);try{return{kind:"unary",op:"!",operand:Jg(e)}}finally{e.depth--}}return JV(e)}s(Jg,"parseUnary");function JV(e){let t=WR(e);if(t||C("Unexpected end"),t.t==="num")return Lt(e),{kind:"num",value:t.v};if(t.t==="str")return Lt(e),{kind:"str",value:t.v};if(t.t==="kw"&&t.v==="true")return Lt(e),{kind:"bool",value:!0};if(t.t==="kw"&&t.v==="false")return Lt(e),{kind:"bool",value:!1};if(t.t==="kw"&&t.v==="null")return Lt(e),{kind:"null"};if(t.t==="punct"&&t.v==="("){Lt(e);let n=Zr(e);return wo(e,"punct",")"),n}if(t.t==="punct"&&t.v==="["){Lt(e);let n=[];if(!Mt(e,"punct","]"))for(n.push(Zr(e));Mt(e,"punct",",");)Lt(e),n.push(Zr(e));return wo(e,"punct","]"),{kind:"arr",items:n}}if(t.t==="ident"){let n=t.v;if(Lt(e),Mt(e,"punct","(")){Lt(e);let r=[];if(!Mt(e,"punct",")"))for(r.push(Zr(e));Mt(e,"punct",",");)Lt(e),r.push(Zr(e));return wo(e,"punct",")"),{kind:"call",name:n,args:r}}return{kind:"ident",path:n}}C(`Unexpected token at ${e.pos}`)}s(JV,"parsePrimary");function qt(e){e.length>KR&&C(`Expression too long (${e.length} > ${KR})`);let t={tokens:WV(e),pos:0,depth:0},n=Zr(t);return t.pos<t.tokens.length&&C(`Unexpected trailing token at ${t.pos}`),n}s(qt,"parseExpression");var QV=new Map([["today",()=>new Date().toISOString().slice(0,10)],["years_between",(e,t)=>{if(typeof e!="string"||typeof t!="string")return null;let n=new Date(e),r=new Date(t);if(isNaN(n.getTime())||isNaN(r.getTime()))return null;let i=r.getFullYear()-n.getFullYear(),o=r.getMonth()-n.getMonth();return(o<0||o===0&&r.getDate()<n.getDate())&&i--,i}],["length",e=>typeof e=="string"||Array.isArray(e)?e.length:0]]);function gt(e,t){switch(e.kind){case"num":return e.value;case"str":return e.value;case"bool":return e.value;case"null":return null;case"ident":{let n=Object.hasOwn(t.values,e.path)?t.values[e.path]:void 0;return n===void 0?null:n}case"arr":return e.items.map(n=>gt(n,t));case"unary":{let n=gt(e.operand,t);return!Ti(n)}case"call":{let n=t.functions!==void 0&&Object.hasOwn(t.functions,e.name)?t.functions[e.name]:QV.get(e.name);n||C(`Unknown function '${e.name}'`);let r=e.args.map(i=>gt(i,t));return n(...r)}case"binary":return ZV(e.op,e.left,e.right,t);case"if":return Ti(gt(e.cond,t))?gt(e.then,t):gt(e.else,t)}}s(gt,"evaluate");function ZV(e,t,n,r){if(e==="&&"){let a=gt(t,r);return Ti(a)?Ti(gt(n,r)):!1}if(e==="||"){let a=gt(t,r);return Ti(a)?!0:Ti(gt(n,r))}let i=gt(t,r),o=gt(n,r);switch(e){case"==":return Hg(i,o);case"!=":return!Hg(i,o);case"<":{let[a,l]=rf(i,o);return a!==null&&l!==null&&a<l}case"<=":{let[a,l]=rf(i,o);return a!==null&&l!==null&&a<=l}case">":{let[a,l]=rf(i,o);return a!==null&&l!==null&&a>l}case">=":{let[a,l]=rf(i,o);return a!==null&&l!==null&&a>=l}case"in":return Array.isArray(o)?o.some(a=>Hg(a,i)):!1}}s(ZV,"evalBinary");function rf(e,t){return[GR(e),GR(t)]}s(rf,"orderedOperands");function GR(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"){if(e.trim()==="")return null;let t=Number(e);return Number.isFinite(t)?t:null}return null}s(GR,"numericOperand");function Hg(e,t){return e===t?!0:e==null||t==null?!1:typeof e=="number"&&typeof t=="string"?e===Number(t):typeof e=="string"&&typeof t=="number"?Number(e)===t:!1}s(Hg,"looseEq");function Ti(e){return!(e==null||e===!1||e===0||e===""||Array.isArray(e)&&e.length===0)}s(Ti,"truthy");function kt(e){let t=new Set;return Qr(e,t),[...t]}s(kt,"dependencies");function Qr(e,t){switch(e.kind){case"ident":t.add(e.path);return;case"call":e.args.forEach(n=>Qr(n,t));return;case"arr":e.items.forEach(n=>Qr(n,t));return;case"unary":Qr(e.operand,t);return;case"binary":Qr(e.left,t),Qr(e.right,t);return;case"if":Qr(e.cond,t),Qr(e.then,t),Qr(e.else,t);return;default:return}}s(Qr,"walk");var zR=new Map;function fr(e){let t=zR.get(e);return t||(t=qt(e),zR.set(e,t)),t}s(fr,"parseCached");function XV(e,t){return gt(fr(e),t)}s(XV,"evalExpression");function YR(e,t){return Ti(XV(e,t))}s(YR,"evalBoolean");function of(e){let t=e.pricingRules;return t===void 0?[]:(Array.isArray(t)||C("graph.pricingRules must be an array \u2014 the graph validator refuses anything else"),t)}s(of,"pricingRuleSets");function Qg(e){return e.derive!==void 0}s(Qg,"isDerivedKey");function eG(e,t){let n=of(e);return(t.rules??[]).map(r=>{let i=n.find(o=>o.key===r);return i===void 0&&C(`[process] derivation names the unknown rule set "${r}" \u2014 publish refuses that`),i})}s(eG,"ruleSetsOfDerivation");function JR(e){return[...new Set(e.rows.flatMap(t=>kt(fr(t.when))))]}s(JR,"ruleSetDependencies");function QR(e){let t=zr(e);return t!==null&&se(t)===e?t:null}s(QR,"ruleIdentifierAddress");function Zg(e,t){let r=[...new Set(eG(e,t).flatMap(JR))].map(o=>{let a=QR(o);return a===null&&C(`[address/bareIdentifier] rule identifier "${o}" is no address \u2014 publish refuses that`),{address:a,id:o,role:"rule"}}),i=t.reduction;return i===void 0?r:(be(i)||C(`[address/bareIdentifier] derive.reduction ${JSON.stringify(i)} is no address \u2014 publish refuses that`),[...r,{address:i,id:se(i),role:"reduction"}])}s(Zg,"derivationSources");function ZR(e,t){let n=of(e);for(let r of t.rules??[]){let i=n.find(o=>o.key===r);if(i===void 0||i.rows.some(o=>tl(o.when)!==null)||JR(i).some(o=>QR(o)===null))return null}return t.reduction!==void 0&&!be(t.reduction)?null:Zg(e,t)}s(ZR,"draftDerivationSources");function tl(e){if(typeof e!="string"||e.trim().length===0)return"leere Bedingung";try{return fr(e),null}catch(t){return t instanceof Error?t.message:String(t)}}s(tl,"conditionIssue");function HR(e){return e.item!==void 0&&e.group===void 0?{kind:"item",key:e.item}:e.group!==void 0&&e.item===void 0?{kind:"group",key:e.group}:null}s(HR,"rowTarget");function Xg(e){if(e.byStage===void 0){let t=HR(e);return t===null?[]:[{...t,stages:null}]}return e.item!==void 0||e.group!==void 0?[]:e.byStage.flatMap(t=>{let n=HR(t);return n===null?[]:[{...n,stages:t.stages}]})}s(Xg,"derivationTargets");function XR(e,t){t!==null&&(typeof t=="object"||typeof t=="function")&&Object.hasOwn(t,"exports")&&C(`[workflow/registry] node type "${e}": custom spec.exports is unsupported; use artifact-slot exports.`)}s(XR,"assertNoCustomNodeExports");var ey=null;function eI(e){for(let[t,n]of Object.entries(e))XR(t,n);ey=e}s(eI,"setSpecs");function tI(){return ey||C("[workflow/registry] Specs not initialised. Import convex/model/admission/specs before calling specFor()."),ey}s(tI,"requireSpecs");function He(e){let t=tI(),n=t[e.type];return n===void 0&&ae("INVALID",{de:`[workflow/registry] Unbekannter Knotentyp "${String(e.type)}" (Knoten "${String(e.id)}"). Registrierte Typen: ${Object.keys(t).sort().join(", ")}.`,en:`[workflow/registry] Unknown node type "${String(e.type)}" (node "${String(e.id)}"). Registered types: ${Object.keys(t).sort().join(", ")}.`}),n}s(He,"specFor");function nI(){return Object.keys(tI()).sort()}s(nI,"registeredNodeTypes");var rI=Gu.filter(e=>Yr[e].cohortBound!==!0);function ty(e){return lr(e)&&Yr[e].cohortBound!==!0}s(ty,"isEnvAddressLeaf");function ny(e){return fo(e).type}s(ny,"envType");function ry(e){return fo(e).label}s(ry,"envLabel");function sf(e){if(e.scope==="env"||e.path===void 0)return e;switch(e.scope){case"node":return{scope:"node",owner:e.owner,key:e.key};case"task":return{scope:"task",owner:e.owner,key:e.key};case"derived":return{scope:"derived",key:e.key}}}s(sf,"addressBase");function bs(e){return e.scope==="node"&&e.key===tn&&e.path===void 0}s(bs,"isInstanceAddress");function at(e){return be(e)&&e.scope==="node"&&e.key===tn&&e.path!==void 0}s(at,"isFormFieldAddress");function iI(e){return at(e)?{owner:e.owner,path:e.path}:null}s(iI,"formFieldOf");function iy(e){return kt(fr(e)).map(t=>{if(!t.startsWith("$"))return{identifier:t,address:null,reason:"bareIdentifier"};let n=zr(t);return n===null?{identifier:t,address:null,reason:"shape"}:{identifier:t,address:n}})}s(iy,"expressionAddresses");var tn="admission",ol="document",vs="contract",xs="contracts",oI="payment",oy=new Set(["adoptForm","setFlagTarget","form","familyRequestFrom"]);var ln={id:"identity",type:"identity",label:"display",sublabel:"display",library:"display",outcomes:"control",outputLabels:"display",inputs:"input",next:"control",tasks:"config",assign:"reference",optionalActions:"config",artifacts:"config",notifications:"config"},Lae={join:{...ln},end:{...ln},eventTrigger:{...ln},form:{...ln,adoptForm:"address",formExports:"stamp"},roleAssign:{...ln},setFlag:{...ln},if:{...ln,condition:"address"},countersign:{...ln,contract:"address",titles:"display",signing:"config"},engagePush:{...ln,engage:"tenantRef",form:"address",contract:"address",payment:"address"},decision:{...ln,commentRequired:"config",decisionAsTask:"config",reads:"address",requiresOneOf:"config"},review:{...ln,reads:"address",commentRequired:"config",decisionAsTask:"config"},waitlist:{...ln},completenessCheck:{...ln,requires:"address",deadline:"config"},collectPayment:{...ln},governedDocument:{...ln,production:"config",form:"address",generatorStamp:"stamp",templateStamp:"stamp",approval:"config",confirmBeforeIssue:"config",confirmContractTerms:"config",contractTermsQuestionText:"display",responseStrategy:"config",titles:"display",responseLabels:"display",reads:"address"}};function Ir(e){return Array.isArray(e)?e:[]}s(Ir,"listOf");function Kt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}s(Kt,"record");function sI(e){switch(e.type){case"countersign":return["contract"];case"engagePush":return["form","contract","payment"];case"governedDocument":return e.production==="resolver"?["form"]:[];default:return[]}}s(sI,"dataSourceFieldsOf");function aI(e){return e.type==="engagePush"?["form"]:sI(e)}s(aI,"requiredDataSourceFields");var tG={setFlag:{target:"setFlagTarget"}};function sl(e,t={}){let n=[],r=e,i=`nodes.${e.id}`,o=s((d,c,u,f={})=>{n.push({kind:d,at:c,nodeId:e.id,value:u,judgedTogether:null,...f})},"field"),a=new Map(t.slotTypes===!1?[]:(He(e).inputs?.(e)??[]).map(d=>[d.id,d.type])),l=tG[e.type]??{};for(let[d,c]of Object.entries(Kt(r.inputs)??{})){let u=Kt(c);if(u?.kind!=="binding")continue;let f="address"in u?u.address:u.path,m=l[d];if(m!==void 0){o(m,`${i}.inputs.${d}`,f);continue}let y=a.get(d);o("binding",`${i}.inputs.${d}`,f,y!==void 0?{expectedType:y}:{})}for(let[d,c]of Ir(r.reads).entries())o("nodeReads",`${i}.reads.${d}`,c,{judgedTogether:`${i}.reads`});for(let[d,c]of Ir(r.requires).entries())o("requires",`${i}.requires.${d}`,c,{judgedTogether:`${i}.requires`});e.type==="form"&&r.adoptForm!==void 0&&o("adoptForm",`${i}.adoptForm`,r.adoptForm);for(let d of sI(e))r[d]!==void 0&&o(d,`${i}.${d}`,r[d]);e.type==="if"&&r.condition!==void 0&&o("condition",`${i}.condition`,r.condition);for(let[d,c]of Ir(r.tasks).entries())n.push(...lI(e.id,c,d));return n}s(sl,"nodeAddressFields");function lI(e,t,n){let r=Kt(t);if(r===null)return[];let i=[],o=typeof r.key=="string"?r.key:String(n),a=`nodes.${e}.tasks.${o}`,l=s((f,m,y,k={})=>{i.push({kind:f,at:m,nodeId:e,taskKey:o,value:y,judgedTogether:null,...k})},"field"),d=`${a}.evidence`;r.when!==void 0&&l("taskWhen",`${a}.when`,r.when,{expectedType:"boolean",judgedTogether:d});for(let[f,m]of Ir(r.reads).entries())l("taskReads",`${a}.reads.${f}`,m,{judgedTogether:d});for(let[f,m]of Ir(r.documents).entries()){let y=Kt(m);y===null||y.kind==="artifact"||l("taskDocument",`${a}.documents.${f}`,"address"in y?y.address:y.key)}let c=Kt(r.familyRequest);if(c!==null){for(let[f,m]of Ir(c.fields).entries())l("familyRequestFields",`${a}.familyRequest.fields.${f}`,m,{judgedTogether:`${a}.familyRequest.fields`});c.from!==void 0&&l("familyRequestFrom",`${a}.familyRequest.from`,c.from)}let u=Kt(r.result);if(u?.kind==="record")for(let[f,m]of Ir(u.fields).entries()){let y=Kt(Kt(m)?.suggest);if(y?.kind!=="form")continue;let k=Kt(m)?.type;l("suggest",`${a}.result.fields.${f}.suggest`,"address"in y?y.address:y.key,typeof k=="string"?{expectedType:k}:{})}return i}s(lI,"taskAddressFields");function af(e){let t=[];for(let[n,r]of Ir(e.processStore).entries()){let i=Kt(Kt(r)?.derive);if(i?.reduction!==void 0){let o=String(Kt(r)?.key);t.push({kind:"reduction",at:`processStore.${n}.derive.reduction`,nodeId:null,priceKey:o,value:i.reduction,judgedTogether:null})}}for(let[n,r]of Ir(e.pricingRules).entries())for(let[i,o]of Ir(Kt(r)?.rows).entries())t.push({kind:"pricingRule",at:`pricingRules.${n}.rows.${i}.when`,nodeId:null,value:Kt(o)?.when,judgedTogether:null});return t}s(af,"priceAddressFields");function Ss(e){return sy(e)?(lf(e.value)??[]).flatMap(t=>t.address===null?[]:[t.address]):be(e.value)?[e.value]:[]}s(Ss,"addressesInField");function sy(e){return e.kind==="pricingRule"||e.kind==="condition"}s(sy,"isExpressionField");function lf(e){return tl(e)===null?iy(e):null}s(lf,"ruleConditionAddresses");function kn(e){return e.type==="form"&&e.adoptForm!==void 0&&e.adoptForm!==!1}s(kn,"adoptsForm");function dI(e){if(e.type!=="form"||kn({type:e.type,adoptForm:e.adoptForm}))return;let t=e.inputs?.smartForm;return t?.kind==="literal"&&typeof t.value=="string"&&t.value!==""?t.value:void 0}s(dI,"createdSmartFormSlug");function nG(e,t){return e.type!=="governedDocument"||e.production!=="resolver"||t!==ol?t:e.generatorStamp?.parts!==void 0?xs:vs}s(nG,"addressKeyOfPort");function ay(e){let t=e.result;return t===void 0||!ys(t)?[]:nf(t).map(n=>n.key)}s(ay,"storeWritesOf");function rl(e,t){return(Array.isArray(e.processStore)?e.processStore:[]).find(n=>n.key===t)}s(rl,"declaredKey");function Or(e,t){let n=[];if(!kn(t))for(let r of He(t).outputs?.(t)??[])n.push({address:{scope:"node",owner:t.id,key:nG(t,r.name)},type:r.type,...r.label!==void 0?{label:r.label}:{},nodeId:t.id,nodePort:r});for(let r of Array.isArray(t.tasks)?t.tasks:[])for(let i of ay(r)){let o=rl(e,i);n.push({address:{scope:"task",owner:r.key,key:i},type:o?.type??"unknown",...o!==void 0?{label:o.label}:{},nodeId:t.id})}return n}s(Or,"producedAddresses");function cI(e,t,n){for(let r of e.nodes)for(let i of Array.isArray(r.tasks)?r.tasks:[])if(i.key===t&&ay(i).includes(n))return{nodeId:r.id,template:i};return null}s(cI,"taskWriter");function Pr(e,t,n){return cI(e,t,n)?.nodeId??null}s(Pr,"taskOwnerNode");function il(e,t){let n=rl(e,t)?.derive;if(n===void 0)return null;let r=Array.isArray(e.pricingRules)?e.pricingRules:[],i=[];for(let a of n.rules??[]){let l=r.find(d=>d.key===a);if(l===void 0)return null;for(let d of l.rows){let c=lf(d.when);if(c===null)return null;for(let u of c)u.address!==null&&i.push(u.address)}}let o=n.reduction;return be(o)&&i.push(o),rG(i)}s(il,"derivedSources");function rG(e){let t=new Set;return e.filter(n=>{let r=se(n);return t.has(r)?!1:(t.add(r),!0)})}s(rG,"dedupe");function iG(e){return sl(e,{slotTypes:!1}).flatMap(t=>Ss(t).map(n=>({address:n,field:t})))}s(iG,"writtenAddressesOf");function ko(e,t){let n=[],r=new Set,i=s((l,d,c,u)=>{let f=`${se(l)}|${d}|${c.at}|${u===void 0?"":se(u)}`;r.has(f)||(r.add(f),n.push({address:l,origin:d,field:c,...u!==void 0?{via:u}:{}}))},"push"),o=s((l,d,c=new Set)=>{let u=se(l);if(!c.has(u)){if(c.add(u),l.scope==="task"){let f=cI(e,l.owner,l.key);if(f===null)return;for(let m of lI(f.nodeId,f.template))if(!(m.kind!=="taskWhen"&&m.kind!=="taskReads"))for(let y of Ss(m))i(y,"evidence",d,l)}if(l.scope==="derived")for(let f of il(e,l.key)??[])i(f,"derivedSource",d,l),o(f,d,c)}},"carried");for(let{address:l,field:d}of iG(t))i(l,"written",d),o(l,d);let a=new Set((Array.isArray(t.tasks)?t.tasks:[]).flatMap(l=>ay(l).map(d=>`${l.key}.${d}`)));for(let l of af(e))if(!(l.kind!=="reduction"||!be(l.value)||l.value.scope!=="task")&&a.has(`${l.value.owner}.${l.value.key}`))for(let d of il(e,l.priceKey)??[])d.scope==="task"&&a.has(`${d.owner}.${d.key}`)||(i(d,"priceCheck",l,{scope:"derived",key:l.priceKey}),o(d,l));return n}s(ko,"addressReadsOf");function ly(e,t){switch(t.scope){case"env":return lr(t.key)?ny(t.key):Qa(e,t.key)?.type;case"derived":case"task":{if(t.path!==void 0||t.scope==="task"&&Pr(e,t.owner,t.key)===null)return;let n=rl(e,t.key);return n===void 0||t.scope==="derived"!=(n.derive!==void 0)?void 0:n.type}case"node":{let n=e.nodes.find(i=>i.id===t.owner);if(n===void 0)return;let r=Or(e,n).find(i=>i.address.scope==="node"&&i.address.key===t.key);return r===void 0?void 0:t.path===void 0?r.type:r.nodePort?.schema?.find(i=>i.key===t.path)?.type}}}s(ly,"addressType");function nl(e,t){let n=Kt(e)?.[t];return typeof n=="string"&&n.length>0?n:void 0}s(nl,"labelText");function Oe(e,t,n){let r=e.nodes.find(i=>i.id===t);return nl(r?.label,n)??t}s(Oe,"nodeDisplayName");function bo(e,t,n){for(let r of e.nodes){let i=(Array.isArray(r.tasks)?r.tasks:[]).find(o=>o.key===t);if(i!==void 0)return nl(i.title,n)??t}return t}s(bo,"taskDisplayName");function Be(e,t,n){let r=[];switch(t.scope){case"env":r.push(lr(t.key)?ry(t.key)[n]:Qa(e,t.key)?.label[n]??t.key);break;case"derived":r.push(nl(rl(e,t.key)?.label,n)??t.key);break;case"task":r.push(bo(e,t.owner,n),nl(rl(e,t.key)?.label,n)??t.key);break;case"node":{r.push(Oe(e,t.owner,n));let i=e.nodes.find(a=>a.id===t.owner),o=i===void 0?void 0:Or(e,i).find(a=>a.address.scope==="node"&&a.address.key===t.key);r.push(nl(o?.label,n)??t.key);break}}return t.scope!=="env"&&t.path!==void 0&&r.push(t.path),`${r.join(" \u203A ")} (${se(t)})`}s(Be,"displayAddress");var al=["beneficiary","signers"];function uI(e,t){return Array.isArray(e.artifacts)&&e.artifacts.some(n=>n?.key===t)}s(uI,"ownsSlot");function ll(e){let t=[];for(let[n,r]of Object.entries(Kt(e.inputs)??{})){let i=Kt(r);i?.kind==="binding"&&be(i.address)&&t.push({slot:n,address:i.address})}return t}s(ll,"bindingAddresses");function fI(e,t){return ll(e).find(n=>n.slot===t)?.address??null}s(fI,"bindingAddressAt");function pI(e,t){let n=s(i=>i.scope==="node"&&i.owner===t||i.scope==="task"&&Pr(e,i.owner,i.key)===t,"names");return[...e.nodes.filter(i=>i.id!==t).flatMap(i=>sl(i,{slotTypes:!1})),...af(e)].flatMap(i=>Ss(i).filter(n).map(o=>({at:i.at,nodeId:i.nodeId,address:o})))}s(pI,"addressesNaming");var Tt={target:"target",flagKey:"flagKey",value:"value"};function oG(e){return fI(e,Tt.target)}s(oG,"setFlagTarget");function mI(e){let t=oG(e);return t!==null&&bs(t)?t.owner:null}s(mI,"setFlagTargetOwner");function df(e){let t=e.inputs?.[Tt.flagKey];return t?.kind==="literal"&&typeof t.value=="string"&&t.value.length>0?t.value:null}s(df,"setFlagKey");function hI(e){let t=e.inputs?.[Tt.value];if(t===void 0||t.kind==="unset")return!0;if(t.kind==="literal"&&typeof t.value=="boolean")return t.value;C(`[setFlag/valueType] setFlag node "${String(e.id)}": \`${Tt.value}\` is no yes/no literal \u2014 publish refuses that`)}s(hI,"setFlagValue");function gI(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(gI,"isObject");var yI=["target","flagKey","value"];function wI(e){return gI(e)&&e.type==="setFlag"&&yI.some(t=>t in e)}s(wI,"oldShape");function kI(e){return(e?.nodes??[]).some(wI)}s(kI,"needsSetFlagInputMove");function sG(e){let t=gI(e.inputs)?{...e.inputs}:{};if(yI.some(a=>a in e&&Tt[a]in t))return{unmoved:"inputExists"};if("target"in e&&!be(e.target))return{unmoved:"targetNotAddress"};if("flagKey"in e&&typeof e.flagKey!="string")return{unmoved:"flagKeyNotString"};if("value"in e&&typeof e.value!="boolean")return{unmoved:"valueNotBoolean"};let{target:n,flagKey:r,value:i,...o}=e;return n!==void 0&&(t[Tt.target]={kind:"binding",address:n}),typeof r=="string"&&r.length>0&&(t[Tt.flagKey]={kind:"literal",value:r}),i!==void 0&&(t[Tt.value]={kind:"literal",value:i}),{node:{...o,inputs:t}}}s(sG,"moveNode");function bI(e){let t=[],n=[],r=e.nodes.map(i=>{if(!wI(i))return i;let o=sG(i);return"unmoved"in o?(n.push({nodeId:String(i.id),reason:o.unmoved}),i):(t.push(String(i.id)),o.node)});return t.length===0?{graph:e,moved:t,unmoved:n}:{graph:{...e,nodes:r},moved:t,unmoved:n}}s(bI,"moveSetFlagConfigToInputs");function vI(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(vI,"isObject");var dy={countersign:{dueInDays:"number"},decision:{allowSkipInTest:"boolean"},completenessCheck:{guestRole:"string"},governedDocument:{responseDueInDays:"number"}},cy={review:["allowSkipInTest"]};function xI(e){return dy[String(e)]??{}}s(xI,"movesOf");function SI(e){return cy[String(e)]??[]}s(SI,"deadOf");function AI(e){return vI(e)&&[...Object.keys(xI(e.type)),...SI(e.type)].some(t=>t in e)}s(AI,"oldShape");function EI(e){return(e?.nodes??[]).some(AI)}s(EI,"needsScalarInputMove");function aG(e,t){return t==="number"?typeof e=="number"&&Number.isInteger(e)&&e>=1:typeof e===t}s(aG,"wellTyped");function lG(e){let t=vI(e.inputs)?{...e.inputs}:{},n={...e};for(let[r,i]of Object.entries(xI(e.type))){if(!(r in e))continue;let o=e[r];if(r in t)return{unmoved:{nodeId:String(e.id),key:r,reason:"inputExists"}};if(!(i==="string"&&o==="")&&!aG(o,i))return{unmoved:{nodeId:String(e.id),key:r,reason:"valueWrongType"}};o!==""&&(t[r]={kind:"literal",value:o}),delete n[r]}for(let r of SI(e.type))delete n[r];return n.inputs=t,{node:n}}s(lG,"moveNode");function TI(e){let t=[],n=[],r=e.nodes.map(i=>{if(!AI(i))return i;let o=lG(i);return"unmoved"in o?(n.push(o.unmoved),i):(t.push(String(i.id)),o.node)});return t.length===0?{graph:e,moved:t,unmoved:n}:{graph:{...e,nodes:r},moved:t,unmoved:n}}s(TI,"moveScalarConfigToInputs");var As={team:{label:{de:"Team",en:"Team"},optionSource:"tenantTeams",existence:{check:"generic",catalog:"teamKeys"}},roleKey:{label:{de:"Rolle",en:"Role"},optionSource:"tenantRoles",existence:{check:"node",codes:["roleAssign/unknownRoleKey","completenessCheck/unknownRole"]}},article:{label:{de:"Artikel",en:"Article"},optionSource:"programArticles",existence:{check:"node",codes:["collectPayment/unknownArticle"]}},legalEntity:{label:{de:"Tr\xE4ger",en:"Legal entity"},optionSource:"tenantTraeger",existence:{check:"node",codes:["governedDocument/unknownTraeger","collectPayment/unknownPayee"]}},contractGenerator:{label:{de:"Vertragsgenerator",en:"Contract generator"},optionSource:"tenantGenerators",existence:{check:"publish",by:"admittedGeneratorByKey"}},documentTemplate:{label:{de:"Dokumentvorlage",en:"Document template"},optionSource:"tenantDocumentTemplates",existence:{check:"publish",by:"governedDocument/unknownTemplate"}},smartForm:{label:{de:"Formular",en:"Form"},optionSource:"offerSmartForms",existence:{check:"publish",by:"form/unknownSmartForm"}},unit:{label:{de:"Einrichtung",en:"Unit"},optionSource:"tenantUnits",existence:{check:"generic",catalog:"unitKeys"}},formFlag:{label:{de:"Merkmal im Formular",en:"Flag in the form"},optionSource:"targetFormFlags",existence:{check:"node",codes:["setFlag/unknownFlag"]}}};function cf(e){return typeof e=="string"&&Object.hasOwn(As,e)}s(cf,"isResourceType");var Zae=Object.keys(As).filter(e=>As[e].existence.check==="generic");function $I(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.groupKey=="string"&&t.groupKey.length>0&&Array.isArray(t.grantKeys)&&t.grantKeys.every(n=>typeof n=="string"&&n.length>0)&&(t.reduction===void 0||go(t.reduction)===null&&t.reduction.kind==="amount")&&Object.keys(t).every(n=>n==="groupKey"||n==="grantKeys"||n==="reduction")}s($I,"isPricedGroupValue");var uy=["street","hausnr","plz","ort","land"];function RI(e){return uy.includes(e)}s(RI,"isAddressPart");var dG=["municipality","municipalityKey","district","districtKey"],fy=[...uy,...dG],py={string:"text",email:"text",tel:"text",number:"number",date:"date",boolean:"boolean",enum:"option",address:"composite",docRef:"file",party:"edge",personRef:"edge",personList:"edge",roleKey:"roleKey",pricedItem:"pricedItem",pricedGroup:"pricedGroup",reduction:"reduction",article:"article",legalEntity:"legalEntity",contractGenerator:"contractGenerator",documentTemplate:"documentTemplate",localizedText:"localizedText"},Es=Object.keys(py);function $i(e){return typeof e=="string"&&e in py}s($i,"isValueType");function bn(e){return e===void 0?void 0:py[e]}s(bn,"dataTypeOf");function uf(e,t){let n=bn(e),r=bn(t);return n!==void 0&&n===r}s(uf,"valueTypesCompatible");function ff(e){return e===null?"null is not a text in both languages":dl(e,{type:"localizedText"})}s(ff,"completeLocalizedTextIssue");function dl(e,t){if(cf(t.type)&&!$i(t.type))return typeof e=="string"&&e.length>0?null:`${JSON.stringify(e)} is not a ${t.type} key`;let n=bn(t.type),r=JSON.stringify(e),i=`slot type "${t.type}" takes a binding, not a literal`;if(n===void 0||n==="composite"||n==="file"||n==="edge")return i;if(e===null)return null;switch(n){case"text":return typeof e=="string"?null:`${r} is not a text (slot type "${t.type}")`;case"date":return typeof e=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(e)?null:`${r} is not a date YYYY-MM-DD`;case"number":return typeof e=="number"&&Number.isFinite(e)?null:`${r} is not a number`;case"boolean":return typeof e=="boolean"?null:`${r} is not true/false`;case"option":{if(typeof e!="string")return`${r} is not an option value`;let o=(t.enumOptions??[]).map(a=>a.value);return o.length===0||o.includes(e)?null:`${r} is not one of the options ${o.join(", ")}`}case"pricedItem":{let o=e;return typeof o=="object"&&typeof o.itemKey=="string"&&o.itemKey.length>0&&Array.isArray(o.grantKeys)&&o.grantKeys.every(a=>typeof a=="string")?null:`${r} is not a priced item {"itemKey":\u2026,"grantKeys":[\u2026]}`}case"pricedGroup":return $I(e)?null:`${r} is not a priced group {"groupKey":\u2026,"grantKeys":[\u2026]}`;case"article":return typeof e=="string"&&e.length>0?null:`${r} is not an article key`;case"legalEntity":return typeof e=="string"&&e.length>0?null:`${r} is not a legal entity key`;case"contractGenerator":return Za(e)?null:`${r} is not a contract generator {"kind":"generator"|"package","key":\u2026,"revision"?:n}`;case"documentTemplate":return typeof e=="string"&&e.length>0?null:`${r} is not a document template key`;case"roleKey":return typeof e=="string"&&e.length>0?null:`${r} is not a role key`;case"localizedText":{let o=e,a=s(l=>typeof l=="string"&&l.trim().length>0,"filled");return typeof o=="object"&&Object.keys(o).sort().join(",")==="de,en"&&a(o.de)&&a(o.en)?null:`${r} is not a text in both languages {"de":\u2026,"en":\u2026}`}case"reduction":{let o=go(e);return o===null?null:`${r} is not a reduction \u2014 ${o.en}`}}}s(dl,"literalTypeIssue");function II(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(II,"isObject");var cG={collectPayment:{reason:"reason"}},uG={governedDocument:["mockAutoProduce"]},OI={collectPayment:{reason:{de:"`reason` gibt es als Knoteneigenschaft nicht mehr \u2014 der Hinweis f\xFCr die Familie ist der Eingang `inputs.reason` (ein fester Text auf Deutsch und Englisch im Parameter-Bereich).",en:"`reason` no longer exists as a node property \u2014 the note for the family is the input `inputs.reason` (a fixed text in German and English among the parameters)."}},governedDocument:{template:{de:"`template` gibt es am Knoten nicht mehr \u2014 die Parameter geh\xF6ren der Vorlage (ihr Datensatz, `plexus-cli catalog` documentTemplates[].parameters) und werden beim Speichern und Ver\xF6ffentlichen als `templateStamp` \xFCbernommen.",en:"`template` no longer exists on the node \u2014 the parameters belong to the template (its record, `plexus-cli catalog` documentTemplates[].parameters) and are stamped as `templateStamp` on save and publish."},cockpitFields:{de:'`cockpitFields` gibt es nicht mehr \u2014 ein Parameter, der im Cockpit erg\xE4nzt wird, ist sein Eingang `{ kind: "cockpit" }` (im Parameter-Bereich \u201Eim Cockpit erg\xE4nzen").',en:'`cockpitFields` no longer exists \u2014 a parameter completed in the cockpit is its input `{ kind: "cockpit" }` ("complete in the cockpit" among the parameters).'},mockAutoProduce:{de:"`mockAutoProduce` gibt es nicht mehr \u2014 das Muster-Dokument, das ein Upload-Knoten beim Eintritt selbst einstellte, ist entfernt; das Dokument kommt aus einem Upload.",en:"`mockAutoProduce` no longer exists \u2014 the sample document an upload node put on its slot by itself on entry is removed; the document comes from an upload."}}};function my(e){return cG[String(e)]??{}}s(my,"movesOf");function PI(e){return uG[String(e)]??[]}s(PI,"deadOf");function _I(e){return II(e)&&[...Object.keys(my(e.type)),...PI(e.type)].some(t=>t in e)}s(_I,"oldShape");function CI(e){return(e?.nodes??[]).some(_I)}s(CI,"needsNodeConfigInputMove");function fG(e){return ff(e)===null}s(fG,"isCompleteText");function pG(e){let t=II(e.inputs)?{...e.inputs}:{},n={...e};for(let[r,i]of Object.entries(my(e.type)))if(r in e){if(i in t)return{unmoved:{nodeId:String(e.id),key:r,reason:"inputExists"}};if(!fG(e[r]))return{unmoved:{nodeId:String(e.id),key:r,reason:"valueNotLocalized"}};t[i]={kind:"literal",value:e[r]},delete n[r]}for(let r of PI(e.type))delete n[r];return Object.keys(my(e.type)).some(r=>r in e)&&(n.inputs=t),{node:n}}s(pG,"moveNode");function NI(e){let t=[],n=[],r=e.nodes.map(i=>{if(!_I(i))return i;let o=pG(i);return"unmoved"in o?(n.push(o.unmoved),i):(t.push(String(i.id)),o.node)});return t.length===0?{graph:e,moved:t,unmoved:n}:{graph:{...e,nodes:r},moved:t,unmoved:n}}s(NI,"moveNodeConfigToInputs");var hy="collectPayment",Ts=["online","separate"];function pf(e){return Ts.includes(e)}s(pf,"isCollectPaymentSettlement");var $s="paid",gy="skipPayment",Ri="article",Wn="settlement",Ii="reason",Yn="payee",yy=["one_time"];function mf(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(mf,"isObject");function DI(e){if(!mf(e)||e.type!==hy)return!1;let t=mf(e.inputs)?e.inputs:{},n=t[Wn];return!mf(n)||n.kind!=="literal"||n.value!=="online"?!1:!(Yn in t)}s(DI,"isOnlinePaymentWithoutPayee");function FI(e){return(e?.nodes??[]).some(DI)}s(FI,"needsPayee");function LI(e,t={}){let n=[],r=[],i=e.nodes.map(o=>{if(!DI(o))return o;let a=String(o.id),l=Object.hasOwn(t,a)?t[a]:void 0;if(l===void 0||l==="")return r.push(a),o;n.push({nodeId:a,payee:l});let d=mf(o.inputs)?o.inputs:{};return{...o,inputs:{...d,[Yn]:{kind:"literal",value:l}}}});return n.length===0?{graph:e,set:n,refused:r}:{graph:{...e,nodes:i},set:n,refused:r}}s(LI,"setPayeeOnOnlinePayments");function hf(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(hf,"isObject");function wy(e){return hf(e)&&hf(e.assign)&&"userId"in e.assign}s(wy,"namesUser");function gf(e){return(e?.nodes??[]).flatMap(t=>hf(t)&&Array.isArray(t.tasks)?t.tasks.filter(wy).map(n=>({nodeId:String(t.id),taskKey:String(n.key),hasTeam:typeof n.assign.group=="string"&&n.assign.group.length>0})):[])}s(gf,"taskUserAssignments");function MI(e){let t=gf(e);if(t.length===0)return{graph:e,dropped:t};let n=e.nodes.map(r=>{if(!hf(r)||!Array.isArray(r.tasks)||!r.tasks.some(wy))return r;let i=r.tasks.map(o=>{if(!wy(o))return o;let{userId:a,...l}=o.assign,{assign:d,...c}=o;return Object.keys(l).length===0?c:{...c,assign:l}});return{...r,tasks:i}});return{graph:{...e,nodes:n},dropped:t}}s(MI,"dropTaskAssignUserIds");var Rs={"assign{}":{kind:"team",codec:"key",involves:!0,required:!1,what:{de:"Team der Knoten-Aufgabe",en:"team of the node task"},consequence:{de:"beim Betreten des Knotens entsteht die Aufgabe f\xFCr niemanden",en:"entering the node creates the task for nobody"}},"tasks[].assign.group":{kind:"team",codec:"key",involves:!0,required:!0,what:{de:"Team der Aufgabe",en:"team of the task"},consequence:{de:"die Aufgabe kann nicht angelegt werden, und der Prozess bleibt stehen",en:"the task cannot be created and the process stops"}},"tasks[].params.revisionGroup":{kind:"team",codec:"key",involves:!0,required:!1,what:{de:"Team der \xDCberarbeitung",en:"revision team"},consequence:{de:"eine Ablehnung findet niemanden, der \xFCberarbeitet",en:"a rejection finds nobody to revise"}},"tasks[].result.chat":{kind:"team",codec:"chatTarget",involves:!1,required:!1,what:{de:"Chat des Ergebnisses",en:"chat of the result"},consequence:{de:"das Ergebnis l\xE4sst sich nicht im Chat ablegen",en:"the result cannot be posted to the chat"}},"optionalActions[].trigger":{kind:"team",codec:"key",involves:!1,required:!1,what:{de:"Team, das die Aktion ausl\xF6sen darf",en:"team that may trigger the action"},consequence:{de:"niemand au\xDFer der Prozessverantwortung kann die Aktion ausl\xF6sen",en:"nobody but the process owner can trigger the action"}}},ky=s(e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null,"record");function qI(e,t){if(typeof t!="string"||t.length===0)return null;if(e==="key")return t;let n=ws(t);return n?.kind==="team"?n.groupKey:null}s(qI,"decodeKey");function mG(e){let t=/^(tasks|optionalActions)\[\](?:\.([a-zA-Z]+))?\.([a-zA-Z]+)$/.exec(e);return t===null&&C(`[resource] unreadable reference leaf "${e}"`),{list:t[1],field:t[2]??null,key:t[3]}}s(mG,"locate");function yf(e){let t=[],n=e;for(let[r,i]of Object.entries(ky(n.assign)??{})){let o=qI("key",i);t.push({path:`assign.${r}`,leaf:"assign{}",owner:r,key:o,missing:typeof i!="string"||i.length===0})}for(let r of Object.keys(Rs)){if(r==="assign{}")continue;let i=Rs[r],{list:o,field:a,key:l}=mG(r);for(let d of Array.isArray(n[o])?n[o]:[]){let c=ky(d);if(c===null||typeof c.key!="string")continue;let f=(a===null?c:ky(c[a]))?.[l];if(f===void 0&&!i.required)continue;let m=typeof f!="string"||f.length===0;t.push({path:`${o}.${c.key}${a===null?"":`.${a}`}.${l}`,leaf:r,owner:c.key,key:qI(i.codec,f),missing:m})}}return t}s(yf,"nodeResourceReferences");var KI=s(e=>(e??[]).map(t=>`\u201E${t}\u201C`).join(", "),"list"),jI=s(e=>(e??[]).map(t=>`"${t}"`).join(", "),"listEn"),hG={"address/shape":{de:s(e=>({problem:`${e.where}: \u201E${e.address}\u201C ist keine g\xFCltige Adresse.`,remedy:"W\xE4hle die Adresse in der Auswahl neu."}),"de"),en:s(e=>({problem:`${e.where}: "${e.address}" is not a valid address.`,remedy:"Choose the address again from the picker."}),"en")},"address/missing":{de:s(e=>({problem:`${e.where}: Hier fehlt die Adresse, ohne die dieser Schritt nicht arbeiten kann.`,remedy:"W\xE4hle sie in der Auswahl."}),"de"),en:s(e=>({problem:`${e.where}: The address this step cannot work without is missing.`,remedy:"Choose it from the picker."}),"en")},"address/bareIdentifier":{de:s(e=>({problem:`${e.where}: \u201E${e.address}\u201C nennt nur einen Schl\xFCssel, nicht, wer ihn erzeugt.`,remedy:"W\xE4hle in der Auswahl die volle Adresse, z. B. das Feld aus dem Formular, das es erfasst."}),"de"),en:s(e=>({problem:`${e.where}: "${e.address}" names a key only, not who produces it.`,remedy:"Choose the full address from the picker, e.g. the field from the form that collects it."}),"en")},"address/unknownOwner":{de:s(e=>({problem:`${e.where}: ${e.address} nennt einen Knoten oder eine Aufgabe, die es im Ablauf nicht gibt.`,remedy:"W\xE4hle eine Adresse aus der Auswahl."}),"de"),en:s(e=>({problem:`${e.where}: ${e.address} names a node or task the workflow does not have.`,remedy:"Choose an address from the picker."}),"en")},"address/unknownKey":{de:s(e=>({problem:`${e.where}: ${e.producer??"der Erzeuger"} erzeugt ${e.address} nicht.`,remedy:"W\xE4hle einen Wert, den der Erzeuger tats\xE4chlich liefert."}),"de"),en:s(e=>({problem:`${e.where}: ${e.producer??"the producer"} does not produce ${e.address}.`,remedy:"Choose a value the producer actually delivers."}),"en")},"address/envCohortBound":{de:s(e=>({problem:`${e.where}: ${e.address} \xE4ndert sich, wenn Stufe oder Schuljahr gewechselt werden \u2014 ein Dokument, das den Wert druckt, w\xFCrde das nicht bemerken.`,remedy:"Lies den Wert \xFCber ein Formularfeld, das ihn berechnet (z. B. \u201EKlassenstufe\u201C): ein Wechsel friert es neu ein und h\xE4lt ein gedrucktes Dokument an."}),"de"),en:s(e=>({problem:`${e.where}: ${e.address} changes when the application's stage or school year is changed \u2014 a document printing it would not notice.`,remedy:'Read it through a form field that computes it (e.g. "Grade"): a change re-freezes it and holds a printed document.'}),"en")},"address/staffInputConditionOnly":{de:s(e=>({problem:`${e.where}: ${e.address} ist eine interne Angabe beim Anlegen \u2014 sie lenkt eine Weiche (\u201EWenn\u201C-Knoten) oder f\xFCllt einen Parameter eines Knotens.`,remedy:"Lies sie in der Bedingung eines \u201EWenn\u201C-Knotens oder binde einen Parameter des Knotens daran (z. B. im Vertrag); Formulare, Aufgaben und Regeln lesen sie nicht."}),"de"),en:s(e=>({problem:`${e.where}: ${e.address} is a staff input set at the start \u2014 it steers a branch (an "If" node) or fills a node's parameter.`,remedy:'Read it in the condition of an "If" node or bind a node parameter to it (e.g. in the contract); forms, tasks and rules do not read it.'}),"en")},"address/ownerNotWriter":{de:s(e=>({problem:`${e.where}: Die Aufgabe \u201E${e.producer}\u201C schreibt ${e.address} nicht.`,remedy:"W\xE4hle den Wert \xFCber seinen Schl\xFCssel; die schreibende Aufgabe folgt daraus."}),"de"),en:s(e=>({problem:`${e.where}: The task "${e.producer}" does not write ${e.address}.`,remedy:"Choose the value by its key; the writing task follows from it."}),"en")},"address/taskOwnerTaken":{de:s(e=>({problem:`${e.where}: Den Aufgaben-Schl\xFCssel gibt es mehrfach (${KI(e.names)}), und eine dieser Aufgaben schreibt Prozesswerte.`,remedy:"Gib der schreibenden Aufgabe einen Schl\xFCssel, den keine andere Aufgabe tr\xE4gt."}),"de"),en:s(e=>({problem:`${e.where}: The task key is used more than once (${jI(e.names)}), and one of these tasks writes process values.`,remedy:"Give the writing task a key no other task carries."}),"en")},"address/notVisible":{de:s(e=>({problem:e.producerNode!==void 0&&e.producerNode!==e.producer?`${e.where}: ${e.address} \u2014 \u201E${e.producer}\u201C h\xE4ngt an \u201E${e.producerNode}\u201C, das nicht auf jedem Weg vor \u201E${e.reader}\u201C liegt.`:`${e.where}: ${e.address} \u2014 \u201E${e.producer}\u201C liegt nicht auf jedem Weg vor \u201E${e.reader}\u201C.`,remedy:`Lies nur, was auf jedem Weg vor \u201E${e.reader}\u201C entsteht, oder ordne die Schritte so, dass der Erzeuger immer vorher l\xE4uft.`}),"de"),en:s(e=>({problem:e.producerNode!==void 0&&e.producerNode!==e.producer?`${e.where}: ${e.address} \u2014 "${e.producer}" hangs on "${e.producerNode}", which does not lie before "${e.reader}" on every path.`:`${e.where}: ${e.address} \u2014 "${e.producer}" does not lie before "${e.reader}" on every path.`,remedy:`Read only what is produced before "${e.reader}" on every path, or order the steps so the producer always runs first.`}),"en")},"address/pathNotInTarget":{de:s(e=>({problem:`${e.where}: ${e.address} \u2014 ${e.producer??"der Erzeuger"} hat dieses Feld nicht.`,remedy:"W\xE4hle ein Feld, das es dort gibt."}),"de"),en:s(e=>({problem:`${e.where}: ${e.address} \u2014 ${e.producer??"the producer"} has no such field.`,remedy:"Choose a field that exists there."}),"en")},"address/typeMismatch":{de:s(e=>({problem:`${e.where}: erwartet ${e.expected}, ${e.address} ist ${e.actual}.`,remedy:`W\xE4hle einen Wert vom Typ ${e.expected}.`}),"de"),en:s(e=>({problem:`${e.where}: expects ${e.expected}, ${e.address} is ${e.actual}.`,remedy:`Choose a value of type ${e.expected}.`}),"en")},"address/notFormInstance":{de:s(e=>({problem:`${e.where}: ${e.address} ist kein ganzes Formular.`,remedy:"W\xE4hle das Formular des Knotens, der es anlegt \u2014 ohne Feld, nicht den Knoten, der es \xFCbernimmt."}),"de"),en:s(e=>({problem:`${e.where}: ${e.address} is not a whole form.`,remedy:"Choose the form of the node that creates it \u2014 without a field, not the node that continues it."}),"en")},"address/mixedForms":{de:s(e=>({problem:`${e.where}: Die Liste liest Felder aus mehreren Formularen (${KI(e.names)}), beurteilt wird sie aber an einem Formular.`,remedy:"W\xE4hle alle Felder dieser Liste aus demselben Formular."}),"de"),en:s(e=>({problem:`${e.where}: The list reads fields of several forms (${jI(e.names)}) but is judged on one.`,remedy:"Choose every field of this list from the same form."}),"en")},"workItems/keyFormat":{de:s(e=>({problem:`${e.where}: Der Aufgaben-Schl\xFCssel \u201E${e.address}\u201C hat nicht die Form ^[a-z][a-zA-Z0-9_]*$.`,remedy:"Benenne die Aufgabe in camelCase um, z. B. \u201EgeschwisterRang\u201C."}),"de"),en:s(e=>({problem:`${e.where}: The task key "${e.address}" does not match ^[a-z][a-zA-Z0-9_]*$.`,remedy:'Rename the task in camelCase, e.g. "siblingRank".'}),"en")}};function Is(e,t,n){let{problem:r,remedy:i}=hG[e][n](t);return`[${e}] ${r} ${i}`}s(Is,"addressMessage");function Pn(e){let t=[];for(let n of e){let r=n.next;if(r)for(let[i,o]of Object.entries(r))t.push({id:`${n.id}|${i}`,source:n.id,target:o.to,sourceBranchId:i})}return t}s(Pn,"derivedEdges");function wf(e,t,n){if(t===n)return!0;let r=new Map,i=new Set;for(let l of Pn(e.nodes)){let d=r.get(l.source)??[];d.push(l.target),r.set(l.source,d),i.add(l.target)}let o=e.nodes.filter(l=>!i.has(l.id)&&l.id!==t).map(l=>l.id),a=new Set(o);for(;o.length>0;){let l=o.shift();if(l===n)return!1;for(let d of r.get(l)??[])d===t||a.has(d)||(a.add(d),o.push(d))}return!0}s(wf,"dominates");function BI(e,t,n){if(t===n)return!0;let r=new Map;for(let a of Pn(e.nodes)){let l=r.get(a.source)??[];l.push(a.target),r.set(a.source,l)}let i=[t],o=new Set(i);for(;i.length>0;){let a=i.shift();for(let l of r.get(a)??[]){if(l===n)return!0;o.has(l)||(o.add(l),i.push(l))}}return!1}s(BI,"reaches");function by(e,t){let n=[],r=s(a=>({address:a.address,type:a.type,...a.label!==void 0?{label:a.label}:{},nodeId:a.nodeId}),"toVisible");for(let a of e.nodes)if(wf(e,a.id,t))for(let l of Or(e,a))n.push(r(l));for(let a of rI)n.push({address:{scope:"env",key:a},type:ny(a),label:ry(a),nodeId:null});for(let a of Wu(e))n.push({address:{scope:"env",key:Yu(a.key)},type:a.type,label:a.label,nodeId:null});let i=new Set(n.map(a=>se(a.address))),o=(Array.isArray(e.processStore)?e.processStore:[]).filter(a=>a.derive!==void 0);for(let a=!0;a;){a=!1;for(let l of o){let d=se({scope:"derived",key:l.key});if(i.has(d))continue;let c=il(e,l.key);c===null||!c.every(u=>i.has(se(sf(u))))||(n.push({address:{scope:"derived",key:l.key},type:l.type,label:l.label,nodeId:null}),i.add(d),a=!0)}}return n}s(by,"visibleAddressesAt");function _r(e,t){let n=e?.readinessFormFieldsByFormNode?.get(t.owner);if(n!==void 0)return n.get(t.path)??null}s(_r,"formFieldEntryOf");var UI={binding:{de:"Eingang",en:"Input"},condition:{de:"Bedingung",en:"Condition"},nodeReads:{de:"Gelesene Felder",en:"Fields read"},requires:{de:"Geforderte Felder",en:"Required fields"},adoptForm:{de:"\xDCbernommenes Formular",en:"Continued form"},setFlagTarget:{de:"Freizuschaltendes Formular",en:"Form to unlock"},form:{de:"Formular",en:"Form"},contract:{de:"Vertrag",en:"Contract"},payment:{de:"Zahlung",en:"Payment"},taskWhen:{de:"Bedingung",en:"Condition"},taskReads:{de:"Gelesene Felder der Aufgabe",en:"Fields the task reads"},taskDocument:{de:"Dokumente",en:"Documents"},familyRequestFields:{de:"Nachforderbare Felder",en:"Requestable fields"},familyRequestFrom:{de:"Nachforderung aus",en:"Request from"},suggest:{de:"Vorschlag",en:"Suggestion"},reduction:{de:"Erm\xE4\xDFigung des Preises",en:"Reduction of the price"},pricingRule:{de:"Preisregel",en:"Pricing rule"}},gG=new Set(["nodeReads","requires","taskReads","taskDocument","familyRequestFields"]);function yG(e,t,n){let r=[];t.taskKey!==void 0&&r.push(`${n==="de"?"Aufgabe":"task"} \u201E${bo(e,t.taskKey,n)}\u201C`);let i=t.kind==="binding"?` \u201E${t.at.split(".").pop()}\u201C`:"";return r.push(`${UI[t.kind][n]}${i}`),r.join(" \u203A ")}s(yG,"addressFieldWhere");function cl(e,t,n){let r=yG(e,t,n);return t.nodeId===null?r:`\u201E${Oe(e,t.nodeId,n)}\u201C \u203A ${r}`}s(cl,"whereOf");function VI(e,t,n){if(t.scope==="node")return Oe(e,t.owner,n);if(t.scope==="task")return bo(e,t.owner,n)}s(VI,"producerName");function GI(e,t){let n=[],r=new Set,i=s((l,d,c)=>{let u={de:Is(l,c("de"),"de"),en:Is(l,c("en"),"en")},f=`${d}|${u.de}`;r.has(f)||(r.add(f),n.push({layer:"GRAPH",kind:"nodeRule",path:d,reason:u,severity:"error"}))},"report"),o=new Map(e.nodes.map(l=>[l.id,l])),a=[...e.nodes.flatMap(l=>sl(l)),...af(e)];for(let l of a){let d=s(c=>cl(e,l,c),"where");for(let c of wG(e,l,i))bG(e,l,c,i)&&(xG(e,l,c,t,i),oy.has(l.kind)&&!AG(o,c)&&i("address/notFormInstance",l.at,u=>({where:d(u),address:Be(e,c,u)})))}return EG(e,i),TG(e,a,i),OG(e,i),_G(e,i),n}s(GI,"checkAddresses");function wG(e,t,n){let r=s(i=>cl(e,t,i),"where");if(sy(t)){let i=lf(t.value)??[];for(let o of i)o.address===null&&n(o.reason==="bareIdentifier"?"address/bareIdentifier":"address/shape",t.at,a=>({where:r(a),address:o.identifier}));return Ss(t)}return typeof t.value=="string"?(n("address/bareIdentifier",t.at,i=>({where:r(i),address:t.value})),[]):be(t.value)?[t.value]:(n("address/shape",t.at,i=>({where:r(i),address:JSON.stringify(t.value)??"undefined"})),[])}s(wG,"checkFieldShape");function zI(e,t,n,r){let i=VI(e,n,r);return{where:cl(e,t,r),address:Be(e,n,r),...i!==void 0?{producer:i}:{}}}s(zI,"addressParams");function kG(e,t,n){return ty(t)?null:Qa(e,t)!==void 0?n==="condition"||n==="binding"?null:"address/staffInputConditionOnly":lr(t)?"address/envCohortBound":"address/unknownKey"}s(kG,"envAddressRefusal");function bG(e,t,n,r){let i=s(o=>zI(e,t,n,o),"params");switch(n.scope){case"env":{let o=kG(e,n.key,t.kind);return o===null?!0:(r(o,t.at,i),!1)}case"derived":return(e.processStore??[]).find(a=>a.key===n.key)?.derive!==void 0?!0:(r("address/unknownKey",t.at,i),!1);case"task":return e.nodes.some(a=>(a.tasks??[]).some(l=>l.key===n.owner))?(e.processStore??[]).some(a=>a.key===n.key&&a.derive===void 0)?Pr(e,n.owner,n.key)===null?(r("address/ownerNotWriter",t.at,i),!1):!0:(r("address/unknownKey",t.at,i),!1):(r("address/unknownOwner",t.at,i),!1);case"node":{let o=e.nodes.find(a=>a.id===n.owner);return o===void 0?(r("address/unknownOwner",t.at,i),!1):Or(e,o).some(a=>a.address.scope==="node"&&a.address.key===n.key)?!0:(r(oy.has(t.kind)&&kn(o)?"address/notFormInstance":"address/unknownKey",t.at,i),!1)}}}s(bG,"resolves");function vG(e,t){return e===void 0||t===void 0||bn(t)===void 0?!0:bn(e)!==void 0&&uf(e,t)}s(vG,"addressTypeFits");function xG(e,t,n,r,i){let o=s(l=>zI(e,t,n,l),"params");if(n.scope!=="env"&&n.path!==void 0&&!SG(e,t,n,r)){i("address/pathNotInTarget",t.at,o);return}if(t.expectedType===void 0)return;let a=ly(e,n);vG(a,t.expectedType)||i("address/typeMismatch",t.at,l=>({...o(l),expected:t.expectedType,actual:a}))}s(xG,"checkPathAndType");function SG(e,t,n,r){if(n.scope!=="node")return!1;if(ly(e,n)!==void 0)return!0;if(n.key!==tn)return!1;if(!gG.has(t.kind))return e.nodes.find(o=>o.id===n.owner)?.formExports===void 0;let i=r?.readinessFormFieldsByFormNode?.get(n.owner);return i===void 0||i.has(n.path)}s(SG,"pathExists");function AG(e,t){if(!bs(t))return!1;let n=e.get(t.owner);return n!==void 0&&n.type==="form"&&!kn(n)}s(AG,"isCreatingFormInstance");function EG(e,t){for(let n of e.nodes){let r=new Set(sl(n).map(i=>i.kind));for(let i of aI(n))r.has(i)||t("address/missing",`nodes.${n.id}.${i}`,o=>({where:`\u201E${Oe(e,n.id,o)}\u201C \u203A ${UI[i][o]}`}))}}s(EG,"checkRequiredFields");function TG(e,t,n){let r=new Map;for(let i of t)if(i.judgedTogether!==null)for(let o of Ss(i)){if(o.scope!=="node"||o.key!==tn)continue;let a=r.get(i.judgedTogether)??[];a.push({field:i,owner:o.owner}),r.set(i.judgedTogether,a)}for(let[i,o]of r){let a=[...new Set(o.map(l=>l.owner))];a.length<2||n("address/mixedForms",i,l=>({where:cl(e,o[0].field,l),names:a.map(d=>Oe(e,d,l))}))}}s(TG,"checkMixedForms");function $G(e,t){return e.type==="engagePush"&&t.kind==="payment"}s($G,"readSkipsAbsentProducer");function RG(e,t,n){return t!==n&&BI(e,t,n)}s(RG,"precedesOnSomePath");function IG(e,t,n,r){let i=sf(n.address);return r.has(se(i))||!PG(e,i)?!0:n.origin==="written"&&i.scope==="node"&&$G(t,n.field)&&RG(e,i.owner,t.id)}s(IG,"readPassesVisibility");function OG(e,t){for(let n of e.nodes){let r=ko(e,n);if(r.length===0)continue;let i=new Set(by(e,n.id).map(o=>se(o.address)));for(let o of r){let a=sf(o.address);if(IG(e,n,o,i))continue;let l=a.scope==="task"?Pr(e,a.owner,a.key):a.scope==="node"?a.owner:null;t("address/notVisible",o.field.at,d=>({where:cl(e,o.field,d),address:Be(e,o.address,d),producer:VI(e,a,d)??Be(e,a,d),...l!==null?{producerNode:Oe(e,l,d)}:{},reader:Oe(e,n.id,d)}))}}}s(OG,"checkVisibility");function PG(e,t){if(t.scope==="env")return ty(t.key);if(t.scope==="derived")return il(e,t.key)!==null;let n=se(t);return e.nodes.some(r=>Or(e,r).some(i=>se(i.address)===n))}s(PG,"producedSomewhere");function _G(e,t){let n=new Map;for(let r of e.nodes){let i=new Set(Or(e,r).flatMap(o=>o.address.scope==="task"?[o.address.owner]:[]));for(let[o,a]of(r.tasks??[]).entries()){let l=a.key;if(typeof l!="string"||!Rr.test(l)){t("workItems/keyFormat",`nodes.${r.id}.tasks.${o}.key`,c=>({where:`\u201E${Oe(e,r.id,c)}\u201C`,address:String(l)}));continue}let d=n.get(l)??[];d.push({nodeId:r.id,writes:i.has(l)}),n.set(l,d)}}for(let[r,i]of n)if(!(i.length<2||!i.some(o=>o.writes)))for(let o of i)t("address/taskOwnerTaken",`nodes.${o.nodeId}.tasks.${r}`,a=>({where:`\u201E${Oe(e,o.nodeId,a)}\u201C \u203A ${a==="de"?"Aufgabe":"task"} \u201E${bo(e,r,a)}\u201C`,names:i.map(l=>Oe(e,l.nodeId,a))}))}s(_G,"checkTaskKeys");function kf(e,t){return e.label[t]??""}s(kf,"wordingIn");function Oi(e,t){let n=WI(e,t),r=kf(e.qualifier,t);return n===""||r===""&&kf(e.qualifier,"de")!==""?"":r===""?n:`${r} \xB7 ${n}`}s(Oi,"fieldLabelIn");function WI(e,t){return kf(e,t)}s(WI,"fieldOwnLabelIn");function Pi(e){return{key:e.key,kind:e.kind,type:e.kind==="entered"?e.type:null,repeated:e.kind==="entered"&&e.repeated,name:{de:Oi(e,"de"),en:Oi(e,"en")}}}s(Pi,"catalogField");function _i(e,t,n){switch(e){case"nodeReads":return t.repeated?"repeated":n==="review"&&t.kind==="computed"?"computed":null;case"requires":return t.repeated?"repeated":t.kind==="computed"?"computed":t.name.en===""?"untranslated":null;case"taskDocument":return t.repeated?"repeated":t.kind==="entered"&&t.type==="docRef"?null:"notDocument";case"taskReads":case"familyRequestFields":return null}}s(_i,"catalogFieldRefusal");function bf(e,t){let n=e.buses.find(r=>r.key===t);return n||C(`[progress] layout '${e.id}' has no bus '${t}'`),n}s(bf,"progressBus");function ul(e,t){return e.states.some(n=>n.id===t)}s(ul,"isBusState");function YI(e,t){let n=e.terminalSemantics?.[t];return n||C(`[progress] no terminal semantics for state '${t}' on bus '${e.key}'`),n}s(YI,"terminalSemantics");function vf(e,t){return!!e.terminalSemantics&&Object.prototype.hasOwnProperty.call(e.terminalSemantics,t)}s(vf,"hasTerminalSemantics");function CG(e,t){return(e.boards??[]).find(n=>n.audience===t||n.audience==="both")??null}s(CG,"boardForAudience");function HI(e){return CG(bf(e,"process"),"internal")}s(HI,"internalProcessBoard");function Os(e,t,n){let r=null;for(let i of e.mappings)if(i.event===n)if("nodeId"in i.match){if(i.match.nodeId===t.id)return{bus:i.bus,state:i.state}}else i.match.nodeType===t.type&&(r=i);return r?{bus:r.bus,state:r.state}:null}s(Os,"resolveProgressEvent");var Ps={approved:"enrolled",rejected:"declined",withdrawn:"declined",expired:"declined"},Xr=Object.keys(Ps);function vo(e){return Object.hasOwn(Ps,e)}s(vo,"isEndNodeOutcome");var vy={approved:{de:"Angenommen",en:"Admitted"},rejected:{de:"Abgelehnt",en:"Rejected"},withdrawn:{de:"Zur\xFCckgezogen",en:"Withdrawn"},expired:{de:"Abgelaufen",en:"Expired"}};var Ci=["commit","discard"],Hle=w.union(...Ci.map(e=>w.literal(e)));function xf(e){return typeof e=="string"&&Ci.includes(e)}s(xf,"isApplicationDataDecision");function _t(e){return Object.keys(e)}s(_t,"progressEventsOf");var ne=s((e,t)=>({de:e,en:t}),"lt"),Ze=s((e,t,n,r,i=null,o=null)=>({chipLabel:e,tone:t,nextAction:i,affordance:o,title:n,body:r}),"ex"),JI={key:"eingeschrieben",label:ne("Eingeschrieben","Enrolled"),scope:"global",defaultCollapsed:!0},Sf={key:"abgesagt",label:ne("Abgesagt","Declined"),scope:"global",track:"exit",defaultCollapsed:!0},QI={key:"abgelehnt",label:ne("Abgelehnt","Rejected"),scope:"global",track:"exit",defaultCollapsed:!0};var ZI={enrolled:{label:ne("Eingeschrieben","Enrolled"),tone:"green",terminal:{lifecycleStatus:"completed",outcome:"approved"},phase:JI,external:Ze(ne("Eingeschrieben","Enrolled"),"green",ne("Sie sind eingeschrieben!","You are enrolled!"),ne("Ihre Anmeldung ist abgeschlossen und Ihr Platz ist gesichert. Wir freuen uns auf Sie.","Your enrolment is complete and your place is secured. We look forward to welcoming you."))},declined:{label:ne("Abgesagt","Declined"),tone:"red",terminal:{lifecycleStatus:"completed",outcome:"rejected"},phase:Sf,external:Ze(ne("Abgesagt","Declined"),"red",ne("Die Bewerbung wurde beendet","The application has ended"),ne("Ihre Bewerbung wurde nicht fortgef\xFChrt.","Your application was not continued."))}},XI={role:"effect",effect:"pure",progressDefaults:ZI,progressEvents:_t(ZI),inputs:s(()=>[{id:"applicationOutcome",label:{de:"Ergebnis",en:"Outcome"},type:"enum",required:!0,inspector:"literal-only",optionSource:"declared",enumOptions:Xr.map(e=>({value:e,label:vy[e]}))},{id:"dataDecision",label:{de:"Erfasste Daten",en:"Captured data"},type:"enum",required:!0,inspector:"literal-only",optionSource:"declared",enumOptions:[{value:"commit",label:{de:"\xDCbernehmen",en:"Keep"}},{value:"discard",label:{de:"Verwerfen",en:"Discard"}}]}],"inputs"),notificationEvents:s(()=>[{id:"reached",label:{de:"Verfahren abgeschlossen",en:"Process completed"},audience:"external",args:[{key:"applicationId",type:"string",required:!0},{key:"outcome",type:"string",required:!0}]}],"notificationEvents"),validate:s(e=>[...NG(e),...DG(e),...FG(e)],"validate")},_s=s((e,t,n,r)=>({layer:"GRAPH",kind:"nodeRule",path:`node.${e.id}.inputs.${t}`,reason:{de:n,en:r},severity:"error"}),"nodeIssue");function xy(e){let t=e.inputs?.applicationOutcome;return t?.kind==="literal"&&t.value!=null?String(t.value):null}s(xy,"literalOutcome");function NG(e){if(e.type!=="end")return[];let t=e.inputs?.applicationOutcome;if(t===void 0||t.kind==="unset")return[];let n=xy(e);return n===null?[_s(e,"applicationOutcome",`[end/applicationOutcome] ${e.label.de}: das Ergebnis ist kein fester Wert \u2014 die Engine kann den Abschluss nicht ableiten`,`[end/applicationOutcome] ${e.label.en}: the application outcome is no fixed value \u2014 the engine cannot derive the terminal`)]:vo(n)?[]:[_s(e,"applicationOutcome",`[end/applicationOutcome] ${e.label.de}: '${n}' ist kein Ausgang eines Endknotens (${Xr.join("|")}) \u2014 die Warteliste endet \xFCber das closed-Outcome ihres Wartelistenknotens`,`[end/applicationOutcome] ${e.label.en}: '${n}' is not an outcome of an end node (${Xr.join("|")}) \u2014 the waitlist ends through the closed outcome of its waitlist node`)]}s(NG,"checkEndApplicationOutcome");function DG(e){if(e.type!=="end")return[];let t=e.inputs?.dataDecision;return!t||t.kind!=="literal"||t.value==null?[_s(e,"dataDecision",`[end/dataDecision] ${e.label.de}: dataDecision fehlt \u2014 der Endknoten muss festlegen, ob die erfassten Daten \xFCbernommen (commit) oder verworfen (discard) werden`,`[end/dataDecision] ${e.label.en}: dataDecision is missing \u2014 the end node must decide whether the collected data is kept (commit) or discarded (discard)`)]:xf(t.value)?[]:[_s(e,"dataDecision",`[end/dataDecision] ${e.label.de}: dataDecision '${String(t.value)}' ist ung\xFCltig (${Ci.join("|")})`,`[end/dataDecision] ${e.label.en}: dataDecision '${String(t.value)}' is invalid (${Ci.join("|")})`)]}s(DG,"checkEndDataDecision");function FG(e){if(e.type!=="end")return[];let t=xy(e);if(t===null||!vo(t)||t==="approved")return[];let n=e.inputs?.dataDecision;if(n?.kind!=="literal"||n.value!=="commit")return[];let r=vy[t];return[{..._s(e,"dataDecision",`[end/commitWithoutApproval] ${e.label.de}: Ende ohne Zusage \xFCbernimmt die erfassten Daten (commit) \u2014 Personen und Beziehungen bleiben nach dem Ergebnis \u201E${r.de}" bestehen. Gewollt? Sonst discard.`,`[end/commitWithoutApproval] ${e.label.en}: end without admission keeps the captured data (commit) \u2014 persons and relationships remain after the outcome "${r.en}". Intended? Otherwise discard.`),severity:"warning"}]}s(FG,"checkEndCommitWithoutApproval");function eO(e,t){if(!t?.layout||!t.wiring)return[];let n=[];for(let r of e.nodes){if(r.type!=="end")continue;let i=xy(r);if(i===null||!vo(i))continue;let o=Ps[i],a=Os(t.wiring,r,o);if(a===null)continue;let l=t.layout.buses.find(c=>c.key===a.bus);if(l===void 0||!vf(l,a.state))continue;let d=YI(l,a.state).outcome;d!==i&&n.push(_s(r,"applicationOutcome",`[end/outcomeMismatch] ${r.label.de}: das Ergebnis \u201E${i}" passt nicht zum Endzustand \u201E${a.state}" (Bus ${a.bus}), der \u201E${String(d)}" besiegelt \u2014 Ergebnis oder Verdrahtung angleichen.`,`[end/outcomeMismatch] ${r.label.en}: the outcome "${i}" does not match the final state "${a.state}" (bus ${a.bus}), which seals "${String(d)}" \u2014 align the outcome or the wiring.`))}return n}s(eO,"checkEndOutcomeMatchesTerminal");function Cs(e){let t=He(e);return typeof t.inputs=="function"?t.inputs(e):[]}s(Cs,"inputSlots");function LG(e,t){return Cs(e).find(n=>n.id===t)}s(LG,"findInputSlot");function MG(e,t){let n=LG(e,t);if(!n)return{source:"missing",spec:{id:t,label:{de:t,en:t},type:"string"},unknownSlot:!0};let r=e.inputs?.[t]??{kind:"unset"};return r.kind==="binding"&&be(r.address)?{source:"binding",spec:n,address:r.address}:r.kind==="literal"?{source:"literal",spec:n,value:r.value}:r.kind==="cockpit"&&n.deferrable===!0?{source:"cockpit",spec:n}:n.defaultValue!==void 0?{source:"default",spec:n,value:n.defaultValue}:n.required?{source:"missing",spec:n}:{source:"optional",spec:n}}s(MG,"resolveInput");function tO(e){return Cs(e).filter(t=>MG(e,t.id).source==="missing")}s(tO,"missingRequiredInputs");var qG=["personRef","formRef","documentRef","docRef"];function KG(e){let t=He(e);return typeof t.inputs!="function"?[]:t.inputs(e).map(n=>({id:n.id,type:n.type}))}s(KG,"listInputs");function nO(e){let t=[];for(let n of e.nodes)for(let r of KG(n))!qG.includes(r.type)||n.inputs?.[r.id]?.kind!=="literal"||t.push({layer:"GRAPH",kind:"modelError",path:`node.${n.id}.param.${r.id}`,reason:{de:`${n.label.de}: Literal f\xFCr referenztypisierten Slot "${r.id}" ist verboten \u2014 der Slot wird an eine Adresse gebunden`,en:`${n.label.en}: A literal for the reference-typed slot "${r.id}" is not allowed \u2014 the slot is bound to an address`},severity:"error"});return t}s(nO,"findParamValueRefSlotErrors");function rO(e){let t=[];for(let n of e.nodes){let r=He(n);if(typeof r.inputs=="function")for(let i of r.inputs(n)){let o=n.inputs?.[i.id];if(o?.kind==="cockpit"&&i.deferrable!==!0){t.push({layer:"GRAPH",kind:"modelError",path:`nodes.${n.id}.inputs.${i.id}`,reason:{de:`[inputs/notDeferrable] ${n.label.de}: Parameter \u201E${i.label.de}\u201C l\xE4sst sich nicht im Cockpit erg\xE4nzen \u2014 nur Parameter eines Generators oder einer Vorlage.`,en:`[inputs/notDeferrable] ${n.label.en}: Parameter "${i.label.en}" cannot be completed in the cockpit \u2014 only parameters of a generator or a template can.`},severity:"error"});continue}(i.inspector==="literal-only"&&o?.kind==="binding"||i.inspector==="binding-only"&&o?.kind==="literal")&&t.push({layer:"GRAPH",kind:"modelError",path:`nodes.${n.id}.inputs.${i.id}`,reason:i.inspector==="literal-only"?{de:`[inputs/inspectorKind] ${n.label.de}: Parameter \u201E${i.label.de}\u201C ist ein fester Wert \u2014 eine Bindung an eine Adresse ist hier nicht m\xF6glich.`,en:`[inputs/inspectorKind] ${n.label.en}: Parameter "${i.label.en}" is a fixed value \u2014 it cannot be bound to an address.`}:{de:`[inputs/inspectorKind] ${n.label.de}: Parameter \u201E${i.label.de}\u201C wird an eine Adresse gebunden \u2014 ein fester Wert ist hier nicht m\xF6glich.`,en:`[inputs/inspectorKind] ${n.label.en}: Parameter "${i.label.en}" is bound to an address \u2014 a fixed value is not possible here.`},severity:"error"})}}return t}s(rO,"findInspectorKindErrors");function iO(e){let t=[];for(let n of e.nodes)for(let r of tO(n))t.push({layer:"GRAPH",kind:"contractGap",path:`node.${n.id}.input.${r.id}`,reason:{de:`${n.label.de}: Pflicht-Slot "${r.label.de}" nicht gesetzt`,en:`${n.label.en}: Required slot "${r.label.en}" is not set`},severity:"error"});return t}s(iO,"findMissingRequiredInputs");function Af(e){let t=e.processStore;return t===void 0?[]:(Array.isArray(t)||C("graph.processStore must be an array \u2014 the graph validator refuses anything else"),t)}s(Af,"processStoreKeys");function sO(e){let t=[];for(let n of e.tasks??[]){let r=n.result;if(!(r===void 0||!ys(r)))for(let i of nf(r))t.push({key:i.key,nodeId:e.id,taskKey:n.key,template:n,result:r,valueType:i.valueType,...i.field!==void 0?{fieldKey:i.field.key}:{}})}return t}s(sO,"storeWritersOn");function aO(e){let t=new Map;for(let n of e.nodes)for(let r of sO(n)){let i=t.get(r.key)??[];i.push(r),t.set(r.key,i)}return t}s(aO,"processStoreWriters");function jG(e,t,n){for(let r of e.nodes){let i=sO(r).find(o=>o.taskKey===t&&o.key===n);if(i!==void 0)return i}return null}s(jG,"writerAt");function oO(e,t,n){(t.scope!=="task"||t.path!==void 0)&&C(`[process] ${n}: ${se(t)} is no task value`);let r=jG(e,t.owner,t.key);return r===null&&C(`[address/ownerNotWriter] ${n}: task "${t.owner}" writes no "${t.key}" \u2014 publish refuses that`),{key:t.key,nodeId:r.nodeId,taskKey:r.taskKey,...r.fieldKey!==void 0?{fieldKey:r.fieldKey}:{}}}s(oO,"sourceOfAddress");function Sy(e,t){(t.scope!=="task"&&t.scope!=="derived"||t.path!==void 0)&&C(`[process] ${se(t)} is no store address`);let n=Af(e).find(o=>o.key===t.key);n===void 0&&C(`[address/unknownKey] ${se(t)}: "${t.key}" is not declared in processStore`);let r={key:n.key,type:n.type,label:n.label,audience:n.audience};if(t.scope==="task")return Qg(n)&&C(`[address/unknownKey] ${se(t)}: "${t.key}" is a derived price \u2014 read it as $derived`),{...r,sources:[oO(e,t,se(t))]};Qg(n)||C(`[address/unknownKey] ${se(t)}: "${t.key}" is a written value \u2014 read it as $task`);let i=Zg(e,n.derive).map(o=>oO(e,o.address,se(t)));return{...r,sources:i,derive:n.derive}}s(Sy,"processLeafOf");var Ay=new Set(["enum","pricedItem","number","boolean","reduction"]),Ey=new Set(["pricedItem","pricedGroup"]),Ty=new Set(["number","boolean","enum"]),De={invalidKey:"[process/invalidKey]",unknownKey:"[process/unknownKey]",secondWriter:"[process/secondWriter]",noWriter:"[process/noWriter]",writerTypeMismatch:"[process/writerTypeMismatch]",pricedItemWritesNothing:"[process/pricedItemWritesNothing]",ruleSet:"[process/ruleSet]",ruleCondition:"[process/ruleCondition]",ruleSource:"[process/ruleSource]",ruleReadsAbsent:"[process/ruleReadsAbsent]",absentValue:"[process/absentValue]",derive:"[process/derive]",derivedHasWriter:"[process/derivedHasWriter]",ruleGrantUnknown:"[process/ruleGrantUnknown]",ruleGrantUnused:"[process/ruleGrantUnused]",derivePriceUnknown:"[process/derivePriceUnknown]",derivePriceNotInProgram:"[process/derivePriceNotInProgram]",derivePriceOfferWithoutProgram:"[process/derivePriceOfferWithoutProgram]",deriveStageUnknown:"[process/deriveStageUnknown]",deriveStageUncovered:"[process/deriveStageUncovered]",reductionPrices:"[process/reductionPrices]",internalInDocument:"[process/internalInDocument]",writerMustBlock:"[process/writerMustBlock]",absentWithoutDefault:"[process/absentWithoutDefault]",defaultItemMismatch:"[process/defaultItemMismatch]"};function Fe(e,t,n,r){return{layer:"GRAPH",kind:"contractGap",path:e,reason:{de:`${t} ${n}`,en:`${t} ${r}`},severity:"error"}}s(Fe,"err");function lO(e,t={}){let n=[],r=Af(e),i=new Map(r.map(d=>[d.key,d])),o=new Set;for(let[d,c]of r.entries()){let u=`processStore[${d}]`;if(typeof c.key!="string"||!/^[a-z][a-zA-Z0-9_]*$/.test(c.key)){n.push(Fe(u,De.invalidKey,`Vorgangs-Schl\xFCssel ${JSON.stringify(c.key)} \u2014 erlaubt sind Buchstaben, Ziffern und _, beginnend mit einem Kleinbuchstaben.`,`Process key ${JSON.stringify(c.key)} \u2014 letters, digits and _ are allowed, starting with a lowercase letter.`));continue}o.has(c.key)&&n.push(Fe(u,De.invalidKey,`Vorgangs-Schl\xFCssel "${c.key}" ist doppelt deklariert.`,`Process key "${c.key}" is declared twice.`)),o.add(c.key),(c.derive!==void 0?!Ey.has(c.type):!Ay.has(c.type))&&n.push(c.derive!==void 0?Fe(u,De.derive,`Vorgangs-Schl\xFCssel "${c.key}" ist abgeleitet, hat aber den Typ "${c.type}" \u2014 abgeleitet wird nur ein Preis: ${[...Ey].join(", ")}.`,`Process key "${c.key}" is derived but has the type "${c.type}" \u2014 only a price can be derived: ${[...Ey].join(", ")}.`):Fe(u,De.invalidKey,`Vorgangs-Schl\xFCssel "${c.key}" hat den Typ "${c.type}" \u2014 der Vorgang speichert nur Ergebnisse mit Wert: ${[...Ay].join(", ")}${c.type==="pricedGroup"?" (ein Paket wird abgeleitet: derive)":""}.`,`Process key "${c.key}" has the type "${c.type}" \u2014 the process only stores results with a value: ${[...Ay].join(", ")}${c.type==="pricedGroup"?" (a package is derived: derive)":""}.`)),(!c.label?.de?.trim()||!c.label?.en?.trim())&&n.push(Fe(u,De.invalidKey,`Vorgangs-Schl\xFCssel "${c.key}" braucht ein Label in beiden Sprachen.`,`Process key "${c.key}" needs a label in both languages.`)),c.audience!=="internal"&&c.audience!=="printable"&&n.push(Fe(u,De.invalidKey,`Vorgangs-Schl\xFCssel "${c.key}": audience muss 'internal' oder 'printable' sein.`,`Process key "${c.key}": audience must be 'internal' or 'printable'.`))}let a=aO(e);for(let d of e.nodes)for(let c of d.tasks??[]){let u=c.result;u?.kind==="pricedItem"&&u.writes===void 0&&n.push(Fe(`node.${d.id}.tasks.${c.key}.result.writes`,De.pricedItemWritesNothing,`Aufgabe "${c.key}" (Knoten "${d.id}") bepreist einen Artikel, schreibt das Ergebnis aber in keinen Vorgangs-Schl\xFCssel ('result.writes') \u2014 niemand k\xF6nnte den Preis lesen.`,`Task "${c.key}" (node "${d.id}") prices an article but writes the result to no process key ('result.writes') \u2014 nobody could read the price.`))}for(let[d,c]of a){let u=i.get(d);for(let f of c){let m=f.fieldKey===void 0?`node.${f.nodeId}.tasks.${f.taskKey}.result.writes`:`node.${f.nodeId}.tasks.${f.taskKey}.result.fields.${f.fieldKey}.writes`;if(u===void 0){n.push(Fe(m,De.unknownKey,`${f.fieldKey===void 0?"":`Feld "${f.fieldKey}" der `}Aufgabe "${f.taskKey}" schreibt "${d}", aber der Workflow deklariert keinen solchen Vorgangs-Schl\xFCssel (graph.processStore).`,`${f.fieldKey===void 0?"Task":`Field "${f.fieldKey}" of task`} "${f.taskKey}" writes "${d}", but the workflow declares no such process key (graph.processStore).`));continue}if(f.valueType!==u.type){let y=f.fieldKey===void 0?`Aufgabe "${f.taskKey}"`:`Feld "${f.fieldKey}" der Aufgabe "${f.taskKey}"`,k=f.fieldKey===void 0?`Task "${f.taskKey}"`:`Field "${f.fieldKey}" of task "${f.taskKey}"`;n.push(Fe(m,De.writerTypeMismatch,`${y} liefert ${f.valueType}, der Vorgangs-Schl\xFCssel "${d}" ist aber als ${u.type} deklariert.`,`${k} delivers ${f.valueType}, but the process key "${d}" is declared as ${u.type}.`))}}if(c.length>1){let f=c.map(m=>`${m.nodeId}/${m.taskKey}${m.fieldKey===void 0?"":`.${m.fieldKey}`}`).join(", ");n.push(Fe(`processStore.${d}`,De.secondWriter,`Vorgangs-Schl\xFCssel "${d}" wird ${c.length}-mal geschrieben (${f}) \u2014 genau ein Schreiber je Schl\xFCssel.`,`Process key "${d}" is written ${c.length} times (${f}) \u2014 exactly one writer per key.`))}}for(let d of r){if(d.derive!==void 0){if(a.has(d.key)){let c=a.get(d.key).map(u=>`${u.nodeId}/${u.taskKey}`).join(", ");n.push(Fe(`processStore.${d.key}`,De.derivedHasWriter,`Vorgangs-Schl\xFCssel "${d.key}" wird abgeleitet (derive) \u2014 keine Aufgabe darf ihn schreiben (${c}).`,`Process key "${d.key}" is derived (derive) \u2014 no task may write it (${c}).`))}continue}a.has(d.key)||n.push(Fe(`processStore.${d.key}`,De.noWriter,`Vorgangs-Schl\xFCssel "${d.key}" ist deklariert, aber keine Aufgabe schreibt ihn ('result.writes').`,`Process key "${d.key}" is declared, but no task writes it ('result.writes').`))}n.push(...BG(e,r,a,t));let l=new Map;for(let d of e.nodes){let c=He(d),u=typeof c.inputs=="function"?c.inputs(d):[];for(let f of u){let m=d.inputs?.[f.id];if(m?.kind!=="binding")continue;let y=UG(e,m.address);if(y===null)continue;let k=`node.${d.id}.input.${f.id}`,g=se(m.address);for(let A of y.sources){let $=l.get(A.key)??new Set;$.add(d.id),l.set(A.key,$)}if(y.audience==="internal"&&n.push(Fe(k,De.internalInDocument,`${d.label.de}: "${f.id}" liest den internen Vorgangs-Schl\xFCssel "${y.key}" \u2014 ein Dokument dieses Knotens geht an die Familie; nur 'printable'-Schl\xFCssel d\xFCrfen hinein.`,`${d.label.en}: "${f.id}" reads the internal process key "${y.key}" \u2014 a document of this node goes to the family; only 'printable' keys may go in.`)),y.derive!==void 0)continue;let v=VG(a,y.sources[0].key,y.sources[0].taskKey);if(v.template.when!==void 0&&f.required===!0&&f.defaultValue===void 0&&n.push(Fe(k,De.absentWithoutDefault,`${d.label.de}: "${f.id}" ist Pflicht und an ${g} gebunden, aber die schreibende Aufgabe entsteht nur unter einer Bedingung (when: ${Ef(v.template.when)}) \u2014 ohne Vorgabewert bliebe das Feld dann f\xFCr immer leer.`,`${d.label.en}: "${f.id}" is required and bound to ${g}, but the writing task only exists under a condition (when: ${Ef(v.template.when)}) \u2014 without a default value the field would stay empty forever.`)),v.result.kind==="pricedItem"&&f.defaultValue!==void 0){let A=f.defaultValue;(!Ai(A)||A.itemKey!==v.result.item||A.grantKeys.length>0)&&n.push(Fe(k,De.defaultItemMismatch,`${d.label.de}: der Vorgabewert von "${f.id}" muss der Artikel der schreibenden Aufgabe ohne Erm\xE4\xDFigung sein ({ itemKey: '${v.result.item??"?"}', grantKeys: [] }) \u2014 sonst rechnete die Familie ohne Antrag einen anderen Artikel als mit.`,`${d.label.en}: the default value of "${f.id}" must be the article of the writing task without a reduction ({ itemKey: '${v.result.item??"?"}', grantKeys: [] }) \u2014 otherwise the family would be charged a different article without an application than with one.`))}}}for(let[d,c]of l){let u=a.get(d)[0],f=u.template.blocks,m=f===void 0?void 0:f.node??u.nodeId,y=m!==void 0&&c.has(m)&&(()=>{let g=e.nodes.find(v=>v.id===m);return g!==void 0&&He(g).processHoldTemplate?.(g)===f.templateKey})(),k=`node.${u.nodeId}.tasks.${u.taskKey}.blocks`;if(!y){let g=[...c][0],v=e.nodes.find($=>$.id===g),A=He(v).processHoldTemplate?.(v)??"?";n.push(Fe(k,De.writerMustBlock,`Die Aufgabe "${u.taskKey}" schreibt "${d}", h\xE4lt aber keinen der lesenden Knoten (${[...c].join(", ")}) zur\xFCck \u2014 sie muss den ersten blockieren, z. B. blocks: { ${g===u.nodeId?"":`node: '${g}', `}templateKey: '${A}' }, sonst arbeitet er, bevor der Wert existiert.`,`The task "${u.taskKey}" writes "${d}" but holds back none of the reading nodes (${[...c].join(", ")}) \u2014 it must block the first one, e.g. blocks: { ${g===u.nodeId?"":`node: '${g}', `}templateKey: '${A}' }, otherwise it works before the value exists.`));continue}for(let g of c)g===m||wf(e,m,g)||n.push(Fe(k,De.writerMustBlock,`"${g}" liest "${d}", liegt aber nicht hinter dem zur\xFCckgehaltenen Knoten "${m}" \u2014 auf einem Weg an ihm vorbei l\xE4se er den Wert, bevor er feststeht.`,`"${g}" reads "${d}" but does not lie behind the held-back node "${m}" \u2014 on a path past it, it would read the value before it is settled.`))}return n}s(lO,"processBindingIssues");function BG(e,t,n,r){let i=[],o=new Map(t.map(u=>[u.key,u])),a=of(e),l=new Set;for(let[u,f]of a.entries()){let m=`pricingRules[${u}]`;if((typeof f.key!="string"||!/^[a-z][a-zA-Z0-9_]*$/.test(f.key)||l.has(f.key))&&i.push(Fe(m,De.ruleSet,`Regelgruppe ${JSON.stringify(f.key)} \u2014 ein eindeutiger Schl\xFCssel aus Buchstaben, Ziffern und _, beginnend mit einem Kleinbuchstaben.`,`Rule group ${JSON.stringify(f.key)} \u2014 a unique key of letters, digits and _, starting with a lowercase letter.`)),l.add(f.key),(!f.label?.de?.trim()||!f.label?.en?.trim())&&i.push(Fe(m,De.ruleSet,`Regelgruppe "${f.key}" braucht ein Label in beiden Sprachen.`,`Rule group "${f.key}" needs a label in both languages.`)),!Array.isArray(f.rows)||f.rows.length===0){i.push(Fe(m,De.ruleSet,`Regelgruppe "${f.key}" hat keine Zeilen.`,`Rule group "${f.key}" has no rows.`));continue}for(let[y,k]of f.rows.entries()){let g=`${m}.rows[${y}]`;(!Array.isArray(k.grants)||k.grants.length===0||k.grants.some(A=>typeof A!="string"||A.length===0))&&i.push(Fe(g,De.ruleSet,`Regelgruppe "${f.key}", Zeile ${y+1}: nennt keine Rabattvorlage \u2014 eine Zeile ohne Rabatt ist die fehlende Zeile.`,`Rule group "${f.key}", row ${y+1}: names no discount template \u2014 a row without a discount is the missing row.`));let v=tl(k.when);if(v!==null){i.push(Fe(g,De.ruleCondition,`Regelgruppe "${f.key}", Zeile ${y+1}: Bedingung ${JSON.stringify(k.when)} \u2014 ${v}.`,`Rule group "${f.key}", row ${y+1}: condition ${JSON.stringify(k.when)} \u2014 ${v==="leere Bedingung"?"empty condition":v}.`));continue}for(let{identifier:A,address:$}of iy(k.when)){if($===null)continue;let E=GG($,o,n);if(E==="ruleSource")i.push(Fe(g,De.ruleSource,`Regelgruppe "${f.key}", Zeile ${y+1}: liest ${A} \u2014 eine Bedingung liest nur Werte, die eine Aufgabe schreibt ($task.<aufgabe>.<schl\xFCssel>), vom Typ ${[...Ty].join(", ")}.`,`Rule group "${f.key}", row ${y+1}: reads ${A} \u2014 a condition only reads values that a task writes ($task.<task>.<key>), of type ${[...Ty].join(", ")}.`));else if(E==="ruleReadsAbsent"){let I=n.get($.key).find(F=>F.taskKey===$.owner);i.push(Fe(g,De.ruleReadsAbsent,`Regelgruppe "${f.key}" liest ${A}, dessen Aufgabe entfallen kann (${I.template.when!==void 0?`when: ${Ef(I.template.when)}`:"sie endet mit ihrem Knoten"}) \u2014 der Schl\xFCssel muss sagen, wof\xFCr er ohne Aufgabe steht ('absentValue'), sonst entschiede die Regel still \xFCber einen fehlenden Wert.`,`Rule group "${f.key}" reads ${A}, whose task can lapse (${I.template.when!==void 0?`when: ${Ef(I.template.when)}`:"it ends with its node"}) \u2014 the key must say what it stands for without a task ('absentValue'), otherwise the rule would silently decide on a missing value.`))}}}}for(let u of t){if(u.absentValue===void 0)continue;let f=`processStore.${u.key}.absentValue`;if(!(u.type==="number"&&typeof u.absentValue=="number"||u.type==="boolean"&&typeof u.absentValue=="boolean"||u.type==="enum"&&typeof u.absentValue=="string"&&u.absentValue.length>0)){i.push(Fe(f,De.absentValue,`Vorgangs-Schl\xFCssel "${u.key}" (${u.type}): absentValue ${JSON.stringify(u.absentValue)} passt nicht zum Typ.`,`Process key "${u.key}" (${u.type}): absentValue ${JSON.stringify(u.absentValue)} does not fit the type.`));continue}let y=n.get(u.key)?.[0];y!==void 0&&!dO(y)&&i.push(Fe(f,De.absentValue,`Vorgangs-Schl\xFCssel "${u.key}": seine Aufgabe ist immer geschuldet und \xFCberlebt ihren Knoten \u2014 ein absentValue w\xFCrde nie gelesen.`,`Process key "${u.key}": its task is always owed and outlives its node \u2014 an absentValue would never be read.`))}let d=[];for(let u of t){let f=u.derive;if(f===void 0)continue;let m=`processStore.${u.key}.derive`,y=u.type==="pricedGroup"?"group":"item",k=[f.item,f.group,f.byStage].filter(F=>F!==void 0).length,g=Xg(f),v=f.byStage??[];(k!==1||g.length===0||g.length!==Math.max(v.length,1)||g.some(F=>F.kind!==y))&&i.push(Fe(m,De.derive,`"${u.key}" (${u.type}) leitet ${y==="group"?"ein Paket ab: genau 'group' oder 'byStage' mit je einem 'group'":"einen Artikel ab: genau 'item' oder 'byStage' mit je einem 'item'"}.`,`"${u.key}" (${u.type}) derives ${y==="group"?"a package: exactly 'group' or 'byStage' with one 'group' each":"an article: exactly 'item' or 'byStage' with one 'item' each"}.`));let A=new Set;for(let[F,b]of v.entries()){if(!Array.isArray(b.stages)||b.stages.length===0){i.push(Fe(`${m}.byStage[${F}]`,De.derive,`"${u.key}": die Zeile ${F+1} nennt keine Stufe.`,`"${u.key}": row ${F+1} names no stage.`));continue}for(let T of b.stages)A.has(T)&&i.push(Fe(`${m}.byStage[${F}]`,De.derive,`"${u.key}": die Stufe "${T}" steht in mehr als einer Zeile \u2014 welcher Preis gilt, w\xE4re geraten.`,`"${u.key}": the stage "${T}" is in more than one row \u2014 which price applies would be a guess.`)),A.add(T)}let $=new Set;for(let F of f.rules??[]){let b=a.find(T=>T.key===F);if(b===void 0){i.push(Fe(m,De.derive,`"${u.key}" nennt die Regelgruppe "${F}", die der Workflow nicht deklariert (bekannt: ${a.map(T=>T.key).join(", ")||"keine"}).`,`"${u.key}" names the rule group "${F}", which the workflow does not declare (known: ${a.map(T=>T.key).join(", ")||"none"}).`));continue}for(let T of b.rows??[])for(let q of T.grants??[])$.add(q)}let E=f.reduction;be(E)&&(zG(E,o)||i.push(Fe(m,De.derive,`"${u.key}": Reduktion ${se(E)} ist kein von einer Aufgabe geschriebener Wert vom Typ reduction ($task.<aufgabe>.<schl\xFCssel>).`,`"${u.key}": reduction ${se(E)} is not a value of type reduction written by a task ($task.<task>.<key>).`)));for(let F of g)d.push({key:u.key,target:F,grants:$}),(F.kind==="item"?r.billingItemKeys?.has(F.key):r.groupArticleKeys?.has(F.key))===!1?i.push(Fe(m,De.derivePriceUnknown,`"${u.key}": ${F.kind==="item"?"der Artikel":"das Paket"} "${F.key}" ist nicht im Katalog des Mandanten.`,`"${u.key}": the ${F.kind==="item"?"article":"package"} "${F.key}" is not in the school's catalog.`)):r.offerProgram===null?i.push(Fe(m,De.derivePriceOfferWithoutProgram,`"${u.key}": das Angebot ist keinem Programm zugeordnet, also geh\xF6rt ${F.kind==="item"?"kein Artikel":"kein Paket"} zu ihm; dem Angebot ein Programm geben.`,`"${u.key}": the offer is not assigned to a program, so no ${F.kind==="item"?"article":"package"} belongs to it; give the offer a program.`)):r.offerProgram!==void 0&&((F.kind==="item"?r.offerProgram.billingItemKeys:r.offerProgram.groupKeys).has(F.key)||i.push(Fe(m,De.derivePriceNotInProgram,`"${u.key}": ${F.kind==="item"?"der Artikel":"das Paket"} "${F.key}" ist dem Programm \u201E${r.offerProgram.nameDe}\u201C des Angebots nicht zugeordnet${F.kind==="group"?" oder wird nicht angeboten":""} (unter Finanzen \u2192 Artikel zuordnen).`,`"${u.key}": the ${F.kind==="item"?"article":"package"} "${F.key}" is not assigned to the offer's program "${r.offerProgram.nameDe}"${F.kind==="group"?" or is not offered":""} (under Finance \u2192 assign articles).`)));let I=r.offerProgram?.stageKeys;if(f.byStage!==void 0&&I!==void 0){let F=[...A].filter(T=>!I.all.has(T));F.length>0&&i.push(Fe(m,De.deriveStageUnknown,`"${u.key}": ${F.map(T=>`"${T}"`).join(", ")} ist keine Stufe des Programms \u201E${r.offerProgram.nameDe}\u201C (Stufen: ${[...I.all].join(", ")||"keine"}).`,`"${u.key}": ${F.map(T=>`"${T}"`).join(", ")} ${F.length===1?"is not a stage":"are not stages"} of the program "${r.offerProgram.nameDe}" (stages: ${[...I.all].join(", ")||"none"}).`));let b=[...I.active].filter(T=>!A.has(T));b.length>0&&i.push(Fe(m,De.deriveStageUncovered,`"${u.key}": f\xFCr ${b.map(T=>`"${T}"`).join(", ")} nennt byStage keinen ${y==="group"?"Paket":"Artikel"} \u2014 diese Stufe h\xE4tte keinen Preis.`,`"${u.key}": for ${b.map(T=>`"${T}"`).join(", ")} byStage names no ${y==="group"?"package":"article"} \u2014 that stage would have no price.`))}}for(let u of n.values())for(let f of u){if(f.result.kind!=="reduction"||f.result.prices===void 0||f.result.writes===void 0)continue;let m=`node.${f.nodeId}.tasks.${f.taskKey}.result.prices`,k=o.get(f.result.prices)?.derive?.reduction;be(k)&&k.scope==="task"&&k.owner===f.taskKey&&k.key===f.result.writes||i.push(Fe(m,De.reductionPrices,`Aufgabe "${f.taskKey}" senkt "${f.result.prices}" \u2014 das muss ein abgeleiteter Preis sein, dessen derive.reduction $task.${f.taskKey}.${f.result.writes} ist.`,`Task "${f.taskKey}" reduces "${f.result.prices}" \u2014 that must be a derived price whose derive.reduction is $task.${f.taskKey}.${f.result.writes}.`))}let c=r.grantTemplates;if(c!==void 0){let u=new Set(a.flatMap(f=>(f.rows??[]).flatMap(m=>m.grants??[])));for(let f of u){let m=c.get(f);if(m===void 0){i.push(Fe("pricingRules",De.ruleGrantUnknown,`Eine Regelgruppe vergibt "${f}", aber keine Rabattvorlage des Mandanten tr\xE4gt diesen Schl\xFCssel.`,`A rule group grants "${f}", but no discount template of the school has this key.`));continue}d.some(({target:k,grants:g})=>{if(!g.has(f))return!1;if(k.kind==="item")return m.itemKeys.includes(k.key);let v=r.groupArticleKeys?.get(k.key);return m.itemKeys.some(A=>v?.has(A))})||i.push(Fe("pricingRules",De.ruleGrantUnused,`Die Rabattvorlage "${f}" (gebunden an Artikel "${m.itemKeys.join(", ")}") wird vergeben, aber kein abgeleiteter Preis, der ihre Regelgruppe liest, enth\xE4lt ihr Ziel \u2014 sie wirkte nirgends.`,`The discount template "${f}" (bound to article "${m.itemKeys.join(", ")}") is granted, but no derived price reading its rule group contains its target \u2014 it would have no effect anywhere.`))}}return i}s(BG,"derivedPriceIssues");function UG(e,t){if(!be(t)||t.scope!=="task"&&t.scope!=="derived"||t.path!==void 0)return null;let n=Af(e).find(o=>o.key===t.key);if(n===void 0||t.scope==="derived"!=(n.derive!==void 0))return null;if(t.scope==="task")return Pr(e,t.owner,t.key)===null?null:Sy(e,t);let r=ZR(e,n.derive),i=s(o=>o.scope==="task"&&o.path===void 0&&Pr(e,o.owner,o.key)!==null,"resolvable");return r!==null&&r.every(o=>i(o.address))?Sy(e,t):null}s(UG,"draftLeafOf");function VG(e,t,n){let r=e.get(t)?.find(i=>i.taskKey===n);return r===void 0&&C(`[process] the leaf of "${t}" names task "${n}", which does not write it`),r}s(VG,"writerOf");function Ef(e){return be(e)?se(e):JSON.stringify(e)}s(Ef,"shown");function GG(e,t,n){let r=e.scope==="task"&&e.path===void 0?t.get(e.key):void 0;if(e.scope==="task"&&e.path===void 0&&r===void 0)return null;if(e.scope!=="task"||r===void 0||r.derive!==void 0||!Ty.has(r.type))return"ruleSource";let i=n.get(r.key)?.find(o=>o.taskKey===e.owner);return i!==void 0&&dO(i)&&r.absentValue===void 0?"ruleReadsAbsent":null}s(GG,"ruleSourceRefusal");function zG(e,t){let n=e.scope==="task"&&e.path===void 0?t.get(e.key):void 0;return n!==void 0&&n.type==="reduction"&&n.derive===void 0}s(zG,"isReductionValue");function dO(e){return e.template.when!==void 0||e.template.blocks?.node===void 0}s(dO,"writerMayBeNotOwed");function $y(e){let t=He(e);return e.outcomes&&e.outcomes.length>0?[...e.outcomes]:t.outcomes&&t.outcomes.length>0?[...t.outcomes]:null}s($y,"nodeOutcomes");var WG=["documentChangeRequested","documentReturned"];function cO(e){return WG.includes(e)}s(cO,"isNonAdvancingExternalEvent");var Ns=["offer","contract"];function Tf(e){return typeof e=="string"&&Ns.includes(e)}s(Tf,"isArtifactSlotType");var uO="open",Ds="done";function Ry(e){let t={};for(let n of ze)t[n]=e(n);return t}s(Ry,"localized");var fO=[{key:"tenantSlug",type:"string"}];var YG=/^(\d{4})-(\d{2})-(\d{2})$/;function HG(e){return e>=1900&&e<=2100}s(HG,"isSupportedYear");function JG(e,t,n){let r=new Date(Date.UTC(e,t-1,n));return r.getUTCFullYear()===e&&r.getUTCMonth()===t-1&&r.getUTCDate()===n}s(JG,"isRealDate");function Iy(e){if(typeof e!="string")return null;let t=YG.exec(e);if(t===null)return null;let[,n,r,i]=t;return n===void 0||r===void 0||i===void 0||!HG(Number(n))||!JG(Number(n),Number(r),Number(i))?null:{year:n,month:r,day:i}}s(Iy,"isoDateParts");var QG="Europe/Berlin";function mO(){return QG}s(mO,"tenantTimeZone");var pO=new Map;function ZG(e){let t=pO.get(e);if(t)return t;let n;try{n=new Intl.DateTimeFormat("en-US",{timeZone:e,hour12:!1,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{ae("INVALID",{de:`Unbekannte Zeitzone "${e}".`,en:`Unknown time zone "${e}".`})}return pO.set(e,n),n}s(ZG,"formatterFor");function XG(e,t){let n=new Map(ZG(e).formatToParts(new Date(t)).map(a=>[a.type,a.value])),r=s(a=>{let l=n.get(a);return l===void 0&&C(`Zeitzone "${e}" liefert kein Feld ${a}.`),Number(l)},"read"),i=r("hour")%24;return Date.UTC(r("year"),r("month")-1,r("day"),i,r("minute"),r("second"))-Math.floor(t/1e3)*1e3}s(XG,"zoneOffsetAt");function Oy(e,t){let n=e+XG(t,e);return{wallClock:new Date(n).toISOString().slice(0,19),timeZone:t}}s(Oy,"instantToLocalDateTime");var Py=3;function hO(e){return Oy(e,mO()).wallClock.slice(0,10)}s(hO,"localIsoDate");var $f=["login","security","admission","tasks","deadlines","schoolMessages","staffTasks","staffAppointments","staffDeadlines","staffWaitlist","familyMessages","mentions"],gO=w.union(...$f.map(e=>w.literal(e)));var lce=w.union(w.literal("admission"),w.literal("tasks"),w.literal("staff"),w.literal("chat")),_y=["loginOnly","all"],dce=w.union(w.literal("loginOnly"),w.literal("all"));function yO(e){return typeof e=="string"&&_y.includes(e)}s(yO,"isMailLevel");var fl="subject";function wO(e){return e.category==="login"}s(wO,"isSignInLetter");var dt={key:"schoolName",label:"Name der Schule"},kO={de:"Zu Ihren Bewerbungen",en:"View your applications"},vt={key:"portalLink",label:"Link zum Bewerberportal",required:!0,link:!0,actionLabel:kO},Cy={key:vt.key,label:vt.label,link:!0,actionLabel:kO},bO={key:"authorName",label:"Name der schreibenden Person"},Fs={key:"applicationLink",label:"Link zur Bewerbung",required:!0,link:!0,actionLabel:{de:"Bewerbung \xF6ffnen",en:"Open application"}},pl={key:"anmeldeLink",label:"Anmeldelink",required:!0,link:!0,actionLabel:{de:"Jetzt anmelden",en:"Sign in now"},previewValue:{de:"https://beispiel.plexus.schule/anmelden?token=BEISPIEL",en:"https://beispiel.plexus.schule/anmelden?token=BEISPIEL"}},tz={key:"passwortLink",label:"Link zum neuen Passwort",required:!0,link:!0,actionLabel:{de:"Neues Passwort festlegen",en:"Set a new password"},previewValue:{de:"https://beispiel.plexus.schule/login/reset?token=BEISPIEL",en:"https://beispiel.plexus.schule/login/reset?token=BEISPIEL"}},vO={key:"bestaetigungsLink",label:"Best\xE4tigungslink",required:!0,link:!0,actionLabel:{de:"E-Mail best\xE4tigen",en:"Confirm email address"},previewValue:{de:"https://beispiel.plexus.schule/bestaetigen?token=BEISPIEL",en:"https://beispiel.plexus.schule/bestaetigen?token=BEISPIEL"}},ml={key:"gueltigkeit",label:"G\xFCltigkeitsdauer des Links",previewValue:{de:"15 Minuten",en:"15 minutes"}},xO={key:"gueltigkeit",label:"G\xFCltigkeitsdauer des Links",previewValue:{de:"24 Stunden",en:"24 hours"}},nz={key:"gueltigkeit",label:"G\xFCltigkeitsdauer des Links",previewValue:{de:"60 Minuten",en:"60 minutes"}};function Le(e){return{key:fl,label:"Betreff",default:e}}s(Le,"subjectSlot");var Ni=w.object({de:w.string(),en:w.string()}),$t={tenantSlug:w.string(),applicationId:w.id("applications")},rz=w.object({tenantSlug:w.string()}),iz={id:"applicant.welcome",category:"admission",label:"Willkommen",occasion:{de:"Sobald f\xFCr eine Familie ein Zugang angelegt wurde",en:"As soon as an account has been created for a family"},audience:"external",frame:"letter",timeline:"correspondence",paramsValidator:rz,channels:["email"],portalVisible:!0,placeholders:[dt,vt],slots:[Le({de:"Willkommen \u2014 Ihre Bewerbung bei uns",en:"Welcome \u2014 your application"}),{key:"intro",label:"Einleitung",multiline:!0,default:{de:`vielen Dank f\xFCr Ihre Registrierung bei {{schoolName}}. \xDCber den folgenden Link k\xF6nnen Sie jederzeit Ihre Bewerbungen einsehen und fortsetzen:
10203
10203
 
10204
10204
  {{portalLink}}`,en:`Thank you for registering with {{schoolName}}. You can view and continue your applications at any time using the link below:
10205
10205
 
@@ -10243,11 +10243,11 @@ You can check the current status at any time here:
10243
10243
 
10244
10244
  {{portalLink}}`,en:`You can take care of this in your applicant portal:
10245
10245
 
10246
- {{portalLink}}`}}]},Rf=w.object({...$t,workItemId:w.id("work_items"),dueAt:w.number()}),hl={key:"taskTitle",label:"Titel der Aufgabe"},gl={key:"dueDate",label:"F\xE4lligkeitstag",subjectSafe:!0},Ls={key:"applicantName",label:"Name aus der Bewerbung"},mz={id:"applicant.taskDueSoon",category:"tasks",label:"Frist l\xE4uft bald ab",occasion:{de:`${Py} Tage bevor die Frist einer Aufgabe der Familie abl\xE4uft`,en:`${Py} days before the deadline of a family task runs out`},audience:"external",frame:"letter",timeline:"correspondence",paramsValidator:Rf,channels:["email"],portalVisible:!0,placeholders:[dt,hl,gl,Ls,vt],slots:[Le({de:"Erinnerung: Eine Frist zu Ihrer Bewerbung l\xE4uft bald ab",en:"Reminder: a deadline for your application is coming up"}),{key:"intro",label:"Einleitung",multiline:!0,default:{de:"f\xFCr die Bewerbung von {{applicantName}} bei {{schoolName}} ist noch eine Aufgabe offen: \u201E{{taskTitle}}\u201C. Bitte erledigen Sie sie bis zum {{dueDate}}.",en:"There is still a task open on {{applicantName}}\u2019s application to {{schoolName}}: \u201C{{taskTitle}}\u201D. Please complete it by {{dueDate}}."}},{key:"outro",label:"Abschluss",multiline:!0,default:{de:`Das geht in Ihrem Portal:
10246
+ {{portalLink}}`}}]},Rf=w.object({...$t,workItemId:w.id("work_items"),dueAt:w.number()}),hl={key:"taskTitle",label:"Titel der Aufgabe"},gl={key:"dueDate",label:"F\xE4lligkeitstag",subjectSafe:!0},Ls={key:"applicantName",label:"Name aus der Bewerbung"},mz={id:"applicant.taskDueSoon",category:"deadlines",label:"Frist l\xE4uft bald ab",occasion:{de:`${Py} Tage bevor die Frist einer Aufgabe der Familie abl\xE4uft`,en:`${Py} days before the deadline of a family task runs out`},audience:"external",frame:"letter",timeline:"correspondence",paramsValidator:Rf,channels:["email"],portalVisible:!0,placeholders:[dt,hl,gl,Ls,vt],slots:[Le({de:"Erinnerung: Eine Frist zu Ihrer Bewerbung l\xE4uft bald ab",en:"Reminder: a deadline for your application is coming up"}),{key:"intro",label:"Einleitung",multiline:!0,default:{de:"f\xFCr die Bewerbung von {{applicantName}} bei {{schoolName}} ist noch eine Aufgabe offen: \u201E{{taskTitle}}\u201C. Bitte erledigen Sie sie bis zum {{dueDate}}.",en:"There is still a task open on {{applicantName}}\u2019s application to {{schoolName}}: \u201C{{taskTitle}}\u201D. Please complete it by {{dueDate}}."}},{key:"outro",label:"Abschluss",multiline:!0,default:{de:`Das geht in Ihrem Portal:
10247
10247
 
10248
10248
  {{portalLink}}`,en:`You can do this in your applicant portal:
10249
10249
 
10250
- {{portalLink}}`}}]},hz={id:"applicant.taskOverdue",category:"tasks",label:"Frist \xFCberschritten",occasion:{de:"Am Tag nach dem Ablauf der Frist einer Aufgabe, die die Familie noch nicht erledigt hat",en:"The day after the deadline of a family task passed without it being done"},audience:"external",frame:"letter",timeline:"correspondence",paramsValidator:Rf,channels:["email"],portalVisible:!0,placeholders:[dt,hl,gl,Ls,vt],slots:[Le({de:"Eine Frist zu Ihrer Bewerbung ist \xFCberschritten",en:"A deadline for your application has passed"}),{key:"intro",label:"Einleitung",multiline:!0,default:{de:"die Frist f\xFCr \u201E{{taskTitle}}\u201C in der Bewerbung von {{applicantName}} bei {{schoolName}} ist am {{dueDate}} abgelaufen.",en:"The deadline for \u201C{{taskTitle}}\u201D on {{applicantName}}\u2019s application to {{schoolName}} passed on {{dueDate}}."}},{key:"outro",label:"Abschluss",multiline:!0,default:{de:`Bitte erledigen Sie die Aufgabe so bald wie m\xF6glich in Ihrem Portal:
10250
+ {{portalLink}}`}}]},hz={id:"applicant.taskOverdue",category:"deadlines",label:"Frist \xFCberschritten",occasion:{de:"Am Tag nach dem Ablauf der Frist einer Aufgabe, die die Familie noch nicht erledigt hat",en:"The day after the deadline of a family task passed without it being done"},audience:"external",frame:"letter",timeline:"correspondence",paramsValidator:Rf,channels:["email"],portalVisible:!0,placeholders:[dt,hl,gl,Ls,vt],slots:[Le({de:"Eine Frist zu Ihrer Bewerbung ist \xFCberschritten",en:"A deadline for your application has passed"}),{key:"intro",label:"Einleitung",multiline:!0,default:{de:"die Frist f\xFCr \u201E{{taskTitle}}\u201C in der Bewerbung von {{applicantName}} bei {{schoolName}} ist am {{dueDate}} abgelaufen.",en:"The deadline for \u201C{{taskTitle}}\u201D on {{applicantName}}\u2019s application to {{schoolName}} passed on {{dueDate}}."}},{key:"outro",label:"Abschluss",multiline:!0,default:{de:`Bitte erledigen Sie die Aufgabe so bald wie m\xF6glich in Ihrem Portal:
10251
10251
 
10252
10252
  {{portalLink}}`,en:`Please complete the task as soon as possible in your applicant portal:
10253
10253
 
@@ -10649,6 +10649,6 @@ ${n.length} unusable ${o}:
10649
10649
  `),r.length>0&&this.context.stdout.write(` ${r.length} linkable \u2014 plexus-cli platform users relink-auth <email>
10650
10650
  `),i.length>0&&this.context.stdout.write(` ${i.length} without any login account \u2014 plexus-cli platform users provision --tenant <slug> --email <email> --name <name>
10651
10651
  `)}else this.context.stdout.write(`No unusable identities.
10652
- `);return n.length>0?1:0}},eE=class extends rr{static{s(this,"UsersRelinkAuthCommand")}static paths=[["platform","users","relink-auth"],["users","relink-auth"]];static usage=R.Usage({category:"Users",description:"Relink a user's identity row to its live Better Auth account (heals an orphan)."});email=p.String({required:!0});async execute(){let n=await(await this.caller()).mutation(S.platformAdmin.relinkAuthAccount,{email:this.email}),r=n.changed?`Relinked ${this.email} to live auth account ${n.authId}.`:`${this.email} already linked to the live auth account (no change).`;return this.report(n,r),0}};function qK(e,t){if(e===t)throw new Error("Pass exactly one of --on or --off.");return e}s(qK,"requireOnOff");var KK=[LA,MA,qA,KA,jA,BA,UA,VA,GA,zA,Bc,WA,YA,HA,JA,QA,ZA,XA,eE];function jK(e){return e.de??e.en??Object.values(e)[0]??""}s(jK,"titleDe");function SQ(e){return{id:e._id,kind:e.kind,status:e.status,title:jK(e.title).slice(0,50),assignee:e.assigneeUserId??"",group:e.queueGroupId??"",outcome:e.outcome??""}}s(SQ,"row");var AQ=["id","kind","status","title","assignee","group","outcome"],rE=class extends N{static{s(this,"WorkItemsListCommand")}static paths=[["work-items","list"]];static usage=R.Usage({category:"Work-Items",description:"List work-items for the active tenant (filter by --mine/--application/--group)."});mine=p.Boolean("--mine",!1,{description:"Only items assigned to me."});application=p.String("--application",{description:"Filter by application id."});group=p.String("--group",{description:"Filter by team (permission-group) id."});assignee=p.String("--assignee",{description:"Filter by assignee users._id."});openOnly=p.Boolean("--open-only",!1,{description:"Only open items."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.query(S.workItems.list,{client:n,...this.mine?{mine:!0}:{},...this.application?{applicationId:this.application}:{},...this.group?{queueGroupId:this.group}:{},...this.assignee?{assigneeUserId:this.assignee}:{},...this.openOnly?{openOnly:!0}:{}});return this.print(r,i=>i.map(SQ),AQ),0}},iE=class extends N{static{s(this,"WorkItemsShowCommand")}static paths=[["work-items","show"]];static usage=R.Usage({category:"Work-Items",description:"Show one work-item by id."});workItemId=p.String({required:!0,name:"workItemId"});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.query(S.workItems.get,{client:n,workItemId:this.workItemId});if(r===null)throw new Error(`work-item ${this.workItemId} not found in tenant ${n}.`);return this.print(r,i=>[{field:"id",value:i._id},{field:"kind",value:i.kind},{field:"status",value:i.status},{field:"title",value:jK(i.title)},{field:"assignee",value:i.assigneeUserId??""},{field:"group",value:i.queueGroupId??""},{field:"application",value:i.applicationId??""},{field:"node",value:i.nodeId??""},{field:"outcome",value:i.outcome??""}]),0}},oE=class extends N{static{s(this,"WorkItemsCreateCommand")}static paths=[["work-items","create"]];static usage=R.Usage({category:"Work-Items",description:"Create a manual task work-item."});title=p.String("--title",{required:!0,description:"Task title."});description=p.String("--description",{description:"Task description."});application=p.String("--application",{description:"Link to an application id."});group=p.String("--group",{description:"Team (permission-group) id whose queue holds the task."});assignee=p.String("--assignee",{description:"Assignee users._id."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.mutation(S.workItems.createManual,{client:n,title:this.title,...this.description?{description:this.description}:{},...this.application?{applicationId:this.application}:{},...this.group?{queueGroupId:this.group}:{},...this.assignee?{assigneeUserId:this.assignee}:{}});return this.print({workItemId:r.workItemId},i=>[{field:"workItemId",value:i.workItemId}]),0}},sE=class extends N{static{s(this,"WorkItemsCompleteCommand")}static paths=[["work-items","complete"]];static usage=R.Usage({category:"Work-Items",description:"Complete a work-item (optionally with an outcome)."});workItemId=p.String({required:!0,name:"workItemId"});outcome=p.String("--outcome",{description:"Outcome id to record."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.mutation(S.workItems.complete,{client:n,workItemId:this.workItemId,...this.outcome?{outcome:this.outcome}:{}});return this.print({workItemId:r.workItemId,status:"done"},i=>[{field:"workItemId",value:i.workItemId},{field:"status",value:i.status}]),0}},aE=class extends N{static{s(this,"WorkItemsAssignCommand")}static paths=[["work-items","assign"]];static usage=R.Usage({category:"Work-Items",description:"Assign a work-item to a user (omit --user to unassign)."});workItemId=p.String({required:!0,name:"workItemId"});user=p.String("--user",{description:"Assignee users._id (omit to clear)."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.mutation(S.workItems.assign,{client:n,workItemId:this.workItemId,...this.user?{userId:this.user}:{}});return this.print({workItemId:r.workItemId,assignee:this.user??"(cleared)"},i=>[{field:"workItemId",value:i.workItemId},{field:"assignee",value:i.assignee}]),0}},BK=[rE,iE,oE,sE,aE];var Uc=[...j$,...C_,...V_,...eN,...XC,...TN,...CN,..._N,...LK,...KK,...FK,...Nq,...y_,...xN,...EK,...q$,...uR,...m_,...FN,...DN,...qN,...KN,...bN,...sN,...BK,...C0,...wM,..._q,...kM,...lK,...gK,...Dq,...Vq,...Wq,...kK,...IK,...rR];for(let e of Uc){let t=e.paths?.[0];t===void 0||!Object.hasOwn(e,"usage")||e.usage===void 0||(e.usage={...e.usage,category:lT(e.usage.category,t.join(" "))})}var UK="0.1.58";function VK(){return Uc.flatMap(e=>(e.paths??[]).map(t=>{let n=t.join(" "),r=iT[io(n)];return{path:n,effect:oo(n),host:r===void 0?"shared":"terminal",...r===void 0?{}:{reason:r}}})).sort((e,t)=>e.path.localeCompare(t.path))}s(VK,"plexusCommandCatalog");import Wo from"node:path";function EQ(e){let t=st()?.workspaceRoot??process.cwd(),n=Wo.resolve(t,e),r=Wo.relative(t,n);if(Wo.isAbsolute(e)||r===".."||r.startsWith(`..${Wo.sep}`))throw new Error("plexus: use a relative path inside the current workspace.");return{absolute:n,relative:r}}s(EQ,"workspacePath");function TQ(e){let{absolute:t,relative:n}=EQ(e.path??".");if(e.operation==="list"){if(!Ae(t))return{files:[]};let r=[],i=s(o=>{for(let a of xr(o,{withFileTypes:!0})){if(a.isSymbolicLink())throw new Error("plexus: workspace symlinks are not supported.");let l=Wo.join(o,a.name);if(a.isDirectory()?i(l):r.push(Wo.relative(t,l)),r.length>200)throw new Error("plexus: the workspace contains too many files. List a subdirectory.")}},"visit");return i(t),{files:r.sort()}}if(!n)throw new Error("plexus: name a workspace file.");if(["read","search","edit"].includes(e.operation)){let r=ye(t);if(r.length>10*1024*1024)throw new Error("plexus: the workspace file exceeds 10 MB.");let i=new TextDecoder("utf-8",{fatal:!0}).decode(r);if(e.operation==="read"){let l=e.offset??0,d=e.maxChars??8e3,c=i.slice(l,l+d);return{path:n,content:c,...l||c.length<i.length?{offset:l,nextOffset:l+c.length<i.length?l+c.length:null,totalCharacters:i.length}:{}}}if(e.operation==="search"){if(!e.query)throw new Error("plexus: search needs a nonempty query.");let l=[],d=e.offset??0;for(;l.length<10;){let c=i.indexOf(e.query,d);if(c<0)break;l.push({offset:c,text:i.slice(Math.max(0,c-160),c+e.query.length+240)}),d=c+e.query.length}return{path:n,matches:l,nextOffset:l.length===10?d:null}}if(!e.oldText||typeof e.content!="string")throw new Error("plexus: edit needs oldText and replacement content.");let o=i.indexOf(e.oldText);if(o<0||o!==i.lastIndexOf(e.oldText))throw new Error("plexus: oldText must match exactly once. Read the current file and choose unique context.");let a=i.slice(0,o)+e.content+i.slice(o+e.oldText.length);if(Buffer.byteLength(a)>10*1024*1024)throw new Error("plexus: the edited file exceeds 10 MB.");return lt(t,a,"utf8"),{path:n,sizeBytes:Buffer.byteLength(a)}}if(e.operation==="write"){if(typeof e.content!="string"||Buffer.byteLength(e.content)>1e6)throw new Error("plexus: file content is missing or too large.");return Pt(Wo.dirname(t),{recursive:!0}),lt(t,e.content,"utf8"),{path:n,sizeBytes:Buffer.byteLength(e.content)}}if(e.operation==="remove")return Qo(t),{path:n,removed:!0};throw new Error("plexus: unknown workspace operation.")}s(TQ,"plexusWorkspace");function GK(e){return s(async function(n,r){if(!r||typeof r!="object"||Array.isArray(r))throw new Error("plexus: tool input must be an object.");let i=r,o=Ya[n];if(!o||!Object.hasOwn(Ya,n))throw new Error("plexus: unknown agent tool.");if(Object.keys(i).some(a=>!Object.hasOwn(o.inputSchema.properties,a)))throw new Error("plexus: unexpected tool argument.");if(n==="plexus"){if(!Array.isArray(i.argv)||i.argv.some(a=>typeof a!="string")||i.stdin!==void 0&&typeof i.stdin!="string")throw new Error("plexus: invalid command input.");return e.inspectCommand(i.argv),e.executeCommand({argv:i.argv,...i.stdin===void 0?{}:{stdin:i.stdin}})}if(n==="plexus_skill"){if(typeof i.path!="string"||i.path.length>240||!Object.hasOwn(Sg,i.path))throw new Error("plexus: unknown skill reference. Start with SKILL.md.");return{path:i.path,content:Sg[i.path],skillHash:Mu}}if(typeof i.operation!="string"||!["list","read","search","edit","write","remove"].includes(i.operation)||i.path!==void 0&&(typeof i.path!="string"||i.path.length>500)||i.content!==void 0&&(typeof i.content!="string"||i.content.length>1e6)||i.oldText!==void 0&&(typeof i.oldText!="string"||i.oldText.length>1e6)||i.query!==void 0&&(typeof i.query!="string"||!i.query.length||i.query.length>1e3)||i.offset!==void 0&&(typeof i.offset!="number"||!Number.isSafeInteger(i.offset)||i.offset<0)||i.maxChars!==void 0&&(typeof i.maxChars!="number"||!Number.isSafeInteger(i.maxChars)||i.maxChars<1||i.maxChars>24e3))throw new Error("plexus: invalid workspace input.");return TQ(i)},"executePlexusAgentTool")}s(GK,"createPlexusAgentToolExecutor");var lh=GK({inspectCommand:WK,executeCommand:YK});function dh(){let e=new ts({binaryLabel:"Plexus CLI",binaryName:"plexus-cli",binaryVersion:UK});e.register(Pa.HelpCommand),e.register(Pa.VersionCommand);for(let n of Uc)e.register(n);async function t(n,r){let i;try{i=e.process(n,r)}catch(o){return(r.stderr??process.stderr).write(e.error(o,{colored:!1})),2}return IQ(i,r.stderr??process.stderr),e.run(i,r)}return s(t,"run"),{process(n,r){return e.process(n,r)},run:t,async runExit(n,r){process.exitCode=await t(n,r)}}}s(dh,"createPlexusCli");function IQ(e,t){let n=e.path.join(" "),r=e.constructor.paths?.[0]?.join(" ");r!==void 0&&n!==r&&Fa[n]===r&&it(t,n,r),n in Fa&&oo(n)==="confirm"&&!La(e)&&t.write(`plexus-cli: \`${Fa[n]}\` only prints its plan without --confirm \u2014 nothing was changed.
10652
+ `);return n.length>0?1:0}},eE=class extends rr{static{s(this,"UsersRelinkAuthCommand")}static paths=[["platform","users","relink-auth"],["users","relink-auth"]];static usage=R.Usage({category:"Users",description:"Relink a user's identity row to its live Better Auth account (heals an orphan)."});email=p.String({required:!0});async execute(){let n=await(await this.caller()).mutation(S.platformAdmin.relinkAuthAccount,{email:this.email}),r=n.changed?`Relinked ${this.email} to live auth account ${n.authId}.`:`${this.email} already linked to the live auth account (no change).`;return this.report(n,r),0}};function qK(e,t){if(e===t)throw new Error("Pass exactly one of --on or --off.");return e}s(qK,"requireOnOff");var KK=[LA,MA,qA,KA,jA,BA,UA,VA,GA,zA,Bc,WA,YA,HA,JA,QA,ZA,XA,eE];function jK(e){return e.de??e.en??Object.values(e)[0]??""}s(jK,"titleDe");function SQ(e){return{id:e._id,kind:e.kind,status:e.status,title:jK(e.title).slice(0,50),assignee:e.assigneeUserId??"",group:e.queueGroupId??"",outcome:e.outcome??""}}s(SQ,"row");var AQ=["id","kind","status","title","assignee","group","outcome"],rE=class extends N{static{s(this,"WorkItemsListCommand")}static paths=[["work-items","list"]];static usage=R.Usage({category:"Work-Items",description:"List work-items for the active tenant (filter by --mine/--application/--group)."});mine=p.Boolean("--mine",!1,{description:"Only items assigned to me."});application=p.String("--application",{description:"Filter by application id."});group=p.String("--group",{description:"Filter by team (permission-group) id."});assignee=p.String("--assignee",{description:"Filter by assignee users._id."});openOnly=p.Boolean("--open-only",!1,{description:"Only open items."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.query(S.workItems.list,{client:n,...this.mine?{mine:!0}:{},...this.application?{applicationId:this.application}:{},...this.group?{queueGroupId:this.group}:{},...this.assignee?{assigneeUserId:this.assignee}:{},...this.openOnly?{openOnly:!0}:{}});return this.print(r,i=>i.map(SQ),AQ),0}},iE=class extends N{static{s(this,"WorkItemsShowCommand")}static paths=[["work-items","show"]];static usage=R.Usage({category:"Work-Items",description:"Show one work-item by id."});workItemId=p.String({required:!0,name:"workItemId"});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.query(S.workItems.get,{client:n,workItemId:this.workItemId});if(r===null)throw new Error(`work-item ${this.workItemId} not found in tenant ${n}.`);return this.print(r,i=>[{field:"id",value:i._id},{field:"kind",value:i.kind},{field:"status",value:i.status},{field:"title",value:jK(i.title)},{field:"assignee",value:i.assigneeUserId??""},{field:"group",value:i.queueGroupId??""},{field:"application",value:i.applicationId??""},{field:"node",value:i.nodeId??""},{field:"outcome",value:i.outcome??""}]),0}},oE=class extends N{static{s(this,"WorkItemsCreateCommand")}static paths=[["work-items","create"]];static usage=R.Usage({category:"Work-Items",description:"Create a manual task work-item."});title=p.String("--title",{required:!0,description:"Task title."});description=p.String("--description",{description:"Task description."});application=p.String("--application",{description:"Link to an application id."});group=p.String("--group",{description:"Team (permission-group) id whose queue holds the task."});assignee=p.String("--assignee",{description:"Assignee users._id."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.mutation(S.workItems.createManual,{client:n,title:this.title,...this.description?{description:this.description}:{},...this.application?{applicationId:this.application}:{},...this.group?{queueGroupId:this.group}:{},...this.assignee?{assigneeUserId:this.assignee}:{}});return this.print({workItemId:r.workItemId},i=>[{field:"workItemId",value:i.workItemId}]),0}},sE=class extends N{static{s(this,"WorkItemsCompleteCommand")}static paths=[["work-items","complete"]];static usage=R.Usage({category:"Work-Items",description:"Complete a work-item (optionally with an outcome)."});workItemId=p.String({required:!0,name:"workItemId"});outcome=p.String("--outcome",{description:"Outcome id to record."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.mutation(S.workItems.complete,{client:n,workItemId:this.workItemId,...this.outcome?{outcome:this.outcome}:{}});return this.print({workItemId:r.workItemId,status:"done"},i=>[{field:"workItemId",value:i.workItemId},{field:"status",value:i.status}]),0}},aE=class extends N{static{s(this,"WorkItemsAssignCommand")}static paths=[["work-items","assign"]];static usage=R.Usage({category:"Work-Items",description:"Assign a work-item to a user (omit --user to unassign)."});workItemId=p.String({required:!0,name:"workItemId"});user=p.String("--user",{description:"Assignee users._id (omit to clear)."});async execute(){let t=await this.caller(),n=this.requireTenant(t),r=await t.mutation(S.workItems.assign,{client:n,workItemId:this.workItemId,...this.user?{userId:this.user}:{}});return this.print({workItemId:r.workItemId,assignee:this.user??"(cleared)"},i=>[{field:"workItemId",value:i.workItemId},{field:"assignee",value:i.assignee}]),0}},BK=[rE,iE,oE,sE,aE];var Uc=[...j$,...C_,...V_,...eN,...XC,...TN,...CN,..._N,...LK,...KK,...FK,...Nq,...y_,...xN,...EK,...q$,...uR,...m_,...FN,...DN,...qN,...KN,...bN,...sN,...BK,...C0,...wM,..._q,...kM,...lK,...gK,...Dq,...Vq,...Wq,...kK,...IK,...rR];for(let e of Uc){let t=e.paths?.[0];t===void 0||!Object.hasOwn(e,"usage")||e.usage===void 0||(e.usage={...e.usage,category:lT(e.usage.category,t.join(" "))})}var UK="0.1.60";function VK(){return Uc.flatMap(e=>(e.paths??[]).map(t=>{let n=t.join(" "),r=iT[io(n)];return{path:n,effect:oo(n),host:r===void 0?"shared":"terminal",...r===void 0?{}:{reason:r}}})).sort((e,t)=>e.path.localeCompare(t.path))}s(VK,"plexusCommandCatalog");import Wo from"node:path";function EQ(e){let t=st()?.workspaceRoot??process.cwd(),n=Wo.resolve(t,e),r=Wo.relative(t,n);if(Wo.isAbsolute(e)||r===".."||r.startsWith(`..${Wo.sep}`))throw new Error("plexus: use a relative path inside the current workspace.");return{absolute:n,relative:r}}s(EQ,"workspacePath");function TQ(e){let{absolute:t,relative:n}=EQ(e.path??".");if(e.operation==="list"){if(!Ae(t))return{files:[]};let r=[],i=s(o=>{for(let a of xr(o,{withFileTypes:!0})){if(a.isSymbolicLink())throw new Error("plexus: workspace symlinks are not supported.");let l=Wo.join(o,a.name);if(a.isDirectory()?i(l):r.push(Wo.relative(t,l)),r.length>200)throw new Error("plexus: the workspace contains too many files. List a subdirectory.")}},"visit");return i(t),{files:r.sort()}}if(!n)throw new Error("plexus: name a workspace file.");if(["read","search","edit"].includes(e.operation)){let r=ye(t);if(r.length>10*1024*1024)throw new Error("plexus: the workspace file exceeds 10 MB.");let i=new TextDecoder("utf-8",{fatal:!0}).decode(r);if(e.operation==="read"){let l=e.offset??0,d=e.maxChars??8e3,c=i.slice(l,l+d);return{path:n,content:c,...l||c.length<i.length?{offset:l,nextOffset:l+c.length<i.length?l+c.length:null,totalCharacters:i.length}:{}}}if(e.operation==="search"){if(!e.query)throw new Error("plexus: search needs a nonempty query.");let l=[],d=e.offset??0;for(;l.length<10;){let c=i.indexOf(e.query,d);if(c<0)break;l.push({offset:c,text:i.slice(Math.max(0,c-160),c+e.query.length+240)}),d=c+e.query.length}return{path:n,matches:l,nextOffset:l.length===10?d:null}}if(!e.oldText||typeof e.content!="string")throw new Error("plexus: edit needs oldText and replacement content.");let o=i.indexOf(e.oldText);if(o<0||o!==i.lastIndexOf(e.oldText))throw new Error("plexus: oldText must match exactly once. Read the current file and choose unique context.");let a=i.slice(0,o)+e.content+i.slice(o+e.oldText.length);if(Buffer.byteLength(a)>10*1024*1024)throw new Error("plexus: the edited file exceeds 10 MB.");return lt(t,a,"utf8"),{path:n,sizeBytes:Buffer.byteLength(a)}}if(e.operation==="write"){if(typeof e.content!="string"||Buffer.byteLength(e.content)>1e6)throw new Error("plexus: file content is missing or too large.");return Pt(Wo.dirname(t),{recursive:!0}),lt(t,e.content,"utf8"),{path:n,sizeBytes:Buffer.byteLength(e.content)}}if(e.operation==="remove")return Qo(t),{path:n,removed:!0};throw new Error("plexus: unknown workspace operation.")}s(TQ,"plexusWorkspace");function GK(e){return s(async function(n,r){if(!r||typeof r!="object"||Array.isArray(r))throw new Error("plexus: tool input must be an object.");let i=r,o=Ya[n];if(!o||!Object.hasOwn(Ya,n))throw new Error("plexus: unknown agent tool.");if(Object.keys(i).some(a=>!Object.hasOwn(o.inputSchema.properties,a)))throw new Error("plexus: unexpected tool argument.");if(n==="plexus"){if(!Array.isArray(i.argv)||i.argv.some(a=>typeof a!="string")||i.stdin!==void 0&&typeof i.stdin!="string")throw new Error("plexus: invalid command input.");return e.inspectCommand(i.argv),e.executeCommand({argv:i.argv,...i.stdin===void 0?{}:{stdin:i.stdin}})}if(n==="plexus_skill"){if(typeof i.path!="string"||i.path.length>240||!Object.hasOwn(Sg,i.path))throw new Error("plexus: unknown skill reference. Start with SKILL.md.");return{path:i.path,content:Sg[i.path],skillHash:Mu}}if(typeof i.operation!="string"||!["list","read","search","edit","write","remove"].includes(i.operation)||i.path!==void 0&&(typeof i.path!="string"||i.path.length>500)||i.content!==void 0&&(typeof i.content!="string"||i.content.length>1e6)||i.oldText!==void 0&&(typeof i.oldText!="string"||i.oldText.length>1e6)||i.query!==void 0&&(typeof i.query!="string"||!i.query.length||i.query.length>1e3)||i.offset!==void 0&&(typeof i.offset!="number"||!Number.isSafeInteger(i.offset)||i.offset<0)||i.maxChars!==void 0&&(typeof i.maxChars!="number"||!Number.isSafeInteger(i.maxChars)||i.maxChars<1||i.maxChars>24e3))throw new Error("plexus: invalid workspace input.");return TQ(i)},"executePlexusAgentTool")}s(GK,"createPlexusAgentToolExecutor");var lh=GK({inspectCommand:WK,executeCommand:YK});function dh(){let e=new ts({binaryLabel:"Plexus CLI",binaryName:"plexus-cli",binaryVersion:UK});e.register(Pa.HelpCommand),e.register(Pa.VersionCommand);for(let n of Uc)e.register(n);async function t(n,r){let i;try{i=e.process(n,r)}catch(o){return(r.stderr??process.stderr).write(e.error(o,{colored:!1})),2}return IQ(i,r.stderr??process.stderr),e.run(i,r)}return s(t,"run"),{process(n,r){return e.process(n,r)},run:t,async runExit(n,r){process.exitCode=await t(n,r)}}}s(dh,"createPlexusCli");function IQ(e,t){let n=e.path.join(" "),r=e.constructor.paths?.[0]?.join(" ");r!==void 0&&n!==r&&Fa[n]===r&&it(t,n,r),n in Fa&&oo(n)==="confirm"&&!La(e)&&t.write(`plexus-cli: \`${Fa[n]}\` only prints its plan without --confirm \u2014 nothing was changed.
10653
10653
  `)}s(IQ,"noteRetiredPath");function WK(e){let t=dh().process(xa(e),{executePlexusAgentTool:lh}),n=t.path.join(" ");if(n.startsWith("agent "))throw new Error("plexus: nested agent transports are not allowed.");let r=VK().find(l=>l.path===n);if(!r){if(n===""||n==="--help"||n==="--version")return{path:n,writes:!1,host:"shared"};throw new Error(`plexus: command ${n} has no host classification.`)}let i=t,o=r.effect==="callKind"?Ep(ta(na),i.fn??"",i.kind):void 0,a=Eu(n,{confirm:La(t),callKind:o});return{...r,writes:a}}s(WK,"inspectPlexusCommand");async function YK(e,t){if(t)return cE(t,()=>YK(e));if(!Array.isArray(e.argv)||e.argv.length===0||e.argv.length>128||e.argv.some(l=>typeof l!="string"||l.length>128e3)||(e.stdin?.length??0)>1e6)throw new Error("plexus: invalid command invocation.");let n="",r="",i=dh();if(st()){let l=WK(e.argv);if(l.host==="terminal")throw new Error(`plexus: this command requires a local machine. ${l.reason??""}`)}return{exitCode:await i.run(xa(e.argv),{executePlexusAgentTool:lh,stdin:RQ.from(e.stdin===void 0?[]:[e.stdin]),stdout:new zK({write(l,d,c){n+=String(l),c()}}),stderr:new zK({write(l,d,c){r+=String(l),c()}})}),stdout:n,stderr:r}}s(YK,"executePlexusCommand");hE({source:OQ.join(import.meta.dirname,"skill")});dh().runExit(xa(process.argv.slice(2)),{executePlexusAgentTool:lh});
10654
10654
  //# sourceMappingURL=cli.mjs.map