archik 0.19.2 → 0.19.4

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.
@@ -515,7 +515,7 @@ ${u}
515
515
  Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let w of o.seen.entries()){let v=w[1];if(c===w[0]){y(w);continue}if(o.external){let T=o.external.registry.get(w[0])?.id;if(c!==w[0]&&T){y(w);continue}}if(o.metadataRegistry.get(w[0])?.id){y(w);continue}if(v.cycle){y(w);continue}if(v.count>1&&o.reused==="ref"){y(w);continue}}}function _E(o,c){let u=o.seen.get(c);if(!u)throw new Error("Unprocessed schema. This is a bug in Zod.");let p=w=>{let v=o.seen.get(w);if(v.ref===null)return;let _=v.def??v.schema,T={..._},R=v.ref;if(v.ref=null,R){p(R);let B=o.seen.get(R),V=B.schema;if(V.$ref&&(o.target==="draft-07"||o.target==="draft-04"||o.target==="openapi-3.0")?(_.allOf=_.allOf??[],_.allOf.push(V)):Object.assign(_,V),Object.assign(_,T),w._zod.parent===R)for(let ee in _)ee==="$ref"||ee==="allOf"||ee in T||delete _[ee];if(V.$ref&&B.def)for(let ee in _)ee==="$ref"||ee==="allOf"||ee in B.def&&JSON.stringify(_[ee])===JSON.stringify(B.def[ee])&&delete _[ee]}let F=w._zod.parent;if(F&&F!==R){p(F);let B=o.seen.get(F);if(B?.schema.$ref&&(_.$ref=B.schema.$ref,B.def))for(let V in _)V==="$ref"||V==="allOf"||V in B.def&&JSON.stringify(_[V])===JSON.stringify(B.def[V])&&delete _[V]}o.override({zodSchema:w,jsonSchema:_,path:v.path??[]})};for(let w of[...o.seen.entries()].reverse())p(w[0]);let f={};if(o.target==="draft-2020-12"?f.$schema="https://json-schema.org/draft/2020-12/schema":o.target==="draft-07"?f.$schema="http://json-schema.org/draft-07/schema#":o.target==="draft-04"?f.$schema="http://json-schema.org/draft-04/schema#":o.target,o.external?.uri){let w=o.external.registry.get(c)?.id;if(!w)throw new Error("Schema is missing an `id` property");f.$id=o.external.uri(w)}Object.assign(f,u.def??u.schema);let y=o.external?.defs??{};for(let w of o.seen.entries()){let v=w[1];v.def&&v.defId&&(y[v.defId]=v.def)}o.external||Object.keys(y).length>0&&(o.target==="draft-2020-12"?f.$defs=y:f.definitions=y);try{let w=JSON.parse(JSON.stringify(f));return Object.defineProperty(w,"~standard",{value:{...c["~standard"],jsonSchema:{input:Xq(c,"input",o.processors),output:Xq(c,"output",o.processors)}},enumerable:!1,writable:!1}),w}catch{throw new Error("Error converting schema to JSON.")}}function ib(o,c){let u=c??{seen:new Set};if(u.seen.has(o))return!1;u.seen.add(o);let p=o._zod.def;if(p.type==="transform")return!0;if(p.type==="array")return ib(p.element,u);if(p.type==="set")return ib(p.valueType,u);if(p.type==="lazy")return ib(p.getter(),u);if(p.type==="promise"||p.type==="optional"||p.type==="nonoptional"||p.type==="nullable"||p.type==="readonly"||p.type==="default"||p.type==="prefault")return ib(p.innerType,u);if(p.type==="intersection")return ib(p.left,u)||ib(p.right,u);if(p.type==="record"||p.type==="map")return ib(p.keyType,u)||ib(p.valueType,u);if(p.type==="pipe")return ib(p.in,u)||ib(p.out,u);if(p.type==="object"){for(let f in p.shape)if(ib(p.shape[f],u))return!0;return!1}if(p.type==="union"){for(let f of p.options)if(ib(f,u))return!0;return!1}if(p.type==="tuple"){for(let f of p.items)if(ib(f,u))return!0;return!!(p.rest&&ib(p.rest,u))}return!1}var C1t=(o,c={})=>u=>{let p=xE({...u,processors:c});return ll(o,p),SE(p,o),_E(p,o)},Xq=(o,c,u={})=>p=>{let{libraryOptions:f,target:y}=p??{},w=xE({...f??{},target:y,io:c,processors:u});return ll(o,w),SE(w,o),_E(w,o)};var pGn={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},I1t=(o,c,u,p)=>{let f=u;f.type="string";let{minimum:y,maximum:w,format:v,patterns:_,contentEncoding:T}=o._zod.bag;if(typeof y=="number"&&(f.minLength=y),typeof w=="number"&&(f.maxLength=w),v&&(f.format=pGn[v]??v,f.format===""&&delete f.format,v==="time"&&delete f.format),T&&(f.contentEncoding=T),_&&_.size>0){let R=[..._];R.length===1?f.pattern=R[0].source:R.length>1&&(f.allOf=[...R.map(F=>({...c.target==="draft-07"||c.target==="draft-04"||c.target==="openapi-3.0"?{type:"string"}:{},pattern:F.source}))])}},E1t=(o,c,u,p)=>{let f=u,{minimum:y,maximum:w,format:v,multipleOf:_,exclusiveMaximum:T,exclusiveMinimum:R}=o._zod.bag;typeof v=="string"&&v.includes("int")?f.type="integer":f.type="number",typeof R=="number"&&(c.target==="draft-04"||c.target==="openapi-3.0"?(f.minimum=R,f.exclusiveMinimum=!0):f.exclusiveMinimum=R),typeof y=="number"&&(f.minimum=y,typeof R=="number"&&c.target!=="draft-04"&&(R>=y?delete f.minimum:delete f.exclusiveMinimum)),typeof T=="number"&&(c.target==="draft-04"||c.target==="openapi-3.0"?(f.maximum=T,f.exclusiveMaximum=!0):f.exclusiveMaximum=T),typeof w=="number"&&(f.maximum=w,typeof T=="number"&&c.target!=="draft-04"&&(T<=w?delete f.maximum:delete f.exclusiveMaximum)),typeof _=="number"&&(f.multipleOf=_)},P1t=(o,c,u,p)=>{u.type="boolean"},L1t=(o,c,u,p)=>{if(c.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},T1t=(o,c,u,p)=>{if(c.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},A1t=(o,c,u,p)=>{c.target==="openapi-3.0"?(u.type="string",u.nullable=!0,u.enum=[null]):u.type="null"},N1t=(o,c,u,p)=>{if(c.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},R1t=(o,c,u,p)=>{if(c.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},D1t=(o,c,u,p)=>{u.not={}},O1t=(o,c,u,p)=>{},F1t=(o,c,u,p)=>{},z1t=(o,c,u,p)=>{if(c.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},$1t=(o,c,u,p)=>{let f=o._zod.def,y=Ree(f.entries);y.every(w=>typeof w=="number")&&(u.type="number"),y.every(w=>typeof w=="string")&&(u.type="string"),u.enum=y},j1t=(o,c,u,p)=>{let f=o._zod.def,y=[];for(let w of f.values)if(w===void 0){if(c.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof w=="bigint"){if(c.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");y.push(Number(w))}else y.push(w);if(y.length!==0)if(y.length===1){let w=y[0];u.type=w===null?"null":typeof w,c.target==="draft-04"||c.target==="openapi-3.0"?u.enum=[w]:u.const=w}else y.every(w=>typeof w=="number")&&(u.type="number"),y.every(w=>typeof w=="string")&&(u.type="string"),y.every(w=>typeof w=="boolean")&&(u.type="boolean"),y.every(w=>w===null)&&(u.type="null"),u.enum=y},B1t=(o,c,u,p)=>{if(c.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},H1t=(o,c,u,p)=>{let f=u,y=o._zod.pattern;if(!y)throw new Error("Pattern not found in template literal");f.type="string",f.pattern=y.source},U1t=(o,c,u,p)=>{let f=u,y={type:"string",format:"binary",contentEncoding:"binary"},{minimum:w,maximum:v,mime:_}=o._zod.bag;w!==void 0&&(y.minLength=w),v!==void 0&&(y.maxLength=v),_?_.length===1?(y.contentMediaType=_[0],Object.assign(f,y)):(Object.assign(f,y),f.anyOf=_.map(T=>({contentMediaType:T}))):Object.assign(f,y)},q1t=(o,c,u,p)=>{u.type="boolean"},G1t=(o,c,u,p)=>{if(c.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},V1t=(o,c,u,p)=>{if(c.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},W1t=(o,c,u,p)=>{if(c.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},J1t=(o,c,u,p)=>{if(c.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},Z1t=(o,c,u,p)=>{if(c.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},X1t=(o,c,u,p)=>{let f=u,y=o._zod.def,{minimum:w,maximum:v}=o._zod.bag;typeof w=="number"&&(f.minItems=w),typeof v=="number"&&(f.maxItems=v),f.type="array",f.items=ll(y.element,c,{...p,path:[...p.path,"items"]})},K1t=(o,c,u,p)=>{let f=u,y=o._zod.def;f.type="object",f.properties={};let w=y.shape;for(let T in w)f.properties[T]=ll(w[T],c,{...p,path:[...p.path,"properties",T]});let v=new Set(Object.keys(w)),_=new Set([...v].filter(T=>{let R=y.shape[T]._zod;return c.io==="input"?R.optin===void 0:R.optout===void 0}));_.size>0&&(f.required=Array.from(_)),y.catchall?._zod.def.type==="never"?f.additionalProperties=!1:y.catchall?y.catchall&&(f.additionalProperties=ll(y.catchall,c,{...p,path:[...p.path,"additionalProperties"]})):c.io==="output"&&(f.additionalProperties=!1)},Npe=(o,c,u,p)=>{let f=o._zod.def,y=f.inclusive===!1,w=f.options.map((v,_)=>ll(v,c,{...p,path:[...p.path,y?"oneOf":"anyOf",_]}));y?u.oneOf=w:u.anyOf=w},Y1t=(o,c,u,p)=>{let f=o._zod.def,y=ll(f.left,c,{...p,path:[...p.path,"allOf",0]}),w=ll(f.right,c,{...p,path:[...p.path,"allOf",1]}),v=T=>"allOf"in T&&Object.keys(T).length===1,_=[...v(y)?y.allOf:[y],...v(w)?w.allOf:[w]];u.allOf=_},Q1t=(o,c,u,p)=>{let f=u,y=o._zod.def;f.type="array";let w=c.target==="draft-2020-12"?"prefixItems":"items",v=c.target==="draft-2020-12"||c.target==="openapi-3.0"?"items":"additionalItems",_=y.items.map((B,V)=>ll(B,c,{...p,path:[...p.path,w,V]})),T=y.rest?ll(y.rest,c,{...p,path:[...p.path,v,...c.target==="openapi-3.0"?[y.items.length]:[]]}):null;c.target==="draft-2020-12"?(f.prefixItems=_,T&&(f.items=T)):c.target==="openapi-3.0"?(f.items={anyOf:_},T&&f.items.anyOf.push(T),f.minItems=_.length,T||(f.maxItems=_.length)):(f.items=_,T&&(f.additionalItems=T));let{minimum:R,maximum:F}=o._zod.bag;typeof R=="number"&&(f.minItems=R),typeof F=="number"&&(f.maxItems=F)},eht=(o,c,u,p)=>{let f=u,y=o._zod.def;f.type="object";let w=y.keyType,_=w._zod.bag?.patterns;if(y.mode==="loose"&&_&&_.size>0){let R=ll(y.valueType,c,{...p,path:[...p.path,"patternProperties","*"]});f.patternProperties={};for(let F of _)f.patternProperties[F.source]=R}else(c.target==="draft-07"||c.target==="draft-2020-12")&&(f.propertyNames=ll(y.keyType,c,{...p,path:[...p.path,"propertyNames"]})),f.additionalProperties=ll(y.valueType,c,{...p,path:[...p.path,"additionalProperties"]});let T=w._zod.values;if(T){let R=[...T].filter(F=>typeof F=="string"||typeof F=="number");R.length>0&&(f.required=R)}},tht=(o,c,u,p)=>{let f=o._zod.def,y=ll(f.innerType,c,p),w=c.seen.get(o);c.target==="openapi-3.0"?(w.ref=f.innerType,u.nullable=!0):u.anyOf=[y,{type:"null"}]},nht=(o,c,u,p)=>{let f=o._zod.def;ll(f.innerType,c,p);let y=c.seen.get(o);y.ref=f.innerType},rht=(o,c,u,p)=>{let f=o._zod.def;ll(f.innerType,c,p);let y=c.seen.get(o);y.ref=f.innerType,u.default=JSON.parse(JSON.stringify(f.defaultValue))},iht=(o,c,u,p)=>{let f=o._zod.def;ll(f.innerType,c,p);let y=c.seen.get(o);y.ref=f.innerType,c.io==="input"&&(u._prefault=JSON.parse(JSON.stringify(f.defaultValue)))},oht=(o,c,u,p)=>{let f=o._zod.def;ll(f.innerType,c,p);let y=c.seen.get(o);y.ref=f.innerType;let w;try{w=f.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}u.default=w},cht=(o,c,u,p)=>{let f=o._zod.def,y=c.io==="input"?f.in._zod.def.type==="transform"?f.out:f.in:f.out;ll(y,c,p);let w=c.seen.get(o);w.ref=y},aht=(o,c,u,p)=>{let f=o._zod.def;ll(f.innerType,c,p);let y=c.seen.get(o);y.ref=f.innerType,u.readOnly=!0},sht=(o,c,u,p)=>{let f=o._zod.def;ll(f.innerType,c,p);let y=c.seen.get(o);y.ref=f.innerType},Rpe=(o,c,u,p)=>{let f=o._zod.def;ll(f.innerType,c,p);let y=c.seen.get(o);y.ref=f.innerType},lht=(o,c,u,p)=>{let f=o._zod.innerType;ll(f,c,p);let y=c.seen.get(o);y.ref=f},Ape={string:I1t,number:E1t,boolean:P1t,bigint:L1t,symbol:T1t,null:A1t,undefined:N1t,void:R1t,never:D1t,any:O1t,unknown:F1t,date:z1t,enum:$1t,literal:j1t,nan:B1t,template_literal:H1t,file:U1t,success:q1t,custom:G1t,function:V1t,transform:W1t,map:J1t,set:Z1t,array:X1t,object:K1t,union:Npe,intersection:Y1t,tuple:Q1t,record:eht,nullable:tht,nonoptional:nht,default:rht,prefault:iht,catch:oht,pipe:cht,readonly:aht,promise:sht,optional:Rpe,lazy:lht};function Dpe(o,c){if("_idmap"in o){let p=o,f=xE({...c,processors:Ape}),y={};for(let _ of p._idmap.entries()){let[T,R]=_;ll(R,f)}let w={},v={registry:p,uri:c?.uri,defs:y};f.external=v;for(let _ of p._idmap.entries()){let[T,R]=_;SE(f,R),w[T]=_E(f,R)}if(Object.keys(y).length>0){let _=f.target==="draft-2020-12"?"$defs":"definitions";w.__shared={[_]:y}}return{schemas:w}}let u=xE({...c,processors:Ape});return ll(o,u),SE(u,o),_E(u,o)}var Ope=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(c){this.ctx.counter=c}get seen(){return this.ctx.seen}constructor(c){let u=c?.target??"draft-2020-12";u==="draft-4"&&(u="draft-04"),u==="draft-7"&&(u="draft-07"),this.ctx=xE({processors:Ape,target:u,...c?.metadata&&{metadata:c.metadata},...c?.unrepresentable&&{unrepresentable:c.unrepresentable},...c?.override&&{override:c.override},...c?.io&&{io:c.io}})}process(c,u={path:[],schemaPath:[]}){return ll(c,this.ctx,u)}emit(c,u){u&&(u.cycles&&(this.ctx.cycles=u.cycles),u.reused&&(this.ctx.reused=u.reused),u.external&&(this.ctx.external=u.external)),SE(this.ctx,c);let p=_E(this.ctx,c),{"~standard":f,...y}=p;return y}};var Nrn={};var Yee={};Qx(Yee,{ZodAny:()=>Nht,ZodArray:()=>Fht,ZodBase64:()=>rge,ZodBase64URL:()=>ige,ZodBigInt:()=>rG,ZodBigIntFormat:()=>age,ZodBoolean:()=>nG,ZodCIDRv4:()=>tge,ZodCIDRv6:()=>nge,ZodCUID:()=>Jpe,ZodCUID2:()=>Zpe,ZodCatch:()=>oft,ZodCodec:()=>gge,ZodCustom:()=>lte,ZodCustomStringFormat:()=>eG,ZodDate:()=>ite,ZodDefault:()=>Qht,ZodDiscriminatedUnion:()=>$ht,ZodE164:()=>oge,ZodEmail:()=>Gpe,ZodEmoji:()=>Vpe,ZodEnum:()=>Yq,ZodExactOptional:()=>Xht,ZodFile:()=>Jht,ZodFunction:()=>pft,ZodGUID:()=>Qee,ZodIPv4:()=>Qpe,ZodIPv6:()=>ege,ZodIntersection:()=>jht,ZodJWT:()=>cge,ZodKSUID:()=>Ype,ZodLazy:()=>dft,ZodLiteral:()=>Wht,ZodMAC:()=>Cht,ZodMap:()=>Ght,ZodNaN:()=>aft,ZodNanoID:()=>Wpe,ZodNever:()=>Dht,ZodNonOptional:()=>fge,ZodNull:()=>Tht,ZodNullable:()=>Yht,ZodNumber:()=>tG,ZodNumberFormat:()=>TR,ZodObject:()=>cte,ZodOptional:()=>hge,ZodPipe:()=>pge,ZodPrefault:()=>tft,ZodPromise:()=>fft,ZodReadonly:()=>sft,ZodRecord:()=>ste,ZodSet:()=>Vht,ZodString:()=>Qq,ZodStringFormat:()=>iu,ZodSuccess:()=>ift,ZodSymbol:()=>Pht,ZodTemplateLiteral:()=>uft,ZodTransform:()=>Zht,ZodTuple:()=>Hht,ZodType:()=>kc,ZodULID:()=>Xpe,ZodURL:()=>rte,ZodUUID:()=>j9,ZodUndefined:()=>Lht,ZodUnion:()=>ate,ZodUnknown:()=>Rht,ZodVoid:()=>Oht,ZodXID:()=>Kpe,ZodXor:()=>zht,_ZodString:()=>qpe,_default:()=>eft,_function:()=>jin,any:()=>min,array:()=>ote,base64:()=>tin,base64url:()=>nin,bigint:()=>fin,boolean:()=>Eht,catch:()=>cft,check:()=>Bin,cidrv4:()=>Qrn,cidrv6:()=>ein,codec:()=>Fin,cuid:()=>Grn,cuid2:()=>Vrn,custom:()=>Hin,date:()=>vin,describe:()=>Uin,discriminatedUnion:()=>Cin,e164:()=>rin,email:()=>Drn,emoji:()=>Urn,enum:()=>uge,exactOptional:()=>Kht,file:()=>Nin,float32:()=>lin,float64:()=>uin,function:()=>jin,guid:()=>Orn,hash:()=>sin,hex:()=>ain,hostname:()=>cin,httpUrl:()=>Hrn,instanceof:()=>Gin,int:()=>Upe,int32:()=>din,int64:()=>pin,intersection:()=>Bht,ipv4:()=>Xrn,ipv6:()=>Yrn,json:()=>Win,jwt:()=>iin,keyof:()=>kin,ksuid:()=>Zrn,lazy:()=>hft,literal:()=>Ain,looseObject:()=>Sin,looseRecord:()=>Ein,mac:()=>Krn,map:()=>Pin,meta:()=>qin,nan:()=>Oin,nanoid:()=>qrn,nativeEnum:()=>Tin,never:()=>sge,nonoptional:()=>rft,null:()=>Aht,nullable:()=>tte,nullish:()=>Rin,number:()=>Iht,object:()=>Min,optional:()=>ete,partialRecord:()=>Iin,pipe:()=>nte,prefault:()=>nft,preprocess:()=>Jin,promise:()=>$in,readonly:()=>lft,record:()=>qht,refine:()=>gft,set:()=>Lin,strictObject:()=>xin,string:()=>Hpe,stringFormat:()=>oin,stringbool:()=>Vin,success:()=>Din,superRefine:()=>yft,symbol:()=>yin,templateLiteral:()=>zin,transform:()=>dge,tuple:()=>Uht,uint32:()=>hin,uint64:()=>gin,ulid:()=>Wrn,undefined:()=>bin,union:()=>lge,unknown:()=>LR,url:()=>Brn,uuid:()=>Frn,uuidv4:()=>zrn,uuidv6:()=>$rn,uuidv7:()=>jrn,void:()=>win,xid:()=>Jrn,xor:()=>_in});var Fpe={};Qx(Fpe,{endsWith:()=>Hq,gt:()=>z9,gte:()=>rb,includes:()=>jq,length:()=>PR,lowercase:()=>zq,lt:()=>F9,lte:()=>xv,maxLength:()=>ER,maxSize:()=>ME,mime:()=>Uq,minLength:()=>oS,minSize:()=>$9,multipleOf:()=>kE,negative:()=>Epe,nonnegative:()=>Lpe,nonpositive:()=>Ppe,normalize:()=>qq,overwrite:()=>s6,positive:()=>Ipe,property:()=>Tpe,regex:()=>Fq,size:()=>IR,slugify:()=>Jq,startsWith:()=>Bq,toLowerCase:()=>Vq,toUpperCase:()=>Wq,trim:()=>Gq,uppercase:()=>$q});var Kq={};Qx(Kq,{ZodISODate:()=>$pe,ZodISODateTime:()=>zpe,ZodISODuration:()=>Bpe,ZodISOTime:()=>jpe,date:()=>dht,datetime:()=>uht,duration:()=>fht,time:()=>hht});var zpe=xt("ZodISODateTime",(o,c)=>{But.init(o,c),iu.init(o,c)});function uht(o){return Gdt(zpe,o)}var $pe=xt("ZodISODate",(o,c)=>{Hut.init(o,c),iu.init(o,c)});function dht(o){return Vdt($pe,o)}var jpe=xt("ZodISOTime",(o,c)=>{Uut.init(o,c),iu.init(o,c)});function hht(o){return Wdt(jpe,o)}var Bpe=xt("ZodISODuration",(o,c)=>{qut.init(o,c),iu.init(o,c)});function fht(o){return Jdt(Bpe,o)}var Rrn=(o,c)=>{$ee.init(o,c),o.name="ZodError",Object.defineProperties(o,{format:{value:u=>Bee(o,u)},flatten:{value:u=>jee(o,u)},addIssue:{value:u=>{o.issues.push(u),o.message=JSON.stringify(o.issues,Eq,2)}},addIssues:{value:u=>{o.issues.push(...u),o.message=JSON.stringify(o.issues,Eq,2)}},isEmpty:{get(){return o.issues.length===0}}})},yGn=xt("ZodError",Rrn),Hm=xt("ZodError",Rrn,{Parent:Error});var pht=Tq(Hm),ght=Aq(Hm),yht=Nq(Hm),bht=Rq(Hm),mht=D2e(Hm),wht=O2e(Hm),vht=F2e(Hm),kht=z2e(Hm),Mht=$2e(Hm),xht=j2e(Hm),Sht=B2e(Hm),_ht=H2e(Hm);var kc=xt("ZodType",(o,c)=>(Ho.init(o,c),Object.assign(o["~standard"],{jsonSchema:{input:Xq(o,"input"),output:Xq(o,"output")}}),o.toJSONSchema=C1t(o,{}),o.def=c,o.type=c.type,Object.defineProperty(o,"_def",{value:c}),o.check=(...u)=>o.clone(fr.mergeDefs(c,{checks:[...c.checks??[],...u.map(p=>typeof p=="function"?{_zod:{check:p,def:{check:"custom"},onattach:[]}}:p)]}),{parent:!0}),o.with=o.check,o.clone=(u,p)=>nb(o,u,p),o.brand=()=>o,o.register=((u,p)=>(u.add(o,p),o)),o.parse=(u,p)=>pht(o,u,p,{callee:o.parse}),o.safeParse=(u,p)=>yht(o,u,p),o.parseAsync=async(u,p)=>ght(o,u,p,{callee:o.parseAsync}),o.safeParseAsync=async(u,p)=>bht(o,u,p),o.spa=o.safeParseAsync,o.encode=(u,p)=>mht(o,u,p),o.decode=(u,p)=>wht(o,u,p),o.encodeAsync=async(u,p)=>vht(o,u,p),o.decodeAsync=async(u,p)=>kht(o,u,p),o.safeEncode=(u,p)=>Mht(o,u,p),o.safeDecode=(u,p)=>xht(o,u,p),o.safeEncodeAsync=async(u,p)=>Sht(o,u,p),o.safeDecodeAsync=async(u,p)=>_ht(o,u,p),o.refine=(u,p)=>o.check(gft(u,p)),o.superRefine=u=>o.check(yft(u)),o.overwrite=u=>o.check(s6(u)),o.optional=()=>ete(o),o.exactOptional=()=>Kht(o),o.nullable=()=>tte(o),o.nullish=()=>ete(tte(o)),o.nonoptional=u=>rft(o,u),o.array=()=>ote(o),o.or=u=>lge([o,u]),o.and=u=>Bht(o,u),o.transform=u=>nte(o,dge(u)),o.default=u=>eft(o,u),o.prefault=u=>nft(o,u),o.catch=u=>cft(o,u),o.pipe=u=>nte(o,u),o.readonly=()=>lft(o),o.describe=u=>{let p=o.clone();return Dp.add(p,{description:u}),p},Object.defineProperty(o,"description",{get(){return Dp.get(o)?.description},configurable:!0}),o.meta=(...u)=>{if(u.length===0)return Dp.get(o);let p=o.clone();return Dp.add(p,u[0]),p},o.isOptional=()=>o.safeParse(void 0).success,o.isNullable=()=>o.safeParse(null).success,o.apply=u=>u(o),o)),qpe=xt("_ZodString",(o,c)=>{CR.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(p,f,y)=>I1t(o,p,f,y);let u=o._zod.bag;o.format=u.format??null,o.minLength=u.minimum??null,o.maxLength=u.maximum??null,o.regex=(...p)=>o.check(Fq(...p)),o.includes=(...p)=>o.check(jq(...p)),o.startsWith=(...p)=>o.check(Bq(...p)),o.endsWith=(...p)=>o.check(Hq(...p)),o.min=(...p)=>o.check(oS(...p)),o.max=(...p)=>o.check(ER(...p)),o.length=(...p)=>o.check(PR(...p)),o.nonempty=(...p)=>o.check(oS(1,...p)),o.lowercase=p=>o.check(zq(p)),o.uppercase=p=>o.check($q(p)),o.trim=()=>o.check(Gq()),o.normalize=(...p)=>o.check(qq(...p)),o.toLowerCase=()=>o.check(Vq()),o.toUpperCase=()=>o.check(Wq()),o.slugify=()=>o.check(Jq())}),Qq=xt("ZodString",(o,c)=>{CR.init(o,c),qpe.init(o,c),o.email=u=>o.check(ape(Gpe,u)),o.url=u=>o.check(Kee(rte,u)),o.jwt=u=>o.check(Cpe(cge,u)),o.emoji=u=>o.check(hpe(Vpe,u)),o.guid=u=>o.check(Xee(Qee,u)),o.uuid=u=>o.check(spe(j9,u)),o.uuidv4=u=>o.check(lpe(j9,u)),o.uuidv6=u=>o.check(upe(j9,u)),o.uuidv7=u=>o.check(dpe(j9,u)),o.nanoid=u=>o.check(fpe(Wpe,u)),o.guid=u=>o.check(Xee(Qee,u)),o.cuid=u=>o.check(ppe(Jpe,u)),o.cuid2=u=>o.check(gpe(Zpe,u)),o.ulid=u=>o.check(ype(Xpe,u)),o.base64=u=>o.check(xpe(rge,u)),o.base64url=u=>o.check(Spe(ige,u)),o.xid=u=>o.check(bpe(Kpe,u)),o.ksuid=u=>o.check(mpe(Ype,u)),o.ipv4=u=>o.check(wpe(Qpe,u)),o.ipv6=u=>o.check(vpe(ege,u)),o.cidrv4=u=>o.check(kpe(tge,u)),o.cidrv6=u=>o.check(Mpe(nge,u)),o.e164=u=>o.check(_pe(oge,u)),o.datetime=u=>o.check(uht(u)),o.date=u=>o.check(dht(u)),o.time=u=>o.check(hht(u)),o.duration=u=>o.check(fht(u))});function Hpe(o){return Bdt(Qq,o)}var iu=xt("ZodStringFormat",(o,c)=>{ru.init(o,c),qpe.init(o,c)}),Gpe=xt("ZodEmail",(o,c)=>{Aut.init(o,c),iu.init(o,c)});function Drn(o){return ape(Gpe,o)}var Qee=xt("ZodGUID",(o,c)=>{Lut.init(o,c),iu.init(o,c)});function Orn(o){return Xee(Qee,o)}var j9=xt("ZodUUID",(o,c)=>{Tut.init(o,c),iu.init(o,c)});function Frn(o){return spe(j9,o)}function zrn(o){return lpe(j9,o)}function $rn(o){return upe(j9,o)}function jrn(o){return dpe(j9,o)}var rte=xt("ZodURL",(o,c)=>{Nut.init(o,c),iu.init(o,c)});function Brn(o){return Kee(rte,o)}function Hrn(o){return Kee(rte,{protocol:/^https?$/,hostname:I3.domain,...fr.normalizeParams(o)})}var Vpe=xt("ZodEmoji",(o,c)=>{Rut.init(o,c),iu.init(o,c)});function Urn(o){return hpe(Vpe,o)}var Wpe=xt("ZodNanoID",(o,c)=>{Dut.init(o,c),iu.init(o,c)});function qrn(o){return fpe(Wpe,o)}var Jpe=xt("ZodCUID",(o,c)=>{Out.init(o,c),iu.init(o,c)});function Grn(o){return ppe(Jpe,o)}var Zpe=xt("ZodCUID2",(o,c)=>{Fut.init(o,c),iu.init(o,c)});function Vrn(o){return gpe(Zpe,o)}var Xpe=xt("ZodULID",(o,c)=>{zut.init(o,c),iu.init(o,c)});function Wrn(o){return ype(Xpe,o)}var Kpe=xt("ZodXID",(o,c)=>{$ut.init(o,c),iu.init(o,c)});function Jrn(o){return bpe(Kpe,o)}var Ype=xt("ZodKSUID",(o,c)=>{jut.init(o,c),iu.init(o,c)});function Zrn(o){return mpe(Ype,o)}var Qpe=xt("ZodIPv4",(o,c)=>{Gut.init(o,c),iu.init(o,c)});function Xrn(o){return wpe(Qpe,o)}var Cht=xt("ZodMAC",(o,c)=>{Wut.init(o,c),iu.init(o,c)});function Krn(o){return Udt(Cht,o)}var ege=xt("ZodIPv6",(o,c)=>{Vut.init(o,c),iu.init(o,c)});function Yrn(o){return vpe(ege,o)}var tge=xt("ZodCIDRv4",(o,c)=>{Jut.init(o,c),iu.init(o,c)});function Qrn(o){return kpe(tge,o)}var nge=xt("ZodCIDRv6",(o,c)=>{Zut.init(o,c),iu.init(o,c)});function ein(o){return Mpe(nge,o)}var rge=xt("ZodBase64",(o,c)=>{Kut.init(o,c),iu.init(o,c)});function tin(o){return xpe(rge,o)}var ige=xt("ZodBase64URL",(o,c)=>{Yut.init(o,c),iu.init(o,c)});function nin(o){return Spe(ige,o)}var oge=xt("ZodE164",(o,c)=>{Qut.init(o,c),iu.init(o,c)});function rin(o){return _pe(oge,o)}var cge=xt("ZodJWT",(o,c)=>{edt.init(o,c),iu.init(o,c)});function iin(o){return Cpe(cge,o)}var eG=xt("ZodCustomStringFormat",(o,c)=>{tdt.init(o,c),iu.init(o,c)});function oin(o,c,u={}){return Zq(eG,o,c,u)}function cin(o){return Zq(eG,"hostname",I3.hostname,o)}function ain(o){return Zq(eG,"hex",I3.hex,o)}function sin(o,c){let u=c?.enc??"hex",p=`${o}_${u}`,f=I3[p];if(!f)throw new Error(`Unrecognized hash format: ${p}`);return Zq(eG,p,f,c)}var tG=xt("ZodNumber",(o,c)=>{Y2e.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(p,f,y)=>E1t(o,p,f,y),o.gt=(p,f)=>o.check(z9(p,f)),o.gte=(p,f)=>o.check(rb(p,f)),o.min=(p,f)=>o.check(rb(p,f)),o.lt=(p,f)=>o.check(F9(p,f)),o.lte=(p,f)=>o.check(xv(p,f)),o.max=(p,f)=>o.check(xv(p,f)),o.int=p=>o.check(Upe(p)),o.safe=p=>o.check(Upe(p)),o.positive=p=>o.check(z9(0,p)),o.nonnegative=p=>o.check(rb(0,p)),o.negative=p=>o.check(F9(0,p)),o.nonpositive=p=>o.check(xv(0,p)),o.multipleOf=(p,f)=>o.check(kE(p,f)),o.step=(p,f)=>o.check(kE(p,f)),o.finite=()=>o;let u=o._zod.bag;o.minValue=Math.max(u.minimum??Number.NEGATIVE_INFINITY,u.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,o.maxValue=Math.min(u.maximum??Number.POSITIVE_INFINITY,u.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,o.isInt=(u.format??"").includes("int")||Number.isSafeInteger(u.multipleOf??.5),o.isFinite=!0,o.format=u.format??null});function Iht(o){return Zdt(tG,o)}var TR=xt("ZodNumberFormat",(o,c)=>{ndt.init(o,c),tG.init(o,c)});function Upe(o){return Kdt(TR,o)}function lin(o){return Ydt(TR,o)}function uin(o){return Qdt(TR,o)}function din(o){return e1t(TR,o)}function hin(o){return t1t(TR,o)}var nG=xt("ZodBoolean",(o,c)=>{Gee.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>P1t(o,u,p,f)});function Eht(o){return n1t(nG,o)}var rG=xt("ZodBigInt",(o,c)=>{Q2e.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(p,f,y)=>L1t(o,p,f,y),o.gte=(p,f)=>o.check(rb(p,f)),o.min=(p,f)=>o.check(rb(p,f)),o.gt=(p,f)=>o.check(z9(p,f)),o.gte=(p,f)=>o.check(rb(p,f)),o.min=(p,f)=>o.check(rb(p,f)),o.lt=(p,f)=>o.check(F9(p,f)),o.lte=(p,f)=>o.check(xv(p,f)),o.max=(p,f)=>o.check(xv(p,f)),o.positive=p=>o.check(z9(BigInt(0),p)),o.negative=p=>o.check(F9(BigInt(0),p)),o.nonpositive=p=>o.check(xv(BigInt(0),p)),o.nonnegative=p=>o.check(rb(BigInt(0),p)),o.multipleOf=(p,f)=>o.check(kE(p,f));let u=o._zod.bag;o.minValue=u.minimum??null,o.maxValue=u.maximum??null,o.format=u.format??null});function fin(o){return i1t(rG,o)}var age=xt("ZodBigIntFormat",(o,c)=>{rdt.init(o,c),rG.init(o,c)});function pin(o){return c1t(age,o)}function gin(o){return a1t(age,o)}var Pht=xt("ZodSymbol",(o,c)=>{idt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>T1t(o,u,p,f)});function yin(o){return s1t(Pht,o)}var Lht=xt("ZodUndefined",(o,c)=>{odt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>N1t(o,u,p,f)});function bin(o){return l1t(Lht,o)}var Tht=xt("ZodNull",(o,c)=>{cdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>A1t(o,u,p,f)});function Aht(o){return u1t(Tht,o)}var Nht=xt("ZodAny",(o,c)=>{adt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>O1t(o,u,p,f)});function min(){return d1t(Nht)}var Rht=xt("ZodUnknown",(o,c)=>{sdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>F1t(o,u,p,f)});function LR(){return h1t(Rht)}var Dht=xt("ZodNever",(o,c)=>{ldt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>D1t(o,u,p,f)});function sge(o){return f1t(Dht,o)}var Oht=xt("ZodVoid",(o,c)=>{udt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>R1t(o,u,p,f)});function win(o){return p1t(Oht,o)}var ite=xt("ZodDate",(o,c)=>{ddt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(p,f,y)=>z1t(o,p,f,y),o.min=(p,f)=>o.check(rb(p,f)),o.max=(p,f)=>o.check(xv(p,f));let u=o._zod.bag;o.minDate=u.minimum?new Date(u.minimum):null,o.maxDate=u.maximum?new Date(u.maximum):null});function vin(o){return g1t(ite,o)}var Fht=xt("ZodArray",(o,c)=>{hdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>X1t(o,u,p,f),o.element=c.element,o.min=(u,p)=>o.check(oS(u,p)),o.nonempty=u=>o.check(oS(1,u)),o.max=(u,p)=>o.check(ER(u,p)),o.length=(u,p)=>o.check(PR(u,p)),o.unwrap=()=>o.element});function ote(o,c){return m1t(Fht,o,c)}function kin(o){let c=o._zod.def.shape;return uge(Object.keys(c))}var cte=xt("ZodObject",(o,c)=>{fdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>K1t(o,u,p,f),fr.defineLazy(o,"shape",()=>c.shape),o.keyof=()=>uge(Object.keys(o._zod.def.shape)),o.catchall=u=>o.clone({...o._zod.def,catchall:u}),o.passthrough=()=>o.clone({...o._zod.def,catchall:LR()}),o.loose=()=>o.clone({...o._zod.def,catchall:LR()}),o.strict=()=>o.clone({...o._zod.def,catchall:sge()}),o.strip=()=>o.clone({...o._zod.def,catchall:void 0}),o.extend=u=>fr.extend(o,u),o.safeExtend=u=>fr.safeExtend(o,u),o.merge=u=>fr.merge(o,u),o.pick=u=>fr.pick(o,u),o.omit=u=>fr.omit(o,u),o.partial=(...u)=>fr.partial(hge,o,u[0]),o.required=(...u)=>fr.required(fge,o,u[0])});function Min(o,c){let u={type:"object",shape:o??{},...fr.normalizeParams(c)};return new cte(u)}function xin(o,c){return new cte({type:"object",shape:o,catchall:sge(),...fr.normalizeParams(c)})}function Sin(o,c){return new cte({type:"object",shape:o,catchall:LR(),...fr.normalizeParams(c)})}var ate=xt("ZodUnion",(o,c)=>{Vee.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>Npe(o,u,p,f),o.options=c.options});function lge(o,c){return new ate({type:"union",options:o,...fr.normalizeParams(c)})}var zht=xt("ZodXor",(o,c)=>{ate.init(o,c),pdt.init(o,c),o._zod.processJSONSchema=(u,p,f)=>Npe(o,u,p,f),o.options=c.options});function _in(o,c){return new zht({type:"union",options:o,inclusive:!1,...fr.normalizeParams(c)})}var $ht=xt("ZodDiscriminatedUnion",(o,c)=>{ate.init(o,c),gdt.init(o,c)});function Cin(o,c,u){return new $ht({type:"union",options:c,discriminator:o,...fr.normalizeParams(u)})}var jht=xt("ZodIntersection",(o,c)=>{ydt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>Y1t(o,u,p,f)});function Bht(o,c){return new jht({type:"intersection",left:o,right:c})}var Hht=xt("ZodTuple",(o,c)=>{epe.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>Q1t(o,u,p,f),o.rest=u=>o.clone({...o._zod.def,rest:u})});function Uht(o,c,u){let p=c instanceof Ho,f=p?u:c,y=p?c:null;return new Hht({type:"tuple",items:o,rest:y,...fr.normalizeParams(f)})}var ste=xt("ZodRecord",(o,c)=>{bdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>eht(o,u,p,f),o.keyType=c.keyType,o.valueType=c.valueType});function qht(o,c,u){return new ste({type:"record",keyType:o,valueType:c,...fr.normalizeParams(u)})}function Iin(o,c,u){let p=nb(o);return p._zod.values=void 0,new ste({type:"record",keyType:p,valueType:c,...fr.normalizeParams(u)})}function Ein(o,c,u){return new ste({type:"record",keyType:o,valueType:c,mode:"loose",...fr.normalizeParams(u)})}var Ght=xt("ZodMap",(o,c)=>{mdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>J1t(o,u,p,f),o.keyType=c.keyType,o.valueType=c.valueType,o.min=(...u)=>o.check($9(...u)),o.nonempty=u=>o.check($9(1,u)),o.max=(...u)=>o.check(ME(...u)),o.size=(...u)=>o.check(IR(...u))});function Pin(o,c,u){return new Ght({type:"map",keyType:o,valueType:c,...fr.normalizeParams(u)})}var Vht=xt("ZodSet",(o,c)=>{wdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>Z1t(o,u,p,f),o.min=(...u)=>o.check($9(...u)),o.nonempty=u=>o.check($9(1,u)),o.max=(...u)=>o.check(ME(...u)),o.size=(...u)=>o.check(IR(...u))});function Lin(o,c){return new Vht({type:"set",valueType:o,...fr.normalizeParams(c)})}var Yq=xt("ZodEnum",(o,c)=>{vdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(p,f,y)=>$1t(o,p,f,y),o.enum=c.entries,o.options=Object.values(c.entries);let u=new Set(Object.keys(c.entries));o.extract=(p,f)=>{let y={};for(let w of p)if(u.has(w))y[w]=c.entries[w];else throw new Error(`Key ${w} not found in enum`);return new Yq({...c,checks:[],...fr.normalizeParams(f),entries:y})},o.exclude=(p,f)=>{let y={...c.entries};for(let w of p)if(u.has(w))delete y[w];else throw new Error(`Key ${w} not found in enum`);return new Yq({...c,checks:[],...fr.normalizeParams(f),entries:y})}});function uge(o,c){let u=Array.isArray(o)?Object.fromEntries(o.map(p=>[p,p])):o;return new Yq({type:"enum",entries:u,...fr.normalizeParams(c)})}function Tin(o,c){return new Yq({type:"enum",entries:o,...fr.normalizeParams(c)})}var Wht=xt("ZodLiteral",(o,c)=>{kdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>j1t(o,u,p,f),o.values=new Set(c.values),Object.defineProperty(o,"value",{get(){if(c.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return c.values[0]}})});function Ain(o,c){return new Wht({type:"literal",values:Array.isArray(o)?o:[o],...fr.normalizeParams(c)})}var Jht=xt("ZodFile",(o,c)=>{Mdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>U1t(o,u,p,f),o.min=(u,p)=>o.check($9(u,p)),o.max=(u,p)=>o.check(ME(u,p)),o.mime=(u,p)=>o.check(Uq(Array.isArray(u)?u:[u],p))});function Nin(o){return w1t(Jht,o)}var Zht=xt("ZodTransform",(o,c)=>{xdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>W1t(o,u,p,f),o._zod.parse=(u,p)=>{if(p.direction==="backward")throw new yE(o.constructor.name);u.addIssue=y=>{if(typeof y=="string")u.issues.push(fr.issue(y,u.value,c));else{let w=y;w.fatal&&(w.continue=!1),w.code??(w.code="custom"),w.input??(w.input=u.value),w.inst??(w.inst=o),u.issues.push(fr.issue(w))}};let f=c.transform(u.value,u);return f instanceof Promise?f.then(y=>(u.value=y,u)):(u.value=f,u)}});function dge(o){return new Zht({type:"transform",transform:o})}var hge=xt("ZodOptional",(o,c)=>{tpe.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>Rpe(o,u,p,f),o.unwrap=()=>o._zod.def.innerType});function ete(o){return new hge({type:"optional",innerType:o})}var Xht=xt("ZodExactOptional",(o,c)=>{Sdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>Rpe(o,u,p,f),o.unwrap=()=>o._zod.def.innerType});function Kht(o){return new Xht({type:"optional",innerType:o})}var Yht=xt("ZodNullable",(o,c)=>{_dt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>tht(o,u,p,f),o.unwrap=()=>o._zod.def.innerType});function tte(o){return new Yht({type:"nullable",innerType:o})}function Rin(o){return ete(tte(o))}var Qht=xt("ZodDefault",(o,c)=>{Cdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>rht(o,u,p,f),o.unwrap=()=>o._zod.def.innerType,o.removeDefault=o.unwrap});function eft(o,c){return new Qht({type:"default",innerType:o,get defaultValue(){return typeof c=="function"?c():fr.shallowClone(c)}})}var tft=xt("ZodPrefault",(o,c)=>{Idt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>iht(o,u,p,f),o.unwrap=()=>o._zod.def.innerType});function nft(o,c){return new tft({type:"prefault",innerType:o,get defaultValue(){return typeof c=="function"?c():fr.shallowClone(c)}})}var fge=xt("ZodNonOptional",(o,c)=>{Edt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>nht(o,u,p,f),o.unwrap=()=>o._zod.def.innerType});function rft(o,c){return new fge({type:"nonoptional",innerType:o,...fr.normalizeParams(c)})}var ift=xt("ZodSuccess",(o,c)=>{Pdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>q1t(o,u,p,f),o.unwrap=()=>o._zod.def.innerType});function Din(o){return new ift({type:"success",innerType:o})}var oft=xt("ZodCatch",(o,c)=>{Ldt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>oht(o,u,p,f),o.unwrap=()=>o._zod.def.innerType,o.removeCatch=o.unwrap});function cft(o,c){return new oft({type:"catch",innerType:o,catchValue:typeof c=="function"?c:()=>c})}var aft=xt("ZodNaN",(o,c)=>{Tdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>B1t(o,u,p,f)});function Oin(o){return b1t(aft,o)}var pge=xt("ZodPipe",(o,c)=>{Adt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>cht(o,u,p,f),o.in=c.in,o.out=c.out});function nte(o,c){return new pge({type:"pipe",in:o,out:c})}var gge=xt("ZodCodec",(o,c)=>{pge.init(o,c),Wee.init(o,c)});function Fin(o,c,u){return new gge({type:"pipe",in:o,out:c,transform:u.decode,reverseTransform:u.encode})}var sft=xt("ZodReadonly",(o,c)=>{Ndt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>aht(o,u,p,f),o.unwrap=()=>o._zod.def.innerType});function lft(o){return new sft({type:"readonly",innerType:o})}var uft=xt("ZodTemplateLiteral",(o,c)=>{Rdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>H1t(o,u,p,f)});function zin(o,c){return new uft({type:"template_literal",parts:o,...fr.normalizeParams(c)})}var dft=xt("ZodLazy",(o,c)=>{Fdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>lht(o,u,p,f),o.unwrap=()=>o._zod.def.getter()});function hft(o){return new dft({type:"lazy",getter:o})}var fft=xt("ZodPromise",(o,c)=>{Odt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>sht(o,u,p,f),o.unwrap=()=>o._zod.def.innerType});function $in(o){return new fft({type:"promise",innerType:o})}var pft=xt("ZodFunction",(o,c)=>{Ddt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>V1t(o,u,p,f)});function jin(o){return new pft({type:"function",input:Array.isArray(o?.input)?Uht(o?.input):o?.input??ote(LR()),output:o?.output??LR()})}var lte=xt("ZodCustom",(o,c)=>{zdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>G1t(o,u,p,f)});function Bin(o){let c=new xu({check:"custom"});return c._zod.check=o,c}function Hin(o,c){return v1t(lte,o??(()=>!0),c)}function gft(o,c={}){return k1t(lte,o,c)}function yft(o){return M1t(o)}var Uin=x1t,qin=S1t;function Gin(o,c={}){let u=new lte({type:"custom",check:"custom",fn:p=>p instanceof o,abort:!0,...fr.normalizeParams(c)});return u._zod.bag.Class=o,u._zod.check=p=>{p.value instanceof o||p.issues.push({code:"invalid_type",expected:o.name,input:p.value,inst:u,path:[...u._zod.def.path??[]]})},u}var Vin=(...o)=>_1t({Codec:gge,Boolean:nG,String:Qq},...o);function Win(o){let c=hft(()=>lge([Hpe(o),Iht(),Eht(),Aht(),ote(c),qht(Hpe(),c)]));return c}function Jin(o,c){return nte(dge(o),c)}var mGn={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function wGn(o){Mh({customError:o})}function vGn(){return Mh().customError}var bft;bft||(bft={});var Hr={...Yee,...Fpe,iso:Kq},kGn=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function MGn(o,c){let u=o.$schema;return u==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":u==="http://json-schema.org/draft-07/schema#"?"draft-7":u==="http://json-schema.org/draft-04/schema#"?"draft-4":c??"draft-2020-12"}function xGn(o,c){if(!o.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let u=o.slice(1).split("/").filter(Boolean);if(u.length===0)return c.rootSchema;let p=c.version==="draft-2020-12"?"$defs":"definitions";if(u[0]===p){let f=u[1];if(!f||!c.defs[f])throw new Error(`Reference not found: ${o}`);return c.defs[f]}throw new Error(`Reference not found: ${o}`)}function Zin(o,c){if(o.not!==void 0){if(typeof o.not=="object"&&Object.keys(o.not).length===0)return Hr.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(o.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(o.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(o.if!==void 0||o.then!==void 0||o.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(o.dependentSchemas!==void 0||o.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(o.$ref){let f=o.$ref;if(c.refs.has(f))return c.refs.get(f);if(c.processing.has(f))return Hr.lazy(()=>{if(!c.refs.has(f))throw new Error(`Circular reference not resolved: ${f}`);return c.refs.get(f)});c.processing.add(f);let y=xGn(f,c),w=$g(y,c);return c.refs.set(f,w),c.processing.delete(f),w}if(o.enum!==void 0){let f=o.enum;if(c.version==="openapi-3.0"&&o.nullable===!0&&f.length===1&&f[0]===null)return Hr.null();if(f.length===0)return Hr.never();if(f.length===1)return Hr.literal(f[0]);if(f.every(w=>typeof w=="string"))return Hr.enum(f);let y=f.map(w=>Hr.literal(w));return y.length<2?y[0]:Hr.union([y[0],y[1],...y.slice(2)])}if(o.const!==void 0)return Hr.literal(o.const);let u=o.type;if(Array.isArray(u)){let f=u.map(y=>{let w={...o,type:y};return Zin(w,c)});return f.length===0?Hr.never():f.length===1?f[0]:Hr.union(f)}if(!u)return Hr.any();let p;switch(u){case"string":{let f=Hr.string();if(o.format){let y=o.format;y==="email"?f=f.check(Hr.email()):y==="uri"||y==="uri-reference"?f=f.check(Hr.url()):y==="uuid"||y==="guid"?f=f.check(Hr.uuid()):y==="date-time"?f=f.check(Hr.iso.datetime()):y==="date"?f=f.check(Hr.iso.date()):y==="time"?f=f.check(Hr.iso.time()):y==="duration"?f=f.check(Hr.iso.duration()):y==="ipv4"?f=f.check(Hr.ipv4()):y==="ipv6"?f=f.check(Hr.ipv6()):y==="mac"?f=f.check(Hr.mac()):y==="cidr"?f=f.check(Hr.cidrv4()):y==="cidr-v6"?f=f.check(Hr.cidrv6()):y==="base64"?f=f.check(Hr.base64()):y==="base64url"?f=f.check(Hr.base64url()):y==="e164"?f=f.check(Hr.e164()):y==="jwt"?f=f.check(Hr.jwt()):y==="emoji"?f=f.check(Hr.emoji()):y==="nanoid"?f=f.check(Hr.nanoid()):y==="cuid"?f=f.check(Hr.cuid()):y==="cuid2"?f=f.check(Hr.cuid2()):y==="ulid"?f=f.check(Hr.ulid()):y==="xid"?f=f.check(Hr.xid()):y==="ksuid"&&(f=f.check(Hr.ksuid()))}typeof o.minLength=="number"&&(f=f.min(o.minLength)),typeof o.maxLength=="number"&&(f=f.max(o.maxLength)),o.pattern&&(f=f.regex(new RegExp(o.pattern))),p=f;break}case"number":case"integer":{let f=u==="integer"?Hr.number().int():Hr.number();typeof o.minimum=="number"&&(f=f.min(o.minimum)),typeof o.maximum=="number"&&(f=f.max(o.maximum)),typeof o.exclusiveMinimum=="number"?f=f.gt(o.exclusiveMinimum):o.exclusiveMinimum===!0&&typeof o.minimum=="number"&&(f=f.gt(o.minimum)),typeof o.exclusiveMaximum=="number"?f=f.lt(o.exclusiveMaximum):o.exclusiveMaximum===!0&&typeof o.maximum=="number"&&(f=f.lt(o.maximum)),typeof o.multipleOf=="number"&&(f=f.multipleOf(o.multipleOf)),p=f;break}case"boolean":{p=Hr.boolean();break}case"null":{p=Hr.null();break}case"object":{let f={},y=o.properties||{},w=new Set(o.required||[]);for(let[_,T]of Object.entries(y)){let R=$g(T,c);f[_]=w.has(_)?R:R.optional()}if(o.propertyNames){let _=$g(o.propertyNames,c),T=o.additionalProperties&&typeof o.additionalProperties=="object"?$g(o.additionalProperties,c):Hr.any();if(Object.keys(f).length===0){p=Hr.record(_,T);break}let R=Hr.object(f).passthrough(),F=Hr.looseRecord(_,T);p=Hr.intersection(R,F);break}if(o.patternProperties){let _=o.patternProperties,T=Object.keys(_),R=[];for(let B of T){let V=$g(_[B],c),se=Hr.string().regex(new RegExp(B));R.push(Hr.looseRecord(se,V))}let F=[];if(Object.keys(f).length>0&&F.push(Hr.object(f).passthrough()),F.push(...R),F.length===0)p=Hr.object({}).passthrough();else if(F.length===1)p=F[0];else{let B=Hr.intersection(F[0],F[1]);for(let V=2;V<F.length;V++)B=Hr.intersection(B,F[V]);p=B}break}let v=Hr.object(f);o.additionalProperties===!1?p=v.strict():typeof o.additionalProperties=="object"?p=v.catchall($g(o.additionalProperties,c)):p=v.passthrough();break}case"array":{let f=o.prefixItems,y=o.items;if(f&&Array.isArray(f)){let w=f.map(_=>$g(_,c)),v=y&&typeof y=="object"&&!Array.isArray(y)?$g(y,c):void 0;v?p=Hr.tuple(w).rest(v):p=Hr.tuple(w),typeof o.minItems=="number"&&(p=p.check(Hr.minLength(o.minItems))),typeof o.maxItems=="number"&&(p=p.check(Hr.maxLength(o.maxItems)))}else if(Array.isArray(y)){let w=y.map(_=>$g(_,c)),v=o.additionalItems&&typeof o.additionalItems=="object"?$g(o.additionalItems,c):void 0;v?p=Hr.tuple(w).rest(v):p=Hr.tuple(w),typeof o.minItems=="number"&&(p=p.check(Hr.minLength(o.minItems))),typeof o.maxItems=="number"&&(p=p.check(Hr.maxLength(o.maxItems)))}else if(y!==void 0){let w=$g(y,c),v=Hr.array(w);typeof o.minItems=="number"&&(v=v.min(o.minItems)),typeof o.maxItems=="number"&&(v=v.max(o.maxItems)),p=v}else p=Hr.array(Hr.any());break}default:throw new Error(`Unsupported type: ${u}`)}return o.description&&(p=p.describe(o.description)),o.default!==void 0&&(p=p.default(o.default)),p}function $g(o,c){if(typeof o=="boolean")return o?Hr.any():Hr.never();let u=Zin(o,c),p=o.type||o.enum!==void 0||o.const!==void 0;if(o.anyOf&&Array.isArray(o.anyOf)){let v=o.anyOf.map(T=>$g(T,c)),_=Hr.union(v);u=p?Hr.intersection(u,_):_}if(o.oneOf&&Array.isArray(o.oneOf)){let v=o.oneOf.map(T=>$g(T,c)),_=Hr.xor(v);u=p?Hr.intersection(u,_):_}if(o.allOf&&Array.isArray(o.allOf))if(o.allOf.length===0)u=p?u:Hr.any();else{let v=p?u:$g(o.allOf[0],c),_=p?0:1;for(let T=_;T<o.allOf.length;T++)v=Hr.intersection(v,$g(o.allOf[T],c));u=v}o.nullable===!0&&c.version==="openapi-3.0"&&(u=Hr.nullable(u)),o.readOnly===!0&&(u=Hr.readonly(u));let f={},y=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let v of y)v in o&&(f[v]=o[v]);let w=["contentEncoding","contentMediaType","contentSchema"];for(let v of w)v in o&&(f[v]=o[v]);for(let v of Object.keys(o))kGn.has(v)||(f[v]=o[v]);return Object.keys(f).length>0&&c.registry.add(u,f),u}function Xin(o,c){if(typeof o=="boolean")return o?Hr.any():Hr.never();let u=MGn(o,c?.defaultTarget),p=o.$defs||o.definitions||{},f={version:u,defs:p,refs:new Map,processing:new Set,rootSchema:o,registry:c?.registry??Dp};return $g(o,f)}var mft={};Qx(mft,{bigint:()=>IGn,boolean:()=>CGn,date:()=>EGn,number:()=>_Gn,string:()=>SGn});function SGn(o){return Hdt(Qq,o)}function _Gn(o){return Xdt(tG,o)}function CGn(o){return r1t(nG,o)}function IGn(o){return o1t(rG,o)}function EGn(o){return y1t(ite,o)}Mh(npe());var wft=["service","function","worker","agent","database","cache","vectordb","storage","model","dto","dataobject","queue","topic","stream","gateway","cdn","route","interface","adapter","port","llm","prompt","tool","auth","observability","cloud","frontend","external","human","page","component","store","hook","module","custom"],yge=ct.enum(wft),PGn=new Set(["service","function","worker","module","page","component","store","hook","model","dto","dataobject"]);function bge(o){return PGn.has(o)}var vft=["http_call","grpc","invokes","routes_to","websocket","webhook","reads","writes","publishes","subscribes","streams_to","implements","extends","depends_on","has_a","uses"],ute=ct.enum(vft),LGn={http_call:"runtime",grpc:"runtime",invokes:"runtime",routes_to:"runtime",websocket:"runtime",webhook:"runtime",reads:"runtime",writes:"runtime",publishes:"runtime",subscribes:"runtime",streams_to:"runtime",implements:"structural",extends:"structural",depends_on:"structural",has_a:"structural",uses:"structural"};function Kin(o){return LGn[o]}var E3=ct.enum(["proposed","active","deprecated"]),Yin=ct.enum(["boundary","control","entity"]),TGn=ct.string().min(1).refine(o=>!o.startsWith("/"),{message:"sourcePath must be a relative path (no leading /)"}).refine(o=>!o.includes("\\"),{message:"sourcePath must use forward slashes"}).refine(o=>!o.split("/").some(c=>c===".."),{message:"sourcePath must not contain `..` segments"}),AGn=/^[a-z][a-z0-9-]*$/,ba=ct.string().regex(AGn,"id must match /^[a-z][a-z0-9-]*$/"),kft=ct.string().min(1).refine(o=>!o.startsWith("/")&&!/^[a-zA-Z]:[\\/]/.test(o),{message:"archikFile must be a relative path"}).refine(o=>!o.includes("\\"),{message:"archikFile must use forward slashes"}).refine(o=>!o.split("/").some(c=>c==="..")&&!o.includes("./../"),{message:"archikFile must not contain `..` segments"}).refine(o=>o.endsWith(".archik.yaml"),{message:"archikFile must end in `.archik.yaml`"}),dte=ct.string().min(1).refine(o=>!o.startsWith("/")&&!/^[a-zA-Z]:[\\/]/.test(o),{message:"seqFile must be a relative path"}).refine(o=>!o.includes("\\"),{message:"seqFile must use forward slashes"}).refine(o=>!o.split("/").some(c=>c===".."),{message:"seqFile must not contain `..` segments"}).refine(o=>o.endsWith(".archik.seq.yaml"),{message:"seqFile must end in `.archik.seq.yaml`"}),NGn=ct.strictObject({name:ct.string().min(1),protocol:ct.string().min(1),description:ct.string().optional()}),RGn=ct.strictObject({id:ba,kind:yge,name:ct.string().min(1),description:ct.string().min(1).optional(),stack:ct.string().optional(),responsibilities:ct.array(ct.string().min(1)).optional(),interfaces:ct.array(NGn).optional(),notes:ct.array(ct.string()).optional(),parentId:ba.optional(),archikFile:kft.optional(),seqFiles:ct.array(dte).min(1).optional(),sourcePath:TGn.optional(),status:E3.optional(),stereotype:Yin.optional(),owner:ct.string().min(1).optional(),metadata:ct.record(ct.string(),ct.unknown()).optional()}),DGn=ct.strictObject({id:ba,from:ba,to:ba,relationship:ute,label:ct.string().optional(),description:ct.string().optional(),protocol:ct.string().optional(),color:ct.string().optional(),status:E3.optional(),fromFile:kft.optional(),toFile:kft.optional()}),iG=ct.strictObject({id:ba.optional(),kind:yge.optional(),parent:ba.optional(),notParent:ba.optional(),stereotype:Yin.optional()}).refine(o=>Object.values(o).some(c=>c!==void 0),{message:"selector must set at least one of id / kind / parent / notParent / stereotype"}),OGn=ct.strictObject({relationship:ute.optional(),from:iG.optional(),to:iG.optional()}).refine(o=>o.relationship!==void 0||o.from!==void 0||o.to!==void 0,{message:"forbidEdge must set at least one of relationship / from / to"}),FGn=ct.strictObject({kinds:ct.array(yge).min(1).optional()}),zGn=ct.strictObject({node:iG,to:iG.optional(),from:iG.optional(),relationship:ute.optional()}).refine(o=>o.to!==void 0!=(o.from!==void 0),{message:"requireEdge must set exactly one of `to` (outgoing) or `from` (incoming)"}),$Gn=ct.strictObject({node:iG,max:ct.number().int().min(0),relationship:ute.optional()}),jGn=ct.strictObject({id:ba,description:ct.string().min(1),forbidEdge:OGn.optional(),requireOwner:FGn.optional(),requireEdge:zGn.optional(),maxDependencies:$Gn.optional(),except:ct.array(ba).min(1).optional()}).superRefine((o,c)=>{[o.forbidEdge,o.requireOwner,o.requireEdge,o.maxDependencies].filter(p=>p!==void 0).length!==1&&c.addIssue({code:ct.ZodIssueCode.custom,message:`constraint "${o.id}" must define exactly one rule (forbidEdge, requireOwner, requireEdge, or maxDependencies)`})}),BGn=ct.strictObject({from:ct.string().min(1),at:ct.string().min(1),note:ct.string().optional()}),HGn=ct.strictObject({createdAt:ct.string().min(1).optional(),updatedAt:ct.string().min(1).optional(),suggestion:BGn.optional()}),Qin=ct.strictObject({version:ct.literal("1.0"),name:ct.string().min(1),description:ct.string().optional(),nodes:ct.array(RGn),edges:ct.array(DGn),constraints:ct.array(jGn).min(1).optional(),metadata:HGn.optional()}).superRefine((o,c)=>{let u=new Set;for(let v=0;v<o.nodes.length;v++){let _=o.nodes[v];u.has(_.id)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["nodes",v,"id"],message:`duplicate node id "${_.id}"`}),u.add(_.id),(_.description===void 0||_.description.length===0)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["nodes",v,"description"],message:`node "${_.id}" is missing required \`description\`. Every node must explain what it does (its responsibility / behaviour) \u2014 not just restate its kind or name.`})}let p=new Set;for(let v=0;v<o.edges.length;v++){let _=o.edges[v];p.has(_.id)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["edges",v,"id"],message:`duplicate edge id "${_.id}"`}),p.add(_.id),_.fromFile===void 0&&!u.has(_.from)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["edges",v,"from"],message:`edge "${_.id}" references unknown node "${_.from}"`}),_.toFile===void 0&&!u.has(_.to)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["edges",v,"to"],message:`edge "${_.id}" references unknown node "${_.to}"`}),_.fromFile!==void 0&&_.toFile!==void 0&&c.addIssue({code:ct.ZodIssueCode.custom,path:["edges",v],message:`edge "${_.id}" has both fromFile and toFile \u2014 at least one endpoint must be local to this file`}),_.from===_.to&&_.fromFile===void 0&&_.toFile===void 0&&c.addIssue({code:ct.ZodIssueCode.custom,path:["edges",v],message:`edge "${_.id}" is a self-loop (from === to). Self-loops aren't meaningful in an architecture diagram.`})}let f=new Map;for(let v of o.nodes)f.set(v.id,v.parentId);for(let v=0;v<o.nodes.length;v++){let _=o.nodes[v];if(_.parentId===void 0)continue;if(_.parentId===_.id){c.addIssue({code:ct.ZodIssueCode.custom,path:["nodes",v,"parentId"],message:`node "${_.id}" lists itself as parentId`});continue}if(!u.has(_.parentId)){c.addIssue({code:ct.ZodIssueCode.custom,path:["nodes",v,"parentId"],message:`node "${_.id}" parentId "${_.parentId}" doesn't match any node`});continue}let T=new Set([_.id]),R=_.parentId,F=0;for(;R!==void 0&&F<=o.nodes.length;){if(T.has(R)){c.addIssue({code:ct.ZodIssueCode.custom,path:["nodes",v,"parentId"],message:`node "${_.id}" is part of a parentId cycle (via "${R}")`});break}T.add(R),R=f.get(R),F++}}function y(v,_){let T=f.get(_),R=0;for(;T!==void 0&&R<=o.nodes.length;){if(T===v)return!0;T=f.get(T),R++}return!1}for(let v=0;v<o.edges.length;v++){let _=o.edges[v];_.fromFile!==void 0||_.toFile!==void 0||!u.has(_.from)||!u.has(_.to)||(y(_.from,_.to)||y(_.to,_.from))&&c.addIssue({code:ct.ZodIssueCode.custom,path:["edges",v],message:`edge "${_.id}" connects "${_.from}" and "${_.to}" but one is an ancestor of the other \u2014 the parent already contains the child, so an edge between them is a duplicate. Either remove the edge or change the parentId.`})}let w=new Map;for(let v=0;v<o.edges.length;v++){let _=o.edges[v];if(_.fromFile!==void 0||_.toFile!==void 0)continue;let T=`${_.from}\0${_.to}\0${_.relationship}`,R=w.get(T);if(R!==void 0){c.addIssue({code:ct.ZodIssueCode.custom,path:["edges",v],message:`edge "${_.id}" duplicates "${R}" \u2014 same from/to/relationship (${_.from} \u2192 ${_.to} via ${_.relationship}). The diagram already expresses this connection; remove one of them.`});continue}w.set(T,_.id)}});function oG(o,c,u){let p=[],f=new Map;for(let y of o.nodes)y.sourcePath!==void 0&&y.sourcePath.length>0&&f.set(y.id,y.sourcePath);return o.nodes.forEach((y,w)=>{if(!bge(y.kind))return;let v=y.status==="proposed"||y.status==="deprecated";if(y.sourcePath===void 0||y.sourcePath.length===0){if(v)return;p.push({path:`nodes.${w}.sourcePath`,message:`node "${y.id}" (kind: ${y.kind}) is missing required \`sourcePath\`. Code-bearing kinds must declare where their source lives. Either add a sourcePath, or mark the node \`status: proposed\` if the code isn't built yet (proposed/deprecated nodes are exempt).`});return}if(!u(y.sourcePath)){p.push({path:`nodes.${w}.sourcePath`,message:`node "${y.id}" sourcePath "${y.sourcePath}" does not exist on disk (resolved relative to the project root). Either fix the path, drop it (if status is proposed/deprecated, sourcePath is optional), or change the node's status to proposed.`});return}if(y.parentId!==void 0){let _=f.get(y.parentId);_!==void 0&&UGn(_)&&!Mft(y.sourcePath,_)&&p.push({path:`nodes.${w}.sourcePath`,message:`node "${y.id}" sourcePath "${y.sourcePath}" is not inside its parent's sourcePath "${_}". The diagram says "${y.id}" lives inside "${y.parentId}", but the source tree disagrees. Either fix the path, change the parentId, or drop one of the sourcePaths.`})}}),p}function Mft(o,c){let u=o.replace(/\/+$/,""),p=c.replace(/\/+$/,"");return u===p?!0:u.startsWith(p+"/")}function UGn(o){let c=o.split("/").pop()??"";return!/\.[^./]+$/.test(c)}function cG(o,c){let u=[];return o.nodes.forEach((p,f)=>{p.archikFile!==void 0&&(c(p.archikFile)||u.push({path:`nodes.${f}.archikFile`,message:`archikFile "${p.archikFile}" does not exist (resolved relative to the project root)`}))}),o.edges.forEach((p,f)=>{p.fromFile!==void 0&&!c(p.fromFile)&&u.push({path:`edges.${f}.fromFile`,message:`fromFile "${p.fromFile}" does not exist (resolved relative to the project root)`}),p.toFile!==void 0&&!c(p.toFile)&&u.push({path:`edges.${f}.toFile`,message:`toFile "${p.toFile}" does not exist (resolved relative to the project root)`})}),u}function ton(o,c){let u=[];return o.nodes.forEach((p,f)=>{p.seqFiles&&p.seqFiles.forEach((y,w)=>{c(y)||u.push({path:`nodes.${f}.seqFiles.${w}`,message:`seqFile "${y}" does not exist on disk (resolved relative to the project root)`})})}),u}function eon(o){return o.length===0?"<root>":o.map(String).join(".")}function qGn(o,c){let u=o[o.length-1],p=/expected array/i.test(c)&&/received\s+string/i.test(c),f=/received\s+undefined/i.test(c)||/required/i.test(c);return p&&(u==="notes"||u==="responsibilities"||u==="interfaces")?`${String(u)} is an array \u2014 wrap your value, e.g. ${String(u)}: ['first', 'second']. Run \`npx archik schema\` for the full shape.`:f&&u==="id"&&o.length>=2&&o[o.length-3]==="edges"?"every edge requires an `id` (kebab-case, unique within the document), e.g. id: api-writes-db. Run `npx archik schema` for the full Edge shape.":null}function GGn(o){return o.issues.flatMap(c=>{if(c.code==="unrecognized_keys")return c.keys.map(f=>({path:eon([...c.path,f]),message:"unrecognized key"}));let u=qGn(c.path,c.message),p=u===null?c.message:`${c.message}
516
516
  hint: ${u}`;return[{path:eon(c.path),message:p}]})}function jg(o){let c=Qin.safeParse(o);return c.success?{ok:!0,value:c.data}:{ok:!1,errors:GGn(c.error)}}function Zu(o){return o.map(c=>` \u2022 ${c.path}: ${c.message}`).join(`
517
517
  `)}import{readFile as VGn,readdir as WGn}from"node:fs/promises";import hte from"node:path";var xft=mi(kv(),1);function Xu(o){let c;try{c=xft.default.parse(o)}catch(p){let f=p instanceof Error?p.message:String(p);throw new Error(`Invalid YAML: ${f}`)}let u=jg(c);if(!u.ok)throw new Error(`Invalid Archik document:
518
- ${Zu(u.errors)}`);return u.value}function Sv(o){return xft.default.stringify(o,{indent:2,lineWidth:0})}var JGn=6;function Sft(o,c){return hte.relative(o,c).split(hte.sep).join("/")||hte.basename(c)}function ZGn(o){return o.endsWith(".archik.yaml")&&!o.endsWith(".archik.suggested.yaml")}async function ul(o,c){let u=[],p=[],f=new Set,y=async v=>{if(f.has(v))return;f.add(v);let _;try{_=await VGn(v,"utf-8")}catch(T){p.push({abs:v,relPath:Sft(c,v),message:T instanceof Error?T.message:String(T)});return}try{let T=Xu(_);u.push({abs:v,relPath:Sft(c,v),doc:T})}catch(T){p.push({abs:v,relPath:Sft(c,v),message:T instanceof Error?T.message:String(T)})}};await y(o);let w=async(v,_)=>{if(_>JGn)return;let T;try{T=await WGn(v,{withFileTypes:!0})}catch{return}for(let R of T){let F=hte.join(v,R.name);if(R.isDirectory()){await w(F,_+1);continue}R.isFile()&&ZGn(R.name)&&await y(F)}};return await w(hte.join(c,".archik"),0),{docs:u,errors:p}}var ion=mi(kv(),1);import{readFile as oVn,readdir as cVn}from"node:fs/promises";import pte from"node:path";var XGn=ct.enum(["sync","async","return","create","destroy"]),KGn=ct.enum(["over","left_of","right_of"]),YGn=ct.enum(["alt","opt","loop","par","break","ref"]),QGn=ct.strictObject({id:ba,nodeId:ba,label:ct.string().min(1).optional(),status:E3.optional()}),eVn=ct.strictObject({type:ct.literal("message"),id:ba,from:ba,to:ba,label:ct.string().min(1),arrow:XGn,activate:ct.boolean().optional(),status:E3.optional()}),tVn=ct.strictObject({type:ct.literal("note"),id:ba,position:KGn,participants:ct.array(ba).min(1),text:ct.string().min(1),status:E3.optional()}),nVn=ct.lazy(()=>ct.strictObject({label:ct.string().optional(),steps:ct.array(non)})),rVn=ct.lazy(()=>ct.strictObject({type:ct.literal("group"),id:ba,kind:YGn,condition:ct.string().optional(),label:ct.string().optional(),branches:ct.array(nVn).optional(),seqFile:dte.optional(),participants:ct.array(ba).optional(),status:E3.optional()})),non=ct.lazy(()=>ct.union([eVn,tVn,rVn]));function ron(o,c){let u=[];for(let p of o)if(c.has(p.id)?u.push(p.id):c.add(p.id),p.type==="group"&&p.branches)for(let f of p.branches)u.push(...ron(f.steps,c));return u}var iVn=ct.strictObject({useCase:ba,slice:ba}),fte=ct.strictObject({version:ct.literal("1.0"),name:ct.string().min(1),description:ct.string().optional(),realizes:iVn.optional(),participants:ct.array(QGn).min(1),steps:ct.array(non)}).superRefine((o,c)=>{let u=new Set;for(let y=0;y<o.participants.length;y++){let w=o.participants[y];u.has(w.id)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["participants",y,"id"],message:`duplicate participant id "${w.id}"`}),u.add(w.id)}let p=new Set,f=ron(o.steps,p);for(let y of f)c.addIssue({code:ct.ZodIssueCode.custom,path:["steps"],message:`duplicate step id "${y}"`})});var aVn=6;function sVn(o,c){return pte.relative(o,c).split(pte.sep).join("/")||pte.basename(c)}async function _v(o){let c=[],u=[],p=async y=>{let w=sVn(o,y),v;try{v=await oVn(y,"utf-8")}catch(_){u.push({abs:y,relPath:w,message:_ instanceof Error?_.message:String(_)});return}try{let _=ion.default.parse(v),T=fte.safeParse(_);if(!T.success){u.push({abs:y,relPath:w,message:T.error.issues.map(R=>R.message).join("; ")});return}c.push({abs:y,relPath:w,doc:T.data})}catch(_){u.push({abs:y,relPath:w,message:_ instanceof Error?_.message:String(_)})}},f=async(y,w)=>{if(w>aVn)return;let v;try{v=await cVn(y,{withFileTypes:!0})}catch{return}for(let _ of v){let T=pte.join(y,_.name);if(_.isDirectory()){await f(T,w+1);continue}_.isFile()&&_.name.endsWith(".archik.seq.yaml")&&await p(T)}};return await f(pte.join(o,".archik"),0),{docs:c,errors:u}}var con=mi(kv(),1);import{readFile as bVn,readdir as mVn}from"node:fs/promises";import gte from"node:path";var lVn=ct.string().min(1).refine(o=>!o.startsWith("/")&&!/^[a-zA-Z]:[\\/]/.test(o),{message:"test path must be relative (no leading / or drive letter)"}).refine(o=>!o.includes("\\"),{message:"test path must use forward slashes"}).refine(o=>!o.split("/").some(c=>c===".."),{message:"test path must not contain `..` segments"}),uVn=/^[a-z][a-z0-9-]*\.\d+$/,dVn=ct.string().regex(uVn,"branchFrom must be `<flowId>.<stepNumber>` (e.g. basic.3)"),hVn=ct.strictObject({steps:ct.array(ct.string().min(1)).min(1)}),fVn=ct.strictObject({id:ba,branchFrom:dVn,steps:ct.array(ct.string().min(1)).min(1)}),pVn=ct.strictObject({basic:hVn,alternates:ct.array(fVn).optional()}),gVn=ct.strictObject({seqFile:dte}),yVn=ct.strictObject({id:ba,description:ct.string().min(1),flows:ct.array(ba).min(1),tests:ct.array(lVn).optional(),realization:gVn.optional(),status:E3.optional()}),oon=ct.strictObject({version:ct.literal("1.0"),id:ba,name:ct.string().min(1),description:ct.string().optional(),status:E3.optional(),primaryActor:ba,secondaryActors:ct.array(ba).optional(),goal:ct.string().min(1),preconditions:ct.array(ct.string().min(1)).optional(),postconditions:ct.array(ct.string().min(1)).optional(),flows:pVn,slices:ct.array(yVn).min(1)}).superRefine((o,c)=>{let u=new Map;u.set("basic",o.flows.basic.steps.length);let p=new Set;o.flows.alternates&&(o.flows.alternates.forEach((y,w)=>{y.id==="basic"&&c.addIssue({code:ct.ZodIssueCode.custom,path:["flows","alternates",w,"id"],message:'alternate id "basic" collides with the basic flow'}),p.has(y.id)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["flows","alternates",w,"id"],message:`duplicate alternate flow id "${y.id}"`}),p.add(y.id),u.set(y.id,y.steps.length)}),o.flows.alternates.forEach((y,w)=>{let[v,_]=y.branchFrom.split("."),T=Number(_),R=u.get(v);if(R===void 0){c.addIssue({code:ct.ZodIssueCode.custom,path:["flows","alternates",w,"branchFrom"],message:`branchFrom "${y.branchFrom}" references unknown flow "${v}"`});return}(T<1||T>R)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["flows","alternates",w,"branchFrom"],message:`branchFrom "${y.branchFrom}" step ${T} is out of range (flow "${v}" has ${R} step(s))`})}));let f=new Set;o.slices.forEach((y,w)=>{f.has(y.id)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["slices",w,"id"],message:`duplicate slice id "${y.id}"`}),f.add(y.id),y.flows.forEach((_,T)=>{u.has(_)||c.addIssue({code:ct.ZodIssueCode.custom,path:["slices",w,"flows",T],message:`slice "${y.id}" references unknown flow "${_}". Available: ${Array.from(u.keys()).join(", ")}.`})}),y.flows.includes("basic")||c.addIssue({code:ct.ZodIssueCode.custom,path:["slices",w,"flows"],message:`slice "${y.id}" does not include the basic flow. Slices must include "basic" plus zero or more alternates that branch off it; otherwise the alternate has no prefix to branch from.`}),!(y.status==="proposed"||y.status==="deprecated")&&(y.tests===void 0||y.tests.length===0)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["slices",w,"tests"],message:`slice "${y.id}" has no tests. Active slices must declare at least one test path (each must exist on disk). Mark the slice \`status: proposed\` if the test isn't written yet.`})})});var wVn=6;function vVn(o,c){return gte.relative(o,c).split(gte.sep).join("/")||gte.basename(c)}function kVn(o){return o.endsWith(".archik.uc.yaml")}async function Op(o){let c=[],u=[],p=async y=>{let w=vVn(o,y),v;try{v=await bVn(y,"utf-8")}catch(R){u.push({abs:y,relPath:w,message:R instanceof Error?R.message:String(R)});return}let _;try{_=con.default.parse(v)}catch(R){u.push({abs:y,relPath:w,message:R instanceof Error?R.message:String(R)});return}let T=oon.safeParse(_);if(!T.success){u.push({abs:y,relPath:w,message:T.error.issues.map(R=>R.message).join("; ")});return}c.push({abs:y,relPath:w,doc:T.data})},f=async(y,w)=>{if(w>wVn)return;let v;try{v=await mVn(y,{withFileTypes:!0})}catch{return}for(let _ of v){let T=gte.join(y,_.name);if(_.isDirectory()){await f(T,w+1);continue}_.isFile()&&kVn(_.name)&&await p(T)}};return await f(gte.join(o,".archik","usecases"),0),{docs:c,errors:u}}var son=mi(kv(),1);import{readFile as SVn,readdir as _Vn}from"node:fs/promises";import yte from"node:path";var MVn=ct.enum(["human","external-system","time","device"]),xVn=ct.strictObject({id:ba,kind:MVn,description:ct.string().min(1),goals:ct.array(ct.string().min(1)).optional(),status:E3.optional()}),aon=ct.strictObject({version:ct.literal("1.0"),description:ct.string().optional(),actors:ct.array(xVn).min(1)}).superRefine((o,c)=>{let u=new Set;o.actors.forEach((p,f)=>{u.has(p.id)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["actors",f,"id"],message:`duplicate actor id "${p.id}"`}),u.add(p.id)})});var CVn=6;function IVn(o,c){return yte.relative(o,c).split(yte.sep).join("/")||yte.basename(c)}function EVn(o){return o.endsWith(".archik.actors.yaml")}async function aS(o){let c=[],u=[],p=async y=>{let w=IVn(o,y),v;try{v=await SVn(y,"utf-8")}catch(R){u.push({abs:y,relPath:w,message:R instanceof Error?R.message:String(R)});return}let _;try{_=son.default.parse(v)}catch(R){u.push({abs:y,relPath:w,message:R instanceof Error?R.message:String(R)});return}let T=aon.safeParse(_);if(!T.success){u.push({abs:y,relPath:w,message:T.error.issues.map(R=>R.message).join("; ")});return}c.push({abs:y,relPath:w,doc:T.data})},f=async(y,w)=>{if(w>CVn)return;let v;try{v=await _Vn(y,{withFileTypes:!0})}catch{return}for(let _ of v){let T=yte.join(y,_.name);if(_.isDirectory()){await f(T,w+1);continue}_.isFile()&&EVn(_.name)&&await p(T)}};return await f(yte.join(o,".archik"),0),{docs:c,errors:u}}import{readFile as LVn,readdir as TVn}from"node:fs/promises";import bte from"node:path";var PVn=ct.strictObject({id:ba.optional(),from:ba,to:ba,label:ct.string().min(1),data:ct.strictObject({in:ct.unknown().optional(),out:ct.unknown().optional()}).optional(),status:ct.enum(["ok","error"]).default("ok")}),lon=ct.strictObject({version:ct.literal("1.0"),useCase:ba,slice:ba,seqFile:ct.string().min(1).optional(),recordedAt:ct.string().min(1),steps:ct.array(PVn).min(1)});var AVn=6;function NVn(o,c){return bte.relative(o,c).split(bte.sep).join("/")||bte.basename(c)}async function aG(o){let c=[],u=[],p=async y=>{let w=NVn(o,y),v;try{v=await LVn(y,"utf-8")}catch(_){u.push({abs:y,relPath:w,message:_ instanceof Error?_.message:String(_)});return}try{let _=JSON.parse(v),T=lon.safeParse(_);if(!T.success){u.push({abs:y,relPath:w,message:T.error.issues.map(R=>R.message).join("; ")});return}c.push({abs:y,relPath:w,doc:T.data})}catch(_){u.push({abs:y,relPath:w,message:_ instanceof Error?_.message:String(_)})}},f=async(y,w)=>{if(w>AVn)return;let v;try{v=await TVn(y,{withFileTypes:!0})}catch{return}for(let _ of v){let T=bte.join(y,_.name);if(_.isDirectory()){await f(T,w+1);continue}_.isFile()&&_.name.endsWith(".archik.trace.json")&&await p(T)}};return await f(bte.join(o,".archik"),0),{docs:c,errors:u}}function RVn(o){let c=new Set,u=p=>{for(let f of p){let y=f;if(y.type==="message"&&y.id&&c.add(y.id),y.branches)for(let w of y.branches)u(w.steps)}};return u(o),c}function uon(o,c,u){let p=[],f=[],y=new Set;for(let{doc:w}of c)for(let v of w.slices)y.add(`${w.id}/${v.id}`);for(let{relPath:w,doc:v}of o){if(!y.has(`${v.useCase}/${v.slice}`)){p.push({path:w,message:`trace targets unknown use case / slice "${v.useCase}/${v.slice}"`});continue}if(v.seqFile===void 0)continue;let _=u.find(B=>B.relPath===v.seqFile||B.abs.endsWith("/"+v.seqFile));if(_===void 0){p.push({path:w,message:`trace seqFile "${v.seqFile}" is not a discovered sequence diagram`});continue}let T=RVn(_.doc.steps),R=new Set(_.doc.participants.map(B=>B.id)),F=new Set;for(let B of v.steps){B.id!==void 0&&(T.has(B.id)?F.add(B.id):p.push({path:w,message:`trace step id "${B.id}" is not a message id in ${v.seqFile}`}));for(let V of[B.from,B.to])R.has(V)||p.push({path:w,message:`trace step references "${V}", not a participant in ${v.seqFile}`})}for(let B of T)F.has(B)||f.push(`${w}: seq step "${B}" was not exercised by this run`)}return{errors:p,info:f}}function don(o,c,u,p){o.forEach((f,y)=>{let w=`${p}.${y}`;f.type==="message"?(c.has(f.from)||u.push({path:`${w}.from`,message:`participant "${f.from}" is not declared in participants`}),c.has(f.to)||u.push({path:`${w}.to`,message:`participant "${f.to}" is not declared in participants`})):f.type==="note"?f.participants.forEach((v,_)=>{c.has(v)||u.push({path:`${w}.participants.${_}`,message:`participant "${v}" is not declared in participants`})}):f.type==="group"&&f.branches&&f.branches.forEach((v,_)=>{don(v.steps,c,u,`${w}.branches.${_}.steps`)})})}function hon(o,c){let u=[],p=new Set;return o.participants.forEach((f,y)=>{p.add(f.id),c.has(f.nodeId)||u.push({path:`participants.${y}.nodeId`,message:`nodeId "${f.nodeId}" does not match any architecture node. Run \`npx archik q list\` to see available node ids.`})}),don(o.steps,p,u,"steps"),u}var DVn={boundary:new Set(["control"]),control:new Set(["boundary","control","entity"]),entity:new Set(["control","entity"])};function fon(o,c,u,p,f,y){o.forEach((w,v)=>{let _=`${f}.${v}`;if(w.type==="message"){let T=c.get(w.from),R=c.get(w.to);if(T===void 0||R===void 0)return;let F=DVn[T];F&&!F.has(R)&&y.push({path:`${u}:${_}`,message:`ECB violation in seq "${p}" message "${w.id}": ${T} \u2192 ${R} is forbidden by the robustness rules (boundaries don't talk to boundaries or entities; entities don't talk to boundaries). Insert a control between them, or revisit the stereotype assignment.`})}else w.type==="group"&&w.branches&&w.branches.forEach((T,R)=>{fon(T.steps,c,u,p,`${_}.branches.${R}.steps`,y)})})}function pon(o,c){let u=[],p=new Map;for(let{doc:f}of c)for(let y of f.nodes)y.stereotype!==void 0&&p.set(y.id,y.stereotype);for(let f of o){if(f.doc.realizes===void 0)continue;let y=new Map;for(let w of f.doc.participants){let v=p.get(w.nodeId);v!==void 0&&y.set(w.id,v)}fon(f.doc.steps,y,f.relPath,f.doc.name,"steps",u)}return u}function gon(o,c){let u=[],p=new Map;for(let{doc:f}of c)for(let y of f.nodes){let w=p.get(y.id)??new Set;for(let v of y.seqFiles??[])w.add(v);p.set(y.id,w)}for(let f of o){if(f.doc.realizes===void 0)continue;let y=new Set;for(let w of f.doc.participants){if(y.has(w.nodeId))continue;let v=p.get(w.nodeId);v!==void 0&&(v.has(f.relPath)||(y.add(w.nodeId),u.push({path:`${f.relPath}:participants.${w.id}`,message:`seq "${f.doc.name}" lists node "${w.nodeId}" as a participant, but that node's \`seqFiles\` array does not reference this diagram. Add "${f.relPath}" to node "${w.nodeId}"'s \`seqFiles\` array via \`npx archik suggest set\` so the canvas can surface the flow on that node.`})))}}return u}function yon(o,c){let u=[],p=new Map(c.map(f=>[f.doc.id,f]));for(let f of o){if(f.doc.realizes===void 0)continue;let{useCase:y,slice:w}=f.doc.realizes,v=p.get(y);if(v===void 0){u.push({path:`${f.relPath}:realizes.useCase`,message:`seq diagram "${f.doc.name}" claims to realize use case "${y}" but no such use case file was found.`});continue}let _=v.doc.slices.find(T=>T.id===w);if(_===void 0){u.push({path:`${f.relPath}:realizes.slice`,message:`seq diagram "${f.doc.name}" claims to realize slice "${w}" of use case "${y}", but that use case has no slice with that id. Available slices: ${v.doc.slices.map(T=>T.id).join(", ")}.`});continue}if(_.realization===void 0){u.push({path:`${f.relPath}:realizes.slice`,message:`seq diagram "${f.doc.name}" realizes slice "${w}" of "${y}", but the slice does not declare \`realization.seqFile\`. Add \`realization: { seqFile: "${f.relPath}" }\` to slice "${w}" in ${v.relPath}.`});continue}_.realization.seqFile!==f.relPath&&u.push({path:`${f.relPath}:realizes.slice`,message:`seq diagram "${f.doc.name}" realizes slice "${w}" of "${y}", but that slice's realization.seqFile points at "${_.realization.seqFile}", not at this file ("${f.relPath}"). Pick one canonical seq file and update both sides.`})}return u}function bon(o){let c=new Map,u=[];for(let{relPath:p,doc:f}of o)for(let y of f.actors){let w=c.get(y.id);if(w!==void 0){u.push({path:p,message:`actor id "${y.id}" is duplicated across actor files (also defined in ${w.relPath})`});continue}c.set(y.id,{relPath:p})}return{index:c,errors:u}}function mon(o){let c=new Map,u=[];for(let{relPath:p,doc:f}of o){let y=c.get(f.id);if(y!==void 0){u.push({path:p,message:`use case id "${f.id}" is duplicated across files (also defined in ${y.relPath})`});continue}c.set(f.id,{relPath:p})}return{index:c,errors:u}}function won(o,c){let u=[];for(let{relPath:p,doc:f}of o)c.has(f.primaryActor)||u.push({path:`${p}:primaryActor`,message:`use case "${f.id}" references unknown primaryActor "${f.primaryActor}". Define it in a *.archik.actors.yaml file.`}),f.secondaryActors&&f.secondaryActors.forEach((y,w)=>{c.has(y)||u.push({path:`${p}:secondaryActors.${w}`,message:`use case "${f.id}" references unknown secondary actor "${y}". Define it in a *.archik.actors.yaml file.`})});return u}function von(o,c){let u=[];for(let{relPath:p,doc:f}of o)f.slices.forEach((y,w)=>{y.status==="proposed"||y.status==="deprecated"||y.tests!==void 0&&y.tests.forEach((_,T)=>{c(_)||u.push({path:`${p}:slices.${w}.tests.${T}`,message:`slice "${y.id}" test "${_}" does not exist on disk (resolved relative to project root). Either fix the path or mark the slice \`status: proposed\`.`})})});return u}function kon(o,c){let u=[],p=new Map(c.map(f=>[f.relPath,f]));for(let{relPath:f,doc:y}of o)y.slices.forEach((w,v)=>{if(w.realization===void 0)return;let _=p.get(w.realization.seqFile);if(_===void 0){u.push({path:`${f}:slices.${v}.realization.seqFile`,message:`slice "${w.id}" realization seqFile "${w.realization.seqFile}" does not exist or did not parse. Run \`npx archik q sequences\` to see available seq files.`});return}if(_.doc.realizes===void 0){u.push({path:`${f}:slices.${v}.realization.seqFile`,message:`slice "${w.id}" claims realization "${w.realization.seqFile}", but that seq diagram has no \`realizes\` block. Add \`realizes: { useCase: "${y.id}", slice: "${w.id}" }\` to ${_.relPath}, or remove the realization claim.`});return}(_.doc.realizes.useCase!==y.id||_.doc.realizes.slice!==w.id)&&u.push({path:`${f}:slices.${v}.realization.seqFile`,message:`slice "${w.id}" claims realization "${w.realization.seqFile}", but that seq diagram's \`realizes\` points at "${_.doc.realizes.useCase}/${_.doc.realizes.slice}", not at "${y.id}/${w.id}". Pick one canonical link.`})});return u}import mte from"node:path";function Cv(o){let c=mte.dirname(o),u=mte.basename(o),p=mte.extname(u),f=p.length>0?u.slice(0,-p.length):u;return mte.join(c,`${f}.suggested${p}`)}function sG(o){return mte.basename(o).endsWith(".archik.suggested.yaml")?"suggested":"normal"}function Mon(o){return o.metadata?.suggestion!==void 0}function mge(o){if(o.metadata?.suggestion===void 0)return o;let{suggestion:c,...u}=o.metadata,p={...o};return Object.keys(u).length===0?delete p.metadata:p.metadata=u,p}function OVn(o){let c=new Map;for(let p of o)c.set(p.id,p.parentId);let u=new Map;for(let p of o){let f=new Set,y=p.parentId,w=0;for(;y!==void 0&&w<=o.length&&!f.has(y);)f.add(y),y=c.get(y),w++;u.set(p.id,f)}return u}function lG(o,c,u){if(c.id!==void 0&&o.id!==c.id||c.kind!==void 0&&o.kind!==c.kind||c.stereotype!==void 0&&o.stereotype!==c.stereotype)return!1;let p=u.get(o.id)??new Set;return!(c.parent!==void 0&&!p.has(c.parent)||c.notParent!==void 0&&p.has(c.notParent))}function wge(o,c,u,p){let f=o.filter(y=>y.abs!==c);return f.push({abs:c,relPath:u,doc:p}),_ft(f)}function _ft(o){let c=[],u=o.flatMap(_=>_.doc.nodes),p=o.flatMap(_=>_.doc.edges.map(T=>({edge:T,relPath:_.relPath}))),f=new Map(u.map(_=>[_.id,_])),y=OVn(u),w=[],v=new Map;for(let _ of o)for(let T of _.doc.constraints??[]){let R=v.get(T.id);if(R!==void 0){c.push({path:`constraints.${T.id}`,message:`duplicate constraint id "${T.id}" (already defined in ${R})`});continue}v.set(T.id,_.relPath),w.push({constraint:T,relPath:_.relPath})}for(let{constraint:_}of w){let T=new Set(_.except??[]);if(_.forbidEdge!==void 0){let R=_.forbidEdge;for(let{edge:F,relPath:B}of p)if(!T.has(F.id)&&!(R.relationship!==void 0&&F.relationship!==R.relationship)){if(R.from!==void 0){let V=f.get(F.from);if(V===void 0||!lG(V,R.from,y))continue}if(R.to!==void 0){let V=f.get(F.to);if(V===void 0||!lG(V,R.to,y))continue}c.push({path:`constraints.${_.id}`,message:`edge "${F.id}" (${F.from} \u2192 ${F.to} via ${F.relationship}, in ${B}) violates constraint "${_.id}": ${_.description} \u2014 fix the edge, or add "${F.id}" to the constraint's \`except\` list with a reason in review.`})}}if(_.requireEdge!==void 0){let R=_.requireEdge;for(let F of u){if(T.has(F.id)||!lG(F,R.node,y)||p.some(({edge:se})=>{if(R.relationship!==void 0&&se.relationship!==R.relationship)return!1;if(R.to!==void 0){if(se.from!==F.id)return!1;let ce=f.get(se.to);return ce!==void 0&&lG(ce,R.to,y)}if(se.to!==F.id)return!1;let ee=f.get(se.from);return ee!==void 0&&lG(ee,R.from,y)}))continue;let V=R.to!==void 0?`an outgoing edge to a node matching ${JSON.stringify(R.to)}`:`an incoming edge from a node matching ${JSON.stringify(R.from)}`;c.push({path:`constraints.${_.id}`,message:`node "${F.id}" (kind: ${F.kind}) violates constraint "${_.id}": ${_.description} \u2014 it needs ${V}`+(R.relationship!==void 0?` (relationship: ${R.relationship})`:"")+`, or add "${F.id}" to the constraint's \`except\` list.`})}}if(_.maxDependencies!==void 0){let R=_.maxDependencies;for(let F of u){if(T.has(F.id)||!lG(F,R.node,y))continue;let B=p.filter(({edge:V})=>V.from===F.id&&(R.relationship===void 0||V.relationship===R.relationship));B.length<=R.max||c.push({path:`constraints.${_.id}`,message:`node "${F.id}" (kind: ${F.kind}) violates constraint "${_.id}": ${_.description} \u2014 ${B.length} outgoing ${R.relationship??""} edge(s), max is ${R.max} (${B.map(V=>V.edge.to).join(", ")}). Split the node, introduce a port/gateway, or add "${F.id}" to \`except\`.`})}}if(_.requireOwner!==void 0){let R=_.requireOwner.kinds;for(let F of u)T.has(F.id)||R!==void 0&&!R.includes(F.kind)||F.owner===void 0&&c.push({path:`constraints.${_.id}`,message:`node "${F.id}" (kind: ${F.kind}) violates constraint "${_.id}": ${_.description} \u2014 add \`owner: <team>\` to the node, or add "${F.id}" to the constraint's \`except\` list.`})}}return c}var CE={maxNodes:15,maxEdges:20,maxChildren:6,maxDegree:6,maxDepth:3};function FVn(o,c){let u=0,p=c.get(o);for(;p!==void 0&&u<=c.size;)u++,p=c.get(p);return u}function vge(o,c){let u=[];for(let{doc:f,relPath:y}of o){f.nodes.length>c.maxNodes&&u.push({kind:"file-nodes",subject:y,value:f.nodes.length,limit:c.maxNodes,suggestion:`split ${y} into sub-files via archikFile (${f.nodes.length} nodes; limit ${c.maxNodes})`}),f.edges.length>c.maxEdges&&u.push({kind:"file-edges",subject:y,value:f.edges.length,limit:c.maxEdges,suggestion:`split ${y} into sub-files via archikFile (${f.edges.length} edges; limit ${c.maxEdges})`});let w=new Map,v=new Map;for(let _ of f.nodes)v.set(_.id,_.parentId);for(let _ of f.nodes)_.parentId!==void 0&&w.set(_.parentId,(w.get(_.parentId)??0)+1);for(let[_,T]of w)T>c.maxChildren&&u.push({kind:"container-children",subject:_,value:T,limit:c.maxChildren,suggestion:`give container '${_}' its own archikFile \u2014 ${T} children, limit ${c.maxChildren}`});for(let _ of f.nodes){let T=FVn(_.id,v);T>c.maxDepth&&u.push({kind:"nesting-depth",subject:_.id,value:T,limit:c.maxDepth,suggestion:`flatten or split \u2014 '${_.id}' is ${T} levels deep, limit ${c.maxDepth}`})}}let p=new Map;for(let{doc:f}of o)for(let y of f.edges)p.set(y.from,(p.get(y.from)??0)+1),p.set(y.to,(p.get(y.to)??0)+1);for(let[f,y]of p)y>c.maxDegree&&u.push({kind:"node-degree",subject:f,value:y,limit:c.maxDegree,suggestion:`'${f}' has ${y} connections \u2014 name a bounded context or add a port/gateway (limit ${c.maxDegree})`});return u.sort((f,y)=>y.value-y.limit-(f.value-f.limit)),u}var jVn=o=>{let c=dn(o,"json");return c!==void 0&&c!=="false"&&c!=="0"};function Iv(o){console.log(JSON.stringify(o,null,2))}async function AR(o){let c=jVn(o),u;try{u=await cc(o._[0])}catch(nn){let cn=nn instanceof Error?nn.message:String(nn);return c?Iv({ok:!1,errors:[{path:"<root>",message:cn}]}):console.error(`\u2717 ${cn}`),1}let p=xon.relative(process.cwd(),u)||u,f;try{f=await $Vn(u,"utf-8")}catch(nn){let cn=nn instanceof Error?nn.message:String(nn);return c?Iv({ok:!1,file:p,errors:[{path:"<root>",message:cn}]}):(console.error(`\u2717 Cannot read ${p}`),console.error(cn)),1}let y;try{y=Son.default.parse(f)}catch(nn){let Nr=[{path:"<root>",message:`Invalid YAML: ${nn instanceof Error?nn.message:String(nn)}`}];return c?Iv({ok:!1,file:p,errors:Nr}):(console.error(`\u2717 ${p}`),console.error(Zu(Nr))),1}let w=jg(y);if(!w.ok)return c?Iv({ok:!1,file:p,errors:w.errors}):(console.error(`\u2717 ${p}`),console.error(Zu(w.errors))),1;let v=Ba(u),_=nn=>zVn(xon.resolve(v,nn)),T=cG(w.value,_);if(T.length>0)return c?Iv({ok:!1,file:p,errors:T}):(console.error(`\u2717 ${p}`),console.error(Zu(T))),1;let R=sG(u),F=oG(w.value,R,_);if(F.length>0)return c?Iv({ok:!1,file:p,errors:F}):(console.error(`\u2717 ${p}`),console.error(Zu(F))),1;let B=await ul(u,v);if(B.errors.length>0){if(c)Iv({ok:!1,file:p,errors:B.errors.map(nn=>({path:nn.relPath,message:nn.message}))});else for(let nn of B.errors)console.error(`\u2717 ${nn.relPath}: ${nn.message}`);return 1}let V=new Set(B.docs.flatMap(nn=>nn.doc.nodes.map(cn=>cn.id))),se=[];for(let{doc:nn}of B.docs)se.push(...ton(nn,_));if(se.length>0){if(c)Iv({ok:!1,file:p,errors:se});else{console.error("\u2717 seqFiles path errors:");for(let nn of se)console.error(` \u2717 ${nn.path}: ${nn.message}`)}return 1}let ee=await _v(v),ce=0;for(let nn of ee.errors)c||console.error(`\u2717 ${nn.relPath}: ${nn.message}`),ce++;for(let{relPath:nn,doc:cn}of ee.docs){let Nr=hon(cn,V);if(Nr.length>0){if(!c){console.error(`\u2717 ${nn}`);for(let oi of Nr)console.error(` \u2717 ${oi.path}: ${oi.message}`)}ce+=Nr.length}}if(ce>0)return c&&Iv({ok:!1,file:p,errors:[{path:"<seq>",message:`${ce} sequence diagram error(s)`}]}),1;let ge=await Op(v),Oe=await aS(v),ut=[];for(let nn of ge.errors)ut.push({path:nn.relPath,message:nn.message});for(let nn of Oe.errors)ut.push({path:nn.relPath,message:nn.message});if(ut.length===0){let nn=bon(Oe.docs);ut.push(...nn.errors);let cn=mon(ge.docs);ut.push(...cn.errors),ut.length===0&&(ut.push(...won(ge.docs,nn.index)),ut.push(...von(ge.docs,_)),ut.push(...kon(ge.docs,ee.docs)),ut.push(...yon(ee.docs,ge.docs)),ut.push(...pon(ee.docs,B.docs)),ut.push(...gon(ee.docs,B.docs)))}if(ut.length>0)return c?Iv({ok:!1,file:p,errors:ut}):(console.error(`\u2717 ${p}`),console.error(Zu(ut))),1;let Se=await aG(v),je=Se.errors.map(nn=>({path:nn.relPath,message:nn.message})),Be=[];if(je.length===0){let nn=uon(Se.docs,ge.docs,ee.docs);je.push(...nn.errors),Be=nn.info}if(je.length>0)return c?Iv({ok:!1,file:p,errors:je}):(console.error(`\u2717 ${p}`),console.error(Zu(je))),1;let tn=_ft(B.docs);if(tn.length>0)return c?Iv({ok:!1,file:p,errors:tn}):(console.error(`\u2717 ${p}`),console.error(Zu(tn))),1;let Gt=Oe.docs.reduce((nn,cn)=>nn+cn.doc.actors.length,0),xn=ge.docs.length,Vn=vge(B.docs,CE).length;if(c)Iv({ok:!0,file:p,nodes:w.value.nodes.length,edges:w.value.edges.length,useCases:xn,actors:Gt,complexityHints:Vn});else{let nn=B.docs.reduce((Pi,ue)=>Pi+ue.doc.nodes.length,0),cn=B.docs.reduce((Pi,ue)=>Pi+ue.doc.edges.length,0),Nr=B.docs.length,oi=Nr>1?` (${Nr} files)`:"",wo=xn>0?`, ${xn} use case${xn===1?"":"s"}`:"",Za=Gt>0?`, ${Gt} actor${Gt===1?"":"s"}`:"";console.log(`\u2713 ${p}${oi} \u2014 ${nn} nodes, ${cn} edges${wo}${Za}`),Vn>0&&console.log(`\u24D8 ${Vn} complexity hint${Vn===1?"":"s"} \u2014 run \`archik complexity\` to see them`);for(let Pi of Be)console.log(`\u24D8 ${Pi}`)}return 0}var w2t=mi(P3(),1),v2t=mi(Dye(),1),Gln=mi(kv(),1);import{mkdir as Hln,readFile as Uln,writeFile as qln}from"node:fs/promises";import OG from"node:path";var Rsn=mi(Lsn(),1);function cne(o,c){return o.length*c}function t0(o,c,u){if(c<=0)return"";let p=Math.floor(c/u);return o.length<=p?o:p<=1?"\u2026":o.slice(0,p-1)+"\u2026"}var ane={nodeSpacing:60,layerSpacing:100,padding:40,viewMode:"detailed"};function HXn(o){let c=o.nodeSpacing??ane.nodeSpacing,u=o.layerSpacing??ane.layerSpacing,p=o.padding??ane.padding;return{"elk.algorithm":"layered","elk.direction":"RIGHT","elk.edgeRouting":"ORTHOGONAL","elk.layered.spacing.nodeNodeBetweenLayers":String(u),"elk.spacing.nodeNode":String(c),"elk.padding":`[top=${p}, left=${p}, bottom=${p}, right=${p}]`,"elk.hierarchyHandling":"INCLUDE_CHILDREN","elk.edgeLabels.placement":"CENTER","elk.spacing.edgeLabel":"8","elk.spacing.labelLabel":"6","elk.spacing.edgeNode":"20","elk.spacing.edgeEdge":"12","elk.layered.spacing.edgeEdgeBetweenLayers":"12"}}var ed={width:172,height:82},Tsn={width:172,height:90},UXn={service:ed,function:ed,worker:ed,agent:ed,database:{width:184,height:100},cache:Tsn,vectordb:ed,storage:ed,model:ed,dto:ed,dataobject:ed,queue:{width:188,height:80},topic:ed,stream:ed,gateway:ed,cdn:ed,route:ed,interface:ed,adapter:ed,port:ed,llm:ed,prompt:ed,tool:ed,auth:ed,observability:ed,cloud:{width:200,height:120},frontend:Tsn,page:ed,component:ed,store:ed,hook:ed,external:{width:184,height:100},human:{width:184,height:100},module:{width:240,height:130},custom:{width:240,height:130}},dl={width:152,height:36},Asn={width:200,height:80},qXn={service:dl,function:dl,worker:dl,agent:dl,database:dl,cache:dl,vectordb:dl,storage:dl,model:dl,dto:dl,dataobject:dl,queue:{width:168,height:36},topic:dl,stream:dl,gateway:dl,cdn:dl,route:dl,interface:dl,adapter:dl,port:dl,llm:dl,prompt:dl,tool:dl,auth:dl,observability:dl,cloud:dl,frontend:dl,page:dl,component:dl,store:dl,hook:dl,external:{width:168,height:40},human:{width:168,height:40},module:Asn,custom:Asn},GXn=24,Nsn=320;function VXn(o,c,u){if(o.kind==="module"||o.kind==="custom")return c;if(u==="compact"){let v=36+cne(o.name,5.9)+12;return Math.max(c,Math.min(Nsn,Math.ceil(v)))}let p=cne(o.name,7.4),f=o.stack!==void 0?cne(o.stack,5.9):0,y=Math.max(p,f)+GXn;return Math.max(c,Math.min(Nsn,Math.ceil(y)))}var WXn={top:48,left:18,bottom:18,right:18};function JXn(o,c,u,p){let f=u[o.kind],y={id:o.id,width:VXn(o,f.width,p),height:f.height};if(c.length>0){y.children=c;let w=p==="compact"?{top:30,left:12,bottom:12,right:12}:WXn;y.layoutOptions={"elk.padding":`[top=${w.top}, left=${w.left}, bottom=${w.bottom}, right=${w.right}]`}}return y}function ZXn(o,c,u){let p=new Map;for(let v of o.nodes)p.set(v.id,v);let f=new Map;for(let v of o.nodes){let _=f.get(v.parentId)??[];_.push(v),f.set(v.parentId,_)}function y(v){let _=(f.get(v.id)??[]).map(y);return JXn(v,_,c,u)}return{roots:(f.get(void 0)??[]).map(y),byId:p}}function XXn(o){return o.fromFile===void 0&&o.toFile===void 0}function KXn(o){return o.edges.filter(XXn).map(c=>{let u={id:c.id,sources:[c.from],targets:[c.to]};return c.label!==void 0&&c.label.length>0&&(u.labels=[{text:c.label,width:Math.ceil(cne(c.label,5.9)),height:14}]),u})}function Gm(o){return o??0}function Dsn(o,c){let u=c.get(o.id);if(!u)throw new Error(`ELK returned unknown node id "${o.id}"`);let p=(o.children??[]).map(f=>Dsn(f,c));return{...u,x:Gm(o.x),y:Gm(o.y),width:Gm(o.width),height:Gm(o.height),children:p}}function YXn(o,c){let u=new Map,p=new Map,f=(T,R,F,B)=>{let V=R+Gm(T.x),se=F+Gm(T.y);u.set(T.id,{x:V,y:se}),p.set(T.id,B);let ee=[...B,T.id];for(let ce of T.children??[])f(ce,V,se,ee)};f(o,0,0,[]);let y=(T,R)=>{let F=p.get(T)??[],B=p.get(R)??[],V=0;for(;V<F.length&&V<B.length&&F[V]===B[V];)V++;let se=V===0?o.id:F[V-1];return u.get(se)??{x:0,y:0}},w=new Map,v=new Map,_=T=>{for(let R of T.edges??[]){let F=R.sources?.[0]??"",B=R.targets?.[0]??"",V=y(F,B),se=ge=>({x:Gm(ge.x)+V.x,y:Gm(ge.y)+V.y}),ee=(R.sections??[]).map(ge=>({startPoint:se(ge.startPoint),endPoint:se(ge.endPoint),bendPoints:(ge.bendPoints??[]).map(se)}));w.set(R.id,ee);let ce=(R.labels??[]).map(ge=>({text:typeof ge.text=="string"?ge.text:"",x:Gm(ge.x)+V.x,y:Gm(ge.y)+V.y,width:Gm(ge.width),height:Gm(ge.height)}));v.set(R.id,ce)}for(let R of T.children??[])_(R)};return _(o),c.edges.map(T=>({...T,sections:w.get(T.id)??[],labels:v.get(T.id)??[]}))}var QXn=new Rsn.default;async function eKn(o,c={}){if(o.nodes.length===0)return{document:o,width:0,height:0,roots:[],edges:[]};let u=c.viewMode==="compact"?"compact":"detailed",p=u==="compact"?qXn:UXn,{roots:f,byId:y}=ZXn(o,p,u),w={id:"__root__",layoutOptions:HXn(c),children:f,edges:KXn(o)},v=await QXn.layout(w),_=(v.children??[]).map(T=>Dsn(T,y));return{document:o,width:Gm(v.width),height:Gm(v.height),roots:_,edges:YXn(v,o)}}var Oye={name:"elk",layout:eKn};var Ili={[Oye.name]:Oye},tKn=Oye;function TG(o,c){return tKn.layout(o,c)}function Osn(o,c,u){let p=new Map,f=(v,_)=>{let T=p.get(v)??new Set;T.add(_),p.set(v,T)};for(let v of o)f(v.from,v.to),f(v.to,v.from);let y=new Set([c]),w=new Set([c]);for(let v=0;v<u;v++){let _=new Set;for(let T of w)for(let R of p.get(T)??[])y.has(R)||(y.add(R),_.add(R));if(_.size===0)break;w=_}return y}function Fsn(o,c,u){let p=o.flatMap(v=>v.doc.edges),f=Osn(p,c,u),y=[],w=[];for(let{doc:v,relPath:_}of o){for(let T of v.nodes)f.has(T.id)&&y.push({node:T,relPath:_});for(let T of v.edges)f.has(T.from)&&f.has(T.to)&&w.push({edge:T,relPath:_})}return{nodes:y,edges:w}}function zsn(o,c,u){let p=Osn(o.edges,c,u);return{...o,nodes:o.nodes.filter(f=>p.has(f.id)).map(f=>f.parentId!==void 0&&!p.has(f.parentId)?(({parentId:y,...w})=>w)(f):f),edges:o.edges.filter(f=>p.has(f.from)&&p.has(f.to))}}function $sn(o,c){let u=new Set(c.hideRel??[]),p=c.onlyRel?new Set(c.onlyRel):null,f=o.edges.filter(y=>!(p&&!p.has(y.relationship)||u.has(y.relationship)||c.hideStructural&&Kin(y.relationship)==="structural"));return{...o,edges:f}}function nKn(o){return Math.max(160,o.length*8+80)}function jsn(o,c,u,p,f,y=0){let w=u,v=[],_=Number.POSITIVE_INFINITY,T=Number.NEGATIVE_INFINITY;for(let R of o)if(R.type==="message"){let F=c.get(R.from),B=c.get(R.to),V=F?.cx??p,se=B?.cx??p;v.push({type:"message",id:R.id,fromCx:V,toCx:se,y:w,label:R.label,arrow:R.arrow,activate:R.activate??!1,isSelf:R.from===R.to,...R.status!==void 0?{status:R.status}:{}}),w+=R.from===R.to?56*1.5:56}else if(R.type==="note"){let F=R.participants.map(ce=>c.get(ce)?.cx).filter(ce=>ce!==void 0).sort((ce,ge)=>ce-ge),B=F[0]??p,V=F[F.length-1]??f,se=Math.min(Math.max(R.text.length*7.5+24,V-B+16,80),400),ee;R.position==="left_of"?ee=B-se-8:R.position==="right_of"?ee=V+8:ee=(B+V)/2-se/2,_=Math.min(_,ee),T=Math.max(T,ee+se),v.push({type:"note",id:R.id,x:ee,y:w,width:se,height:64,text:R.text,...R.status!==void 0?{status:R.status}:{}}),w+=72}else if(R.type==="group"){let F=Math.min(y*6,12),B=p-12+F,V=f-p+24-F*2,se=w;w+=24;let ee=[];if(R.branches)for(let ce=0;ce<R.branches.length;ce++){let ge=R.branches[ce],Oe=w,{items:ut,endY:Se,contentMinX:je,contentMaxX:Be}=jsn(ge.steps,c,w,p,f,y+1);w=Se,_=Math.min(_,je),T=Math.max(T,Be),ee.push({...ge.label!==void 0?{label:ge.label}:{},startY:Oe,...ce<R.branches.length-1?{dividerY:w}:{},steps:ut}),ce<R.branches.length-1&&(w+=4)}w+=12,v.push({type:"group",id:R.id,kind:R.kind,...R.condition!==void 0?{condition:R.condition}:{},...R.label!==void 0?{label:R.label}:{},...R.seqFile!==void 0?{seqFile:R.seqFile}:{},x:B,y:se,width:V,height:w-se,branches:ee,...R.status!==void 0?{status:R.status}:{}}),_=Math.min(_,B),T=Math.max(T,B+V),w+=20}return{items:v,endY:w,contentMinX:_,contentMaxX:T}}function Bsn(o){let c=new Map;for(let u of o)if(u.type==="message"&&u.arrow==="destroy"&&c.set(u.toCx,u.y+56+20),u.type==="group")for(let p of u.branches)for(let[f,y]of Bsn(p.steps))c.set(f,y);return c}function rKn(o){let c=[],u=new Map;function p(f){for(let y of f)if(y.type==="message"){if(y.activate&&y.arrow==="sync"&&!y.isSelf){let w=u.get(y.toCx)??[];w.push(y.y),u.set(y.toCx,w)}if(y.arrow==="return"&&!y.isSelf){let w=u.get(y.fromCx);if(w&&w.length>0){let v=w.pop();c.push({cx:y.fromCx,startY:v,endY:y.y}),w.length===0&&u.delete(y.fromCx)}}}else if(y.type==="group")for(let w of y.branches)p(w.steps)}p(o);for(let[f,y]of u)for(let w of y)c.push({cx:f,startY:w,endY:w+56/2});return c}function Hsn(o,c){let u=o.participants.map(tn=>nKn(tn.label??tn.nodeId)),p=32,f=o.participants.map((tn,Gt)=>{let xn=u[Gt],Vn=p+xn/2;p+=xn;let nn=c?.get(tn.nodeId);return{id:tn.id,nodeId:tn.nodeId,label:tn.label??tn.nodeId,cx:Vn,colWidth:xn,...nn!==void 0?{kind:nn}:{},...tn.status!==void 0?{status:tn.status}:{},lifelineEndY:0}}),y=p+32,w=new Map(f.map(tn=>[tn.id,tn])),v=f[0]?.cx??32,_=f[f.length-1]?.cx??y-32,T=24,{items:R,endY:F,contentMinX:B,contentMaxX:V}=jsn(o.steps,w,T,v,_),se=B<32&&Number.isFinite(B)?32-B:0,ee=Number.isFinite(V)?V+se+32:0,ce=Math.max(y+se,ee),ge=se>0?R.map(tn=>Usn(tn,se)):R,Oe=se>0?f.map(tn=>({...tn,cx:tn.cx+se})):f,ut=Bsn(ge),Se=Oe.map(tn=>({...tn,lifelineEndY:ut.get(tn.cx)??56+F+24})),je=56+F+24,Be=rKn(ge);return{participants:Se,steps:ge,activations:Be,totalWidth:ce,totalHeight:je}}function Usn(o,c){return o.type==="message"?{...o,fromCx:o.fromCx+c,toCx:o.toCx+c}:o.type==="note"?{...o,x:o.x+c}:{...o,x:o.x+c,branches:o.branches.map(u=>({...u,steps:u.steps.map(p=>Usn(p,c))}))}}var ci=mi(s2t(),1);var D3=mi(hc(),1),Ysn=(o,c,u)=>({width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:c,strokeWidth:u,strokeLinecap:"round",strokeLinejoin:"round"});function Qsn({size:o=16,color:c="currentColor",strokeWidth:u=1.8}){return(0,D3.jsxs)("svg",{...Ysn(o,c,u),"aria-hidden":"true",children:[(0,D3.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3.5",ry:"3.5"}),(0,D3.jsx)("line",{x1:"9",y1:"9",x2:"9",y2:"13"}),(0,D3.jsx)("line",{x1:"15",y1:"9",x2:"15",y2:"13"}),(0,D3.jsx)("circle",{cx:"12",cy:"16.5",r:"1",fill:c,stroke:"none"})]})}function eln({size:o=16,color:c="currentColor",strokeWidth:u=1.8}){return(0,D3.jsxs)("svg",{...Ysn(o,c,u),"aria-hidden":"true",children:[(0,D3.jsx)("path",{d:"M 7.5 6 L 3.5 12 L 7.5 18"}),(0,D3.jsx)("path",{d:"M 16.5 6 L 20.5 12 L 16.5 18"}),(0,D3.jsx)("circle",{cx:"13",cy:"8.6",r:"0.9",fill:c,stroke:"none"}),(0,D3.jsx)("line",{x1:"13",y1:"11",x2:"11",y2:"16.5"})]})}var Vm={service:{color:"#38bdf8",icon:ci.Server,description:"Long-running compute that owns business logic."},function:{color:"#22d3ee",icon:ci.FunctionSquare,description:"Stateless function-as-a-service / lambda."},worker:{color:"#06b6d4",icon:ci.Cog,description:"Background job processor or consumer loop."},agent:{color:"#14b8a6",icon:ci.Bot,description:"Autonomous AI agent driving tools and actions."},database:{color:"#34d399",icon:ci.Database,description:"Persistent state \u2014 relational, document, key-value."},cache:{color:"#a78bfa",icon:ci.Layers,description:"In-memory store for fast reads."},vectordb:{color:"#c084fc",icon:ci.Sparkles,description:"Vector store for embeddings / similarity search."},storage:{color:"#84cc16",icon:ci.HardDrive,description:"Object / blob storage (S3, GCS, etc.)."},model:{color:"#2dd4bf",icon:ci.Shapes,description:"Domain model \u2014 rich business object with behavior."},dto:{color:"#4ade80",icon:ci.FileJson2,description:"Data transfer object \u2014 shape crossing a boundary."},dataobject:{color:"#86efac",icon:ci.Braces,description:"Plain data structure / record, no behavior."},queue:{color:"#fbbf24",icon:ci.SendHorizontal,description:"Asynchronous work queue with at-least-once delivery."},topic:{color:"#f97316",icon:ci.Radio,description:"Pub/sub topic with multiple consumers."},stream:{color:"#fb923c",icon:ci.Waves,description:"Append-only event log (Kafka, Kinesis)."},gateway:{color:"#6366f1",icon:ci.DoorOpen,description:"API gateway, ingress, edge router."},cdn:{color:"#0ea5e9",icon:ci.Globe,description:"Content delivery network / static edge."},route:{color:"#f59e0b",icon:ci.Route,description:"HTTP / URL route \u2014 path + method mapped to a handler."},interface:{color:"#d946ef",icon:eln,description:"Abstract contract \u2014 the <i> a system commits to."},adapter:{color:"#c026d3",icon:ci.Cable,description:"Concrete implementation of an interface."},port:{color:"#a21caf",icon:Qsn,description:"Hexagonal-architecture port \u2014 the socket an adapter plugs into."},llm:{color:"#a855f7",icon:ci.Brain,description:"Large language model service."},prompt:{color:"#c4b5fd",icon:ci.MessageSquare,description:"Prompt template / instruction set."},tool:{color:"#fde047",icon:ci.Wrench,description:"Tool callable by an agent or LLM."},auth:{color:"#ef4444",icon:ci.Lock,description:"Identity provider, auth service."},observability:{color:"#10b981",icon:ci.Eye,description:"Metrics, logs, traces \u2014 operational telemetry."},cloud:{color:"#0284c7",icon:ci.Cloud,description:"Managed cloud service (compute, hosted, etc.)."},frontend:{color:"#f472b6",icon:ci.Monitor,description:"User-facing surface \u2014 browser, mobile, CLI."},page:{color:"#fb7185",icon:ci.LayoutTemplate,description:"Route-level UI screen mapped to a URL."},component:{color:"#8b5cf6",icon:ci.Component,description:"Reusable UI component / view fragment."},store:{color:"#facc15",icon:ci.Boxes,description:"Client-side state container \u2014 Redux, Zustand, Pinia."},hook:{color:"#0d9488",icon:ci.Anchor,description:"Reusable client logic \u2014 React hook, Vue composable."},external:{color:"#94a3b8",icon:ci.ExternalLink,description:"Third-party system you don't own."},human:{color:"#60a5fa",icon:ci.UserRound,description:"Human actor \u2014 end user, operator, or customer."},module:{color:"#7dd3fc",icon:ci.Package,description:"Module / component grouping (logical container)."},custom:{color:"#64748b",icon:ci.Box,description:"Container or anything not in the taxonomy."}};var Kz=mi(hc(),1),WOe=36,z6r=128,$6r=7,tln=20,nln=24;function rln({participant:o,nodeKind:c}){let u=c?Vm[c]:void 0,p=u?.color??"var(--archik-fg-muted)",f=(56-WOe)/2,y=u?.icon,w=Math.max(z6r,o.label.length*$6r+nln+(y?tln:0)),v=w/2,_=y?v+tln/2:v,T=o.status,R=T==="proposed"?.55:T==="deprecated"?.35:1,F=T==="proposed"||T==="deprecated"?"4 3":void 0;return(0,Kz.jsxs)("g",{transform:`translate(${o.cx-v}, ${f})`,opacity:R,children:[(0,Kz.jsx)("rect",{width:w,height:WOe,rx:8,fill:"var(--archik-node-fill)",stroke:p,strokeWidth:1.4,...F!==void 0?{strokeDasharray:F}:{}}),y&&(0,Kz.jsx)("g",{transform:`translate(${nln/2}, ${(WOe-14)/2})`,children:(0,Kz.jsx)(y,{size:14,color:p,strokeWidth:1.5})}),(0,Kz.jsx)("text",{x:_,y:WOe/2+4,textAnchor:"middle",fontSize:12,fontWeight:500,fill:"var(--archik-fg)",fontFamily:"inherit",children:o.label})]})}var oln=mi(hc(),1);function iln({participant:o}){let c=o.status,u=c==="proposed"?.3:c==="deprecated"?.2:.5;return(0,oln.jsx)("line",{x1:o.cx,y1:56,x2:o.cx,y2:o.lifelineEndY,stroke:"var(--archik-node-stroke)",strokeWidth:1,strokeDasharray:"4 4",opacity:u})}function u2t(o,c){let u=o.x-c.x,p=o.y-c.y,f=Math.hypot(u,p);if(f<.01)return null;let y=u/f,w=p/f;return{ux:y,uy:w,px:-w,py:y,len:f}}var n0=o=>String(Math.round(o*100)/100);function AG(o,c,u=10,p=4){let f=u2t(o,c);if(!f)return"";let y=o.x-f.ux*u,w=o.y-f.uy*u;return`M ${n0(y+f.px*p)} ${n0(w+f.py*p)} L ${n0(o.x)} ${n0(o.y)} L ${n0(y-f.px*p)} ${n0(w-f.py*p)} Z`}function JOe(o,c,u=10,p=4.5){let f=u2t(o,c);if(!f)return"";let y=o.x-f.ux*u,w=o.y-f.uy*u;return`M ${n0(y+f.px*p)} ${n0(w+f.py*p)} L ${n0(o.x)} ${n0(o.y)} L ${n0(y-f.px*p)} ${n0(w-f.py*p)}`}function cln(o,c,u=14,p=6){return AG(o,c,u,p)}function aln(o,c,u=14,p=4.5){let f=u2t(c,o);if(!f)return"";let y=o.x+f.ux*(u/2),w=o.y+f.uy*(u/2),v=o.x+f.ux*u,_=o.y+f.uy*u;return`M ${n0(o.x)} ${n0(o.y)} L ${n0(y+f.px*p)} ${n0(w+f.py*p)} L ${n0(v)} ${n0(_)} L ${n0(y-f.px*p)} ${n0(w-f.py*p)} Z`}var Rv=mi(hc(),1),ZOe=32,lne=20,j6r=-6,XOe="var(--archik-edge-filled)";function sln({msg:o}){let c=o.arrow==="return",u=o.arrow==="async",p=o.arrow==="create",f=c||p,y=o.arrow==="destroy",w=c||u,v=o.status==="proposed"?.5:o.status==="deprecated"?.35:1,_=(B,V)=>w?(0,Rv.jsx)("path",{"data-archik-arrowhead":"end",d:JOe(B,V),fill:"none",stroke:XOe,strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"}):(0,Rv.jsx)("path",{"data-archik-arrowhead":"end",d:AG(B,V),fill:XOe});if(o.isSelf){let B=o.fromCx,V=o.y,se=`M ${B} ${V} L ${B+ZOe} ${V} L ${B+ZOe} ${V+lne} L ${B} ${V+lne}`;return(0,Rv.jsxs)("g",{opacity:v,children:[(0,Rv.jsx)("path",{d:se,fill:"none",stroke:XOe,strokeWidth:1.4}),_({x:B,y:V+lne},{x:B+ZOe,y:V+lne}),(0,Rv.jsx)("text",{x:B+ZOe+6,y:V+lne/2+4,fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:o.label})]})}let R=o.fromCx<o.toCx?o.toCx-6:o.toCx+6,F=(o.fromCx+o.toCx)/2;return(0,Rv.jsxs)("g",{opacity:v,children:[(0,Rv.jsx)("line",{x1:o.fromCx,y1:o.y,x2:R,y2:o.y,stroke:XOe,strokeWidth:1.4,strokeDasharray:f?"4 4":void 0}),!y&&_({x:o.toCx,y:o.y},{x:o.fromCx,y:o.y}),(0,Rv.jsxs)("text",{x:F,y:o.y+j6r,textAnchor:"middle",fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:[p&&"\xABcreate\xBB ",o.label]}),o.arrow==="destroy"&&(0,Rv.jsxs)("g",{transform:`translate(${o.toCx-6}, ${o.y-6})`,children:[(0,Rv.jsx)("line",{x1:0,y1:0,x2:12,y2:12,stroke:"var(--archik-fg-muted)",strokeWidth:1.5}),(0,Rv.jsx)("line",{x1:12,y1:0,x2:0,y2:12,stroke:"var(--archik-fg-muted)",strokeWidth:1.5})]})]})}var Y9=mi(hc(),1),B6r={alt:"#6366f1",opt:"#0ea5e9",loop:"#10b981",par:"#f59e0b",break:"#ef4444",ref:"#8b5cf6"},lln=36,d2t=18;function uln({group:o,renderStep:c,onRefClick:u}){let p=B6r[o.kind]??"var(--archik-fg-muted)",f=o.status==="proposed"?.55:o.status==="deprecated"?.35:1,y=o.kind==="ref"&&o.seqFile!==void 0&&u!==void 0;return(0,Y9.jsxs)("g",{opacity:f,onClick:y?()=>u(o.seqFile):void 0,style:y?{cursor:"pointer"}:void 0,children:[(0,Y9.jsx)("rect",{x:o.x,y:o.y,width:o.width,height:o.height,rx:4,fill:"none",stroke:p,strokeWidth:1.2,opacity:.6}),(0,Y9.jsx)("rect",{x:o.x,y:o.y,width:lln,height:d2t,rx:4,fill:p,opacity:.8}),(0,Y9.jsx)("text",{x:o.x+6,y:o.y+d2t-5,fontSize:10,fontWeight:600,fill:"#fff",fontFamily:"inherit",children:o.kind}),(o.condition??o.label)&&(0,Y9.jsx)("text",{x:o.x+lln+6,y:o.y+d2t-5,fontSize:10,fill:p,fontFamily:"inherit",children:o.condition??o.label}),o.branches.map((w,v)=>(0,Y9.jsxs)("g",{children:[w.label&&(0,Y9.jsx)("text",{x:o.x+6,y:w.startY+12,fontSize:10,fill:p,fontFamily:"inherit",children:w.label}),w.steps.map(_=>c(_)),w.dividerY!==void 0&&(0,Y9.jsx)("line",{x1:o.x,y1:w.dividerY,x2:o.x+o.width,y2:w.dividerY,stroke:p,strokeWidth:1,strokeDasharray:"4 2",opacity:.5})]},v))]})}var NG=mi(hc(),1);function H6r(o,c){let u=Math.max(10,Math.floor(c/6.5));if(o.length<=u)return[o];let p=o.split(" "),f=[],y="";for(let w of p)(y+(y?" ":"")+w).length>u&&y?(f.push(y),y=w):y=y?y+" "+w:w;return y&&f.push(y),f.slice(0,3)}function dln({note:o}){let{x:c,y:u,width:p,height:f,text:y}=o,w=o.status==="proposed"?.55:o.status==="deprecated"?.35:1;return(0,NG.jsxs)("g",{opacity:w,children:[(0,NG.jsx)("path",{d:`M ${c} ${u} L ${c+p-10} ${u} L ${c+p} ${u+10} L ${c+p} ${u+f} L ${c} ${u+f} Z`,fill:"var(--archik-node-fill)",stroke:"var(--archik-node-stroke)",strokeWidth:1.2}),(0,NG.jsx)("path",{d:`M ${c+p-10} ${u} L ${c+p-10} ${u+10} L ${c+p} ${u+10}`,fill:"none",stroke:"var(--archik-node-stroke)",strokeWidth:1.2}),H6r(y,p-16).map((v,_)=>(0,NG.jsx)("text",{x:c+8,y:u+8+11+_*13,fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:v},_))]})}var O3=mi(hc(),1);function fln({step:o,onRefClick:c}){return o.type==="message"?(0,O3.jsx)(sln,{msg:o}):o.type==="note"?(0,O3.jsx)(dln,{note:o}):o.type==="group"?(0,O3.jsx)(uln,{group:o,...c!==void 0?{onRefClick:c}:{},renderStep:u=>(0,O3.jsx)(fln,{step:u,...c!==void 0?{onRefClick:c}:{}},u.id)}):null}function pln({laid:o,svgRef:c,onRefClick:u}){let{participants:p,steps:f,activations:y,totalWidth:w,totalHeight:v}=o;return(0,O3.jsxs)("svg",{ref:c,width:w,height:v,viewBox:`0 0 ${w} ${v}`,xmlns:"http://www.w3.org/2000/svg",style:{fontFamily:"var(--archik-font, system-ui)"},children:[p.map(_=>(0,O3.jsx)(iln,{participant:_},_.id)),p.map(_=>(0,O3.jsx)(rln,{participant:_,..._.kind!==void 0?{nodeKind:_.kind}:{}},_.id)),(0,O3.jsxs)("g",{transform:`translate(0, ${56})`,children:[y.map(_=>(0,O3.jsx)("rect",{x:_.cx-8/2,y:_.startY,width:8,height:_.endY-_.startY,fill:"var(--archik-node-fill)",stroke:"var(--archik-node-stroke)",strokeWidth:1,rx:2},`${_.cx}-${_.startY}`)),f.map(_=>(0,O3.jsx)(fln,{step:_,...u!==void 0?{onRefClick:u}:{}},_.id))]})]})}var HE=mi(hc(),1),r0=28;function RG({kind:o,iconAt:c,labelAt:u}){let p=Vm[o],f=p.icon,y=14;return(0,HE.jsxs)(HE.Fragment,{children:[(0,HE.jsx)("g",{transform:`translate(${c.cx-y/2}, ${c.cy-y/2})`,pointerEvents:"none","aria-hidden":"true",children:(0,HE.jsx)(f,{size:y,color:p.color,strokeWidth:1.8})}),(0,HE.jsx)("text",{x:u.cx,y:u.cy,textAnchor:"middle",fontSize:9.5,fontWeight:600,letterSpacing:"0.12em",fill:"var(--archik-node-caption)",children:o.toUpperCase()})]})}var UE=mi(hc(),1),U6r=24;function gln({node:o,selected:c}){let u=o.width,p=o.height,f=o.stack!==void 0,y=r0+(p-r0)/2,w=f?y-4:y+4,v=y+14,_=Math.max(0,u-U6r),T=t0(o.name,_,7.4),R=f?t0(o.stack,_,5.9):"";return(0,UE.jsxs)("g",{className:`archik-node archik-node--${o.kind}`,children:[(0,UE.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:u,height:p,rx:10,ry:10,fill:"var(--archik-node-fill)",stroke:c?"var(--archik-selected)":"var(--archik-node-stroke)",strokeWidth:c?1.8:1.4}),(0,UE.jsx)("line",{x1:0,y1:r0,x2:u,y2:r0,stroke:"var(--archik-node-stroke)",strokeOpacity:.25,strokeWidth:1}),(0,UE.jsx)(RG,{kind:o.kind,iconAt:{cx:18,cy:r0/2},labelAt:{cx:u/2,cy:r0/2+3}}),(0,UE.jsx)("text",{x:u/2,y:w,textAnchor:"middle",fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:T}),f&&(0,UE.jsx)("text",{x:u/2,y:v,textAnchor:"middle",fontSize:11,fill:"var(--archik-node-text-dim)",children:R})]})}var qE=mi(hc(),1);function yln({node:o,selected:c}){let u=o.width,p=o.height,f=Math.min(p/2,28),y=o.stack!==void 0,w=r0+(p-r0)/2,v=y?w-4:w+4,_=w+14,T=Math.max(0,u-2*f-8),R=t0(o.name,T,7.4),F=y?t0(o.stack,T,5.9):"",B=c?"var(--archik-selected)":"var(--archik-node-stroke)";return(0,qE.jsxs)("g",{className:"archik-node archik-node--queue",children:[(0,qE.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:u,height:p,rx:f,ry:f,fill:"var(--archik-node-fill)",stroke:B,strokeWidth:c?1.8:1.4}),(0,qE.jsx)("line",{x1:f,y1:r0,x2:u-f,y2:r0,stroke:B,strokeOpacity:.25,strokeWidth:1}),(0,qE.jsx)(RG,{kind:"queue",iconAt:{cx:f+8,cy:r0/2},labelAt:{cx:u/2,cy:r0/2+3}}),(0,qE.jsx)("text",{x:u/2,y:v,textAnchor:"middle",fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:R}),y&&(0,qE.jsx)("text",{x:u/2,y:_,textAnchor:"middle",fontSize:11,fill:"var(--archik-node-text-dim)",children:F})]})}var GE=mi(hc(),1),q6r=24;function bln({node:o,selected:c}){let u=o.width,p=o.height,f=o.description!==void 0,y=r0,w=y+(p-y)/2,v=f?w-2:w+4,_=p-12,T=Math.max(0,u-q6r),R=t0(o.name,T,7.4),F=f?t0(o.description,T,5.9):"",B=c?"var(--archik-selected)":"var(--archik-node-stroke-soft)";return(0,GE.jsxs)("g",{className:`archik-node archik-node--${o.kind}`,children:[(0,GE.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:u,height:p,rx:8,ry:8,fill:"var(--archik-node-fill-tinted)",stroke:B,strokeWidth:c?1.8:1.2,strokeDasharray:c?void 0:"6 4"}),(0,GE.jsx)("line",{x1:6,y1:r0,x2:u-6,y2:r0,stroke:B,strokeOpacity:.25,strokeWidth:1}),(0,GE.jsx)(RG,{kind:o.kind,iconAt:{cx:18,cy:r0/2},labelAt:{cx:u/2,cy:r0/2+3}}),(0,GE.jsx)("text",{x:u/2,y:v,textAnchor:"middle",fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:R}),f&&(0,GE.jsx)("text",{x:u/2,y:_,textAnchor:"middle",fontSize:10,fill:"var(--archik-node-text-dim)",children:F})]})}var h6=mi(hc(),1),G6r=28,h2t=10,V6r=22;function mln({node:o,selected:c}){let u=o.width,p=o.height,f=u/2,y=h2t,w=Vm[o.kind],v=w.icon,_=c?"var(--archik-selected)":"var(--archik-node-stroke)",T=c?1.8:1.4,R=o.stack!==void 0,F=Math.max(0,u-G6r),B=t0(o.name,F,7.4),V=R?t0(o.stack,F,5.9):"",se=p,ee=se-V6r,ce=(ee+se)/2,ut=(y+8+ee)/2,Se=R?ut-4:ut+4,je=ut+14;return(0,h6.jsxs)("g",{className:"archik-node archik-node--database",children:[(0,h6.jsx)("path",{className:c?"archik-selected-glow":void 0,d:f2t(u,p,y),fill:"var(--archik-node-fill)",stroke:_,strokeWidth:T,strokeLinejoin:"round"}),(0,h6.jsx)("ellipse",{cx:f,cy:y,rx:u/2,ry:y,fill:"var(--archik-node-fill)",stroke:_,strokeWidth:T}),(0,h6.jsx)("text",{x:f,y:Se,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"var(--archik-node-text)",children:B}),R&&(0,h6.jsx)("text",{x:f,y:je,textAnchor:"middle",fontSize:11,fill:"var(--archik-node-text-dim)",children:V}),(0,h6.jsx)("line",{x1:4,y1:ee,x2:u-4,y2:ee,stroke:_,strokeOpacity:.45,strokeWidth:1}),(0,h6.jsx)("g",{transform:`translate(14, ${ce-7})`,pointerEvents:"none","aria-hidden":"true",children:(0,h6.jsx)(v,{size:14,color:w.color,strokeWidth:1.9})}),(0,h6.jsx)("text",{x:f,y:ce+4,textAnchor:"middle",fontSize:9.5,fontWeight:600,letterSpacing:"0.12em",fill:"var(--archik-node-caption)",children:o.kind.toUpperCase()})]})}var W6r=10;function f2t(o,c,u){let p=W6r;return[`M 0 ${u}`,`L 0 ${c-p}`,`A ${p} ${p} 0 0 0 ${p} ${c}`,`L ${o-p} ${c}`,`A ${p} ${p} 0 0 0 ${o} ${c-p}`,`L ${o} ${u}`,`A ${o/2} ${u} 0 0 0 0 ${u}`,"Z"].join(" ")}var bS=mi(hc(),1),J6r=36,wln=18;function vln({node:o,selected:c}){let u=o.width,p=o.height,f=Vm[o.kind],y=f.icon,w=c?"var(--archik-selected)":"var(--archik-node-stroke)",v=c?1.8:1.4,_=o.stack!==void 0,T=Math.max(0,u-J6r),R=t0(o.name,T,7.4),F=_?t0(o.stack,T,5.9):"",B=u/2,V=p*.55,se=_?V-4:V+4,ee=V+14;return(0,bS.jsxs)("g",{className:"archik-node archik-node--cloud",children:[(0,bS.jsx)("path",{className:c?"archik-selected-glow":void 0,d:Z6r(u,p),fill:"var(--archik-node-fill)",stroke:w,strokeWidth:v,strokeLinejoin:"round"}),(0,bS.jsx)("g",{transform:`translate(18, ${wln-6})`,pointerEvents:"none","aria-hidden":"true",children:(0,bS.jsx)(y,{size:14,color:f.color,strokeWidth:1.9})}),(0,bS.jsx)("text",{x:B,y:wln+4,textAnchor:"middle",fontSize:9.5,fontWeight:600,letterSpacing:"0.12em",fill:"var(--archik-node-caption)",children:o.kind.toUpperCase()}),(0,bS.jsx)("text",{x:B,y:se,textAnchor:"middle",fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:R}),_&&(0,bS.jsx)("text",{x:B,y:ee,textAnchor:"middle",fontSize:11,fill:"var(--archik-node-text-dim)",children:F})]})}function Z6r(o,c){let p=c-2,f=c*.62,y=Math.min(c*.18,14),w=o-4,v=c*.5,_=Math.min(w*.15,v*.85),T=Math.min(w*.18,v),R=Math.min(w*.15,v*.85),F=2*(_+T+R),B=Math.max(0,w-F)/4,V=2,se=o-2,ee=V+B,ce=ee+2*_,ge=ce+B,Oe=ge+2*T,ut=Oe+B,Se=ut+2*R;return[`M ${V} ${p-y}`,`Q ${V} ${p} ${V+y} ${p}`,`L ${se-y} ${p}`,`Q ${se} ${p} ${se} ${p-y}`,`L ${se} ${f}`,`L ${Se} ${f}`,`A ${R} ${R} 0 0 0 ${ut} ${f}`,`L ${Oe} ${f}`,`A ${T} ${T} 0 0 0 ${ge} ${f}`,`L ${ce} ${f}`,`A ${_} ${_} 0 0 0 ${ee} ${f}`,`L ${V} ${f}`,"Z"].join(" ")}var hb=mi(hc(),1),DG=32,KOe=14,p2t=14;function kln({node:o,selected:c,depth:u=0}){let p=o.width,f=o.height;if(!(o.children.length>0))return(0,hb.jsx)(K6r,{node:o,selected:!!c});let w=Vm[o.kind],v=w.icon,_=Math.min(.04+u*.06,.22),T=Math.min(.55+u*.12,.95),R=c?"var(--archik-selected)":"var(--archik-container-border)",F=c?1.8:1.2,B=Math.max(0,p-KOe*2-60),V=t0(o.name,B,7.4);return(0,hb.jsxs)("g",{className:`archik-node archik-node--${o.kind} archik-node--container`,children:[(0,hb.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:p,height:f,rx:8,ry:8,fill:w.color,fillOpacity:_,stroke:R,strokeWidth:F,pointerEvents:"none"}),u>=1&&p>8&&f>8&&(0,hb.jsx)("rect",{x:3,y:3,width:p-6,height:f-6,rx:6,ry:6,fill:"none",stroke:w.color,strokeOpacity:Math.min(.18+(u-1)*.06,.32),strokeWidth:1,pointerEvents:"none"}),(0,hb.jsx)("path",{d:X6r(p,DG,8),fill:w.color,fillOpacity:T*.18}),(0,hb.jsx)("line",{x1:0,y1:DG,x2:p,y2:DG,stroke:R,strokeOpacity:.45,strokeWidth:1}),(0,hb.jsx)("g",{transform:`translate(${KOe}, ${DG/2-p2t/2})`,pointerEvents:"none","aria-hidden":"true",children:(0,hb.jsx)(v,{size:p2t,color:w.color,strokeWidth:1.9})}),(0,hb.jsx)("text",{x:KOe+p2t+8,y:DG/2+4,fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:V}),(0,hb.jsx)("text",{x:p-KOe,y:DG/2+3,textAnchor:"end",fontSize:9.5,fontWeight:600,letterSpacing:"0.12em",fill:"var(--archik-node-caption)",children:o.kind.toUpperCase()})]})}function X6r(o,c,u){return`M ${u} 0 H ${o-u} A ${u} ${u} 0 0 1 ${o} ${u} V ${c} H 0 V ${u} A ${u} ${u} 0 0 1 ${u} 0 Z`}function K6r({node:o,selected:c}){let u=o.width,p=o.height,f=Vm[o.kind],y=c?"var(--archik-selected)":"var(--archik-node-stroke-soft)";return(0,hb.jsxs)("g",{className:`archik-node archik-node--${o.kind}`,children:[(0,hb.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:u,height:p,rx:8,ry:8,fill:"var(--archik-node-fill-tinted)",stroke:y,strokeWidth:c?1.8:1.2,strokeDasharray:c?void 0:"5 4"}),(0,hb.jsx)("text",{x:u/2,y:p/2+4,textAnchor:"middle",fontSize:12,fontWeight:600,fill:f.color,children:o.name})]})}var fb=mi(hc(),1),une=24,Mln=10,g2t=28;function xln({node:o,selected:c,depth:u=0}){let p=o.width,f=o.height,y=Vm[o.kind],w=y.icon,v=o.kind==="external";if(o.children.length>0)return(0,fb.jsx)(Y6r,{node:o,selected:!!c,depth:u});let _=c?"var(--archik-selected)":v?"var(--archik-node-stroke-soft)":"var(--archik-node-stroke)",T=v?"var(--archik-node-fill-tinted)":"var(--archik-node-fill)",R=o.kind==="queue"?Math.min(f/2,18):8;return(0,fb.jsxs)("g",{className:`archik-node archik-node--${o.kind} archik-node--compact`,children:[(0,fb.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:p,height:f,rx:R,ry:R,fill:T,stroke:_,strokeWidth:c?1.8:1.4,strokeDasharray:v&&!c?"5 4":void 0}),(0,fb.jsx)("g",{transform:`translate(${Mln}, ${f/2-7})`,pointerEvents:"none","aria-hidden":"true",children:(0,fb.jsx)(w,{size:13,color:y.color,strokeWidth:1.9})}),(0,fb.jsx)("text",{x:g2t,y:f/2+4,fontSize:12,fontWeight:600,fill:"var(--archik-node-text)",children:t0(o.name,Math.max(0,p-g2t-8),5.9)})]})}function Y6r({node:o,selected:c,depth:u}){let p=o.width,f=o.height,y=Vm[o.kind],w=y.icon,v=Math.min(.04+u*.035,.14),_=Math.min(.55+u*.08,.85),T=c?"var(--archik-selected)":"var(--archik-container-border)",R=Math.max(0,p-12-22),F=t0(o.name,R,5.9);return(0,fb.jsxs)("g",{className:`archik-node archik-node--${o.kind} archik-node--compact archik-node--container`,children:[(0,fb.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:p,height:f,rx:6,ry:6,fill:y.color,fillOpacity:v,stroke:T,strokeWidth:c?1.8:1.2}),(0,fb.jsx)("path",{d:Q6r(p,une,6),fill:y.color,fillOpacity:_*.18}),(0,fb.jsx)("line",{x1:0,y1:une,x2:p,y2:une,stroke:T,strokeOpacity:.45,strokeWidth:1}),(0,fb.jsx)("g",{transform:`translate(${Mln}, ${une/2-6})`,pointerEvents:"none","aria-hidden":"true",children:(0,fb.jsx)(w,{size:12,color:y.color,strokeWidth:1.9})}),(0,fb.jsx)("text",{x:g2t,y:une/2+4,fontSize:12,fontWeight:600,fill:"var(--archik-node-text)",children:F})]})}function Q6r(o,c,u){return`M ${u} 0 H ${o-u} A ${u} ${u} 0 0 1 ${o} ${u} V ${c} H 0 V ${u} A ${u} ${u} 0 0 1 ${u} 0 Z`}var Q9=mi(s2t(),1),_d=mi(hc(),1),e8r=12,t8r=18;function Sln({Icon:o,cx:c,cy:u,size:p=e8r,color:f,strokeWidth:y=1.8}){return(0,_d.jsx)("g",{transform:`translate(${c-p/2}, ${u-p/2})`,pointerEvents:"none","aria-hidden":"true",children:(0,_d.jsx)(o,{size:p,color:f??"var(--archik-fg-dim)",strokeWidth:y})})}function _ln(o){return(0,_d.jsx)(Sln,{Icon:Q9.Info,...o})}function Cln(o){return(0,_d.jsx)(Sln,{Icon:Q9.StickyNote,...o})}function Iln({cx:o,cy:c,filePath:u,fileLabel:p,onClick:f,size:y=13}){return(0,_d.jsxs)("g",{transform:`translate(${o-y/2}, ${c-y/2})`,style:{cursor:f?"pointer":"default"},onClick:f,children:[(0,_d.jsx)("title",{children:`Cross-file edge \u2192 ${p} (${u})`}),(0,_d.jsx)("circle",{cx:y/2,cy:y/2,r:y/2+.5,fill:"var(--archik-fg-dim)",fillOpacity:.12,stroke:"var(--archik-fg-dim)",strokeOpacity:.4,strokeWidth:1}),(0,_d.jsx)("g",{transform:"translate(1, 1)",pointerEvents:"none",children:(0,_d.jsx)(Q9.ArrowUpRight,{size:y-2,color:"var(--archik-fg-muted)",strokeWidth:2.2})})]})}function Eln({cx:o,cy:c,onClick:u,size:p=14}){return(0,_d.jsxs)("g",{transform:`translate(${o-p/2}, ${c-p/2})`,style:{cursor:u?"pointer":"default"},onClick:u,children:[(0,_d.jsx)("title",{children:"Open sub-architecture"}),(0,_d.jsx)("circle",{cx:p/2,cy:p/2,r:p/2+.5,fill:"var(--archik-accent)",fillOpacity:.16,stroke:"var(--archik-accent)",strokeOpacity:.45,strokeWidth:1}),(0,_d.jsx)("g",{transform:"translate(1, 1)",pointerEvents:"none",children:(0,_d.jsx)(Q9.ChevronDown,{size:p-2,color:"var(--archik-accent)",strokeWidth:2.2})})]})}function Pln({cx:o,cy:c,files:u,count:p,size:f=14}){let y=u.length===1?`Open sequence diagram \u2192 ${u[0].label} (${u[0].path})`:`${u.length} sequence diagrams on this node:
518
+ ${Zu(u.errors)}`);return u.value}function Sv(o){return xft.default.stringify(o,{indent:2,lineWidth:0})}var JGn=6;function Sft(o,c){return hte.relative(o,c).split(hte.sep).join("/")||hte.basename(c)}function ZGn(o){return o.endsWith(".archik.yaml")&&!o.endsWith(".archik.suggested.yaml")}async function ul(o,c){let u=[],p=[],f=new Set,y=async v=>{if(f.has(v))return;f.add(v);let _;try{_=await VGn(v,"utf-8")}catch(T){p.push({abs:v,relPath:Sft(c,v),message:T instanceof Error?T.message:String(T)});return}try{let T=Xu(_);u.push({abs:v,relPath:Sft(c,v),doc:T})}catch(T){p.push({abs:v,relPath:Sft(c,v),message:T instanceof Error?T.message:String(T)})}};await y(o);let w=async(v,_)=>{if(_>JGn)return;let T;try{T=await WGn(v,{withFileTypes:!0})}catch{return}for(let R of T){let F=hte.join(v,R.name);if(R.isDirectory()){await w(F,_+1);continue}R.isFile()&&ZGn(R.name)&&await y(F)}};return await w(hte.join(c,".archik"),0),{docs:u,errors:p}}var ion=mi(kv(),1);import{readFile as oVn,readdir as cVn}from"node:fs/promises";import pte from"node:path";var XGn=ct.enum(["sync","async","return","create","destroy"]),KGn=ct.enum(["over","left_of","right_of"]),YGn=ct.enum(["alt","opt","loop","par","break","ref"]),QGn=ct.strictObject({id:ba,nodeId:ba,label:ct.string().min(1).optional(),status:E3.optional()}),eVn=ct.strictObject({type:ct.literal("message"),id:ba,from:ba,to:ba,label:ct.string().min(1),arrow:XGn,activate:ct.boolean().optional(),status:E3.optional()}),tVn=ct.strictObject({type:ct.literal("note"),id:ba,position:KGn,participants:ct.array(ba).min(1),text:ct.string().min(1),status:E3.optional()}),nVn=ct.lazy(()=>ct.strictObject({label:ct.string().optional(),steps:ct.array(non)})),rVn=ct.lazy(()=>ct.strictObject({type:ct.literal("group"),id:ba,kind:YGn,condition:ct.string().optional(),label:ct.string().optional(),branches:ct.array(nVn).optional(),seqFile:dte.optional(),participants:ct.array(ba).optional(),status:E3.optional()})),non=ct.lazy(()=>ct.union([eVn,tVn,rVn]));function ron(o,c){let u=[];for(let p of o)if(c.has(p.id)?u.push(p.id):c.add(p.id),p.type==="group"&&p.branches)for(let f of p.branches)u.push(...ron(f.steps,c));return u}var iVn=ct.strictObject({useCase:ba,slice:ba}),fte=ct.strictObject({version:ct.literal("1.0"),name:ct.string().min(1),description:ct.string().optional(),realizes:iVn.optional(),participants:ct.array(QGn).min(1),steps:ct.array(non)}).superRefine((o,c)=>{let u=new Set;for(let y=0;y<o.participants.length;y++){let w=o.participants[y];u.has(w.id)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["participants",y,"id"],message:`duplicate participant id "${w.id}"`}),u.add(w.id)}let p=new Set,f=ron(o.steps,p);for(let y of f)c.addIssue({code:ct.ZodIssueCode.custom,path:["steps"],message:`duplicate step id "${y}"`})});var aVn=6;function sVn(o,c){return pte.relative(o,c).split(pte.sep).join("/")||pte.basename(c)}async function _v(o){let c=[],u=[],p=async y=>{let w=sVn(o,y),v;try{v=await oVn(y,"utf-8")}catch(_){u.push({abs:y,relPath:w,message:_ instanceof Error?_.message:String(_)});return}try{let _=ion.default.parse(v),T=fte.safeParse(_);if(!T.success){u.push({abs:y,relPath:w,message:T.error.issues.map(R=>R.message).join("; ")});return}c.push({abs:y,relPath:w,doc:T.data})}catch(_){u.push({abs:y,relPath:w,message:_ instanceof Error?_.message:String(_)})}},f=async(y,w)=>{if(w>aVn)return;let v;try{v=await cVn(y,{withFileTypes:!0})}catch{return}for(let _ of v){let T=pte.join(y,_.name);if(_.isDirectory()){await f(T,w+1);continue}_.isFile()&&_.name.endsWith(".archik.seq.yaml")&&await p(T)}};return await f(pte.join(o,".archik"),0),{docs:c,errors:u}}var con=mi(kv(),1);import{readFile as bVn,readdir as mVn}from"node:fs/promises";import gte from"node:path";var lVn=ct.string().min(1).refine(o=>!o.startsWith("/")&&!/^[a-zA-Z]:[\\/]/.test(o),{message:"test path must be relative (no leading / or drive letter)"}).refine(o=>!o.includes("\\"),{message:"test path must use forward slashes"}).refine(o=>!o.split("/").some(c=>c===".."),{message:"test path must not contain `..` segments"}),uVn=/^[a-z][a-z0-9-]*\.\d+$/,dVn=ct.string().regex(uVn,"branchFrom must be `<flowId>.<stepNumber>` (e.g. basic.3)"),hVn=ct.strictObject({steps:ct.array(ct.string().min(1)).min(1)}),fVn=ct.strictObject({id:ba,branchFrom:dVn,steps:ct.array(ct.string().min(1)).min(1)}),pVn=ct.strictObject({basic:hVn,alternates:ct.array(fVn).optional()}),gVn=ct.strictObject({seqFile:dte}),yVn=ct.strictObject({id:ba,description:ct.string().min(1),flows:ct.array(ba).min(1),tests:ct.array(lVn).optional(),realization:gVn.optional(),status:E3.optional()}),oon=ct.strictObject({version:ct.literal("1.0"),id:ba,name:ct.string().min(1),description:ct.string().optional(),status:E3.optional(),primaryActor:ba,secondaryActors:ct.array(ba).optional(),goal:ct.string().min(1),preconditions:ct.array(ct.string().min(1)).optional(),postconditions:ct.array(ct.string().min(1)).optional(),flows:pVn,slices:ct.array(yVn).min(1)}).superRefine((o,c)=>{let u=new Map;u.set("basic",o.flows.basic.steps.length);let p=new Set;o.flows.alternates&&(o.flows.alternates.forEach((y,w)=>{y.id==="basic"&&c.addIssue({code:ct.ZodIssueCode.custom,path:["flows","alternates",w,"id"],message:'alternate id "basic" collides with the basic flow'}),p.has(y.id)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["flows","alternates",w,"id"],message:`duplicate alternate flow id "${y.id}"`}),p.add(y.id),u.set(y.id,y.steps.length)}),o.flows.alternates.forEach((y,w)=>{let[v,_]=y.branchFrom.split("."),T=Number(_),R=u.get(v);if(R===void 0){c.addIssue({code:ct.ZodIssueCode.custom,path:["flows","alternates",w,"branchFrom"],message:`branchFrom "${y.branchFrom}" references unknown flow "${v}"`});return}(T<1||T>R)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["flows","alternates",w,"branchFrom"],message:`branchFrom "${y.branchFrom}" step ${T} is out of range (flow "${v}" has ${R} step(s))`})}));let f=new Set;o.slices.forEach((y,w)=>{f.has(y.id)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["slices",w,"id"],message:`duplicate slice id "${y.id}"`}),f.add(y.id),y.flows.forEach((_,T)=>{u.has(_)||c.addIssue({code:ct.ZodIssueCode.custom,path:["slices",w,"flows",T],message:`slice "${y.id}" references unknown flow "${_}". Available: ${Array.from(u.keys()).join(", ")}.`})}),y.flows.includes("basic")||c.addIssue({code:ct.ZodIssueCode.custom,path:["slices",w,"flows"],message:`slice "${y.id}" does not include the basic flow. Slices must include "basic" plus zero or more alternates that branch off it; otherwise the alternate has no prefix to branch from.`}),!(y.status==="proposed"||y.status==="deprecated")&&(y.tests===void 0||y.tests.length===0)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["slices",w,"tests"],message:`slice "${y.id}" has no tests. Active slices must declare at least one test path (each must exist on disk). Mark the slice \`status: proposed\` if the test isn't written yet.`})})});var wVn=6;function vVn(o,c){return gte.relative(o,c).split(gte.sep).join("/")||gte.basename(c)}function kVn(o){return o.endsWith(".archik.uc.yaml")}async function Op(o){let c=[],u=[],p=async y=>{let w=vVn(o,y),v;try{v=await bVn(y,"utf-8")}catch(R){u.push({abs:y,relPath:w,message:R instanceof Error?R.message:String(R)});return}let _;try{_=con.default.parse(v)}catch(R){u.push({abs:y,relPath:w,message:R instanceof Error?R.message:String(R)});return}let T=oon.safeParse(_);if(!T.success){u.push({abs:y,relPath:w,message:T.error.issues.map(R=>R.message).join("; ")});return}c.push({abs:y,relPath:w,doc:T.data})},f=async(y,w)=>{if(w>wVn)return;let v;try{v=await mVn(y,{withFileTypes:!0})}catch{return}for(let _ of v){let T=gte.join(y,_.name);if(_.isDirectory()){await f(T,w+1);continue}_.isFile()&&kVn(_.name)&&await p(T)}};return await f(gte.join(o,".archik","usecases"),0),{docs:c,errors:u}}var son=mi(kv(),1);import{readFile as SVn,readdir as _Vn}from"node:fs/promises";import yte from"node:path";var MVn=ct.enum(["human","external-system","time","device"]),xVn=ct.strictObject({id:ba,kind:MVn,description:ct.string().min(1),goals:ct.array(ct.string().min(1)).optional(),status:E3.optional()}),aon=ct.strictObject({version:ct.literal("1.0"),description:ct.string().optional(),actors:ct.array(xVn).min(1)}).superRefine((o,c)=>{let u=new Set;o.actors.forEach((p,f)=>{u.has(p.id)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["actors",f,"id"],message:`duplicate actor id "${p.id}"`}),u.add(p.id)})});var CVn=6;function IVn(o,c){return yte.relative(o,c).split(yte.sep).join("/")||yte.basename(c)}function EVn(o){return o.endsWith(".archik.actors.yaml")}async function aS(o){let c=[],u=[],p=async y=>{let w=IVn(o,y),v;try{v=await SVn(y,"utf-8")}catch(R){u.push({abs:y,relPath:w,message:R instanceof Error?R.message:String(R)});return}let _;try{_=son.default.parse(v)}catch(R){u.push({abs:y,relPath:w,message:R instanceof Error?R.message:String(R)});return}let T=aon.safeParse(_);if(!T.success){u.push({abs:y,relPath:w,message:T.error.issues.map(R=>R.message).join("; ")});return}c.push({abs:y,relPath:w,doc:T.data})},f=async(y,w)=>{if(w>CVn)return;let v;try{v=await _Vn(y,{withFileTypes:!0})}catch{return}for(let _ of v){let T=yte.join(y,_.name);if(_.isDirectory()){await f(T,w+1);continue}_.isFile()&&EVn(_.name)&&await p(T)}};return await f(yte.join(o,".archik"),0),{docs:c,errors:u}}import{readFile as LVn,readdir as TVn}from"node:fs/promises";import bte from"node:path";var PVn=ct.strictObject({id:ba.optional(),from:ba,to:ba,label:ct.string().min(1),data:ct.strictObject({in:ct.unknown().optional(),out:ct.unknown().optional()}).optional(),status:ct.enum(["ok","error"]).default("ok")}),lon=ct.strictObject({version:ct.literal("1.0"),useCase:ba,slice:ba,seqFile:ct.string().min(1).optional(),recordedAt:ct.string().min(1),steps:ct.array(PVn).min(1)});var AVn=6;function NVn(o,c){return bte.relative(o,c).split(bte.sep).join("/")||bte.basename(c)}async function aG(o){let c=[],u=[],p=async y=>{let w=NVn(o,y),v;try{v=await LVn(y,"utf-8")}catch(_){u.push({abs:y,relPath:w,message:_ instanceof Error?_.message:String(_)});return}try{let _=JSON.parse(v),T=lon.safeParse(_);if(!T.success){u.push({abs:y,relPath:w,message:T.error.issues.map(R=>R.message).join("; ")});return}c.push({abs:y,relPath:w,doc:T.data})}catch(_){u.push({abs:y,relPath:w,message:_ instanceof Error?_.message:String(_)})}},f=async(y,w)=>{if(w>AVn)return;let v;try{v=await TVn(y,{withFileTypes:!0})}catch{return}for(let _ of v){let T=bte.join(y,_.name);if(_.isDirectory()){await f(T,w+1);continue}_.isFile()&&_.name.endsWith(".archik.trace.json")&&await p(T)}};return await f(bte.join(o,".archik"),0),{docs:c,errors:u}}function RVn(o){let c=new Set,u=p=>{for(let f of p){let y=f;if(y.type==="message"&&y.id&&c.add(y.id),y.branches)for(let w of y.branches)u(w.steps)}};return u(o),c}function uon(o,c,u){let p=[],f=[],y=new Set;for(let{doc:w}of c)for(let v of w.slices)y.add(`${w.id}/${v.id}`);for(let{relPath:w,doc:v}of o){if(!y.has(`${v.useCase}/${v.slice}`)){p.push({path:w,message:`trace targets unknown use case / slice "${v.useCase}/${v.slice}"`});continue}if(v.seqFile===void 0)continue;let _=u.find(B=>B.relPath===v.seqFile||B.abs.endsWith("/"+v.seqFile));if(_===void 0){p.push({path:w,message:`trace seqFile "${v.seqFile}" is not a discovered sequence diagram`});continue}let T=RVn(_.doc.steps),R=new Set(_.doc.participants.map(B=>B.id)),F=new Set;for(let B of v.steps){B.id!==void 0&&(T.has(B.id)?F.add(B.id):p.push({path:w,message:`trace step id "${B.id}" is not a message id in ${v.seqFile}`}));for(let V of[B.from,B.to])R.has(V)||p.push({path:w,message:`trace step references "${V}", not a participant in ${v.seqFile}`})}for(let B of T)F.has(B)||f.push(`${w}: seq step "${B}" was not exercised by this run`)}return{errors:p,info:f}}function don(o,c,u,p){o.forEach((f,y)=>{let w=`${p}.${y}`;f.type==="message"?(c.has(f.from)||u.push({path:`${w}.from`,message:`participant "${f.from}" is not declared in participants`}),c.has(f.to)||u.push({path:`${w}.to`,message:`participant "${f.to}" is not declared in participants`})):f.type==="note"?f.participants.forEach((v,_)=>{c.has(v)||u.push({path:`${w}.participants.${_}`,message:`participant "${v}" is not declared in participants`})}):f.type==="group"&&f.branches&&f.branches.forEach((v,_)=>{don(v.steps,c,u,`${w}.branches.${_}.steps`)})})}function hon(o,c){let u=[],p=new Set;return o.participants.forEach((f,y)=>{p.add(f.id),c.has(f.nodeId)||u.push({path:`participants.${y}.nodeId`,message:`nodeId "${f.nodeId}" does not match any architecture node. Run \`npx archik q list\` to see available node ids.`})}),don(o.steps,p,u,"steps"),u}var DVn={boundary:new Set(["control"]),control:new Set(["boundary","control","entity"]),entity:new Set(["control","entity"])};function fon(o,c,u,p,f,y){o.forEach((w,v)=>{let _=`${f}.${v}`;if(w.type==="message"){let T=c.get(w.from),R=c.get(w.to);if(T===void 0||R===void 0)return;let F=DVn[T];F&&!F.has(R)&&y.push({path:`${u}:${_}`,message:`ECB violation in seq "${p}" message "${w.id}": ${T} \u2192 ${R} is forbidden by the robustness rules (boundaries don't talk to boundaries or entities; entities don't talk to boundaries). Insert a control between them, or revisit the stereotype assignment.`})}else w.type==="group"&&w.branches&&w.branches.forEach((T,R)=>{fon(T.steps,c,u,p,`${_}.branches.${R}.steps`,y)})})}function pon(o,c){let u=[],p=new Map;for(let{doc:f}of c)for(let y of f.nodes)y.stereotype!==void 0&&p.set(y.id,y.stereotype);for(let f of o){if(f.doc.realizes===void 0)continue;let y=new Map;for(let w of f.doc.participants){let v=p.get(w.nodeId);v!==void 0&&y.set(w.id,v)}fon(f.doc.steps,y,f.relPath,f.doc.name,"steps",u)}return u}function gon(o,c){let u=[],p=new Map;for(let{doc:f}of c)for(let y of f.nodes){let w=p.get(y.id)??new Set;for(let v of y.seqFiles??[])w.add(v);p.set(y.id,w)}for(let f of o){if(f.doc.realizes===void 0)continue;let y=new Set;for(let w of f.doc.participants){if(y.has(w.nodeId))continue;let v=p.get(w.nodeId);v!==void 0&&(v.has(f.relPath)||(y.add(w.nodeId),u.push({path:`${f.relPath}:participants.${w.id}`,message:`seq "${f.doc.name}" lists node "${w.nodeId}" as a participant, but that node's \`seqFiles\` array does not reference this diagram. Add "${f.relPath}" to node "${w.nodeId}"'s \`seqFiles\` array via \`npx archik suggest set\` so the canvas can surface the flow on that node.`})))}}return u}function yon(o,c){let u=[],p=new Map(c.map(f=>[f.doc.id,f]));for(let f of o){if(f.doc.realizes===void 0)continue;let{useCase:y,slice:w}=f.doc.realizes,v=p.get(y);if(v===void 0){u.push({path:`${f.relPath}:realizes.useCase`,message:`seq diagram "${f.doc.name}" claims to realize use case "${y}" but no such use case file was found.`});continue}let _=v.doc.slices.find(T=>T.id===w);if(_===void 0){u.push({path:`${f.relPath}:realizes.slice`,message:`seq diagram "${f.doc.name}" claims to realize slice "${w}" of use case "${y}", but that use case has no slice with that id. Available slices: ${v.doc.slices.map(T=>T.id).join(", ")}.`});continue}if(_.realization===void 0){u.push({path:`${f.relPath}:realizes.slice`,message:`seq diagram "${f.doc.name}" realizes slice "${w}" of "${y}", but the slice does not declare \`realization.seqFile\`. Add \`realization: { seqFile: "${f.relPath}" }\` to slice "${w}" in ${v.relPath}.`});continue}_.realization.seqFile!==f.relPath&&u.push({path:`${f.relPath}:realizes.slice`,message:`seq diagram "${f.doc.name}" realizes slice "${w}" of "${y}", but that slice's realization.seqFile points at "${_.realization.seqFile}", not at this file ("${f.relPath}"). Pick one canonical seq file and update both sides.`})}return u}function bon(o){let c=new Map,u=[];for(let{relPath:p,doc:f}of o)for(let y of f.actors){let w=c.get(y.id);if(w!==void 0){u.push({path:p,message:`actor id "${y.id}" is duplicated across actor files (also defined in ${w.relPath})`});continue}c.set(y.id,{relPath:p})}return{index:c,errors:u}}function mon(o){let c=new Map,u=[];for(let{relPath:p,doc:f}of o){let y=c.get(f.id);if(y!==void 0){u.push({path:p,message:`use case id "${f.id}" is duplicated across files (also defined in ${y.relPath})`});continue}c.set(f.id,{relPath:p})}return{index:c,errors:u}}function won(o,c){let u=[];for(let{relPath:p,doc:f}of o)c.has(f.primaryActor)||u.push({path:`${p}:primaryActor`,message:`use case "${f.id}" references unknown primaryActor "${f.primaryActor}". Define it in a *.archik.actors.yaml file.`}),f.secondaryActors&&f.secondaryActors.forEach((y,w)=>{c.has(y)||u.push({path:`${p}:secondaryActors.${w}`,message:`use case "${f.id}" references unknown secondary actor "${y}". Define it in a *.archik.actors.yaml file.`})});return u}function von(o,c){let u=[];for(let{relPath:p,doc:f}of o)f.slices.forEach((y,w)=>{y.status==="proposed"||y.status==="deprecated"||y.tests!==void 0&&y.tests.forEach((_,T)=>{c(_)||u.push({path:`${p}:slices.${w}.tests.${T}`,message:`slice "${y.id}" test "${_}" does not exist on disk (resolved relative to project root). Either fix the path or mark the slice \`status: proposed\`.`})})});return u}function kon(o,c){let u=[],p=new Map(c.map(f=>[f.relPath,f]));for(let{relPath:f,doc:y}of o)y.slices.forEach((w,v)=>{if(w.realization===void 0)return;let _=p.get(w.realization.seqFile);if(_===void 0){u.push({path:`${f}:slices.${v}.realization.seqFile`,message:`slice "${w.id}" realization seqFile "${w.realization.seqFile}" does not exist or did not parse. Run \`npx archik q sequences\` to see available seq files.`});return}if(_.doc.realizes===void 0){u.push({path:`${f}:slices.${v}.realization.seqFile`,message:`slice "${w.id}" claims realization "${w.realization.seqFile}", but that seq diagram has no \`realizes\` block. Add \`realizes: { useCase: "${y.id}", slice: "${w.id}" }\` to ${_.relPath}, or remove the realization claim.`});return}(_.doc.realizes.useCase!==y.id||_.doc.realizes.slice!==w.id)&&u.push({path:`${f}:slices.${v}.realization.seqFile`,message:`slice "${w.id}" claims realization "${w.realization.seqFile}", but that seq diagram's \`realizes\` points at "${_.doc.realizes.useCase}/${_.doc.realizes.slice}", not at "${y.id}/${w.id}". Pick one canonical link.`})});return u}import mte from"node:path";function Cv(o){let c=mte.dirname(o),u=mte.basename(o),p=mte.extname(u),f=p.length>0?u.slice(0,-p.length):u;return mte.join(c,`${f}.suggested${p}`)}function sG(o){return mte.basename(o).endsWith(".archik.suggested.yaml")?"suggested":"normal"}function Mon(o){return o.metadata?.suggestion!==void 0}function mge(o){if(o.metadata?.suggestion===void 0)return o;let{suggestion:c,...u}=o.metadata,p={...o};return Object.keys(u).length===0?delete p.metadata:p.metadata=u,p}function OVn(o){let c=new Map;for(let p of o)c.set(p.id,p.parentId);let u=new Map;for(let p of o){let f=new Set,y=p.parentId,w=0;for(;y!==void 0&&w<=o.length&&!f.has(y);)f.add(y),y=c.get(y),w++;u.set(p.id,f)}return u}function lG(o,c,u){if(c.id!==void 0&&o.id!==c.id||c.kind!==void 0&&o.kind!==c.kind||c.stereotype!==void 0&&o.stereotype!==c.stereotype)return!1;let p=u.get(o.id)??new Set;return!(c.parent!==void 0&&!p.has(c.parent)||c.notParent!==void 0&&p.has(c.notParent))}function wge(o,c,u,p){let f=o.filter(y=>y.abs!==c);return f.push({abs:c,relPath:u,doc:p}),_ft(f)}function _ft(o){let c=[],u=o.flatMap(_=>_.doc.nodes),p=o.flatMap(_=>_.doc.edges.map(T=>({edge:T,relPath:_.relPath}))),f=new Map(u.map(_=>[_.id,_])),y=OVn(u),w=[],v=new Map;for(let _ of o)for(let T of _.doc.constraints??[]){let R=v.get(T.id);if(R!==void 0){c.push({path:`constraints.${T.id}`,message:`duplicate constraint id "${T.id}" (already defined in ${R})`});continue}v.set(T.id,_.relPath),w.push({constraint:T,relPath:_.relPath})}for(let{constraint:_}of w){let T=new Set(_.except??[]);if(_.forbidEdge!==void 0){let R=_.forbidEdge;for(let{edge:F,relPath:B}of p)if(!T.has(F.id)&&!(R.relationship!==void 0&&F.relationship!==R.relationship)){if(R.from!==void 0){let V=f.get(F.from);if(V===void 0||!lG(V,R.from,y))continue}if(R.to!==void 0){let V=f.get(F.to);if(V===void 0||!lG(V,R.to,y))continue}c.push({path:`constraints.${_.id}`,message:`edge "${F.id}" (${F.from} \u2192 ${F.to} via ${F.relationship}, in ${B}) violates constraint "${_.id}": ${_.description} \u2014 fix the edge, or add "${F.id}" to the constraint's \`except\` list with a reason in review.`})}}if(_.requireEdge!==void 0){let R=_.requireEdge;for(let F of u){if(T.has(F.id)||!lG(F,R.node,y)||p.some(({edge:se})=>{if(R.relationship!==void 0&&se.relationship!==R.relationship)return!1;if(R.to!==void 0){if(se.from!==F.id)return!1;let ce=f.get(se.to);return ce!==void 0&&lG(ce,R.to,y)}if(se.to!==F.id)return!1;let ee=f.get(se.from);return ee!==void 0&&lG(ee,R.from,y)}))continue;let V=R.to!==void 0?`an outgoing edge to a node matching ${JSON.stringify(R.to)}`:`an incoming edge from a node matching ${JSON.stringify(R.from)}`;c.push({path:`constraints.${_.id}`,message:`node "${F.id}" (kind: ${F.kind}) violates constraint "${_.id}": ${_.description} \u2014 it needs ${V}`+(R.relationship!==void 0?` (relationship: ${R.relationship})`:"")+`, or add "${F.id}" to the constraint's \`except\` list.`})}}if(_.maxDependencies!==void 0){let R=_.maxDependencies;for(let F of u){if(T.has(F.id)||!lG(F,R.node,y))continue;let B=p.filter(({edge:V})=>V.from===F.id&&(R.relationship===void 0||V.relationship===R.relationship));B.length<=R.max||c.push({path:`constraints.${_.id}`,message:`node "${F.id}" (kind: ${F.kind}) violates constraint "${_.id}": ${_.description} \u2014 ${B.length} outgoing ${R.relationship??""} edge(s), max is ${R.max} (${B.map(V=>V.edge.to).join(", ")}). Split the node, introduce a port/gateway, or add "${F.id}" to \`except\`.`})}}if(_.requireOwner!==void 0){let R=_.requireOwner.kinds;for(let F of u)T.has(F.id)||R!==void 0&&!R.includes(F.kind)||F.owner===void 0&&c.push({path:`constraints.${_.id}`,message:`node "${F.id}" (kind: ${F.kind}) violates constraint "${_.id}": ${_.description} \u2014 add \`owner: <team>\` to the node, or add "${F.id}" to the constraint's \`except\` list.`})}}return c}var CE={maxNodes:15,maxEdges:20,maxChildren:6,maxDegree:6,maxDepth:3};function FVn(o,c){let u=0,p=c.get(o);for(;p!==void 0&&u<=c.size;)u++,p=c.get(p);return u}function vge(o,c){let u=[];for(let{doc:f,relPath:y}of o){f.nodes.length>c.maxNodes&&u.push({kind:"file-nodes",subject:y,value:f.nodes.length,limit:c.maxNodes,suggestion:`split ${y} into sub-files via archikFile (${f.nodes.length} nodes; limit ${c.maxNodes})`}),f.edges.length>c.maxEdges&&u.push({kind:"file-edges",subject:y,value:f.edges.length,limit:c.maxEdges,suggestion:`split ${y} into sub-files via archikFile (${f.edges.length} edges; limit ${c.maxEdges})`});let w=new Map,v=new Map;for(let _ of f.nodes)v.set(_.id,_.parentId);for(let _ of f.nodes)_.parentId!==void 0&&w.set(_.parentId,(w.get(_.parentId)??0)+1);for(let[_,T]of w)T>c.maxChildren&&u.push({kind:"container-children",subject:_,value:T,limit:c.maxChildren,suggestion:`give container '${_}' its own archikFile \u2014 ${T} children, limit ${c.maxChildren}`});for(let _ of f.nodes){let T=FVn(_.id,v);T>c.maxDepth&&u.push({kind:"nesting-depth",subject:_.id,value:T,limit:c.maxDepth,suggestion:`flatten or split \u2014 '${_.id}' is ${T} levels deep, limit ${c.maxDepth}`})}}let p=new Map;for(let{doc:f}of o)for(let y of f.edges)p.set(y.from,(p.get(y.from)??0)+1),p.set(y.to,(p.get(y.to)??0)+1);for(let[f,y]of p)y>c.maxDegree&&u.push({kind:"node-degree",subject:f,value:y,limit:c.maxDegree,suggestion:`'${f}' has ${y} connections \u2014 name a bounded context or add a port/gateway (limit ${c.maxDegree})`});return u.sort((f,y)=>y.value-y.limit-(f.value-f.limit)),u}var jVn=o=>{let c=dn(o,"json");return c!==void 0&&c!=="false"&&c!=="0"};function Iv(o){console.log(JSON.stringify(o,null,2))}async function AR(o){let c=jVn(o),u;try{u=await cc(o._[0])}catch(nn){let cn=nn instanceof Error?nn.message:String(nn);return c?Iv({ok:!1,errors:[{path:"<root>",message:cn}]}):console.error(`\u2717 ${cn}`),1}let p=xon.relative(process.cwd(),u)||u,f;try{f=await $Vn(u,"utf-8")}catch(nn){let cn=nn instanceof Error?nn.message:String(nn);return c?Iv({ok:!1,file:p,errors:[{path:"<root>",message:cn}]}):(console.error(`\u2717 Cannot read ${p}`),console.error(cn)),1}let y;try{y=Son.default.parse(f)}catch(nn){let Nr=[{path:"<root>",message:`Invalid YAML: ${nn instanceof Error?nn.message:String(nn)}`}];return c?Iv({ok:!1,file:p,errors:Nr}):(console.error(`\u2717 ${p}`),console.error(Zu(Nr))),1}let w=jg(y);if(!w.ok)return c?Iv({ok:!1,file:p,errors:w.errors}):(console.error(`\u2717 ${p}`),console.error(Zu(w.errors))),1;let v=Ba(u),_=nn=>zVn(xon.resolve(v,nn)),T=cG(w.value,_);if(T.length>0)return c?Iv({ok:!1,file:p,errors:T}):(console.error(`\u2717 ${p}`),console.error(Zu(T))),1;let R=sG(u),F=oG(w.value,R,_);if(F.length>0)return c?Iv({ok:!1,file:p,errors:F}):(console.error(`\u2717 ${p}`),console.error(Zu(F))),1;let B=await ul(u,v);if(B.errors.length>0){if(c)Iv({ok:!1,file:p,errors:B.errors.map(nn=>({path:nn.relPath,message:nn.message}))});else for(let nn of B.errors)console.error(`\u2717 ${nn.relPath}: ${nn.message}`);return 1}let V=new Set(B.docs.flatMap(nn=>nn.doc.nodes.map(cn=>cn.id))),se=[];for(let{doc:nn}of B.docs)se.push(...ton(nn,_));if(se.length>0){if(c)Iv({ok:!1,file:p,errors:se});else{console.error("\u2717 seqFiles path errors:");for(let nn of se)console.error(` \u2717 ${nn.path}: ${nn.message}`)}return 1}let ee=await _v(v),ce=0;for(let nn of ee.errors)c||console.error(`\u2717 ${nn.relPath}: ${nn.message}`),ce++;for(let{relPath:nn,doc:cn}of ee.docs){let Nr=hon(cn,V);if(Nr.length>0){if(!c){console.error(`\u2717 ${nn}`);for(let oi of Nr)console.error(` \u2717 ${oi.path}: ${oi.message}`)}ce+=Nr.length}}if(ce>0)return c&&Iv({ok:!1,file:p,errors:[{path:"<seq>",message:`${ce} sequence diagram error(s)`}]}),1;let ge=await Op(v),Oe=await aS(v),ut=[];for(let nn of ge.errors)ut.push({path:nn.relPath,message:nn.message});for(let nn of Oe.errors)ut.push({path:nn.relPath,message:nn.message});if(ut.length===0){let nn=bon(Oe.docs);ut.push(...nn.errors);let cn=mon(ge.docs);ut.push(...cn.errors),ut.length===0&&(ut.push(...won(ge.docs,nn.index)),ut.push(...von(ge.docs,_)),ut.push(...kon(ge.docs,ee.docs)),ut.push(...yon(ee.docs,ge.docs)),ut.push(...pon(ee.docs,B.docs)),ut.push(...gon(ee.docs,B.docs)))}if(ut.length>0)return c?Iv({ok:!1,file:p,errors:ut}):(console.error(`\u2717 ${p}`),console.error(Zu(ut))),1;let Se=await aG(v),je=Se.errors.map(nn=>({path:nn.relPath,message:nn.message})),Be=[];if(je.length===0){let nn=uon(Se.docs,ge.docs,ee.docs);je.push(...nn.errors),Be=nn.info}if(je.length>0)return c?Iv({ok:!1,file:p,errors:je}):(console.error(`\u2717 ${p}`),console.error(Zu(je))),1;let tn=_ft(B.docs);if(tn.length>0)return c?Iv({ok:!1,file:p,errors:tn}):(console.error(`\u2717 ${p}`),console.error(Zu(tn))),1;let Gt=Oe.docs.reduce((nn,cn)=>nn+cn.doc.actors.length,0),xn=ge.docs.length,Vn=vge(B.docs,CE).length;if(c)Iv({ok:!0,file:p,nodes:w.value.nodes.length,edges:w.value.edges.length,useCases:xn,actors:Gt,complexityHints:Vn});else{let nn=B.docs.reduce((Pi,ue)=>Pi+ue.doc.nodes.length,0),cn=B.docs.reduce((Pi,ue)=>Pi+ue.doc.edges.length,0),Nr=B.docs.length,oi=Nr>1?` (${Nr} files)`:"",wo=xn>0?`, ${xn} use case${xn===1?"":"s"}`:"",Za=Gt>0?`, ${Gt} actor${Gt===1?"":"s"}`:"";console.log(`\u2713 ${p}${oi} \u2014 ${nn} nodes, ${cn} edges${wo}${Za}`),Vn>0&&console.log(`\u24D8 ${Vn} complexity hint${Vn===1?"":"s"} \u2014 run \`archik complexity\` to see them`);for(let Pi of Be)console.log(`\u24D8 ${Pi}`)}return 0}var w2t=mi(P3(),1),v2t=mi(Dye(),1),Gln=mi(kv(),1);import{mkdir as Hln,readFile as Uln,writeFile as qln}from"node:fs/promises";import OG from"node:path";var Rsn=mi(Lsn(),1);function cne(o,c){return o.length*c}function t0(o,c,u){if(c<=0)return"";let p=Math.floor(c/u);return o.length<=p?o:p<=1?"\u2026":o.slice(0,p-1)+"\u2026"}var ane={nodeSpacing:60,layerSpacing:100,padding:40,viewMode:"detailed"};function HXn(o){let c=o.nodeSpacing??ane.nodeSpacing,u=o.layerSpacing??ane.layerSpacing,p=o.padding??ane.padding;return{"elk.algorithm":"layered","elk.direction":"RIGHT","elk.edgeRouting":"ORTHOGONAL","elk.layered.spacing.nodeNodeBetweenLayers":String(u),"elk.spacing.nodeNode":String(c),"elk.padding":`[top=${p}, left=${p}, bottom=${p}, right=${p}]`,"elk.hierarchyHandling":"INCLUDE_CHILDREN","elk.edgeLabels.placement":"CENTER","elk.spacing.edgeLabel":"8","elk.spacing.labelLabel":"6","elk.spacing.edgeNode":"20","elk.spacing.edgeEdge":"12","elk.layered.spacing.edgeEdgeBetweenLayers":"12"}}var ed={width:172,height:82},Tsn={width:172,height:90},UXn={service:ed,function:ed,worker:ed,agent:ed,database:{width:184,height:100},cache:Tsn,vectordb:ed,storage:ed,model:ed,dto:ed,dataobject:ed,queue:{width:188,height:80},topic:ed,stream:ed,gateway:ed,cdn:ed,route:ed,interface:ed,adapter:ed,port:ed,llm:ed,prompt:ed,tool:ed,auth:ed,observability:ed,cloud:{width:200,height:120},frontend:Tsn,page:ed,component:ed,store:ed,hook:ed,external:{width:184,height:100},human:{width:184,height:100},module:{width:240,height:130},custom:{width:240,height:130}},dl={width:152,height:36},Asn={width:200,height:80},qXn={service:dl,function:dl,worker:dl,agent:dl,database:dl,cache:dl,vectordb:dl,storage:dl,model:dl,dto:dl,dataobject:dl,queue:{width:168,height:36},topic:dl,stream:dl,gateway:dl,cdn:dl,route:dl,interface:dl,adapter:dl,port:dl,llm:dl,prompt:dl,tool:dl,auth:dl,observability:dl,cloud:dl,frontend:dl,page:dl,component:dl,store:dl,hook:dl,external:{width:168,height:40},human:{width:168,height:40},module:Asn,custom:Asn},GXn=24,Nsn=320;function VXn(o,c,u){if(o.kind==="module"||o.kind==="custom")return c;if(u==="compact"){let v=36+cne(o.name,5.9)+12;return Math.max(c,Math.min(Nsn,Math.ceil(v)))}let p=cne(o.name,7.4),f=o.stack!==void 0?cne(o.stack,5.9):0,y=Math.max(p,f)+GXn;return Math.max(c,Math.min(Nsn,Math.ceil(y)))}var WXn={top:48,left:18,bottom:18,right:18};function JXn(o,c,u,p){let f=u[o.kind],y={id:o.id,width:VXn(o,f.width,p),height:f.height};if(c.length>0){y.children=c;let w=p==="compact"?{top:30,left:12,bottom:12,right:12}:WXn;y.layoutOptions={"elk.padding":`[top=${w.top}, left=${w.left}, bottom=${w.bottom}, right=${w.right}]`}}return y}function ZXn(o,c,u){let p=new Map;for(let v of o.nodes)p.set(v.id,v);let f=new Map;for(let v of o.nodes){let _=f.get(v.parentId)??[];_.push(v),f.set(v.parentId,_)}function y(v){let _=(f.get(v.id)??[]).map(y);return JXn(v,_,c,u)}return{roots:(f.get(void 0)??[]).map(y),byId:p}}function XXn(o){return o.fromFile===void 0&&o.toFile===void 0}function KXn(o){return o.edges.filter(XXn).map(c=>{let u={id:c.id,sources:[c.from],targets:[c.to]};return c.label!==void 0&&c.label.length>0&&(u.labels=[{text:c.label,width:Math.ceil(cne(c.label,5.9)),height:14}]),u})}function Gm(o){return o??0}function Dsn(o,c){let u=c.get(o.id);if(!u)throw new Error(`ELK returned unknown node id "${o.id}"`);let p=(o.children??[]).map(f=>Dsn(f,c));return{...u,x:Gm(o.x),y:Gm(o.y),width:Gm(o.width),height:Gm(o.height),children:p}}function YXn(o,c){let u=new Map,p=new Map,f=(T,R,F,B)=>{let V=R+Gm(T.x),se=F+Gm(T.y);u.set(T.id,{x:V,y:se}),p.set(T.id,B);let ee=[...B,T.id];for(let ce of T.children??[])f(ce,V,se,ee)};f(o,0,0,[]);let y=(T,R)=>{let F=p.get(T)??[],B=p.get(R)??[],V=0;for(;V<F.length&&V<B.length&&F[V]===B[V];)V++;let se=V===0?o.id:F[V-1];return u.get(se)??{x:0,y:0}},w=new Map,v=new Map,_=T=>{for(let R of T.edges??[]){let F=R.sources?.[0]??"",B=R.targets?.[0]??"",V=y(F,B),se=ge=>({x:Gm(ge.x)+V.x,y:Gm(ge.y)+V.y}),ee=(R.sections??[]).map(ge=>({startPoint:se(ge.startPoint),endPoint:se(ge.endPoint),bendPoints:(ge.bendPoints??[]).map(se)}));w.set(R.id,ee);let ce=(R.labels??[]).map(ge=>({text:typeof ge.text=="string"?ge.text:"",x:Gm(ge.x)+V.x,y:Gm(ge.y)+V.y,width:Gm(ge.width),height:Gm(ge.height)}));v.set(R.id,ce)}for(let R of T.children??[])_(R)};return _(o),c.edges.map(T=>({...T,sections:w.get(T.id)??[],labels:v.get(T.id)??[]}))}var QXn=new Rsn.default;async function eKn(o,c={}){if(o.nodes.length===0)return{document:o,width:0,height:0,roots:[],edges:[]};let u=c.viewMode==="compact"?"compact":"detailed",p=u==="compact"?qXn:UXn,{roots:f,byId:y}=ZXn(o,p,u),w={id:"__root__",layoutOptions:HXn(c),children:f,edges:KXn(o)},v=await QXn.layout(w),_=(v.children??[]).map(T=>Dsn(T,y));return{document:o,width:Gm(v.width),height:Gm(v.height),roots:_,edges:YXn(v,o)}}var Oye={name:"elk",layout:eKn};var Ili={[Oye.name]:Oye},tKn=Oye;function TG(o,c){return tKn.layout(o,c)}function Osn(o,c,u){let p=new Map,f=(v,_)=>{let T=p.get(v)??new Set;T.add(_),p.set(v,T)};for(let v of o)f(v.from,v.to),f(v.to,v.from);let y=new Set([c]),w=new Set([c]);for(let v=0;v<u;v++){let _=new Set;for(let T of w)for(let R of p.get(T)??[])y.has(R)||(y.add(R),_.add(R));if(_.size===0)break;w=_}return y}function Fsn(o,c,u){let p=o.flatMap(v=>v.doc.edges),f=Osn(p,c,u),y=[],w=[];for(let{doc:v,relPath:_}of o){for(let T of v.nodes)f.has(T.id)&&y.push({node:T,relPath:_});for(let T of v.edges)f.has(T.from)&&f.has(T.to)&&w.push({edge:T,relPath:_})}return{nodes:y,edges:w}}function zsn(o,c,u){let p=Osn(o.edges,c,u);return{...o,nodes:o.nodes.filter(f=>p.has(f.id)).map(f=>f.parentId!==void 0&&!p.has(f.parentId)?(({parentId:y,...w})=>w)(f):f),edges:o.edges.filter(f=>p.has(f.from)&&p.has(f.to))}}function $sn(o,c){let u=new Set(c.hideRel??[]),p=c.onlyRel?new Set(c.onlyRel):null,f=o.edges.filter(y=>!(p&&!p.has(y.relationship)||u.has(y.relationship)||c.hideStructural&&Kin(y.relationship)==="structural"));return{...o,edges:f}}function nKn(o){return Math.max(160,o.length*8+80)}function jsn(o,c,u,p,f,y=0){let w=u,v=[],_=Number.POSITIVE_INFINITY,T=Number.NEGATIVE_INFINITY;for(let R of o)if(R.type==="message"){let F=c.get(R.from),B=c.get(R.to),V=F?.cx??p,se=B?.cx??p;v.push({type:"message",id:R.id,fromCx:V,toCx:se,y:w,label:R.label,arrow:R.arrow,activate:R.activate??!1,isSelf:R.from===R.to,...R.status!==void 0?{status:R.status}:{}}),w+=R.from===R.to?56*1.5:56}else if(R.type==="note"){let F=R.participants.map(ce=>c.get(ce)?.cx).filter(ce=>ce!==void 0).sort((ce,ge)=>ce-ge),B=F[0]??p,V=F[F.length-1]??f,se=Math.min(Math.max(R.text.length*7.5+24,V-B+16,80),400),ee;R.position==="left_of"?ee=B-se-8:R.position==="right_of"?ee=V+8:ee=(B+V)/2-se/2,_=Math.min(_,ee),T=Math.max(T,ee+se),v.push({type:"note",id:R.id,x:ee,y:w,width:se,height:64,text:R.text,...R.status!==void 0?{status:R.status}:{}}),w+=72}else if(R.type==="group"){let F=Math.min(y*6,12),B=p-12+F,V=f-p+24-F*2,se=w;w+=24;let ee=[];if(R.branches)for(let ce=0;ce<R.branches.length;ce++){let ge=R.branches[ce],Oe=w,{items:ut,endY:Se,contentMinX:je,contentMaxX:Be}=jsn(ge.steps,c,w,p,f,y+1);w=Se,_=Math.min(_,je),T=Math.max(T,Be),ee.push({...ge.label!==void 0?{label:ge.label}:{},startY:Oe,...ce<R.branches.length-1?{dividerY:w}:{},steps:ut}),ce<R.branches.length-1&&(w+=4)}w+=12,v.push({type:"group",id:R.id,kind:R.kind,...R.condition!==void 0?{condition:R.condition}:{},...R.label!==void 0?{label:R.label}:{},...R.seqFile!==void 0?{seqFile:R.seqFile}:{},x:B,y:se,width:V,height:w-se,branches:ee,...R.status!==void 0?{status:R.status}:{}}),_=Math.min(_,B),T=Math.max(T,B+V),w+=20}return{items:v,endY:w,contentMinX:_,contentMaxX:T}}function Bsn(o){let c=new Map;for(let u of o)if(u.type==="message"&&u.arrow==="destroy"&&c.set(u.toCx,u.y+56+20),u.type==="group")for(let p of u.branches)for(let[f,y]of Bsn(p.steps))c.set(f,y);return c}function rKn(o){let c=[],u=new Map;function p(f){for(let y of f)if(y.type==="message"){if(y.activate&&y.arrow==="sync"&&!y.isSelf){let w=u.get(y.toCx)??[];w.push(y.y),u.set(y.toCx,w)}if(y.arrow==="return"&&!y.isSelf){let w=u.get(y.fromCx);if(w&&w.length>0){let v=w.pop();c.push({cx:y.fromCx,startY:v,endY:y.y}),w.length===0&&u.delete(y.fromCx)}}}else if(y.type==="group")for(let w of y.branches)p(w.steps)}p(o);for(let[f,y]of u)for(let w of y)c.push({cx:f,startY:w,endY:w+56/2});return c}function Hsn(o,c){let u=o.participants.map(tn=>nKn(tn.label??tn.nodeId)),p=32,f=o.participants.map((tn,Gt)=>{let xn=u[Gt],Vn=p+xn/2;p+=xn;let nn=c?.get(tn.nodeId);return{id:tn.id,nodeId:tn.nodeId,label:tn.label??tn.nodeId,cx:Vn,colWidth:xn,...nn!==void 0?{kind:nn}:{},...tn.status!==void 0?{status:tn.status}:{},lifelineEndY:0}}),y=p+32,w=new Map(f.map(tn=>[tn.id,tn])),v=f[0]?.cx??32,_=f[f.length-1]?.cx??y-32,T=24,{items:R,endY:F,contentMinX:B,contentMaxX:V}=jsn(o.steps,w,T,v,_),se=B<32&&Number.isFinite(B)?32-B:0,ee=Number.isFinite(V)?V+se+32:0,ce=Math.max(y+se,ee),ge=se>0?R.map(tn=>Usn(tn,se)):R,Oe=se>0?f.map(tn=>({...tn,cx:tn.cx+se})):f,ut=Bsn(ge),Se=Oe.map(tn=>({...tn,lifelineEndY:ut.get(tn.cx)??56+F+24})),je=56+F+24,Be=rKn(ge);return{participants:Se,steps:ge,activations:Be,totalWidth:ce,totalHeight:je}}function Usn(o,c){return o.type==="message"?{...o,fromCx:o.fromCx+c,toCx:o.toCx+c}:o.type==="note"?{...o,x:o.x+c}:{...o,x:o.x+c,branches:o.branches.map(u=>({...u,steps:u.steps.map(p=>Usn(p,c))}))}}var ci=mi(s2t(),1);var D3=mi(hc(),1),Ysn=(o,c,u)=>({width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:c,strokeWidth:u,strokeLinecap:"round",strokeLinejoin:"round"});function Qsn({size:o=16,color:c="currentColor",strokeWidth:u=1.8}){return(0,D3.jsxs)("svg",{...Ysn(o,c,u),"aria-hidden":"true",children:[(0,D3.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3.5",ry:"3.5"}),(0,D3.jsx)("line",{x1:"9",y1:"9",x2:"9",y2:"13"}),(0,D3.jsx)("line",{x1:"15",y1:"9",x2:"15",y2:"13"}),(0,D3.jsx)("circle",{cx:"12",cy:"16.5",r:"1",fill:c,stroke:"none"})]})}function eln({size:o=16,color:c="currentColor",strokeWidth:u=1.8}){return(0,D3.jsxs)("svg",{...Ysn(o,c,u),"aria-hidden":"true",children:[(0,D3.jsx)("path",{d:"M 7.5 6 L 3.5 12 L 7.5 18"}),(0,D3.jsx)("path",{d:"M 16.5 6 L 20.5 12 L 16.5 18"}),(0,D3.jsx)("circle",{cx:"13",cy:"8.6",r:"0.9",fill:c,stroke:"none"}),(0,D3.jsx)("line",{x1:"13",y1:"11",x2:"11",y2:"16.5"})]})}var Vm={service:{color:"#38bdf8",icon:ci.Server,description:"Long-running compute that owns business logic."},function:{color:"#22d3ee",icon:ci.FunctionSquare,description:"Stateless function-as-a-service / lambda."},worker:{color:"#06b6d4",icon:ci.Cog,description:"Background job processor or consumer loop."},agent:{color:"#14b8a6",icon:ci.Bot,description:"Autonomous AI agent driving tools and actions."},database:{color:"#34d399",icon:ci.Database,description:"Persistent state \u2014 relational, document, key-value."},cache:{color:"#a78bfa",icon:ci.Layers,description:"In-memory store for fast reads."},vectordb:{color:"#c084fc",icon:ci.Sparkles,description:"Vector store for embeddings / similarity search."},storage:{color:"#84cc16",icon:ci.HardDrive,description:"Object / blob storage (S3, GCS, etc.)."},model:{color:"#2dd4bf",icon:ci.Shapes,description:"Domain model \u2014 rich business object with behavior."},dto:{color:"#4ade80",icon:ci.FileJson2,description:"Data transfer object \u2014 shape crossing a boundary."},dataobject:{color:"#86efac",icon:ci.Braces,description:"Plain data structure / record, no behavior."},queue:{color:"#fbbf24",icon:ci.SendHorizontal,description:"Asynchronous work queue with at-least-once delivery."},topic:{color:"#f97316",icon:ci.Radio,description:"Pub/sub topic with multiple consumers."},stream:{color:"#fb923c",icon:ci.Waves,description:"Append-only event log (Kafka, Kinesis)."},gateway:{color:"#6366f1",icon:ci.DoorOpen,description:"API gateway, ingress, edge router."},cdn:{color:"#0ea5e9",icon:ci.Globe,description:"Content delivery network / static edge."},route:{color:"#f59e0b",icon:ci.Route,description:"HTTP / URL route \u2014 path + method mapped to a handler."},interface:{color:"#d946ef",icon:eln,description:"Abstract contract \u2014 the <i> a system commits to."},adapter:{color:"#c026d3",icon:ci.Cable,description:"Concrete implementation of an interface."},port:{color:"#a21caf",icon:Qsn,description:"Hexagonal-architecture port \u2014 the socket an adapter plugs into."},llm:{color:"#a855f7",icon:ci.Brain,description:"Large language model service."},prompt:{color:"#c4b5fd",icon:ci.MessageSquare,description:"Prompt template / instruction set."},tool:{color:"#fde047",icon:ci.Wrench,description:"Tool callable by an agent or LLM."},auth:{color:"#ef4444",icon:ci.Lock,description:"Identity provider, auth service."},observability:{color:"#10b981",icon:ci.Eye,description:"Metrics, logs, traces \u2014 operational telemetry."},cloud:{color:"#0284c7",icon:ci.Cloud,description:"Managed cloud service (compute, hosted, etc.)."},frontend:{color:"#f472b6",icon:ci.Monitor,description:"User-facing surface \u2014 browser, mobile, CLI."},page:{color:"#fb7185",icon:ci.LayoutTemplate,description:"Route-level UI screen mapped to a URL."},component:{color:"#8b5cf6",icon:ci.Component,description:"Reusable UI component / view fragment."},store:{color:"#facc15",icon:ci.Boxes,description:"Client-side state container \u2014 Redux, Zustand, Pinia."},hook:{color:"#0d9488",icon:ci.Anchor,description:"Reusable client logic \u2014 React hook, Vue composable."},external:{color:"#94a3b8",icon:ci.ExternalLink,description:"Third-party system you don't own."},human:{color:"#60a5fa",icon:ci.UserRound,description:"Human actor \u2014 end user, operator, or customer."},module:{color:"#7dd3fc",icon:ci.Package,description:"Module / component grouping (logical container)."},custom:{color:"#64748b",icon:ci.Box,description:"Container or anything not in the taxonomy."}};var Kz=mi(hc(),1),WOe=36,z6r=128,$6r=7,tln=20,nln=24;function rln({participant:o,nodeKind:c}){let u=c?Vm[c]:void 0,p=u?.color??"var(--archik-fg-muted)",f=(56-WOe)/2,y=u?.icon,w=Math.max(z6r,o.label.length*$6r+nln+(y?tln:0)),v=w/2,_=y?v+tln/2:v,T=o.status,R=T==="proposed"?.55:T==="deprecated"?.35:1,F=T==="proposed"||T==="deprecated"?"4 3":void 0;return(0,Kz.jsxs)("g",{transform:`translate(${o.cx-v}, ${f})`,opacity:R,children:[(0,Kz.jsx)("rect",{width:w,height:WOe,rx:8,fill:"var(--archik-node-fill)",stroke:p,strokeWidth:1.4,...F!==void 0?{strokeDasharray:F}:{}}),y&&(0,Kz.jsx)("g",{transform:`translate(${nln/2}, ${(WOe-14)/2})`,children:(0,Kz.jsx)(y,{size:14,color:p,strokeWidth:1.5})}),(0,Kz.jsx)("text",{x:_,y:WOe/2+4,textAnchor:"middle",fontSize:12,fontWeight:500,fill:"var(--archik-fg)",fontFamily:"inherit",children:o.label})]})}var oln=mi(hc(),1);function iln({participant:o}){let c=o.status,u=c==="proposed"?.35:c==="deprecated"?.25:.6;return(0,oln.jsx)("line",{x1:o.cx,y1:56,x2:o.cx,y2:o.lifelineEndY,stroke:"var(--archik-fg-muted)",strokeWidth:1.2,strokeDasharray:"6 5",opacity:u})}function u2t(o,c){let u=o.x-c.x,p=o.y-c.y,f=Math.hypot(u,p);if(f<.01)return null;let y=u/f,w=p/f;return{ux:y,uy:w,px:-w,py:y,len:f}}var n0=o=>String(Math.round(o*100)/100);function AG(o,c,u=10,p=4){let f=u2t(o,c);if(!f)return"";let y=o.x-f.ux*u,w=o.y-f.uy*u;return`M ${n0(y+f.px*p)} ${n0(w+f.py*p)} L ${n0(o.x)} ${n0(o.y)} L ${n0(y-f.px*p)} ${n0(w-f.py*p)} Z`}function JOe(o,c,u=10,p=4.5){let f=u2t(o,c);if(!f)return"";let y=o.x-f.ux*u,w=o.y-f.uy*u;return`M ${n0(y+f.px*p)} ${n0(w+f.py*p)} L ${n0(o.x)} ${n0(o.y)} L ${n0(y-f.px*p)} ${n0(w-f.py*p)}`}function cln(o,c,u=14,p=6){return AG(o,c,u,p)}function aln(o,c,u=14,p=4.5){let f=u2t(c,o);if(!f)return"";let y=o.x+f.ux*(u/2),w=o.y+f.uy*(u/2),v=o.x+f.ux*u,_=o.y+f.uy*u;return`M ${n0(o.x)} ${n0(o.y)} L ${n0(y+f.px*p)} ${n0(w+f.py*p)} L ${n0(v)} ${n0(_)} L ${n0(y-f.px*p)} ${n0(w-f.py*p)} Z`}var Rv=mi(hc(),1),ZOe=32,lne=20,j6r=-6,XOe="var(--archik-edge-filled)";function sln({msg:o}){let c=o.arrow==="return",u=o.arrow==="async",p=o.arrow==="create",f=c||p,y=o.arrow==="destroy",w=c||u,v=o.status==="proposed"?.5:o.status==="deprecated"?.35:1,_=(B,V)=>w?(0,Rv.jsx)("path",{"data-archik-arrowhead":"end",d:JOe(B,V),fill:"none",stroke:XOe,strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"}):(0,Rv.jsx)("path",{"data-archik-arrowhead":"end",d:AG(B,V),fill:XOe});if(o.isSelf){let B=o.fromCx,V=o.y,se=`M ${B} ${V} L ${B+ZOe} ${V} L ${B+ZOe} ${V+lne} L ${B} ${V+lne}`;return(0,Rv.jsxs)("g",{opacity:v,children:[(0,Rv.jsx)("path",{d:se,fill:"none",stroke:XOe,strokeWidth:1.4}),_({x:B,y:V+lne},{x:B+ZOe,y:V+lne}),(0,Rv.jsx)("text",{x:B+ZOe+6,y:V+lne/2+4,fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:o.label})]})}let R=o.fromCx<o.toCx?o.toCx-6:o.toCx+6,F=(o.fromCx+o.toCx)/2;return(0,Rv.jsxs)("g",{opacity:v,children:[(0,Rv.jsx)("line",{x1:o.fromCx,y1:o.y,x2:R,y2:o.y,stroke:XOe,strokeWidth:1.4,strokeDasharray:f?"4 4":void 0}),!y&&_({x:o.toCx,y:o.y},{x:o.fromCx,y:o.y}),(0,Rv.jsxs)("text",{x:F,y:o.y+j6r,textAnchor:"middle",fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:[p&&"\xABcreate\xBB ",o.label]}),o.arrow==="destroy"&&(0,Rv.jsxs)("g",{transform:`translate(${o.toCx-6}, ${o.y-6})`,children:[(0,Rv.jsx)("line",{x1:0,y1:0,x2:12,y2:12,stroke:"var(--archik-fg-muted)",strokeWidth:1.5}),(0,Rv.jsx)("line",{x1:12,y1:0,x2:0,y2:12,stroke:"var(--archik-fg-muted)",strokeWidth:1.5})]})]})}var Y9=mi(hc(),1),B6r={alt:"#6366f1",opt:"#0ea5e9",loop:"#10b981",par:"#f59e0b",break:"#ef4444",ref:"#8b5cf6"},lln=36,d2t=18;function uln({group:o,renderStep:c,onRefClick:u}){let p=B6r[o.kind]??"var(--archik-fg-muted)",f=o.status==="proposed"?.55:o.status==="deprecated"?.35:1,y=o.kind==="ref"&&o.seqFile!==void 0&&u!==void 0;return(0,Y9.jsxs)("g",{opacity:f,onClick:y?()=>u(o.seqFile):void 0,style:y?{cursor:"pointer"}:void 0,children:[(0,Y9.jsx)("rect",{x:o.x,y:o.y,width:o.width,height:o.height,rx:4,fill:"none",stroke:p,strokeWidth:1.2,opacity:.8}),(0,Y9.jsx)("rect",{x:o.x,y:o.y,width:lln,height:d2t,rx:4,fill:p,opacity:.8}),(0,Y9.jsx)("text",{x:o.x+6,y:o.y+d2t-5,fontSize:10,fontWeight:600,fill:"#fff",fontFamily:"inherit",children:o.kind}),(o.condition??o.label)&&(0,Y9.jsx)("text",{x:o.x+lln+6,y:o.y+d2t-5,fontSize:10,fill:p,fontFamily:"inherit",children:o.condition??o.label}),o.branches.map((w,v)=>(0,Y9.jsxs)("g",{children:[w.label&&(0,Y9.jsx)("text",{x:o.x+6,y:w.startY+12,fontSize:10,fill:p,fontFamily:"inherit",children:w.label}),w.steps.map(_=>c(_)),w.dividerY!==void 0&&(0,Y9.jsx)("line",{x1:o.x,y1:w.dividerY,x2:o.x+o.width,y2:w.dividerY,stroke:p,strokeWidth:1,strokeDasharray:"4 2",opacity:.65})]},v))]})}var NG=mi(hc(),1);function H6r(o,c){let u=Math.max(10,Math.floor(c/6.5));if(o.length<=u)return[o];let p=o.split(" "),f=[],y="";for(let w of p)(y+(y?" ":"")+w).length>u&&y?(f.push(y),y=w):y=y?y+" "+w:w;return y&&f.push(y),f.slice(0,3)}function dln({note:o}){let{x:c,y:u,width:p,height:f,text:y}=o,w=o.status==="proposed"?.55:o.status==="deprecated"?.35:1;return(0,NG.jsxs)("g",{opacity:w,children:[(0,NG.jsx)("path",{d:`M ${c} ${u} L ${c+p-10} ${u} L ${c+p} ${u+10} L ${c+p} ${u+f} L ${c} ${u+f} Z`,fill:"var(--archik-node-fill)",stroke:"var(--archik-node-stroke)",strokeWidth:1.2}),(0,NG.jsx)("path",{d:`M ${c+p-10} ${u} L ${c+p-10} ${u+10} L ${c+p} ${u+10}`,fill:"none",stroke:"var(--archik-node-stroke)",strokeWidth:1.2}),H6r(y,p-16).map((v,_)=>(0,NG.jsx)("text",{x:c+8,y:u+8+11+_*13,fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:v},_))]})}var O3=mi(hc(),1);function fln({step:o,onRefClick:c}){return o.type==="message"?(0,O3.jsx)(sln,{msg:o}):o.type==="note"?(0,O3.jsx)(dln,{note:o}):o.type==="group"?(0,O3.jsx)(uln,{group:o,...c!==void 0?{onRefClick:c}:{},renderStep:u=>(0,O3.jsx)(fln,{step:u,...c!==void 0?{onRefClick:c}:{}},u.id)}):null}function pln({laid:o,svgRef:c,onRefClick:u}){let{participants:p,steps:f,activations:y,totalWidth:w,totalHeight:v}=o;return(0,O3.jsxs)("svg",{ref:c,width:w,height:v,viewBox:`0 0 ${w} ${v}`,xmlns:"http://www.w3.org/2000/svg",style:{fontFamily:"var(--archik-font, system-ui)"},children:[p.map(_=>(0,O3.jsx)(iln,{participant:_},_.id)),p.map(_=>(0,O3.jsx)(rln,{participant:_,..._.kind!==void 0?{nodeKind:_.kind}:{}},_.id)),(0,O3.jsxs)("g",{transform:`translate(0, ${56})`,children:[y.map(_=>(0,O3.jsx)("rect",{x:_.cx-8/2,y:_.startY,width:8,height:_.endY-_.startY,fill:"var(--archik-surface)",stroke:"var(--archik-fg-muted)",strokeWidth:1.2,rx:2},`${_.cx}-${_.startY}`)),f.map(_=>(0,O3.jsx)(fln,{step:_,...u!==void 0?{onRefClick:u}:{}},_.id))]})]})}var HE=mi(hc(),1),r0=28;function RG({kind:o,iconAt:c,labelAt:u}){let p=Vm[o],f=p.icon,y=14;return(0,HE.jsxs)(HE.Fragment,{children:[(0,HE.jsx)("g",{transform:`translate(${c.cx-y/2}, ${c.cy-y/2})`,pointerEvents:"none","aria-hidden":"true",children:(0,HE.jsx)(f,{size:y,color:p.color,strokeWidth:1.8})}),(0,HE.jsx)("text",{x:u.cx,y:u.cy,textAnchor:"middle",fontSize:9.5,fontWeight:600,letterSpacing:"0.12em",fill:"var(--archik-node-caption)",children:o.toUpperCase()})]})}var UE=mi(hc(),1),U6r=24;function gln({node:o,selected:c}){let u=o.width,p=o.height,f=o.stack!==void 0,y=r0+(p-r0)/2,w=f?y-4:y+4,v=y+14,_=Math.max(0,u-U6r),T=t0(o.name,_,7.4),R=f?t0(o.stack,_,5.9):"";return(0,UE.jsxs)("g",{className:`archik-node archik-node--${o.kind}`,children:[(0,UE.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:u,height:p,rx:10,ry:10,fill:"var(--archik-node-fill)",stroke:c?"var(--archik-selected)":"var(--archik-node-stroke)",strokeWidth:c?1.8:1.4}),(0,UE.jsx)("line",{x1:0,y1:r0,x2:u,y2:r0,stroke:"var(--archik-node-stroke)",strokeOpacity:.25,strokeWidth:1}),(0,UE.jsx)(RG,{kind:o.kind,iconAt:{cx:18,cy:r0/2},labelAt:{cx:u/2,cy:r0/2+3}}),(0,UE.jsx)("text",{x:u/2,y:w,textAnchor:"middle",fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:T}),f&&(0,UE.jsx)("text",{x:u/2,y:v,textAnchor:"middle",fontSize:11,fill:"var(--archik-node-text-dim)",children:R})]})}var qE=mi(hc(),1);function yln({node:o,selected:c}){let u=o.width,p=o.height,f=Math.min(p/2,28),y=o.stack!==void 0,w=r0+(p-r0)/2,v=y?w-4:w+4,_=w+14,T=Math.max(0,u-2*f-8),R=t0(o.name,T,7.4),F=y?t0(o.stack,T,5.9):"",B=c?"var(--archik-selected)":"var(--archik-node-stroke)";return(0,qE.jsxs)("g",{className:"archik-node archik-node--queue",children:[(0,qE.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:u,height:p,rx:f,ry:f,fill:"var(--archik-node-fill)",stroke:B,strokeWidth:c?1.8:1.4}),(0,qE.jsx)("line",{x1:f,y1:r0,x2:u-f,y2:r0,stroke:B,strokeOpacity:.25,strokeWidth:1}),(0,qE.jsx)(RG,{kind:"queue",iconAt:{cx:f+8,cy:r0/2},labelAt:{cx:u/2,cy:r0/2+3}}),(0,qE.jsx)("text",{x:u/2,y:v,textAnchor:"middle",fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:R}),y&&(0,qE.jsx)("text",{x:u/2,y:_,textAnchor:"middle",fontSize:11,fill:"var(--archik-node-text-dim)",children:F})]})}var GE=mi(hc(),1),q6r=24;function bln({node:o,selected:c}){let u=o.width,p=o.height,f=o.description!==void 0,y=r0,w=y+(p-y)/2,v=f?w-2:w+4,_=p-12,T=Math.max(0,u-q6r),R=t0(o.name,T,7.4),F=f?t0(o.description,T,5.9):"",B=c?"var(--archik-selected)":"var(--archik-node-stroke-soft)";return(0,GE.jsxs)("g",{className:`archik-node archik-node--${o.kind}`,children:[(0,GE.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:u,height:p,rx:8,ry:8,fill:"var(--archik-node-fill-tinted)",stroke:B,strokeWidth:c?1.8:1.2,strokeDasharray:c?void 0:"6 4"}),(0,GE.jsx)("line",{x1:6,y1:r0,x2:u-6,y2:r0,stroke:B,strokeOpacity:.25,strokeWidth:1}),(0,GE.jsx)(RG,{kind:o.kind,iconAt:{cx:18,cy:r0/2},labelAt:{cx:u/2,cy:r0/2+3}}),(0,GE.jsx)("text",{x:u/2,y:v,textAnchor:"middle",fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:R}),f&&(0,GE.jsx)("text",{x:u/2,y:_,textAnchor:"middle",fontSize:10,fill:"var(--archik-node-text-dim)",children:F})]})}var h6=mi(hc(),1),G6r=28,h2t=10,V6r=22;function mln({node:o,selected:c}){let u=o.width,p=o.height,f=u/2,y=h2t,w=Vm[o.kind],v=w.icon,_=c?"var(--archik-selected)":"var(--archik-node-stroke)",T=c?1.8:1.4,R=o.stack!==void 0,F=Math.max(0,u-G6r),B=t0(o.name,F,7.4),V=R?t0(o.stack,F,5.9):"",se=p,ee=se-V6r,ce=(ee+se)/2,ut=(y+8+ee)/2,Se=R?ut-4:ut+4,je=ut+14;return(0,h6.jsxs)("g",{className:"archik-node archik-node--database",children:[(0,h6.jsx)("path",{className:c?"archik-selected-glow":void 0,d:f2t(u,p,y),fill:"var(--archik-node-fill)",stroke:_,strokeWidth:T,strokeLinejoin:"round"}),(0,h6.jsx)("ellipse",{cx:f,cy:y,rx:u/2,ry:y,fill:"var(--archik-node-fill)",stroke:_,strokeWidth:T}),(0,h6.jsx)("text",{x:f,y:Se,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"var(--archik-node-text)",children:B}),R&&(0,h6.jsx)("text",{x:f,y:je,textAnchor:"middle",fontSize:11,fill:"var(--archik-node-text-dim)",children:V}),(0,h6.jsx)("line",{x1:4,y1:ee,x2:u-4,y2:ee,stroke:_,strokeOpacity:.45,strokeWidth:1}),(0,h6.jsx)("g",{transform:`translate(14, ${ce-7})`,pointerEvents:"none","aria-hidden":"true",children:(0,h6.jsx)(v,{size:14,color:w.color,strokeWidth:1.9})}),(0,h6.jsx)("text",{x:f,y:ce+4,textAnchor:"middle",fontSize:9.5,fontWeight:600,letterSpacing:"0.12em",fill:"var(--archik-node-caption)",children:o.kind.toUpperCase()})]})}var W6r=10;function f2t(o,c,u){let p=W6r;return[`M 0 ${u}`,`L 0 ${c-p}`,`A ${p} ${p} 0 0 0 ${p} ${c}`,`L ${o-p} ${c}`,`A ${p} ${p} 0 0 0 ${o} ${c-p}`,`L ${o} ${u}`,`A ${o/2} ${u} 0 0 0 0 ${u}`,"Z"].join(" ")}var bS=mi(hc(),1),J6r=36,wln=18;function vln({node:o,selected:c}){let u=o.width,p=o.height,f=Vm[o.kind],y=f.icon,w=c?"var(--archik-selected)":"var(--archik-node-stroke)",v=c?1.8:1.4,_=o.stack!==void 0,T=Math.max(0,u-J6r),R=t0(o.name,T,7.4),F=_?t0(o.stack,T,5.9):"",B=u/2,V=p*.55,se=_?V-4:V+4,ee=V+14;return(0,bS.jsxs)("g",{className:"archik-node archik-node--cloud",children:[(0,bS.jsx)("path",{className:c?"archik-selected-glow":void 0,d:Z6r(u,p),fill:"var(--archik-node-fill)",stroke:w,strokeWidth:v,strokeLinejoin:"round"}),(0,bS.jsx)("g",{transform:`translate(18, ${wln-6})`,pointerEvents:"none","aria-hidden":"true",children:(0,bS.jsx)(y,{size:14,color:f.color,strokeWidth:1.9})}),(0,bS.jsx)("text",{x:B,y:wln+4,textAnchor:"middle",fontSize:9.5,fontWeight:600,letterSpacing:"0.12em",fill:"var(--archik-node-caption)",children:o.kind.toUpperCase()}),(0,bS.jsx)("text",{x:B,y:se,textAnchor:"middle",fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:R}),_&&(0,bS.jsx)("text",{x:B,y:ee,textAnchor:"middle",fontSize:11,fill:"var(--archik-node-text-dim)",children:F})]})}function Z6r(o,c){let p=c-2,f=c*.62,y=Math.min(c*.18,14),w=o-4,v=c*.5,_=Math.min(w*.15,v*.85),T=Math.min(w*.18,v),R=Math.min(w*.15,v*.85),F=2*(_+T+R),B=Math.max(0,w-F)/4,V=2,se=o-2,ee=V+B,ce=ee+2*_,ge=ce+B,Oe=ge+2*T,ut=Oe+B,Se=ut+2*R;return[`M ${V} ${p-y}`,`Q ${V} ${p} ${V+y} ${p}`,`L ${se-y} ${p}`,`Q ${se} ${p} ${se} ${p-y}`,`L ${se} ${f}`,`L ${Se} ${f}`,`A ${R} ${R} 0 0 0 ${ut} ${f}`,`L ${Oe} ${f}`,`A ${T} ${T} 0 0 0 ${ge} ${f}`,`L ${ce} ${f}`,`A ${_} ${_} 0 0 0 ${ee} ${f}`,`L ${V} ${f}`,"Z"].join(" ")}var hb=mi(hc(),1),DG=32,KOe=14,p2t=14;function kln({node:o,selected:c,depth:u=0}){let p=o.width,f=o.height;if(!(o.children.length>0))return(0,hb.jsx)(K6r,{node:o,selected:!!c});let w=Vm[o.kind],v=w.icon,_=Math.min(.04+u*.06,.22),T=Math.min(.55+u*.12,.95),R=c?"var(--archik-selected)":"var(--archik-container-border)",F=c?1.8:1.2,B=Math.max(0,p-KOe*2-60),V=t0(o.name,B,7.4);return(0,hb.jsxs)("g",{className:`archik-node archik-node--${o.kind} archik-node--container`,children:[(0,hb.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:p,height:f,rx:8,ry:8,fill:w.color,fillOpacity:_,stroke:R,strokeWidth:F,pointerEvents:"none"}),u>=1&&p>8&&f>8&&(0,hb.jsx)("rect",{x:3,y:3,width:p-6,height:f-6,rx:6,ry:6,fill:"none",stroke:w.color,strokeOpacity:Math.min(.18+(u-1)*.06,.32),strokeWidth:1,pointerEvents:"none"}),(0,hb.jsx)("path",{d:X6r(p,DG,8),fill:w.color,fillOpacity:T*.18}),(0,hb.jsx)("line",{x1:0,y1:DG,x2:p,y2:DG,stroke:R,strokeOpacity:.45,strokeWidth:1}),(0,hb.jsx)("g",{transform:`translate(${KOe}, ${DG/2-p2t/2})`,pointerEvents:"none","aria-hidden":"true",children:(0,hb.jsx)(v,{size:p2t,color:w.color,strokeWidth:1.9})}),(0,hb.jsx)("text",{x:KOe+p2t+8,y:DG/2+4,fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:V}),(0,hb.jsx)("text",{x:p-KOe,y:DG/2+3,textAnchor:"end",fontSize:9.5,fontWeight:600,letterSpacing:"0.12em",fill:"var(--archik-node-caption)",children:o.kind.toUpperCase()})]})}function X6r(o,c,u){return`M ${u} 0 H ${o-u} A ${u} ${u} 0 0 1 ${o} ${u} V ${c} H 0 V ${u} A ${u} ${u} 0 0 1 ${u} 0 Z`}function K6r({node:o,selected:c}){let u=o.width,p=o.height,f=Vm[o.kind],y=c?"var(--archik-selected)":"var(--archik-node-stroke-soft)";return(0,hb.jsxs)("g",{className:`archik-node archik-node--${o.kind}`,children:[(0,hb.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:u,height:p,rx:8,ry:8,fill:"var(--archik-node-fill-tinted)",stroke:y,strokeWidth:c?1.8:1.2,strokeDasharray:c?void 0:"5 4"}),(0,hb.jsx)("text",{x:u/2,y:p/2+4,textAnchor:"middle",fontSize:12,fontWeight:600,fill:f.color,children:o.name})]})}var fb=mi(hc(),1),une=24,Mln=10,g2t=28;function xln({node:o,selected:c,depth:u=0}){let p=o.width,f=o.height,y=Vm[o.kind],w=y.icon,v=o.kind==="external";if(o.children.length>0)return(0,fb.jsx)(Y6r,{node:o,selected:!!c,depth:u});let _=c?"var(--archik-selected)":v?"var(--archik-node-stroke-soft)":"var(--archik-node-stroke)",T=v?"var(--archik-node-fill-tinted)":"var(--archik-node-fill)",R=o.kind==="queue"?Math.min(f/2,18):8;return(0,fb.jsxs)("g",{className:`archik-node archik-node--${o.kind} archik-node--compact`,children:[(0,fb.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:p,height:f,rx:R,ry:R,fill:T,stroke:_,strokeWidth:c?1.8:1.4,strokeDasharray:v&&!c?"5 4":void 0}),(0,fb.jsx)("g",{transform:`translate(${Mln}, ${f/2-7})`,pointerEvents:"none","aria-hidden":"true",children:(0,fb.jsx)(w,{size:13,color:y.color,strokeWidth:1.9})}),(0,fb.jsx)("text",{x:g2t,y:f/2+4,fontSize:12,fontWeight:600,fill:"var(--archik-node-text)",children:t0(o.name,Math.max(0,p-g2t-8),5.9)})]})}function Y6r({node:o,selected:c,depth:u}){let p=o.width,f=o.height,y=Vm[o.kind],w=y.icon,v=Math.min(.04+u*.035,.14),_=Math.min(.55+u*.08,.85),T=c?"var(--archik-selected)":"var(--archik-container-border)",R=Math.max(0,p-12-22),F=t0(o.name,R,5.9);return(0,fb.jsxs)("g",{className:`archik-node archik-node--${o.kind} archik-node--compact archik-node--container`,children:[(0,fb.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:p,height:f,rx:6,ry:6,fill:y.color,fillOpacity:v,stroke:T,strokeWidth:c?1.8:1.2}),(0,fb.jsx)("path",{d:Q6r(p,une,6),fill:y.color,fillOpacity:_*.18}),(0,fb.jsx)("line",{x1:0,y1:une,x2:p,y2:une,stroke:T,strokeOpacity:.45,strokeWidth:1}),(0,fb.jsx)("g",{transform:`translate(${Mln}, ${une/2-6})`,pointerEvents:"none","aria-hidden":"true",children:(0,fb.jsx)(w,{size:12,color:y.color,strokeWidth:1.9})}),(0,fb.jsx)("text",{x:g2t,y:une/2+4,fontSize:12,fontWeight:600,fill:"var(--archik-node-text)",children:F})]})}function Q6r(o,c,u){return`M ${u} 0 H ${o-u} A ${u} ${u} 0 0 1 ${o} ${u} V ${c} H 0 V ${u} A ${u} ${u} 0 0 1 ${u} 0 Z`}var Q9=mi(s2t(),1),_d=mi(hc(),1),e8r=12,t8r=18;function Sln({Icon:o,cx:c,cy:u,size:p=e8r,color:f,strokeWidth:y=1.8}){return(0,_d.jsx)("g",{transform:`translate(${c-p/2}, ${u-p/2})`,pointerEvents:"none","aria-hidden":"true",children:(0,_d.jsx)(o,{size:p,color:f??"var(--archik-fg-dim)",strokeWidth:y})})}function _ln(o){return(0,_d.jsx)(Sln,{Icon:Q9.Info,...o})}function Cln(o){return(0,_d.jsx)(Sln,{Icon:Q9.StickyNote,...o})}function Iln({cx:o,cy:c,filePath:u,fileLabel:p,onClick:f,size:y=13}){return(0,_d.jsxs)("g",{transform:`translate(${o-y/2}, ${c-y/2})`,style:{cursor:f?"pointer":"default"},onClick:f,children:[(0,_d.jsx)("title",{children:`Cross-file edge \u2192 ${p} (${u})`}),(0,_d.jsx)("circle",{cx:y/2,cy:y/2,r:y/2+.5,fill:"var(--archik-fg-dim)",fillOpacity:.12,stroke:"var(--archik-fg-dim)",strokeOpacity:.4,strokeWidth:1}),(0,_d.jsx)("g",{transform:"translate(1, 1)",pointerEvents:"none",children:(0,_d.jsx)(Q9.ArrowUpRight,{size:y-2,color:"var(--archik-fg-muted)",strokeWidth:2.2})})]})}function Eln({cx:o,cy:c,onClick:u,size:p=14}){return(0,_d.jsxs)("g",{transform:`translate(${o-p/2}, ${c-p/2})`,style:{cursor:u?"pointer":"default"},onClick:u,children:[(0,_d.jsx)("title",{children:"Open sub-architecture"}),(0,_d.jsx)("circle",{cx:p/2,cy:p/2,r:p/2+.5,fill:"var(--archik-accent)",fillOpacity:.16,stroke:"var(--archik-accent)",strokeOpacity:.45,strokeWidth:1}),(0,_d.jsx)("g",{transform:"translate(1, 1)",pointerEvents:"none",children:(0,_d.jsx)(Q9.ChevronDown,{size:p-2,color:"var(--archik-accent)",strokeWidth:2.2})})]})}function Pln({cx:o,cy:c,files:u,count:p,size:f=14}){let y=u.length===1?`Open sequence diagram \u2192 ${u[0].label} (${u[0].path})`:`${u.length} sequence diagrams on this node:
519
519
  `+u.map(w=>` \u2022 ${w.label}`).join(`
520
520
  `)+`
521
521
  Click to open the first; the rest live in the inspector.`;return(0,_d.jsxs)("g",{transform:`translate(${o-f/2}, ${c-f/2})`,style:{cursor:"pointer"},children:[(0,_d.jsx)("title",{children:y}),(0,_d.jsx)("circle",{cx:f/2,cy:f/2,r:f/2+.5,fill:"var(--archik-status-proposed)",fillOpacity:.16,stroke:"var(--archik-status-proposed)",strokeOpacity:.5,strokeWidth:1}),(0,_d.jsx)("g",{transform:"translate(1, 1)",pointerEvents:"none",children:(0,_d.jsx)(Q9.GitBranch,{size:f-2,color:"var(--archik-status-proposed)",strokeWidth:2.2})}),p!==void 0&&p>1&&(0,_d.jsxs)("g",{pointerEvents:"none",children:[(0,_d.jsx)("circle",{cx:f/2,cy:-3,r:5.5,fill:"var(--archik-canvas)"}),(0,_d.jsx)("circle",{cx:f/2,cy:-3,r:4.5,fill:"var(--archik-status-proposed)"}),(0,_d.jsx)("text",{x:f/2,y:-.5,fontSize:7.5,fontWeight:700,fill:"#ffffff",textAnchor:"middle",children:p})]})]})}function Lln(o,c,u,p=!1){if(p)return{right:{x:c-14,y:42}};switch(o){case"queue":{let y=Math.min(u/2,28);return{right:{x:c-y-4,y:14}}}case"database":return{right:{x:c-14,y:u-11}};case"module":case"custom":return{right:{x:c-14,y:42}};default:return{right:{x:c-14,y:14}}}}function Tln(o,c){return Array.from({length:c},(u,p)=>({x:o.x-p*t8r,y:o.y}))}var hl=mi(hc(),1);function n8r({node:o,selected:c,viewMode:u,depth:p}){if(u==="compact")return(0,hl.jsx)(xln,{node:o,selected:c,depth:p});if(o.children.length>0)return(0,hl.jsx)(kln,{node:o,selected:c,depth:p});switch(o.kind){case"queue":return(0,hl.jsx)(yln,{node:o,selected:c});case"external":case"human":return(0,hl.jsx)(bln,{node:o,selected:c});case"database":return(0,hl.jsx)(mln,{node:o,selected:c});case"cloud":return(0,hl.jsx)(vln,{node:o,selected:c});case"module":case"custom":case"service":case"function":case"worker":case"agent":case"cache":case"vectordb":case"storage":case"model":case"dto":case"dataobject":case"topic":case"stream":case"gateway":case"cdn":case"route":case"interface":case"adapter":case"port":case"llm":case"prompt":case"tool":case"auth":case"observability":case"frontend":case"page":case"component":case"store":case"hook":return(0,hl.jsx)(gln,{node:o,selected:c});default:{let f=o.kind;throw new Error("unreachable node kind")}}}function y2t({node:o,selectedNodeIds:c,glowNodeIds:u,onSelectNode:p,onOpenSubFile:f,onCrossFileNavigate:y,crossFileByNode:w,viewMode:v="detailed",depth:_=0,showStereotypeBands:T=!0}){let R=c?.has(o.id)??!1,F=u?.has(o.id)??!1,B=o.children.length>0,V=B?_+1:_,se=p?ce=>{ce.stopPropagation(),p(o.id,ce)}:void 0,ee=o.description!==void 0&&o.description.length>0;return(0,hl.jsxs)("g",{"data-archik-node-id":o.id,...R?{"data-archik-selected":"true"}:{},...o.status!==void 0&&o.status!=="active"?{"data-archik-status":o.status}:{},...o.stereotype!==void 0?{"data-archik-stereotype":o.stereotype}:{},transform:`translate(${o.x}, ${o.y})`,...se!==void 0?{onClick:se}:{},style:p?{cursor:"pointer"}:void 0,children:[F&&(0,hl.jsx)("rect",{x:-4,y:-4,width:o.width+8,height:o.height+8,rx:10,fill:"none",stroke:"var(--archik-status-proposed)",strokeWidth:2,opacity:.85,style:{pointerEvents:"none"}}),(0,hl.jsx)(n8r,{node:o,selected:R,viewMode:v,depth:_}),o.stereotype!==void 0&&T&&(0,hl.jsxs)(hl.Fragment,{children:[(0,hl.jsx)("clipPath",{id:`archik-nclip-${o.id}`,children:o.kind==="database"?(0,hl.jsx)("path",{d:f2t(o.width,o.height,h2t)}):(0,hl.jsx)("rect",{width:o.width,height:o.height,rx:8,ry:8})}),(0,hl.jsx)("rect",{className:"archik-stereotype-band",x:0,y:0,width:o.width,height:4,clipPath:`url(#archik-nclip-${o.id})`,style:{pointerEvents:"none"}})]}),v==="detailed"&&(()=>{let ce=o.notes!==void 0&&o.notes.length>0,ge=o.archikFile!==void 0&&o.archikFile.length>0,Oe=w?.get(o.id),ut=Oe?Array.from(Oe).sort():[],Se=o.seqFiles??[],je=[];ge&&je.push("subarch"),Se.length>0&&je.push({type:"seq",paths:Se});for(let Gt of ut)je.push({type:"crossfile",path:Gt});if(ee&&je.push("info"),ce&&je.push("notes"),je.length===0)return null;let Be=Lln(o.kind,o.width,o.height,B),tn=Tln(Be.right,je.length);return(0,hl.jsx)(hl.Fragment,{children:je.map((Gt,xn)=>{let Vn=tn[xn];if(typeof Gt=="object"&&Gt.type==="seq"){let nn=Gt.paths.map(Nr=>({path:Nr,label:Nr.split("/").pop().replace(/\.archik\.seq\.yaml$/,"")})),cn=`/__archik/seq?path=${encodeURIComponent(nn[0].path)}`;return(0,hl.jsx)("a",{href:cn,onClick:Nr=>Nr.stopPropagation(),children:(0,hl.jsx)(Pln,{cx:Vn.x,cy:Vn.y,files:nn,count:nn.length})},"seq")}if(typeof Gt=="object"&&Gt.type==="crossfile"){let nn=Gt.path,cn=nn.split("/").pop().replace(/\.archik\.yaml$/,""),Nr=y??f,oi=Nr?wo=>{wo.stopPropagation(),Nr(nn,cn)}:void 0;return(0,hl.jsx)(Iln,{cx:Vn.x,cy:Vn.y,filePath:nn,fileLabel:cn,...oi?{onClick:oi}:{}},`xf-${nn}`)}if(Gt==="subarch"){let nn=o.archikFile,cn=f?Nr=>{Nr.stopPropagation(),f(nn,o.name)}:void 0;return(0,hl.jsx)(Eln,{cx:Vn.x,cy:Vn.y,...cn?{onClick:cn}:{}},"subarch")}return Gt==="info"?(0,hl.jsx)(_ln,{cx:Vn.x,cy:Vn.y,color:"var(--archik-node-caption)"},"info"):(0,hl.jsxs)("g",{children:[(0,hl.jsx)(Cln,{cx:Vn.x,cy:Vn.y,color:"var(--archik-node-caption)"}),o.notes&&o.notes.length>1&&(0,hl.jsx)("text",{x:Vn.x+7,y:Vn.y-5,fontSize:8,fontWeight:700,fill:"var(--archik-accent)",textAnchor:"middle",pointerEvents:"none",children:o.notes.length})]},"notes")})})})(),o.children.map(ce=>(0,hl.jsx)(y2t,{node:ce,viewMode:v,depth:V,showStereotypeBands:T,...c!==void 0?{selectedNodeIds:c}:{},...u!==void 0?{glowNodeIds:u}:{},...p!==void 0?{onSelectNode:p}:{},...f!==void 0?{onOpenSubFile:f}:{},...y!==void 0?{onCrossFileNavigate:y}:{},...w!==void 0?{crossFileByNode:w}:{}},ce.id))]})}var F3=mi(hc(),1),f6="var(--archik-edge-filled)",dne="var(--archik-edge-dim)",r8r={http_call:{stroke:f6,strokeWidth:1.4,strokeDasharray:"2 6",animated:!0,head:"filled"},grpc:{stroke:f6,strokeWidth:1.4,strokeDasharray:"2 6",animated:!0,head:"filled"},invokes:{stroke:f6,strokeWidth:1.4,strokeDasharray:"2 6",animated:!0,head:"filled"},routes_to:{stroke:f6,strokeWidth:1.4,head:"filled"},websocket:{stroke:f6,strokeWidth:1.4,strokeDasharray:"2 6",animated:!0,head:"filled",startHead:"filled"},webhook:{stroke:f6,strokeWidth:1.4,strokeDasharray:"2 6",animated:!0,head:"filled"},reads:{stroke:f6,strokeWidth:1.4,head:"open"},writes:{stroke:f6,strokeWidth:1.4,head:"filled"},publishes:{stroke:f6,strokeWidth:1.4,head:"filled"},subscribes:{stroke:f6,strokeWidth:1.4,head:"filled"},streams_to:{stroke:f6,strokeWidth:1.4,head:"filled"},implements:{stroke:dne,strokeWidth:1.2,strokeDasharray:"7 5",head:"triangle"},extends:{stroke:dne,strokeWidth:1.2,head:"triangle"},depends_on:{stroke:dne,strokeWidth:1.2,strokeDasharray:"7 5",head:"open"},has_a:{stroke:dne,strokeWidth:1.2,head:"open",startHead:"diamond"},uses:{stroke:dne,strokeWidth:1.2,head:"open"}};function Aln(o){return o.map(c=>`${c.x},${c.y}`).join(" ")}function i8r(o){if(o.length===0)return;let c=Math.floor(o.length/2);if(o.length%2===1)return o[c];let u=o[c-1],p=o[c];return{x:(u.x+p.x)/2,y:(u.y+p.y)/2}}function Nln({edge:o,selectedEdgeIds:c,onSelectEdge:u}){let p=o.sections[0];if(!p)return null;let f=[p.startPoint,...p.bendPoints,p.endPoint],y=r8r[o.relationship],w=o.labels[0],v=w?{x:w.x+w.width/2,y:w.y+w.height/2}:i8r(f),_=c?.has(o.id)??!1,T=o.status==="proposed"?"var(--archik-status-proposed)":o.status==="deprecated"?"var(--archik-status-deprecated)":void 0,R=_?"var(--archik-selected)":T??o.color??y.stroke,F=_?y.strokeWidth+.5:y.strokeWidth,B=!_&&y.animated?"archik-edge-flowing":void 0,V=f[f.length-1],se=f[f.length-2]??V,ee=f[0],ce=f[1]??ee,ge=_?"filled":y.head,Oe=_?void 0:y.startHead,ut=y.strokeDasharray!==void 0?y.strokeDasharray.trim().split(/\s+/).reduce((Be,tn)=>Be+Number(tn),0):0,Se=B!==void 0&&ut>0?{"--archik-dash-period":String(ut)}:void 0,je=u?Be=>{Be.stopPropagation(),u(o.id,Be)}:void 0;return(0,F3.jsxs)("g",{"data-archik-edge-id":o.id,"data-archik-edge-relationship":o.relationship,..._?{"data-archik-selected":"true"}:{},...o.status!==void 0&&o.status!=="active"?{"data-archik-status":o.status}:{},className:`archik-edge archik-edge--${o.relationship}`,...je!==void 0?{onClick:je}:{},style:u?{cursor:"pointer"}:void 0,children:[u&&(0,F3.jsx)("polyline",{"data-archik-edge-hitarea":"",points:Aln(f),fill:"none",stroke:"transparent",strokeWidth:14,strokeLinecap:"round",strokeLinejoin:"round"}),(0,F3.jsx)("polyline",{className:B,points:Aln(f),fill:"none",stroke:R,strokeWidth:F,strokeLinecap:"round",strokeLinejoin:"round",...y.strokeDasharray!==void 0?{strokeDasharray:y.strokeDasharray}:{},...Se!==void 0?{style:Se}:{}}),ge==="filled"&&(0,F3.jsx)("path",{"data-archik-arrowhead":"end",d:AG(V,se),fill:R}),ge==="open"&&(0,F3.jsx)("path",{"data-archik-arrowhead":"end",d:JOe(V,se),fill:"none",stroke:R,strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"}),ge==="triangle"&&(0,F3.jsx)("path",{"data-archik-arrowhead":"end",d:cln(V,se),fill:"var(--archik-panel)",stroke:R,strokeWidth:1.8,strokeLinejoin:"round"}),Oe==="filled"&&(0,F3.jsx)("path",{"data-archik-arrowhead":"start",d:AG(ee,ce),fill:R}),Oe==="diamond"&&(0,F3.jsx)("path",{"data-archik-arrowhead":"start",d:aln(ee,ce),fill:R}),o.label!==void 0&&v!==void 0&&(0,F3.jsx)("g",{transform:`translate(${v.x}, ${w?v.y+4:v.y-6})`,children:(0,F3.jsx)("text",{textAnchor:"middle",fontSize:11,fontWeight:_?700:500,fill:_?"var(--archik-selected)":"var(--archik-fg-dim)",stroke:"var(--archik-panel)",strokeWidth:_?4:3,paintOrder:"stroke",children:o.label})})]})}var pb=mi(hc(),1);var b2t={added:"var(--archik-success)",removed:"var(--archik-danger)",changed:"var(--archik-warning)"};function o8r(o){let c=[],u=(p,f,y)=>{for(let w of p){let v=f+w.x,_=y+w.y;c.push({...w,absX:v,absY:_}),w.children.length>0&&u(w.children,v,_)}};return u(o,0,0),c}function c8r(o){return o.replace(/[^a-z0-9-]/g,c=>`\\${c}`)}function Oln({statuses:o,scopeClass:c}){let u=[];for(let[f,y]of o.nodes)y==="removed"&&u.push(f);if(u.length===0)return null;let p=u.map(f=>`.${c} [data-archik-node-id="${c8r(f)}"] { opacity: 0.35; }`).join(`