@sentry/junior-dashboard 0.238.0 → 0.238.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.js CHANGED
@@ -67,7 +67,7 @@ ${l}
67
67
 
68
68
  Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let s=i[1];if(t===i[0]){o(i);continue}if(e.external){let c=e.external.registry.get(i[0])?.id;if(t!==i[0]&&c){o(i);continue}}if(e.metadataRegistry.get(i[0])?.id){o(i);continue}if(s.cycle){o(i);continue}if(s.count>1&&e.reused==="ref"){o(i);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function C7(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let a=[];for(let r of t){if(!r||typeof r!="object")return;C7(r);let n=Object.keys(r);if(n.length!==1||n[0]!=="type")return;let o=r.type;for(let i of Array.isArray(o)?o:[o]){if(typeof i!="string")return;a.includes(i)||a.push(i)}}delete e.anyOf,e.type=a.length===1?a[0]:a}var k7=new Set(["type","properties","required","additionalProperties"]),S7=["oneOf","anyOf"];function w7(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function gP(e){let t=[];for(let o of e){if(typeof o!="object"||o.type!=="object")return null;for(let i in o)if(!k7.has(i))return null;t.push(o)}let a={},r=new Set;for(let o of t){for(let i in o.properties){if(Object.prototype.hasOwnProperty.call(a,i))continue;let s=[];for(let c of t){let d=c.properties?.[i]??w7(c);d!=null&&(s.some(f=>JSON.stringify(f)===JSON.stringify(d))||s.push(d))}let l=s.length===1?s[0]:gP(s)??{allOf:s};Xa(a,i,l)}for(let i of o.required??[])r.add(i)}let n={type:"object",properties:a};if(r.size&&(n.required=[...r]),t.every(o=>o.additionalProperties===!1))n.additionalProperties=!1;else{let o=[];for(let i of t){let s=w7(i);s&&!o.some(l=>JSON.stringify(l)===JSON.stringify(s))&&o.push(s)}o.length===1?n.additionalProperties=o[0]:o.length>1&&(n.additionalProperties={allOf:o})}return n}function xpe(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let n of k7)if(n in e)return;let a=t.filter(n=>S7.some(o=>Array.isArray(n[o]))),r=null;if(!a.length)r=gP(t);else{let n=a[0],o=S7.find(l=>Array.isArray(n[l]));if(Object.keys(n).length!==1)return;let i=t.filter(l=>l!==n),s=n[o].map(l=>gP([...i,l]));if(s.some(l=>!l))return;r={[o]:s}}r&&(delete e.allOf,qb(e,r))}function wd(e,t){let a=e.seen.get(t);if(!a)throw new Error("Unprocessed schema. This is a bug in Zod.");let r=s=>{let l=e.seen.get(s);if(l.ref===null)return;let c=l.def??l.schema,d={...c},f=l.ref;if(l.ref=null,f){r(f);let p=e.seen.get(f),h=p.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(h)):qb(c,h),qb(c,d),s._zod.parent===f)for(let x in c)x==="$ref"||x==="allOf"||x in d||delete c[x];if(h.$ref&&p.def)for(let x in c)x==="$ref"||x==="allOf"||x in p.def&&JSON.stringify(c[x])===JSON.stringify(p.def[x])&&delete c[x]}let m=s._zod.parent;if(m&&m!==f){r(m);let p=e.seen.get(m);if(p?.schema.$ref&&(c.$ref=p.schema.$ref,p.def))for(let h in c)h==="$ref"||h==="allOf"||h in p.def&&JSON.stringify(c[h])===JSON.stringify(p.def[h])&&delete c[h]}e.override({zodSchema:s,jsonSchema:c,path:l.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let s of[...e.seen.entries()].reverse())r(s[0]);if(e.target!=="openapi-3.0")for(let s of e.seen.entries())C7(s[1].def??s[1].schema);for(let s of e.deferred)s();if(e.intersections.length){let s=new Map;for(let l of e.seen.values())for(let c of[l.schema,l.def]){let d=c?.allOf;if(!Array.isArray(d))continue;let f=s.get(d);f?f.push(c):s.set(d,[c])}for(let l of e.intersections)for(let c of s.get(l)??[])xpe(c)}}let n={};if(e.target==="draft-2020-12"?n.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?n.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?n.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");n.$id=e.external.uri(s)}qb(n,a.defId?a.schema:a.def??a.schema);let o=e.metadataRegistry.get(t)?.id;o!==void 0&&n.id===o&&delete n.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let s of e.seen.entries()){let l=s[1];l.def&&l.defId&&(l.def.id===l.defId&&delete l.def.id,Xa(i,l.defId,l.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?n.$defs=i:n.definitions=i);try{let s=JSON.parse(JSON.stringify(n));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:Bh(t,"input",e.processors),output:Bh(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function bo(e,t){let a=t??{seen:new Set};if(a.seen.has(e))return!1;a.seen.add(e);let r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return bo(r.element,a);if(r.type==="set")return bo(r.valueType,a);if(r.type==="lazy")return bo(r.getter(),a);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault"||r.type==="catch")return bo(r.innerType,a);if(r.type==="intersection")return bo(r.left,a)||bo(r.right,a);if(r.type==="record"||r.type==="map")return bo(r.keyType,a)||bo(r.valueType,a);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:bo(r.in,a)||bo(r.out,a);if(r.type==="object"){for(let n in r.shape)if(bo(r.shape[n],a))return!0;return!1}if(r.type==="union"){for(let n of r.options)if(bo(n,a))return!0;return!1}if(r.type==="tuple"){for(let n of r.items)if(bo(n,a))return!0;return!!(r.rest&&bo(r.rest,a))}return!1}var vP=(e,t={})=>a=>{let r=xd({...a,processors:t});return Xt(e,r),Sd(r,e),wd(r,e)},Bh=(e,t,a={})=>r=>{let{libraryOptions:n,target:o}=r??{},i=xd({...n??{},target:o,io:t,processors:a});return Xt(e,i),Sd(i,e),wd(i,e)};var Spe={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},xP=(e,t,a,r)=>{let n=a;n.type="string";let{minimum:o,maximum:i,format:s,patterns:l,contentEncoding:c,laxFormat:d}=e._zod.bag;if(typeof o=="number"&&(n.minLength=o),typeof i=="number"&&(n.maxLength=i),s&&(n.format=Spe[s]??s,n.format===""&&delete n.format,(s==="time"||d)&&delete n.format),c&&(n.contentEncoding=c),l&&l.size>0){let f=[...l];f.length===1?n.pattern=f[0].source:f.length>1&&(n.allOf=[...f.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},SP=(e,t,a,r)=>{let n=a,{minimum:o,maximum:i,format:s,multipleOf:l,exclusiveMaximum:c,exclusiveMinimum:d}=e._zod.bag;typeof s=="string"&&s.includes("int")?n.type="integer":n.type="number";let f=typeof d=="number"&&d>=(o??Number.NEGATIVE_INFINITY),m=typeof c=="number"&&c<=(i??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";f?p?(n.minimum=d,n.exclusiveMinimum=!0):n.exclusiveMinimum=d:typeof o=="number"&&(n.minimum=o),m?p?(n.maximum=c,n.exclusiveMaximum=!0):n.exclusiveMaximum=c:typeof i=="number"&&(n.maximum=i),typeof l=="number"&&(Number.isFinite(l)&&l!==0?n.multipleOf=Math.abs(l):Xn(e,t,n,r,`A multipleOf divisor of ${l} cannot be represented in JSON Schema`))},wP=(e,t,a,r)=>{a.type="boolean"},CP=(e,t,a,r)=>{Xn(e,t,a,r,"BigInt cannot be represented in JSON Schema")},kP=(e,t,a,r)=>{Xn(e,t,a,r,"Symbols cannot be represented in JSON Schema")},IP=(e,t,a,r)=>{t.target==="openapi-3.0"?(a.type="string",a.nullable=!0,a.enum=[null]):a.type="null"},LP=(e,t,a,r)=>{Xn(e,t,a,r,"Undefined cannot be represented in JSON Schema")},TP=(e,t,a,r)=>{Xn(e,t,a,r,"Void cannot be represented in JSON Schema")},RP=(e,t,a,r)=>{a.not={}},_P=(e,t,a,r)=>{},NP=(e,t,a,r)=>{},AP=(e,t,a,r)=>{Xn(e,t,a,r,"Date cannot be represented in JSON Schema")},$P=(e,t,a,r)=>{let n=e._zod.def,o=vb(n.entries);if(o.length===0){a.not={};return}o.every(i=>typeof i=="number")&&(a.type="number"),o.every(i=>typeof i=="string")&&(a.type="string"),a.enum=o},PP=(e,t,a,r)=>{let n=e._zod.def;if(n.values.length===0){a.not={};return}let o=[];for(let i of n.values)if(i===void 0){if(Xn(e,t,a,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(Xn(e,t,a,r,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(i))}else o.push(i);if(o.length!==0)if(o.length===1){let i=o[0];a.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?a.enum=[i]:a.const=i}else o.every(i=>typeof i=="number")&&(a.type="number"),o.every(i=>typeof i=="string")&&(a.type="string"),o.every(i=>typeof i=="boolean")&&(a.type="boolean"),o.every(i=>i===null)&&(a.type="null"),a.enum=o},DP=(e,t,a,r)=>{Xn(e,t,a,r,"NaN cannot be represented in JSON Schema")},EP=(e,t,a,r)=>{let n=a,o=e._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");n.type="string",n.pattern=o.source},MP=(e,t,a,r)=>{let n=a,o={type:"string",format:"binary",contentEncoding:"binary"},{minimum:i,maximum:s,mime:l}=e._zod.bag;i!==void 0&&(o.minLength=i),s!==void 0&&(o.maxLength=s),l?l.length===1?(o.contentMediaType=l[0],Object.assign(n,o)):(Object.assign(n,o),n.anyOf=l.map(c=>({contentMediaType:c}))):Object.assign(n,o)},OP=(e,t,a,r)=>{a.type="boolean"},zP=(e,t,a,r)=>{Xn(e,t,a,r,"Custom types cannot be represented in JSON Schema")},UP=(e,t,a,r)=>{Xn(e,t,a,r,"Function types cannot be represented in JSON Schema")},jP=(e,t,a,r)=>{Xn(e,t,a,r,"Transforms cannot be represented in JSON Schema")},BP=(e,t,a,r)=>{Xn(e,t,a,r,"Map cannot be represented in JSON Schema")},FP=(e,t,a,r)=>{Xn(e,t,a,r,"Set cannot be represented in JSON Schema")},HP=(e,t,a,r)=>{let n=a,o=e._zod.def,{minimum:i,maximum:s}=e._zod.bag;typeof i=="number"&&(n.minItems=i),typeof s=="number"&&(n.maxItems=s),n.type="array",n.items=Xt(o.element,t,{...r,path:[...r.path,"items"]})};function Vb(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?Vb(t.out):t.type==="catch"?Vb(t.innerType):e._zod.optin}var qP=(e,t,a,r)=>{let n=a,o=e._zod.def,i=o.shape;if(Object.getOwnPropertySymbols(i).length&&Xn(e,t,n,r,"Symbol keys cannot be represented in JSON Schema"))return;n.type="object",n.properties={};for(let d in i)Xa(n.properties,d,Xt(i[d],t,{...r,path:[...r.path,"properties",d]}));let l=new Set(Object.keys(i)),c=new Set([...l].filter(d=>{let f=o.shape[d];return t.io==="input"?Vb(f)===void 0:f._zod.optout===void 0}));c.size>0&&(n.required=Array.from(c)),o.catchall?._zod.def.type==="never"?n.additionalProperties=!1:o.catchall?o.catchall&&(n.additionalProperties=Xt(o.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(n.additionalProperties=!1)},pk=(e,t,a,r)=>{let n=e._zod.def,o=n.inclusive===!1,i=n.options.map((s,l)=>Xt(s,t,{...r,path:[...r.path,o?"oneOf":"anyOf",l]}));o?a.oneOf=i:a.anyOf=i},VP=(e,t,a,r)=>{let n=e._zod.def,o=Xt(n.left,t,{...r,path:[...r.path,"allOf",0]}),i=Xt(n.right,t,{...r,path:[...r.path,"allOf",1]}),s=c=>"allOf"in c&&Object.keys(c).length===1,l=[...s(o)?o.allOf:[o],...s(i)?i.allOf:[i]];a.allOf=l,t.intersections.push(l)},ZP=(e,t,a,r)=>{let n=a,o=e._zod.def;n.type="array";let i=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",l=o.items.map((g,x)=>Xt(g,t,{...r,path:[...r.path,i,x]})),c=o.rest?Xt(o.rest,t,{...r,path:[...r.path,s,...t.target==="openapi-3.0"?[o.items.length]:[]]}):null,d=o.items.length;for(;d>0;){let g=o.items[d-1];if(!(t.io==="input"?Vb(g)!==void 0:g._zod.optout==="optional"))break;d--}let f=o.items.length,m=!o.rest;t.target==="draft-2020-12"?(n.prefixItems=l,m?n.items=!1:c&&(n.items=c),d>0&&(n.minItems=d),m&&(n.maxItems=f)):t.target==="openapi-3.0"?(n.items={anyOf:l},c&&n.items.anyOf.push(c),d>0&&(n.minItems=d),m&&(n.maxItems=f)):(n.items=l,m?n.additionalItems=!1:c&&(n.additionalItems=c),d>0&&(n.minItems=d),m&&(n.maxItems=f));let{minimum:p,maximum:h}=e._zod.bag;typeof p=="number"&&(n.minItems=p),typeof h=="number"&&(n.maxItems=h)};function yP(e,t,a){if(t.$ref){if(a.has(t))return t;a.add(t);let h=e.get(t)?.def;if(!h)return t;let g=yP(e,h,a);return g===h?t:g}for(let h of["anyOf","oneOf"]){let g=t[h];if(!Array.isArray(g))continue;let x=g.map(y=>yP(e,y,a));x.some((y,v)=>y!==g[v])&&(t={...t,[h]:x})}let r=Array.isArray(t.type)?t.type:[t.type],n=!r.includes("string")&&r.some(h=>h==="number"||h==="integer"),o=t.enum??(t.const!==void 0?[t.const]:void 0);if(!n&&!o?.some(h=>typeof h=="number"))return t;let{minimum:i,maximum:s,exclusiveMinimum:l,exclusiveMaximum:c,multipleOf:d,format:f,id:m,...p}=t;return p.enum?p.enum=p.enum.map(h=>typeof h=="number"?String(h):h):typeof p.const=="number"&&(p.const=String(p.const)),n&&(p.type="string",o||(p.pattern=(r.includes("number")?vd:Tb).source)),p}var bP=new WeakMap;function wpe(e){let t=new Map;for(let r of e.seen.values())r.def&&!t.has(r.schema)&&t.set(r.schema,r);let a=new Map;for(let r of bP.get(e)??[]){let n=e.seen.get(r),o=(n?.def??n?.schema)?.propertyNames;if(!o||o===!0||a.has(o))continue;let i=yP(t,o,new Set);i!==o&&a.set(o,i)}if(a.size)for(let r of e.seen.values())for(let n of[r.schema,r.def]){let o=n&&a.get(n.propertyNames);o&&(n.propertyNames=o)}}var GP=(e,t,a,r)=>{let n=a,o=e._zod.def;n.type="object";let i=o.keyType,l=i._zod.bag?.patterns;if(o.mode==="loose"&&l&&l.size>0){let f=Xt(o.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});n.patternProperties={};for(let m of l)Xa(n.patternProperties,m.source,f)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){n.propertyNames=Xt(o.keyType,t,{...r,path:[...r.path,"propertyNames"]});let f=bP.get(t);f||(f=[],bP.set(t,f),t.deferred.push(()=>wpe(t))),f.push(e)}n.additionalProperties=Xt(o.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}let c=i._zod.values,d=t.io==="input"&&Vb(o.valueType)!==void 0;if(c&&!o.partial&&!d){let f=[...c].filter(m=>typeof m=="string"||typeof m=="number");f.length>0&&(n.required=f.map(String))}},KP=(e,t,a,r)=>{let n=e._zod.def,o=Xt(n.innerType,t,r),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=n.innerType,a.nullable=!0):a.anyOf=[o,{type:"null"}]},WP=(e,t,a,r)=>{let n=e._zod.def;Xt(n.innerType,t,r);let o=t.seen.get(e);o.ref=n.innerType},JP=Symbol();function I7(e,t,a,r,n){let o=!1,i=JSON.stringify(e,(s,l)=>typeof l!="bigint"?l:(o=!0,null));return o?(Xn(t,a,r,n,"BigInt defaults cannot be represented in JSON Schema"),JP):JSON.parse(i)}var QP=(e,t,a,r)=>{let n=e._zod.def;Xt(n.innerType,t,r);let o=t.seen.get(e);o.ref=n.innerType;let i=I7(n.defaultValue,e,t,a,r);i!==JP&&(a.default=i)},XP=(e,t,a,r)=>{let n=e._zod.def;Xt(n.innerType,t,r);let o=t.seen.get(e);if(o.ref=n.innerType,t.io!=="input")return;let i=I7(n.defaultValue,e,t,a,r);i!==JP&&(a._prefault=i)},YP=(e,t,a,r)=>{let n=e._zod.def;Xt(n.innerType,t,r);let o=t.seen.get(e);o.ref=n.innerType;let i;try{i=n.catchValue(void 0)}catch{Xn(e,t,a,r,"Dynamic catch values are not supported in JSON Schema");return}a.default=i},eD=(e,t,a,r)=>{let n=e._zod.def,o=n.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?o?n.out:n.in:n.out;Xt(i,t,r);let s=t.seen.get(e);s.ref=i},tD=(e,t,a,r)=>{let n=e._zod.def;Xt(n.innerType,t,r);let o=t.seen.get(e);o.ref=n.innerType,a.readOnly=!0},aD=(e,t,a,r)=>{let n=e._zod.def;Xt(n.innerType,t,r);let o=t.seen.get(e);o.ref=n.innerType},hk=(e,t,a,r)=>{let n=e._zod.def;Xt(n.innerType,t,r);let o=t.seen.get(e);o.ref=n.innerType},nD=(e,t,a,r)=>{let n=e._zod.innerType;Xt(n,t,r);let o=t.seen.get(e);o.ref=n},mk={string:xP,number:SP,boolean:wP,bigint:CP,symbol:kP,null:IP,undefined:LP,void:TP,never:RP,any:_P,unknown:NP,date:AP,enum:$P,literal:PP,nan:DP,template_literal:EP,file:MP,success:OP,custom:zP,function:UP,transform:jP,map:BP,set:FP,array:HP,object:qP,union:pk,intersection:VP,tuple:ZP,record:GP,nullable:KP,nonoptional:WP,default:QP,prefault:XP,catch:YP,pipe:eD,readonly:tD,promise:aD,optional:hk,lazy:nD};function gk(e,t){if("_idmap"in e){let r=e,n=xd({...t,processors:mk}),o={};for(let l of r._idmap.entries()){let[c,d]=l;Xt(d,n)}let i={},s={registry:r,uri:t?.uri,defs:o};n.external=s;for(let l of r._idmap.entries()){let[c,d]=l;Sd(n,d),Xa(i,c,wd(n,d))}if(Object.keys(o).length>0){let l=n.target==="draft-2020-12"?"$defs":"definitions";i.__shared={[l]:o}}return{schemas:i}}let a=xd({...t,processors:mk});return Xt(e,a),Sd(a,e),wd(a,e)}var vk=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(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let a=t?.target??"draft-2020-12";a==="draft-4"&&(a="draft-04"),a==="draft-7"&&(a="draft-07"),this.ctx=xd({processors:mk,target:a,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,a={path:[],schemaPath:[]}){return Xt(t,this.ctx,a)}emit(t,a){a&&(a.cycles&&(this.ctx.cycles=a.cycles),a.reused&&(this.ctx.reused=a.reused),a.external&&(this.ctx.external=a.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,Sd(this.ctx,t);let r=wd(this.ctx,t),{"~standard":n,...o}=r;return o}};var L7={};var Jh={};Sl(Jh,{ZodAny:()=>kD,ZodArray:()=>RD,ZodBase64:()=>Mk,ZodBase64URL:()=>Ok,ZodBigInt:()=>Kh,ZodBigIntFormat:()=>jk,ZodBoolean:()=>Gh,ZodCIDRv4:()=>Dk,ZodCIDRv6:()=>Ek,ZodCUID:()=>Tk,ZodCUID2:()=>Rk,ZodCatch:()=>WD,ZodCodec:()=>tx,ZodCreditCard:()=>vD,ZodCustom:()=>ax,ZodCustomStringFormat:()=>Vh,ZodDate:()=>Wb,ZodDefault:()=>HD,ZodDiscriminatedUnion:()=>ND,ZodE164:()=>zk,ZodEmail:()=>Ck,ZodEmoji:()=>Ik,ZodEnum:()=>Hh,ZodExactOptional:()=>qk,ZodFile:()=>UD,ZodFunction:()=>oE,ZodGUID:()=>kk,ZodIPv4:()=>$k,ZodIPv6:()=>Pk,ZodISODate:()=>kd,ZodISODateTime:()=>Cd,ZodISODuration:()=>Ld,ZodISOTime:()=>Id,ZodIntersection:()=>AD,ZodJWT:()=>Uk,ZodKSUID:()=>Ak,ZodLazy:()=>aE,ZodLiteral:()=>zD,ZodMAC:()=>gD,ZodMap:()=>MD,ZodNaN:()=>QD,ZodNanoID:()=>Lk,ZodNever:()=>LD,ZodNonOptional:()=>Vk,ZodNull:()=>wD,ZodNullable:()=>FD,ZodNumber:()=>Zh,ZodNumberFormat:()=>dm,ZodObject:()=>Qb,ZodOptional:()=>Yb,ZodPipe:()=>ex,ZodPrefault:()=>VD,ZodPreprocess:()=>XD,ZodPromise:()=>rE,ZodReadonly:()=>YD,ZodRecord:()=>Fh,ZodSet:()=>OD,ZodString:()=>qh,ZodStringFormat:()=>ua,ZodSuccess:()=>KD,ZodSymbol:()=>xD,ZodTemplateLiteral:()=>tE,ZodTransform:()=>jD,ZodTuple:()=>PD,ZodType:()=>rt,ZodULID:()=>_k,ZodURL:()=>Kb,ZodUUID:()=>Fl,ZodUndefined:()=>SD,ZodUnion:()=>Xb,ZodUnknown:()=>ID,ZodVoid:()=>TD,ZodXID:()=>Nk,ZodXor:()=>_D,_ZodString:()=>wk,_default:()=>qD,_function:()=>M8,any:()=>m8,array:()=>Jb,base64:()=>W7,base64url:()=>J7,bigint:()=>l8,boolean:()=>bD,catch:()=>JD,check:()=>O8,cidrv4:()=>G7,cidrv6:()=>K7,codec:()=>$8,creditCard:()=>X7,cuid:()=>U7,cuid2:()=>j7,custom:()=>z8,date:()=>h8,describe:()=>U8,discriminatedUnion:()=>S8,e164:()=>Q7,email:()=>_7,emoji:()=>O7,enum:()=>Fk,exactOptional:()=>BD,file:()=>R8,float32:()=>r8,float64:()=>o8,function:()=>M8,guid:()=>N7,hash:()=>n8,hex:()=>a8,hostname:()=>t8,httpUrl:()=>M7,instanceof:()=>B8,int:()=>xk,int32:()=>i8,int64:()=>u8,intersection:()=>$D,invertCodec:()=>P8,ipv4:()=>q7,ipv6:()=>Z7,json:()=>H8,jwt:()=>Y7,keyof:()=>g8,ksuid:()=>H7,lazy:()=>nE,literal:()=>T8,looseObject:()=>b8,looseRecord:()=>C8,mac:()=>V7,map:()=>k8,meta:()=>j8,nan:()=>A8,nanoid:()=>z7,nativeEnum:()=>L8,never:()=>Bk,nonoptional:()=>GD,null:()=>CD,nullable:()=>Gb,nullish:()=>_8,number:()=>yD,object:()=>v8,optional:()=>um,partialRecord:()=>w8,pipe:()=>Sk,prefault:()=>ZD,preprocess:()=>q8,promise:()=>E8,readonly:()=>eE,record:()=>ED,refine:()=>iE,set:()=>I8,strictObject:()=>y8,string:()=>Zb,stringFormat:()=>e8,stringbool:()=>F8,success:()=>N8,superRefine:()=>sE,symbol:()=>d8,templateLiteral:()=>D8,transform:()=>Hk,tuple:()=>DD,uint32:()=>s8,uint64:()=>c8,ulid:()=>B7,undefined:()=>f8,union:()=>Wh,unknown:()=>lm,url:()=>E7,uuid:()=>A7,uuidv4:()=>$7,uuidv6:()=>P7,uuidv7:()=>D7,void:()=>p8,xid:()=>F7,xor:()=>x8});var yk={};Sl(yk,{endsWith:()=>Ph,gt:()=>jl,gte:()=>Li,includes:()=>Ah,length:()=>sm,lowercase:()=>_h,lt:()=>Ul,lte:()=>Ii,maxLength:()=>im,maxSize:()=>bd,mime:()=>Dh,minLength:()=>Wu,minSize:()=>Bl,multipleOf:()=>yd,negative:()=>lk,nonnegative:()=>ck,nonpositive:()=>uk,normalize:()=>Eh,overwrite:()=>Ws,positive:()=>sk,properties:()=>fk,property:()=>dk,regex:()=>Rh,size:()=>om,slugify:()=>Uh,startsWith:()=>$h,toLowerCase:()=>Oh,toUpperCase:()=>zh,trim:()=>Mh,uppercase:()=>Nh});var T7=new WeakSet([Object.prototype,Error.prototype]);function bk(e,t,a){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let r=a(this);return Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0})}})}var R7=(e,t)=>{kb.init(e,t),e.name="ZodError";let a=Object.getPrototypeOf(e);T7.has(a)||(T7.add(a),bk(a,"format",r=>n=>Lb(r,n)),bk(a,"flatten",r=>n=>Ib(r,n)),bk(a,"addIssue",r=>n=>{r.issues.push(n),r.message=JSON.stringify(r.issues,yh,2)}),bk(a,"addIssues",r=>n=>{r.issues.push(...n),r.message=JSON.stringify(r.issues,yh,2)}),Object.defineProperty(a,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},kpe=A("ZodError",R7),Xo=A("ZodError",R7,void 0,{Parent:Error});var rD=Sh(Xo),oD=wh(Xo),iD=Ch(Xo),sD=kh(Xo),lD=Xw(Xo),uD=Yw(Xo),cD=eC(Xo),dD=tC(Xo),fD=aC(Xo),mD=nC(Xo),pD=rC(Xo),hD=oC(Xo);function Lpe(){pr.localeError||vn(DC())}function cm(){pr.memoizer||vn({memoizer:Mb()})}var rt=A("ZodType",(e,t)=>(Lpe(),Ke.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(V.mergeDefs(t,{checks:[...t.checks??[],...e.map(a=>typeof a=="function"?{_zod:{check:a,def:{check:"custom"},onattach:[]}}:a)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Qt(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(iE(e,t))},superRefine(e,t){return this.check(sE(e,t))},overwrite(e){return this.check(Ws(e))},optional(){return um(this)},exactOptional(){return BD(this)},nullable(){return Gb(this)},nullish(){return um(Gb(this))},nonoptional(e){return GD(this,e)},array(){return Jb(this)},or(e){return Wh([this,e])},and(e){return $D(this,e)},transform(e){return Sk(this,Hk(e))},default(e){return qD(this,e)},prefault(e){return ZD(this,e)},catch(e){return JD(this,e)},pipe(e){return Sk(this,e)},readonly(){return eE(this)},describe(e){let t=this.clone();return _r.add(t,{description:e}),t},meta(...e){if(e.length===0)return _r.get(this);let t=this.clone();return _r.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return V.hide(this,"~standard",{...gC(this),jsonSchema:{input:Bh(this,"input"),output:Bh(this,"output")}})},set"~standard"(e){V.own(this,"~standard",e)},parse:function e(t,a){return rD(this,t,a,{callee:e})},parseAsync:async function e(t,a){return await oD(this,t,a,{callee:e})},safeParse(e,t){return iD(this,e,t)},async safeParseAsync(e,t){return sD(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){V.own(this,"spa",e)},encode:function e(t,a){return lD(this,t,a,{callee:e})},decode:function e(t,a){return uD(this,t,a,{callee:e})},encodeAsync:async function e(t,a){return await cD(this,t,a,{callee:e})},decodeAsync:async function e(t,a){return await dD(this,t,a,{callee:e})},safeEncode(e,t){return fD(this,e,t)},safeDecode(e,t){return mD(this,e,t)},async safeEncodeAsync(e,t){return pD(this,e,t)},async safeDecodeAsync(e,t){return hD(this,e,t)},toJSONSchema(e){return vP(this,{})(e)},get description(){return _r.get(this)?.description},get _def(){return this._zod.def}}),wk=A("_ZodString",(e,t)=>{em.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>xP(e,r,n,o);let a=e._zod.bag;e.format=a.format??null,e.minLength=a.minimum??null,e.maxLength=a.maximum??null},{regex(...e){return this.check(Rh(...e))},includes(...e){return this.check(Ah(...e))},startsWith(...e){return this.check($h(...e))},endsWith(...e){return this.check(Ph(...e))},min(...e){return this.check(Wu(...e))},max(...e){return this.check(im(...e))},length(...e){return this.check(sm(...e))},nonempty(...e){return this.check(Wu(1,...e))},lowercase(e){return this.check(_h(e))},uppercase(e){return this.check(Nh(e))},trim(){return this.check(Mh())},normalize(...e){return this.check(Eh(...e))},toLowerCase(){return this.check(Oh())},toUpperCase(){return this.check(zh())},slugify(){return this.check(Uh())}}),qh=A("ZodString",(e,t)=>{em.init(e,t),wk.init(e,t)},{email(e){return this.check(jC(Ck,e))},url(e){return this.check(Ub(Kb,e))},jwt(e){return this.check(ik(Uk,e))},emoji(e){return this.check(ZC(Ik,e))},guid(e){return this.check(BC(kk,e))},uuid(e){return this.check(FC(Fl,e))},uuidv4(e){return this.check(HC(Fl,e))},uuidv6(e){return this.check(qC(Fl,e))},uuidv7(e){return this.check(VC(Fl,e))},nanoid(e){return this.check(GC(Lk,e))},cuid(e){return this.check(KC(Tk,e))},cuid2(e){return this.check(WC(Rk,e))},ulid(e){return this.check(JC(_k,e))},base64(e){return this.check(nk(Mk,e))},base64url(e){return this.check(rk(Ok,e))},xid(e){return this.check(QC(Nk,e))},ksuid(e){return this.check(XC(Ak,e))},ipv4(e){return this.check(YC($k,e))},ipv6(e){return this.check(ek(Pk,e))},cidrv4(e){return this.check(tk(Dk,e))},cidrv6(e){return this.check(ak(Ek,e))},e164(e){return this.check(ok(zk,e))},datetime(e){return this.check(jb(Cd,e))},date(e){return this.check(Bb(kd,e))},time(e){return this.check(Fb(Id,e))},duration(e){return this.check(Hb(Ld,e))}});function Zb(e){return D$(qh,e)}var ua=A("ZodStringFormat",(e,t)=>{ta.init(e,t),wk.init(e,t)}),Cd=A("ZodISODateTime",(e,t)=>{I2.init(e,t),ua.init(e,t)}),kd=A("ZodISODate",(e,t)=>{L2.init(e,t),ua.init(e,t)}),Id=A("ZodISOTime",(e,t)=>{T2.init(e,t),ua.init(e,t)}),Ld=A("ZodISODuration",(e,t)=>{R2.init(e,t),ua.init(e,t)}),Ck=A("ZodEmail",(e,t)=>{p2.init(e,t),ua.init(e,t)});function _7(e){return jC(Ck,e)}var kk=A("ZodGUID",(e,t)=>{f2.init(e,t),ua.init(e,t)});function N7(e){return BC(kk,e)}var Fl=A("ZodUUID",(e,t)=>{m2.init(e,t),ua.init(e,t)});function A7(e){return FC(Fl,e)}function $7(e){return HC(Fl,e)}function P7(e){return qC(Fl,e)}function D7(e){return VC(Fl,e)}var Kb=A("ZodURL",(e,t)=>{v2.init(e,t),ua.init(e,t)});function E7(e){return Ub(Kb,e)}function M7(e){return Ub(Kb,{protocol:vo.httpProtocol,hostname:vo.domain,...V.normalizeParams(e)})}var Ik=A("ZodEmoji",(e,t)=>{y2.init(e,t),ua.init(e,t)});function O7(e){return ZC(Ik,e)}var Lk=A("ZodNanoID",(e,t)=>{b2.init(e,t),ua.init(e,t)});function z7(e){return GC(Lk,e)}var Tk=A("ZodCUID",(e,t)=>{x2.init(e,t),ua.init(e,t)});function U7(e){return KC(Tk,e)}var Rk=A("ZodCUID2",(e,t)=>{S2.init(e,t),ua.init(e,t)});function j7(e){return WC(Rk,e)}var _k=A("ZodULID",(e,t)=>{w2.init(e,t),ua.init(e,t)});function B7(e){return JC(_k,e)}var Nk=A("ZodXID",(e,t)=>{C2.init(e,t),ua.init(e,t)});function F7(e){return QC(Nk,e)}var Ak=A("ZodKSUID",(e,t)=>{k2.init(e,t),ua.init(e,t)});function H7(e){return XC(Ak,e)}var $k=A("ZodIPv4",(e,t)=>{_2.init(e,t),ua.init(e,t)});function q7(e){return YC($k,e)}var gD=A("ZodMAC",(e,t)=>{A2.init(e,t),ua.init(e,t)});function V7(e){return M$(gD,e)}var Pk=A("ZodIPv6",(e,t)=>{N2.init(e,t),ua.init(e,t)});function Z7(e){return ek(Pk,e)}var Dk=A("ZodCIDRv4",(e,t)=>{$2.init(e,t),ua.init(e,t)});function G7(e){return tk(Dk,e)}var Ek=A("ZodCIDRv6",(e,t)=>{P2.init(e,t),ua.init(e,t)});function K7(e){return ak(Ek,e)}var Mk=A("ZodBase64",(e,t)=>{D2.init(e,t),ua.init(e,t)});function W7(e){return nk(Mk,e)}var Ok=A("ZodBase64URL",(e,t)=>{E2.init(e,t),ua.init(e,t)});function J7(e){return rk(Ok,e)}var zk=A("ZodE164",(e,t)=>{M2.init(e,t),ua.init(e,t)});function Q7(e){return ok(zk,e)}var vD=A("ZodCreditCard",(e,t)=>{O2.init(e,t),ua.init(e,t)});function X7(e){return O$(vD,e)}var Uk=A("ZodJWT",(e,t)=>{z2.init(e,t),ua.init(e,t)});function Y7(e){return ik(Uk,e)}var Vh=A("ZodCustomStringFormat",(e,t)=>{U2.init(e,t),ua.init(e,t)});function e8(e,t,a={}){return jh(Vh,e,t,a)}function t8(e){return jh(Vh,"hostname",vo.hostname,e)}function a8(e){return jh(Vh,"hex",vo.hex,e)}function n8(e,t){let a=t?.enc??"hex",r=`${e}_${a}`,n=vo[r];if(!n)throw new Error(`Unrecognized hash format: ${r}`);return jh(Vh,r,n,t)}var Zh=A("ZodNumber",(e,t)=>{IC.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>SP(e,r,n,o);let a=e._zod.bag;e.minValue=Math.max(a.minimum??Number.NEGATIVE_INFINITY,a.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(a.maximum??Number.POSITIVE_INFINITY,a.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(a.format??"").includes("int")||Number.isSafeInteger(a.multipleOf??.5),e.isFinite=!0,e.format=a.format??null},{gt(e,t){return this.check(jl(e,t))},gte(e,t){return this.check(Li(e,t))},min(e,t){return this.check(Li(e,t))},lt(e,t){return this.check(Ul(e,t))},lte(e,t){return this.check(Ii(e,t))},max(e,t){return this.check(Ii(e,t))},int(e){return this.check(xk(e))},safe(e){return this.check(xk(e))},positive(e){return this.check(jl(0,e))},nonnegative(e){return this.check(Li(0,e))},negative(e){return this.check(Ul(0,e))},nonpositive(e){return this.check(Ii(0,e))},multipleOf(e,t){return this.check(yd(e,t))},step(e,t){return this.check(yd(e,t))},finite(){return this}});function yD(e){return U$(Zh,e)}var dm=A("ZodNumberFormat",(e,t)=>{j2.init(e,t),Zh.init(e,t)});function xk(e){return B$(dm,e)}function r8(e){return F$(dm,e)}function o8(e){return H$(dm,e)}function i8(e){return q$(dm,e)}function s8(e){return V$(dm,e)}var Gh=A("ZodBoolean",(e,t)=>{$b.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>wP(e,a,r,n)});function bD(e){return Z$(Gh,e)}var Kh=A("ZodBigInt",(e,t)=>{LC.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>CP(e,r,n,o);let a=e._zod.bag;e.minValue=a.minimum??null,e.maxValue=a.maximum??null,e.format=a.format??null},{gte(e,t){return this.check(Li(e,t))},min(e,t){return this.check(Li(e,t))},gt(e,t){return this.check(jl(e,t))},lt(e,t){return this.check(Ul(e,t))},lte(e,t){return this.check(Ii(e,t))},max(e,t){return this.check(Ii(e,t))},positive(e){return this.check(jl(BigInt(0),e))},negative(e){return this.check(Ul(BigInt(0),e))},nonpositive(e){return this.check(Ii(BigInt(0),e))},nonnegative(e){return this.check(Li(BigInt(0),e))},multipleOf(e,t){return this.check(yd(e,t))}});function l8(e){return K$(Kh,e)}var jk=A("ZodBigIntFormat",(e,t)=>{B2.init(e,t),Kh.init(e,t)});function u8(e){return J$(jk,e)}function c8(e){return Q$(jk,e)}var xD=A("ZodSymbol",(e,t)=>{F2.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>kP(e,a,r,n)});function d8(e){return X$(xD,e)}var SD=A("ZodUndefined",(e,t)=>{H2.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>LP(e,a,r,n)});function f8(e){return Y$(SD,e)}var wD=A("ZodNull",(e,t)=>{q2.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>IP(e,a,r,n)});function CD(e){return eP(wD,e)}var kD=A("ZodAny",(e,t)=>{V2.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>_P(e,a,r,n)});function m8(){return tP(kD)}var ID=A("ZodUnknown",(e,t)=>{Z2.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>NP(e,a,r,n)});function lm(){return aP(ID)}var LD=A("ZodNever",(e,t)=>{G2.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>RP(e,a,r,n)});function Bk(e){return nP(LD,e)}var TD=A("ZodVoid",(e,t)=>{K2.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>TP(e,a,r,n)});function p8(e){return rP(TD,e)}var Wb=A("ZodDate",(e,t)=>{W2.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>AP(e,r,n,o),e.min=(r,n)=>e.check(Li(r,n)),e.max=(r,n)=>e.check(Ii(r,n));let a=e._zod.bag;e.minDate=a.minimum?new Date(a.minimum):null,e.maxDate=a.maximum?new Date(a.maximum):null});function h8(e){return oP(Wb,e)}var RD=A("ZodArray",(e,t)=>{cm(),J2.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>HP(e,a,r,n),e.element=t.element},{min(e,t){return this.check(Wu(e,t))},nonempty(e){return this.check(Wu(1,e))},max(e,t){return this.check(im(e,t))},length(e,t){return this.check(sm(e,t))},unwrap(){return this.element}});function Jb(e,t){return lP(RD,e,t)}function g8(e){let t=e._zod.def.shape;return Fk(Object.keys(t))}var Qb=A("ZodObject",(e,t)=>{cm(),Q2.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>qP(e,a,r,n),V.installLazyProp(e,"shape",a=>a._zod.def.shape,!1)},{keyof(){return Fk(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:lm()})},loose(){return this.clone({...this._zod.def,catchall:lm()})},strict(){return this.clone({...this._zod.def,catchall:Bk()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return V.extend(this,e)},safeExtend(e){return V.safeExtend(this,e)},merge(e){return V.merge(this,e)},pick(e){return V.pick(this,e)},omit(e){return V.omit(this,e)},partial(...e){return V.partial(Yb,this,e[0])},exactPartial(...e){return V.partial(qk,this,e[0],"exactPartial")},required(...e){return V.required(Vk,this,e[0])}});function v8(e,t){let a={type:"object",shape:e??{},...V.normalizeParams(t)};return new Qb(a)}function y8(e,t){return new Qb({type:"object",shape:e,catchall:Bk(),...V.normalizeParams(t)})}function b8(e,t){return new Qb({type:"object",shape:e,catchall:lm(),...V.normalizeParams(t)})}var Xb=A("ZodUnion",(e,t)=>{Pb.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>pk(e,a,r,n),e.options=t.options});function Wh(e,t){return new Xb({type:"union",options:e,...V.normalizeParams(t)})}var _D=A("ZodXor",(e,t)=>{Xb.init(e,t),X2.init(e,t),e._zod.processJSONSchema=(a,r,n)=>pk(e,a,r,n),e.options=t.options});function x8(e,t){return new _D({type:"union",options:e,inclusive:!1,...V.normalizeParams(t)})}var ND=A("ZodDiscriminatedUnion",(e,t)=>{Xb.init(e,t),e$.init(e,t)});function S8(e,t,a){return new ND({type:"union",options:t,discriminator:e,...V.normalizeParams(a)})}var AD=A("ZodIntersection",(e,t)=>{t$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>VP(e,a,r,n)});function $D(e,t){return new AD({type:"intersection",left:e,right:t})}var PD=A("ZodTuple",(e,t)=>{cm(),TC.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>ZP(e,a,r,n)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(t=>new Yb({type:"optional",innerType:t}))})}});function DD(e,t,a){let r=t instanceof Ke,n=r?a:t,o=r?t:null;return new PD({type:"tuple",items:e,rest:o,...V.normalizeParams(n)})}var Fh=A("ZodRecord",(e,t)=>{cm(),a$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>GP(e,a,r,n),e.keyType=t.keyType,e.valueType=t.valueType});function ED(e,t,a){return!t||!t._zod?new Fh({type:"record",keyType:Zb(),valueType:e,...V.normalizeParams(t)}):new Fh({type:"record",keyType:e,valueType:t,...V.normalizeParams(a)})}function w8(e,t,a){return new Fh({type:"record",keyType:e,valueType:t,...V.normalizeParams(a),partial:!0})}function C8(e,t,a){return new Fh({type:"record",keyType:e,valueType:t,mode:"loose",...V.normalizeParams(a)})}var MD=A("ZodMap",(e,t)=>{cm(),n$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>BP(e,a,r,n),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...a)=>e.check(Bl(...a)),e.nonempty=a=>e.check(Bl(1,a)),e.max=(...a)=>e.check(bd(...a)),e.size=(...a)=>e.check(om(...a))});function k8(e,t,a){return new MD({type:"map",keyType:e,valueType:t,...V.normalizeParams(a)})}var OD=A("ZodSet",(e,t)=>{cm(),r$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>FP(e,a,r,n),e.min=(...a)=>e.check(Bl(...a)),e.nonempty=a=>e.check(Bl(1,a)),e.max=(...a)=>e.check(bd(...a)),e.size=(...a)=>e.check(om(...a))});function I8(e,t){return new OD({type:"set",valueType:e,...V.normalizeParams(t)})}var Hh=A("ZodEnum",(e,t)=>{o$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>$P(e,r,n,o),e.enum=t.entries,e.options=Object.values(t.entries);let a=new Set(Object.keys(t.entries));e.extract=(r,n)=>{let o={};for(let i of r)if(a.has(i))o[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Hh({...t,checks:[],...V.normalizeParams(n),entries:o})},e.exclude=(r,n)=>{let o={...t.entries};for(let i of r)if(a.has(i))delete o[i];else throw new Error(`Key ${i} not found in enum`);return new Hh({...t,checks:[],...V.normalizeParams(n),entries:o})}});function Fk(e,t){let a=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Hh({type:"enum",entries:a,...V.normalizeParams(t)})}function L8(e,t){return new Hh({type:"enum",entries:e,...V.normalizeParams(t)})}var zD=A("ZodLiteral",(e,t)=>{i$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>PP(e,a,r,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function T8(e,t){return new zD({type:"literal",values:Array.isArray(e)?e:[e],...V.normalizeParams(t)})}var UD=A("ZodFile",(e,t)=>{s$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>MP(e,a,r,n),e.min=(a,r)=>e.check(Bl(a,r)),e.max=(a,r)=>e.check(bd(a,r)),e.mime=(a,r)=>e.check(Dh(Array.isArray(a)?a:[a],r))});function R8(e){return uP(UD,e)}var jD=A("ZodTransform",(e,t)=>{cm(),l$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>jP(e,a,r,n),e._zod.parse=(a,r)=>{if(r.direction==="backward")throw new gd(e.constructor.name);a.addIssue=o=>{if(typeof o=="string")a.issues.push(V.issue(o,a.value,t));else{let i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=a.value),i.inst??(i.inst=e),a.issues.push(V.issue(i))}};let n=t.transform(a.value,a);return n instanceof Promise?n.then(o=>(a.value=o,a)):(a.value=n,a)}});function Hk(e){return new jD({type:"transform",transform:e})}var Yb=A("ZodOptional",(e,t)=>{RC.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>hk(e,a,r,n),e.unwrap=()=>e._zod.def.innerType});function um(e){return new Yb({type:"optional",innerType:e})}var qk=A("ZodExactOptional",(e,t)=>{u$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>hk(e,a,r,n),e.unwrap=()=>e._zod.def.innerType});function BD(e){return new qk({type:"optional",innerType:e})}var FD=A("ZodNullable",(e,t)=>{c$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>KP(e,a,r,n),e.unwrap=()=>e._zod.def.innerType});function Gb(e){return new FD({type:"nullable",innerType:e})}function _8(e){return um(Gb(e))}var HD=A("ZodDefault",(e,t)=>{d$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>QP(e,a,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function qD(e,t){return new HD({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():V.shallowClone(t)}})}var VD=A("ZodPrefault",(e,t)=>{f$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>XP(e,a,r,n),e.unwrap=()=>e._zod.def.innerType});function ZD(e,t){return new VD({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():V.shallowClone(t)}})}var Vk=A("ZodNonOptional",(e,t)=>{m$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>WP(e,a,r,n),e.unwrap=()=>e._zod.def.innerType});function GD(e,t){return new Vk({type:"nonoptional",innerType:e,...V.normalizeParams(t)})}var KD=A("ZodSuccess",(e,t)=>{p$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>OP(e,a,r,n),e.unwrap=()=>e._zod.def.innerType});function N8(e){return new KD({type:"success",innerType:e})}var WD=A("ZodCatch",(e,t)=>{h$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>YP(e,a,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function JD(e,t){return new WD({type:"catch",innerType:e,catchValue:typeof t=="function"?t:V.constantCatch(t)})}var QD=A("ZodNaN",(e,t)=>{g$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>DP(e,a,r,n)});function A8(e){return sP(QD,e)}var ex=A("ZodPipe",(e,t)=>{_C.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>eD(e,a,r,n),e.in=t.in,e.out=t.out});function Sk(e,t){return new ex({type:"pipe",in:e,out:t})}var tx=A("ZodCodec",(e,t)=>{ex.init(e,t),Db.init(e,t)});function $8(e,t,a){return new tx({type:"pipe",in:e,out:t,transform:a.decode,reverseTransform:a.encode})}function P8(e){let t=e._zod.def;return new tx({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var XD=A("ZodPreprocess",(e,t)=>{ex.init(e,t),v$.init(e,t)}),YD=A("ZodReadonly",(e,t)=>{y$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>tD(e,a,r,n),e.unwrap=()=>e._zod.def.innerType});function eE(e){return new YD({type:"readonly",innerType:e})}var tE=A("ZodTemplateLiteral",(e,t)=>{b$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>EP(e,a,r,n)});function D8(e,t){return new tE({type:"template_literal",parts:e,...V.normalizeParams(t)})}var aE=A("ZodLazy",(e,t)=>{Eb.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>nD(e,a,r,n),e.unwrap=()=>e._zod.def.getter()});function nE(e){return new aE({type:"lazy",getter:e})}var rE=A("ZodPromise",(e,t)=>{S$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>aD(e,a,r,n),e.unwrap=()=>e._zod.def.innerType});function E8(e){return new rE({type:"promise",innerType:e})}var oE=A("ZodFunction",(e,t)=>{x$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>UP(e,a,r,n)});function M8(e){return new oE({type:"function",input:Array.isArray(e?.input)?DD(e?.input):e?.input??Jb(lm()),output:e?.output??lm()})}var ax=A("ZodCustom",(e,t)=>{w$.init(e,t),rt.init(e,t),e._zod.processJSONSchema=(a,r,n)=>zP(e,a,r,n)});function O8(e){let t=new ya({check:"custom"});return t._zod.check=e,t}function z8(e,t){return cP(ax,e??(()=>!0),t)}function iE(e,t={}){return dP(ax,e,t)}function sE(e,t){return fP(e,t)}var U8=mP,j8=pP;function B8(e,t={}){let a=new ax({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...V.normalizeParams(t)});return a._zod.bag.Class=e,a._zod.check=r=>{r.value instanceof e||r.issues.push({code:"invalid_type",expected:e.name,input:r.value,inst:a,path:[...a._zod.def.path??[]]})},a}var F8=(...e)=>hP({Codec:tx,Boolean:Gh,String:qh},...e);function H8(e){let t=nE(()=>Wh([Zb(e),yD(),bD(),CD(),Jb(t),ED(Zb(),t)]));return t}function q8(e,t){return new XD({type:"pipe",in:Hk(e),out:t})}var Tpe={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 Rpe(e){vn({customError:e})}function _pe(){return vn().customError}var lE;lE||(lE={});var nx={};Sl(nx,{ZodISODate:()=>kd,ZodISODateTime:()=>Cd,ZodISODuration:()=>Ld,ZodISOTime:()=>Id,date:()=>Ape,datetime:()=>Npe,duration:()=>Ppe,time:()=>$pe});function Npe(e){return jb(Cd,e)}function Ape(e){return Bb(kd,e)}function $pe(e){return Fb(Id,e)}function Ppe(e){return Hb(Ld,e)}var le={...Jh,...yk,iso:nx},Dpe=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 Epe(e,t){let a=e.$schema;return a==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":a==="http://json-schema.org/draft-07/schema#"?"draft-7":a==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function V8(e,t){return e.map((a,r)=>r<t?a:a.optional())}function Mpe(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Ope(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let a=e.slice(1).split("/").filter(Boolean);if(a.length===0)return t.rootSchema;let r=t.version==="draft-2020-12"?"$defs":"definitions";if(a[0]===r){let n=a[1]===void 0?void 0:Mpe(a[1]);if(!n||!t.defs[n])throw new Error(`Reference not found: ${e}`);return t.defs[n]}throw new Error(`Reference not found: ${e}`)}function zpe(e,t){return le.transform(r=>r).check(r=>{let n=r.value;if(!(typeof n!="object"||n===null||Array.isArray(n)))for(let o of Object.getOwnPropertyNames(n)){let i=t.safeParse(o);i.success||r.issues.push({code:"invalid_key",origin:"record",issues:i.error.issues,input:o,path:[o],continue:!0})}}).pipe(e)}function Z8(e,t){if(e!==!1)return e===void 0||e===!0?le.any():Yo(e,t)}var Upe=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function G8(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return le.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return le.lazy(()=>{if(!t.refs.has(n))throw new Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let o=Ope(n,t),i=Yo(o,t);return t.refs.set(n,i),t.processing.delete(n),i}if(e.enum!==void 0){let n=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&n.length===1&&n[0]===null)return le.null();if(n.length===0)return le.never();if(n.length===1)return le.literal(n[0]);if(n.every(i=>typeof i=="string"))return le.enum(n);let o=n.map(i=>le.literal(i));return o.length<2?o[0]:le.union([o[0],o[1],...o.slice(2)])}if(e.const!==void 0)return le.literal(e.const);let a=e.type;if(Array.isArray(a)){let n=a.map(o=>{let i={...e,type:o};return G8(i,t)});return n.length===0?le.never():n.length===1?n[0]:le.union(n)}if(!a)return le.any();let r;switch(a){case"string":{let n=le.string();if(e.format){let o=e.format;o==="email"?n=n.check(le.email()):o==="uri"||o==="uri-reference"?n=n.check(le.url()):o==="uuid"||o==="guid"?n=n.check(le.uuid()):o==="date-time"?n=n.check(le.iso.datetime({offset:!0})):o==="date"?n=n.check(le.iso.date()):o==="time"?n=n.check(le.regex(Upe)):o==="duration"?n=n.check(le.iso.duration()):o==="hostname"?n=n.check(le.hostname()):o==="ipv4"?n=n.check(le.ipv4()):o==="ipv6"?n=n.check(le.ipv6()):o==="mac"?n=n.check(le.mac()):o==="cidr"?n=n.check(le.cidrv4()):o==="cidr-v6"?n=n.check(le.cidrv6()):o==="base64"?n=n.check(le.base64()):o==="base64url"?n=n.check(le.base64url()):o==="e164"?n=n.check(le.e164()):o==="credit_card"?n=n.check(le.creditCard()):o==="jwt"?n=n.check(le.jwt()):o==="emoji"?n=n.check(le.emoji()):o==="nanoid"?n=n.check(le.nanoid()):o==="cuid"?n=n.check(le.cuid()):o==="cuid2"?n=n.check(le.cuid2()):o==="ulid"?n=n.check(le.ulid()):o==="xid"?n=n.check(le.xid()):o==="ksuid"&&(n=n.check(le.ksuid()))}typeof e.minLength=="number"&&(n=n.min(e.minLength)),typeof e.maxLength=="number"&&(n=n.max(e.maxLength)),e.pattern&&(n=n.regex(new RegExp(e.pattern))),r=n;break}case"number":case"integer":{let n=a==="integer"?le.number().int():le.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(n=n.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(n=n.max(e.maximum)),typeof e.exclusiveMinimum=="number"?n=n.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(n=n.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?n=n.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(n=n.lt(e.maximum)),typeof e.multipleOf=="number"&&(n=n.multipleOf(e.multipleOf)),r=n;break}case"boolean":{r=le.boolean();break}case"null":{r=le.null();break}case"object":{let n={},o=e.properties||{},i=new Set(e.required||[]),s=typeof e.additionalProperties=="object"?Yo(e.additionalProperties,t):void 0;for(let[l,c]of Object.entries(o)){let d=Yo(c,t);Xa(n,l,i.has(l)?d:d.optional())}if(e.patternProperties){let l=e.patternProperties,c=Object.keys(l),d=[];for(let m of c){let p=Yo(l[m],t),h=le.string().regex(new RegExp(m));d.push(le.looseRecord(h,p))}let f=[];if(Object.keys(n).length>0&&f.push(le.object(n).passthrough()),f.push(...d),f.length===0)r=le.object({}).passthrough();else if(f.length===1)r=f[0];else{let m=le.intersection(f[0],f[1]);for(let p=2;p<f.length;p++)m=le.intersection(m,f[p]);r=m}if(e.additionalProperties===!1){let m=Object.keys(n),p=c.map(g=>new RegExp(g)),h=r;r=r.check(g=>{if(!us(g.value))return;let x=[];for(let y of Object.keys(g.value))m.includes(y)||p.some(v=>v.test(y))||x.push(y);x.length&&g.issues.push({code:"unrecognized_keys",keys:x,input:g.value,inst:h})})}}else{let l=le.object(n);e.additionalProperties===!1?r=l.strict():s?r=l.catchall(s):r=l.passthrough()}if(e.propertyNames!==void 0&&e.propertyNames!==!0){let l=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;r=zpe(r,Yo(l,t))}break}case"array":{let n=e.prefixItems,o=e.items;if(n&&Array.isArray(n)){let i=typeof e.minItems=="number"?e.minItems:0,s=n.map(f=>Yo(f,t)),l=V8(s,i),c=Array.isArray(o)?void 0:Z8(o,t),d=le.tuple(l);r=c?d.rest(c):d,typeof e.minItems=="number"&&(r=r.check(le.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(le.maxLength(e.maxItems)))}else if(Array.isArray(o)){let i=typeof e.minItems=="number"?e.minItems:0,s=o.map(f=>Yo(f,t)),l=V8(s,i),c=Z8(e.additionalItems,t),d=le.tuple(l);r=c?d.rest(c):d,typeof e.minItems=="number"&&(r=r.check(le.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(le.maxLength(e.maxItems)))}else if(o!==void 0){let i=Yo(o,t),s=le.array(i);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),r=s}else r=le.array(le.any());break}default:throw new Error(`Unsupported type: ${a}`)}return r}function Yo(e,t){if(typeof e=="boolean")return e?le.any():le.never();let a=G8(e,t),r=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let s=e.anyOf.map(c=>Yo(c,t)),l=le.union(s);a=r?le.intersection(a,l):l}if(e.oneOf&&Array.isArray(e.oneOf)){let s=e.oneOf.map(c=>Yo(c,t)),l=le.xor(s);a=r?le.intersection(a,l):l}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)a=r?a:le.any();else{let s=r?a:Yo(e.allOf[0],t),l=r?0:1;for(let c=l;c<e.allOf.length;c++)s=le.intersection(s,Yo(e.allOf[c],t));a=s}e.nullable===!0&&t.version==="openapi-3.0"&&(a=le.nullable(a)),e.readOnly===!0&&(a=le.readonly(a)),e.default!==void 0&&(a=a.default(e.default));let n={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of o)s in e&&(n[s]=e[s]);let i=["contentEncoding","contentMediaType","contentSchema"];for(let s of i)s in e&&(n[s]=e[s]);e.propertyNames!==void 0&&e.type==="object"&&e.$ref===void 0&&(n.propertyNames=e.propertyNames);for(let s of Object.keys(e))Dpe.has(s)||Xa(n,s,e[s]);return Object.keys(n).length>0&&t.registry.add(a,n),e.description&&(a=a.describe(e.description)),a}function K8(e,t){if(typeof e=="boolean")return e?le.any():le.never();let a;try{a=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let r=Epe(a,t?.defaultTarget),n=a.$defs||a.definitions||{},o={version:r,defs:n,refs:new Map,processing:new Set,rootSchema:a,registry:t?.registry??_r};return Yo(a,o)}var W8=Symbol("z.visit/resolving");function rx(e,t){let a=typeof t=="function"?t:(i,s)=>{let l=t[i._zod.def.type];return l?l(i,s):i},r=new Map;function n(i){let s=r.get(i);if(s===W8)return new Eb({type:"lazy",getter:()=>r.get(i)});if(s!==void 0)return s;r.set(i,W8);let l=o(i),c=a(l,l!==i);return r.set(i,c),c}function o(i){let s=i._zod.def,l=s.type;switch(l){case"object":{let c=s.shape,d=Object.keys(c),f=!1,m={};for(let h of d){let g=n(c[h]);g!==c[h]&&(f=!0),m[h]=g}let p=s.catchall;return s.catchall&&(p=n(s.catchall),p!==s.catchall&&(f=!0)),f?Qt(i,{...s,shape:m,catchall:p}):i}case"array":{let c=n(s.element);return c===s.element?i:Qt(i,{...s,element:c})}case"tuple":{let c=s.items,d=!1,f=[];for(let p of c){let h=n(p);h!==p&&(d=!0),f.push(h)}let m=s.rest;return s.rest&&(m=n(s.rest),m!==s.rest&&(d=!0)),d?Qt(i,{...s,items:f,rest:m}):i}case"record":case"map":{let c=n(s.keyType),d=n(s.valueType);return c===s.keyType&&d===s.valueType?i:Qt(i,{...s,keyType:c,valueType:d})}case"set":{let c=n(s.valueType);return c===s.valueType?i:Qt(i,{...s,valueType:c})}case"union":{let c=s.options,d=!1,f=[];for(let m of c){let p=n(m);p!==m&&(d=!0),f.push(p)}return d?Qt(i,{...s,options:f}):i}case"intersection":{let c=n(s.left),d=n(s.right);return c===s.left&&d===s.right?i:Qt(i,{...s,left:c,right:d})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{let c=n(s.innerType);return c===s.innerType?i:Qt(i,{...s,innerType:c})}case"pipe":{let c=n(s.in),d=n(s.out);return c===s.in&&d===s.out?i:Qt(i,{...s,in:c,out:d})}case"function":{let c=n(s.input),d=n(s.output);return c===s.input&&d===s.output?i:Qt(i,{...s,input:c,output:d})}case"lazy":{let c=s.getter,{_cachedInner:d,...f}=s;return Qt(i,{...f,getter:()=>n(c())})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return i;default:return i}}return n(e)}function J8(e){return rx(e,{object:t=>t.partial(),union:t=>{let a=t._zod.def;return a.discriminator===void 0?t:Wh(a.options)}})}function jpe(e,t){if(!t?.length)return e;let a=e._zod.def;return Qt(e,Gs(a,{checks:[...a.checks??[],...t]}),{parent:!0})}function Q8(e){return jpe(e.out,e.checks)}function Bpe(e){return e.in._zod.traits.has("$ZodTransform")?Q8(e):e.in}function X8(e){return rx(e,{pipe:t=>Bpe(t._zod.def),default:(t,a)=>a?um(t._zod.def.innerType):t,catch:(t,a)=>a?t._zod.def.innerType:t})}function Y8(e){return rx(e,{pipe:t=>Q8(t._zod.def),prefault:(t,a)=>a?t._zod.def.innerType:t})}var uE={};Sl(uE,{bigint:()=>Vpe,boolean:()=>qpe,date:()=>Zpe,number:()=>Hpe,string:()=>Fpe});function Fpe(e){return E$(qh,e)}function Hpe(e){return j$(Zh,e)}function qpe(e){return G$(Gh,e)}function Vpe(e){return W$(Kh,e)}function Zpe(e){return iP(Wb,e)}var e9=["none","low","medium","high","xhigh"];var Zk=u.string().regex(/^[a-z][a-z0-9_-]*$/);var Ti=u.string().trim().min(1).max(160),Qh=u.number().int().nonnegative(),Gpe=u.discriminatedUnion("type",[u.strictObject({type:u.literal("code_change"),author:Ti.optional(),sourceBranch:Ti.optional(),targetBranch:Ti.optional(),reviewers:u.array(Ti).max(5).optional(),review:u.enum(["required","approved","changes_requested"]).optional(),checks:u.strictObject({passed:Qh,failed:Qh,pending:Qh}).optional(),mergeable:u.boolean().optional(),changedFiles:Qh.optional(),additions:Qh.optional(),deletions:Qh.optional()}),u.strictObject({type:u.literal("task"),assignees:u.array(Ti).max(5).optional(),priority:Ti.optional(),project:Ti.optional(),cycle:Ti.optional(),dueDate:u.iso.date().optional(),labels:u.array(Ti).max(5).optional()}),u.strictObject({type:u.literal("deployment"),project:Ti.optional(),environment:Ti.optional(),revision:Ti.optional(),branch:Ti.optional()})]);function a9(e){if(!e)return[];let t=[],a=n=>n?.length?`${n.join(", ")}${n.length===5?" (up to 5 shown)":""}`:void 0;function r(n,o,i){i!==void 0&&i!==""&&t.push({key:n,label:o,value:String(i)})}switch(e.type){case"code_change":r("sourceBranch","Branch",e.sourceBranch);break;case"task":r("assignees","Assignees",e.assignees?.length===0?"Unassigned":a(e.assignees)),r("priority","Priority",e.priority),r("project","Project",e.project),r("cycle","Cycle",e.cycle),r("dueDate","Due",e.dueDate),r("labels","Labels",a(e.labels));break;case"deployment":r("environment","Environment",e.environment),r("project","Project",e.project),r("revision","Revision",e.revision),r("branch","Branch",e.branch);break}return t.slice(0,4)}var Yh=u.enum(["task","code_change","automation","deployment","item"]);var cE=u.object({kind:u.literal("object"),key:u.string().trim().min(1).max(256),label:u.string().trim().min(1).max(256),objectType:Yh,title:u.string().trim().min(1).max(512),url:u.url().max(2048).refine(e=>["http:","https:"].includes(new URL(e).protocol)).nullable(),description:u.string().max(4e3).optional(),status:u.string().trim().min(1).max(100).optional(),trigger:u.string().max(4e3).optional(),warning:u.string().max(1e3).optional(),displayType:u.string().trim().min(1).max(80).optional(),sourceUpdatedAt:u.iso.datetime({offset:!0}).optional(),facts:Gpe.refine(e=>new TextEncoder().encode(JSON.stringify(e)).length<=4096,"Object facts must not exceed 4 KiB").optional()}).strict().refine(e=>!e.facts||(e.facts.type==="deployment"?e.objectType==="deployment"||e.objectType==="item":e.facts.type===e.objectType),"Object facts must match the object type"),i4e=cE.safeExtend({plugin:u.string().min(1)});function Kpe(e){try{let t=new URL(e).protocol;return t==="http:"||t==="https:"}catch{return!1}}var Wpe=u.object({kind:u.literal("resource_link"),objectType:Yh.optional(),key:u.string().trim().min(1).max(256),label:u.string().trim().min(1).max(256),url:u.string().url().max(2048).refine(Kpe,"URL must use HTTP or HTTPS."),description:u.string().trim().min(1).max(512).optional(),status:u.enum(["open","draft","closed","merged","warning"]).optional()}).strict(),n9=u.discriminatedUnion("kind",[Wpe,cE]),Jpe=u.enum(["circle-dot","circle-dashed","circle-x","git-merge","git-pull-request","triangle-alert"]),r9=u.object({icon:Jpe.optional(),objectType:Yh.optional(),status:u.string().trim().min(1).max(100).optional(),key:u.string().trim().min(1).max(256),label:u.string().trim().min(1).max(256)}).strict(),ix=u.enum(["closed","merged","open"]),u4e=u.object({closedAt:u.date().optional(),conversationIds:u.array(u.string().min(1)).default([]),mergedAt:u.date().optional(),number:u.number().int().positive(),openedAt:u.date(),providerId:u.string().min(1),repository:u.object({name:u.string().min(1),providerId:u.string().min(1),url:u.string().url().optional()}).strict(),state:ix,title:u.string().min(1).optional(),updatedAt:u.date(),url:u.string().url().optional()}).strict(),d4e=u.string().trim().min(1).max(64).regex(/^[a-z][a-z0-9_]*$/),Qpe=u.enum(["activity","brain","calendar","check","database","info","key","link","sparkles","warning"]),Xpe=u.object({content:u.string().min(1).max(32*1024).optional(),description:u.string().trim().min(1).max(2e3).optional(),metadata:u.array(u.string().trim().min(1).max(120)).max(8).optional(),title:u.string().trim().min(1).max(4e3)}).strict(),o9=u.object({details:u.array(Xpe).max(100).optional(),icon:Qpe.optional(),preview:u.string().trim().min(1).max(500).optional(),title:u.string().trim().min(1).max(120)}).strict();var Kk=u.string().regex(/^T[A-Z0-9]+$/),dE=u.string().regex(/^(C|G|D)[A-Z0-9]+$/),i9=u.string().regex(/^local:[a-z0-9_-]+:[a-z0-9][a-z0-9_-]*$/),Wk=u.string().min(1).refine(e=>e===e.trim()&&e.toLowerCase()!=="unknown"),Gk=Wk,Ue=u.string().refine(e=>e.trim().length>0),Jr=Ue.refine(e=>e===e.trim()),Ype=u.object({id:Ue,provider:Jr}).strict(),ehe=Ype.extend({provider:u.literal("slack"),teamId:Kk,channelId:dE,threadTs:Jr.optional()}).strict(),m4e=u.discriminatedUnion("provider",[ehe]),p4e=u.enum(["slack","local"]),s9=u.enum(["public","private"]),fE=u.enum(["public","private"]),the=u.object({platform:u.literal("slack"),teamId:Kk,channelId:dE,threadTs:Jr.optional()}).strict(),eg=the,ahe=u.object({platform:u.literal("local"),conversationId:i9}).strict(),nhe=u.discriminatedUnion("platform",[eg,ahe]),sx=u.object({action:u.literal("send_message"),destination:eg}).strict(),rhe=u.object({kind:u.literal("slack"),teamId:Kk,channelId:dE,visibility:s9,messageTs:Ue.optional(),threadTs:Ue.optional()}).strict(),ohe=u.object({kind:u.literal("local"),visibility:u.literal("private"),conversationId:i9}).strict(),ihe=u.object({kind:u.literal("web"),visibility:s9,conversationId:Jr}).strict(),she=u.object({kind:u.literal("event"),eventKey:Jr,eventType:Jr,identifier:Jr,namespace:Jr}).strict(),lhe=u.object({kind:u.literal("scheduled_automation")}).strict(),uhe=u.object({kind:u.literal("event_automation")}).strict(),che=u.object({kind:u.literal("plugin_dispatch")}).strict(),dhe=u.object({kind:u.literal("agent_invocation")}).strict(),fhe=u.discriminatedUnion("kind",[rhe,ohe,ihe,she,lhe,uhe,che,dhe]);function mhe(e){if(!e||typeof e!="object"||Array.isArray(e))return e;let t=e;if("kind"in t){let o={event_task:"event_automation",resource_event:"event",scheduled_task:"scheduled_automation"},i=typeof t.kind=="string"?o[t.kind]:void 0;return i?{...t,kind:i}:e}if(t.platform!=="slack"&&t.platform!=="local"&&t.platform!=="web")return e;let{location:a,platform:r,...n}=t;return{...n,kind:r}}var phe=u.preprocess(mhe,fhe),hhe=u.discriminatedUnion("allowedWhen",[u.object({type:u.literal("user"),userId:Gk,allowedWhen:u.literal("private-direct-conversation")}).strict(),u.object({type:u.literal("user"),userId:Gk,allowedWhen:u.literal("scheduled-automation"),taskId:Jr}).strict()]),mE={email:Ue.optional(),fullName:Ue.optional(),userId:Gk,userName:Ue.optional()},ghe=u.object({...mE,platform:u.literal("slack"),teamId:Kk}).strict(),vhe=u.object({...mE,platform:u.literal("local")}).strict(),yhe=u.object({...mE,platform:u.literal("web")}).strict(),bhe=u.object({platform:u.literal("system"),name:Gk}).strict(),ox=u.discriminatedUnion("platform",[ghe,vhe,yhe,bhe]),xhe=u.object({displayName:Ue.optional(),handle:Ue.optional(),id:Jr,provider:Jr,providerSubjectId:Jr,providerTenantId:Jr.optional()}).strict(),h4e=u.object({displayName:Ue.optional(),email:Ue.max(320),id:Jr,identities:u.array(xhe).max(100),isAdmin:u.literal(!0).optional()}).strict(),She=u.record(u.string(),u.string()).superRefine((e,t)=>{let a=Object.entries(e);if(a.length>20){t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata has too many keys"});return}for(let[r,n]of a){if(!r.trim()){t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata values must be strings",path:[r]});continue}r.length>128&&t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata key exceeds the maximum length",path:[r]}),/[\r\n]/.test(r)&&t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata keys must be single-line strings",path:[r]}),/[\r\n]/.test(n)&&t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata values must be single-line strings",path:[r]}),n.length>512&&t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata value exceeds the maximum length",path:[r]})}}),whe=u.object({label:Jr.pipe(u.string().max(48)).refine(e=>!/[\r\n]/.test(e)),detail:Jr.pipe(u.string().max(128)).refine(e=>!/[\r\n]/.test(e)).optional()}).strict(),g4e=u.object({idempotencyKey:Ue.pipe(u.string().max(512)),credentialSubject:hhe.optional(),destination:eg,destinationVisibility:fE,input:Ue.pipe(u.string().max(32e3)),metadata:She.optional(),replyAttribution:whe.optional()}).strict();var Che=u.string().trim().min(1).max(64).regex(/^[a-z][a-z0-9_-]*$/),y4e=u.object({text:u.string().trim().min(1).max(8e3)}).strict(),b4e=u.object({kind:Che,version:u.number().int().positive(),content:u.record(u.string(),u.unknown())}).strict();var khe=4e3,Ihe=8e3,Xh=32,t9=4e3,Lhe=1e3,The=u.record(u.string(),u.unknown()).superRefine((e,t)=>{Object.keys(e).length>Xh&&t.addIssue({code:"custom",message:`Event data may include at most ${Xh} keys.`}),new TextEncoder().encode(JSON.stringify(e)).byteLength>t9&&t.addIssue({code:"custom",message:`Event data may be at most ${t9} JSON bytes.`})}),Qu=u.string().regex(/^[a-z][a-z0-9_-]*(?:\.[a-z][a-z0-9_-]*)+$/).describe("Canonical dotted event type, such as issue.closed or pull_request.review.changes_requested."),l9=u.string().regex(/^[a-z][a-z0-9_]*$/).describe("Canonical plugin-defined resource type, such as issue or pull_request."),u9=/^[a-z][a-zA-Z0-9]*$/,Rhe=u.object({kind:u.enum(["boolean","string","number"]),description:u.string().trim().min(1).max(200),enum:u.array(u.string().min(1)).min(1).optional()}).strict().superRefine((e,t)=>{e.enum&&e.kind!=="string"&&t.addIssue({code:"custom",message:'Event match field enum requires kind "string".',path:["enum"]})}),_he=u.record(u.string().regex(u9),Rhe).superRefine((e,t)=>{Object.keys(e).length>Xh&&t.addIssue({code:"custom",message:`Event match keys may include at most ${Xh} keys.`})}),pE=u.record(u.string().regex(u9),u.union([u.boolean(),u.number().finite(),u.string().min(1),u.array(u.union([u.number().finite(),u.string().min(1)])).min(1)])).superRefine((e,t)=>{Object.keys(e).length>Xh&&t.addIssue({code:"custom",message:`Event match may include at most ${Xh} keys.`});for(let[a,r]of Object.entries(e))Array.isArray(r)&&r.some(n=>typeof n=="boolean")&&t.addIssue({code:"custom",message:`Event match field "${a}" cannot use a boolean list.`,path:[a]})});var Nhe=u.object({format:u.string().trim().min(1).max(200),pattern:u.instanceof(RegExp)}).strict(),hE=u.object({type:l9,identifier:Nhe.optional(),supportedEvents:u.array(Qu).min(1),suggestedEvents:u.array(Qu).optional(),matchFields:_he.optional(),guidance:u.record(Qu,u.string().trim().min(1).max(Lhe)).optional()}).strict().superRefine((e,t)=>{let a=new Set;e.supportedEvents.forEach((n,o)=>{a.has(n)&&t.addIssue({code:"custom",message:`Duplicate supported event type "${n}".`,path:["supportedEvents",o]}),a.add(n)});for(let n of Object.keys(e.guidance??{}))a.has(n)||t.addIssue({code:"custom",message:`Guidance event type "${n}" is not supported.`,path:["guidance",n]});let r=new Set;e.suggestedEvents?.forEach((n,o)=>{r.has(n)&&t.addIssue({code:"custom",message:`Duplicate suggested event type "${n}".`,path:["suggestedEvents",o]}),a.has(n)||t.addIssue({code:"custom",message:`Suggested event type "${n}" is not supported.`,path:["suggestedEvents",o]}),r.add(n)})}),S4e=u.object({resourceTypes:u.array(hE).min(1),isEnabled:u.function({input:[],output:u.boolean()}).optional(),normalizeIdentifier:u.function({input:[u.string()],output:u.string()}).optional()}).strict().superRefine((e,t)=>{let a=new Set;e.resourceTypes.forEach((r,n)=>{a.has(r.type)&&t.addIssue({code:"custom",message:`Duplicate resource type "${r.type}".`,path:["resourceTypes",n,"type"]}),a.add(r.type)})});var w4e=u.object({identifier:u.string().min(1),label:u.string().min(1),namespace:u.string().min(1),suggestedEvents:u.array(Qu).optional(),supportedEvents:u.array(Qu),type:l9}).strict(),C4e=u.object({events:u.array(Qu).min(1),id:u.string().min(1)}).strict(),Ahe=u.object({objectType:Yh.optional(),eventKey:u.string().min(1),eventType:Qu,identifier:u.string().min(1),occurredAtMs:u.number().finite(),terminal:u.boolean().optional(),trustedSummary:u.string().min(1).transform(e=>e.slice(0,khe)),data:The.optional(),untrustedText:u.string().transform(e=>e.slice(0,Ihe)).optional()}).strict(),k4e=Ahe.extend({namespace:u.string().min(1)}),$he=u.object({authority:u.enum(["instruction","context"]),actor:ox.optional()}).strict(),Phe=u.discriminatedUnion("type",[u.object({type:u.literal("message"),role:u.enum(["user","assistant"]),text:u.string().min(1),provenance:$he.optional(),isRunActor:u.boolean().optional()}).strict(),u.object({type:u.literal("toolResult"),toolName:u.string().min(1),isError:u.boolean(),text:u.string().min(1).optional()}).strict()]),L4e=u.object({actorUserId:u.string().min(1).optional(),completedAtMs:u.number().finite(),conversationId:u.string().min(1),destination:nhe,locationId:u.string().min(1).optional(),actors:u.array(ox),actor:ox.optional(),runId:u.string().min(1),source:phe,transcript:u.array(Phe)}).strict();var R4e=u.discriminatedUnion("type",[u.object({type:u.literal("text"),text:u.string()}).strict(),u.object({type:u.literal("image"),data:u.string(),mimeType:u.string()}).strict()]),Dhe=u.object({arguments:u.record(u.string(),u.unknown()),reason:u.string().min(1).optional()}).strict(),_4e=u.object({objectAnnotations:u.array(cE).optional(),target:u.string().min(1).optional(),truncated:u.boolean().optional(),continuation:Dhe.optional()}).passthrough(),N4e=u.enum(["auto","review","approve"]);var $4e=u.object({auth:u.object({user:u.object({email:u.string().nullable().optional(),emailVerified:u.boolean().optional(),isAdmin:u.boolean(),name:u.string().nullable().optional()}).strict()}).strict(),pluginName:Ue}).strict(),Ehe=u.string().regex(/^[a-z][a-z0-9-]*$/),Mhe=u.string().regex(/^[a-z][a-z0-9.-]*$/),Ohe=u.union([u.literal("read"),u.literal("write")]),c9=u.object({provider:Ehe,scope:Ue.optional(),type:u.literal("oauth")}).strict(),d9=u.object({displayName:Ue.optional(),handle:Ue.optional(),id:Ue,label:Ue.optional(),url:Ue.optional()}).strict(),D4e=u.object({account:d9.optional(),accessToken:Ue,expiresAt:u.number().finite().optional(),refreshToken:Ue,refreshTokenExpiresAt:u.number().finite().optional(),scope:Ue.optional()}).strict(),E4e=u.object({access:Ohe,leaseScope:Ue.optional(),name:Mhe,reason:Ue.optional(),requirements:u.array(Ue).min(1).optional()}).strict(),zhe=u.object({domain:u.string().min(1),headers:u.record(u.string(),u.string()).refine(e=>Object.keys(e).length>0)}).strict(),Uhe=u.object({account:d9.optional(),authorization:c9.optional(),expiresAt:u.string().refine(e=>Number.isFinite(Date.parse(e))),headerTransforms:u.array(zhe).min(1)}).strict(),M4e=u.discriminatedUnion("type",[u.object({lease:Uhe,type:u.literal("lease")}).strict(),u.object({authorization:c9.optional(),message:Ue,type:u.literal("needed")}).strict(),u.object({message:Ue,type:u.literal("unavailable")}).strict()]);var jhe=Ue.max(64).regex(/^[a-z][a-z0-9-]*$/),Bhe=Ue.max(80),Fhe=Ue.max(500),Hhe=u.enum(["primary","profile","admin"]),qhe=u.object({detail:Ue.max(500).optional(),label:Ue.max(80),tone:u.enum(["good","neutral","warning"]).optional(),value:Ue.max(120)}).strict(),Vhe=u.object({label:Ue.max(80),value:Ue.max(500)}).strict(),Zhe=u.object({confirmation:Ue.max(500).optional(),href:Ue.max(500).regex(/^\/api\/plugins\/[a-z][a-z0-9-]*(?:\/|$)/),label:Ue.max(80),method:u.enum(["DELETE","GET"]),tone:u.enum(["danger","neutral"]).optional()}).strict(),Ghe=u.object({actions:u.array(Zhe).max(4).optional(),description:Ue.max(1e3).optional(),id:Ue.max(128),metadata:u.array(Vhe).max(8).optional(),title:Ue.max(4e3)}).strict(),z4e=u.object({emptyText:Ue.max(500).optional(),metrics:u.array(qhe).max(6).optional(),nextCursor:Ue.max(1e3).optional(),records:u.array(Ghe).max(100),searchPlaceholder:Ue.max(120).optional(),type:u.literal("list")}).strict(),Khe=u.object({description:Fhe,id:jhe,label:Bhe,navigation:Hhe,pluginDisplayName:Ue.max(200),pluginName:Ue.max(100)}).strict(),U4e=u.array(Khe),Whe=Ue.max(1e3).optional(),Jhe=Ue.max(64).optional(),Qhe=u.string().trim().max(200).optional(),j4e=u.object({cursor:Whe,filter:Jhe,limit:u.number().int().min(1).max(50),query:Qhe}).strict();var Xhe=u.object({input:u.number().finite().nonnegative().optional(),output:u.number().finite().nonnegative().optional(),cacheRead:u.number().finite().nonnegative().optional(),cacheWrite:u.number().finite().nonnegative().optional(),total:u.number().finite().nonnegative().optional()}).strict(),m9=u.object({inputTokens:u.number().int().nonnegative().optional(),outputTokens:u.number().int().nonnegative().optional(),cachedInputTokens:u.number().int().nonnegative().optional(),cacheCreationTokens:u.number().int().nonnegative().optional(),reasoningTokens:u.number().int().nonnegative().optional(),totalTokens:u.number().int().nonnegative().optional(),cost:Xhe.optional()}).strict(),Yhe=u.union([u.literal("instruction"),u.literal("context")]),ege=u.object({authority:Yhe,actor:ox.optional()}).strict();var V4e=u.record(u.string(),u.unknown()),Z4e=u.object({item:u.string()}).passthrough();function tge(e){return e==="user_message"||e==="assistant_message"||e==="tool_result"||e==="handoff"||e==="compaction"}var age=u.object({type:u.literal("user_message"),role:u.never().optional(),provenance:ege}).passthrough(),nge=u.object({type:u.literal("assistant_message"),role:u.never().optional()}).passthrough(),rge=u.object({type:u.literal("tool_result"),role:u.never().optional()}).passthrough(),p9=u.discriminatedUnion("type",[age,nge,rge]),oge=u.object({item:p9,sourceEventSeq:u.number().int().nonnegative().optional()}).strict(),f9=u.array(oge),ige=u.object({reason:u.literal("capacity"),estimatedInputTokens:u.number().int().nonnegative(),replacementInputTokens:u.number().int().nonnegative().optional(),triggerTokens:u.number().int().nonnegative(),inputLimitTokens:u.number().int().positive(),inputMessageCount:u.number().int().nonnegative(),retainedMessageCount:u.number().int().nonnegative(),summaryChars:u.number().int().nonnegative()}).strict(),h9=u.discriminatedUnion("type",[u.object({type:u.literal("handoff"),modelProfile:Zk,modelId:u.string().min(1),reasoningLevel:u.string().min(1).optional(),triggeringToolCallId:u.string().min(1).optional(),summary:u.string().min(1).optional(),replacementHistory:f9}).strict(),u.object({type:u.literal("compaction"),modelProfile:Zk,modelId:u.string().min(1),details:ige.optional(),summary:u.string().min(1).optional(),replacementHistory:f9}).strict()]),G4e=u.object({data:h9,createdAtMs:u.number().finite()}).strict(),sge=u.object({type:u.literal("mcp_provider_connected"),provider:u.string().min(1),credentialSubjectId:u.string().min(1)}).strict(),lge=u.object({type:u.literal("mcp_provider_connected_unowned"),provider:u.string().min(1)}).strict(),g9=u.union([u.literal("plugin"),u.literal("mcp")]),uge=u.object({type:u.literal("authorization_requested"),kind:g9,provider:u.string().min(1),actorId:u.string().min(1),authorizationId:u.string().min(1),delivery:u.union([u.literal("private_link_sent"),u.literal("private_link_reused")])}).strict(),cge=u.object({type:u.literal("authorization_completed"),kind:g9,provider:u.string().min(1),actorId:u.string().min(1),authorizationId:u.string().min(1)}).strict(),dge=u.object({type:u.literal("tool_execution_started"),toolCallId:u.string().min(1),toolName:u.string().min(1)}).strict(),fge=u.object({type:u.literal("guardian_action_reviewed"),turnId:u.string().min(1),toolCallId:u.string().min(1),toolName:u.string().min(1),costUsd:u.number().finite().nonnegative().optional(),decision:u.enum(["allow","ask","deny"]),riskLevel:u.enum(["low","medium","high","critical"]),userAuthorization:u.enum(["high","medium","low","unknown"])}).strict(),mge=u.union([u.literal("user"),u.literal("assistant"),u.literal("system")]),v9=u.object({type:u.literal("message"),messageId:u.string().min(1),role:mge,text:u.string(),authorIdentityId:u.string().min(1).optional(),meta:u.record(u.string(),u.unknown()).optional()}).strict(),pge=v9.extend({type:u.literal("message_updated")}),hge=u.object({type:u.literal("message_handled"),messageId:u.string().min(1)}).strict(),gge=u.object({type:u.literal("messages_summarized"),historyFromSeq:u.number().int().nonnegative(),compactions:u.array(u.object({coveredMessageCount:u.number().int().nonnegative(),createdAtMs:u.number(),id:u.string().min(1),summary:u.string()}).strict())}).strict(),vge=u.enum(["slack","api","scheduler","internal"]),Jk=u.enum(["agent_run_failed","delivery_failed","model_execution_failed","persistence_failed"]),Qk=u.enum(["auth","permission","rate_limit","capacity","timeout","network","server","invalid_request","invalid_response","quota","content_policy","unknown","empty_output","tool_errors","suppressed_output"]),yge=u.object({type:u.literal("turn_started"),turnId:u.string().min(1),inputMessageIds:u.array(u.string().min(1)).min(1),surface:vge}).strict().refine(e=>new Set(e.inputMessageIds).size===e.inputMessageIds.length,"turn input message ids must be unique"),bge=u.object({type:u.literal("turn_routed"),turnId:u.string().min(1),modelProfile:Zk,modelId:u.string().min(1),costUsd:u.number().finite().nonnegative().optional(),reasoningLevel:u.enum(e9),confidence:u.number().min(0).max(1).optional(),source:u.enum(["configured","inherited","router"])}).strict(),xge=u.object({type:u.literal("turn_context"),turnId:u.string().min(1),pluginName:u.string().min(1),kind:u.string().min(1).max(64),version:u.number().int().positive(),content:u.record(u.string(),u.unknown())}).strict(),Sge=u.object({type:u.literal("structured_event"),namespace:u.string().regex(/^[a-z][a-z0-9-]*$/),name:u.string().regex(/^[a-z][a-z0-9_]*$/),version:u.number().int().positive(),turnId:u.string().min(1).optional(),content:u.record(u.string(),u.unknown())}).strict(),wge=u.object({id:u.string().min(1),filename:u.string().min(1),contentType:u.string().min(1),bytes:u.number().int().nonnegative()}).strict(),Cge=u.object({type:u.literal("attachments_delivered"),attachments:u.array(wge).min(1),toolCallId:u.string().min(1).optional(),turnId:u.string().min(1).optional()}).strict(),kge=u.object({type:u.literal("turn_completed"),turnId:u.string().min(1),outcome:u.enum(["success","no_reply","cancelled"])}).strict(),Ige=u.object({type:u.literal("turn_failed"),turnId:u.string().min(1),failureCode:Jk,failureReason:Qk.optional(),eventId:u.string().regex(/^[a-f0-9]{32}$/i).optional()}).strict(),Lge=u.object({type:u.literal("subagent_started"),subagentInvocationId:u.string().min(1),subagentKind:u.string().min(1),modelId:u.string().min(1).optional(),parentToolCallId:u.string().min(1).optional(),reasoningLevel:u.string().min(1).optional(),childConversationId:u.string().min(1)}).strict(),Tge=u.object({type:u.literal("subagent_ended"),subagentInvocationId:u.string().min(1),outcome:u.union([u.literal("success"),u.literal("error"),u.literal("aborted")]),errorCode:u.string().min(1).optional()}).strict(),y9=u.union([v9,pge,p9,sge,uge,cge,dge,fge,hge,gge,yge,xge,Sge,Cge,bge,kge,Ige,Lge,Tge]),Rge=u.union([y9,h9,lge]),_ge=["message","message_updated","user_message","assistant_message","tool_result","mcp_provider_connected","mcp_provider_connected_unowned","authorization_requested","authorization_completed","tool_execution_started","guardian_action_reviewed","message_handled","messages_summarized","turn_started","turn_context","structured_event","attachments_delivered","turn_routed","turn_completed","turn_failed","subagent_started","subagent_ended","handoff","compaction"],K4e=u.enum(_ge),Nge=u.object({type:u.literal("unknown"),originalType:u.string().min(1),payload:u.unknown()}).strict(),gE=u.object({schemaVersion:u.number().int().nonnegative(),seq:u.number().int().nonnegative(),historyVersion:u.number().int().nonnegative(),idempotencyKey:u.string().min(1).optional(),createdAtMs:u.number().finite()}).strict(),W4e=u.union([gE.extend({schemaVersion:u.union([u.literal(1),u.literal(2)]),data:Rge}).refine(e=>e.schemaVersion===1||tge(e.data.type)),gE.extend({data:Nge})]),J4e=gE.extend({type:u.string().min(1),payload:u.unknown()});var Q4e=u.object({data:y9,idempotencyKey:u.string().min(1).optional(),createdAtMs:u.number().finite()}).strict();var Age=u.object({kind:u.literal("automation"),id:u.string().min(1),title:u.string().min(1).max(160),url:u.string().url().nullable(),instruction:u.string().max(4e3),trigger:u.string().min(1),warning:u.string().nullable()}).strict();function $ge(e){return[e.title,e.warning,e.trigger,e.instruction,e.url,`Automation ID: ${e.id}`].filter(Boolean).join(`
69
69
  `)}var aUe=Age.extend({operation:u.enum(["created","updated","deleted"]).optional()});function bE(e){switch(e.kind){case"object":return[e.title,e.label!==e.title?e.label:void 0,e.description,e.status,...a9(e.facts).map(t=>`${t.label}: ${t.value}`),e.trigger,e.warning,e.url].filter(Boolean).join(`
70
- `);case"automation":return $ge(e)}}var Pge=u.object({plugin:u.string().min(1),key:u.string().min(1)}).strict(),Dge=Pge.extend({kind:u.literal("object")});function xE(e,t){return e.map(a=>{let r=t.find(n=>n.kind===a.kind&&n.plugin===a.plugin&&n.key===a.key);return r?Ege(r):{...a,objectType:"item",title:a.key,label:a.key,url:null,warning:"Saved annotation is unavailable."}})}function Ege(e){let{createdAt:t,updatedAt:a,...r}=e;return r.kind==="object"?r:{...r,kind:"object",objectType:r.objectType??"item",title:r.label}}var Qr=u.string().trim().min(1).max(400),SE=u.string().url().max(2048),lx=u.string().datetime(),b9=u.object({provider:u.string().trim().min(1).max(100),channelName:Qr.optional()}).strict(),Mge=u.enum(["in_progress","answered","done","partial","blocked","abandoned"]),x9=u.object({repository:Qr,number:u.number().int().positive(),title:Qr.optional(),url:SE,state:ix,openedAt:lx.optional(),mergedAt:lx.optional(),closedAt:lx.optional()}).strict(),Oge=u.object({kind:u.enum(["code_change","resource","url"]),label:Qr,url:SE,status:Qr.optional()}).strict(),zge=u.object({startedAt:lx,lastActivityAt:lx,durationMs:u.number().int().nonnegative(),participants:u.array(u.object({name:Qr,messages:u.number().int().positive()}).strict()),userMessages:u.number().int().nonnegative(),assistantMessages:u.number().int().nonnegative(),toolResults:u.number().int().nonnegative(),events:u.number().int().nonnegative(),turns:u.number().int().positive().optional(),location:b9.optional(),codeChanges:u.array(x9)}).strict(),Uge=u.object({schemaVersion:u.literal(1),record:zge,summary:u.string().trim().min(1).max(600),intent:Qr,outcome:u.object({status:Mge,text:u.string().trim().min(1).max(600)}).strict(),decisions:u.array(u.object({text:Qr,by:Qr.optional(),kind:u.enum(["stated","confirmed","assumed"])}).strict()).max(20),openDecisions:u.array(u.object({text:Qr,owner:Qr.optional()}).strict()).max(20),facts:u.array(Qr).max(30),links:u.array(Oge).max(40),keywords:u.array(u.string().trim().toLowerCase().min(1).max(400)).max(12)}).strict(),jge=u.object({index:u.number().int().nonnegative(),role:u.enum(["user","assistant","tool","event"]),author:Qr.optional(),text:u.string().min(1),createdAtMs:u.number().int().nonnegative(),turnId:u.string().min(1).optional()}).strict(),Bge=u.object({label:Qr,url:SE,status:Qr.optional()}).strict(),nUe=u.object({conversationId:u.string().min(1),title:Qr.optional(),visibility:u.enum(["private","public"]),location:b9.optional(),entries:u.array(jge),codeChanges:u.array(x9),resources:u.array(Bge)}).strict();var Td=["image/png","image/jpeg","image/gif","image/webp"];var ux=3145728,wE=3,Fge=u.object({filename:u.string().trim().min(1).max(255),contentType:u.enum(Td),data:u.string().min(4).max(ux*4/3).regex(/^[A-Za-z0-9+/]*={0,2}$/).refine(e=>e.length%4===0)}).strict(),CE=u.object({id:u.string().min(1),filename:u.string().min(1),contentType:u.string().min(1),bytes:u.number().int().nonnegative()}).strict();var Hge=u.enum(["active","completed","failed"]),qge=u.enum(["api","internal","scheduler","slack"]),kE=m9,Vge=u.object({conversationId:u.string().min(1)}).strict(),rUe=u.object({attachmentId:u.string().min(1),conversationId:u.string().min(1)}).strict(),Zge=u.object({limit:u.coerce.number().int().min(1).max(1e3).default(500)}).strict(),Gge=u.object({before:u.string().min(1),limit:u.coerce.number().int().min(1).max(1e3).default(500)}).strict(),Kge=u.object({actorEmail:u.string().trim().email().transform(e=>e.toLowerCase()).optional(),codeRepositoryId:u.string().uuid().optional(),q:u.string().trim().max(200).optional(),status:u.enum(["active","archived"]).default("active")}).strict(),Wge=u.object({archived:u.boolean(),lastSeenAt:u.string().datetime()}).strict(),IE=u.object({archivedAt:u.string().datetime().nullable()}).strict(),S9=u.object({idempotencyKey:u.string().trim().min(1).max(200),message:u.string().trim().max(32e3),images:u.array(Fge).max(3).optional()}).strict().refine(e=>!!(e.message||e.images?.length),"Add a message or an image.").refine(e=>(e.images??[]).reduce((t,a)=>t+a.data.length,0)<=ux*4/3,"Images must total 3 MB or less."),Jge=S9.safeExtend({visibility:u.enum(["private","public"]).optional()}),cx=u.object({conversationId:u.string().min(1),messageId:u.string().min(1),status:u.enum(["accepted","duplicate"])}).strict(),fm=u.object({email:u.string().optional(),fullName:u.string().optional(),slackUserId:u.string().optional(),slackUserName:u.string().optional()}).strict(),w9=u.enum(["defer","interrupt"]),C9=u.object({actorIdentity:fm.optional(),createdAt:u.string().datetime(),delivery:w9,inboundMessageId:u.string().min(1),messageId:u.string().min(1),receivedAt:u.string().datetime(),role:u.literal("user"),source:u.enum(["slack","web"]),text:u.string().optional(),attachments:u.array(CE).optional(),redacted:u.literal(!0).optional()}).strict().superRefine((e,t)=>{e.text===void 0==(e.redacted!==!0)&&t.addIssue({code:"custom",message:"pending message content must be text or explicitly redacted"}),e.redacted&&(e.actorIdentity||e.attachments)&&t.addIssue({code:"custom",message:"redacted pending messages must not expose actor identity or attachments"})}),k9=u.object({authorizationUrl:u.string().url(),completionText:u.string().min(1),label:u.string().min(1)}).strict(),LE=u.object({authorization:k9.optional(),conversationId:u.string().min(1),generatedAt:u.string().datetime(),messages:u.array(C9)}).strict(),Qge=u.object({inboundMessageIds:u.array(u.string().min(1)).min(1).optional(),receivedBefore:u.string().datetime().optional()}).strict(),TE=u.object({cancelledCount:u.number().int().nonnegative(),cancelledInboundMessageIds:u.array(u.string().min(1)),conversationId:u.string().min(1)}).strict(),I9=u.object({costUsd:u.number().finite().nonnegative(),operations:u.array(u.object({costUsd:u.number().finite().nonnegative(),events:u.number().int().positive(),name:u.string().min(1),namespace:u.string().min(1)}).strict()).min(1)}).strict(),Xge=u.object({id:u.string().min(1).optional(),kind:u.enum(["scheduled","event"]),label:u.string().min(1).optional(),title:u.string().min(1).optional()}).strict().superRefine((e,t)=>{!!e.id!=!!e.label&&t.addIssue({code:"custom",message:"sourceTask id and label must both be set or both omitted"})}),Yge=n9.and(u.object({plugin:u.string().min(1),createdAt:u.string().datetime(),updatedAt:u.string().datetime()})),L9=u.object({createdAt:u.string().datetime(),role:u.enum(["assistant","user"]),text:u.string().min(1)}).strict(),tg=u.object({displayTitle:u.string(),activityPreview:L9.optional(),cumulativeDurationMs:u.number(),cumulativeUsage:kE.optional(),auxiliaryCosts:I9.optional(),conversationId:u.string(),isParticipant:u.boolean(),visibility:u.enum(["private","public"]).optional(),status:Hge,startedAt:u.string(),lastSeenAt:u.string(),lastProgressAt:u.string(),surface:qge,actorIdentity:fm.optional(),participants:u.array(fm).optional(),archivedAt:u.string().datetime().nullable().optional(),channel:u.string().optional(),channelName:u.string().optional(),channelNameRedacted:u.boolean().optional(),locationId:u.string().optional(),sentryTraceUrl:u.string().optional(),locationUrl:u.string().url().optional(),traceId:u.string().optional(),annotations:u.array(Yge).optional(),sidebarAnnotations:u.array(r9).optional(),assignedWork:u.boolean().optional(),finishedWorkAt:u.string().datetime().optional(),isPriority:u.boolean().optional(),unfinishedWork:u.boolean().optional()}).strict(),eve=u.object({type:u.literal("message"),messageId:u.string().min(1),role:u.enum(["assistant","system","user"]),source:u.enum(["slack","web"]).optional(),actorIdentity:fm.optional(),eventType:u.string().min(1).optional(),eventObjectType:Yh.optional(),explicitMention:u.boolean().optional(),trustedSummary:u.string().min(1).optional(),cards:u.array(Dge).optional(),text:u.string().optional(),attachments:u.array(CE).optional(),redacted:u.literal(!0).optional()}).strict().superRefine((e,t)=>{e.text===void 0==(e.redacted!==!0)&&t.addIssue({code:"custom",message:"message content must be text or explicitly redacted"}),e.redacted&&(e.actorIdentity||e.cards||e.attachments)&&t.addIssue({code:"custom",message:"redacted messages must not expose actor identity, cards, or attachments"})}),tve=u.object({type:u.literal("message_handled"),messageId:u.string().min(1)}).strict(),ave=u.object({toolCallId:u.string().min(1),name:u.string().min(1),status:u.enum(["running","completed","error"]),startedAt:u.string().datetime().optional(),startedSeq:u.number().int().nonnegative().optional(),input:u.unknown().optional(),output:u.unknown().optional()}).strict().superRefine((e,t)=>{e.startedAt===void 0!=(e.startedSeq===void 0)&&t.addIssue({code:"custom",message:"tool start sequence and timestamp must be provided together"})}),T9=u.object({type:u.literal("reasoning"),text:u.string().min(1).optional(),redacted:u.literal(!0).optional()}).strict().superRefine((e,t)=>{e.text===void 0==(e.redacted!==!0)&&t.addIssue({code:"custom",message:"reasoning content must be text or explicitly redacted"})}),nve=u.object({type:u.literal("tool_call"),toolCallId:u.string().min(1)}).strict(),rve=u.object({parts:u.array(u.discriminatedUnion("type",[T9,nve])).min(1)}).strict(),ove=u.object({type:u.literal("tool_calls"),calls:u.array(ave).min(1),assistant:rve.optional()}).strict().superRefine((e,t)=>{if(!e.assistant)return;let a=new Map;for(let n of e.calls)a.set(n.toolCallId,(a.get(n.toolCallId)??0)+1);let r=new Map;for(let n of e.assistant.parts)n.type==="tool_call"&&r.set(n.toolCallId,(r.get(n.toolCallId)??0)+1);(a.size!==r.size||[...a].some(([n,o])=>r.get(n)!==o))&&t.addIssue({code:"custom",path:["assistant","parts"],message:"assistant tool parts must reference every call exactly once"})}),ive=u.object({type:u.literal("assistant_message"),parts:u.array(T9)}).strict(),sve=u.discriminatedUnion("state",[u.object({type:u.literal("turn_lifecycle"),turnId:u.string().min(1),state:u.enum(["succeeded","no_reply"])}).strict(),u.object({type:u.literal("turn_lifecycle"),turnId:u.string().min(1),state:u.literal("started"),inputMessageIds:u.array(u.string().min(1)).min(1).optional()}).strict(),u.object({type:u.literal("turn_lifecycle"),turnId:u.string().min(1),state:u.literal("failed"),failureCode:Jk,failureReason:Qk.optional(),eventId:u.string().regex(/^[a-f0-9]{32}$/i).optional(),sentryEventUrl:u.string().url().optional()}).strict()]),lve=u.object({type:u.literal("turn_routed"),turnId:u.string().min(1),modelProfile:u.string().min(1),modelId:u.string().min(1),costUsd:u.number().finite().nonnegative().optional(),reasoningLevel:u.string().min(1),confidence:u.number().min(0).max(1).optional(),source:u.enum(["configured","inherited","router"])}).strict(),uve=u.object({type:u.literal("guardian_action_reviewed"),turnId:u.string().min(1),toolCallId:u.string().min(1),toolName:u.string().min(1),decision:u.enum(["allow","ask","deny"]),riskLevel:u.enum(["low","medium","high","critical"]),userAuthorization:u.enum(["high","medium","low","unknown"])}).strict(),cve=u.object({type:u.literal("turn_context"),turnId:u.string().min(1),pluginName:u.string().min(1),kind:u.string().min(1),version:u.number().int().positive(),content:u.record(u.string(),u.unknown())}).strict(),dve=u.object({type:u.literal("structured_event"),namespace:u.string().min(1),name:u.string().min(1),version:u.number().int().positive(),turnId:u.string().min(1).optional(),presentation:o9}).strict(),fve=u.object({type:u.literal("attachments_delivered"),attachments:u.array(CE).min(1)}).strict(),mve=u.object({type:u.literal("compaction"),modelProfile:u.string().min(1).optional(),modelId:u.string().min(1).optional(),summary:u.string().min(1).optional(),details:u.object({reason:u.literal("capacity"),estimatedInputTokens:u.number().int().nonnegative(),replacementInputTokens:u.number().int().nonnegative().optional(),triggerTokens:u.number().int().nonnegative(),inputLimitTokens:u.number().int().positive(),inputMessageCount:u.number().int().nonnegative(),retainedMessageCount:u.number().int().nonnegative(),summaryChars:u.number().int().nonnegative()}).strict().optional()}).strict(),pve=u.object({type:u.literal("handoff"),modelProfile:u.string().min(1),modelId:u.string().min(1),reasoningLevel:u.string().min(1).optional(),triggeringToolCallId:u.string().min(1).optional(),summary:u.string().min(1).optional()}).strict(),hve=u.object({type:u.literal("subagent"),startedSeq:u.number().int().nonnegative(),startedAt:u.string().datetime(),childConversationId:u.string().min(1),subagentKind:u.string().min(1),parentToolCallId:u.string().min(1).optional(),status:u.enum(["running","completed","error","aborted"])}).strict(),R9=u.discriminatedUnion("type",[eve,tve,ive,ove,sve,cve,dve,fve,lve,uve,mve,pve,hve]),RE=u.object({seq:u.number().int().nonnegative(),createdAt:u.string().datetime(),data:R9,model:u.object({modelId:u.string().min(1),modelProfile:u.string().min(1).optional(),reasoningLevel:u.string().min(1).optional()}).strict().optional(),modelCall:u.object({provider:u.string().min(1).optional(),api:u.string().min(1).optional(),stopReason:u.string().min(1).optional(),usage:kE.optional()}).strict().optional()}).strict(),_E=u.discriminatedUnion("status",[u.object({status:u.literal("available")}).strict(),u.object({status:u.literal("redacted"),reason:u.literal("non_public_conversation")}).strict(),u.object({status:u.literal("expired"),expiredAt:u.string().datetime()}).strict()]),gve=u.object({modelId:u.string(),usage:kE}).strict();function _9(e,t){e.eventHistory.status==="expired"&&e.events.length>0&&t.addIssue({code:"custom",path:["events"],message:"expired event history must not contain events"});for(let a=1;a<e.events.length;a+=1)e.events[a].seq<=e.events[a-1].seq&&t.addIssue({code:"custom",path:["events",a,"seq"],message:"report event sequences must be strictly increasing"});for(let[a,r]of e.events.entries())r.data.type==="message"&&(e.eventHistory.status==="redacted"&&r.data.redacted!==!0&&t.addIssue({code:"custom",path:["events",a,"data"],message:"redacted event history must redact messages"}),e.eventHistory.status==="available"&&r.data.redacted===!0&&t.addIssue({code:"custom",path:["events",a,"data"],message:"available event history must expose messages"})),e.eventHistory.status==="redacted"&&r.data.type==="tool_calls"&&r.data.calls.some(n=>n.input!==void 0||n.output!==void 0)&&t.addIssue({code:"custom",path:["events",a,"data"],message:"redacted event history must redact tool payloads"}),e.eventHistory.status==="redacted"&&r.data.type==="assistant_message"&&r.data.parts.some(n=>n.text!==void 0)&&t.addIssue({code:"custom",path:["events",a,"data"],message:"redacted event history must redact assistant messages"}),e.eventHistory.status==="available"&&r.data.type==="assistant_message"&&r.data.parts.some(n=>n.redacted===!0)&&t.addIssue({code:"custom",path:["events",a,"data"],message:"available event history must expose reasoning"}),r.data.type==="tool_calls"&&(e.eventHistory.status==="redacted"&&r.data.assistant?.parts.some(n=>n.type==="reasoning"&&n.text!==void 0)||e.eventHistory.status==="available"&&r.data.assistant?.parts.some(n=>n.type==="reasoning"&&n.redacted===!0))&&t.addIssue({code:"custom",path:["events",a,"data","assistant"],message:"assistant reasoning must match event history visibility"})}var vve=u.object({messageId:u.string().min(1).max(500),idempotencyKey:u.string().trim().min(1).max(200)}).strict(),NE=u.object({conversationId:u.string()}).strict(),AE=tg.extend({canFork:u.boolean().optional(),forkedFromConversationId:u.string().optional(),forkedFromTitle:u.string().optional(),forks:u.array(u.string()).optional(),brief:u.object({content:Uge,updatedAt:u.string().datetime(),version:u.number().int().positive()}).strict().optional(),modelUsage:u.array(gve).optional(),events:u.array(RE),eventHistory:_E,previousCursor:u.string().min(1).optional(),generatedAt:u.string(),sentryConversationUrl:u.string().optional(),sourceTask:Xge.optional()}).strict().superRefine(_9),$E=u.object({events:u.array(RE),eventHistory:_E,previousCursor:u.string().min(1).optional(),generatedAt:u.string()}).strict().superRefine(_9),Xk=u.object({conversations:u.array(tg),source:u.literal("conversation_index"),generatedAt:u.string()}).strict(),mm=u.object({active:u.number(),conversations:u.number(),durationMs:u.number(),failed:u.number(),label:u.string(),costUsd:u.number().optional(),tokens:u.number().optional()}).strict(),N9=u.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/),vE=u.object({cachedInputTokens:u.number().optional(),cacheCreationTokens:u.number().optional(),conversations:u.number(),costUsd:u.number().optional(),date:N9,durationMs:u.number(),inputTokens:u.number().optional(),tokens:u.number().optional()}).strict(),yE=u.object({allow:u.number(),ask:u.number(),costUsd:u.number().optional(),date:N9,deny:u.number(),requests:u.number()}).strict(),yve=u.object({allow:u.number(),ask:u.number(),costUsd:u.number().optional(),deny:u.number(),metricDays:u.array(yE),metricHours:u.array(yE).optional(),metricSixHours:u.array(yE).optional(),requests:u.number()}).strict(),PE=u.object({active:u.number(),cachedInputTokens:u.number().optional(),cacheCreationTokens:u.number().optional(),conversations:u.number(),durationMs:u.number(),failed:u.number(),generatedAt:u.string(),guardian:yve,metricDays:u.array(vE),metricHours:u.array(vE).optional(),metricSixHours:u.array(vE).optional(),locations:u.array(mm),actors:u.array(mm),source:u.literal("conversation_index"),costUsd:u.number().optional(),inputTokens:u.number().optional(),tokens:u.number().optional(),windowEnd:u.string(),windowStart:u.string()}).strict();var bve=u.enum(["current_conversation","task_creator"]).describe("Where to send the message. Use current_conversation for posts, digests, summaries, and channel reminders. Use task_creator only when the user asks for a direct reminder or notification."),xve=u.object({action:u.literal("send_message"),destination:bve}).strict();var E9=u.string().regex(/^\d{4}-\d{2}-\d{2}$/,"Use a local date in YYYY-MM-DD format."),M9=u.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/,"Use local time in HH:MM format."),O9=u.string().min(1).max(80).describe("IANA timezone the user asked for, for example America/New_York. Omit or use null to use the creator's timezone on create, or to keep the saved timezone on update. Do not guess it from office locations.").nullable().optional(),Sve=u.enum(["sunday","monday","tuesday","wednesday","thursday","friday","saturday"]),wve=u.object({kind:u.literal("one_off").describe("A schedule that runs once."),timezone:O9,timing:u.discriminatedUnion("type",[u.object({type:u.literal("after").describe("Run after a relative delay from the server clock."),value:u.number().int().positive().max(1e5),unit:u.enum(["second","minute","hour","day","week"])}).strict(),u.object({type:u.literal("at").describe("Run at an explicit local calendar date and time."),date:E9.describe("Requested local calendar date in YYYY-MM-DD format."),time:M9.describe("Requested local wall-clock time in HH:MM format.")}).strict()]).describe("Relative delay or explicit local time for the one-off run.")}).strict(),Cve=u.object({kind:u.literal("recurring").describe("A repeating calendar schedule."),frequency:u.enum(["daily","weekly","monthly","yearly"]).describe("Recurring tasks can run at most once per day."),interval:u.number().int().positive().max(365).describe("Repeat every N frequency units. Defaults to 1.").nullable().optional(),time:M9.describe("Local wall-clock time for each occurrence in HH:MM format."),weekdays:u.array(Sve).min(1).max(7).describe("Required for weekly schedules.").nullable().optional(),dayOfMonth:u.number().int().min(1).max(31).describe("Required for monthly and yearly schedules.").nullable().optional(),month:u.number().int().min(1).max(12).describe("Required for yearly schedules, where January is 1.").nullable().optional(),startDate:E9.describe("Optional local calendar date that anchors the recurrence. Omit to start with the next matching occurrence.").nullable().optional(),timezone:O9}).strict().superRefine((e,t)=>{e.frequency==="weekly"&&e.weekdays==null&&t.addIssue({code:"custom",message:"Weekly schedules require weekdays.",path:["weekdays"]}),(e.frequency==="monthly"||e.frequency==="yearly")&&e.dayOfMonth==null&&t.addIssue({code:"custom",message:`${e.frequency} schedules require dayOfMonth.`,path:["dayOfMonth"]}),e.frequency==="yearly"&&e.month==null&&t.addIssue({code:"custom",message:"Yearly schedules require month.",path:["month"]}),e.frequency!=="weekly"&&e.weekdays!=null&&t.addIssue({code:"custom",message:"weekdays applies only to weekly schedules.",path:["weekdays"]}),e.frequency!=="monthly"&&e.frequency!=="yearly"&&e.dayOfMonth!=null&&t.addIssue({code:"custom",message:"dayOfMonth applies only to monthly or yearly schedules.",path:["dayOfMonth"]}),e.frequency!=="yearly"&&e.month!=null&&t.addIssue({code:"custom",message:"month applies only to yearly schedules.",path:["month"]})}),z9=u.union([wve,Cve]);var U9=u.object({slackUserId:Wk,fullName:u.string().optional(),userName:u.string().optional()}).strict(),EE=u.object({events:u.array(Qu).min(1),label:u.string().min(1),match:pE.optional(),namespace:u.string().min(1),identifier:u.string().min(1).max(300),resourceType:u.string().min(1)}).strict(),j9=eg.omit({threadTs:!0}),kve=sx.extend({destination:j9}),Ive=u.object({id:u.string().min(1),createdAtMs:u.number().finite(),createdBy:U9,credentialMode:u.enum(["system","creator"]),destination:j9,destinationVisibility:fE,outcomes:u.array(kve).max(5),task:u.object({text:u.string().min(1)}).strict(),trigger:EE}).strict(),Lve=u.string().trim().min(1).max(60),B9=u.string().trim().min(1).max(4e3),lUe=B9.describe("Work to perform when the Automation runs. It runs later without this conversation, so write it to stand alone: name each person with their Slack mention, such as <@U123>, instead of me, my, or you. Preserve the user's scope, targets, and constraints. Do not add permissions or side effects the user did not request."),F9=u.object({title:Lve.optional(),instruction:B9.optional(),credentialMode:u.enum(["system","creator"]).optional(),outcomes:u.array(u.union([xve,sx])).max(5).optional()}),Tve=F9.extend({schedule:z9.optional(),status:u.enum(["active","blocked"]).optional()}).strict(),Rve=F9.extend({trigger:EE.extend({identifier:u.string().trim().min(1).max(300),label:u.string().trim().min(1).max(500)}).optional()}).strict(),_ve=u.enum(["active","blocked","paused","completed","deleted"]),Nve=u.enum(["system","creator"]),Ave=u.enum(["pending","running","completed","failed","blocked","skipped"]),$ve=u.object({slackUserId:Wk,fullName:u.string().optional(),userName:u.string().optional()}).strict(),Pve=u.object({dayOfMonth:u.number().optional(),frequency:u.enum(["daily","weekly","monthly","yearly"]),interval:u.number(),month:u.number().optional(),startDate:u.string(),time:u.object({hour:u.number(),minute:u.number()}).strict(),weekdays:u.array(u.number()).optional()}).strict(),Dve=u.object({description:u.string(),kind:u.enum(["one_off","recurring"]),recurrence:Pve.optional(),timezone:u.string()}).strict(),Eve=u.object({platform:u.literal("system"),name:u.string()}).strict(),H9=eg.omit({threadTs:!0}),Mve=u.object({action:u.literal("send_message"),destination:H9}).strict(),e1=u.object({id:u.string(),conversationAccess:u.object({audience:u.enum(["direct","group","channel"]),visibility:u.enum(["private","public"])}).strict(),createdAtMs:u.number(),createdBy:$ve,creatorIdentityId:u.string(),credentialMode:Nve,destination:H9,executionActor:Eve.optional(),lastRunAtMs:u.number().optional(),nextRunAtMs:u.number().optional(),originalRequest:u.string().optional(),runNowAtMs:u.number().optional(),schedule:Dve,status:_ve,statusReason:u.string().optional(),outcomes:u.array(Mve).max(5),task:u.object({text:u.string()}).strict(),title:u.string().optional(),updatedAtMs:u.number()}).strict(),uUe=u.object({id:u.string(),attempt:u.number(),claimedAtMs:u.number(),completedAtMs:u.number().optional(),dispatchId:u.string().optional(),errorMessage:u.string().optional(),resultMessageTs:u.string().optional(),scheduledForMs:u.number(),startedAtMs:u.number().optional(),status:Ave,taskId:u.string()}).strict(),cUe=Object.freeze({platform:"system",name:"scheduled-automation"}),Ove=u.object({channelId:u.string().min(1),label:u.string().min(1),teamId:u.string().min(1),visibility:u.enum(["private","public"])}).strict(),q9=u.object({1:u.number().int().nonnegative(),7:u.number().int().nonnegative(),30:u.number().int().nonnegative(),90:u.number().int().nonnegative()}).strict(),V9=u.object({credentialMode:u.enum(["creator","system"]),createdAt:u.string().datetime(),createdBy:u.string().min(1),createdByAvatarUrl:u.string().url().optional(),createdByEmail:u.string().trim().email().optional(),destination:Ove,id:u.string().min(1),instruction:u.string().min(1),lastConversationId:u.string().min(1).optional(),lastRunAt:u.string().datetime().optional(),lastRunStatus:u.enum(["blocked","completed","failed"]).optional(),ownedByViewer:u.boolean(),runs:q9,outcomes:u.array(sx).max(5),title:u.string().min(1),totalRuns:u.number().int().nonnegative()}),Z9=V9.extend({kind:u.literal("scheduled"),nextRunAt:u.string().datetime().optional(),schedule:u.string().min(1),timezone:u.string().min(1),statusReason:u.string().optional(),status:u.enum(["active","blocked","paused","completed"])}).strict(),G9=V9.extend({events:u.array(u.string().min(1)).min(1),match:pE.optional(),kind:u.literal("event"),resource:u.string().min(1),source:u.string().min(1),triggerAvailable:u.boolean(),status:u.enum(["active","paused"])}).strict(),fx=u.discriminatedUnion("kind",[Z9,G9]),K9=u.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/),DE=u.object({costUsd:u.number().finite().nonnegative(),date:K9,event:u.number().int().nonnegative(),scheduled:u.number().int().nonnegative()}).strict(),t1=u.object({q:u.string().trim().max(200).optional(),scope:u.enum(["all","mine","public","attention"]).default("all"),type:u.enum(["all","scheduled","event"]).default("all"),state:u.enum(["all","active","blocked","paused","completed","unavailable"]).default("all"),creator:u.string().max(300).optional(),destination:u.string().max(300).optional(),sort:u.enum(["newest","oldest","title"]).default("newest"),page:u.coerce.number().int().min(1).max(1e6).default(1),pageSize:u.coerce.number().int().min(1).max(100).default(25)}).strict(),A9=u.object({value:u.string(),label:u.string()}).strict(),ME=u.object({executionDays:u.array(DE),executionHours:u.array(DE).optional(),executionSixHours:u.array(DE).optional(),automations:u.array(fx),total:u.number().int().nonnegative(),page:u.number().int().positive(),pageSize:u.number().int().positive(),counts:u.object({all:u.number().int().nonnegative(),mine:u.number().int().nonnegative(),public:u.number().int().nonnegative(),private:u.number().int().nonnegative()}).strict(),creators:u.array(A9),destinations:u.array(A9)}).strict(),W9=u.object({id:u.string().min(1),kind:u.enum(["scheduled","event"])}).strict(),J9=u.enum(["blocked","completed","failed"]),OE=u.object({conversationId:u.string().min(1).optional(),costUsd:u.number().finite().nonnegative().optional(),durationMs:u.number().finite().nonnegative().optional(),executedAt:u.string().datetime(),executionId:u.string().min(1),status:J9,title:u.string().min(1).optional(),totalTokens:u.number().int().nonnegative().optional()}).strict(),Yk=u.object({blocked:u.number().int().nonnegative(),completed:u.number().int().nonnegative(),date:K9,failed:u.number().int().nonnegative()}).strict(),zE=u.object({executionDays:u.array(Yk),executionHours:u.array(Yk).optional(),executionSixHours:u.array(Yk).optional(),executions:u.array(OE),automation:fx,truncated:u.boolean()}).strict(),Q9=OE.extend({kind:u.enum(["scheduled","event"]),automationId:u.string().min(1),automationTitle:u.string().min(1)}).strict(),UE=u.object({runs:u.array(Q9),truncated:u.boolean()}).strict(),$9={title:u.string().nullable(),instruction:u.string()},P9={version:u.number().int().positive(),createdAt:u.string().datetime(),editedBy:U9.nullable()},X9=u.discriminatedUnion("kind",[u.object({...P9,kind:u.literal("scheduled"),definition:e1.pick({credentialMode:!0,destination:!0,outcomes:!0,schedule:!0}).extend($9).strict()}).strict(),u.object({...P9,kind:u.literal("event"),definition:Ive.pick({credentialMode:!0,destination:!0,outcomes:!0,trigger:!0}).extend($9).strict()}).strict()]),jE=u.object({versions:u.array(X9),activeVersion:u.number().int().positive().nullable(),truncated:u.boolean()}).strict(),zve=W9.extend({version:u.coerce.number().int().positive()}).strict(),dx=u.string().regex(/^[a-f0-9]{64}$/),Uve=u.object({revision:dx}).strict(),dUe=u.object({action:u.enum(["pause","resume"]),revision:dx}).strict(),D9=e1.pick({destination:!0,createdBy:!0}).extend({id:u.string().min(1),revision:dx,title:u.string().nullable(),instruction:u.string(),credentialMode:u.enum(["system","creator"]),outcomes:u.array(sx).max(5),ownedByViewer:u.boolean()}),ds=u.discriminatedUnion("kind",[D9.merge(e1.pick({schedule:!0})).extend({kind:u.literal("scheduled"),nextRunAtMs:u.number().optional(),status:u.enum(["active","blocked","paused","completed"])}).strict(),D9.extend({kind:u.literal("event"),trigger:EE,triggerAvailable:u.boolean(),status:u.enum(["active","paused"])}).strict()]),BE=u.discriminatedUnion("kind",[Tve.omit({status:!0}).extend({kind:u.literal("scheduled"),revision:dx}).strict(),Rve.extend({kind:u.literal("event"),revision:dx}).strict()]),jve=u.object({error:u.string(),code:u.enum(["invalid_edit","conflict","not_found"]),fields:u.record(u.string(),u.array(u.string())).optional()}).strict(),FE=u.array(hE.safeExtend({namespace:u.string()})),HE=z9,qE=e1.pick({schedule:!0}).extend({nextRunAtMs:u.number()}).strict();var Bve=u.object({status:u.literal("ok"),service:u.string(),timestamp:u.string()}).strict(),Y9=u.object({configKeys:u.array(u.string()),description:u.string(),displayName:u.string(),name:u.string()}).strict(),VE=u.array(Y9),ZE=u.object({name:u.string(),pluginProvider:u.string().optional()}).strict(),GE=u.array(ZE),eZ=u.object({dir:u.string(),hasMigrationsDir:u.boolean(),hasSkillsDir:u.boolean(),packageName:u.string()}).strict(),tZ=u.object({packageNames:u.array(u.string()),packages:u.array(eZ),manifestRoots:u.array(u.string()),skillRoots:u.array(u.string()),tracingIncludes:u.array(u.string())}).strict(),Fve=u.object({cwd:u.string(),homeDir:u.string(),descriptionText:u.string().optional(),providers:u.array(u.string()),skills:u.array(ZE),packagedContent:tZ}).strict(),KE=u.enum(["danger","good","neutral","warning"]),Hve=u.object({label:u.string(),tone:KE.optional(),value:u.string()}).strict(),qve=u.object({key:u.string(),label:u.string()}).strict(),Vve=u.object({id:u.string(),tone:KE.optional(),values:u.record(u.string(),u.string())}).strict(),Zve=u.object({fields:u.array(qve).optional(),emptyText:u.string().optional(),records:u.array(Vve).optional(),title:u.string()}).strict(),Gve=u.object({categories:u.array(u.object({id:u.string().min(1),label:u.string().min(1),values:u.record(u.string(),u.number().finite())}).strict()).max(100),description:u.string().optional(),emptyText:u.string().optional(),id:u.string().min(1),series:u.array(u.object({format:u.literal("usd").optional(),key:u.string().min(1),label:u.string().min(1),tone:KE.optional()}).strict()).min(1).max(8),timeRangeDays:u.array(u.union([u.literal(1),u.literal(7),u.literal(30),u.literal(90)])).min(1).max(4).optional(),title:u.string().min(1),type:u.literal("bar_chart")}).strict(),aZ=u.object({generatedAt:u.string().optional(),metrics:u.array(Hve).optional(),recordSets:u.array(Zve).optional(),title:u.string().optional(),pluginName:u.string(),widgets:u.array(Gve).max(12).optional()}).strict(),a1=u.object({generatedAt:u.string(),reports:u.array(aZ),source:u.literal("plugins")}).strict(),nZ=36e5,pUe=6*nZ,hUe=24*nZ;async function WE(e){let t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(`${e.conversationId}\0${e.idempotencyKey}`));return`api-msg:${Array.from(new Uint8Array(t),a=>a.toString(16).padStart(2,"0")).join("").slice(0,24)}`}var D=Symbol.for("drizzle:entityKind");function Bn(e,t){if(!e||typeof e!="object")return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,D))throw new Error(`Class "${t.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let a=Object.getPrototypeOf(e).constructor;if(a)for(;a;){if(D in a&&a[D]===t[D])return!0;a=Object.getPrototypeOf(a)}return!1}var pm=class{constructor(t,a){this.table=t,this.config=a,this.name=a.name,this.keyAsName=a.keyAsName,this.notNull=a.notNull,this.default=a.default,this.defaultFn=a.defaultFn,this.onUpdateFn=a.onUpdateFn,this.hasDefault=a.hasDefault,this.primary=a.primaryKey,this.isUnique=a.isUnique,this.uniqueName=a.uniqueName,this.uniqueType=a.uniqueType,this.dataType=a.dataType,this.columnType=a.columnType,this.generated=a.generated,this.generatedIdentity=a.generatedIdentity}static[D]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue(t){return t}mapToDriverValue(t){return t}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}};var n1=class{static[D]="ColumnBuilder";config;constructor(t,a,r){this.config={name:t,keyAsName:t==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:a,columnType:r,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(t){return this.config.default=t,this.config.hasDefault=!0,this}$defaultFn(t){return this.config.defaultFn=t,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(t){return this.config.onUpdateFn=t,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(t){this.config.name===""&&(this.config.name=t)}};var Xu=Symbol.for("drizzle:Name");var r1=class{static[D]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor(t,a){this.reference=()=>{let{name:r,columns:n,foreignColumns:o}=t();return{name:r,columns:n,foreignTable:o[0].table,foreignColumns:o}},a&&(this._onUpdate=a.onUpdate,this._onDelete=a.onDelete)}onUpdate(t){return this._onUpdate=t===void 0?"no action":t,this}onDelete(t){return this._onDelete=t===void 0?"no action":t,this}build(t){return new JE(t,this)}},JE=class{constructor(t,a){this.table=t,this.reference=a.reference,this.onUpdate=a._onUpdate,this.onDelete=a._onDelete}static[D]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:t,columns:a,foreignColumns:r}=this.reference(),n=a.map(s=>s.name),o=r.map(s=>s.name),i=[this.table[Xu],...n,r[0].table[Xu],...o];return t??`${i.join("_")}_fk`}};function o1(e,...t){return e(...t)}function YE(e,t){return`${e[Xu]}_${t.join("_")}_unique`}var QE=class{constructor(t,a){this.name=a,this.columns=t}static[D]="PgUniqueConstraintBuilder";columns;nullsNotDistinctConfig=!1;nullsNotDistinct(){return this.nullsNotDistinctConfig=!0,this}build(t){return new XE(t,this.columns,this.nullsNotDistinctConfig,this.name)}},rZ=class{static[D]="PgUniqueOnConstraintBuilder";name;constructor(t){this.name=t}on(...t){return new QE(t,this.name)}},XE=class{constructor(t,a,r,n){this.table=t,this.columns=a,this.name=n??YE(this.table,this.columns.map(o=>o.name)),this.nullsNotDistinct=r}static[D]="PgUniqueConstraint";columns;name;nullsNotDistinct=!1;getName(){return this.name}};function oZ(e,t,a){for(let r=t;r<e.length;r++){let n=e[r];if(n==="\\"){r++;continue}if(n==='"')return[e.slice(t,r).replace(/\\/g,""),r+1];if(!a&&(n===","||n==="}"))return[e.slice(t,r).replace(/\\/g,""),r]}return[e.slice(t).replace(/\\/g,""),e.length]}function iZ(e,t=0){let a=[],r=t,n=!1;for(;r<e.length;){let o=e[r];if(o===","){(n||r===t)&&a.push(""),n=!0,r++;continue}if(n=!1,o==="\\"){r+=2;continue}if(o==='"'){let[l,c]=oZ(e,r+1,!0);a.push(l),r=c;continue}if(o==="}")return[a,r+1];if(o==="{"){let[l,c]=iZ(e,r+1);a.push(l),r=c;continue}let[i,s]=oZ(e,r,!1);a.push(i),r=s}return[a,r]}function sZ(e){let[t]=iZ(e,1);return t}function eM(e){return`{${e.map(t=>Array.isArray(t)?eM(t):typeof t=="string"?`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`${t}`).join(",")}}`}var de=class extends n1{foreignKeyConfigs=[];static[D]="PgColumnBuilder";array(t){return new aM(this.config.name,this,t)}references(t,a={}){return this.foreignKeyConfigs.push({ref:t,actions:a}),this}unique(t,a){return this.config.isUnique=!0,this.config.uniqueName=t,this.config.uniqueType=a?.nulls,this}generatedAlwaysAs(t){return this.config.generated={as:t,type:"always",mode:"stored"},this}buildForeignKeys(t,a){return this.foreignKeyConfigs.map(({ref:r,actions:n})=>o1((o,i)=>{let s=new r1(()=>{let l=o();return{columns:[t],foreignColumns:[l]}});return i.onUpdate&&s.onUpdate(i.onUpdate),i.onDelete&&s.onDelete(i.onDelete),s.build(a)},r,n))}buildExtraConfigColumn(t){return new tM(t,this.config)}},ne=class extends pm{constructor(t,a){a.uniqueName||(a.uniqueName=YE(t,[a.name])),super(t,a),this.table=t}static[D]="PgColumn"},tM=class extends ne{static[D]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op(t){return this.indexConfig.opClass=t,this}},ag=class{static[D]="IndexedColumn";constructor(t,a,r,n){this.name=t,this.keyAsName=a,this.type=r,this.indexConfig=n}name;keyAsName;type;indexConfig},aM=class extends de{static[D]="PgArrayBuilder";constructor(t,a,r){super(t,"array","PgArray"),this.config.baseBuilder=a,this.config.size=r}build(t){let a=this.config.baseBuilder.build(t);return new nM(t,this.config,a)}},nM=class e extends ne{constructor(t,a,r,n){super(t,a),this.baseColumn=r,this.range=n,this.size=a.size}size;static[D]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size=="number"?this.size:""}]`}mapFromDriverValue(t){return typeof t=="string"&&(t=sZ(t)),t.map(a=>this.baseColumn.mapFromDriverValue(a))}mapToDriverValue(t,a=!1){let r=t.map(n=>n===null?null:Bn(this.baseColumn,e)?this.baseColumn.mapToDriverValue(n,!0):this.baseColumn.mapToDriverValue(n));return a?r:eM(r)}};var lZ=class extends de{static[D]="PgEnumObjectColumnBuilder";constructor(t,a){super(t,"string","PgEnumObjectColumn"),this.config.enum=a}build(t){return new rM(t,this.config)}},rM=class extends ne{static[D]="PgEnumObjectColumn";enum;enumValues=this.config.enum.enumValues;constructor(t,a){super(t,a),this.enum=a.enum}getSQLType(){return this.enum.enumName}},uZ=Symbol.for("drizzle:isPgEnum");function dZ(e){return!!e&&typeof e=="function"&&uZ in e&&e[uZ]===!0}var cZ=class extends de{static[D]="PgEnumColumnBuilder";constructor(t,a){super(t,"string","PgEnumColumn"),this.config.enum=a}build(t){return new oM(t,this.config)}},oM=class extends ne{static[D]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor(t,a){super(t,a),this.enum=a.enum}getSQLType(){return this.enum.enumName}};var ng=class{static[D]="Subquery";constructor(t,a,r,n=!1,o=[]){this._={brand:"Subquery",sql:t,selectedFields:a,alias:r,isWith:n,usedTables:o}}},fZ=class extends ng{static[D]="WithSubquery"};var mZ="0.45.2";var iM,sM,pZ={startActiveSpan(e,t){return iM?(sM||(sM=iM.trace.getTracer("drizzle-orm",mZ)),o1((a,r)=>r.startActiveSpan(e,n=>{try{return t(n)}catch(o){throw n.setStatus({code:a.SpanStatusCode.ERROR,message:o instanceof Error?o.message:"Unknown error"}),o}finally{n.end()}}),iM,sM)):t()}};var rg=Symbol.for("drizzle:ViewBaseConfig");var lM=Symbol.for("drizzle:Schema"),hZ=Symbol.for("drizzle:Columns"),gZ=Symbol.for("drizzle:ExtraConfigColumns"),uM=Symbol.for("drizzle:OriginalName"),cM=Symbol.for("drizzle:BaseName"),mx=Symbol.for("drizzle:IsAlias"),vZ=Symbol.for("drizzle:ExtraConfigBuilder"),Kve=Symbol.for("drizzle:IsDrizzleTable"),kn=class{static[D]="Table";static Symbol={Name:Xu,Schema:lM,OriginalName:uM,Columns:hZ,ExtraConfigColumns:gZ,BaseName:cM,IsAlias:mx,ExtraConfigBuilder:vZ};[Xu];[uM];[lM];[hZ];[gZ];[cM];[mx]=!1;[Kve]=!0;[vZ]=void 0;constructor(t,a,r){this[Xu]=this[uM]=t,this[lM]=a,this[cM]=r}};var yZ=class{static[D]="FakePrimitiveParam"};function Wve(e){return e!=null&&typeof e.getSQL=="function"}function Jve(e){let t={sql:"",params:[]};for(let a of e)t.sql+=a.sql,t.params.push(...a.params),a.typings?.length&&(t.typings||(t.typings=[]),t.typings.push(...a.typings));return t}var Ri=class{static[D]="StringChunk";value;constructor(t){this.value=Array.isArray(t)?t:[t]}getSQL(){return new In([this])}},In=class e{constructor(t){this.queryChunks=t;for(let a of t)if(Bn(a,kn)){let r=a[kn.Symbol.Schema];this.usedTables.push(r===void 0?a[kn.Symbol.Name]:r+"."+a[kn.Symbol.Name])}}static[D]="SQL";decoder=bZ;shouldInlineParams=!1;usedTables=[];append(t){return this.queryChunks.push(...t.queryChunks),this}toQuery(t){return pZ.startActiveSpan("drizzle.buildSQL",a=>{let r=this.buildQueryFromSourceParams(this.queryChunks,t);return a?.setAttributes({"drizzle.query.text":r.sql,"drizzle.query.params":JSON.stringify(r.params)}),r})}buildQueryFromSourceParams(t,a){let r=Object.assign({},a,{inlineParams:a.inlineParams||this.shouldInlineParams,paramStartIndex:a.paramStartIndex||{value:0}}),{casing:n,escapeName:o,escapeParam:i,prepareTyping:s,inlineParams:l,paramStartIndex:c}=r;return Jve(t.map(d=>{if(Bn(d,Ri))return{sql:d.value.join(""),params:[]};if(Bn(d,px))return{sql:o(d.value),params:[]};if(d===void 0)return{sql:"",params:[]};if(Array.isArray(d)){let f=[new Ri("(")];for(let[m,p]of d.entries())f.push(p),m<d.length-1&&f.push(new Ri(", "));return f.push(new Ri(")")),this.buildQueryFromSourceParams(f,r)}if(Bn(d,e))return this.buildQueryFromSourceParams(d.queryChunks,{...r,inlineParams:l||d.shouldInlineParams});if(Bn(d,kn)){let f=d[kn.Symbol.Schema],m=d[kn.Symbol.Name];return{sql:f===void 0||d[mx]?o(m):o(f)+"."+o(m),params:[]}}if(Bn(d,pm)){let f=n.getColumnCasing(d);if(a.invokeSource==="indexes")return{sql:o(f),params:[]};let m=d.table[kn.Symbol.Schema];return{sql:d.table[mx]||m===void 0?o(d.table[kn.Symbol.Name])+"."+o(f):o(m)+"."+o(d.table[kn.Symbol.Name])+"."+o(f),params:[]}}if(Bn(d,dM)){let f=d[rg].schema,m=d[rg].name;return{sql:f===void 0||d[rg].isAlias?o(m):o(f)+"."+o(m),params:[]}}if(Bn(d,i1)){if(Bn(d.value,hx))return{sql:i(c.value++,d),params:[d],typings:["none"]};let f=d.value===null?null:d.encoder.mapToDriverValue(d.value);if(Bn(f,e))return this.buildQueryFromSourceParams([f],r);if(l)return{sql:this.mapInlineParam(f,r),params:[]};let m=["none"];return s&&(m=[s(d.encoder)]),{sql:i(c.value++,f),params:[f],typings:m}}return Bn(d,hx)?{sql:i(c.value++,d),params:[d],typings:["none"]}:Bn(d,e.Aliased)&&d.fieldAlias!==void 0?{sql:o(d.fieldAlias),params:[]}:Bn(d,ng)?d._.isWith?{sql:o(d._.alias),params:[]}:this.buildQueryFromSourceParams([new Ri("("),d._.sql,new Ri(") "),new px(d._.alias)],r):dZ(d)?d.schema?{sql:o(d.schema)+"."+o(d.enumName),params:[]}:{sql:o(d.enumName),params:[]}:Wve(d)?d.shouldOmitSQLParens?.()?this.buildQueryFromSourceParams([d.getSQL()],r):this.buildQueryFromSourceParams([new Ri("("),d.getSQL(),new Ri(")")],r):l?{sql:this.mapInlineParam(d,r),params:[]}:{sql:i(c.value++,d),params:[d],typings:["none"]}}))}mapInlineParam(t,{escapeString:a}){if(t===null)return"null";if(typeof t=="number"||typeof t=="boolean")return t.toString();if(typeof t=="string")return a(t);if(typeof t=="object"){let r=t.toString();return a(r==="[object Object]"?JSON.stringify(t):r)}throw new Error("Unexpected param value: "+t)}getSQL(){return this}as(t){return t===void 0?this:new e.Aliased(this,t)}mapWith(t){return this.decoder=typeof t=="function"?{mapFromDriverValue:t}:t,this}inlineParams(){return this.shouldInlineParams=!0,this}if(t){return t?this:void 0}},px=class{constructor(t){this.value=t}static[D]="Name";brand;getSQL(){return new In([this])}};var bZ={mapFromDriverValue:e=>e},xZ={mapToDriverValue:e=>e},o5e={...bZ,...xZ},i1=class{constructor(t,a=xZ){this.value=t,this.encoder=a}static[D]="Param";brand;getSQL(){return new In([this])}};function og(e,...t){let a=[];(t.length>0||e.length>0&&e[0]!=="")&&a.push(new Ri(e[0]));for(let[r,n]of t.entries())a.push(n,new Ri(e[r+1]));return new In(a)}(e=>{function t(){return new In([])}e.empty=t;function a(l){return new In(l)}e.fromList=a;function r(l){return new In([new Ri(l)])}e.raw=r;function n(l,c){let d=[];for(let[f,m]of l.entries())f>0&&c!==void 0&&d.push(c),d.push(m);return new In(d)}e.join=n;function o(l){return new px(l)}e.identifier=o;function i(l){return new hx(l)}e.placeholder=i;function s(l,c){return new i1(l,c)}e.param=s})(og||(og={}));(e=>{class t{constructor(r,n){this.sql=r,this.fieldAlias=n}static[D]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new t(this.sql,this.fieldAlias)}}e.Aliased=t})(In||(In={}));var hx=class{constructor(t){this.name=t}static[D]="Placeholder";getSQL(){return new In([this])}};var Qve=Symbol.for("drizzle:IsDrizzleView"),dM=class{static[D]="View";[rg];[Qve]=!0;constructor({name:t,schema:a,selectedFields:r,query:n}){this[rg]={name:t,originalName:t,schema:a,selectedFields:r,query:n,isExisting:!n,isAlias:!1}}getSQL(){return new In([this])}};pm.prototype.getSQL=function(){return new In([this])};kn.prototype.getSQL=function(){return new In([this])};ng.prototype.getSQL=function(){return new In([this])};function _t(e,t){return{name:typeof e=="string"&&e.length>0?e:"",config:typeof e=="object"?e:t}}var s5e=typeof TextDecoder>"u"?null:new TextDecoder;var Yu=class extends de{static[D]="PgIntColumnBaseBuilder";generatedAlwaysAsIdentity(t){if(t){let{name:a,...r}=t;this.config.generatedIdentity={type:"always",sequenceName:a,sequenceOptions:r}}else this.config.generatedIdentity={type:"always"};return this.config.hasDefault=!0,this.config.notNull=!0,this}generatedByDefaultAsIdentity(t){if(t){let{name:a,...r}=t;this.config.generatedIdentity={type:"byDefault",sequenceName:a,sequenceOptions:r}}else this.config.generatedIdentity={type:"byDefault"};return this.config.hasDefault=!0,this.config.notNull=!0,this}};var fM=class extends Yu{static[D]="PgBigInt53Builder";constructor(t){super(t,"number","PgBigInt53")}build(t){return new mM(t,this.config)}},mM=class extends ne{static[D]="PgBigInt53";getSQLType(){return"bigint"}mapFromDriverValue(t){return typeof t=="number"?t:Number(t)}},pM=class extends Yu{static[D]="PgBigInt64Builder";constructor(t){super(t,"bigint","PgBigInt64")}build(t){return new hM(t,this.config)}},hM=class extends ne{static[D]="PgBigInt64";getSQLType(){return"bigint"}mapFromDriverValue(t){return BigInt(t)}};function SZ(e,t){let{name:a,config:r}=_t(e,t);return r.mode==="number"?new fM(a):new pM(a)}var gM=class extends de{static[D]="PgBigSerial53Builder";constructor(t){super(t,"number","PgBigSerial53"),this.config.hasDefault=!0,this.config.notNull=!0}build(t){return new vM(t,this.config)}},vM=class extends ne{static[D]="PgBigSerial53";getSQLType(){return"bigserial"}mapFromDriverValue(t){return typeof t=="number"?t:Number(t)}},yM=class extends de{static[D]="PgBigSerial64Builder";constructor(t){super(t,"bigint","PgBigSerial64"),this.config.hasDefault=!0}build(t){return new bM(t,this.config)}},bM=class extends ne{static[D]="PgBigSerial64";getSQLType(){return"bigserial"}mapFromDriverValue(t){return BigInt(t)}};function wZ(e,t){let{name:a,config:r}=_t(e,t);return r.mode==="number"?new gM(a):new yM(a)}var xM=class extends de{static[D]="PgBooleanBuilder";constructor(t){super(t,"boolean","PgBoolean")}build(t){return new SM(t,this.config)}},SM=class extends ne{static[D]="PgBoolean";getSQLType(){return"boolean"}};function CZ(e){return new xM(e??"")}var wM=class extends de{static[D]="PgCharBuilder";constructor(t,a){super(t,"string","PgChar"),this.config.length=a.length,this.config.enumValues=a.enum}build(t){return new CM(t,this.config)}},CM=class extends ne{static[D]="PgChar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"char":`char(${this.length})`}};function kZ(e,t={}){let{name:a,config:r}=_t(e,t);return new wM(a,r)}var kM=class extends de{static[D]="PgCidrBuilder";constructor(t){super(t,"string","PgCidr")}build(t){return new IM(t,this.config)}},IM=class extends ne{static[D]="PgCidr";getSQLType(){return"cidr"}};function IZ(e){return new kM(e??"")}var LM=class extends de{static[D]="PgCustomColumnBuilder";constructor(t,a,r){super(t,"custom","PgCustomColumn"),this.config.fieldConfig=a,this.config.customTypeParams=r}build(t){return new TM(t,this.config)}},TM=class extends ne{static[D]="PgCustomColumn";sqlName;mapTo;mapFrom;constructor(t,a){super(t,a),this.sqlName=a.customTypeParams.dataType(a.fieldConfig),this.mapTo=a.customTypeParams.toDriver,this.mapFrom=a.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(t){return typeof this.mapFrom=="function"?this.mapFrom(t):t}mapToDriverValue(t){return typeof this.mapTo=="function"?this.mapTo(t):t}};function LZ(e){return(t,a)=>{let{name:r,config:n}=_t(t,a);return new LM(r,n,e)}}var Hl=class extends de{static[D]="PgDateColumnBaseBuilder";defaultNow(){return this.default(og`now()`)}};var RM=class extends Hl{static[D]="PgDateBuilder";constructor(t){super(t,"date","PgDate")}build(t){return new _M(t,this.config)}},_M=class extends ne{static[D]="PgDate";getSQLType(){return"date"}mapFromDriverValue(t){return typeof t=="string"?new Date(t):t}mapToDriverValue(t){return t.toISOString()}},NM=class extends Hl{static[D]="PgDateStringBuilder";constructor(t){super(t,"string","PgDateString")}build(t){return new AM(t,this.config)}},AM=class extends ne{static[D]="PgDateString";getSQLType(){return"date"}mapFromDriverValue(t){return typeof t=="string"?t:t.toISOString().slice(0,-14)}};function TZ(e,t){let{name:a,config:r}=_t(e,t);return r?.mode==="date"?new RM(a):new NM(a)}var $M=class extends de{static[D]="PgDoublePrecisionBuilder";constructor(t){super(t,"number","PgDoublePrecision")}build(t){return new PM(t,this.config)}},PM=class extends ne{static[D]="PgDoublePrecision";getSQLType(){return"double precision"}mapFromDriverValue(t){return typeof t=="string"?Number.parseFloat(t):t}};function RZ(e){return new $M(e??"")}var DM=class extends de{static[D]="PgInetBuilder";constructor(t){super(t,"string","PgInet")}build(t){return new EM(t,this.config)}},EM=class extends ne{static[D]="PgInet";getSQLType(){return"inet"}};function _Z(e){return new DM(e??"")}var MM=class extends Yu{static[D]="PgIntegerBuilder";constructor(t){super(t,"number","PgInteger")}build(t){return new OM(t,this.config)}},OM=class extends ne{static[D]="PgInteger";getSQLType(){return"integer"}mapFromDriverValue(t){return typeof t=="string"?Number.parseInt(t):t}};function NZ(e){return new MM(e??"")}var zM=class extends de{static[D]="PgIntervalBuilder";constructor(t,a){super(t,"string","PgInterval"),this.config.intervalConfig=a}build(t){return new UM(t,this.config)}},UM=class extends ne{static[D]="PgInterval";fields=this.config.intervalConfig.fields;precision=this.config.intervalConfig.precision;getSQLType(){let t=this.fields?` ${this.fields}`:"",a=this.precision?`(${this.precision})`:"";return`interval${t}${a}`}};function AZ(e,t={}){let{name:a,config:r}=_t(e,t);return new zM(a,r)}var jM=class extends de{static[D]="PgJsonBuilder";constructor(t){super(t,"json","PgJson")}build(t){return new BM(t,this.config)}},BM=class extends ne{static[D]="PgJson";constructor(t,a){super(t,a)}getSQLType(){return"json"}mapToDriverValue(t){return JSON.stringify(t)}mapFromDriverValue(t){if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t}};function $Z(e){return new jM(e??"")}var FM=class extends de{static[D]="PgJsonbBuilder";constructor(t){super(t,"json","PgJsonb")}build(t){return new HM(t,this.config)}},HM=class extends ne{static[D]="PgJsonb";constructor(t,a){super(t,a)}getSQLType(){return"jsonb"}mapToDriverValue(t){return JSON.stringify(t)}mapFromDriverValue(t){if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t}};function s1(e){return new FM(e??"")}var qM=class extends de{static[D]="PgLineBuilder";constructor(t){super(t,"array","PgLine")}build(t){return new VM(t,this.config)}},VM=class extends ne{static[D]="PgLine";getSQLType(){return"line"}mapFromDriverValue(t){let[a,r,n]=t.slice(1,-1).split(",");return[Number.parseFloat(a),Number.parseFloat(r),Number.parseFloat(n)]}mapToDriverValue(t){return`{${t[0]},${t[1]},${t[2]}}`}},ZM=class extends de{static[D]="PgLineABCBuilder";constructor(t){super(t,"json","PgLineABC")}build(t){return new GM(t,this.config)}},GM=class extends ne{static[D]="PgLineABC";getSQLType(){return"line"}mapFromDriverValue(t){let[a,r,n]=t.slice(1,-1).split(",");return{a:Number.parseFloat(a),b:Number.parseFloat(r),c:Number.parseFloat(n)}}mapToDriverValue(t){return`{${t.a},${t.b},${t.c}}`}};function PZ(e,t){let{name:a,config:r}=_t(e,t);return!r?.mode||r.mode==="tuple"?new qM(a):new ZM(a)}var KM=class extends de{static[D]="PgMacaddrBuilder";constructor(t){super(t,"string","PgMacaddr")}build(t){return new WM(t,this.config)}},WM=class extends ne{static[D]="PgMacaddr";getSQLType(){return"macaddr"}};function DZ(e){return new KM(e??"")}var JM=class extends de{static[D]="PgMacaddr8Builder";constructor(t){super(t,"string","PgMacaddr8")}build(t){return new QM(t,this.config)}},QM=class extends ne{static[D]="PgMacaddr8";getSQLType(){return"macaddr8"}};function EZ(e){return new JM(e??"")}var XM=class extends de{static[D]="PgNumericBuilder";constructor(t,a,r){super(t,"string","PgNumeric"),this.config.precision=a,this.config.scale=r}build(t){return new YM(t,this.config)}},YM=class extends ne{static[D]="PgNumeric";precision;scale;constructor(t,a){super(t,a),this.precision=a.precision,this.scale=a.scale}mapFromDriverValue(t){return typeof t=="string"?t:String(t)}getSQLType(){return this.precision!==void 0&&this.scale!==void 0?`numeric(${this.precision}, ${this.scale})`:this.precision===void 0?"numeric":`numeric(${this.precision})`}},eO=class extends de{static[D]="PgNumericNumberBuilder";constructor(t,a,r){super(t,"number","PgNumericNumber"),this.config.precision=a,this.config.scale=r}build(t){return new tO(t,this.config)}},tO=class extends ne{static[D]="PgNumericNumber";precision;scale;constructor(t,a){super(t,a),this.precision=a.precision,this.scale=a.scale}mapFromDriverValue(t){return typeof t=="number"?t:Number(t)}mapToDriverValue=String;getSQLType(){return this.precision!==void 0&&this.scale!==void 0?`numeric(${this.precision}, ${this.scale})`:this.precision===void 0?"numeric":`numeric(${this.precision})`}},aO=class extends de{static[D]="PgNumericBigIntBuilder";constructor(t,a,r){super(t,"bigint","PgNumericBigInt"),this.config.precision=a,this.config.scale=r}build(t){return new nO(t,this.config)}},nO=class extends ne{static[D]="PgNumericBigInt";precision;scale;constructor(t,a){super(t,a),this.precision=a.precision,this.scale=a.scale}mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return this.precision!==void 0&&this.scale!==void 0?`numeric(${this.precision}, ${this.scale})`:this.precision===void 0?"numeric":`numeric(${this.precision})`}};function MZ(e,t){let{name:a,config:r}=_t(e,t),n=r?.mode;return n==="number"?new eO(a,r?.precision,r?.scale):n==="bigint"?new aO(a,r?.precision,r?.scale):new XM(a,r?.precision,r?.scale)}var rO=class extends de{static[D]="PgPointTupleBuilder";constructor(t){super(t,"array","PgPointTuple")}build(t){return new oO(t,this.config)}},oO=class extends ne{static[D]="PgPointTuple";getSQLType(){return"point"}mapFromDriverValue(t){if(typeof t=="string"){let[a,r]=t.slice(1,-1).split(",");return[Number.parseFloat(a),Number.parseFloat(r)]}return[t.x,t.y]}mapToDriverValue(t){return`(${t[0]},${t[1]})`}},iO=class extends de{static[D]="PgPointObjectBuilder";constructor(t){super(t,"json","PgPointObject")}build(t){return new sO(t,this.config)}},sO=class extends ne{static[D]="PgPointObject";getSQLType(){return"point"}mapFromDriverValue(t){if(typeof t=="string"){let[a,r]=t.slice(1,-1).split(",");return{x:Number.parseFloat(a),y:Number.parseFloat(r)}}return t}mapToDriverValue(t){return`(${t.x},${t.y})`}};function OZ(e,t){let{name:a,config:r}=_t(e,t);return!r?.mode||r.mode==="tuple"?new rO(a):new iO(a)}function Xve(e){let t=[];for(let a=0;a<e.length;a+=2)t.push(Number.parseInt(e.slice(a,a+2),16));return new Uint8Array(t)}function zZ(e,t){let a=new ArrayBuffer(8),r=new DataView(a);for(let n=0;n<8;n++)r.setUint8(n,e[t+n]);return r.getFloat64(0,!0)}function lO(e){let t=Xve(e),a=0,r=t[a];a+=1;let n=new DataView(t.buffer),o=n.getUint32(a,r===1);a+=4;let i;if(o&536870912&&(i=n.getUint32(a,r===1),a+=4),(o&65535)===1){let s=zZ(t,a);a+=8;let l=zZ(t,a);return a+=8,[s,l]}throw new Error("Unsupported geometry type")}var uO=class extends de{static[D]="PgGeometryBuilder";constructor(t){super(t,"array","PgGeometry")}build(t){return new cO(t,this.config)}},cO=class extends ne{static[D]="PgGeometry";getSQLType(){return"geometry(point)"}mapFromDriverValue(t){return lO(t)}mapToDriverValue(t){return`point(${t[0]} ${t[1]})`}},dO=class extends de{static[D]="PgGeometryObjectBuilder";constructor(t){super(t,"json","PgGeometryObject")}build(t){return new fO(t,this.config)}},fO=class extends ne{static[D]="PgGeometryObject";getSQLType(){return"geometry(point)"}mapFromDriverValue(t){let a=lO(t);return{x:a[0],y:a[1]}}mapToDriverValue(t){return`point(${t.x} ${t.y})`}};function UZ(e,t){let{name:a,config:r}=_t(e,t);return!r?.mode||r.mode==="tuple"?new uO(a):new dO(a)}var mO=class extends de{static[D]="PgRealBuilder";constructor(t,a){super(t,"number","PgReal"),this.config.length=a}build(t){return new pO(t,this.config)}},pO=class extends ne{static[D]="PgReal";constructor(t,a){super(t,a)}getSQLType(){return"real"}mapFromDriverValue=t=>typeof t=="string"?Number.parseFloat(t):t};function jZ(e){return new mO(e??"")}var hO=class extends de{static[D]="PgSerialBuilder";constructor(t){super(t,"number","PgSerial"),this.config.hasDefault=!0,this.config.notNull=!0}build(t){return new gO(t,this.config)}},gO=class extends ne{static[D]="PgSerial";getSQLType(){return"serial"}};function BZ(e){return new hO(e??"")}var vO=class extends Yu{static[D]="PgSmallIntBuilder";constructor(t){super(t,"number","PgSmallInt")}build(t){return new yO(t,this.config)}},yO=class extends ne{static[D]="PgSmallInt";getSQLType(){return"smallint"}mapFromDriverValue=t=>typeof t=="string"?Number(t):t};function FZ(e){return new vO(e??"")}var bO=class extends de{static[D]="PgSmallSerialBuilder";constructor(t){super(t,"number","PgSmallSerial"),this.config.hasDefault=!0,this.config.notNull=!0}build(t){return new xO(t,this.config)}},xO=class extends ne{static[D]="PgSmallSerial";getSQLType(){return"smallserial"}};function HZ(e){return new bO(e??"")}var SO=class extends de{static[D]="PgTextBuilder";constructor(t,a){super(t,"string","PgText"),this.config.enumValues=a.enum}build(t){return new wO(t,this.config)}},wO=class extends ne{static[D]="PgText";enumValues=this.config.enumValues;getSQLType(){return"text"}};function Js(e,t={}){let{name:a,config:r}=_t(e,t);return new SO(a,r)}var CO=class extends Hl{constructor(t,a,r){super(t,"string","PgTime"),this.withTimezone=a,this.precision=r,this.config.withTimezone=a,this.config.precision=r}static[D]="PgTimeBuilder";build(t){return new kO(t,this.config)}},kO=class extends ne{static[D]="PgTime";withTimezone;precision;constructor(t,a){super(t,a),this.withTimezone=a.withTimezone,this.precision=a.precision}getSQLType(){return`time${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}};function qZ(e,t={}){let{name:a,config:r}=_t(e,t);return new CO(a,r.withTimezone??!1,r.precision)}var IO=class extends Hl{static[D]="PgTimestampBuilder";constructor(t,a,r){super(t,"date","PgTimestamp"),this.config.withTimezone=a,this.config.precision=r}build(t){return new LO(t,this.config)}},LO=class extends ne{static[D]="PgTimestamp";withTimezone;precision;constructor(t,a){super(t,a),this.withTimezone=a.withTimezone,this.precision=a.precision}getSQLType(){return`timestamp${this.precision===void 0?"":` (${this.precision})`}${this.withTimezone?" with time zone":""}`}mapFromDriverValue(t){return typeof t=="string"?new Date(this.withTimezone?t:t+"+0000"):t}mapToDriverValue=t=>t.toISOString()},TO=class extends Hl{static[D]="PgTimestampStringBuilder";constructor(t,a,r){super(t,"string","PgTimestampString"),this.config.withTimezone=a,this.config.precision=r}build(t){return new RO(t,this.config)}},RO=class extends ne{static[D]="PgTimestampString";withTimezone;precision;constructor(t,a){super(t,a),this.withTimezone=a.withTimezone,this.precision=a.precision}getSQLType(){return`timestamp${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}mapFromDriverValue(t){if(typeof t=="string")return t;let a=t.toISOString().slice(0,-1).replace("T"," ");if(this.withTimezone){let r=t.getTimezoneOffset(),n=r<=0?"+":"-";return`${a}${n}${Math.floor(Math.abs(r)/60).toString().padStart(2,"0")}`}return a}};function l1(e,t={}){let{name:a,config:r}=_t(e,t);return r?.mode==="string"?new TO(a,r.withTimezone??!1,r.precision):new IO(a,r?.withTimezone??!1,r?.precision)}var _O=class extends de{static[D]="PgUUIDBuilder";constructor(t){super(t,"string","PgUUID")}defaultRandom(){return this.default(og`gen_random_uuid()`)}build(t){return new NO(t,this.config)}},NO=class extends ne{static[D]="PgUUID";getSQLType(){return"uuid"}};function VZ(e){return new _O(e??"")}var AO=class extends de{static[D]="PgVarcharBuilder";constructor(t,a){super(t,"string","PgVarchar"),this.config.length=a.length,this.config.enumValues=a.enum}build(t){return new $O(t,this.config)}},$O=class extends ne{static[D]="PgVarchar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"varchar":`varchar(${this.length})`}};function ZZ(e,t={}){let{name:a,config:r}=_t(e,t);return new AO(a,r)}var PO=class extends de{static[D]="PgBinaryVectorBuilder";constructor(t,a){super(t,"string","PgBinaryVector"),this.config.dimensions=a.dimensions}build(t){return new DO(t,this.config)}},DO=class extends ne{static[D]="PgBinaryVector";dimensions=this.config.dimensions;getSQLType(){return`bit(${this.dimensions})`}};function GZ(e,t){let{name:a,config:r}=_t(e,t);return new PO(a,r)}var EO=class extends de{static[D]="PgHalfVectorBuilder";constructor(t,a){super(t,"array","PgHalfVector"),this.config.dimensions=a.dimensions}build(t){return new MO(t,this.config)}},MO=class extends ne{static[D]="PgHalfVector";dimensions=this.config.dimensions;getSQLType(){return`halfvec(${this.dimensions})`}mapToDriverValue(t){return JSON.stringify(t)}mapFromDriverValue(t){return t.slice(1,-1).split(",").map(a=>Number.parseFloat(a))}};function KZ(e,t){let{name:a,config:r}=_t(e,t);return new EO(a,r)}var OO=class extends de{static[D]="PgSparseVectorBuilder";constructor(t,a){super(t,"string","PgSparseVector"),this.config.dimensions=a.dimensions}build(t){return new zO(t,this.config)}},zO=class extends ne{static[D]="PgSparseVector";dimensions=this.config.dimensions;getSQLType(){return`sparsevec(${this.dimensions})`}};function WZ(e,t){let{name:a,config:r}=_t(e,t);return new OO(a,r)}var UO=class extends de{static[D]="PgVectorBuilder";constructor(t,a){super(t,"array","PgVector"),this.config.dimensions=a.dimensions}build(t){return new jO(t,this.config)}},jO=class extends ne{static[D]="PgVector";dimensions=this.config.dimensions;getSQLType(){return`vector(${this.dimensions})`}mapToDriverValue(t){return JSON.stringify(t)}mapFromDriverValue(t){return t.slice(1,-1).split(",").map(a=>Number.parseFloat(a))}};function JZ(e,t){let{name:a,config:r}=_t(e,t);return new UO(a,r)}function QZ(){return{bigint:SZ,bigserial:wZ,boolean:CZ,char:kZ,cidr:IZ,customType:LZ,date:TZ,doublePrecision:RZ,inet:_Z,integer:NZ,interval:AZ,json:$Z,jsonb:s1,line:PZ,macaddr:DZ,macaddr8:EZ,numeric:MZ,point:OZ,geometry:UZ,real:jZ,serial:BZ,smallint:FZ,smallserial:HZ,text:Js,time:qZ,timestamp:l1,uuid:VZ,varchar:ZZ,bit:GZ,halfvec:KZ,sparsevec:WZ,vector:JZ}}var BO=Symbol.for("drizzle:PgInlineForeignKeys"),XZ=Symbol.for("drizzle:EnableRLS"),gx=class extends kn{static[D]="PgTable";static Symbol=Object.assign({},kn.Symbol,{InlineForeignKeys:BO,EnableRLS:XZ});[BO]=[];[XZ]=!1;[kn.Symbol.ExtraConfigBuilder]=void 0;[kn.Symbol.ExtraConfigColumns]={}};function Yve(e,t,a,r,n=e){let o=new gx(e,r,n),i=typeof t=="function"?t(QZ()):t,s=Object.fromEntries(Object.entries(i).map(([d,f])=>{let m=f;m.setName(d);let p=m.build(o);return o[BO].push(...m.buildForeignKeys(p,o)),[d,p]})),l=Object.fromEntries(Object.entries(i).map(([d,f])=>{let m=f;m.setName(d);let p=m.buildExtraConfigColumn(o);return[d,p]})),c=Object.assign(o,s);return c[kn.Symbol.Columns]=s,c[kn.Symbol.ExtraConfigColumns]=l,a&&(c[gx.Symbol.ExtraConfigBuilder]=a),Object.assign(c,{enableRLS:()=>(c[gx.Symbol.EnableRLS]=!0,c)})}var YZ=(e,t,a)=>Yve(e,t,a,void 0);var u1=class{constructor(t,a){this.unique=t,this.name=a}static[D]="PgIndexBuilderOn";on(...t){return new vx(t.map(a=>{if(Bn(a,In))return a;a=a;let r=new ag(a.name,!!a.keyAsName,a.columnType,a.indexConfig);return a.indexConfig=JSON.parse(JSON.stringify(a.defaultConfig)),r}),this.unique,!1,this.name)}onOnly(...t){return new vx(t.map(a=>{if(Bn(a,In))return a;a=a;let r=new ag(a.name,!!a.keyAsName,a.columnType,a.indexConfig);return a.indexConfig=a.defaultConfig,r}),this.unique,!0,this.name)}using(t,...a){return new vx(a.map(r=>{if(Bn(r,In))return r;r=r;let n=new ag(r.name,!!r.keyAsName,r.columnType,r.indexConfig);return r.indexConfig=JSON.parse(JSON.stringify(r.defaultConfig)),n}),this.unique,!0,this.name,t)}},vx=class{static[D]="PgIndexBuilder";config;constructor(t,a,r,n,o="btree"){this.config={name:n,columns:t,unique:a,only:r,method:o}}concurrently(){return this.config.concurrently=!0,this}with(t){return this.config.with=t,this}where(t){return this.config.where=t,this}build(t){return new FO(this.config,t)}},FO=class{static[D]="PgIndex";config;constructor(t,a){this.config={...t,table:a}}};function eG(e){return new u1(!1,e)}function tG(e){return new u1(!0,e)}var aG=e=>l1(e,{withTimezone:!0}),nG=u.enum(["channel","dm","group","local_conversation","thread","web_session"]),xje=YZ("junior_destinations",{id:Js("id").primaryKey(),provider:Js("provider").notNull(),providerTenantId:Js("provider_tenant_id").notNull().default(""),providerDestinationId:Js("provider_destination_id").notNull(),kind:Js("kind").$type().notNull(),parentDestinationId:Js("parent_destination_id"),displayName:Js("display_name"),visibility:Js("visibility").$type().notNull().default("unknown"),metadata:s1("metadata_json"),createdAt:aG("created_at").notNull(),updatedAt:aG("updated_at").notNull()},e=>[tG("junior_destinations_provider_destination_uidx").on(e.provider,e.providerTenantId,e.providerDestinationId),eG("junior_destinations_provider_kind_idx").on(e.provider,e.kind)]);var eye=u.object({error:u.string().min(1)}).strict(),m1=u.object({closed:u.number().int().nonnegative(),costUsd:u.number().nonnegative().optional(),created:u.number().int().nonnegative(),medianCostUsd:u.number().nonnegative().optional(),medianMergeTimeMs:u.number().nonnegative().optional(),merged:u.number().int().nonnegative(),mergeRate:u.number().min(0).max(1).optional(),open:u.number().int().nonnegative()}).strict(),tye=u.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/),ql=u.object({closed:u.number().int().nonnegative(),created:u.number().int().nonnegative(),date:tye,merged:u.number().int().nonnegative()}).strict(),oG=u.object({closed:u.number().int().nonnegative(),created:u.number().int().nonnegative(),id:u.string().uuid(),medianCostUsd:u.number().nonnegative().optional(),merged:u.number().int().nonnegative(),mergeRate:u.number().min(0).max(1).optional(),name:u.string().min(1),open:u.number().int().nonnegative(),provider:u.string().min(1),url:u.string().url().optional()}).strict(),VO=u.object({closedAt:u.string().optional(),id:u.string().uuid(),mergedAt:u.string().optional(),number:u.number().int().positive(),openedAt:u.string(),provider:u.string().min(1),repository:u.string().min(1),state:ix,title:u.string().optional(),url:u.string().url().optional()}).strict(),ZO=u.object({activityDays:u.array(ql),activityHours:u.array(ql).optional(),activitySixHours:u.array(ql).optional(),changes:u.array(VO),generatedAt:u.string(),repositories:u.array(oG),summary:m1,windowEnd:u.string(),windowStart:u.string()}).strict(),aye=u.object({repositoryId:u.string().uuid()}).strict(),GO=u.object({activityDays:u.array(ql),activityHours:u.array(ql).optional(),activitySixHours:u.array(ql).optional(),changes:u.array(VO),generatedAt:u.string(),repository:u.object({id:u.string().uuid(),name:u.string().min(1),provider:u.string().min(1),url:u.string().url().optional()}).strict(),summary:m1,windowEnd:u.string(),windowStart:u.string(),workspaces:u.array(u.object({id:u.string().min(1),name:u.string().min(1)}).strict())}).strict(),KO=u.object({activityDays:u.array(ql),activityHours:u.array(ql).optional(),activitySixHours:u.array(ql).optional(),generatedAt:u.string(),summary:m1,windowEnd:u.string(),windowStart:u.string()}).strict(),d1=u.object({active:u.number(),conversations:u.number(),date:u.string(),durationMs:u.number(),failed:u.number(),tokens:u.number().optional()}).strict();var nye=u.object({locationId:u.string().min(1)}).strict(),iG=mm.extend({id:u.string(),firstSeenAt:u.string(),kind:nG,lastSeenAt:u.string(),provider:u.string(),providerDestinationId:u.string(),visibility:u.literal("public")}).strict(),rye=mm.extend({actor:fm}).strict(),oye=u.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/),f1=u.object({date:oye,privateConversations:u.number(),publicConversations:u.number()}).strict(),WO=u.object({activityDays:u.array(f1),activityHours:u.array(f1).optional(),activitySixHours:u.array(f1).optional(),generatedAt:u.string(),locations:u.array(iG),privateActivity:mm,source:u.literal("conversation_index"),windowEnd:u.string(),windowStart:u.string()}).strict(),JO=iG.extend({activityDays:u.array(d1),activityHours:u.array(d1).optional(),activitySixHours:u.array(d1).optional(),actors:u.array(rye),generatedAt:u.string(),recentConversations:u.array(tg),source:u.literal("conversation_index"),windowEnd:u.string(),windowStart:u.string()}).strict(),iye=u.object({email:u.string().trim().min(1)}).strict(),rG=mm.omit({costUsd:!0}),sG=u.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/),HO=u.object({active:u.number(),conversations:u.number(),costUsd:u.number().optional(),date:sG,durationMs:u.number(),failed:u.number(),tokens:u.number().optional()}).strict(),qO=u.object({activePeople:u.number(),conversations:u.number(),date:sG}).strict(),lG=u.object({active:u.number(),activeDays:u.number(),conversations:u.number(),durationMs:u.number(),failed:u.number(),tokens:u.number().optional()}).strict(),c1=u.object({conversations:u.number().int().nonnegative(),costUsd:u.number().finite().nonnegative(),durationMs:u.number().finite().nonnegative(),priorCostUsd:u.number().finite().nonnegative()}).strict(),sye=u.object({1:c1,7:c1,30:c1,90:c1}).strict(),uG=fm.extend({email:u.string().min(1)}).strict(),lye=lG.extend({firstSeenAt:u.string(),lastSeenAt:u.string(),actor:uG,windows:sye}).strict(),QO=u.object({activityDays:u.array(qO),activityHours:u.array(qO).optional(),activitySixHours:u.array(qO).optional(),generatedAt:u.string(),people:u.array(lye),source:u.literal("conversation_index"),windowEnd:u.string(),windowStart:u.string()}).strict(),XO=u.object({activityDays:u.array(HO),activityHours:u.array(HO).optional(),activitySixHours:u.array(HO).optional(),generatedAt:u.string(),locations:u.array(rG),recentConversations:u.array(tg),actor:uG,source:u.literal("conversation_index"),surfaces:u.array(rG),totals:lG,windowEnd:u.string(),windowStart:u.string()}).strict(),YO=u.object({generatedAt:u.string(),sevenDaysUsd:u.number().finite().nonnegative(),source:u.literal("conversation_index"),thirtyDaysUsd:u.number().finite().nonnegative(),windowEnd:u.string(),windowStart:u.string()}).strict(),ez=u.object({id:u.string().uuid(),name:u.string(),tokenSuffix:u.string(),createdAt:u.string().datetime(),expiresAt:u.string().datetime(),lastUsedAt:u.string().datetime().nullable()}).strict(),tz=u.object({tokens:u.array(ez)}).strict(),uye=u.object({name:u.string().trim().min(1).max(80)}).strict(),az=ez.extend({token:u.string().startsWith("jr_pat_")}).strict(),cye=u.object({id:u.string().uuid()}).strict(),dye=u.object({revoked:u.literal(!0)}).strict(),fye=u.object({provider:u.string(),repo:u.string()}).strict(),cG=u.object({provider:u.string(),repo:u.string(),checkoutPath:u.string()}).strict(),mye=u.object({id:u.string(),generatedAt:u.iso.datetime(),buildDurationMs:u.number().int().nonnegative(),sizeBytes:u.number().int().nonnegative().nullable()}).strict(),dG=u.object({id:u.string(),generatedAt:u.iso.datetime(),buildDurationMs:u.number().int().nonnegative(),dependencyCount:u.number().int().nonnegative()}).strict(),ig=u.object({id:u.string().uuid(),name:u.string(),setupScript:u.string(),repos:u.array(cG),snapshot:mye.nullable()}).strict(),nz=u.object({baselineSnapshot:dG.nullable(),workspaces:u.array(ig)}).strict(),pye=u.object({name:u.string(),setupScript:u.string().optional(),repos:u.array(fye)}).strict(),hye=u.object({id:u.string().uuid()}).strict(),gye=u.object({deleted:u.literal(!0)}).strict(),fG=u.object({count:u.number().int().nonnegative(),date:u.string(),metric:u.string().min(1),name:u.string().min(1),namespace:u.string().min(1)}).strict(),rz=u.object({generatedAt:u.string().datetime(),stats:u.array(fG),windowEnd:u.string(),windowStart:u.string()}).strict();var _i=u.string().trim().min(1).max(160),sg=u.number().int().nonnegative(),vye=u.discriminatedUnion("type",[u.strictObject({type:u.literal("code_change"),author:_i.optional(),sourceBranch:_i.optional(),targetBranch:_i.optional(),reviewers:u.array(_i).max(5).optional(),review:u.enum(["required","approved","changes_requested"]).optional(),checks:u.strictObject({passed:sg,failed:sg,pending:sg}).optional(),mergeable:u.boolean().optional(),changedFiles:sg.optional(),additions:sg.optional(),deletions:sg.optional()}),u.strictObject({type:u.literal("task"),assignees:u.array(_i).max(5).optional(),priority:_i.optional(),project:_i.optional(),cycle:_i.optional(),dueDate:u.iso.date().optional(),labels:u.array(_i).max(5).optional()}),u.strictObject({type:u.literal("deployment"),project:_i.optional(),environment:_i.optional(),revision:_i.optional(),branch:_i.optional()})]);function pG(e){if(!e)return[];let t=[],a=n=>n?.length?`${n.join(", ")}${n.length===5?" (up to 5 shown)":""}`:void 0;function r(n,o,i){i!==void 0&&i!==""&&t.push({key:n,label:o,value:String(i)})}switch(e.type){case"code_change":r("sourceBranch","Branch",e.sourceBranch);break;case"task":r("assignees","Assignees",e.assignees?.length===0?"Unassigned":a(e.assignees)),r("priority","Priority",e.priority),r("project","Project",e.project),r("cycle","Cycle",e.cycle),r("dueDate","Due",e.dueDate),r("labels","Labels",a(e.labels));break;case"deployment":r("environment","Environment",e.environment),r("project","Project",e.project),r("revision","Revision",e.revision),r("branch","Branch",e.branch);break}return t.slice(0,4)}var h1=u.enum(["task","code_change","automation","deployment","item"]),yye={task:"Ticket",code_change:"Code change",automation:"Automation",deployment:"Deployment",item:"Item"};function fs(e){let t=e.objectType==="item"&&e.facts?.type==="deployment"?"deployment":e.objectType,a=e.status?.toLowerCase(),r={task:"issue-opened",code_change:"git-pull-request",automation:"workflow",deployment:"rocket",item:"package"}[t],n=t==="automation"?"info":"neutral";return t==="code_change"?(a==="draft"&&(r="git-pull-request-draft"),a==="closed"&&(r="git-pull-request-closed",n="danger"),a==="merged"&&(r="git-merge",n="accent"),a==="open"&&(n="success")):t==="task"?(a==="closed"&&(r="issue-closed",n="accent"),a==="open"&&(n="success")):t==="deployment"&&((a==="ready"||a==="succeeded")&&(n="success"),(a==="error"||a==="failed")&&(n="danger"),(a==="building"||a==="in_progress")&&(n="info")),(a==="warning"||a==="blocked")&&(n="warning"),{icon:r,tone:n,label:yye[t]}}function hG(e){return`/_junior/dashboard/object-icons/v1/${e}.png`}var iz=u.object({kind:u.literal("object"),key:u.string().trim().min(1).max(256),label:u.string().trim().min(1).max(256),objectType:h1,title:u.string().trim().min(1).max(512),url:u.url().max(2048).refine(e=>["http:","https:"].includes(new URL(e).protocol)).nullable(),description:u.string().max(4e3).optional(),status:u.string().trim().min(1).max(100).optional(),trigger:u.string().max(4e3).optional(),warning:u.string().max(1e3).optional(),displayType:u.string().trim().min(1).max(80).optional(),sourceUpdatedAt:u.iso.datetime({offset:!0}).optional(),facts:vye.refine(e=>new TextEncoder().encode(JSON.stringify(e)).length<=4096,"Object facts must not exceed 4 KiB").optional()}).strict().refine(e=>!e.facts||(e.facts.type==="deployment"?e.objectType==="deployment"||e.objectType==="item":e.facts.type===e.objectType),"Object facts must match the object type"),Bje=iz.safeExtend({plugin:u.string().min(1)}),gG={"issue-opened":["M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z","M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Z"],"issue-closed":["M11.28 6.78a.75.75 0 0 0-1.06-1.06L7.25 8.69 5.78 7.22a.75.75 0 0 0-1.06 1.06l2 2a.75.75 0 0 0 1.06 0l3.5-3.5Z","M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0Zm-1.5 0a6.5 6.5 0 1 0-13 0 6.5 6.5 0 0 0 13 0Z"],"git-pull-request":["M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z"],"git-pull-request-draft":["M3.25 1A2.25 2.25 0 0 1 4 5.372v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.251 2.251 0 0 1 3.25 1Zm9.5 14a2.25 2.25 0 1 1 0-4.5 2.25 2.25 0 0 1 0 4.5ZM2.5 3.25a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0ZM3.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm9.5 0a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM14 7.5a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Zm0-4.25a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Z"],"git-pull-request-closed":["M3.25 1A2.25 2.25 0 0 1 4 5.372v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.251 2.251 0 0 1 3.25 1Zm9.5 5.5a.75.75 0 0 1 .75.75v3.378a2.251 2.251 0 1 1-1.5 0V7.25a.75.75 0 0 1 .75-.75Zm-2.03-5.273a.75.75 0 0 1 1.06 0l.97.97.97-.97a.748.748 0 0 1 1.265.332.75.75 0 0 1-.205.729l-.97.97.97.97a.751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018l-.97-.97-.97.97a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734l.97-.97-.97-.97a.75.75 0 0 1 0-1.06ZM2.5 3.25a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0ZM3.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm9.5 0a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"],"git-merge":["M5.45 5.154A4.25 4.25 0 0 0 9.25 7.5h1.378a2.251 2.251 0 1 1 0 1.5H9.25A5.734 5.734 0 0 1 5 7.123v3.505a2.25 2.25 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.95-.218ZM4.25 13.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm8.5-4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5ZM5 3.25a.75.75 0 1 0 0 .005V3.25Z"],workflow:["M0 1.75C0 .784.784 0 1.75 0h3.5C6.216 0 7 .784 7 1.75v3.5A1.75 1.75 0 0 1 5.25 7H4v4a1 1 0 0 0 1 1h4v-1.25C9 9.784 9.784 9 10.75 9h3.5c.966 0 1.75.784 1.75 1.75v3.5A1.75 1.75 0 0 1 14.25 16h-3.5A1.75 1.75 0 0 1 9 14.25v-.75H5A2.5 2.5 0 0 1 2.5 11V7h-.75A1.75 1.75 0 0 1 0 5.25Zm1.75-.25a.25.25 0 0 0-.25.25v3.5c0 .138.112.25.25.25h3.5a.25.25 0 0 0 .25-.25v-3.5a.25.25 0 0 0-.25-.25Zm9 9a.25.25 0 0 0-.25.25v3.5c0 .138.112.25.25.25h3.5a.25.25 0 0 0 .25-.25v-3.5a.25.25 0 0 0-.25-.25Z"],rocket:["M14.064 0h.186C15.216 0 16 .784 16 1.75v.186a8.752 8.752 0 0 1-2.564 6.186l-.458.459c-.314.314-.641.616-.979.904v3.207c0 .608-.315 1.172-.833 1.49l-2.774 1.707a.749.749 0 0 1-1.11-.418l-.954-3.102a1.214 1.214 0 0 1-.145-.125L3.754 9.816a1.218 1.218 0 0 1-.124-.145L.528 8.717a.749.749 0 0 1-.418-1.11l1.71-2.774A1.748 1.748 0 0 1 3.31 4h3.204c.288-.338.59-.665.904-.979l.459-.458A8.749 8.749 0 0 1 14.064 0ZM8.938 3.623h-.002l-.458.458c-.76.76-1.437 1.598-2.02 2.5l-1.5 2.317 2.143 2.143 2.317-1.5c.902-.583 1.74-1.26 2.499-2.02l.459-.458a7.25 7.25 0 0 0 2.123-5.127V1.75a.25.25 0 0 0-.25-.25h-.186a7.249 7.249 0 0 0-5.125 2.123ZM3.56 14.56c-.732.732-2.334 1.045-3.005 1.148a.234.234 0 0 1-.201-.064.234.234 0 0 1-.064-.201c.103-.671.416-2.273 1.15-3.003a1.502 1.502 0 1 1 2.12 2.12Zm6.94-3.935c-.088.06-.177.118-.266.175l-2.35 1.521.548 1.783 1.949-1.2a.25.25 0 0 0 .119-.213ZM3.678 8.116 5.2 5.766c.058-.09.117-.178.176-.266H3.309a.25.25 0 0 0-.213.119l-1.2 1.95ZM12 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"],package:["m8.878.392 5.25 3.045c.54.314.872.89.872 1.514v6.098a1.75 1.75 0 0 1-.872 1.514l-5.25 3.045a1.75 1.75 0 0 1-1.756 0l-5.25-3.045A1.75 1.75 0 0 1 1 11.049V4.951c0-.624.332-1.201.872-1.514L7.122.392a1.75 1.75 0 0 1 1.756 0ZM7.875 1.69l-4.63 2.685L8 7.133l4.755-2.758-4.63-2.685a.248.248 0 0 0-.25 0ZM2.5 5.677v5.372c0 .09.047.171.125.216l4.625 2.683V8.432Zm6.25 8.271 4.625-2.683a.25.25 0 0 0 .125-.216V5.677L8.75 8.432Z"]};function bye(e){try{let t=new URL(e).protocol;return t==="http:"||t==="https:"}catch{return!1}}var xye=u.object({kind:u.literal("resource_link"),objectType:h1.optional(),key:u.string().trim().min(1).max(256),label:u.string().trim().min(1).max(256),url:u.string().url().max(2048).refine(bye,"URL must use HTTP or HTTPS."),description:u.string().trim().min(1).max(512).optional(),status:u.enum(["open","draft","closed","merged","warning"]).optional()}).strict(),Hje=u.discriminatedUnion("kind",[xye,iz]),Sye=u.enum(["circle-dot","circle-dashed","circle-x","git-merge","git-pull-request","triangle-alert"]),qje=u.object({icon:Sye.optional(),objectType:h1.optional(),status:u.string().trim().min(1).max(100).optional(),key:u.string().trim().min(1).max(256),label:u.string().trim().min(1).max(256)}).strict(),wye=u.enum(["closed","merged","open"]),Zje=u.object({closedAt:u.date().optional(),conversationIds:u.array(u.string().min(1)).default([]),mergedAt:u.date().optional(),number:u.number().int().positive(),openedAt:u.date(),providerId:u.string().min(1),repository:u.object({name:u.string().min(1),providerId:u.string().min(1),url:u.string().url().optional()}).strict(),state:wye,title:u.string().min(1).optional(),updatedAt:u.date(),url:u.string().url().optional()}).strict(),Kje=u.string().trim().min(1).max(64).regex(/^[a-z][a-z0-9_]*$/),Cye=u.enum(["activity","brain","calendar","check","database","info","key","link","sparkles","warning"]),kye=u.object({content:u.string().min(1).max(32*1024).optional(),description:u.string().trim().min(1).max(2e3).optional(),metadata:u.array(u.string().trim().min(1).max(120)).max(8).optional(),title:u.string().trim().min(1).max(4e3)}).strict(),Wje=u.object({details:u.array(kye).max(100).optional(),icon:Cye.optional(),preview:u.string().trim().min(1).max(500).optional(),title:u.string().trim().min(1).max(120)}).strict();var g1=u.string().regex(/^T[A-Z0-9]+$/),sz=u.string().regex(/^(C|G|D)[A-Z0-9]+$/),vG=u.string().regex(/^local:[a-z0-9_-]+:[a-z0-9][a-z0-9_-]*$/),Iye=u.string().min(1).refine(e=>e===e.trim()&&e.toLowerCase()!=="unknown"),p1=Iye,je=u.string().refine(e=>e.trim().length>0),Xr=je.refine(e=>e===e.trim()),Lye=u.object({id:je,provider:Xr}).strict(),Tye=Lye.extend({provider:u.literal("slack"),teamId:g1,channelId:sz,threadTs:Xr.optional()}).strict(),Qje=u.discriminatedUnion("provider",[Tye]),Xje=u.enum(["slack","local"]),yG=u.enum(["public","private"]),Rye=u.enum(["public","private"]),_ye=u.object({platform:u.literal("slack"),teamId:g1,channelId:sz,threadTs:Xr.optional()}).strict(),lz=_ye,Nye=u.object({platform:u.literal("local"),conversationId:vG}).strict(),Aye=u.discriminatedUnion("platform",[lz,Nye]),Yje=u.object({action:u.literal("send_message"),destination:lz}).strict(),$ye=u.object({kind:u.literal("slack"),teamId:g1,channelId:sz,visibility:yG,messageTs:je.optional(),threadTs:je.optional()}).strict(),Pye=u.object({kind:u.literal("local"),visibility:u.literal("private"),conversationId:vG}).strict(),Dye=u.object({kind:u.literal("web"),visibility:yG,conversationId:Xr}).strict(),Eye=u.object({kind:u.literal("event"),eventKey:Xr,eventType:Xr,identifier:Xr,namespace:Xr}).strict(),Mye=u.object({kind:u.literal("scheduled_automation")}).strict(),Oye=u.object({kind:u.literal("event_automation")}).strict(),zye=u.object({kind:u.literal("plugin_dispatch")}).strict(),Uye=u.object({kind:u.literal("agent_invocation")}).strict(),jye=u.discriminatedUnion("kind",[$ye,Pye,Dye,Eye,Mye,Oye,zye,Uye]);function Bye(e){if(!e||typeof e!="object"||Array.isArray(e))return e;let t=e;if("kind"in t){let o={event_task:"event_automation",resource_event:"event",scheduled_task:"scheduled_automation"},i=typeof t.kind=="string"?o[t.kind]:void 0;return i?{...t,kind:i}:e}if(t.platform!=="slack"&&t.platform!=="local"&&t.platform!=="web")return e;let{location:a,platform:r,...n}=t;return{...n,kind:r}}var Fye=u.preprocess(Bye,jye),Hye=u.discriminatedUnion("allowedWhen",[u.object({type:u.literal("user"),userId:p1,allowedWhen:u.literal("private-direct-conversation")}).strict(),u.object({type:u.literal("user"),userId:p1,allowedWhen:u.literal("scheduled-automation"),taskId:Xr}).strict()]),uz={email:je.optional(),fullName:je.optional(),userId:p1,userName:je.optional()},qye=u.object({...uz,platform:u.literal("slack"),teamId:g1}).strict(),Vye=u.object({...uz,platform:u.literal("local")}).strict(),Zye=u.object({...uz,platform:u.literal("web")}).strict(),Gye=u.object({platform:u.literal("system"),name:p1}).strict(),oz=u.discriminatedUnion("platform",[qye,Vye,Zye,Gye]),Kye=u.object({displayName:je.optional(),handle:je.optional(),id:Xr,provider:Xr,providerSubjectId:Xr,providerTenantId:Xr.optional()}).strict(),eBe=u.object({displayName:je.optional(),email:je.max(320),id:Xr,identities:u.array(Kye).max(100),isAdmin:u.literal(!0).optional()}).strict(),Wye=u.record(u.string(),u.string()).superRefine((e,t)=>{let a=Object.entries(e);if(a.length>20){t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata has too many keys"});return}for(let[r,n]of a){if(!r.trim()){t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata values must be strings",path:[r]});continue}r.length>128&&t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata key exceeds the maximum length",path:[r]}),/[\r\n]/.test(r)&&t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata keys must be single-line strings",path:[r]}),/[\r\n]/.test(n)&&t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata values must be single-line strings",path:[r]}),n.length>512&&t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata value exceeds the maximum length",path:[r]})}}),Jye=u.object({label:Xr.pipe(u.string().max(48)).refine(e=>!/[\r\n]/.test(e)),detail:Xr.pipe(u.string().max(128)).refine(e=>!/[\r\n]/.test(e)).optional()}).strict(),tBe=u.object({idempotencyKey:je.pipe(u.string().max(512)),credentialSubject:Hye.optional(),destination:lz,destinationVisibility:Rye,input:je.pipe(u.string().max(32e3)),metadata:Wye.optional(),replyAttribution:Jye.optional()}).strict();var Qye=u.string().trim().min(1).max(64).regex(/^[a-z][a-z0-9_-]*$/),nBe=u.object({text:u.string().trim().min(1).max(8e3)}).strict(),rBe=u.object({kind:Qye,version:u.number().int().positive(),content:u.record(u.string(),u.unknown())}).strict();var Xye=4e3,Yye=8e3,lg=32,mG=4e3,ebe=1e3,tbe=u.record(u.string(),u.unknown()).superRefine((e,t)=>{Object.keys(e).length>lg&&t.addIssue({code:"custom",message:`Event data may include at most ${lg} keys.`}),new TextEncoder().encode(JSON.stringify(e)).byteLength>mG&&t.addIssue({code:"custom",message:`Event data may be at most ${mG} JSON bytes.`})}),hm=u.string().regex(/^[a-z][a-z0-9_-]*(?:\.[a-z][a-z0-9_-]*)+$/).describe("Canonical dotted event type, such as issue.closed or pull_request.review.changes_requested."),bG=u.string().regex(/^[a-z][a-z0-9_]*$/).describe("Canonical plugin-defined resource type, such as issue or pull_request."),xG=/^[a-z][a-zA-Z0-9]*$/,abe=u.object({kind:u.enum(["boolean","string","number"]),description:u.string().trim().min(1).max(200),enum:u.array(u.string().min(1)).min(1).optional()}).strict().superRefine((e,t)=>{e.enum&&e.kind!=="string"&&t.addIssue({code:"custom",message:'Event match field enum requires kind "string".',path:["enum"]})}),nbe=u.record(u.string().regex(xG),abe).superRefine((e,t)=>{Object.keys(e).length>lg&&t.addIssue({code:"custom",message:`Event match keys may include at most ${lg} keys.`})}),iBe=u.record(u.string().regex(xG),u.union([u.boolean(),u.number().finite(),u.string().min(1),u.array(u.union([u.number().finite(),u.string().min(1)])).min(1)])).superRefine((e,t)=>{Object.keys(e).length>lg&&t.addIssue({code:"custom",message:`Event match may include at most ${lg} keys.`});for(let[a,r]of Object.entries(e))Array.isArray(r)&&r.some(n=>typeof n=="boolean")&&t.addIssue({code:"custom",message:`Event match field "${a}" cannot use a boolean list.`,path:[a]})});var rbe=u.object({format:u.string().trim().min(1).max(200),pattern:u.instanceof(RegExp)}).strict(),obe=u.object({type:bG,identifier:rbe.optional(),supportedEvents:u.array(hm).min(1),suggestedEvents:u.array(hm).optional(),matchFields:nbe.optional(),guidance:u.record(hm,u.string().trim().min(1).max(ebe)).optional()}).strict().superRefine((e,t)=>{let a=new Set;e.supportedEvents.forEach((n,o)=>{a.has(n)&&t.addIssue({code:"custom",message:`Duplicate supported event type "${n}".`,path:["supportedEvents",o]}),a.add(n)});for(let n of Object.keys(e.guidance??{}))a.has(n)||t.addIssue({code:"custom",message:`Guidance event type "${n}" is not supported.`,path:["guidance",n]});let r=new Set;e.suggestedEvents?.forEach((n,o)=>{r.has(n)&&t.addIssue({code:"custom",message:`Duplicate suggested event type "${n}".`,path:["suggestedEvents",o]}),a.has(n)||t.addIssue({code:"custom",message:`Suggested event type "${n}" is not supported.`,path:["suggestedEvents",o]}),r.add(n)})}),sBe=u.object({resourceTypes:u.array(obe).min(1),isEnabled:u.function({input:[],output:u.boolean()}).optional(),normalizeIdentifier:u.function({input:[u.string()],output:u.string()}).optional()}).strict().superRefine((e,t)=>{let a=new Set;e.resourceTypes.forEach((r,n)=>{a.has(r.type)&&t.addIssue({code:"custom",message:`Duplicate resource type "${r.type}".`,path:["resourceTypes",n,"type"]}),a.add(r.type)})});var lBe=u.object({identifier:u.string().min(1),label:u.string().min(1),namespace:u.string().min(1),suggestedEvents:u.array(hm).optional(),supportedEvents:u.array(hm),type:bG}).strict(),uBe=u.object({events:u.array(hm).min(1),id:u.string().min(1)}).strict(),ibe=u.object({objectType:h1.optional(),eventKey:u.string().min(1),eventType:hm,identifier:u.string().min(1),occurredAtMs:u.number().finite(),terminal:u.boolean().optional(),trustedSummary:u.string().min(1).transform(e=>e.slice(0,Xye)),data:tbe.optional(),untrustedText:u.string().transform(e=>e.slice(0,Yye)).optional()}).strict(),cBe=ibe.extend({namespace:u.string().min(1)}),sbe=u.object({authority:u.enum(["instruction","context"]),actor:oz.optional()}).strict(),lbe=u.discriminatedUnion("type",[u.object({type:u.literal("message"),role:u.enum(["user","assistant"]),text:u.string().min(1),provenance:sbe.optional(),isRunActor:u.boolean().optional()}).strict(),u.object({type:u.literal("toolResult"),toolName:u.string().min(1),isError:u.boolean(),text:u.string().min(1).optional()}).strict()]),fBe=u.object({actorUserId:u.string().min(1).optional(),completedAtMs:u.number().finite(),conversationId:u.string().min(1),destination:Aye,locationId:u.string().min(1).optional(),actors:u.array(oz),actor:oz.optional(),runId:u.string().min(1),source:Fye,transcript:u.array(lbe)}).strict();var pBe=u.discriminatedUnion("type",[u.object({type:u.literal("text"),text:u.string()}).strict(),u.object({type:u.literal("image"),data:u.string(),mimeType:u.string()}).strict()]),ube=u.object({arguments:u.record(u.string(),u.unknown()),reason:u.string().min(1).optional()}).strict(),hBe=u.object({objectAnnotations:u.array(iz).optional(),target:u.string().min(1).optional(),truncated:u.boolean().optional(),continuation:ube.optional()}).passthrough(),gBe=u.enum(["auto","review","approve"]);var yBe=u.object({auth:u.object({user:u.object({email:u.string().nullable().optional(),emailVerified:u.boolean().optional(),isAdmin:u.boolean(),name:u.string().nullable().optional()}).strict()}).strict(),pluginName:je}).strict(),cbe=u.string().regex(/^[a-z][a-z0-9-]*$/),dbe=u.string().regex(/^[a-z][a-z0-9.-]*$/),fbe=u.union([u.literal("read"),u.literal("write")]),SG=u.object({provider:cbe,scope:je.optional(),type:u.literal("oauth")}).strict(),wG=u.object({displayName:je.optional(),handle:je.optional(),id:je,label:je.optional(),url:je.optional()}).strict(),xBe=u.object({account:wG.optional(),accessToken:je,expiresAt:u.number().finite().optional(),refreshToken:je,refreshTokenExpiresAt:u.number().finite().optional(),scope:je.optional()}).strict(),SBe=u.object({access:fbe,leaseScope:je.optional(),name:dbe,reason:je.optional(),requirements:u.array(je).min(1).optional()}).strict(),mbe=u.object({domain:u.string().min(1),headers:u.record(u.string(),u.string()).refine(e=>Object.keys(e).length>0)}).strict(),pbe=u.object({account:wG.optional(),authorization:SG.optional(),expiresAt:u.string().refine(e=>Number.isFinite(Date.parse(e))),headerTransforms:u.array(mbe).min(1)}).strict(),wBe=u.discriminatedUnion("type",[u.object({lease:pbe,type:u.literal("lease")}).strict(),u.object({authorization:SG.optional(),message:je,type:u.literal("needed")}).strict(),u.object({message:je,type:u.literal("unavailable")}).strict()]);var hbe=je.max(64).regex(/^[a-z][a-z0-9-]*$/),gbe=je.max(80),vbe=je.max(500),ybe=u.enum(["primary","profile","admin"]),bbe=u.object({detail:je.max(500).optional(),label:je.max(80),tone:u.enum(["good","neutral","warning"]).optional(),value:je.max(120)}).strict(),xbe=u.object({label:je.max(80),value:je.max(500)}).strict(),Sbe=u.object({confirmation:je.max(500).optional(),href:je.max(500).regex(/^\/api\/plugins\/[a-z][a-z0-9-]*(?:\/|$)/),label:je.max(80),method:u.enum(["DELETE","GET"]),tone:u.enum(["danger","neutral"]).optional()}).strict(),wbe=u.object({actions:u.array(Sbe).max(4).optional(),description:je.max(1e3).optional(),id:je.max(128),metadata:u.array(xbe).max(8).optional(),title:je.max(4e3)}).strict(),CG=u.object({emptyText:je.max(500).optional(),metrics:u.array(bbe).max(6).optional(),nextCursor:je.max(1e3).optional(),records:u.array(wbe).max(100),searchPlaceholder:je.max(120).optional(),type:u.literal("list")}).strict(),Cbe=u.object({description:vbe,id:hbe,label:gbe,navigation:ybe,pluginDisplayName:je.max(200),pluginName:je.max(100)}).strict(),kG=u.array(Cbe),kbe=je.max(1e3).optional(),Ibe=je.max(64).optional(),Lbe=u.string().trim().max(200).optional(),kBe=u.object({cursor:kbe,filter:Ibe,limit:u.number().int().min(1).max(50),query:Lbe}).strict();var IG=u.object({email:u.string().trim().email(),emailVerified:u.boolean().optional(),name:u.string().nullable().optional()}).strict(),TBe=u.object({user:IG}).strict(),v1=u.object({user:IG.extend({isAdmin:u.boolean()}).strict()}).strict(),RBe=u.object({displayName:u.string().trim().min(1).max(80)}).strict(),LG=u.object({allowedEmailCount:u.number(),allowedGoogleDomainCount:u.number(),authRequired:u.boolean(),authPath:u.string(),basePath:u.string(),componentGallery:u.boolean(),sentryConversationLinks:u.boolean(),timeZone:u.string().optional(),version:u.string().min(1)}).strict();var yx=b(G(),1);var TG="x-junior-version";var cz="junior:dashboard-version";function RG(e){let t=e.headers.get(TG)?.trim();!t||typeof window>"u"||window.dispatchEvent(new CustomEvent(cz,{detail:t}))}function _G(e){let[t,a]=(0,yx.useState)(e);return(0,yx.useEffect)(()=>{e&&a(e)},[e]),(0,yx.useEffect)(()=>{let r=n=>{a(n.detail)};return window.addEventListener(cz,r),()=>window.removeEventListener(cz,r)},[]),t}var yn=class extends Error{status;fields;code;apiError;constructor(t,a,r,n){super(`${t} returned ${a}`),this.status=a,this.fields=n?.fields,this.code=n?.code,r?.trim()&&(this.apiError=r.trim())}};async function ug(e,t){let a,r,n;try{let o=await t.json();typeof o.error=="string"&&(a=o.error),typeof o.code=="string"&&(n=o.code),o.fields&&typeof o.fields=="object"&&(r=Object.fromEntries(Object.entries(o.fields).filter(i=>Array.isArray(i[1])&&i[1].every(s=>typeof s=="string"))))}catch{}throw new yn(e,t.status,a,{fields:r,code:n})}function cg(){if(typeof window>"u")return;let e=window.__JUNIOR_DASHBOARD_BASE_PATH__??"/",t=e==="/"?"/auth/login":`${e}/auth/login`;if(window.location.pathname!==t){let a=`${window.location.pathname}${window.location.search||""}`,r=new URLSearchParams;a!=="/"&&r.set("next",a);let n=r.toString();window.location.assign(n?`${t}?${n}`:t)}}async function dg(e,t,a){let r=await fg(t,{body:JSON.stringify(a),credentials:"same-origin",headers:{"content-type":"application/json"},method:"PATCH"});return r.status===401&&cg(),r.ok||await ug(t,r),e.parse(await r.json())}async function xo(e,t,a){let r=await fg(t,{body:JSON.stringify(a),credentials:"same-origin",headers:{"content-type":"application/json"},method:"POST"});return r.status===401&&cg(),r.ok||await ug(t,r),e.parse(await r.json())}async function NG(e,t,a){let r=await fg(t,{body:JSON.stringify(a),credentials:"same-origin",headers:{"content-type":"application/json"},method:"PUT"});return r.status===401&&cg(),r.ok||await ug(t,r),e.parse(await r.json())}async function Rd(e){let t=await fg(e,{credentials:"same-origin",method:"DELETE"});t.status===401&&cg(),t.ok||await ug(e,t)}async function AG(e,t,a={}){let r=await fg(t,{body:JSON.stringify(a),credentials:"same-origin",headers:{"content-type":"application/json"},method:"DELETE"});return r.status===401&&cg(),r.ok||await ug(t,r),e.parse(await r.json())}async function fg(e,t){let a=await fetch(e,t);return RG(a),a}async function Pe(e,t,a){let r=await dz(t,a);return e.parse(await r.json())}async function dz(e,t,a){let r=await fg(e,{credentials:"same-origin",...t?{signal:t}:void 0,...a?{cache:"no-store",headers:{"if-none-match":a}}:void 0});return r.status===401&&cg(),!r.ok&&!(a&&r.status===304)&&await ug(e,r),r}var y1=5*6e4,fz=5*6e4,Tbe=1e3;function Rbe(e,t=Date.now()){if(!e)return fz;let a=Date.parse(e);if(!Number.isFinite(a))return fz;let r=Math.max(0,t-a);return Math.max(Tbe,fz-r)}function $G(){return Be({queryKey:["dashboard","core"],queryFn:async({signal:e})=>{let[t,a]=await Promise.all([Pe(v1,"/api/me",e),Pe(LG,"/api/config",e)]);return{config:a,me:t}},retry:!1,staleTime:y1})}function _be(){return Be({queryKey:["dashboard","plugins"],queryFn:({signal:e})=>Pe(VE,"/api/plugins",e),retry:!1,staleTime:y1})}function PG(){return Be({queryKey:["dashboard","plugin-user-pages"],queryFn:({signal:e})=>Pe(kG,"/api/user-pages",e),retry:!1,staleTime:y1})}function b1(e=""){return Be({queryKey:["dashboard","conversations","viewer",{search:e}],queryFn:({signal:t})=>Pe(Xk,`/api/conversations${e?`?q=${encodeURIComponent(e)}`:""}`,t),placeholderData:vv,retry:!1})}function DG(){return Be({queryKey:["dashboard","code"],queryFn:({signal:e})=>Pe(ZO,"/api/code",e),retry:!1})}function EG(e){return Be({enabled:!!e,queryKey:["dashboard","code","repositories",e],queryFn:({signal:t})=>Pe(GO,`/api/code/repositories/${encodeURIComponent(e)}`,t),retry:!1})}function x1(e,t=""){return Be({enabled:!!e,queryKey:["dashboard","conversations","code-repository",{repositoryId:e,search:t}],queryFn:({signal:a})=>{let r=new URLSearchParams({codeRepositoryId:e});return t&&r.set("q",t),Pe(Xk,`/api/conversations?${r.toString()}`,a)},placeholderData:vv,retry:!1})}function MG(e,t){return Be({enabled:e,queryKey:["dashboard","automations",t],queryFn:({signal:a})=>Pe(ME,`/api/automations${t?`?${t}`:""}`,a),placeholderData:vv,retry:!1})}function mg(e,t){return Be({enabled:e&&!!t,queryKey:["dashboard","automations","detail",t],queryFn:({signal:a})=>Pe(fx,`/api/automations/${encodeURIComponent(t)}`,a),retry:!1})}function OG(e){return Be({enabled:e,queryKey:["dashboard","automations","runs"],queryFn:({signal:t})=>Pe(UE,"/api/automations/runs",t),retry:!1})}function zG(e,t,a){return Be({enabled:e&&!!(t&&a),queryKey:["dashboard","automations",t,a,"executions"],queryFn:({signal:r})=>Pe(zE,`/api/automations/${t}/${encodeURIComponent(a)}/executions`,r),retry:!1})}function UG(e,t,a){return Be({enabled:e&&!!(t&&a),queryKey:["dashboard","automations",t,a,"versions"],queryFn:({signal:r})=>Pe(jE,`/api/automations/${t}/${encodeURIComponent(a)}/versions`,r),retry:!1})}function jG(){return Be({queryKey:["dashboard","people"],queryFn:({signal:e})=>Pe(QO,"/api/people",e),retry:!1})}function BG(e){return Be({enabled:!!e,queryKey:["dashboard","people",e],queryFn:async({signal:t})=>Pe(XO,`/api/people/${encodeURIComponent(e)}`,t),retry:!1})}function FG(e){return Be({enabled:!!e,queryKey:["dashboard","people",e,"plugin-reports"],queryFn:({signal:t})=>Pe(a1,`/api/people/${encodeURIComponent(e)}/plugin-reports`,t),retry:!1})}function HG(e){return Be({enabled:!!e,queryKey:["dashboard","people",e,"code"],queryFn:({signal:t})=>Pe(KO,`/api/people/${encodeURIComponent(e)}/code`,t),retry:!1})}function qG(e){return Be({enabled:e,queryKey:["dashboard","personal-spend"],queryFn:({signal:t})=>Pe(YO,"/api/people/me/spend",t),refetchInterval:t=>Rbe(t.state.data?.generatedAt),retry:!1,staleTime:0})}function VG(){return Be({queryKey:["dashboard","locations"],queryFn:({signal:e})=>Pe(WO,"/api/locations",e),retry:!1})}function ZG(e){return Be({enabled:!!e,queryKey:["dashboard","locations",e],queryFn:async({signal:t})=>Pe(JO,`/api/locations/${encodeURIComponent(e)}`,t),retry:!1})}function Nbe(){return Be({queryKey:["dashboard","skills"],queryFn:({signal:e})=>Pe(GE,"/api/skills",e),retry:!1,staleTime:y1})}function Abe(){return Be({queryKey:["dashboard","plugin-reports"],queryFn:({signal:e})=>Pe(a1,"/api/plugin-reports",e),retry:!1})}function GG(){return Be({queryKey:["dashboard","stats"],queryFn:({signal:e})=>Pe(rz,"/api/stats",e),retry:!1})}function KG(e){let t=_be(),a=Be({queryKey:["dashboard","conversation-stats"],queryFn:({signal:i})=>Pe(PE,"/api/conversations/stats",i),retry:!1}),r=Nbe(),n=Abe();return{data:t.data&&r.data?{...e,conversationStatsError:!!a.error,...a.data?{conversationStats:a.data}:void 0,conversationStatsLoading:a.isPending,pluginReportsError:!!n.error,...n.data?{pluginReports:n.data}:void 0,pluginReportsLoading:n.isPending,plugins:t.data,skills:r.data}:void 0,error:t.error??r.error,isPending:t.isPending||r.isPending}}function I(...e){return e.filter(Boolean).join(" ")}var Ya="mx-auto w-full min-w-0 max-w-screen-xl",gm="text-dashboard-text-muted hover:text-dashboard-text",WG="rounded-xl border border-dashboard-border-interactive bg-dashboard-surface-active",JG="dashboard-shell-bg";var S1=b(w(),1),QG="inline-flex h-9 max-w-full items-center gap-2 rounded border border-dashboard-border-emphasis bg-dashboard-surface-raised px-3 font-mono text-sm font-semibold leading-none text-dashboard-text transition-colors hover:border-dashboard-border-heavy hover:bg-dashboard-surface-hover hover:text-dashboard-text",$be="inline-flex h-9 max-w-full items-center justify-center gap-1.5 rounded border border-dashboard-border-strong bg-transparent px-3 font-mono text-xs font-semibold text-dashboard-text-muted transition-colors hover:border-rose-300/40 hover:text-rose-300";function ie({className:e,size:t="default",tone:a="default",type:r="button",...n}){let o=a==="danger";return(0,S1.jsx)("button",{...n,className:I("font-mono transition-colors disabled:cursor-not-allowed disabled:opacity-50",t==="icon"?I("grid size-9 place-items-center rounded-md border-0 bg-transparent p-0 focus-visible:outline focus-visible:outline-1 disabled:hover:!bg-transparent",o?"text-dashboard-text-muted hover:!bg-rose-300/10 hover:!text-rose-300 focus-visible:outline-rose-300/55 disabled:hover:!text-dashboard-text-muted":"text-dashboard-text-muted hover:!bg-dashboard-fill-strong hover:!text-dashboard-text focus-visible:outline-cyan-300/55 disabled:hover:!text-dashboard-text-muted"):a==="primary"?"inline-flex h-9 items-center justify-center gap-2 rounded border border-dashboard-text-solid bg-dashboard-text-solid px-3 font-sans text-sm font-semibold text-dashboard-text-inverse hover:bg-dashboard-text-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-dashboard-focus":o?I($be,"disabled:hover:border-dashboard-border-strong disabled:hover:text-dashboard-text-muted"):I(QG,"disabled:hover:border-dashboard-border-emphasis disabled:hover:bg-dashboard-surface-raised disabled:hover:text-dashboard-text"),n.disabled?"":"cursor-pointer",e),type:r})}function _d({className:e,...t}){return(0,S1.jsx)(ae,{...t,className:I(QG,"no-underline",e)})}function Ln({className:e,pressed:t,type:a="button",variant:r,...n}){return(0,S1.jsx)("button",{...n,"aria-pressed":t,className:I(Pbe[r],t?Dbe[r]:Ebe[r],e),type:a})}var Pbe={pill:"cursor-pointer rounded border px-2 py-1 font-mono text-xs font-semibold uppercase leading-tight transition-colors focus-visible:outline focus-visible:outline-1 focus-visible:outline-cyan-300/55",segment:"h-7 min-w-10 cursor-pointer rounded border px-2 font-mono text-xs transition-colors focus-visible:outline focus-visible:outline-1 focus-visible:outline-cyan-300/55",text:"cursor-pointer border-0 bg-transparent px-1.5 py-1 font-mono uppercase tracking-normal underline-offset-4 transition-colors focus-visible:outline focus-visible:outline-1 focus-visible:outline-cyan-300/55"},Dbe={pill:"border-dashboard-border-heavy bg-dashboard-text-solid text-dashboard-text-inverse",segment:"border-amber-500/30 bg-amber-500/20 text-amber-400",text:"text-dashboard-text underline decoration-dashboard-text-solid"},Ebe={pill:"border-dashboard-border-strong bg-dashboard-surface-raised text-dashboard-text-muted hover:border-dashboard-border-interactive hover:bg-dashboard-surface-hover hover:text-dashboard-text",segment:"border-dashboard-border-strong bg-dashboard-fill-faint text-dashboard-text-muted hover:bg-dashboard-fill-strong hover:text-dashboard-text",text:"text-dashboard-text-muted hover:text-dashboard-text"};var vm=b(w(),1);function Yr(e){let t=e.tone==="error";return(0,vm.jsxs)("div",{role:t?"alert":"status",className:I("flex min-w-0 gap-3 rounded-md border p-4",t?"border-rose-300/25 bg-rose-300/5":"border-amber-300/25 bg-amber-300/5"),children:[(0,vm.jsx)(Kr,{"aria-hidden":!0,size:18,className:I("mt-0.5 shrink-0",t?"text-rose-300":"text-amber-300")}),(0,vm.jsxs)("div",{className:"min-w-0",children:[(0,vm.jsx)("p",{className:"m-0 text-sm font-medium",children:e.title}),e.children?(0,vm.jsx)("div",{className:"mt-1 text-sm leading-relaxed text-dashboard-text-muted",children:e.children}):null]})]})}var bx=b(w(),1),Mbe={accent:"text-violet-300",danger:"text-rose-300",info:"text-cyan-300",neutral:"text-dashboard-text-muted",success:"text-emerald-300",warning:"text-amber-300"},Obe={compact:"text-xs",default:"text-sm"};function ba(e){return(0,bx.jsxs)("span",{className:I("inline-flex w-fit items-center gap-1.5 font-sans font-medium normal-case leading-snug tracking-normal",Obe[e.size??"default"],Mbe[e.tone??"neutral"],e.className),children:[(0,bx.jsx)("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full bg-current"}),(0,bx.jsx)("span",{className:"block first-letter:uppercase",children:e.children})]})}var XG=b(w(),1);function U(e){let t=e.as??"div",a={none:"",sm:"p-4",md:"p-5 sm:p-6"}[e.padding??"none"],r=e.variant==="section"?"mb-4 border-dashboard-border-subtle bg-dashboard-fill-faint shadow-[0_24px_80px_rgba(0,0,0,0.18)]":e.variant==="raised"?"border-dashboard-border-emphasis bg-dashboard-surface-raised":"border-dashboard-border-subtle bg-dashboard-fill-faint";return(0,XG.jsx)(t,{className:I("min-w-0 overflow-hidden rounded-lg border",r,a,e.className),children:e.children})}var YG=b(w(),1);function Qe(e){let t=e.as??"div";return(0,YG.jsx)(t,{"aria-hidden":"true",className:I("animate-pulse rounded bg-dashboard-fill-soft motion-reduce:animate-none",e.className)})}var ot=b(w(),1);function Yn(e){let t=e.variant??"panel";return(0,ot.jsxs)("div",{"aria-busy":"true","aria-live":"polite",className:I("grid gap-4",e.className),role:"status",children:[(0,ot.jsx)("span",{className:"sr-only",children:e.label}),zbe(t)]})}function zbe(e){switch(e){case"stats":return(0,ot.jsx)(Ube,{});case"overview":return(0,ot.jsx)(jbe,{});case"list":return(0,ot.jsx)(Bbe,{});case"library":return(0,ot.jsx)(Fbe,{});case"panel":return(0,ot.jsx)(Vl,{className:"min-h-64"})}}function Ube(){return(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsx)("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:Array.from({length:4},(e,t)=>(0,ot.jsx)(Vl,{className:"min-h-[7.5rem] p-4 sm:min-h-32 sm:p-5"},t))}),(0,ot.jsx)(Vl,{className:"min-h-[17rem]"})]})}function jbe(){return(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsxs)("div",{className:"grid gap-4 xl:grid-cols-2",children:[(0,ot.jsx)(Vl,{className:"min-h-[17rem]"}),(0,ot.jsx)(Vl,{className:"min-h-[17rem]"})]}),(0,ot.jsx)(pg,{className:"h-24 border-y border-dashboard-border-subtle bg-dashboard-fill-faint"}),(0,ot.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,ot.jsx)(Vl,{className:"min-h-56"}),(0,ot.jsx)(Vl,{className:"min-h-56"})]})]})}function Bbe(){return(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsx)(Vl,{className:"min-h-20 p-4"}),(0,ot.jsx)(pg,{className:"h-10 border-b border-dashboard-border-subtle"}),(0,ot.jsx)(Vl,{className:"min-h-80"})]})}function Fbe(){return(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsxs)("div",{className:"flex flex-wrap items-end justify-between gap-4",children:[(0,ot.jsx)(pg,{className:"h-7 w-56 rounded bg-dashboard-fill-soft"}),(0,ot.jsx)(pg,{className:"h-10 w-full max-w-md rounded-lg border border-dashboard-border-subtle bg-dashboard-fill-faint sm:w-72"})]}),(0,ot.jsx)("div",{"aria-hidden":"true",className:"grid min-w-0 grid-cols-3 gap-1 border-b border-dashboard-border-subtle sm:flex",children:Array.from({length:3},(e,t)=>(0,ot.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2.5 sm:justify-start",children:[(0,ot.jsx)(pg,{className:"h-3 w-12 rounded bg-dashboard-fill-soft"}),(0,ot.jsx)(pg,{className:"h-5 w-8 rounded-sm border border-dashboard-border-subtle bg-dashboard-fill-faint"})]},t))}),(0,ot.jsx)(Vl,{className:"min-h-80"})]})}function Vl(e){return(0,ot.jsx)(U,{className:I("animate-pulse motion-reduce:animate-none",e.className),children:(0,ot.jsx)("span",{"aria-hidden":"true"})})}function pg(e){return(0,ot.jsx)(Qe,{className:e.className})}var mz=b(w(),1),Hbe=[1,7,30,90];function pz(e){return e===1?"24h":`${e}d`}function hg(e){return e===1?"last 24 hours":`last ${e} days`}function Ha(e){return e===1?"hour":e===7?"6hour":"day"}function eK(e){return e===1}function qbe(e){return e===7}function eo(e){return e==="hour"?"hour":e==="6hour"?"6h":"day"}function gg(e){return e==="hour"?"hour":e==="6hour"?"6 hours":"day"}function xx(e){return e==="hour"?"Hourly":e==="6hour"?"6-hour":"Daily"}function en(e){return eK(e.range)&&e.hours?.length?e.hours.slice(-24):eK(e.range)?e.days.slice(-1):qbe(e.range)?e.sixHours?.length?[...e.sixHours]:e.hours?.length&&e.emptySixHour?Vbe({empty:e.emptySixHour,hours:e.hours}):e.days.slice(-e.range):e.days.slice(-e.range)}function Vbe(e){let t=new Map;for(let a of e.hours){let r=Date.parse(`${a.date}:00:00.000Z`);if(Number.isNaN(r))continue;let n=new Date(r);n.setUTCMinutes(0,0,0),n.setUTCHours(Math.floor(n.getUTCHours()/6)*6,0,0,0);let o=n.toISOString().slice(0,13),s={...t.get(o)??e.empty(o),date:o};for(let[l,c]of Object.entries(a))if(l!=="date"&&typeof c=="number"){let d=s[l];s[l]=(typeof d=="number"?d:0)+c}t.set(o,s)}if(e.hours.length>=24){let a=e.hours[e.hours.length-1]?.date,r=a?Date.parse(`${a}:00:00.000Z`):Date.now(),n=new Date(r);n.setUTCMinutes(0,0,0),n.setUTCHours(Math.floor(n.getUTCHours()/6)*6,0,0,0);let o=new Date(n.getTime()-9720*60*1e3),i=[];for(let s=new Date(o);s.getTime()<=n.getTime();s.setTime(s.getTime()+360*60*1e3)){let l=s.toISOString().slice(0,13);i.push(t.get(l)??e.empty(l))}return i}return[...t.values()].sort((a,r)=>a.date.localeCompare(r.date))}function vg(e){return(0,mz.jsx)("div",{"aria-label":"Reporting period",className:"flex items-center gap-1",role:"group",children:(e.options??Hbe).map(t=>(0,mz.jsx)(Ln,{onClick:()=>e.onChange(t),pressed:e.value===t,variant:"segment",children:pz(t)},t))})}var Nd=b(w(),1);function We(e){let t=e.range!==void 0&&e.onRangeChange?(0,Nd.jsx)(vg,{onChange:e.onRangeChange,...e.rangeOptions?{options:e.rangeOptions}:{},value:e.range}):void 0,a=e.actions??t;return(0,Nd.jsxs)("header",{className:"flex min-w-0 items-center justify-between gap-6 border-b border-white/[0.05] pb-4 sm:pb-6 max-md:flex-col max-md:items-stretch",children:[(0,Nd.jsxs)("div",{className:"min-w-0",children:[(0,Nd.jsx)("h2",{className:"m-0 font-display text-3xl font-light leading-none tracking-[-0.03em] text-dashboard-text sm:text-4xl",children:e.title}),(0,Nd.jsx)("div",{className:"mt-2 max-w-2xl font-mono text-xs leading-relaxed text-dashboard-text-muted sm:text-sm",children:e.description})]}),a?(0,Nd.jsx)("div",{className:"shrink-0",children:a}):null]})}var tK=b(w(),1);function So(e){return(0,tK.jsx)("div",{className:I(Ya,"grid min-w-0 content-start gap-4 px-4 py-4 pb-[max(1rem,env(safe-area-inset-bottom))] sm:gap-6 sm:px-8 sm:py-8 sm:pb-8",e.className),children:e.children})}var bm=b(G(),1);var ym=b(G(),1);function Ni(e,t){let a=typeof t=="string"?t.startsWith("?")?t.slice(1):t:t?.toString()??"",r=e.indexOf("?"),n=r===-1?e:e.slice(0,r),o=r===-1?"":e.slice(r+1).replace(/^\?+/,""),i=new URLSearchParams(a);for(let[l,c]of new URLSearchParams(o))i.set(l,c);let s=i.toString();return s?`${n}?${s}`:n}function Zbe(e,t){let a=e?.trim();return a&&t.includes(a)?a:void 0}function Zl(e="q",t={}){let a=t.delayMs??250,r=t.resetPage??!1,[n,o]=Ho(),i=n.get(e)?.trim()??"",[s,l]=(0,ym.useState)(i);return(0,ym.useEffect)(()=>{l(c=>c.trim()===i?c:i)},[i]),(0,ym.useEffect)(()=>{let c=window.setTimeout(()=>{let d=s.trim();d!==i&&o(f=>{let m=new URLSearchParams(f);return r&&m.delete("page"),d?m.set(e,d):m.delete(e),m},{replace:!0})},a);return()=>window.clearTimeout(c)},[i,a,e,r,o,s]),[s,l,i]}function ec(e,t,a){let[r,n]=Ho(),o=Zbe(r.get(e),a)??t,i=(0,ym.useCallback)(s=>{n(l=>{let c=new URLSearchParams(l);return s===t?c.delete(e):c.set(e,s),c},{replace:!0})},[t,e,n]);return[o,i]}var aK=b(G(),1);var yg=b(w(),1),hz="rounded-lg border border-dashboard-border bg-dashboard-surface-panel",gz="gap-1 p-1";function vz(e){return I("min-h-9 cursor-pointer rounded-md border-0 px-3 py-2 font-sans text-sm font-medium transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus",e?"bg-dashboard-fill-strong text-dashboard-text":"bg-transparent text-dashboard-text-muted hover:bg-dashboard-fill-faint hover:text-dashboard-text")}function w1(e){let t=(0,aK.useId)();return(0,yg.jsxs)("div",{className:"grid min-w-0 gap-4",children:[(0,yg.jsx)("div",{"aria-label":e.label,className:I("grid auto-cols-fr grid-flow-col",hz,gz),role:"tablist",children:e.items.map((a,r)=>(0,yg.jsx)("button",{"aria-controls":`${t}-panel`,"aria-selected":e.value===a.value,className:I("min-w-0",vz(e.value===a.value)),id:`${t}-${a.value}`,onClick:()=>e.onChange(a.value),onKeyDown:n=>{let o,i=e.items.length;switch(n.key){case"ArrowLeft":o=(r+i-1)%i;break;case"ArrowRight":o=(r+1)%i;break;case"Home":o=0;break;case"End":o=i-1;break;default:return}n.preventDefault(),e.onChange(e.items[o].value),n.currentTarget.parentElement?.querySelectorAll('[role="tab"]')[o]?.focus()},role:"tab",tabIndex:e.value===a.value?0:-1,type:"button",children:a.label},a.value))}),(0,yg.jsx)("div",{"aria-labelledby":`${t}-${e.value}`,className:"min-w-0 rounded focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus",id:`${t}-panel`,role:"tabpanel",tabIndex:0,children:e.children})]})}var bg=b(w(),1);function bz(e){let{className:t,item:a}=e,r=vt(),n=Ni(a.to,r.search);if(a.isActive){let o=a.isActive(r.pathname);return(0,bg.jsx)(ae,{"aria-current":o?"page":void 0,className:t({isActive:o}),to:n,children:a.label})}return(0,bg.jsx)(Uf,{className:t,end:a.end,to:n,children:a.label})}var yz=24;function rK(e){let t=e.scrollWidth-e.clientWidth;return{end:e.scrollLeft<t-1,start:e.scrollLeft>1}}function nK(e){let t=e.querySelector('[aria-current="page"]');if(!t||e.clientWidth===0)return;let a=rK(e),r=e.scrollLeft+(a.start?yz:0),n=e.scrollLeft+e.clientWidth-(a.end?yz:0),o=t.offsetLeft,i=o+t.offsetWidth;o>=r&&i<=n||(e.scrollLeft=o-(e.clientWidth-t.offsetWidth)/2)}function Gbe(e){if(!e.start&&!e.end)return;let t=`${yz}px`,a=e.start?`transparent, black ${t}`:"black",r=e.end?`black calc(100% - ${t}), transparent`:"black",n=`linear-gradient(to right, ${a}, ${r})`;return{maskImage:n,WebkitMaskImage:n}}function xm(e){let{pathname:t}=vt(),a=(0,bm.useRef)(null),[r,n]=(0,bm.useState)({end:!1,start:!1});(0,bm.useLayoutEffect)(()=>{let i=a.current;if(!i)return;let s=()=>{let{end:c,start:d}=rK(i);n(f=>f.start===d&&f.end===c?f:{end:c,start:d})},l=new ResizeObserver(()=>{nK(i),s()});return s(),i.addEventListener("scroll",s,{passive:!0}),l.observe(i),()=>{i.removeEventListener("scroll",s),l.disconnect()}},[]),(0,bm.useLayoutEffect)(()=>{a.current&&nK(a.current)},[t]);let o=({isActive:i})=>I(vz(i),"flex items-center justify-center whitespace-nowrap no-underline",e.fill?"min-w-max flex-[1_0_0]":"shrink-0");return(0,bg.jsx)("nav",{"aria-label":e.ariaLabel,className:I(hz,"flex min-w-0 max-w-full",!e.fill&&"w-fit"),children:(0,bg.jsx)("div",{className:I(gz,"relative flex min-w-0 flex-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"),ref:a,style:Gbe(r),children:e.items.map(i=>(0,bg.jsx)(bz,{className:o,item:i},i.to))})})}var Gt=b(G(),1),Sx=b(Tl(),1),Qs=b(w(),1),Gl=(0,Gt.createContext)(null);function C1(e){let[t,a]=(0,Gt.useState)(null),[r,n]=(0,Gt.useState)(null),[o,i]=(0,Gt.useState)(null),[s,l]=(0,Gt.useState)(null),c=(0,Gt.useRef)(null),d=(0,Gt.useCallback)(y=>{a(y)},[]),f=(0,Gt.useCallback)(y=>{n(y)},[]),m=(0,Gt.useCallback)(y=>{i(y)},[]),p=(0,Gt.useCallback)(y=>{l(y)},[]),h=(0,Gt.useCallback)(y=>{c.current=y},[]),g=(0,Gt.useCallback)(()=>{c.current?.()},[]),x=(0,Gt.useMemo)(()=>({mobileHeaderActionsSlot:o,mobileHeaderActionsSlotRef:m,mobileHeaderLiveSlot:s,mobileHeaderLiveSlotRef:p,mobileSecondarySlot:r,mobileSecondarySlotRef:f,openMobileNavigation:g,registerOpenMobileNavigation:h,secondarySlot:t,secondarySlotRef:d}),[o,m,s,p,r,f,g,h,t,d]);return(0,Qs.jsx)(Gl.Provider,{value:x,children:e.children})}function oK(e){let t=(0,Gt.useContext)(Gl);if(!t)throw new Error("DashboardChrome requires DashboardChromeProvider");return(0,Qs.jsxs)("div",{className:"sticky top-0 z-30 bg-dashboard-bg/95 pt-[env(safe-area-inset-top)]",children:[e.header,(0,Qs.jsx)("div",{className:"hidden md:block",ref:t.secondarySlotRef}),e.banner]})}function iK(){let e=(0,Gt.useContext)(Gl);if(!e)throw new Error("MobileSecondaryNavigationSlot requires DashboardChromeProvider");return(0,Qs.jsx)("div",{ref:e.mobileSecondarySlotRef})}function sK(){let e=(0,Gt.useContext)(Gl);if(!e)throw new Error("MobileHeaderActionsSlot requires DashboardChromeProvider");return(0,Qs.jsx)("div",{className:"col-start-3 row-start-1 flex min-w-0 items-center justify-self-end md:hidden",ref:e.mobileHeaderActionsSlotRef})}function lK(){let e=(0,Gt.useContext)(Gl);if(!e)throw new Error("MobileHeaderLiveSlot requires DashboardChromeProvider");return(0,Qs.jsx)("div",{className:"flex shrink-0 items-center md:hidden",ref:e.mobileHeaderLiveSlotRef})}function uK(e){let t=(0,Gt.useContext)(Gl);return t?.mobileHeaderActionsSlot?(0,Sx.createPortal)(e.children,t.mobileHeaderActionsSlot):null}function cK(e){let t=(0,Gt.useContext)(Gl);return t?.mobileHeaderLiveSlot?(0,Sx.createPortal)(e.children,t.mobileHeaderLiveSlot):null}function dK(){let e=(0,Gt.useContext)(Gl);return e?e.openMobileNavigation:null}function fK(e){let t=(0,Gt.useContext)(Gl),a=(0,Gt.useRef)(e);a.current=e,(0,Gt.useEffect)(()=>{if(!t)return;let r=()=>{a.current?.()};return t.registerOpenMobileNavigation(e?r:null),()=>{t.registerOpenMobileNavigation(null)}},[t,e])}function mK(e){let t=(0,Gt.useContext)(Gl);return t?t.secondarySlot?(0,Qs.jsxs)(Qs.Fragment,{children:[(0,Sx.createPortal)(e.desktop,t.secondarySlot),t.mobileSecondarySlot?(0,Sx.createPortal)(e.mobile,t.mobileSecondarySlot):null]}):null:e.desktop}var Xs=b(w(),1);function Ad(e){let t=({isActive:a})=>I("rounded-lg px-3 py-3 pl-6 font-mono text-sm font-medium no-underline transition-colors",a?"bg-cyan-300/[0.1] text-cyan-50":I("hover:bg-white/[0.035]",gm));return(0,Xs.jsxs)("div",{className:"min-w-0",children:[(0,Xs.jsx)(mK,{desktop:(0,Xs.jsx)("div",{className:"border-b border-white/[0.06] bg-white/[0.018]",children:(0,Xs.jsx)("div",{className:I(Ya,"min-w-0 px-4 py-2 md:px-8"),children:(0,Xs.jsx)(xm,{ariaLabel:e.ariaLabel,items:e.items})})}),mobile:(0,Xs.jsx)("nav",{"aria-label":e.ariaLabel,className:"mt-3 grid gap-1 border-t border-white/[0.07] pt-3",children:e.items.map(a=>(0,Xs.jsx)(bz,{className:t,item:a},a.to))})}),(0,Xs.jsx)("div",{className:"px-4 pt-4 sm:px-8 md:hidden",children:(0,Xs.jsx)(xm,{ariaLabel:e.ariaLabel,fill:!0,items:e.items})}),e.children]})}var Kl=b(w(),1),Kbe=new Set(["list","runs"]);function Wbe(e){if(e==="/automations/list"||/^\/automations\/(scheduled|event)\/[^/]+\/edit$/.test(e))return!0;let t=e.match(/^\/automations\/([^/]+)$/);return!!(t?.[1]&&!Kbe.has(t[1]))}var Jbe=[{end:!0,label:"Overview",to:"/automations"},{isActive:Wbe,label:"Automations",to:"/automations/list"},{label:"Runs",to:"/automations/runs"}];function xz(e){return(0,Kl.jsx)(Ad,{ariaLabel:"Automations navigation",items:Jbe,children:e.children})}function Ai(e){return(0,Kl.jsx)(xz,{children:(0,Kl.jsx)(So,{children:e.children})})}function Sm(e){return(0,Kl.jsxs)(Kl.Fragment,{children:[(0,Kl.jsx)(We,{description:e.description,title:e.title}),(0,Kl.jsx)(Yn,{label:e.label,variant:e.variant})]})}var ps=b(G(),1);var xg=b(w(),1),Qbe={compact:"font-mono text-xs uppercase tracking-[0.12em] text-dashboard-text-muted",default:"text-sm font-semibold text-dashboard-text"},Xbe={compact:"grid gap-1.5",default:"grid gap-2"};function Ot(e){let t=e.size??"default";return(0,xg.jsxs)("div",{className:I(Xbe[t],e.className),children:[(0,xg.jsx)("label",{className:Qbe[t],htmlFor:e.htmlFor,children:e.label}),e.children,e.error?(0,xg.jsx)("p",{id:e.htmlFor?`${e.htmlFor}-error`:void 0,role:"alert",className:"m-0 text-xs leading-relaxed text-rose-300",children:e.error}):null,e.help?(0,xg.jsx)("p",{id:e.htmlFor?`${e.htmlFor}-help`:void 0,className:"m-0 text-xs leading-relaxed text-dashboard-text-muted sm:text-sm",children:e.help}):null]})}var Sz=b(w(),1),pK="block w-full rounded border border-dashboard-border-emphasis bg-dashboard-ink px-3 py-2 text-sm text-dashboard-text focus:border-dashboard-focus focus:outline-none aria-invalid:border-rose-300 disabled:cursor-not-allowed disabled:opacity-50";function xa({className:e,type:t="text",size:a="default",...r}){return(0,Sz.jsx)("input",{...r,className:I(pK,a==="comfortable"&&"min-h-11 text-base sm:min-h-10 sm:text-sm",e),type:t})}function tc({className:e,prose:t=!1,...a}){return(0,Sz.jsx)("textarea",{...a,className:I(pK,"min-h-36",t?"font-sans leading-relaxed":"font-mono",e)})}var wm=b(w(),1);function ms(e){return(0,wm.jsxs)("section",{className:"grid min-w-0 gap-5 border-t border-dashboard-border-emphasis py-8 md:grid-cols-[12rem_minmax(0,1fr)] md:gap-10",children:[(0,wm.jsxs)("div",{children:[(0,wm.jsx)("h2",{className:"m-0 font-display text-lg font-medium",children:e.title}),e.detail?(0,wm.jsx)("p",{className:"mt-2 mb-0 text-sm leading-relaxed text-dashboard-text-muted",children:e.detail}):null]}),(0,wm.jsx)("div",{className:"grid min-w-0 content-start gap-5",children:e.children})]})}var T1=b(G(),1);var hK=b(w(),1);function Wl({className:e,...t}){return(0,hK.jsx)("select",{...t,className:I("block min-h-11 w-full min-w-0 rounded border border-dashboard-border-emphasis bg-dashboard-ink px-3 py-2 text-base text-dashboard-text focus:border-dashboard-focus focus:outline-none aria-invalid:border-rose-300 disabled:cursor-not-allowed disabled:opacity-60 sm:min-h-10 sm:text-sm",e)})}var k1=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function I1(e){return{title:e.title??"",instruction:e.instruction,credentialMode:e.credentialMode,outcomes:e.outcomes,trigger:e.kind==="event"?e.trigger:void 0}}function L1(e){let t=e.schedule.recurrence;if(e.schedule.kind==="recurring"&&t){let{time:a,weekdays:r,...n}=t;return{kind:"recurring",...n,timezone:e.schedule.timezone,time:`${String(a.hour).padStart(2,"0")}:${String(a.minute).padStart(2,"0")}`,weekdays:r?.map(o=>k1[o])}}if(e.nextRunAtMs){let a=new Intl.DateTimeFormat("en-CA",{timeZone:e.schedule.timezone,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(e.nextRunAtMs),r=n=>a.find(o=>o.type===n)?.value??"";return{kind:"one_off",timezone:e.schedule.timezone,timing:{type:"at",date:`${r("year")}-${r("month")}-${r("day")}`,time:`${r("hour")}:${r("minute")}`}}}return{kind:"recurring",frequency:"daily",time:"09:00",timezone:e.schedule.timezone}}function gK(e,t){let a={};return t.title!==(e.title??"")&&(a.title=t.title),t.instruction!==e.instruction&&(a.instruction=t.instruction),t.credentialMode!==e.credentialMode&&(a.credentialMode=t.credentialMode),JSON.stringify(t.outcomes)!==JSON.stringify(e.outcomes)&&(a.outcomes=t.outcomes),e.kind==="scheduled"&&t.schedule&&(a.schedule=t.schedule),e.kind==="event"&&JSON.stringify(t.trigger)!==JSON.stringify(e.trigger)&&(a.trigger=t.trigger),a}var He=b(w(),1);function vK(e){let t=e.value??L1(e.automation),[a,r]=(0,T1.useState)(e.value);(0,T1.useEffect)(()=>{let f=setTimeout(()=>r(e.value),300);return()=>clearTimeout(f)},[e.value]);let n=HE.safeParse(a),o=Be({queryKey:["dashboard","automation-schedule-preview",e.automation.id,a],enabled:!!a&&n.success,retry:!1,queryFn:()=>xo(qE,`/api/automations/scheduled/${encodeURIComponent(e.automation.id)}/preview`,a)}),i=t.kind==="recurring"?t.frequency:"once",s=t.kind==="recurring"?t.time:t.timing.time,l=e.value?o.data?.nextRunAtMs:e.automation.nextRunAtMs,c=e.value!==a||o.isFetching,d=o.error instanceof yn?o.error.apiError:o.error?"Schedule preview could not be loaded. Try again.":e.value&&!n.success&&!c?n.error.issues[0]?.message:void 0;return(0,He.jsxs)(He.Fragment,{children:[(0,He.jsxs)("div",{className:"grid grid-cols-1 items-start gap-4 sm:grid-cols-2",children:[(0,He.jsx)(Ot,{label:"Repeat",htmlFor:"schedule-frequency",children:(0,He.jsxs)(Wl,{id:"schedule-frequency",value:i,onChange:f=>{let m=f.target.value;m!=="once"&&m!=="daily"&&m!=="weekly"&&m!=="monthly"&&m!=="yearly"||e.onChange(m==="once"?{kind:"one_off",timezone:t.timezone??e.automation.schedule.timezone,timing:{type:"at",date:"",time:s}}:{kind:"recurring",timezone:t.timezone,time:s,frequency:m,interval:1,weekdays:m==="weekly"?["monday"]:void 0,dayOfMonth:["monthly","yearly"].includes(m)?1:void 0,month:m==="yearly"?1:void 0})},children:[(0,He.jsx)("option",{value:"once",children:"Once"}),(0,He.jsx)("option",{value:"daily",children:"Every day"}),(0,He.jsx)("option",{value:"weekly",children:"Every week"}),(0,He.jsx)("option",{value:"monthly",children:"Every month"}),(0,He.jsx)("option",{value:"yearly",children:"Every year"})]})}),(0,He.jsx)(Ot,{label:"Time",htmlFor:"schedule-time",children:(0,He.jsx)(xa,{size:"comfortable",id:"schedule-time",type:"time",value:s,onChange:f=>e.onChange(t.kind==="recurring"?{...t,time:f.target.value}:{...t,timing:{type:"at",date:t.timing.date,time:f.target.value}})})})]}),t.kind==="recurring"?(0,He.jsxs)(He.Fragment,{children:[t.frequency==="weekly"?(0,He.jsxs)("fieldset",{children:[(0,He.jsx)("legend",{className:"mb-2 text-sm font-semibold",children:"On"}),(0,He.jsx)("div",{className:"grid grid-cols-7 gap-1.5",children:[...k1.slice(1),k1[0]].map(f=>(0,He.jsx)("button",{type:"button","aria-label":f,"aria-pressed":t.weekdays?.includes(f)??!1,onClick:()=>e.onChange({...t,weekdays:t.weekdays?.includes(f)?t.weekdays.filter(m=>m!==f):[...t.weekdays??[],f]}),className:I("min-h-11 cursor-pointer rounded border px-1 text-xs font-medium capitalize focus-visible:outline-2 focus-visible:outline-dashboard-focus sm:min-h-10 sm:text-sm",t.weekdays?.includes(f)?"border-dashboard-focus/50 bg-dashboard-focus/10 text-dashboard-focus":"border-dashboard-border-emphasis text-dashboard-text-muted hover:bg-dashboard-fill-hover"),children:f.slice(0,3)},f))})]}):null,(0,He.jsxs)("div",{className:"grid grid-cols-1 items-start gap-4 sm:grid-cols-2",children:[(0,He.jsx)(Ot,{label:"Interval",htmlFor:"schedule-interval",help:"Number of calendar periods between runs.",children:(0,He.jsx)(xa,{size:"comfortable",id:"schedule-interval",type:"number",min:1,max:365,value:t.interval??1,onChange:f=>e.onChange({...t,interval:f.target.valueAsNumber})})}),(0,He.jsx)(Ot,{label:"Start date",htmlFor:"schedule-start",children:(0,He.jsx)(xa,{size:"comfortable",id:"schedule-start",type:"date",value:t.startDate??"",onChange:f=>e.onChange({...t,startDate:f.target.value||void 0})})})]}),t.frequency==="monthly"||t.frequency==="yearly"?(0,He.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[(0,He.jsx)(Ot,{label:"Day of month",htmlFor:"schedule-day",children:(0,He.jsx)(xa,{size:"comfortable",id:"schedule-day",type:"number",min:1,max:31,value:t.dayOfMonth??1,onChange:f=>e.onChange({...t,dayOfMonth:f.target.valueAsNumber})})}),t.frequency==="yearly"?(0,He.jsx)(Ot,{label:"Month",htmlFor:"schedule-month",children:(0,He.jsx)(Wl,{id:"schedule-month",value:t.month??1,onChange:f=>e.onChange({...t,month:Number(f.target.value)}),children:Array.from({length:12},(f,m)=>(0,He.jsx)("option",{value:m+1,children:new Intl.DateTimeFormat("en",{month:"long",timeZone:"UTC"}).format(new Date(Date.UTC(2026,m,1)))},m))})}):null]}):null]}):(0,He.jsx)(Ot,{label:"Date",htmlFor:"schedule-date",children:(0,He.jsx)(xa,{size:"comfortable",id:"schedule-date",type:"date",value:t.timing.date,onChange:f=>e.onChange({...t,timing:{type:"at",time:s,date:f.target.value}})})}),(0,He.jsxs)(Ot,{label:"Timezone",htmlFor:"schedule-timezone",help:"Use an IANA timezone. The schedule follows local time, including daylight saving time.",children:[(0,He.jsx)(xa,{size:"comfortable",id:"schedule-timezone",list:"automation-timezones",value:t.timezone??"",onChange:f=>e.onChange({...t,timezone:f.target.value})}),(0,He.jsx)("datalist",{id:"automation-timezones",children:["UTC",...Intl.supportedValuesOf("timeZone")].map(f=>(0,He.jsx)("option",{children:f},f))})]}),(0,He.jsxs)("div",{role:"status",className:"flex gap-3 rounded-md bg-dashboard-fill-soft p-3 text-sm leading-relaxed",children:[(0,He.jsx)(Fs,{"aria-hidden":!0,size:17,className:"mt-0.5 shrink-0 text-dashboard-text-muted"}),(0,He.jsx)("div",{children:c?"Checking schedule\u2026":d?(0,He.jsxs)(He.Fragment,{children:[(0,He.jsx)("span",{className:"text-rose-300",children:d}),o.error?(0,He.jsx)(ie,{onClick:()=>{o.refetch()},children:"Try again"}):null]}):l?(0,He.jsxs)(He.Fragment,{children:["Next run"," ",new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short",timeZone:e.value?o.data?.schedule.timezone??"UTC":e.automation.schedule.timezone}).format(l)]}):"No next run."})]}),e.value?(0,He.jsx)(ie,{className:"w-fit",onClick:()=>e.onChange(void 0),children:"Keep saved schedule"}):null]})}var ht=b(w(),1);function yK(e){let t=Be({queryKey:["dashboard","automation-event-catalog"],queryFn:({signal:o})=>Pe(FE,"/api/automations/event-catalog",o),retry:!1}),a=t.data?.find(o=>o.namespace===e.value.namespace&&o.type===e.value.resourceType),r=!a||e.value.events.some(o=>!a.supportedEvents.includes(o))||Object.entries(e.value.match??{}).some(([o,i])=>{let s=a.matchFields?.[o];return s?(Array.isArray(i)?i:[i]).some(l=>typeof l!==s.kind||s.enum&&!s.enum.includes(String(l))):!0}),n=(o,i)=>{let s={...e.value.match};i===void 0?delete s[o]:s[o]=i,e.onChange({...e.value,match:s})};return(0,ht.jsxs)(ht.Fragment,{children:[t.error?(0,ht.jsxs)(Yr,{title:"Event choices could not be loaded.",children:["Saved values are kept."," ",(0,ht.jsx)(ie,{onClick:()=>{t.refetch()},children:"Try again"})]}):t.isPending?(0,ht.jsx)("p",{role:"status",children:"Loading event choices\u2026"}):null,r&&t.data?(0,ht.jsxs)(Yr,{title:"Saved trigger \xB7 Kept unchanged",children:["Some saved values are not in the current catalog. You can edit other fields, or select a new resource type to replace the trigger.",(0,ht.jsx)("pre",{className:"whitespace-pre-wrap break-all text-xs",children:JSON.stringify(e.value,null,2)})]}):null,(0,ht.jsx)(Ot,{label:r?"Replace trigger":"Resource type",htmlFor:"trigger-resource",children:(0,ht.jsxs)(Wl,{id:"trigger-resource",value:r?"":`${e.value.namespace}:${e.value.resourceType}`,onChange:o=>{let i=t.data?.find(s=>`${s.namespace}:${s.type}`===o.target.value);i&&window.confirm("Replace the saved trigger? Its resource, events, and conditions will be cleared.")&&e.onChange({namespace:i.namespace,resourceType:i.type,identifier:"",label:"",events:[]})},children:[(0,ht.jsx)("option",{value:"",disabled:!0,children:"Keep saved trigger"}),t.data?.map(o=>(0,ht.jsxs)("option",{value:`${o.namespace}:${o.type}`,children:[o.namespace," \xB7 ",o.type.replaceAll("_"," ")]},`${o.namespace}:${o.type}`))]})}),!r&&a?(0,ht.jsxs)(ht.Fragment,{children:[(0,ht.jsx)(Ot,{label:"Resource name",htmlFor:"trigger-label",children:(0,ht.jsx)(xa,{size:"comfortable",id:"trigger-label",value:e.value.label,onChange:o=>e.onChange({...e.value,label:o.target.value})})}),(0,ht.jsx)(Ot,{label:"Resource identifier",htmlFor:"trigger-identifier",help:"Use the exact provider resource identifier, not its display name.",children:(0,ht.jsx)(xa,{size:"comfortable",id:"trigger-identifier",value:e.value.identifier,onChange:o=>e.onChange({...e.value,identifier:o.target.value})})}),(0,ht.jsxs)("fieldset",{children:[(0,ht.jsx)("legend",{className:"mb-2 text-sm font-semibold",children:"Run on these events"}),(0,ht.jsx)("div",{className:"divide-y divide-dashboard-border-subtle rounded-md border border-dashboard-border-emphasis",children:a.supportedEvents.map(o=>(0,ht.jsxs)("label",{className:"flex min-h-11 cursor-pointer items-start gap-3 px-3 py-3 text-sm",children:[(0,ht.jsx)("input",{type:"checkbox",className:"mt-0.5 size-4 shrink-0 accent-dashboard-focus",checked:e.value.events.includes(o),onChange:()=>e.onChange({...e.value,events:e.value.events.includes(o)?e.value.events.filter(i=>i!==o):[...e.value.events,o]})}),(0,ht.jsxs)("span",{className:"min-w-0 break-words",children:[o.replaceAll("_"," ").replaceAll("."," \xB7 "),a.guidance?.[o]?(0,ht.jsx)("span",{className:"mt-1 block text-xs leading-relaxed text-dashboard-text-muted",children:a.guidance[o]}):null]})]},o))})]}),Object.keys(a.matchFields??{}).length?(0,ht.jsxs)("fieldset",{className:"grid gap-4",children:[(0,ht.jsx)("legend",{className:"mb-3 text-sm font-semibold",children:"Only when"}),(0,ht.jsx)("p",{className:"m-0 text-xs leading-relaxed text-dashboard-text-muted",children:"All conditions must match. Leave a field blank to match any value. Existing lists match any one listed value."}),Object.entries(a.matchFields??{}).map(([o,i])=>{let s=e.value.match?.[o];return(0,ht.jsx)(Ot,{label:o,htmlFor:`match-${o}`,help:i.description,children:Array.isArray(s)?(0,ht.jsxs)("div",{className:"text-sm",children:[(0,ht.jsx)("span",{className:"break-all",children:s.join(", ")})," ",(0,ht.jsx)(ie,{onClick:()=>n(o,void 0),children:"Remove condition"})]}):i.kind==="boolean"||i.enum?(0,ht.jsxs)(Wl,{id:`match-${o}`,value:s===void 0?"":String(s),onChange:l=>n(o,l.target.value===""?void 0:i.kind==="boolean"?l.target.value==="true":l.target.value),children:[(0,ht.jsx)("option",{value:"",children:"Any value"}),(i.enum??["true","false"]).map(l=>(0,ht.jsx)("option",{children:l},l))]}):(0,ht.jsx)(xa,{size:"comfortable",id:`match-${o}`,type:i.kind==="number"?"number":"text",step:"any",value:s===void 0?"":String(s),onChange:l=>n(o,l.target.value===""?void 0:i.kind==="number"?l.target.valueAsNumber:l.target.value)})},o)})]}):null]}):null,JSON.stringify(e.value)!==JSON.stringify(e.original)?(0,ht.jsx)(ie,{className:"w-fit",onClick:()=>e.onChange(e.original),children:"Keep saved trigger"}):null]})}function Cm(e,t){return typeof e.destination=="string"?e.destination==="task_creator"?"Creator \xB7 Direct message":`${t.label} \xB7 ${t.visibility}`:e.destination.channelId===t.channelId&&e.destination.teamId===t.teamId?`${t.label} \xB7 ${t.visibility}`:`Saved destination \xB7 ${e.destination.channelId}`}var aa=b(w(),1);function R1(e){return e.outcomes.length?(0,aa.jsx)("ol",{className:"m-0 grid gap-2 pl-5 text-sm",children:e.outcomes.map((t,a)=>(0,aa.jsx)("li",{children:Cm(t,e.destination)},a))}):(0,aa.jsx)("p",{className:"m-0 text-sm",children:"No success message"})}function bK(e){let t=e.original.length?e.original:[{action:"send_message",destination:"current_conversation"}],a=[...e.original.flatMap((r,n)=>typeof r.destination=="string"?[]:[{value:`saved:${n}`,label:Cm(r,e.destination),outcome:r}]),{value:"current_conversation",label:`${e.destination.label} \xB7 ${e.destination.visibility}`,outcome:{action:"send_message",destination:"current_conversation"}},{value:"task_creator",label:"Creator \xB7 Direct message",outcome:{action:"send_message",destination:"task_creator"}}];return(0,aa.jsxs)(aa.Fragment,{children:[(0,aa.jsxs)("fieldset",{children:[(0,aa.jsx)("legend",{className:"sr-only",children:"Success messages"}),(0,aa.jsx)("div",{className:"flex flex-wrap gap-x-6 gap-y-3",children:[!0,!1].map(r=>(0,aa.jsxs)("label",{className:"inline-flex min-h-8 cursor-pointer items-center gap-2 text-sm",children:[(0,aa.jsx)("input",{type:"radio",name:"messages",className:"size-4 accent-dashboard-focus",checked:!!e.value.length===r,onChange:()=>e.onChange(r?t:[])}),r?"Send a message":"No success message"]},String(r)))})]}),e.value.length?(0,aa.jsxs)("div",{className:"grid gap-4 sm:gap-2",children:[e.value.map((r,n)=>{let o=e.original.findIndex(i=>JSON.stringify(i)===JSON.stringify(r));return(0,aa.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,aa.jsxs)("span",{className:"w-4 text-xs text-dashboard-text-muted",children:[n+1,"."]}),(0,aa.jsx)("div",{className:I("min-w-0 flex-1",e.value.length>1&&"order-last basis-full sm:order-none sm:basis-auto"),children:(0,aa.jsx)(Wl,{"aria-label":`Message ${n+1} destination`,value:typeof r.destination=="string"?r.destination:`saved:${o}`,onChange:i=>{let s=a.find(l=>l.value===i.target.value);s&&e.onChange(e.value.map((l,c)=>c===n?s.outcome:l))},children:a.map(i=>(0,aa.jsx)("option",{value:i.value,children:i.label},i.value))})}),e.value.length>1?(0,aa.jsxs)(aa.Fragment,{children:[(0,aa.jsx)(ie,{size:"icon",className:"ml-auto sm:ml-0","aria-label":`Move message ${n+1} up`,disabled:n===0,onClick:()=>{let i=[...e.value];[i[n-1],i[n]]=[i[n],i[n-1]],e.onChange(i)},children:(0,aa.jsx)(zy,{size:16})}),(0,aa.jsx)(ie,{size:"icon","aria-label":`Remove message ${n+1}`,onClick:()=>e.onChange(e.value.filter((i,s)=>s!==n)),children:(0,aa.jsx)(jn,{size:16})})]}):null]},n)}),e.value.length<5?(0,aa.jsxs)(ie,{className:"w-fit",onClick:()=>e.onChange([...e.value,{action:"send_message",destination:"task_creator"}]),children:[(0,aa.jsx)(Ku,{size:15}),"Add message"]}):null]}):(0,aa.jsx)("p",{className:"m-0 text-sm leading-relaxed text-dashboard-text-muted",children:"Junior still does the work. No message is sent after success."}),(0,aa.jsxs)("p",{className:"m-0 text-xs leading-relaxed text-dashboard-text-muted",children:[e.value.length?"Messages are sent in this order. ":"","This does not limit actions in the instruction."]})]})}var ce=b(w(),1);function SK(e){let[t,a]=(0,ps.useState)(e.automation),[r,n]=(0,ps.useState)(()=>I1(e.automation)),[o,i]=(0,ps.useState)({}),[s,l]=(0,ps.useState)(),c=(0,ps.useRef)(null),d=(0,ps.useRef)(!1),f=gn(),m=Bt(),p=gK(t,r),h=Object.keys(p).length>0,g={kind:t.kind,revision:t.revision,...p},x=EN(()=>h&&!d.current),y=(0,ps.useRef)(null);(0,ps.useEffect)(()=>{x.state==="blocked"&&y.current?.focus()},[x.state]);let v=`/api/automations/${t.kind}/${encodeURIComponent(t.id)}`;(0,ps.useEffect)(()=>{let Z=fe=>{h&&!d.current&&(fe.preventDefault(),fe.returnValue="")};return window.addEventListener("beforeunload",Z),()=>window.removeEventListener("beforeunload",Z)},[h]);let S=()=>requestAnimationFrame(()=>(c.current?.querySelector('[aria-invalid="true"]')??c.current?.querySelector("[data-save-error]"))?.focus()),C=ga({mutationFn:()=>dg(ds,v,g),onSuccess:async()=>{d.current=!0,await m.invalidateQueries({queryKey:["dashboard","automations"]}),f(e.returnPath,{state:{automationSaved:!0}})},onError:Z=>{i(Z instanceof yn?Z.fields??{}:{}),S()}});function T(Z){s&&(n(Z?{...I1(s),...p}:I1(s)),a(s),l(void 0),C.reset(),i({}))}let L=ga({mutationFn:()=>Pe(ds,`${v}/edit`),onSuccess:l}),_=C.error instanceof yn&&C.error.code==="conflict",k=Z=>n(fe=>({...fe,...Z})),j=Z=>Object.entries(o).filter(([fe])=>fe===Z||fe.startsWith(`${Z}.`)).flatMap(([,fe])=>fe).join(" ")||void 0,F=t.kind==="scheduled"?"schedule":"trigger",ue=t.ownedByViewer,z=e.summary.createdBy,Y=!ue&&t.credentialMode==="creator"&&(p.instruction!==void 0||t.kind==="event"&&p.trigger!==void 0),ee=j(F),ve=Z=>({"aria-invalid":!!j(Z)||void 0,"aria-describedby":j(Z)?`${Z}-error`:void 0});return(0,ce.jsxs)("form",{ref:c,noValidate:!0,onSubmit:Z=>{if(Z.preventDefault(),C.isPending||_||!h)return;let fe=BE.safeParse(g);if(!fe.success){let Q={};for(let se of fe.error.issues)(Q[se.path.join(".")]??=[]).push(se.message);i(Q),S();return}i({}),C.mutate()},children:[x.state==="blocked"?(0,ce.jsx)("div",{tabIndex:-1,ref:y,className:"mb-6 outline-none",children:(0,ce.jsxs)(Yr,{title:"Discard unsaved changes?",children:[(0,ce.jsx)("p",{children:"Your changes have not been saved."}),(0,ce.jsxs)("div",{className:"flex gap-2",children:[(0,ce.jsx)(ie,{onClick:()=>x.reset(),children:"Keep editing"}),(0,ce.jsx)(ie,{onClick:()=>x.proceed(),children:"Discard changes"})]})]})}):null,C.error||Object.keys(o).length?(0,ce.jsx)("div",{tabIndex:-1,"data-save-error":!0,className:"mb-6 outline-none",children:(0,ce.jsxs)(Yr,{tone:_?"warning":"error",title:_?"This automation changed while you were editing.":"Changes could not be saved.",children:[(0,ce.jsxs)("p",{className:"mt-1",children:["Your edits are still here."," ",_?"Review the latest version before saving again.":C.error instanceof yn?C.error.apiError:"Check the fields below, or try again."]}),_?(0,ce.jsx)(ie,{disabled:L.isPending,onClick:()=>L.mutate(),children:L.isPending?"Loading\u2026":"Review latest version"}):null,L.error?(0,ce.jsx)("p",{role:"alert",children:"The latest version could not be loaded. Try again."}):null]})}):null,s?(0,ce.jsx)("div",{className:"mb-6",children:(0,ce.jsxs)(Yr,{title:"Compare your edits with the latest saved version",children:[(0,ce.jsx)("p",{children:"Only the fields you changed are shown. Keeping your edits will replace these fields. Other saved fields stay unchanged."}),Object.entries(p).map(([Z,fe])=>(0,ce.jsxs)("section",{className:"my-4",children:[(0,ce.jsx)("h3",{className:"text-sm font-semibold capitalize",children:Z==="credentialMode"?"Credentials":Z}),(0,ce.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,ce.jsxs)("div",{children:[(0,ce.jsx)("p",{children:"Latest saved"}),(0,ce.jsx)("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm",children:xK(Z==="schedule"&&s.kind==="scheduled"?L1(s):s[Z])})]}),(0,ce.jsxs)("div",{children:[(0,ce.jsx)("p",{children:"Your edit"}),(0,ce.jsx)("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm",children:xK(fe)})]})]})]},Z)),(0,ce.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,ce.jsx)(ie,{onClick:()=>T(!0),children:"Keep my changed fields"}),(0,ce.jsx)(ie,{onClick:()=>T(!1),children:"Use latest saved version"})]})]})}):null,ue?null:(0,ce.jsxs)("p",{className:"mt-0 mb-6 max-w-2xl text-sm leading-relaxed text-dashboard-text-muted",children:[z," created this automation. You can edit it because it is in a public channel. Only ",z," can change where results go or turn on their connected accounts. Version history keeps every saved change."]}),(0,ce.jsxs)("fieldset",{disabled:C.isPending,className:"min-w-0",children:[(0,ce.jsxs)(ms,{title:"What to do",detail:"Give Junior a clear instruction and a name you can find later.",children:[(0,ce.jsx)(Ot,{label:"Title",htmlFor:"title",error:j("title"),children:(0,ce.jsx)(xa,{size:"comfortable",id:"title",value:r.title,placeholder:e.summary.title,onChange:Z=>k({title:Z.target.value}),...ve("title")})}),(0,ce.jsxs)(Ot,{label:"Instruction",htmlFor:"instruction",error:j("instruction"),children:[(0,ce.jsx)(tc,{prose:!0,id:"instruction",rows:8,value:r.instruction,onChange:Z=>k({instruction:Z.target.value}),...ve("instruction"),className:"resize-y text-base sm:text-sm"}),(0,ce.jsxs)("p",{className:"m-0 text-right text-xs text-dashboard-text-muted",children:[r.instruction.length.toLocaleString()," / 4,000"]})]})]}),(0,ce.jsx)(ms,{title:"When to run",detail:t.kind==="scheduled"?"Choose a schedule in a specific timezone.":"Run when a matching event occurs.",children:(0,ce.jsxs)("div",{id:`${F}-error`,tabIndex:-1,"aria-invalid":!!ee||void 0,className:"grid min-w-0 gap-5 outline-none",children:[ee?(0,ce.jsx)("p",{role:"alert",className:"m-0 text-sm text-rose-300",children:ee}):null,t.kind==="scheduled"?(0,ce.jsx)(vK,{automation:t,value:r.schedule,onChange:Z=>k({schedule:Z})}):(0,ce.jsx)(yK,{value:r.trigger??t.trigger,original:t.trigger,onChange:Z=>k({trigger:Z})})]})}),(0,ce.jsxs)(ms,{title:"Where results go",detail:"Choose who gets a message after successful work.",children:[j("outcomes")?(0,ce.jsx)("p",{role:"alert",className:"m-0 text-sm text-rose-300",children:j("outcomes")}):null,ue?(0,ce.jsx)(bK,{value:r.outcomes,original:t.outcomes,destination:e.summary.destination,onChange:Z=>k({outcomes:Z})}):(0,ce.jsxs)(ce.Fragment,{children:[(0,ce.jsx)(R1,{outcomes:t.outcomes,destination:e.summary.destination}),(0,ce.jsxs)("p",{className:"m-0 text-xs text-dashboard-text-muted",children:["Only ",z," can change where results go."]})]})]}),(0,ce.jsxs)(ms,{title:"Credentials",detail:"Choose which connected accounts Junior can use.",children:[(0,ce.jsxs)("fieldset",{className:"divide-y divide-dashboard-border-subtle rounded-md border border-dashboard-border-emphasis",children:[(0,ce.jsx)("legend",{className:"sr-only",children:"Credential mode"}),[["creator",ue?"Your connected accounts":`${z}\u2019s connected accounts`,ue?"Uses accounts connected by you, the creator.":`Uses accounts connected by ${z}. Only ${z} can turn this on.`],["system","System credentials only",ue?"Does not use your connected accounts. Some work may not be possible.":"Does not use anyone\u2019s connected accounts. Some work may not be possible."]].map(([Z,fe,Q])=>(0,ce.jsxs)("label",{className:"flex cursor-pointer items-start gap-3 px-4 py-4 has-checked:bg-dashboard-fill-soft has-disabled:cursor-not-allowed has-disabled:opacity-60",children:[(0,ce.jsx)("input",{type:"radio",name:"credentials",className:"mt-0.5 size-4 shrink-0 accent-dashboard-focus",checked:Y?Z==="system":r.credentialMode===Z,disabled:Z==="creator"&&!ue&&(t.credentialMode!=="creator"||Y),onChange:()=>k({credentialMode:Z})}),(0,ce.jsxs)("span",{children:[(0,ce.jsx)("span",{className:"block text-sm font-medium",children:fe}),(0,ce.jsx)("span",{className:"mt-1 block text-xs leading-relaxed text-dashboard-text-muted",children:Q})]})]},Z))]}),Y?(0,ce.jsxs)(Yr,{title:"Saving switches this automation to system credentials.",children:["Only ",z," can let a changed instruction",t.kind==="event"?" or trigger":""," use their connected accounts."]}):null,j("credentialMode")?(0,ce.jsx)("p",{role:"alert",children:j("credentialMode")}):null]})]}),(0,ce.jsx)("p",{className:"mb-5 text-xs leading-relaxed text-dashboard-text-muted sm:hidden",children:"Changes apply to future work. Saving does not run this automation."}),(0,ce.jsx)("div",{className:"sticky bottom-0 z-20 -mx-4 border-t border-dashboard-border-emphasis bg-dashboard-bg px-4 py-4 sm:-mx-8 sm:px-8",children:(0,ce.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ce.jsxs)("div",{className:"min-w-0 flex-1",role:"status",children:[(0,ce.jsx)("p",{className:"m-0 text-xs font-medium sm:text-sm",children:C.isPending?"Saving\u2026":h?"Unsaved changes":"Unchanged"}),(0,ce.jsx)("p",{className:"mt-1 mb-0 hidden text-xs text-dashboard-text-muted sm:block",children:"Changes apply to future work. Saving does not run it."})]}),(0,ce.jsxs)("div",{className:"flex shrink-0 gap-2",children:[(0,ce.jsx)(ae,{to:e.returnPath,className:"inline-flex min-h-11 items-center rounded border border-dashboard-border-emphasis px-3 text-sm text-dashboard-text no-underline sm:min-h-9",children:"Cancel"}),(0,ce.jsx)(ie,{type:"submit",tone:"primary",className:"min-h-11 sm:min-h-9",disabled:!h||C.isPending||_,children:"Save changes"})]})]})})]})}function xK(e){return e==null?"Not set":typeof e=="string"?e:JSON.stringify(e,null,2)}var Sg=b(w(),1);function wK(){return(0,Sg.jsx)("div",{role:"status","aria-label":"Loading automation editor",children:["What to do","When to run","Where results go","Credentials"].map((e,t)=>(0,Sg.jsxs)(ms,{title:e,children:[(0,Sg.jsx)(Qe,{className:"h-4 w-24"}),(0,Sg.jsx)(Qe,{className:t===0?"h-48 w-full":"h-20 w-full"})]},e))})}var Mt=b(w(),1);function CK(e){let{kind:t,automationId:a}=Ba(),r=vt(),n=mg(e.enabled,a),o=n.data&&!(n.data.kind==="scheduled"&&n.data.status==="completed"),i=Be({queryKey:["dashboard","automations","edit",t,a],enabled:e.enabled&&!!o&&n.data?.kind===t,retry:!1,queryFn:({signal:f})=>Pe(ds,`/api/automations/${t}/${encodeURIComponent(a)}/edit`,f)}),s=`/automations/list${r.search}`,l=n.data,c=l?.kind==="event"?l.status==="paused"?"paused":l.triggerAvailable?"active":"unavailable":l?.status,d=c==="active"?"success":c==="blocked"||c==="unavailable"?"warning":"neutral";return(0,Mt.jsx)(xz,{children:(0,Mt.jsxs)("div",{className:"mx-auto w-full min-w-0 max-w-5xl px-4 pt-7 sm:px-8 sm:pt-9",children:[(0,Mt.jsxs)(ae,{to:s,className:"inline-flex min-h-8 items-center gap-2 text-sm text-dashboard-text-muted no-underline hover:text-dashboard-text",children:[(0,Mt.jsx)(Zr,{"aria-hidden":!0,size:15}),"All automations"]}),(0,Mt.jsxs)("div",{className:"mt-4 mb-8 flex flex-wrap items-start justify-between gap-4",children:[(0,Mt.jsxs)("div",{className:"min-w-0",children:[(0,Mt.jsx)("h1",{className:"m-0 break-words font-display text-3xl font-light tracking-tight",children:l&&!o?l.title:"Edit automation"}),l?(0,Mt.jsxs)("p",{className:"mt-2 mb-0 text-sm text-dashboard-text-muted",children:["Created by ",l.ownedByViewer?"you":l.createdBy," \xB7"," ",l.destination.label]}):null]}),l?(0,Mt.jsxs)("div",{className:"flex items-center gap-4",children:[(0,Mt.jsx)(ae,{to:`/automations/${l.kind}/${encodeURIComponent(l.id)}/versions${r.search}`,className:"text-sm text-dashboard-text-muted underline underline-offset-2 hover:text-dashboard-text",children:"Version history"}),(0,Mt.jsx)(ba,{tone:d,children:c==="unavailable"?"Trigger unavailable":c})]}):null]}),!l&&n.error||!i.data&&i.error||l&&l.kind!==t?(0,Mt.jsxs)(Yr,{tone:"error",title:"Automation could not be loaded.",children:["It may no longer be available, or you may not have access."," ",(0,Mt.jsx)(ie,{onClick:()=>{n.refetch(),o&&i.refetch()},children:"Try again"})]}):!l||o&&!i.data?(0,Mt.jsx)(wK,{}):o&&i.data?(0,Mt.jsx)(SK,{automation:i.data,summary:l,returnPath:s},`${t}:${a}`):(0,Mt.jsx)(Ybe,{automation:l})]})})}function Ybe({automation:e}){return(0,Mt.jsxs)(Mt.Fragment,{children:[(0,Mt.jsx)("p",{className:"mb-6 text-sm text-dashboard-text-muted",children:"This automation has completed and cannot be edited. It will not run again."}),(0,Mt.jsx)(ms,{title:"What to do",detail:"The saved instruction.",children:(0,Mt.jsx)("p",{className:"m-0 whitespace-pre-wrap break-words text-sm leading-relaxed",children:e.instruction})}),(0,Mt.jsx)(ms,{title:"When to run",detail:"The saved trigger.",children:e.kind==="scheduled"?(0,Mt.jsxs)("p",{className:"m-0 text-sm",children:[e.schedule," \xB7 ",e.timezone]}):(0,Mt.jsxs)("div",{className:"grid gap-3 text-sm",children:[(0,Mt.jsx)("p",{className:"m-0 break-words",children:e.resource}),(0,Mt.jsx)("p",{className:"m-0 break-words",children:e.events.join(", ")}),e.match?(0,Mt.jsx)("pre",{className:"whitespace-pre-wrap break-words text-xs",children:JSON.stringify(e.match,null,2)}):null]})}),(0,Mt.jsx)(ms,{title:"Where results go",detail:"Messages after successful work.",children:(0,Mt.jsx)(R1,{outcomes:e.outcomes,destination:e.destination})}),(0,Mt.jsx)(ms,{title:"Credentials",detail:"The accounts Junior can use.",children:(0,Mt.jsx)("p",{className:"m-0 text-sm",children:e.credentialMode==="creator"?`Uses ${e.ownedByViewer?"your":`${e.createdBy}\u2019s`} connected accounts.`:"System credentials only."})})]})}var rp=b(G(),1);var kK=b(G(),1);function _1(){return(0,kK.useSyncExternalStore)(e=>Il.subscribe(e),()=>Il.isOnline(),()=>!0)}var LK=b(w(),1);function IK(){return _1()?null:(0,LK.jsx)("div",{"aria-live":"polite",className:"border-t border-amber-300/15 bg-amber-300/[0.07] px-3 py-1.5 text-center font-sans text-xs text-amber-100/80",role:"status",children:"You\u2019re offline. Drafts stay on this device."})}var wz=b(w(),1);function N1(){return(0,wz.jsx)("div",{className:"relative grid size-10 shrink-0 select-none place-items-center overflow-visible",children:(0,wz.jsx)("img",{alt:"",className:"relative size-11 max-w-none -translate-y-0.5 object-contain opacity-90 drop-shadow-[0_0_7px_rgba(255,255,255,0.16)]",draggable:!1,src:"/_junior/dashboard/avatar.png"})})}var TK=["relative","overflow-hidden","bg-white/15","before:absolute","before:inset-0","before:content-['']","before:bg-[linear-gradient(90deg,#ff4d6d,#ffb703,#56f39a,#4cc9f0,#9b5de5,#ff4d6d)]","before:bg-[length:200%_100%]","before:animate-[junior-rainbow-flow_1.2s_linear_infinite]","motion-reduce:before:animate-none"].join(" ");var $d=b(w(),1);function Tn(e){return(0,$d.jsx)("div",{className:I(Ya,"grid min-h-[calc(100dvh-5rem)] place-items-center px-4 py-8 md:px-8"),children:(0,$d.jsxs)("section",{className:"grid w-full max-w-lg grid-cols-[auto_minmax(0,1fr)] items-center gap-3 rounded-lg border border-dashboard-border-emphasis bg-dashboard-surface-raised p-4",children:[(0,$d.jsx)(N1,{}),(0,$d.jsxs)("div",{children:[(0,$d.jsx)("div",{className:"font-bold",children:e.label}),(0,$d.jsx)("div",{"aria-label":e.label,className:`${TK} mt-3 h-1.5 w-full`,role:"progressbar"})]})]})})}var Cz="0.238.0",A1=typeof Cz=="string"&&Cz.trim()?Cz:"unknown";var wx=b(w(),1);function RK(e){return exe(e.serverVersion)?(0,wx.jsxs)("div",{"aria-live":"polite",className:"flex flex-wrap items-center justify-center gap-x-3 gap-y-1 border-t border-cyan-300/15 bg-cyan-300/[0.07] px-3 py-1.5 text-center font-sans text-xs text-cyan-100/80",role:"status",children:[(0,wx.jsx)("span",{children:"The dashboard changed. Refresh to load the latest version."}),(0,wx.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0 font-mono font-semibold text-cyan-100 underline decoration-cyan-300/40 underline-offset-2 hover:text-dashboard-text-solid",onClick:()=>window.location.reload(),type:"button",children:"Refresh"})]}):null}function exe(e){return!!e&&A1!=="unknown"&&e!=="unknown"&&e!==A1}var Cx=b(w(),1);function ac(e){return(0,Cx.jsxs)(So,{children:[(0,Cx.jsx)(We,{description:e.description,title:e.title}),(0,Cx.jsx)(Yn,{label:e.label,variant:e.variant})]})}var iu=b(G(),1);var $1={"angular-html":()=>import("./chunks/angular-html-3W5ULHSG.js"),"angular-ts":()=>import("./chunks/angular-ts-4LWK3KJS.js"),astro:()=>import("./chunks/astro-TCFNN3TA.js"),blade:()=>import("./chunks/blade-2ZY5IBVK.js"),c:()=>import("./chunks/c-WHCDUHJR.js"),coffee:()=>import("./chunks/coffee-NWMA7ZVV.js"),coffeescript:()=>import("./chunks/coffee-NWMA7ZVV.js"),cpp:()=>import("./chunks/cpp-7ZDYJCCI.js"),"c++":()=>import("./chunks/cpp-7ZDYJCCI.js"),css:()=>import("./chunks/css-XF3SDJYW.js"),csv:()=>import("./chunks/csv-I2Y5BPVG.js"),glsl:()=>import("./chunks/glsl-SDKJ4MVB.js"),graphql:()=>import("./chunks/graphql-XJBKAS4G.js"),gql:()=>import("./chunks/graphql-XJBKAS4G.js"),haml:()=>import("./chunks/haml-QQIA6ZDV.js"),handlebars:()=>import("./chunks/handlebars-IBE27NOG.js"),hbs:()=>import("./chunks/handlebars-IBE27NOG.js"),html:()=>import("./chunks/html-SP67HH5F.js"),"html-derivative":()=>import("./chunks/html-derivative-HSRB64DA.js"),http:()=>import("./chunks/http-VGZ3EXS5.js"),hurl:()=>import("./chunks/hurl-TO4NQQLI.js"),imba:()=>import("./chunks/imba-P3ARIZRP.js"),java:()=>import("./chunks/java-WCBM5OUU.js"),javascript:()=>import("./chunks/javascript-TQH7GGAM.js"),js:()=>import("./chunks/javascript-TQH7GGAM.js"),cjs:()=>import("./chunks/javascript-TQH7GGAM.js"),mjs:()=>import("./chunks/javascript-TQH7GGAM.js"),jinja:()=>import("./chunks/jinja-RWPJ7VSG.js"),jison:()=>import("./chunks/jison-ED4UFXGK.js"),json:()=>import("./chunks/json-XRHV7G5W.js"),json5:()=>import("./chunks/json5-2OA2ZMVI.js"),jsonc:()=>import("./chunks/jsonc-KO53QF6Y.js"),jsonl:()=>import("./chunks/jsonl-GHTNFMM6.js"),jsx:()=>import("./chunks/jsx-V5TSP3NI.js"),julia:()=>import("./chunks/julia-EI7BACOV.js"),jl:()=>import("./chunks/julia-EI7BACOV.js"),less:()=>import("./chunks/less-FPWZXUDW.js"),markdown:()=>import("./chunks/markdown-QWIM2DOI.js"),md:()=>import("./chunks/markdown-QWIM2DOI.js"),marko:()=>import("./chunks/marko-3POAQSZY.js"),mdc:()=>import("./chunks/mdc-GOYXY36C.js"),mdx:()=>import("./chunks/mdx-CWS3UMSH.js"),php:()=>import("./chunks/php-HGK4AZCK.js"),postcss:()=>import("./chunks/postcss-7K34RN34.js"),pug:()=>import("./chunks/pug-J24HZP2J.js"),jade:()=>import("./chunks/pug-J24HZP2J.js"),python:()=>import("./chunks/python-GCPXLELR.js"),py:()=>import("./chunks/python-GCPXLELR.js"),r:()=>import("./chunks/r-XV5O7BSV.js"),regexp:()=>import("./chunks/regexp-655IUQFI.js"),regex:()=>import("./chunks/regexp-655IUQFI.js"),sass:()=>import("./chunks/sass-MSBN6O54.js"),scss:()=>import("./chunks/scss-N73GNFL4.js"),shellscript:()=>import("./chunks/shellscript-OPDT4ZZ3.js"),bash:()=>import("./chunks/shellscript-OPDT4ZZ3.js"),sh:()=>import("./chunks/shellscript-OPDT4ZZ3.js"),shell:()=>import("./chunks/shellscript-OPDT4ZZ3.js"),zsh:()=>import("./chunks/shellscript-OPDT4ZZ3.js"),sql:()=>import("./chunks/sql-ZR72I7RP.js"),stylus:()=>import("./chunks/stylus-NVEQWGLA.js"),styl:()=>import("./chunks/stylus-NVEQWGLA.js"),svelte:()=>import("./chunks/svelte-ZZAXFLSI.js"),"ts-tags":()=>import("./chunks/ts-tags-5RZIQFFW.js"),lit:()=>import("./chunks/ts-tags-5RZIQFFW.js"),tsx:()=>import("./chunks/tsx-ZTNB67YL.js"),typescript:()=>import("./chunks/typescript-HV6B525T.js"),ts:()=>import("./chunks/typescript-HV6B525T.js"),cts:()=>import("./chunks/typescript-HV6B525T.js"),mts:()=>import("./chunks/typescript-HV6B525T.js"),vue:()=>import("./chunks/vue-WQSBUNEP.js"),"vue-html":()=>import("./chunks/vue-html-SKWAUQDE.js"),"vue-vine":()=>import("./chunks/vue-vine-V3A5HTCZ.js"),wasm:()=>import("./chunks/wasm-JWJ5BADC.js"),wgsl:()=>import("./chunks/wgsl-ZCQ7MKDM.js"),wit:()=>import("./chunks/wit-MLLAONFF.js"),xml:()=>import("./chunks/xml-VST5CLIL.js"),yaml:()=>import("./chunks/yaml-BX3BWN2A.js"),yml:()=>import("./chunks/yaml-BX3BWN2A.js")};var _K="Junior";function Ft(){return typeof window>"u"?_K:window.__JUNIOR_DASHBOARD_AGENT_NAME__?.trim()||_K}function NK(e=Ft()){return e.endsWith("s")?`${e}'`:`${e}'s`}var P1=b(w(),1);function to(e){if(typeof e!="number"||!Number.isFinite(e))return"";let t=Math.max(0,Math.floor(e));if(t<1e3)return`${t}ms`;if(t<6e4){let n=t/1e3;return`${n.toFixed(n<10?1:0)}s`}let a=[],r=[["mo",2592e6],["d",864e5],["h",36e5],["m",6e4],["s",1e3]];for(let[n,o]of r){let i=Math.floor(t/o);if(i!==0){if(a.push(`${i}${n}`),a.length===2)break;t%=o}}return a.join(" ")}function nc(e){return(0,P1.jsx)(P1.Fragment,{children:to(e.value)||e.fallback||null})}function kx(e){return Date.parse(e.createdAt)}function Pd(e,t,a){return{parts:a,role:t,sourceSeq:e.seq,timestamp:kx(e)}}function txe(e){let t=new Set;for(let a of e){let r=a.data;r.type==="handoff"&&r.triggeringToolCallId&&t.add(r.triggeringToolCallId),r.type==="subagent"&&r.parentToolCallId&&t.add(r.parentToolCallId)}return t}function axe(e){let t=new Set;for(let a of e)a.messageId&&t.add(a.messageId);return t}function nxe(e,t){return{delivery:e.delivery,messageId:e.messageId,parts:e.redacted?[{type:"text",redacted:!0}]:[{type:"text",text:e.text??""}],...e.attachments?{attachments:e.attachments}:void 0,pending:!0,role:"user",source:e.source,sourceSeq:Number.MAX_SAFE_INTEGER-1e6+t,timestamp:Date.parse(e.createdAt),...e.actorIdentity?{actorIdentity:e.actorIdentity}:void 0}}function rxe(e,t){if(!t?.length)return e;let a=oxe(e,t);return a.length===0?e:[...e,...a]}function oxe(e,t){if(!t?.length)return[];let a=axe(e);return t.filter(r=>!a.has(r.messageId)).map((r,n)=>nxe(r,n))}function kz(e,t){return Iz(e.events,e.annotations,t)}function Iz(e,t,a){let r=txe(e),n=new Map,o=new Map,i=new Map,s=[],l=new Map,c=new Map,d,f=(p,h)=>{if(r.has(h.toolCallId))return;let g="output"in h?h.output:void 0,x=n.get(h.toolCallId);if(x){x.name=h.name,x.status=h.status,h.input!==void 0&&(x.input=h.input),g!==void 0&&(x.output=g),x.startedTimestamp===void 0&&h.startedAt&&(x.startedTimestamp=Date.parse(h.startedAt)),h.status!=="running"&&(x.resultTimestamp=kx(p));return}let y={type:"tool_call",id:h.toolCallId,name:h.name,status:h.status,...h.input===void 0?void 0:{input:h.input},...g===void 0?void 0:{output:g},...h.status==="running"?void 0:{resultTimestamp:kx(p)}},v={...Pd(p,"tool",[y]),sourceSeq:h.startedSeq??p.seq,timestamp:h.startedAt?Date.parse(h.startedAt):kx(p)};n.set(h.toolCallId,y),o.set(h.toolCallId,v),s.push(v)};for(let p of e){let h=p.data;if(h.type==="message"){let g={...Pd(p,h.role,[h.redacted?{type:"text",redacted:!0}:{type:"text",text:h.text}]),messageId:h.messageId,...h.attachments?{attachments:h.attachments}:void 0,...h.cards?{cards:xE(h.cards,t??[])}:void 0,...h.actorIdentity?{actorIdentity:h.actorIdentity}:void 0,...h.eventType?{eventType:h.eventType}:void 0,eventObjectType:h.eventObjectType,...h.trustedSummary?{trustedSummary:h.trustedSummary}:void 0,...h.explicitMention!==void 0?{explicitMention:h.explicitMention}:void 0,...h.source?{source:h.source}:void 0};s.push(g),l.set(g.messageId,g),g.role==="user"&&(d=g);continue}if(h.type==="message_handled"){let g=l.get(h.messageId);g?.role==="user"&&g.explicitMention===!1&&!g.eventType&&(g.context=!0);continue}if(h.type==="assistant_message"){if(h.parts.length===0)continue;s.push(Pd(p,"assistant",h.parts.map(g=>g.redacted?{type:"reasoning",redacted:!0}:{type:"reasoning",text:g.text})));continue}if(h.type==="turn_lifecycle"&&h.state==="started"){let g=h.inputMessageIds?.map(y=>l.get(y)).filter(y=>y!==void 0),x=g?.slice().reverse().find(y=>y.role==="user");x?c.set(h.turnId,x):d&&c.set(h.turnId,d);for(let y of g??[])y.role==="user"&&y.explicitMention===!1&&!y.eventType&&(y.context=!0);continue}if(h.type==="turn_routed"){let g=c.get(h.turnId);g&&(g.route={modelProfile:h.modelProfile,modelId:h.modelId,reasoningLevel:h.reasoningLevel,...h.confidence!==void 0?{confidence:h.confidence}:void 0,source:h.source});continue}if(h.type==="turn_context"){let g=c.get(h.turnId);g&&(g.contexts??=[],g.contexts.push({content:h.content,kind:h.kind,loadedAt:p.createdAt,pluginName:h.pluginName,version:h.version}));continue}if(h.type==="tool_calls"){for(let g of h.calls)f(p,g);if(h.assistant){let g=[];for(let x of h.assistant.parts){if(x.type==="reasoning"){g.push(x.redacted?{type:"reasoning",redacted:!0}:{type:"reasoning",text:x.text});continue}if(r.has(x.toolCallId))continue;let y=n.get(x.toolCallId);if(!y)continue;let v=o.get(x.toolCallId);if(v){v.sourceSeq!==p.seq&&(y.startedTimestamp=v.timestamp);let S=s.indexOf(v);S>=0&&s.splice(S,1),o.delete(x.toolCallId)}g.push(y)}g.length>0&&s.push(Pd(p,"assistant",g))}continue}if(h.type==="subagent"){let g=`${h.childConversationId}:${h.startedSeq}`,x=i.get(g);if(x){x.status=h.status;continue}let y={type:"subagent",id:g,childConversationId:h.childConversationId,subagentKind:h.subagentKind,status:h.status};i.set(g,y),s.push({...Pd(p,"tool",[y]),sourceSeq:h.startedSeq,timestamp:Date.parse(h.startedAt)});continue}if(h.type==="structured_event"){s.push(Pd(p,"system",[{type:"structured_event",namespace:h.namespace,name:h.name,version:h.version,presentation:h.presentation}]));continue}if(h.type==="attachments_delivered"){s.push(Pd(p,"system",[{type:"attachments_delivered",attachments:h.attachments}]));continue}if(h.type==="compaction"||h.type==="handoff"){s.push(Pd(p,"system",[{type:"context_event",event:h.type==="handoff"?{type:h.type,createdAt:p.createdAt,modelId:h.modelId,modelProfile:h.modelProfile,...h.summary?{summary:h.summary}:void 0,...h.reasoningLevel?{reasoningLevel:h.reasoningLevel}:void 0}:{type:h.type,createdAt:p.createdAt,...h.modelId?{modelId:h.modelId}:void 0,...h.modelProfile?{modelProfile:h.modelProfile}:void 0,...h.summary?{summary:h.summary}:void 0,...h.details?{details:h.details}:void 0}}]));continue}if(h.type==="turn_lifecycle"&&h.state==="failed"){s.push({role:h.failureCode==="delivery_failed"?"system":"assistant",failureCode:h.failureCode,...h.failureReason?{failureReason:h.failureReason}:void 0,...h.eventId?{eventId:h.eventId}:void 0,...h.sentryEventUrl?{sentryEventUrl:h.sentryEventUrl}:void 0,parts:[],sourceSeq:p.seq,timestamp:kx(p)});continue}}let m=s.filter(p=>p.role!=="user"||p.eventType!==void 0||p.explicitMention!==!1||p.context===!0).sort((p,h)=>p.sourceSeq-h.sourceSeq);return rxe(m,a)}function AK(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return"UTC"}}var Tz=AK();function $K(e){Tz=e||AK()}function Ed(){return Tz}function E1(){return Tz}function ixe(e){return e.status==="active"}function sxe(e){return e.status==="failed"}function lxe(e){return e.status==="active"}function uxe(e){return e.status==="failed"}function M1(e){if(!e)return null;let t=Date.parse(e);return Number.isFinite(t)?t:null}function Rn(e,t){let a=M1(e);return a==null?"none":new Date(a).toLocaleString(void 0,{...t,timeZone:E1()})}function ao(e){let t=M1(e);if(t==null)return"not updated yet";let a=Math.round((t-Date.now())/1e3),r=Math.abs(a),n=[["year",3600*24*365],["month",3600*24*30],["week",3600*24*7],["day",3600*24],["hour",3600],["minute",60]];for(let[o,i]of n)if(r>=i)return new Intl.RelativeTimeFormat(void 0,{numeric:"auto"}).format(Math.round(a/i),o);return"just now"}function Im(e){if(typeof e!="number"||!Number.isFinite(e))return"none";let t=Math.max(0,Math.floor(e));if(t<1e3)return`${t}ms`;let a=t/1e3;if(a<60)return`${a.toFixed(a<10?1:0)}s`;let r=Math.round(a),n=Math.floor(r/60),o=r%60;return`${n}m ${o}s`}function PK(e){if(e===void 0)return;let t=typeof e=="string"?e:JSON.stringify(e);if(t===void 0)return;let a=new TextEncoder().encode(t).byteLength;return a<1e3?`${a}b`:`${Math.round(a/1e3)}kb`}function O1(e,t){if(!(typeof e!="number"||typeof t!="number"||t<e))return Im(t-e)}function Lx(e){if(typeof e!="number"||!Number.isFinite(e))return"";let t=Math.max(0,Math.floor(e));return t===0?"":to(t)}function ca(e,t=!1){if(typeof e!="number"||!Number.isFinite(e))return"no timestamp";let a=new Date(e);return t?a.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium",timeZone:E1()}):a.toLocaleTimeString(void 0,{timeZone:E1()})}function DK(e){if(typeof e!="number"||!Number.isFinite(e))return"no timestamp";let t=Math.round((e-Date.now())/1e3),a=Math.abs(t),r=[["year",3600*24*365],["month",3600*24*30],["week",3600*24*7],["day",3600*24],["hour",3600]],[n,o]=r.find(([,i])=>a>=i)??r.at(-1);return new Intl.RelativeTimeFormat(void 0,{numeric:"auto"}).format(Math.round(t/o),n)}function EK(e){let t=new Date(e),a={dateStyle:"medium",timeStyle:"long"};return{local:t.toLocaleString(void 0,{...a,timeZone:E1()}),utc:t.toLocaleString(void 0,{...a,timeZone:"UTC"})}}function MK(e){if(typeof e!="number"||!Number.isFinite(e))return"0";let t=Math.max(0,Math.floor(e));if(t<1e3)return String(t);let a=[["t",1e12],["b",1e9],["m",1e6],["k",1e3]],[r,n]=a.find(([,s])=>t>=s)??a[1],o=t/n;return`${o>=100||Number.isInteger(o)||o>=10?Math.round(o).toString():(Math.floor(o*10)/10).toFixed(1).replace(/\.0$/,"")}${r}`}function km(e){return typeof e=="number"&&Number.isFinite(e)?Math.max(0,Math.floor(e)):void 0}function cxe(e){return[e.inputTokens,e.outputTokens,e.cachedInputTokens,e.cacheCreationTokens].reduce((t,a)=>{let r=km(a);return r===void 0?t:(t??0)+r},void 0)}function Lm(e){let t=e.toLowerCase();return t==="assistant"?"assistant":t==="user"?"user":t==="system"?"system":t.includes("tool")?"tool":"other"}function Md(e,t){let a=Lm(t.role);return a==="assistant"?Ft():a==="user"?Dd(t.actorIdentity)??Dd(e.actorIdentity)??"User":a==="system"?"System":a==="tool"?"Tool":t.role||"Unknown"}function re(e){return MK(e)}function ei(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?"0":e<10?(Math.round(e*10)/10).toFixed(1).replace(/\.0$/,""):re(e)}function wg(e){if(!e)return;let t={totalTokens:0};t.reasoningTokens=km(e.reasoningTokens);let a=cxe(e);if(a!==void 0)t.totalTokens=a,t.inputTokens=km(e.inputTokens),t.outputTokens=km(e.outputTokens),t.cachedInputTokens=km(e.cachedInputTokens),t.cacheCreationTokens=km(e.cacheCreationTokens);else{let r=km(e.totalTokens);r!==void 0&&(t.totalTokens=r,t.providerTotalTokens=r)}return t.totalTokens>0?t:void 0}function OK(e){if(!e?.length)return;let t={totalTokens:0};for(let a of e){let r=wg(a.usage);if(r){t.totalTokens+=r.totalTokens;for(let n of["inputTokens","outputTokens","cachedInputTokens","cacheCreationTokens","reasoningTokens"]){let o=r[n];o!==void 0&&(t[n]=(t[n]??0)+o)}}}return t.totalTokens>0?t:void 0}function Rz(e){return e?`${MK(e.totalTokens)} tokens`:""}function zK(e){return Rz(wg(e))}function Ix(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:void 0}function _z(e,t){return Math.round((e+t)*1e12)/1e12}function Jl(e){if(!e?.cost)return;let t={total:0},a=e.cost,r=Ix(a.total),n={input:Ix(a.input),output:Ix(a.output),cacheRead:Ix(a.cacheRead),cacheWrite:Ix(a.cacheWrite)},o=Object.values(n).reduce((i,s)=>i+(s??0),0);return t.total=_z(t.total,r??o),t.input=n.input,t.output=n.output,t.cacheRead=n.cacheRead,t.cacheWrite=n.cacheWrite,r!==void 0||o>0?t:void 0}function UK(e){let t;for(let a of e??[]){let r=Jl(a.usage);r&&(t=_z(t??0,r.total))}return t===void 0?void 0:{total:t}}function ze(e){if(!e)return"";let t=e.total>0&&e.total<.01?4:2;return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:t}).format(e.total)}function Nr(e){return e?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:4}).format(e.total):""}function z1(e,t){if(!(!e&&!t))return{...e,total:_z(e?.total??0,t?.costUsd??0)}}function jK(e,t){return ze(z1(Jl(e),t))}function BK(e){return Lx(e.cumulativeDurationMs)||"none"}function dxe(e,t){return(M1(t)??0)-(M1(e)??0)}function Ar(e){return e?.displayTitle??"Conversation"}function Dd(e){let t=e?.email?.trim()||void 0,a=e?.fullName?.trim()||void 0,r=e?.slackUserName?.trim()||void 0;return t??a??r??e?.slackUserId}function Ys(e,t={}){let a=e.channel;if(!a)return;let n=t.includeId??!0?` (${a})`:"";if(e.channelNameRedacted&&e.channelName)return`${e.channelName}${n}`;let o=e.channelName?.replace(/^#/,"");return a.startsWith("D")?`Direct Message${n}`:a.startsWith("C")?o?`#${o}${n}`:`Public Channel${n}`:a.startsWith("G")?o?.startsWith("mpdm-")?`Group DM${n}`:`Private Channel${n}`:o?`${o}${n}`:a}function fxe(e){return sxe(e)?"failed":ixe(e)?"active":"idle"}function Od(e){return lxe(e)?"active":uxe(e)?"failed":"idle"}function Tx(e){return e.eventHistory.status==="redacted"?"Transcript hidden because this conversation is not public.":e.eventHistory.status==="expired"?"Transcript expired for this conversation.":fxe(e)==="active"?"Transcript pending while this conversation is active.":"Transcript unavailable for this conversation."}function el(e){return`/people/${encodeURIComponent(e)}`}function FK(e){return`/system/locations/${encodeURIComponent(e)}`}function tl(e){return`/automations/${encodeURIComponent(e)}`}function mxe(e){let t=e?.trim().toLowerCase();if(!t)return"markdown";let r={console:"shellscript",htm:"html",js:"javascript",jsonl:"json",md:"markdown",ndjson:"json",sh:"shellscript",text:"markdown",txt:"markdown",xml:"xml",yml:"yaml"}[t]??t;return Object.hasOwn($1,r)?r:"markdown"}function HK(e){let t=e.trim();if(t)try{return JSON.stringify(JSON.parse(t),null,2)}catch{return}}function qK(e){let t=e.trim().split(/\r?\n/).filter(r=>r.trim().length>0);if(t.length<2)return;let a=[];for(let r of t){let n=HK(r);if(!n)return;a.push(n)}return a.join(`
70
+ `);case"automation":return $ge(e)}}var Pge=u.object({plugin:u.string().min(1),key:u.string().min(1)}).strict(),Dge=Pge.extend({kind:u.literal("object")});function xE(e,t){return e.map(a=>{let r=t.find(n=>n.kind===a.kind&&n.plugin===a.plugin&&n.key===a.key);return r?Ege(r):{...a,objectType:"item",title:a.key,label:a.key,url:null,warning:"Saved annotation is unavailable."}})}function Ege(e){let{createdAt:t,updatedAt:a,...r}=e;return r.kind==="object"?r:{...r,kind:"object",objectType:r.objectType??"item",title:r.label}}var Qr=u.string().trim().min(1).max(400),SE=u.string().url().max(2048),lx=u.string().datetime(),b9=u.object({provider:u.string().trim().min(1).max(100),channelName:Qr.optional()}).strict(),Mge=u.enum(["in_progress","answered","done","partial","blocked","abandoned"]),x9=u.object({repository:Qr,number:u.number().int().positive(),title:Qr.optional(),url:SE,state:ix,openedAt:lx.optional(),mergedAt:lx.optional(),closedAt:lx.optional()}).strict(),Oge=u.object({kind:u.enum(["code_change","resource","url"]),label:Qr,url:SE,status:Qr.optional()}).strict(),zge=u.object({startedAt:lx,lastActivityAt:lx,durationMs:u.number().int().nonnegative(),participants:u.array(u.object({name:Qr,messages:u.number().int().positive()}).strict()),userMessages:u.number().int().nonnegative(),assistantMessages:u.number().int().nonnegative(),toolResults:u.number().int().nonnegative(),events:u.number().int().nonnegative(),turns:u.number().int().positive().optional(),location:b9.optional(),codeChanges:u.array(x9)}).strict(),Uge=u.object({schemaVersion:u.literal(1),record:zge,summary:u.string().trim().min(1).max(600),intent:Qr,outcome:u.object({status:Mge,text:u.string().trim().min(1).max(600)}).strict(),decisions:u.array(u.object({text:Qr,by:Qr.optional(),kind:u.enum(["stated","confirmed","assumed"])}).strict()).max(20),openDecisions:u.array(u.object({text:Qr,owner:Qr.optional()}).strict()).max(20),facts:u.array(Qr).max(30),links:u.array(Oge).max(40),keywords:u.array(u.string().trim().toLowerCase().min(1).max(400)).max(12)}).strict(),jge=u.object({index:u.number().int().nonnegative(),role:u.enum(["user","assistant","tool","event"]),author:Qr.optional(),text:u.string().min(1),createdAtMs:u.number().int().nonnegative(),turnId:u.string().min(1).optional()}).strict(),Bge=u.object({label:Qr,url:SE,status:Qr.optional()}).strict(),nUe=u.object({conversationId:u.string().min(1),title:Qr.optional(),visibility:u.enum(["private","public"]),location:b9.optional(),entries:u.array(jge),codeChanges:u.array(x9),resources:u.array(Bge)}).strict();var Td=["image/png","image/jpeg","image/gif","image/webp"];var ux=3145728,wE=3,Fge=u.object({filename:u.string().trim().min(1).max(255),contentType:u.enum(Td),data:u.string().min(4).max(ux*4/3).regex(/^[A-Za-z0-9+/]*={0,2}$/).refine(e=>e.length%4===0)}).strict(),CE=u.object({id:u.string().min(1),filename:u.string().min(1),contentType:u.string().min(1),bytes:u.number().int().nonnegative()}).strict();var Hge=u.enum(["active","completed","failed"]),qge=u.enum(["api","internal","scheduler","slack"]),kE=m9,Vge=u.object({conversationId:u.string().min(1)}).strict(),rUe=u.object({attachmentId:u.string().min(1),conversationId:u.string().min(1)}).strict(),Zge=u.object({limit:u.coerce.number().int().min(1).max(1e3).default(500)}).strict(),Gge=u.object({before:u.string().min(1),limit:u.coerce.number().int().min(1).max(1e3).default(500)}).strict(),Kge=u.object({actorEmail:u.string().trim().email().transform(e=>e.toLowerCase()).optional(),codeRepositoryId:u.string().uuid().optional(),q:u.string().trim().max(200).optional(),status:u.enum(["active","archived"]).default("active")}).strict(),Wge=u.object({archived:u.boolean(),lastSeenAt:u.string().datetime()}).strict(),IE=u.object({archivedAt:u.string().datetime().nullable()}).strict(),S9=u.object({idempotencyKey:u.string().trim().min(1).max(200),message:u.string().trim().max(32e3),images:u.array(Fge).max(3).optional()}).strict().refine(e=>!!(e.message||e.images?.length),"Add a message or an image.").refine(e=>(e.images??[]).reduce((t,a)=>t+a.data.length,0)<=ux*4/3,"Images must total 3 MB or less."),Jge=S9.safeExtend({visibility:u.enum(["private","public"]).optional()}),cx=u.object({conversationId:u.string().min(1),messageId:u.string().min(1),status:u.enum(["accepted","duplicate"])}).strict(),fm=u.object({email:u.string().optional(),fullName:u.string().optional(),slackUserId:u.string().optional(),slackUserName:u.string().optional()}).strict(),w9=u.enum(["defer","interrupt"]),C9=u.object({actorIdentity:fm.optional(),createdAt:u.string().datetime(),delivery:w9,inboundMessageId:u.string().min(1),messageId:u.string().min(1),receivedAt:u.string().datetime(),role:u.literal("user"),source:u.enum(["slack","web"]),text:u.string().optional(),attachments:u.array(CE).optional(),redacted:u.literal(!0).optional()}).strict().superRefine((e,t)=>{e.text===void 0==(e.redacted!==!0)&&t.addIssue({code:"custom",message:"pending message content must be text or explicitly redacted"}),e.redacted&&(e.actorIdentity||e.attachments)&&t.addIssue({code:"custom",message:"redacted pending messages must not expose actor identity or attachments"})}),k9=u.object({authorizationUrl:u.string().url(),completionText:u.string().min(1),label:u.string().min(1)}).strict(),LE=u.object({authorization:k9.optional(),conversationId:u.string().min(1),generatedAt:u.string().datetime(),messages:u.array(C9)}).strict(),Qge=u.object({inboundMessageIds:u.array(u.string().min(1)).min(1).optional(),receivedBefore:u.string().datetime().optional()}).strict(),TE=u.object({cancelledCount:u.number().int().nonnegative(),cancelledInboundMessageIds:u.array(u.string().min(1)),conversationId:u.string().min(1)}).strict(),I9=u.object({costUsd:u.number().finite().nonnegative(),operations:u.array(u.object({costUsd:u.number().finite().nonnegative(),events:u.number().int().positive(),name:u.string().min(1),namespace:u.string().min(1)}).strict()).min(1)}).strict(),Xge=u.object({id:u.string().min(1).optional(),kind:u.enum(["scheduled","event"]),label:u.string().min(1).optional(),title:u.string().min(1).optional()}).strict().superRefine((e,t)=>{!!e.id!=!!e.label&&t.addIssue({code:"custom",message:"sourceTask id and label must both be set or both omitted"})}),Yge=n9.and(u.object({plugin:u.string().min(1),createdAt:u.string().datetime(),updatedAt:u.string().datetime()})),L9=u.object({createdAt:u.string().datetime(),role:u.enum(["assistant","user"]),text:u.string().min(1)}).strict(),tg=u.object({displayTitle:u.string(),activityPreview:L9.optional(),cumulativeDurationMs:u.number(),cumulativeUsage:kE.optional(),auxiliaryCosts:I9.optional(),conversationId:u.string(),isParticipant:u.boolean(),visibility:u.enum(["private","public"]).optional(),status:Hge,startedAt:u.string(),lastSeenAt:u.string(),lastProgressAt:u.string(),surface:qge,actorIdentity:fm.optional(),participants:u.array(fm).optional(),archivedAt:u.string().datetime().nullable().optional(),channel:u.string().optional(),channelName:u.string().optional(),channelNameRedacted:u.boolean().optional(),locationId:u.string().optional(),sentryTraceUrl:u.string().optional(),locationUrl:u.string().url().optional(),traceId:u.string().optional(),annotations:u.array(Yge).optional(),sidebarAnnotations:u.array(r9).optional(),assignedWork:u.boolean().optional(),finishedWorkAt:u.string().datetime().optional(),isPriority:u.boolean().optional(),unfinishedWork:u.boolean().optional()}).strict(),eve=u.object({type:u.literal("message"),messageId:u.string().min(1),role:u.enum(["assistant","system","user"]),source:u.enum(["slack","web"]).optional(),actorIdentity:fm.optional(),eventType:u.string().min(1).optional(),eventObjectType:Yh.optional(),explicitMention:u.boolean().optional(),trustedSummary:u.string().min(1).optional(),cards:u.array(Dge).optional(),text:u.string().optional(),attachments:u.array(CE).optional(),redacted:u.literal(!0).optional()}).strict().superRefine((e,t)=>{e.text===void 0==(e.redacted!==!0)&&t.addIssue({code:"custom",message:"message content must be text or explicitly redacted"}),e.redacted&&(e.actorIdentity||e.cards||e.attachments)&&t.addIssue({code:"custom",message:"redacted messages must not expose actor identity, cards, or attachments"})}),tve=u.object({type:u.literal("message_handled"),messageId:u.string().min(1)}).strict(),ave=u.object({toolCallId:u.string().min(1),name:u.string().min(1),status:u.enum(["running","completed","error"]),startedAt:u.string().datetime().optional(),startedSeq:u.number().int().nonnegative().optional(),input:u.unknown().optional(),output:u.unknown().optional()}).strict().superRefine((e,t)=>{e.startedAt===void 0!=(e.startedSeq===void 0)&&t.addIssue({code:"custom",message:"tool start sequence and timestamp must be provided together"})}),T9=u.object({type:u.literal("reasoning"),text:u.string().min(1).optional(),redacted:u.literal(!0).optional()}).strict().superRefine((e,t)=>{e.text===void 0==(e.redacted!==!0)&&t.addIssue({code:"custom",message:"reasoning content must be text or explicitly redacted"})}),nve=u.object({type:u.literal("tool_call"),toolCallId:u.string().min(1)}).strict(),rve=u.object({parts:u.array(u.discriminatedUnion("type",[T9,nve])).min(1)}).strict(),ove=u.object({type:u.literal("tool_calls"),calls:u.array(ave).min(1),assistant:rve.optional()}).strict().superRefine((e,t)=>{if(!e.assistant)return;let a=new Map;for(let n of e.calls)a.set(n.toolCallId,(a.get(n.toolCallId)??0)+1);let r=new Map;for(let n of e.assistant.parts)n.type==="tool_call"&&r.set(n.toolCallId,(r.get(n.toolCallId)??0)+1);(a.size!==r.size||[...a].some(([n,o])=>r.get(n)!==o))&&t.addIssue({code:"custom",path:["assistant","parts"],message:"assistant tool parts must reference every call exactly once"})}),ive=u.object({type:u.literal("assistant_message"),parts:u.array(T9)}).strict(),sve=u.discriminatedUnion("state",[u.object({type:u.literal("turn_lifecycle"),turnId:u.string().min(1),state:u.enum(["succeeded","no_reply"])}).strict(),u.object({type:u.literal("turn_lifecycle"),turnId:u.string().min(1),state:u.literal("started"),inputMessageIds:u.array(u.string().min(1)).min(1).optional()}).strict(),u.object({type:u.literal("turn_lifecycle"),turnId:u.string().min(1),state:u.literal("failed"),failureCode:Jk,failureReason:Qk.optional(),eventId:u.string().regex(/^[a-f0-9]{32}$/i).optional(),sentryEventUrl:u.string().url().optional()}).strict()]),lve=u.object({type:u.literal("turn_routed"),turnId:u.string().min(1),modelProfile:u.string().min(1),modelId:u.string().min(1),costUsd:u.number().finite().nonnegative().optional(),reasoningLevel:u.string().min(1),confidence:u.number().min(0).max(1).optional(),source:u.enum(["configured","inherited","router"])}).strict(),uve=u.object({type:u.literal("guardian_action_reviewed"),turnId:u.string().min(1),toolCallId:u.string().min(1),toolName:u.string().min(1),decision:u.enum(["allow","ask","deny"]),riskLevel:u.enum(["low","medium","high","critical"]),userAuthorization:u.enum(["high","medium","low","unknown"])}).strict(),cve=u.object({type:u.literal("turn_context"),turnId:u.string().min(1),pluginName:u.string().min(1),kind:u.string().min(1),version:u.number().int().positive(),content:u.record(u.string(),u.unknown())}).strict(),dve=u.object({type:u.literal("structured_event"),namespace:u.string().min(1),name:u.string().min(1),version:u.number().int().positive(),turnId:u.string().min(1).optional(),presentation:o9}).strict(),fve=u.object({type:u.literal("attachments_delivered"),attachments:u.array(CE).min(1)}).strict(),mve=u.object({type:u.literal("compaction"),modelProfile:u.string().min(1).optional(),modelId:u.string().min(1).optional(),summary:u.string().min(1).optional(),details:u.object({reason:u.literal("capacity"),estimatedInputTokens:u.number().int().nonnegative(),replacementInputTokens:u.number().int().nonnegative().optional(),triggerTokens:u.number().int().nonnegative(),inputLimitTokens:u.number().int().positive(),inputMessageCount:u.number().int().nonnegative(),retainedMessageCount:u.number().int().nonnegative(),summaryChars:u.number().int().nonnegative()}).strict().optional()}).strict(),pve=u.object({type:u.literal("handoff"),modelProfile:u.string().min(1),modelId:u.string().min(1),reasoningLevel:u.string().min(1).optional(),triggeringToolCallId:u.string().min(1).optional(),summary:u.string().min(1).optional()}).strict(),hve=u.object({type:u.literal("subagent"),startedSeq:u.number().int().nonnegative(),startedAt:u.string().datetime(),childConversationId:u.string().min(1),subagentKind:u.string().min(1),parentToolCallId:u.string().min(1).optional(),status:u.enum(["running","completed","error","aborted"])}).strict(),R9=u.discriminatedUnion("type",[eve,tve,ive,ove,sve,cve,dve,fve,lve,uve,mve,pve,hve]),RE=u.object({seq:u.number().int().nonnegative(),createdAt:u.string().datetime(),data:R9,model:u.object({modelId:u.string().min(1),modelProfile:u.string().min(1).optional(),reasoningLevel:u.string().min(1).optional()}).strict().optional(),modelCall:u.object({provider:u.string().min(1).optional(),api:u.string().min(1).optional(),stopReason:u.string().min(1).optional(),usage:kE.optional()}).strict().optional()}).strict(),_E=u.discriminatedUnion("status",[u.object({status:u.literal("available")}).strict(),u.object({status:u.literal("redacted"),reason:u.literal("non_public_conversation")}).strict(),u.object({status:u.literal("expired"),expiredAt:u.string().datetime()}).strict()]),gve=u.object({modelId:u.string(),usage:kE}).strict();function _9(e,t){e.eventHistory.status==="expired"&&e.events.length>0&&t.addIssue({code:"custom",path:["events"],message:"expired event history must not contain events"});for(let a=1;a<e.events.length;a+=1)e.events[a].seq<=e.events[a-1].seq&&t.addIssue({code:"custom",path:["events",a,"seq"],message:"report event sequences must be strictly increasing"});for(let[a,r]of e.events.entries())r.data.type==="message"&&(e.eventHistory.status==="redacted"&&r.data.redacted!==!0&&t.addIssue({code:"custom",path:["events",a,"data"],message:"redacted event history must redact messages"}),e.eventHistory.status==="available"&&r.data.redacted===!0&&t.addIssue({code:"custom",path:["events",a,"data"],message:"available event history must expose messages"})),e.eventHistory.status==="redacted"&&r.data.type==="tool_calls"&&r.data.calls.some(n=>n.input!==void 0||n.output!==void 0)&&t.addIssue({code:"custom",path:["events",a,"data"],message:"redacted event history must redact tool payloads"}),e.eventHistory.status==="redacted"&&r.data.type==="assistant_message"&&r.data.parts.some(n=>n.text!==void 0)&&t.addIssue({code:"custom",path:["events",a,"data"],message:"redacted event history must redact assistant messages"}),e.eventHistory.status==="available"&&r.data.type==="assistant_message"&&r.data.parts.some(n=>n.redacted===!0)&&t.addIssue({code:"custom",path:["events",a,"data"],message:"available event history must expose reasoning"}),r.data.type==="tool_calls"&&(e.eventHistory.status==="redacted"&&r.data.assistant?.parts.some(n=>n.type==="reasoning"&&n.text!==void 0)||e.eventHistory.status==="available"&&r.data.assistant?.parts.some(n=>n.type==="reasoning"&&n.redacted===!0))&&t.addIssue({code:"custom",path:["events",a,"data","assistant"],message:"assistant reasoning must match event history visibility"})}var vve=u.object({messageId:u.string().min(1).max(500),idempotencyKey:u.string().trim().min(1).max(200)}).strict(),NE=u.object({conversationId:u.string()}).strict(),AE=tg.extend({canFork:u.boolean().optional(),forkedFromConversationId:u.string().optional(),forkedFromTitle:u.string().optional(),forks:u.array(u.string()).optional(),brief:u.object({content:Uge,updatedAt:u.string().datetime(),version:u.number().int().positive()}).strict().optional(),modelUsage:u.array(gve).optional(),events:u.array(RE),eventHistory:_E,previousCursor:u.string().min(1).optional(),generatedAt:u.string(),sentryConversationUrl:u.string().optional(),sourceTask:Xge.optional()}).strict().superRefine(_9),$E=u.object({events:u.array(RE),eventHistory:_E,previousCursor:u.string().min(1).optional(),generatedAt:u.string()}).strict().superRefine(_9),Xk=u.object({conversations:u.array(tg),source:u.literal("conversation_index"),generatedAt:u.string()}).strict(),mm=u.object({active:u.number(),conversations:u.number(),durationMs:u.number(),failed:u.number(),label:u.string(),costUsd:u.number().optional(),tokens:u.number().optional()}).strict(),N9=u.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/),vE=u.object({cachedInputTokens:u.number().optional(),cacheCreationTokens:u.number().optional(),conversations:u.number(),costUsd:u.number().optional(),date:N9,durationMs:u.number(),inputTokens:u.number().optional(),tokens:u.number().optional()}).strict(),yE=u.object({allow:u.number(),ask:u.number(),costUsd:u.number().optional(),date:N9,deny:u.number(),requests:u.number()}).strict(),yve=u.object({allow:u.number(),ask:u.number(),costUsd:u.number().optional(),deny:u.number(),metricDays:u.array(yE),metricHours:u.array(yE).optional(),metricSixHours:u.array(yE).optional(),requests:u.number()}).strict(),PE=u.object({active:u.number(),cachedInputTokens:u.number().optional(),cacheCreationTokens:u.number().optional(),conversations:u.number(),durationMs:u.number(),failed:u.number(),generatedAt:u.string(),guardian:yve,metricDays:u.array(vE),metricHours:u.array(vE).optional(),metricSixHours:u.array(vE).optional(),locations:u.array(mm),actors:u.array(mm),source:u.literal("conversation_index"),costUsd:u.number().optional(),inputTokens:u.number().optional(),tokens:u.number().optional(),windowEnd:u.string(),windowStart:u.string()}).strict();var bve=u.enum(["current_conversation","task_creator"]).describe("Where to send the message. Use current_conversation for posts, digests, summaries, and channel reminders. Use task_creator only when the user asks for a direct reminder or notification."),xve=u.object({action:u.literal("send_message"),destination:bve}).strict();var E9=u.string().regex(/^\d{4}-\d{2}-\d{2}$/,"Use a local date in YYYY-MM-DD format."),M9=u.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/,"Use local time in HH:MM format."),O9=u.string().min(1).max(80).describe("IANA timezone the user asked for, for example America/New_York. Omit or use null to use the creator's timezone on create, or to keep the saved timezone on update. Do not guess it from office locations.").nullable().optional(),Sve=u.enum(["sunday","monday","tuesday","wednesday","thursday","friday","saturday"]),wve=u.object({kind:u.literal("one_off").describe("A schedule that runs once."),timezone:O9,timing:u.discriminatedUnion("type",[u.object({type:u.literal("after").describe("Run after a relative delay from the server clock."),value:u.number().int().positive().max(1e5),unit:u.enum(["second","minute","hour","day","week"])}).strict(),u.object({type:u.literal("at").describe("Run at an explicit local calendar date and time."),date:E9.describe("Requested local calendar date in YYYY-MM-DD format."),time:M9.describe("Requested local wall-clock time in HH:MM format.")}).strict()]).describe("Relative delay or explicit local time for the one-off run.")}).strict(),Cve=u.object({kind:u.literal("recurring").describe("A repeating calendar schedule."),frequency:u.enum(["daily","weekly","monthly","yearly"]).describe("Recurring tasks can run at most once per day."),interval:u.number().int().positive().max(365).describe("Repeat every N frequency units. Defaults to 1.").nullable().optional(),time:M9.describe("Local wall-clock time for each occurrence in HH:MM format."),weekdays:u.array(Sve).min(1).max(7).describe("Required for weekly schedules.").nullable().optional(),dayOfMonth:u.number().int().min(1).max(31).describe("Required for monthly and yearly schedules.").nullable().optional(),month:u.number().int().min(1).max(12).describe("Required for yearly schedules, where January is 1.").nullable().optional(),startDate:E9.describe("Optional local calendar date that anchors the recurrence. Omit to start with the next matching occurrence.").nullable().optional(),timezone:O9}).strict().superRefine((e,t)=>{e.frequency==="weekly"&&e.weekdays==null&&t.addIssue({code:"custom",message:"Weekly schedules require weekdays.",path:["weekdays"]}),(e.frequency==="monthly"||e.frequency==="yearly")&&e.dayOfMonth==null&&t.addIssue({code:"custom",message:`${e.frequency} schedules require dayOfMonth.`,path:["dayOfMonth"]}),e.frequency==="yearly"&&e.month==null&&t.addIssue({code:"custom",message:"Yearly schedules require month.",path:["month"]}),e.frequency!=="weekly"&&e.weekdays!=null&&t.addIssue({code:"custom",message:"weekdays applies only to weekly schedules.",path:["weekdays"]}),e.frequency!=="monthly"&&e.frequency!=="yearly"&&e.dayOfMonth!=null&&t.addIssue({code:"custom",message:"dayOfMonth applies only to monthly or yearly schedules.",path:["dayOfMonth"]}),e.frequency!=="yearly"&&e.month!=null&&t.addIssue({code:"custom",message:"month applies only to yearly schedules.",path:["month"]})}),z9=u.union([wve,Cve]);var U9=u.object({slackUserId:Wk,fullName:u.string().optional(),userName:u.string().optional()}).strict(),EE=u.object({events:u.array(Qu).min(1),label:u.string().min(1),match:pE.optional(),namespace:u.string().min(1),identifier:u.string().min(1).max(300),resourceType:u.string().min(1)}).strict(),j9=eg.omit({threadTs:!0}),kve=sx.extend({destination:j9}),Ive=u.object({id:u.string().min(1),createdAtMs:u.number().finite(),createdBy:U9,credentialMode:u.enum(["system","creator"]),destination:j9,destinationVisibility:fE,outcomes:u.array(kve).max(5),task:u.object({text:u.string().min(1)}).strict(),trigger:EE}).strict(),Lve=u.string().trim().min(1).max(60),B9=u.string().trim().min(1).max(4e3),lUe=B9.describe("Work to perform when the Automation runs. It runs later without this conversation, so write it to stand alone: name each person with their Slack mention, such as <@U123>, instead of me, my, or you. Preserve the user's scope, targets, and constraints. Do not add permissions or side effects the user did not request."),F9=u.object({title:Lve.optional(),instruction:B9.optional(),credentialMode:u.enum(["system","creator"]).optional(),outcomes:u.array(u.union([xve,sx])).max(5).optional()}),Tve=F9.extend({schedule:z9.optional(),status:u.enum(["active","blocked"]).optional()}).strict(),Rve=F9.extend({trigger:EE.extend({identifier:u.string().trim().min(1).max(300),label:u.string().trim().min(1).max(500)}).optional()}).strict(),_ve=u.enum(["active","blocked","paused","completed","deleted"]),Nve=u.enum(["system","creator"]),Ave=u.enum(["pending","running","completed","failed","blocked","skipped"]),$ve=u.object({slackUserId:Wk,fullName:u.string().optional(),userName:u.string().optional()}).strict(),Pve=u.object({dayOfMonth:u.number().optional(),frequency:u.enum(["daily","weekly","monthly","yearly"]),interval:u.number(),month:u.number().optional(),startDate:u.string(),time:u.object({hour:u.number(),minute:u.number()}).strict(),weekdays:u.array(u.number()).optional()}).strict(),Dve=u.object({description:u.string(),kind:u.enum(["one_off","recurring"]),recurrence:Pve.optional(),timezone:u.string()}).strict(),Eve=u.object({platform:u.literal("system"),name:u.string()}).strict(),H9=eg.omit({threadTs:!0}),Mve=u.object({action:u.literal("send_message"),destination:H9}).strict(),e1=u.object({id:u.string(),conversationAccess:u.object({audience:u.enum(["direct","group","channel"]),visibility:u.enum(["private","public"])}).strict(),createdAtMs:u.number(),createdBy:$ve,creatorIdentityId:u.string(),credentialMode:Nve,destination:H9,executionActor:Eve.optional(),lastRunAtMs:u.number().optional(),nextRunAtMs:u.number().optional(),originalRequest:u.string().optional(),runNowAtMs:u.number().optional(),schedule:Dve,status:_ve,statusReason:u.string().optional(),outcomes:u.array(Mve).max(5),task:u.object({text:u.string()}).strict(),title:u.string().optional(),updatedAtMs:u.number()}).strict(),uUe=u.object({id:u.string(),attempt:u.number(),claimedAtMs:u.number(),completedAtMs:u.number().optional(),dispatchId:u.string().optional(),errorMessage:u.string().optional(),resultMessageTs:u.string().optional(),scheduledForMs:u.number(),startedAtMs:u.number().optional(),status:Ave,taskId:u.string()}).strict(),cUe=Object.freeze({platform:"system",name:"scheduled-automation"}),Ove=u.object({channelId:u.string().min(1),label:u.string().min(1),teamId:u.string().min(1),visibility:u.enum(["private","public"])}).strict(),q9=u.object({1:u.number().int().nonnegative(),7:u.number().int().nonnegative(),30:u.number().int().nonnegative(),90:u.number().int().nonnegative()}).strict(),V9=u.object({credentialMode:u.enum(["creator","system"]),createdAt:u.string().datetime(),createdBy:u.string().min(1),createdByAvatarUrl:u.string().url().optional(),createdByEmail:u.string().trim().email().optional(),destination:Ove,id:u.string().min(1),instruction:u.string().min(1),lastConversationId:u.string().min(1).optional(),lastRunAt:u.string().datetime().optional(),lastRunStatus:u.enum(["blocked","completed","failed"]).optional(),ownedByViewer:u.boolean(),runs:q9,outcomes:u.array(sx).max(5),title:u.string().min(1),totalRuns:u.number().int().nonnegative()}),Z9=V9.extend({kind:u.literal("scheduled"),nextRunAt:u.string().datetime().optional(),schedule:u.string().min(1),timezone:u.string().min(1),statusReason:u.string().optional(),status:u.enum(["active","blocked","paused","completed"])}).strict(),G9=V9.extend({events:u.array(u.string().min(1)).min(1),match:pE.optional(),kind:u.literal("event"),resource:u.string().min(1),source:u.string().min(1),triggerAvailable:u.boolean(),status:u.enum(["active","paused"])}).strict(),fx=u.discriminatedUnion("kind",[Z9,G9]),K9=u.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/),DE=u.object({costUsd:u.number().finite().nonnegative(),date:K9,event:u.number().int().nonnegative(),scheduled:u.number().int().nonnegative()}).strict(),t1=u.object({q:u.string().trim().max(200).optional(),scope:u.enum(["all","mine","public","attention"]).default("all"),type:u.enum(["all","scheduled","event"]).default("all"),state:u.enum(["all","active","blocked","paused","completed","unavailable"]).default("all"),creator:u.string().max(300).optional(),destination:u.string().max(300).optional(),sort:u.enum(["newest","oldest","title"]).default("newest"),page:u.coerce.number().int().min(1).max(1e6).default(1),pageSize:u.coerce.number().int().min(1).max(100).default(25)}).strict(),A9=u.object({value:u.string(),label:u.string()}).strict(),ME=u.object({executionDays:u.array(DE),executionHours:u.array(DE).optional(),executionSixHours:u.array(DE).optional(),automations:u.array(fx),total:u.number().int().nonnegative(),page:u.number().int().positive(),pageSize:u.number().int().positive(),counts:u.object({all:u.number().int().nonnegative(),mine:u.number().int().nonnegative(),public:u.number().int().nonnegative(),private:u.number().int().nonnegative()}).strict(),creators:u.array(A9),destinations:u.array(A9)}).strict(),W9=u.object({id:u.string().min(1),kind:u.enum(["scheduled","event"])}).strict(),J9=u.enum(["blocked","completed","failed"]),OE=u.object({conversationId:u.string().min(1).optional(),costUsd:u.number().finite().nonnegative().optional(),durationMs:u.number().finite().nonnegative().optional(),executedAt:u.string().datetime(),executionId:u.string().min(1),status:J9,title:u.string().min(1).optional(),totalTokens:u.number().int().nonnegative().optional()}).strict(),Yk=u.object({blocked:u.number().int().nonnegative(),completed:u.number().int().nonnegative(),date:K9,failed:u.number().int().nonnegative()}).strict(),zE=u.object({executionDays:u.array(Yk),executionHours:u.array(Yk).optional(),executionSixHours:u.array(Yk).optional(),executions:u.array(OE),automation:fx,truncated:u.boolean()}).strict(),Q9=OE.extend({kind:u.enum(["scheduled","event"]),automationId:u.string().min(1),automationTitle:u.string().min(1)}).strict(),UE=u.object({runs:u.array(Q9),truncated:u.boolean()}).strict(),$9={title:u.string().nullable(),instruction:u.string()},P9={version:u.number().int().positive(),createdAt:u.string().datetime(),editedBy:U9.nullable()},X9=u.discriminatedUnion("kind",[u.object({...P9,kind:u.literal("scheduled"),definition:e1.pick({credentialMode:!0,destination:!0,outcomes:!0,schedule:!0}).extend($9).strict()}).strict(),u.object({...P9,kind:u.literal("event"),definition:Ive.pick({credentialMode:!0,destination:!0,outcomes:!0,trigger:!0}).extend($9).strict()}).strict()]),jE=u.object({versions:u.array(X9),activeVersion:u.number().int().positive().nullable(),truncated:u.boolean()}).strict(),zve=W9.extend({version:u.coerce.number().int().positive()}).strict(),dx=u.string().regex(/^[a-f0-9]{64}$/),Uve=u.object({revision:dx}).strict(),dUe=u.object({action:u.enum(["pause","resume"]),revision:dx}).strict(),D9=e1.pick({destination:!0,createdBy:!0}).extend({id:u.string().min(1),revision:dx,title:u.string().nullable(),instruction:u.string(),credentialMode:u.enum(["system","creator"]),outcomes:u.array(sx).max(5),ownedByViewer:u.boolean()}),ds=u.discriminatedUnion("kind",[D9.merge(e1.pick({schedule:!0})).extend({kind:u.literal("scheduled"),nextRunAtMs:u.number().optional(),status:u.enum(["active","blocked","paused","completed"])}).strict(),D9.extend({kind:u.literal("event"),trigger:EE,triggerAvailable:u.boolean(),status:u.enum(["active","paused"])}).strict()]),BE=u.discriminatedUnion("kind",[Tve.omit({status:!0}).extend({kind:u.literal("scheduled"),revision:dx}).strict(),Rve.extend({kind:u.literal("event"),revision:dx}).strict()]),jve=u.object({error:u.string(),code:u.enum(["invalid_edit","conflict","not_found"]),fields:u.record(u.string(),u.array(u.string())).optional()}).strict(),FE=u.array(hE.safeExtend({namespace:u.string()})),HE=z9,qE=e1.pick({schedule:!0}).extend({nextRunAtMs:u.number()}).strict();var Bve=u.object({status:u.literal("ok"),service:u.string(),timestamp:u.string()}).strict(),Y9=u.object({configKeys:u.array(u.string()),description:u.string(),displayName:u.string(),name:u.string()}).strict(),VE=u.array(Y9),ZE=u.object({name:u.string(),pluginProvider:u.string().optional()}).strict(),GE=u.array(ZE),eZ=u.object({dir:u.string(),hasMigrationsDir:u.boolean(),hasSkillsDir:u.boolean(),packageName:u.string()}).strict(),tZ=u.object({packageNames:u.array(u.string()),packages:u.array(eZ),manifestRoots:u.array(u.string()),skillRoots:u.array(u.string()),tracingIncludes:u.array(u.string())}).strict(),Fve=u.object({cwd:u.string(),homeDir:u.string(),descriptionText:u.string().optional(),providers:u.array(u.string()),skills:u.array(ZE),packagedContent:tZ}).strict(),KE=u.enum(["danger","good","neutral","warning"]),Hve=u.object({label:u.string(),tone:KE.optional(),value:u.string()}).strict(),qve=u.object({key:u.string(),label:u.string()}).strict(),Vve=u.object({id:u.string(),tone:KE.optional(),values:u.record(u.string(),u.string())}).strict(),Zve=u.object({fields:u.array(qve).optional(),emptyText:u.string().optional(),records:u.array(Vve).optional(),title:u.string()}).strict(),Gve=u.object({categories:u.array(u.object({id:u.string().min(1),label:u.string().min(1),values:u.record(u.string(),u.number().finite())}).strict()).max(100),description:u.string().optional(),emptyText:u.string().optional(),id:u.string().min(1),series:u.array(u.object({format:u.literal("usd").optional(),key:u.string().min(1),label:u.string().min(1),tone:KE.optional()}).strict()).min(1).max(8),timeRangeDays:u.array(u.union([u.literal(1),u.literal(7),u.literal(30),u.literal(90)])).min(1).max(4).optional(),title:u.string().min(1),type:u.literal("bar_chart")}).strict(),aZ=u.object({generatedAt:u.string().optional(),metrics:u.array(Hve).optional(),recordSets:u.array(Zve).optional(),title:u.string().optional(),pluginName:u.string(),widgets:u.array(Gve).max(12).optional()}).strict(),a1=u.object({generatedAt:u.string(),reports:u.array(aZ),source:u.literal("plugins")}).strict(),nZ=36e5,pUe=6*nZ,hUe=24*nZ;async function WE(e){let t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(`${e.conversationId}\0${e.idempotencyKey}`));return`api-msg:${Array.from(new Uint8Array(t),a=>a.toString(16).padStart(2,"0")).join("").slice(0,24)}`}var D=Symbol.for("drizzle:entityKind");function Bn(e,t){if(!e||typeof e!="object")return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,D))throw new Error(`Class "${t.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let a=Object.getPrototypeOf(e).constructor;if(a)for(;a;){if(D in a&&a[D]===t[D])return!0;a=Object.getPrototypeOf(a)}return!1}var pm=class{constructor(t,a){this.table=t,this.config=a,this.name=a.name,this.keyAsName=a.keyAsName,this.notNull=a.notNull,this.default=a.default,this.defaultFn=a.defaultFn,this.onUpdateFn=a.onUpdateFn,this.hasDefault=a.hasDefault,this.primary=a.primaryKey,this.isUnique=a.isUnique,this.uniqueName=a.uniqueName,this.uniqueType=a.uniqueType,this.dataType=a.dataType,this.columnType=a.columnType,this.generated=a.generated,this.generatedIdentity=a.generatedIdentity}static[D]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue(t){return t}mapToDriverValue(t){return t}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}};var n1=class{static[D]="ColumnBuilder";config;constructor(t,a,r){this.config={name:t,keyAsName:t==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:a,columnType:r,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(t){return this.config.default=t,this.config.hasDefault=!0,this}$defaultFn(t){return this.config.defaultFn=t,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(t){return this.config.onUpdateFn=t,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(t){this.config.name===""&&(this.config.name=t)}};var Xu=Symbol.for("drizzle:Name");var r1=class{static[D]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor(t,a){this.reference=()=>{let{name:r,columns:n,foreignColumns:o}=t();return{name:r,columns:n,foreignTable:o[0].table,foreignColumns:o}},a&&(this._onUpdate=a.onUpdate,this._onDelete=a.onDelete)}onUpdate(t){return this._onUpdate=t===void 0?"no action":t,this}onDelete(t){return this._onDelete=t===void 0?"no action":t,this}build(t){return new JE(t,this)}},JE=class{constructor(t,a){this.table=t,this.reference=a.reference,this.onUpdate=a._onUpdate,this.onDelete=a._onDelete}static[D]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:t,columns:a,foreignColumns:r}=this.reference(),n=a.map(s=>s.name),o=r.map(s=>s.name),i=[this.table[Xu],...n,r[0].table[Xu],...o];return t??`${i.join("_")}_fk`}};function o1(e,...t){return e(...t)}function YE(e,t){return`${e[Xu]}_${t.join("_")}_unique`}var QE=class{constructor(t,a){this.name=a,this.columns=t}static[D]="PgUniqueConstraintBuilder";columns;nullsNotDistinctConfig=!1;nullsNotDistinct(){return this.nullsNotDistinctConfig=!0,this}build(t){return new XE(t,this.columns,this.nullsNotDistinctConfig,this.name)}},rZ=class{static[D]="PgUniqueOnConstraintBuilder";name;constructor(t){this.name=t}on(...t){return new QE(t,this.name)}},XE=class{constructor(t,a,r,n){this.table=t,this.columns=a,this.name=n??YE(this.table,this.columns.map(o=>o.name)),this.nullsNotDistinct=r}static[D]="PgUniqueConstraint";columns;name;nullsNotDistinct=!1;getName(){return this.name}};function oZ(e,t,a){for(let r=t;r<e.length;r++){let n=e[r];if(n==="\\"){r++;continue}if(n==='"')return[e.slice(t,r).replace(/\\/g,""),r+1];if(!a&&(n===","||n==="}"))return[e.slice(t,r).replace(/\\/g,""),r]}return[e.slice(t).replace(/\\/g,""),e.length]}function iZ(e,t=0){let a=[],r=t,n=!1;for(;r<e.length;){let o=e[r];if(o===","){(n||r===t)&&a.push(""),n=!0,r++;continue}if(n=!1,o==="\\"){r+=2;continue}if(o==='"'){let[l,c]=oZ(e,r+1,!0);a.push(l),r=c;continue}if(o==="}")return[a,r+1];if(o==="{"){let[l,c]=iZ(e,r+1);a.push(l),r=c;continue}let[i,s]=oZ(e,r,!1);a.push(i),r=s}return[a,r]}function sZ(e){let[t]=iZ(e,1);return t}function eM(e){return`{${e.map(t=>Array.isArray(t)?eM(t):typeof t=="string"?`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`${t}`).join(",")}}`}var de=class extends n1{foreignKeyConfigs=[];static[D]="PgColumnBuilder";array(t){return new aM(this.config.name,this,t)}references(t,a={}){return this.foreignKeyConfigs.push({ref:t,actions:a}),this}unique(t,a){return this.config.isUnique=!0,this.config.uniqueName=t,this.config.uniqueType=a?.nulls,this}generatedAlwaysAs(t){return this.config.generated={as:t,type:"always",mode:"stored"},this}buildForeignKeys(t,a){return this.foreignKeyConfigs.map(({ref:r,actions:n})=>o1((o,i)=>{let s=new r1(()=>{let l=o();return{columns:[t],foreignColumns:[l]}});return i.onUpdate&&s.onUpdate(i.onUpdate),i.onDelete&&s.onDelete(i.onDelete),s.build(a)},r,n))}buildExtraConfigColumn(t){return new tM(t,this.config)}},ne=class extends pm{constructor(t,a){a.uniqueName||(a.uniqueName=YE(t,[a.name])),super(t,a),this.table=t}static[D]="PgColumn"},tM=class extends ne{static[D]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op(t){return this.indexConfig.opClass=t,this}},ag=class{static[D]="IndexedColumn";constructor(t,a,r,n){this.name=t,this.keyAsName=a,this.type=r,this.indexConfig=n}name;keyAsName;type;indexConfig},aM=class extends de{static[D]="PgArrayBuilder";constructor(t,a,r){super(t,"array","PgArray"),this.config.baseBuilder=a,this.config.size=r}build(t){let a=this.config.baseBuilder.build(t);return new nM(t,this.config,a)}},nM=class e extends ne{constructor(t,a,r,n){super(t,a),this.baseColumn=r,this.range=n,this.size=a.size}size;static[D]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size=="number"?this.size:""}]`}mapFromDriverValue(t){return typeof t=="string"&&(t=sZ(t)),t.map(a=>this.baseColumn.mapFromDriverValue(a))}mapToDriverValue(t,a=!1){let r=t.map(n=>n===null?null:Bn(this.baseColumn,e)?this.baseColumn.mapToDriverValue(n,!0):this.baseColumn.mapToDriverValue(n));return a?r:eM(r)}};var lZ=class extends de{static[D]="PgEnumObjectColumnBuilder";constructor(t,a){super(t,"string","PgEnumObjectColumn"),this.config.enum=a}build(t){return new rM(t,this.config)}},rM=class extends ne{static[D]="PgEnumObjectColumn";enum;enumValues=this.config.enum.enumValues;constructor(t,a){super(t,a),this.enum=a.enum}getSQLType(){return this.enum.enumName}},uZ=Symbol.for("drizzle:isPgEnum");function dZ(e){return!!e&&typeof e=="function"&&uZ in e&&e[uZ]===!0}var cZ=class extends de{static[D]="PgEnumColumnBuilder";constructor(t,a){super(t,"string","PgEnumColumn"),this.config.enum=a}build(t){return new oM(t,this.config)}},oM=class extends ne{static[D]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor(t,a){super(t,a),this.enum=a.enum}getSQLType(){return this.enum.enumName}};var ng=class{static[D]="Subquery";constructor(t,a,r,n=!1,o=[]){this._={brand:"Subquery",sql:t,selectedFields:a,alias:r,isWith:n,usedTables:o}}},fZ=class extends ng{static[D]="WithSubquery"};var mZ="0.45.2";var iM,sM,pZ={startActiveSpan(e,t){return iM?(sM||(sM=iM.trace.getTracer("drizzle-orm",mZ)),o1((a,r)=>r.startActiveSpan(e,n=>{try{return t(n)}catch(o){throw n.setStatus({code:a.SpanStatusCode.ERROR,message:o instanceof Error?o.message:"Unknown error"}),o}finally{n.end()}}),iM,sM)):t()}};var rg=Symbol.for("drizzle:ViewBaseConfig");var lM=Symbol.for("drizzle:Schema"),hZ=Symbol.for("drizzle:Columns"),gZ=Symbol.for("drizzle:ExtraConfigColumns"),uM=Symbol.for("drizzle:OriginalName"),cM=Symbol.for("drizzle:BaseName"),mx=Symbol.for("drizzle:IsAlias"),vZ=Symbol.for("drizzle:ExtraConfigBuilder"),Kve=Symbol.for("drizzle:IsDrizzleTable"),kn=class{static[D]="Table";static Symbol={Name:Xu,Schema:lM,OriginalName:uM,Columns:hZ,ExtraConfigColumns:gZ,BaseName:cM,IsAlias:mx,ExtraConfigBuilder:vZ};[Xu];[uM];[lM];[hZ];[gZ];[cM];[mx]=!1;[Kve]=!0;[vZ]=void 0;constructor(t,a,r){this[Xu]=this[uM]=t,this[lM]=a,this[cM]=r}};var yZ=class{static[D]="FakePrimitiveParam"};function Wve(e){return e!=null&&typeof e.getSQL=="function"}function Jve(e){let t={sql:"",params:[]};for(let a of e)t.sql+=a.sql,t.params.push(...a.params),a.typings?.length&&(t.typings||(t.typings=[]),t.typings.push(...a.typings));return t}var Ri=class{static[D]="StringChunk";value;constructor(t){this.value=Array.isArray(t)?t:[t]}getSQL(){return new In([this])}},In=class e{constructor(t){this.queryChunks=t;for(let a of t)if(Bn(a,kn)){let r=a[kn.Symbol.Schema];this.usedTables.push(r===void 0?a[kn.Symbol.Name]:r+"."+a[kn.Symbol.Name])}}static[D]="SQL";decoder=bZ;shouldInlineParams=!1;usedTables=[];append(t){return this.queryChunks.push(...t.queryChunks),this}toQuery(t){return pZ.startActiveSpan("drizzle.buildSQL",a=>{let r=this.buildQueryFromSourceParams(this.queryChunks,t);return a?.setAttributes({"drizzle.query.text":r.sql,"drizzle.query.params":JSON.stringify(r.params)}),r})}buildQueryFromSourceParams(t,a){let r=Object.assign({},a,{inlineParams:a.inlineParams||this.shouldInlineParams,paramStartIndex:a.paramStartIndex||{value:0}}),{casing:n,escapeName:o,escapeParam:i,prepareTyping:s,inlineParams:l,paramStartIndex:c}=r;return Jve(t.map(d=>{if(Bn(d,Ri))return{sql:d.value.join(""),params:[]};if(Bn(d,px))return{sql:o(d.value),params:[]};if(d===void 0)return{sql:"",params:[]};if(Array.isArray(d)){let f=[new Ri("(")];for(let[m,p]of d.entries())f.push(p),m<d.length-1&&f.push(new Ri(", "));return f.push(new Ri(")")),this.buildQueryFromSourceParams(f,r)}if(Bn(d,e))return this.buildQueryFromSourceParams(d.queryChunks,{...r,inlineParams:l||d.shouldInlineParams});if(Bn(d,kn)){let f=d[kn.Symbol.Schema],m=d[kn.Symbol.Name];return{sql:f===void 0||d[mx]?o(m):o(f)+"."+o(m),params:[]}}if(Bn(d,pm)){let f=n.getColumnCasing(d);if(a.invokeSource==="indexes")return{sql:o(f),params:[]};let m=d.table[kn.Symbol.Schema];return{sql:d.table[mx]||m===void 0?o(d.table[kn.Symbol.Name])+"."+o(f):o(m)+"."+o(d.table[kn.Symbol.Name])+"."+o(f),params:[]}}if(Bn(d,dM)){let f=d[rg].schema,m=d[rg].name;return{sql:f===void 0||d[rg].isAlias?o(m):o(f)+"."+o(m),params:[]}}if(Bn(d,i1)){if(Bn(d.value,hx))return{sql:i(c.value++,d),params:[d],typings:["none"]};let f=d.value===null?null:d.encoder.mapToDriverValue(d.value);if(Bn(f,e))return this.buildQueryFromSourceParams([f],r);if(l)return{sql:this.mapInlineParam(f,r),params:[]};let m=["none"];return s&&(m=[s(d.encoder)]),{sql:i(c.value++,f),params:[f],typings:m}}return Bn(d,hx)?{sql:i(c.value++,d),params:[d],typings:["none"]}:Bn(d,e.Aliased)&&d.fieldAlias!==void 0?{sql:o(d.fieldAlias),params:[]}:Bn(d,ng)?d._.isWith?{sql:o(d._.alias),params:[]}:this.buildQueryFromSourceParams([new Ri("("),d._.sql,new Ri(") "),new px(d._.alias)],r):dZ(d)?d.schema?{sql:o(d.schema)+"."+o(d.enumName),params:[]}:{sql:o(d.enumName),params:[]}:Wve(d)?d.shouldOmitSQLParens?.()?this.buildQueryFromSourceParams([d.getSQL()],r):this.buildQueryFromSourceParams([new Ri("("),d.getSQL(),new Ri(")")],r):l?{sql:this.mapInlineParam(d,r),params:[]}:{sql:i(c.value++,d),params:[d],typings:["none"]}}))}mapInlineParam(t,{escapeString:a}){if(t===null)return"null";if(typeof t=="number"||typeof t=="boolean")return t.toString();if(typeof t=="string")return a(t);if(typeof t=="object"){let r=t.toString();return a(r==="[object Object]"?JSON.stringify(t):r)}throw new Error("Unexpected param value: "+t)}getSQL(){return this}as(t){return t===void 0?this:new e.Aliased(this,t)}mapWith(t){return this.decoder=typeof t=="function"?{mapFromDriverValue:t}:t,this}inlineParams(){return this.shouldInlineParams=!0,this}if(t){return t?this:void 0}},px=class{constructor(t){this.value=t}static[D]="Name";brand;getSQL(){return new In([this])}};var bZ={mapFromDriverValue:e=>e},xZ={mapToDriverValue:e=>e},o5e={...bZ,...xZ},i1=class{constructor(t,a=xZ){this.value=t,this.encoder=a}static[D]="Param";brand;getSQL(){return new In([this])}};function og(e,...t){let a=[];(t.length>0||e.length>0&&e[0]!=="")&&a.push(new Ri(e[0]));for(let[r,n]of t.entries())a.push(n,new Ri(e[r+1]));return new In(a)}(e=>{function t(){return new In([])}e.empty=t;function a(l){return new In(l)}e.fromList=a;function r(l){return new In([new Ri(l)])}e.raw=r;function n(l,c){let d=[];for(let[f,m]of l.entries())f>0&&c!==void 0&&d.push(c),d.push(m);return new In(d)}e.join=n;function o(l){return new px(l)}e.identifier=o;function i(l){return new hx(l)}e.placeholder=i;function s(l,c){return new i1(l,c)}e.param=s})(og||(og={}));(e=>{class t{constructor(r,n){this.sql=r,this.fieldAlias=n}static[D]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new t(this.sql,this.fieldAlias)}}e.Aliased=t})(In||(In={}));var hx=class{constructor(t){this.name=t}static[D]="Placeholder";getSQL(){return new In([this])}};var Qve=Symbol.for("drizzle:IsDrizzleView"),dM=class{static[D]="View";[rg];[Qve]=!0;constructor({name:t,schema:a,selectedFields:r,query:n}){this[rg]={name:t,originalName:t,schema:a,selectedFields:r,query:n,isExisting:!n,isAlias:!1}}getSQL(){return new In([this])}};pm.prototype.getSQL=function(){return new In([this])};kn.prototype.getSQL=function(){return new In([this])};ng.prototype.getSQL=function(){return new In([this])};function _t(e,t){return{name:typeof e=="string"&&e.length>0?e:"",config:typeof e=="object"?e:t}}var s5e=typeof TextDecoder>"u"?null:new TextDecoder;var Yu=class extends de{static[D]="PgIntColumnBaseBuilder";generatedAlwaysAsIdentity(t){if(t){let{name:a,...r}=t;this.config.generatedIdentity={type:"always",sequenceName:a,sequenceOptions:r}}else this.config.generatedIdentity={type:"always"};return this.config.hasDefault=!0,this.config.notNull=!0,this}generatedByDefaultAsIdentity(t){if(t){let{name:a,...r}=t;this.config.generatedIdentity={type:"byDefault",sequenceName:a,sequenceOptions:r}}else this.config.generatedIdentity={type:"byDefault"};return this.config.hasDefault=!0,this.config.notNull=!0,this}};var fM=class extends Yu{static[D]="PgBigInt53Builder";constructor(t){super(t,"number","PgBigInt53")}build(t){return new mM(t,this.config)}},mM=class extends ne{static[D]="PgBigInt53";getSQLType(){return"bigint"}mapFromDriverValue(t){return typeof t=="number"?t:Number(t)}},pM=class extends Yu{static[D]="PgBigInt64Builder";constructor(t){super(t,"bigint","PgBigInt64")}build(t){return new hM(t,this.config)}},hM=class extends ne{static[D]="PgBigInt64";getSQLType(){return"bigint"}mapFromDriverValue(t){return BigInt(t)}};function SZ(e,t){let{name:a,config:r}=_t(e,t);return r.mode==="number"?new fM(a):new pM(a)}var gM=class extends de{static[D]="PgBigSerial53Builder";constructor(t){super(t,"number","PgBigSerial53"),this.config.hasDefault=!0,this.config.notNull=!0}build(t){return new vM(t,this.config)}},vM=class extends ne{static[D]="PgBigSerial53";getSQLType(){return"bigserial"}mapFromDriverValue(t){return typeof t=="number"?t:Number(t)}},yM=class extends de{static[D]="PgBigSerial64Builder";constructor(t){super(t,"bigint","PgBigSerial64"),this.config.hasDefault=!0}build(t){return new bM(t,this.config)}},bM=class extends ne{static[D]="PgBigSerial64";getSQLType(){return"bigserial"}mapFromDriverValue(t){return BigInt(t)}};function wZ(e,t){let{name:a,config:r}=_t(e,t);return r.mode==="number"?new gM(a):new yM(a)}var xM=class extends de{static[D]="PgBooleanBuilder";constructor(t){super(t,"boolean","PgBoolean")}build(t){return new SM(t,this.config)}},SM=class extends ne{static[D]="PgBoolean";getSQLType(){return"boolean"}};function CZ(e){return new xM(e??"")}var wM=class extends de{static[D]="PgCharBuilder";constructor(t,a){super(t,"string","PgChar"),this.config.length=a.length,this.config.enumValues=a.enum}build(t){return new CM(t,this.config)}},CM=class extends ne{static[D]="PgChar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"char":`char(${this.length})`}};function kZ(e,t={}){let{name:a,config:r}=_t(e,t);return new wM(a,r)}var kM=class extends de{static[D]="PgCidrBuilder";constructor(t){super(t,"string","PgCidr")}build(t){return new IM(t,this.config)}},IM=class extends ne{static[D]="PgCidr";getSQLType(){return"cidr"}};function IZ(e){return new kM(e??"")}var LM=class extends de{static[D]="PgCustomColumnBuilder";constructor(t,a,r){super(t,"custom","PgCustomColumn"),this.config.fieldConfig=a,this.config.customTypeParams=r}build(t){return new TM(t,this.config)}},TM=class extends ne{static[D]="PgCustomColumn";sqlName;mapTo;mapFrom;constructor(t,a){super(t,a),this.sqlName=a.customTypeParams.dataType(a.fieldConfig),this.mapTo=a.customTypeParams.toDriver,this.mapFrom=a.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(t){return typeof this.mapFrom=="function"?this.mapFrom(t):t}mapToDriverValue(t){return typeof this.mapTo=="function"?this.mapTo(t):t}};function LZ(e){return(t,a)=>{let{name:r,config:n}=_t(t,a);return new LM(r,n,e)}}var Hl=class extends de{static[D]="PgDateColumnBaseBuilder";defaultNow(){return this.default(og`now()`)}};var RM=class extends Hl{static[D]="PgDateBuilder";constructor(t){super(t,"date","PgDate")}build(t){return new _M(t,this.config)}},_M=class extends ne{static[D]="PgDate";getSQLType(){return"date"}mapFromDriverValue(t){return typeof t=="string"?new Date(t):t}mapToDriverValue(t){return t.toISOString()}},NM=class extends Hl{static[D]="PgDateStringBuilder";constructor(t){super(t,"string","PgDateString")}build(t){return new AM(t,this.config)}},AM=class extends ne{static[D]="PgDateString";getSQLType(){return"date"}mapFromDriverValue(t){return typeof t=="string"?t:t.toISOString().slice(0,-14)}};function TZ(e,t){let{name:a,config:r}=_t(e,t);return r?.mode==="date"?new RM(a):new NM(a)}var $M=class extends de{static[D]="PgDoublePrecisionBuilder";constructor(t){super(t,"number","PgDoublePrecision")}build(t){return new PM(t,this.config)}},PM=class extends ne{static[D]="PgDoublePrecision";getSQLType(){return"double precision"}mapFromDriverValue(t){return typeof t=="string"?Number.parseFloat(t):t}};function RZ(e){return new $M(e??"")}var DM=class extends de{static[D]="PgInetBuilder";constructor(t){super(t,"string","PgInet")}build(t){return new EM(t,this.config)}},EM=class extends ne{static[D]="PgInet";getSQLType(){return"inet"}};function _Z(e){return new DM(e??"")}var MM=class extends Yu{static[D]="PgIntegerBuilder";constructor(t){super(t,"number","PgInteger")}build(t){return new OM(t,this.config)}},OM=class extends ne{static[D]="PgInteger";getSQLType(){return"integer"}mapFromDriverValue(t){return typeof t=="string"?Number.parseInt(t):t}};function NZ(e){return new MM(e??"")}var zM=class extends de{static[D]="PgIntervalBuilder";constructor(t,a){super(t,"string","PgInterval"),this.config.intervalConfig=a}build(t){return new UM(t,this.config)}},UM=class extends ne{static[D]="PgInterval";fields=this.config.intervalConfig.fields;precision=this.config.intervalConfig.precision;getSQLType(){let t=this.fields?` ${this.fields}`:"",a=this.precision?`(${this.precision})`:"";return`interval${t}${a}`}};function AZ(e,t={}){let{name:a,config:r}=_t(e,t);return new zM(a,r)}var jM=class extends de{static[D]="PgJsonBuilder";constructor(t){super(t,"json","PgJson")}build(t){return new BM(t,this.config)}},BM=class extends ne{static[D]="PgJson";constructor(t,a){super(t,a)}getSQLType(){return"json"}mapToDriverValue(t){return JSON.stringify(t)}mapFromDriverValue(t){if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t}};function $Z(e){return new jM(e??"")}var FM=class extends de{static[D]="PgJsonbBuilder";constructor(t){super(t,"json","PgJsonb")}build(t){return new HM(t,this.config)}},HM=class extends ne{static[D]="PgJsonb";constructor(t,a){super(t,a)}getSQLType(){return"jsonb"}mapToDriverValue(t){return JSON.stringify(t)}mapFromDriverValue(t){if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t}};function s1(e){return new FM(e??"")}var qM=class extends de{static[D]="PgLineBuilder";constructor(t){super(t,"array","PgLine")}build(t){return new VM(t,this.config)}},VM=class extends ne{static[D]="PgLine";getSQLType(){return"line"}mapFromDriverValue(t){let[a,r,n]=t.slice(1,-1).split(",");return[Number.parseFloat(a),Number.parseFloat(r),Number.parseFloat(n)]}mapToDriverValue(t){return`{${t[0]},${t[1]},${t[2]}}`}},ZM=class extends de{static[D]="PgLineABCBuilder";constructor(t){super(t,"json","PgLineABC")}build(t){return new GM(t,this.config)}},GM=class extends ne{static[D]="PgLineABC";getSQLType(){return"line"}mapFromDriverValue(t){let[a,r,n]=t.slice(1,-1).split(",");return{a:Number.parseFloat(a),b:Number.parseFloat(r),c:Number.parseFloat(n)}}mapToDriverValue(t){return`{${t.a},${t.b},${t.c}}`}};function PZ(e,t){let{name:a,config:r}=_t(e,t);return!r?.mode||r.mode==="tuple"?new qM(a):new ZM(a)}var KM=class extends de{static[D]="PgMacaddrBuilder";constructor(t){super(t,"string","PgMacaddr")}build(t){return new WM(t,this.config)}},WM=class extends ne{static[D]="PgMacaddr";getSQLType(){return"macaddr"}};function DZ(e){return new KM(e??"")}var JM=class extends de{static[D]="PgMacaddr8Builder";constructor(t){super(t,"string","PgMacaddr8")}build(t){return new QM(t,this.config)}},QM=class extends ne{static[D]="PgMacaddr8";getSQLType(){return"macaddr8"}};function EZ(e){return new JM(e??"")}var XM=class extends de{static[D]="PgNumericBuilder";constructor(t,a,r){super(t,"string","PgNumeric"),this.config.precision=a,this.config.scale=r}build(t){return new YM(t,this.config)}},YM=class extends ne{static[D]="PgNumeric";precision;scale;constructor(t,a){super(t,a),this.precision=a.precision,this.scale=a.scale}mapFromDriverValue(t){return typeof t=="string"?t:String(t)}getSQLType(){return this.precision!==void 0&&this.scale!==void 0?`numeric(${this.precision}, ${this.scale})`:this.precision===void 0?"numeric":`numeric(${this.precision})`}},eO=class extends de{static[D]="PgNumericNumberBuilder";constructor(t,a,r){super(t,"number","PgNumericNumber"),this.config.precision=a,this.config.scale=r}build(t){return new tO(t,this.config)}},tO=class extends ne{static[D]="PgNumericNumber";precision;scale;constructor(t,a){super(t,a),this.precision=a.precision,this.scale=a.scale}mapFromDriverValue(t){return typeof t=="number"?t:Number(t)}mapToDriverValue=String;getSQLType(){return this.precision!==void 0&&this.scale!==void 0?`numeric(${this.precision}, ${this.scale})`:this.precision===void 0?"numeric":`numeric(${this.precision})`}},aO=class extends de{static[D]="PgNumericBigIntBuilder";constructor(t,a,r){super(t,"bigint","PgNumericBigInt"),this.config.precision=a,this.config.scale=r}build(t){return new nO(t,this.config)}},nO=class extends ne{static[D]="PgNumericBigInt";precision;scale;constructor(t,a){super(t,a),this.precision=a.precision,this.scale=a.scale}mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return this.precision!==void 0&&this.scale!==void 0?`numeric(${this.precision}, ${this.scale})`:this.precision===void 0?"numeric":`numeric(${this.precision})`}};function MZ(e,t){let{name:a,config:r}=_t(e,t),n=r?.mode;return n==="number"?new eO(a,r?.precision,r?.scale):n==="bigint"?new aO(a,r?.precision,r?.scale):new XM(a,r?.precision,r?.scale)}var rO=class extends de{static[D]="PgPointTupleBuilder";constructor(t){super(t,"array","PgPointTuple")}build(t){return new oO(t,this.config)}},oO=class extends ne{static[D]="PgPointTuple";getSQLType(){return"point"}mapFromDriverValue(t){if(typeof t=="string"){let[a,r]=t.slice(1,-1).split(",");return[Number.parseFloat(a),Number.parseFloat(r)]}return[t.x,t.y]}mapToDriverValue(t){return`(${t[0]},${t[1]})`}},iO=class extends de{static[D]="PgPointObjectBuilder";constructor(t){super(t,"json","PgPointObject")}build(t){return new sO(t,this.config)}},sO=class extends ne{static[D]="PgPointObject";getSQLType(){return"point"}mapFromDriverValue(t){if(typeof t=="string"){let[a,r]=t.slice(1,-1).split(",");return{x:Number.parseFloat(a),y:Number.parseFloat(r)}}return t}mapToDriverValue(t){return`(${t.x},${t.y})`}};function OZ(e,t){let{name:a,config:r}=_t(e,t);return!r?.mode||r.mode==="tuple"?new rO(a):new iO(a)}function Xve(e){let t=[];for(let a=0;a<e.length;a+=2)t.push(Number.parseInt(e.slice(a,a+2),16));return new Uint8Array(t)}function zZ(e,t){let a=new ArrayBuffer(8),r=new DataView(a);for(let n=0;n<8;n++)r.setUint8(n,e[t+n]);return r.getFloat64(0,!0)}function lO(e){let t=Xve(e),a=0,r=t[a];a+=1;let n=new DataView(t.buffer),o=n.getUint32(a,r===1);a+=4;let i;if(o&536870912&&(i=n.getUint32(a,r===1),a+=4),(o&65535)===1){let s=zZ(t,a);a+=8;let l=zZ(t,a);return a+=8,[s,l]}throw new Error("Unsupported geometry type")}var uO=class extends de{static[D]="PgGeometryBuilder";constructor(t){super(t,"array","PgGeometry")}build(t){return new cO(t,this.config)}},cO=class extends ne{static[D]="PgGeometry";getSQLType(){return"geometry(point)"}mapFromDriverValue(t){return lO(t)}mapToDriverValue(t){return`point(${t[0]} ${t[1]})`}},dO=class extends de{static[D]="PgGeometryObjectBuilder";constructor(t){super(t,"json","PgGeometryObject")}build(t){return new fO(t,this.config)}},fO=class extends ne{static[D]="PgGeometryObject";getSQLType(){return"geometry(point)"}mapFromDriverValue(t){let a=lO(t);return{x:a[0],y:a[1]}}mapToDriverValue(t){return`point(${t.x} ${t.y})`}};function UZ(e,t){let{name:a,config:r}=_t(e,t);return!r?.mode||r.mode==="tuple"?new uO(a):new dO(a)}var mO=class extends de{static[D]="PgRealBuilder";constructor(t,a){super(t,"number","PgReal"),this.config.length=a}build(t){return new pO(t,this.config)}},pO=class extends ne{static[D]="PgReal";constructor(t,a){super(t,a)}getSQLType(){return"real"}mapFromDriverValue=t=>typeof t=="string"?Number.parseFloat(t):t};function jZ(e){return new mO(e??"")}var hO=class extends de{static[D]="PgSerialBuilder";constructor(t){super(t,"number","PgSerial"),this.config.hasDefault=!0,this.config.notNull=!0}build(t){return new gO(t,this.config)}},gO=class extends ne{static[D]="PgSerial";getSQLType(){return"serial"}};function BZ(e){return new hO(e??"")}var vO=class extends Yu{static[D]="PgSmallIntBuilder";constructor(t){super(t,"number","PgSmallInt")}build(t){return new yO(t,this.config)}},yO=class extends ne{static[D]="PgSmallInt";getSQLType(){return"smallint"}mapFromDriverValue=t=>typeof t=="string"?Number(t):t};function FZ(e){return new vO(e??"")}var bO=class extends de{static[D]="PgSmallSerialBuilder";constructor(t){super(t,"number","PgSmallSerial"),this.config.hasDefault=!0,this.config.notNull=!0}build(t){return new xO(t,this.config)}},xO=class extends ne{static[D]="PgSmallSerial";getSQLType(){return"smallserial"}};function HZ(e){return new bO(e??"")}var SO=class extends de{static[D]="PgTextBuilder";constructor(t,a){super(t,"string","PgText"),this.config.enumValues=a.enum}build(t){return new wO(t,this.config)}},wO=class extends ne{static[D]="PgText";enumValues=this.config.enumValues;getSQLType(){return"text"}};function Js(e,t={}){let{name:a,config:r}=_t(e,t);return new SO(a,r)}var CO=class extends Hl{constructor(t,a,r){super(t,"string","PgTime"),this.withTimezone=a,this.precision=r,this.config.withTimezone=a,this.config.precision=r}static[D]="PgTimeBuilder";build(t){return new kO(t,this.config)}},kO=class extends ne{static[D]="PgTime";withTimezone;precision;constructor(t,a){super(t,a),this.withTimezone=a.withTimezone,this.precision=a.precision}getSQLType(){return`time${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}};function qZ(e,t={}){let{name:a,config:r}=_t(e,t);return new CO(a,r.withTimezone??!1,r.precision)}var IO=class extends Hl{static[D]="PgTimestampBuilder";constructor(t,a,r){super(t,"date","PgTimestamp"),this.config.withTimezone=a,this.config.precision=r}build(t){return new LO(t,this.config)}},LO=class extends ne{static[D]="PgTimestamp";withTimezone;precision;constructor(t,a){super(t,a),this.withTimezone=a.withTimezone,this.precision=a.precision}getSQLType(){return`timestamp${this.precision===void 0?"":` (${this.precision})`}${this.withTimezone?" with time zone":""}`}mapFromDriverValue(t){return typeof t=="string"?new Date(this.withTimezone?t:t+"+0000"):t}mapToDriverValue=t=>t.toISOString()},TO=class extends Hl{static[D]="PgTimestampStringBuilder";constructor(t,a,r){super(t,"string","PgTimestampString"),this.config.withTimezone=a,this.config.precision=r}build(t){return new RO(t,this.config)}},RO=class extends ne{static[D]="PgTimestampString";withTimezone;precision;constructor(t,a){super(t,a),this.withTimezone=a.withTimezone,this.precision=a.precision}getSQLType(){return`timestamp${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}mapFromDriverValue(t){if(typeof t=="string")return t;let a=t.toISOString().slice(0,-1).replace("T"," ");if(this.withTimezone){let r=t.getTimezoneOffset(),n=r<=0?"+":"-";return`${a}${n}${Math.floor(Math.abs(r)/60).toString().padStart(2,"0")}`}return a}};function l1(e,t={}){let{name:a,config:r}=_t(e,t);return r?.mode==="string"?new TO(a,r.withTimezone??!1,r.precision):new IO(a,r?.withTimezone??!1,r?.precision)}var _O=class extends de{static[D]="PgUUIDBuilder";constructor(t){super(t,"string","PgUUID")}defaultRandom(){return this.default(og`gen_random_uuid()`)}build(t){return new NO(t,this.config)}},NO=class extends ne{static[D]="PgUUID";getSQLType(){return"uuid"}};function VZ(e){return new _O(e??"")}var AO=class extends de{static[D]="PgVarcharBuilder";constructor(t,a){super(t,"string","PgVarchar"),this.config.length=a.length,this.config.enumValues=a.enum}build(t){return new $O(t,this.config)}},$O=class extends ne{static[D]="PgVarchar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"varchar":`varchar(${this.length})`}};function ZZ(e,t={}){let{name:a,config:r}=_t(e,t);return new AO(a,r)}var PO=class extends de{static[D]="PgBinaryVectorBuilder";constructor(t,a){super(t,"string","PgBinaryVector"),this.config.dimensions=a.dimensions}build(t){return new DO(t,this.config)}},DO=class extends ne{static[D]="PgBinaryVector";dimensions=this.config.dimensions;getSQLType(){return`bit(${this.dimensions})`}};function GZ(e,t){let{name:a,config:r}=_t(e,t);return new PO(a,r)}var EO=class extends de{static[D]="PgHalfVectorBuilder";constructor(t,a){super(t,"array","PgHalfVector"),this.config.dimensions=a.dimensions}build(t){return new MO(t,this.config)}},MO=class extends ne{static[D]="PgHalfVector";dimensions=this.config.dimensions;getSQLType(){return`halfvec(${this.dimensions})`}mapToDriverValue(t){return JSON.stringify(t)}mapFromDriverValue(t){return t.slice(1,-1).split(",").map(a=>Number.parseFloat(a))}};function KZ(e,t){let{name:a,config:r}=_t(e,t);return new EO(a,r)}var OO=class extends de{static[D]="PgSparseVectorBuilder";constructor(t,a){super(t,"string","PgSparseVector"),this.config.dimensions=a.dimensions}build(t){return new zO(t,this.config)}},zO=class extends ne{static[D]="PgSparseVector";dimensions=this.config.dimensions;getSQLType(){return`sparsevec(${this.dimensions})`}};function WZ(e,t){let{name:a,config:r}=_t(e,t);return new OO(a,r)}var UO=class extends de{static[D]="PgVectorBuilder";constructor(t,a){super(t,"array","PgVector"),this.config.dimensions=a.dimensions}build(t){return new jO(t,this.config)}},jO=class extends ne{static[D]="PgVector";dimensions=this.config.dimensions;getSQLType(){return`vector(${this.dimensions})`}mapToDriverValue(t){return JSON.stringify(t)}mapFromDriverValue(t){return t.slice(1,-1).split(",").map(a=>Number.parseFloat(a))}};function JZ(e,t){let{name:a,config:r}=_t(e,t);return new UO(a,r)}function QZ(){return{bigint:SZ,bigserial:wZ,boolean:CZ,char:kZ,cidr:IZ,customType:LZ,date:TZ,doublePrecision:RZ,inet:_Z,integer:NZ,interval:AZ,json:$Z,jsonb:s1,line:PZ,macaddr:DZ,macaddr8:EZ,numeric:MZ,point:OZ,geometry:UZ,real:jZ,serial:BZ,smallint:FZ,smallserial:HZ,text:Js,time:qZ,timestamp:l1,uuid:VZ,varchar:ZZ,bit:GZ,halfvec:KZ,sparsevec:WZ,vector:JZ}}var BO=Symbol.for("drizzle:PgInlineForeignKeys"),XZ=Symbol.for("drizzle:EnableRLS"),gx=class extends kn{static[D]="PgTable";static Symbol=Object.assign({},kn.Symbol,{InlineForeignKeys:BO,EnableRLS:XZ});[BO]=[];[XZ]=!1;[kn.Symbol.ExtraConfigBuilder]=void 0;[kn.Symbol.ExtraConfigColumns]={}};function Yve(e,t,a,r,n=e){let o=new gx(e,r,n),i=typeof t=="function"?t(QZ()):t,s=Object.fromEntries(Object.entries(i).map(([d,f])=>{let m=f;m.setName(d);let p=m.build(o);return o[BO].push(...m.buildForeignKeys(p,o)),[d,p]})),l=Object.fromEntries(Object.entries(i).map(([d,f])=>{let m=f;m.setName(d);let p=m.buildExtraConfigColumn(o);return[d,p]})),c=Object.assign(o,s);return c[kn.Symbol.Columns]=s,c[kn.Symbol.ExtraConfigColumns]=l,a&&(c[gx.Symbol.ExtraConfigBuilder]=a),Object.assign(c,{enableRLS:()=>(c[gx.Symbol.EnableRLS]=!0,c)})}var YZ=(e,t,a)=>Yve(e,t,a,void 0);var u1=class{constructor(t,a){this.unique=t,this.name=a}static[D]="PgIndexBuilderOn";on(...t){return new vx(t.map(a=>{if(Bn(a,In))return a;a=a;let r=new ag(a.name,!!a.keyAsName,a.columnType,a.indexConfig);return a.indexConfig=JSON.parse(JSON.stringify(a.defaultConfig)),r}),this.unique,!1,this.name)}onOnly(...t){return new vx(t.map(a=>{if(Bn(a,In))return a;a=a;let r=new ag(a.name,!!a.keyAsName,a.columnType,a.indexConfig);return a.indexConfig=a.defaultConfig,r}),this.unique,!0,this.name)}using(t,...a){return new vx(a.map(r=>{if(Bn(r,In))return r;r=r;let n=new ag(r.name,!!r.keyAsName,r.columnType,r.indexConfig);return r.indexConfig=JSON.parse(JSON.stringify(r.defaultConfig)),n}),this.unique,!0,this.name,t)}},vx=class{static[D]="PgIndexBuilder";config;constructor(t,a,r,n,o="btree"){this.config={name:n,columns:t,unique:a,only:r,method:o}}concurrently(){return this.config.concurrently=!0,this}with(t){return this.config.with=t,this}where(t){return this.config.where=t,this}build(t){return new FO(this.config,t)}},FO=class{static[D]="PgIndex";config;constructor(t,a){this.config={...t,table:a}}};function eG(e){return new u1(!1,e)}function tG(e){return new u1(!0,e)}var aG=e=>l1(e,{withTimezone:!0}),nG=u.enum(["channel","dm","group","local_conversation","thread","web_session"]),xje=YZ("junior_destinations",{id:Js("id").primaryKey(),provider:Js("provider").notNull(),providerTenantId:Js("provider_tenant_id").notNull().default(""),providerDestinationId:Js("provider_destination_id").notNull(),kind:Js("kind").$type().notNull(),parentDestinationId:Js("parent_destination_id"),displayName:Js("display_name"),visibility:Js("visibility").$type().notNull().default("unknown"),metadata:s1("metadata_json"),createdAt:aG("created_at").notNull(),updatedAt:aG("updated_at").notNull()},e=>[tG("junior_destinations_provider_destination_uidx").on(e.provider,e.providerTenantId,e.providerDestinationId),eG("junior_destinations_provider_kind_idx").on(e.provider,e.kind)]);var eye=u.object({error:u.string().min(1)}).strict(),m1=u.object({closed:u.number().int().nonnegative(),costUsd:u.number().nonnegative().optional(),created:u.number().int().nonnegative(),medianCostUsd:u.number().nonnegative().optional(),medianMergeTimeMs:u.number().nonnegative().optional(),merged:u.number().int().nonnegative(),mergeRate:u.number().min(0).max(1).optional(),open:u.number().int().nonnegative()}).strict(),tye=u.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/),ql=u.object({closed:u.number().int().nonnegative(),created:u.number().int().nonnegative(),date:tye,merged:u.number().int().nonnegative()}).strict(),oG=u.object({closed:u.number().int().nonnegative(),created:u.number().int().nonnegative(),id:u.string().uuid(),medianCostUsd:u.number().nonnegative().optional(),merged:u.number().int().nonnegative(),mergeRate:u.number().min(0).max(1).optional(),name:u.string().min(1),open:u.number().int().nonnegative(),provider:u.string().min(1),url:u.string().url().optional()}).strict(),VO=u.object({closedAt:u.string().optional(),id:u.string().uuid(),mergedAt:u.string().optional(),number:u.number().int().positive(),openedAt:u.string(),provider:u.string().min(1),repository:u.string().min(1),state:ix,title:u.string().optional(),url:u.string().url().optional()}).strict(),ZO=u.object({activityDays:u.array(ql),activityHours:u.array(ql).optional(),activitySixHours:u.array(ql).optional(),changes:u.array(VO),generatedAt:u.string(),repositories:u.array(oG),summary:m1,windowEnd:u.string(),windowStart:u.string()}).strict(),aye=u.object({repositoryId:u.string().uuid()}).strict(),GO=u.object({activityDays:u.array(ql),activityHours:u.array(ql).optional(),activitySixHours:u.array(ql).optional(),changes:u.array(VO),generatedAt:u.string(),repository:u.object({id:u.string().uuid(),name:u.string().min(1),provider:u.string().min(1),url:u.string().url().optional()}).strict(),summary:m1,windowEnd:u.string(),windowStart:u.string(),workspaces:u.array(u.object({id:u.string().min(1),name:u.string().min(1)}).strict())}).strict(),KO=u.object({activityDays:u.array(ql),activityHours:u.array(ql).optional(),activitySixHours:u.array(ql).optional(),generatedAt:u.string(),summary:m1,windowEnd:u.string(),windowStart:u.string()}).strict(),d1=u.object({active:u.number(),conversations:u.number(),date:u.string(),durationMs:u.number(),failed:u.number(),tokens:u.number().optional()}).strict();var nye=u.object({locationId:u.string().min(1)}).strict(),iG=mm.extend({id:u.string(),firstSeenAt:u.string(),kind:nG,lastSeenAt:u.string(),provider:u.string(),providerDestinationId:u.string(),visibility:u.literal("public")}).strict(),rye=mm.extend({actor:fm}).strict(),oye=u.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/),f1=u.object({date:oye,privateConversations:u.number(),publicConversations:u.number()}).strict(),WO=u.object({activityDays:u.array(f1),activityHours:u.array(f1).optional(),activitySixHours:u.array(f1).optional(),generatedAt:u.string(),locations:u.array(iG),privateActivity:mm,source:u.literal("conversation_index"),windowEnd:u.string(),windowStart:u.string()}).strict(),JO=iG.extend({activityDays:u.array(d1),activityHours:u.array(d1).optional(),activitySixHours:u.array(d1).optional(),actors:u.array(rye),generatedAt:u.string(),recentConversations:u.array(tg),source:u.literal("conversation_index"),windowEnd:u.string(),windowStart:u.string()}).strict(),iye=u.object({email:u.string().trim().min(1)}).strict(),rG=mm.omit({costUsd:!0}),sG=u.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/),HO=u.object({active:u.number(),conversations:u.number(),costUsd:u.number().optional(),date:sG,durationMs:u.number(),failed:u.number(),tokens:u.number().optional()}).strict(),qO=u.object({activePeople:u.number(),conversations:u.number(),date:sG}).strict(),lG=u.object({active:u.number(),activeDays:u.number(),conversations:u.number(),durationMs:u.number(),failed:u.number(),tokens:u.number().optional()}).strict(),c1=u.object({conversations:u.number().int().nonnegative(),costUsd:u.number().finite().nonnegative(),durationMs:u.number().finite().nonnegative(),priorCostUsd:u.number().finite().nonnegative()}).strict(),sye=u.object({1:c1,7:c1,30:c1,90:c1}).strict(),uG=fm.extend({email:u.string().min(1)}).strict(),lye=lG.extend({firstSeenAt:u.string(),lastSeenAt:u.string(),actor:uG,windows:sye}).strict(),QO=u.object({activityDays:u.array(qO),activityHours:u.array(qO).optional(),activitySixHours:u.array(qO).optional(),generatedAt:u.string(),people:u.array(lye),source:u.literal("conversation_index"),windowEnd:u.string(),windowStart:u.string()}).strict(),XO=u.object({activityDays:u.array(HO),activityHours:u.array(HO).optional(),activitySixHours:u.array(HO).optional(),generatedAt:u.string(),locations:u.array(rG),recentConversations:u.array(tg),actor:uG,source:u.literal("conversation_index"),surfaces:u.array(rG),totals:lG,windowEnd:u.string(),windowStart:u.string()}).strict(),YO=u.object({generatedAt:u.string(),sevenDaysUsd:u.number().finite().nonnegative(),source:u.literal("conversation_index"),thirtyDaysUsd:u.number().finite().nonnegative(),windowEnd:u.string(),windowStart:u.string()}).strict(),ez=u.object({id:u.string().uuid(),name:u.string(),tokenSuffix:u.string(),createdAt:u.string().datetime(),expiresAt:u.string().datetime(),lastUsedAt:u.string().datetime().nullable()}).strict(),tz=u.object({tokens:u.array(ez)}).strict(),uye=u.object({name:u.string().trim().min(1).max(80)}).strict(),az=ez.extend({token:u.string().startsWith("jr_pat_")}).strict(),cye=u.object({id:u.string().uuid()}).strict(),dye=u.object({revoked:u.literal(!0)}).strict(),fye=u.object({provider:u.string(),repo:u.string()}).strict(),cG=u.object({provider:u.string(),repo:u.string(),checkoutPath:u.string()}).strict(),mye=u.object({id:u.string(),generatedAt:u.iso.datetime(),buildDurationMs:u.number().int().nonnegative(),sizeBytes:u.number().int().nonnegative().nullable()}).strict(),dG=u.object({id:u.string(),generatedAt:u.iso.datetime(),buildDurationMs:u.number().int().nonnegative(),dependencyCount:u.number().int().nonnegative()}).strict(),ig=u.object({id:u.string().uuid(),name:u.string(),setupScript:u.string(),repos:u.array(cG),snapshot:mye.nullable()}).strict(),nz=u.object({baselineSnapshot:dG.nullable(),workspaces:u.array(ig)}).strict(),pye=u.object({name:u.string(),setupScript:u.string().optional(),repos:u.array(fye)}).strict(),hye=u.object({id:u.string().uuid()}).strict(),gye=u.object({deleted:u.literal(!0)}).strict(),fG=u.object({count:u.number().int().nonnegative(),date:u.string(),metric:u.string().min(1),name:u.string().min(1),namespace:u.string().min(1)}).strict(),rz=u.object({generatedAt:u.string().datetime(),stats:u.array(fG),windowEnd:u.string(),windowStart:u.string()}).strict();var _i=u.string().trim().min(1).max(160),sg=u.number().int().nonnegative(),vye=u.discriminatedUnion("type",[u.strictObject({type:u.literal("code_change"),author:_i.optional(),sourceBranch:_i.optional(),targetBranch:_i.optional(),reviewers:u.array(_i).max(5).optional(),review:u.enum(["required","approved","changes_requested"]).optional(),checks:u.strictObject({passed:sg,failed:sg,pending:sg}).optional(),mergeable:u.boolean().optional(),changedFiles:sg.optional(),additions:sg.optional(),deletions:sg.optional()}),u.strictObject({type:u.literal("task"),assignees:u.array(_i).max(5).optional(),priority:_i.optional(),project:_i.optional(),cycle:_i.optional(),dueDate:u.iso.date().optional(),labels:u.array(_i).max(5).optional()}),u.strictObject({type:u.literal("deployment"),project:_i.optional(),environment:_i.optional(),revision:_i.optional(),branch:_i.optional()})]);function pG(e){if(!e)return[];let t=[],a=n=>n?.length?`${n.join(", ")}${n.length===5?" (up to 5 shown)":""}`:void 0;function r(n,o,i){i!==void 0&&i!==""&&t.push({key:n,label:o,value:String(i)})}switch(e.type){case"code_change":r("sourceBranch","Branch",e.sourceBranch);break;case"task":r("assignees","Assignees",e.assignees?.length===0?"Unassigned":a(e.assignees)),r("priority","Priority",e.priority),r("project","Project",e.project),r("cycle","Cycle",e.cycle),r("dueDate","Due",e.dueDate),r("labels","Labels",a(e.labels));break;case"deployment":r("environment","Environment",e.environment),r("project","Project",e.project),r("revision","Revision",e.revision),r("branch","Branch",e.branch);break}return t.slice(0,4)}var h1=u.enum(["task","code_change","automation","deployment","item"]),yye={task:"Ticket",code_change:"Code change",automation:"Automation",deployment:"Deployment",item:"Item"};function fs(e){let t=e.objectType==="item"&&e.facts?.type==="deployment"?"deployment":e.objectType,a=e.status?.toLowerCase(),r={task:"issue-opened",code_change:"git-pull-request",automation:"workflow",deployment:"rocket",item:"package"}[t],n=t==="automation"?"info":"neutral";return t==="code_change"?(a==="draft"&&(r="git-pull-request-draft"),a==="closed"&&(r="git-pull-request-closed",n="danger"),a==="merged"&&(r="git-merge",n="accent"),a==="open"&&(n="success")):t==="task"?(a==="closed"&&(r="issue-closed",n="accent"),a==="open"&&(n="success")):t==="deployment"&&((a==="ready"||a==="succeeded")&&(n="success"),(a==="error"||a==="failed")&&(n="danger"),(a==="building"||a==="in_progress")&&(n="info")),(a==="warning"||a==="blocked")&&(n="warning"),{icon:r,tone:n,label:yye[t]}}function hG(e){return`/_junior/dashboard/object-icons/v1/${e}.png`}var iz=u.object({kind:u.literal("object"),key:u.string().trim().min(1).max(256),label:u.string().trim().min(1).max(256),objectType:h1,title:u.string().trim().min(1).max(512),url:u.url().max(2048).refine(e=>["http:","https:"].includes(new URL(e).protocol)).nullable(),description:u.string().max(4e3).optional(),status:u.string().trim().min(1).max(100).optional(),trigger:u.string().max(4e3).optional(),warning:u.string().max(1e3).optional(),displayType:u.string().trim().min(1).max(80).optional(),sourceUpdatedAt:u.iso.datetime({offset:!0}).optional(),facts:vye.refine(e=>new TextEncoder().encode(JSON.stringify(e)).length<=4096,"Object facts must not exceed 4 KiB").optional()}).strict().refine(e=>!e.facts||(e.facts.type==="deployment"?e.objectType==="deployment"||e.objectType==="item":e.facts.type===e.objectType),"Object facts must match the object type"),Bje=iz.safeExtend({plugin:u.string().min(1)}),gG={"issue-opened":["M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z","M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Z"],"issue-closed":["M11.28 6.78a.75.75 0 0 0-1.06-1.06L7.25 8.69 5.78 7.22a.75.75 0 0 0-1.06 1.06l2 2a.75.75 0 0 0 1.06 0l3.5-3.5Z","M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0Zm-1.5 0a6.5 6.5 0 1 0-13 0 6.5 6.5 0 0 0 13 0Z"],"git-pull-request":["M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z"],"git-pull-request-draft":["M3.25 1A2.25 2.25 0 0 1 4 5.372v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.251 2.251 0 0 1 3.25 1Zm9.5 14a2.25 2.25 0 1 1 0-4.5 2.25 2.25 0 0 1 0 4.5ZM2.5 3.25a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0ZM3.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm9.5 0a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM14 7.5a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Zm0-4.25a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Z"],"git-pull-request-closed":["M3.25 1A2.25 2.25 0 0 1 4 5.372v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.251 2.251 0 0 1 3.25 1Zm9.5 5.5a.75.75 0 0 1 .75.75v3.378a2.251 2.251 0 1 1-1.5 0V7.25a.75.75 0 0 1 .75-.75Zm-2.03-5.273a.75.75 0 0 1 1.06 0l.97.97.97-.97a.748.748 0 0 1 1.265.332.75.75 0 0 1-.205.729l-.97.97.97.97a.751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018l-.97-.97-.97.97a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734l.97-.97-.97-.97a.75.75 0 0 1 0-1.06ZM2.5 3.25a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0ZM3.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm9.5 0a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"],"git-merge":["M5.45 5.154A4.25 4.25 0 0 0 9.25 7.5h1.378a2.251 2.251 0 1 1 0 1.5H9.25A5.734 5.734 0 0 1 5 7.123v3.505a2.25 2.25 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.95-.218ZM4.25 13.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm8.5-4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5ZM5 3.25a.75.75 0 1 0 0 .005V3.25Z"],workflow:["M0 1.75C0 .784.784 0 1.75 0h3.5C6.216 0 7 .784 7 1.75v3.5A1.75 1.75 0 0 1 5.25 7H4v4a1 1 0 0 0 1 1h4v-1.25C9 9.784 9.784 9 10.75 9h3.5c.966 0 1.75.784 1.75 1.75v3.5A1.75 1.75 0 0 1 14.25 16h-3.5A1.75 1.75 0 0 1 9 14.25v-.75H5A2.5 2.5 0 0 1 2.5 11V7h-.75A1.75 1.75 0 0 1 0 5.25Zm1.75-.25a.25.25 0 0 0-.25.25v3.5c0 .138.112.25.25.25h3.5a.25.25 0 0 0 .25-.25v-3.5a.25.25 0 0 0-.25-.25Zm9 9a.25.25 0 0 0-.25.25v3.5c0 .138.112.25.25.25h3.5a.25.25 0 0 0 .25-.25v-3.5a.25.25 0 0 0-.25-.25Z"],rocket:["M14.064 0h.186C15.216 0 16 .784 16 1.75v.186a8.752 8.752 0 0 1-2.564 6.186l-.458.459c-.314.314-.641.616-.979.904v3.207c0 .608-.315 1.172-.833 1.49l-2.774 1.707a.749.749 0 0 1-1.11-.418l-.954-3.102a1.214 1.214 0 0 1-.145-.125L3.754 9.816a1.218 1.218 0 0 1-.124-.145L.528 8.717a.749.749 0 0 1-.418-1.11l1.71-2.774A1.748 1.748 0 0 1 3.31 4h3.204c.288-.338.59-.665.904-.979l.459-.458A8.749 8.749 0 0 1 14.064 0ZM8.938 3.623h-.002l-.458.458c-.76.76-1.437 1.598-2.02 2.5l-1.5 2.317 2.143 2.143 2.317-1.5c.902-.583 1.74-1.26 2.499-2.02l.459-.458a7.25 7.25 0 0 0 2.123-5.127V1.75a.25.25 0 0 0-.25-.25h-.186a7.249 7.249 0 0 0-5.125 2.123ZM3.56 14.56c-.732.732-2.334 1.045-3.005 1.148a.234.234 0 0 1-.201-.064.234.234 0 0 1-.064-.201c.103-.671.416-2.273 1.15-3.003a1.502 1.502 0 1 1 2.12 2.12Zm6.94-3.935c-.088.06-.177.118-.266.175l-2.35 1.521.548 1.783 1.949-1.2a.25.25 0 0 0 .119-.213ZM3.678 8.116 5.2 5.766c.058-.09.117-.178.176-.266H3.309a.25.25 0 0 0-.213.119l-1.2 1.95ZM12 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"],package:["m8.878.392 5.25 3.045c.54.314.872.89.872 1.514v6.098a1.75 1.75 0 0 1-.872 1.514l-5.25 3.045a1.75 1.75 0 0 1-1.756 0l-5.25-3.045A1.75 1.75 0 0 1 1 11.049V4.951c0-.624.332-1.201.872-1.514L7.122.392a1.75 1.75 0 0 1 1.756 0ZM7.875 1.69l-4.63 2.685L8 7.133l4.755-2.758-4.63-2.685a.248.248 0 0 0-.25 0ZM2.5 5.677v5.372c0 .09.047.171.125.216l4.625 2.683V8.432Zm6.25 8.271 4.625-2.683a.25.25 0 0 0 .125-.216V5.677L8.75 8.432Z"]};function bye(e){try{let t=new URL(e).protocol;return t==="http:"||t==="https:"}catch{return!1}}var xye=u.object({kind:u.literal("resource_link"),objectType:h1.optional(),key:u.string().trim().min(1).max(256),label:u.string().trim().min(1).max(256),url:u.string().url().max(2048).refine(bye,"URL must use HTTP or HTTPS."),description:u.string().trim().min(1).max(512).optional(),status:u.enum(["open","draft","closed","merged","warning"]).optional()}).strict(),Hje=u.discriminatedUnion("kind",[xye,iz]),Sye=u.enum(["circle-dot","circle-dashed","circle-x","git-merge","git-pull-request","triangle-alert"]),qje=u.object({icon:Sye.optional(),objectType:h1.optional(),status:u.string().trim().min(1).max(100).optional(),key:u.string().trim().min(1).max(256),label:u.string().trim().min(1).max(256)}).strict(),wye=u.enum(["closed","merged","open"]),Zje=u.object({closedAt:u.date().optional(),conversationIds:u.array(u.string().min(1)).default([]),mergedAt:u.date().optional(),number:u.number().int().positive(),openedAt:u.date(),providerId:u.string().min(1),repository:u.object({name:u.string().min(1),providerId:u.string().min(1),url:u.string().url().optional()}).strict(),state:wye,title:u.string().min(1).optional(),updatedAt:u.date(),url:u.string().url().optional()}).strict(),Kje=u.string().trim().min(1).max(64).regex(/^[a-z][a-z0-9_]*$/),Cye=u.enum(["activity","brain","calendar","check","database","info","key","link","sparkles","warning"]),kye=u.object({content:u.string().min(1).max(32*1024).optional(),description:u.string().trim().min(1).max(2e3).optional(),metadata:u.array(u.string().trim().min(1).max(120)).max(8).optional(),title:u.string().trim().min(1).max(4e3)}).strict(),Wje=u.object({details:u.array(kye).max(100).optional(),icon:Cye.optional(),preview:u.string().trim().min(1).max(500).optional(),title:u.string().trim().min(1).max(120)}).strict();var g1=u.string().regex(/^T[A-Z0-9]+$/),sz=u.string().regex(/^(C|G|D)[A-Z0-9]+$/),vG=u.string().regex(/^local:[a-z0-9_-]+:[a-z0-9][a-z0-9_-]*$/),Iye=u.string().min(1).refine(e=>e===e.trim()&&e.toLowerCase()!=="unknown"),p1=Iye,je=u.string().refine(e=>e.trim().length>0),Xr=je.refine(e=>e===e.trim()),Lye=u.object({id:je,provider:Xr}).strict(),Tye=Lye.extend({provider:u.literal("slack"),teamId:g1,channelId:sz,threadTs:Xr.optional()}).strict(),Qje=u.discriminatedUnion("provider",[Tye]),Xje=u.enum(["slack","local"]),yG=u.enum(["public","private"]),Rye=u.enum(["public","private"]),_ye=u.object({platform:u.literal("slack"),teamId:g1,channelId:sz,threadTs:Xr.optional()}).strict(),lz=_ye,Nye=u.object({platform:u.literal("local"),conversationId:vG}).strict(),Aye=u.discriminatedUnion("platform",[lz,Nye]),Yje=u.object({action:u.literal("send_message"),destination:lz}).strict(),$ye=u.object({kind:u.literal("slack"),teamId:g1,channelId:sz,visibility:yG,messageTs:je.optional(),threadTs:je.optional()}).strict(),Pye=u.object({kind:u.literal("local"),visibility:u.literal("private"),conversationId:vG}).strict(),Dye=u.object({kind:u.literal("web"),visibility:yG,conversationId:Xr}).strict(),Eye=u.object({kind:u.literal("event"),eventKey:Xr,eventType:Xr,identifier:Xr,namespace:Xr}).strict(),Mye=u.object({kind:u.literal("scheduled_automation")}).strict(),Oye=u.object({kind:u.literal("event_automation")}).strict(),zye=u.object({kind:u.literal("plugin_dispatch")}).strict(),Uye=u.object({kind:u.literal("agent_invocation")}).strict(),jye=u.discriminatedUnion("kind",[$ye,Pye,Dye,Eye,Mye,Oye,zye,Uye]);function Bye(e){if(!e||typeof e!="object"||Array.isArray(e))return e;let t=e;if("kind"in t){let o={event_task:"event_automation",resource_event:"event",scheduled_task:"scheduled_automation"},i=typeof t.kind=="string"?o[t.kind]:void 0;return i?{...t,kind:i}:e}if(t.platform!=="slack"&&t.platform!=="local"&&t.platform!=="web")return e;let{location:a,platform:r,...n}=t;return{...n,kind:r}}var Fye=u.preprocess(Bye,jye),Hye=u.discriminatedUnion("allowedWhen",[u.object({type:u.literal("user"),userId:p1,allowedWhen:u.literal("private-direct-conversation")}).strict(),u.object({type:u.literal("user"),userId:p1,allowedWhen:u.literal("scheduled-automation"),taskId:Xr}).strict()]),uz={email:je.optional(),fullName:je.optional(),userId:p1,userName:je.optional()},qye=u.object({...uz,platform:u.literal("slack"),teamId:g1}).strict(),Vye=u.object({...uz,platform:u.literal("local")}).strict(),Zye=u.object({...uz,platform:u.literal("web")}).strict(),Gye=u.object({platform:u.literal("system"),name:p1}).strict(),oz=u.discriminatedUnion("platform",[qye,Vye,Zye,Gye]),Kye=u.object({displayName:je.optional(),handle:je.optional(),id:Xr,provider:Xr,providerSubjectId:Xr,providerTenantId:Xr.optional()}).strict(),eBe=u.object({displayName:je.optional(),email:je.max(320),id:Xr,identities:u.array(Kye).max(100),isAdmin:u.literal(!0).optional()}).strict(),Wye=u.record(u.string(),u.string()).superRefine((e,t)=>{let a=Object.entries(e);if(a.length>20){t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata has too many keys"});return}for(let[r,n]of a){if(!r.trim()){t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata values must be strings",path:[r]});continue}r.length>128&&t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata key exceeds the maximum length",path:[r]}),/[\r\n]/.test(r)&&t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata keys must be single-line strings",path:[r]}),/[\r\n]/.test(n)&&t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata values must be single-line strings",path:[r]}),n.length>512&&t.addIssue({code:u.ZodIssueCode.custom,message:"Dispatch metadata value exceeds the maximum length",path:[r]})}}),Jye=u.object({label:Xr.pipe(u.string().max(48)).refine(e=>!/[\r\n]/.test(e)),detail:Xr.pipe(u.string().max(128)).refine(e=>!/[\r\n]/.test(e)).optional()}).strict(),tBe=u.object({idempotencyKey:je.pipe(u.string().max(512)),credentialSubject:Hye.optional(),destination:lz,destinationVisibility:Rye,input:je.pipe(u.string().max(32e3)),metadata:Wye.optional(),replyAttribution:Jye.optional()}).strict();var Qye=u.string().trim().min(1).max(64).regex(/^[a-z][a-z0-9_-]*$/),nBe=u.object({text:u.string().trim().min(1).max(8e3)}).strict(),rBe=u.object({kind:Qye,version:u.number().int().positive(),content:u.record(u.string(),u.unknown())}).strict();var Xye=4e3,Yye=8e3,lg=32,mG=4e3,ebe=1e3,tbe=u.record(u.string(),u.unknown()).superRefine((e,t)=>{Object.keys(e).length>lg&&t.addIssue({code:"custom",message:`Event data may include at most ${lg} keys.`}),new TextEncoder().encode(JSON.stringify(e)).byteLength>mG&&t.addIssue({code:"custom",message:`Event data may be at most ${mG} JSON bytes.`})}),hm=u.string().regex(/^[a-z][a-z0-9_-]*(?:\.[a-z][a-z0-9_-]*)+$/).describe("Canonical dotted event type, such as issue.closed or pull_request.review.changes_requested."),bG=u.string().regex(/^[a-z][a-z0-9_]*$/).describe("Canonical plugin-defined resource type, such as issue or pull_request."),xG=/^[a-z][a-zA-Z0-9]*$/,abe=u.object({kind:u.enum(["boolean","string","number"]),description:u.string().trim().min(1).max(200),enum:u.array(u.string().min(1)).min(1).optional()}).strict().superRefine((e,t)=>{e.enum&&e.kind!=="string"&&t.addIssue({code:"custom",message:'Event match field enum requires kind "string".',path:["enum"]})}),nbe=u.record(u.string().regex(xG),abe).superRefine((e,t)=>{Object.keys(e).length>lg&&t.addIssue({code:"custom",message:`Event match keys may include at most ${lg} keys.`})}),iBe=u.record(u.string().regex(xG),u.union([u.boolean(),u.number().finite(),u.string().min(1),u.array(u.union([u.number().finite(),u.string().min(1)])).min(1)])).superRefine((e,t)=>{Object.keys(e).length>lg&&t.addIssue({code:"custom",message:`Event match may include at most ${lg} keys.`});for(let[a,r]of Object.entries(e))Array.isArray(r)&&r.some(n=>typeof n=="boolean")&&t.addIssue({code:"custom",message:`Event match field "${a}" cannot use a boolean list.`,path:[a]})});var rbe=u.object({format:u.string().trim().min(1).max(200),pattern:u.instanceof(RegExp)}).strict(),obe=u.object({type:bG,identifier:rbe.optional(),supportedEvents:u.array(hm).min(1),suggestedEvents:u.array(hm).optional(),matchFields:nbe.optional(),guidance:u.record(hm,u.string().trim().min(1).max(ebe)).optional()}).strict().superRefine((e,t)=>{let a=new Set;e.supportedEvents.forEach((n,o)=>{a.has(n)&&t.addIssue({code:"custom",message:`Duplicate supported event type "${n}".`,path:["supportedEvents",o]}),a.add(n)});for(let n of Object.keys(e.guidance??{}))a.has(n)||t.addIssue({code:"custom",message:`Guidance event type "${n}" is not supported.`,path:["guidance",n]});let r=new Set;e.suggestedEvents?.forEach((n,o)=>{r.has(n)&&t.addIssue({code:"custom",message:`Duplicate suggested event type "${n}".`,path:["suggestedEvents",o]}),a.has(n)||t.addIssue({code:"custom",message:`Suggested event type "${n}" is not supported.`,path:["suggestedEvents",o]}),r.add(n)})}),sBe=u.object({resourceTypes:u.array(obe).min(1),isEnabled:u.function({input:[],output:u.boolean()}).optional(),normalizeIdentifier:u.function({input:[u.string()],output:u.string()}).optional()}).strict().superRefine((e,t)=>{let a=new Set;e.resourceTypes.forEach((r,n)=>{a.has(r.type)&&t.addIssue({code:"custom",message:`Duplicate resource type "${r.type}".`,path:["resourceTypes",n,"type"]}),a.add(r.type)})});var lBe=u.object({identifier:u.string().min(1),label:u.string().min(1),namespace:u.string().min(1),suggestedEvents:u.array(hm).optional(),supportedEvents:u.array(hm),type:bG}).strict(),uBe=u.object({events:u.array(hm).min(1),id:u.string().min(1)}).strict(),ibe=u.object({objectType:h1.optional(),eventKey:u.string().min(1),eventType:hm,identifier:u.string().min(1),occurredAtMs:u.number().finite(),terminal:u.boolean().optional(),trustedSummary:u.string().min(1).transform(e=>e.slice(0,Xye)),data:tbe.optional(),untrustedText:u.string().transform(e=>e.slice(0,Yye)).optional()}).strict(),cBe=ibe.extend({namespace:u.string().min(1)}),sbe=u.object({authority:u.enum(["instruction","context"]),actor:oz.optional()}).strict(),lbe=u.discriminatedUnion("type",[u.object({type:u.literal("message"),role:u.enum(["user","assistant"]),text:u.string().min(1),provenance:sbe.optional(),isRunActor:u.boolean().optional()}).strict(),u.object({type:u.literal("toolResult"),toolName:u.string().min(1),isError:u.boolean(),text:u.string().min(1).optional()}).strict()]),fBe=u.object({actorUserId:u.string().min(1).optional(),completedAtMs:u.number().finite(),conversationId:u.string().min(1),destination:Aye,locationId:u.string().min(1).optional(),actors:u.array(oz),actor:oz.optional(),runId:u.string().min(1),source:Fye,transcript:u.array(lbe)}).strict();var pBe=u.discriminatedUnion("type",[u.object({type:u.literal("text"),text:u.string()}).strict(),u.object({type:u.literal("image"),data:u.string(),mimeType:u.string()}).strict()]),ube=u.object({arguments:u.record(u.string(),u.unknown()),reason:u.string().min(1).optional()}).strict(),hBe=u.object({objectAnnotations:u.array(iz).optional(),target:u.string().min(1).optional(),truncated:u.boolean().optional(),continuation:ube.optional()}).passthrough(),gBe=u.enum(["auto","review","approve"]);var yBe=u.object({auth:u.object({user:u.object({email:u.string().nullable().optional(),emailVerified:u.boolean().optional(),isAdmin:u.boolean(),name:u.string().nullable().optional()}).strict()}).strict(),pluginName:je}).strict(),cbe=u.string().regex(/^[a-z][a-z0-9-]*$/),dbe=u.string().regex(/^[a-z][a-z0-9.-]*$/),fbe=u.union([u.literal("read"),u.literal("write")]),SG=u.object({provider:cbe,scope:je.optional(),type:u.literal("oauth")}).strict(),wG=u.object({displayName:je.optional(),handle:je.optional(),id:je,label:je.optional(),url:je.optional()}).strict(),xBe=u.object({account:wG.optional(),accessToken:je,expiresAt:u.number().finite().optional(),refreshToken:je,refreshTokenExpiresAt:u.number().finite().optional(),scope:je.optional()}).strict(),SBe=u.object({access:fbe,leaseScope:je.optional(),name:dbe,reason:je.optional(),requirements:u.array(je).min(1).optional()}).strict(),mbe=u.object({domain:u.string().min(1),headers:u.record(u.string(),u.string()).refine(e=>Object.keys(e).length>0)}).strict(),pbe=u.object({account:wG.optional(),authorization:SG.optional(),expiresAt:u.string().refine(e=>Number.isFinite(Date.parse(e))),headerTransforms:u.array(mbe).min(1)}).strict(),wBe=u.discriminatedUnion("type",[u.object({lease:pbe,type:u.literal("lease")}).strict(),u.object({authorization:SG.optional(),message:je,type:u.literal("needed")}).strict(),u.object({message:je,type:u.literal("unavailable")}).strict()]);var hbe=je.max(64).regex(/^[a-z][a-z0-9-]*$/),gbe=je.max(80),vbe=je.max(500),ybe=u.enum(["primary","profile","admin"]),bbe=u.object({detail:je.max(500).optional(),label:je.max(80),tone:u.enum(["good","neutral","warning"]).optional(),value:je.max(120)}).strict(),xbe=u.object({label:je.max(80),value:je.max(500)}).strict(),Sbe=u.object({confirmation:je.max(500).optional(),href:je.max(500).regex(/^\/api\/plugins\/[a-z][a-z0-9-]*(?:\/|$)/),label:je.max(80),method:u.enum(["DELETE","GET"]),tone:u.enum(["danger","neutral"]).optional()}).strict(),wbe=u.object({actions:u.array(Sbe).max(4).optional(),description:je.max(1e3).optional(),id:je.max(128),metadata:u.array(xbe).max(8).optional(),title:je.max(4e3)}).strict(),CG=u.object({emptyText:je.max(500).optional(),metrics:u.array(bbe).max(6).optional(),nextCursor:je.max(1e3).optional(),records:u.array(wbe).max(100),searchPlaceholder:je.max(120).optional(),type:u.literal("list")}).strict(),Cbe=u.object({description:vbe,id:hbe,label:gbe,navigation:ybe,pluginDisplayName:je.max(200),pluginName:je.max(100)}).strict(),kG=u.array(Cbe),kbe=je.max(1e3).optional(),Ibe=je.max(64).optional(),Lbe=u.string().trim().max(200).optional(),kBe=u.object({cursor:kbe,filter:Ibe,limit:u.number().int().min(1).max(50),query:Lbe}).strict();var IG=u.object({email:u.string().trim().email(),emailVerified:u.boolean().optional(),name:u.string().nullable().optional()}).strict(),TBe=u.object({user:IG}).strict(),v1=u.object({user:IG.extend({isAdmin:u.boolean()}).strict()}).strict(),RBe=u.object({displayName:u.string().trim().min(1).max(80)}).strict(),LG=u.object({allowedEmailCount:u.number(),allowedGoogleDomainCount:u.number(),authRequired:u.boolean(),authPath:u.string(),basePath:u.string(),componentGallery:u.boolean(),sentryConversationLinks:u.boolean(),timeZone:u.string().optional(),version:u.string().min(1)}).strict();var yx=b(G(),1);var TG="x-junior-version";var cz="junior:dashboard-version";function RG(e){let t=e.headers.get(TG)?.trim();!t||typeof window>"u"||window.dispatchEvent(new CustomEvent(cz,{detail:t}))}function _G(e){let[t,a]=(0,yx.useState)(e);return(0,yx.useEffect)(()=>{e&&a(e)},[e]),(0,yx.useEffect)(()=>{let r=n=>{a(n.detail)};return window.addEventListener(cz,r),()=>window.removeEventListener(cz,r)},[]),t}var yn=class extends Error{status;fields;code;apiError;constructor(t,a,r,n){super(`${t} returned ${a}`),this.status=a,this.fields=n?.fields,this.code=n?.code,r?.trim()&&(this.apiError=r.trim())}};async function ug(e,t){let a,r,n;try{let o=await t.json();typeof o.error=="string"&&(a=o.error),typeof o.code=="string"&&(n=o.code),o.fields&&typeof o.fields=="object"&&(r=Object.fromEntries(Object.entries(o.fields).filter(i=>Array.isArray(i[1])&&i[1].every(s=>typeof s=="string"))))}catch{}throw new yn(e,t.status,a,{fields:r,code:n})}function cg(){if(typeof window>"u")return;let e=window.__JUNIOR_DASHBOARD_BASE_PATH__??"/",t=e==="/"?"/auth/login":`${e}/auth/login`;if(window.location.pathname!==t){let a=`${window.location.pathname}${window.location.search||""}`,r=new URLSearchParams;a!=="/"&&r.set("next",a);let n=r.toString();window.location.assign(n?`${t}?${n}`:t)}}async function dg(e,t,a){let r=await fg(t,{body:JSON.stringify(a),credentials:"same-origin",headers:{"content-type":"application/json"},method:"PATCH"});return r.status===401&&cg(),r.ok||await ug(t,r),e.parse(await r.json())}async function xo(e,t,a){let r=await fg(t,{body:JSON.stringify(a),credentials:"same-origin",headers:{"content-type":"application/json"},method:"POST"});return r.status===401&&cg(),r.ok||await ug(t,r),e.parse(await r.json())}async function NG(e,t,a){let r=await fg(t,{body:JSON.stringify(a),credentials:"same-origin",headers:{"content-type":"application/json"},method:"PUT"});return r.status===401&&cg(),r.ok||await ug(t,r),e.parse(await r.json())}async function Rd(e){let t=await fg(e,{credentials:"same-origin",method:"DELETE"});t.status===401&&cg(),t.ok||await ug(e,t)}async function AG(e,t,a={}){let r=await fg(t,{body:JSON.stringify(a),credentials:"same-origin",headers:{"content-type":"application/json"},method:"DELETE"});return r.status===401&&cg(),r.ok||await ug(t,r),e.parse(await r.json())}async function fg(e,t){let a=await fetch(e,t);return RG(a),a}async function Pe(e,t,a){let r=await dz(t,a);return e.parse(await r.json())}async function dz(e,t,a){let r=await fg(e,{credentials:"same-origin",...t?{signal:t}:void 0,...a?{cache:"no-store",headers:{"if-none-match":a}}:void 0});return r.status===401&&cg(),!r.ok&&!(a&&r.status===304)&&await ug(e,r),r}var y1=5*6e4,fz=5*6e4,Tbe=1e3;function Rbe(e,t=Date.now()){if(!e)return fz;let a=Date.parse(e);if(!Number.isFinite(a))return fz;let r=Math.max(0,t-a);return Math.max(Tbe,fz-r)}function $G(){return Be({queryKey:["dashboard","core"],queryFn:async({signal:e})=>{let[t,a]=await Promise.all([Pe(v1,"/api/me",e),Pe(LG,"/api/config",e)]);return{config:a,me:t}},retry:!1,staleTime:y1})}function _be(){return Be({queryKey:["dashboard","plugins"],queryFn:({signal:e})=>Pe(VE,"/api/plugins",e),retry:!1,staleTime:y1})}function PG(){return Be({queryKey:["dashboard","plugin-user-pages"],queryFn:({signal:e})=>Pe(kG,"/api/user-pages",e),retry:!1,staleTime:y1})}function b1(e=""){return Be({queryKey:["dashboard","conversations","viewer",{search:e}],queryFn:({signal:t})=>Pe(Xk,`/api/conversations${e?`?q=${encodeURIComponent(e)}`:""}`,t),placeholderData:vv,retry:!1})}function DG(){return Be({queryKey:["dashboard","code"],queryFn:({signal:e})=>Pe(ZO,"/api/code",e),retry:!1})}function EG(e){return Be({enabled:!!e,queryKey:["dashboard","code","repositories",e],queryFn:({signal:t})=>Pe(GO,`/api/code/repositories/${encodeURIComponent(e)}`,t),retry:!1})}function x1(e,t=""){return Be({enabled:!!e,queryKey:["dashboard","conversations","code-repository",{repositoryId:e,search:t}],queryFn:({signal:a})=>{let r=new URLSearchParams({codeRepositoryId:e});return t&&r.set("q",t),Pe(Xk,`/api/conversations?${r.toString()}`,a)},placeholderData:vv,retry:!1})}function MG(e,t){return Be({enabled:e,queryKey:["dashboard","automations",t],queryFn:({signal:a})=>Pe(ME,`/api/automations${t?`?${t}`:""}`,a),placeholderData:vv,retry:!1})}function mg(e,t){return Be({enabled:e&&!!t,queryKey:["dashboard","automations","detail",t],queryFn:({signal:a})=>Pe(fx,`/api/automations/${encodeURIComponent(t)}`,a),retry:!1})}function OG(e){return Be({enabled:e,queryKey:["dashboard","automations","runs"],queryFn:({signal:t})=>Pe(UE,"/api/automations/runs",t),retry:!1})}function zG(e,t,a){return Be({enabled:e&&!!(t&&a),queryKey:["dashboard","automations",t,a,"executions"],queryFn:({signal:r})=>Pe(zE,`/api/automations/${t}/${encodeURIComponent(a)}/executions`,r),retry:!1})}function UG(e,t,a){return Be({enabled:e&&!!(t&&a),queryKey:["dashboard","automations",t,a,"versions"],queryFn:({signal:r})=>Pe(jE,`/api/automations/${t}/${encodeURIComponent(a)}/versions`,r),retry:!1})}function jG(){return Be({queryKey:["dashboard","people"],queryFn:({signal:e})=>Pe(QO,"/api/people",e),retry:!1})}function BG(e){return Be({enabled:!!e,queryKey:["dashboard","people",e],queryFn:async({signal:t})=>Pe(XO,`/api/people/${encodeURIComponent(e)}`,t),retry:!1})}function FG(e){return Be({enabled:!!e,queryKey:["dashboard","people",e,"plugin-reports"],queryFn:({signal:t})=>Pe(a1,`/api/people/${encodeURIComponent(e)}/plugin-reports`,t),retry:!1})}function HG(e){return Be({enabled:!!e,queryKey:["dashboard","people",e,"code"],queryFn:({signal:t})=>Pe(KO,`/api/people/${encodeURIComponent(e)}/code`,t),retry:!1})}function qG(e){return Be({enabled:e,queryKey:["dashboard","personal-spend"],queryFn:({signal:t})=>Pe(YO,"/api/people/me/spend",t),refetchInterval:t=>Rbe(t.state.data?.generatedAt),retry:!1,staleTime:0})}function VG(){return Be({queryKey:["dashboard","locations"],queryFn:({signal:e})=>Pe(WO,"/api/locations",e),retry:!1})}function ZG(e){return Be({enabled:!!e,queryKey:["dashboard","locations",e],queryFn:async({signal:t})=>Pe(JO,`/api/locations/${encodeURIComponent(e)}`,t),retry:!1})}function Nbe(){return Be({queryKey:["dashboard","skills"],queryFn:({signal:e})=>Pe(GE,"/api/skills",e),retry:!1,staleTime:y1})}function Abe(){return Be({queryKey:["dashboard","plugin-reports"],queryFn:({signal:e})=>Pe(a1,"/api/plugin-reports",e),retry:!1})}function GG(){return Be({queryKey:["dashboard","stats"],queryFn:({signal:e})=>Pe(rz,"/api/stats",e),retry:!1})}function KG(e){let t=_be(),a=Be({queryKey:["dashboard","conversation-stats"],queryFn:({signal:i})=>Pe(PE,"/api/conversations/stats",i),retry:!1}),r=Nbe(),n=Abe();return{data:t.data&&r.data?{...e,conversationStatsError:!!a.error,...a.data?{conversationStats:a.data}:void 0,conversationStatsLoading:a.isPending,pluginReportsError:!!n.error,...n.data?{pluginReports:n.data}:void 0,pluginReportsLoading:n.isPending,plugins:t.data,skills:r.data}:void 0,error:t.error??r.error,isPending:t.isPending||r.isPending}}function I(...e){return e.filter(Boolean).join(" ")}var Ya="mx-auto w-full min-w-0 max-w-screen-xl",gm="text-dashboard-text-muted hover:text-dashboard-text",WG="rounded-xl border border-dashboard-border-interactive bg-dashboard-surface-active",JG="dashboard-shell-bg";var S1=b(w(),1),QG="inline-flex h-9 max-w-full items-center gap-2 rounded border border-dashboard-border-emphasis bg-dashboard-surface-raised px-3 font-mono text-sm font-semibold leading-none text-dashboard-text transition-colors hover:border-dashboard-border-heavy hover:bg-dashboard-surface-hover hover:text-dashboard-text",$be="inline-flex h-9 max-w-full items-center justify-center gap-1.5 rounded border border-dashboard-border-strong bg-transparent px-3 font-mono text-xs font-semibold text-dashboard-text-muted transition-colors hover:border-rose-300/40 hover:text-rose-300";function ie({className:e,size:t="default",tone:a="default",type:r="button",...n}){let o=a==="danger";return(0,S1.jsx)("button",{...n,className:I("font-mono transition-colors disabled:cursor-not-allowed disabled:opacity-50",t==="icon"?I("grid size-9 place-items-center rounded-md border-0 bg-transparent p-0 focus-visible:outline focus-visible:outline-1 disabled:hover:!bg-transparent",o?"text-dashboard-text-muted hover:!bg-rose-300/10 hover:!text-rose-300 focus-visible:outline-rose-300/55 disabled:hover:!text-dashboard-text-muted":"text-dashboard-text-muted hover:!bg-dashboard-fill-strong hover:!text-dashboard-text focus-visible:outline-cyan-300/55 disabled:hover:!text-dashboard-text-muted"):a==="primary"?"inline-flex h-9 items-center justify-center gap-2 rounded border border-dashboard-text-solid bg-dashboard-text-solid px-3 font-sans text-sm font-semibold text-dashboard-text-inverse hover:bg-dashboard-text-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-dashboard-focus":o?I($be,"disabled:hover:border-dashboard-border-strong disabled:hover:text-dashboard-text-muted"):I(QG,"disabled:hover:border-dashboard-border-emphasis disabled:hover:bg-dashboard-surface-raised disabled:hover:text-dashboard-text"),n.disabled?"":"cursor-pointer",e),type:r})}function _d({className:e,...t}){return(0,S1.jsx)(ae,{...t,className:I(QG,"no-underline",e)})}function Ln({className:e,pressed:t,type:a="button",variant:r,...n}){return(0,S1.jsx)("button",{...n,"aria-pressed":t,className:I(Pbe[r],t?Dbe[r]:Ebe[r],e),type:a})}var Pbe={pill:"cursor-pointer rounded border px-2 py-1 font-mono text-xs font-semibold uppercase leading-tight transition-colors focus-visible:outline focus-visible:outline-1 focus-visible:outline-cyan-300/55",segment:"h-7 min-w-10 cursor-pointer rounded border px-2 font-mono text-xs transition-colors focus-visible:outline focus-visible:outline-1 focus-visible:outline-cyan-300/55",text:"cursor-pointer border-0 bg-transparent px-1.5 py-1 font-mono uppercase tracking-normal underline-offset-4 transition-colors focus-visible:outline focus-visible:outline-1 focus-visible:outline-cyan-300/55"},Dbe={pill:"border-dashboard-border-heavy bg-dashboard-text-solid text-dashboard-text-inverse",segment:"border-amber-500/30 bg-amber-500/20 text-amber-400",text:"text-dashboard-text underline decoration-dashboard-text-solid"},Ebe={pill:"border-dashboard-border-strong bg-dashboard-surface-raised text-dashboard-text-muted hover:border-dashboard-border-interactive hover:bg-dashboard-surface-hover hover:text-dashboard-text",segment:"border-dashboard-border-strong bg-dashboard-fill-faint text-dashboard-text-muted hover:bg-dashboard-fill-strong hover:text-dashboard-text",text:"text-dashboard-text-muted hover:text-dashboard-text"};var vm=b(w(),1);function Yr(e){let t=e.tone==="error";return(0,vm.jsxs)("div",{role:t?"alert":"status",className:I("flex min-w-0 gap-3 rounded-md border p-4",t?"border-rose-300/25 bg-rose-300/5":"border-amber-300/25 bg-amber-300/5"),children:[(0,vm.jsx)(Kr,{"aria-hidden":!0,size:18,className:I("mt-0.5 shrink-0",t?"text-rose-300":"text-amber-300")}),(0,vm.jsxs)("div",{className:"min-w-0",children:[(0,vm.jsx)("p",{className:"m-0 text-sm font-medium",children:e.title}),e.children?(0,vm.jsx)("div",{className:"mt-1 text-sm leading-relaxed text-dashboard-text-muted",children:e.children}):null]})]})}var bx=b(w(),1),Mbe={accent:"text-violet-300",danger:"text-rose-300",info:"text-cyan-300",neutral:"text-dashboard-text-muted",success:"text-emerald-300",warning:"text-amber-300"},Obe={compact:"text-xs",default:"text-sm"};function ba(e){return(0,bx.jsxs)("span",{className:I("inline-flex w-fit items-center gap-1.5 font-sans font-medium normal-case leading-snug tracking-normal",Obe[e.size??"default"],Mbe[e.tone??"neutral"],e.className),children:[(0,bx.jsx)("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full bg-current"}),(0,bx.jsx)("span",{className:"block first-letter:uppercase",children:e.children})]})}var XG=b(w(),1);function U(e){let t=e.as??"div",a={none:"",sm:"p-4",md:"p-5 sm:p-6"}[e.padding??"none"],r=e.variant==="section"?"mb-4 border-dashboard-border-subtle bg-dashboard-fill-faint shadow-[0_24px_80px_rgba(0,0,0,0.18)]":e.variant==="raised"?"border-dashboard-border-emphasis bg-dashboard-surface-raised":"border-dashboard-border-subtle bg-dashboard-fill-faint";return(0,XG.jsx)(t,{className:I("min-w-0 overflow-hidden rounded-lg border",r,a,e.className),children:e.children})}var YG=b(w(),1);function Qe(e){let t=e.as??"div";return(0,YG.jsx)(t,{"aria-hidden":"true",className:I("animate-pulse rounded bg-dashboard-fill-soft motion-reduce:animate-none",e.className)})}var ot=b(w(),1);function Yn(e){let t=e.variant??"panel";return(0,ot.jsxs)("div",{"aria-busy":"true","aria-live":"polite",className:I("grid gap-4",e.className),role:"status",children:[(0,ot.jsx)("span",{className:"sr-only",children:e.label}),zbe(t)]})}function zbe(e){switch(e){case"stats":return(0,ot.jsx)(Ube,{});case"overview":return(0,ot.jsx)(jbe,{});case"list":return(0,ot.jsx)(Bbe,{});case"library":return(0,ot.jsx)(Fbe,{});case"panel":return(0,ot.jsx)(Vl,{className:"min-h-64"})}}function Ube(){return(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsx)("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:Array.from({length:4},(e,t)=>(0,ot.jsx)(Vl,{className:"min-h-[7.5rem] p-4 sm:min-h-32 sm:p-5"},t))}),(0,ot.jsx)(Vl,{className:"min-h-[17rem]"})]})}function jbe(){return(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsxs)("div",{className:"grid gap-4 xl:grid-cols-2",children:[(0,ot.jsx)(Vl,{className:"min-h-[17rem]"}),(0,ot.jsx)(Vl,{className:"min-h-[17rem]"})]}),(0,ot.jsx)(pg,{className:"h-24 border-y border-dashboard-border-subtle bg-dashboard-fill-faint"}),(0,ot.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,ot.jsx)(Vl,{className:"min-h-56"}),(0,ot.jsx)(Vl,{className:"min-h-56"})]})]})}function Bbe(){return(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsx)(Vl,{className:"min-h-20 p-4"}),(0,ot.jsx)(pg,{className:"h-10 border-b border-dashboard-border-subtle"}),(0,ot.jsx)(Vl,{className:"min-h-80"})]})}function Fbe(){return(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsxs)("div",{className:"flex flex-wrap items-end justify-between gap-4",children:[(0,ot.jsx)(pg,{className:"h-7 w-56 rounded bg-dashboard-fill-soft"}),(0,ot.jsx)(pg,{className:"h-10 w-full max-w-md rounded-lg border border-dashboard-border-subtle bg-dashboard-fill-faint sm:w-72"})]}),(0,ot.jsx)("div",{"aria-hidden":"true",className:"grid min-w-0 grid-cols-3 gap-1 border-b border-dashboard-border-subtle sm:flex",children:Array.from({length:3},(e,t)=>(0,ot.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2.5 sm:justify-start",children:[(0,ot.jsx)(pg,{className:"h-3 w-12 rounded bg-dashboard-fill-soft"}),(0,ot.jsx)(pg,{className:"h-5 w-8 rounded-sm border border-dashboard-border-subtle bg-dashboard-fill-faint"})]},t))}),(0,ot.jsx)(Vl,{className:"min-h-80"})]})}function Vl(e){return(0,ot.jsx)(U,{className:I("animate-pulse motion-reduce:animate-none",e.className),children:(0,ot.jsx)("span",{"aria-hidden":"true"})})}function pg(e){return(0,ot.jsx)(Qe,{className:e.className})}var mz=b(w(),1),Hbe=[1,7,30,90];function pz(e){return e===1?"24h":`${e}d`}function hg(e){return e===1?"last 24 hours":`last ${e} days`}function Ha(e){return e===1?"hour":e===7?"6hour":"day"}function eK(e){return e===1}function qbe(e){return e===7}function eo(e){return e==="hour"?"hour":e==="6hour"?"6h":"day"}function gg(e){return e==="hour"?"hour":e==="6hour"?"6 hours":"day"}function xx(e){return e==="hour"?"Hourly":e==="6hour"?"6-hour":"Daily"}function en(e){return eK(e.range)&&e.hours?.length?e.hours.slice(-24):eK(e.range)?e.days.slice(-1):qbe(e.range)?e.sixHours?.length?[...e.sixHours]:e.hours?.length&&e.emptySixHour?Vbe({empty:e.emptySixHour,hours:e.hours}):e.days.slice(-e.range):e.days.slice(-e.range)}function Vbe(e){let t=new Map;for(let a of e.hours){let r=Date.parse(`${a.date}:00:00.000Z`);if(Number.isNaN(r))continue;let n=new Date(r);n.setUTCMinutes(0,0,0),n.setUTCHours(Math.floor(n.getUTCHours()/6)*6,0,0,0);let o=n.toISOString().slice(0,13),s={...t.get(o)??e.empty(o),date:o};for(let[l,c]of Object.entries(a))if(l!=="date"&&typeof c=="number"){let d=s[l];s[l]=(typeof d=="number"?d:0)+c}t.set(o,s)}if(e.hours.length>=24){let a=e.hours[e.hours.length-1]?.date,r=a?Date.parse(`${a}:00:00.000Z`):Date.now(),n=new Date(r);n.setUTCMinutes(0,0,0),n.setUTCHours(Math.floor(n.getUTCHours()/6)*6,0,0,0);let o=new Date(n.getTime()-9720*60*1e3),i=[];for(let s=new Date(o);s.getTime()<=n.getTime();s.setTime(s.getTime()+360*60*1e3)){let l=s.toISOString().slice(0,13);i.push(t.get(l)??e.empty(l))}return i}return[...t.values()].sort((a,r)=>a.date.localeCompare(r.date))}function vg(e){return(0,mz.jsx)("div",{"aria-label":"Reporting period",className:"flex items-center gap-1",role:"group",children:(e.options??Hbe).map(t=>(0,mz.jsx)(Ln,{onClick:()=>e.onChange(t),pressed:e.value===t,variant:"segment",children:pz(t)},t))})}var Nd=b(w(),1);function We(e){let t=e.range!==void 0&&e.onRangeChange?(0,Nd.jsx)(vg,{onChange:e.onRangeChange,...e.rangeOptions?{options:e.rangeOptions}:{},value:e.range}):void 0,a=e.actions??t;return(0,Nd.jsxs)("header",{className:"flex min-w-0 items-center justify-between gap-6 border-b border-white/[0.05] pb-4 sm:pb-6 max-md:flex-col max-md:items-stretch",children:[(0,Nd.jsxs)("div",{className:"min-w-0",children:[(0,Nd.jsx)("h2",{className:"m-0 font-display text-3xl font-light leading-none tracking-[-0.03em] text-dashboard-text sm:text-4xl",children:e.title}),(0,Nd.jsx)("div",{className:"mt-2 max-w-2xl font-mono text-xs leading-relaxed text-dashboard-text-muted sm:text-sm",children:e.description})]}),a?(0,Nd.jsx)("div",{className:"shrink-0",children:a}):null]})}var tK=b(w(),1);function So(e){return(0,tK.jsx)("div",{className:I(Ya,"grid min-w-0 content-start gap-4 px-4 py-4 pb-[max(1rem,env(safe-area-inset-bottom))] sm:gap-6 sm:px-8 sm:py-8 sm:pb-8",e.className),children:e.children})}var bm=b(G(),1);var ym=b(G(),1);function Ni(e,t){let a=typeof t=="string"?t.startsWith("?")?t.slice(1):t:t?.toString()??"",r=e.indexOf("?"),n=r===-1?e:e.slice(0,r),o=r===-1?"":e.slice(r+1).replace(/^\?+/,""),i=new URLSearchParams(a);for(let[l,c]of new URLSearchParams(o))i.set(l,c);let s=i.toString();return s?`${n}?${s}`:n}function Zbe(e,t){let a=e?.trim();return a&&t.includes(a)?a:void 0}function Zl(e="q",t={}){let a=t.delayMs??250,r=t.resetPage??!1,[n,o]=Ho(),i=n.get(e)?.trim()??"",[s,l]=(0,ym.useState)(i);return(0,ym.useEffect)(()=>{l(c=>c.trim()===i?c:i)},[i]),(0,ym.useEffect)(()=>{let c=window.setTimeout(()=>{let d=s.trim();d!==i&&o(f=>{let m=new URLSearchParams(f);return r&&m.delete("page"),d?m.set(e,d):m.delete(e),m},{replace:!0})},a);return()=>window.clearTimeout(c)},[i,a,e,r,o,s]),[s,l,i]}function ec(e,t,a){let[r,n]=Ho(),o=Zbe(r.get(e),a)??t,i=(0,ym.useCallback)(s=>{n(l=>{let c=new URLSearchParams(l);return s===t?c.delete(e):c.set(e,s),c},{replace:!0})},[t,e,n]);return[o,i]}var aK=b(G(),1);var yg=b(w(),1),hz="rounded-lg border border-dashboard-border bg-dashboard-surface-panel",gz="gap-1 p-1";function vz(e){return I("min-h-9 cursor-pointer rounded-md border-0 px-3 py-2 font-sans text-sm font-medium transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus",e?"bg-dashboard-fill-strong text-dashboard-text":"bg-transparent text-dashboard-text-muted hover:bg-dashboard-fill-faint hover:text-dashboard-text")}function w1(e){let t=(0,aK.useId)();return(0,yg.jsxs)("div",{className:"grid min-w-0 gap-4",children:[(0,yg.jsx)("div",{"aria-label":e.label,className:I("grid auto-cols-fr grid-flow-col",hz,gz),role:"tablist",children:e.items.map((a,r)=>(0,yg.jsx)("button",{"aria-controls":`${t}-panel`,"aria-selected":e.value===a.value,className:I("min-w-0",vz(e.value===a.value)),id:`${t}-${a.value}`,onClick:()=>e.onChange(a.value),onKeyDown:n=>{let o,i=e.items.length;switch(n.key){case"ArrowLeft":o=(r+i-1)%i;break;case"ArrowRight":o=(r+1)%i;break;case"Home":o=0;break;case"End":o=i-1;break;default:return}n.preventDefault(),e.onChange(e.items[o].value),n.currentTarget.parentElement?.querySelectorAll('[role="tab"]')[o]?.focus()},role:"tab",tabIndex:e.value===a.value?0:-1,type:"button",children:a.label},a.value))}),(0,yg.jsx)("div",{"aria-labelledby":`${t}-${e.value}`,className:"min-w-0 rounded focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus",id:`${t}-panel`,role:"tabpanel",tabIndex:0,children:e.children})]})}var bg=b(w(),1);function bz(e){let{className:t,item:a}=e,r=vt(),n=Ni(a.to,r.search);if(a.isActive){let o=a.isActive(r.pathname);return(0,bg.jsx)(ae,{"aria-current":o?"page":void 0,className:t({isActive:o}),to:n,children:a.label})}return(0,bg.jsx)(Uf,{className:t,end:a.end,to:n,children:a.label})}var yz=24;function rK(e){let t=e.scrollWidth-e.clientWidth;return{end:e.scrollLeft<t-1,start:e.scrollLeft>1}}function nK(e){let t=e.querySelector('[aria-current="page"]');if(!t||e.clientWidth===0)return;let a=rK(e),r=e.scrollLeft+(a.start?yz:0),n=e.scrollLeft+e.clientWidth-(a.end?yz:0),o=t.offsetLeft,i=o+t.offsetWidth;o>=r&&i<=n||(e.scrollLeft=o-(e.clientWidth-t.offsetWidth)/2)}function Gbe(e){if(!e.start&&!e.end)return;let t=`${yz}px`,a=e.start?`transparent, black ${t}`:"black",r=e.end?`black calc(100% - ${t}), transparent`:"black",n=`linear-gradient(to right, ${a}, ${r})`;return{maskImage:n,WebkitMaskImage:n}}function xm(e){let{pathname:t}=vt(),a=(0,bm.useRef)(null),[r,n]=(0,bm.useState)({end:!1,start:!1});(0,bm.useLayoutEffect)(()=>{let i=a.current;if(!i)return;let s=()=>{let{end:c,start:d}=rK(i);n(f=>f.start===d&&f.end===c?f:{end:c,start:d})},l=new ResizeObserver(()=>{nK(i),s()});return s(),i.addEventListener("scroll",s,{passive:!0}),l.observe(i),()=>{i.removeEventListener("scroll",s),l.disconnect()}},[]),(0,bm.useLayoutEffect)(()=>{a.current&&nK(a.current)},[t]);let o=({isActive:i})=>I(vz(i),"flex items-center justify-center whitespace-nowrap no-underline",e.fill?"min-w-max flex-[1_0_0]":"shrink-0");return(0,bg.jsx)("nav",{"aria-label":e.ariaLabel,className:I(hz,"flex min-w-0 max-w-full",!e.fill&&"w-fit"),children:(0,bg.jsx)("div",{className:I(gz,"relative flex min-w-0 flex-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"),ref:a,style:Gbe(r),children:e.items.map(i=>(0,bg.jsx)(bz,{className:o,item:i},i.to))})})}var Gt=b(G(),1),Sx=b(Tl(),1),Qs=b(w(),1),Gl=(0,Gt.createContext)(null);function C1(e){let[t,a]=(0,Gt.useState)(null),[r,n]=(0,Gt.useState)(null),[o,i]=(0,Gt.useState)(null),[s,l]=(0,Gt.useState)(null),c=(0,Gt.useRef)(null),d=(0,Gt.useCallback)(y=>{a(y)},[]),f=(0,Gt.useCallback)(y=>{n(y)},[]),m=(0,Gt.useCallback)(y=>{i(y)},[]),p=(0,Gt.useCallback)(y=>{l(y)},[]),h=(0,Gt.useCallback)(y=>{c.current=y},[]),g=(0,Gt.useCallback)(()=>{c.current?.()},[]),x=(0,Gt.useMemo)(()=>({mobileHeaderActionsSlot:o,mobileHeaderActionsSlotRef:m,mobileHeaderLiveSlot:s,mobileHeaderLiveSlotRef:p,mobileSecondarySlot:r,mobileSecondarySlotRef:f,openMobileNavigation:g,registerOpenMobileNavigation:h,secondarySlot:t,secondarySlotRef:d}),[o,m,s,p,r,f,g,h,t,d]);return(0,Qs.jsx)(Gl.Provider,{value:x,children:e.children})}function oK(e){let t=(0,Gt.useContext)(Gl);if(!t)throw new Error("DashboardChrome requires DashboardChromeProvider");return(0,Qs.jsxs)("div",{className:"sticky top-0 z-30 bg-dashboard-bg/95 pt-[env(safe-area-inset-top)]",children:[e.header,(0,Qs.jsx)("div",{className:"hidden md:block",ref:t.secondarySlotRef}),e.banner]})}function iK(){let e=(0,Gt.useContext)(Gl);if(!e)throw new Error("MobileSecondaryNavigationSlot requires DashboardChromeProvider");return(0,Qs.jsx)("div",{ref:e.mobileSecondarySlotRef})}function sK(){let e=(0,Gt.useContext)(Gl);if(!e)throw new Error("MobileHeaderActionsSlot requires DashboardChromeProvider");return(0,Qs.jsx)("div",{className:"col-start-3 row-start-1 flex min-w-0 items-center justify-self-end md:hidden",ref:e.mobileHeaderActionsSlotRef})}function lK(){let e=(0,Gt.useContext)(Gl);if(!e)throw new Error("MobileHeaderLiveSlot requires DashboardChromeProvider");return(0,Qs.jsx)("div",{className:"flex shrink-0 items-center md:hidden",ref:e.mobileHeaderLiveSlotRef})}function uK(e){let t=(0,Gt.useContext)(Gl);return t?.mobileHeaderActionsSlot?(0,Sx.createPortal)(e.children,t.mobileHeaderActionsSlot):null}function cK(e){let t=(0,Gt.useContext)(Gl);return t?.mobileHeaderLiveSlot?(0,Sx.createPortal)(e.children,t.mobileHeaderLiveSlot):null}function dK(){let e=(0,Gt.useContext)(Gl);return e?e.openMobileNavigation:null}function fK(e){let t=(0,Gt.useContext)(Gl),a=(0,Gt.useRef)(e);a.current=e,(0,Gt.useEffect)(()=>{if(!t)return;let r=()=>{a.current?.()};return t.registerOpenMobileNavigation(e?r:null),()=>{t.registerOpenMobileNavigation(null)}},[t,e])}function mK(e){let t=(0,Gt.useContext)(Gl);return t?t.secondarySlot?(0,Qs.jsxs)(Qs.Fragment,{children:[(0,Sx.createPortal)(e.desktop,t.secondarySlot),t.mobileSecondarySlot?(0,Sx.createPortal)(e.mobile,t.mobileSecondarySlot):null]}):null:e.desktop}var Xs=b(w(),1);function Ad(e){let t=({isActive:a})=>I("rounded-lg px-3 py-3 pl-6 font-mono text-sm font-medium no-underline transition-colors",a?"bg-cyan-300/[0.1] text-cyan-50":I("hover:bg-white/[0.035]",gm));return(0,Xs.jsxs)("div",{className:"min-w-0",children:[(0,Xs.jsx)(mK,{desktop:(0,Xs.jsx)("div",{className:"border-b border-white/[0.06] bg-white/[0.018]",children:(0,Xs.jsx)("div",{className:I(Ya,"min-w-0 px-4 py-2 md:px-8"),children:(0,Xs.jsx)(xm,{ariaLabel:e.ariaLabel,items:e.items})})}),mobile:(0,Xs.jsx)("nav",{"aria-label":e.ariaLabel,className:"mt-3 grid gap-1 border-t border-white/[0.07] pt-3",children:e.items.map(a=>(0,Xs.jsx)(bz,{className:t,item:a},a.to))})}),(0,Xs.jsx)("div",{className:"px-4 pt-4 sm:px-8 md:hidden",children:(0,Xs.jsx)(xm,{ariaLabel:e.ariaLabel,fill:!0,items:e.items})}),e.children]})}var Kl=b(w(),1),Kbe=new Set(["list","runs"]);function Wbe(e){if(e==="/automations/list"||/^\/automations\/(scheduled|event)\/[^/]+\/edit$/.test(e))return!0;let t=e.match(/^\/automations\/([^/]+)$/);return!!(t?.[1]&&!Kbe.has(t[1]))}var Jbe=[{end:!0,label:"Overview",to:"/automations"},{isActive:Wbe,label:"Automations",to:"/automations/list"},{label:"Runs",to:"/automations/runs"}];function xz(e){return(0,Kl.jsx)(Ad,{ariaLabel:"Automations navigation",items:Jbe,children:e.children})}function Ai(e){return(0,Kl.jsx)(xz,{children:(0,Kl.jsx)(So,{children:e.children})})}function Sm(e){return(0,Kl.jsxs)(Kl.Fragment,{children:[(0,Kl.jsx)(We,{description:e.description,title:e.title}),(0,Kl.jsx)(Yn,{label:e.label,variant:e.variant})]})}var ps=b(G(),1);var xg=b(w(),1),Qbe={compact:"font-mono text-xs uppercase tracking-[0.12em] text-dashboard-text-muted",default:"text-sm font-semibold text-dashboard-text"},Xbe={compact:"grid gap-1.5",default:"grid gap-2"};function Ot(e){let t=e.size??"default";return(0,xg.jsxs)("div",{className:I(Xbe[t],e.className),children:[(0,xg.jsx)("label",{className:Qbe[t],htmlFor:e.htmlFor,children:e.label}),e.children,e.error?(0,xg.jsx)("p",{id:e.htmlFor?`${e.htmlFor}-error`:void 0,role:"alert",className:"m-0 text-xs leading-relaxed text-rose-300",children:e.error}):null,e.help?(0,xg.jsx)("p",{id:e.htmlFor?`${e.htmlFor}-help`:void 0,className:"m-0 text-xs leading-relaxed text-dashboard-text-muted sm:text-sm",children:e.help}):null]})}var Sz=b(w(),1),pK="block w-full rounded border border-dashboard-border-emphasis bg-dashboard-ink px-3 py-2 text-sm text-dashboard-text focus:border-dashboard-focus focus:outline-none aria-invalid:border-rose-300 disabled:cursor-not-allowed disabled:opacity-50";function xa({className:e,type:t="text",size:a="default",...r}){return(0,Sz.jsx)("input",{...r,className:I(pK,a==="comfortable"&&"min-h-11 text-base sm:min-h-10 sm:text-sm",e),type:t})}function tc({className:e,prose:t=!1,...a}){return(0,Sz.jsx)("textarea",{...a,className:I(pK,"min-h-36",t?"font-sans leading-relaxed":"font-mono",e)})}var wm=b(w(),1);function ms(e){return(0,wm.jsxs)("section",{className:"grid min-w-0 gap-5 border-t border-dashboard-border-emphasis py-8 md:grid-cols-[12rem_minmax(0,1fr)] md:gap-10",children:[(0,wm.jsxs)("div",{children:[(0,wm.jsx)("h2",{className:"m-0 font-display text-lg font-medium",children:e.title}),e.detail?(0,wm.jsx)("p",{className:"mt-2 mb-0 text-sm leading-relaxed text-dashboard-text-muted",children:e.detail}):null]}),(0,wm.jsx)("div",{className:"grid min-w-0 content-start gap-5",children:e.children})]})}var T1=b(G(),1);var hK=b(w(),1);function Wl({className:e,...t}){return(0,hK.jsx)("select",{...t,className:I("block min-h-11 w-full min-w-0 rounded border border-dashboard-border-emphasis bg-dashboard-ink px-3 py-2 text-base text-dashboard-text focus:border-dashboard-focus focus:outline-none aria-invalid:border-rose-300 disabled:cursor-not-allowed disabled:opacity-60 sm:min-h-10 sm:text-sm",e)})}var k1=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function I1(e){return{title:e.title??"",instruction:e.instruction,credentialMode:e.credentialMode,outcomes:e.outcomes,trigger:e.kind==="event"?e.trigger:void 0}}function L1(e){let t=e.schedule.recurrence;if(e.schedule.kind==="recurring"&&t){let{time:a,weekdays:r,...n}=t;return{kind:"recurring",...n,timezone:e.schedule.timezone,time:`${String(a.hour).padStart(2,"0")}:${String(a.minute).padStart(2,"0")}`,weekdays:r?.map(o=>k1[o])}}if(e.nextRunAtMs){let a=new Intl.DateTimeFormat("en-CA",{timeZone:e.schedule.timezone,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(e.nextRunAtMs),r=n=>a.find(o=>o.type===n)?.value??"";return{kind:"one_off",timezone:e.schedule.timezone,timing:{type:"at",date:`${r("year")}-${r("month")}-${r("day")}`,time:`${r("hour")}:${r("minute")}`}}}return{kind:"recurring",frequency:"daily",time:"09:00",timezone:e.schedule.timezone}}function gK(e,t){let a={};return t.title!==(e.title??"")&&(a.title=t.title),t.instruction!==e.instruction&&(a.instruction=t.instruction),t.credentialMode!==e.credentialMode&&(a.credentialMode=t.credentialMode),JSON.stringify(t.outcomes)!==JSON.stringify(e.outcomes)&&(a.outcomes=t.outcomes),e.kind==="scheduled"&&t.schedule&&(a.schedule=t.schedule),e.kind==="event"&&JSON.stringify(t.trigger)!==JSON.stringify(e.trigger)&&(a.trigger=t.trigger),a}var He=b(w(),1);function vK(e){let t=e.value??L1(e.automation),[a,r]=(0,T1.useState)(e.value);(0,T1.useEffect)(()=>{let f=setTimeout(()=>r(e.value),300);return()=>clearTimeout(f)},[e.value]);let n=HE.safeParse(a),o=Be({queryKey:["dashboard","automation-schedule-preview",e.automation.id,a],enabled:!!a&&n.success,retry:!1,queryFn:()=>xo(qE,`/api/automations/scheduled/${encodeURIComponent(e.automation.id)}/preview`,a)}),i=t.kind==="recurring"?t.frequency:"once",s=t.kind==="recurring"?t.time:t.timing.time,l=e.value?o.data?.nextRunAtMs:e.automation.nextRunAtMs,c=e.value!==a||o.isFetching,d=o.error instanceof yn?o.error.apiError:o.error?"Schedule preview could not be loaded. Try again.":e.value&&!n.success&&!c?n.error.issues[0]?.message:void 0;return(0,He.jsxs)(He.Fragment,{children:[(0,He.jsxs)("div",{className:"grid grid-cols-1 items-start gap-4 sm:grid-cols-2",children:[(0,He.jsx)(Ot,{label:"Repeat",htmlFor:"schedule-frequency",children:(0,He.jsxs)(Wl,{id:"schedule-frequency",value:i,onChange:f=>{let m=f.target.value;m!=="once"&&m!=="daily"&&m!=="weekly"&&m!=="monthly"&&m!=="yearly"||e.onChange(m==="once"?{kind:"one_off",timezone:t.timezone??e.automation.schedule.timezone,timing:{type:"at",date:"",time:s}}:{kind:"recurring",timezone:t.timezone,time:s,frequency:m,interval:1,weekdays:m==="weekly"?["monday"]:void 0,dayOfMonth:["monthly","yearly"].includes(m)?1:void 0,month:m==="yearly"?1:void 0})},children:[(0,He.jsx)("option",{value:"once",children:"Once"}),(0,He.jsx)("option",{value:"daily",children:"Every day"}),(0,He.jsx)("option",{value:"weekly",children:"Every week"}),(0,He.jsx)("option",{value:"monthly",children:"Every month"}),(0,He.jsx)("option",{value:"yearly",children:"Every year"})]})}),(0,He.jsx)(Ot,{label:"Time",htmlFor:"schedule-time",children:(0,He.jsx)(xa,{size:"comfortable",id:"schedule-time",type:"time",value:s,onChange:f=>e.onChange(t.kind==="recurring"?{...t,time:f.target.value}:{...t,timing:{type:"at",date:t.timing.date,time:f.target.value}})})})]}),t.kind==="recurring"?(0,He.jsxs)(He.Fragment,{children:[t.frequency==="weekly"?(0,He.jsxs)("fieldset",{children:[(0,He.jsx)("legend",{className:"mb-2 text-sm font-semibold",children:"On"}),(0,He.jsx)("div",{className:"grid grid-cols-7 gap-1.5",children:[...k1.slice(1),k1[0]].map(f=>(0,He.jsx)("button",{type:"button","aria-label":f,"aria-pressed":t.weekdays?.includes(f)??!1,onClick:()=>e.onChange({...t,weekdays:t.weekdays?.includes(f)?t.weekdays.filter(m=>m!==f):[...t.weekdays??[],f]}),className:I("min-h-11 cursor-pointer rounded border px-1 text-xs font-medium capitalize focus-visible:outline-2 focus-visible:outline-dashboard-focus sm:min-h-10 sm:text-sm",t.weekdays?.includes(f)?"border-dashboard-focus/50 bg-dashboard-focus/10 text-dashboard-focus":"border-dashboard-border-emphasis text-dashboard-text-muted hover:bg-dashboard-fill-hover"),children:f.slice(0,3)},f))})]}):null,(0,He.jsxs)("div",{className:"grid grid-cols-1 items-start gap-4 sm:grid-cols-2",children:[(0,He.jsx)(Ot,{label:"Interval",htmlFor:"schedule-interval",help:"Number of calendar periods between runs.",children:(0,He.jsx)(xa,{size:"comfortable",id:"schedule-interval",type:"number",min:1,max:365,value:t.interval??1,onChange:f=>e.onChange({...t,interval:f.target.valueAsNumber})})}),(0,He.jsx)(Ot,{label:"Start date",htmlFor:"schedule-start",children:(0,He.jsx)(xa,{size:"comfortable",id:"schedule-start",type:"date",value:t.startDate??"",onChange:f=>e.onChange({...t,startDate:f.target.value||void 0})})})]}),t.frequency==="monthly"||t.frequency==="yearly"?(0,He.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[(0,He.jsx)(Ot,{label:"Day of month",htmlFor:"schedule-day",children:(0,He.jsx)(xa,{size:"comfortable",id:"schedule-day",type:"number",min:1,max:31,value:t.dayOfMonth??1,onChange:f=>e.onChange({...t,dayOfMonth:f.target.valueAsNumber})})}),t.frequency==="yearly"?(0,He.jsx)(Ot,{label:"Month",htmlFor:"schedule-month",children:(0,He.jsx)(Wl,{id:"schedule-month",value:t.month??1,onChange:f=>e.onChange({...t,month:Number(f.target.value)}),children:Array.from({length:12},(f,m)=>(0,He.jsx)("option",{value:m+1,children:new Intl.DateTimeFormat("en",{month:"long",timeZone:"UTC"}).format(new Date(Date.UTC(2026,m,1)))},m))})}):null]}):null]}):(0,He.jsx)(Ot,{label:"Date",htmlFor:"schedule-date",children:(0,He.jsx)(xa,{size:"comfortable",id:"schedule-date",type:"date",value:t.timing.date,onChange:f=>e.onChange({...t,timing:{type:"at",time:s,date:f.target.value}})})}),(0,He.jsxs)(Ot,{label:"Timezone",htmlFor:"schedule-timezone",help:"Use an IANA timezone. The schedule follows local time, including daylight saving time.",children:[(0,He.jsx)(xa,{size:"comfortable",id:"schedule-timezone",list:"automation-timezones",value:t.timezone??"",onChange:f=>e.onChange({...t,timezone:f.target.value})}),(0,He.jsx)("datalist",{id:"automation-timezones",children:["UTC",...Intl.supportedValuesOf("timeZone")].map(f=>(0,He.jsx)("option",{children:f},f))})]}),(0,He.jsxs)("div",{role:"status",className:"flex gap-3 rounded-md bg-dashboard-fill-soft p-3 text-sm leading-relaxed",children:[(0,He.jsx)(Fs,{"aria-hidden":!0,size:17,className:"mt-0.5 shrink-0 text-dashboard-text-muted"}),(0,He.jsx)("div",{children:c?"Checking schedule\u2026":d?(0,He.jsxs)(He.Fragment,{children:[(0,He.jsx)("span",{className:"text-rose-300",children:d}),o.error?(0,He.jsx)(ie,{onClick:()=>{o.refetch()},children:"Try again"}):null]}):l?(0,He.jsxs)(He.Fragment,{children:["Next run"," ",new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short",timeZone:e.value?o.data?.schedule.timezone??"UTC":e.automation.schedule.timezone}).format(l)]}):"No next run."})]}),e.value?(0,He.jsx)(ie,{className:"w-fit",onClick:()=>e.onChange(void 0),children:"Keep saved schedule"}):null]})}var ht=b(w(),1);function yK(e){let t=Be({queryKey:["dashboard","automation-event-catalog"],queryFn:({signal:o})=>Pe(FE,"/api/automations/event-catalog",o),retry:!1}),a=t.data?.find(o=>o.namespace===e.value.namespace&&o.type===e.value.resourceType),r=!a||e.value.events.some(o=>!a.supportedEvents.includes(o))||Object.entries(e.value.match??{}).some(([o,i])=>{let s=a.matchFields?.[o];return s?(Array.isArray(i)?i:[i]).some(l=>typeof l!==s.kind||s.enum&&!s.enum.includes(String(l))):!0}),n=(o,i)=>{let s={...e.value.match};i===void 0?delete s[o]:s[o]=i,e.onChange({...e.value,match:s})};return(0,ht.jsxs)(ht.Fragment,{children:[t.error?(0,ht.jsxs)(Yr,{title:"Event choices could not be loaded.",children:["Saved values are kept."," ",(0,ht.jsx)(ie,{onClick:()=>{t.refetch()},children:"Try again"})]}):t.isPending?(0,ht.jsx)("p",{role:"status",children:"Loading event choices\u2026"}):null,r&&t.data?(0,ht.jsxs)(Yr,{title:"Saved trigger \xB7 Kept unchanged",children:["Some saved values are not in the current catalog. You can edit other fields, or select a new resource type to replace the trigger.",(0,ht.jsx)("pre",{className:"whitespace-pre-wrap break-all text-xs",children:JSON.stringify(e.value,null,2)})]}):null,(0,ht.jsx)(Ot,{label:r?"Replace trigger":"Resource type",htmlFor:"trigger-resource",children:(0,ht.jsxs)(Wl,{id:"trigger-resource",value:r?"":`${e.value.namespace}:${e.value.resourceType}`,onChange:o=>{let i=t.data?.find(s=>`${s.namespace}:${s.type}`===o.target.value);i&&window.confirm("Replace the saved trigger? Its resource, events, and conditions will be cleared.")&&e.onChange({namespace:i.namespace,resourceType:i.type,identifier:"",label:"",events:[]})},children:[(0,ht.jsx)("option",{value:"",disabled:!0,children:"Keep saved trigger"}),t.data?.map(o=>(0,ht.jsxs)("option",{value:`${o.namespace}:${o.type}`,children:[o.namespace," \xB7 ",o.type.replaceAll("_"," ")]},`${o.namespace}:${o.type}`))]})}),!r&&a?(0,ht.jsxs)(ht.Fragment,{children:[(0,ht.jsx)(Ot,{label:"Resource name",htmlFor:"trigger-label",children:(0,ht.jsx)(xa,{size:"comfortable",id:"trigger-label",value:e.value.label,onChange:o=>e.onChange({...e.value,label:o.target.value})})}),(0,ht.jsx)(Ot,{label:"Resource identifier",htmlFor:"trigger-identifier",help:"Use the exact provider resource identifier, not its display name.",children:(0,ht.jsx)(xa,{size:"comfortable",id:"trigger-identifier",value:e.value.identifier,onChange:o=>e.onChange({...e.value,identifier:o.target.value})})}),(0,ht.jsxs)("fieldset",{children:[(0,ht.jsx)("legend",{className:"mb-2 text-sm font-semibold",children:"Run on these events"}),(0,ht.jsx)("div",{className:"divide-y divide-dashboard-border-subtle rounded-md border border-dashboard-border-emphasis",children:a.supportedEvents.map(o=>(0,ht.jsxs)("label",{className:"flex min-h-11 cursor-pointer items-start gap-3 px-3 py-3 text-sm",children:[(0,ht.jsx)("input",{type:"checkbox",className:"mt-0.5 size-4 shrink-0 accent-dashboard-focus",checked:e.value.events.includes(o),onChange:()=>e.onChange({...e.value,events:e.value.events.includes(o)?e.value.events.filter(i=>i!==o):[...e.value.events,o]})}),(0,ht.jsxs)("span",{className:"min-w-0 break-words",children:[o.replaceAll("_"," ").replaceAll("."," \xB7 "),a.guidance?.[o]?(0,ht.jsx)("span",{className:"mt-1 block text-xs leading-relaxed text-dashboard-text-muted",children:a.guidance[o]}):null]})]},o))})]}),Object.keys(a.matchFields??{}).length?(0,ht.jsxs)("fieldset",{className:"grid gap-4",children:[(0,ht.jsx)("legend",{className:"mb-3 text-sm font-semibold",children:"Only when"}),(0,ht.jsx)("p",{className:"m-0 text-xs leading-relaxed text-dashboard-text-muted",children:"All conditions must match. Leave a field blank to match any value. Existing lists match any one listed value."}),Object.entries(a.matchFields??{}).map(([o,i])=>{let s=e.value.match?.[o];return(0,ht.jsx)(Ot,{label:o,htmlFor:`match-${o}`,help:i.description,children:Array.isArray(s)?(0,ht.jsxs)("div",{className:"text-sm",children:[(0,ht.jsx)("span",{className:"break-all",children:s.join(", ")})," ",(0,ht.jsx)(ie,{onClick:()=>n(o,void 0),children:"Remove condition"})]}):i.kind==="boolean"||i.enum?(0,ht.jsxs)(Wl,{id:`match-${o}`,value:s===void 0?"":String(s),onChange:l=>n(o,l.target.value===""?void 0:i.kind==="boolean"?l.target.value==="true":l.target.value),children:[(0,ht.jsx)("option",{value:"",children:"Any value"}),(i.enum??["true","false"]).map(l=>(0,ht.jsx)("option",{children:l},l))]}):(0,ht.jsx)(xa,{size:"comfortable",id:`match-${o}`,type:i.kind==="number"?"number":"text",step:"any",value:s===void 0?"":String(s),onChange:l=>n(o,l.target.value===""?void 0:i.kind==="number"?l.target.valueAsNumber:l.target.value)})},o)})]}):null]}):null,JSON.stringify(e.value)!==JSON.stringify(e.original)?(0,ht.jsx)(ie,{className:"w-fit",onClick:()=>e.onChange(e.original),children:"Keep saved trigger"}):null]})}function Cm(e,t){return typeof e.destination=="string"?e.destination==="task_creator"?"Creator \xB7 Direct message":`${t.label} \xB7 ${t.visibility}`:e.destination.channelId===t.channelId&&e.destination.teamId===t.teamId?`${t.label} \xB7 ${t.visibility}`:`Saved destination \xB7 ${e.destination.channelId}`}var aa=b(w(),1);function R1(e){return e.outcomes.length?(0,aa.jsx)("ol",{className:"m-0 grid gap-2 pl-5 text-sm",children:e.outcomes.map((t,a)=>(0,aa.jsx)("li",{children:Cm(t,e.destination)},a))}):(0,aa.jsx)("p",{className:"m-0 text-sm",children:"No success message"})}function bK(e){let t=e.original.length?e.original:[{action:"send_message",destination:"current_conversation"}],a=[...e.original.flatMap((r,n)=>typeof r.destination=="string"?[]:[{value:`saved:${n}`,label:Cm(r,e.destination),outcome:r}]),{value:"current_conversation",label:`${e.destination.label} \xB7 ${e.destination.visibility}`,outcome:{action:"send_message",destination:"current_conversation"}},{value:"task_creator",label:"Creator \xB7 Direct message",outcome:{action:"send_message",destination:"task_creator"}}];return(0,aa.jsxs)(aa.Fragment,{children:[(0,aa.jsxs)("fieldset",{children:[(0,aa.jsx)("legend",{className:"sr-only",children:"Success messages"}),(0,aa.jsx)("div",{className:"flex flex-wrap gap-x-6 gap-y-3",children:[!0,!1].map(r=>(0,aa.jsxs)("label",{className:"inline-flex min-h-8 cursor-pointer items-center gap-2 text-sm",children:[(0,aa.jsx)("input",{type:"radio",name:"messages",className:"size-4 accent-dashboard-focus",checked:!!e.value.length===r,onChange:()=>e.onChange(r?t:[])}),r?"Send a message":"No success message"]},String(r)))})]}),e.value.length?(0,aa.jsxs)("div",{className:"grid gap-4 sm:gap-2",children:[e.value.map((r,n)=>{let o=e.original.findIndex(i=>JSON.stringify(i)===JSON.stringify(r));return(0,aa.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,aa.jsxs)("span",{className:"w-4 text-xs text-dashboard-text-muted",children:[n+1,"."]}),(0,aa.jsx)("div",{className:I("min-w-0 flex-1",e.value.length>1&&"order-last basis-full sm:order-none sm:basis-auto"),children:(0,aa.jsx)(Wl,{"aria-label":`Message ${n+1} destination`,value:typeof r.destination=="string"?r.destination:`saved:${o}`,onChange:i=>{let s=a.find(l=>l.value===i.target.value);s&&e.onChange(e.value.map((l,c)=>c===n?s.outcome:l))},children:a.map(i=>(0,aa.jsx)("option",{value:i.value,children:i.label},i.value))})}),e.value.length>1?(0,aa.jsxs)(aa.Fragment,{children:[(0,aa.jsx)(ie,{size:"icon",className:"ml-auto sm:ml-0","aria-label":`Move message ${n+1} up`,disabled:n===0,onClick:()=>{let i=[...e.value];[i[n-1],i[n]]=[i[n],i[n-1]],e.onChange(i)},children:(0,aa.jsx)(zy,{size:16})}),(0,aa.jsx)(ie,{size:"icon","aria-label":`Remove message ${n+1}`,onClick:()=>e.onChange(e.value.filter((i,s)=>s!==n)),children:(0,aa.jsx)(jn,{size:16})})]}):null]},n)}),e.value.length<5?(0,aa.jsxs)(ie,{className:"w-fit",onClick:()=>e.onChange([...e.value,{action:"send_message",destination:"task_creator"}]),children:[(0,aa.jsx)(Ku,{size:15}),"Add message"]}):null]}):(0,aa.jsx)("p",{className:"m-0 text-sm leading-relaxed text-dashboard-text-muted",children:"Junior still does the work. No message is sent after success."}),(0,aa.jsxs)("p",{className:"m-0 text-xs leading-relaxed text-dashboard-text-muted",children:[e.value.length?"Messages are sent in this order. ":"","This does not limit actions in the instruction."]})]})}var ce=b(w(),1);function SK(e){let[t,a]=(0,ps.useState)(e.automation),[r,n]=(0,ps.useState)(()=>I1(e.automation)),[o,i]=(0,ps.useState)({}),[s,l]=(0,ps.useState)(),c=(0,ps.useRef)(null),d=(0,ps.useRef)(!1),f=gn(),m=Bt(),p=gK(t,r),h=Object.keys(p).length>0,g={kind:t.kind,revision:t.revision,...p},x=EN(()=>h&&!d.current),y=(0,ps.useRef)(null);(0,ps.useEffect)(()=>{x.state==="blocked"&&y.current?.focus()},[x.state]);let v=`/api/automations/${t.kind}/${encodeURIComponent(t.id)}`;(0,ps.useEffect)(()=>{let Z=fe=>{h&&!d.current&&(fe.preventDefault(),fe.returnValue="")};return window.addEventListener("beforeunload",Z),()=>window.removeEventListener("beforeunload",Z)},[h]);let S=()=>requestAnimationFrame(()=>(c.current?.querySelector('[aria-invalid="true"]')??c.current?.querySelector("[data-save-error]"))?.focus()),C=ga({mutationFn:()=>dg(ds,v,g),onSuccess:async()=>{d.current=!0,await m.invalidateQueries({queryKey:["dashboard","automations"]}),f(e.returnPath,{state:{automationSaved:!0}})},onError:Z=>{i(Z instanceof yn?Z.fields??{}:{}),S()}});function T(Z){s&&(n(Z?{...I1(s),...p}:I1(s)),a(s),l(void 0),C.reset(),i({}))}let L=ga({mutationFn:()=>Pe(ds,`${v}/edit`),onSuccess:l}),_=C.error instanceof yn&&C.error.code==="conflict",k=Z=>n(fe=>({...fe,...Z})),j=Z=>Object.entries(o).filter(([fe])=>fe===Z||fe.startsWith(`${Z}.`)).flatMap(([,fe])=>fe).join(" ")||void 0,F=t.kind==="scheduled"?"schedule":"trigger",ue=t.ownedByViewer,z=e.summary.createdBy,Y=!ue&&t.credentialMode==="creator"&&(p.instruction!==void 0||t.kind==="event"&&p.trigger!==void 0),ee=j(F),ve=Z=>({"aria-invalid":!!j(Z)||void 0,"aria-describedby":j(Z)?`${Z}-error`:void 0});return(0,ce.jsxs)("form",{ref:c,noValidate:!0,onSubmit:Z=>{if(Z.preventDefault(),C.isPending||_||!h)return;let fe=BE.safeParse(g);if(!fe.success){let Q={};for(let se of fe.error.issues)(Q[se.path.join(".")]??=[]).push(se.message);i(Q),S();return}i({}),C.mutate()},children:[x.state==="blocked"?(0,ce.jsx)("div",{tabIndex:-1,ref:y,className:"mb-6 outline-none",children:(0,ce.jsxs)(Yr,{title:"Discard unsaved changes?",children:[(0,ce.jsx)("p",{children:"Your changes have not been saved."}),(0,ce.jsxs)("div",{className:"flex gap-2",children:[(0,ce.jsx)(ie,{onClick:()=>x.reset(),children:"Keep editing"}),(0,ce.jsx)(ie,{onClick:()=>x.proceed(),children:"Discard changes"})]})]})}):null,C.error||Object.keys(o).length?(0,ce.jsx)("div",{tabIndex:-1,"data-save-error":!0,className:"mb-6 outline-none",children:(0,ce.jsxs)(Yr,{tone:_?"warning":"error",title:_?"This automation changed while you were editing.":"Changes could not be saved.",children:[(0,ce.jsxs)("p",{className:"mt-1",children:["Your edits are still here."," ",_?"Review the latest version before saving again.":C.error instanceof yn?C.error.apiError:"Check the fields below, or try again."]}),_?(0,ce.jsx)(ie,{disabled:L.isPending,onClick:()=>L.mutate(),children:L.isPending?"Loading\u2026":"Review latest version"}):null,L.error?(0,ce.jsx)("p",{role:"alert",children:"The latest version could not be loaded. Try again."}):null]})}):null,s?(0,ce.jsx)("div",{className:"mb-6",children:(0,ce.jsxs)(Yr,{title:"Compare your edits with the latest saved version",children:[(0,ce.jsx)("p",{children:"Only the fields you changed are shown. Keeping your edits will replace these fields. Other saved fields stay unchanged."}),Object.entries(p).map(([Z,fe])=>(0,ce.jsxs)("section",{className:"my-4",children:[(0,ce.jsx)("h3",{className:"text-sm font-semibold capitalize",children:Z==="credentialMode"?"Credentials":Z}),(0,ce.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,ce.jsxs)("div",{children:[(0,ce.jsx)("p",{children:"Latest saved"}),(0,ce.jsx)("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm",children:xK(Z==="schedule"&&s.kind==="scheduled"?L1(s):s[Z])})]}),(0,ce.jsxs)("div",{children:[(0,ce.jsx)("p",{children:"Your edit"}),(0,ce.jsx)("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm",children:xK(fe)})]})]})]},Z)),(0,ce.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,ce.jsx)(ie,{onClick:()=>T(!0),children:"Keep my changed fields"}),(0,ce.jsx)(ie,{onClick:()=>T(!1),children:"Use latest saved version"})]})]})}):null,ue?null:(0,ce.jsxs)("p",{className:"mt-0 mb-6 max-w-2xl text-sm leading-relaxed text-dashboard-text-muted",children:[z," created this automation. You can edit it because it is in a public channel. Only ",z," can change where results go or turn on their connected accounts. Version history keeps every saved change."]}),(0,ce.jsxs)("fieldset",{disabled:C.isPending,className:"min-w-0",children:[(0,ce.jsxs)(ms,{title:"What to do",detail:"Give Junior a clear instruction and a name you can find later.",children:[(0,ce.jsx)(Ot,{label:"Title",htmlFor:"title",error:j("title"),children:(0,ce.jsx)(xa,{size:"comfortable",id:"title",value:r.title,placeholder:e.summary.title,onChange:Z=>k({title:Z.target.value}),...ve("title")})}),(0,ce.jsxs)(Ot,{label:"Instruction",htmlFor:"instruction",error:j("instruction"),children:[(0,ce.jsx)(tc,{prose:!0,id:"instruction",rows:8,value:r.instruction,onChange:Z=>k({instruction:Z.target.value}),...ve("instruction"),className:"resize-y text-base sm:text-sm"}),(0,ce.jsxs)("p",{className:"m-0 text-right text-xs text-dashboard-text-muted",children:[r.instruction.length.toLocaleString()," / 4,000"]})]})]}),(0,ce.jsx)(ms,{title:"When to run",detail:t.kind==="scheduled"?"Choose a schedule in a specific timezone.":"Run when a matching event occurs.",children:(0,ce.jsxs)("div",{id:`${F}-error`,tabIndex:-1,"aria-invalid":!!ee||void 0,className:"grid min-w-0 gap-5 outline-none",children:[ee?(0,ce.jsx)("p",{role:"alert",className:"m-0 text-sm text-rose-300",children:ee}):null,t.kind==="scheduled"?(0,ce.jsx)(vK,{automation:t,value:r.schedule,onChange:Z=>k({schedule:Z})}):(0,ce.jsx)(yK,{value:r.trigger??t.trigger,original:t.trigger,onChange:Z=>k({trigger:Z})})]})}),(0,ce.jsxs)(ms,{title:"Where results go",detail:"Choose who gets a message after successful work.",children:[j("outcomes")?(0,ce.jsx)("p",{role:"alert",className:"m-0 text-sm text-rose-300",children:j("outcomes")}):null,ue?(0,ce.jsx)(bK,{value:r.outcomes,original:t.outcomes,destination:e.summary.destination,onChange:Z=>k({outcomes:Z})}):(0,ce.jsxs)(ce.Fragment,{children:[(0,ce.jsx)(R1,{outcomes:t.outcomes,destination:e.summary.destination}),(0,ce.jsxs)("p",{className:"m-0 text-xs text-dashboard-text-muted",children:["Only ",z," can change where results go."]})]})]}),(0,ce.jsxs)(ms,{title:"Credentials",detail:"Choose which connected accounts Junior can use.",children:[(0,ce.jsxs)("fieldset",{className:"divide-y divide-dashboard-border-subtle rounded-md border border-dashboard-border-emphasis",children:[(0,ce.jsx)("legend",{className:"sr-only",children:"Credential mode"}),[["creator",ue?"Your connected accounts":`${z}\u2019s connected accounts`,ue?"Uses accounts connected by you, the creator.":`Uses accounts connected by ${z}. Only ${z} can turn this on.`],["system","System credentials only",ue?"Does not use your connected accounts. Some work may not be possible.":"Does not use anyone\u2019s connected accounts. Some work may not be possible."]].map(([Z,fe,Q])=>(0,ce.jsxs)("label",{className:"flex cursor-pointer items-start gap-3 px-4 py-4 has-checked:bg-dashboard-fill-soft has-disabled:cursor-not-allowed has-disabled:opacity-60",children:[(0,ce.jsx)("input",{type:"radio",name:"credentials",className:"mt-0.5 size-4 shrink-0 accent-dashboard-focus",checked:Y?Z==="system":r.credentialMode===Z,disabled:Z==="creator"&&!ue&&(t.credentialMode!=="creator"||Y),onChange:()=>k({credentialMode:Z})}),(0,ce.jsxs)("span",{children:[(0,ce.jsx)("span",{className:"block text-sm font-medium",children:fe}),(0,ce.jsx)("span",{className:"mt-1 block text-xs leading-relaxed text-dashboard-text-muted",children:Q})]})]},Z))]}),Y?(0,ce.jsxs)(Yr,{title:"Saving switches this automation to system credentials.",children:["Only ",z," can let a changed instruction",t.kind==="event"?" or trigger":""," use their connected accounts."]}):null,j("credentialMode")?(0,ce.jsx)("p",{role:"alert",children:j("credentialMode")}):null]})]}),(0,ce.jsx)("p",{className:"mb-5 text-xs leading-relaxed text-dashboard-text-muted sm:hidden",children:"Changes apply to future work. Saving does not run this automation."}),(0,ce.jsx)("div",{className:"sticky bottom-0 z-20 -mx-4 border-t border-dashboard-border-emphasis bg-dashboard-bg px-4 py-4 sm:-mx-8 sm:px-8",children:(0,ce.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ce.jsxs)("div",{className:"min-w-0 flex-1",role:"status",children:[(0,ce.jsx)("p",{className:"m-0 text-xs font-medium sm:text-sm",children:C.isPending?"Saving\u2026":h?"Unsaved changes":"Unchanged"}),(0,ce.jsx)("p",{className:"mt-1 mb-0 hidden text-xs text-dashboard-text-muted sm:block",children:"Changes apply to future work. Saving does not run it."})]}),(0,ce.jsxs)("div",{className:"flex shrink-0 gap-2",children:[(0,ce.jsx)(ae,{to:e.returnPath,className:"inline-flex min-h-11 items-center rounded border border-dashboard-border-emphasis px-3 text-sm text-dashboard-text no-underline sm:min-h-9",children:"Cancel"}),(0,ce.jsx)(ie,{type:"submit",tone:"primary",className:"min-h-11 sm:min-h-9",disabled:!h||C.isPending||_,children:"Save changes"})]})]})})]})}function xK(e){return e==null?"Not set":typeof e=="string"?e:JSON.stringify(e,null,2)}var Sg=b(w(),1);function wK(){return(0,Sg.jsx)("div",{role:"status","aria-label":"Loading automation editor",children:["What to do","When to run","Where results go","Credentials"].map((e,t)=>(0,Sg.jsxs)(ms,{title:e,children:[(0,Sg.jsx)(Qe,{className:"h-4 w-24"}),(0,Sg.jsx)(Qe,{className:t===0?"h-48 w-full":"h-20 w-full"})]},e))})}var Mt=b(w(),1);function CK(e){let{kind:t,automationId:a}=Ba(),r=vt(),n=mg(e.enabled,a),o=n.data&&!(n.data.kind==="scheduled"&&n.data.status==="completed"),i=Be({queryKey:["dashboard","automations","edit",t,a],enabled:e.enabled&&!!o&&n.data?.kind===t,retry:!1,queryFn:({signal:f})=>Pe(ds,`/api/automations/${t}/${encodeURIComponent(a)}/edit`,f)}),s=`/automations/list${r.search}`,l=n.data,c=l?.kind==="event"?l.status==="paused"?"paused":l.triggerAvailable?"active":"unavailable":l?.status,d=c==="active"?"success":c==="blocked"||c==="unavailable"?"warning":"neutral";return(0,Mt.jsx)(xz,{children:(0,Mt.jsxs)("div",{className:"mx-auto w-full min-w-0 max-w-5xl px-4 pt-7 sm:px-8 sm:pt-9",children:[(0,Mt.jsxs)(ae,{to:s,className:"inline-flex min-h-8 items-center gap-2 text-sm text-dashboard-text-muted no-underline hover:text-dashboard-text",children:[(0,Mt.jsx)(Zr,{"aria-hidden":!0,size:15}),"All automations"]}),(0,Mt.jsxs)("div",{className:"mt-4 mb-8 flex flex-wrap items-start justify-between gap-4",children:[(0,Mt.jsxs)("div",{className:"min-w-0",children:[(0,Mt.jsx)("h1",{className:"m-0 break-words font-display text-3xl font-light tracking-tight",children:l&&!o?l.title:"Edit automation"}),l?(0,Mt.jsxs)("p",{className:"mt-2 mb-0 text-sm text-dashboard-text-muted",children:["Created by ",l.ownedByViewer?"you":l.createdBy," \xB7"," ",l.destination.label]}):null]}),l?(0,Mt.jsxs)("div",{className:"flex items-center gap-4",children:[(0,Mt.jsx)(ae,{to:`/automations/${l.kind}/${encodeURIComponent(l.id)}/versions${r.search}`,className:"text-sm text-dashboard-text-muted underline underline-offset-2 hover:text-dashboard-text",children:"Version history"}),(0,Mt.jsx)(ba,{tone:d,children:c==="unavailable"?"Trigger unavailable":c})]}):null]}),!l&&n.error||!i.data&&i.error||l&&l.kind!==t?(0,Mt.jsxs)(Yr,{tone:"error",title:"Automation could not be loaded.",children:["It may no longer be available, or you may not have access."," ",(0,Mt.jsx)(ie,{onClick:()=>{n.refetch(),o&&i.refetch()},children:"Try again"})]}):!l||o&&!i.data?(0,Mt.jsx)(wK,{}):o&&i.data?(0,Mt.jsx)(SK,{automation:i.data,summary:l,returnPath:s},`${t}:${a}`):(0,Mt.jsx)(Ybe,{automation:l})]})})}function Ybe({automation:e}){return(0,Mt.jsxs)(Mt.Fragment,{children:[(0,Mt.jsx)("p",{className:"mb-6 text-sm text-dashboard-text-muted",children:"This automation has completed and cannot be edited. It will not run again."}),(0,Mt.jsx)(ms,{title:"What to do",detail:"The saved instruction.",children:(0,Mt.jsx)("p",{className:"m-0 whitespace-pre-wrap break-words text-sm leading-relaxed",children:e.instruction})}),(0,Mt.jsx)(ms,{title:"When to run",detail:"The saved trigger.",children:e.kind==="scheduled"?(0,Mt.jsxs)("p",{className:"m-0 text-sm",children:[e.schedule," \xB7 ",e.timezone]}):(0,Mt.jsxs)("div",{className:"grid gap-3 text-sm",children:[(0,Mt.jsx)("p",{className:"m-0 break-words",children:e.resource}),(0,Mt.jsx)("p",{className:"m-0 break-words",children:e.events.join(", ")}),e.match?(0,Mt.jsx)("pre",{className:"whitespace-pre-wrap break-words text-xs",children:JSON.stringify(e.match,null,2)}):null]})}),(0,Mt.jsx)(ms,{title:"Where results go",detail:"Messages after successful work.",children:(0,Mt.jsx)(R1,{outcomes:e.outcomes,destination:e.destination})}),(0,Mt.jsx)(ms,{title:"Credentials",detail:"The accounts Junior can use.",children:(0,Mt.jsx)("p",{className:"m-0 text-sm",children:e.credentialMode==="creator"?`Uses ${e.ownedByViewer?"your":`${e.createdBy}\u2019s`} connected accounts.`:"System credentials only."})})]})}var rp=b(G(),1);var kK=b(G(),1);function _1(){return(0,kK.useSyncExternalStore)(e=>Il.subscribe(e),()=>Il.isOnline(),()=>!0)}var LK=b(w(),1);function IK(){return _1()?null:(0,LK.jsx)("div",{"aria-live":"polite",className:"border-t border-amber-300/15 bg-amber-300/[0.07] px-3 py-1.5 text-center font-sans text-xs text-amber-100/80",role:"status",children:"You\u2019re offline. Drafts stay on this device."})}var wz=b(w(),1);function N1(){return(0,wz.jsx)("div",{className:"relative grid size-10 shrink-0 select-none place-items-center overflow-visible",children:(0,wz.jsx)("img",{alt:"",className:"relative size-11 max-w-none -translate-y-0.5 object-contain opacity-90 drop-shadow-[0_0_7px_rgba(255,255,255,0.16)]",draggable:!1,src:"/_junior/dashboard/avatar.png"})})}var TK=["relative","overflow-hidden","bg-white/15","before:absolute","before:inset-0","before:content-['']","before:bg-[linear-gradient(90deg,#ff4d6d,#ffb703,#56f39a,#4cc9f0,#9b5de5,#ff4d6d)]","before:bg-[length:200%_100%]","before:animate-[junior-rainbow-flow_1.2s_linear_infinite]","motion-reduce:before:animate-none"].join(" ");var $d=b(w(),1);function Tn(e){return(0,$d.jsx)("div",{className:I(Ya,"grid min-h-[calc(100dvh-5rem)] place-items-center px-4 py-8 md:px-8"),children:(0,$d.jsxs)("section",{className:"grid w-full max-w-lg grid-cols-[auto_minmax(0,1fr)] items-center gap-3 rounded-lg border border-dashboard-border-emphasis bg-dashboard-surface-raised p-4",children:[(0,$d.jsx)(N1,{}),(0,$d.jsxs)("div",{children:[(0,$d.jsx)("div",{className:"font-bold",children:e.label}),(0,$d.jsx)("div",{"aria-label":e.label,className:`${TK} mt-3 h-1.5 w-full`,role:"progressbar"})]})]})})}var Cz="0.238.1",A1=typeof Cz=="string"&&Cz.trim()?Cz:"unknown";var wx=b(w(),1);function RK(e){return exe(e.serverVersion)?(0,wx.jsxs)("div",{"aria-live":"polite",className:"flex flex-wrap items-center justify-center gap-x-3 gap-y-1 border-t border-cyan-300/15 bg-cyan-300/[0.07] px-3 py-1.5 text-center font-sans text-xs text-cyan-100/80",role:"status",children:[(0,wx.jsx)("span",{children:"The dashboard changed. Refresh to load the latest version."}),(0,wx.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0 font-mono font-semibold text-cyan-100 underline decoration-cyan-300/40 underline-offset-2 hover:text-dashboard-text-solid",onClick:()=>window.location.reload(),type:"button",children:"Refresh"})]}):null}function exe(e){return!!e&&A1!=="unknown"&&e!=="unknown"&&e!==A1}var Cx=b(w(),1);function ac(e){return(0,Cx.jsxs)(So,{children:[(0,Cx.jsx)(We,{description:e.description,title:e.title}),(0,Cx.jsx)(Yn,{label:e.label,variant:e.variant})]})}var iu=b(G(),1);var $1={"angular-html":()=>import("./chunks/angular-html-3W5ULHSG.js"),"angular-ts":()=>import("./chunks/angular-ts-4LWK3KJS.js"),astro:()=>import("./chunks/astro-TCFNN3TA.js"),blade:()=>import("./chunks/blade-2ZY5IBVK.js"),c:()=>import("./chunks/c-WHCDUHJR.js"),coffee:()=>import("./chunks/coffee-NWMA7ZVV.js"),coffeescript:()=>import("./chunks/coffee-NWMA7ZVV.js"),cpp:()=>import("./chunks/cpp-7ZDYJCCI.js"),"c++":()=>import("./chunks/cpp-7ZDYJCCI.js"),css:()=>import("./chunks/css-XF3SDJYW.js"),csv:()=>import("./chunks/csv-I2Y5BPVG.js"),glsl:()=>import("./chunks/glsl-SDKJ4MVB.js"),graphql:()=>import("./chunks/graphql-XJBKAS4G.js"),gql:()=>import("./chunks/graphql-XJBKAS4G.js"),haml:()=>import("./chunks/haml-QQIA6ZDV.js"),handlebars:()=>import("./chunks/handlebars-IBE27NOG.js"),hbs:()=>import("./chunks/handlebars-IBE27NOG.js"),html:()=>import("./chunks/html-SP67HH5F.js"),"html-derivative":()=>import("./chunks/html-derivative-HSRB64DA.js"),http:()=>import("./chunks/http-VGZ3EXS5.js"),hurl:()=>import("./chunks/hurl-TO4NQQLI.js"),imba:()=>import("./chunks/imba-P3ARIZRP.js"),java:()=>import("./chunks/java-WCBM5OUU.js"),javascript:()=>import("./chunks/javascript-TQH7GGAM.js"),js:()=>import("./chunks/javascript-TQH7GGAM.js"),cjs:()=>import("./chunks/javascript-TQH7GGAM.js"),mjs:()=>import("./chunks/javascript-TQH7GGAM.js"),jinja:()=>import("./chunks/jinja-RWPJ7VSG.js"),jison:()=>import("./chunks/jison-ED4UFXGK.js"),json:()=>import("./chunks/json-XRHV7G5W.js"),json5:()=>import("./chunks/json5-2OA2ZMVI.js"),jsonc:()=>import("./chunks/jsonc-KO53QF6Y.js"),jsonl:()=>import("./chunks/jsonl-GHTNFMM6.js"),jsx:()=>import("./chunks/jsx-V5TSP3NI.js"),julia:()=>import("./chunks/julia-EI7BACOV.js"),jl:()=>import("./chunks/julia-EI7BACOV.js"),less:()=>import("./chunks/less-FPWZXUDW.js"),markdown:()=>import("./chunks/markdown-QWIM2DOI.js"),md:()=>import("./chunks/markdown-QWIM2DOI.js"),marko:()=>import("./chunks/marko-3POAQSZY.js"),mdc:()=>import("./chunks/mdc-GOYXY36C.js"),mdx:()=>import("./chunks/mdx-CWS3UMSH.js"),php:()=>import("./chunks/php-HGK4AZCK.js"),postcss:()=>import("./chunks/postcss-7K34RN34.js"),pug:()=>import("./chunks/pug-J24HZP2J.js"),jade:()=>import("./chunks/pug-J24HZP2J.js"),python:()=>import("./chunks/python-GCPXLELR.js"),py:()=>import("./chunks/python-GCPXLELR.js"),r:()=>import("./chunks/r-XV5O7BSV.js"),regexp:()=>import("./chunks/regexp-655IUQFI.js"),regex:()=>import("./chunks/regexp-655IUQFI.js"),sass:()=>import("./chunks/sass-MSBN6O54.js"),scss:()=>import("./chunks/scss-N73GNFL4.js"),shellscript:()=>import("./chunks/shellscript-OPDT4ZZ3.js"),bash:()=>import("./chunks/shellscript-OPDT4ZZ3.js"),sh:()=>import("./chunks/shellscript-OPDT4ZZ3.js"),shell:()=>import("./chunks/shellscript-OPDT4ZZ3.js"),zsh:()=>import("./chunks/shellscript-OPDT4ZZ3.js"),sql:()=>import("./chunks/sql-ZR72I7RP.js"),stylus:()=>import("./chunks/stylus-NVEQWGLA.js"),styl:()=>import("./chunks/stylus-NVEQWGLA.js"),svelte:()=>import("./chunks/svelte-ZZAXFLSI.js"),"ts-tags":()=>import("./chunks/ts-tags-5RZIQFFW.js"),lit:()=>import("./chunks/ts-tags-5RZIQFFW.js"),tsx:()=>import("./chunks/tsx-ZTNB67YL.js"),typescript:()=>import("./chunks/typescript-HV6B525T.js"),ts:()=>import("./chunks/typescript-HV6B525T.js"),cts:()=>import("./chunks/typescript-HV6B525T.js"),mts:()=>import("./chunks/typescript-HV6B525T.js"),vue:()=>import("./chunks/vue-WQSBUNEP.js"),"vue-html":()=>import("./chunks/vue-html-SKWAUQDE.js"),"vue-vine":()=>import("./chunks/vue-vine-V3A5HTCZ.js"),wasm:()=>import("./chunks/wasm-JWJ5BADC.js"),wgsl:()=>import("./chunks/wgsl-ZCQ7MKDM.js"),wit:()=>import("./chunks/wit-MLLAONFF.js"),xml:()=>import("./chunks/xml-VST5CLIL.js"),yaml:()=>import("./chunks/yaml-BX3BWN2A.js"),yml:()=>import("./chunks/yaml-BX3BWN2A.js")};var _K="Junior";function Ft(){return typeof window>"u"?_K:window.__JUNIOR_DASHBOARD_AGENT_NAME__?.trim()||_K}function NK(e=Ft()){return e.endsWith("s")?`${e}'`:`${e}'s`}var P1=b(w(),1);function to(e){if(typeof e!="number"||!Number.isFinite(e))return"";let t=Math.max(0,Math.floor(e));if(t<1e3)return`${t}ms`;if(t<6e4){let n=t/1e3;return`${n.toFixed(n<10?1:0)}s`}let a=[],r=[["mo",2592e6],["d",864e5],["h",36e5],["m",6e4],["s",1e3]];for(let[n,o]of r){let i=Math.floor(t/o);if(i!==0){if(a.push(`${i}${n}`),a.length===2)break;t%=o}}return a.join(" ")}function nc(e){return(0,P1.jsx)(P1.Fragment,{children:to(e.value)||e.fallback||null})}function kx(e){return Date.parse(e.createdAt)}function Pd(e,t,a){return{parts:a,role:t,sourceSeq:e.seq,timestamp:kx(e)}}function txe(e){let t=new Set;for(let a of e){let r=a.data;r.type==="handoff"&&r.triggeringToolCallId&&t.add(r.triggeringToolCallId),r.type==="subagent"&&r.parentToolCallId&&t.add(r.parentToolCallId)}return t}function axe(e){let t=new Set;for(let a of e)a.messageId&&t.add(a.messageId);return t}function nxe(e,t){return{delivery:e.delivery,messageId:e.messageId,parts:e.redacted?[{type:"text",redacted:!0}]:[{type:"text",text:e.text??""}],...e.attachments?{attachments:e.attachments}:void 0,pending:!0,role:"user",source:e.source,sourceSeq:Number.MAX_SAFE_INTEGER-1e6+t,timestamp:Date.parse(e.createdAt),...e.actorIdentity?{actorIdentity:e.actorIdentity}:void 0}}function rxe(e,t){if(!t?.length)return e;let a=oxe(e,t);return a.length===0?e:[...e,...a]}function oxe(e,t){if(!t?.length)return[];let a=axe(e);return t.filter(r=>!a.has(r.messageId)).map((r,n)=>nxe(r,n))}function kz(e,t){return Iz(e.events,e.annotations,t)}function Iz(e,t,a){let r=txe(e),n=new Map,o=new Map,i=new Map,s=[],l=new Map,c=new Map,d,f=(p,h)=>{if(r.has(h.toolCallId))return;let g="output"in h?h.output:void 0,x=n.get(h.toolCallId);if(x){x.name=h.name,x.status=h.status,h.input!==void 0&&(x.input=h.input),g!==void 0&&(x.output=g),x.startedTimestamp===void 0&&h.startedAt&&(x.startedTimestamp=Date.parse(h.startedAt)),h.status!=="running"&&(x.resultTimestamp=kx(p));return}let y={type:"tool_call",id:h.toolCallId,name:h.name,status:h.status,...h.input===void 0?void 0:{input:h.input},...g===void 0?void 0:{output:g},...h.status==="running"?void 0:{resultTimestamp:kx(p)}},v={...Pd(p,"tool",[y]),sourceSeq:h.startedSeq??p.seq,timestamp:h.startedAt?Date.parse(h.startedAt):kx(p)};n.set(h.toolCallId,y),o.set(h.toolCallId,v),s.push(v)};for(let p of e){let h=p.data;if(h.type==="message"){let g={...Pd(p,h.role,[h.redacted?{type:"text",redacted:!0}:{type:"text",text:h.text}]),messageId:h.messageId,...h.attachments?{attachments:h.attachments}:void 0,...h.cards?{cards:xE(h.cards,t??[])}:void 0,...h.actorIdentity?{actorIdentity:h.actorIdentity}:void 0,...h.eventType?{eventType:h.eventType}:void 0,eventObjectType:h.eventObjectType,...h.trustedSummary?{trustedSummary:h.trustedSummary}:void 0,...h.explicitMention!==void 0?{explicitMention:h.explicitMention}:void 0,...h.source?{source:h.source}:void 0};s.push(g),l.set(g.messageId,g),g.role==="user"&&(d=g);continue}if(h.type==="message_handled"){let g=l.get(h.messageId);g?.role==="user"&&g.explicitMention===!1&&!g.eventType&&(g.context=!0);continue}if(h.type==="assistant_message"){if(h.parts.length===0)continue;s.push(Pd(p,"assistant",h.parts.map(g=>g.redacted?{type:"reasoning",redacted:!0}:{type:"reasoning",text:g.text})));continue}if(h.type==="turn_lifecycle"&&h.state==="started"){let g=h.inputMessageIds?.map(y=>l.get(y)).filter(y=>y!==void 0),x=g?.slice().reverse().find(y=>y.role==="user");x?c.set(h.turnId,x):d&&c.set(h.turnId,d);for(let y of g??[])y.role==="user"&&y.explicitMention===!1&&!y.eventType&&(y.context=!0);continue}if(h.type==="turn_routed"){let g=c.get(h.turnId);g&&(g.route={modelProfile:h.modelProfile,modelId:h.modelId,reasoningLevel:h.reasoningLevel,...h.confidence!==void 0?{confidence:h.confidence}:void 0,source:h.source});continue}if(h.type==="turn_context"){let g=c.get(h.turnId);g&&(g.contexts??=[],g.contexts.push({content:h.content,kind:h.kind,loadedAt:p.createdAt,pluginName:h.pluginName,version:h.version}));continue}if(h.type==="tool_calls"){for(let g of h.calls)f(p,g);if(h.assistant){let g=[];for(let x of h.assistant.parts){if(x.type==="reasoning"){g.push(x.redacted?{type:"reasoning",redacted:!0}:{type:"reasoning",text:x.text});continue}if(r.has(x.toolCallId))continue;let y=n.get(x.toolCallId);if(!y)continue;let v=o.get(x.toolCallId);if(v){v.sourceSeq!==p.seq&&(y.startedTimestamp=v.timestamp);let S=s.indexOf(v);S>=0&&s.splice(S,1),o.delete(x.toolCallId)}g.push(y)}g.length>0&&s.push(Pd(p,"assistant",g))}continue}if(h.type==="subagent"){let g=`${h.childConversationId}:${h.startedSeq}`,x=i.get(g);if(x){x.status=h.status;continue}let y={type:"subagent",id:g,childConversationId:h.childConversationId,subagentKind:h.subagentKind,status:h.status};i.set(g,y),s.push({...Pd(p,"tool",[y]),sourceSeq:h.startedSeq,timestamp:Date.parse(h.startedAt)});continue}if(h.type==="structured_event"){s.push(Pd(p,"system",[{type:"structured_event",namespace:h.namespace,name:h.name,version:h.version,presentation:h.presentation}]));continue}if(h.type==="attachments_delivered"){s.push(Pd(p,"system",[{type:"attachments_delivered",attachments:h.attachments}]));continue}if(h.type==="compaction"||h.type==="handoff"){s.push(Pd(p,"system",[{type:"context_event",event:h.type==="handoff"?{type:h.type,createdAt:p.createdAt,modelId:h.modelId,modelProfile:h.modelProfile,...h.summary?{summary:h.summary}:void 0,...h.reasoningLevel?{reasoningLevel:h.reasoningLevel}:void 0}:{type:h.type,createdAt:p.createdAt,...h.modelId?{modelId:h.modelId}:void 0,...h.modelProfile?{modelProfile:h.modelProfile}:void 0,...h.summary?{summary:h.summary}:void 0,...h.details?{details:h.details}:void 0}}]));continue}if(h.type==="turn_lifecycle"&&h.state==="failed"){s.push({role:h.failureCode==="delivery_failed"?"system":"assistant",failureCode:h.failureCode,...h.failureReason?{failureReason:h.failureReason}:void 0,...h.eventId?{eventId:h.eventId}:void 0,...h.sentryEventUrl?{sentryEventUrl:h.sentryEventUrl}:void 0,parts:[],sourceSeq:p.seq,timestamp:kx(p)});continue}}let m=s.filter(p=>p.role!=="user"||p.eventType!==void 0||p.explicitMention!==!1||p.context===!0).sort((p,h)=>p.sourceSeq-h.sourceSeq);return rxe(m,a)}function AK(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return"UTC"}}var Tz=AK();function $K(e){Tz=e||AK()}function Ed(){return Tz}function E1(){return Tz}function ixe(e){return e.status==="active"}function sxe(e){return e.status==="failed"}function lxe(e){return e.status==="active"}function uxe(e){return e.status==="failed"}function M1(e){if(!e)return null;let t=Date.parse(e);return Number.isFinite(t)?t:null}function Rn(e,t){let a=M1(e);return a==null?"none":new Date(a).toLocaleString(void 0,{...t,timeZone:E1()})}function ao(e){let t=M1(e);if(t==null)return"not updated yet";let a=Math.round((t-Date.now())/1e3),r=Math.abs(a),n=[["year",3600*24*365],["month",3600*24*30],["week",3600*24*7],["day",3600*24],["hour",3600],["minute",60]];for(let[o,i]of n)if(r>=i)return new Intl.RelativeTimeFormat(void 0,{numeric:"auto"}).format(Math.round(a/i),o);return"just now"}function Im(e){if(typeof e!="number"||!Number.isFinite(e))return"none";let t=Math.max(0,Math.floor(e));if(t<1e3)return`${t}ms`;let a=t/1e3;if(a<60)return`${a.toFixed(a<10?1:0)}s`;let r=Math.round(a),n=Math.floor(r/60),o=r%60;return`${n}m ${o}s`}function PK(e){if(e===void 0)return;let t=typeof e=="string"?e:JSON.stringify(e);if(t===void 0)return;let a=new TextEncoder().encode(t).byteLength;return a<1e3?`${a}b`:`${Math.round(a/1e3)}kb`}function O1(e,t){if(!(typeof e!="number"||typeof t!="number"||t<e))return Im(t-e)}function Lx(e){if(typeof e!="number"||!Number.isFinite(e))return"";let t=Math.max(0,Math.floor(e));return t===0?"":to(t)}function ca(e,t=!1){if(typeof e!="number"||!Number.isFinite(e))return"no timestamp";let a=new Date(e);return t?a.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium",timeZone:E1()}):a.toLocaleTimeString(void 0,{timeZone:E1()})}function DK(e){if(typeof e!="number"||!Number.isFinite(e))return"no timestamp";let t=Math.round((e-Date.now())/1e3),a=Math.abs(t),r=[["year",3600*24*365],["month",3600*24*30],["week",3600*24*7],["day",3600*24],["hour",3600]],[n,o]=r.find(([,i])=>a>=i)??r.at(-1);return new Intl.RelativeTimeFormat(void 0,{numeric:"auto"}).format(Math.round(t/o),n)}function EK(e){let t=new Date(e),a={dateStyle:"medium",timeStyle:"long"};return{local:t.toLocaleString(void 0,{...a,timeZone:E1()}),utc:t.toLocaleString(void 0,{...a,timeZone:"UTC"})}}function MK(e){if(typeof e!="number"||!Number.isFinite(e))return"0";let t=Math.max(0,Math.floor(e));if(t<1e3)return String(t);let a=[["t",1e12],["b",1e9],["m",1e6],["k",1e3]],[r,n]=a.find(([,s])=>t>=s)??a[1],o=t/n;return`${o>=100||Number.isInteger(o)||o>=10?Math.round(o).toString():(Math.floor(o*10)/10).toFixed(1).replace(/\.0$/,"")}${r}`}function km(e){return typeof e=="number"&&Number.isFinite(e)?Math.max(0,Math.floor(e)):void 0}function cxe(e){return[e.inputTokens,e.outputTokens,e.cachedInputTokens,e.cacheCreationTokens].reduce((t,a)=>{let r=km(a);return r===void 0?t:(t??0)+r},void 0)}function Lm(e){let t=e.toLowerCase();return t==="assistant"?"assistant":t==="user"?"user":t==="system"?"system":t.includes("tool")?"tool":"other"}function Md(e,t){let a=Lm(t.role);return a==="assistant"?Ft():a==="user"?Dd(t.actorIdentity)??Dd(e.actorIdentity)??"User":a==="system"?"System":a==="tool"?"Tool":t.role||"Unknown"}function re(e){return MK(e)}function ei(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?"0":e<10?(Math.round(e*10)/10).toFixed(1).replace(/\.0$/,""):re(e)}function wg(e){if(!e)return;let t={totalTokens:0};t.reasoningTokens=km(e.reasoningTokens);let a=cxe(e);if(a!==void 0)t.totalTokens=a,t.inputTokens=km(e.inputTokens),t.outputTokens=km(e.outputTokens),t.cachedInputTokens=km(e.cachedInputTokens),t.cacheCreationTokens=km(e.cacheCreationTokens);else{let r=km(e.totalTokens);r!==void 0&&(t.totalTokens=r,t.providerTotalTokens=r)}return t.totalTokens>0?t:void 0}function OK(e){if(!e?.length)return;let t={totalTokens:0};for(let a of e){let r=wg(a.usage);if(r){t.totalTokens+=r.totalTokens;for(let n of["inputTokens","outputTokens","cachedInputTokens","cacheCreationTokens","reasoningTokens"]){let o=r[n];o!==void 0&&(t[n]=(t[n]??0)+o)}}}return t.totalTokens>0?t:void 0}function Rz(e){return e?`${MK(e.totalTokens)} tokens`:""}function zK(e){return Rz(wg(e))}function Ix(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:void 0}function _z(e,t){return Math.round((e+t)*1e12)/1e12}function Jl(e){if(!e?.cost)return;let t={total:0},a=e.cost,r=Ix(a.total),n={input:Ix(a.input),output:Ix(a.output),cacheRead:Ix(a.cacheRead),cacheWrite:Ix(a.cacheWrite)},o=Object.values(n).reduce((i,s)=>i+(s??0),0);return t.total=_z(t.total,r??o),t.input=n.input,t.output=n.output,t.cacheRead=n.cacheRead,t.cacheWrite=n.cacheWrite,r!==void 0||o>0?t:void 0}function UK(e){let t;for(let a of e??[]){let r=Jl(a.usage);r&&(t=_z(t??0,r.total))}return t===void 0?void 0:{total:t}}function ze(e){if(!e)return"";let t=e.total>0&&e.total<.01?4:2;return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:t}).format(e.total)}function Nr(e){return e?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:4}).format(e.total):""}function z1(e,t){if(!(!e&&!t))return{...e,total:_z(e?.total??0,t?.costUsd??0)}}function jK(e,t){return ze(z1(Jl(e),t))}function BK(e){return Lx(e.cumulativeDurationMs)||"none"}function dxe(e,t){return(M1(t)??0)-(M1(e)??0)}function Ar(e){return e?.displayTitle??"Conversation"}function Dd(e){let t=e?.email?.trim()||void 0,a=e?.fullName?.trim()||void 0,r=e?.slackUserName?.trim()||void 0;return t??a??r??e?.slackUserId}function Ys(e,t={}){let a=e.channel;if(!a)return;let n=t.includeId??!0?` (${a})`:"";if(e.channelNameRedacted&&e.channelName)return`${e.channelName}${n}`;let o=e.channelName?.replace(/^#/,"");return a.startsWith("D")?`Direct Message${n}`:a.startsWith("C")?o?`#${o}${n}`:`Public Channel${n}`:a.startsWith("G")?o?.startsWith("mpdm-")?`Group DM${n}`:`Private Channel${n}`:o?`${o}${n}`:a}function fxe(e){return sxe(e)?"failed":ixe(e)?"active":"idle"}function Od(e){return lxe(e)?"active":uxe(e)?"failed":"idle"}function Tx(e){return e.eventHistory.status==="redacted"?"Transcript hidden because this conversation is not public.":e.eventHistory.status==="expired"?"Transcript expired for this conversation.":fxe(e)==="active"?"Transcript pending while this conversation is active.":"Transcript unavailable for this conversation."}function el(e){return`/people/${encodeURIComponent(e)}`}function FK(e){return`/system/locations/${encodeURIComponent(e)}`}function tl(e){return`/automations/${encodeURIComponent(e)}`}function mxe(e){let t=e?.trim().toLowerCase();if(!t)return"markdown";let r={console:"shellscript",htm:"html",js:"javascript",jsonl:"json",md:"markdown",ndjson:"json",sh:"shellscript",text:"markdown",txt:"markdown",xml:"xml",yml:"yaml"}[t]??t;return Object.hasOwn($1,r)?r:"markdown"}function HK(e){let t=e.trim();if(t)try{return JSON.stringify(JSON.parse(t),null,2)}catch{return}}function qK(e){let t=e.trim().split(/\r?\n/).filter(r=>r.trim().length>0);if(t.length<2)return;let a=[];for(let r of t){let n=HK(r);if(!n)return;a.push(n)}return a.join(`
71
71
  `)}function VK(e){return HK(e)??qK(e)}function D1(e,t){return t==="json"?VK(e)??e:e}function Lz(e){let t=e.trim();if(!t)return"markdown";try{return JSON.parse(t),"json"}catch{}return qK(t)?"json":"markdown"}function ZK(e){let t=[],a=/```([A-Za-z0-9_-]+)?\n([\s\S]*?)```/g,r=0,n;for(;n=a.exec(e);){let s=e.slice(r,n.index).trim();if(s){let c=Lz(s);t.push({code:D1(s,c),fenced:!1,language:c})}let l=mxe(n[1]);t.push({code:D1(n[2]??"",l),fenced:!0,language:l}),r=n.index+n[0].length}let o=e.slice(r).trim();if(o){let s=Lz(o);t.push({code:D1(o,s),fenced:!1,language:s})}if(t.length>0)return t;let i=Lz(e);return[{code:D1(e,i),fenced:!1,language:i}]}function $i(e){return e.map(t=>({activityPreview:t.activityPreview,annotations:t.annotations,sidebarAnnotations:t.sidebarAnnotations,archivedAt:t.archivedAt,auxiliaryCosts:t.auxiliaryCosts,channel:t.channel,channelName:t.channelName,channelNameRedacted:t.channelNameRedacted,cumulativeDurationMs:t.cumulativeDurationMs,cumulativeUsage:t.cumulativeUsage,displayTitle:t.displayTitle,id:t.conversationId,lastProgressAt:t.lastProgressAt,lastSeenAt:t.lastSeenAt,locationId:t.locationId,locationUrl:t.locationUrl,actorIdentity:t.actorIdentity,participants:t.participants,sentryTraceUrl:t.sentryTraceUrl,startedAt:t.startedAt,status:t.status,surface:t.surface,traceId:t.traceId,isPriority:t.isPriority,unfinishedWork:t.unfinishedWork,visibility:t.visibility})).sort((t,a)=>dxe(t.lastSeenAt,a.lastSeenAt))}function GK(e){if(!e)return;let t=$i([e])[0];return t?{...t,displayTitle:e.displayTitle}:void 0}function Ql(e){return e==null||e===""?"":typeof e=="string"?VK(e)??e:JSON.stringify(e,null,2)??""}var KK=b(w(),1);function tn(e){return(0,KK.jsx)("p",{className:I("m-0 text-sm text-rose-300",e.className),role:"alert",children:e.children})}var al=b(w(),1);function U1(e){return e.hasMore?(0,al.jsx)(ie,{className:I("justify-self-center",e.className),disabled:e.loading,onClick:e.onLoadMore,children:e.loading?"Loading\u2026":"Load more"}):null}function Tm(e,t,a){let n=(Math.max(1,t)-1)*a;return e.slice(n,n+a)}function rc(e,t){return e<=0?1:Math.max(1,Math.ceil(e/t))}function oc(e){if(e.total<=e.pageSize||e.pageCount<=1)return null;let t=Math.min(Math.max(1,e.page),e.pageCount),a=(t-1)*e.pageSize+1,r=Math.min(e.total,t*e.pageSize);return(0,al.jsxs)("div",{"aria-label":"Pagination",className:I("flex flex-wrap items-center justify-between gap-3",e.className),children:[(0,al.jsxs)("p",{className:"m-0 font-mono text-xs text-dashboard-text-muted",children:["Showing ",a.toLocaleString("en-US"),"-",r.toLocaleString("en-US")," of"," ",e.total.toLocaleString("en-US")]}),(0,al.jsxs)("div",{className:"flex items-center gap-2",children:[(0,al.jsx)(ie,{"aria-label":"Previous page",disabled:t<=1,onClick:()=>e.onPageChange(t-1),size:"icon",children:(0,al.jsx)(Fy,{"aria-hidden":"true",size:16})}),(0,al.jsxs)("span",{className:"min-w-16 text-center font-mono text-xs text-dashboard-text-muted",children:[t," / ",e.pageCount]}),(0,al.jsx)(ie,{"aria-label":"Next page",disabled:t>=e.pageCount,onClick:()=>e.onPageChange(t+1),size:"icon",children:(0,al.jsx)(Qa,{"aria-hidden":"true",size:16})})]})]})}var Rx=b(w(),1);function an(e){let t=e.size??"compact";return(0,Rx.jsxs)("div",{className:I("relative min-w-0",e.className),children:[(0,Rx.jsx)(md,{"aria-hidden":"true",className:I("pointer-events-none absolute top-1/2 -translate-y-1/2 text-dashboard-text-muted",pxe[t]),size:t==="compact"?13:14,strokeWidth:2.5}),(0,Rx.jsx)("input",{"aria-label":e.label,className:I("w-full rounded-lg border border-dashboard-border font-mono text-xs text-dashboard-text outline-none transition-colors placeholder:text-dashboard-text-muted hover:border-dashboard-border-emphasis focus:border-dashboard-focus",hxe[t]),onChange:a=>e.onChange(a.currentTarget.value),placeholder:e.placeholder,ref:e.inputRef,type:"search",value:e.value})]})}var pxe={compact:"left-2.5",default:"left-3"},hxe={compact:"h-9 bg-dashboard-overlay-soft pr-3 pl-8 focus:ring-1 focus:ring-dashboard-focus/25",default:"h-10 bg-dashboard-overlay-soft pr-3 pl-9 focus:ring-2 focus:ring-dashboard-focus/20"};var zI=b(G(),1);var nl=b(w(),1);function WK(e){return(0,nl.jsxs)(U,{className:I("flex flex-wrap items-end gap-4 p-4",e.className),children:[e.children,e.search?(0,nl.jsx)(Rm,{className:"min-w-[16rem] flex-1",label:"Search",children:(0,nl.jsx)(an,{className:"w-full max-w-md",label:e.search.label,onChange:e.search.onChange,placeholder:e.search.placeholder,value:e.search.value})}):null]})}function Rm(e){return(0,nl.jsxs)("div",{className:I("min-w-0",e.className),children:[(0,nl.jsx)("div",{className:"mb-2 font-mono text-xs uppercase tracking-[0.12em] text-dashboard-text-muted",children:e.label}),(0,nl.jsx)("div",{"aria-label":e.label,className:"flex flex-wrap gap-2",role:"group",children:e.children})]})}function j1(e){return(0,nl.jsx)("div",{"aria-label":e.ariaLabel,className:"grid min-w-0 grid-cols-3 gap-1 border-b border-white/[0.06] sm:flex sm:overflow-x-auto",role:"tablist",children:e.items.map(t=>{let a=e.value===t.value;return(0,nl.jsxs)("button",{"aria-selected":a,className:I("relative flex min-w-0 cursor-pointer items-center justify-between gap-2 border-0 bg-transparent px-3 py-2.5 font-mono text-xs uppercase tracking-[0.1em] transition-colors after:absolute after:inset-x-2 after:bottom-0 after:h-px sm:shrink-0 sm:justify-start",a?"text-cyan-100 after:bg-cyan-300":"text-dashboard-text-muted after:bg-transparent hover:text-dashboard-text"),onClick:()=>e.onChange(t.value),role:"tab",type:"button",children:[t.label,t.count!==void 0?(0,nl.jsx)("span",{className:I("rounded-sm border px-1.5 py-0.5 text-xs",a?"border-cyan-300/20 bg-cyan-300/10 text-cyan-100":"border-white/[0.07] bg-white/[0.025] text-dashboard-text-muted"),children:t.count.toLocaleString("en-US")}):null]},t.value||"all")})})}var JK=b(w(),1),gxe="a, button, input, select, textarea, [role='button'], [role='link']";function Cg(e){function t(a){a.target instanceof Element&&a.target.closest(gxe)||e.onSelect()}return(0,JK.jsx)("div",{className:I("group cursor-pointer transition-colors",e.selected?"bg-cyan-300/[0.045]":"hover:bg-white/[0.035] focus-within:bg-white/[0.035]",e.className),onClick:t,children:e.children})}var B1=b(G(),1);function F1(e){let[t,a]=Ho(),r=Bt(),n=(0,B1.useRef)(!1),o=t.get("filter")?.trim()??"",[i,s,l]=Zl(),c=Sv({initialPageParam:void 0,queryKey:["dashboard","plugin-user-page",e.pluginName,e.id,o,l],queryFn:({pageParam:h,signal:g})=>{let x=new URLSearchParams;o&&x.set("filter",o),l&&x.set("q",l),h&&x.set("cursor",h);let y=x.toString();return Pe(CG,`/api/user-pages/${encodeURIComponent(e.pluginName)}/${encodeURIComponent(e.id)}${y?`?${y}`:""}`,g)},getNextPageParam:h=>h.nextCursor,placeholderData:h=>h,retry:!1}),d=(0,B1.useMemo)(()=>[...new Map((c.data?.pages??[]).flatMap(h=>h.records).map(h=>[h.id,h])).values()],[c.data?.pages]),f=ga({mutationFn:h=>Rd(h.href),onMutate:()=>({pluginName:e.pluginName}),onSuccess:async(h,g,x)=>{r.removeQueries({queryKey:["dashboard","plugin-user-page",x.pluginName,"record"]}),await r.invalidateQueries({queryKey:["dashboard","plugin-user-page",x.pluginName]})},onSettled:()=>{n.current=!1}});function m(h){n.current||h.confirmation&&!window.confirm(h.confirmation)||(n.current=!0,f.mutate(h))}function p(h){let g=new URLSearchParams(t);h?g.set("filter",h):g.delete("filter"),a(g,{replace:!0})}return{action:f,content:c.data?.pages[0],filter:o,query:c,records:d,runAction:m,searchQuery:l,searchText:i,setFilter:p,setSearchText:s}}var XK=u.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/),QK=u.object({date:XK,personal:u.number().int().min(0),public:u.number().int().min(0)}).strict(),H1=u.object({costUsd:u.number().finite().min(0),date:XK,events:u.number().int().min(0)}).strict(),vxe=u.object({days:u.array(QK).length(90),extractionDays:u.array(H1).length(90),extractionHours:u.array(H1).min(24).optional(),generatedAt:u.iso.datetime(),hours:u.array(QK).min(24).optional(),recallDays:u.array(H1).length(90),recallHours:u.array(H1).min(24).optional(),stats:u.object({active:u.number().int().min(0),automatic:u.number().int().min(0),createdThirtyDays:u.number().int().min(0),embedded:u.number().int().min(0),explicit:u.number().int().min(0),knowledge:u.number().int().min(0),personal:u.number().int().min(0),preference:u.number().int().min(0),procedure:u.number().int().min(0),public:u.number().int().min(0)}).strict()}).strict();function Nz(){return Be({queryFn:({signal:e})=>Pe(vxe,"/api/plugins/memory/dashboard",e),queryKey:["dashboard","plugin-user-page","memory","summary"],retry:!1})}var UJ=b(G(),1);var kg=b(w(),1);function Pi(e){return(0,kg.jsx)("dl",{className:I("grid gap-px overflow-hidden rounded border border-white/[0.06] bg-white/[0.055]",e.className),children:e.children})}function da(e){return(0,kg.jsxs)("div",{className:"min-w-0 bg-[#09090b] px-3 py-3",children:[(0,kg.jsx)("dt",{className:"font-mono text-xs uppercase tracking-[0.12em] text-dashboard-text-muted",children:e.label}),(0,kg.jsx)("dd",{className:I("mt-1.5 ml-0 break-words text-sm leading-relaxed text-dashboard-text",e.valueClassName),children:e.children})]})}var Ig=b(G(),1);function yxe(){let e=0,t;return{acquire(){if(!(typeof document>"u")){if(e===0){let a=document.documentElement,r=document.body,n=typeof window>"u"?0:window.scrollX||window.pageXOffset||0,o=typeof window>"u"?0:window.scrollY||window.pageYOffset||0;t={bodyHeight:r.style.height,bodyLeft:r.style.left,bodyOverflow:r.style.overflow,bodyOverscroll:r.style.overscrollBehavior,bodyPosition:r.style.position,bodyRight:r.style.right,bodyTop:r.style.top,bodyWidth:r.style.width,htmlHeight:a.style.height,htmlOverflow:a.style.overflow,htmlOverscroll:a.style.overscrollBehavior,scrollX:n,scrollY:o},a.style.overflow="hidden",a.style.overscrollBehavior="none",a.style.height="100%",r.style.overflow="hidden",r.style.overscrollBehavior="none",r.style.position="fixed",r.style.top=`-${o}px`,r.style.left=`-${n}px`,r.style.right="0",r.style.width="100%",r.style.height="100%"}e+=1}},release(){if(typeof document>"u"||e===0||(e=Math.max(0,e-1),e>0||t===void 0))return;let a=document.documentElement,r=document.body;a.style.overflow=t.htmlOverflow,a.style.overscrollBehavior=t.htmlOverscroll,a.style.height=t.htmlHeight,r.style.overflow=t.bodyOverflow,r.style.overscrollBehavior=t.bodyOverscroll,r.style.position=t.bodyPosition,r.style.top=t.bodyTop,r.style.left=t.bodyLeft,r.style.right=t.bodyRight,r.style.width=t.bodyWidth,r.style.height=t.bodyHeight;let{scrollX:n,scrollY:o}=t;t=void 0,typeof window<"u"&&window.scrollTo(n,o)}}}var YK=yxe();function zd(){YK.acquire()}function Ud(){YK.release()}var rl=b(w(),1),bxe=["a[href]","button:not([disabled])","input:not([disabled]):not([type='hidden'])","select:not([disabled])","textarea:not([disabled])","summary","[tabindex]:not([tabindex='-1'])"].join(",");function $r(e){let t=(0,Ig.useRef)(null),a=(0,Ig.useRef)(e.onClose),r=(0,Ig.useRef)(void 0);return a.current=e.onClose,(0,Ig.useEffect)(()=>{r.current=document.activeElement instanceof HTMLElement?document.activeElement:void 0,zd();let n=requestAnimationFrame(()=>{t.current?.querySelector("[data-drawer-close]")?.focus()}),o=i=>{let s=document.querySelectorAll("[data-dashboard-drawer]");if(s[s.length-1]!==t.current)return;if(i.key==="Escape"){i.preventDefault(),a.current();return}if(i.key!=="Tab")return;let l=t.current,c=Array.from(l?.querySelectorAll(bxe)??[]).filter(p=>p.tabIndex>=0&&p.getClientRects().length>0),d=c.at(0),f=c.at(-1);if(!l||!d||!f){i.preventDefault();return}let m=document.activeElement;i.shiftKey&&(m===d||!l.contains(m))?(i.preventDefault(),f.focus()):!i.shiftKey&&(m===f||!l.contains(m))&&(i.preventDefault(),d.focus())};return window.addEventListener("keydown",o),()=>{cancelAnimationFrame(n),window.removeEventListener("keydown",o),Ud();let i=r.current;r.current=void 0,i?.isConnected&&i.focus()}},[e.openKey]),(0,rl.jsxs)("div",{"aria-labelledby":e.titleId,"aria-modal":"true","data-dashboard-drawer":"",className:"fixed inset-0 z-50",ref:t,role:"dialog",children:[(0,rl.jsx)("button",{"aria-label":e.dismissLabel,className:"absolute inset-0 cursor-default bg-dashboard-overlay",onClick:e.onClose,tabIndex:-1,type:"button"}),(0,rl.jsxs)("aside",{className:I("absolute top-0 right-0 grid h-full w-full grid-rows-[auto_minmax(0,1fr)] bg-dashboard-bg-elevated shadow-[-20px_0_60px_rgba(0,0,0,0.45)] md:border-l md:border-dashboard-border-emphasis",e.width==="wide"?"md:w-[min(760px,94vw)]":e.width==="narrow"?"md:w-[min(440px,94vw)]":"md:w-[min(560px,94vw)]"),children:[(0,rl.jsxs)("header",{className:"relative grid grid-cols-[minmax(0,1fr)_auto] gap-3 border-b border-dashboard-border-strong bg-dashboard-surface-raised px-4 py-3 pt-[max(0.75rem,env(safe-area-inset-top))] md:px-5",children:[(0,rl.jsx)("div",{className:"min-w-0",children:e.header}),(0,rl.jsxs)("div",{className:"flex items-start gap-1.5",children:[e.actions,(0,rl.jsx)(ie,{"aria-label":e.closeLabel,"data-drawer-close":!0,onClick:e.onClose,size:"icon",title:"Close",children:(0,rl.jsx)(Wr,{"aria-hidden":"true",size:15,strokeWidth:2.25})})]})]}),(0,rl.jsx)("div",{className:"min-h-0 overflow-auto px-4 py-4 pb-[max(1rem,env(safe-area-inset-bottom))] md:px-5",children:e.children})]})]})}var zJ=b(G(),1);var na=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function xxe(e){return jz(e)}function jz(e){return Array.isArray(e)?Sxe(e):e instanceof RegExp?e:typeof e=="object"?wxe(e):e}function Sxe(e){let t=[];for(let a=0,r=e.length;a<r;a++)t[a]=jz(e[a]);return t}function wxe(e){let t={};for(let a in e)t[a]=jz(e[a]);return t}function lW(e,...t){return t.forEach(a=>{for(let r in a)e[r]=a[r]}),e}function uW(e){let t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?uW(e.substring(0,e.length-1)):e.substr(~t+1)}var Az=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,q1=class{static hasCaptures(e){return e===null?!1:(Az.lastIndex=0,Az.test(e))}static replaceCaptures(e,t,a){return e.replace(Az,(r,n,o,i)=>{let s=a[parseInt(n||o,10)];if(s){let l=t.substring(s.start,s.end);for(;l[0]===".";)l=l.substring(1);switch(i){case"downcase":return l.toLowerCase();case"upcase":return l.toUpperCase();default:return l}}else return r})}};function cW(e,t){return e<t?-1:e>t?1:0}function dW(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let a=e.length,r=t.length;if(a===r){for(let n=0;n<a;n++){let o=cW(e[n],t[n]);if(o!==0)return o}return 0}return a-r}function eW(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function fW(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var mW=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},Ax=class{constructor(e,t,a){this._colorMap=e,this._defaults=t,this._root=a}static createFromRawTheme(e,t){return this.createFromParsedTheme(Ixe(e),t)}static createFromParsedTheme(e,t){return Txe(e,t)}_cachedMatchRoot=new mW(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,r=this._cachedMatchRoot.get(t).find(n=>Cxe(e.parent,n.parentScopes));return r?new pW(r.fontStyle,r.foreground,r.background):null}},$z=class V1{constructor(t,a){this.parent=t,this.scopeName=a}static push(t,a){for(let r of a)t=new V1(t,r);return t}static from(...t){let a=null;for(let r=0;r<t.length;r++)a=new V1(a,t[r]);return a}push(t){return new V1(this,t)}getSegments(){let t=this,a=[];for(;t;)a.push(t.scopeName),t=t.parent;return a.reverse(),a}toString(){return this.getSegments().join(" ")}extends(t){return this===t?!0:this.parent===null?!1:this.parent.extends(t)}getExtensionIfDefined(t){let a=[],r=this;for(;r&&r!==t;)a.push(r.scopeName),r=r.parent;return r===t?a.reverse():void 0}};function Cxe(e,t){if(t.length===0)return!0;for(let a=0;a<t.length;a++){let r=t[a],n=!1;if(r===">"){if(a===t.length-1)return!1;r=t[++a],n=!0}for(;e&&!kxe(e.scopeName,r);){if(n)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function kxe(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var pW=class{constructor(e,t,a){this.fontStyle=e,this.foregroundId=t,this.backgroundId=a}};function Ixe(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,a=[],r=0;for(let n=0,o=t.length;n<o;n++){let i=t[n];if(!i.settings)continue;let s;if(typeof i.scope=="string"){let f=i.scope;f=f.replace(/^[,]+/,""),f=f.replace(/[,]+$/,""),s=f.split(",")}else Array.isArray(i.scope)?s=i.scope:s=[""];let l=-1;if(typeof i.settings.fontStyle=="string"){l=0;let f=i.settings.fontStyle.split(" ");for(let m=0,p=f.length;m<p;m++)switch(f[m]){case"italic":l=l|1;break;case"bold":l=l|2;break;case"underline":l=l|4;break;case"strikethrough":l=l|8;break}}let c=null;typeof i.settings.foreground=="string"&&eW(i.settings.foreground)&&(c=i.settings.foreground);let d=null;typeof i.settings.background=="string"&&eW(i.settings.background)&&(d=i.settings.background);for(let f=0,m=s.length;f<m;f++){let h=s[f].trim().split(" "),g=h[h.length-1],x=null;h.length>1&&(x=h.slice(0,h.length-1),x.reverse()),a[r++]=new Lxe(g,x,n,l,c,d)}}return a}var Lxe=class{constructor(e,t,a,r,n,o){this.scope=e,this.parentScopes=t,this.index=a,this.fontStyle=r,this.foreground=n,this.background=o}},Pr=(e=>(e[e.NotSet=-1]="NotSet",e[e.None=0]="None",e[e.Italic=1]="Italic",e[e.Bold=2]="Bold",e[e.Underline=4]="Underline",e[e.Strikethrough=8]="Strikethrough",e))(Pr||{});function Txe(e,t){e.sort((l,c)=>{let d=cW(l.scope,c.scope);return d!==0||(d=dW(l.parentScopes,c.parentScopes),d!==0)?d:l.index-c.index});let a=0,r="#000000",n="#ffffff";for(;e.length>=1&&e[0].scope==="";){let l=e.shift();l.fontStyle!==-1&&(a=l.fontStyle),l.foreground!==null&&(r=l.foreground),l.background!==null&&(n=l.background)}let o=new Rxe(t),i=new pW(a,o.getId(r),o.getId(n)),s=new Nxe(new Dz(0,null,-1,0,0),[]);for(let l=0,c=e.length;l<c;l++){let d=e[l];s.insert(0,d.scope,d.parentScopes,d.fontStyle,o.getId(d.foreground),o.getId(d.background))}return new Ax(o,i,s)}var Rxe=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,a=e.length;t<a;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw new Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},_xe=Object.freeze([]),Dz=class hW{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,a,r,n,o){this.scopeDepth=t,this.parentScopes=a||_xe,this.fontStyle=r,this.foreground=n,this.background=o}clone(){return new hW(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let a=[];for(let r=0,n=t.length;r<n;r++)a[r]=t[r].clone();return a}acceptOverwrite(t,a,r,n){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,a!==-1&&(this.fontStyle=a),r!==0&&(this.foreground=r),n!==0&&(this.background=n)}},Nxe=class Ez{constructor(t,a=[],r={}){this._mainRule=t,this._children=r,this._rulesWithParentScopes=a}_rulesWithParentScopes;static _cmpBySpecificity(t,a){if(t.scopeDepth!==a.scopeDepth)return a.scopeDepth-t.scopeDepth;let r=0,n=0;for(;t.parentScopes[r]===">"&&r++,a.parentScopes[n]===">"&&n++,!(r>=t.parentScopes.length||n>=a.parentScopes.length);){let o=a.parentScopes[n].length-t.parentScopes[r].length;if(o!==0)return o;r++,n++}return a.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let r=t.indexOf("."),n,o;if(r===-1?(n=t,o=""):(n=t.substring(0,r),o=t.substring(r+1)),this._children.hasOwnProperty(n))return this._children[n].match(o)}let a=this._rulesWithParentScopes.concat(this._mainRule);return a.sort(Ez._cmpBySpecificity),a}insert(t,a,r,n,o,i){if(a===""){this._doInsertHere(t,r,n,o,i);return}let s=a.indexOf("."),l,c;s===-1?(l=a,c=""):(l=a.substring(0,s),c=a.substring(s+1));let d;this._children.hasOwnProperty(l)?d=this._children[l]:(d=new Ez(this._mainRule.clone(),Dz.cloneArr(this._rulesWithParentScopes)),this._children[l]=d),d.insert(t+1,c,r,n,o,i)}_doInsertHere(t,a,r,n,o){if(a===null){this._mainRule.acceptOverwrite(t,r,n,o);return}for(let i=0,s=this._rulesWithParentScopes.length;i<s;i++){let l=this._rulesWithParentScopes[i];if(dW(l.parentScopes,a)===0){l.acceptOverwrite(t,r,n,o);return}}r===-1&&(r=this._mainRule.fontStyle),n===0&&(n=this._mainRule.foreground),o===0&&(o=this._mainRule.background),this._rulesWithParentScopes.push(new Dz(t,a,r,n,o))}},Nm=class hs{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){let a=hs.getLanguageId(t),r=hs.getTokenType(t),n=hs.getFontStyle(t),o=hs.getForeground(t),i=hs.getBackground(t);console.log({languageId:a,tokenType:r,fontStyle:n,foreground:o,background:i})}static getLanguageId(t){return(t&255)>>>0}static getTokenType(t){return(t&768)>>>8}static containsBalancedBrackets(t){return(t&1024)!==0}static getFontStyle(t){return(t&30720)>>>11}static getForeground(t){return(t&16744448)>>>15}static getBackground(t){return(t&4278190080)>>>24}static set(t,a,r,n,o,i,s){let l=hs.getLanguageId(t),c=hs.getTokenType(t),d=hs.containsBalancedBrackets(t)?1:0,f=hs.getFontStyle(t),m=hs.getForeground(t),p=hs.getBackground(t);return a!==0&&(l=a),r!==8&&(c=r),n!==null&&(d=n?1:0),o!==-1&&(f=o),i!==0&&(m=i),s!==0&&(p=s),(l<<0|c<<8|d<<10|f<<11|m<<15|p<<24)>>>0}};function G1(e,t){let a=[],r=Axe(e),n=r.next();for(;n!==null;){let l=0;if(n.length===2&&n.charAt(1)===":"){switch(n.charAt(0)){case"R":l=1;break;case"L":l=-1;break;default:console.log(`Unknown priority ${n} in scope selector`)}n=r.next()}let c=i();if(a.push({matcher:c,priority:l}),n!==",")break;n=r.next()}return a;function o(){if(n==="-"){n=r.next();let l=o();return c=>!!l&&!l(c)}if(n==="("){n=r.next();let l=s();return n===")"&&(n=r.next()),l}if(tW(n)){let l=[];do l.push(n),n=r.next();while(tW(n));return c=>t(l,c)}return null}function i(){let l=[],c=o();for(;c;)l.push(c),c=o();return d=>l.every(f=>f(d))}function s(){let l=[],c=i();for(;c&&(l.push(c),n==="|"||n===",");){do n=r.next();while(n==="|"||n===",");c=i()}return d=>l.some(f=>f(d))}}function tW(e){return!!e&&!!e.match(/[\w\.:]+/)}function Axe(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,a=t.exec(e);return{next:()=>{if(!a)return null;let r=a[0];return a=t.exec(e),r}}}function gW(e){typeof e.dispose=="function"&&e.dispose()}var $x=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},$xe=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},Pxe=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},Dxe=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new $x(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new Pxe;for(let a of e)Exe(a,this.initialScopeName,this.repo,t);for(let a of t.references)if(a instanceof $x){if(this.seenFullScopeRequests.has(a.scopeName))continue;this.seenFullScopeRequests.add(a.scopeName),this.Q.push(a)}else{if(this.seenFullScopeRequests.has(a.scopeName)||this.seenPartialScopeRequests.has(a.toKey()))continue;this.seenPartialScopeRequests.add(a.toKey()),this.Q.push(a)}}};function Exe(e,t,a,r){let n=a.lookup(e.scopeName);if(!n){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}let o=a.lookup(t);e instanceof $x?Z1({baseGrammar:o,selfGrammar:n},r):Mz(e.ruleName,{baseGrammar:o,selfGrammar:n,repository:n.repository},r);let i=a.injections(e.scopeName);if(i)for(let s of i)r.add(new $x(s))}function Mz(e,t,a){if(t.repository&&t.repository[e]){let r=t.repository[e];K1([r],t,a)}}function Z1(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&K1(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&K1(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function K1(e,t,a){for(let r of e){if(a.visitedRule.has(r))continue;a.visitedRule.add(r);let n=r.repository?lW({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&K1(r.patterns,{...t,repository:n},a);let o=r.include;if(!o)continue;let i=vW(o);switch(i.kind){case 0:Z1({...t,selfGrammar:t.baseGrammar},a);break;case 1:Z1(t,a);break;case 2:Mz(i.ruleName,{...t,repository:n},a);break;case 3:case 4:let s=i.scopeName===t.selfGrammar.scopeName?t.selfGrammar:i.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(s){let l={baseGrammar:t.baseGrammar,selfGrammar:s,repository:n};i.kind===4?Mz(i.ruleName,l,a):Z1(l,a)}else i.kind===4?a.add(new $xe(i.scopeName,i.ruleName)):a.add(new $x(i.scopeName));break}}}var Mxe=class{kind=0},Oxe=class{kind=1},zxe=class{constructor(e){this.ruleName=e}kind=2},Uxe=class{constructor(e){this.scopeName=e}kind=3},jxe=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function vW(e){if(e==="$base")return new Mxe;if(e==="$self")return new Oxe;let t=e.indexOf("#");if(t===-1)return new Uxe(e);if(t===0)return new zxe(e.substring(1));{let a=e.substring(0,t),r=e.substring(t+1);return new jxe(a,r)}}var Bxe=/\\(\d+)/,aW=/\\(\d+)/g;var Fxe=-1,yW=-2;var Ex=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,a,r){this.$location=e,this.id=t,this._name=a||null,this._nameIsCapturing=q1.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=q1.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${uW(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:q1.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:q1.replaceCaptures(this._contentName,e,t)}},Hxe=class extends Ex{retokenizeCapturedWithRuleId;constructor(e,t,a,r,n){super(e,t,a,r),this.retokenizeCapturedWithRuleId=n}dispose(){}collectPatterns(e,t){throw new Error("Not supported!")}compile(e,t){throw new Error("Not supported!")}compileAG(e,t,a,r){throw new Error("Not supported!")}},qxe=class extends Ex{_match;captures;_cachedCompiledPatterns;constructor(e,t,a,r,n){super(e,t,a,null),this._match=new Px(r,this.id),this.captures=n,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,a,r){return this._getCachedCompiledPatterns(e).compileAG(e,a,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Dx,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},nW=class extends Ex{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,a,r,n){super(e,t,a,r),this.patterns=n.patterns,this.hasMissingPatterns=n.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(let a of this.patterns)e.getRule(a).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,a,r){return this._getCachedCompiledPatterns(e).compileAG(e,a,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Dx,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Oz=class extends Ex{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,a,r,n,o,i,s,l,c){super(e,t,a,r),this._begin=new Px(n,this.id),this.beginCaptures=o,this._end=new Px(i||"\uFFFF",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=s,this.applyEndPatternLast=l||!1,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,a,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,a,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Dx;for(let a of this.patterns)e.getRule(a).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},W1=class extends Ex{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,a,r,n,o,i,s,l){super(e,t,a,r),this._begin=new Px(n,this.id),this.beginCaptures=o,this.whileCaptures=s,this._while=new Px(i,yW),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,a,r){return this._getCachedCompiledPatterns(e).compileAG(e,a,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Dx;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,a,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,a,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Dx,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||"\uFFFF"),this._cachedCompiledWhilePatterns}},bW=class no{static createCaptureRule(t,a,r,n,o){return t.registerRule(i=>new Hxe(a,i,r,n,o))}static getCompiledRuleId(t,a,r){return t.id||a.registerRule(n=>{if(t.id=n,t.match)return new qxe(t.$vscodeTextmateLocation,t.id,t.name,t.match,no._compileCaptures(t.captures,a,r));if(typeof t.begin>"u"){t.repository&&(r=lW({},r,t.repository));let o=t.patterns;return typeof o>"u"&&t.include&&(o=[{include:t.include}]),new nW(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,no._compilePatterns(o,a,r))}return t.while?new W1(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,no._compileCaptures(t.beginCaptures||t.captures,a,r),t.while,no._compileCaptures(t.whileCaptures||t.captures,a,r),no._compilePatterns(t.patterns,a,r)):new Oz(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,no._compileCaptures(t.beginCaptures||t.captures,a,r),t.end,no._compileCaptures(t.endCaptures||t.captures,a,r),t.applyEndPatternLast,no._compilePatterns(t.patterns,a,r))}),t.id}static _compileCaptures(t,a,r){let n=[];if(t){let o=0;for(let i in t){if(i==="$vscodeTextmateLocation")continue;let s=parseInt(i,10);s>o&&(o=s)}for(let i=0;i<=o;i++)n[i]=null;for(let i in t){if(i==="$vscodeTextmateLocation")continue;let s=parseInt(i,10),l=0;t[i].patterns&&(l=no.getCompiledRuleId(t[i],a,r)),n[s]=no.createCaptureRule(a,t[i].$vscodeTextmateLocation,t[i].name,t[i].contentName,l)}}return n}static _compilePatterns(t,a,r){let n=[];if(t)for(let o=0,i=t.length;o<i;o++){let s=t[o],l=-1;if(s.include){let c=vW(s.include);switch(c.kind){case 0:case 1:l=no.getCompiledRuleId(r[s.include],a,r);break;case 2:let d=r[c.ruleName];d&&(l=no.getCompiledRuleId(d,a,r));break;case 3:case 4:let f=c.scopeName,m=c.kind===4?c.ruleName:null,p=a.getExternalGrammar(f,r);if(p)if(m){let h=p.repository[m];h&&(l=no.getCompiledRuleId(h,a,p.repository))}else l=no.getCompiledRuleId(p.repository.$self,a,p.repository);break}}else l=no.getCompiledRuleId(s,a,r);if(l!==-1){let c=a.getRule(l),d=!1;if((c instanceof nW||c instanceof Oz||c instanceof W1)&&c.hasMissingPatterns&&c.patterns.length===0&&(d=!0),d)continue;n.push(l)}}return{patterns:n,hasMissingPatterns:(t?t.length:0)!==n.length}}},Px=class xW{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(t,a){if(t&&typeof t=="string"){let r=t.length,n=0,o=[],i=!1;for(let s=0;s<r;s++)if(t.charAt(s)==="\\"&&s+1<r){let c=t.charAt(s+1);c==="z"?(o.push(t.substring(n,s)),o.push("$(?!\\n)(?<!\\n)"),n=s+2):(c==="A"||c==="G")&&(i=!0),s++}this.hasAnchor=i,n===0?this.source=t:(o.push(t.substring(n,r)),this.source=o.join(""))}else this.hasAnchor=!1,this.source=t;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=a,typeof this.source=="string"?this.hasBackReferences=Bxe.test(this.source):this.hasBackReferences=!1}clone(){return new xW(this.source,this.ruleId)}setSource(t){this.source!==t&&(this.source=t,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(t,a){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let r=a.map(n=>t.substring(n.start,n.end));return aW.lastIndex=0,this.source.replace(aW,(n,o)=>fW(r[parseInt(o,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let t=[],a=[],r=[],n=[],o,i,s,l;for(o=0,i=this.source.length;o<i;o++)s=this.source.charAt(o),t[o]=s,a[o]=s,r[o]=s,n[o]=s,s==="\\"&&o+1<i&&(l=this.source.charAt(o+1),l==="A"?(t[o+1]="\uFFFF",a[o+1]="\uFFFF",r[o+1]="A",n[o+1]="A"):l==="G"?(t[o+1]="\uFFFF",a[o+1]="G",r[o+1]="\uFFFF",n[o+1]="G"):(t[o+1]=l,a[o+1]=l,r[o+1]=l,n[o+1]=l),o++);return{A0_G0:t.join(""),A0_G1:a.join(""),A1_G0:r.join(""),A1_G1:n.join("")}}resolveAnchors(t,a){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:t?a?this._anchorCache.A1_G1:this._anchorCache.A1_G0:a?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},Dx=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(a=>a.source);this._cached=new rW(e,t,this._items.map(a=>a.ruleId))}return this._cached}compileAG(e,t,a){return this._hasAnchors?t?a?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,a)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,a)),this._anchorCache.A1_G0):a?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,a)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,a)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,a){let r=this._items.map(n=>n.resolveAnchors(t,a));return new rW(e,r,this._items.map(n=>n.ruleId))}},rW=class{constructor(e,t,a){this.regExps=t,this.rules=a,this.scanner=e.createOnigScanner(t)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){let e=[];for(let t=0,a=this.rules.length;t<a;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join(`
72
72
  `)}findNextMatchSync(e,t,a){let r=this.scanner.findNextMatchSync(e,t,a);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},Pz=class{constructor(e,t){this.languageId=e,this.tokenType=t}},Vxe=class zz{_defaultAttributes;_embeddedLanguagesMatcher;constructor(t,a){this._defaultAttributes=new Pz(t,8),this._embeddedLanguagesMatcher=new Zxe(Object.entries(a||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?zz._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new Pz(0,0);_getBasicScopeAttributes=new mW(t=>{let a=this._scopeToLanguage(t),r=this._toStandardTokenType(t);return new Pz(a,r)});_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){let a=t.match(zz.STANDARD_TOKEN_TYPE_REGEXP);if(!a)return 8;switch(a[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},Zxe=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);let t=e.map(([a,r])=>fW(a));t.sort(),t.reverse(),this.scopesRegExp=new RegExp(`^((${t.join(")|(")}))($|\\.)`,"")}}match(e){if(!this.scopesRegExp)return;let t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}},eVe={InDebugMode:typeof process<"u"&&!!process.env.VSCODE_TEXTMATE_DEBUG},SW=!1,oW=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function wW(e,t,a,r,n,o,i,s){let l=t.content.length,c=!1,d=-1;if(i){let p=Gxe(e,t,a,r,n,o);n=p.stack,r=p.linePos,a=p.isFirstLine,d=p.anchorPosition}let f=Date.now();for(;!c;){if(s!==0&&Date.now()-f>s)return new oW(n,!0);m()}return new oW(n,!1);function m(){let p=Kxe(e,t,a,r,n,d);if(!p){o.produce(n,l),c=!0;return}let h=p.captureIndices,g=p.matchedRuleId,x=h&&h.length>0?h[0].end>r:!1;if(g===Fxe){let y=n.getRule(e);o.produce(n,h[0].start),n=n.withContentNameScopesList(n.nameScopesList),_x(e,t,a,n,o,y.endCaptures,h),o.produce(n,h[0].end);let v=n;if(n=n.parent,d=v.getAnchorPos(),!x&&v.getEnterPos()===r){n=v,o.produce(n,l),c=!0;return}}else{let y=e.getRule(g);o.produce(n,h[0].start);let v=n,S=y.getName(t.content,h),C=n.contentNameScopesList.pushAttributed(S,e);if(n=n.push(g,r,d,h[0].end===l,null,C,C),y instanceof Oz){let T=y;_x(e,t,a,n,o,T.beginCaptures,h),o.produce(n,h[0].end),d=h[0].end;let L=T.getContentName(t.content,h),_=C.pushAttributed(L,e);if(n=n.withContentNameScopesList(_),T.endHasBackReferences&&(n=n.withEndRule(T.getEndWithResolvedBackReferences(t.content,h))),!x&&v.hasSameRuleAs(n)){n=n.pop(),o.produce(n,l),c=!0;return}}else if(y instanceof W1){let T=y;_x(e,t,a,n,o,T.beginCaptures,h),o.produce(n,h[0].end),d=h[0].end;let L=T.getContentName(t.content,h),_=C.pushAttributed(L,e);if(n=n.withContentNameScopesList(_),T.whileHasBackReferences&&(n=n.withEndRule(T.getWhileWithResolvedBackReferences(t.content,h))),!x&&v.hasSameRuleAs(n)){n=n.pop(),o.produce(n,l),c=!0;return}}else if(_x(e,t,a,n,o,y.captures,h),o.produce(n,h[0].end),n=n.pop(),!x){n=n.safePop(),o.produce(n,l),c=!0;return}}h[0].end>r&&(r=h[0].end,a=!1)}}function Gxe(e,t,a,r,n,o){let i=n.beginRuleCapturedEOL?0:-1,s=[];for(let l=n;l;l=l.pop()){let c=l.getRule(e);c instanceof W1&&s.push({rule:c,stack:l})}for(let l=s.pop();l;l=s.pop()){let{ruleScanner:c,findOptions:d}=Qxe(l.rule,e,l.stack.endRule,a,r===i),f=c.findNextMatchSync(t,r,d);if(f){if(f.ruleId!==yW){n=l.stack.pop();break}f.captureIndices&&f.captureIndices.length&&(o.produce(l.stack,f.captureIndices[0].start),_x(e,t,a,l.stack,o,l.rule.whileCaptures,f.captureIndices),o.produce(l.stack,f.captureIndices[0].end),i=f.captureIndices[0].end,f.captureIndices[0].end>r&&(r=f.captureIndices[0].end,a=!1))}else{n=l.stack.pop();break}}return{stack:n,linePos:r,anchorPosition:i,isFirstLine:a}}function Kxe(e,t,a,r,n,o){let i=Wxe(e,t,a,r,n,o),s=e.getInjections();if(s.length===0)return i;let l=Jxe(s,e,t,a,r,n,o);if(!l)return i;if(!i)return l;let c=i.captureIndices[0].start,d=l.captureIndices[0].start;return d<c||l.priorityMatch&&d===c?l:i}function Wxe(e,t,a,r,n,o){let i=n.getRule(e),{ruleScanner:s,findOptions:l}=CW(i,e,n.endRule,a,r===o),c=s.findNextMatchSync(t,r,l);return c?{captureIndices:c.captureIndices,matchedRuleId:c.ruleId}:null}function Jxe(e,t,a,r,n,o,i){let s=Number.MAX_VALUE,l=null,c,d=0,f=o.contentNameScopesList.getScopeNames();for(let m=0,p=e.length;m<p;m++){let h=e[m];if(!h.matcher(f))continue;let g=t.getRule(h.ruleId),{ruleScanner:x,findOptions:y}=CW(g,t,null,r,n===i),v=x.findNextMatchSync(a,n,y);if(!v)continue;let S=v.captureIndices[0].start;if(!(S>=s)&&(s=S,l=v.captureIndices,c=v.ruleId,d=h.priority,s===n))break}return l?{priorityMatch:d===-1,captureIndices:l,matchedRuleId:c}:null}function CW(e,t,a,r,n){if(SW){let i=e.compile(t,a),s=kW(r,n);return{ruleScanner:i,findOptions:s}}return{ruleScanner:e.compileAG(t,a,r,n),findOptions:0}}function Qxe(e,t,a,r,n){if(SW){let i=e.compileWhile(t,a),s=kW(r,n);return{ruleScanner:i,findOptions:s}}return{ruleScanner:e.compileWhileAG(t,a,r,n),findOptions:0}}function kW(e,t){let a=0;return e||(a|=1),t||(a|=4),a}function _x(e,t,a,r,n,o,i){if(o.length===0)return;let s=t.content,l=Math.min(o.length,i.length),c=[],d=i[0].end;for(let f=0;f<l;f++){let m=o[f];if(m===null)continue;let p=i[f];if(p.length===0)continue;if(p.start>d)break;for(;c.length>0&&c[c.length-1].endPos<=p.start;)n.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop();if(c.length>0?n.produceFromScopes(c[c.length-1].scopes,p.start):n.produce(r,p.start),m.retokenizeCapturedWithRuleId){let g=m.getName(s,i),x=r.contentNameScopesList.pushAttributed(g,e),y=m.getContentName(s,i),v=x.pushAttributed(y,e),S=r.push(m.retokenizeCapturedWithRuleId,p.start,-1,!1,null,x,v),C=e.createOnigString(s.substring(0,p.end));wW(e,C,a&&p.start===0,p.start,S,n,!1,0),gW(C);continue}let h=m.getName(s,i);if(h!==null){let x=(c.length>0?c[c.length-1].scopes:r.contentNameScopesList).pushAttributed(h,e);c.push(new Xxe(x,p.end))}}for(;c.length>0;)n.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop()}var Xxe=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function Yxe(e,t,a,r,n,o,i,s){return new t0e(e,t,a,r,n,o,i,s)}function iW(e,t,a,r,n){let o=G1(t,J1),i=bW.getCompiledRuleId(a,r,n.repository);for(let s of o)e.push({debugSelector:t,matcher:s.matcher,ruleId:i,grammar:n,priority:s.priority})}function J1(e,t){if(t.length<e.length)return!1;let a=0;return e.every(r=>{for(let n=a;n<t.length;n++)if(e0e(t[n],r))return a=n+1,!0;return!1})}function e0e(e,t){if(!e)return!1;if(e===t)return!0;let a=t.length;return e.length>a&&e.substr(0,a)===t&&e[a]==="."}var t0e=class{constructor(e,t,a,r,n,o,i,s){if(this._rootScopeName=e,this.balancedBracketSelectors=o,this._onigLib=s,this._basicScopeAttributesProvider=new Vxe(a,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=i,this._grammar=sW(t,null),this._injections=null,this._tokenTypeMatchers=[],n)for(let l of Object.keys(n)){let c=G1(l,J1);for(let d of c)this._tokenTypeMatchers.push({matcher:d.matcher,type:n[l]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(let e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){let e={lookup:n=>n===this._rootScopeName?this._grammar:this.getExternalGrammar(n),injections:n=>this._grammarRepository.injections(n)},t=[],a=this._rootScopeName,r=e.lookup(a);if(r){let n=r.injections;if(n)for(let i in n)iW(t,i,n[i],this,r);let o=this._grammarRepository.injections(a);o&&o.forEach(i=>{let s=this.getExternalGrammar(i);if(s){let l=s.injectionSelector;l&&iW(t,l,s,this,s)}})}return t.sort((n,o)=>n.priority-o.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){let t=++this._lastRuleId,a=e(t);return this._ruleId2desc[t]=a,a}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){let a=this._grammarRepository.lookup(e);if(a)return this._includedGrammars[e]=sW(a,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,a=0){let r=this._tokenize(e,t,!1,a);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,t,a=0){let r=this._tokenize(e,t,!0,a);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,t,a,r){this._rootId===-1&&(this._rootId=bW.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let n;if(!t||t===Uz.NULL){n=!0;let c=this._basicScopeAttributesProvider.getDefaultAttributes(),d=this.themeProvider.getDefaults(),f=Nm.set(0,c.languageId,c.tokenType,null,d.fontStyle,d.foregroundId,d.backgroundId),m=this.getRule(this._rootId).getName(null,null),p;m?p=Nx.createRootAndLookUpScopeName(m,f,this):p=Nx.createRoot("unknown",f),t=new Uz(null,this._rootId,-1,-1,!1,null,p,p)}else n=!1,t.reset();e=e+`
73
73
  `;let o=this.createOnigString(e),i=o.content.length,s=new n0e(a,e,this._tokenTypeMatchers,this.balancedBracketSelectors),l=wW(this,o,n,0,t,s,!0,r);return gW(o),{lineLength:i,lineTokens:s,ruleStack:l.stack,stoppedEarly:l.stoppedEarly}}};function sW(e,t){return e=xxe(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var Nx=class Xl{constructor(t,a,r){this.parent=t,this.scopePath=a,this.tokenAttributes=r}static fromExtension(t,a){let r=t,n=t?.scopePath??null;for(let o of a)n=$z.push(n,o.scopeNames),r=new Xl(r,n,o.encodedTokenAttributes);return r}static createRoot(t,a){return new Xl(null,new $z(null,t),a)}static createRootAndLookUpScopeName(t,a,r){let n=r.getMetadataForScope(t),o=new $z(null,t),i=r.themeProvider.themeMatch(o),s=Xl.mergeAttributes(a,n,i);return new Xl(null,o,s)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return Xl.equals(this,t)}static equals(t,a){do{if(t===a||!t&&!a)return!0;if(!t||!a||t.scopeName!==a.scopeName||t.tokenAttributes!==a.tokenAttributes)return!1;t=t.parent,a=a.parent}while(!0)}static mergeAttributes(t,a,r){let n=-1,o=0,i=0;return r!==null&&(n=r.fontStyle,o=r.foregroundId,i=r.backgroundId),Nm.set(t,a.languageId,a.tokenType,null,n,o,i)}pushAttributed(t,a){if(t===null)return this;if(t.indexOf(" ")===-1)return Xl._pushAttributed(this,t,a);let r=t.split(/ /g),n=this;for(let o of r)n=Xl._pushAttributed(n,o,a);return n}static _pushAttributed(t,a,r){let n=r.getMetadataForScope(a),o=t.scopePath.push(a),i=r.themeProvider.themeMatch(o),s=Xl.mergeAttributes(t.tokenAttributes,n,i);return new Xl(t,o,s)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){let a=[],r=this;for(;r&&r!==t;)a.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(r.parent?.scopePath??null)}),r=r.parent;return r===t?a.reverse():void 0}},Uz=class _m{constructor(t,a,r,n,o,i,s,l){this.parent=t,this.ruleId=a,this.beginRuleCapturedEOL=o,this.endRule=i,this.nameScopesList=s,this.contentNameScopesList=l,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=n}_stackElementBrand=void 0;static NULL=new _m(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t===null?!1:_m._equals(this,t)}static _equals(t,a){return t===a?!0:this._structuralEquals(t,a)?Nx.equals(t.contentNameScopesList,a.contentNameScopesList):!1}static _structuralEquals(t,a){do{if(t===a||!t&&!a)return!0;if(!t||!a||t.depth!==a.depth||t.ruleId!==a.ruleId||t.endRule!==a.endRule)return!1;t=t.parent,a=a.parent}while(!0)}clone(){return this}static _reset(t){for(;t;)t._enterPos=-1,t._anchorPos=-1,t=t.parent}reset(){_m._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,a,r,n,o,i,s){return new _m(this,t,a,r,n,o,i,s)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(t){return t.getRule(this.ruleId)}toString(){let t=[];return this._writeString(t,0),"["+t.join(",")+"]"}_writeString(t,a){return this.parent&&(a=this.parent._writeString(t,a)),t[a++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,a}withContentNameScopesList(t){return this.contentNameScopesList===t?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,t)}withEndRule(t){return this.endRule===t?this:new _m(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(t){let a=this;for(;a&&a._enterPos===t._enterPos;){if(a.ruleId===t.ruleId)return!0;a=a.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,a){let r=Nx.fromExtension(t?.nameScopesList??null,a.nameScopesList);return new _m(t,a.ruleId,a.enterPos??-1,a.anchorPos??-1,a.beginRuleCapturedEOL,a.endRule,r,Nx.fromExtension(r,a.contentNameScopesList))}},a0e=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(a=>a==="*"?(this.allowAny=!0,[]):G1(a,J1).map(r=>r.matcher)),this.unbalancedBracketScopes=t.flatMap(a=>G1(a,J1).map(r=>r.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},n0e=class{constructor(e,t,a,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=a,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let r=e?.tokenAttributes??0,n=!1;if(this.balancedBracketSelectors?.matchesAlways&&(n=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let o=e?.getScopeNames()??[];for(let i of this._tokenTypeOverrides)i.matcher(o)&&(r=Nm.set(r,0,i.type,null,-1,0,0));this.balancedBracketSelectors&&(n=this.balancedBracketSelectors.match(o))}if(n&&(r=Nm.set(r,0,8,n,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===r){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(r),this._lastTokenEndIndex=t;return}let a=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:a}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);let a=new Uint32Array(this._binaryTokens.length);for(let r=0,n=this._binaryTokens.length;r<n;r++)a[r]=this._binaryTokens[r];return a}},r0e=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,a,r,n){if(!this._grammars.has(e)){let o=this._rawGrammars.get(e);if(!o)return null;this._grammars.set(e,Yxe(e,o,t,a,r,n,this,this._onigLib))}return this._grammars.get(e)}},IW=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new r0e(Ax.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(Ax.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,a){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:a})}loadGrammarWithConfiguration(e,t,a){return this._loadGrammar(e,t,a.embeddedLanguages,a.tokenTypes,new a0e(a.balancedBracketSelectors||[],a.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,a,r,n){let o=new Dxe(this._syncRegistry,e);for(;o.Q.length>0;)o.Q.map(i=>this._loadSingleGrammar(i.scopeName)),o.processQueue();return this._grammarForScopeName(e,t,a,r,n)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let a=typeof this._options.getInjections=="function"?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,a)}}addGrammar(e,t=[],a=0,r=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,a,r)}_grammarForScopeName(e,t=0,a=null,r=null,n=null){return this._syncRegistry.grammarForScopeName(e,t,a,r,n)}},Q1=Uz.NULL;function Ox(e,t){let a=typeof e=="string"?{}:{...e.colorReplacements},r=typeof e=="string"?e:e.name;for(let[n,o]of Object.entries(t?.colorReplacements||{}))typeof o=="string"?a[n]=o:n===r&&Object.assign(a,o);return a}function ic(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function NW(e){return Array.isArray(e)?e:[e]}async function Bz(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function zx(e){return!e||["plaintext","txt","text","plain"].includes(e)}function Fz(e){return e==="ansi"||zx(e)}function Ux(e){return e==="none"}function Hz(e){return Ux(e)}var o0e=/(\r?\n)/g;function Lg(e,t=!1){if(e.length===0)return[["",0]];let a=e.split(o0e),r=0,n=[];for(let o=0;o<a.length;o+=2){let i=t?a[o]+(a[o+1]||""):a[o];n.push([i,r]),r+=a[o].length,r+=a[o+1]?.length||0}return n}var LW={light:"#333333",dark:"#bbbbbb"},TW={light:"#fffffe",dark:"#1e1e1e"},RW="__shiki_resolved";function X1(e){if(e?.[RW])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||="dark",t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:a,fg:r}=t;if(!a||!r){let s=t.settings?t.settings.find(l=>!l.name&&!l.scope):void 0;s?.settings?.foreground&&(r=s.settings.foreground),s?.settings?.background&&(a=s.settings.background),!r&&t?.colors?.["editor.foreground"]&&(r=t.colors["editor.foreground"]),!a&&t?.colors?.["editor.background"]&&(a=t.colors["editor.background"]),r||(r=t.type==="light"?LW.light:LW.dark),a||(a=t.type==="light"?TW.light:TW.dark),t.fg=r,t.bg=a}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let n=0,o=new Map;function i(s){if(o.has(s))return o.get(s);n+=1;let l=`#${n.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${l}`]?i(s):(o.set(s,l),l)}t.settings=t.settings.map(s=>{let l=s.settings?.foreground&&!s.settings.foreground.startsWith("#"),c=s.settings?.background&&!s.settings.background.startsWith("#");if(!l&&!c)return s;let d={...s,settings:{...s.settings}};if(l){let f=i(s.settings.foreground);t.colorReplacements[f]=s.settings.foreground,d.settings.foreground=f}if(c){let f=i(s.settings.background);t.colorReplacements[f]=s.settings.background,d.settings.background=f}return d});for(let s of Object.keys(t.colors||{}))if((s==="editor.foreground"||s==="editor.background"||s.startsWith("terminal.ansi"))&&!t.colors[s]?.startsWith("#")){let l=i(t.colors[s]);t.colorReplacements[l]=t.colors[s],t.colors[s]=l}return Object.defineProperty(t,RW,{enumerable:!1,writable:!1,value:!0}),t}async function AW(e){return[...new Set((await Promise.all(e.filter(t=>!Fz(t)).map(async t=>await Bz(t).then(a=>Array.isArray(a)?a:[a])))).flat())]}async function $W(e){return(await Promise.all(e.map(async t=>Hz(t)?null:X1(await Bz(t))))).filter(t=>!!t)}function PW(e,t){if(!t)return e;if(t[e]){let a=new Set([e]);for(;t[e];){if(e=t[e],a.has(e))throw new na(`Circular alias \`${[...a].join(" -> ")} -> ${e}\``);a.add(e)}}return e}var i0e=class extends IW{_resolver;_themes;_langs;_alias;_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;constructor(e,t,a,r={}){super(e),this._resolver=e,this._themes=t,this._langs=a,this._alias=r,this._themes.map(n=>this.loadTheme(n)),this.loadLanguages(this._langs)}getTheme(e){return typeof e=="string"?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){let t=X1(e);return t.name&&(this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null),t}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);t||(t=Ax.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=PW(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;let t=new Set([...this._langMap.values()].filter(n=>n.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);let a={balancedBracketSelectors:e.balancedBracketSelectors||["*"],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);let r=this.loadGrammarWithConfiguration(e.scopeName,1,a);if(r.name=e.name,this._resolvedGrammars.set(e.name,r),e.aliases&&e.aliases.forEach(n=>{this._alias[n]=e.name}),this._loadedLanguagesCache=null,t.size)for(let n of t)this._resolvedGrammars.delete(n.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(n.scopeName),this._syncRegistry?._grammars?.delete(n.scopeName),this.loadLanguage(this._langMap.get(n.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(let r of e)this.resolveEmbeddedLanguages(r);let t=[...this._langGraph.entries()],a=t.filter(([r,n])=>!n);if(a.length){let r=t.filter(([n,o])=>o?(o.embeddedLanguages||o.embeddedLangs)?.some(i=>a.map(([s])=>s).includes(i)):!1).filter(n=>!a.includes(n));throw new na(`Missing languages ${a.map(([n])=>`\`${n}\``).join(", ")}, required by ${r.map(([n])=>`\`${n}\``).join(", ")}`)}for(let[r,n]of t)this._resolver.addLanguage(n);for(let[r,n]of t)this.loadLanguage(n)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);let t=e.embeddedLanguages??e.embeddedLangs;if(t)for(let a of t)this._langGraph.set(a,this._langMap.get(a))}},s0e=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:a=>e.createScanner(a),createOnigString:a=>e.createString(a)},t.forEach(a=>this.addLanguage(a))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).push(e.scopeName)})}getInjections(e){let t=e.split("."),a=[];for(let r=1;r<=t.length;r++){let n=t.slice(0,r).join(".");a=[...a,...this._injections.get(n)||[]]}return a}},Mx=0;function qz(e){Mx+=1,e.warnings!==!1&&Mx>=10&&Mx%10===0&&console.warn(`[Shiki] ${Mx} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new na("`engine` option is required for synchronous mode");let a=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(X1),n=new i0e(new s0e(e.engine,a),r,a,e.langAlias),o;function i(v){return PW(v,e.langAlias)}function s(v){x();let S=n.getGrammar(typeof v=="string"?v:v.name);if(!S)throw new na(`Language \`${v}\` not found, you may need to load it first`);return S}function l(v){if(v==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};x();let S=n.getTheme(v);if(!S)throw new na(`Theme \`${v}\` not found, you may need to load it first`);return S}function c(v){x();let S=l(v);return o!==v&&(n.setTheme(S),o=v),{theme:S,colorMap:n.getColorMap()}}function d(){return x(),n.getLoadedThemes()}function f(){return x(),n.getLoadedLanguages()}function m(...v){x(),n.loadLanguages(v.flat(1))}async function p(...v){return m(await AW(v))}function h(...v){x();for(let S of v.flat(1))n.loadTheme(S)}async function g(...v){return x(),h(await $W(v))}function x(){if(t)throw new na("Shiki instance has been disposed")}function y(){t||(t=!0,n.dispose(),Mx-=1)}return{setTheme:c,getTheme:l,getLanguage:s,getLoadedThemes:d,getLoadedLanguages:f,resolveLangAlias:i,loadLanguage:p,loadLanguageSync:m,loadTheme:g,loadThemeSync:h,dispose:y,[Symbol.dispose]:y}}async function Vz(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,a,r]=await Promise.all([$W(e.themes||[]),AW(e.langs||[]),e.engine]);return qz({...e,themes:t,langs:a,engine:r})}var DW=new WeakMap;function jx(e,t){DW.set(e,t)}function Tg(e){return DW.get(e)}var Y1=class EW{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,a){return new EW(Object.fromEntries(NW(a).map(r=>[r,Q1])),t)}constructor(...t){if(t.length===2){let[a,r]=t;this.lang=r,this._stacks=a}else{let[a,r,n]=t;this.lang=r,this._stacks={[n]:a}}}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return l0e(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function l0e(e){let t=[],a=new Set;function r(n){if(a.has(n))return;a.add(n);let o=n?.nameScopesList?.scopeName;o&&t.push(o),n.parent&&r(n.parent)}return r(e),t}function u0e(e,t){if(!(e instanceof Y1))throw new na("Invalid grammar state");return e.getInternalStack(t)}var c0e=/,/,d0e=/ /;function Zz(e,t,a={}){let{theme:r=e.getLoadedThemes()[0]}=a;if(zx(e.resolveLangAlias(a.lang||"text"))||Ux(r))return Lg(t).map(s=>[{content:s[0],offset:s[1]}]);let{theme:n,colorMap:o}=e.setTheme(r),i=e.getLanguage(a.lang||"text");if(a.grammarState){if(a.grammarState.lang!==i.name)throw new na(`Grammar state language "${a.grammarState.lang}" does not match highlight language "${i.name}"`);if(!a.grammarState.themes.includes(n.name))throw new na(`Grammar state themes "${a.grammarState.themes}" do not contain highlight theme "${n.name}"`)}return OW(t,i,n,o,a)}function MW(...e){if(e.length===2)return Tg(e[1]);let[t,a,r={}]=e,{lang:n="text",theme:o=t.getLoadedThemes()[0]}=r;if(zx(n)||Ux(o))throw new na("Plain language does not have grammar state");if(n==="ansi")throw new na("ANSI language does not have grammar state");let{theme:i,colorMap:s}=t.setTheme(o),l=t.getLanguage(n);return new Y1(Gz(a,l,i,s,r).stateStack,l.name,i.name)}function OW(e,t,a,r,n){let o=Gz(e,t,a,r,n),i=new Y1(o.stateStack,t.name,a.name);return jx(o.tokens,i),o.tokens}function Gz(e,t,a,r,n){let o=Ox(a,n),{tokenizeMaxLineLength:i=0,tokenizeTimeLimit:s=500}=n,l=Lg(e),c=n.grammarState?u0e(n.grammarState,a.name)??Q1:n.grammarContextCode!=null?Gz(n.grammarContextCode,t,a,r,{...n,grammarState:void 0,grammarContextCode:void 0}).stateStack:Q1,d=[],f=[];for(let m=0,p=l.length;m<p;m++){let[h,g]=l[m];if(h===""){d=[],f.push([]);continue}if(i>0&&h.length>=i){d=[],f.push([{content:h,offset:g,color:"",fontStyle:0}]);continue}let x,y,v;n.includeExplanation&&(x=t.tokenizeLine(h,c,s),y=x.tokens,v=0);let S=t.tokenizeLine2(h,c,s),C=S.tokens.length/2;for(let T=0;T<C;T++){let L=S.tokens[2*T],_=T+1<C?S.tokens[2*T+2]:h.length;if(L===_)continue;let k=S.tokens[2*T+1],j=ic(r[Nm.getForeground(k)],o),F=Nm.getFontStyle(k),ue={content:h.substring(L,_),offset:g+L,color:j,fontStyle:F};if(n.includeExplanation){let z=[];if(n.includeExplanation!=="scopeName")for(let ee of a.settings){let ve;switch(typeof ee.scope){case"string":ve=ee.scope.split(c0e).map(Z=>Z.trim());break;case"object":ve=ee.scope;break;default:continue}z.push({settings:ee,selectors:ve.map(Z=>Z.split(d0e))})}ue.explanation=[];let Y=0;for(;L+Y<_;){let ee=y[v],ve=h.substring(ee.startIndex,ee.endIndex);Y+=ve.length,ue.explanation.push({content:ve,scopes:n.includeExplanation==="scopeName"?f0e(ee.scopes):m0e(z,ee.scopes)}),v+=1}}d.push(ue)}f.push(d),d=[],c=S.ruleStack}return{tokens:f,stateStack:c}}function f0e(e){return e.map(t=>({scopeName:t}))}function m0e(e,t){let a=[];for(let r=0,n=t.length;r<n;r++){let o=t[r];a[r]={scopeName:o,themeMatches:h0e(e,o,t.slice(0,r))}}return a}function _W(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function p0e(e,t,a){if(!_W(e.at(-1),t))return!1;let r=e.length-2,n=a.length-1;for(;r>=0&&n>=0;)_W(e[r],a[n])&&(r-=1),n-=1;return r===-1}function h0e(e,t,a){let r=[];for(let{selectors:n,settings:o}of e)for(let i of n)if(p0e(i,t,a)){r.push(o);break}return r}function eI(e,t,a,r=Zz){let n=Object.entries(a.themes).filter(c=>c[1]).map(c=>({color:c[0],theme:c[1]})),o=n.map(c=>{let d=r(e,t,{...a,theme:c.theme});return{tokens:d,state:Tg(d),theme:typeof c.theme=="string"?c.theme:c.theme.name}}),i=g0e(...o.map(c=>c.tokens)),s=i[0].map((c,d)=>c.map((f,m)=>{let p={content:f.content,variants:{},offset:f.offset};return"includeExplanation"in a&&a.includeExplanation&&(p.explanation=f.explanation),i.forEach((h,g)=>{let{content:x,explanation:y,offset:v,...S}=h[d][m];p.variants[n[g].color]=S}),p})),l=o[0].state?new Y1(Object.fromEntries(o.map(c=>[c.theme,c.state?.getInternalStack(c.theme)])),o[0].state.lang):void 0;return l&&jx(s,l),s}function g0e(...e){let t=e.map(()=>[]),a=e.length;for(let r=0;r<e[0].length;r++){let n=e.map(l=>l[r]),o=t.map(()=>[]);t.forEach((l,c)=>l.push(o[c]));let i=n.map(()=>0),s=n.map(l=>l[0]);for(;s.every(l=>l);){let l=Math.min(...s.map(c=>c.content.length));for(let c=0;c<a;c++){let d=s[c];d.content.length===l?(o[c].push(d),i[c]+=1,s[c]=n[c][i[c]]):(o[c].push({...d,content:d.content.slice(0,l)}),s[c]={...d,content:d.content.slice(l),offset:d.offset+l})}}}return t}var zW=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];var sc=class{constructor(t,a,r){this.normal=a,this.property=t,r&&(this.space=r)}};sc.prototype.normal={};sc.prototype.property={};sc.prototype.space=void 0;function Kz(e,t){let a={},r={};for(let n of e)Object.assign(a,n.property),Object.assign(r,n.normal);return new sc(a,r,t)}function Bx(e){return e.toLowerCase()}var hr=class{constructor(t,a){this.attribute=a,this.property=t}};hr.prototype.attribute="";hr.prototype.booleanish=!1;hr.prototype.boolean=!1;hr.prototype.commaOrSpaceSeparated=!1;hr.prototype.commaSeparated=!1;hr.prototype.defined=!1;hr.prototype.mustUseProperty=!1;hr.prototype.number=!1;hr.prototype.overloadedBoolean=!1;hr.prototype.property="";hr.prototype.spaceSeparated=!1;hr.prototype.space=void 0;var Fx={};Sl(Fx,{boolean:()=>et,booleanish:()=>bn,commaOrSpaceSeparated:()=>ti,commaSeparated:()=>jd,number:()=>J,overloadedBoolean:()=>tI,spaceSeparated:()=>ra});var v0e=0,et=Am(),bn=Am(),tI=Am(),J=Am(),ra=Am(),jd=Am(),ti=Am();function Am(){return 2**++v0e}var Wz=Object.keys(Fx),$m=class extends hr{constructor(t,a,r,n){let o=-1;if(super(t,a),UW(this,"space",n),typeof r=="number")for(;++o<Wz.length;){let i=Wz[o];UW(this,Wz[o],(r&Fx[i])===Fx[i])}}};$m.prototype.defined=!0;function UW(e,t,a){a&&(e[t]=a)}function gs(e){let t={},a={};for(let[r,n]of Object.entries(e.properties)){let o=new $m(r,e.transform(e.attributes||{},r),n,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,a[Bx(r)]=r,a[Bx(o.attribute)]=r}return new sc(t,a,e.space)}var Jz=gs({properties:{ariaActiveDescendant:null,ariaAtomic:bn,ariaAutoComplete:null,ariaBusy:bn,ariaChecked:bn,ariaColCount:J,ariaColIndex:J,ariaColSpan:J,ariaControls:ra,ariaCurrent:null,ariaDescribedBy:ra,ariaDetails:null,ariaDisabled:bn,ariaDropEffect:ra,ariaErrorMessage:null,ariaExpanded:bn,ariaFlowTo:ra,ariaGrabbed:bn,ariaHasPopup:null,ariaHidden:bn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ra,ariaLevel:J,ariaLive:null,ariaModal:bn,ariaMultiLine:bn,ariaMultiSelectable:bn,ariaOrientation:null,ariaOwns:ra,ariaPlaceholder:null,ariaPosInSet:J,ariaPressed:bn,ariaReadOnly:bn,ariaRelevant:null,ariaRequired:bn,ariaRoleDescription:ra,ariaRowCount:J,ariaRowIndex:J,ariaRowSpan:J,ariaSelected:bn,ariaSetSize:J,ariaSort:null,ariaValueMax:J,ariaValueMin:J,ariaValueNow:J,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function aI(e,t){return t in e?e[t]:t}function nI(e,t){return aI(e,t.toLowerCase())}var jW=gs({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:jd,acceptCharset:ra,accessKey:ra,action:null,allow:null,allowFullScreen:et,allowPaymentRequest:et,allowUserMedia:et,alt:null,as:null,async:et,autoCapitalize:null,autoComplete:ra,autoFocus:et,autoPlay:et,blocking:ra,capture:null,charSet:null,checked:et,cite:null,className:ra,cols:J,colSpan:null,content:null,contentEditable:bn,controls:et,controlsList:ra,coords:J|jd,crossOrigin:null,data:null,dateTime:null,decoding:null,default:et,defer:et,dir:null,dirName:null,disabled:et,download:tI,draggable:bn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:et,formTarget:null,headers:ra,height:J,hidden:tI,high:J,href:null,hrefLang:null,htmlFor:ra,httpEquiv:ra,id:null,imageSizes:null,imageSrcSet:null,inert:et,inputMode:null,integrity:null,is:null,isMap:et,itemId:null,itemProp:ra,itemRef:ra,itemScope:et,itemType:ra,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:et,low:J,manifest:null,max:null,maxLength:J,media:null,method:null,min:null,minLength:J,multiple:et,muted:et,name:null,nonce:null,noModule:et,noValidate:et,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:et,optimum:J,pattern:null,ping:ra,placeholder:null,playsInline:et,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:et,referrerPolicy:null,rel:ra,required:et,reversed:et,rows:J,rowSpan:J,sandbox:ra,scope:null,scoped:et,seamless:et,selected:et,shadowRootClonable:et,shadowRootDelegatesFocus:et,shadowRootMode:null,shape:null,size:J,sizes:null,slot:null,span:J,spellCheck:bn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:J,step:null,style:null,tabIndex:J,target:null,title:null,translate:null,type:null,typeMustMatch:et,useMap:null,value:bn,width:J,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ra,axis:null,background:null,bgColor:null,border:J,borderColor:null,bottomMargin:J,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:et,declare:et,event:null,face:null,frame:null,frameBorder:null,hSpace:J,leftMargin:J,link:null,longDesc:null,lowSrc:null,marginHeight:J,marginWidth:J,noResize:et,noHref:et,noShade:et,noWrap:et,object:null,profile:null,prompt:null,rev:null,rightMargin:J,rules:null,scheme:null,scrolling:bn,standby:null,summary:null,text:null,topMargin:J,valueType:null,version:null,vAlign:null,vLink:null,vSpace:J,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:et,disableRemotePlayback:et,prefix:null,property:null,results:J,security:null,unselectable:null},space:"html",transform:nI});var BW=gs({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:ti,accentHeight:J,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:J,amplitude:J,arabicForm:null,ascent:J,attributeName:null,attributeType:null,azimuth:J,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:J,by:null,calcMode:null,capHeight:J,className:ra,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:J,diffuseConstant:J,direction:null,display:null,dur:null,divisor:J,dominantBaseline:null,download:et,dx:null,dy:null,edgeMode:null,editable:null,elevation:J,enableBackground:null,end:null,event:null,exponent:J,externalResourcesRequired:null,fill:null,fillOpacity:J,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:jd,g2:jd,glyphName:jd,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:J,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:J,horizOriginX:J,horizOriginY:J,id:null,ideographic:J,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:J,k:J,k1:J,k2:J,k3:J,k4:J,kernelMatrix:ti,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:J,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:J,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:J,overlineThickness:J,paintOrder:null,panose1:null,path:null,pathLength:J,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ra,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:J,pointsAtY:J,pointsAtZ:J,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ti,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ti,rev:ti,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ti,requiredFeatures:ti,requiredFonts:ti,requiredFormats:ti,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:J,specularExponent:J,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:J,strikethroughThickness:J,string:null,stroke:null,strokeDashArray:ti,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:J,strokeOpacity:J,strokeWidth:null,style:null,surfaceScale:J,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ti,tabIndex:J,tableValues:null,target:null,targetX:J,targetY:J,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ti,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:J,underlineThickness:J,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:J,values:null,vAlphabetic:J,vMathematical:J,vectorEffect:null,vHanging:J,vIdeographic:J,version:null,vertAdvY:J,vertOriginX:J,vertOriginY:J,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:J,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:aI});var Qz=gs({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}});var Xz=gs({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:nI});var Yz=gs({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}});var y0e=/[A-Z]/g,FW=/-[a-z]/g,b0e=/^data[-\w.:]+$/i;function e4(e,t){let a=Bx(t),r=t,n=hr;if(a in e.normal)return e.property[e.normal[a]];if(a.length>4&&a.slice(0,4)==="data"&&b0e.test(t)){if(t.charAt(4)==="-"){let o=t.slice(5).replace(FW,S0e);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{let o=t.slice(4);if(!FW.test(o)){let i=o.replace(y0e,x0e);i.charAt(0)!=="-"&&(i="-"+i),t="data"+i}}n=$m}return new n(r,t)}function x0e(e){return"-"+e.toLowerCase()}function S0e(e){return e.charAt(1).toUpperCase()}var HW=Kz([Jz,jW,Qz,Xz,Yz],"html"),rI=Kz([Jz,BW,Qz,Xz,Yz],"svg");var qW={}.hasOwnProperty;function VW(e,t){let a=t||{};function r(n,...o){let i=r.invalid,s=r.handlers;if(n&&qW.call(n,e)){let l=String(n[e]);i=qW.call(s,l)?s[l]:r.unknown}if(i)return i.call(this,n,...o)}return r.handlers=a.handlers||{},r.invalid=a.invalid,r.unknown=a.unknown,r}var w0e=/["&'<>`]/g,C0e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,k0e=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,I0e=/[|\\{}()[\]^$+*?.]/g,ZW=new WeakMap;function GW(e,t){if(e=e.replace(t.subset?L0e(t.subset):w0e,r),t.subset||t.escapeOnly)return e;return e.replace(C0e,a).replace(k0e,r);function a(n,o,i){return t.format((n.charCodeAt(0)-55296)*1024+n.charCodeAt(1)-56320+65536,i.charCodeAt(o+2),t)}function r(n,o,i){return t.format(n.charCodeAt(0),i.charCodeAt(o+1),t)}}function L0e(e){let t=ZW.get(e);return t||(t=T0e(e),ZW.set(e,t)),t}function T0e(e){let t=[],a=-1;for(;++a<e.length;)t.push(e[a].replace(I0e,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}var R0e=/[\dA-Fa-f]/;function KW(e,t,a){let r="&#x"+e.toString(16).toUpperCase();return a&&t&&!R0e.test(String.fromCharCode(t))?r:r+";"}var _0e=/\d/;function WW(e,t,a){let r="&#"+String(e);return a&&t&&!_0e.test(String.fromCharCode(t))?r:r+";"}var JW=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"];var oI={nbsp:"\xA0",iexcl:"\xA1",cent:"\xA2",pound:"\xA3",curren:"\xA4",yen:"\xA5",brvbar:"\xA6",sect:"\xA7",uml:"\xA8",copy:"\xA9",ordf:"\xAA",laquo:"\xAB",not:"\xAC",shy:"\xAD",reg:"\xAE",macr:"\xAF",deg:"\xB0",plusmn:"\xB1",sup2:"\xB2",sup3:"\xB3",acute:"\xB4",micro:"\xB5",para:"\xB6",middot:"\xB7",cedil:"\xB8",sup1:"\xB9",ordm:"\xBA",raquo:"\xBB",frac14:"\xBC",frac12:"\xBD",frac34:"\xBE",iquest:"\xBF",Agrave:"\xC0",Aacute:"\xC1",Acirc:"\xC2",Atilde:"\xC3",Auml:"\xC4",Aring:"\xC5",AElig:"\xC6",Ccedil:"\xC7",Egrave:"\xC8",Eacute:"\xC9",Ecirc:"\xCA",Euml:"\xCB",Igrave:"\xCC",Iacute:"\xCD",Icirc:"\xCE",Iuml:"\xCF",ETH:"\xD0",Ntilde:"\xD1",Ograve:"\xD2",Oacute:"\xD3",Ocirc:"\xD4",Otilde:"\xD5",Ouml:"\xD6",times:"\xD7",Oslash:"\xD8",Ugrave:"\xD9",Uacute:"\xDA",Ucirc:"\xDB",Uuml:"\xDC",Yacute:"\xDD",THORN:"\xDE",szlig:"\xDF",agrave:"\xE0",aacute:"\xE1",acirc:"\xE2",atilde:"\xE3",auml:"\xE4",aring:"\xE5",aelig:"\xE6",ccedil:"\xE7",egrave:"\xE8",eacute:"\xE9",ecirc:"\xEA",euml:"\xEB",igrave:"\xEC",iacute:"\xED",icirc:"\xEE",iuml:"\xEF",eth:"\xF0",ntilde:"\xF1",ograve:"\xF2",oacute:"\xF3",ocirc:"\xF4",otilde:"\xF5",ouml:"\xF6",divide:"\xF7",oslash:"\xF8",ugrave:"\xF9",uacute:"\xFA",ucirc:"\xFB",uuml:"\xFC",yacute:"\xFD",thorn:"\xFE",yuml:"\xFF",fnof:"\u0192",Alpha:"\u0391",Beta:"\u0392",Gamma:"\u0393",Delta:"\u0394",Epsilon:"\u0395",Zeta:"\u0396",Eta:"\u0397",Theta:"\u0398",Iota:"\u0399",Kappa:"\u039A",Lambda:"\u039B",Mu:"\u039C",Nu:"\u039D",Xi:"\u039E",Omicron:"\u039F",Pi:"\u03A0",Rho:"\u03A1",Sigma:"\u03A3",Tau:"\u03A4",Upsilon:"\u03A5",Phi:"\u03A6",Chi:"\u03A7",Psi:"\u03A8",Omega:"\u03A9",alpha:"\u03B1",beta:"\u03B2",gamma:"\u03B3",delta:"\u03B4",epsilon:"\u03B5",zeta:"\u03B6",eta:"\u03B7",theta:"\u03B8",iota:"\u03B9",kappa:"\u03BA",lambda:"\u03BB",mu:"\u03BC",nu:"\u03BD",xi:"\u03BE",omicron:"\u03BF",pi:"\u03C0",rho:"\u03C1",sigmaf:"\u03C2",sigma:"\u03C3",tau:"\u03C4",upsilon:"\u03C5",phi:"\u03C6",chi:"\u03C7",psi:"\u03C8",omega:"\u03C9",thetasym:"\u03D1",upsih:"\u03D2",piv:"\u03D6",bull:"\u2022",hellip:"\u2026",prime:"\u2032",Prime:"\u2033",oline:"\u203E",frasl:"\u2044",weierp:"\u2118",image:"\u2111",real:"\u211C",trade:"\u2122",alefsym:"\u2135",larr:"\u2190",uarr:"\u2191",rarr:"\u2192",darr:"\u2193",harr:"\u2194",crarr:"\u21B5",lArr:"\u21D0",uArr:"\u21D1",rArr:"\u21D2",dArr:"\u21D3",hArr:"\u21D4",forall:"\u2200",part:"\u2202",exist:"\u2203",empty:"\u2205",nabla:"\u2207",isin:"\u2208",notin:"\u2209",ni:"\u220B",prod:"\u220F",sum:"\u2211",minus:"\u2212",lowast:"\u2217",radic:"\u221A",prop:"\u221D",infin:"\u221E",ang:"\u2220",and:"\u2227",or:"\u2228",cap:"\u2229",cup:"\u222A",int:"\u222B",there4:"\u2234",sim:"\u223C",cong:"\u2245",asymp:"\u2248",ne:"\u2260",equiv:"\u2261",le:"\u2264",ge:"\u2265",sub:"\u2282",sup:"\u2283",nsub:"\u2284",sube:"\u2286",supe:"\u2287",oplus:"\u2295",otimes:"\u2297",perp:"\u22A5",sdot:"\u22C5",lceil:"\u2308",rceil:"\u2309",lfloor:"\u230A",rfloor:"\u230B",lang:"\u2329",rang:"\u232A",loz:"\u25CA",spades:"\u2660",clubs:"\u2663",hearts:"\u2665",diams:"\u2666",quot:'"',amp:"&",lt:"<",gt:">",OElig:"\u0152",oelig:"\u0153",Scaron:"\u0160",scaron:"\u0161",Yuml:"\u0178",circ:"\u02C6",tilde:"\u02DC",ensp:"\u2002",emsp:"\u2003",thinsp:"\u2009",zwnj:"\u200C",zwj:"\u200D",lrm:"\u200E",rlm:"\u200F",ndash:"\u2013",mdash:"\u2014",lsquo:"\u2018",rsquo:"\u2019",sbquo:"\u201A",ldquo:"\u201C",rdquo:"\u201D",bdquo:"\u201E",dagger:"\u2020",Dagger:"\u2021",permil:"\u2030",lsaquo:"\u2039",rsaquo:"\u203A",euro:"\u20AC"};var QW=["cent","copy","divide","gt","lt","not","para","times"];var XW={}.hasOwnProperty,t4={},iI;for(iI in oI)XW.call(oI,iI)&&(t4[oI[iI]]=iI);var N0e=/[^\dA-Za-z]/;function YW(e,t,a,r){let n=String.fromCharCode(e);if(XW.call(t4,n)){let o=t4[n],i="&"+o;return a&&JW.includes(o)&&!QW.includes(o)&&(!r||t&&t!==61&&N0e.test(String.fromCharCode(t)))?i:i+";"}return""}function eJ(e,t,a){let r=KW(e,t,a.omitOptionalSemicolons),n;if((a.useNamedReferences||a.useShortestReferences)&&(n=YW(e,t,a.omitOptionalSemicolons,a.attribute)),(a.useShortestReferences||!n)&&a.useShortestReferences){let o=WW(e,t,a.omitOptionalSemicolons);o.length<r.length&&(r=o)}return n&&(!a.useShortestReferences||n.length<r.length)?n:r}function lc(e,t){return GW(e,Object.assign({format:eJ},t))}var A0e=/^>|^->|<!--|-->|--!>|<!-$/g,$0e=[">"],P0e=["<",">"];function tJ(e,t,a,r){return r.settings.bogusComments?"<?"+lc(e.value,Object.assign({},r.settings.characterReferences,{subset:$0e}))+">":"<!--"+e.value.replace(A0e,n)+"-->";function n(o){return lc(o,Object.assign({},r.settings.characterReferences,{subset:P0e}))}}function aJ(e,t,a,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}function a4(e,t){let a=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,n=a.indexOf(t);for(;n!==-1;)r++,n=a.indexOf(t,n+t.length);return r}function nJ(e,t){let a=t||{};return(e[e.length-1]===""?[...e,""]:e).join((a.padRight?" ":"")+","+(a.padLeft===!1?"":" ")).trim()}function rJ(e){return e.join(" ").trim()}var D0e=/[ \t\n\f\r]/g;function Pm(e){return typeof e=="object"?e.type==="text"?oJ(e.value):!1:oJ(e)}function oJ(e){return e.replace(D0e,"")===""}var _n=iJ(1),n4=iJ(-1),E0e=[];function iJ(e){return t;function t(a,r,n){let o=a?a.children:E0e,i=(r||0)+e,s=o[i];if(!n)for(;s&&Pm(s);)i+=e,s=o[i];return s}}var M0e={}.hasOwnProperty;function sI(e){return t;function t(a,r,n){return M0e.call(e,a.tagName)&&e[a.tagName](a,r,n)}}var Hx=sI({body:z0e,caption:r4,colgroup:r4,dd:F0e,dt:B0e,head:r4,html:O0e,li:j0e,optgroup:H0e,option:q0e,p:U0e,rp:sJ,rt:sJ,tbody:Z0e,td:lJ,tfoot:G0e,th:lJ,thead:V0e,tr:K0e});function r4(e,t,a){let r=_n(a,t,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&Pm(r.value.charAt(0)))}function O0e(e,t,a){let r=_n(a,t);return!r||r.type!=="comment"}function z0e(e,t,a){let r=_n(a,t);return!r||r.type!=="comment"}function U0e(e,t,a){let r=_n(a,t);return r?r.type==="element"&&(r.tagName==="address"||r.tagName==="article"||r.tagName==="aside"||r.tagName==="blockquote"||r.tagName==="details"||r.tagName==="div"||r.tagName==="dl"||r.tagName==="fieldset"||r.tagName==="figcaption"||r.tagName==="figure"||r.tagName==="footer"||r.tagName==="form"||r.tagName==="h1"||r.tagName==="h2"||r.tagName==="h3"||r.tagName==="h4"||r.tagName==="h5"||r.tagName==="h6"||r.tagName==="header"||r.tagName==="hgroup"||r.tagName==="hr"||r.tagName==="main"||r.tagName==="menu"||r.tagName==="nav"||r.tagName==="ol"||r.tagName==="p"||r.tagName==="pre"||r.tagName==="section"||r.tagName==="table"||r.tagName==="ul"):!a||!(a.type==="element"&&(a.tagName==="a"||a.tagName==="audio"||a.tagName==="del"||a.tagName==="ins"||a.tagName==="map"||a.tagName==="noscript"||a.tagName==="video"))}function j0e(e,t,a){let r=_n(a,t);return!r||r.type==="element"&&r.tagName==="li"}function B0e(e,t,a){let r=_n(a,t);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function F0e(e,t,a){let r=_n(a,t);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function sJ(e,t,a){let r=_n(a,t);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function H0e(e,t,a){let r=_n(a,t);return!r||r.type==="element"&&r.tagName==="optgroup"}function q0e(e,t,a){let r=_n(a,t);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function V0e(e,t,a){let r=_n(a,t);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function Z0e(e,t,a){let r=_n(a,t);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function G0e(e,t,a){return!_n(a,t)}function K0e(e,t,a){let r=_n(a,t);return!r||r.type==="element"&&r.tagName==="tr"}function lJ(e,t,a){let r=_n(a,t);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}var uJ=sI({body:Q0e,colgroup:X0e,head:J0e,html:W0e,tbody:Y0e});function W0e(e){let t=_n(e,-1);return!t||t.type!=="comment"}function J0e(e){let t=new Set;for(let r of e.children)if(r.type==="element"&&(r.tagName==="base"||r.tagName==="title")){if(t.has(r.tagName))return!1;t.add(r.tagName)}let a=e.children[0];return!a||a.type==="element"}function Q0e(e){let t=_n(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&Pm(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function X0e(e,t,a){let r=n4(a,t),n=_n(e,-1,!0);return a&&r&&r.type==="element"&&r.tagName==="colgroup"&&Hx(r,a.children.indexOf(r),a)?!1:!!(n&&n.type==="element"&&n.tagName==="col")}function Y0e(e,t,a){let r=n4(a,t),n=_n(e,-1);return a&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&Hx(r,a.children.indexOf(r),a)?!1:!!(n&&n.type==="element"&&n.tagName==="tr")}var lI={name:[[`