@smartkomm/plexus-cli 0.1.196 → 0.1.197

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
@@ -11292,7 +11292,7 @@ Ihr Aufnahme-Team`,noReplyNote:"Diese E-Mail wurde automatisch versandt. Bitte a
11292
11292
  The admissions team`,noReplyNote:"This e-mail was sent automatically. Please do not reply to it."}},P4={de:{...gd.de,closing:`Viele Gr\xFC\xDFe
11293
11293
  Ihr Plexus-Team`},en:{...gd.en,closing:`Kind regards
11294
11294
  The Plexus team`}},C4={de:{...gd.de,closing:null},en:{...gd.en,closing:null}};var D4=/\{\{([a-zA-Z][a-zA-Z0-9_]*)\}\}/g,Qo=2e3;function cm(e){let n=[];for(let t of e.matchAll(D4)){let r=t[1];n.includes(r)||n.push(r)}return n}s(cm,"placeholdersIn");function hF(e){return e.slots??[]}s(hF,"slotsOf");function F4(e){return e.bodyVariants!==void 0?e.bodyVariants:[hF(e).filter(n=>n.key!==Vl).map(n=>n.key)]}s(F4,"bodyVariantsOf");var L4=/:\/\/|www\.|mailto:/i;function M4(e,n){let t=`{{${n}}}`,r=0;for(;;){let i=e.indexOf(t,r);if(i===-1)return!1;let o=i===0?"":e[i-1],a=e[i+t.length]??"";if(o!==""&&!/\s/.test(o)||a!==""&&!/[\s.,;:!?)]/.test(a))return!0;r=i+t.length}}s(M4,"linkGlued");function q4(e,n){let t=e.default[n];return(typeof t!="string"||t.length===0)&&F(`notifications: slot "${e.key}" has no "${n}" text`),t}s(q4,"defaultText");function gF(e,n,t){let r=[],i=hF(e),o=e.placeholders??[],a=o.map(u=>u.key),l=o.filter(u=>u.subjectSafe===!0).map(u=>u.key);for(let[u,p]of Object.entries(n)){let h=i.find(w=>w.key===u);if(h===void 0){r.push({slotKey:u,code:"unknownSlot",message:i.length===0?{de:`Der Brief \u201E${e.label}\u201C l\xE4sst sich nicht anpassen.`,en:`The letter "${e.label}" cannot be customized.`}:{de:`Der Baustein \u201E${u}\u201C geh\xF6rt nicht zum Brief \u201E${e.label}\u201C.`,en:`The block "${u}" does not belong to the letter "${e.label}".`}});continue}if(p.trim().length===0){r.push({slotKey:u,code:"empty",message:{de:`\u201E${h.label}\u201C darf nicht leer sein. Zum Entfernen den Baustein zur\xFCcksetzen.`,en:`"${h.label}" must not be empty. To remove it, reset the block.`}});continue}if(p.length>Qo){r.push({slotKey:u,code:"tooLong",message:{de:`\u201E${h.label}\u201C ist ${p.length} Zeichen lang, erlaubt sind ${Qo}.`,en:`"${h.label}" is ${p.length} characters long; the limit is ${Qo}.`}});continue}if(fN(e)){L4.test(p)&&r.push({slotKey:u,code:"foreignUrl",message:{de:`\u201E${h.label}\u201C enth\xE4lt eine Adresse. Der Brief \u201E${e.label}\u201C tr\xE4gt einen Anmeldeschl\xFCssel und darf keine weiteren Links enthalten.`,en:`"${h.label}" contains an address. The letter "${e.label}" carries a sign-in key and must not contain any further links.`}});for(let w of o)w.link!==!0||!M4(p,w.key)||r.push({slotKey:u,code:"linkNotStandalone",message:{de:`\u201E{{${w.key}}}\u201C (${w.label}) muss f\xFCr sich stehen \u2014 davor und dahinter nur ein Leerzeichen, ein Zeilenumbruch oder ein Satzzeichen.`,en:`"{{${w.key}}}" (${w.label}) must stand on its own \u2014 only a space, a line break or punctuation before and after it.`}})}for(let w of cm(p)){if(!a.includes(w)){r.push({slotKey:u,code:"unknownPlaceholder",message:w===Ur?{de:`\u201E{{${Ur}}}\u201C (${Ia}) geh\xF6rt in die Anrede des Briefrahmens, nicht in \u201E${h.label}\u201C \u2014 dort gibt es eine neutrale Anrede, wenn kein Name bekannt ist.`,en:`"{{${Ur}}}" (${Ia}) belongs in the greeting of the letter frame, not in "${h.label}" \u2014 the greeting has a neutral form for when no name is known.`}:a.length===0?{de:`Der Brief \u201E${e.label}\u201C kennt keine Platzhalter, \u201E{{${w}}}\u201C bliebe unersetzt stehen.`,en:`The letter "${e.label}" has no placeholders; "{{${w}}}" would stay in the text unreplaced.`}:{de:`\u201E{{${w}}}\u201C gibt es in \u201E${e.label}\u201C nicht. Erlaubt: ${a.map(y=>`{{${y}}}`).join(", ")}.`,en:`"{{${w}}}" does not exist in "${e.label}". Allowed: ${a.map(y=>`{{${y}}}`).join(", ")}.`}});continue}if(u!==Vl||l.includes(w))continue;let k=o.find(y=>y.key===w)?.label??w;r.push({slotKey:u,code:"subjectUnsupported",message:{de:`\u201E{{${w}}}\u201C (${k}) l\xE4sst sich im Betreff nicht einsetzen \u2014 der Wert entsteht erst beim Versand. `+(l.length===0?"In diesem Brief kann der Betreff keine Platzhalter tragen.":`Im Betreff m\xF6glich: ${l.map(y=>`{{${y}}}`).join(", ")}.`),en:`"{{${w}}}" (${k}) cannot be used in the subject \u2014 the value only exists when the mail is sent. `+(l.length===0?"In this letter the subject cannot carry placeholders.":`Possible in the subject: ${l.map(y=>`{{${y}}}`).join(", ")}.`)}})}}let d=s(u=>n[u]??K4(i,u,t),"textOf"),c=F4(e);for(let u of o){if(u.required!==!0)continue;let p=c.filter(y=>!cm(y.map(d).join(`
11295
- `)).includes(u.key));if(p.length===0)continue;let h=s((y,v)=>y.map(E=>v(i.find(T=>T.key===E)?.label??E)).join(" + "),"variantLabel"),w=c.length===1?"":` Er fehlt in der Fassung aus ${p.map(y=>h(y,v=>`\u201E${v}\u201C`)).join(" und in der aus ")}.`,k=c.length===1?"":` It is missing in the version made of ${p.map(y=>h(y,v=>`"${v}"`)).join(" and in the one made of ")}.`;r.push({slotKey:u.key,code:"missingRequired",message:{de:`Ohne \u201E{{${u.key}}}\u201C (${u.label}) funktioniert der Brief \u201E${e.label}\u201C nicht \u2014 der Platzhalter muss im Text stehen, nicht nur im Betreff.`+w,en:`Without "{{${u.key}}}" (${u.label}) the letter "${e.label}" does not work \u2014 the placeholder must be in the text, not only in the subject.`+k}})}return r}s(gF,"validateOverride");function K4(e,n,t){let r=e.find(i=>i.key===n);return r===void 0?"":q4(r,t)}s(K4,"defaultTextOf");function Zk(e){let n=e?.trim();return n===void 0||n.length===0?void 0:n}s(Zk,"normalizeChromeText");var Zo=s(e=>String.fromCharCode(e),"cp"),j4=new RegExp(`[${Zo(0)}-${Zo(31)}${Zo(127)}]`,"g"),V4=new RegExp(`[${Zo(8234)}-${Zo(8238)}${Zo(8294)}-${Zo(8297)}]`,"g");var B4=200;function U4(e,n=B4){return e.replace(j4," ").replace(V4,"").replace(/\s+/g," ").trim().slice(0,n)}s(U4,"sanitizeHeaderValue");function um(e){return U4(e.replace(/["<>@]/g,""),100)}s(um,"sanitizeDisplayName");var Xk={de:{de:"Deutsch",en:"German"},en:{de:"Englisch",en:"English"}},G4={greeting:{de:"Anrede",en:"Greeting"},closing:{de:"Gru\xDFformel",en:"Closing"}};function yF(e){let n=[],t=[];for(let i of["greeting","closing"]){let o=e[i];if(o===void 0)continue;let a=G4[i],l=Rn(o);l!=="not-localized"&&l.length>0&&l.length<We.length&&t.push({de:`${a.de} fehlt auf ${l.map(d=>Xk[d].de).join(" und ")}`,en:`${a.en} is missing in ${l.map(d=>Xk[d].en).join(" and ")}`});for(let d of We){let c=vw(h=>`${a[h]} (${Xk[d][h]})`),u=Zk(o[d]);u!==void 0&&u.length>Qo&&n.push({de:`${c.de} hat ${u.length} Zeichen \u2014 h\xF6chstens ${Qo}; der Briefrahmen ist eine Zeile der Mail, kein Dokument.`,en:`${c.en} has ${u.length} characters \u2014 at most ${Qo}; the letter frame is one line of the mail, not a document.`});let p=i==="greeting"?[Ur]:[];for(let h of cm(u??""))p.includes(h)||n.push(p.length===0?{de:`${c.de} kann keine Platzhalter tragen \u2014 \u201E{{${h}}}\u201C bliebe unersetzt stehen.`,en:`${c.en} cannot carry placeholders \u2014 "{{${h}}}" would stay in the text unreplaced.`}:{de:`\u201E{{${h}}}\u201C gibt es in der ${c.de} nicht. Erlaubt: {{${Ur}}} (${Ia}).`,en:`"{{${h}}}" does not exist in the ${c.en}. Allowed: {{${Ur}}} (${Ia}).`})}}t.length>0&&n.unshift({de:`[notification/chromeMissingTranslation] ${t.map(i=>i.de).join("; ")} \u2014 der Briefrahmen gilt f\xFCr jeden Brief, in jeder Sprache.`,en:`[notification/chromeMissingTranslation] ${t.map(i=>i.en).join("; ")} \u2014 the letter frame applies to every letter, in every language.`});let r=Zk(e.senderName);return r!==void 0&&um(r)!==r&&n.push({de:`Absendername (senderName) \u201E${r}\u201C \xFCbersteht die Kopfzeile der Mail nicht unver\xE4ndert \u2014 er ginge als \u201E${um(r)}\u201C hinaus. Keine Anf\xFChrungszeichen, spitzen Klammern, \u201E@\u201C oder Steuerzeichen.`,en:`The sender name (senderName) "${r}" does not survive the mail header unchanged \u2014 it would go out as "${um(r)}". No quotation marks, angle brackets, "@" or control characters.`}),n}s(yF,"chromeFindings");var wF=m.object({family:m.string()}),kF=m.object({family:m.string(),url:m.optional(m.string())}),WAe=m.object({heading:m.optional(kF),body:m.optional(kF)}),z4=m.union(m.literal("sharp"),m.literal("rounded"),m.literal("soft")),W4=m.union(m.literal("light"),m.literal("dark")),Y4=m.union(m.literal("sm"),m.literal("md"),m.literal("lg"),m.literal("max")),H4=m.union(m.literal("compact"),m.literal("normal"),m.literal("spacious")),J4=m.object({primary:m.optional(m.string()),accent:m.optional(m.string()),background:m.optional(m.string()),foreground:m.optional(m.string())}),Q4=m.object({heading:m.optional(wF),body:m.optional(wF)}),YAe=m.object({colors:m.optional(J4),radius:m.optional(z4),logoSize:m.optional(Y4),bannerDensity:m.optional(H4),logoGround:m.optional(W4),filledHeader:m.optional(m.boolean()),websiteUrl:m.optional(m.string()),fonts:m.optional(Q4)}),HAe=m.object({primaryUrl:m.union(m.null(),m.string())}),JAe=m.literal("primary"),QAe=m.object({headingUrl:m.union(m.null(),m.string()),bodyUrl:m.union(m.null(),m.string())}),ZAe=m.union(m.literal("heading"),m.literal("body")),fm=["logo","fontHeading","fontBody"],bF={logo:null,fontHeading:"heading",fontBody:"body"};function vF(e){let{contentType:n,size:t}=e;return n==null||!n.startsWith("image/")?{de:`Das Logo muss ein Bild sein (erhalten: \u201E${n??"unbekannt"}\u201C).`,en:`The logo must be an image (received: "${n??"unknown"}").`}:n.startsWith("image/svg")?{de:"Das Logo muss eine Rastergrafik sein (PNG, JPEG oder GIF) \u2013 E-Mail-Programme zeigen SVG nicht an.",en:"The logo must be a raster image (PNG, JPEG or GIF) \u2013 email clients do not display SVG."}:t>3e6?{de:`Das Logo ist zu gro\xDF (${t} Byte, h\xF6chstens 3000000 Byte).`,en:`The logo is too large (${t} bytes, at most 3000000 bytes).`}:null}s(vF,"logoFileProblem");var eb="font/woff2";var Z4=["Inter Variable","Azeret Mono Variable","Source Sans 3 Variable"];function xF(e){return e?.trim()?Z4.some(n=>n.toLowerCase()===e.trim().toLowerCase())?{de:`\u201E${e}\u201C ist die Schrift von Plexus selbst \u2013 w\xE4hlen Sie f\xFCr eine eigene Datei einen anderen Familiennamen.`,en:`"${e}" is Plexus's own typeface \u2013 choose a different family name for your own file.`}:null:{de:"Speichern Sie zuerst die Schriftfamilie \u2013 die Datei wird unter diesem Namen eingebunden.",en:"Save the font family first \u2013 the file is registered under that name."}}s(xF,"fontFamilyProblem");var X4=["approved","rejected","withdrawn","waitlist","expired"];var pm=["admitted","rejected","withdrawn","waitlist","expired","unknown"],oEe=m.union(...X4.map(e=>m.literal(e))),sEe=m.union(...pm.map(e=>m.literal(e))),e3=["approved","rejected","waitlist"],n3=["withdrawn","expired"],t3=m.union(...e3.map(e=>m.literal(e))),r3=m.union(...n3.map(e=>m.literal(e))),aEe={active:{status:m.literal("active")},completed:{status:m.literal("completed"),outcome:t3,endedAt:m.number()},aborted:{status:m.literal("aborted"),outcome:m.optional(r3),endedAt:m.number()}};var SF=30,AF=3650;var i3=m.object({admitted:m.optional(m.number()),rejected:m.optional(m.number()),withdrawn:m.optional(m.number()),expired:m.optional(m.number()),waitlist:m.optional(m.number()),unknown:m.optional(m.number())}),pEe=i3.fields,o3=s(e=>pm.includes(e),"isClassification");function EF(e,n="tenant.retentionDays"){if(e===null||typeof e!="object"||Array.isArray(e))return[`[retention/shape] ${n} must be an object of days per classification (got ${JSON.stringify(e)}).`];let t=[];for(let[r,i]of Object.entries(e)){if(!o3(r)){t.push(`[retention/unknownClassification] ${n}.${r} is no retention classification \u2014 one of ${pm.join(", ")}.`);continue}(typeof i!="number"||!Number.isSafeInteger(i)||i<SF||i>AF)&&t.push(`[retention/days] ${n}.${r} must be a whole number of days from ${SF} to ${AF} (got ${JSON.stringify(i)}).`)}return t}s(EF,"retentionDaysFindings");var s3=["ad","ae","af","ag","ai","al","am","ao","aq","ar","as","at","au","aw","ax","az","ba","bb","bd","be","bf","bg","bh","bi","bj","bl","bm","bn","bo","bq","br","bs","bt","bv","bw","by","bz","ca","cc","cd","cf","cg","ch","ci","ck","cl","cm","cn","co","cr","cu","cv","cw","cx","cy","cz","de","dj","dk","dm","do","dz","ec","ee","eg","eh","er","es","et","fi","fj","fk","fm","fo","fr","ga","gb","gd","ge","gf","gg","gh","gi","gl","gm","gn","gp","gq","gr","gs","gt","gu","gw","gy","hk","hm","hn","hr","ht","hu","id","ie","il","im","in","io","iq","ir","is","it","je","jm","jo","jp","ke","kg","kh","ki","km","kn","kp","kr","kw","ky","kz","la","lb","lc","li","lk","lr","ls","lt","lu","lv","ly","ma","mc","md","me","mf","mg","mh","mk","ml","mm","mn","mo","mp","mq","mr","ms","mt","mu","mv","mw","mx","my","mz","na","nc","ne","nf","ng","ni","nl","no","np","nr","nu","nz","om","pa","pe","pf","pg","ph","pk","pl","pm","pn","pr","ps","pt","pw","py","qa","re","ro","rs","ru","rw","sa","sb","sc","sd","se","sg","sh","si","sj","sk","sl","sm","sn","so","sr","ss","st","sv","sx","sy","sz","tc","td","tf","tg","th","tj","tk","tl","tm","tn","to","tr","tt","tv","tw","tz","ua","ug","um","us","uy","uz","va","vc","ve","vg","vi","vn","vu","wf","ws","xk","ye","yt","za","zm","zw"],a3=new Set(s3);function mm(e){return a3.has(e)}s(mm,"isCountryCode");var nb=["off","always","deviating"],TF={mode:"deviating",defaultCountryCode:"de"};var l3=["street","plz","ort"];function d3(e){return l3.filter(n=>!e.has(n))}s(d3,"missingInvoiceAddressParts");var c3=new Set(["0-1-select","0-n-select"]);function $F(e){return e===void 0?null:new Set(e.properties.flatMap(n=>n.addressPart!==void 0&&ZO(n.addressPart)?[n.addressPart]:[]))}s($F,"declaredAddressParts");function u3(e){return c3.has(e)}s(u3,"isSelectFieldKind");function RF(e){let n=[];for(let o of e)if(o.isNationality&&(u3(o.kind)?o.listKind!=="country"&&n.push({code:"nationality/notCountryList",fieldKey:o.key}):n.push({code:"nationality/wrongFieldKind",fieldKey:o.key})),o.isAccountEmail&&o.kind!=="email"&&n.push({code:"accountEmail/wrongFieldKind",fieldKey:o.key}),o.isContactPhone&&o.kind!=="tel"&&n.push({code:"contactPhone/wrongFieldKind",fieldKey:o.key}),o.isInvoiceAddress)if(o.addressParts===null)n.push({code:"invoiceAddress/wrongFieldKind",fieldKey:o.key});else{let a=d3(o.addressParts);a.length>0&&n.push({code:"invoiceAddress/missingPart",fieldKey:o.key,parts:a})}let t=e.filter(o=>o.isAccountEmail);if(t.length>1)for(let o of t)n.push({code:"accountEmail/multiple",fieldKey:o.key});let r=e.filter(o=>o.isContactPhone);if(r.length>1)for(let o of r)n.push({code:"contactPhone/multiple",fieldKey:o.key});let i=e.filter(o=>o.isInvoiceAddress);if(i.length>1)for(let o of i)n.push({code:"invoiceAddress/multiple",fieldKey:o.key});return n}s(RF,"fieldRoleFindings");function IF(e,n,...t){let r=e[n.code];return r(n,...t)}s(IF,"wordListElementFinding");function OF(e,n){let t=[];for(let r of n){if(e.kind==="plain"){r.countryCode!==void 0&&t.push({code:"list/countryCodeOnPlain",elementKey:r.key,countryCode:r.countryCode});continue}r.countryCode===void 0?t.push({code:"list/countryCodeMissing",elementKey:r.key}):r.countryCode!==null&&!mm(r.countryCode)&&t.push({code:"list/unknownCountryCode",elementKey:r.key,countryCode:r.countryCode})}return t}s(OF,"listElementCountryFindings");var p3={key:!0,tenant:!0,foundation:!0,source:!0,displayGroups:!0,lists:!0,roles:!0,fields:!0,roleFields:!0,contractRoleMappings:!0,templatePlaceholders:!0,searchTargets:!0,searchFilters:!0,partyResultIcons:!0,notificationLetters:!0,admission:!0,files:!0,agent:!0,deferredColumns:!0,ignoredColumns:!0},m3={slug:!0,name:!0,enabledModules:!0,permissions:!0,defaultApplicantGroupKey:!0,defaultEnrolleeRoleKey:!0,priceCriteriaFacts:!0,defaultInteressentRoleKey:!0,admissionFieldDisplayGroupKey:!0,defaultStartInProxy:!0,terms:!0,retentionDays:!0,mailLevel:!0,notificationChrome:!0,hideMailLevelNotice:!0,unassignedTaskNoticeDays:!0,magicLinkLogin:!0,externalSignIn:!0,nationalityFlag:!0,adminSeesSignatureImages:!0,signatureStamp:!0,bankImportScope:!0,branding:!0,brandingAssets:!0,partyRetention:!0},h3=new Set(["enabledMailCategories","mailEnabled"]);function g3(e){let n=s((t,r,i)=>t.filter(o=>!Object.hasOwn(r,o)&&!(i==="tenant."&&h3.has(o))).map(o=>`[config/unknownKey] ${i}${o} is not a config field of this release \u2014 a typo, or a field a newer release introduced.`),"unknown");return[...n(Object.keys(e),p3,""),...n(Object.keys(e.tenant),m3,"tenant.")]}s(g3,"unknownKeyFindings");var _F=["plain","country"],y3={"list/countryCodeMissing":s(({elementKey:e},n)=>`Element "${n}.${e}" of a country list must state countryCode (null for no state).`,"list/countryCodeMissing"),"list/countryCodeOnPlain":s(({elementKey:e},n)=>`Element "${n}.${e}" carries countryCode, but list "${n}" is not kind "country".`,"list/countryCodeOnPlain"),"list/unknownCountryCode":s(({elementKey:e,countryCode:n},t)=>`Element "${t}.${e}" has unknown countryCode ${JSON.stringify(n)}.`,"list/unknownCountryCode")},w3={"nationality/wrongFieldKind":s(({fieldKey:e})=>`Field "${e}" is isNationality but not a 0-1-select / 0-n-select.`,"nationality/wrongFieldKind"),"nationality/notCountryList":s(({fieldKey:e})=>`Field "${e}" is isNationality but its list is not kind "country".`,"nationality/notCountryList"),"accountEmail/wrongFieldKind":s(({fieldKey:e})=>`Field "${e}" is isAccountEmail but not an email field.`,"accountEmail/wrongFieldKind"),"accountEmail/multiple":s(({fieldKey:e})=>`Field "${e}" is one of several isAccountEmail fields \u2014 at most one per tenant.`,"accountEmail/multiple"),"contactPhone/wrongFieldKind":s(({fieldKey:e})=>`Field "${e}" is isContactPhone but not a tel field.`,"contactPhone/wrongFieldKind"),"contactPhone/multiple":s(({fieldKey:e})=>`Field "${e}" is one of several isContactPhone fields \u2014 at most one per tenant.`,"contactPhone/multiple"),"invoiceAddress/wrongFieldKind":s(({fieldKey:e})=>`Field "${e}" is isInvoiceAddress but not an object field.`,"invoiceAddress/wrongFieldKind"),"invoiceAddress/missingPart":s(({fieldKey:e,parts:n})=>`Field "${e}" is isInvoiceAddress but declares no property for the address part(s) ${n.join(", ")} (objectSchema.properties[].addressPart) \u2014 an invoice cannot print its address without them.`,"invoiceAddress/missingPart"),"invoiceAddress/multiple":s(({fieldKey:e})=>`Field "${e}" is one of several isInvoiceAddress fields \u2014 at most one per tenant.`,"invoiceAddress/multiple")};function k3(e){let n=w3[e.code];return n(e)}s(k3,"roleText");function b3(e){let n=[],t=e.tenant.nationalityFlag,r=typeof t=="object"&&t!==null?t:{},i=r.mode;if(nb.includes(i)||n.push(`[nationality/flagMode] tenant.nationalityFlag.mode must be one of ${nb.join(", ")} (got ${t===void 0?"no tenant.nationalityFlag":JSON.stringify(i??null)}).`),t!==void 0){let l=r.defaultCountryCode;(typeof l!="string"||!mm(l))&&n.push(`[nationality/defaultCountryCode] tenant.nationalityFlag.defaultCountryCode must be a lowercase ISO 3166-1 alpha-2 code (got ${JSON.stringify(l??null)}).`)}let o=new Map;for(let l of e.lists){let d=l.kind;if(!_F.includes(d)){n.push(`[list/kind] List "${l.key}" has kind ${JSON.stringify(d??null)} \u2014 one of ${_F.join(", ")}.`);continue}o.set(l.key,l.kind);for(let c of OF({key:l.key,kind:l.kind},l.elements))n.push(`[${c.code}] ${IF(y3,c,l.key)}`)}let a=RF(e.fields.map(l=>({key:l.key,kind:l.type,listKind:l.listKey===void 0?null:o.get(l.listKey)??null,isNationality:l.isNationality===!0,isAccountEmail:l.isAccountEmail===!0,isContactPhone:l.isContactPhone===!0,isInvoiceAddress:l.isInvoiceAddress===!0,addressParts:l.type==="object"?$F(l.objectSchema??{properties:[]}):null})));for(let l of a)n.push(`[${l.code}] ${k3(l)}`);return n}s(b3,"nationalityFindings");function NF(e){return $i(e)?.message.de??(e instanceof Error?e.message:String(e))}s(NF,"errorText");function DF(e,n={}){let t=[...g3(e)],r=[];try{iF(e.fields.map(b=>b.key),[])}catch(b){t.push(NF(b))}e.tenant.terms!==void 0&&t.push(...Qk(e.tenant.terms)),e.tenant.retentionDays!==void 0&&t.push(...EF(e.tenant.retentionDays)),dN(e.tenant.mailLevel)?e.tenant.mailLevel==="all"&&!sm(e.tenant.enabledModules,"notifications")&&t.push('[notification/levelWithoutModule] tenant.mailLevel is "all" but the notifications module is not enabled \u2014 only sign-in and security mail would go out. Enable the module or set "loginOnly".'):t.push(`[notification/mailLevel] tenant.mailLevel must be one of ${Ew.join(", ")} (got ${e.tenant.mailLevel===void 0?"nothing":JSON.stringify(e.tenant.mailLevel)}).`),"enabledMailCategories"in e.tenant&&t.push('[notification/mailCategoriesRetired] tenant.enabledMailCategories was replaced by tenant.mailLevel \u2014 "all" for every mail, "loginOnly" for sign-in mail only to families (staff mail follows personal settings).'),"mailEnabled"in e.tenant&&t.push('[notification/mailEnabledRetired] tenant.mailEnabled was replaced by tenant.mailLevel \u2014 "all" for every mail, "loginOnly" for sign-in mail only to families (staff mail follows personal settings).'),En(e.displayGroups.map(b=>b.key),"display group",t),En(e.lists.map(b=>b.key),"list",t),En(e.roles.map(b=>b.key),"role",t),En(e.fields.map(b=>b.key),"field",t),En(e.foundation.legalEntities.map(b=>b.key),"legal entity",t),En(e.foundation.units.map(b=>b.key),"unit",t),En(e.foundation.permissionGroups.map(b=>b.key),"permission group",t),"teams"in e.foundation&&t.push("foundation.teams is retired: a team is a permission group \u2014 move each team to foundation.permissionGroups (same key) and remove the block.");for(let b of e.foundation.users)"teamKeys"in b&&t.push(`User "${b.email}" carries teamKeys, retired: team membership is the user's permission-group membership.`);En(e.foundation.users.map(b=>b.key),"user",t),En((e.searchFilters??[]).map(b=>b.key),"search filter",t),En((e.searchTargets??[]).map(b=>b.objectPropertyKey===void 0?b.fieldKey:`${b.fieldKey}.${b.objectPropertyKey}`),"search target",t),En((e.partyResultIcons??[]).map(b=>b.key),"party result icon",t),En((e.templatePlaceholders??[]).map(b=>b.key),"template placeholder",t),En((e.notificationLetters??[]).map(FF),"notification letter",t),R3(e.notificationLetters??[],t),I3(e.tenant.notificationChrome,t),e.tenant.bankImportScope!==void 0&&!["sepa_only","full_statement"].includes(e.tenant.bankImportScope)&&t.push("tenant.bankImportScope must be sepa_only or full_statement."),e.tenant.hideMailLevelNotice!==void 0&&typeof e.tenant.hideMailLevelNotice!="boolean"&&t.push("tenant.hideMailLevelNotice must be true or false (the dashboard's mail-level notice)."),e.tenant.unassignedTaskNoticeDays!==void 0&&!cN(e.tenant.unassignedTaskNoticeDays)&&t.push("tenant.unassignedTaskNoticeDays must be a whole number from 1 to 30 (days before an unassigned team task is reported); leave it out for the platform default."),typeof e.tenant.magicLinkLogin!="boolean"&&t.push("tenant.magicLinkLogin must be true or false (the login page's sign-in link option)."),typeof e.tenant.adminSeesSignatureImages!="boolean"&&t.push("tenant.adminSeesSignatureImages must be true or false (whether a school administrator sees other accounts' signature images)."),typeof e.tenant.signatureStamp!="boolean"&&t.push("tenant.signatureStamp must be true or false (whether the school offers the signature stamp at the countersignature)."),nF(e.tenant.externalSignIn)?t.push(`[auth/externalSignInRetired] tenant.externalSignIn names the retired mode "${String(e.tenant.externalSignIn.mode)}" \u2014 every sign-in link now signs in once; state { mode: "oneTimeLink" }.`):eF(e.tenant.externalSignIn)||t.push('[auth/externalSignIn] tenant.externalSignIn must be { mode: "oneTimeLink" } (how families sign in).');let i=new Set(e.displayGroups.map(b=>b.key)),o=new Set(e.lists.map(b=>b.key)),a=new Set(e.roles.map(b=>b.key)),l=new Set(e.fields.map(b=>b.key)),d=new Map(e.fields.map(b=>[b.key,b])),c=new Set(e.foundation.legalEntities.map(b=>b.key)),u=new Set(e.foundation.units.map(b=>b.key)),p=new Set(e.foundation.permissionGroups.map(b=>b.key));sm(e.tenant.enabledModules,"bewerbungsmanagement")&&e.tenant.defaultApplicantGroupKey!==void 0&&(e.foundation.permissionGroups.find(I=>I.key===e.tenant.defaultApplicantGroupKey)?.permissions.includes("bewerbungsmanagement.applications.submitOwn")||t.push(`Default applicant group "${e.tenant.defaultApplicantGroupKey}" must grant submitOwn.`));let h=e.tenant.admissionFieldDisplayGroupKey;h!==void 0&&!i.has(h)&&t.push(`tenant.admissionFieldDisplayGroupKey "${h}" names no display group of this config.`),h===void 0&&(sm(e.tenant.enabledModules,"bewerbungsmanagement")||(e.admission?.fields.length??0)>0)&&t.push("tenant.admissionFieldDisplayGroupKey is required when admissions is enabled or admission.fields declares fields: it names the display group the fields an offer creates land in."),t.push(...b3(e)),En(e.fields.flatMap(b=>(b.relationshipKinds??[]).map(I=>I.key)),"relationship kind",t);for(let b of e.fields){i.has(b.displayGroupKey)||t.push(`Field "${b.key}" references missing display group "${b.displayGroupKey}".`),x3(b,t),b.formWritable===!0&&!Yk[b.type].fieldMapTarget&&t.push(`Field "${b.key}" is formWritable, but a form cannot write a "${b.type}" field.`),b.type==="files"&&b.shareable===!0&&t.push(`[field/filesShareable] Field "${b.key}" is a files field and cannot be shareable.`),b.type==="auto-string"?S3(b,d,t):b.autoString!==void 0&&t.push(`Non-automatic field "${b.key}" must not define autoString.`),(!Number.isFinite(b.sortOrder)||b.sortOrder<0)&&t.push(`Field "${b.key}" has invalid sortOrder "${b.sortOrder}" (must be a non-negative number).`),(b.type==="0-1-select"||b.type==="0-n-select")&&!b.listKey&&t.push(`Select field "${b.key}" must define listKey.`),b.type!=="0-1-select"&&b.type!=="0-n-select"&&b.listKey!==void 0&&t.push(`Non-select field "${b.key}" must not define listKey.`),b.listKey&&!o.has(b.listKey)&&t.push(`Field "${b.key}" references missing list "${b.listKey}".`),(b.type==="object"||b.type==="relationship")&&!b.objectSchema&&t.push(`Field "${b.key}" must define objectSchema.`),b.type!=="object"&&b.type!=="relationship"&&b.objectSchema&&t.push(`Non-object field "${b.key}" must not define objectSchema.`);for(let I of b.objectSchema?.properties??[])(I.type==="0-1-select"||I.type==="0-n-select")&&!I.listKey&&t.push(`Object select property "${b.key}.${I.key}" must define listKey.`),I.listKey&&!o.has(I.listKey)&&t.push(`Object property "${b.key}.${I.key}" references missing list "${I.listKey}".`);v3(b,t)}let w=e.tenant.priceCriteriaFacts;if(w){let b=e.fields.find(I=>I.key===w.birthDateFieldKey);(!b||b.type!=="date")&&t.push("Price criteria require a configured date field for birth dates."),a.has(w.studentRoleKey)||t.push("Price criteria require a configured Student eligibility role."),w.siblingRankSource!==void 0&&w.siblingRankSource!=="derived"&&w.siblingRankSource!=="chosen"&&t.push('Price criteria siblingRankSource must be "derived" or "chosen".');for(let I of Object.keys(w))I!=="birthDateFieldKey"&&I!=="studentRoleKey"&&I!=="siblingRankSource"&&t.push(`Unknown price criteria fact setting "${I}".`)}let k=e.tenant.defaultEnrolleeRoleKey;k&&!a.has(k)&&t.push(`Default enrollment role "${k}" does not exist.`),k&&e.roles.some(b=>b.parentRoleKey===k)&&t.push(`Default enrollment role "${k}" must be a leaf role.`);for(let b of e.roles){(typeof b.icon!="string"||b.icon.trim().length===0)&&t.push(`Role "${b.key}" must define an icon.`),b.parentRoleKey&&!a.has(b.parentRoleKey)&&t.push(`Role "${b.key}" references missing parent role "${b.parentRoleKey}".`);for(let I of b.listDisplayFieldKeys??[])l.has(I)||t.push(`Role "${b.key}" list display references missing field "${I}".`)}let y=new Map(e.roles.map(b=>[b.key,b.parentRoleKey])),v=new Map;for(let b of e.roleFields){let I=v.get(b.roleKey)??[];I.push({roleId:b.roleKey,customFieldId:b.fieldKey}),v.set(b.roleKey,I)}for(let b of e.roles)try{tF(b.key,y,v)}catch(I){t.push(NF(I))}for(let b of e.roleFields){a.has(b.roleKey)||t.push(`Role field references missing role "${b.roleKey}" for field "${b.fieldKey}".`),l.has(b.fieldKey)||t.push(`Role field references missing field "${b.fieldKey}" for role "${b.roleKey}".`);for(let I of b.targetRequirementFieldKeys??[])l.has(I)||t.push(`Role field "${b.roleKey}.${b.fieldKey}" references missing target requirement field "${I}".`)}$3(e.contractRoleMappings??[],a,t);for(let b of e.templatePlaceholders??[])ND.test(b.key)||t.push(`Template placeholder "${b.key}" must use lower_snake_case segments, optionally separated by dots.`),b.source.kind==="customField"?hm(b.source,d,t,`Template placeholder "${b.key}"`):b.source.kind==="relationshipTargetField"&&A3(b,d,t);for(let b of e.searchTargets??[])hm(b,d,t,"Search target");for(let b of e.fields)dF(b.key)&&(b.defaultValue!==void 0||b.validations!==void 0)&&t.push(`System field "${b.key}" takes no defaultValue or validations.`);for(let b of e.lists)En(b.elements.map((I,M)=>String(I.sortOrder??(M+1)*10)),`sortOrder of an element of list "${b.key}"`,t);for(let b of e.searchFilters??[])En((b.options??[]).map((I,M)=>String(I.sortOrder??(M+1)*10)),`sortOrder of an option of search filter "${b.key}"`,t);for(let b of e.foundation.permissionGroups){b.grantAllCustomFields===!0&&b.customFieldPermissions!==void 0&&t.push(`Permission group "${b.key}" states both grantAllCustomFields and customFieldPermissions \u2014 one of them.`),En((b.customFieldPermissions??[]).map(I=>I.displayGroupKey),`display group of a field permission of group "${b.key}"`,t);for(let I of b.customFieldPermissions??[]){i.has(I.displayGroupKey)||t.push(`Permission group "${b.key}" grants field permissions on missing display group "${I.displayGroupKey}".`);for(let M of I.permissions)sF.includes(M)||t.push(`Permission group "${b.key}" grants unknown field permission "${M}".`)}}let E=e.tenant.partyRetention;E!==void 0&&(lF(E.days)||t.push(`tenant.partyRetention.days must be a whole number of days from 1 to ${36500} (got ${JSON.stringify(E.days)}).`),Number.isFinite(E.enabledAt)||t.push("tenant.partyRetention.enabledAt must be a timestamp (epoch ms)."),E.formerRoleKey!==void 0&&!a.has(E.formerRoleKey)&&t.push(`tenant.partyRetention references missing role "${E.formerRoleKey}".`));for(let b of e.searchFilters??[]){(b.kind==="chips"||b.kind==="select")&&(b.options?.length??0)===0&&t.push(`Search filter "${b.key}" must define options.`),(b.kind==="text"||b.kind==="numberRange")&&b.target===void 0&&t.push(`Search filter "${b.key}" must define a target field.`),b.options!==void 0&&En(b.options.map(I=>I.key),`search filter option for "${b.key}"`,t),hm(b.target,d,t,`Search filter "${b.key}"`);for(let I of b.options??[]){I.predicates.length===0&&t.push(`Search filter option "${b.key}.${I.key}" must define at least one predicate.`);for(let M of I.predicates){if(M.kind==="role"){a.has(M.roleKey)||t.push(`Search filter option "${b.key}.${I.key}" references missing role "${M.roleKey}".`);continue}hm(M,d,t,`Search filter option "${b.key}.${I.key}"`)}}}for(let b of e.partyResultIcons??[])E3(b,d,t);for(let b of e.foundation.legalEntities)if(b.terms!==void 0&&t.push(...Qk(b.terms,`foundation.legalEntities.${b.key}.terms`)),PF(b.branding,t,`foundation.legalEntities.${b.key}.branding`),CF(b,t,`foundation.legalEntities.${b.key}`),b.signatoryUserKey!==void 0&&b.type==="school_group"&&t.push(`[config/signatoryOnGroup] Legal entity "${b.key}" is a school_group \u2014 only a Tr\xE4ger (school_operator, service_entity) declares an Unterschriftsperson.`),b.parentLegalEntityKey&&!c.has(b.parentLegalEntityKey)&&t.push(`Legal entity "${b.key}" references missing parent "${b.parentLegalEntityKey}".`),b.address!==void 0){let I=b.address,M=["street","hausnr","plz","ort"];b.type==="school_group"?t.push(`Legal entity "${b.key}" is a school_group \u2014 only a Tr\xE4ger (school_operator, service_entity) has an address.`):(typeof I!="object"||I===null||Array.isArray(I)||Object.keys(I).some(S=>!M.includes(S))||M.some(S=>typeof I[S]!="string"||(I[S]??"").trim()===""))&&t.push(`Legal entity "${b.key}" has an invalid address \u2014 expected { street, hausnr, plz, ort }, each non-empty.`)}let T=new Map;for(let b of e.foundation.units){if(b.slug!==void 0){let I=typeof b.slug=="string"?UD(b.slug):"must be a string";I!==void 0&&t.push(`Unit "${b.key}" has invalid slug "${b.slug}" (${I}).`);let M=T.get(b.slug);M!==void 0&&t.push(`Units "${M}" and "${b.key}" both declare slug "${b.slug}" (unit slugs are unique per tenant).`),T.set(b.slug,b.key)}c.has(b.legalEntityKey)||t.push(`Unit "${b.key}" references missing legal entity "${b.legalEntityKey}".`),b.parentUnitKey&&!u.has(b.parentUnitKey)&&t.push(`Unit "${b.key}" references missing parent unit "${b.parentUnitKey}".`),b.sortOrder!==void 0&&(!Number.isFinite(b.sortOrder)||b.sortOrder<0)&&t.push(`Unit "${b.key}" has invalid sortOrder "${b.sortOrder}" (must be a non-negative number).`)}let R=/^[0-9a-f]{32}:[0-9a-f]{128}$/;for(let b of e.foundation.users){p.has(b.permissionGroupKey)||t.push(`User "${b.email}" references missing permission group "${b.permissionGroupKey}".`),b.unitKey&&!u.has(b.unitKey)&&t.push(`User "${b.email}" references missing unit "${b.unitKey}".`),b.status!==void 0&&b.status!=="deactivated"&&t.push(`User "${b.email}": status must be "deactivated" or absent, not "${String(b.status)}".`);let I=[b,...b.additionalMemberships??[]];for(let S of b.additionalMemberships??[])p.has(S.permissionGroupKey)||t.push(`User "${b.email}" references missing permission group "${S.permissionGroupKey}".`),S.unitKey&&!u.has(S.unitKey)&&t.push(`User "${b.email}" references missing unit "${S.unitKey}".`);En(I.map(S=>`${S.permissionGroupKey}/${S.unitKey??""}`),`membership (permission group/unit) of user "${b.email}"`,t);for(let S of I)S.validFrom!==void 0&&S.validTo!==void 0&&S.validTo<=S.validFrom&&t.push(`User "${b.email}": membership "${S.permissionGroupKey}" ends (validTo) before it starts (validFrom).`);let M=[b.firstName,b.lastName];M.some(S=>S!==void 0)&&M.some(S=>typeof S!="string"||S.trim()==="")&&t.push(`[config/userNameIncomplete] User "${b.email}" states only part of firstName/lastName (or an empty one) \u2014 set both or neither.`);for(let S of["staging","prod"]){let j=b.passwordHashes?.[S];j!==void 0&&!R.test(j)&&t.push(`User "${b.email}" passwordHashes.${S} is not in Better Auth scrypt format "<32hex>:<128hex>".`)}}PF(e.tenant.branding,t),CF(e.tenant,t);let N=LF(e.fields.flatMap(b=>b.sourceColumns));for(let b of N)r.push(`Source column "${b}" is mapped by more than one field.`);N3(e,t);let P=n.sourceColumns===void 0||e.source===void 0?void 0:O3(e,n.sourceColumns,t);return{ok:t.length===0,errors:t,warnings:r,coverage:P}}s(DF,"validateTenantConfig");function v3(e,n){let t=new Map;for(let r of e.objectSchema?.properties??[]){let i=r.addressPart;if(i===void 0)continue;let o=`Object property "${e.key}.${r.key}"`;if(!rw.includes(i)){n.push(`${o}: addressPart "${i}" is none of ${rw.join(", ")}.`);continue}e.type!=="object"&&n.push(`${o}: only an object field stores an address (addressPart).`),r.type!=="string"&&n.push(`${o}: addressPart "${i}" needs a string property, not "${r.type}".`);let a=t.get(i);a!==void 0&&n.push(`${o}: addressPart "${i}" is already declared by "${e.key}.${a}".`),t.set(i,r.key)}}s(v3,"validateAddressParts");function x3(e,n){let t=e.relationshipKinds;if(t===void 0)return;if(e.type!=="relationship"){n.push(`Field "${e.key}" declares relationshipKinds, but only a relationship field carries them.`);return}let r=new Map((e.objectSchema?.properties??[]).map(i=>[i.key,i]));for(let i of t){let o=`Field "${e.key}" relationship kind "${i.key}"`;if(typeof i.key!="string"||i.key.trim()===""){n.push(`Field "${e.key}": a relationship kind needs a key.`);continue}for(let l of["de","en"])(i.label?.[l]??"").trim()===""&&n.push(`${o}: label.${l} is required \u2014 [i18n/missingTranslation] every shown text needs German and English.`);if(i.edge===null||typeof i.edge!="object"||Array.isArray(i.edge)){n.push(`${o}: edge must be an object.`);continue}i.sibling!==void 0&&i.sibling!==!0&&n.push(`${o}: sibling must be true or absent.`),i.sibling===!0&&i.mergeInto!==void 0&&n.push(`${o}: a sibling kind's edge is its identity \u2014 it cannot declare mergeInto.`);let a=t.flatMap(l=>l.mergeInto!==void 0?[l.mergeInto]:[]);if(i.sibling===!0&&a.some(l=>l in i.edge)&&n.push(`${o}: a sibling kind's edge is its identity \u2014 it cannot declare a property another kind of the field merges into.`),i.sibling===!0&&Object.keys(i.edge).length===0&&n.push(`${o}: a sibling kind's edge is its identity \u2014 an empty edge would count every edge of the field.`),i.mergeInto!==void 0){let l=r.get(i.mergeInto);l===void 0||l.type!=="0-n-select"?n.push(`${o}: mergeInto "${i.mergeInto}" must name a 0-n-select property of the field's objectSchema.`):Array.isArray(i.edge[i.mergeInto])||n.push(`${o}: mergeInto "${i.mergeInto}" must be set to a list in the edge.`)}}}s(x3,"validateRelationshipKinds");function S3(e,n,t){if(e.autoString===void 0){t.push(`Automatic field "${e.key}" must define autoString.`);return}e.allowMultiple===!0&&t.push(`Automatic field "${e.key}" must not allow multiple values.`),e.shareable===!0&&t.push(`Automatic field "${e.key}" must not be shareable.`),e.autoString.segments.length===0&&t.push(`Automatic field "${e.key}" must define at least one segment.`),e.autoString.segments.filter(i=>i.kind==="sequence").length!==1&&t.push(`Automatic field "${e.key}" must define exactly one sequence segment.`);for(let i of e.autoString.segments)if(i.kind==="literal"&&i.value.length===0&&t.push(`Automatic field "${e.key}" has an empty literal segment.`),i.kind==="sequence"&&(i.startAt!==void 0&&(!Number.isInteger(i.startAt)||i.startAt<1)&&t.push(`Automatic field "${e.key}" sequence startAt must be an integer >= 1.`),i.minDigits!==void 0&&(!Number.isInteger(i.minDigits)||i.minDigits<0)&&t.push(`Automatic field "${e.key}" sequence minDigits must be an integer >= 0.`)),i.kind==="field"){let o=n.get(i.fieldKey);if(o===void 0){t.push(`Automatic field "${e.key}" references missing field "${i.fieldKey}".`);continue}i.objectPropertyKey!==void 0&&o.objectSchema?.properties.find(l=>l.key===i.objectPropertyKey)===void 0&&t.push(`Automatic field "${e.key}" references missing object property "${i.fieldKey}.${i.objectPropertyKey}".`)}}s(S3,"validateAutomaticStringField");function hm(e,n,t,r){if(e===void 0)return;let i=n.get(e.fieldKey);if(i===void 0){t.push(`${r} references missing field "${e.fieldKey}".`);return}if(e.objectPropertyKey===void 0)return;(i.objectSchema?.properties.some(a=>a.key===e.objectPropertyKey)??!1)||t.push(`${r} references missing object property "${e.fieldKey}.${e.objectPropertyKey}".`)}s(hm,"validateSearchTarget");function A3(e,n,t){if(e.source.kind!=="relationshipTargetField")return;let r=`Template placeholder "${e.key}"`,i=n.get(e.source.relationshipFieldKey);if(i===void 0)t.push(`${r} references missing relationship field "${e.source.relationshipFieldKey}".`);else if(i.type!=="relationship")t.push(`${r} relationship field "${e.source.relationshipFieldKey}" must be a relationship field.`);else{for(let a of e.source.edgeFilters??[])tb(i,a.propertyKey,t,`${r} edge filter`);e.source.selection?.sortPropertyKey!==void 0&&tb(i,e.source.selection.sortPropertyKey,t,`${r} selection sort`)}let o=n.get(e.source.targetFieldKey);if(o===void 0){t.push(`${r} references missing target field "${e.source.targetFieldKey}".`);return}o.type==="relationship"&&t.push(`${r} target field "${e.source.targetFieldKey}" must not be a relationship field.`),e.source.targetObjectPropertyKey!==void 0&&tb(o,e.source.targetObjectPropertyKey,t,`${r} target`)}s(A3,"validateRelationshipTemplatePlaceholder");function tb(e,n,t,r){(e.objectSchema?.properties.some(o=>o.key===n)??!1)||t.push(`${r} references missing object property "${e.key}.${n}".`)}s(tb,"validateObjectPropertyReference");function E3(e,n,t){let r=`Party result icon "${e.key}"`,i=n.get(e.when.fieldKey);if(i===void 0){t.push(`${r} references missing field "${e.when.fieldKey}".`);return}if(e.when.objectPropertyKey===void 0){i.type!=="boolean"&&t.push(`${r} must target a Boolean field or object property.`);return}let o=i.objectSchema?.properties.find(a=>a.key===e.when.objectPropertyKey);if(o===void 0){t.push(`${r} references missing object property "${e.when.fieldKey}.${e.when.objectPropertyKey}".`);return}o.type!=="boolean"&&t.push(`${r} must target a Boolean field or object property.`)}s(E3,"validatePartyResultIconTarget");function FF(e){return`${e.templateId}:${e.locale}:${e.scopeKey}`}s(FF,"letterIdentity");function T3(e){return`${e.generatorKey??"*"}/${e.partyKind}/${e.roleKey}`}s(T3,"contractRoleMappingIdentity");function $3(e,n,t){let r=new Set;for(let i of e){let o=T3(i),a=`Contract role mapping "${o}"`;Uk.includes(i.partyKind)||t.push(`${a}: partyKind must be one of ${Uk.join(", ")}.`),n.has(i.roleKey)||t.push(`${a} references missing role "${i.roleKey}".`),i.generatorKey!==void 0&&i.generatorKey.trim()===""&&t.push(`${a}: generatorKey must not be blank \u2014 omit it for the tenant default.`),r.has(o)&&t.push(`${a} is declared twice.`),r.add(o)}}s($3,"validateContractRoleMappings");function R3(e,n){for(let t of e){let r=`Notification letter "${FF(t)}"`;if(!dm(t.locale)){n.push(`${r} declares locale "${String(t.locale)}" \u2014 letters are written in ${We.map(i=>`"${i}"`).join(" and ")} only, so no mail would ever read this deviation.`);continue}if(t.scopeKey!==am){n.push(`${r} declares scopeKey "${t.scopeKey}" \u2014 the only scope is "${am}" (the whole school).`);continue}if(Object.keys(t.slots).length===0){n.push(`${r} overrides no block. A deviation that deviates in nothing is not an entry \u2014 remove it.`);continue}if(!Nw(t.templateId)){n.push(`${r} references no registered letter \u2014 "${t.templateId}" is not in the letter catalog.`);continue}for(let i of gF(_w(t.templateId),t.slots,t.locale))n.push(`${r}, block "${i.slotKey}" [${i.code}]: ${i.message.de}`)}}s(R3,"validateNotificationLetters");function I3(e,n){if(e!==void 0)for(let t of yF(e))n.push(`Notification chrome: ${t.de}`)}s(I3,"validateNotificationChrome");function PF(e,n,t){if(e===void 0)return;let r=t===void 0?n:{push:s((...p)=>n.push(...p.map(h=>`${t}: ${h}`)),"push")},i=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,o=/^(?:rgb|rgba|hsl|hsla)\(.+\)$/i,a=s(p=>i.test(p.trim())||o.test(p.trim()),"isColor");for(let[p,h]of Object.entries(e.colors??{}))h!==void 0&&(a(h)||r.push(`Branding color "colors.${p}" has invalid value "${h}" (expected hex "#rgb"/"#rrggbb"/"#rrggbbaa" or rgb()/rgba()/hsl()/hsla()).`));let l=["sharp","rounded","soft"];e.radius!==void 0&&!l.includes(e.radius)&&r.push(`Branding radius "${e.radius}" is invalid (expected "sharp", "rounded", or "soft").`);let d=["sm","md","lg","max"];e.logoSize!==void 0&&!d.includes(e.logoSize)&&r.push(`Branding logoSize "${e.logoSize}" is invalid (expected "sm", "md", "lg", or "max").`);let c=["compact","normal","spacious"];e.bannerDensity!==void 0&&!c.includes(e.bannerDensity)&&r.push(`Branding bannerDensity "${e.bannerDensity}" is invalid (expected "compact", "normal", or "spacious").`);let u=["light","dark"];e.logoGround!==void 0&&!u.includes(e.logoGround)&&r.push(`Branding logoGround "${e.logoGround}" is invalid (expected "light" or "dark").`),e.websiteUrl!==void 0&&!e.websiteUrl.startsWith("https://")&&r.push(`Branding websiteUrl must be an https:// URL (got "${e.websiteUrl}").`);for(let p of["heading","body"]){let h=e.fonts?.[p];h!==void 0&&((typeof h.family!="string"||h.family.trim().length===0)&&r.push(`Branding font "fonts.${p}" must define a non-empty family.`),Object.hasOwn(h,"url")&&r.push(`Branding font "fonts.${p}.url" is no longer supported \u2014 the font file is uploaded (plexus-cli branding set-font --slot ${p} --file <woff2>) and config carries the family only.`))}}s(PF,"validateBranding");function CF(e,n,t="tenant"){let r=e.brandingAssets;if(r!==void 0){if(typeof r!="object"||r===null||Array.isArray(r)){n.push(`${t}.brandingAssets must be an object keyed by slot (${fm.join(", ")}).`);return}for(let[i,o]of Object.entries(r)){let a=`${t}.brandingAssets.${i}`;if(!fm.includes(i)){n.push(`${a}: unknown slot (expected ${fm.join(", ")}).`);continue}if(typeof o!="object"||o===null){n.push(`${a}: must be { sha256, sizeBytes, mimeType }.`);continue}if("size"in o){n.push(`[config/fileRefRenamed] ${a} still names size \u2014 this bundle was exported before the file-field rename, or by a plexus-cli older than this release (now sizeBytes). Update plexus-cli, export it again (plexus-cli --env <env> config export) and re-apply.`);continue}MF.test(o.sha256??"")||n.push(`${a}: sha256 must be 64 lowercase hex chars.`),(!Number.isInteger(o.sizeBytes)||o.sizeBytes<=0)&&n.push(`${a}: sizeBytes must be a positive integer.`);let l=bF[i];if(l===null){let d=vF({contentType:o.mimeType,size:o.sizeBytes});d!==null&&n.push(`${a}: ${d.de}`)}else{o.mimeType!==eb&&n.push(`${a}: mimeType must be "${eb}" (got "${o.mimeType}").`);let d=xF(e.branding?.fonts?.[l]?.family);d!==null&&n.push(`${a}: [branding/fontFamilyMissing] ${t}.branding.fonts.${l}: ${d.de}`)}"path"in o&&n.push(`${a}: "path" is a CLI snapshot field \u2014 resolve it with plexus-cli config apply.`)}}}s(CF,"validateBrandingAssets");function O3(e,n,t){let{source:r}=e;r===void 0&&F("validateSourceCoverage: called without a `source` block.");let i=new Set(n),o=new Set(e.fields.flatMap(k=>k.sourceColumns)),a=new Set(e.deferredColumns.map(k=>k.column)),l=new Set(e.ignoredColumns.map(k=>k.column)),d=new Set([...o,...a,...l]),c=r.requiredColumns.filter(k=>!i.has(k)),u=n.filter(k=>!d.has(k)),p=[...o].filter(k=>!i.has(k)),h=[...a].filter(k=>!i.has(k)),w=[...l].filter(k=>!i.has(k));for(let k of c)t.push(`Required source column "${k}" is missing from ${r.primaryTable}.`);for(let k of u)t.push(`Source column "${k}" is neither mapped nor explicitly deferred/ignored.`);for(let k of p)t.push(`Mapped source column "${k}" does not exist in the source schema.`);for(let k of h)t.push(`Deferred source column "${k}" does not exist in the source schema.`);for(let k of w)t.push(`Ignored source column "${k}" does not exist in the source schema.`);return{table:r.primaryTable,availableColumns:n.length,mappedColumns:[...o].filter(k=>i.has(k)).length,deferredColumns:[...a].filter(k=>i.has(k)).length,ignoredColumns:[...l].filter(k=>i.has(k)).length,missingRequiredColumns:c,unmappedColumns:u,unknownMappedColumns:p,unknownDeferredColumns:h,unknownIgnoredColumns:w}}s(O3,"validateSourceCoverage");function En(e,n,t){for(let r of LF(e))t.push(`Duplicate ${n} key "${r}".`)}s(En,"requireUnique");function LF(e){let n=new Set,t=new Set;for(let r of e)n.has(r)&&t.add(r),n.add(r);return[...t]}s(LF,"duplicates");var MF=/^[0-9a-f]{64}$/,_3=["fileName","size"];function N3(e,n){if(!Array.isArray(e.files)){n.push('"files" is missing \u2014 declare the file library (an empty list is fine).');return}En(e.files.map(t=>t.key),"file",n);for(let t of e.files){let r=`files["${t.key}"]`;Sa(t.key)||n.push(`${r}: key must match ${bk}.`);for(let o of["de","en"])(t.label?.[o]??"").trim()===""&&n.push(`${r}: label.${o} is required \u2014 [i18n/missingTranslation] every shown text needs German and English.`);let i=_3.filter(o=>o in t);if(i.length>0){n.push(`[config/fileRefRenamed] ${r} still names ${i.join(", ")} \u2014 this bundle was exported before the file-field rename, or by a plexus-cli older than this release (now filename / sizeBytes). Update plexus-cli, export it again (plexus-cli --env <env> config export) and re-apply.`);continue}if(typeof t.filename!="string")n.push(`${r}: filename is missing.`);else{let o=Yo(t.filename);o!==null&&n.push(`${r}: filename ${o}.`)}lm.includes(t.mimeType)||n.push(`${r}: mimeType "${t.mimeType}" is not allowed (${lm.join(", ")}).`),MF.test(t.sha256??"")||n.push(`${r}: sha256 must be 64 lowercase hex chars.`),(!Number.isInteger(t.sizeBytes)||t.sizeBytes<=0)&&n.push(`${r}: sizeBytes must be a positive integer.`),"path"in t&&n.push(`${r}: "path" is a CLI snapshot field \u2014 resolve it with plexus-cli config apply.`)}}s(N3,"validateFiles");var P3=new WeakMap,C3=new WeakSet;function rb(e,n){n(e);let r=e.asOptional.bind(e);return Object.defineProperty(e,"asOptional",{value:s(()=>rb(r(),n),"value"),enumerable:!1}),e}s(rb,"carry");function Oa(e,n){return rb(e,t=>P3.set(t,n))}s(Oa,"tagged");var D3="tenant teardown drains every table explicitly (config/wipe.ts)",Ve={belongsTo:s(e=>Oa(e,{kind:"belongsTo"}),"belongsTo"),owns:s(e=>Oa(e,{kind:"owns"}),"owns"),holds:s(e=>Oa(e,{kind:"holds"}),"holds"),restrict:s((e,n)=>Oa(e,n?{kind:"restrict",unindexed:n.unindexed}:{kind:"restrict"}),"restrict"),history:s(e=>Oa(e,{kind:"history"}),"history"),tenant:s(e=>Oa(e,{kind:"restrict",unindexed:D3}),"tenant"),historyOf:s(e=>rb(e,n=>C3.add(n)),"historyOf")};var F3=m.object({street:m.string(),hausnr:m.string(),plz:m.string(),ort:m.string()}),qF=m.union(m.literal("school_operator"),m.literal("school_group"),m.literal("service_entity")),Gr=qF.members.map(e=>e.value),L3={tenantId:Ve.tenant(m.id("tenants")),name:m.optional(m.string()),type:qF,parentLegalEntityId:m.optional(Ve.restrict(m.id("legal_entities"))),configKey:m.optional(m.string()),partyId:m.optional(Ve.restrict(m.id("parties"))),address:m.optional(F3),signatoryUserId:m.optional(Ve.restrict(m.id("users"))),terms:m.optional(mF)},cTe=Pt(L3).index("by_tenantId",["tenantId"]).index("by_parentLegalEntityId",["parentLegalEntityId"]).index("by_tenantId_and_configKey",["tenantId","configKey"]).index("by_partyId",["partyId"]).index("by_signatoryUserId",["signatoryUserId"]);var M3=m.union(m.literal("school"),m.literal("kindergarten"),m.literal("after_school_care"),m.literal("department"),m.literal("site"),m.literal("other")),qt=M3.members.map(e=>e.value),pTe=m.union(m.literal("school"),m.literal("vocational"),m.literal("care"),m.literal("seminar"),m.literal("other")),mTe=m.union(m.literal("none"),m.literal("manual"),m.literal("annual_rollover")),hTe=m.union(m.literal("grade_level"),m.literal("module"),m.literal("phase"),m.literal("other")),gTe=m.union(m.literal("school_year"),m.literal("cohort"),m.literal("seminar"),m.literal("care_period"),m.literal("other")),yTe=m.union(m.literal("planned"),m.literal("active"),m.literal("completed"),m.literal("archived")),wTe=m.union(m.literal("class"),m.literal("course"),m.literal("care_group"),m.literal("seminar_group"),m.literal("mixed_age_group"),m.literal("other")),kTe=m.union(m.literal("planned"),m.literal("active"),m.literal("completed"),m.literal("cancelled")),bTe=m.union(m.literal("class_teacher"),m.literal("teacher"),m.literal("mentor"),m.literal("instructor"),m.literal("assistant"),m.literal("other")),vTe=m.union(m.literal("units"),m.literal("unit_profiles"),m.literal("programs"),m.literal("program_stages"),m.literal("program_runs"),m.literal("learning_groups"),m.literal("enrollments"),m.literal("learning_group_staff_assignments")),xTe=m.union(m.literal("open"),m.literal("mapped"),m.literal("ignored"));function jF(e){let n=["street","hausnr","plz","ort"].filter(t=>e[t]!==void 0);if(n.length!==0){if(n.length!==4)throw new Error(`config legal-entity add: an address needs all of --street, --hausnr, --plz and --ort (got ${n.map(t=>`--${t}`).join(", ")})`);return{street:e.street,hausnr:e.hausnr,plz:e.plz,ort:e.ort}}}s(jF,"addressFrom");function VF(e){if(!Gr.includes(e))throw new Error(`config legal-entity add: --type "${e}" is none of ${Gr.join(", ")}`);return e}s(VF,"legalEntityType");function BF(e){if(!qt.includes(e))throw new Error(`config unit add: --kind "${e}" is none of ${qt.join(", ")}`);return e}s(BF,"unitKind");function UF(e,n,t){let r=e.find(i=>i.key===n.key);if(r===void 0)return e.push(n),"create";if(Ne(r)===Ne(n))return"same";throw new Error(`${t} "${n.key}" already exists with other values \u2014 decide by hand, nothing written.
11295
+ `)).includes(u.key));if(p.length===0)continue;let h=s((y,v)=>y.map(E=>v(i.find(T=>T.key===E)?.label??E)).join(" + "),"variantLabel"),w=c.length===1?"":` Er fehlt in der Fassung aus ${p.map(y=>h(y,v=>`\u201E${v}\u201C`)).join(" und in der aus ")}.`,k=c.length===1?"":` It is missing in the version made of ${p.map(y=>h(y,v=>`"${v}"`)).join(" and in the one made of ")}.`;r.push({slotKey:u.key,code:"missingRequired",message:{de:`Ohne \u201E{{${u.key}}}\u201C (${u.label}) funktioniert der Brief \u201E${e.label}\u201C nicht \u2014 der Platzhalter muss im Text stehen, nicht nur im Betreff.`+w,en:`Without "{{${u.key}}}" (${u.label}) the letter "${e.label}" does not work \u2014 the placeholder must be in the text, not only in the subject.`+k}})}return r}s(gF,"validateOverride");function K4(e,n,t){let r=e.find(i=>i.key===n);return r===void 0?"":q4(r,t)}s(K4,"defaultTextOf");function Zk(e){let n=e?.trim();return n===void 0||n.length===0?void 0:n}s(Zk,"normalizeChromeText");var Zo=s(e=>String.fromCharCode(e),"cp"),j4=new RegExp(`[${Zo(0)}-${Zo(31)}${Zo(127)}]`,"g"),V4=new RegExp(`[${Zo(8234)}-${Zo(8238)}${Zo(8294)}-${Zo(8297)}]`,"g");var B4=200;function U4(e,n=B4){return e.replace(j4," ").replace(V4,"").replace(/\s+/g," ").trim().slice(0,n)}s(U4,"sanitizeHeaderValue");function um(e){return U4(e.replace(/["<>@]/g,""),100)}s(um,"sanitizeDisplayName");var Xk={de:{de:"Deutsch",en:"German"},en:{de:"Englisch",en:"English"}},G4={greeting:{de:"Anrede",en:"Greeting"},closing:{de:"Gru\xDFformel",en:"Closing"}};function yF(e){let n=[],t=[];for(let i of["greeting","closing"]){let o=e[i];if(o===void 0)continue;let a=G4[i],l=Rn(o);l!=="not-localized"&&l.length>0&&l.length<We.length&&t.push({de:`${a.de} fehlt auf ${l.map(d=>Xk[d].de).join(" und ")}`,en:`${a.en} is missing in ${l.map(d=>Xk[d].en).join(" and ")}`});for(let d of We){let c=vw(h=>`${a[h]} (${Xk[d][h]})`),u=Zk(o[d]);u!==void 0&&u.length>Qo&&n.push({de:`${c.de} hat ${u.length} Zeichen \u2014 h\xF6chstens ${Qo}; der Briefrahmen ist eine Zeile der Mail, kein Dokument.`,en:`${c.en} has ${u.length} characters \u2014 at most ${Qo}; the letter frame is one line of the mail, not a document.`});let p=i==="greeting"?[Ur]:[];for(let h of cm(u??""))p.includes(h)||n.push(p.length===0?{de:`${c.de} kann keine Platzhalter tragen \u2014 \u201E{{${h}}}\u201C bliebe unersetzt stehen.`,en:`${c.en} cannot carry placeholders \u2014 "{{${h}}}" would stay in the text unreplaced.`}:{de:`\u201E{{${h}}}\u201C gibt es in der ${c.de} nicht. Erlaubt: {{${Ur}}} (${Ia}).`,en:`"{{${h}}}" does not exist in the ${c.en}. Allowed: {{${Ur}}} (${Ia}).`})}}t.length>0&&n.unshift({de:`[notification/chromeMissingTranslation] ${t.map(i=>i.de).join("; ")} \u2014 der Briefrahmen gilt f\xFCr jeden Brief, in jeder Sprache.`,en:`[notification/chromeMissingTranslation] ${t.map(i=>i.en).join("; ")} \u2014 the letter frame applies to every letter, in every language.`});let r=Zk(e.senderName);return r!==void 0&&um(r)!==r&&n.push({de:`Absendername (senderName) \u201E${r}\u201C \xFCbersteht die Kopfzeile der Mail nicht unver\xE4ndert \u2014 er ginge als \u201E${um(r)}\u201C hinaus. Keine Anf\xFChrungszeichen, spitzen Klammern, \u201E@\u201C oder Steuerzeichen.`,en:`The sender name (senderName) "${r}" does not survive the mail header unchanged \u2014 it would go out as "${um(r)}". No quotation marks, angle brackets, "@" or control characters.`}),n}s(yF,"chromeFindings");var wF=m.object({family:m.string()}),kF=m.object({family:m.string(),url:m.optional(m.string())}),WAe=m.object({heading:m.optional(kF),body:m.optional(kF)}),z4=m.union(m.literal("sharp"),m.literal("rounded"),m.literal("soft")),W4=m.union(m.literal("light"),m.literal("dark")),Y4=m.union(m.literal("sm"),m.literal("md"),m.literal("lg"),m.literal("max")),H4=m.union(m.literal("compact"),m.literal("normal"),m.literal("spacious")),J4=m.object({primary:m.optional(m.string()),accent:m.optional(m.string()),background:m.optional(m.string()),foreground:m.optional(m.string())}),Q4=m.object({heading:m.optional(wF),body:m.optional(wF)}),YAe=m.object({colors:m.optional(J4),radius:m.optional(z4),logoSize:m.optional(Y4),bannerDensity:m.optional(H4),logoGround:m.optional(W4),filledHeader:m.optional(m.boolean()),websiteUrl:m.optional(m.string()),fonts:m.optional(Q4)}),HAe=m.object({primaryUrl:m.union(m.null(),m.string())}),JAe=m.literal("primary"),QAe=m.object({headingUrl:m.union(m.null(),m.string()),bodyUrl:m.union(m.null(),m.string())}),ZAe=m.union(m.literal("heading"),m.literal("body")),fm=["logo","fontHeading","fontBody"],bF={logo:null,fontHeading:"heading",fontBody:"body"};function vF(e){let{contentType:n,size:t}=e;return n==null||!n.startsWith("image/")?{de:`Das Logo muss ein Bild sein (erhalten: \u201E${n??"unbekannt"}\u201C).`,en:`The logo must be an image (received: "${n??"unknown"}").`}:n.startsWith("image/svg")?{de:"Das Logo muss eine Rastergrafik sein (PNG, JPEG oder GIF) \u2013 E-Mail-Programme zeigen SVG nicht an.",en:"The logo must be a raster image (PNG, JPEG or GIF) \u2013 email clients do not display SVG."}:t>3e6?{de:`Das Logo ist zu gro\xDF (${t} Byte, h\xF6chstens 3000000 Byte).`,en:`The logo is too large (${t} bytes, at most 3000000 bytes).`}:null}s(vF,"logoFileProblem");var eb="font/woff2";var Z4=["Inter Variable","Azeret Mono Variable","Source Sans 3 Variable"];function xF(e){return e?.trim()?Z4.some(n=>n.toLowerCase()===e.trim().toLowerCase())?{de:`\u201E${e}\u201C ist die Schrift von Plexus selbst \u2013 w\xE4hlen Sie f\xFCr eine eigene Datei einen anderen Familiennamen.`,en:`"${e}" is Plexus's own typeface \u2013 choose a different family name for your own file.`}:null:{de:"Speichern Sie zuerst die Schriftfamilie \u2013 die Datei wird unter diesem Namen eingebunden.",en:"Save the font family first \u2013 the file is registered under that name."}}s(xF,"fontFamilyProblem");var X4=["approved","rejected","withdrawn","waitlist","expired"];var pm=["admitted","rejected","withdrawn","waitlist","expired","unknown"],oEe=m.union(...X4.map(e=>m.literal(e))),sEe=m.union(...pm.map(e=>m.literal(e))),e3=["approved","rejected","waitlist"],n3=["withdrawn","expired"],t3=m.union(...e3.map(e=>m.literal(e))),r3=m.union(...n3.map(e=>m.literal(e))),aEe={active:{status:m.literal("active")},completed:{status:m.literal("completed"),outcome:t3,endedAt:m.number()},aborted:{status:m.literal("aborted"),outcome:m.optional(r3),endedAt:m.number()}};var SF=30,AF=3650;var i3=m.object({admitted:m.optional(m.number()),rejected:m.optional(m.number()),withdrawn:m.optional(m.number()),expired:m.optional(m.number()),waitlist:m.optional(m.number()),unknown:m.optional(m.number())}),pEe=i3.fields,o3=s(e=>pm.includes(e),"isClassification");function EF(e,n="tenant.retentionDays"){if(e===null||typeof e!="object"||Array.isArray(e))return[`[retention/shape] ${n} must be an object of days per classification (got ${JSON.stringify(e)}).`];let t=[];for(let[r,i]of Object.entries(e)){if(!o3(r)){t.push(`[retention/unknownClassification] ${n}.${r} is no retention classification \u2014 one of ${pm.join(", ")}.`);continue}(typeof i!="number"||!Number.isSafeInteger(i)||i<SF||i>AF)&&t.push(`[retention/days] ${n}.${r} must be a whole number of days from ${SF} to ${AF} (got ${JSON.stringify(i)}).`)}return t}s(EF,"retentionDaysFindings");var s3=["ad","ae","af","ag","ai","al","am","ao","aq","ar","as","at","au","aw","ax","az","ba","bb","bd","be","bf","bg","bh","bi","bj","bl","bm","bn","bo","bq","br","bs","bt","bv","bw","by","bz","ca","cc","cd","cf","cg","ch","ci","ck","cl","cm","cn","co","cr","cu","cv","cw","cx","cy","cz","de","dj","dk","dm","do","dz","ec","ee","eg","eh","er","es","et","fi","fj","fk","fm","fo","fr","ga","gb","gd","ge","gf","gg","gh","gi","gl","gm","gn","gp","gq","gr","gs","gt","gu","gw","gy","hk","hm","hn","hr","ht","hu","id","ie","il","im","in","io","iq","ir","is","it","je","jm","jo","jp","ke","kg","kh","ki","km","kn","kp","kr","kw","ky","kz","la","lb","lc","li","lk","lr","ls","lt","lu","lv","ly","ma","mc","md","me","mf","mg","mh","mk","ml","mm","mn","mo","mp","mq","mr","ms","mt","mu","mv","mw","mx","my","mz","na","nc","ne","nf","ng","ni","nl","no","np","nr","nu","nz","om","pa","pe","pf","pg","ph","pk","pl","pm","pn","pr","ps","pt","pw","py","qa","re","ro","rs","ru","rw","sa","sb","sc","sd","se","sg","sh","si","sj","sk","sl","sm","sn","so","sr","ss","st","sv","sx","sy","sz","tc","td","tf","tg","th","tj","tk","tl","tm","tn","to","tr","tt","tv","tw","tz","ua","ug","um","us","uy","uz","va","vc","ve","vg","vi","vn","vu","wf","ws","xk","ye","yt","za","zm","zw"],a3=new Set(s3);function mm(e){return a3.has(e)}s(mm,"isCountryCode");var nb=["off","always","deviating"],TF={mode:"deviating",defaultCountryCode:"de"};var l3=["street","plz","ort"];function d3(e){return l3.filter(n=>!e.has(n))}s(d3,"missingInvoiceAddressParts");var c3=new Set(["0-1-select","0-n-select"]);function $F(e){return e===void 0?null:new Set(e.properties.flatMap(n=>n.addressPart!==void 0&&ZO(n.addressPart)?[n.addressPart]:[]))}s($F,"declaredAddressParts");function u3(e){return c3.has(e)}s(u3,"isSelectFieldKind");function RF(e){let n=[];for(let o of e)if(o.isNationality&&(u3(o.kind)?o.listKind!=="country"&&n.push({code:"nationality/notCountryList",fieldKey:o.key}):n.push({code:"nationality/wrongFieldKind",fieldKey:o.key})),o.isAccountEmail&&o.kind!=="email"&&n.push({code:"accountEmail/wrongFieldKind",fieldKey:o.key}),o.isContactPhone&&o.kind!=="tel"&&n.push({code:"contactPhone/wrongFieldKind",fieldKey:o.key}),o.isInvoiceAddress)if(o.addressParts===null)n.push({code:"invoiceAddress/wrongFieldKind",fieldKey:o.key});else{let a=d3(o.addressParts);a.length>0&&n.push({code:"invoiceAddress/missingPart",fieldKey:o.key,parts:a})}let t=e.filter(o=>o.isAccountEmail);if(t.length>1)for(let o of t)n.push({code:"accountEmail/multiple",fieldKey:o.key});let r=e.filter(o=>o.isContactPhone);if(r.length>1)for(let o of r)n.push({code:"contactPhone/multiple",fieldKey:o.key});let i=e.filter(o=>o.isInvoiceAddress);if(i.length>1)for(let o of i)n.push({code:"invoiceAddress/multiple",fieldKey:o.key});return n}s(RF,"fieldRoleFindings");function IF(e,n,...t){let r=e[n.code];return r(n,...t)}s(IF,"wordListElementFinding");function OF(e,n){let t=[];for(let r of n){if(e.kind==="plain"){r.countryCode!==void 0&&t.push({code:"list/countryCodeOnPlain",elementKey:r.key,countryCode:r.countryCode});continue}r.countryCode===void 0?t.push({code:"list/countryCodeMissing",elementKey:r.key}):r.countryCode!==null&&!mm(r.countryCode)&&t.push({code:"list/unknownCountryCode",elementKey:r.key,countryCode:r.countryCode})}return t}s(OF,"listElementCountryFindings");var p3={key:!0,tenant:!0,foundation:!0,source:!0,displayGroups:!0,lists:!0,roles:!0,fields:!0,roleFields:!0,contractRoleMappings:!0,templatePlaceholders:!0,searchTargets:!0,searchFilters:!0,partyResultIcons:!0,notificationLetters:!0,admission:!0,files:!0,agent:!0,deferredColumns:!0,ignoredColumns:!0},m3={slug:!0,name:!0,enabledModules:!0,permissions:!0,defaultApplicantGroupKey:!0,defaultEnrolleeRoleKey:!0,priceCriteriaFacts:!0,defaultInteressentRoleKey:!0,admissionFieldDisplayGroupKey:!0,defaultStartInProxy:!0,terms:!0,retentionDays:!0,mailLevel:!0,notificationChrome:!0,hideMailLevelNotice:!0,unassignedTaskNoticeDays:!0,magicLinkLogin:!0,externalSignIn:!0,nationalityFlag:!0,adminSeesSignatureImages:!0,signatureStamp:!0,bankImportScope:!0,branding:!0,brandingAssets:!0,partyRetention:!0},h3=new Set(["enabledMailCategories","mailEnabled"]);function g3(e){let n=s((t,r,i)=>t.filter(o=>!Object.hasOwn(r,o)&&!(i==="tenant."&&h3.has(o))).map(o=>`[config/unknownKey] ${i}${o} is not a config field of this release \u2014 a typo, or a field a newer release introduced.`),"unknown");return[...n(Object.keys(e),p3,""),...n(Object.keys(e.tenant),m3,"tenant.")]}s(g3,"unknownKeyFindings");var _F=["plain","country"],y3={"list/countryCodeMissing":s(({elementKey:e},n)=>`Element "${n}.${e}" of a country list must state countryCode (null for no state).`,"list/countryCodeMissing"),"list/countryCodeOnPlain":s(({elementKey:e},n)=>`Element "${n}.${e}" carries countryCode, but list "${n}" is not kind "country".`,"list/countryCodeOnPlain"),"list/unknownCountryCode":s(({elementKey:e,countryCode:n},t)=>`Element "${t}.${e}" has unknown countryCode ${JSON.stringify(n)}.`,"list/unknownCountryCode")},w3={"nationality/wrongFieldKind":s(({fieldKey:e})=>`Field "${e}" is isNationality but not a 0-1-select / 0-n-select.`,"nationality/wrongFieldKind"),"nationality/notCountryList":s(({fieldKey:e})=>`Field "${e}" is isNationality but its list is not kind "country".`,"nationality/notCountryList"),"accountEmail/wrongFieldKind":s(({fieldKey:e})=>`Field "${e}" is isAccountEmail but not an email field.`,"accountEmail/wrongFieldKind"),"accountEmail/multiple":s(({fieldKey:e})=>`Field "${e}" is one of several isAccountEmail fields \u2014 at most one per tenant.`,"accountEmail/multiple"),"contactPhone/wrongFieldKind":s(({fieldKey:e})=>`Field "${e}" is isContactPhone but not a tel field.`,"contactPhone/wrongFieldKind"),"contactPhone/multiple":s(({fieldKey:e})=>`Field "${e}" is one of several isContactPhone fields \u2014 at most one per tenant.`,"contactPhone/multiple"),"invoiceAddress/wrongFieldKind":s(({fieldKey:e})=>`Field "${e}" is isInvoiceAddress but not an object field.`,"invoiceAddress/wrongFieldKind"),"invoiceAddress/missingPart":s(({fieldKey:e,parts:n})=>`Field "${e}" is isInvoiceAddress but declares no property for the address part(s) ${n.join(", ")} (objectSchema.properties[].addressPart) \u2014 an invoice cannot print its address without them.`,"invoiceAddress/missingPart"),"invoiceAddress/multiple":s(({fieldKey:e})=>`Field "${e}" is one of several isInvoiceAddress fields \u2014 at most one per tenant.`,"invoiceAddress/multiple")};function k3(e){let n=w3[e.code];return n(e)}s(k3,"roleText");function b3(e){let n=[],t=e.tenant.nationalityFlag,r=typeof t=="object"&&t!==null?t:{},i=r.mode;if(nb.includes(i)||n.push(`[nationality/flagMode] tenant.nationalityFlag.mode must be one of ${nb.join(", ")} (got ${t===void 0?"no tenant.nationalityFlag":JSON.stringify(i??null)}).`),t!==void 0){let l=r.defaultCountryCode;(typeof l!="string"||!mm(l))&&n.push(`[nationality/defaultCountryCode] tenant.nationalityFlag.defaultCountryCode must be a lowercase ISO 3166-1 alpha-2 code (got ${JSON.stringify(l??null)}).`)}let o=new Map;for(let l of e.lists){let d=l.kind;if(!_F.includes(d)){n.push(`[list/kind] List "${l.key}" has kind ${JSON.stringify(d??null)} \u2014 one of ${_F.join(", ")}.`);continue}o.set(l.key,l.kind);for(let c of OF({key:l.key,kind:l.kind},l.elements))n.push(`[${c.code}] ${IF(y3,c,l.key)}`)}let a=RF(e.fields.map(l=>({key:l.key,kind:l.type,listKind:l.listKey===void 0?null:o.get(l.listKey)??null,isNationality:l.isNationality===!0,isAccountEmail:l.isAccountEmail===!0,isContactPhone:l.isContactPhone===!0,isInvoiceAddress:l.isInvoiceAddress===!0,addressParts:l.type==="object"?$F(l.objectSchema??{properties:[]}):null})));for(let l of a)n.push(`[${l.code}] ${k3(l)}`);return n}s(b3,"nationalityFindings");function NF(e){return $i(e)?.message.de??(e instanceof Error?e.message:String(e))}s(NF,"errorText");function DF(e,n={}){let t=[...g3(e)],r=[];try{iF(e.fields.map(b=>b.key),[])}catch(b){t.push(NF(b))}e.tenant.terms!==void 0&&t.push(...Qk(e.tenant.terms)),e.tenant.retentionDays!==void 0&&t.push(...EF(e.tenant.retentionDays)),dN(e.tenant.mailLevel)?e.tenant.mailLevel==="all"&&!sm(e.tenant.enabledModules,"notifications")&&t.push('[notification/levelWithoutModule] tenant.mailLevel is "all" but the notifications module is not enabled \u2014 only sign-in and security mail would go out. Enable the module or set "loginOnly".'):t.push(`[notification/mailLevel] tenant.mailLevel must be one of ${Ew.join(", ")} (got ${e.tenant.mailLevel===void 0?"nothing":JSON.stringify(e.tenant.mailLevel)}).`),"enabledMailCategories"in e.tenant&&t.push('[notification/mailCategoriesRetired] tenant.enabledMailCategories was replaced by tenant.mailLevel \u2014 "all" for every mail, "loginOnly" for sign-in mail only to families (staff mail follows personal settings).'),"mailEnabled"in e.tenant&&t.push('[notification/mailEnabledRetired] tenant.mailEnabled was replaced by tenant.mailLevel \u2014 "all" for every mail, "loginOnly" for sign-in mail only to families (staff mail follows personal settings).'),En(e.displayGroups.map(b=>b.key),"display group",t),En(e.lists.map(b=>b.key),"list",t),En(e.roles.map(b=>b.key),"role",t),En(e.fields.map(b=>b.key),"field",t),En(e.foundation.legalEntities.map(b=>b.key),"legal entity",t),En(e.foundation.units.map(b=>b.key),"unit",t),En(e.foundation.permissionGroups.map(b=>b.key),"permission group",t),"teams"in e.foundation&&t.push("foundation.teams is retired: a team is a permission group \u2014 move each team to foundation.permissionGroups (same key) and remove the block.");for(let b of e.foundation.users)"teamKeys"in b&&t.push(`User "${b.email}" carries teamKeys, retired: team membership is the user's permission-group membership.`);En(e.foundation.users.map(b=>b.key),"user",t),En((e.searchFilters??[]).map(b=>b.key),"search filter",t),En((e.searchTargets??[]).map(b=>b.objectPropertyKey===void 0?b.fieldKey:`${b.fieldKey}.${b.objectPropertyKey}`),"search target",t),En((e.partyResultIcons??[]).map(b=>b.key),"party result icon",t),En((e.templatePlaceholders??[]).map(b=>b.key),"template placeholder",t),En((e.notificationLetters??[]).map(FF),"notification letter",t),R3(e.notificationLetters??[],t),I3(e.tenant.notificationChrome,t),e.tenant.bankImportScope!==void 0&&!["sepa_only","full_statement"].includes(e.tenant.bankImportScope)&&t.push("tenant.bankImportScope must be sepa_only or full_statement."),e.tenant.hideMailLevelNotice!==void 0&&typeof e.tenant.hideMailLevelNotice!="boolean"&&t.push("tenant.hideMailLevelNotice must be true or false (the dashboard's mail-level notice)."),e.tenant.unassignedTaskNoticeDays!==void 0&&!cN(e.tenant.unassignedTaskNoticeDays)&&t.push("tenant.unassignedTaskNoticeDays must be a whole number from 1 to 30 (days before an unassigned team task is reported); leave it out for the platform default."),typeof e.tenant.magicLinkLogin!="boolean"&&t.push("tenant.magicLinkLogin must be true or false (the login page's sign-in link option)."),typeof e.tenant.adminSeesSignatureImages!="boolean"&&t.push("tenant.adminSeesSignatureImages must be true or false (whether a school administrator sees other accounts' signature images)."),typeof e.tenant.signatureStamp!="boolean"&&t.push("tenant.signatureStamp must be true or false (whether the school offers the signature stamp at the countersignature)."),nF(e.tenant.externalSignIn)?t.push(`[auth/externalSignInRetired] tenant.externalSignIn names the retired mode "${String(e.tenant.externalSignIn.mode)}" \u2014 every sign-in link now signs in once; state { mode: "oneTimeLink" }.`):eF(e.tenant.externalSignIn)||t.push('[auth/externalSignIn] tenant.externalSignIn must be { mode: "oneTimeLink" } (how families sign in).');let i=new Set(e.displayGroups.map(b=>b.key)),o=new Set(e.lists.map(b=>b.key)),a=new Set(e.roles.map(b=>b.key)),l=new Set(e.fields.map(b=>b.key)),d=new Map(e.fields.map(b=>[b.key,b])),c=new Set(e.foundation.legalEntities.map(b=>b.key)),u=new Set(e.foundation.units.map(b=>b.key)),p=new Set(e.foundation.permissionGroups.map(b=>b.key));sm(e.tenant.enabledModules,"bewerbungsmanagement")&&e.tenant.defaultApplicantGroupKey!==void 0&&(e.foundation.permissionGroups.find(I=>I.key===e.tenant.defaultApplicantGroupKey)?.permissions.includes("bewerbungsmanagement.applications.submitOwn")||t.push(`Default applicant group "${e.tenant.defaultApplicantGroupKey}" must grant submitOwn.`));let h=e.tenant.admissionFieldDisplayGroupKey;h!==void 0&&!i.has(h)&&t.push(`tenant.admissionFieldDisplayGroupKey "${h}" names no display group of this config.`),h===void 0&&(sm(e.tenant.enabledModules,"bewerbungsmanagement")||(e.admission?.fields.length??0)>0)&&t.push("tenant.admissionFieldDisplayGroupKey is required when admissions is enabled or admission.fields declares fields: it names the display group the fields an offer creates land in."),t.push(...b3(e)),En(e.fields.flatMap(b=>(b.relationshipKinds??[]).map(I=>I.key)),"relationship kind",t);for(let b of e.fields){i.has(b.displayGroupKey)||t.push(`Field "${b.key}" references missing display group "${b.displayGroupKey}".`),x3(b,t),b.formWritable===!0&&!Yk[b.type].fieldMapTarget&&t.push(`Field "${b.key}" is formWritable, but a form cannot write a "${b.type}" field.`),b.type==="files"&&b.shareable===!0&&t.push(`[field/filesShareable] Field "${b.key}" is a files field and cannot be shareable.`),b.type==="auto-string"?S3(b,d,t):b.autoString!==void 0&&t.push(`Non-automatic field "${b.key}" must not define autoString.`),(!Number.isFinite(b.sortOrder)||b.sortOrder<0)&&t.push(`Field "${b.key}" has invalid sortOrder "${b.sortOrder}" (must be a non-negative number).`),(b.type==="0-1-select"||b.type==="0-n-select")&&!b.listKey&&t.push(`Select field "${b.key}" must define listKey.`),b.type!=="0-1-select"&&b.type!=="0-n-select"&&b.listKey!==void 0&&t.push(`Non-select field "${b.key}" must not define listKey.`),b.listKey&&!o.has(b.listKey)&&t.push(`Field "${b.key}" references missing list "${b.listKey}".`),(b.type==="object"||b.type==="relationship")&&!b.objectSchema&&t.push(`Field "${b.key}" must define objectSchema.`),b.type!=="object"&&b.type!=="relationship"&&b.objectSchema&&t.push(`Non-object field "${b.key}" must not define objectSchema.`);for(let I of b.objectSchema?.properties??[])(I.type==="0-1-select"||I.type==="0-n-select")&&!I.listKey&&t.push(`Object select property "${b.key}.${I.key}" must define listKey.`),I.listKey&&!o.has(I.listKey)&&t.push(`Object property "${b.key}.${I.key}" references missing list "${I.listKey}".`);v3(b,t)}let w=e.tenant.priceCriteriaFacts;if(w){let b=e.fields.find(I=>I.key===w.birthDateFieldKey);(!b||b.type!=="date")&&t.push("Price criteria require a configured date field for birth dates."),a.has(w.studentRoleKey)||t.push("Price criteria require a configured Student eligibility role."),w.siblingRankSource!==void 0&&w.siblingRankSource!=="derived"&&w.siblingRankSource!=="chosen"&&t.push('Price criteria siblingRankSource must be "derived" or "chosen".');for(let I of Object.keys(w))I!=="birthDateFieldKey"&&I!=="studentRoleKey"&&I!=="siblingRankSource"&&t.push(`Unknown price criteria fact setting "${I}".`)}let k=e.tenant.defaultEnrolleeRoleKey;k&&!a.has(k)&&t.push(`Default enrollment role "${k}" does not exist.`),k&&e.roles.some(b=>b.parentRoleKey===k)&&t.push(`Default enrollment role "${k}" must be a leaf role.`);for(let b of e.roles){(typeof b.icon!="string"||b.icon.trim().length===0)&&t.push(`Role "${b.key}" must define an icon.`),b.parentRoleKey&&!a.has(b.parentRoleKey)&&t.push(`Role "${b.key}" references missing parent role "${b.parentRoleKey}".`);for(let I of b.listDisplayFieldKeys??[])l.has(I)||t.push(`Role "${b.key}" list display references missing field "${I}".`)}let y=new Map(e.roles.map(b=>[b.key,b.parentRoleKey])),v=new Map;for(let b of e.roleFields){let I=v.get(b.roleKey)??[];I.push({roleId:b.roleKey,customFieldId:b.fieldKey}),v.set(b.roleKey,I)}for(let b of e.roles)try{tF(b.key,y,v)}catch(I){t.push(NF(I))}for(let b of e.roleFields){a.has(b.roleKey)||t.push(`Role field references missing role "${b.roleKey}" for field "${b.fieldKey}".`),l.has(b.fieldKey)||t.push(`Role field references missing field "${b.fieldKey}" for role "${b.roleKey}".`);for(let I of b.targetRequirementFieldKeys??[])l.has(I)||t.push(`Role field "${b.roleKey}.${b.fieldKey}" references missing target requirement field "${I}".`)}$3(e.contractRoleMappings??[],a,t);for(let b of e.templatePlaceholders??[])ND.test(b.key)||t.push(`Template placeholder "${b.key}" must use lower_snake_case segments, optionally separated by dots.`),b.source.kind==="customField"?hm(b.source,d,t,`Template placeholder "${b.key}"`):b.source.kind==="relationshipTargetField"&&A3(b,d,t);for(let b of e.searchTargets??[])hm(b,d,t,"Search target");for(let b of e.fields)dF(b.key)&&(b.defaultValue!==void 0||b.validations!==void 0)&&t.push(`System field "${b.key}" takes no defaultValue or validations.`);for(let b of e.lists)En(b.elements.map((I,M)=>String(I.sortOrder??(M+1)*10)),`sortOrder of an element of list "${b.key}"`,t);for(let b of e.searchFilters??[])En((b.options??[]).map((I,M)=>String(I.sortOrder??(M+1)*10)),`sortOrder of an option of search filter "${b.key}"`,t);for(let b of e.foundation.permissionGroups){b.grantAllCustomFields===!0&&b.customFieldPermissions!==void 0&&t.push(`Permission group "${b.key}" states both grantAllCustomFields and customFieldPermissions \u2014 one of them.`),En((b.customFieldPermissions??[]).map(I=>I.displayGroupKey),`display group of a field permission of group "${b.key}"`,t);for(let I of b.customFieldPermissions??[]){i.has(I.displayGroupKey)||t.push(`Permission group "${b.key}" grants field permissions on missing display group "${I.displayGroupKey}".`);for(let M of I.permissions)sF.includes(M)||t.push(`Permission group "${b.key}" grants unknown field permission "${M}".`)}}let E=e.tenant.partyRetention;E!==void 0&&(lF(E.days)||t.push(`tenant.partyRetention.days must be a whole number of days from 1 to ${36500} (got ${JSON.stringify(E.days)}).`),Number.isFinite(E.enabledAt)||t.push("tenant.partyRetention.enabledAt must be a timestamp (epoch ms)."),E.formerRoleKey!==void 0&&!a.has(E.formerRoleKey)&&t.push(`tenant.partyRetention references missing role "${E.formerRoleKey}".`));for(let b of e.searchFilters??[]){(b.kind==="chips"||b.kind==="select")&&(b.options?.length??0)===0&&t.push(`Search filter "${b.key}" must define options.`),(b.kind==="text"||b.kind==="numberRange")&&b.target===void 0&&t.push(`Search filter "${b.key}" must define a target field.`),b.options!==void 0&&En(b.options.map(I=>I.key),`search filter option for "${b.key}"`,t),hm(b.target,d,t,`Search filter "${b.key}"`);for(let I of b.options??[]){I.predicates.length===0&&t.push(`Search filter option "${b.key}.${I.key}" must define at least one predicate.`);for(let M of I.predicates){if(M.kind==="role"){a.has(M.roleKey)||t.push(`Search filter option "${b.key}.${I.key}" references missing role "${M.roleKey}".`);continue}hm(M,d,t,`Search filter option "${b.key}.${I.key}"`)}}}for(let b of e.partyResultIcons??[])E3(b,d,t);for(let b of e.foundation.legalEntities)if(b.terms!==void 0&&t.push(...Qk(b.terms,`foundation.legalEntities.${b.key}.terms`)),PF(b.branding,t,`foundation.legalEntities.${b.key}.branding`),CF(b,t,`foundation.legalEntities.${b.key}`),b.signatoryUserKey!==void 0&&b.type==="school_group"&&t.push(`[config/signatoryOnGroup] Legal entity "${b.key}" is a school_group \u2014 only a Tr\xE4ger (school_operator, service_entity) declares an Unterschriftsperson.`),b.parentLegalEntityKey&&!c.has(b.parentLegalEntityKey)&&t.push(`Legal entity "${b.key}" references missing parent "${b.parentLegalEntityKey}".`),b.address!==void 0){let I=b.address,M=["street","hausnr","plz","ort"];b.type==="school_group"?t.push(`Legal entity "${b.key}" is a school_group \u2014 only a Tr\xE4ger (school_operator, service_entity) has an address.`):(typeof I!="object"||I===null||Array.isArray(I)||Object.keys(I).some(S=>!M.includes(S))||M.some(S=>typeof I[S]!="string"||(I[S]??"").trim()===""))&&t.push(`Legal entity "${b.key}" has an invalid address \u2014 expected { street, hausnr, plz, ort }, each non-empty.`)}let T=new Map;for(let b of e.foundation.units){if(b.slug!==void 0){let I=typeof b.slug=="string"?UD(b.slug):"must be a string";I!==void 0&&t.push(`Unit "${b.key}" has invalid slug "${b.slug}" (${I}).`);let M=T.get(b.slug);M!==void 0&&t.push(`Units "${M}" and "${b.key}" both declare slug "${b.slug}" (unit slugs are unique per tenant).`),T.set(b.slug,b.key)}c.has(b.legalEntityKey)||t.push(`Unit "${b.key}" references missing legal entity "${b.legalEntityKey}".`),b.parentUnitKey&&!u.has(b.parentUnitKey)&&t.push(`Unit "${b.key}" references missing parent unit "${b.parentUnitKey}".`),b.sortOrder!==void 0&&(!Number.isFinite(b.sortOrder)||b.sortOrder<0)&&t.push(`Unit "${b.key}" has invalid sortOrder "${b.sortOrder}" (must be a non-negative number).`)}let R=/^[0-9a-f]{32}:[0-9a-f]{128}$/;for(let b of e.foundation.users){p.has(b.permissionGroupKey)||t.push(`User "${b.email}" references missing permission group "${b.permissionGroupKey}".`),b.unitKey&&!u.has(b.unitKey)&&t.push(`User "${b.email}" references missing unit "${b.unitKey}".`),b.status!==void 0&&b.status!=="deactivated"&&t.push(`User "${b.email}": status must be "deactivated" or absent, not "${String(b.status)}".`);let I=[b,...b.additionalMemberships??[]];for(let S of b.additionalMemberships??[])p.has(S.permissionGroupKey)||t.push(`User "${b.email}" references missing permission group "${S.permissionGroupKey}".`),S.unitKey&&!u.has(S.unitKey)&&t.push(`User "${b.email}" references missing unit "${S.unitKey}".`);En(I.map(S=>`${S.permissionGroupKey}/${S.unitKey??""}`),`membership (permission group/unit) of user "${b.email}"`,t);for(let S of I)S.validFrom!==void 0&&S.validTo!==void 0&&S.validTo<=S.validFrom&&t.push(`User "${b.email}": membership "${S.permissionGroupKey}" ends (validTo) before it starts (validFrom).`);let M=[b.firstName,b.lastName];M.some(S=>S!==void 0)&&M.some(S=>typeof S!="string"||S.trim()==="")&&t.push(`[config/userNameIncomplete] User "${b.email}" states only part of firstName/lastName (or an empty one) \u2014 set both or neither.`);for(let S of["staging","prod"]){let j=b.passwordHashes?.[S];j!==void 0&&!R.test(j)&&t.push(`User "${b.email}" passwordHashes.${S} is not in Better Auth scrypt format "<32hex>:<128hex>".`)}}PF(e.tenant.branding,t),CF(e.tenant,t);let N=LF(e.fields.flatMap(b=>b.sourceColumns));for(let b of N)r.push(`Source column "${b}" is mapped by more than one field.`);N3(e,t);let P=n.sourceColumns===void 0||e.source===void 0?void 0:O3(e,n.sourceColumns,t);return{ok:t.length===0,errors:t,warnings:r,coverage:P}}s(DF,"validateTenantConfig");function v3(e,n){let t=new Map;for(let r of e.objectSchema?.properties??[]){let i=r.addressPart;if(i===void 0)continue;let o=`Object property "${e.key}.${r.key}"`;if(!rw.includes(i)){n.push(`${o}: addressPart "${i}" is none of ${rw.join(", ")}.`);continue}e.type!=="object"&&n.push(`${o}: only an object field stores an address (addressPart).`),r.type!=="string"&&n.push(`${o}: addressPart "${i}" needs a string property, not "${r.type}".`);let a=t.get(i);a!==void 0&&n.push(`${o}: addressPart "${i}" is already declared by "${e.key}.${a}".`),t.set(i,r.key)}}s(v3,"validateAddressParts");function x3(e,n){let t=e.relationshipKinds;if(t===void 0)return;if(e.type!=="relationship"){n.push(`Field "${e.key}" declares relationshipKinds, but only a relationship field carries them.`);return}let r=new Map((e.objectSchema?.properties??[]).map(i=>[i.key,i]));for(let i of t){let o=`Field "${e.key}" relationship kind "${i.key}"`;if(typeof i.key!="string"||i.key.trim()===""){n.push(`Field "${e.key}": a relationship kind needs a key.`);continue}for(let l of["de","en"])(i.label?.[l]??"").trim()===""&&n.push(`${o}: label.${l} is required \u2014 [i18n/missingTranslation] every shown text needs German and English.`);if(i.edge===null||typeof i.edge!="object"||Array.isArray(i.edge)){n.push(`${o}: edge must be an object.`);continue}i.sibling!==void 0&&i.sibling!==!0&&n.push(`${o}: sibling must be true or absent.`),i.sibling===!0&&i.mergeInto!==void 0&&n.push(`${o}: a sibling kind's edge is its identity \u2014 it cannot declare mergeInto.`);let a=t.flatMap(l=>l.mergeInto!==void 0?[l.mergeInto]:[]);if(i.sibling===!0&&a.some(l=>l in i.edge)&&n.push(`${o}: a sibling kind's edge is its identity \u2014 it cannot declare a property another kind of the field merges into.`),i.sibling===!0&&Object.keys(i.edge).length===0&&n.push(`${o}: a sibling kind's edge is its identity \u2014 an empty edge would count every edge of the field.`),i.mergeInto!==void 0){let l=r.get(i.mergeInto);l===void 0||l.type!=="0-n-select"?n.push(`${o}: mergeInto "${i.mergeInto}" must name a 0-n-select property of the field's objectSchema.`):Array.isArray(i.edge[i.mergeInto])||n.push(`${o}: mergeInto "${i.mergeInto}" must be set to a list in the edge.`)}}}s(x3,"validateRelationshipKinds");function S3(e,n,t){if(e.autoString===void 0){t.push(`Automatic field "${e.key}" must define autoString.`);return}e.allowMultiple===!0&&t.push(`Automatic field "${e.key}" must not allow multiple values.`),e.shareable===!0&&t.push(`Automatic field "${e.key}" must not be shareable.`),e.autoString.segments.length===0&&t.push(`Automatic field "${e.key}" must define at least one segment.`),e.autoString.segments.filter(i=>i.kind==="sequence").length!==1&&t.push(`Automatic field "${e.key}" must define exactly one sequence segment.`);for(let i of e.autoString.segments)if(i.kind==="literal"&&i.value.length===0&&t.push(`Automatic field "${e.key}" has an empty literal segment.`),i.kind==="sequence"&&(i.startAt!==void 0&&(!Number.isInteger(i.startAt)||i.startAt<1)&&t.push(`Automatic field "${e.key}" sequence startAt must be an integer >= 1.`),i.minDigits!==void 0&&(!Number.isInteger(i.minDigits)||i.minDigits<0)&&t.push(`Automatic field "${e.key}" sequence minDigits must be an integer >= 0.`)),i.kind==="field"){let o=n.get(i.fieldKey);if(o===void 0){t.push(`Automatic field "${e.key}" references missing field "${i.fieldKey}".`);continue}i.objectPropertyKey!==void 0&&o.objectSchema?.properties.find(l=>l.key===i.objectPropertyKey)===void 0&&t.push(`Automatic field "${e.key}" references missing object property "${i.fieldKey}.${i.objectPropertyKey}".`)}}s(S3,"validateAutomaticStringField");function hm(e,n,t,r){if(e===void 0)return;let i=n.get(e.fieldKey);if(i===void 0){t.push(`${r} references missing field "${e.fieldKey}".`);return}if(e.objectPropertyKey===void 0)return;(i.objectSchema?.properties.some(a=>a.key===e.objectPropertyKey)??!1)||t.push(`${r} references missing object property "${e.fieldKey}.${e.objectPropertyKey}".`)}s(hm,"validateSearchTarget");function A3(e,n,t){if(e.source.kind!=="relationshipTargetField")return;let r=`Template placeholder "${e.key}"`,i=n.get(e.source.relationshipFieldKey);if(i===void 0)t.push(`${r} references missing relationship field "${e.source.relationshipFieldKey}".`);else if(i.type!=="relationship")t.push(`${r} relationship field "${e.source.relationshipFieldKey}" must be a relationship field.`);else{for(let a of e.source.edgeFilters??[])tb(i,a.propertyKey,t,`${r} edge filter`);e.source.selection?.sortPropertyKey!==void 0&&tb(i,e.source.selection.sortPropertyKey,t,`${r} selection sort`)}let o=n.get(e.source.targetFieldKey);if(o===void 0){t.push(`${r} references missing target field "${e.source.targetFieldKey}".`);return}o.type==="relationship"&&t.push(`${r} target field "${e.source.targetFieldKey}" must not be a relationship field.`),e.source.targetObjectPropertyKey!==void 0&&tb(o,e.source.targetObjectPropertyKey,t,`${r} target`)}s(A3,"validateRelationshipTemplatePlaceholder");function tb(e,n,t,r){(e.objectSchema?.properties.some(o=>o.key===n)??!1)||t.push(`${r} references missing object property "${e.key}.${n}".`)}s(tb,"validateObjectPropertyReference");function E3(e,n,t){let r=`Party result icon "${e.key}"`,i=n.get(e.when.fieldKey);if(i===void 0){t.push(`${r} references missing field "${e.when.fieldKey}".`);return}if(e.when.objectPropertyKey===void 0){i.type!=="boolean"&&t.push(`${r} must target a Boolean field or object property.`);return}let o=i.objectSchema?.properties.find(a=>a.key===e.when.objectPropertyKey);if(o===void 0){t.push(`${r} references missing object property "${e.when.fieldKey}.${e.when.objectPropertyKey}".`);return}o.type!=="boolean"&&t.push(`${r} must target a Boolean field or object property.`)}s(E3,"validatePartyResultIconTarget");function FF(e){return`${e.templateId}:${e.locale}:${e.scopeKey}`}s(FF,"letterIdentity");function T3(e){return`${e.generatorKey??"*"}/${e.partyKind}/${e.roleKey}`}s(T3,"contractRoleMappingIdentity");function $3(e,n,t){let r=new Set;for(let i of e){let o=T3(i),a=`Contract role mapping "${o}"`;Uk.includes(i.partyKind)||t.push(`${a}: partyKind must be one of ${Uk.join(", ")}.`),i.partyKind==="beneficiary"&&t.push(`${a}: a beneficiary holds the enrollee role of the program it attends (programs.enrolleeRoleKey, else tenant.defaultEnrolleeRoleKey) \u2014 remove the mapping.`),n.has(i.roleKey)||t.push(`${a} references missing role "${i.roleKey}".`),i.generatorKey!==void 0&&i.generatorKey.trim()===""&&t.push(`${a}: generatorKey must not be blank \u2014 omit it for the tenant default.`),r.has(o)&&t.push(`${a} is declared twice.`),r.add(o)}}s($3,"validateContractRoleMappings");function R3(e,n){for(let t of e){let r=`Notification letter "${FF(t)}"`;if(!dm(t.locale)){n.push(`${r} declares locale "${String(t.locale)}" \u2014 letters are written in ${We.map(i=>`"${i}"`).join(" and ")} only, so no mail would ever read this deviation.`);continue}if(t.scopeKey!==am){n.push(`${r} declares scopeKey "${t.scopeKey}" \u2014 the only scope is "${am}" (the whole school).`);continue}if(Object.keys(t.slots).length===0){n.push(`${r} overrides no block. A deviation that deviates in nothing is not an entry \u2014 remove it.`);continue}if(!Nw(t.templateId)){n.push(`${r} references no registered letter \u2014 "${t.templateId}" is not in the letter catalog.`);continue}for(let i of gF(_w(t.templateId),t.slots,t.locale))n.push(`${r}, block "${i.slotKey}" [${i.code}]: ${i.message.de}`)}}s(R3,"validateNotificationLetters");function I3(e,n){if(e!==void 0)for(let t of yF(e))n.push(`Notification chrome: ${t.de}`)}s(I3,"validateNotificationChrome");function PF(e,n,t){if(e===void 0)return;let r=t===void 0?n:{push:s((...p)=>n.push(...p.map(h=>`${t}: ${h}`)),"push")},i=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,o=/^(?:rgb|rgba|hsl|hsla)\(.+\)$/i,a=s(p=>i.test(p.trim())||o.test(p.trim()),"isColor");for(let[p,h]of Object.entries(e.colors??{}))h!==void 0&&(a(h)||r.push(`Branding color "colors.${p}" has invalid value "${h}" (expected hex "#rgb"/"#rrggbb"/"#rrggbbaa" or rgb()/rgba()/hsl()/hsla()).`));let l=["sharp","rounded","soft"];e.radius!==void 0&&!l.includes(e.radius)&&r.push(`Branding radius "${e.radius}" is invalid (expected "sharp", "rounded", or "soft").`);let d=["sm","md","lg","max"];e.logoSize!==void 0&&!d.includes(e.logoSize)&&r.push(`Branding logoSize "${e.logoSize}" is invalid (expected "sm", "md", "lg", or "max").`);let c=["compact","normal","spacious"];e.bannerDensity!==void 0&&!c.includes(e.bannerDensity)&&r.push(`Branding bannerDensity "${e.bannerDensity}" is invalid (expected "compact", "normal", or "spacious").`);let u=["light","dark"];e.logoGround!==void 0&&!u.includes(e.logoGround)&&r.push(`Branding logoGround "${e.logoGround}" is invalid (expected "light" or "dark").`),e.websiteUrl!==void 0&&!e.websiteUrl.startsWith("https://")&&r.push(`Branding websiteUrl must be an https:// URL (got "${e.websiteUrl}").`);for(let p of["heading","body"]){let h=e.fonts?.[p];h!==void 0&&((typeof h.family!="string"||h.family.trim().length===0)&&r.push(`Branding font "fonts.${p}" must define a non-empty family.`),Object.hasOwn(h,"url")&&r.push(`Branding font "fonts.${p}.url" is no longer supported \u2014 the font file is uploaded (plexus-cli branding set-font --slot ${p} --file <woff2>) and config carries the family only.`))}}s(PF,"validateBranding");function CF(e,n,t="tenant"){let r=e.brandingAssets;if(r!==void 0){if(typeof r!="object"||r===null||Array.isArray(r)){n.push(`${t}.brandingAssets must be an object keyed by slot (${fm.join(", ")}).`);return}for(let[i,o]of Object.entries(r)){let a=`${t}.brandingAssets.${i}`;if(!fm.includes(i)){n.push(`${a}: unknown slot (expected ${fm.join(", ")}).`);continue}if(typeof o!="object"||o===null){n.push(`${a}: must be { sha256, sizeBytes, mimeType }.`);continue}if("size"in o){n.push(`[config/fileRefRenamed] ${a} still names size \u2014 this bundle was exported before the file-field rename, or by a plexus-cli older than this release (now sizeBytes). Update plexus-cli, export it again (plexus-cli --env <env> config export) and re-apply.`);continue}MF.test(o.sha256??"")||n.push(`${a}: sha256 must be 64 lowercase hex chars.`),(!Number.isInteger(o.sizeBytes)||o.sizeBytes<=0)&&n.push(`${a}: sizeBytes must be a positive integer.`);let l=bF[i];if(l===null){let d=vF({contentType:o.mimeType,size:o.sizeBytes});d!==null&&n.push(`${a}: ${d.de}`)}else{o.mimeType!==eb&&n.push(`${a}: mimeType must be "${eb}" (got "${o.mimeType}").`);let d=xF(e.branding?.fonts?.[l]?.family);d!==null&&n.push(`${a}: [branding/fontFamilyMissing] ${t}.branding.fonts.${l}: ${d.de}`)}"path"in o&&n.push(`${a}: "path" is a CLI snapshot field \u2014 resolve it with plexus-cli config apply.`)}}}s(CF,"validateBrandingAssets");function O3(e,n,t){let{source:r}=e;r===void 0&&F("validateSourceCoverage: called without a `source` block.");let i=new Set(n),o=new Set(e.fields.flatMap(k=>k.sourceColumns)),a=new Set(e.deferredColumns.map(k=>k.column)),l=new Set(e.ignoredColumns.map(k=>k.column)),d=new Set([...o,...a,...l]),c=r.requiredColumns.filter(k=>!i.has(k)),u=n.filter(k=>!d.has(k)),p=[...o].filter(k=>!i.has(k)),h=[...a].filter(k=>!i.has(k)),w=[...l].filter(k=>!i.has(k));for(let k of c)t.push(`Required source column "${k}" is missing from ${r.primaryTable}.`);for(let k of u)t.push(`Source column "${k}" is neither mapped nor explicitly deferred/ignored.`);for(let k of p)t.push(`Mapped source column "${k}" does not exist in the source schema.`);for(let k of h)t.push(`Deferred source column "${k}" does not exist in the source schema.`);for(let k of w)t.push(`Ignored source column "${k}" does not exist in the source schema.`);return{table:r.primaryTable,availableColumns:n.length,mappedColumns:[...o].filter(k=>i.has(k)).length,deferredColumns:[...a].filter(k=>i.has(k)).length,ignoredColumns:[...l].filter(k=>i.has(k)).length,missingRequiredColumns:c,unmappedColumns:u,unknownMappedColumns:p,unknownDeferredColumns:h,unknownIgnoredColumns:w}}s(O3,"validateSourceCoverage");function En(e,n,t){for(let r of LF(e))t.push(`Duplicate ${n} key "${r}".`)}s(En,"requireUnique");function LF(e){let n=new Set,t=new Set;for(let r of e)n.has(r)&&t.add(r),n.add(r);return[...t]}s(LF,"duplicates");var MF=/^[0-9a-f]{64}$/,_3=["fileName","size"];function N3(e,n){if(!Array.isArray(e.files)){n.push('"files" is missing \u2014 declare the file library (an empty list is fine).');return}En(e.files.map(t=>t.key),"file",n);for(let t of e.files){let r=`files["${t.key}"]`;Sa(t.key)||n.push(`${r}: key must match ${bk}.`);for(let o of["de","en"])(t.label?.[o]??"").trim()===""&&n.push(`${r}: label.${o} is required \u2014 [i18n/missingTranslation] every shown text needs German and English.`);let i=_3.filter(o=>o in t);if(i.length>0){n.push(`[config/fileRefRenamed] ${r} still names ${i.join(", ")} \u2014 this bundle was exported before the file-field rename, or by a plexus-cli older than this release (now filename / sizeBytes). Update plexus-cli, export it again (plexus-cli --env <env> config export) and re-apply.`);continue}if(typeof t.filename!="string")n.push(`${r}: filename is missing.`);else{let o=Yo(t.filename);o!==null&&n.push(`${r}: filename ${o}.`)}lm.includes(t.mimeType)||n.push(`${r}: mimeType "${t.mimeType}" is not allowed (${lm.join(", ")}).`),MF.test(t.sha256??"")||n.push(`${r}: sha256 must be 64 lowercase hex chars.`),(!Number.isInteger(t.sizeBytes)||t.sizeBytes<=0)&&n.push(`${r}: sizeBytes must be a positive integer.`),"path"in t&&n.push(`${r}: "path" is a CLI snapshot field \u2014 resolve it with plexus-cli config apply.`)}}s(N3,"validateFiles");var P3=new WeakMap,C3=new WeakSet;function rb(e,n){n(e);let r=e.asOptional.bind(e);return Object.defineProperty(e,"asOptional",{value:s(()=>rb(r(),n),"value"),enumerable:!1}),e}s(rb,"carry");function Oa(e,n){return rb(e,t=>P3.set(t,n))}s(Oa,"tagged");var D3="tenant teardown drains every table explicitly (config/wipe.ts)",Ve={belongsTo:s(e=>Oa(e,{kind:"belongsTo"}),"belongsTo"),owns:s(e=>Oa(e,{kind:"owns"}),"owns"),holds:s(e=>Oa(e,{kind:"holds"}),"holds"),restrict:s((e,n)=>Oa(e,n?{kind:"restrict",unindexed:n.unindexed}:{kind:"restrict"}),"restrict"),history:s(e=>Oa(e,{kind:"history"}),"history"),tenant:s(e=>Oa(e,{kind:"restrict",unindexed:D3}),"tenant"),historyOf:s(e=>rb(e,n=>C3.add(n)),"historyOf")};var F3=m.object({street:m.string(),hausnr:m.string(),plz:m.string(),ort:m.string()}),qF=m.union(m.literal("school_operator"),m.literal("school_group"),m.literal("service_entity")),Gr=qF.members.map(e=>e.value),L3={tenantId:Ve.tenant(m.id("tenants")),name:m.optional(m.string()),type:qF,parentLegalEntityId:m.optional(Ve.restrict(m.id("legal_entities"))),configKey:m.optional(m.string()),partyId:m.optional(Ve.restrict(m.id("parties"))),address:m.optional(F3),signatoryUserId:m.optional(Ve.restrict(m.id("users"))),terms:m.optional(mF)},cTe=Pt(L3).index("by_tenantId",["tenantId"]).index("by_parentLegalEntityId",["parentLegalEntityId"]).index("by_tenantId_and_configKey",["tenantId","configKey"]).index("by_partyId",["partyId"]).index("by_signatoryUserId",["signatoryUserId"]);var M3=m.union(m.literal("school"),m.literal("kindergarten"),m.literal("after_school_care"),m.literal("department"),m.literal("site"),m.literal("other")),qt=M3.members.map(e=>e.value),pTe=m.union(m.literal("school"),m.literal("vocational"),m.literal("care"),m.literal("seminar"),m.literal("other")),mTe=m.union(m.literal("none"),m.literal("manual"),m.literal("annual_rollover")),hTe=m.union(m.literal("grade_level"),m.literal("module"),m.literal("phase"),m.literal("other")),gTe=m.union(m.literal("school_year"),m.literal("cohort"),m.literal("seminar"),m.literal("care_period"),m.literal("other")),yTe=m.union(m.literal("planned"),m.literal("active"),m.literal("completed"),m.literal("archived")),wTe=m.union(m.literal("class"),m.literal("course"),m.literal("care_group"),m.literal("seminar_group"),m.literal("mixed_age_group"),m.literal("other")),kTe=m.union(m.literal("planned"),m.literal("active"),m.literal("completed"),m.literal("cancelled")),bTe=m.union(m.literal("class_teacher"),m.literal("teacher"),m.literal("mentor"),m.literal("instructor"),m.literal("assistant"),m.literal("other")),vTe=m.union(m.literal("units"),m.literal("unit_profiles"),m.literal("programs"),m.literal("program_stages"),m.literal("program_runs"),m.literal("learning_groups"),m.literal("enrollments"),m.literal("learning_group_staff_assignments")),xTe=m.union(m.literal("open"),m.literal("mapped"),m.literal("ignored"));function jF(e){let n=["street","hausnr","plz","ort"].filter(t=>e[t]!==void 0);if(n.length!==0){if(n.length!==4)throw new Error(`config legal-entity add: an address needs all of --street, --hausnr, --plz and --ort (got ${n.map(t=>`--${t}`).join(", ")})`);return{street:e.street,hausnr:e.hausnr,plz:e.plz,ort:e.ort}}}s(jF,"addressFrom");function VF(e){if(!Gr.includes(e))throw new Error(`config legal-entity add: --type "${e}" is none of ${Gr.join(", ")}`);return e}s(VF,"legalEntityType");function BF(e){if(!qt.includes(e))throw new Error(`config unit add: --kind "${e}" is none of ${qt.join(", ")}`);return e}s(BF,"unitKind");function UF(e,n,t){let r=e.find(i=>i.key===n.key);if(r===void 0)return e.push(n),"create";if(Ne(r)===Ne(n))return"same";throw new Error(`${t} "${n.key}" already exists with other values \u2014 decide by hand, nothing written.
11296
11296
  in the file: ${JSON.stringify(r)}
11297
11297
  requested: ${JSON.stringify(n)}`)}s(UF,"addRow");function KF(e){return new Set(DF(e).errors)}s(KF,"findings");function GF(e,n){let t=s(()=>JSON.parse(he(e,"utf8")),"read"),r=t();if(typeof r!="object"||r===null||typeof r.foundation!="object")throw new Error(`config: ${e} is no exported tenant config (no "foundation" block) \u2014 export one with \`config export --out <file>\``);let i=KF(r),o=t(),a=n(o),l=[...KF(o)].filter(d=>!i.has(d));if(l.length>0)throw new Error(`config: the edit is refused by the config validator, nothing written:
11298
11298
  ${l.join(`
@@ -11530,6 +11530,6 @@ ${t.length} unusable ${o}:
11530
11530
  `),r.length>0&&this.context.stdout.write(` ${r.length} linkable \u2014 plexus-cli platform users relink-auth <email>
11531
11531
  `),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>
11532
11532
  `)}else this.context.stdout.write(`No unusable identities.
11533
- `);return t.length>0?1:0}},AT=class extends ur{static{s(this,"UsersRelinkAuthCommand")}static paths=[["platform","users","relink-auth"],["users","relink-auth"]];static usage=$.Usage({category:"Users",description:"Relink a user's identity row to its live Better Auth account (heals an orphan)."});email=f.String({required:!0});async execute(){let t=await(await this.caller()).mutation(x.platformAdmin.relinkAuthAccount,{email:this.email}),r=t.changed?`Relinked ${this.email} to live auth account ${t.authId}.`:`${this.email} already linked to the live auth account (no change).`;return this.report(t,r),0}};function CB(e,n){if(e===n)throw new Error("Pass exactly one of --on or --off.");return e}s(CB,"requireOnOff");var DB=[aT,lT,dT,cT,uT,fT,pT,mT,hT,gT,vu,yT,wT,kT,bT,vT,xT,ST,AT];function FB(e){return e.de??e.en??Object.values(e)[0]??""}s(FB,"titleDe");function GX(e){return{id:e._id,kind:e.kind,status:e.status,title:FB(e.title).slice(0,50),assignee:e.assigneeUserId??"",group:e.queueGroupId??"",outcome:e.outcome??""}}s(GX,"row");var zX=["id","kind","status","title","assignee","group","outcome"],$T=class extends D{static{s(this,"WorkItemsListCommand")}static paths=[["work-items","list"]];static usage=$.Usage({category:"Work-Items",description:"List work-items for the active tenant (filter by --mine/--application/--group)."});mine=f.Boolean("--mine",!1,{description:"Only items assigned to me."});application=f.String("--application",{description:"Filter by application id."});group=f.String("--group",{description:"Filter by team (permission-group) id."});assignee=f.String("--assignee",{description:"Filter by assignee users._id."});openOnly=f.Boolean("--open-only",!1,{description:"Only open items."});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.query(x.workItems.list,{client:t,...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(GX),zX),0}},RT=class extends D{static{s(this,"WorkItemsShowCommand")}static paths=[["work-items","show"]];static usage=$.Usage({category:"Work-Items",description:"Show one work-item by id."});workItemId=f.String({required:!0,name:"workItemId"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.query(x.workItems.get,{client:t,workItemId:this.workItemId});if(r===null)throw new Error(`work-item ${this.workItemId} not found in tenant ${t}.`);return this.print(r,i=>[{field:"id",value:i._id},{field:"kind",value:i.kind},{field:"status",value:i.status},{field:"title",value:FB(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}},IT=class extends D{static{s(this,"WorkItemsCreateCommand")}static paths=[["work-items","create"]];static usage=$.Usage({category:"Work-Items",description:"Create a manual task work-item."});title=f.String("--title",{required:!0,description:"Task title."});description=f.String("--description",{description:"Task description."});application=f.String("--application",{description:"Link to an application id."});group=f.String("--group",{description:"Team (permission-group) id whose queue holds the task."});assignee=f.String("--assignee",{description:"Assignee users._id."});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.mutation(x.workItems.createManual,{client:t,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}},OT=class extends D{static{s(this,"WorkItemsCompleteCommand")}static paths=[["work-items","complete"]];static usage=$.Usage({category:"Work-Items",description:"Complete a work-item (optionally with an outcome)."});workItemId=f.String({required:!0,name:"workItemId"});outcome=f.String("--outcome",{description:"Outcome id to record."});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.mutation(x.workItems.complete,{client:t,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}},_T=class extends D{static{s(this,"WorkItemsAssignCommand")}static paths=[["work-items","assign"]];static usage=$.Usage({category:"Work-Items",description:"Assign a work-item to a user (omit --user to unassign)."});workItemId=f.String({required:!0,name:"workItemId"});user=f.String("--user",{description:"Assignee users._id (omit to clear)."});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.mutation(x.workItems.assign,{client:t,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}},LB=[$T,RT,IT,OT,_T];var xu=[...uI,...VD,...XD,...nL,...eL,...$L,...CL,...PL,...NB,...DB,..._B,...gV,...xV,...TD,...SL,...kB,...dI,...LI,...uD,...LL,...FL,...KL,...jL,...vL,...aL,...LB,...cK,...XK,...mV,...ej,...tB,...cB,...SV,...NV,...DV,...qV,...jV,...pB,...AB,...$I];for(let e of xu){let n=e.paths?.[0];n===void 0||!Object.hasOwn(e,"usage")||e.usage===void 0||(e.usage={...e.usage,category:N$(e.usage.category,n.join(" "))})}var MB="0.1.196";function qB(){return xu.flatMap(e=>(e.paths??[]).map(n=>{let t=n.join(" "),r=R$[ho(t)];return{path:t,effect:go(t),host:r===void 0?"shared":"terminal",...r===void 0?{}:{reason:r}}})).sort((e,n)=>e.path.localeCompare(n.path))}s(qB,"plexusCommandCatalog");import ps from"node:path";function WX(e){let n=dn()?.workspaceRoot??process.cwd(),t=ps.resolve(n,e),r=ps.relative(n,t);if(ps.isAbsolute(e)||r===".."||r.startsWith(`..${ps.sep}`))throw new Error("plexus: use a relative path inside the current workspace.");return{absolute:t,relative:r}}s(WX,"workspacePath");function YX(e){let{absolute:n,relative:t}=WX(e.path??".");if(e.operation==="list"){if(!Ae(n))return{files:[]};let r=[],i=s(o=>{for(let a of Or(o,{withFileTypes:!0})){if(a.isSymbolicLink())throw new Error("plexus: workspace symlinks are not supported.");let l=ps.join(o,a.name);if(a.isDirectory()?i(l):r.push(ps.relative(n,l)),r.length>200)throw new Error("plexus: the workspace contains too many files. List a subdirectory.")}},"visit");return i(n),{files:r.sort()}}if(!t)throw new Error("plexus: name a workspace file.");if(["read","search","edit"].includes(e.operation)){let r=he(n);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:t,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:t,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 ze(n,a,"utf8"),{path:t,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 Fn(ps.dirname(n),{recursive:!0}),ze(n,e.content,"utf8"),{path:t,sizeBytes:Buffer.byteLength(e.content)}}if(e.operation==="remove")return ys(n),{path:t,removed:!0};throw new Error("plexus: unknown workspace operation.")}s(YX,"plexusWorkspace");function KB(e){return s(async function(t,r){if(!r||typeof r!="object"||Array.isArray(r))throw new Error("plexus: tool input must be an object.");let i=r,o=El[t];if(!o||!Object.hasOwn(El,t))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(t==="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(t==="plexus_skill"){if(typeof i.path!="string"||i.path.length>240||!Object.hasOwn(hy,i.path))throw new Error("plexus: unknown skill reference. Start with SKILL.md.");return{path:i.path,content:hy[i.path],skillHash:yf}}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 YX(i)},"executePlexusAgentTool")}s(KB,"createPlexusAgentToolExecutor");var eg=KB({inspectCommand:VB,executeCommand:BB});function ng(){let e=new vs({binaryLabel:"Plexus CLI",binaryName:"plexus-cli",binaryVersion:MB});e.register(ll.HelpCommand),e.register(ll.VersionCommand);for(let t of xu)e.register(t);async function n(t,r){let i;try{i=e.process(t,r)}catch(o){return(r.stderr??process.stderr).write(e.error(o,{colored:!1})),2}return QX(i,r.stderr??process.stderr),e.run(i,r)}return s(n,"run"),{process(t,r){return e.process(t,r)},run:n,async runExit(t,r){process.exitCode=await n(t,r)}}}s(ng,"createPlexusCli");function QX(e,n){let t=e.path.join(" "),r=e.constructor.paths?.[0]?.join(" ");r!==void 0&&t!==r&&pl[t]===r&&an(n,t,r),t in pl&&go(t)==="confirm"&&!ml(e)&&n.write(`plexus-cli: \`${pl[t]}\` only prints its plan without --confirm \u2014 nothing was changed.
11533
+ `);return t.length>0?1:0}},AT=class extends ur{static{s(this,"UsersRelinkAuthCommand")}static paths=[["platform","users","relink-auth"],["users","relink-auth"]];static usage=$.Usage({category:"Users",description:"Relink a user's identity row to its live Better Auth account (heals an orphan)."});email=f.String({required:!0});async execute(){let t=await(await this.caller()).mutation(x.platformAdmin.relinkAuthAccount,{email:this.email}),r=t.changed?`Relinked ${this.email} to live auth account ${t.authId}.`:`${this.email} already linked to the live auth account (no change).`;return this.report(t,r),0}};function CB(e,n){if(e===n)throw new Error("Pass exactly one of --on or --off.");return e}s(CB,"requireOnOff");var DB=[aT,lT,dT,cT,uT,fT,pT,mT,hT,gT,vu,yT,wT,kT,bT,vT,xT,ST,AT];function FB(e){return e.de??e.en??Object.values(e)[0]??""}s(FB,"titleDe");function GX(e){return{id:e._id,kind:e.kind,status:e.status,title:FB(e.title).slice(0,50),assignee:e.assigneeUserId??"",group:e.queueGroupId??"",outcome:e.outcome??""}}s(GX,"row");var zX=["id","kind","status","title","assignee","group","outcome"],$T=class extends D{static{s(this,"WorkItemsListCommand")}static paths=[["work-items","list"]];static usage=$.Usage({category:"Work-Items",description:"List work-items for the active tenant (filter by --mine/--application/--group)."});mine=f.Boolean("--mine",!1,{description:"Only items assigned to me."});application=f.String("--application",{description:"Filter by application id."});group=f.String("--group",{description:"Filter by team (permission-group) id."});assignee=f.String("--assignee",{description:"Filter by assignee users._id."});openOnly=f.Boolean("--open-only",!1,{description:"Only open items."});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.query(x.workItems.list,{client:t,...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(GX),zX),0}},RT=class extends D{static{s(this,"WorkItemsShowCommand")}static paths=[["work-items","show"]];static usage=$.Usage({category:"Work-Items",description:"Show one work-item by id."});workItemId=f.String({required:!0,name:"workItemId"});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.query(x.workItems.get,{client:t,workItemId:this.workItemId});if(r===null)throw new Error(`work-item ${this.workItemId} not found in tenant ${t}.`);return this.print(r,i=>[{field:"id",value:i._id},{field:"kind",value:i.kind},{field:"status",value:i.status},{field:"title",value:FB(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}},IT=class extends D{static{s(this,"WorkItemsCreateCommand")}static paths=[["work-items","create"]];static usage=$.Usage({category:"Work-Items",description:"Create a manual task work-item."});title=f.String("--title",{required:!0,description:"Task title."});description=f.String("--description",{description:"Task description."});application=f.String("--application",{description:"Link to an application id."});group=f.String("--group",{description:"Team (permission-group) id whose queue holds the task."});assignee=f.String("--assignee",{description:"Assignee users._id."});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.mutation(x.workItems.createManual,{client:t,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}},OT=class extends D{static{s(this,"WorkItemsCompleteCommand")}static paths=[["work-items","complete"]];static usage=$.Usage({category:"Work-Items",description:"Complete a work-item (optionally with an outcome)."});workItemId=f.String({required:!0,name:"workItemId"});outcome=f.String("--outcome",{description:"Outcome id to record."});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.mutation(x.workItems.complete,{client:t,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}},_T=class extends D{static{s(this,"WorkItemsAssignCommand")}static paths=[["work-items","assign"]];static usage=$.Usage({category:"Work-Items",description:"Assign a work-item to a user (omit --user to unassign)."});workItemId=f.String({required:!0,name:"workItemId"});user=f.String("--user",{description:"Assignee users._id (omit to clear)."});async execute(){let n=await this.caller(),t=this.requireTenant(n),r=await n.mutation(x.workItems.assign,{client:t,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}},LB=[$T,RT,IT,OT,_T];var xu=[...uI,...VD,...XD,...nL,...eL,...$L,...CL,...PL,...NB,...DB,..._B,...gV,...xV,...TD,...SL,...kB,...dI,...LI,...uD,...LL,...FL,...KL,...jL,...vL,...aL,...LB,...cK,...XK,...mV,...ej,...tB,...cB,...SV,...NV,...DV,...qV,...jV,...pB,...AB,...$I];for(let e of xu){let n=e.paths?.[0];n===void 0||!Object.hasOwn(e,"usage")||e.usage===void 0||(e.usage={...e.usage,category:N$(e.usage.category,n.join(" "))})}var MB="0.1.197";function qB(){return xu.flatMap(e=>(e.paths??[]).map(n=>{let t=n.join(" "),r=R$[ho(t)];return{path:t,effect:go(t),host:r===void 0?"shared":"terminal",...r===void 0?{}:{reason:r}}})).sort((e,n)=>e.path.localeCompare(n.path))}s(qB,"plexusCommandCatalog");import ps from"node:path";function WX(e){let n=dn()?.workspaceRoot??process.cwd(),t=ps.resolve(n,e),r=ps.relative(n,t);if(ps.isAbsolute(e)||r===".."||r.startsWith(`..${ps.sep}`))throw new Error("plexus: use a relative path inside the current workspace.");return{absolute:t,relative:r}}s(WX,"workspacePath");function YX(e){let{absolute:n,relative:t}=WX(e.path??".");if(e.operation==="list"){if(!Ae(n))return{files:[]};let r=[],i=s(o=>{for(let a of Or(o,{withFileTypes:!0})){if(a.isSymbolicLink())throw new Error("plexus: workspace symlinks are not supported.");let l=ps.join(o,a.name);if(a.isDirectory()?i(l):r.push(ps.relative(n,l)),r.length>200)throw new Error("plexus: the workspace contains too many files. List a subdirectory.")}},"visit");return i(n),{files:r.sort()}}if(!t)throw new Error("plexus: name a workspace file.");if(["read","search","edit"].includes(e.operation)){let r=he(n);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:t,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:t,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 ze(n,a,"utf8"),{path:t,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 Fn(ps.dirname(n),{recursive:!0}),ze(n,e.content,"utf8"),{path:t,sizeBytes:Buffer.byteLength(e.content)}}if(e.operation==="remove")return ys(n),{path:t,removed:!0};throw new Error("plexus: unknown workspace operation.")}s(YX,"plexusWorkspace");function KB(e){return s(async function(t,r){if(!r||typeof r!="object"||Array.isArray(r))throw new Error("plexus: tool input must be an object.");let i=r,o=El[t];if(!o||!Object.hasOwn(El,t))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(t==="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(t==="plexus_skill"){if(typeof i.path!="string"||i.path.length>240||!Object.hasOwn(hy,i.path))throw new Error("plexus: unknown skill reference. Start with SKILL.md.");return{path:i.path,content:hy[i.path],skillHash:yf}}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 YX(i)},"executePlexusAgentTool")}s(KB,"createPlexusAgentToolExecutor");var eg=KB({inspectCommand:VB,executeCommand:BB});function ng(){let e=new vs({binaryLabel:"Plexus CLI",binaryName:"plexus-cli",binaryVersion:MB});e.register(ll.HelpCommand),e.register(ll.VersionCommand);for(let t of xu)e.register(t);async function n(t,r){let i;try{i=e.process(t,r)}catch(o){return(r.stderr??process.stderr).write(e.error(o,{colored:!1})),2}return QX(i,r.stderr??process.stderr),e.run(i,r)}return s(n,"run"),{process(t,r){return e.process(t,r)},run:n,async runExit(t,r){process.exitCode=await n(t,r)}}}s(ng,"createPlexusCli");function QX(e,n){let t=e.path.join(" "),r=e.constructor.paths?.[0]?.join(" ");r!==void 0&&t!==r&&pl[t]===r&&an(n,t,r),t in pl&&go(t)==="confirm"&&!ml(e)&&n.write(`plexus-cli: \`${pl[t]}\` only prints its plan without --confirm \u2014 nothing was changed.
11534
11534
  `)}s(QX,"noteRetiredPath");function VB(e){let n=ng().process(Xa(e),{executePlexusAgentTool:eg}),t=n.path.join(" ");if(t.startsWith("agent "))throw new Error("plexus: nested agent transports are not allowed.");let r=qB().find(l=>l.path===t);if(!r){if(t===""||t==="--help"||t==="--version")return{path:t,writes:!1,host:"shared"};throw new Error(`plexus: command ${t} has no host classification.`)}let i=n,o=r.effect==="callKind"?Em(_a(Na),i.fn??"",i.kind):void 0,a=rf(t,{confirm:ml(n),callKind:o});return{...r,writes:a}}s(VB,"inspectPlexusCommand");async function BB(e,n){if(n)return CT(n,()=>BB(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 t="",r="",i=ng();if(dn()){let l=VB(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:eg,stdin:JX.from(e.stdin===void 0?[]:[e.stdin]),stdout:new jB({write(l,d,c){t+=String(l),c()}}),stderr:new jB({write(l,d,c){r+=String(l),c()}})}),stdout:t,stderr:r}}s(BB,"executePlexusCommand");qT({source:ZX.join(import.meta.dirname,"skill")});ng().runExit(Xa(process.argv.slice(2)),{executePlexusAgentTool:eg});
11535
11535
  //# sourceMappingURL=cli.mjs.map