@stndrds/schema 1.0.0-alpha.295 → 1.0.0-alpha.296

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.
Files changed (77) hide show
  1. package/dist/{all-Cru_CaSY.d.mts → all-BekDmUP1.d.mts} +32 -32
  2. package/dist/{all-CDJSpI46.d.ts → all-Bl3DlCEn.d.ts} +32 -32
  3. package/dist/{attributes-CWPLbp7c.d.mts → attributes-CtS5Gf_i.d.mts} +1 -1
  4. package/dist/{attributes-CNYwg_Nr.d.ts → attributes-SIbTof03.d.ts} +1 -1
  5. package/dist/{chunk-TP63U7PL.js → chunk-47EGJRW7.js} +2 -2
  6. package/dist/{chunk-XPF6CGAW.js → chunk-5QAE5NPN.js} +4 -4
  7. package/dist/chunk-72TQRSNX.js +12 -0
  8. package/dist/{chunk-7SDHYJX4.mjs → chunk-GWAHL4A2.mjs} +1 -1
  9. package/dist/{chunk-HTY3NECU.mjs → chunk-JCPAOH76.mjs} +1 -1
  10. package/dist/{chunk-JOJ4LF2I.js → chunk-LQYUPOWB.js} +2 -2
  11. package/dist/chunk-PT25FZ62.mjs +12 -0
  12. package/dist/{chunk-OCAMDRO3.mjs → chunk-RFKNNT2Q.mjs} +1 -1
  13. package/dist/{chunk-EREGHAGI.js → chunk-SDOYGWU4.js} +2 -2
  14. package/dist/{chunk-257HAQVV.mjs → chunk-V43RXKN2.mjs} +1 -1
  15. package/dist/exceptions.d.mts +3 -2
  16. package/dist/exceptions.d.ts +3 -2
  17. package/dist/exceptions.js +1 -1
  18. package/dist/exceptions.mjs +1 -1
  19. package/dist/{helpers-Dul_r9rJ.d.mts → helpers-BUsoR80N.d.mts} +3 -3
  20. package/dist/{helpers-CXkVwpsl.d.ts → helpers-DZFOorZt.d.ts} +3 -3
  21. package/dist/{index-CFhPHQaI.d.ts → index-DaY37pqb.d.ts} +2 -2
  22. package/dist/{index-BdVnHL3F.d.mts → index-EHhbbH-p.d.mts} +2 -2
  23. package/dist/index.d.mts +87 -32
  24. package/dist/index.d.ts +87 -32
  25. package/dist/index.js +19 -19
  26. package/dist/index.mjs +11 -11
  27. package/dist/{migrations-fRvadl6i.d.mts → migrations-DRBic-QO.d.mts} +1 -1
  28. package/dist/{migrations-DaFneOfx.d.ts → migrations-DhQ05TqN.d.ts} +1 -1
  29. package/dist/{objects-DJv6WrDE.d.ts → objects-DMOfJNYg.d.ts} +2 -2
  30. package/dist/{objects-CDwMSnqv.d.mts → objects-KU7alqZq.d.mts} +2 -2
  31. package/dist/{types-NGEww_ln.d.ts → types-BNaHEz_n.d.ts} +1 -1
  32. package/dist/{types-CVYiFc69.d.mts → types-ldo4nJxP.d.mts} +1 -1
  33. package/dist/utils.js +1 -1
  34. package/dist/utils.mjs +1 -1
  35. package/dist/validation/all.d.mts +7 -7
  36. package/dist/validation/all.d.ts +7 -7
  37. package/dist/validation/all.js +1 -1
  38. package/dist/validation/all.mjs +1 -1
  39. package/dist/validation/complex/currency.d.mts +2 -2
  40. package/dist/validation/complex/currency.d.ts +2 -2
  41. package/dist/validation/complex/location.d.mts +2 -2
  42. package/dist/validation/complex/location.d.ts +2 -2
  43. package/dist/validation/complex/phone.d.mts +2 -2
  44. package/dist/validation/complex/phone.d.ts +2 -2
  45. package/dist/validation/complex/relation.d.mts +2 -2
  46. package/dist/validation/complex/relation.d.ts +2 -2
  47. package/dist/validation/complex/richtext.d.mts +2 -2
  48. package/dist/validation/complex/richtext.d.ts +2 -2
  49. package/dist/validation/complex/select.d.mts +2 -2
  50. package/dist/validation/complex/select.d.ts +2 -2
  51. package/dist/validation/complex/user.d.mts +2 -2
  52. package/dist/validation/complex/user.d.ts +2 -2
  53. package/dist/validation/computed/formula.d.mts +2 -2
  54. package/dist/validation/computed/formula.d.ts +2 -2
  55. package/dist/validation/computed/rollup.d.mts +2 -2
  56. package/dist/validation/computed/rollup.d.ts +2 -2
  57. package/dist/validation/config/index.d.mts +4 -4
  58. package/dist/validation/config/index.d.ts +4 -4
  59. package/dist/validation/config/index.js +1 -1
  60. package/dist/validation/config/index.mjs +1 -1
  61. package/dist/validation/core/index.d.mts +3 -3
  62. package/dist/validation/core/index.d.ts +3 -3
  63. package/dist/validation/object/index.d.mts +5 -5
  64. package/dist/validation/object/index.d.ts +5 -5
  65. package/dist/validation/object/index.js +1 -1
  66. package/dist/validation/object/index.mjs +1 -1
  67. package/dist/validation/primitives/checkbox.d.mts +2 -2
  68. package/dist/validation/primitives/checkbox.d.ts +2 -2
  69. package/dist/validation/primitives/date.d.mts +2 -2
  70. package/dist/validation/primitives/date.d.ts +2 -2
  71. package/dist/validation/primitives/number.d.mts +2 -2
  72. package/dist/validation/primitives/number.d.ts +2 -2
  73. package/dist/validation/primitives/text.d.mts +2 -2
  74. package/dist/validation/primitives/text.d.ts +2 -2
  75. package/package.json +2 -2
  76. package/dist/chunk-TKABCIEO.js +0 -12
  77. package/dist/chunk-YBDR5ZMH.mjs +0 -12
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import {d,a as a$4}from'./chunk-HTY3NECU.mjs';export{b as asTenantId,c as asUserId,a as canonicalStringify,f as deepEqual,d as generateId,e as indexBy}from'./chunk-HTY3NECU.mjs';import {z as z$2,Q as Q$1,T as T$1,A as A$1,ka as ka$1,la as la$1,ia as ia$1,da as da$1,ca as ca$1,Z as Z$1,_,X,ga as ga$1,ja as ja$1,w as w$1,$ as $$1,Y,n as n$1,j,g,h as h$1,I,H,F as F$1,B,qa as qa$1,pa as pa$1}from'./chunk-7SDHYJX4.mjs';export{i as ATTRIBUTE_FILTER_OPERATORS,qa as LIST_TAB_KANBAN_KEYS,pa as LIST_TAB_TABLE_KEYS,w as LIST_VIEW_TAB_VISIBILITIES,f as LOCATION_FILTER_PROPERTIES,s as NO_VALUE_OPERATORS,r as OPERATORS_BY_TYPE,U as REMOVED_OPERATOR_REPLACEMENTS,z as RESERVED_ATTRIBUTE_NAMES,A as RESERVED_OBJECT_NAMES,v as RESOURCE_VISIBILITIES,M as SYNONYM_ALIASES,c as SYSTEM_ATTRIBUTES,a as SYSTEM_ATTRIBUTE_I18N_KEYS,y as SYSTEM_FIELD_NAMES,T as SYSTEM_FILTER_ATTRIBUTE_TYPES,L as canonicalizeFilterValue,V as collectQualifiedRuleIssues,X as columnsSchema,C as currentActor,ia as detailTabDraftSchema,ha as detailTabSchema,la as detailViewConfigSchema,Y as displayAttributesSchema,F as extractCurrencyFilterValue,G as extractFilterValue,ba as fieldSchema,aa as fieldShape,ca as fieldSlotSchema,$ as filterGroupSchema,_ as filterStateSchema,j as getAttributeCapabilities,k as getAttributeFilterOperators,H as getOperatorPolarity,u as getRollupFilterOperators,b as getSystemAttributeI18nKey,d as getSystemAttributeList,da as groupWriteSchema,fa as inverseSourceSchema,l as isAttributeFilterable,o as isAttributeGroupable,p as isAttributeKanbanGroupable,m as isAttributeSearchable,B as isDynamicValue,g as isLocationFilterProperty,h as isLocationPartOperator,e as isManagedSystemAttribute,t as isNoValueOperator,P as isRelativeDateValue,K as isSetMembershipOperator,ka as listViewConfigSchema,ja as listViewTabSchema,O as normalizeFilterRule,I as normalizeForEdgeRpc,N as normalizeOperator,E as now,x as parseResourceVisibility,oa as parseViewConfig,ea as relationSourceSchema,q as resolveEffectiveFilterType,Q as resolveIsWithinBounds,R as resolveUtcDayBounds,Z as sortsSchema,ga as tableSourceSchema,J as toMultiValueOperator,S as toUtcDayString,D as today,W as validateQualifiedRule,na as viewConfigByTypeSchema,ma as viewTypeSchema}from'./chunk-7SDHYJX4.mjs';import {a as a$1,c as c$2,e,g as g$1}from'./chunk-257HAQVV.mjs';export{d as createFormAttributeValidator,a as isNullishOrEmptyString,b as isValuePresent,l as rejectUnknownAttributesOrThrow,j as validateDraft,k as validateDraftOrThrow,h as validateObject,i as validateObjectOrThrow}from'./chunk-257HAQVV.mjs';import'./chunk-GKXTXH4Y.mjs';import'./chunk-VKFLXFPP.mjs';import'./chunk-YIXNAWH6.mjs';import'./chunk-XRDP2Y4J.mjs';import'./chunk-Q7TQCRSD.mjs';import'./chunk-WMQRTFOP.mjs';import {c,n,e as e$1,m}from'./chunk-OCAMDRO3.mjs';export{d as ComputedFormulaParseError,a as SCHEMA_LIMITS,b as colorIdSchema,c as iconNameSchema,h as multiselectOptionWriteSchema,l as parseAttributeConfig,n as parseAttributeConfigForCreate,o as parseAttributeConfigForUpdate,e as parseComputedFormula,g as selectOptionWriteSchema,f as statusGroupSchema,i as statusOptionWriteSchema}from'./chunk-OCAMDRO3.mjs';export{a as createCheckboxValidator}from'./chunk-4VCADZK4.mjs';export{a as createDateValidator}from'./chunk-KYPEBOPW.mjs';export{a as createNumberValidator}from'./chunk-KG2ADZG6.mjs';export{a as TEXT_FORMAT_PATTERNS,c as createTextValidator,b as resolveTextPattern}from'./chunk-O34B5KOW.mjs';import {h,b as b$1,a as a$2,r,c as c$3}from'./chunk-YBDR5ZMH.mjs';export{B as AccessDeniedError,H as AttributeInUseError,e as AttributeNotFoundError,q as ChangeTypeNotSupportedError,z as ConcurrentModificationError,o as DestructiveSyncNotAllowedError,r as DuplicateError,w as ForbiddenError,F as MemoryNotFoundError,p as MigrationTimeoutError,c as NotFoundError,E as NotImplementedError,d as ObjectNotFoundError,I as ObjectReferencedError,n as OrphanSystemAttributeError,i as ProtectedResourceError,x as ProtectedRoleError,f as RecordNotFoundError,G as RecordReferencedError,C as RepositoryError,y as RoleNotFoundError,b as SchemaError,a as SchemaErrorCode,g as SchemaPlanNotFoundError,D as SearchBackendError,A as StorageError,m as SyncCascadeError,l as SyncConflictError,j as SyncError,k as SystemEntityImmutableError,h as ValidationError,K as isAttributeInUseError,t as isNotFoundError,L as isObjectReferencedError,v as isProtectedResourceError,J as isRecordReferencedError,s as isSchemaError,u as isValidationError}from'./chunk-YBDR5ZMH.mjs';import'./chunk-PFO7NWQW.mjs';import'./chunk-XMQV2WFY.mjs';import {c as c$1,a as a$3,b as b$2}from'./chunk-LB4TNMZU.mjs';export{a as DEFAULT_VALIDATION_MESSAGES,b as formatZodErrors}from'./chunk-4OTKOCGB.mjs';import {a}from'./chunk-KSPJP74K.mjs';import {ICONS,SKILL_NAME_MAX_LENGTH,SKILL_DESCRIPTION_MAX_LENGTH,MEMORY_NAME_MAX_LENGTH,MEMORY_DESCRIPTION_MAX_LENGTH,getCountryDisplayNameByIso3}from'@stndrds/constants';import Jt,{z as z$1}from'zod';/*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
2
- var ki=["fyi","task","question","handoff","system"],Oi=["low","normal","high","urgent"],_i=["public","internal","sensitive"],Pi=["unread","read","archived","snoozed"],Fi=["none","pending","processing","completed","dismissed","expired","failed"],hs="agent.session.waiting_human",As="agent.task.assigned",Ts="agent.question.requested",Kf=[hs,As,Ts];var Hf=["name","type"],Qf=["required","hidden","archived","deprecated","defaultValue","config","order","unique"],Jf=["label","description","placeholder","icon"];var Vi=["text","richtext","number","checkbox","date","phone","currency","status","location","select","multiselect","user","relation","formula","rollup","document"],$t="*";function ji(e){return e.targets.length===1&&e.targets[0].object===$t}a(ji,"isUniversalRelation");function eb(e){return e.bilateral!==void 0}a(eb,"isBilateralRelation");function tb(e){return "many"}a(tb,"inferInverseCardinality");function rb(e){return n$1(e)}a(rb,"isAttributeSortable");var ob=["record","object","attribute","view","user","role","settings","file","agent","schema_source"],ab=["record.created","record.updated","record.deleted","record.restored","record.purged","object.created","object.updated","object.deleted","attribute.created","attribute.updated","attribute.deleted","view.created","view.updated","view.deleted","schema_source.applied","schema_source.removed","user.created","user.invited","user.updated","user.deleted","user.login","user.logout","role.created","role.updated","role.deleted","role.assigned","role.revoked","settings.updated","file.uploaded","file.updated","file.deleted"];function lb(e){return e.phase==="terminal"}a(lb,"isTerminalState");function db(e){switch(e.phase){case "running":return "active";case "queued":return "idle";case "parked":if(e.parkedOn===void 0)throw new b$1("parked state without parkedOn",a$2.INVARIANT_VIOLATION);return e.parkedOn==="agents"?"waiting_agents":"waiting_human";case "terminal":if(e.outcome===void 0)throw new b$1("terminal state without outcome",a$2.INVARIANT_VIOLATION);return e.outcome}}a(db,"sessionStateToLegacyStatus");function cb(e){switch(e){case "active":return {phase:"running"};case "idle":return {phase:"queued"};case "waiting_human":return {phase:"parked",parkedOn:"human",humanRequestIds:[]};case "waiting_agents":return {phase:"parked",parkedOn:"agents"};default:return {phase:"terminal",outcome:e}}}a(cb,"legacyStatusToSessionState");var ws=["completed","failed","cancelled","timeout","expired"];function pb(e){return ws.includes(e)}a(pb,"isTerminalSessionStatus");var xs=["idle","completed","waiting_human","waiting_agents","cancelled","failed","timeout"];function mb(e){return xs.includes(e)}a(mb,"isClaimableSessionStatus");var Li=Object.freeze({mutation:"ask",destructive:"ask",outward:"ask"}),fb=["active","completed","abandoned"],Mi=["openai","anthropic","google","spacexai","deepseek","moonshotai","alibaba","mistral","minimax","meta","zai"],Bi=["standard","fast"],Ui=["none","minimal","low","medium","high","xhigh"];function bb(e){return e.label?.trim()||e.name}a(bb,"agentDisplayName");var $i=["approval-requested","approval-responded","approval-dispatched"],Is=["streaming","running",...$i];function gb(e){return Is.includes(e)}a(gb,"isOpenToolPartState");function yb(e){return $i.includes(e)}a(yb,"isToolApprovalState");var qt=["CREDITS_EXHAUSTED"];function hb(e){return typeof e=="string"&&qt.includes(e)}a(hb,"isSystemPartCode");function Ss(e,t){let r=e.createdAt.getTime()-t.createdAt.getTime();return r===0?e.id.localeCompare(t.id):r}a(Ss,"compareAgentSessionMessages");function Ab(e){return [...e].sort(Ss)}a(Ab,"orderAgentSessionMessages");var Tb=["pending","in_progress","completed","blocked"],wb=50,xb=80,Ib=500,Sb=2e3;var Db="session-state",vs="__stndrdsNativeUiPartIds",Rs=1,Es="Native agent UI part IDs metadata is invalid";function se(){throw new h(Es,[])}a(se,"invalidNativePartIds");function qi(e){if(e===null||typeof e!="object"||Array.isArray(e))return false;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}a(qi,"isPlainRecord");function Ds(e,t){if(e.type==="text"||e.type==="reasoning")return `${e.type}:${t}`;if(e.type==="tool")return `tool:${e.toolCallId}`}a(Ds,"nativeAgentUIPartIdMetadataKey");function Cb(e){let t=e.metadata?.[vs];qi(t)||se(),(Object.keys(t).length!==2||t.schemaVersion!==Rs||!qi(t.partIds))&&se();let r=new Map;for(let[s,l]of e.parts.entries()){let p=Ds(l,s);if(!p||r.has(p)){p&&se();continue}r.set(p,l);}let n=Object.entries(t.partIds);n.length!==r.size&&se();let o=new Map,a={};for(let[s,l]of n){let p=r.get(s);p&&typeof l=="string"&&l.length>0||se();let I=o.get(l);I&&(p.type==="tool"||I!==p.type)&&se(),p.type==="tool"&&l!==p.toolCallId&&se(),o.set(l,p.type),a[s]=l;}return a}a(Cb,"parseNativeAgentUIPartIdsMetadata");var Ob=16e3,_b=3200,Pb=6400,Fb=16e3,Vb=65536,jb=15e3,Lb=1e4,Mb=5e3,Bb="google/gemini-3.5-transcribe-live",Ub={maxDurationMs:3e5,dailyDurationMs:36e5,monthlyDurationMs:72e6,tenantMonthlyBudgetMicrousd:5e7,globalMonthlyBudgetMicrousd:5e7,estimatedMicrousdPerSecond:150,reservationMultiplier:2};var qb=["web","presentation","document","spreadsheet","image","code","other"],zb=["ephemeral","conversation","persistent"],Gb=["source","preview","entrypoint","asset"];var zi=5;function Yb(e){return e instanceof Error?e.message:typeof e=="string"?e:e&&typeof e=="object"?"message"in e&&typeof e.message=="string"?e.message:JSON.stringify(e):String(e)}a(Yb,"getErrorMessage");function Xb(e){return typeof e=="object"&&e!==null&&"slots"in e&&"steps"in e&&"name"in e&&typeof e.name=="string"&&Array.isArray(e.slots)&&Array.isArray(e.steps)}a(Xb,"isFormDefinition");var zt=["relation","multiRelation","formula","rollup","document","richtext","user"];function Gi(e){return e.type==="slot"}a(Gi,"isFormSlotFieldRef");function Gt(e){return e.type==="free"}a(Gt,"isFormFreeFieldRef");function tg(e){return e.fieldRequired!==void 0?e.fieldRequired:e.slotMode==="create"&&e.attributeRequired===true}a(tg,"resolveFieldRequired");function Wi(e){return e.additionalSlotIds?.length?[e.slotId,...e.additionalSlotIds]:[e.slotId]}a(Wi,"getSlotFieldTargets");function Cs(e){return Gi(e)?`${e.slotId}.${e.attribute}`:`free.${e.attribute.name}`}a(Cs,"formFieldKey");function Ns(e){return Gi(e)?e.attribute:e.attribute.name}a(Ns,"formFieldFlatKey");function rg(e,t){return e[Cs(t)]??e[Ns(t)]}a(rg,"readFormFieldValue");function We(e){return e.type==="fields"}a(We,"isFormFieldsRow");function og(e){return e.type==="heading"}a(og,"isFormHeadingRow");function ag(e){return e.type==="separator"}a(ag,"isFormSeparatorRow");function sg(e){return e.type==="text"}a(sg,"isFormTextRow");var Wt=class Wt{async autocomplete(){return await Promise.resolve([])}async reverse(){return await Promise.resolve(null)}async geocode(){return await Promise.resolve(null)}};a(Wt,"NoopGeocodingAdapter");var Ki=Wt;var Kt=["read","create","update","delete","manage"];function fg(e){return e.length===0?"none":e.length===1&&e[0]==="read"?"read-only":e.length===Kt.length&&Kt.every(t=>e.includes(t))?"full":"custom"}a(fg,"actionsToAccessLevel");function bg(e){switch(e){case "full":return [...Kt];case "read-only":return ["read"];case "none":return []}}a(bg,"accessLevelToActions");function Yi(e){let t=e.properties;if(!t)return [];if(Array.isArray(t))return t;let r=t;return Array.isArray(r.definitions)?r.definitions:[]}a(Yi,"resolvePropertyDefinitions");function hg(e){return e.type==="select"||e.type==="status"||e.type==="multiselect"}a(hg,"hasOptions");var ks="Notetaker",wg={systemPrompt:null,meetingRecordingPolicy:"none",meetingBotDisplayName:ks};var Ig=["active","suspended"],Sg=["plan","manual","auto"];function Rg(e){return `${e.object}:${e.name}:${e.type}`}a(Rg,"viewStateKey");function Ke(e){return e.type==="detail"}a(Ke,"isDetailView");function Hi(e){return e.type==="list"}a(Hi,"isListView");function Os(e){return e.type==="fields"}a(Os,"isFieldGroup");var kg=["square","landscape","portrait"];var Qi=["none","estimated","exact"];function _s(e){if(typeof e=="string"&&Qi.includes(e))return e;throw new h(`countMode must be one of: ${Qi.join(", ")} (received: ${String(e)})`,[])}a(_s,"parseCountMode");function Pg(e){return e===void 0?void 0:_s(e)}a(Pg,"parseOptionalCountMode");var Fg=1e4;function Ps(e){return e==null?true:typeof e!="object"?false:Object.keys(e).length===0}a(Ps,"isEmptyObject");function Ji(e){return e!=null&&typeof e=="object"&&Object.keys(e).length>0}a(Ji,"isNotEmpty");function Fs(e){return Ji(e)?e:void 0}a(Fs,"toUndefinedIfEmpty");function Vs(e){if(e<=0)return {value:0,unitIndex:0};let t=1e3,r=Math.min(4,Math.floor(Math.log(e)/Math.log(t)));return {value:Number.parseFloat((e/t**r).toFixed(1)),unitIndex:r}}a(Vs,"computeByteMagnitude");var js=["B","KB","MB","GB","TB"];function Dy(e){let{value:t,unitIndex:r}=Vs(e);return `${t} ${js[r]}`}a(Dy,"formatByteSize");function Ls(e){return e.displayAttributes!==void 0?[...e.displayAttributes]:[...new Set([e.cardUserAttribute,e.cardDateAttribute].filter(t=>t!==void 0))]}a(Ls,"getListViewDisplayAttributeNames");var _y={ATTACHMENTS:"attachments"};function Py(e){return e.type==="document"}a(Py,"isDocumentAttribute");function Fy(e,t){if(!t||t.length===0)return true;let r=e.name.toLowerCase();return t.some(n=>n.endsWith("/*")?e.mimeType.startsWith(n.slice(0,-1)):n.startsWith(".")?r.endsWith(n.toLowerCase()):e.mimeType===n)}a(Fy,"matchesAccepts");var Xi=Object.freeze(["text","number","checkbox","date","phone","currency","status","select","multiselect","location"]);function Ye(e){let t=[];for(let r of e){let n=r.build();if(!Xi.includes(n.type))throw new Error(`Property type "${n.type}" is not supported in .qualifyWith()`);t.push(n);}return {definitions:t}}a(Ye,"buildPropertySchema");var By="__";function Uy(e){let t=e.indexOf("__");return t<=0||t+2>=e.length?{kind:"scalar",attribute:e}:{kind:"qualified",root:e.slice(0,t),property:e.slice(t+2)}}a(Uy,"parseQualifiedAttribute");function $y(e,t){return `${e}__${t}`}a($y,"buildQualifiedAttribute");function Z(e){return typeof e=="object"&&e!==null&&typeof e.start=="string"}a(Z,"isDateRangeValue");function Ms(e,t){return a$1(e)?null:Z(e)?t.endDate?{start:e.start,end:e.end??null}:e.start:typeof e=="string"?t.endDate?{start:e,end:null}:e:null}a(Ms,"normalizeDateValue");function fe(e){return typeof e=="string"&&e!==""?e:Z(e)&&e.start!==""?e.start:null}a(fe,"dateValueStart");var He="\u2014";function Bs(e){return String(e)}a(Bs,"formatText");function Us(e){return e?"Yes":"No"}a(Us,"formatCheckbox");function $s(e,t){if(typeof e!="number")return String(e);if(t.renderAs==="rating")return `${e}/${t.max??5}`;let r=t.decimals;return t.unit==="integer"?e.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:0}):t.unit==="percentage"?(e/100).toLocaleString(void 0,{style:"percent",minimumFractionDigits:r,maximumFractionDigits:r}):e.toLocaleString(void 0,{minimumFractionDigits:r,maximumFractionDigits:r})}a($s,"formatNumber");function qs(e,t){if(typeof e!="object"||e===null)return String(e);let r=e;return "value"in r&&"code"in r?`${r.value.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})} ${r.code}`:String(e)}a(qs,"formatCurrency");function Yt(e){if(Z(e)){let t=Yt(e.start);return e.end?`${t} \u2192 ${Yt(e.end)}`:t}if(e instanceof Date)return e.toISOString().split("T")[0];if(typeof e=="string"){let t=new Date(e);if(!Number.isNaN(t.getTime()))return t.toISOString().split("T")[0]}return String(e)}a(Yt,"formatDate");function zs(e){if(typeof e!="object"||e===null)return String(e);let t=e;return "phoneNumber"in t?t.phoneNumber?t.countryCode?c$1(t):t.phoneNumber:"":String(e)}a(zs,"formatPhone");function Gs(e,t="full"){if(typeof e!="object"||e===null)return "";let r=e,n=[];switch(t){case "country":r.country&&n.push(getCountryDisplayNameByIso3(r.country));break;case "state":r.state&&n.push(r.state),r.country&&n.push(getCountryDisplayNameByIso3(r.country));break;case "city":r.city&&n.push(r.city),r.state&&n.push(r.state),r.country&&n.push(getCountryDisplayNameByIso3(r.country));break;case "coordinates":r.latitude!==void 0&&r.longitude!==void 0&&n.push(`${r.latitude}, ${r.longitude}`);break;case "address":r.address&&n.push(r.address),r.city&&n.push(r.city),r.state&&n.push(r.state),r.country&&n.push(getCountryDisplayNameByIso3(r.country));break;default:r.address&&n.push(r.address),r.address2&&n.push(r.address2),r.city&&n.push(r.city),r.state&&n.push(r.state),r.postalCode&&n.push(r.postalCode),r.country&&n.push(getCountryDisplayNameByIso3(r.country));break}return n.join(", ")}a(Gs,"formatLocationValue");function Ws(e,t){return typeof e!="object"||e===null?String(e):Gs(e,t.granularity??"full")||He}a(Ws,"formatLocation");function Ks(e,t){return typeof e!="string"?String(e):t.options?.find(n=>n.value===e)?.label??String(e)}a(Ks,"formatSelect");function Ys(e,t){return Array.isArray(e)?t.options?e.map(n=>t.options.find(o=>o.value===n)?.label).filter(Boolean).join(", "):e.join(", "):String(e)}a(Ys,"formatMultiselect");function Zi(e,t){if(a$1(e))return He;switch(t.type){case "text":return Bs(e);case "checkbox":return Us(e);case "number":return $s(e,t);case "currency":return qs(e);case "date":return Yt(e);case "phone":return zs(e);case "location":return Ws(e,t);case "select":case "status":return Ks(e,t);case "multiselect":return Ys(e,t);case "user":case "relation":return Array.isArray(e)?e.join(", "):String(e);default:return Array.isArray(e)?e.join(", "):String(e)}}a(Zi,"formatAttributeValue");var Qs=["UPPER","LOWER","capitalize","trim"],Js=["prefix","suffix","wrap","default"],Qe=[...Qs,...Js],be=z$1.string().min(1,"labelExpression cannot be empty").refine(e=>Je(e),{message:"labelExpression must contain at least one {{ attribute }} interpolation"}).refine(e=>!/\{\{\s*\}\}/.test(e),{message:"labelExpression contains empty {{ }} interpolation"}).refine(e=>{let t=/(?<!\|)\|(?!\|)\s*(\w+)(?::[^|}]*)?/g,r;for(;(r=t.exec(e))!==null;){let n=r[1];if(!Qe.includes(n))return false}return true},{message:`Invalid pipe name. Valid pipes: ${Qe.join(", ")}`});function Xs(e){let t=be.safeParse(e);return t.success?{success:true,attributes:oo(e)}:{success:false,error:t.error.issues[0]?.message??"Invalid labelExpression"}}a(Xs,"validateLabelExpression");var eo={UPPER:a(e=>String(e).toUpperCase(),"UPPER"),LOWER:a(e=>String(e).toLowerCase(),"LOWER"),capitalize:a(e=>String(e).replace(/(^|\s)\S/g,t=>t.toUpperCase()),"capitalize"),trim:a(e=>String(e).trim(),"trim")},to={prefix:a((e,t="")=>e?`${t}${e}`:"","prefix"),suffix:a((e,t="")=>e?`${e}${t}`:"","suffix"),wrap:a((e,t="",r="")=>e?`${t}${e}${r}`:"","wrap"),default:a((e,t="")=>e||t,"default")};function Zs(e,t){let r=e;for(let n of t){let{name:o,args:a}=no(n),s=eo[o];if(s)r!==""&&(r=s(r));else {let l=to[o];l&&(r=l(r,...a));}}return r}a(Zs,"applyPipes");function eu(e,t){return t.split(".").reduce((r,n)=>{if(!(r==null||typeof r!="object"))return r[n]},e)}a(eu,"getValue");var ro="(Untitled)";function no(e){let t=e.match(/^(\w+)(?::(.*))?$/);if(!t)return {name:e,args:[]};let r=t[1],n=t[2];if(!n)return {name:r,args:[]};let o=[],a=/["']([^"']*?)["']/g,s;for(;(s=a.exec(n))!==null;)o.push(s[1]);return {name:r,args:o}}a(no,"parsePipeExpression");function Ht(e,t,r=ro){return e.replace(/\{\{\s*([^}]+)\s*\}\}/g,(o,a)=>{let s=a.split("||").map(j=>j.trim()),p=s[s.length-1].split("|").map(j=>j.trim());s[s.length-1]=p[0];let I=p.slice(1).filter(Boolean),X=s.filter(Boolean),B="";for(let j of X){let Y=io(eu(t,j));if(Y!==""){B=Y;break}}if(a$1(B)&&I.length===0)return "";for(let j of I){let{name:Y,args:es}=no(j),si=eo[Y];if(si)B!==""&&(B=si(B));else {let ui=to[Y];ui&&(B=ui(B,...es));}}return B}).trim()||r}a(Ht,"renderLabelExpression");function io(e){if(e==null||typeof e=="function")return "";if(typeof e!="object")return String(e);if(Array.isArray(e))return e.map(io).filter(Boolean).join(",");let t=e.toString;return typeof t=="function"&&t!==Object.prototype.toString?String(e):""}a(io,"toText");function Je(e){return /\{\{\s*\S+.*\}\}/.test(e)}a(Je,"isLabelExpression");function oo(e){let t=[],r=/\{\{\s*([^}]+)\s*\}\}/g,n;for(;(n=r.exec(e))!==null;){let a=n[1].trim().split("||").map(l=>l.trim()),s=a[a.length-1];a[a.length-1]=s.split("|")[0].trim();for(let l of a){if(!l)continue;let p=l.split(".")[0];p&&!t.includes(p)&&t.push(p);}}return t}a(oo,"extractAttributeNames");var tu=/^\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}$/;function ao(e){let t=e.trim().match(tu);return t?t[1]:null}a(ao,"getSingleAttributeFromExpression");function ru(e,t){let r=ao(e);if(r===null)return null;let n=t.find(o=>o.name===r);return !n||n.type!=="text"||j(n).authoring.readOnly?null:n}a(ru,"getEditableLabelAttribute");var nu=/\{\{\s*props\./;function iu(e,t,r){if(!nu.test(e))return e;let n={},o=new Map(r?.map(s=>[s.name,s]));if(t)for(let[s,l]of Object.entries(t)){if(l==null)continue;let p=o.get(s);if(p){let I=Zi(l,p);n[s]=I===He?"":I;}else n[s]=l;}return Ht(e,{props:n},"").replace(/\(\s*\)/g,"").replace(/\[\s*\]/g,"").replace(/\s*[-—|:]\s*$/g,"").replace(/\s{2,}/g," ").trim()}a(iu,"applyRelationProps");function ou(e){if(e?.type==="relation")return e.properties?.definitions}a(ou,"relationPropertyDefs");function au(e){if(e?.type==="relation"||e?.type==="document")return e.properties?.definitions}a(au,"qualifiedPropertyDefs");function so(e){if(a$1(e))return [];if(typeof e=="string")return [{id:e}];if(Array.isArray(e))return e.flatMap(t=>so(t));if(typeof e=="object"&&"id"in e){let t=e;if(typeof t.id=="string")return [{id:t.id,props:t.props}]}return []}a(so,"extractValueRefs");function su(e){let t=[e.firstName,e.lastName].map(r=>r?.trim()).filter(Boolean).join(" ");return t!==""?t:e.email?.split("@")[0]??""}a(su,"getUserDisplayName");var uu=/\p{L}|\p{N}/u;function lu(e,t){let r=e?.trim()??"";if(r==="")return t;let n=r.split(/\s+/),a=(n.length===1?r.split("@")[0].split(/[._-]/):n).map(s=>{let l=s.match(uu)?.[0];return l===void 0?"":[...l.toUpperCase()][0]??""}).filter(Boolean).slice(0,2).join("");return a===""?t:a}a(lu,"deriveInitials");var uo="__creatorRootActorId";function du(e){let t=e.metadata?.[uo];return typeof t=="string"&&t.length>0?t:e.createdBy}a(du,"getRecordCreatorPrincipalId");function ge(e,t){return e?.includes("*")===true||e?.includes(t)===true}a(ge,"includesAction");function cu(e){return {canRead:ge(e,"read"),canCreate:ge(e,"create"),canUpdate:ge(e,"update"),canDelete:ge(e,"delete"),canManage:ge(e,"manage")}}a(cu,"buildPermissionFlags");var gh=new Set(["id","name","label","type","required","system","unique","order"]);var L={PEOPLE:"people",WORKSPACE:"workspace",ARCHITECT:"architect",FEATURE_FLAGS:"feature-flags",FILES:"files",VIEWS:"views",FORMS:"forms",DOCUMENTS:"documents",AUDIT:"audit",API_KEYS:"api-keys",CONNECTORS:"connectors",ENV_VARS:"env-vars",SESSION:"session"},hh=[L.PEOPLE,L.WORKSPACE,L.ARCHITECT,L.FEATURE_FLAGS,L.FILES,L.VIEWS,L.FORMS,L.DOCUMENTS,L.AUDIT,L.API_KEYS,L.CONNECTORS,L.ENV_VARS,L.SESSION],Ah={people:"People",workspace:"Workspace",architect:"Architect","feature-flags":"Feature flags",files:"Files",views:"Views",forms:"Forms",documents:"Documents",audit:"Audit","api-keys":"API keys",connectors:"Connected accounts","env-vars":"Environment variables",session:"Agent sessions"},pu={OWNER:"owner",MEMBER:"member",AGENT_DEFAULT:"agent_default",REFLEX_DEFAULT:"reflex_default"},Th={owner:"Owner",member:"Member",agent_default:"Agent Default",reflex_default:"Reflex Default"},wh={owner:"Full access to all platform features and data",member:"Can view, create, edit and delete business data",agent_default:"Default role for AI agents \u2014 CRUD on records plus documents and files",reflex_default:"Default role for reflexes \u2014 no data access; each reflex is granted exactly what its rehearsal showed it uses"},Qt=["read","create","update","delete","manage"],mu=["read","create","delete"],xh={owner:{system:[{target:"*",actions:Qt}],object:[{target:"*",actions:Qt}]},member:{system:[{target:"people",actions:["read"]},{target:"workspace",actions:["read"]},{target:"connectors",actions:mu},{target:"files",actions:["read","create","update"]}],object:[{target:"*",actions:Qt}]},agent_default:{system:[{target:"documents",actions:["read","create","update"]},{target:"files",actions:["read","create","update"]},{target:"env-vars",actions:["read"]},{target:"session",actions:["observe"]}],object:[{target:"*",actions:["read","create","update","delete"]}]},reflex_default:{system:[],object:[]}};function Ih(e){return Object.values(pu).includes(e)}a(Ih,"isDefaultRole");var bu=new Set(ICONS),co=/^[a-zA-Z_][a-zA-Z0-9_]*$/,gu=/^[a-z][a-z0-9-]*$/,ye=63,lo=128,Xe=Jt.string().min(1,"Object name cannot be empty").max(63,"Object name is too long (max 63 characters)").regex(/^[a-z][a-z0-9-]*$/,{message:`Invalid object name format.
1
+ import {d,a as a$4}from'./chunk-JCPAOH76.mjs';export{b as asTenantId,c as asUserId,a as canonicalStringify,f as deepEqual,d as generateId,e as indexBy}from'./chunk-JCPAOH76.mjs';import {z as z$2,Q as Q$1,T as T$1,A as A$1,ka as ka$1,la as la$1,ia as ia$1,da as da$1,ca as ca$1,Z as Z$1,_,X,ga as ga$1,ja as ja$1,w as w$1,$ as $$1,Y,n as n$1,j,g,h as h$1,I,H,F as F$1,B,qa as qa$1,pa as pa$1}from'./chunk-GWAHL4A2.mjs';export{i as ATTRIBUTE_FILTER_OPERATORS,qa as LIST_TAB_KANBAN_KEYS,pa as LIST_TAB_TABLE_KEYS,w as LIST_VIEW_TAB_VISIBILITIES,f as LOCATION_FILTER_PROPERTIES,s as NO_VALUE_OPERATORS,r as OPERATORS_BY_TYPE,U as REMOVED_OPERATOR_REPLACEMENTS,z as RESERVED_ATTRIBUTE_NAMES,A as RESERVED_OBJECT_NAMES,v as RESOURCE_VISIBILITIES,M as SYNONYM_ALIASES,c as SYSTEM_ATTRIBUTES,a as SYSTEM_ATTRIBUTE_I18N_KEYS,y as SYSTEM_FIELD_NAMES,T as SYSTEM_FILTER_ATTRIBUTE_TYPES,L as canonicalizeFilterValue,V as collectQualifiedRuleIssues,X as columnsSchema,C as currentActor,ia as detailTabDraftSchema,ha as detailTabSchema,la as detailViewConfigSchema,Y as displayAttributesSchema,F as extractCurrencyFilterValue,G as extractFilterValue,ba as fieldSchema,aa as fieldShape,ca as fieldSlotSchema,$ as filterGroupSchema,_ as filterStateSchema,j as getAttributeCapabilities,k as getAttributeFilterOperators,H as getOperatorPolarity,u as getRollupFilterOperators,b as getSystemAttributeI18nKey,d as getSystemAttributeList,da as groupWriteSchema,fa as inverseSourceSchema,l as isAttributeFilterable,o as isAttributeGroupable,p as isAttributeKanbanGroupable,m as isAttributeSearchable,B as isDynamicValue,g as isLocationFilterProperty,h as isLocationPartOperator,e as isManagedSystemAttribute,t as isNoValueOperator,P as isRelativeDateValue,K as isSetMembershipOperator,ka as listViewConfigSchema,ja as listViewTabSchema,O as normalizeFilterRule,I as normalizeForEdgeRpc,N as normalizeOperator,E as now,x as parseResourceVisibility,oa as parseViewConfig,ea as relationSourceSchema,q as resolveEffectiveFilterType,Q as resolveIsWithinBounds,R as resolveUtcDayBounds,Z as sortsSchema,ga as tableSourceSchema,J as toMultiValueOperator,S as toUtcDayString,D as today,W as validateQualifiedRule,na as viewConfigByTypeSchema,ma as viewTypeSchema}from'./chunk-GWAHL4A2.mjs';import {c,n,e as e$1,m}from'./chunk-RFKNNT2Q.mjs';export{d as ComputedFormulaParseError,a as SCHEMA_LIMITS,b as colorIdSchema,c as iconNameSchema,h as multiselectOptionWriteSchema,l as parseAttributeConfig,n as parseAttributeConfigForCreate,o as parseAttributeConfigForUpdate,e as parseComputedFormula,g as selectOptionWriteSchema,f as statusGroupSchema,i as statusOptionWriteSchema}from'./chunk-RFKNNT2Q.mjs';import {a as a$1,c as c$2,e,g as g$1}from'./chunk-V43RXKN2.mjs';export{d as createFormAttributeValidator,a as isNullishOrEmptyString,b as isValuePresent,l as rejectUnknownAttributesOrThrow,j as validateDraft,k as validateDraftOrThrow,h as validateObject,i as validateObjectOrThrow}from'./chunk-V43RXKN2.mjs';import'./chunk-GKXTXH4Y.mjs';import'./chunk-Q7TQCRSD.mjs';import'./chunk-WMQRTFOP.mjs';export{a as createCheckboxValidator}from'./chunk-4VCADZK4.mjs';export{a as createDateValidator}from'./chunk-KYPEBOPW.mjs';import {c as c$1,a as a$3,b as b$2}from'./chunk-LB4TNMZU.mjs';import'./chunk-PFO7NWQW.mjs';import'./chunk-XMQV2WFY.mjs';import'./chunk-VKFLXFPP.mjs';import'./chunk-YIXNAWH6.mjs';import'./chunk-XRDP2Y4J.mjs';import {h,b as b$1,a as a$2,r,c as c$3}from'./chunk-PT25FZ62.mjs';export{B as AccessDeniedError,H as AttributeInUseError,e as AttributeNotFoundError,q as ChangeTypeNotSupportedError,z as ConcurrentModificationError,o as DestructiveSyncNotAllowedError,r as DuplicateError,w as ForbiddenError,F as MemoryNotFoundError,p as MigrationTimeoutError,c as NotFoundError,E as NotImplementedError,d as ObjectNotFoundError,I as ObjectReferencedError,n as OrphanSystemAttributeError,i as ProtectedResourceError,x as ProtectedRoleError,f as RecordNotFoundError,G as RecordReferencedError,C as RepositoryError,y as RoleNotFoundError,b as SchemaError,a as SchemaErrorCode,g as SchemaPlanNotFoundError,D as SearchBackendError,A as StorageError,m as SyncCascadeError,l as SyncConflictError,j as SyncError,k as SystemEntityImmutableError,h as ValidationError,K as isAttributeInUseError,t as isNotFoundError,L as isObjectReferencedError,v as isProtectedResourceError,J as isRecordReferencedError,s as isSchemaError,u as isValidationError}from'./chunk-PT25FZ62.mjs';export{a as TEXT_FORMAT_PATTERNS,c as createTextValidator,b as resolveTextPattern}from'./chunk-O34B5KOW.mjs';export{a as createNumberValidator}from'./chunk-KG2ADZG6.mjs';export{a as DEFAULT_VALIDATION_MESSAGES,b as formatZodErrors}from'./chunk-4OTKOCGB.mjs';import {a}from'./chunk-KSPJP74K.mjs';import {ICONS,SKILL_NAME_MAX_LENGTH,SKILL_DESCRIPTION_MAX_LENGTH,MEMORY_NAME_MAX_LENGTH,MEMORY_DESCRIPTION_MAX_LENGTH,getCountryDisplayNameByIso3}from'@stndrds/constants';import Jt,{z as z$1}from'zod';/*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
2
+ var ki=["fyi","task","question","handoff","system"],Oi=["low","normal","high","urgent"],_i=["public","internal","sensitive"],Pi=["unread","read","archived","snoozed"],Fi=["none","pending","processing","completed","dismissed","expired","failed"],hs="agent.session.waiting_human",As="agent.task.assigned",Ts="agent.question.requested",Hf=[hs,As,Ts];var Jf=["name","type"],Xf=["required","hidden","archived","deprecated","defaultValue","config","order","unique"],Zf=["label","description","placeholder","icon"];var Vi=["text","richtext","number","checkbox","date","phone","currency","status","location","select","multiselect","user","relation","formula","rollup","document"],$t="*";function ji(e){return e.targets.length===1&&e.targets[0].object===$t}a(ji,"isUniversalRelation");function rb(e){return e.bilateral!==void 0}a(rb,"isBilateralRelation");function nb(e){return "many"}a(nb,"inferInverseCardinality");function ib(e){return n$1(e)}a(ib,"isAttributeSortable");var sb=["record","object","attribute","view","user","role","settings","file","agent","schema_source"],ub=["record.created","record.updated","record.deleted","record.restored","record.purged","object.created","object.updated","object.deleted","attribute.created","attribute.updated","attribute.deleted","view.created","view.updated","view.deleted","schema_source.applied","schema_source.removed","user.created","user.invited","user.updated","user.deleted","user.login","user.logout","role.created","role.updated","role.deleted","role.assigned","role.revoked","settings.updated","file.uploaded","file.updated","file.deleted"];function cb(e){return e.phase==="terminal"}a(cb,"isTerminalState");function pb(e){switch(e.phase){case "running":return "active";case "queued":return "idle";case "parked":if(e.parkedOn===void 0)throw new b$1("parked state without parkedOn",a$2.INVARIANT_VIOLATION);return e.parkedOn==="agents"?"waiting_agents":"waiting_human";case "terminal":if(e.outcome===void 0)throw new b$1("terminal state without outcome",a$2.INVARIANT_VIOLATION);return e.outcome}}a(pb,"sessionStateToLegacyStatus");function mb(e){switch(e){case "active":return {phase:"running"};case "idle":return {phase:"queued"};case "waiting_human":return {phase:"parked",parkedOn:"human",humanRequestIds:[]};case "waiting_agents":return {phase:"parked",parkedOn:"agents"};default:return {phase:"terminal",outcome:e}}}a(mb,"legacyStatusToSessionState");var ws=["completed","failed","cancelled","timeout","expired"];function fb(e){return ws.includes(e)}a(fb,"isTerminalSessionStatus");var xs=["idle","completed","waiting_human","waiting_agents","cancelled","failed","timeout"];function bb(e){return xs.includes(e)}a(bb,"isClaimableSessionStatus");var Mi=Object.freeze({mutation:"ask",destructive:"ask",outward:"ask"}),gb=["active","completed","abandoned"],Li=["openai","anthropic","google","spacexai","deepseek","moonshotai","alibaba","mistral","minimax","meta","zai"],Bi=["standard","fast"],Ui=["none","minimal","low","medium","high","xhigh"];function yb(e){return e.label?.trim()||e.name}a(yb,"agentDisplayName");var $i=["approval-requested","approval-responded","approval-dispatched"],Is=["streaming","running",...$i];function hb(e){return Is.includes(e)}a(hb,"isOpenToolPartState");function Ab(e){return $i.includes(e)}a(Ab,"isToolApprovalState");var qt=["CREDITS_EXHAUSTED"];function Tb(e){return typeof e=="string"&&qt.includes(e)}a(Tb,"isSystemPartCode");function Ss(e,t){let r=e.createdAt.getTime()-t.createdAt.getTime();return r===0?e.id.localeCompare(t.id):r}a(Ss,"compareAgentSessionMessages");function wb(e){return [...e].sort(Ss)}a(wb,"orderAgentSessionMessages");var xb=["pending","in_progress","completed","blocked"],Ib=50,Sb=80,vb=500,Rb=2e3;var Nb="session-state",vs="__stndrdsNativeUiPartIds",Rs=1,Es="Native agent UI part IDs metadata is invalid";function se(){throw new h(Es,[])}a(se,"invalidNativePartIds");function qi(e){if(e===null||typeof e!="object"||Array.isArray(e))return false;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}a(qi,"isPlainRecord");function Ds(e,t){if(e.type==="text"||e.type==="reasoning")return `${e.type}:${t}`;if(e.type==="tool")return `tool:${e.toolCallId}`}a(Ds,"nativeAgentUIPartIdMetadataKey");function kb(e){let t=e.metadata?.[vs];qi(t)||se(),(Object.keys(t).length!==2||t.schemaVersion!==Rs||!qi(t.partIds))&&se();let r=new Map;for(let[s,l]of e.parts.entries()){let p=Ds(l,s);if(!p||r.has(p)){p&&se();continue}r.set(p,l);}let n=Object.entries(t.partIds);n.length!==r.size&&se();let o=new Map,a={};for(let[s,l]of n){let p=r.get(s);p&&typeof l=="string"&&l.length>0||se();let I=o.get(l);I&&(p.type==="tool"||I!==p.type)&&se(),p.type==="tool"&&l!==p.toolCallId&&se(),o.set(l,p.type),a[s]=l;}return a}a(kb,"parseNativeAgentUIPartIdsMetadata");var Pb=16e3,Fb=3200,Vb=6400,jb=16e3,Mb=65536,Lb=15e3,Bb=1e4,Ub=5e3,$b="google/gemini-3.5-transcribe-live",qb={maxDurationMs:3e5,dailyDurationMs:36e5,monthlyDurationMs:72e6,tenantMonthlyBudgetMicrousd:5e7,globalMonthlyBudgetMicrousd:5e7,estimatedMicrousdPerSecond:150,reservationMultiplier:2};var Gb=["web","presentation","document","spreadsheet","image","code","other"],Wb=["ephemeral","conversation","persistent"],Kb=["source","preview","entrypoint","asset"];var zi=5;function Qb(e){return e instanceof Error?e.message:typeof e=="string"?e:e&&typeof e=="object"?"message"in e&&typeof e.message=="string"?e.message:JSON.stringify(e):String(e)}a(Qb,"getErrorMessage");function eg(e){return typeof e=="object"&&e!==null&&"slots"in e&&"steps"in e&&"name"in e&&typeof e.name=="string"&&Array.isArray(e.slots)&&Array.isArray(e.steps)}a(eg,"isFormDefinition");var zt=["relation","multiRelation","formula","rollup","document","richtext","user"];function Gi(e){return e.type==="slot"}a(Gi,"isFormSlotFieldRef");function Gt(e){return e.type==="free"}a(Gt,"isFormFreeFieldRef");function ng(e){return e.fieldRequired!==void 0?e.fieldRequired:e.slotMode==="create"&&e.attributeRequired===true}a(ng,"resolveFieldRequired");function Wi(e){return e.additionalSlotIds?.length?[e.slotId,...e.additionalSlotIds]:[e.slotId]}a(Wi,"getSlotFieldTargets");function Cs(e){return Gi(e)?`${e.slotId}.${e.attribute}`:`free.${e.attribute.name}`}a(Cs,"formFieldKey");function Ns(e){return Gi(e)?e.attribute:e.attribute.name}a(Ns,"formFieldFlatKey");function ig(e,t){return e[Cs(t)]??e[Ns(t)]}a(ig,"readFormFieldValue");function We(e){return e.type==="fields"}a(We,"isFormFieldsRow");function sg(e){return e.type==="heading"}a(sg,"isFormHeadingRow");function ug(e){return e.type==="separator"}a(ug,"isFormSeparatorRow");function lg(e){return e.type==="text"}a(lg,"isFormTextRow");var Wt=class Wt{async autocomplete(){return await Promise.resolve([])}async reverse(){return await Promise.resolve(null)}async geocode(){return await Promise.resolve(null)}};a(Wt,"NoopGeocodingAdapter");var Ki=Wt;var Kt=["read","create","update","delete","manage"];function gg(e){return e.length===0?"none":e.length===1&&e[0]==="read"?"read-only":e.length===Kt.length&&Kt.every(t=>e.includes(t))?"full":"custom"}a(gg,"actionsToAccessLevel");function yg(e){switch(e){case "full":return [...Kt];case "read-only":return ["read"];case "none":return []}}a(yg,"accessLevelToActions");function Yi(e){let t=e.properties;if(!t)return [];if(Array.isArray(t))return t;let r=t;return Array.isArray(r.definitions)?r.definitions:[]}a(Yi,"resolvePropertyDefinitions");function Tg(e){return e.type==="select"||e.type==="status"||e.type==="multiselect"}a(Tg,"hasOptions");var ks="Notetaker",Ig={systemPrompt:null,meetingRecordingPolicy:"none",meetingBotDisplayName:ks};var vg=["active","suspended"],Rg=["plan","manual","auto"];function Dg(e){return `${e.object}:${e.name}:${e.type}`}a(Dg,"viewStateKey");function Ke(e){return e.type==="detail"}a(Ke,"isDetailView");function Hi(e){return e.type==="list"}a(Hi,"isListView");function Os(e){return e.type==="fields"}a(Os,"isFieldGroup");var _g=["square","landscape","portrait"];var Qi=["none","estimated","exact"];function _s(e){if(typeof e=="string"&&Qi.includes(e))return e;throw new h(`countMode must be one of: ${Qi.join(", ")} (received: ${String(e)})`,[])}a(_s,"parseCountMode");function Vg(e){return e===void 0?void 0:_s(e)}a(Vg,"parseOptionalCountMode");var jg=1e4;var Bg=["storage.bytes"];function Ps(e){return e==null?true:typeof e!="object"?false:Object.keys(e).length===0}a(Ps,"isEmptyObject");function Ji(e){return e!=null&&typeof e=="object"&&Object.keys(e).length>0}a(Ji,"isNotEmpty");function Fs(e){return Ji(e)?e:void 0}a(Fs,"toUndefinedIfEmpty");function Vs(e){if(e<=0)return {value:0,unitIndex:0};let t=1e3,r=Math.min(4,Math.floor(Math.log(e)/Math.log(t)));return {value:Number.parseFloat((e/t**r).toFixed(1)),unitIndex:r}}a(Vs,"computeByteMagnitude");var js=["B","KB","MB","GB","TB"];function _y(e){let{value:t,unitIndex:r}=Vs(e);return `${t} ${js[r]}`}a(_y,"formatByteSize");function Ms(e){return e.displayAttributes!==void 0?[...e.displayAttributes]:[...new Set([e.cardUserAttribute,e.cardDateAttribute].filter(t=>t!==void 0))]}a(Ms,"getListViewDisplayAttributeNames");var My={ATTACHMENTS:"attachments"};function Ly(e){return e.type==="document"}a(Ly,"isDocumentAttribute");function By(e,t){if(!t||t.length===0)return true;let r=e.name.toLowerCase();return t.some(n=>n.endsWith("/*")?e.mimeType.startsWith(n.slice(0,-1)):n.startsWith(".")?r.endsWith(n.toLowerCase()):e.mimeType===n)}a(By,"matchesAccepts");var Xi=Object.freeze(["text","number","checkbox","date","phone","currency","status","select","multiselect","location"]);function Ye(e){let t=[];for(let r of e){let n=r.build();if(!Xi.includes(n.type))throw new Error(`Property type "${n.type}" is not supported in .qualifyWith()`);t.push(n);}return {definitions:t}}a(Ye,"buildPropertySchema");var Gy="__";function Wy(e){let t=e.indexOf("__");return t<=0||t+2>=e.length?{kind:"scalar",attribute:e}:{kind:"qualified",root:e.slice(0,t),property:e.slice(t+2)}}a(Wy,"parseQualifiedAttribute");function Ky(e,t){return `${e}__${t}`}a(Ky,"buildQualifiedAttribute");function Z(e){return typeof e=="object"&&e!==null&&typeof e.start=="string"}a(Z,"isDateRangeValue");function Ls(e,t){return a$1(e)?null:Z(e)?t.endDate?{start:e.start,end:e.end??null}:e.start:typeof e=="string"?t.endDate?{start:e,end:null}:e:null}a(Ls,"normalizeDateValue");function fe(e){return typeof e=="string"&&e!==""?e:Z(e)&&e.start!==""?e.start:null}a(fe,"dateValueStart");var He="\u2014";function Bs(e){return String(e)}a(Bs,"formatText");function Us(e){return e?"Yes":"No"}a(Us,"formatCheckbox");function $s(e,t){if(typeof e!="number")return String(e);if(t.renderAs==="rating")return `${e}/${t.max??5}`;let r=t.decimals;return t.unit==="integer"?e.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:0}):t.unit==="percentage"?(e/100).toLocaleString(void 0,{style:"percent",minimumFractionDigits:r,maximumFractionDigits:r}):e.toLocaleString(void 0,{minimumFractionDigits:r,maximumFractionDigits:r})}a($s,"formatNumber");function qs(e,t){if(typeof e!="object"||e===null)return String(e);let r=e;return "value"in r&&"code"in r?`${r.value.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})} ${r.code}`:String(e)}a(qs,"formatCurrency");function Yt(e){if(Z(e)){let t=Yt(e.start);return e.end?`${t} \u2192 ${Yt(e.end)}`:t}if(e instanceof Date)return e.toISOString().split("T")[0];if(typeof e=="string"){let t=new Date(e);if(!Number.isNaN(t.getTime()))return t.toISOString().split("T")[0]}return String(e)}a(Yt,"formatDate");function zs(e){if(typeof e!="object"||e===null)return String(e);let t=e;return "phoneNumber"in t?t.phoneNumber?t.countryCode?c$1(t):t.phoneNumber:"":String(e)}a(zs,"formatPhone");function Gs(e,t="full"){if(typeof e!="object"||e===null)return "";let r=e,n=[];switch(t){case "country":r.country&&n.push(getCountryDisplayNameByIso3(r.country));break;case "state":r.state&&n.push(r.state),r.country&&n.push(getCountryDisplayNameByIso3(r.country));break;case "city":r.city&&n.push(r.city),r.state&&n.push(r.state),r.country&&n.push(getCountryDisplayNameByIso3(r.country));break;case "coordinates":r.latitude!==void 0&&r.longitude!==void 0&&n.push(`${r.latitude}, ${r.longitude}`);break;case "address":r.address&&n.push(r.address),r.city&&n.push(r.city),r.state&&n.push(r.state),r.country&&n.push(getCountryDisplayNameByIso3(r.country));break;default:r.address&&n.push(r.address),r.address2&&n.push(r.address2),r.city&&n.push(r.city),r.state&&n.push(r.state),r.postalCode&&n.push(r.postalCode),r.country&&n.push(getCountryDisplayNameByIso3(r.country));break}return n.join(", ")}a(Gs,"formatLocationValue");function Ws(e,t){return typeof e!="object"||e===null?String(e):Gs(e,t.granularity??"full")||He}a(Ws,"formatLocation");function Ks(e,t){return typeof e!="string"?String(e):t.options?.find(n=>n.value===e)?.label??String(e)}a(Ks,"formatSelect");function Ys(e,t){return Array.isArray(e)?t.options?e.map(n=>t.options.find(o=>o.value===n)?.label).filter(Boolean).join(", "):e.join(", "):String(e)}a(Ys,"formatMultiselect");function Zi(e,t){if(a$1(e))return He;switch(t.type){case "text":return Bs(e);case "checkbox":return Us(e);case "number":return $s(e,t);case "currency":return qs(e);case "date":return Yt(e);case "phone":return zs(e);case "location":return Ws(e,t);case "select":case "status":return Ks(e,t);case "multiselect":return Ys(e,t);case "user":case "relation":return Array.isArray(e)?e.join(", "):String(e);default:return Array.isArray(e)?e.join(", "):String(e)}}a(Zi,"formatAttributeValue");var Qs=["UPPER","LOWER","capitalize","trim"],Js=["prefix","suffix","wrap","default"],Qe=[...Qs,...Js],be=z$1.string().min(1,"labelExpression cannot be empty").refine(e=>Je(e),{message:"labelExpression must contain at least one {{ attribute }} interpolation"}).refine(e=>!/\{\{\s*\}\}/.test(e),{message:"labelExpression contains empty {{ }} interpolation"}).refine(e=>{let t=/(?<!\|)\|(?!\|)\s*(\w+)(?::[^|}]*)?/g,r;for(;(r=t.exec(e))!==null;){let n=r[1];if(!Qe.includes(n))return false}return true},{message:`Invalid pipe name. Valid pipes: ${Qe.join(", ")}`});function Xs(e){let t=be.safeParse(e);return t.success?{success:true,attributes:oo(e)}:{success:false,error:t.error.issues[0]?.message??"Invalid labelExpression"}}a(Xs,"validateLabelExpression");var eo={UPPER:a(e=>String(e).toUpperCase(),"UPPER"),LOWER:a(e=>String(e).toLowerCase(),"LOWER"),capitalize:a(e=>String(e).replace(/(^|\s)\S/g,t=>t.toUpperCase()),"capitalize"),trim:a(e=>String(e).trim(),"trim")},to={prefix:a((e,t="")=>e?`${t}${e}`:"","prefix"),suffix:a((e,t="")=>e?`${e}${t}`:"","suffix"),wrap:a((e,t="",r="")=>e?`${t}${e}${r}`:"","wrap"),default:a((e,t="")=>e||t,"default")};function Zs(e,t){let r=e;for(let n of t){let{name:o,args:a}=no(n),s=eo[o];if(s)r!==""&&(r=s(r));else {let l=to[o];l&&(r=l(r,...a));}}return r}a(Zs,"applyPipes");function eu(e,t){return t.split(".").reduce((r,n)=>{if(!(r==null||typeof r!="object"))return r[n]},e)}a(eu,"getValue");var ro="(Untitled)";function no(e){let t=e.match(/^(\w+)(?::(.*))?$/);if(!t)return {name:e,args:[]};let r=t[1],n=t[2];if(!n)return {name:r,args:[]};let o=[],a=/["']([^"']*?)["']/g,s;for(;(s=a.exec(n))!==null;)o.push(s[1]);return {name:r,args:o}}a(no,"parsePipeExpression");function Ht(e,t,r=ro){return e.replace(/\{\{\s*([^}]+)\s*\}\}/g,(o,a)=>{let s=a.split("||").map(j=>j.trim()),p=s[s.length-1].split("|").map(j=>j.trim());s[s.length-1]=p[0];let I=p.slice(1).filter(Boolean),X=s.filter(Boolean),B="";for(let j of X){let Y=io(eu(t,j));if(Y!==""){B=Y;break}}if(a$1(B)&&I.length===0)return "";for(let j of I){let{name:Y,args:es}=no(j),si=eo[Y];if(si)B!==""&&(B=si(B));else {let ui=to[Y];ui&&(B=ui(B,...es));}}return B}).trim()||r}a(Ht,"renderLabelExpression");function io(e){if(e==null||typeof e=="function")return "";if(typeof e!="object")return String(e);if(Array.isArray(e))return e.map(io).filter(Boolean).join(",");let t=e.toString;return typeof t=="function"&&t!==Object.prototype.toString?String(e):""}a(io,"toText");function Je(e){return /\{\{\s*\S+.*\}\}/.test(e)}a(Je,"isLabelExpression");function oo(e){let t=[],r=/\{\{\s*([^}]+)\s*\}\}/g,n;for(;(n=r.exec(e))!==null;){let a=n[1].trim().split("||").map(l=>l.trim()),s=a[a.length-1];a[a.length-1]=s.split("|")[0].trim();for(let l of a){if(!l)continue;let p=l.split(".")[0];p&&!t.includes(p)&&t.push(p);}}return t}a(oo,"extractAttributeNames");var tu=/^\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}$/;function ao(e){let t=e.trim().match(tu);return t?t[1]:null}a(ao,"getSingleAttributeFromExpression");function ru(e,t){let r=ao(e);if(r===null)return null;let n=t.find(o=>o.name===r);return !n||n.type!=="text"||j(n).authoring.readOnly?null:n}a(ru,"getEditableLabelAttribute");var nu=/\{\{\s*props\./;function iu(e,t,r){if(!nu.test(e))return e;let n={},o=new Map(r?.map(s=>[s.name,s]));if(t)for(let[s,l]of Object.entries(t)){if(l==null)continue;let p=o.get(s);if(p){let I=Zi(l,p);n[s]=I===He?"":I;}else n[s]=l;}return Ht(e,{props:n},"").replace(/\(\s*\)/g,"").replace(/\[\s*\]/g,"").replace(/\s*[-—|:]\s*$/g,"").replace(/\s{2,}/g," ").trim()}a(iu,"applyRelationProps");function ou(e){if(e?.type==="relation")return e.properties?.definitions}a(ou,"relationPropertyDefs");function au(e){if(e?.type==="relation"||e?.type==="document")return e.properties?.definitions}a(au,"qualifiedPropertyDefs");function so(e){if(a$1(e))return [];if(typeof e=="string")return [{id:e}];if(Array.isArray(e))return e.flatMap(t=>so(t));if(typeof e=="object"&&"id"in e){let t=e;if(typeof t.id=="string")return [{id:t.id,props:t.props}]}return []}a(so,"extractValueRefs");function su(e){let t=[e.firstName,e.lastName].map(r=>r?.trim()).filter(Boolean).join(" ");return t!==""?t:e.email?.split("@")[0]??""}a(su,"getUserDisplayName");var uu=/\p{L}|\p{N}/u;function lu(e,t){let r=e?.trim()??"";if(r==="")return t;let n=r.split(/\s+/),a=(n.length===1?r.split("@")[0].split(/[._-]/):n).map(s=>{let l=s.match(uu)?.[0];return l===void 0?"":[...l.toUpperCase()][0]??""}).filter(Boolean).slice(0,2).join("");return a===""?t:a}a(lu,"deriveInitials");var uo="__creatorRootActorId";function du(e){let t=e.metadata?.[uo];return typeof t=="string"&&t.length>0?t:e.createdBy}a(du,"getRecordCreatorPrincipalId");function ge(e,t){return e?.includes("*")===true||e?.includes(t)===true}a(ge,"includesAction");function cu(e){return {canRead:ge(e,"read"),canCreate:ge(e,"create"),canUpdate:ge(e,"update"),canDelete:ge(e,"delete"),canManage:ge(e,"manage")}}a(cu,"buildPermissionFlags");var wh=new Set(["id","name","label","type","required","system","unique","order"]);var M={PEOPLE:"people",WORKSPACE:"workspace",ARCHITECT:"architect",FEATURE_FLAGS:"feature-flags",FILES:"files",VIEWS:"views",FORMS:"forms",DOCUMENTS:"documents",AUDIT:"audit",API_KEYS:"api-keys",CONNECTORS:"connectors",ENV_VARS:"env-vars",SESSION:"session"},Ih=[M.PEOPLE,M.WORKSPACE,M.ARCHITECT,M.FEATURE_FLAGS,M.FILES,M.VIEWS,M.FORMS,M.DOCUMENTS,M.AUDIT,M.API_KEYS,M.CONNECTORS,M.ENV_VARS,M.SESSION],Sh={people:"People",workspace:"Workspace",architect:"Architect","feature-flags":"Feature flags",files:"Files",views:"Views",forms:"Forms",documents:"Documents",audit:"Audit","api-keys":"API keys",connectors:"Connected accounts","env-vars":"Environment variables",session:"Agent sessions"},pu={OWNER:"owner",MEMBER:"member",AGENT_DEFAULT:"agent_default",REFLEX_DEFAULT:"reflex_default"},vh={owner:"Owner",member:"Member",agent_default:"Agent Default",reflex_default:"Reflex Default"},Rh={owner:"Full access to all platform features and data",member:"Can view, create, edit and delete business data",agent_default:"Default role for AI agents \u2014 CRUD on records plus documents and files",reflex_default:"Default role for reflexes \u2014 no data access; each reflex is granted exactly what its rehearsal showed it uses"},Qt=["read","create","update","delete","manage"],mu=["read","create","delete"],Eh={owner:{system:[{target:"*",actions:Qt}],object:[{target:"*",actions:Qt}]},member:{system:[{target:"people",actions:["read"]},{target:"workspace",actions:["read"]},{target:"connectors",actions:mu},{target:"files",actions:["read","create","update"]}],object:[{target:"*",actions:Qt}]},agent_default:{system:[{target:"documents",actions:["read","create","update"]},{target:"files",actions:["read","create","update"]},{target:"env-vars",actions:["read"]},{target:"session",actions:["observe"]}],object:[{target:"*",actions:["read","create","update","delete"]}]},reflex_default:{system:[],object:[]}};function Dh(e){return Object.values(pu).includes(e)}a(Dh,"isDefaultRole");var bu=new Set(ICONS),co=/^[a-zA-Z_][a-zA-Z0-9_]*$/,gu=/^[a-z][a-z0-9-]*$/,ye=63,lo=128,Xe=Jt.string().min(1,"Object name cannot be empty").max(63,"Object name is too long (max 63 characters)").regex(/^[a-z][a-z0-9-]*$/,{message:`Invalid object name format.
3
3
  Name must be in kebab-case (slug format):
4
4
  \u2705 Valid: 'products', 'user-profiles', 'order-items'
5
5
  \u274C Invalid: 'Products', 'userProfiles', 'user_profiles'`});function De(e){try{Xe.parse(e);}catch(t){throw t instanceof Jt.ZodError?new b$1(t.issues[0].message,a$2.INVALID_OBJECT_NAME):t}}a(De,"validateObjectName");function Ze(e){if(!e||e.length===0)throw new h("View name cannot be empty",[{path:["name"],message:"View name cannot be empty"}]);if(e.length>ye)throw new h("View name is too long",[{path:["name"],message:`View name is too long (max ${ye} characters)`}]);if(!gu.test(e))throw new h("Invalid view name format",[{path:["name"],message:"View name must be in kebab-case (e.g., 'detail', 'list-view')"}])}a(Ze,"validateViewName");function ue(e,t,r){let n=new Set;for(let o of e){let a=t(o);if(n.has(a))throw r(a);n.add(a);}}a(ue,"assertUniqueBy");var po=Jt.string().min(1,"Attribute name cannot be empty").max(ye,`Attribute name is too long (max ${ye} characters)`).regex(co,{message:`Invalid attribute name format.
@@ -10,13 +10,13 @@ Name must be a valid variable identifier:
10
10
  \u2705 Valid: 'firstName', 'first_name', 'FirstName', 'FIRST_NAME'
11
11
  \u274C Invalid: 'first-name', 'first name', '123name', 'first.name'`);if(z$2.includes(e))throw new Error(`[AttributeBuilder] "${e}" is a reserved name and cannot be used as an attribute name.
12
12
  Reserved names: ${z$2.join(", ")}`)}a(Ce,"validateAttributeName");function mo(e){if(!e||e.length===0)throw new Error("[AttributeBuilder] Attribute label cannot be empty");if(e.length>lo)throw new Error(`[AttributeBuilder] Attribute label is too long (max ${lo} characters)`)}a(mo,"validateLabel");function fo(e,t){if(!bu.has(e))throw new Error(`[AttributeBuilder] Invalid icon "${e}" in ${t}.
13
- Icon must be one of the predefined icons from @stndrds/constants.`)}a(fo,"validateIconName");function le(e,t){let r=new Set;for(let n of t){if(!n.value?.trim())throw new Error(`[AttributeBuilder] Option in "${e}" has an empty or missing value.`);if(!n.label?.trim())throw new Error(`[AttributeBuilder] Option "${n.value}" in "${e}" has an empty or missing label.`);if(r.has(n.value))throw new Error(`[AttributeBuilder] Duplicate option value "${n.value}" in "${e}".`);r.add(n.value);}for(let n of t){if(n.inverse===void 0)continue;let o=t.find(a=>a.value===n.inverse);if(!o)throw new Error(`[AttributeBuilder] Option "${n.value}" in "${e}" has inverse "${n.inverse}" which does not match any option value.`);if(o.inverse!==n.value)throw new Error(`[AttributeBuilder] Inverse mismatch in "${e}": "${n.value}" points to "${n.inverse}", but "${n.inverse}" points to "${o.inverse??"(none)"}". Inverse pairs must be symmetric.`)}}a(le,"validateOptions");var bo={maxConcurrentRuns:3,retryPolicy:{maxRetries:3,backoffMs:1e3,backoffMultiplier:2},timeoutMs:3e5},Zt=class Zt{constructor(t){if(!t.name||t.name.trim().length===0)throw new h("Agent name is required",[]);this.bp={name:t.name,system:true,visibility:"workspace",triggers:[]};}description(t){return this.bp.description=t,this}label(t){return this.bp.label=t,this}icon(t){return this.bp.icon=t,this}systemPrompt(t){return this.bp.systemPrompt=t,this}model(t,r,n){return this.bp.model={provider:t,model:r,...n},this}tools(t){return this.bp.tools=[...t],this}schedule(t){return this.bp.schedule={...t,enabled:t.enabled??true},this}config(t){let r=this.bp.config??bo,n=t.inference===void 0?r.inference:{...r.inference,...t.inference};return this.bp.config={...r,...t,...n===void 0?{}:{inference:n}},this}delegation(t){return Object.assign(this.bp,t),this}mcpServers(t){return this.bp.mcpServers=Array.isArray(t)?[...t]:t,this}approval(t){return this.bp.approval={...Li,...this.bp.approval,...t},this}visibility(t){return this.bp.visibility=t,this}requiresPermission(t,r){return this.bp.requiredPermission={resource:t,action:r},this}trigger(t,r,n){return this.bp.triggers.push({name:t,eventType:r,...n,enabled:n?.enabled??true}),this}runtime(){return this.bp.system=false,this}build(){if(!this.bp.systemPrompt)throw new h(`Agent "${this.bp.name}": systemPrompt is required`,[]);if(!this.bp.model)throw new h(`Agent "${this.bp.name}": model is required`,[]);if(this.bp.system&&this.bp.visibility==="private")throw new h(`Agent "${this.bp.name}": system agents must use workspace visibility`,[]);return ue(this.bp.triggers,t=>t.name,t=>new h(`Agent "${this.bp.name}": duplicate trigger name "${t}"`,[])),{...this.bp,visibility:this.bp.visibility??"workspace",config:this.bp.config??bo,systemPrompt:this.bp.systemPrompt,model:this.bp.model}}};a(Zt,"AgentBuilder");var Xt=Zt;function Fh(e){return new Xt(e)}a(Fh,"agent");var yu="@stndrds/schema";function et(e){return {version:1,vendor:yu,validate:a(t=>{let r=e.safeParse(t);return r.success?{value:r.data}:{issues:r.error.issues.map(n=>({message:n.message,path:n.path}))}},"validate")}}a(et,"createStandardSchemaProps");function Lh(e){return typeof e=="object"&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"].version===1}a(Lh,"isStandardSchema");var yr=class yr{get"~standard"(){let t=c$2(this.build());return et(t)}constructor(t,r,n){Ce(r),mo(n),this.attr={name:r,label:n,type:t,required:false,system:true};}setRequired(t){this.attr.required=t;}asRequiredState(){return this}asPhantomState(){return this}runtime(){return this.attr.system=false,this}hidden(){return this.attr.hidden=true,this}placeholder(t){return this.attr.placeholder=t,this}description(t){return this.attr.description=t,this}icon(t){return fo(t,`attribute "${this.attr.name}"`),this.attr.icon=t,this}order(t){return this.attr.order=t,this}defaultValue(t){return ("defaultValue"in this.attr||!["formula","rollup"].includes(this.attr.type))&&(this.attr.defaultValue=t),this}metadata(t){return this.attr.metadata=t,this}build(){return this.attr}};a(yr,"BaseAttributeBuilder");var R=yr,hr=class hr extends R{constructor(t,r){super("text",t,r);}minLength(t){return this.attr.minLength=t,this}maxLength(t){return this.attr.maxLength=t,this}pattern(t){return this.attr.pattern=t,this.attr.format=void 0,this}multiline(t=true){return this.attr.multiline=t,this}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}email(){return this.attr.format="email",this.attr.pattern=void 0,this}url(){return this.attr.format="url",this.attr.pattern=void 0,this}slug(){return this.attr.format="slug",this.attr.pattern=void 0,this}};a(hr,"TextAttributeBuilder");var er=hr;function f(e){return new er(e.name,e.label)}a(f,"text");var Ar=class Ar extends R{constructor(t,r){super("richtext",t,r);}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(Ar,"RichtextAttributeBuilder");var tr=Ar;function he(e){return new tr(e.name,e.label)}a(he,"richtext");var Tr=class Tr extends R{constructor(t,r){super("number",t,r);}min(t){return this.attr.min=t,this}max(t){return this.attr.max=t,this}integer(){return this.attr.unit="integer",this.attr.decimals=0,this}decimal(t=2){return this.attr.unit="decimal",this.attr.decimals=t,this}percentage(){return this.attr.unit="percentage",this}renderAs(t){return this.attr.renderAs=t,this}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(Tr,"NumberAttributeBuilder");var rr=Tr;function rt(e){return new rr(e.name,e.label)}a(rt,"number");var wr=class wr extends R{constructor(t,r){super("checkbox",t,r);}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(wr,"CheckboxAttributeBuilder");var nr=wr;function go(e){return new nr(e.name,e.label)}a(go,"checkbox");var xr=class xr extends R{constructor(t,r){super("date",t,r);}format(t){return this.attr.dateFormat=t,this}minDate(t){return this.attr.minDate=t,this}maxDate(t){return this.attr.maxDate=t,this}endDate(){return this.attr.endDate=true,this.asPhantomState()}includeTime(){return this.attr.includeTime=true,this}timeFormat(t){return this.attr.timeFormat=t,this}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(xr,"DateAttributeBuilder");var ir=xr;function U(e){return new ir(e.name,e.label)}a(U,"date");var Ir=class Ir extends R{constructor(t,r){super("phone",t,r);}defaultCountry(t){return this.attr.defaultCountryCode=t,this}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(Ir,"PhoneAttributeBuilder");var or=Ir;function Kh(e){return new or(e.name,e.label)}a(Kh,"phone");var Sr=class Sr extends R{constructor(t,r){super("currency",t,r);}defaultCurrency(t){return this.attr.defaultCurrency=t,this}allowedCurrencies(t){return this.attr.allowedCurrencies=t,this}allowNegative(t=true){return this.attr.allowNegative=t,this}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(Sr,"CurrencyAttributeBuilder");var ar=Sr;function Yh(e){return new ar(e.name,e.label)}a(Yh,"currency");var vr=class vr extends R{constructor(t,r){super("status",t,r);}options(t){let r=t;return le(this.attr.name??"unknown",r),this.attr.options=r,this.asPhantomState()}option(t){this.attr.options||(this.attr.options=[]);let r=[...this.attr.options,t];return le(this.attr.name??"unknown",r),this.attr.options.push(t),this}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(vr,"StatusAttributeBuilder");var sr=vr;function Hh(e){return new sr(e.name,e.label)}a(Hh,"status");var Rr=class Rr extends R{constructor(t,r){super("select",t,r);}options(t){let r=t;return le(this.attr.name??"unknown",r),this.attr.options=r,this.asPhantomState()}option(t){this.attr.options||(this.attr.options=[]);let r=[...this.attr.options,t];return le(this.attr.name??"unknown",r),this.attr.options.push(t),this}renderAs(t){return this.attr.renderAs=t,this}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(Rr,"SelectAttributeBuilder");var ur=Rr;function q(e){return new ur(e.name,e.label)}a(q,"select");var Er=class Er extends R{constructor(t,r){super("multiselect",t,r);}options(t){let r=t;return le(this.attr.name??"unknown",r),this.attr.options=r,this.asPhantomState()}option(t){this.attr.options||(this.attr.options=[]);let r=[...this.attr.options,t];return le(this.attr.name??"unknown",r),this.attr.options.push(t),this}renderAs(t){return this.attr.renderAs=t,this}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(Er,"MultiselectAttributeBuilder");var lr=Er;function Qh(e){return new lr(e.name,e.label)}a(Qh,"multiselect");var Dr=class Dr extends R{constructor(t,r){super("location",t,r);}granularity(t){return this.attr.granularity=t,this}defaultCountry(t){return this.attr.defaultCountry=t,this}allowedCountries(t){return this.attr.allowedCountries=t,this}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(Dr,"LocationAttributeBuilder");var dr=Dr;function Jh(e){return new dr(e.name,e.label)}a(Jh,"location");var Cr=class Cr extends R{constructor(t,r){super("user",t,r),this.attr.types=["user","agent"];}types(t){let r=[...new Set(t)];if(r.length===0)throw new Error("[AttributeBuilder] user.types must contain at least one type.");return this.attr.types=r,this}multiple(){return this.attr.multiple=true,this}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(Cr,"UserAttributeBuilder");var cr=Cr;function Xh(e){return new cr(e.name,e.label)}a(Xh,"user");var Nr=class Nr extends R{to(t,r){let n={object:t,...r};return this.attr.targets?.push(n),this}toAny(){return this.attr.targets=[{object:$t}],this}qualifyWith(...t){let r=this.attr.targets;if(!r||r.length===0)throw new Error('.qualifyWith() must be called AFTER .to(). Example: relation({ name: "companies" }).to("companies").qualifyWith(...)');return this.attr.properties=Ye(t),this}bilateral(t){let r=this.attr.targets;if(!r||r.length===0)throw new Error('.bilateral() must be called AFTER .to(). Example: relation({ name: "company" }).to("companies").bilateral({ ... })');if(r.length>1)throw new Error("Bilateral relations are not supported for polymorphic relations (multiple .to() targets).");if(ji(this.attr))throw new Error("Bilateral relations are not supported for universal relations (.toAny()).");return this.attr.bilateral=t,this}};a(Nr,"BaseRelationAttributeBuilder");var tt=Nr,kr=class kr extends tt{constructor(t,r){super("relation",t,r),this.attr.cardinality="one",this.attr.targets=[];}many(){let t=new mr(this.attr.name,this.attr.label??"",{targets:this.attr.targets,isRequired:this.attr.required});return this.attr.system===false&&t.runtime(),this.attr.hidden&&t.hidden(),this.attr.placeholder&&t.placeholder(this.attr.placeholder),this.attr.description&&t.description(this.attr.description),this.attr.icon&&t.icon(this.attr.icon),this.attr.order!==void 0&&t.order(this.attr.order),this.attr.metadata&&t.metadata(this.attr.metadata),t}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(kr,"SingleRelationAttributeBuilder");var pr=kr,Or=class Or extends tt{constructor(t,r,n){super("relation",t,r),this.attr.cardinality="many",this.attr.targets=n?.targets??[],this.attr.defaultValue=[],n?.isRequired&&this.setRequired(true);}maxItems(t){return this.attr.maxItems=t,this}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(Or,"MultiRelationAttributeBuilder");var mr=Or;function Ae(e){return new pr(e.name,e.label)}a(Ae,"relation");var _r=class _r extends R{constructor(t,r){super("formula",t,r),this.attr.required=false;}expression(t){return this.attr.expression=t,this}returns(t){return this.attr.returnType=t,this}decimals(t){return this.attr.decimals=t,this}required(){throw new Error("Formula attributes cannot be required: they are computed read-only values. Remove .required() from this attribute definition.")}optional(){return this}};a(_r,"FormulaAttributeBuilder");var fr=_r;function Zh(e){return new fr(e.name,e.label)}a(Zh,"formula");var Pr=class Pr extends R{constructor(t,r){super("rollup",t,r),this.attr.required=false;}from(t){return this.attr.relationAttribute=t,this}aggregate(t){return this.attr.targetAttribute=t,this}using(t){return this.attr.function=t,this}decimals(t){return this.attr.decimals=t,this}path(t){return this.attr.relationPath=t,this}targetType(t){return this.attr.targetAttributeType=t,this}targetOptions(t){return this.attr.targetAttributeOptions=t,this}targetCurrency(t){return this.attr.targetCurrencyCode=t,this}build(){let t=this.attr.function,r=this.attr.targetAttributeType;if(t==="original"&&r!==void 0&&r!=="select"&&r!=="status"&&r!=="multiselect"){let n=this.attr.relationAttribute??"relation",o=this.attr.targetAttribute??"field";throw new b$1(`Rollup "${this.attr.name}": .using("original") only supports a "select", "status", or "multiselect" target, but .targetType("${r}") was given. To surface a plain ${r} value from a related record, use a formula instead \u2014 e.g. formula({ name: "${this.attr.name}", label: "\u2026" }).expression("${n}.${o}").`,a$2.VALIDATION_FAILED)}return super.build()}required(){throw new Error("Rollup attributes cannot be required: they are computed read-only values. Remove .required() from this attribute definition.")}optional(){return this}};a(Pr,"RollupAttributeBuilder");var br=Pr;function eA(e){return new br(e.name,e.label)}a(eA,"rollup");var Fr=class Fr extends R{constructor(t,r){super("document",t,r);}accepts(t){return this.attr.accepts=t,this}maxFileSize(t){return this.attr.maxFileSize=t,this}qualifyWith(...t){return this.attr.properties=Ye(t),this}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(Fr,"DocumentAttributeBuilder");var gr=Fr;function yo(e){return new gr(e.name,e.label)}a(yo,"document");function Ao(e,t,r){let n=Array.isArray(e)?e:[e],[o,...a]=n;return {type:"slot",slotId:o,additionalSlotIds:a.length>0?a:void 0,attribute:t,label:r?.label,required:r?.required,tooltip:r?.tooltip}}a(Ao,"buildSlotFieldRef");var Mr=class Mr{constructor(t,r,n){this._finalized=false;this.stepBuilder=t,this.rowData={id:r,order:n,type:"fields",fields:[]};}field(t,r,n){return this.rowData.fields.push(Ao(t,r,n)),this}freeField(t,r){let o={type:"free",attribute:t.build(),label:r?.label,required:r?.required,prefillExpression:r?.prefillExpression};return this.rowData.fields.push(o),this}row(t){return this._finalized=true,this.stepBuilder._finalizeRow(this.rowData).row(t)}heading(t,r){return this._finalized=true,this.stepBuilder._finalizeRow(this.rowData).heading(t,r)}separator(){return this._finalized=true,this.stepBuilder._finalizeRow(this.rowData).separator()}text(t){return this._finalized=true,this.stepBuilder._finalizeRow(this.rowData).text(t)}endRow(){return this._finalized?this.stepBuilder:(this._finalized=true,this.stepBuilder._finalizeRow(this.rowData))}};a(Mr,"FormRowBuilder");var Vr=Mr,Br=class Br{constructor(t,r,n){this.rowOrder=0;this.formBuilder=t,this.stepData={id:r,label:n,rows:[]};}description(t){return this.stepData.description=t,this}field(t,r,n){this.rowOrder++;let o=`row-${this.stepData.id}-${this.rowOrder}`,a=Ao(t,r,n),s={id:o,order:this.rowOrder,type:"fields",fields:[a]};return this.stepData.rows.push(s),this}freeField(t,r){this.rowOrder++;let n=`row-${this.stepData.id}-${this.rowOrder}`,a={type:"free",attribute:t.build(),label:r?.label,required:r?.required,prefillExpression:r?.prefillExpression},s={id:n,order:this.rowOrder,type:"fields",fields:[a]};return this.stepData.rows.push(s),this}row(t){return this.rowOrder++,new Vr(this,t,this.rowOrder)}heading(t,r){this.rowOrder++;let n={id:`heading-${this.stepData.id}-${this.rowOrder}`,order:this.rowOrder,type:"heading",content:t,level:r};return this.stepData.rows.push(n),this}separator(){this.rowOrder++;let t={id:`sep-${this.stepData.id}-${this.rowOrder}`,order:this.rowOrder,type:"separator"};return this.stepData.rows.push(t),this}text(t){this.rowOrder++;let r={id:`text-${this.stepData.id}-${this.rowOrder}`,order:this.rowOrder,type:"text",content:t};return this.stepData.rows.push(r),this}step(t,r){return this.formBuilder._finalizeStep(this.stepData).step(t,r)}build(){return this.formBuilder._finalizeStep(this.stepData).build()}_finalizeRow(t){return t.fields.length>0&&this.stepData.rows.push(t),this}_getData(){return this.stepData}};a(Br,"FormStepBuilder");var jr=Br,Ur=class Ur{constructor(t,r){this.data={slots:[],steps:[],status:"draft",version:1};this.validateName(t),this.data.name=t,this.data.label=r;}description(t){return this.data.description=t,this}icon(t){return this.data.icon=t,this}status(t){return this.data.status=t,this}metadata(t){return this.data.metadata=t,this}slot(t,r,n){if(this.data.slots.some(a=>a.id===t))throw new Error(`[FormBuilder] Duplicate slot id: "${t}"`);let o={id:t,objectName:r,label:n.label,mode:n.mode??"create",color:n.color,icon:n.icon};return this.data.slots.push(o),this}step(t,r){if(this.data.steps.some(n=>n.id===t))throw new Error(`[FormBuilder] Duplicate step id: "${t}"`);return new jr(this,t,r)}build(){return this.validateRequiredData(),this.validateSlotReferences(),this.validateFreeFields(),this.validatePrefillExpressions(),this.data}_finalizeStep(t){return this.data.steps.push(t),this}validateName(t){let r=z$1.string().min(1,"Form name cannot be empty").max(63,"Form name is too long (max 63 characters)").regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,{message:"Invalid form name format. Name must be in kebab-case: 'client-onboarding', 'contact-creation'"});try{r.parse(t);}catch(n){throw n instanceof z$1.ZodError?new Error(`[FormBuilder] ${n.issues[0].message}`):n}}validateRequiredData(){if(this.data.slots.length===0)throw new Error("[FormBuilder] At least one slot is required. Use .slot() to add slots.");if(this.data.steps.length===0)throw new Error("[FormBuilder] At least one step is required. Use .step() to add steps.")}validateSlotReferences(){let t=new Map(this.data.slots.map(r=>[r.id,r.objectName]));for(let r of this.data.steps)for(let n of r.rows)if(We(n))for(let o of n.fields){if(o.type!=="slot")continue;let a=Wi(o);for(let l of a)if(!t.has(l))throw new Error(`[FormBuilder] Step "${r.id}" references unknown slot "${l}". Declare it with .slot("${l}", ...) first.`);let s=new Set(a.map(l=>t.get(l)));if(s.size>1)throw new Error(`[FormBuilder] Step "${r.id}" field on attribute "${o.attribute}" targets slots of different objects (${[...s].join(", ")}). A multi-slot field must target slots of the same object.`)}}validatePrefillExpressions(){let t=[...Qe,"join"];for(let r of this.data.steps)for(let n of r.rows)if(We(n))for(let o of n.fields){if(!Gt(o)||!o.prefillExpression)continue;let a=o.prefillExpression,s=`prefillExpression on free field "${o.attribute.name}" in step "${r.id}"`;if(!Je(a))throw new Error(`[FormBuilder] ${s} must contain at least one {{ attribute }} interpolation.`);if(/\{\{\s*\}\}/.test(a))throw new Error(`[FormBuilder] ${s} contains empty {{ }} interpolation.`);for(let l of a.matchAll(/(?<!\|)\|(?!\|)\s*(\w+)(?::[^|}]*)?/g)){let p=l[1];if(!t.includes(p))throw new Error(`[FormBuilder] ${s} uses invalid pipe "${p}". Valid pipes: ${t.join(", ")}`)}}}validateFreeFields(){let t=new Set(zt);for(let r of this.data.steps)for(let n of r.rows)if(We(n)){for(let o of n.fields)if(Gt(o)){let a=o.attribute.type;if(t.has(a))throw new Error(`[FormBuilder] Free field in step "${r.id}" uses forbidden attribute type "${a}". Forbidden types: ${zt.join(", ")}`)}}}};a(Ur,"FormBuilder");var Lr=Ur;function sA(e,t){return new Lr(e,t)}a(sA,"form");function hu(e){return {text:"toString",richtext:"toString",number:"toNumber",currency:"toNumber",date:"toDate",checkbox:"toBoolean"}[e]}a(hu,"resolveBuiltInTransform");var $r=class $r{constructor(t){this.operations=[];this.touchedAttributes=new Set;this.version=t;}assertNotTouched(t,r){if(this.touchedAttributes.has(t))throw new Error(`[MigrationBuilder] Conflicting operations on attribute "${t}": it was already modified earlier in this migration (attempted: ${r}).`)}renameAttribute(t,r){return this.assertNotTouched(t,"rename_attribute"),this.touchedAttributes.add(t),this.operations.push({type:"rename_attribute",from:t,to:r}),this}changeType(t,r,n,o){this.assertNotTouched(t,"change_type"),this.touchedAttributes.add(t);let a=o?.transform?hu(n):void 0;return this.operations.push({type:"change_type",name:t,from:r,to:n,transform:a}),this}removeAttribute(t){return this.assertNotTouched(t,"remove_attribute"),this.touchedAttributes.add(t),this.operations.push({type:"remove_attribute",name:t,backup_config:{}}),this}addAttribute(t){return this.assertNotTouched(t.name,"add_attribute"),this.touchedAttributes.add(t.name),this.operations.push({type:"add_attribute",attribute:t}),this}updateConfig(t,r){return this.assertNotTouched(t,"update_config"),this.touchedAttributes.add(t),this.operations.push({type:"update_config",name:t,from:{},to:r}),this}build(){return {version:this.version,operations:[...this.operations]}}};a($r,"MigrationBuilder");var nt=$r;var zr=class zr{constructor(t){this._migrations=[];this._sealed=false;this._toleratedAttributes=[];this.validateName(t.name),this.obj={name:t.name,label:t.label,attributes:[],system:true},t.id&&(this.obj.id=t.id);}get"~standard"(){let t=e(this.build());return et(t)}description(t){return this.obj.description=t,this}pluralLabel(t){return this._pluralLabel=t,this}icon(t){return this.obj.icon=t,this}runtime(){return this.obj.system=false,this}sealed(){return this._sealed=true,this}tolerate(t){return this._toleratedAttributes=[...this._toleratedAttributes,...t],this}attribute(t){return this.pushAttributes([t]),this}attributes(t){return this.pushAttributes(t),this}pushAttributes(t){let r$1=t.map(n=>"build"in n&&typeof n.build=="function"?n.build():n);ue([...this.obj.attributes,...r$1],n=>n.name,n=>new r("attribute",n,`Object "${this.obj.name}": duplicate attribute name "${n}"`)),this.obj.attributes.push(...r$1);}metadata(t){return this.obj.metadata={...this.obj.metadata,...t},this}order(t){return this.obj.metadata={...this.obj.metadata,order:t},this}hidden(){return this.obj.metadata={...this.obj.metadata,hidden:true},this}labelExpression(t){return this._labelExpression=t,this}embeddingExpression(t){return this._embeddingExpression=t,this}documentLayout(t){if(t.presets)for(let r of t.presets)To(r.id,r.structure,1);return this.obj.documentLayout=t,this}migration(t,r){if(t<2)throw new Error(`[ObjectBuilder] Migration version must be >= 2 (version 1 is implicit). Got: ${t}`);if(this._migrations.some(a=>a.version===t))throw new Error(`[ObjectBuilder] Duplicate migration version: ${t}`);let o=new nt(t);return r(o),this._migrations.push(o.build()),this}build(){if(!this.obj.name)throw new Error("[ObjectBuilder] Missing required field: name");if(!this.obj.label)throw new Error("[ObjectBuilder] Missing required field: label");if(!this._labelExpression)throw new b$1(`Object "${this.obj.name}" must have a labelExpression. The labelExpression defines how records are displayed in lists and relations (e.g. "{{ name }}").`,a$2.VALIDATION_FAILED);let t=be.safeParse(this._labelExpression);if(!t.success){let o=t.error.issues[0]?.message??"Invalid labelExpression";throw new b$1(`Invalid labelExpression for "${this.obj.name}": ${o}`,a$2.VALIDATION_FAILED)}if(this._embeddingExpression!==void 0){let o=be.safeParse(this._embeddingExpression);if(!o.success){let a=o.error.issues[0]?.message??"Invalid embeddingExpression";throw new b$1(`Invalid embeddingExpression for "${this.obj.name}": ${a}`,a$2.VALIDATION_FAILED)}}let r=[...this._migrations].sort((o,a)=>o.version-a.version);for(let o=0;o<r.length;o++){let a=o+2;if(r[o].version!==a)throw new Error(`[ObjectBuilder] Migration versions must be sequential starting at 2. Expected version ${a}, got ${r[o].version}.`)}let n=r.length>0?r[r.length-1].version:1;return {...this.obj,pluralLabel:this._pluralLabel,labelExpression:this._labelExpression,embeddingExpression:this._embeddingExpression,schema_version:n,migrations:r,sealed:this._sealed,toleratedAttributes:this._toleratedAttributes}}validateName(t){t!==void 0&&De(t);}};a(zr,"ObjectBuilder");var qr=zr;function z(e){return new qr(e)}a(z,"object");function To(e,t,r){let n=a((a,s)=>{throw new h(a,[{path:["documentLayout","presets",e],message:s}])},"fail");r>5&&n(`Preset structure exceeds max depth of ${5}`,"Preset structure too deep");let o=new Set;for(let a of t){let s=a.title.trim();s.length===0&&n("Folder preset node title is required","Empty folder title"),s.includes("/")&&n("Folder preset node title cannot contain /",`Folder title contains /: "${s}"`),o.has(s)&&n("Folder preset sibling titles must be unique",`Duplicate folder title: "${s}"`),o.add(s),a.children&&a.children.length>0&&To(e,a.children,r+1);}}a(To,"validatePresetStructure");var en=class en{constructor(t,r){this.data={type:"fields",fields:[]};this.data.id=t,this.data.label=r;}description(t){return this.data.description=t,this}collapsible(t=false){return this.data.collapsible=true,this.data.collapsed=t,this}order(t){return this.data.order=t,this}fields(...t){for(let r of t)this.data.fields?.push({attribute:r});return this}field(t,r){return this.data.fields?.push({attribute:t,...r}),this}attributeGroup(t,r){return this.data.fields?.push({attributeGroup:t,...r}),this}build(){if(!this.data.id)throw new Error("[GroupBuilder] id is required");if(!this.data.label)throw new Error("[GroupBuilder] label is required");if(!this.data.fields||this.data.fields.length===0)throw new Error("[GroupBuilder] At least one field is required");return this.data}};a(en,"GroupBuilder");var ot=en,tn=class tn{constructor(t,r){this.view=t,this.tabData=r;}columns(...t){return this.tabData.columns=t,this}create(t){return this.tabData.allowCreate=true,t?.mode&&(this.tabData.createMode=t.mode),this}createMode(t){return this.tabData.createMode=t,this}edit(){return this.tabData.allowEdit=true,this}delete(){return this.tabData.allowDelete=true,this}crud(){return this.tabData.allowCreate=true,this.tabData.allowEdit=true,this.tabData.allowDelete=true,this}filters(t){return this.tabData.filters=t,this}sorts(t){return this.tabData.sorts=t,this}sort(t,r="asc"){return this.tabData.sorts||(this.tabData.sorts=[]),this.tabData.sorts.push({attribute:t,direction:r}),this}tab(t,r){return this.finalize(),new Q(this.view,t,r)}done(){return this.finalize(),this.view}build(){return this.finalize(),this.view.build()}finalize(){if(!this.tabData.columns||this.tabData.columns.length===0)throw new Error(`[TableTabConfig] columns() is required for tab "${this.tabData.name}"`);this.view._addTab(this.tabData);}};a(tn,"TableTabConfig");var at=tn,rn=class rn{constructor(t,r,n){this.view=t,this.tabData={...r,type:"custom",component:n};}props(t){return this.tabData.props=t,this}tab(t,r){return this.view._addTab(this.tabData),new Q(this.view,t,r)}done(){return this.view._addTab(this.tabData),this.view}build(){return this.view._addTab(this.tabData),this.view.build()}};a(rn,"CustomTabConfig");var Gr=rn,nn=class nn{constructor(t,r,n){this.view=t,this.tabData={...r,type:"richtext",attribute:n};}titleAttribute(t){return this.tabData.titleAttribute=t,this}tab(t,r){return this.view._addTab(this.tabData),new Q(this.view,t,r)}done(){return this.view._addTab(this.tabData),this.view}build(){return this.view._addTab(this.tabData),this.view.build()}};a(nn,"RichtextTabConfig");var Wr=nn,on=class on{constructor(t,r){this.view=t,this.tabData={...r,type:"activity"};}limit(t){return this.tabData.limit=t,this}tab(t,r){return this.view._addTab(this.tabData),new Q(this.view,t,r)}done(){return this.view._addTab(this.tabData),this.view}build(){return this.view._addTab(this.tabData),this.view.build()}};a(on,"ActivityTabConfig");var Kr=on,an=class an{constructor(t,r,n){this.view=t,this.tabData={...r,type:n,emailAttributeIds:[]};}emailAttributes(...t){return this.tabData.emailAttributeIds=t,this}tab(t,r){return this.view._addTab(this.tabData),new Q(this.view,t,r)}done(){return this.view._addTab(this.tabData),this.view}build(){return this.view._addTab(this.tabData),this.view.build()}};a(an,"AddressMatchedTabConfig");var st=an,sn=class sn extends st{constructor(t,r){super(t,r,"emails");}};a(sn,"EmailsTabConfig");var Yr=sn,un=class un extends st{constructor(t,r){super(t,r,"meetings");}};a(un,"MeetingsTabConfig");var Hr=un,ln=class ln{constructor(t,r){this.view=t,this.tabData={...r,type:"documents",allowUpload:true,allowRemove:true,hideAttachments:false};}disableUpload(){return this.tabData.allowUpload=false,this}disableRemove(){return this.tabData.allowRemove=false,this}hideAttachments(){return this.tabData.hideAttachments=true,this}tab(t,r){return this.view._addTab(this.tabData),new Q(this.view,t,r)}done(){return this.view._addTab(this.tabData),this.view}build(){return this.view._addTab(this.tabData),this.view.build()}};a(ln,"DocumentsTabConfig");var Qr=ln,dn=class dn{constructor(t,r,n){this.view=t,this.base={id:r,name:r,label:n};}icon(t){return this.base.icon=t,this}order(t){return this.base.order=t,this}form(...t){if(t.length===0)throw new Error(`[TabBuilder] form() requires at least one group for tab "${this.base.name}"`);let r={...this.base,type:"form",groups:t.map(n=>n instanceof ot?n.build():n)};return this.view._addTab(r)}table(t){return new at(this.view,{...this.base,type:"table",source:{type:"relation",attribute:t},columns:[]})}tableFrom(t,r){return new at(this.view,{...this.base,type:"table",source:{type:"inverse",object:t,attribute:r},columns:[]})}custom(t){return new Gr(this.view,this.base,t)}richtext(t){return new Wr(this.view,this.base,t)}activity(){return new Kr(this.view,this.base)}documents(){return new Qr(this.view,this.base)}emails(){return new Yr(this.view,this.base)}meetings(){return new Hr(this.view,this.base)}forms(t){let r={...this.base,type:"forms",...t};return this.view._addTab(r)}};a(dn,"TabBuilder");var Q=dn,cn=class cn{constructor(t,r){Ze(t),this.data={name:t,label:r,tabs:[]};}description(t){return this.data.description=t,this}icon(t){return this.data.icon=t,this}for(t){return this.data.object=t,this}default(){return this.data.default=true,this}metadata(t){return this.data.metadata=t,this}sidePanel(t){return this.data.sidePanel=t,this}tab(t,r){return new Q(this,t,r)}addTab(t){return this.data.tabs.push(t),this}_addTab(t){return this.data.tabs.push(t),this}build(){if(!this.data.object)throw new Error("[DetailViewBuilder] for() is required - specify the target object");if(this.data.tabs.length===0)throw new Error("[DetailViewBuilder] At least one tab is required");ue(this.data.tabs,r=>r.name,r=>new Error(`[DetailViewBuilder] Duplicate tab name "${r}"`));let t={tabs:this.data.tabs,sidePanel:this.data.sidePanel};return {name:this.data.name,label:this.data.label,description:this.data.description,icon:this.data.icon,object:this.data.object,type:"detail",config:t,default:this.data.default,metadata:this.data.metadata}}};a(cn,"DetailViewBuilder");var Jr=cn;function ee(e,t){return new Jr(e,t)}a(ee,"detailView");function it(e){if(Array.isArray(e))return e.map(it).find(r=>r!==void 0);if(e===null||typeof e!="object")return;let t=e;return t.attribute==="visibility"||t.attribute==="ownedBy"?t.attribute:it(t.rules)??it(t.groups)}a(it,"findProtectedTabFilterAttribute");var pn=class pn{constructor(t,r){Ze(t),this.data={name:t,label:r,tabs:[]};}description(t){return this.data.description=t,this}icon(t){return this.data.icon=t,this}for(t){return this.data.object=t,this}default(){return this.data.default=true,this}metadata(t){return this.data.metadata=t,this}baseFilter(t){return this.data.defaultFilters=t,this}allowPresentationCustomization(){return this.data.allowPresentationCustomization=true,this}tab(t,r){return new Zr(this,t,r)}_addTab(t){return this.data.tabs.push(t),this}build(){if(!this.data.object)throw new Error("[ListViewBuilder] for() is required - specify the target object");if(this.data.tabs.length===0)throw new Error("[ListViewBuilder] At least one tab is required");if(ue(this.data.tabs,n=>n.id,n=>new Error(`[ListViewBuilder] Duplicate tab id "${n}"`)),this.data.tabs.filter(n=>n.default).length>1)throw new Error("[ListViewBuilder] Only one tab can be marked as default");for(let n of this.data.tabs){if(n.layout==="table"&&n.columns.length===0)throw new h(`[ListViewBuilder] Tab "${n.id}" must have at least one column`,[]);if(n.layout==="kanban"&&!n.groupByAttribute)throw new h(`[ListViewBuilder] Kanban tab "${n.id}" requires a groupByAttribute`,[]);if(n.descriptionAttribute!==void 0&&n.descriptionAttribute.length===0)throw new h(`[ListViewBuilder] Tab "${n.id}" requires a nonempty description attribute name`,[]);if(n.displayAttributes!==void 0){let o=Y.safeParse(n.displayAttributes);if(!o.success)throw new h(`[ListViewBuilder] Tab "${n.id}" has invalid display attributes`,o.error.issues.map(a=>({path:["tabs",n.id,"displayAttributes",...a.path.map(String)],message:a.message})))}}let r={allowPresentationCustomization:this.data.allowPresentationCustomization,defaultFilters:this.data.defaultFilters?{id:d(),combinator:this.data.defaultFilters.combinator,rules:this.data.defaultFilters.rules}:void 0,tabs:this.data.tabs.map(n=>{let o={id:n.id,label:n.label,icon:n.icon,default:n.default,visibility:n.visibility,columns:n.columns,descriptionAttribute:n.descriptionAttribute,displayAttributes:n.displayAttributes,filters:n.filters?{id:d(),combinator:n.filters.combinator,rules:n.filters.rules}:void 0,sorts:n.sorts,createMode:n.createMode};return n.layout==="kanban"?{...o,layout:"kanban",groupByAttribute:n.groupByAttribute,cardUserAttribute:n.cardUserAttribute,cardDateAttribute:n.cardDateAttribute,kanbanColumnOrder:n.kanbanColumnOrder,kanbanColumnVisibility:n.kanbanColumnVisibility,kanbanPinnedColumns:n.kanbanPinnedColumns}:{...o,layout:n.layout,columnSizing:n.columnSizing}})};return {name:this.data.name,label:this.data.label,description:this.data.description,icon:this.data.icon,object:this.data.object,type:"list",config:r,default:this.data.default,metadata:this.data.metadata}}};a(pn,"ListViewBuilder");var Xr=pn,ut=class ut{constructor(t,r,n){this.view=t,this.tabData={id:r,label:n,visibility:"all",layout:"table",columns:[]};}icon(t){return this.tabData.icon=t,this}default(){return this.tabData.default=true,this}visibility(t){return this.tabData.visibility=t,this}table(){return this.tabData.layout="table",this}list(){return this.tabData.layout="list",this}descriptionAttribute(t){return this.tabData.descriptionAttribute=t,this}displayAttributes(...t){return this.tabData.displayAttributes=t,this}kanban(t){return this.tabData.layout="kanban",this.tabData.groupByAttribute=t,this}cardUserAttribute(t){return this.tabData.cardUserAttribute=t,this}cardDateAttribute(t){return this.tabData.cardDateAttribute=t,this}kanbanColumnOrder(t){return this.tabData.kanbanColumnOrder=t,this}kanbanColumnVisibility(t){return this.tabData.kanbanColumnVisibility=t,this}kanbanPinnedColumns(t){return this.tabData.kanbanPinnedColumns=t,this}createMode(t){return this.tabData.createMode=t,this}columns(...t){return this.tabData.columns=t,this}columnWidth(t,r){return this.tabData.columnSizing||(this.tabData.columnSizing={}),this.tabData.columnSizing[t]=r,this}filter(t){let r=it(t);if(r){let n=`Tab filters cannot target "${r}". Use .visibility("private")`;throw new h(n,[{path:["filters"],message:n}])}return this.tabData.filters=t,this}sort(t,r="asc"){return this.tabData.sorts||(this.tabData.sorts=[]),this.tabData.sorts.push({attribute:t,direction:r}),this}sorts(t){return this.tabData.sorts=t,this}tab(t,r){return this.view._addTab(this.tabData),new ut(this.view,t,r)}done(){return this.view._addTab(this.tabData),this.view}build(){return this.view._addTab(this.tabData),this.view.build()}};a(ut,"ListViewTabConfigBuilder");var Zr=ut;function G(e,t){return new Xr(e,t)}a(G,"listView");function SA(e,t){return new ot(e,t)}a(SA,"group");function Au(e){if(!/^[a-z][a-z0-9-]*[a-z0-9]$|^[a-z]$/.test(e))throw new Error(`Invalid flag name "${e}". Flag names must be kebab-case (e.g., "architect-mode", "ai-features").`)}a(Au,"validateFlagName");var yn=class yn{constructor(t,r,n){Au(t),this.flag={name:t,valueType:r,defaultValue:n,allowedLevels:["global","tenant","user"]};}label(t){return this.flag.label=t,this}description(t){return this.flag.description=t,this}category(t){return this.flag.category=t,this}system(){return this.flag.system=true,this}tenantScoped(){return this.flag.allowedLevels=["global","tenant"],this}globalOnly(){return this.flag.allowedLevels=["global"],this}allowedLevels(t){return this.flag.allowedLevels=[...t],this}build(){if(!this.flag.label?.trim())throw new Error(`Flag "${this.flag.name}" must have a label. Use .label("Human-readable label").`);return {...this.flag,allowedLevels:[...this.flag.allowedLevels||[]]}}};a(yn,"BaseFlagBuilder");var Te=yn,hn=class hn extends Te{constructor(t){super(t,"boolean",false);}defaultValue(t){return this.flag.defaultValue=t,this}enabledByDefault(){return this.flag.defaultValue=true,this}};a(hn,"BooleanFlagBuilder");var mn=hn,An=class An extends Te{constructor(t){super(t,"string","");}defaultValue(t){return this.flag.defaultValue=t,this}};a(An,"StringFlagBuilder");var fn=An,Tn=class Tn extends Te{constructor(t){super(t,"number",0);}defaultValue(t){return this.flag.defaultValue=t,this}};a(Tn,"NumberFlagBuilder");var bn=Tn,wn=class wn extends Te{constructor(t,r){super(t,"json",r);}defaultValue(t){return this.flag.defaultValue=t,this}};a(wn,"JsonFlagBuilder");var gn=wn;function Tu(e){return new mn(e)}a(Tu,"booleanFlag");function wu(e){return new fn(e)}a(wu,"stringFlag");function xu(e){return new bn(e)}a(xu,"numberFlag");function Iu(e,t){return new gn(e,t)}a(Iu,"jsonFlag");function xn(e){return new r("feature flag",e,`Flag "${e}" is already registered. Each flag name must be unique.`)}a(xn,"duplicateFlagError");function In(e){return {...e,allowedLevels:[...e.allowedLevels]}}a(In,"cloneFlagDefinition");var Sn=class Sn{constructor(){this.flags=new Map;}register(t){if(this.flags.has(t.name))throw xn(t.name);this.flags.set(t.name,In(t));}registerAll(t){let r=new Set;for(let n of t){if(this.flags.has(n.name)||r.has(n.name))throw xn(n.name);r.add(n.name);}for(let n of t)this.register(n);}get(t){let r=this.flags.get(t);return r?In(r):void 0}getOrThrow(t){let r=this.get(t);if(!r)throw new c$3("Feature flag",t,void 0,`Flag "${t}" is not registered. Available flags: ${this.listNames().join(", ")}`);return r}has(t){return this.flags.has(t)}list(){return Array.from(this.flags.values(),In)}listNames(){return Array.from(this.flags.keys())}unregister(t){return this.flags.delete(t)}clear(){this.flags.clear();}get size(){return this.flags.size}};a(Sn,"FlagRegistry");var Ne=Sn,Su=new Ne;function vu(){return new Ne}a(vu,"createFlagRegistry");function lt(){return {global:new Map,tenant:new Map,user:new Map}}a(lt,"emptyOverrides");function Ru(e,t){return e.expiresAt===void 0||e.expiresAt.getTime()>t}a(Ru,"isActiveOverride");function vn(e,t){let r=new Map;for(let n of e){if(!Ru(n,t))continue;let o=n.flagName;r.has(o)||r.set(o,n);}return r}a(vn,"indexOverrides");var Rn=class Rn{constructor(t){this.repository=t.repository,this.registry=t.registry,this.staticDefaults=new Map(t.staticDefaults?.map(r=>[r.name,r.value])??[]);}async resolveAll(t={}){let r=this.collectFlagNames(),n=this.repository&&r.size>0?await this.getAllOverrides(t,[...r]):lt();return this.resolveNames(r,n,t)}resolveAllStatic(){return this.resolveNames(this.collectFlagNames(),lt(),{})}collectFlagNames(){let t=new Set;for(let r of this.registry.listNames())t.add(r);for(let r of this.staticDefaults.keys())t.add(r);return t}resolveNames(t,r,n){let o=new Map;for(let a of t)o.set(a,this.resolveValue(a,r,n));return o}async resolve(t,r={}){let n=this.repository?await this.getAllOverrides(r,[t]):lt();return this.resolveWithSource(t,n,r)}async isEnabled(t,r={}){return (await this.resolve(t,r)).value===true}async getValue(t,r={}){return (await this.resolve(t,r)).value}async setOverride(t,r,n,o={}){if(!this.repository)throw new b$1("Cannot set override: no FeatureFlagsRepository configured. Add featureFlags to your DatabaseAdapter to enable runtime overrides.",a$2.CONFIGURATION_REQUIRED);let a=this.registry.get(t);if(a&&!a.allowedLevels.includes(r)){let s=`Flag "${t}" does not allow ${r}-level overrides. Allowed levels: ${a.allowedLevels.join(", ")}`;throw new h(s,[{path:["level"],message:s}])}if(a?.system){let s=`Flag "${t}" is a system flag and cannot be overridden via API.`;throw new h(s,[{path:["flagName"],message:s}])}await this.repository.setOverride({flagName:t,level:r,value:n,targetId:o.targetId,expiresAt:o.expiresAt,createdBy:o.createdBy});}async deleteOverride(t,r,n){if(!this.repository)throw new b$1("Cannot delete override: no FeatureFlagsRepository configured.",a$2.CONFIGURATION_REQUIRED);await this.repository.deleteOverride(t,r,n);}async getAllOverrides(t,r){if(!this.repository)return lt();let[n,o,a]=await Promise.all([this.repository.getOverrides({level:"global",flagNames:r}),t.tenantId?this.repository.getOverrides({level:"tenant",targetId:t.tenantId,flagNames:r}):Promise.resolve([]),t.userId?this.repository.getOverrides({level:"user",targetId:t.userId,flagNames:r}):Promise.resolve([])]),s=Date.now();return {global:vn(n,s),tenant:vn(o,s),user:vn(a,s)}}resolveValue(t,r,n){return this.resolveWithSource(t,r,n).value}resolveWithSource(t,r,n){let o=this.registry.get(t),a=o?.allowedLevels??["global","tenant","user"];if(n.userId&&a.includes("user")){let s=r.user.get(t);if(s)return {name:t,value:s.value,source:"user",sourceId:n.userId}}if(n.tenantId&&a.includes("tenant")){let s=r.tenant.get(t);if(s)return {name:t,value:s.value,source:"tenant",sourceId:n.tenantId}}if(a.includes("global")){let s=r.global.get(t);if(s)return {name:t,value:s.value,source:"global"}}return this.staticDefaults.has(t)?{name:t,value:this.staticDefaults.get(t),source:"default"}:{name:t,value:o?.defaultValue??void 0,source:"default"}}};a(Rn,"FlagService");var dt=Rn;function Eu(e){return new dt(e)}a(Eu,"createFlagService");function En(e){return structuredClone(e)}a(En,"cloneObjectDefinition");var Cn=class Cn{constructor(){this.objects=new Map;}register(t){let r=Array.isArray(t)?t:[t];for(let n of r){let o="build"in n&&typeof n.build=="function"?n.build():n;this.validateAndRegister(o);}return this}validateAndRegister(t){if(!t.system){let r=`[NativeObjectRegistry] Cannot register object "${t.name}" (id: ${t.id}): missing system flag.
13
+ Icon must be one of the predefined icons from @stndrds/constants.`)}a(fo,"validateIconName");function le(e,t){let r=new Set;for(let n of t){if(!n.value?.trim())throw new Error(`[AttributeBuilder] Option in "${e}" has an empty or missing value.`);if(!n.label?.trim())throw new Error(`[AttributeBuilder] Option "${n.value}" in "${e}" has an empty or missing label.`);if(r.has(n.value))throw new Error(`[AttributeBuilder] Duplicate option value "${n.value}" in "${e}".`);r.add(n.value);}for(let n of t){if(n.inverse===void 0)continue;let o=t.find(a=>a.value===n.inverse);if(!o)throw new Error(`[AttributeBuilder] Option "${n.value}" in "${e}" has inverse "${n.inverse}" which does not match any option value.`);if(o.inverse!==n.value)throw new Error(`[AttributeBuilder] Inverse mismatch in "${e}": "${n.value}" points to "${n.inverse}", but "${n.inverse}" points to "${o.inverse??"(none)"}". Inverse pairs must be symmetric.`)}}a(le,"validateOptions");var bo={maxConcurrentRuns:3,retryPolicy:{maxRetries:3,backoffMs:1e3,backoffMultiplier:2},timeoutMs:3e5},Zt=class Zt{constructor(t){if(!t.name||t.name.trim().length===0)throw new h("Agent name is required",[]);this.bp={name:t.name,system:true,visibility:"workspace",triggers:[]};}description(t){return this.bp.description=t,this}label(t){return this.bp.label=t,this}icon(t){return this.bp.icon=t,this}systemPrompt(t){return this.bp.systemPrompt=t,this}model(t,r,n){return this.bp.model={provider:t,model:r,...n},this}tools(t){return this.bp.tools=[...t],this}schedule(t){return this.bp.schedule={...t,enabled:t.enabled??true},this}config(t){let r=this.bp.config??bo,n=t.inference===void 0?r.inference:{...r.inference,...t.inference};return this.bp.config={...r,...t,...n===void 0?{}:{inference:n}},this}delegation(t){return Object.assign(this.bp,t),this}mcpServers(t){return this.bp.mcpServers=Array.isArray(t)?[...t]:t,this}approval(t){return this.bp.approval={...Mi,...this.bp.approval,...t},this}visibility(t){return this.bp.visibility=t,this}requiresPermission(t,r){return this.bp.requiredPermission={resource:t,action:r},this}trigger(t,r,n){return this.bp.triggers.push({name:t,eventType:r,...n,enabled:n?.enabled??true}),this}runtime(){return this.bp.system=false,this}build(){if(!this.bp.systemPrompt)throw new h(`Agent "${this.bp.name}": systemPrompt is required`,[]);if(!this.bp.model)throw new h(`Agent "${this.bp.name}": model is required`,[]);if(this.bp.system&&this.bp.visibility==="private")throw new h(`Agent "${this.bp.name}": system agents must use workspace visibility`,[]);return ue(this.bp.triggers,t=>t.name,t=>new h(`Agent "${this.bp.name}": duplicate trigger name "${t}"`,[])),{...this.bp,visibility:this.bp.visibility??"workspace",config:this.bp.config??bo,systemPrompt:this.bp.systemPrompt,model:this.bp.model}}};a(Zt,"AgentBuilder");var Xt=Zt;function Bh(e){return new Xt(e)}a(Bh,"agent");var yu="@stndrds/schema";function et(e){return {version:1,vendor:yu,validate:a(t=>{let r=e.safeParse(t);return r.success?{value:r.data}:{issues:r.error.issues.map(n=>({message:n.message,path:n.path}))}},"validate")}}a(et,"createStandardSchemaProps");function qh(e){return typeof e=="object"&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"].version===1}a(qh,"isStandardSchema");var yr=class yr{get"~standard"(){let t=c$2(this.build());return et(t)}constructor(t,r,n){Ce(r),mo(n),this.attr={name:r,label:n,type:t,required:false,system:true};}setRequired(t){this.attr.required=t;}asRequiredState(){return this}asPhantomState(){return this}runtime(){return this.attr.system=false,this}hidden(){return this.attr.hidden=true,this}placeholder(t){return this.attr.placeholder=t,this}description(t){return this.attr.description=t,this}icon(t){return fo(t,`attribute "${this.attr.name}"`),this.attr.icon=t,this}order(t){return this.attr.order=t,this}defaultValue(t){return ("defaultValue"in this.attr||!["formula","rollup"].includes(this.attr.type))&&(this.attr.defaultValue=t),this}metadata(t){return this.attr.metadata=t,this}build(){return this.attr}};a(yr,"BaseAttributeBuilder");var R=yr,hr=class hr extends R{constructor(t,r){super("text",t,r);}minLength(t){return this.attr.minLength=t,this}maxLength(t){return this.attr.maxLength=t,this}pattern(t){return this.attr.pattern=t,this.attr.format=void 0,this}multiline(t=true){return this.attr.multiline=t,this}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}email(){return this.attr.format="email",this.attr.pattern=void 0,this}url(){return this.attr.format="url",this.attr.pattern=void 0,this}slug(){return this.attr.format="slug",this.attr.pattern=void 0,this}};a(hr,"TextAttributeBuilder");var er=hr;function f(e){return new er(e.name,e.label)}a(f,"text");var Ar=class Ar extends R{constructor(t,r){super("richtext",t,r);}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(Ar,"RichtextAttributeBuilder");var tr=Ar;function he(e){return new tr(e.name,e.label)}a(he,"richtext");var Tr=class Tr extends R{constructor(t,r){super("number",t,r);}min(t){return this.attr.min=t,this}max(t){return this.attr.max=t,this}integer(){return this.attr.unit="integer",this.attr.decimals=0,this}decimal(t=2){return this.attr.unit="decimal",this.attr.decimals=t,this}percentage(){return this.attr.unit="percentage",this}renderAs(t){return this.attr.renderAs=t,this}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(Tr,"NumberAttributeBuilder");var rr=Tr;function rt(e){return new rr(e.name,e.label)}a(rt,"number");var wr=class wr extends R{constructor(t,r){super("checkbox",t,r);}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(wr,"CheckboxAttributeBuilder");var nr=wr;function go(e){return new nr(e.name,e.label)}a(go,"checkbox");var xr=class xr extends R{constructor(t,r){super("date",t,r);}format(t){return this.attr.dateFormat=t,this}minDate(t){return this.attr.minDate=t,this}maxDate(t){return this.attr.maxDate=t,this}endDate(){return this.attr.endDate=true,this.asPhantomState()}includeTime(){return this.attr.includeTime=true,this}timeFormat(t){return this.attr.timeFormat=t,this}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(xr,"DateAttributeBuilder");var ir=xr;function U(e){return new ir(e.name,e.label)}a(U,"date");var Ir=class Ir extends R{constructor(t,r){super("phone",t,r);}defaultCountry(t){return this.attr.defaultCountryCode=t,this}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(Ir,"PhoneAttributeBuilder");var or=Ir;function Xh(e){return new or(e.name,e.label)}a(Xh,"phone");var Sr=class Sr extends R{constructor(t,r){super("currency",t,r);}defaultCurrency(t){return this.attr.defaultCurrency=t,this}allowedCurrencies(t){return this.attr.allowedCurrencies=t,this}allowNegative(t=true){return this.attr.allowNegative=t,this}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(Sr,"CurrencyAttributeBuilder");var ar=Sr;function Zh(e){return new ar(e.name,e.label)}a(Zh,"currency");var vr=class vr extends R{constructor(t,r){super("status",t,r);}options(t){let r=t;return le(this.attr.name??"unknown",r),this.attr.options=r,this.asPhantomState()}option(t){this.attr.options||(this.attr.options=[]);let r=[...this.attr.options,t];return le(this.attr.name??"unknown",r),this.attr.options.push(t),this}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(vr,"StatusAttributeBuilder");var sr=vr;function eA(e){return new sr(e.name,e.label)}a(eA,"status");var Rr=class Rr extends R{constructor(t,r){super("select",t,r);}options(t){let r=t;return le(this.attr.name??"unknown",r),this.attr.options=r,this.asPhantomState()}option(t){this.attr.options||(this.attr.options=[]);let r=[...this.attr.options,t];return le(this.attr.name??"unknown",r),this.attr.options.push(t),this}renderAs(t){return this.attr.renderAs=t,this}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(Rr,"SelectAttributeBuilder");var ur=Rr;function q(e){return new ur(e.name,e.label)}a(q,"select");var Er=class Er extends R{constructor(t,r){super("multiselect",t,r);}options(t){let r=t;return le(this.attr.name??"unknown",r),this.attr.options=r,this.asPhantomState()}option(t){this.attr.options||(this.attr.options=[]);let r=[...this.attr.options,t];return le(this.attr.name??"unknown",r),this.attr.options.push(t),this}renderAs(t){return this.attr.renderAs=t,this}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(Er,"MultiselectAttributeBuilder");var lr=Er;function tA(e){return new lr(e.name,e.label)}a(tA,"multiselect");var Dr=class Dr extends R{constructor(t,r){super("location",t,r);}granularity(t){return this.attr.granularity=t,this}defaultCountry(t){return this.attr.defaultCountry=t,this}allowedCountries(t){return this.attr.allowedCountries=t,this}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(Dr,"LocationAttributeBuilder");var dr=Dr;function rA(e){return new dr(e.name,e.label)}a(rA,"location");var Cr=class Cr extends R{constructor(t,r){super("user",t,r),this.attr.types=["user","agent"];}types(t){let r=[...new Set(t)];if(r.length===0)throw new Error("[AttributeBuilder] user.types must contain at least one type.");return this.attr.types=r,this}multiple(){return this.attr.multiple=true,this}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(Cr,"UserAttributeBuilder");var cr=Cr;function nA(e){return new cr(e.name,e.label)}a(nA,"user");var Nr=class Nr extends R{to(t,r){let n={object:t,...r};return this.attr.targets?.push(n),this}toAny(){return this.attr.targets=[{object:$t}],this}qualifyWith(...t){let r=this.attr.targets;if(!r||r.length===0)throw new Error('.qualifyWith() must be called AFTER .to(). Example: relation({ name: "companies" }).to("companies").qualifyWith(...)');return this.attr.properties=Ye(t),this}bilateral(t){let r=this.attr.targets;if(!r||r.length===0)throw new Error('.bilateral() must be called AFTER .to(). Example: relation({ name: "company" }).to("companies").bilateral({ ... })');if(r.length>1)throw new Error("Bilateral relations are not supported for polymorphic relations (multiple .to() targets).");if(ji(this.attr))throw new Error("Bilateral relations are not supported for universal relations (.toAny()).");return this.attr.bilateral=t,this}};a(Nr,"BaseRelationAttributeBuilder");var tt=Nr,kr=class kr extends tt{constructor(t,r){super("relation",t,r),this.attr.cardinality="one",this.attr.targets=[];}many(){let t=new mr(this.attr.name,this.attr.label??"",{targets:this.attr.targets,isRequired:this.attr.required});return this.attr.system===false&&t.runtime(),this.attr.hidden&&t.hidden(),this.attr.placeholder&&t.placeholder(this.attr.placeholder),this.attr.description&&t.description(this.attr.description),this.attr.icon&&t.icon(this.attr.icon),this.attr.order!==void 0&&t.order(this.attr.order),this.attr.metadata&&t.metadata(this.attr.metadata),t}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(kr,"SingleRelationAttributeBuilder");var pr=kr,Or=class Or extends tt{constructor(t,r,n){super("relation",t,r),this.attr.cardinality="many",this.attr.targets=n?.targets??[],this.attr.defaultValue=[],n?.isRequired&&this.setRequired(true);}maxItems(t){return this.attr.maxItems=t,this}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(Or,"MultiRelationAttributeBuilder");var mr=Or;function Ae(e){return new pr(e.name,e.label)}a(Ae,"relation");var _r=class _r extends R{constructor(t,r){super("formula",t,r),this.attr.required=false;}expression(t){return this.attr.expression=t,this}returns(t){return this.attr.returnType=t,this}decimals(t){return this.attr.decimals=t,this}required(){throw new Error("Formula attributes cannot be required: they are computed read-only values. Remove .required() from this attribute definition.")}optional(){return this}};a(_r,"FormulaAttributeBuilder");var fr=_r;function iA(e){return new fr(e.name,e.label)}a(iA,"formula");var Pr=class Pr extends R{constructor(t,r){super("rollup",t,r),this.attr.required=false;}from(t){return this.attr.relationAttribute=t,this}aggregate(t){return this.attr.targetAttribute=t,this}using(t){return this.attr.function=t,this}decimals(t){return this.attr.decimals=t,this}path(t){return this.attr.relationPath=t,this}targetType(t){return this.attr.targetAttributeType=t,this}targetOptions(t){return this.attr.targetAttributeOptions=t,this}targetCurrency(t){return this.attr.targetCurrencyCode=t,this}build(){let t=this.attr.function,r=this.attr.targetAttributeType;if(t==="original"&&r!==void 0&&r!=="select"&&r!=="status"&&r!=="multiselect"){let n=this.attr.relationAttribute??"relation",o=this.attr.targetAttribute??"field";throw new b$1(`Rollup "${this.attr.name}": .using("original") only supports a "select", "status", or "multiselect" target, but .targetType("${r}") was given. To surface a plain ${r} value from a related record, use a formula instead \u2014 e.g. formula({ name: "${this.attr.name}", label: "\u2026" }).expression("${n}.${o}").`,a$2.VALIDATION_FAILED)}return super.build()}required(){throw new Error("Rollup attributes cannot be required: they are computed read-only values. Remove .required() from this attribute definition.")}optional(){return this}};a(Pr,"RollupAttributeBuilder");var br=Pr;function oA(e){return new br(e.name,e.label)}a(oA,"rollup");var Fr=class Fr extends R{constructor(t,r){super("document",t,r);}accepts(t){return this.attr.accepts=t,this}maxFileSize(t){return this.attr.maxFileSize=t,this}qualifyWith(...t){return this.attr.properties=Ye(t),this}required(){return this.setRequired(true),this.asRequiredState()}optional(){return this.setRequired(false),this.asRequiredState()}};a(Fr,"DocumentAttributeBuilder");var gr=Fr;function yo(e){return new gr(e.name,e.label)}a(yo,"document");function Ao(e,t,r){let n=Array.isArray(e)?e:[e],[o,...a]=n;return {type:"slot",slotId:o,additionalSlotIds:a.length>0?a:void 0,attribute:t,label:r?.label,required:r?.required,tooltip:r?.tooltip}}a(Ao,"buildSlotFieldRef");var Lr=class Lr{constructor(t,r,n){this._finalized=false;this.stepBuilder=t,this.rowData={id:r,order:n,type:"fields",fields:[]};}field(t,r,n){return this.rowData.fields.push(Ao(t,r,n)),this}freeField(t,r){let o={type:"free",attribute:t.build(),label:r?.label,required:r?.required,prefillExpression:r?.prefillExpression};return this.rowData.fields.push(o),this}row(t){return this._finalized=true,this.stepBuilder._finalizeRow(this.rowData).row(t)}heading(t,r){return this._finalized=true,this.stepBuilder._finalizeRow(this.rowData).heading(t,r)}separator(){return this._finalized=true,this.stepBuilder._finalizeRow(this.rowData).separator()}text(t){return this._finalized=true,this.stepBuilder._finalizeRow(this.rowData).text(t)}endRow(){return this._finalized?this.stepBuilder:(this._finalized=true,this.stepBuilder._finalizeRow(this.rowData))}};a(Lr,"FormRowBuilder");var Vr=Lr,Br=class Br{constructor(t,r,n){this.rowOrder=0;this.formBuilder=t,this.stepData={id:r,label:n,rows:[]};}description(t){return this.stepData.description=t,this}field(t,r,n){this.rowOrder++;let o=`row-${this.stepData.id}-${this.rowOrder}`,a=Ao(t,r,n),s={id:o,order:this.rowOrder,type:"fields",fields:[a]};return this.stepData.rows.push(s),this}freeField(t,r){this.rowOrder++;let n=`row-${this.stepData.id}-${this.rowOrder}`,a={type:"free",attribute:t.build(),label:r?.label,required:r?.required,prefillExpression:r?.prefillExpression},s={id:n,order:this.rowOrder,type:"fields",fields:[a]};return this.stepData.rows.push(s),this}row(t){return this.rowOrder++,new Vr(this,t,this.rowOrder)}heading(t,r){this.rowOrder++;let n={id:`heading-${this.stepData.id}-${this.rowOrder}`,order:this.rowOrder,type:"heading",content:t,level:r};return this.stepData.rows.push(n),this}separator(){this.rowOrder++;let t={id:`sep-${this.stepData.id}-${this.rowOrder}`,order:this.rowOrder,type:"separator"};return this.stepData.rows.push(t),this}text(t){this.rowOrder++;let r={id:`text-${this.stepData.id}-${this.rowOrder}`,order:this.rowOrder,type:"text",content:t};return this.stepData.rows.push(r),this}step(t,r){return this.formBuilder._finalizeStep(this.stepData).step(t,r)}build(){return this.formBuilder._finalizeStep(this.stepData).build()}_finalizeRow(t){return t.fields.length>0&&this.stepData.rows.push(t),this}_getData(){return this.stepData}};a(Br,"FormStepBuilder");var jr=Br,Ur=class Ur{constructor(t,r){this.data={slots:[],steps:[],status:"draft",version:1};this.validateName(t),this.data.name=t,this.data.label=r;}description(t){return this.data.description=t,this}icon(t){return this.data.icon=t,this}status(t){return this.data.status=t,this}metadata(t){return this.data.metadata=t,this}slot(t,r,n){if(this.data.slots.some(a=>a.id===t))throw new Error(`[FormBuilder] Duplicate slot id: "${t}"`);let o={id:t,objectName:r,label:n.label,mode:n.mode??"create",color:n.color,icon:n.icon};return this.data.slots.push(o),this}step(t,r){if(this.data.steps.some(n=>n.id===t))throw new Error(`[FormBuilder] Duplicate step id: "${t}"`);return new jr(this,t,r)}build(){return this.validateRequiredData(),this.validateSlotReferences(),this.validateFreeFields(),this.validatePrefillExpressions(),this.data}_finalizeStep(t){return this.data.steps.push(t),this}validateName(t){let r=z$1.string().min(1,"Form name cannot be empty").max(63,"Form name is too long (max 63 characters)").regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,{message:"Invalid form name format. Name must be in kebab-case: 'client-onboarding', 'contact-creation'"});try{r.parse(t);}catch(n){throw n instanceof z$1.ZodError?new Error(`[FormBuilder] ${n.issues[0].message}`):n}}validateRequiredData(){if(this.data.slots.length===0)throw new Error("[FormBuilder] At least one slot is required. Use .slot() to add slots.");if(this.data.steps.length===0)throw new Error("[FormBuilder] At least one step is required. Use .step() to add steps.")}validateSlotReferences(){let t=new Map(this.data.slots.map(r=>[r.id,r.objectName]));for(let r of this.data.steps)for(let n of r.rows)if(We(n))for(let o of n.fields){if(o.type!=="slot")continue;let a=Wi(o);for(let l of a)if(!t.has(l))throw new Error(`[FormBuilder] Step "${r.id}" references unknown slot "${l}". Declare it with .slot("${l}", ...) first.`);let s=new Set(a.map(l=>t.get(l)));if(s.size>1)throw new Error(`[FormBuilder] Step "${r.id}" field on attribute "${o.attribute}" targets slots of different objects (${[...s].join(", ")}). A multi-slot field must target slots of the same object.`)}}validatePrefillExpressions(){let t=[...Qe,"join"];for(let r of this.data.steps)for(let n of r.rows)if(We(n))for(let o of n.fields){if(!Gt(o)||!o.prefillExpression)continue;let a=o.prefillExpression,s=`prefillExpression on free field "${o.attribute.name}" in step "${r.id}"`;if(!Je(a))throw new Error(`[FormBuilder] ${s} must contain at least one {{ attribute }} interpolation.`);if(/\{\{\s*\}\}/.test(a))throw new Error(`[FormBuilder] ${s} contains empty {{ }} interpolation.`);for(let l of a.matchAll(/(?<!\|)\|(?!\|)\s*(\w+)(?::[^|}]*)?/g)){let p=l[1];if(!t.includes(p))throw new Error(`[FormBuilder] ${s} uses invalid pipe "${p}". Valid pipes: ${t.join(", ")}`)}}}validateFreeFields(){let t=new Set(zt);for(let r of this.data.steps)for(let n of r.rows)if(We(n)){for(let o of n.fields)if(Gt(o)){let a=o.attribute.type;if(t.has(a))throw new Error(`[FormBuilder] Free field in step "${r.id}" uses forbidden attribute type "${a}". Forbidden types: ${zt.join(", ")}`)}}}};a(Ur,"FormBuilder");var Mr=Ur;function pA(e,t){return new Mr(e,t)}a(pA,"form");function hu(e){return {text:"toString",richtext:"toString",number:"toNumber",currency:"toNumber",date:"toDate",checkbox:"toBoolean"}[e]}a(hu,"resolveBuiltInTransform");var $r=class $r{constructor(t){this.operations=[];this.touchedAttributes=new Set;this.version=t;}assertNotTouched(t,r){if(this.touchedAttributes.has(t))throw new Error(`[MigrationBuilder] Conflicting operations on attribute "${t}": it was already modified earlier in this migration (attempted: ${r}).`)}renameAttribute(t,r){return this.assertNotTouched(t,"rename_attribute"),this.touchedAttributes.add(t),this.operations.push({type:"rename_attribute",from:t,to:r}),this}changeType(t,r,n,o){this.assertNotTouched(t,"change_type"),this.touchedAttributes.add(t);let a=o?.transform?hu(n):void 0;return this.operations.push({type:"change_type",name:t,from:r,to:n,transform:a}),this}removeAttribute(t){return this.assertNotTouched(t,"remove_attribute"),this.touchedAttributes.add(t),this.operations.push({type:"remove_attribute",name:t,backup_config:{}}),this}addAttribute(t){return this.assertNotTouched(t.name,"add_attribute"),this.touchedAttributes.add(t.name),this.operations.push({type:"add_attribute",attribute:t}),this}updateConfig(t,r){return this.assertNotTouched(t,"update_config"),this.touchedAttributes.add(t),this.operations.push({type:"update_config",name:t,from:{},to:r}),this}build(){return {version:this.version,operations:[...this.operations]}}};a($r,"MigrationBuilder");var nt=$r;function Au(e){let{name:t,labelExpression:r,embeddingExpression:n}=e;if(!r)throw new b$1(`Object "${t}" must have a labelExpression. The labelExpression defines how records are displayed in lists and relations (e.g. "{{ name }}").`,a$2.VALIDATION_FAILED);let o=be.safeParse(r);if(!o.success){let a=o.error.issues[0]?.message??"Invalid labelExpression";throw new b$1(`Invalid labelExpression for "${t}": ${a}`,a$2.VALIDATION_FAILED)}if(n!==void 0){let a=be.safeParse(n);if(!a.success){let s=a.error.issues[0]?.message??"Invalid embeddingExpression";throw new b$1(`Invalid embeddingExpression for "${t}": ${s}`,a$2.VALIDATION_FAILED)}}}a(Au,"validateObjectExpressions");var zr=class zr{constructor(t){this._migrations=[];this._sealed=false;this._toleratedAttributes=[];this.validateName(t.name),this.obj={name:t.name,label:t.label,attributes:[],system:true},t.id&&(this.obj.id=t.id);}get"~standard"(){let t=e(this.build());return et(t)}description(t){return this.obj.description=t,this}pluralLabel(t){return this._pluralLabel=t,this}icon(t){return this.obj.icon=t,this}runtime(){return this.obj.system=false,this}sealed(){return this._sealed=true,this}tolerate(t){return this._toleratedAttributes=[...this._toleratedAttributes,...t],this}attribute(t){return this.pushAttributes([t]),this}attributes(t){return this.pushAttributes(t),this}pushAttributes(t){let r$1=t.map(n=>"build"in n&&typeof n.build=="function"?n.build():n);ue([...this.obj.attributes,...r$1],n=>n.name,n=>new r("attribute",n,`Object "${this.obj.name}": duplicate attribute name "${n}"`)),this.obj.attributes.push(...r$1);}metadata(t){return this.obj.metadata={...this.obj.metadata,...t},this}order(t){return this.obj.metadata={...this.obj.metadata,order:t},this}hidden(){return this.obj.metadata={...this.obj.metadata,hidden:true},this}labelExpression(t){return this._labelExpression=t,this}embeddingExpression(t){return this._embeddingExpression=t,this}documentLayout(t){if(t.presets)for(let r of t.presets)To(r.id,r.structure,1);return this.obj.documentLayout=t,this}migration(t,r){if(t<2)throw new Error(`[ObjectBuilder] Migration version must be >= 2 (version 1 is implicit). Got: ${t}`);if(this._migrations.some(a=>a.version===t))throw new Error(`[ObjectBuilder] Duplicate migration version: ${t}`);let o=new nt(t);return r(o),this._migrations.push(o.build()),this}build(){if(!this.obj.name)throw new Error("[ObjectBuilder] Missing required field: name");if(!this.obj.label)throw new Error("[ObjectBuilder] Missing required field: label");Au({name:this.obj.name,labelExpression:this._labelExpression,embeddingExpression:this._embeddingExpression});let t=[...this._migrations].sort((n,o)=>n.version-o.version);for(let n=0;n<t.length;n++){let o=n+2;if(t[n].version!==o)throw new Error(`[ObjectBuilder] Migration versions must be sequential starting at 2. Expected version ${o}, got ${t[n].version}.`)}let r=t.length>0?t[t.length-1].version:1;return {...this.obj,pluralLabel:this._pluralLabel,labelExpression:this._labelExpression,embeddingExpression:this._embeddingExpression,schema_version:r,migrations:t,sealed:this._sealed,toleratedAttributes:this._toleratedAttributes}}validateName(t){t!==void 0&&De(t);}};a(zr,"ObjectBuilder");var qr=zr;function z(e){return new qr(e)}a(z,"object");function To(e,t,r){let n=a((a,s)=>{throw new h(a,[{path:["documentLayout","presets",e],message:s}])},"fail");r>5&&n(`Preset structure exceeds max depth of ${5}`,"Preset structure too deep");let o=new Set;for(let a of t){let s=a.title.trim();s.length===0&&n("Folder preset node title is required","Empty folder title"),s.includes("/")&&n("Folder preset node title cannot contain /",`Folder title contains /: "${s}"`),o.has(s)&&n("Folder preset sibling titles must be unique",`Duplicate folder title: "${s}"`),o.add(s),a.children&&a.children.length>0&&To(e,a.children,r+1);}}a(To,"validatePresetStructure");var en=class en{constructor(t,r){this.data={type:"fields",fields:[]};this.data.id=t,this.data.label=r;}description(t){return this.data.description=t,this}collapsible(t=false){return this.data.collapsible=true,this.data.collapsed=t,this}order(t){return this.data.order=t,this}fields(...t){for(let r of t)this.data.fields?.push({attribute:r});return this}field(t,r){return this.data.fields?.push({attribute:t,...r}),this}attributeGroup(t,r){return this.data.fields?.push({attributeGroup:t,...r}),this}build(){if(!this.data.id)throw new Error("[GroupBuilder] id is required");if(!this.data.label)throw new Error("[GroupBuilder] label is required");if(!this.data.fields||this.data.fields.length===0)throw new Error("[GroupBuilder] At least one field is required");return this.data}};a(en,"GroupBuilder");var ot=en,tn=class tn{constructor(t,r){this.view=t,this.tabData=r;}columns(...t){return this.tabData.columns=t,this}create(t){return this.tabData.allowCreate=true,t?.mode&&(this.tabData.createMode=t.mode),this}createMode(t){return this.tabData.createMode=t,this}edit(){return this.tabData.allowEdit=true,this}delete(){return this.tabData.allowDelete=true,this}crud(){return this.tabData.allowCreate=true,this.tabData.allowEdit=true,this.tabData.allowDelete=true,this}filters(t){return this.tabData.filters=t,this}sorts(t){return this.tabData.sorts=t,this}sort(t,r="asc"){return this.tabData.sorts||(this.tabData.sorts=[]),this.tabData.sorts.push({attribute:t,direction:r}),this}tab(t,r){return this.finalize(),new Q(this.view,t,r)}done(){return this.finalize(),this.view}build(){return this.finalize(),this.view.build()}finalize(){if(!this.tabData.columns||this.tabData.columns.length===0)throw new Error(`[TableTabConfig] columns() is required for tab "${this.tabData.name}"`);this.view._addTab(this.tabData);}};a(tn,"TableTabConfig");var at=tn,rn=class rn{constructor(t,r,n){this.view=t,this.tabData={...r,type:"custom",component:n};}props(t){return this.tabData.props=t,this}tab(t,r){return this.view._addTab(this.tabData),new Q(this.view,t,r)}done(){return this.view._addTab(this.tabData),this.view}build(){return this.view._addTab(this.tabData),this.view.build()}};a(rn,"CustomTabConfig");var Gr=rn,nn=class nn{constructor(t,r,n){this.view=t,this.tabData={...r,type:"richtext",attribute:n};}titleAttribute(t){return this.tabData.titleAttribute=t,this}tab(t,r){return this.view._addTab(this.tabData),new Q(this.view,t,r)}done(){return this.view._addTab(this.tabData),this.view}build(){return this.view._addTab(this.tabData),this.view.build()}};a(nn,"RichtextTabConfig");var Wr=nn,on=class on{constructor(t,r){this.view=t,this.tabData={...r,type:"activity"};}limit(t){return this.tabData.limit=t,this}tab(t,r){return this.view._addTab(this.tabData),new Q(this.view,t,r)}done(){return this.view._addTab(this.tabData),this.view}build(){return this.view._addTab(this.tabData),this.view.build()}};a(on,"ActivityTabConfig");var Kr=on,an=class an{constructor(t,r,n){this.view=t,this.tabData={...r,type:n,emailAttributeIds:[]};}emailAttributes(...t){return this.tabData.emailAttributeIds=t,this}tab(t,r){return this.view._addTab(this.tabData),new Q(this.view,t,r)}done(){return this.view._addTab(this.tabData),this.view}build(){return this.view._addTab(this.tabData),this.view.build()}};a(an,"AddressMatchedTabConfig");var st=an,sn=class sn extends st{constructor(t,r){super(t,r,"emails");}};a(sn,"EmailsTabConfig");var Yr=sn,un=class un extends st{constructor(t,r){super(t,r,"meetings");}};a(un,"MeetingsTabConfig");var Hr=un,ln=class ln{constructor(t,r){this.view=t,this.tabData={...r,type:"documents",allowUpload:true,allowRemove:true,hideAttachments:false};}disableUpload(){return this.tabData.allowUpload=false,this}disableRemove(){return this.tabData.allowRemove=false,this}hideAttachments(){return this.tabData.hideAttachments=true,this}tab(t,r){return this.view._addTab(this.tabData),new Q(this.view,t,r)}done(){return this.view._addTab(this.tabData),this.view}build(){return this.view._addTab(this.tabData),this.view.build()}};a(ln,"DocumentsTabConfig");var Qr=ln,dn=class dn{constructor(t,r,n){this.view=t,this.base={id:r,name:r,label:n};}icon(t){return this.base.icon=t,this}order(t){return this.base.order=t,this}form(...t){if(t.length===0)throw new Error(`[TabBuilder] form() requires at least one group for tab "${this.base.name}"`);let r={...this.base,type:"form",groups:t.map(n=>n instanceof ot?n.build():n)};return this.view._addTab(r)}table(t){return new at(this.view,{...this.base,type:"table",source:{type:"relation",attribute:t},columns:[]})}tableFrom(t,r){return new at(this.view,{...this.base,type:"table",source:{type:"inverse",object:t,attribute:r},columns:[]})}custom(t){return new Gr(this.view,this.base,t)}richtext(t){return new Wr(this.view,this.base,t)}activity(){return new Kr(this.view,this.base)}documents(){return new Qr(this.view,this.base)}emails(){return new Yr(this.view,this.base)}meetings(){return new Hr(this.view,this.base)}forms(t){let r={...this.base,type:"forms",...t};return this.view._addTab(r)}};a(dn,"TabBuilder");var Q=dn,cn=class cn{constructor(t,r){Ze(t),this.data={name:t,label:r,tabs:[]};}description(t){return this.data.description=t,this}icon(t){return this.data.icon=t,this}for(t){return this.data.object=t,this}default(){return this.data.default=true,this}metadata(t){return this.data.metadata=t,this}sidePanel(t){return this.data.sidePanel=t,this}tab(t,r){return new Q(this,t,r)}addTab(t){return this.data.tabs.push(t),this}_addTab(t){return this.data.tabs.push(t),this}build(){if(!this.data.object)throw new Error("[DetailViewBuilder] for() is required - specify the target object");if(this.data.tabs.length===0)throw new Error("[DetailViewBuilder] At least one tab is required");ue(this.data.tabs,r=>r.name,r=>new Error(`[DetailViewBuilder] Duplicate tab name "${r}"`));let t={tabs:this.data.tabs,sidePanel:this.data.sidePanel};return {name:this.data.name,label:this.data.label,description:this.data.description,icon:this.data.icon,object:this.data.object,type:"detail",config:t,default:this.data.default,metadata:this.data.metadata}}};a(cn,"DetailViewBuilder");var Jr=cn;function ee(e,t){return new Jr(e,t)}a(ee,"detailView");function it(e){if(Array.isArray(e))return e.map(it).find(r=>r!==void 0);if(e===null||typeof e!="object")return;let t=e;return t.attribute==="visibility"||t.attribute==="ownedBy"?t.attribute:it(t.rules)??it(t.groups)}a(it,"findProtectedTabFilterAttribute");var pn=class pn{constructor(t,r){Ze(t),this.data={name:t,label:r,tabs:[]};}description(t){return this.data.description=t,this}icon(t){return this.data.icon=t,this}for(t){return this.data.object=t,this}default(){return this.data.default=true,this}metadata(t){return this.data.metadata=t,this}baseFilter(t){return this.data.defaultFilters=t,this}allowPresentationCustomization(){return this.data.allowPresentationCustomization=true,this}tab(t,r){return new Zr(this,t,r)}_addTab(t){return this.data.tabs.push(t),this}build(){if(!this.data.object)throw new Error("[ListViewBuilder] for() is required - specify the target object");if(this.data.tabs.length===0)throw new Error("[ListViewBuilder] At least one tab is required");if(ue(this.data.tabs,n=>n.id,n=>new Error(`[ListViewBuilder] Duplicate tab id "${n}"`)),this.data.tabs.filter(n=>n.default).length>1)throw new Error("[ListViewBuilder] Only one tab can be marked as default");for(let n of this.data.tabs){if(n.layout==="table"&&n.columns.length===0)throw new h(`[ListViewBuilder] Tab "${n.id}" must have at least one column`,[]);if(n.layout==="kanban"&&!n.groupByAttribute)throw new h(`[ListViewBuilder] Kanban tab "${n.id}" requires a groupByAttribute`,[]);if(n.descriptionAttribute!==void 0&&n.descriptionAttribute.length===0)throw new h(`[ListViewBuilder] Tab "${n.id}" requires a nonempty description attribute name`,[]);if(n.displayAttributes!==void 0){let o=Y.safeParse(n.displayAttributes);if(!o.success)throw new h(`[ListViewBuilder] Tab "${n.id}" has invalid display attributes`,o.error.issues.map(a=>({path:["tabs",n.id,"displayAttributes",...a.path.map(String)],message:a.message})))}}let r={allowPresentationCustomization:this.data.allowPresentationCustomization,defaultFilters:this.data.defaultFilters?{id:d(),combinator:this.data.defaultFilters.combinator,rules:this.data.defaultFilters.rules}:void 0,tabs:this.data.tabs.map(n=>{let o={id:n.id,label:n.label,icon:n.icon,default:n.default,visibility:n.visibility,columns:n.columns,descriptionAttribute:n.descriptionAttribute,displayAttributes:n.displayAttributes,filters:n.filters?{id:d(),combinator:n.filters.combinator,rules:n.filters.rules}:void 0,sorts:n.sorts,createMode:n.createMode};return n.layout==="kanban"?{...o,layout:"kanban",groupByAttribute:n.groupByAttribute,cardUserAttribute:n.cardUserAttribute,cardDateAttribute:n.cardDateAttribute,kanbanColumnOrder:n.kanbanColumnOrder,kanbanColumnVisibility:n.kanbanColumnVisibility,kanbanPinnedColumns:n.kanbanPinnedColumns}:{...o,layout:n.layout,columnSizing:n.columnSizing}})};return {name:this.data.name,label:this.data.label,description:this.data.description,icon:this.data.icon,object:this.data.object,type:"list",config:r,default:this.data.default,metadata:this.data.metadata}}};a(pn,"ListViewBuilder");var Xr=pn,ut=class ut{constructor(t,r,n){this.view=t,this.tabData={id:r,label:n,visibility:"all",layout:"table",columns:[]};}icon(t){return this.tabData.icon=t,this}default(){return this.tabData.default=true,this}visibility(t){return this.tabData.visibility=t,this}table(){return this.tabData.layout="table",this}list(){return this.tabData.layout="list",this}descriptionAttribute(t){return this.tabData.descriptionAttribute=t,this}displayAttributes(...t){return this.tabData.displayAttributes=t,this}kanban(t){return this.tabData.layout="kanban",this.tabData.groupByAttribute=t,this}cardUserAttribute(t){return this.tabData.cardUserAttribute=t,this}cardDateAttribute(t){return this.tabData.cardDateAttribute=t,this}kanbanColumnOrder(t){return this.tabData.kanbanColumnOrder=t,this}kanbanColumnVisibility(t){return this.tabData.kanbanColumnVisibility=t,this}kanbanPinnedColumns(t){return this.tabData.kanbanPinnedColumns=t,this}createMode(t){return this.tabData.createMode=t,this}columns(...t){return this.tabData.columns=t,this}columnWidth(t,r){return this.tabData.columnSizing||(this.tabData.columnSizing={}),this.tabData.columnSizing[t]=r,this}filter(t){let r=it(t);if(r){let n=`Tab filters cannot target "${r}". Use .visibility("private")`;throw new h(n,[{path:["filters"],message:n}])}return this.tabData.filters=t,this}sort(t,r="asc"){return this.tabData.sorts||(this.tabData.sorts=[]),this.tabData.sorts.push({attribute:t,direction:r}),this}sorts(t){return this.tabData.sorts=t,this}tab(t,r){return this.view._addTab(this.tabData),new ut(this.view,t,r)}done(){return this.view._addTab(this.tabData),this.view}build(){return this.view._addTab(this.tabData),this.view.build()}};a(ut,"ListViewTabConfigBuilder");var Zr=ut;function G(e,t){return new Xr(e,t)}a(G,"listView");function CA(e,t){return new ot(e,t)}a(CA,"group");function Tu(e){if(!/^[a-z][a-z0-9-]*[a-z0-9]$|^[a-z]$/.test(e))throw new Error(`Invalid flag name "${e}". Flag names must be kebab-case (e.g., "architect-mode", "ai-features").`)}a(Tu,"validateFlagName");var yn=class yn{constructor(t,r,n){Tu(t),this.flag={name:t,valueType:r,defaultValue:n,allowedLevels:["global","tenant","user"]};}label(t){return this.flag.label=t,this}description(t){return this.flag.description=t,this}category(t){return this.flag.category=t,this}system(){return this.flag.system=true,this}tenantScoped(){return this.flag.allowedLevels=["global","tenant"],this}globalOnly(){return this.flag.allowedLevels=["global"],this}allowedLevels(t){return this.flag.allowedLevels=[...t],this}build(){if(!this.flag.label?.trim())throw new Error(`Flag "${this.flag.name}" must have a label. Use .label("Human-readable label").`);return {...this.flag,allowedLevels:[...this.flag.allowedLevels||[]]}}};a(yn,"BaseFlagBuilder");var Te=yn,hn=class hn extends Te{constructor(t){super(t,"boolean",false);}defaultValue(t){return this.flag.defaultValue=t,this}enabledByDefault(){return this.flag.defaultValue=true,this}};a(hn,"BooleanFlagBuilder");var mn=hn,An=class An extends Te{constructor(t){super(t,"string","");}defaultValue(t){return this.flag.defaultValue=t,this}};a(An,"StringFlagBuilder");var fn=An,Tn=class Tn extends Te{constructor(t){super(t,"number",0);}defaultValue(t){return this.flag.defaultValue=t,this}};a(Tn,"NumberFlagBuilder");var bn=Tn,wn=class wn extends Te{constructor(t,r){super(t,"json",r);}defaultValue(t){return this.flag.defaultValue=t,this}};a(wn,"JsonFlagBuilder");var gn=wn;function wu(e){return new mn(e)}a(wu,"booleanFlag");function xu(e){return new fn(e)}a(xu,"stringFlag");function Iu(e){return new bn(e)}a(Iu,"numberFlag");function Su(e,t){return new gn(e,t)}a(Su,"jsonFlag");function xn(e){return new r("feature flag",e,`Flag "${e}" is already registered. Each flag name must be unique.`)}a(xn,"duplicateFlagError");function In(e){return {...e,allowedLevels:[...e.allowedLevels]}}a(In,"cloneFlagDefinition");var Sn=class Sn{constructor(){this.flags=new Map;}register(t){if(this.flags.has(t.name))throw xn(t.name);this.flags.set(t.name,In(t));}registerAll(t){let r=new Set;for(let n of t){if(this.flags.has(n.name)||r.has(n.name))throw xn(n.name);r.add(n.name);}for(let n of t)this.register(n);}get(t){let r=this.flags.get(t);return r?In(r):void 0}getOrThrow(t){let r=this.get(t);if(!r)throw new c$3("Feature flag",t,void 0,`Flag "${t}" is not registered. Available flags: ${this.listNames().join(", ")}`);return r}has(t){return this.flags.has(t)}list(){return Array.from(this.flags.values(),In)}listNames(){return Array.from(this.flags.keys())}unregister(t){return this.flags.delete(t)}clear(){this.flags.clear();}get size(){return this.flags.size}};a(Sn,"FlagRegistry");var Ne=Sn,vu=new Ne;function Ru(){return new Ne}a(Ru,"createFlagRegistry");function lt(){return {global:new Map,tenant:new Map,user:new Map}}a(lt,"emptyOverrides");function Eu(e,t){return e.expiresAt===void 0||e.expiresAt.getTime()>t}a(Eu,"isActiveOverride");function vn(e,t){let r=new Map;for(let n of e){if(!Eu(n,t))continue;let o=n.flagName;r.has(o)||r.set(o,n);}return r}a(vn,"indexOverrides");var Rn=class Rn{constructor(t){this.repository=t.repository,this.registry=t.registry,this.staticDefaults=new Map(t.staticDefaults?.map(r=>[r.name,r.value])??[]);}async resolveAll(t={}){let r=this.collectFlagNames(),n=this.repository&&r.size>0?await this.getAllOverrides(t,[...r]):lt();return this.resolveNames(r,n,t)}resolveAllStatic(){return this.resolveNames(this.collectFlagNames(),lt(),{})}collectFlagNames(){let t=new Set;for(let r of this.registry.listNames())t.add(r);for(let r of this.staticDefaults.keys())t.add(r);return t}resolveNames(t,r,n){let o=new Map;for(let a of t)o.set(a,this.resolveValue(a,r,n));return o}async resolve(t,r={}){let n=this.repository?await this.getAllOverrides(r,[t]):lt();return this.resolveWithSource(t,n,r)}async isEnabled(t,r={}){return (await this.resolve(t,r)).value===true}async getValue(t,r={}){return (await this.resolve(t,r)).value}async setOverride(t,r,n,o={}){if(!this.repository)throw new b$1("Cannot set override: no FeatureFlagsRepository configured. Add featureFlags to your DatabaseAdapter to enable runtime overrides.",a$2.CONFIGURATION_REQUIRED);let a=this.registry.get(t);if(a&&!a.allowedLevels.includes(r)){let s=`Flag "${t}" does not allow ${r}-level overrides. Allowed levels: ${a.allowedLevels.join(", ")}`;throw new h(s,[{path:["level"],message:s}])}if(a?.system){let s=`Flag "${t}" is a system flag and cannot be overridden via API.`;throw new h(s,[{path:["flagName"],message:s}])}await this.repository.setOverride({flagName:t,level:r,value:n,targetId:o.targetId,expiresAt:o.expiresAt,createdBy:o.createdBy});}async deleteOverride(t,r,n){if(!this.repository)throw new b$1("Cannot delete override: no FeatureFlagsRepository configured.",a$2.CONFIGURATION_REQUIRED);await this.repository.deleteOverride(t,r,n);}async getAllOverrides(t,r){if(!this.repository)return lt();let[n,o,a]=await Promise.all([this.repository.getOverrides({level:"global",flagNames:r}),t.tenantId?this.repository.getOverrides({level:"tenant",targetId:t.tenantId,flagNames:r}):Promise.resolve([]),t.userId?this.repository.getOverrides({level:"user",targetId:t.userId,flagNames:r}):Promise.resolve([])]),s=Date.now();return {global:vn(n,s),tenant:vn(o,s),user:vn(a,s)}}resolveValue(t,r,n){return this.resolveWithSource(t,r,n).value}resolveWithSource(t,r,n){let o=this.registry.get(t),a=o?.allowedLevels??["global","tenant","user"];if(n.userId&&a.includes("user")){let s=r.user.get(t);if(s)return {name:t,value:s.value,source:"user",sourceId:n.userId}}if(n.tenantId&&a.includes("tenant")){let s=r.tenant.get(t);if(s)return {name:t,value:s.value,source:"tenant",sourceId:n.tenantId}}if(a.includes("global")){let s=r.global.get(t);if(s)return {name:t,value:s.value,source:"global"}}return this.staticDefaults.has(t)?{name:t,value:this.staticDefaults.get(t),source:"default"}:{name:t,value:o?.defaultValue??void 0,source:"default"}}};a(Rn,"FlagService");var dt=Rn;function Du(e){return new dt(e)}a(Du,"createFlagService");function En(e){return structuredClone(e)}a(En,"cloneObjectDefinition");var Cn=class Cn{constructor(){this.objects=new Map;}register(t){let r=Array.isArray(t)?t:[t];for(let n of r){let o="build"in n&&typeof n.build=="function"?n.build():n;this.validateAndRegister(o);}return this}validateAndRegister(t){if(!t.system){let r=`[NativeObjectRegistry] Cannot register object "${t.name}" (id: ${t.id}): missing system flag.
14
14
  Native objects must have system=true. Did you call .runtime() on the builder? Remove that call \u2014 objects are system:true by default.`;throw new h(r,[])}if(this.objects.has(t.name)){let r$1=this.objects.get(t.name),n=`[NativeObjectRegistry] Duplicate object name "${t.name}":
15
15
  - Existing: "${r$1?.label}" (id: ${r$1?.id})
16
16
  - New: "${t.label}" (id: ${t.id})
17
17
  Please use unique names for each native object.`;throw new r("object",t.name,n)}this.objects.set(t.name,En(t));}getByName(t){let r=this.objects.get(t);return r?En(r):void 0}getByNameOrThrow(t){let r=this.getByName(t);if(!r){let n=`[NativeObjectRegistry] Native object "${t}" not found.
18
18
  Available objects: ${this.listNames().join(", ")}`;throw new c$3("Native object",t,a$2.OBJECT_NOT_FOUND,n)}return r}getAll(){return Array.from(this.objects.values(),En)}listNames(){return Array.from(this.objects.keys())}has(t){return this.objects.has(t)}get size(){return this.objects.size}clear(){this.objects.clear();}summary(){let t=this.getAll();return [`[NativeObjectRegistry] ${this.size} native object(s) registered:`,...t.map(r=>` - ${r.name}: "${r.label}" (${r.attributes.length} attributes)`)].join(`
19
- `)}debug(t){let r=this.summary();return t?.(r),r}};a(Cn,"NativeObjectRegistryClass");var Dn=Cn,KA=new Dn;function P(e){return {...e,system:true}}a(P,"markSystemView");var wo=`## Overview
19
+ `)}debug(t){let r=this.summary();return t?.(r),r}};a(Cn,"NativeObjectRegistryClass");var Dn=Cn,XA=new Dn;function P(e){return {...e,system:true}}a(P,"markSystemView");var wo=`## Overview
20
20
 
21
21
  Describe in one or two sentences what this skill does and the outcome it produces. The agent reads this page when it uses the skill \u2014 write instructions for the agent, not documentation for people.
22
22
 
@@ -47,14 +47,14 @@ Show at least one concrete example of the skill applied well.
47
47
 
48
48
  - Never \u2026
49
49
  - Do not \u2026
50
- `,Nu=z({name:"skill",label:"Skill"}).sealed().icon("book-open").order(Number.MAX_SAFE_INTEGER).pluralLabel("Skills").labelExpression("{{ name }}").embeddingExpression(`{{ name }}
50
+ `,ku=z({name:"skill",label:"Skill"}).sealed().icon("book-open").order(Number.MAX_SAFE_INTEGER).pluralLabel("Skills").labelExpression("{{ name }}").embeddingExpression(`{{ name }}
51
51
  {{ description }}
52
- {{ content }}`).attribute(f({name:"name",label:"Name"}).maxLength(SKILL_NAME_MAX_LENGTH).required()).attribute(f({name:"description",label:"Description"}).multiline().maxLength(SKILL_DESCRIPTION_MAX_LENGTH).required().placeholder('What this skill does and when to use it \u2014 e.g. "Drafts replies to customer complaints. Use when asked to answer an unhappy customer."')).attribute(he({name:"content",label:"Content"}).defaultValue(wo)).build(),ku=P(ee("skill-detail","Skill").for("skill").default().sidePanel({attributes:["name","description"]}).tab("content","Content").richtext("content").titleAttribute("name").done().tab("files","Files").documents().done().tab("activity","Activity").activity().done().build()),Ou=P(G("skill-list","Skills").for("skill").default().allowPresentationCustomization().tab("workspace","Skills").default().icon("list").visibility("workspace").list().columns("name","description").descriptionAttribute("description").displayAttributes("createdBy","updatedAt").sort("name","asc").tab("mine","My skills").icon("lock").visibility("private").list().columns("name","description").descriptionAttribute("description").displayAttributes("createdBy","updatedAt").sort("name","asc").build());var Fu=z({name:"memory",label:"Memory"}).sealed().icon("database").order(Number.MAX_SAFE_INTEGER).pluralLabel("Memories").labelExpression("{{ name }}").embeddingExpression(`{{ name }}
52
+ {{ content }}`).attribute(f({name:"name",label:"Name"}).maxLength(SKILL_NAME_MAX_LENGTH).required()).attribute(f({name:"description",label:"Description"}).multiline().maxLength(SKILL_DESCRIPTION_MAX_LENGTH).required().placeholder('What this skill does and when to use it \u2014 e.g. "Drafts replies to customer complaints. Use when asked to answer an unhappy customer."')).attribute(he({name:"content",label:"Content"}).defaultValue(wo)).build(),Ou=P(ee("skill-detail","Skill").for("skill").default().sidePanel({attributes:["name","description"]}).tab("content","Content").richtext("content").titleAttribute("name").done().tab("files","Files").documents().done().tab("activity","Activity").activity().done().build()),_u=P(G("skill-list","Skills").for("skill").default().allowPresentationCustomization().tab("workspace","Skills").default().icon("list").visibility("workspace").list().columns("name","description").descriptionAttribute("description").displayAttributes("createdBy","updatedAt").sort("name","asc").tab("mine","My skills").icon("lock").visibility("private").list().columns("name","description").descriptionAttribute("description").displayAttributes("createdBy","updatedAt").sort("name","asc").build());var Vu=z({name:"memory",label:"Memory"}).sealed().icon("database").order(Number.MAX_SAFE_INTEGER).pluralLabel("Memories").labelExpression("{{ name }}").embeddingExpression(`{{ name }}
53
53
  {{ description }}
54
- {{ content }}`).migration(2,e=>e.changeType("content","text","richtext")).attribute(f({name:"name",label:"Name"}).maxLength(MEMORY_NAME_MAX_LENGTH).required()).attribute(f({name:"description",label:"Description"}).multiline().maxLength(MEMORY_DESCRIPTION_MAX_LENGTH).required()).attribute(he({name:"content",label:"Content"})).attribute(q({name:"kind",label:"Kind"}).options([{value:"fact",label:"Fact"},{value:"preference",label:"Preference"},{value:"feedback",label:"Feedback"},{value:"reference",label:"Reference"}])).attribute(Ae({name:"subjects",label:"Subjects"}).toAny().many()).attribute(Ae({name:"links",label:"Links"}).to("memory").many()).attribute(q({name:"source",label:"Source"}).options([{value:"explicit",label:"Saved by an agent"},{value:"extracted",label:"Extracted from a session"},{value:"corroborated",label:"Corroborated across users"},{value:"curated",label:"Curated by Dreamer"}])).attribute(U({name:"validFrom",label:"Valid from"}).includeTime()).attribute(U({name:"invalidAt",label:"Invalid at"}).includeTime()).attribute(Ae({name:"supersededBy",label:"Superseded by"}).to("memory")).attribute(f({name:"provenance",label:"Provenance"}).multiline()).attribute(q({name:"reviewState",label:"Review state"}).options([{value:"needs_review",label:"Needs review"},{value:"skill_candidate",label:"Skill candidate"}])).attribute(f({name:"reviewReason",label:"Review reason"}).multiline()).attribute(U({name:"curatedAt",label:"Curated at"}).includeTime()).attribute(U({name:"reviewAfter",label:"Review after"}).includeTime()).attribute(f({name:"curationFingerprint",label:"Curation fingerprint"})).build(),xo={combinator:"and",rules:[{attribute:"invalidAt",operator:"is_empty",value:null},{attribute:"reviewState",operator:"is_empty",value:null}]},Vu=P(ee("memory-detail","Memory").for("memory").default().sidePanel({attributes:["description","kind","source","provenance","reviewState","reviewReason","validFrom","invalidAt","supersededBy","curatedAt","reviewAfter","subjects","links"]}).tab("content","Content").richtext("content").titleAttribute("name").build()),ju=P(G("memory-list","Memories").for("memory").default().allowPresentationCustomization().tab("workspace","Memories").default().icon("list").visibility("workspace").list().columns("name","kind","description","createdAt").descriptionAttribute("description").displayAttributes("kind","subjects","createdAt").filter(xo).sort("name","asc").tab("mine","My memories").icon("lock").visibility("private").list().columns("name","kind","description","createdAt").descriptionAttribute("description").displayAttributes("kind","subjects","createdAt").filter(xo).sort("name","asc").tab("review","To review").icon("question-circle").table().columns("name","reviewState","reviewReason","updatedAt").filter({combinator:"and",rules:[{attribute:"invalidAt",operator:"is_empty",value:null},{attribute:"reviewState",operator:"is_not_empty",value:null}]}).sort("updatedAt","desc").tab("history","History").icon("archive").table().columns("name","kind","invalidAt","supersededBy").filter({combinator:"and",rules:[{attribute:"invalidAt",operator:"is_not_empty",value:null}]}).sort("invalidAt","desc").build());var ct="drives",Lu=z({name:ct,label:"Drive"}).sealed().icon("folder").hidden().pluralLabel("Drives").labelExpression("{{ name }}").embeddingExpression(`{{ name }}
55
- {{ description }}`).attribute(f({name:"name",label:"Name"}).required()).attribute(f({name:"description",label:"Description"}).multiline()).build(),Mu=P(ee("drive-detail","Drive").for(ct).default().sidePanel({attributes:["description"]}).tab("documents","Documents").documents().build()),Bu=P(G("drive-list","Drives").for(ct).default().tab("workspace","Shared").default().icon("users").visibility("workspace").table().columns("name","description","updatedAt").sort("name","asc").tab("mine","My drives").icon("lock").visibility("private").table().columns("name","description","updatedAt").sort("name","asc").build());var Nn="artifact",Uu=z({name:Nn,label:"Artifact"}).sealed().hidden().icon("package").pluralLabel("Artifacts").labelExpression("{{ name }}").embeddingExpression(`{{ name }}
56
- {{ description }}`).attribute(f({name:"name",label:"Name"}).required()).attribute(f({name:"description",label:"Description"}).multiline()).attribute(q({name:"kind",label:"Kind"}).options([{value:"web",label:"Web",color:"blue"},{value:"presentation",label:"Presentation",color:"purple"},{value:"document",label:"Document",color:"sky"},{value:"spreadsheet",label:"Spreadsheet",color:"green"},{value:"image",label:"Image",color:"pink"},{value:"code",label:"Code",color:"slate"},{value:"other",label:"Other",color:"gray"}]).required()).attribute(q({name:"retention",label:"Retention"}).options([{value:"ephemeral",label:"Ephemeral",color:"gray"},{value:"conversation",label:"Conversation",color:"blue"},{value:"persistent",label:"Persistent",color:"green"}]).defaultValue("conversation").required()).attribute(rt({name:"currentRevision",label:"Current revision"}).integer().min(1)).attribute(U({name:"expiresAt",label:"Expires at"}).includeTime().hidden()).attribute(f({name:"sourceSessionId",label:"Source session"}).hidden()).attribute(f({name:"sourceMessageId",label:"Source message"}).hidden()).attribute(f({name:"initialToolCallId",label:"Initial tool call"}).hidden()).attribute(yo({name:"versions",label:"Versions"}).qualifyWith(rt({name:"revision",label:"Revision"}).integer().min(1).required(),f({name:"toolCallId",label:"Tool call"}).hidden(),f({name:"sourceFileId",label:"Source file"}).hidden(),f({name:"previewFileId",label:"Preview file"}).hidden(),f({name:"fileIds",label:"File manifest"}).hidden(),f({name:"entrypoint",label:"Entrypoint"}).hidden(),f({name:"sourceMessageId",label:"Source message"}).hidden(),f({name:"artifactName",label:"Artifact name"}).hidden(),f({name:"artifactDescription",label:"Artifact description"}).hidden(),f({name:"artifactKind",label:"Artifact kind"}).hidden(),f({name:"displayMode",label:"Display mode"}).hidden(),f({name:"displayInteraction",label:"Display interaction"}).hidden(),f({name:"displaySize",label:"Display size"}).hidden(),rt({name:"displayAspectRatio",label:"Display aspect ratio"}).hidden())).build(),$u=P(G("artifact-list","Artifacts").for(Nn).default().allowPresentationCustomization().tab("all","Artifacts").default().icon("list").list().columns("name","kind","currentRevision","updatedAt").descriptionAttribute("description").displayAttributes("kind","currentRevision","versions").sort("updatedAt","desc").build());var pt="meeting",T={title:"title",description:"description",location:"location",startsAt:"startsAt",endsAt:"endsAt",isAllDay:"isAllDay",status:"status",organizerAddress:"organizerAddress",organizerName:"organizerName",conferenceProvider:"conferenceProvider",conferenceJoinUrl:"conferenceJoinUrl",htmlLink:"htmlLink",participants:"participants",providerEventId:"providerEventId",icalUid:"icalUid",recurringEventId:"recurringEventId",connectionId:"connectionId",recordingOverride:"recordingOverride",endedAnnouncedAt:"endedAnnouncedAt",linkedRecords:"linkedRecords"},So="meeting-list",vo="calendar-sync",Ro="meeting-detail",Io=[T.title,T.startsAt,T.endsAt,T.status],qu=z({name:pt,label:"Meeting"}).sealed().hidden().metadata({platformOwned:{editable:[T.linkedRecords],source:vo}}).icon("calendar").pluralLabel("Meetings").labelExpression("{{ title }}").embeddingExpression(`{{ title }}
54
+ {{ content }}`).migration(2,e=>e.changeType("content","text","richtext")).attribute(f({name:"name",label:"Name"}).maxLength(MEMORY_NAME_MAX_LENGTH).required()).attribute(f({name:"description",label:"Description"}).multiline().maxLength(MEMORY_DESCRIPTION_MAX_LENGTH).required()).attribute(he({name:"content",label:"Content"})).attribute(q({name:"kind",label:"Kind"}).options([{value:"fact",label:"Fact"},{value:"preference",label:"Preference"},{value:"feedback",label:"Feedback"},{value:"reference",label:"Reference"}])).attribute(Ae({name:"subjects",label:"Subjects"}).toAny().many()).attribute(Ae({name:"links",label:"Links"}).to("memory").many()).attribute(q({name:"source",label:"Source"}).options([{value:"explicit",label:"Saved by an agent"},{value:"extracted",label:"Extracted from a session"},{value:"corroborated",label:"Corroborated across users"},{value:"curated",label:"Curated by Dreamer"}])).attribute(U({name:"validFrom",label:"Valid from"}).includeTime()).attribute(U({name:"invalidAt",label:"Invalid at"}).includeTime()).attribute(Ae({name:"supersededBy",label:"Superseded by"}).to("memory")).attribute(f({name:"provenance",label:"Provenance"}).multiline()).attribute(q({name:"reviewState",label:"Review state"}).options([{value:"needs_review",label:"Needs review"},{value:"skill_candidate",label:"Skill candidate"}])).attribute(f({name:"reviewReason",label:"Review reason"}).multiline()).attribute(U({name:"curatedAt",label:"Curated at"}).includeTime()).attribute(U({name:"reviewAfter",label:"Review after"}).includeTime()).attribute(f({name:"curationFingerprint",label:"Curation fingerprint"})).build(),xo={combinator:"and",rules:[{attribute:"invalidAt",operator:"is_empty",value:null},{attribute:"reviewState",operator:"is_empty",value:null}]},ju=P(ee("memory-detail","Memory").for("memory").default().sidePanel({attributes:["description","kind","source","provenance","reviewState","reviewReason","validFrom","invalidAt","supersededBy","curatedAt","reviewAfter","subjects","links"]}).tab("content","Content").richtext("content").titleAttribute("name").build()),Mu=P(G("memory-list","Memories").for("memory").default().allowPresentationCustomization().tab("workspace","Memories").default().icon("list").visibility("workspace").list().columns("name","kind","description","createdAt").descriptionAttribute("description").displayAttributes("kind","subjects","createdAt").filter(xo).sort("name","asc").tab("mine","My memories").icon("lock").visibility("private").list().columns("name","kind","description","createdAt").descriptionAttribute("description").displayAttributes("kind","subjects","createdAt").filter(xo).sort("name","asc").tab("review","To review").icon("question-circle").table().columns("name","reviewState","reviewReason","updatedAt").filter({combinator:"and",rules:[{attribute:"invalidAt",operator:"is_empty",value:null},{attribute:"reviewState",operator:"is_not_empty",value:null}]}).sort("updatedAt","desc").tab("history","History").icon("archive").table().columns("name","kind","invalidAt","supersededBy").filter({combinator:"and",rules:[{attribute:"invalidAt",operator:"is_not_empty",value:null}]}).sort("invalidAt","desc").build());var ct="drives",Lu=z({name:ct,label:"Drive"}).sealed().icon("folder").hidden().pluralLabel("Drives").labelExpression("{{ name }}").embeddingExpression(`{{ name }}
55
+ {{ description }}`).attribute(f({name:"name",label:"Name"}).required()).attribute(f({name:"description",label:"Description"}).multiline()).build(),Bu=P(ee("drive-detail","Drive").for(ct).default().sidePanel({attributes:["description"]}).tab("documents","Documents").documents().build()),Uu=P(G("drive-list","Drives").for(ct).default().tab("workspace","Shared").default().icon("users").visibility("workspace").table().columns("name","description","updatedAt").sort("name","asc").tab("mine","My drives").icon("lock").visibility("private").table().columns("name","description","updatedAt").sort("name","asc").build());var Nn="artifact",$u=z({name:Nn,label:"Artifact"}).sealed().hidden().icon("package").pluralLabel("Artifacts").labelExpression("{{ name }}").embeddingExpression(`{{ name }}
56
+ {{ description }}`).attribute(f({name:"name",label:"Name"}).required()).attribute(f({name:"description",label:"Description"}).multiline()).attribute(q({name:"kind",label:"Kind"}).options([{value:"web",label:"Web",color:"blue"},{value:"presentation",label:"Presentation",color:"purple"},{value:"document",label:"Document",color:"sky"},{value:"spreadsheet",label:"Spreadsheet",color:"green"},{value:"image",label:"Image",color:"pink"},{value:"code",label:"Code",color:"slate"},{value:"other",label:"Other",color:"gray"}]).required()).attribute(q({name:"retention",label:"Retention"}).options([{value:"ephemeral",label:"Ephemeral",color:"gray"},{value:"conversation",label:"Conversation",color:"blue"},{value:"persistent",label:"Persistent",color:"green"}]).defaultValue("conversation").required()).attribute(rt({name:"currentRevision",label:"Current revision"}).integer().min(1)).attribute(U({name:"expiresAt",label:"Expires at"}).includeTime().hidden()).attribute(f({name:"sourceSessionId",label:"Source session"}).hidden()).attribute(f({name:"sourceMessageId",label:"Source message"}).hidden()).attribute(f({name:"initialToolCallId",label:"Initial tool call"}).hidden()).attribute(yo({name:"versions",label:"Versions"}).qualifyWith(rt({name:"revision",label:"Revision"}).integer().min(1).required(),f({name:"toolCallId",label:"Tool call"}).hidden(),f({name:"sourceFileId",label:"Source file"}).hidden(),f({name:"previewFileId",label:"Preview file"}).hidden(),f({name:"fileIds",label:"File manifest"}).hidden(),f({name:"entrypoint",label:"Entrypoint"}).hidden(),f({name:"sourceMessageId",label:"Source message"}).hidden(),f({name:"artifactName",label:"Artifact name"}).hidden(),f({name:"artifactDescription",label:"Artifact description"}).hidden(),f({name:"artifactKind",label:"Artifact kind"}).hidden(),f({name:"displayMode",label:"Display mode"}).hidden(),f({name:"displayInteraction",label:"Display interaction"}).hidden(),f({name:"displaySize",label:"Display size"}).hidden(),rt({name:"displayAspectRatio",label:"Display aspect ratio"}).hidden())).build(),qu=P(G("artifact-list","Artifacts").for(Nn).default().allowPresentationCustomization().tab("all","Artifacts").default().icon("list").list().columns("name","kind","currentRevision","updatedAt").descriptionAttribute("description").displayAttributes("kind","currentRevision","versions").sort("updatedAt","desc").build());var pt="meeting",T={title:"title",description:"description",location:"location",startsAt:"startsAt",endsAt:"endsAt",isAllDay:"isAllDay",status:"status",organizerAddress:"organizerAddress",organizerName:"organizerName",conferenceProvider:"conferenceProvider",conferenceJoinUrl:"conferenceJoinUrl",htmlLink:"htmlLink",participants:"participants",providerEventId:"providerEventId",icalUid:"icalUid",recurringEventId:"recurringEventId",connectionId:"connectionId",recordingOverride:"recordingOverride",endedAnnouncedAt:"endedAnnouncedAt",linkedRecords:"linkedRecords"},So="meeting-list",vo="calendar-sync",Ro="meeting-detail",Io=[T.title,T.startsAt,T.endsAt,T.status],zu=z({name:pt,label:"Meeting"}).sealed().hidden().metadata({platformOwned:{editable:[T.linkedRecords],source:vo}}).icon("calendar").pluralLabel("Meetings").labelExpression("{{ title }}").embeddingExpression(`{{ title }}
57
57
  {{ description }}
58
- {{ participants }}`).attribute(f({name:T.title,label:"Title"}).required()).attribute(he({name:T.description,label:"Description"})).attribute(f({name:T.location,label:"Location"})).attribute(U({name:T.startsAt,label:"Starts at"}).includeTime()).attribute(U({name:T.endsAt,label:"Ends at"}).includeTime()).attribute(go({name:T.isAllDay,label:"All day"})).attribute(q({name:T.status,label:"Status"}).options([{value:"confirmed",label:"Confirmed"},{value:"tentative",label:"Tentative"},{value:"cancelled",label:"Cancelled"}])).attribute(f({name:T.organizerAddress,label:"Organizer address"}).email()).attribute(f({name:T.organizerName,label:"Organizer"})).attribute(f({name:T.conferenceProvider,label:"Conference provider"})).attribute(f({name:T.conferenceJoinUrl,label:"Join link"}).url()).attribute(f({name:T.htmlLink,label:"Open in calendar"}).url()).attribute(f({name:T.participants,label:"Participants"}).multiline()).attribute(f({name:T.providerEventId,label:"Provider event id"}).hidden()).attribute(f({name:T.icalUid,label:"iCal UID"}).hidden()).attribute(f({name:T.recurringEventId,label:"Recurring event id"}).hidden()).attribute(f({name:T.connectionId,label:"Connection id"}).hidden()).attribute(q({name:T.recordingOverride,label:"Recording"}).options([{value:"force",label:"Force"},{value:"skip",label:"Skip"}]).hidden()).attribute(U({name:T.endedAnnouncedAt,label:"Ended announced at"}).includeTime().hidden()).attribute(Ae({name:T.linkedRecords,label:"Linked records"}).toAny().many().qualifyWith(f({name:"source",label:"Source"}).hidden())).build(),zu=P(ee(Ro,"Meeting").for(pt).default().sidePanel({attributes:[T.startsAt,T.endsAt,T.linkedRecords]}).tab("description","Description").richtext(T.description).titleAttribute(T.title).build()),Gu=P(G(So,"Meetings").for(pt).default().tab("workspace","Shared").default().icon("users").visibility("workspace").table().columns(...Io).sort(T.startsAt,"desc").tab("mine","My meetings").icon("lock").visibility("private").table().columns(...Io).sort(T.startsAt,"desc").build());function ke(e){return structuredClone(e)}a(ke,"cloneViewDefinition");var On=class On{constructor(){this.views=new Map;this.byObject=new Map;this.byObjectAndType=new Map;}register(t){let r=Array.isArray(t)?t:[t];for(let n of r)this.registerSingle(n);return this}registerSingle(t){let r$1=this.makeKey(t.object,t.name,t.type);if(this.views.has(r$1)){let l=`[ViewRegistry] Duplicate view: "${t.name}" (${t.type}) for object "${t.object}"`;throw new r("view",r$1,l)}let n=ke(t);this.views.set(r$1,n);let o=this.byObject.get(n.object)??[];o.push(n),this.byObject.set(n.object,o);let a=`${n.object}:${n.type}`,s=this.byObjectAndType.get(a)??[];s.push(n),this.byObjectAndType.set(a,s);}getByObjectName(t){return Array.from(this.byObject.get(t)??[],ke)}getByObjectNameAndType(t,r){return Array.from(this.byObjectAndType.get(`${t}:${r}`)??[],ke)}get(t,r,n){if(n){let a=this.views.get(this.makeKey(t,r,n));return a?ke(a):void 0}return this.getByObjectName(t).find(a=>a.name===r)}getOrThrow(t,r,n){let o=this.get(t,r,n);if(!o){let s=this.getByObjectName(t).map(p=>`${p.name} (${p.type})`).join(", ")||"(none)",l=`[ViewRegistry] View "${r}" not found for object "${t}".
58
+ {{ participants }}`).attribute(f({name:T.title,label:"Title"}).required()).attribute(he({name:T.description,label:"Description"})).attribute(f({name:T.location,label:"Location"})).attribute(U({name:T.startsAt,label:"Starts at"}).includeTime()).attribute(U({name:T.endsAt,label:"Ends at"}).includeTime()).attribute(go({name:T.isAllDay,label:"All day"})).attribute(q({name:T.status,label:"Status"}).options([{value:"confirmed",label:"Confirmed"},{value:"tentative",label:"Tentative"},{value:"cancelled",label:"Cancelled"}])).attribute(f({name:T.organizerAddress,label:"Organizer address"}).email()).attribute(f({name:T.organizerName,label:"Organizer"})).attribute(f({name:T.conferenceProvider,label:"Conference provider"})).attribute(f({name:T.conferenceJoinUrl,label:"Join link"}).url()).attribute(f({name:T.htmlLink,label:"Open in calendar"}).url()).attribute(f({name:T.participants,label:"Participants"}).multiline()).attribute(f({name:T.providerEventId,label:"Provider event id"}).hidden()).attribute(f({name:T.icalUid,label:"iCal UID"}).hidden()).attribute(f({name:T.recurringEventId,label:"Recurring event id"}).hidden()).attribute(f({name:T.connectionId,label:"Connection id"}).hidden()).attribute(q({name:T.recordingOverride,label:"Recording"}).options([{value:"force",label:"Force"},{value:"skip",label:"Skip"}]).hidden()).attribute(U({name:T.endedAnnouncedAt,label:"Ended announced at"}).includeTime().hidden()).attribute(Ae({name:T.linkedRecords,label:"Linked records"}).toAny().many().qualifyWith(f({name:"source",label:"Source"}).hidden())).build(),Gu=P(ee(Ro,"Meeting").for(pt).default().sidePanel({attributes:[T.startsAt,T.endsAt,T.linkedRecords]}).tab("description","Description").richtext(T.description).titleAttribute(T.title).build()),Wu=P(G(So,"Meetings").for(pt).default().tab("workspace","Shared").default().icon("users").visibility("workspace").table().columns(...Io).sort(T.startsAt,"desc").tab("mine","My meetings").icon("lock").visibility("private").table().columns(...Io).sort(T.startsAt,"desc").build());function ke(e){return structuredClone(e)}a(ke,"cloneViewDefinition");var On=class On{constructor(){this.views=new Map;this.byObject=new Map;this.byObjectAndType=new Map;}register(t){let r=Array.isArray(t)?t:[t];for(let n of r)this.registerSingle(n);return this}registerSingle(t){let r$1=this.makeKey(t.object,t.name,t.type);if(this.views.has(r$1)){let l=`[ViewRegistry] Duplicate view: "${t.name}" (${t.type}) for object "${t.object}"`;throw new r("view",r$1,l)}let n=ke(t);this.views.set(r$1,n);let o=this.byObject.get(n.object)??[];o.push(n),this.byObject.set(n.object,o);let a=`${n.object}:${n.type}`,s=this.byObjectAndType.get(a)??[];s.push(n),this.byObjectAndType.set(a,s);}getByObjectName(t){return Array.from(this.byObject.get(t)??[],ke)}getByObjectNameAndType(t,r){return Array.from(this.byObjectAndType.get(`${t}:${r}`)??[],ke)}get(t,r,n){if(n){let a=this.views.get(this.makeKey(t,r,n));return a?ke(a):void 0}return this.getByObjectName(t).find(a=>a.name===r)}getOrThrow(t,r,n){let o=this.get(t,r,n);if(!o){let s=this.getByObjectName(t).map(p=>`${p.name} (${p.type})`).join(", ")||"(none)",l=`[ViewRegistry] View "${r}" not found for object "${t}".
59
59
  Available views: ${s}`;throw new c$3("View",`${t}:${r}`,void 0,l)}return o}getAll(){return Array.from(this.views.values(),ke)}has(t,r,n){return n?this.views.has(this.makeKey(t,r,n)):this.getByObjectName(t).some(a=>a.name===r)}hasObject(t){return this.byObject.has(t)}get size(){return this.views.size}listObjectNames(){return Array.from(this.byObject.keys())}getDefault(t,r){let n=this.getByObjectNameAndType(t,r);return n.find(o=>o.default)??n[0]}clear(){this.views.clear(),this.byObject.clear(),this.byObjectAndType.clear();}summary(){let t=[];t.push(`[ViewRegistry] ${this.size} view(s) registered:`);for(let r of this.listObjectNames()){let o=this.getByObjectName(r).map(a=>{let s=[];a.default&&s.push("default");let l=s.length>0?` (${s.join(", ")})`:"";return `${a.name}:${a.type}${l}`});t.push(` ${r}: ${o.join(", ")}`);}return t.join(`
60
- `)}debug(t){let r=this.summary();return t?.(r),r}makeKey(t,r,n){return `${t}:${r}:${n}`}};a(On,"ViewRegistry");var kn=On,Wu=new kn;function Eo(e,t=[]){return e.filter(r=>!(!j(r).lifecycle.visibleInRuntime||r.system||t.includes(r.name)))}a(Eo,"getRuntimeAttributes");function Do(e){return [...e].sort((t,r)=>{let n=t.order??999,o=r.order??999;return n!==o?n-o:t.name.localeCompare(r.name)})}a(Do,"sortAttributes");function Ku(e){if(e.type==="text"&&e.multiline)return 12;switch(e.type){case "richtext":case "location":return 12;case "checkbox":return 4;default:return 6}}a(Ku,"getDefaultFieldSpan");function Yu(e){return {attribute:e.name,span:Ku(e)}}a(Yu,"attributeToField");function _n(e,t={}){let{includeActivityTab:r=true,includeDocumentsTab:n=true,excludeAttributes:o=[]}=t,a=Eo(e.attributes,o),p=[{id:"form",name:"form",label:"Details",type:"form",groups:[{id:"general",label:"General",type:"fields",fields:Do(a.filter(ae=>j(ae).presentation.formField)).map(Yu),order:0}],order:0}],I=1,X=e.attributes.some(ae=>ae.type==="document");n&&X&&p.push({id:"documents",name:"documents",label:"Documents",type:"documents",order:I++,allowUpload:true,allowRemove:true}),r&&p.push({id:"activity",name:"activity",label:"Activity",type:"activity",order:I++});let B={tabs:p};return {name:"default",label:"Default View",object:e.name,type:"detail",config:B,default:true}}a(_n,"generateDefaultDetailView");function Pn(e,t={}){let{excludeAttributes:r=[],maxListColumns:n=5}=t,o=Eo(e.attributes,r),l={tabs:[{id:"all",label:"All",default:true,visibility:"workspace",layout:"table",columns:Do(o.filter(p=>j(p).presentation.defaultColumn)).slice(0,n).map(p=>p.name)}]};return {name:"default",label:"All Records",object:e.name,type:"list",config:l,default:true}}a(Pn,"generateDefaultListView");function Hu(e,t){let{preserveCustomTabs:r=true,preserveTableTabs:n=true}=t,o=[];for(let a of e.config.tabs)r&&a.type==="custom"&&o.push(a),n&&a.type==="table"&&o.push(a);return o}a(Hu,"getPreservedDetailTabs");function Qu(e,t){if(t.length===0)return e;let r=e.find(s=>s.type==="form"),n=e.filter(s=>s.type!=="form"),o=[];r&&o.push(r);let a=1;for(let s of t)o.push({...s,order:a++});for(let s of n)o.push({...s,order:a++});return o}a(Qu,"mergeDetailTabs");function Ju(e,t,r){let{preserveMetadata:n=true,...o}=r,a=_n(t,o),s=Hu(e,r),l=Qu(a.config.tabs,s),p={...a.config,tabs:l},I={...a,config:p};return n&&(I.id=e.id,I.name=e.name,I.label=e.label,I.description=e.description,I.icon=e.icon),I}a(Ju,"resetDetailViewToDefault");function Xu(e,t,r){let{preserveMetadata:n=true,...o}=r,s={...Pn(t,o)};return n&&(s.id=e.id,s.name=e.name,s.label=e.label,s.description=e.description,s.icon=e.icon),s}a(Xu,"resetListViewToDefault");function Zu(e,t,r={}){if(Ke(e))return Ju(e,t,r);if(Hi(e))return Xu(e,t,r);throw new Error(`Reset not supported for view type: ${e.type}`)}a(Zu,"resetViewToDefault");function vT(e,t){if(t){let r=e.tabs.find(n=>n.id===t);if(r)return r}return e.tabs.find(r=>r.default)??e.tabs[0]}a(vT,"getActiveTab");function Fn(e){return structuredClone(e)}a(Fn,"cloneFormDefinition");var Vn=class Vn{constructor(){this.forms=new Map;}register(t){let r$1=Array.isArray(t)?t:[t];for(let n of r$1){if(this.forms.has(n.name))throw new r("form",n.name,`[FormRegistry] Duplicate form: "${n.name}"`);this.forms.set(n.name,Fn(n));}return this}get(t){let r=this.forms.get(t);return r?Fn(r):void 0}getAll(){return Array.from(this.forms.values(),Fn)}listNames(){return Array.from(this.forms.keys())}};a(Vn,"FormRegistry");var Oe=Vn;var Co=new Oe;function VT(e,t){return `${e}:${t}`}a(VT,"formatAgentStreamFrameId");function jT(e){let t=e.lastIndexOf(":");if(t<=0)return null;let r=e.slice(0,t),n=Number(e.slice(t+1));return !Number.isInteger(n)||n<=0?null:{streamId:r,sequence:n}}a(jT,"parseAgentStreamFrameId");var BT=204800,UT=256;function Ln(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a(Ln,"isRecord");function Mn(e,t){let r=Object.keys(e);return r.length===t.length&&r.every(n=>t.includes(n))}a(Mn,"hasExactKeys");function jn(e){return typeof e=="number"&&Number.isInteger(e)&&e>0}a(jn,"isPositiveInteger");function No(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0}a(No,"isNonNegativeInteger");function el(e){return Ln(e)&&Mn(e,["kind","startOffset","endOffset"])?(e.kind==="text"||e.kind==="reasoning")&&No(e.startOffset)&&No(e.endOffset)&&e.endOffset>=e.startOffset:false}a(el,"isContentRange");function tl(e){if(!Ln(e))return false;let t=e.content===void 0?["sequence","chunk"]:["sequence","content","chunk"];return Mn(e,t)&&jn(e.sequence)&&e.chunk!==void 0&&(e.content===void 0||el(e.content))}a(tl,"isBatchItem");function rl(e){try{return new TextEncoder().encode(JSON.stringify(e)).byteLength}catch{return}}a(rl,"encodedSize");function $T(e){if(!(Ln(e)&&Mn(e,["schemaVersion","batchId","tenantId","sessionId","streamId","sequenceStart","sequenceEnd","items"]))||e.schemaVersion!==1||typeof e.batchId!="string"||e.batchId.trim()===""||typeof e.tenantId!="string"||e.tenantId.trim()===""||typeof e.sessionId!="string"||e.sessionId.trim()===""||typeof e.streamId!="string"||e.streamId.trim()===""||!jn(e.sequenceStart)||!jn(e.sequenceEnd)||!Array.isArray(e.items)||e.items.length===0||e.items.length>256||!e.items.every(tl))return false;let t=0;for(let n of e.items){if(n.sequence<=t)return false;t=n.sequence;}if(e.items[0]?.sequence!==e.sequenceStart||e.items.at(-1)?.sequence!==e.sequenceEnd)return false;let r=rl(e);return r!==void 0&&r<=204800}a($T,"isAgentUIMessageBatch");function GT(e){switch(e.kind){case "workspace":return `workspace:${encodeURIComponent(e.tenantId)}`;case "object":return `object:${encodeURIComponent(e.objectId)}`;case "record":return `record:${encodeURIComponent(e.objectId)}:${encodeURIComponent(e.recordId)}`;case "view":return `view:${encodeURIComponent(e.viewId)}`;case "user":return `user:${encodeURIComponent(e.actorId)}`;case "conversation":return `conversation:${encodeURIComponent(e.sessionId)}`;case "architect-draft":return `architect-draft:${encodeURIComponent(e.actorId)}`}}a(GT,"liveChannelKey");function te(e){try{return decodeURIComponent(e)}catch{return null}}a(te,"decodeLiveChannelPart");function ko(e){let t=e.split(":");if(t[0]==="workspace"&&t.length===2&&t[1]){let r=te(t[1]);return r?{kind:"workspace",tenantId:r}:null}if(t[0]==="object"&&t.length===2&&t[1]){let r=te(t[1]);return r?{kind:"object",objectId:r}:null}if(t[0]==="record"&&t.length===3&&t[1]&&t[2]){let r=te(t[1]),n=te(t[2]);return r&&n?{kind:"record",objectId:r,recordId:n}:null}if(t[0]==="view"&&t.length===2&&t[1]){let r=te(t[1]);return r?{kind:"view",viewId:r}:null}if(t[0]==="user"&&t.length===2&&t[1]){let r=te(t[1]);return r?{kind:"user",actorId:r}:null}if(t[0]==="architect-draft"&&t.length===2&&t[1]){let r=te(t[1]);return r?{kind:"architect-draft",actorId:r}:null}if(t[0]==="conversation"&&t.length===2&&t[1]){let r=te(t[1]);return r?{kind:"conversation",sessionId:r}:null}return null}a(ko,"parseLiveChannelKey");var nl={"record.patch":true,"record.deleted":true,"record.removed":true,"record.created":true,"view.projection.stale":true,"agent.session.patch":true,"notification.created":true,"notification.recipient.patch":true,"notification.count.patch":true,"notification.inbox.archived":true,"reflex.state.changed":true,"reflex.run.completed":true,"reflex.authoring.progress":true,"architect.draft.updated":true,"meeting.recording.patch":true,"wallet.state":true,"channel.revoked":true},il=Object.keys(nl),ol=["membership-unknown","sort-unknown","permissions-changed"],al=["permission-revoked","workspace-left","object-deleted"],sl=["inboxState","workState","lockedAt","lockedByActorId","readAt","archivedAt","snoozedUntil","completedAt","dismissedAt","updatedAt"],ul=["type","objectId","recordId","recordVersion"],ll=["type","objectId","recordId","recordVersion","record"],dl=["id","objectId","visibility","ownedBy","label","values","metadata","createdAt","updatedAt","createdBy","lastUpdatedBy","schemaVersion"],cl=["type","targetActorId","archivedCount","version","updatedAt"];function pl(e){return typeof e=="string"&&il.includes(e)}a(pl,"isLiveEventType");function HT(e){return C(e)&&pl(e.type)?ml(e.type,e):false}a(HT,"isLiveEventPayload");function ml(e,t){if(!C(t))return false;switch(e){case "record.patch":return Tl(t);case "record.deleted":return wl(t);case "record.removed":return xl(t);case "record.created":return Sl(t);case "view.projection.stale":return vl(t);case "agent.session.patch":return Rl(t);case "notification.created":return Nl(t);case "notification.recipient.patch":return kl(t);case "notification.count.patch":return Ol(t);case "notification.inbox.archived":return _l(t);case "reflex.state.changed":return Ml(t);case "reflex.run.completed":return Bl(t);case "reflex.authoring.progress":return Ul(t);case "architect.draft.updated":return Ll(t);case "meeting.recording.patch":return ql(t);case "wallet.state":return Wl(t);case "channel.revoked":return Kl(t);default:return false}}a(ml,"isLiveEventPayloadForType");function C(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a(C,"isRecord");function F(e){return typeof e=="string"}a(F,"isString");function Oo(e){return F(e)&&e.length>0}a(Oo,"isNonEmptyString");function mt(e){return e===null||F(e)}a(mt,"isNullableString");function fl(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}a(fl,"isVersion");function W(e){if(!F(e))return false;let t=Date.parse(e);return Number.isFinite(t)&&new Date(t).toISOString()===e}a(W,"isIsoDateString");function we(e){return e===null||W(e)}a(we,"isNullableIsoDateString");function x(e,t){return F(e[t])}a(x,"hasString");function re(e,t){return Oo(e[t])}a(re,"hasNonEmptyString");function N(e,t){return fl(e[t])}a(N,"hasVersion");function k(e,t){return W(e[t])}a(k,"hasIsoDateString");function w(e,t,r){return !Object.hasOwn(e,t)||r(e[t])}a(w,"hasOptional");function ft(e,t){return Object.keys(e).every(r=>t.includes(r))}a(ft,"hasOnlyKeys");function O(e,t){return typeof e=="string"&&t.includes(e)}a(O,"isOneOf");function bl(e){return O(e,ki)}a(bl,"isNotificationKind");function gl(e){return O(e,Oi)}a(gl,"isNotificationPriority");function yl(e){return O(e,_i)}a(yl,"isNotificationSensitivity");function _o(e){return O(e,Pi)}a(_o,"isNotificationInboxState");function Po(e){return O(e,Fi)}a(Po,"isNotificationWorkState");function hl(e){return C(e)&&x(e,"type")&&x(e,"id")}a(hl,"isNotificationSubject");function Al(e){return C(e)&&x(e,"fieldKey")&&Object.hasOwn(e,"value")&&N(e,"version")}a(Al,"isRecordFieldPatch");function Tl(e){return e.type==="record.patch"&&x(e,"objectId")&&x(e,"recordId")&&N(e,"recordVersion")&&w(e,"label",F)&&w(e,"metadata",C)&&w(e,"fieldsWithheld",t=>t===true)&&Array.isArray(e.fieldPatches)&&e.fieldPatches.every(Al)&&x(e,"updatedAt")}a(Tl,"isRecordPatchPayload");function wl(e){return e.type==="record.deleted"&&x(e,"objectId")&&x(e,"recordId")&&N(e,"recordVersion")&&x(e,"deletedAt")}a(wl,"isRecordDeletedPayload");function xl(e){return e.type==="record.removed"&&ft(e,ul)&&x(e,"objectId")&&x(e,"recordId")&&N(e,"recordVersion")}a(xl,"isRecordRemovedPayload");function Il(e){return C(e)&&ft(e,dl)&&x(e,"id")&&x(e,"objectId")&&O(e.visibility,["workspace","private"])&&mt(e.ownedBy)&&(e.visibility==="workspace"&&e.ownedBy===null||e.visibility==="private"&&Oo(e.ownedBy))&&x(e,"label")&&C(e.values)&&w(e,"metadata",C)&&k(e,"createdAt")&&k(e,"updatedAt")&&w(e,"createdBy",F)&&w(e,"lastUpdatedBy",F)&&N(e,"schemaVersion")}a(Il,"isRecordLiveSnapshot");function Sl(e){return e.type==="record.created"&&ft(e,ll)&&x(e,"objectId")&&x(e,"recordId")&&N(e,"recordVersion")&&Il(e.record)&&e.record.id===e.recordId&&e.record.objectId===e.objectId}a(Sl,"isRecordCreatedPayload");function vl(e){return e.type==="view.projection.stale"&&x(e,"viewId")&&O(e.reason,ol)}a(vl,"isViewProjectionStalePayload");function Rl(e){return e.type==="agent.session.patch"&&x(e,"sessionId")&&C(e.patch)&&N(e,"version")&&x(e,"updatedAt")}a(Rl,"isAgentSessionPatchPayload");function El(e){return C(e)&&x(e,"id")&&x(e,"tenantId")&&w(e,"senderActorId",F)&&w(e,"rootActorId",F)&&w(e,"triggeredByActorId",F)&&bl(e.kind)&&x(e,"type")&&w(e,"subject",hl)&&x(e,"title")&&w(e,"summary",F)&&C(e.payload)&&gl(e.priority)&&yl(e.sensitivity)&&w(e,"threadKey",F)&&w(e,"idempotencyKey",F)&&w(e,"expiresAt",W)&&k(e,"createdAt")&&k(e,"updatedAt")}a(El,"isLiveNotification");function Dl(e){return C(e)&&x(e,"id")&&x(e,"tenantId")&&x(e,"notificationId")&&x(e,"recipientActorId")&&_o(e.inboxState)&&Po(e.workState)&&w(e,"lockedAt",W)&&w(e,"lockedByActorId",F)&&w(e,"readAt",W)&&w(e,"archivedAt",W)&&w(e,"snoozedUntil",W)&&w(e,"completedAt",W)&&w(e,"dismissedAt",W)&&k(e,"createdAt")&&k(e,"updatedAt")}a(Dl,"isLiveNotificationRecipient");function Cl(e){return C(e)?Object.keys(e).every(t=>sl.includes(t))&&w(e,"inboxState",_o)&&w(e,"workState",Po)&&w(e,"lockedAt",we)&&w(e,"lockedByActorId",mt)&&w(e,"readAt",we)&&w(e,"archivedAt",we)&&w(e,"snoozedUntil",we)&&w(e,"completedAt",we)&&w(e,"dismissedAt",we)&&w(e,"updatedAt",W):false}a(Cl,"isNotificationRecipientPatch");function Nl(e){let t=El(e.notification)?e.notification:null;return e.type==="notification.created"&&t!==null&&Array.isArray(e.recipients)&&e.recipients.length>0&&e.recipients.every(r=>Dl(r)&&r.notificationId===t.id)&&N(e,"version")&&k(e,"updatedAt")}a(Nl,"isNotificationCreatedPayload");function kl(e){return e.type==="notification.recipient.patch"&&x(e,"recipientId")&&x(e,"recipientActorId")&&Cl(e.patch)&&N(e,"version")&&k(e,"updatedAt")}a(kl,"isNotificationRecipientPatchPayload");function Ol(e){return e.type==="notification.count.patch"&&x(e,"targetActorId")&&N(e,"unread")&&N(e,"pendingWork")&&N(e,"version")&&k(e,"updatedAt")}a(Ol,"isNotificationCountPatchPayload");function _l(e){return e.type==="notification.inbox.archived"&&ft(e,cl)&&re(e,"targetActorId")&&N(e,"archivedCount")&&N(e,"version")&&k(e,"updatedAt")}a(_l,"isNotificationInboxArchivedPayload");var Pl=["armed","disarmed"],Fl=["authoring","compiling","replaying","promoted","failed"],Vl=["promoted","lkg"],jl=["composing","published","discarded"];function Ll(e){if(e.type!=="architect.draft.updated"||!C(e.draft))return false;let t=e.draft;return re(t,"id")&&re(t,"actorId")&&mt(t.agentSessionId)&&Array.isArray(t.operations)&&t.operations.every(C)&&C(t.baselines)&&O(t.status,jl)}a(Ll,"isArchitectDraftUpdatedPayload");function Ml(e){return e.type==="reflex.state.changed"&&re(e,"reflexId")&&O(e.state,Pl)&&k(e,"updatedAt")}a(Ml,"isReflexStateChangedPayload");function Bl(e){return e.type==="reflex.run.completed"&&re(e,"reflexId")&&re(e,"runId")&&O(e.served,Vl)&&N(e,"version")&&N(e,"wallMs")&&k(e,"completedAt")}a(Bl,"isReflexRunCompletedPayload");function Ul(e){return e.type==="reflex.authoring.progress"&&re(e,"reflexId")&&O(e.status,Fl)&&k(e,"updatedAt")}a(Ul,"isReflexAuthoringProgressPayload");var $l=["none","scheduled","recording","completed","failed"];function ql(e){return e.type==="meeting.recording.patch"&&re(e,"meetingId")&&O(e.status,$l)&&mt(e.failureReason)&&k(e,"updatedAt")}a(ql,"isMeetingRecordingPatchPayload");var zl=["ok","low","exhausted","paused"],Gl=["metering-only","contract","wallet"];function Wl(e){return e.type==="wallet.state"&&O(e.status,zl)&&O(e.mode,Gl)&&k(e,"updatedAt")}a(Wl,"isWalletStatePayload");function Kl(e){return e.type==="channel.revoked"&&x(e,"channel")&&O(e.reason,al)}a(Kl,"isChannelRevokedPayload");function Bn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a(Bn,"isRecord");function Yl(e){let{channel:t}=e;return typeof t=="string"&&ko(t)?t:null}a(Yl,"payloadChannel");function ZT(e){return Bn(e)?Yl(e):null}a(ZT,"getLiveProtocolPayloadChannel");function ew(e){return Bn(e)?typeof e.id=="string"&&e.id.length>0&&typeof e.channel=="string"&&typeof e.type=="string"&&typeof e.tenantId=="string"&&e.tenantId.length>0&&typeof e.occurredAt=="string"&&Bn(e.payload):false}a(ew,"isLiveEventEnvelope");var nw=["if","concat","sum","avg","count","min","max","earliest","latest","unique","first","percent_empty","percent_not_empty","count_empty","count_not_empty","count_unique"],_e={if:{name:"if",returnType:"branch",minArgs:3,maxArgs:3},concat:{name:"concat",returnType:{kind:"scalar",type:"text"},minArgs:1},sum:{name:"sum",returnType:{kind:"scalar",type:"number"},minArgs:1,maxArgs:1},avg:{name:"avg",returnType:{kind:"scalar",type:"number"},minArgs:1,maxArgs:1},count:{name:"count",returnType:{kind:"scalar",type:"number"},minArgs:1,maxArgs:1},min:{name:"min",returnType:"source_item",minArgs:1,maxArgs:1},max:{name:"max",returnType:"source_item",minArgs:1,maxArgs:1},earliest:{name:"earliest",returnType:{kind:"scalar",type:"date"},minArgs:1,maxArgs:1},latest:{name:"latest",returnType:{kind:"scalar",type:"date"},minArgs:1,maxArgs:1},unique:{name:"unique",returnType:"argument",minArgs:1,maxArgs:1},first:{name:"first",returnType:"source_item",minArgs:1,maxArgs:1},percent_empty:{name:"percent_empty",returnType:{kind:"scalar",type:"number"},minArgs:1,maxArgs:1},percent_not_empty:{name:"percent_not_empty",returnType:{kind:"scalar",type:"number"},minArgs:1,maxArgs:1},count_empty:{name:"count_empty",returnType:{kind:"scalar",type:"number"},minArgs:1,maxArgs:1},count_not_empty:{name:"count_not_empty",returnType:{kind:"scalar",type:"number"},minArgs:1,maxArgs:1},count_unique:{name:"count_unique",returnType:{kind:"scalar",type:"number"},minArgs:1,maxArgs:1}};function bt(e){return Object.hasOwn(_e,e)}a(bt,"isComputedFunctionName");var zn=class zn extends Error{constructor(t){super(t),this.name="ComputedFormulaCompileError";}};a(zn,"ComputedFormulaCompileError");var b=zn;function Bo(e){let t=Hl(e.expression),r=gt(t,e.schema),n=yd(r.valueType);if(n!==e.returnType)throw new b(`Computed formula "${e.attributeName}" returns "${n}", expected "${e.returnType}"`);if(Uo(e.returnType)&&r.optionsSource===void 0)throw new b(`Computed formula "${e.attributeName}" returns "${e.returnType}" without optionsSource`);let o=r.optionsSource===void 0?[]:[{kind:"options",source:r.optionsSource}],a=qn([...r.dependencies,...o]);return {kind:"formula",attributeName:e.attributeName,expression:e.expression,returnType:e.returnType,valueType:r.valueType,dependencies:a,ast:t,...r.optionsSource?{optionsSource:r.optionsSource}:{},...r.targetAttributeType?{targetAttributeType:r.targetAttributeType}:{},dependenciesHash:hd({expression:e.expression,returnType:e.returnType,dependencies:a})}}a(Bo,"compileComputedFormula");function uw(e){let t=new Map(e.map(o=>[o.attributeName,o])),r=new Set,n=a((o,a)=>{let s=a.indexOf(o);if(s!==-1){let I=[...a.slice(s),o];throw new b(`Computed field cycle detected: ${I.join(" -> ")}`)}if(r.has(o))return;let l=t.get(o);if(l===void 0)return;let p=[...a,o];for(let I of l.dependencies)I.kind==="computed"&&n(I.attributeName,p);r.add(o);},"visit");for(let o of e)n(o.attributeName,[]);}a(uw,"assertAcyclicComputedDependencies");function Hl(e){try{return e$1(e)}catch(t){throw t instanceof Error?new b(t.message):t}}a(Hl,"parseCompileFormula");function gt(e,t){switch(e.kind){case "literal":return {valueType:Ql(e.value),dependencies:[],...typeof e.value=="string"?{literalString:e.value}:{}};case "path":return Jl(e.parts,t);case "call":return nd(e.functionName,e.args,t);case "binary":return ud(e.operator,gt(e.left,t),gt(e.right,t));default:return e}}a(gt,"inferNode");function Ql(e){switch(typeof e){case "string":return {kind:"scalar",type:"text"};case "number":return {kind:"scalar",type:"number"};case "boolean":return {kind:"scalar",type:"boolean"};case "object":return {kind:"scalar",type:"text"};default:return e}}a(Ql,"literalToValueType");function Jl(e,t){if(e.length===1){let r=e[0],n=Un(t,r);if(n===void 0)throw new b(`Unknown attribute "${r}" on object "${t.objectName}"`);return n.type==="relation"?{valueType:ed(),dependencies:[{kind:"relation",relationName:n.name,cardinality:Fo(n)}],targetAttributeType:n.type}:{valueType:Vo(n),dependencies:[Zl(n)],optionsSource:jo(t.objectName,n),targetAttributeType:n.type}}if(e.length===2){let[r,n]=e,o=Un(t,r);if(o===void 0)throw new b(`Unknown attribute "${r}" on object "${t.objectName}"`);if(o.type!=="relation")throw new b(`Attribute "${r}" on object "${t.objectName}" is not a relation`);let a=Xl(o);if(a===void 0)throw new b(`Relation "${r}" on object "${t.objectName}" is missing targetObjectName`);let s=t.relatedObjects?.[a];if(s===void 0)throw new b(`Unknown related object "${a}"`);let l=Un(s,n);if(l===void 0)throw new b(`Unknown attribute "${n}" on object "${s.objectName}"`);let p=Vo(l);return {valueType:o.cardinality==="many"?rd(p):p,dependencies:[{kind:"relation",relationName:r,targetAttributeName:n,cardinality:Fo(o)}],optionsSource:jo(s.objectName,l),targetAttributeType:l.type}}throw new b("Computed paths support at most one relation hop")}a(Jl,"inferPath");function Un(e,t){return e.attributes.find(r=>r.name===t)}a(Un,"findAttribute");function Xl(e){if(e.targetObjectName!==void 0)return e.targetObjectName;if(e.targets?.length===1){let[t]=e.targets;return t?.object==="*"?void 0:t?.object}}a(Xl,"getRelationTargetObjectName");function Fo(e){return e.cardinality??"one"}a(Fo,"relationCardinality");function Zl(e){return e.type==="formula"||e.type==="rollup"?{kind:"computed",attributeName:e.name}:{kind:"local",attributeName:e.name}}a(Zl,"localDependencyFor");function Vo(e){if(e.type==="formula"||e.type==="rollup"){if(e.returnType===void 0)throw new b(`Computed attribute "${e.name}" is missing returnType`);return td(e.returnType)}switch(e.type){case "number":case "currency":return {kind:"scalar",type:"number"};case "checkbox":return {kind:"scalar",type:"boolean"};case "date":return {kind:"scalar",type:"date"};case "select":case "status":return {kind:"scalar",type:"select"};case "multiselect":return {kind:"collection",itemType:"select"};case "text":case "richtext":case "phone":case "user":case "location":case "relation":case "document":return {kind:"scalar",type:"text"};default:return e.type}}a(Vo,"attributeToValueType");function ed(){return {kind:"collection",itemType:"text"}}a(ed,"relationToValueType");function td(e){return e==="multiselect"?{kind:"collection",itemType:"select"}:{kind:"scalar",type:e}}a(td,"returnTypeToValueType");function rd(e){return e.kind==="collection"?e:{kind:"collection",itemType:e.type}}a(rd,"asCollectionValueType");function jo(e,t){if(t.type==="formula"||t.type==="rollup")return Uo(t.returnType)?t.optionsSource:void 0;if(!(t.type!=="select"&&t.type!=="status"&&t.type!=="multiselect"))return t.optionsSource??{objectName:e,attributeName:t.name,...t.id?{attributeId:t.id}:{}}}a(jo,"optionsSourceForAttribute");function nd(e,t,r){if(!bt(e))throw new b(`Unknown computed function "${e}"`);let n=_e[e];if(t.length<n.minArgs||n.maxArgs!==void 0&&t.length>n.maxArgs){let a=n.maxArgs===void 0||n.maxArgs===n.minArgs?String(n.minArgs):`${n.minArgs}-${n.maxArgs}`;throw new b(`Function "${e}" expects ${a} arguments, received ${t.length}`)}let o=t.map(a=>gt(a,r));return id(e,o)}a(nd,"inferCall");function id(e,t){let r=qn(t.flatMap(n=>n.dependencies));switch(e){case "if":return od(t,r);case "concat":return ld(t,`Function "${e}" does not accept collection values`),{valueType:{kind:"scalar",type:"text"},dependencies:r};case "sum":case "avg":return Lo(e,t[0],"number"),{valueType:{kind:"scalar",type:"number"},dependencies:r};case "count":case "count_empty":case "count_not_empty":case "count_unique":case "percent_empty":case "percent_not_empty":return cd(e,t[0]),{valueType:{kind:"scalar",type:"number"},dependencies:r};case "min":case "max":return dd(e,t[0]),{valueType:pd(t[0]),dependencies:r,optionsSource:t[0].optionsSource,targetAttributeType:t[0].targetAttributeType};case "earliest":case "latest":return Lo(e,t[0],"date"),{valueType:{kind:"scalar",type:"date"},dependencies:r,targetAttributeType:t[0].targetAttributeType};case "unique":return ad(t[0],r);case "first":return sd(t[0],r);default:return e}}a(id,"inferFunctionReturn");function od(e,t){$n(e[0].valueType,"boolean",'Function "if" condition must be boolean');let r=e[1],n=e[2],o=fd(r,n),a=bd(r,n);if(o===void 0)throw new b('Function "if" branches must return the same type');return {valueType:o,dependencies:t,...a?{optionsSource:a}:{},targetAttributeType:r.targetAttributeType??n.targetAttributeType}}a(od,"inferIfFunction");function ad(e,t){if(e.valueType.kind!=="collection"||e.valueType.itemType!=="select")throw new b('Function "unique" expects a select collection');return {valueType:{kind:"collection",itemType:"select"},dependencies:t,optionsSource:e.optionsSource,targetAttributeType:e.targetAttributeType}}a(ad,"inferUniqueFunction");function sd(e,t){if(e.valueType.kind!=="collection")throw new b('Function "first" expects a collection');return {valueType:{kind:"scalar",type:e.valueType.itemType},dependencies:t,optionsSource:e.optionsSource,targetAttributeType:e.targetAttributeType}}a(sd,"inferFirstFunction");function ud(e,t,r){let n=qn([...t.dependencies,...r.dependencies]),o=e==="+"||e==="-"||e==="*"||e==="/";if(t.valueType.kind==="collection"||r.valueType.kind==="collection")throw new b(`Cannot use collection values with ${o?"arithmetic":"comparison"} operator "${e}"`);if(o)return e==="+"&&(t.valueType.type==="text"||r.valueType.type==="text")?{valueType:{kind:"scalar",type:"text"},dependencies:n}:($n(t.valueType,"number",`Operator "${e}" expects number operands`),$n(r.valueType,"number",`Operator "${e}" expects number operands`),{valueType:{kind:"scalar",type:"number"},dependencies:n});if(e==="=="||e==="!="){if(t.valueType.type!==r.valueType.type)throw new b(`Operator "${e}" expects operands with the same scalar type`);return {valueType:{kind:"scalar",type:"boolean"},dependencies:n}}if((t.valueType.type!=="number"||r.valueType.type!=="number")&&(t.valueType.type!=="date"||r.valueType.type!=="date"))throw new b(`Operator "${e}" expects number or date operands of the same type`);return {valueType:{kind:"scalar",type:"boolean"},dependencies:n}}a(ud,"inferBinary");function ld(e,t){for(let r of e)if(r.valueType.kind==="collection")throw new b(t)}a(ld,"ensureNoCollections");function Lo(e,t,r){if((t.valueType.kind==="collection"?t.valueType.itemType:t.valueType.type)!==r)throw new b(`Function "${e}" expects ${r} values`)}a(Lo,"ensureCollectionOrScalarType");function dd(e,t){if(t.valueType.kind!=="collection")throw new b(`Function "${e}" expects a collection`);let r=t.valueType.itemType;if(r!=="number"&&r!=="date")throw new b(`Function "${e}" expects number or date values`)}a(dd,"ensureMinMaxSource");function cd(e,t){if(t.valueType.kind!=="collection")throw new b(`Function "${e}" expects a collection`)}a(cd,"ensureCollectionSource");function $n(e,t,r){if(e.kind!=="scalar"||e.type!==t)throw new b(r)}a($n,"ensureScalarType");function pd(e){return e.valueType.kind==="scalar"?e.valueType:{kind:"scalar",type:e.valueType.itemType}}a(pd,"sourceItemValueType");function md(e,t){return e.kind==="scalar"?t.kind==="scalar"&&e.type===t.type:t.kind==="collection"&&e.itemType===t.itemType}a(md,"sameValueType");function fd(e,t){if(md(e.valueType,t.valueType)||Mo(e,t))return e.valueType;if(Mo(t,e))return t.valueType}a(fd,"resolveIfBranchValueType");function Mo(e,t){return e.valueType.kind==="scalar"&&e.valueType.type==="select"&&t.valueType.kind==="scalar"&&t.valueType.type==="text"&&t.literalString!==void 0}a(Mo,"isSelectScalarWithStringLiteral");function bd(e,t){let r=e.optionsSource,n=t.optionsSource;if(r!==void 0&&n!==void 0&&!gd(r,n))throw new b('Function "if" branches use incompatible options sources');return r??n}a(bd,"resolveIfOptionsSource");function gd(e,t){return e.objectName===t.objectName&&e.attributeName===t.attributeName&&e.attributeId===t.attributeId}a(gd,"sameOptionsSource");function Uo(e){return e==="select"||e==="multiselect"}a(Uo,"isSelectLikeReturnType");function yd(e){if(e.kind==="scalar")return e.type;if(e.itemType==="select")return "multiselect";throw new b(`Collection item type "${e.itemType}" cannot be used as a computed return type`)}a(yd,"valueTypeToReturnType");function qn(e){let t=new Set,r=[];for(let n of e){let o=JSON.stringify(Pe(n));t.has(o)||(t.add(o),r.push(n));}return r}a(qn,"uniqueDependencies");function hd(e){let t=e.dependencies.map(r=>Pe(r)).sort((r,n)=>$o(JSON.stringify(r),JSON.stringify(n)));return JSON.stringify(Pe({expression:e.expression,returnType:e.returnType,dependencies:t}))}a(hd,"createDependenciesHash");function Pe(e){return Array.isArray(e)?e.map(t=>Pe(t)):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0).sort(([t],[r])=>$o(t,r)).map(([t,r])=>[t,Pe(r)])):e}a(Pe,"stableNormalize");function $o(e,t){return e<t?-1:e>t?1:0}a($o,"compareStrings");function Ad(e){return e.function==="count"?`count(${e.relationAttribute})`:`${xd(e.function)}(${e.relationAttribute}.${e.targetAttribute})`}a(Ad,"rollupToFormulaExpression");function Td(e,t){if(e.function==="count")return "number";let r=Id(e,t);switch(e.function){case "countValues":case "countEmpty":case "percentEmpty":case "percentNotEmpty":case "countUniqueValues":return "number";case "sum":case "avg":return "number";case "earliest":case "latest":return "date";case "original":if(!vd(r.type))throw new b('Rollup "original" requires a select, status, or multiselect target');return "multiselect";default:return e.function}}a(Td,"inferRollupReturnType");function pw(e,t){let r=Ad(e),n=Td(e,t);return {...Bo({attributeName:e.name,expression:r,returnType:n,schema:wd(e,t)}),kind:"rollup"}}a(pw,"compileRollupAttribute");function wd(e,t){return {...t,attributes:t.attributes.map(r=>r.name===e.relationAttribute&&r.type==="relation"?{...r,cardinality:"many"}:r)}}a(wd,"schemaWithRollupRelationAsMany");function xd(e){switch(e){case "sum":case "avg":case "earliest":case "latest":return e;case "original":return "unique";case "countValues":return "count_not_empty";case "countEmpty":return "count_empty";case "percentEmpty":return "percent_empty";case "percentNotEmpty":return "percent_not_empty";case "countUniqueValues":return "count_unique";default:return e}}a(xd,"rollupFunctionToFormulaFunction");function Id(e,t){let r=qo(t,e.relationAttribute);if(r===void 0)throw new b(`Unknown relation attribute "${e.relationAttribute}" on object "${t.objectName}"`);if(r.type!=="relation")throw new b(`Attribute "${e.relationAttribute}" on object "${t.objectName}" is not a relation`);let n=Sd(r);if(n===void 0)throw new b(`Relation "${e.relationAttribute}" on object "${t.objectName}" is missing targetObjectName`);let o=t.relatedObjects?.[n];if(o===void 0)throw new b(`Unknown related object "${n}"`);let a=qo(o,e.targetAttribute);if(a===void 0)throw new b(`Unknown attribute "${e.targetAttribute}" on object "${o.objectName}"`);return a}a(Id,"findRollupTargetAttribute");function qo(e,t){return e.attributes.find(r=>r.name===t)}a(qo,"findAttribute");function Sd(e){if(e.targetObjectName!==void 0)return e.targetObjectName;if(e.targets?.length===1){let[t]=e.targets;return t?.object==="*"?void 0:t?.object}}a(Sd,"getRelationTargetObjectName");function vd(e){return e==="select"||e==="status"||e==="multiselect"}a(vd,"isSelectLikeAttributeType");function J(e,t){switch(e.kind){case "literal":return e.value;case "path":return Ed(t,e.parts);case "binary":return Dd(e.operator,J(e.left,t),J(e.right,t));case "call":return Rd(e.functionName,e.args,t);default:return e}}a(J,"evaluateAst");function Rd(e,t,r){if(Nd(e),kd(e,t.length),e==="if"){let n=J(t[0],r);return n===null?null:J(n?t[1]:t[2],r)}return Od(e,t.map(n=>J(n,r)))}a(Rd,"evaluateCallNode");function Ed(e,t){return t.reduce((r,n)=>Ho(r,n),e)}a(Ed,"resolvePath");function Ho(e,t){if(Array.isArray(e))return e.map(n=>Ho(n,t));if(!Yo(e))return null;if(Object.hasOwn(e,t))return e[t]??null;let r=e.values;return Yo(r)&&Object.hasOwn(r,t)?r[t]??null:null}a(Ho,"resolvePathPart");function Dd(e,t,r){switch(e){case "+":return Cd(t,r);case "-":return ht(t,r,(n,o)=>n-o);case "*":return ht(t,r,(n,o)=>n*o);case "/":return ht(t,r,(n,o)=>n/o);case ">":return yt(t,r,n=>n>0);case "<":return yt(t,r,n=>n<0);case ">=":return yt(t,r,n=>n>=0);case "<=":return yt(t,r,n=>n<=0);case "==":return zo(t,r);case "!=":{let n=zo(t,r);return n===null?null:!n}default:return e}}a(Dd,"evaluateBinary");function Cd(e,t){return typeof e=="string"||typeof t=="string"?`${e??""}${t??""}`:ht(e,t,(r,n)=>r+n)}a(Cd,"add");function yt(e,t,r){let n=Qo(e,t);return n===null?null:r(n)}a(yt,"compareWith");function Qo(e,t){if(!xe([e,t]))return null;let r=Ie(e),n=Ie(t);if(r!==null&&n!==null)return r-n;let o=Kn(e),a=Kn(t);return o&&a?o.getTime()-a.getTime():null}a(Qo,"compare");function zo(e,t){return e===t?true:e==null||t===null||t===void 0?false:xe([e,t])?Qo(e,t)===0:null}a(zo,"equalScalar");function Nd(e){if(!bt(e))throw new Error(`Unknown computed function "${e}"`)}a(Nd,"assertComputedFunctionName");function kd(e,t){let{minArgs:r,maxArgs:n}=_e[e];if(t>=r&&t<=(n??Number.POSITIVE_INFINITY))return;let o=n===void 0?`at least ${r}`:`between ${r} and ${n}`;throw new Error(`Function "${e}" expects ${o} arguments, received ${t}`)}a(kd,"validateArity");function Od(e,t){switch(e){case "concat":return t.filter(r=>r!=null).map(String).join("");case "sum":return xe(t)?Gn(t).reduce((r,n)=>r+n,0):null;case "avg":{if(!xe(t))return null;let r=Gn(t);return r.length>0?r.reduce((n,o)=>n+o,0)/r.length:null}case "count":return de(t[0]).length;case "min":return Go(t,"min");case "max":return Go(t,"max");case "earliest":return Wn(t,"min");case "latest":return Wn(t,"max");case "unique":return Ko(de(t[0]));case "first":return de(t[0]).find(r=>r!=null)??null;case "percent_empty":return Wo(t[0],true);case "percent_not_empty":return Wo(t[0],false);case "count_empty":return de(t[0]).filter(a$1).length;case "count_not_empty":return de(t[0]).filter(r=>!a$1(r)).length;case "count_unique":return Ko(de(t[0])).length;default:return e}}a(Od,"evaluateCall");function Gn(e){return At(e).map(Ie).filter(t=>t!==null)}a(Gn,"numericValues");function xe(e){let t=new Set;for(let r of At(e))Yn(r)&&t.add(Jo(r));return t.size<=1}a(xe,"areCommensurable");function Jo(e){return e.code.toUpperCase()}a(Jo,"currencyCode");function ht(e,t,r){if(!xe([e,t]))return null;let n=Ie(e),o=Ie(t);if(n===null||o===null)return null;let a=r(n,o);return Number.isFinite(a)?a:null}a(ht,"numericBinary");function Go(e,t){if(!xe(e))return null;let r=Gn(e);return r.length>0?t==="min"?Math.min(...r):Math.max(...r):Wn(e,t)}a(Go,"minMax");function Wn(e,t){let r=At(e).map(Kn).filter(a=>a!==null);if(r.length===0)return null;let n=r.map(a=>a.getTime()),o=t==="min"?Math.min(...n):Math.max(...n);return new Date(o).toISOString()}a(Wn,"dateMinMax");function Wo(e,t){let r=de(e);return r.length===0?0:r.filter(o=>a$1(o)===t).length/r.length}a(Wo,"percentByEmptyState");function Ko(e){let t=new Set,r=[];for(let n of e){if(a$1(n))continue;let o=_d(n);t.has(o)||(t.add(o),r.push(n));}return r}a(Ko,"uniqueNonEmpty");function de(e){return e==null?[]:Array.isArray(e)?At(e):[e]}a(de,"collectionItems");function At(e){return e.flat(Number.POSITIVE_INFINITY)}a(At,"flatten");function Ie(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){let t=Number(e);return Number.isFinite(t)?t:null}return Yn(e)&&Number.isFinite(e.value)?e.value:null}a(Ie,"toFiniteNumber");function Yn(e){return typeof e=="object"&&e!==null&&typeof e.value=="number"&&typeof e.code=="string"}a(Yn,"isCurrencyValue");function Kn(e){if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;if(typeof e!="string"){let r=fe(e);if(r===null)return null;let n=new Date(r);return Number.isNaN(n.getTime())?null:n}let t=new Date(e);return Number.isNaN(t.getTime())?null:t}a(Kn,"toDate");function _d(e){if(Yn(e))return `currency:${Jo(e)}:${e.value}`;let t=Ie(e);return t!==null?`number:${t}`:e instanceof Date?`date:${e.toISOString()}`:`${typeof e}:${JSON.stringify(e)}`}a(_d,"uniqueKey");function Yo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a(Yo,"isPlainRecord");function Pd(e,t,r){if(e==null)return null;let n=a(o=>typeof o=="string"||typeof o=="number"||typeof o=="boolean"||o instanceof Date?String(o):null,"stringifyScalar");switch(t){case "number":{let o=typeof e=="number"?e:Number(e);return Number.isNaN(o)?null:r!==void 0?Number(o.toFixed(r)):o}case "boolean":return !!e;case "date":return e instanceof Date?e.toISOString():typeof e=="string"?e:null;case "text":return String(e);case "select":if(Array.isArray(e)){for(let o of e){if(o==null)continue;let a=n(o);if(a!==null)return a}return null}return n(e);case "multiselect":return Array.isArray(e)?e.flatMap(o=>{if(o==null)return [];let a=n(o);return a===null?[]:[a]}):n(e)===null?[]:[String(e)];default:{let o=t;throw new Error(`Unsupported computed return type: ${o}`)}}}a(Pd,"formatComputedResult");function Aw(e,t){return J(e,t)}a(Aw,"evaluateComputedAst");function Tw(e,t){return J(e$1(e),t)}a(Tw,"evaluateComputedFormula");function ww(e,t,r,n){try{let o=J(e$1(e),t);return {value:r?Pd(o,r,n):o}}catch(o){return {value:null,error:o instanceof Error?o.message:String(o)}}}a(ww,"evaluateComputedFormulaWithResult");var Sw=[{name:"if",signature:"if(condition, then, else)",description:"Conditional value",category:"logic",example:"if(amount > 100, 'big', 'small')"},{name:"concat",signature:"concat(a, b, ...)",description:"Join values into text",category:"text",example:"concat(firstName, ' ', lastName)"},{name:"sum",signature:"sum(collection)",description:"Total of values",category:"number",example:"sum(orders.amount)"},{name:"avg",signature:"avg(collection)",description:"Average of values",category:"number",example:"avg(orders.amount)"},{name:"min",signature:"min(collection)",description:"Smallest value",category:"number",example:"min(orders.amount)"},{name:"max",signature:"max(collection)",description:"Largest value",category:"number",example:"max(orders.amount)"},{name:"count",signature:"count(collection)",description:"Number of items",category:"collection",example:"count(orders)"},{name:"count_empty",signature:"count_empty(collection)",description:"Items with no value",category:"collection",example:"count_empty(orders.note)"},{name:"count_not_empty",signature:"count_not_empty(collection)",description:"Items with a value",category:"collection",example:"count_not_empty(orders.note)"},{name:"count_unique",signature:"count_unique(collection)",description:"Distinct values",category:"collection",example:"count_unique(orders.status)"},{name:"percent_empty",signature:"percent_empty(collection)",description:"Fraction with no value",category:"collection",example:"percent_empty(orders.note)"},{name:"percent_not_empty",signature:"percent_not_empty(collection)",description:"Fraction with a value",category:"collection",example:"percent_not_empty(orders.note)"},{name:"unique",signature:"unique(collection)",description:"Distinct values as a list",category:"collection",example:"unique(orders.status)"},{name:"first",signature:"first(collection)",description:"First non-empty value",category:"collection",example:"first(orders.status)"},{name:"earliest",signature:"earliest(collection)",description:"Earliest date",category:"date",example:"earliest(orders.closeDate)"},{name:"latest",signature:"latest(collection)",description:"Latest date",category:"date",example:"latest(orders.closeDate)"}];var Xo=a(e=>a$1(e)||Array.isArray(e)&&e.length===0,"isEmpty"),V=a(e=>e==null?"":String(e),"toStr"),xt=a(e=>{if(a$1(e))return null;let t=typeof e=="number"?e:Number(e);return Number.isFinite(t)?t:null},"toNum"),It=a(e=>{if(e==null)return null;let t=e instanceof Date?e:new Date(String(e));return Number.isNaN(t.getTime())?null:t},"toDate"),Tt=a(e=>Array.isArray(e)?e:e==null?[]:[e],"toArr"),Fd=a((e,t,r)=>{let n=xt(e),o=xt(t);return n!==null&&o!==null&&r(n,o)},"compareNumbers"),Vd=a((e,t,r)=>{let n=It(e),o=It(t);return n!==null&&o!==null&&r(n.getTime(),o.getTime())},"compareDates"),Zo=a((e,t,r)=>{if(r.type==="number"||r.type==="currency"){let n=xt(e),o=xt(t);if(n!==null&&o!==null)return n===o}return V(e)===V(t)},"equalsForAttr");function Dw(e,t){return e?e==="checkbox":typeof t=="boolean"}a(Dw,"isCheckboxEquality");var wt=a(e=>({appliesTo:["number","currency","date","formula"],evaluateInMemory:a((t,r,n)=>n.type==="date"?Vd(t,r,e):Fd(t,r,e),"evaluateInMemory")}),"orderingSpec"),St={is:{appliesTo:["text","phone","number","currency","checkbox","status","select","date","user","relation","formula"],evaluateInMemory:a((e,t,r)=>r.type==="checkbox"?e===true==(t===true):Zo(e,t,r),"evaluateInMemory")},is_not:{appliesTo:["text","phone","number","currency","status","select","date","user","relation","formula"],evaluateInMemory:a((e,t,r)=>!Zo(e,t,r),"evaluateInMemory")},contains:{appliesTo:["text","phone","formula"],evaluateInMemory:a((e,t)=>V(e).toLowerCase().includes(V(t).toLowerCase()),"evaluateInMemory")},not_contains:{appliesTo:["text","phone","formula"],evaluateInMemory:a((e,t)=>!V(e).toLowerCase().includes(V(t).toLowerCase()),"evaluateInMemory")},starts_with:{appliesTo:["text","phone"],evaluateInMemory:a((e,t)=>V(e).toLowerCase().startsWith(V(t).toLowerCase()),"evaluateInMemory")},ends_with:{appliesTo:["text"],evaluateInMemory:a((e,t)=>V(e).toLowerCase().endsWith(V(t).toLowerCase()),"evaluateInMemory")},is_empty:{appliesTo:["text","richtext","number","phone","currency","status","select","date","multiselect","location","user","relation","formula","document"],evaluateInMemory:a(e=>Xo(e),"evaluateInMemory")},is_not_empty:{appliesTo:["text","richtext","number","phone","currency","status","select","date","multiselect","location","user","relation","formula","document"],evaluateInMemory:a(e=>!Xo(e),"evaluateInMemory")},less_than:wt((e,t)=>e<t),greater_than:wt((e,t)=>e>t),less_or_equal:wt((e,t)=>e<=t),greater_or_equal:wt((e,t)=>e>=t),is_within:{appliesTo:["date"],evaluateInMemory:a((e,t)=>{let r=It(e),n=Q$1(t);return r&&n?r.getTime()>=n.startMs&&r.getTime()<n.endMs:false},"evaluateInMemory")},on_day_month:{appliesTo:["date"],evaluateInMemory:a((e,t)=>{let r=It(e);if(!r)return false;let n=t;return r.getMonth()+1===n.month&&r.getDate()===n.day},"evaluateInMemory")},any_of:{appliesTo:["status","select","multiselect","user","relation"],evaluateInMemory:a((e,t)=>{let r=Tt(t).map(V);return Tt(e).map(V).some(o=>r.includes(o))},"evaluateInMemory")},none_of:{appliesTo:["status","select","multiselect","user","relation"],evaluateInMemory:a((e,t)=>{let r=Tt(t).map(V);return !Tt(e).map(V).some(o=>r.includes(o))},"evaluateInMemory")}};var jd=a((e,t)=>({id:`system:${e}`,name:e,label:e,type:t,system:true}),"systemAttribute"),Ld=[...Object.entries(T$1).map(([e,t])=>jd(e,t))];function Mw(e,t,r){let n=t;return Md(e,{...t.values,id:t.id,objectId:t.objectId,objectName:n.objectName,tenantId:n.tenantId,label:t.label,createdAt:t.createdAt,updatedAt:t.updatedAt,createdBy:t.createdBy,lastUpdatedBy:t.lastUpdatedBy,deletedAt:t.deletedAt,deletedBy:t.deletedBy,visibility:t.visibility,ownedBy:t.ownedBy},[...r,...Ld])}a(Mw,"evaluateRecordFilterState");function Md(e,t,r){if(e.rules.length===0)return true;let n=new Map(r.map(a=>[a.name,a])),o=e.combinator==="or"?"some":"every";return e.rules[o](a=>Bd(a,t,n))}a(Md,"evaluateFilterState");function Bd(e,t,r){let n=r.get(e.attribute);if(!n)return false;if(e.property&&n.type==="location"){if(!(g(e.property)&&h$1(e.operator)))return false;let l=St[e.operator];if(!l)return false;let p=t[e.attribute],I=typeof p=="object"&&p!==null?p[e.property]:void 0;return Hn(l,"text",e.operator,I,e.value,n)}if(e.property){let l=Yi(n).find(j=>j.name===e.property);if(!l)return false;let p=I(e.operator),I$1=St[p];if(!I$1?.appliesTo.includes(l.type))return false;let X=t[e.attribute],ae=(Array.isArray(X)?X:X==null?[]:[X]).some(j=>{if(typeof j!="object"||j===null)return false;let Y=j.props;return typeof Y!="object"||Y===null?false:Hn(I$1,l.type,p,Y[e.property],e.value,l)});return (e.quantifier??H(e.operator))==="none"?!ae:ae}let o=St[e.operator];if(!o||!o.appliesTo.includes(n.type))return false;let a=t[e.attribute],s=n.type==="relation"||n.type==="document"||n.type==="user"?qd(a):a;return Hn(o,n.type,e.operator,s,e.value,n)}a(Bd,"evaluateRule");function Hn(e,t,r,n,o,a){let[s,l]=Ud(t,r,n,o);return t==="phone"&&l===""&&r==="contains"?false:t==="phone"&&l===""&&r==="not_contains"?true:e.evaluateInMemory(s,l,a)}a(Hn,"evaluateNormalizedComparands");function Ud(e,t,r,n){return e==="date"&&(t==="is"||t==="is_not")?[ea(r),ea(n)]:e==="phone"?$d(r,n):[ta(e,r),ta(e,n)]}a(Ud,"normalizeOperatorComparands");function ea(e){let t=Z(e)?fe(e):e;if(t instanceof Date)return Number.isNaN(t.getTime())?null:t.toISOString().slice(0,10);if(typeof t!="string"||t==="")return null;if(/^\d{4}-\d{2}-\d{2}$/.test(t))return t;let r=new Date(t);return Number.isNaN(r.getTime())?null:r.toISOString().slice(0,10)}a(ea,"normalizeUtcCalendarDay");function $d(e,t){let r=typeof t=="object"&&t!==null?t:{},n=typeof r.countryCode=="string"?r.countryCode:void 0,o=a(a=>{let s=typeof a=="object"&&a!==null?a:{phoneNumber:a};if(typeof s.phoneNumber!="string")return null;if(!n)return a$3(s.phoneNumber);let l=typeof s.countryCode=="string"?s.countryCode:n;return `${l}:${b$2(s.phoneNumber,l)}`},"normalizeOne");return [o(e),o(t)]}a($d,"normalizePhoneComparands");function ta(e,t){return e==="currency"?F$1(t):e==="date"?Z(t)?fe(t):t instanceof Date?Number.isNaN(t.getTime())?null:t.toISOString():t:t}a(ta,"normalizeComparableValue");function qd(e){let t=a(r=>typeof r!="object"||r===null?r:r.id,"normalizeOne");return Array.isArray(e)?e.map(t):t(e)}a(qd,"normalizeReferenceIds");var ra="today";function vt(e,t){return new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).format(e)}a(vt,"dateInTimezone");function zd(e,t){if(!("defaultValue"in e))return;let{defaultValue:r}=e;return e.type!=="date"||r!==ra?r:e.includeTime?t.now.toISOString():vt(t.now,t.timezone)}a(zd,"resolveAttributeDefaultValue");function Kw(e,t,r){if(e.combinator==="or"&&e.rules.length>1)return {};let n=new Map(t.map(a=>[a.name,a])),o={};for(let a of e.rules){if(a.property!==void 0||Object.hasOwn(o,a.attribute))continue;let s=n.get(a.attribute);if(!s)continue;let l=Gd(a,r);l!==void 0&&(o[a.attribute]=j(s).storage.cardinality==="many"?[l]:l);}return o}a(Kw,"deriveCreateDefaultsFromFilters");function Gd(e,t){if(e.operator==="is")return B(e.value)?na(e.value,t):e.value===null||Array.isArray(e.value)?void 0:e.value;if(e.operator==="any_of"){if(!Array.isArray(e.value)||e.value.length!==1)return;let r=e.value[0];return B(r)?na(r,t):r}}a(Gd,"extractDeterministicValue");function na(e,t){if(t){if(e.dynamic==="actor")return t.userId;if(e.anchor==="today")return vt(t.now,t.timezone);if(e.anchor==="now")return t.now.toISOString()}}a(na,"resolveDynamicValue");var Qw={status:"connector_status",error:"connector_error",provider:"connector_provider"};var Xw=["force","skip"],Zw=["none","all","external_only"],ex="x-fake-signature",tx={override:null,status:"none",failureReason:null,botId:null};var Wd=/^Session \d+$/;function ia(e){let t=e.replace(/\s+/g," ").trim().replace(/[.!?]+$/,"");return t?t.length>60?`${t.slice(0,59).trimEnd()}...`:t:"New conversation"}a(ia,"buildAgentFallbackTitle");function Kd(e){let t=e.generated?.trim();return t&&!Wd.test(t)?t:e.firstUserText?ia(e.firstUserText):e.emptyLabel}a(Kd,"conversationDisplayTitle");var Qn=/^[a-z0-9][a-z0-9-]{0,62}$/;function Yd(e){if(!Qn.test(e))throw new h(`Invalid schema source id "${e}": expected a lowercase slug matching ${Qn}`,[])}a(Yd,"assertSchemaSourceId");function Hd(e){return {label:e.label,description:e.description??null,icon:e.icon??null,config:e.config,default:e.default??false,metadata:e.metadata??null}}a(Hd,"viewSyncPayload");function dx(e){let{attributeRemovals:t,objectRemovals:r,renames:n}=e.destructive;return t.length>0||r.length>0||n.length>0}a(dx,"hasDestructiveEntries");var $={objectAdditions:20,totalMutations:500,serializedBytes:512*1024};function Xn(e){return e instanceof Error?e.message:String(e)}a(Xn,"errorMessage");var Qd=z$1.enum(["text","richtext","number","checkbox","date","phone","currency","status","location","select","multiselect","user","relation","formula","rollup","document"]).describe('The attribute\'s data type. Determines which keys `config` accepts and requires: `status`/`select`/`multiselect` need a non-empty `options` array (each `status` option carrying its own `group`); `relation` needs `targets` (non-empty) and `cardinality` ("one" or "many"); `formula` needs `expression` and `returnType`; `rollup` needs `targetAttribute` and `function`. Every other type accepts only the shared presentation keys (`placeholder`, `defaultValue`, `icon`, ...) plus a few type-specific optionals (e.g. `number.decimals`, `date.dateFormat`). An attribute\'s type can never be changed later through this tool \u2014 only through a code migration \u2014 so pick it correctly now.');var ca=z$1.string().min(1).superRefine((e,t)=>{try{Ce(e);}catch(r){t.addIssue({code:z$1.ZodIssueCode.custom,message:Xn(r)});}}).describe('The attribute\'s machine name \u2014 the record\'s field key, and what `{{ name }}` refers to in a labelExpression. Must be a valid identifier: starts with a letter or underscore, then only letters/digits/underscores ("montantHt", "first_name", "FIRST_NAME" are valid; "first-name", "first name", "123name" are not). Max 63 characters. Cannot be a name reserved by the record shape itself (id, createdAt, updatedAt, createdBy, lastUpdatedBy, objectId, label, embeddingText, values, metadata, deletedAt, deletedBy, schemaVersion).'),Jd=z$1.string().min(1).superRefine((e,t)=>{A$1.includes(e)&&t.addIssue({code:z$1.ZodIssueCode.custom,message:`"${e}" is a reserved object name (${A$1.join(", ")}) and cannot be used for a new object.`});try{De(e);}catch(r){t.addIssue({code:z$1.ZodIssueCode.custom,message:Xn(r)});}}).describe(`The new object's machine name: kebab-case slug, lowercase letters/digits/hyphens only, starting with a letter ("products", "user-profiles", "order-items" are valid; "Products", "userProfiles", "user_profiles" are not). Max 63 characters. Cannot be a name the platform reserves for its own system objects, and cannot already exist.`);function pa(e){return e.superRefine((t,r)=>{try{let n$1=n(t.type,{...t.config??{},description:t.description}),o=Object.keys(t.config??{}).filter(a=>!Object.hasOwn(n$1,a));o.length>0&&r.addIssue({code:"unrecognized_keys",keys:o,path:["config"],message:`Unrecognized attribute config key${o.length===1?"":"s"}: ${o.join(", ")}`});}catch(n){if(n instanceof h){for(let o of n.errors)r.addIssue({code:z$1.ZodIssueCode.custom,path:["config",...o.path.map(a=>/^\d+$/.test(a)?Number(a):a)],message:`Config for type "${t.type}" is invalid or incomplete: ${o.message}`});return}r.addIssue({code:z$1.ZodIssueCode.custom,path:["config"],message:`Config for type "${t.type}" is invalid or incomplete: ${Xn(n)}`});}})}a(pa,"withConfigCheck");var ma=z$1.object({objectName:z$1.string().min(1).describe("Name of the existing (or, elsewhere in the same plan, newly created) object this attribute is added to. Ignored for an attribute declared inline in `additive.objects[].attributes` \u2014 there the parent object's own `name` is used instead."),name:ca,label:z$1.string().min(1).max(128).describe("Human-readable display label shown in the UI. 1-128 characters, cannot be empty."),type:Qd,config:z$1.record(z$1.string(),z$1.unknown()).optional().describe('Type-specific configuration; required keys depend on `type` (see `type`\'s description). Shared optional keys on every type: `placeholder`, `defaultValue`, `icon`, `order`, `hidden`, `archived`, `deprecated`, `metadata`. Per-type keys: `text` \u2014 `multiline`, `minLength`, `maxLength`, `pattern`, `format` ("email"|"url"|"slug"); `number` \u2014 `renderAs` ("number"|"rating"), `min`, `max`, `unit`, `decimals`; `date` \u2014 `dateFormat`, `minDate`, `maxDate`, `includeTime`, `endDate`, `timeFormat` ("12h"|"24h"); `phone` \u2014 `defaultCountryCode` (3-letter); `currency` \u2014 `defaultCurrency`, `allowedCurrencies`, `allowNegative`; `status`/`select`/`multiselect` \u2014 `options` (REQUIRED, non-empty array of `{ value, label, color }`, unique `value`s; for `status` every OPTION also carries `group` as idle|in_progress|finished \u2014 `group` belongs on each option, never on `config` itself; select/multiselect accept `renderAs: "badges"`); `location` \u2014 `granularity`, `defaultCountry`, `allowedCountries`; `user` \u2014 `types` ("user"|"agent"), `multiple`; `relation` \u2014 `targets` (REQUIRED, non-empty array of `{ object }`) and `cardinality` (REQUIRED, "one"|"many"); `formula` \u2014 `expression` (REQUIRED formula string) and `returnType` (REQUIRED); `rollup` \u2014 `targetAttribute` (REQUIRED) and `function` (REQUIRED, e.g. "sum"|"avg"|"count"); `document` \u2014 `properties`, `accepts`, `maxFileSize`. Omit entirely for `richtext`/`checkbox`, which take no type-specific keys.'),required:z$1.boolean().optional().describe("Whether the attribute must have a value on every record. Defaults to false (optional)."),description:z$1.string().optional().describe("Help text shown under the field in the UI. Not the same as the plan's `summary`.")}).strict(),Xd=pa(ma),Zd=pa(ma.omit({objectName:true})),ec=z$1.object({name:Jd,label:z$1.string().min(1).describe('Human-readable singular display label (e.g. "Devis").'),pluralLabel:z$1.string().optional().describe('Human-readable plural display label (e.g. "Devis"/"Invoices"). Defaults from `label` if omitted.'),description:z$1.string().optional().describe("Help text describing what this object represents."),icon:c.describe("Required icon name for the object. Must be a catalogue value \u2014 call `search_icons` and use a name it returns verbatim. A name that is not in the catalogue is rejected without any hint as to what would have worked, so never guess one."),labelExpression:be.describe('Template used to render a human-readable label for every record of this object \u2014 e.g. shown in relations, search results, and breadcrumbs. MUST contain at least one `{{ attributeName }}` interpolation referencing an attribute this object will actually have (either declared in this same `attributes` array, or an existing attribute if this is an update) \u2014 a plain string with no `{{ }}` at all (e.g. "Devis") is rejected. Interpolations cannot be empty (`{{ }}` is rejected) and only these pipes are allowed: UPPER, LOWER, capitalize, trim, prefix:"...", suffix:"...", wrap:"..." "...", default:"...". `{{ a || b }}` falls back to `b` when `a` is empty. Examples: "{{ firstName }} {{ lastName }}", "{{ numero | UPPER }}", "{{ name || reference }}".'),attributes:z$1.array(Zd).default([]).describe("Attributes to create on this new object, inline. Same rules as a standalone entry in `additive.attributes`, minus `objectName` (implied by this object). At least one attribute referenced by `labelExpression` should be included here.")}).strict(),fa=z$1.object({attributeRemovals:z$1.array(z$1.object({objectName:z$1.string().min(1).describe("Object the attribute is removed from."),attributeName:z$1.string().min(1).describe("Attribute to delete, together with every record's stored value for it. Must not be a system (code-declared) attribute, and must not be referenced by the object's own `labelExpression` or `embeddingExpression` \u2014 update those first.")}).strict()).default([]).describe("Attributes to permanently delete. Irreversible: record values for the attribute are purged."),objectRemovals:z$1.array(z$1.object({objectName:z$1.string().min(1).describe("Object to delete entirely, together with all its records. Must not be a system (code-declared) object, and must not still be targeted by a `relation` attribute on another object \u2014 retarget or remove that relation first.")}).strict()).default([]).describe("Objects to permanently delete, records included. Irreversible."),renames:z$1.array(z$1.object({objectName:z$1.string().min(1).describe("Object the renamed attribute belongs to."),from:z$1.string().min(1).describe("Current attribute name. Must already exist and not be a system attribute."),to:ca.describe("New attribute name \u2014 same identifier rules as any attribute `name` (see `name` on a planned attribute), and must not collide with another name already on the object, including one added elsewhere in this same plan.")}).strict()).default([]).describe("Attribute renames. Every reference to the old name (labelExpression, views, formulas) must be updated separately \u2014 a rename does not follow references automatically.")}).strict().default({attributeRemovals:[],objectRemovals:[],renames:[]}),ba=z$1.string().min(1).describe("ONE sentence naming the intent of the change \u2014 what it is for, not what it contains. The human approving it has already watched every entry land in the preview window and can read every row of the plan itself, so a recap tells them nothing they do not have. A second sentence is warranted only when `destructive` is non-empty: say plainly what will be lost (e.g. 'deletes the \"ancienMontant\" column and its data on every devis'). Never restate the plan \u2014 explain intent."),oa="The COMPLETE config this view should end up with \u2014 not a patch. Copy the baseline returned by get_default_view and edit it, preserving every tab and setting you are not changing: anything you omit is dropped. To change the columns shown, set `tabs[].columns` (an array of attribute names) \u2014 there is no top-level `columns` on either view type. For a detail view's side panel, set `sidePanel.attributes`. Every attribute name listed must already exist on the object, or be created earlier in this same plan. ONE EXCEPTION to omit-is-dropped: a tab with `type: \"custom\"` renders a component belonging to the application, which you cannot describe or recreate. Copy every such tab through from the baseline exactly as it came, `name`, `component` and `props` untouched \u2014 dropping one, inventing one, or altering any of those three is rejected rather than applied (`name` is the tab's address in links, not its wording). Its `label` and `icon` you may change.",aa="Opaque token returned by get_default_view alongside the baseline you edited. REQUIRED when the object already exists \u2014 it proves you authored against the baseline that is still current. Must be OMITTED when this plan creates the object, which has no baseline yet.",sa=z$1.string().min(1).describe("Name of the object whose default view of this type is replaced. Not a view name \u2014 a plan can only replace an object's deterministic default view, never create a view or target a non-default one."),tc=z$1.discriminatedUnion("viewType",[z$1.object({objectName:sa,viewType:z$1.literal("list").describe("Targets the object's default list view (the grid)."),canonicalConfig:ka$1.describe(oa),baselineToken:z$1.string().min(1).optional().describe(aa)}).strict(),z$1.object({objectName:sa,viewType:z$1.literal("detail").describe("Targets the object's default detail view (the single-record view)."),canonicalConfig:la$1.describe(oa),baselineToken:z$1.string().min(1).optional().describe(aa)}).strict()]);var ua=z$1.string().regex(/^[0-9a-f]{64}$/,"Expected a lowercase SHA-256 hash"),la={baseConfigHash:ua.nullable(),targetConfigHash:ua,baselineOrigin:z$1.enum(["persisted","generated","absent"])},rc=z$1.discriminatedUnion("viewType",[z$1.object({objectName:z$1.string().min(1),viewType:z$1.literal("list"),canonicalConfig:ka$1,...la}).strict(),z$1.object({objectName:z$1.string().min(1),viewType:z$1.literal("detail"),canonicalConfig:la$1,...la}).strict()]).superRefine((e,t)=>{let r=e.baselineOrigin!=="absent";r!==(e.baseConfigHash!==null)&&t.addIssue({code:"custom",path:["baseConfigHash"],message:r?`A ${e.baselineOrigin} baseline requires baseConfigHash`:"An absent baseline requires baseConfigHash to be null"});});function ga(e){return z$1.object({objects:z$1.array(ec).default([]).describe("New objects to create, with their attributes inline."),attributes:z$1.array(Xd).default([]).describe("Attributes to add to existing or same-plan objects."),viewUpdates:z$1.array(e).default([]).describe("Complete target configs for deterministic default views; never view names.")}).strict().default({objects:[],attributes:[],viewUpdates:[]})}a(ga,"buildAdditiveSchema");function Jn(e,t=[],r=new WeakSet){if(e===null||typeof e=="string"||typeof e=="boolean")return null;if(typeof e=="number")return Number.isFinite(e)?null:{path:t,message:"Plan input contains a non-finite number"};if(typeof e!="object")return {path:t,message:"Plan input must contain only JSON-safe values"};if(r.has(e))return {path:t,message:"Plan input cannot contain circular references"};if(Array.isArray(e)){r.add(e);for(let s of Reflect.ownKeys(e))if(s!=="length"&&(typeof s=="symbol"||!/^(0|[1-9]\d*)$/.test(s)))return r.delete(e),{path:[...t,s],message:"Plan input arrays cannot contain non-index JSON properties"};for(let s=0;s<e.length;s++){if(!Object.hasOwn(e,s))return r.delete(e),{path:[...t,s],message:"Plan input cannot contain sparse arrays"};let l=Jn(e[s],[...t,s],r);if(l)return r.delete(e),l}return r.delete(e),null}let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)return {path:t,message:"Plan input must contain only plain JSON objects"};r.add(e);let o=e,a=Reflect.ownKeys(o);for(let s of a){let l=Object.getOwnPropertyDescriptor(o,s);if(typeof s=="symbol"||!(l?.enumerable&&"value"in l))return r.delete(e),{path:[...t,s],message:"Plan input objects must contain enumerable JSON data properties only"}}for(let s of a.sort()){let l=Jn(o[s],[...t,s],r);if(l)return r.delete(e),l}return r.delete(e),null}a(Jn,"findJsonSafetyIssue");function nc(e){let t=[];return e.additive.objects.forEach((r,n)=>{t.push(["additive","objects",n]),r.attributes.forEach((o,a)=>{t.push(["additive","objects",n,"attributes",a]);});}),e.additive.attributes.forEach((r,n)=>{t.push(["additive","attributes",n]);}),e.additive.viewUpdates.forEach((r,n)=>{t.push(["additive","viewUpdates",n]);}),e.destructive.attributeRemovals.forEach((r,n)=>{t.push(["destructive","attributeRemovals",n]);}),e.destructive.objectRemovals.forEach((r,n)=>{t.push(["destructive","objectRemovals",n]);}),e.destructive.renames.forEach((r,n)=>{t.push(["destructive","renames",n]);}),t}a(nc,"mutationPaths");function ya(e,t){e.additive.objects.length>$.objectAdditions&&t.addIssue({code:"too_big",origin:"array",maximum:$.objectAdditions,inclusive:true,path:["additive","objects",$.objectAdditions],message:`A schema plan can add at most ${$.objectAdditions} objects`});let r=nc(e);r.length>$.totalMutations&&t.addIssue({code:"too_big",origin:"array",maximum:$.totalMutations,inclusive:true,path:r[$.totalMutations],message:`A schema plan can contain at most ${$.totalMutations} mutations; received ${r.length}`});}a(ya,"addPlanLimitIssues");function ha(e,t){let r=Jn(e);if(r)return t.addIssue({code:"custom",path:r.path,message:r.message}),z$1.NEVER;let n=new TextEncoder().encode(a$4(e)).byteLength;return n>$.serializedBytes?(t.addIssue({code:"too_big",origin:"string",maximum:$.serializedBytes,inclusive:true,path:[],message:`A schema plan can serialize to at most ${$.serializedBytes} UTF-8 bytes; received ${n}`}),z$1.NEVER):e}a(ha,"boundSerializedPlanInput");var ic=ga(tc),oc=ga(rc),da=z$1.object({schemaPlanVersion:z$1.literal(2).describe("Required proposal contract version."),summary:ba,additive:ic,destructive:fa}).strict().superRefine((e,t)=>{let r=new Set(e.additive.objects.map(n=>n.name));e.additive.viewUpdates.forEach((n,o)=>{let a=["additive","viewUpdates",o,"baselineToken"];if(r.has(n.objectName)){n.baselineToken!==void 0&&t.addIssue({code:"custom",path:a,message:"A view target for an object added by this plan must not include baselineToken"});return}n.baselineToken===void 0&&t.addIssue({code:"custom",path:a,message:"A view target for an existing object requires baselineToken"});}),ya(e,t);}),xx=Object.assign(z$1.preprocess(ha,da),{shape:da.shape}),ac=z$1.object({schemaPlanVersion:z$1.literal(2),summary:ba,additive:oc,destructive:fa}).strict().superRefine(ya),Ix=z$1.preprocess(ha,ac);var A=z$1.number().finite().nonnegative(),Ta=z$1.enum(Mi),Zn=z$1.enum(Bi),ei=z$1.enum(Ui),wa=z$1.object({provider:Ta,model:z$1.string().min(1)}).strict(),Cx=z$1.object({speed:Zn.optional(),reasoning:ei.optional()}).strict(),xa=z$1.string().regex(/^[a-z0-9][a-z0-9-]*\/[a-z0-9][a-z0-9._-]*$/),sc=z$1.object({model:wa.optional(),speed:Zn.optional(),reasoning:ei.optional(),imageModel:xa.optional()}).strict(),Nx=sc.refine(e=>e.model!==void 0||e.speed!==void 0||e.reasoning!==void 0||e.imageModel!==void 0,{message:"At least one inference override is required"}),kx=z$1.object({model:wa.nullable().optional(),speed:Zn.nullable().optional(),reasoning:ei.nullable().optional(),imageModel:xa.nullable().optional()}).strict().refine(e=>Object.keys(e).length>0&&Object.values(e).every(t=>t!==void 0),{message:"At least one inference override is required"}),Ia=z$1.object({label:z$1.string(),denied:z$1.boolean().optional(),deletion:z$1.object({target:z$1.string().optional(),count:A.optional(),restorableDays:A.optional()}).strict().optional(),counts:z$1.record(z$1.string(),A).optional(),warnings:z$1.array(z$1.string()).optional()}).strict(),uc=z$1.union([z$1.object({type:z$1.literal("text"),text:z$1.string()}).strict(),z$1.object({type:z$1.literal("reasoning"),text:z$1.string()}).strict(),z$1.object({type:z$1.literal("system"),code:z$1.enum(qt)}).strict(),z$1.object({type:z$1.literal("error"),error:z$1.string(),errorClass:z$1.string().optional()}).strict(),z$1.object({type:z$1.literal("tool"),toolCallId:z$1.string(),name:z$1.string(),args:z$1.record(z$1.string(),z$1.unknown()),result:z$1.unknown().optional(),error:z$1.string().optional(),errorCode:z$1.enum(["output_limit_reached","interrupted"]).optional(),state:z$1.enum(["streaming","running","completed","error","approval-requested","approval-responded","approval-dispatched"]),durationMs:A.optional(),approvalId:z$1.string().optional(),approvalImpact:Ia.optional(),approved:z$1.boolean().optional(),approvalReason:z$1.string().optional(),approvalRelaxableByAuto:z$1.boolean().optional()}).strict(),z$1.object({type:z$1.literal("file"),fileId:z$1.string(),name:z$1.string(),mimeType:z$1.string()}).strict(),z$1.object({type:z$1.literal("compaction"),state:z$1.literal("in-progress"),reason:z$1.enum(["preflight_threshold","overflow_recovery"]),estimatedTokens:A.optional(),reportedTokens:A.optional()}).strict(),z$1.object({type:z$1.literal("compaction"),state:z$1.literal("completed"),tokensBefore:A,tokensAfter:A,tokensSaved:A,strategy:z$1.enum(["no-op","summary","truncation"]),durationMs:A,summary:z$1.string().optional()}).strict(),z$1.object({type:z$1.literal("compaction"),state:z$1.literal("failed"),reason:z$1.string(),durationMs:A.optional()}).strict()]),lc=z$1.object({id:z$1.string(),name:z$1.string(),mimeType:z$1.string(),size:A}).strict(),dc=z$1.object({id:z$1.string(),type:z$1.string().transform(e=>e),entityId:z$1.string(),label:z$1.string(),objectName:z$1.string().optional(),startIndex:A,endIndex:A}).strict(),cc=z$1.object({provider:Ta,model:z$1.string(),maxTokens:A.optional(),contextWindow:A.optional()}).strict(),pc=z$1.union([z$1.date(),z$1.string().datetime({offset:true}).transform(e=>new Date(e))]),Aa=z$1.object({id:z$1.string(),sessionId:z$1.string(),tenantId:z$1.string().optional(),runId:z$1.string().optional(),role:z$1.enum(["user","assistant","system","tool"]),parts:z$1.array(uc),attachments:z$1.array(lc).optional(),mentions:z$1.array(dc).optional(),model:cc.optional(),tokenUsage:z$1.object({input:A,output:A}).strict().optional(),metadata:z$1.record(z$1.string(),z$1.unknown()).optional(),createdAt:pc}).strict(),mc=z$1.object({id:z$1.string(),description:z$1.string(),status:z$1.enum(["pending","in_progress","completed","blocked"]),result:z$1.string().optional(),updatedAt:A.optional()}).strict(),fc=z$1.object({id:z$1.string(),sessionId:z$1.string(),status:z$1.enum(["active","completed","abandoned"]),todos:z$1.array(mc),version:A,createdAt:z$1.string(),updatedAt:z$1.string(),completedAt:z$1.string().optional()}).strict(),Sa={"session-named":z$1.object({name:z$1.string()}).strict(),"compaction-start":z$1.object({reason:z$1.enum(["preflight_threshold","overflow_recovery"]),estimatedTokens:A.optional(),reportedTokens:A.optional()}).strict(),"compaction-end":z$1.object({tokensBefore:A,tokensAfter:A,tokensSaved:A,strategy:z$1.enum(["no-op","summary","truncation"]),durationMs:A,summary:z$1.string().optional()}).strict(),"compaction-failed":z$1.object({reason:z$1.string()}).strict(),usage:z$1.object({messageId:z$1.string().min(1).optional(),inputTokens:A,outputTokens:A,totalTokens:A,cacheReadTokens:A.optional(),cacheCreationTokens:A.optional(),contextWindow:A,residentTokens:A,utilization:z$1.number().finite().min(0).max(1),costUsd:A.optional()}).strict(),"message-persisted":z$1.object({message:Aa}).strict(),"message-updated":z$1.object({message:Aa}).strict(),"todo-plan-update":z$1.object({plan:fc}).strict(),"approval-context":z$1.object({approvalId:z$1.string(),toolCallId:z$1.string(),impact:Ia.optional(),relaxableByAuto:z$1.boolean().optional()}).strict(),"session-state":z$1.object({state:z$1.object({phase:z$1.enum(["queued","running","parked","terminal"]),parkedOn:z$1.enum(["human","agents"]).optional(),humanRequestIds:z$1.array(z$1.string()).optional(),outcome:z$1.enum(["completed","failed","cancelled","timeout","expired"]).optional()}).strict(),version:z$1.number().int().positive(),updatedAt:z$1.string().datetime({offset:true})}).strict()};function bc(e){return e in Sa}a(bc,"isAgentUIDataName");function gc(e){return new h("Invalid agent UI message chunk",e.map(t=>({path:t.path.map(String),message:t.message,code:t.code})))}a(gc,"agentUIValidationError");function yc(e){if(typeof e!="object"||e===null||typeof e.type!="string")throw new h("Invalid agent UI message chunk",[{path:["type"],message:"Expected UI message chunk type",code:"invalid_type"}]);let t=e.type;if(!t.startsWith("data-"))throw new h("Invalid agent UI message chunk",[{path:["type"],message:"Expected agent data chunk type",code:"invalid_value"}]);let r=t.slice(5);if(!bc(r))throw new h("Invalid agent UI message chunk",[{path:["type"],message:`Unknown agent UI data type: ${r}`,code:"invalid_value"}]);let n=z$1.object({type:z$1.literal(`data-${r}`),id:z$1.string().optional(),data:Sa[r],transient:z$1.boolean().optional()}).strict().safeParse(e);if(!n.success)throw gc(n.error.issues);return n.data}a(yc,"assertCustomAgentUIMessageChunk");function Ox(e,t,r){return yc({type:`data-${e}`,...r?.id!==void 0?{id:r.id}:{},data:t,...r?.transient!==void 0?{transient:r.transient}:{}})}a(Ox,"agentDataChunk");function Rt(e){return e}a(Rt,"defineOperation");function y(e,t,r){let n=t==="atomic"?"none":t==="local"?"if-not-visible":"follow";return o=>{let a=r?.(o);return {impact:t,navigation:n,focus:{...e(o),...a===void 0?{}:{propertyPath:a}}}}}a(y,"definePresentation");var ti={id:z$1.string().min(1)},v={...ti,viewId:z$1.string().min(1)};function S(e,t,r){if(!e.views.some(n=>n.id===t))throw new h(`View "${t}" is not in the draftable state`,[]);return {...e,views:e.views.map(n=>n.id===t?r(n):n)}}a(S,"mapView");function Ra(e,t,r){let n=[...e],[o]=n.splice(t,1);return n.splice(r,0,o),n}a(Ra,"moveWithin");function Fe(e,t,r){if(t.length!==e.length)throw new h(`${r} order lists ${t.length} ids for ${e.length} items`,[]);return t.map(n=>{let o=e.find(a=>a.id===n);if(!o)throw new h(`${r} "${n}" is not in this collection`,[]);return o})}a(Fe,"reorderById");function ne(e,t,r){let n=e.tabs.find(o=>o.id===t);if(!n)throw new h(`Tab "${t}" is not in view "${e.id}"`,[]);if(n.type!=="form")throw new h(`Tab "${t}" is not a form tab`,[]);return {...e,tabs:e.tabs.map(o=>o.id===t?r(n):o)}}a(ne,"mapFormTab");function Ct(e,t){let r=e.groups.find(n=>n.id===t);if(!r)throw new h(`Group "${t}" is not in tab "${e.id}"`,[]);return r}a(Ct,"requireGroup");function ri(e,t){for(let r of e.groups){let n=r.fields.find(o=>o.id===t);if(n)return {group:r,field:n}}throw new h(`Field slot "${t}" is not in tab "${e.id}"`,[])}a(ri,"locateField");function Et(e){return {viewId:e.viewId}}a(Et,"viewFocus");function Dt(e){return {viewId:e.viewId,tabId:e.tabId}}a(Dt,"tabFocus");function Ea(e){return {viewId:e.viewId,tabId:e.tabId,groupId:e.groupId}}a(Ea,"groupFocus");function Da(e){return {viewId:e.viewId,tabId:e.tabId,fieldId:e.fieldId}}a(Da,"fieldFocus");function Ca(e){return {viewId:e.viewId,tabId:e.tab.id}}a(Ca,"addTabFocus");function Na(e){return {viewId:e.viewId,tabId:e.tabId,groupId:e.group.id}}a(Na,"addGroupFocus");function ka(e){return {viewId:e.viewId,tabId:e.tabId,groupId:e.groupId,fieldId:e.field.id}}a(ka,"addFieldFocus");function Oa(e){return {viewId:e.viewId,tabId:e.tabId,groupId:e.toGroupId,fieldId:e.fieldId}}a(Oa,"moveFieldFocus");function Ve(e){let t=Object.keys(e.changes).sort();return t.length===1?[t[0]]:void 0}a(Ve,"firstChangedProperty");var hc=ia$1,Ac=da$1,Tc=ca$1,wc=z$1.object({...v,type:z$1.literal("add_tab"),tab:hc}),xc={type:"add_tab",schema:wc,apply:a((e,t)=>S(e,t.viewId,r=>{if(r.tabs.some(n=>n.id===t.tab.id))throw new h(`Tab "${t.tab.id}" already exists in view "${t.viewId}"`,[]);return {...r,tabs:[...r.tabs,t.tab]}}),"apply"),focus:Ca,presentation:y(Ca,"local"),describe:a(e=>`Ajoute l'onglet \xAB ${e.tab.label} \xBB`,"describe")},Ic=z$1.object({...v,type:z$1.literal("remove_tab"),tabId:z$1.string().min(1)}),Sc={type:"remove_tab",schema:Ic,apply:a((e,t)=>S(e,t.viewId,r=>{if(!r.tabs.some(n=>n.id===t.tabId))throw new h(`Tab "${t.tabId}" is not in view "${t.viewId}"`,[]);return {...r,tabs:r.tabs.filter(n=>n.id!==t.tabId)}}),"apply"),focus:Dt,presentation:y(Dt,"local"),describe:a(e=>`Supprime l'onglet ${e.tabId}`,"describe")},La=z$1.object({label:z$1.string().min(1).optional(),icon:c.optional(),order:z$1.number().int().optional()}),vc=Object.keys(La.shape),Rc=z$1.object({...v,type:z$1.literal("update_tab"),tabId:z$1.string().min(1),changes:La.refine(e=>Object.keys(e).length>0,"update_tab needs at least one change")}),_a=a(e=>({viewId:e.viewId,tabId:e.tabId}),"updateTabFocus"),Ec={type:"update_tab",schema:Rc,apply:a((e,t)=>S(e,t.viewId,r=>{if(!r.tabs.some(n=>n.id===t.tabId))throw new h(`Tab "${t.tabId}" is not in view "${t.viewId}"`,[]);return {...r,tabs:r.tabs.map(n=>n.id===t.tabId?{...n,...t.changes}:n)}}),"apply"),focus:_a,presentation:y(_a,"atomic",Ve),describe:a(e=>e.changes.label?`Renomme l'onglet en \xAB ${e.changes.label} \xBB`:`Modifie l'onglet ${e.tabId}`,"describe")},Dc=z$1.object({...v,type:z$1.literal("reorder_tabs"),tabOrder:z$1.array(z$1.string().min(1))}),Cc={type:"reorder_tabs",schema:Dc,apply:a((e,t)=>S(e,t.viewId,r=>({...r,tabs:Fe(r.tabs,t.tabOrder,"Tab")})),"apply"),focus:Et,presentation:y(Et,"local"),describe:a(()=>"R\xE9ordonne les onglets","describe")},Nc=z$1.object({...v,type:z$1.literal("add_group"),tabId:z$1.string().min(1),group:Ac}),kc={type:"add_group",schema:Nc,apply:a((e,t)=>S(e,t.viewId,r=>ne(r,t.tabId,n=>{if(n.groups.some(o=>o.id===t.group.id))throw new h(`Group "${t.group.id}" already exists in tab "${t.tabId}"`,[]);return {...n,groups:[...n.groups,t.group]}})),"apply"),focus:Na,presentation:y(Na,"local"),describe:a(e=>`Ajoute le groupe \xAB ${e.group.label} \xBB`,"describe")},Oc=z$1.object({...v,type:z$1.literal("remove_group"),tabId:z$1.string().min(1),groupId:z$1.string().min(1)}),_c={type:"remove_group",schema:Oc,apply:a((e,t)=>S(e,t.viewId,r=>ne(r,t.tabId,n=>(Ct(n,t.groupId),{...n,groups:n.groups.filter(o=>o.id!==t.groupId)}))),"apply"),focus:Ea,presentation:y(Ea,"local"),describe:a(e=>`Supprime le groupe ${e.groupId}`,"describe")},Pc=z$1.object({...v,type:z$1.literal("update_group"),tabId:z$1.string().min(1),groupId:z$1.string().min(1),changes:z$1.object({label:z$1.string().min(1).optional(),description:z$1.string().optional(),collapsible:z$1.boolean().optional(),collapsed:z$1.boolean().optional(),order:z$1.number().int().optional()}).refine(e=>Object.keys(e).length>0,"update_group needs at least one change")}),Pa=a(e=>({viewId:e.viewId,tabId:e.tabId,groupId:e.groupId}),"updateGroupFocus"),Fc={type:"update_group",schema:Pc,apply:a((e,t)=>S(e,t.viewId,r=>ne(r,t.tabId,n=>(Ct(n,t.groupId),{...n,groups:n.groups.map(o=>o.id===t.groupId?{...o,...t.changes}:o)}))),"apply"),focus:Pa,presentation:y(Pa,"atomic",Ve),describe:a(e=>e.changes.label?`Renomme le groupe en \xAB ${e.changes.label} \xBB`:"Modifie le groupe","describe")},Vc=z$1.object({...v,type:z$1.literal("reorder_groups"),tabId:z$1.string().min(1),groupOrder:z$1.array(z$1.string().min(1))}),jc={type:"reorder_groups",schema:Vc,apply:a((e,t)=>S(e,t.viewId,r=>ne(r,t.tabId,n=>({...n,groups:Fe(n.groups,t.groupOrder,"Group")}))),"apply"),focus:Dt,presentation:y(Dt,"local"),describe:a(()=>"R\xE9ordonne les groupes","describe")},Lc=z$1.object({...v,type:z$1.literal("add_field"),tabId:z$1.string().min(1),groupId:z$1.string().min(1),field:Tc,index:z$1.number().int().min(0).optional()}),Mc={type:"add_field",schema:Lc,apply:a((e,t)=>S(e,t.viewId,r=>ne(r,t.tabId,n=>{if(Ct(n,t.groupId),n.groups.some(o=>o.fields.some(a=>a.id===t.field.id)))throw new h(`Field slot "${t.field.id}" already exists in tab "${t.tabId}"`,[]);return {...n,groups:n.groups.map(o=>{if(o.id!==t.groupId)return o;let a=t.index??o.fields.length;return {...o,fields:[...o.fields.slice(0,a),t.field,...o.fields.slice(a)]}})}})),"apply"),focus:ka,presentation:y(ka,"local"),describe:a(e=>`Ajoute le champ ${e.field.attribute??e.field.id}`,"describe")},Bc=z$1.object({...v,type:z$1.literal("remove_field"),tabId:z$1.string().min(1),fieldId:z$1.string().min(1)}),Uc={type:"remove_field",schema:Bc,apply:a((e,t)=>S(e,t.viewId,r=>ne(r,t.tabId,n=>{let{group:o}=ri(n,t.fieldId);return {...n,groups:n.groups.map(a=>a.id===o.id?{...a,fields:a.fields.filter(s=>s.id!==t.fieldId)}:a)}})),"apply"),focus:Da,presentation:y(Da,"local"),describe:a(e=>`Retire le champ ${e.fieldId}`,"describe")},$c=z$1.object({...v,type:z$1.literal("move_field"),tabId:z$1.string().min(1),fieldId:z$1.string().min(1),toGroupId:z$1.string().min(1),toIndex:z$1.number().int().min(0)}),qc={type:"move_field",schema:$c,apply:a((e,t)=>S(e,t.viewId,r=>ne(r,t.tabId,n=>{let{group:o,field:a}=ri(n,t.fieldId),s=Ct(n,t.toGroupId);if(o.id===s.id){let l=o.fields.findIndex(p=>p.id===t.fieldId);return {...n,groups:n.groups.map(p=>p.id===o.id?{...p,fields:Ra(p.fields,l,t.toIndex)}:p)}}return {...n,groups:n.groups.map(l=>l.id===o.id?{...l,fields:l.fields.filter(p=>p.id!==t.fieldId)}:l.id===s.id?{...l,fields:[...l.fields.slice(0,t.toIndex),a,...l.fields.slice(t.toIndex)]}:l)}})),"apply"),focus:Oa,presentation:y(Oa,"local"),describe:a(e=>`D\xE9place le champ ${e.fieldId} vers le groupe ${e.toGroupId}`,"describe")},zc=z$1.object({...v,type:z$1.literal("update_field"),tabId:z$1.string().min(1),fieldId:z$1.string().min(1),changes:z$1.object({label:z$1.string().optional(),readOnly:z$1.boolean().optional(),span:z$1.number().int().min(1).max(12).optional()}).refine(e=>Object.keys(e).length>0,"update_field needs at least one change")}),Fa=a(e=>({viewId:e.viewId,tabId:e.tabId,fieldId:e.fieldId}),"updateFieldFocus"),Gc={type:"update_field",schema:zc,apply:a((e,t)=>S(e,t.viewId,r=>ne(r,t.tabId,n=>(ri(n,t.fieldId),{...n,groups:n.groups.map(o=>({...o,fields:o.fields.map(a=>a.id===t.fieldId?{...a,...t.changes}:a)}))}))),"apply"),focus:Fa,presentation:y(Fa,"atomic",Ve),describe:a(e=>`Modifie le champ ${e.fieldId}`,"describe")},Ma=z$1.object({source:ga$1.optional(),columns:X.optional(),filters:_.nullable().optional(),sorts:Z$1.nullable().optional(),allowCreate:z$1.boolean().optional(),allowEdit:z$1.boolean().optional(),allowDelete:z$1.boolean().optional(),createMode:z$1.enum(["redirect","inline","peek"]).optional()}),Wc=Object.keys(Ma.shape),Ba=z$1.object({emailAttributeIds:z$1.array(z$1.string().min(1)).optional(),attribute:z$1.string().min(1).optional(),titleAttribute:z$1.string().min(1).nullable().optional(),component:z$1.string().nullable().optional(),props:z$1.record(z$1.string(),z$1.unknown()).nullable().optional()}),Kc=Object.keys(Ba.shape),Yc={emailAttributeIds:["emails","meetings"],attribute:["richtext"],titleAttribute:["richtext"],component:["custom"],props:["custom"]},Hc=z$1.object({...v,type:z$1.literal("update_tab_config"),tabId:z$1.string().min(1),changes:Ba.refine(e=>Object.keys(e).length>0,"update_tab_config needs at least one change")}),Va=a(e=>({viewId:e.viewId,tabId:e.tabId}),"updateTabConfigFocus"),Qc={type:"update_tab_config",schema:Hc,apply:a((e,t)=>S(e,t.viewId,r=>{let n=r.tabs.find(o=>o.id===t.tabId);if(!n)throw new h(`Tab "${t.tabId}" is not in view "${r.id}"`,[]);for(let o of Object.keys(t.changes)){let a=Yc[o];if(a&&!a.includes(n.type))throw new h(`"${o}" is not a setting of a "${n.type}" tab`,[])}return {...r,tabs:r.tabs.map(o=>o.id===t.tabId?{...o,...t.changes}:o)}}),"apply"),focus:Va,presentation:y(Va,"atomic",Ve),describe:a(e=>`Configure ${Object.keys(e.changes).join(", ")} sur l'onglet ${e.tabId}`,"describe")},Jc=z$1.object({...v,type:z$1.literal("update_table_tab"),tabId:z$1.string().min(1),changes:Ma.refine(e=>Object.keys(e).length>0,"update_table_tab needs at least one change")}),ja=a(e=>({viewId:e.viewId,tabId:e.tabId}),"updateTableTabFocus"),Xc={type:"update_table_tab",schema:Jc,apply:a((e,t)=>S(e,t.viewId,r=>{let n=r.tabs.find(l=>l.id===t.tabId);if(!n)throw new h(`Tab "${t.tabId}" is not in view "${r.id}"`,[]);if(n.type!=="table")throw new h(`Tab "${t.tabId}" is not a table tab`,[]);let o=Object.entries(t.changes),a=Object.fromEntries(o.filter(([,l])=>l!==null)),s=new Set(o.filter(([,l])=>l===null).map(([l])=>l));return {...r,tabs:r.tabs.map(l=>l.id===t.tabId?Object.fromEntries(Object.entries({...l,...a}).filter(([p])=>!s.has(p))):l)}}),"apply"),focus:ja,presentation:y(ja,"atomic",Ve),describe:a(e=>e.changes.columns?`Affiche ${e.changes.columns.length} colonne(s) dans l'onglet ${e.tabId}`:`Modifie l'onglet ${e.tabId}`,"describe")},Zc=z$1.object({...v,type:z$1.literal("set_side_panel"),sidePanel:z$1.object({attributes:z$1.array(z$1.string().min(1)),width:z$1.number().int().min(1).optional()}).nullable()}),ep={type:"set_side_panel",schema:Zc,apply:a((e,t)=>S(e,t.viewId,r=>({...r,config:{...r.config,sidePanel:t.sidePanel??void 0}})),"apply"),focus:Et,presentation:y(Et,"atomic",()=>["config","sidePanel"]),describe:a(e=>e.sidePanel?"Active le panneau lat\xE9ral":"Retire le panneau lat\xE9ral","describe")},Ua=[xc,Sc,Ec,Cc,kc,_c,Fc,jc,Mc,Uc,qc,Gc,Xc,Qc,ep];var je={...v,tabId:z$1.string().min(1)};function Nt(e){return {viewId:e.viewId}}a(Nt,"viewFocus");function ie(e){return {viewId:e.viewId,tabId:e.tabId}}a(ie,"tabFocus");function $a(e){return {viewId:e.viewId,tabId:e.tab.id}}a($a,"addTabFocus");function tp(e){let t=Object.keys(e.changes).sort();return t.length===1?[t[0]]:void 0}a(tp,"firstChangedProperty");function za(e){let t={...e};for(let r of qa$1)delete t[r];return t}a(za,"withoutKanbanKeys");function Ga(e){let t={...e};for(let r of pa$1)delete t[r];return t}a(Ga,"withoutTableKeys");function rp(e,t,r,n){let o=ja$1.safeParse(t);if(!o.success){if(!ja$1.safeParse(e).success)return t;let a=o.error.issues.map(s=>s.path.length?`${s.path.join(".")}: ${s.message}`:s.message).join(", ");throw new h(`List tab "${n}" in view "${r}" would no longer be publishable: ${a}`,[])}return t}a(rp,"assertStillPublishableTab");function kt(e,t,r,n){return S(e,t,o=>{let a=o.config.tabs??[];if(!a.some(s=>s.id===r))throw new h(`List tab "${r}" is not in view "${t}"`,[]);return {...o,config:{...o.config,tabs:a.map(s=>s.id===r?rp(s,n(s),t,r):s)}}})}a(kt,"mapListTab");var np=ja$1,Wa=$$1,ip=Z$1;function K(e,t,r,n){let o=z$1.object({...je,type:z$1.literal(e),value:r});return {type:e,schema:o,apply:a((a,s)=>kt(a,s.viewId,s.tabId,l=>{if(s.value===null){let{[t]:p,...I}=l;return I}return {...l,[t]:s.value}}),"apply"),focus:ie,presentation:y(ie,"atomic",()=>[String(t)]),describe:a(a=>n(a.value),"describe")}}a(K,"setOnTab");var op=z$1.object({...v,type:z$1.literal("add_list_tab"),tab:np}),ap={type:"add_list_tab",schema:op,apply:a((e,t)=>S(e,t.viewId,r=>{let n=r.config.tabs??[];if(n.some(o=>o.id===t.tab.id))throw new h(`List tab "${t.tab.id}" already exists in view "${t.viewId}"`,[]);return {...r,config:{...r.config,tabs:[...n,t.tab]}}}),"apply"),focus:$a,presentation:y($a,"local"),describe:a(e=>`Ajoute l'onglet \xAB ${e.tab.label} \xBB`,"describe")},sp=z$1.object({...je,type:z$1.literal("remove_list_tab")}),up={type:"remove_list_tab",schema:sp,apply:a((e,t)=>S(e,t.viewId,r=>{let n=r.config.tabs??[];if(!n.some(o=>o.id===t.tabId))throw new h(`List tab "${t.tabId}" is not in view "${t.viewId}"`,[]);return {...r,config:{...r.config,tabs:n.filter(o=>o.id!==t.tabId)}}}),"apply"),focus:ie,presentation:y(ie,"local"),describe:a(e=>`Supprime l'onglet ${e.tabId}`,"describe")},lp=z$1.object({...je,type:z$1.literal("update_list_tab"),changes:z$1.object({label:z$1.string().min(1).optional(),icon:c.optional(),default:z$1.boolean().optional(),visibility:z$1.enum(w$1).optional()}).refine(e=>Object.keys(e).length>0,"update_list_tab needs at least one change")}),qa=a(e=>({viewId:e.viewId,tabId:e.tabId}),"updateListTabFocus"),dp={type:"update_list_tab",schema:lp,apply:a((e,t)=>kt(e,t.viewId,t.tabId,r=>({...r,...t.changes})),"apply"),focus:qa,presentation:y(qa,"atomic",tp),describe:a(e=>e.changes.label?`Renomme l'onglet en \xAB ${e.changes.label} \xBB`:`Modifie l'onglet ${e.tabId}`,"describe")},cp=z$1.object({...v,type:z$1.literal("reorder_list_tabs"),tabOrder:z$1.array(z$1.string().min(1))}),pp={type:"reorder_list_tabs",schema:cp,apply:a((e,t)=>S(e,t.viewId,r=>({...r,config:{...r.config,tabs:Fe(r.config.tabs??[],t.tabOrder,"List tab")}})),"apply"),focus:Nt,presentation:y(Nt,"local"),describe:a(()=>"R\xE9ordonne les onglets","describe")},mp=K("set_columns","columns",z$1.array(z$1.string().min(1)),e=>`Affiche ${Array.isArray(e)?e.length:0} colonne(s)`),fp=K("set_column_sizing","columnSizing",z$1.record(z$1.string(),z$1.number().int().positive()),()=>"Ajuste la largeur des colonnes"),bp=z$1.object({...je,type:z$1.literal("set_layout"),value:z$1.enum(["table","list","kanban"])}),gp={type:"set_layout",schema:bp,apply:a((e,t)=>kt(e,t.viewId,t.tabId,r=>{if(t.value!=="kanban")return {...za(r),layout:t.value};if(r.groupByAttribute===void 0)throw new h(`List tab "${t.tabId}" cannot switch to kanban without a group attribute \u2014 use set_group_by, which switches the layout itself`,[]);return {...Ga(r),layout:"kanban"}}),"apply"),focus:ie,presentation:y(ie,"atomic",()=>["layout"]),describe:a(e=>`Passe en affichage ${e.value}`,"describe")},yp=z$1.object({...je,type:z$1.literal("set_group_by"),value:z$1.string().min(1).nullable()}),hp={type:"set_group_by",schema:yp,apply:a((e,t)=>kt(e,t.viewId,t.tabId,r=>t.value===null?{...za(r),layout:"table"}:{...Ga(r),layout:"kanban",groupByAttribute:t.value}),"apply"),focus:ie,presentation:y(ie,"atomic",()=>["groupByAttribute"]),describe:a(e=>e.value?`Regroupe par ${e.value} en kanban`:"Retire le regroupement, retour en table","describe")},Ap=K("set_filters","filters",Wa.nullable(),e=>e?"Modifie les filtres":"Retire les filtres"),Tp=K("set_sorts","sorts",ip.nullable(),e=>e?"Modifie le tri":"Retire le tri"),wp=K("set_create_mode","createMode",z$1.enum(["redirect","inline","peek"]),e=>`Cr\xE9ation en mode ${e}`),xp=K("set_read_only","readOnly",z$1.boolean(),e=>e?"Passe l'onglet en lecture seule":"Rend l'onglet modifiable"),Ip=K("set_card_user_attribute","cardUserAttribute",z$1.string().min(1).nullable(),e=>e?`Affiche ${e} sur les cartes`:"Retire l'utilisateur des cartes"),Sp=K("set_card_date_attribute","cardDateAttribute",z$1.string().min(1).nullable(),e=>e?`Affiche ${e} sur les cartes`:"Retire la date des cartes"),vp=K("set_description_attribute","descriptionAttribute",z$1.string().min(1).nullable(),e=>e?`Affiche ${e} en description`:"Retire la description"),Rp=K("set_display_attributes","displayAttributes",Y.nullable(),e=>`Affiche ${Array.isArray(e)?e.length:0} attribut(s)`),Ep=z$1.object({...v,type:z$1.literal("set_default_filters"),filters:Wa.nullable()}),Dp={type:"set_default_filters",schema:Ep,apply:a((e,t)=>S(e,t.viewId,r=>{if(t.filters===null){let{defaultFilters:n,...o}=r.config;return {...r,config:o}}return {...r,config:{...r.config,defaultFilters:t.filters}}}),"apply"),focus:Nt,presentation:y(Nt,"atomic",()=>["config","defaultFilters"]),describe:a(e=>e.filters?"Modifie les filtres de la vue":"Retire les filtres de la vue","describe")},Ka=[Dp,ap,up,dp,pp,mp,fp,gp,hp,Ap,Tp,wp,xp,Ip,Sp,vp,Rp];function Cp(e){return {id:e.id??e.name,name:e.name,label:e.label,...e.icon===void 0?{}:{icon:e.icon}}}a(Cp,"toDraftableObject");function Np(e){let t=e.id??e.name;return (e.attributes??[]).map(r=>kp(r,t))}a(Np,"toDraftableAttributes");function ni(e){return {id:e.id,name:e.name,label:e.label,type:e.attributeType,...e.config}}a(ni,"toAttribute");function kp(e,t){let{id:r,name:n,label:o,type:a,...s}=e;return {id:e.id??e.name,objectId:t,name:e.name,label:e.label??e.name,attributeType:e.type,config:s}}a(kp,"toDraftableAttribute");function Pt(e,t){if(!e.objects.some(r=>r.id===t))throw new h(`Object "${t}" is not in the draftable state`,[])}a(Pt,"requireObject");function Ot(e){return {objectId:e.objectId}}a(Ot,"objectFocus");function _t(e){return {objectId:e.objectId,recordId:e.recordId}}a(_t,"recordFocus");function Se(e){return {objectId:e.objectId,attributeId:e.attributeId}}a(Se,"attributeFocus");function Op(e){let t=Object.keys(e.changes).sort();return t.length===1?[t[0]]:void 0}a(Op,"firstChangedProperty");var oe={...ti,objectId:z$1.string().uuid()},_p=z$1.object({...oe,type:z$1.literal("add_object"),name:Xe,label:z$1.string().min(1),icon:z$1.string().min(1).optional()}),Pp={type:"add_object",schema:_p,apply:a((e,t)=>{if(e.objects.some(n=>n.name===t.name))throw new h(`Object "${t.name}" already exists`,[]);if(e.objects.some(n=>n.id===t.objectId))throw new h(`Object id "${t.objectId}" is already taken`,[]);let r={id:t.objectId,name:t.name,label:t.label,...t.icon===void 0?{}:{icon:t.icon}};return {...e,objects:[...e.objects,r]}},"apply"),focus:Ot,presentation:y(Ot,"structural"),describe:a(e=>`Cr\xE9e l'objet \xAB ${e.label} \xBB`,"describe")},Fp=z$1.object({...oe,type:z$1.literal("update_object"),changes:z$1.object({label:z$1.string().min(1).optional(),icon:z$1.string().min(1).optional()}).refine(e=>Object.keys(e).length>0,"update_object needs at least one change")}),Ya=a(e=>({objectId:e.objectId}),"updateObjectFocus"),Vp={type:"update_object",schema:Fp,apply:a((e,t)=>(Pt(e,t.objectId),{...e,objects:e.objects.map(r=>r.id===t.objectId?{...r,...t.changes}:r)}),"apply"),focus:Ya,presentation:y(Ya,"atomic",Op),describe:a(e=>e.changes.label?`Renomme l'objet en \xAB ${e.changes.label} \xBB`:"Modifie l'objet","describe")},jp=z$1.object({...oe,type:z$1.literal("remove_object")}),Lp={type:"remove_object",schema:jp,apply:a((e,t)=>{Pt(e,t.objectId);let r=e.objects.find(n=>n.id===t.objectId)?.name;return {...e,objects:e.objects.filter(n=>n.id!==t.objectId),attributes:e.attributes.filter(n=>n.objectId!==t.objectId),sampleRecords:e.sampleRecords.filter(n=>n.objectId!==t.objectId),views:e.views.filter(n=>n.objectName!==r)}},"apply"),focus:Ot,presentation:y(Ot,"structural"),describe:a(e=>`Supprime l'objet ${e.objectId}`,"describe")},Le=Vi.filter(e=>e!=="formula"&&e!=="rollup"),Mp=z$1.object({...oe,type:z$1.literal("add_attribute"),attributeId:z$1.string().min(1),name:po,label:z$1.string().min(1),attributeType:z$1.enum(Le),config:z$1.record(z$1.string(),z$1.unknown()).optional()}).superRefine((e,t)=>{try{n(e.attributeType,e.config??{});}catch(r){if(r instanceof h){for(let n of r.errors)t.addIssue({code:"custom",message:n.message,path:["config",...n.path??[]]});return}throw r}}),Bp={type:"add_attribute",schema:Mp,apply:a((e,t)=>{if(Pt(e,t.objectId),e.attributes.some(n=>n.objectId===t.objectId&&n.name===t.name))throw new h(`Attribute "${t.name}" already exists on object "${t.objectId}"`,[]);let r={id:t.attributeId,objectId:t.objectId,name:t.name,label:t.label,attributeType:t.attributeType,...t.config===void 0?{}:{config:t.config}};for(let n of e.sampleRecords)n.objectId===t.objectId&&Ha(n.id,r,n.values);return {...e,attributes:[...e.attributes,r]}},"apply"),focus:Se,presentation:y(Se,"local"),describe:a(e=>`Ajoute l'attribut \xAB ${e.label} \xBB`,"describe")},Up=z$1.object({...oe,type:z$1.literal("update_attribute"),attributeId:z$1.string().min(1),changes:z$1.object({label:z$1.string().min(1).optional()}).refine(e=>Object.keys(e).length>0,"update_attribute needs at least one change")}),$p={type:"update_attribute",schema:Up,apply:a((e,t)=>{if(!e.attributes.some(r=>r.id===t.attributeId))throw new h(`Attribute "${t.attributeId}" is not in the draftable state`,[]);return {...e,attributes:e.attributes.map(r=>r.id===t.attributeId?{...r,...t.changes}:r)}},"apply"),focus:Se,presentation:y(Se,"atomic"),describe:a(e=>e.changes.label?`Renomme l'attribut en \xAB ${e.changes.label} \xBB`:"Modifie l'attribut","describe")},qp=z$1.object({...oe,type:z$1.literal("remove_attribute"),attributeId:z$1.string().min(1)}),zp={type:"remove_attribute",schema:qp,apply:a((e,t)=>{let r=e.attributes.find(o=>o.id===t.attributeId);if(!r)throw new h(`Attribute "${t.attributeId}" is not in the draftable state`,[]);let n=e.sampleRecords.find(o=>o.objectId===r.objectId&&r.name in o.values);if(n)throw new h(`Attribute "${r.name}" is still used by sample record "${n.id}"`,[]);return {...e,attributes:e.attributes.filter(o=>o.id!==t.attributeId)}},"apply"),focus:Se,presentation:y(Se,"local"),describe:a(e=>`Supprime l'attribut ${e.attributeId}`,"describe")};function Gp(e,t,r,n){let o=ni(r);try{c$2(o);}catch{return}let a=g$1(o,n);if(a.success)return;let s=a.errors??[],l=s.map(p=>p.message).join(", ");throw new h(`Sample record "${e}" has an invalid value for "${t}": ${l}`,s.map(p=>({path:p.path,message:p.message})))}a(Gp,"assertSampleValue");function Ha(e,t,r){if(t.config?.required===true&&t.config?.defaultValue===void 0&&!(t.name in r&&r[t.name]!==void 0))throw new h(`Sample record "${e}" is missing a value for required attribute "${t.name}"`,[])}a(Ha,"assertRequiredCovered");var Wp=z$1.object({...oe,type:z$1.literal("add_sample_record"),recordId:z$1.string().uuid(),values:z$1.record(z$1.string(),z$1.unknown())}),Kp={type:"add_sample_record",schema:Wp,apply:a((e,t)=>{if(Pt(e,t.objectId),e.sampleRecords.some(n=>n.id===t.recordId))throw new h(`Sample record "${t.recordId}" already exists`,[]);let r=new Map(e.attributes.filter(n=>n.objectId===t.objectId).map(n=>[n.name,n]));for(let[n,o]of Object.entries(t.values)){let a=r.get(n);if(!a)throw new h(`Sample record "${t.recordId}" uses unknown attribute "${n}"`,[]);Gp(t.recordId,n,a,o);}for(let n of r.values())Ha(t.recordId,n,t.values);return {...e,sampleRecords:[...e.sampleRecords,{id:t.recordId,objectId:t.objectId,values:t.values}]}},"apply"),focus:_t,presentation:y(_t,"local"),describe:a(()=>"Ajoute un exemple","describe")},Yp=z$1.object({...oe,type:z$1.literal("remove_sample_record"),recordId:z$1.string().min(1)}),Hp={type:"remove_sample_record",schema:Yp,apply:a((e,t)=>{if(!e.sampleRecords.some(r=>r.id===t.recordId&&r.objectId===t.objectId))throw new h(`Sample record "${t.recordId}" is not in object "${t.objectId}"`,[]);return {...e,sampleRecords:e.sampleRecords.filter(r=>r.id!==t.recordId)}},"apply"),focus:_t,presentation:y(_t,"local"),describe:a(()=>"Retire un exemple","describe")},Qa=[Pp,Vp,Lp,Bp,$p,zp,Kp,Hp];function Qp(){let e=new Map;for(let t of [...Qa,...Ua,...Ka]){if(e.has(t.type))throw new r("architect operation",t.type);e.set(t.type,t);}return e}a(Qp,"build");var ce=Qp(),ii=[...ce.keys()];function Me(e){let t=ce.get(e.type);if(!t)throw new h(`Operation "${e.id}" has unknown type "${e.type}"`,[]);return t}a(Me,"defOf");function oi(e,t){return t.reduce((r,n)=>Me(n).apply(r,n),e)}a(oi,"applyOperations");function Jp(e){return Me(e).focus(e)}a(Jp,"focusOf");function Xp(e,t){return e.map(r=>Me(r).describe(r,t))}a(Xp,"describeOperations");function Zp(e){if(typeof e!="object"||e===null||!("type"in e))throw new h("An operation must be an object carrying a type",[]);let t=e.type;if(typeof t!="string")throw new h("An operation's type must be a string",[]);let r=ce.get(t);if(!r)throw new h(`Unknown operation type "${t}"`,[]);let n=r.schema.safeParse(e);if(!n.success)throw new h(`Operation "${t}" is invalid: ${n.error.issues.map(o=>`${o.path.join(".")} ${o.message}`).join("; ")}`,[]);return n.data}a(Zp,"parseOperation");function Ja(e){return z$1.toJSONSchema(e,{io:"input"})}a(Ja,"toJsonSchema");function tm(e){let t=ce.get(e);if(!t)throw new h(`Unknown operation type "${e}"`,[]);return Ja(t.schema)}a(tm,"describeOperationInput");function rm(e){let t=Le.find(r=>r===e);if(!t)throw new h(`Unknown attribute type "${e}"`,[]);return Ja(m(t))}a(rm,"describeAttributeConfig");function nm(){return {operations:[...ii],attributeTypes:[...Le]}}a(nm,"listDescribableNames");function Xa(e,t,r){let n=`fld_${e}_${t}`;return r===0?n:`${n}_${r}`}a(Xa,"makeFieldId");function im(e,t){return e.attributeGroup?e.attributeGroup.id:e.attribute?e.attribute:`slot${t}`}a(im,"seedOf");function om(e){let t=new Map,r=e.fields.map((n,o)=>{if(n.id)return n;let a=im(n,o),s=t.get(a)??0;return t.set(a,s+1),{...n,id:Xa(e.id,a,s)}});return {...e,fields:r}}a(om,"withIds");function am(e){return e.map(t=>t.type==="form"?{...t,groups:t.groups.map(om)}:t)}a(am,"ensureFieldIds");function ai(e){return Me(e).presentation(e)}a(ai,"presentationOf");function sm(e){let t=e.map(ai);return new Set(t.map(({focus:n})=>n.viewId??n.objectId).filter(n=>n!==void 0)).size>1||t.some(({impact:n})=>n==="structural")?"structural":t.some(({impact:n})=>n==="local")?"local":"atomic"}a(sm,"episodeImpactOf");function um(e,t){return e.config.tabs?.find(r=>r.id===t)}a(um,"listTabOf");function Za(e,t){let r=t.viewId?e.views.find(o=>o.id===t.viewId):void 0,n=t.tabId?r?.tabs.find(o=>o.id===t.tabId):void 0;if(t.attributeId)return e.attributes.find(o=>o.id===t.attributeId);if(t.fieldId){if(n?.type!=="form")return;for(let o of n.groups){let a=o.fields.find(s=>s.id===t.fieldId);if(a)return a}return}if(t.groupId)return n?.type!=="form"?void 0:n.groups.find(o=>o.id===t.groupId);if(t.tabId)return r?n??um(r,t.tabId):void 0;if(t.recordId)return e.sampleRecords.find(o=>o.id===t.recordId);if(r)return r;if(t.objectId)return e.objects.find(o=>o.id===t.objectId)}a(Za,"snapshotArchitectTarget");function lm(e,t){let r=e;return t.map(n=>{let o=ai(n),a=Za(r,o.focus);r=oi(r,[n]);let s=Za(r,o.focus);return {operationId:n.id,operationType:n.type,presentation:o,before:a,after:s}})}a(lm,"deriveArchitectChanges");function dm(e){return {id:e.id??"",objectName:e.object,type:e.type,label:e.label,tabs:Ke(e)?e.config.tabs??[]:[],config:e.config}}a(dm,"toDraftableView");function cm(e,t){return e.type==="detail"?{...e,label:t.label,config:{...t.config,tabs:t.tabs}}:{...e,label:t.label,config:t.config}}a(cm,"fromDraftableView");export{BT as AGENT_UI_BATCH_MAX_BYTES,UT as AGENT_UI_BATCH_MAX_ITEMS,Xi as ALLOWED_PROPERTY_TYPES,Kt as ALL_ACTIONS,ii as ALL_OPERATION_TYPES,hh as ALL_SYSTEM_RESOURCES,Gb as ARTIFACT_FILE_ROLES,qb as ARTIFACT_KINDS,$u as ARTIFACT_LIST_VIEW,Uu as ARTIFACT_OBJECT,Nn as ARTIFACT_OBJECT_NAME,zb as ARTIFACT_RETENTIONS,Vi as ATTRIBUTE_TYPES,ab as AUDIT_ACTIONS,ob as AUDIT_RESOURCE_TYPES,Kr as ActivityTabConfig,Xt as AgentBuilder,Qf as BEHAVIOR_PROPERTIES,js as BYTE_UNIT_LABELS,xs as CLAIMABLE_SESSION_STATUSES,_e as COMPUTED_FUNCTIONS,Sw as COMPUTED_FUNCTION_METADATA,nw as COMPUTED_FUNCTION_NAMES,Qw as CONNECTOR_CALLBACK_PARAM,Qi as COUNT_MODES,b as ComputedFormulaCompileError,Gr as CustomTabConfig,gh as DB_COLUMN_FIELDS,bo as DEFAULT_AGENT_EXECUTION_CONFIG,Li as DEFAULT_APPROVAL_POLICY,Ub as DEFAULT_DICTATION_LIMITS,ro as DEFAULT_LABEL_FALLBACK,ks as DEFAULT_MEETING_BOT_DISPLAY_NAME,pu as DEFAULT_ROLES,wh as DEFAULT_ROLE_DESCRIPTIONS,Th as DEFAULT_ROLE_LABELS,xh as DEFAULT_ROLE_PERMISSIONS,wg as DEFAULT_TENANT_SETTINGS,Mb as DICTATION_FINALIZATION_TIMEOUT_MS,_b as DICTATION_FRAME_BYTES,Fb as DICTATION_MAX_BUFFER_BYTES,Pb as DICTATION_MAX_FRAME_BYTES,Vb as DICTATION_MAX_TRANSCRIPT_BYTES,Bb as DICTATION_MODEL_ID,Lb as DICTATION_PREPARATION_TIMEOUT_MS,Ob as DICTATION_SAMPLE_RATE,jb as DICTATION_TICKET_TTL_MS,_y as DOCUMENT_SYSTEM_ATTRIBUTES,Le as DRAFTABLE_ATTRIBUTE_TYPES,Bu as DRIVE_LIST_VIEW,Lu as DRIVE_OBJECT,ct as DRIVE_OBJECT_NAME,Mu as DRIVE_VIEW,Jr as DetailViewBuilder,Qr as DocumentsTabConfig,He as EMPTY_VALUE_PLACEHOLDER,Fg as ESTIMATED_COUNT_CAP,Yr as EmailsTabConfig,ex as FAKE_MEETING_BOT_SIGNATURE_HEADER,zt as FORM_FORBIDDEN_ATTRIBUTE_TYPES,Ne as FlagRegistry,dt as FlagService,Lr as FormBuilder,Oe as FormRegistry,Vr as FormRowBuilder,jr as FormStepBuilder,ot as GroupBuilder,Hf as IDENTITY_PROPERTIES,kg as IMAGE_FORMATS,Ui as INFERENCE_REASONING_OPTIONS,Bi as INFERENCE_SPEEDS,il as LIVE_EVENT_TYPES,Xr as ListViewBuilder,Zr as ListViewTabConfigBuilder,zi as MAX_PRESET_DEPTH,wb as MAX_TODOS,Ib as MAX_TODO_DESCRIPTION_CHARS,xb as MAX_TODO_ID_CHARS,Sb as MAX_TODO_RESULT_CHARS,T as MEETING_ATTRIBUTES,Ro as MEETING_DETAIL_VIEW_ID,Gu as MEETING_LIST_VIEW,So as MEETING_LIST_VIEW_ID,qu as MEETING_OBJECT,pt as MEETING_OBJECT_NAME,zu as MEETING_VIEW,vo as MEETING_WRITE_SOURCE,ju as MEMORY_LIST_VIEW,Fu as MEMORY_OBJECT,Vu as MEMORY_VIEW,Hr as MeetingsTabConfig,vs as NATIVE_AGENT_UI_PART_IDS_METADATA_KEY,Rs as NATIVE_AGENT_UI_PART_IDS_METADATA_SCHEMA_VERSION,Pi as NOTIFICATION_INBOX_STATES,ki as NOTIFICATION_KINDS,Oi as NOTIFICATION_PRIORITIES,_i as NOTIFICATION_SENSITIVITIES,Kf as NOTIFICATION_TYPES_V1,Ts as NOTIFICATION_TYPE_AGENT_QUESTION_REQUESTED,hs as NOTIFICATION_TYPE_AGENT_SESSION_WAITING_HUMAN,As as NOTIFICATION_TYPE_AGENT_TASK_ASSIGNED,Fi as NOTIFICATION_WORK_STATES,tx as NO_RECORDING,Ki as NoopGeocodingAdapter,Xe as OBJECT_NAME_SCHEMA,Is as OPEN_TOOL_PART_STATES,ce as OPERATION_REGISTRY,St as OPERATOR_SPECS,qr as ObjectBuilder,Jf as PRESENTATION_PROPERTIES,Mi as PROVIDER_NAMES,By as QUALIFIED_SEPARATOR,Xw as RECORDING_OVERRIDES,Zw as RECORDING_POLICIES,uo as RECORD_CREATOR_ROOT_ACTOR_METADATA_KEY,$t as RELATION_TARGET_ANY,Wr as RichtextTabConfig,$ as SCHEMA_PLAN_LIMITS,Qn as SCHEMA_SOURCE_ID_PATTERN,Db as SESSION_STATE_STREAM_ID,ws as SESSION_TERMINAL_STATUSES,wo as SKILL_CONTENT_TEMPLATE,Ou as SKILL_LIST_VIEW,Nu as SKILL_OBJECT,ku as SKILL_VIEW,yu as STANDARD_SCHEMA_VENDOR,qt as SYSTEM_PART_CODES,L as SYSTEM_RESOURCES,Ah as SYSTEM_RESOURCE_LABELS,ra as TODAY_DEFAULT,fb as TODO_PLAN_STATUSES,Tb as TODO_STATUSES,$i as TOOL_APPROVAL_STATES,Q as TabBuilder,at as TableTabConfig,Wc as UPDATE_TABLE_TAB_CHANGE_KEYS,vc as UPDATE_TAB_CHANGE_KEYS,Kc as UPDATE_TAB_CONFIG_CHANGE_KEYS,Ig as USER_STATUSES,Sg as USER_WORK_POSTURES,bg as accessLevelToActions,fg as actionsToAccessLevel,Fh as agent,Ox as agentDataChunk,bb as agentDisplayName,Cx as agentInferencePreferencesSchema,lc as agentMessageAttachmentSchema,uc as agentMessagePartSchema,sc as agentSessionInferenceOverridesInputSchema,Nx as agentSessionInferenceOverridesSchema,Aa as agentSessionMessageSchema,gc as agentUIValidationError,oi as applyOperations,Zs as applyPipes,iu as applyRelationProps,uw as assertAcyclicComputedDependencies,yc as assertCustomAgentUIMessageChunk,Yd as assertSchemaSourceId,Tu as booleanFlag,ia as buildAgentFallbackTitle,cu as buildPermissionFlags,Ye as buildPropertySchema,$y as buildQualifiedAttribute,go as checkbox,Ss as compareAgentSessionMessages,Bo as compileComputedFormula,pw as compileRollupAttribute,Vs as computeByteMagnitude,Kd as conversationDisplayTitle,vu as createFlagRegistry,Eu as createFlagService,et as createStandardSchemaProps,Yh as currency,Sa as customDataChunkSchemas,U as date,vt as dateInTimezone,fe as dateValueStart,Rt as defineOperation,y as definePresentation,lm as deriveArchitectChanges,Kw as deriveCreateDefaultsFromFilters,lu as deriveInitials,rm as describeAttributeConfig,tm as describeOperationInput,Xp as describeOperations,fa as destructiveSchema,ee as detailView,yo as document,pc as durableDateSchema,am as ensureFieldIds,sm as episodeImpactOf,Aw as evaluateComputedAst,Tw as evaluateComputedFormula,ww as evaluateComputedFormulaWithResult,Md as evaluateFilterState,Mw as evaluateRecordFilterState,oo as extractAttributeNames,so as extractValueRefs,Su as flagRegistry,Jp as focusOf,sA as form,Ns as formFieldFlatKey,Cs as formFieldKey,Co as formRegistry,VT as formatAgentStreamFrameId,Zi as formatAttributeValue,Dy as formatByteSize,Pd as formatComputedResult,Gs as formatLocationValue,Zh as formula,cm as fromDraftableView,_n as generateDefaultDetailView,Pn as generateDefaultListView,vT as getActiveTab,ru as getEditableLabelAttribute,Yb as getErrorMessage,Ls as getListViewDisplayAttributeNames,ZT as getLiveProtocolPayloadChannel,du as getRecordCreatorPrincipalId,ao as getSingleAttributeFromExpression,Wi as getSlotFieldTargets,su as getUserDisplayName,SA as group,dx as hasDestructiveEntries,hg as hasOptions,xa as imageModelIdSchema,ge as includesAction,tb as inferInverseCardinality,Td as inferRollupReturnType,ei as inferenceReasoningSchema,Zn as inferenceSpeedSchema,bc as isAgentUIDataName,$T as isAgentUIMessageBatch,rb as isAttributeSortable,eb as isBilateralRelation,Dw as isCheckboxEquality,mb as isClaimableSessionStatus,bt as isComputedFunctionName,Z as isDateRangeValue,Ih as isDefaultRole,Ke as isDetailView,Py as isDocumentAttribute,Ps as isEmptyObject,Os as isFieldGroup,Xb as isFormDefinition,We as isFormFieldsRow,Gt as isFormFreeFieldRef,og as isFormHeadingRow,ag as isFormSeparatorRow,Gi as isFormSlotFieldRef,sg as isFormTextRow,Je as isLabelExpression,Hi as isListView,ew as isLiveEventEnvelope,HT as isLiveEventPayload,ml as isLiveEventPayloadForType,pl as isLiveEventType,Ji as isNotEmpty,gb as isOpenToolPartState,Yo as isPlainRecord,Lh as isStandardSchema,hb as isSystemPartCode,pb as isTerminalSessionStatus,lb as isTerminalState,yb as isToolApprovalState,ji as isUniversalRelation,Iu as jsonFlag,cb as legacyStatusToSessionState,nm as listDescribableNames,G as listView,GT as liveChannelKey,Jh as location,Xa as makeFieldId,Fy as matchesAccepts,dc as mentionReferenceSchema,cc as modelDefinitionSchema,wa as modelReferenceSchema,Qh as multiselect,Ds as nativeAgentUIPartIdMetadataKey,Ms as normalizeDateValue,rt as number,xu as numberFlag,z as object,Ab as orderAgentSessionMessages,jT as parseAgentStreamFrameId,_s as parseCountMode,ko as parseLiveChannelKey,Cb as parseNativeAgentUIPartIdsMetadata,Zp as parseOperation,Pg as parseOptionalCountMode,Uy as parseQualifiedAttribute,rc as persistedDefaultViewTargetSchema,Ix as persistedSchemaPlanSchema,Kh as phone,Xd as plannedAttributeSchema,Zd as plannedInlineAttributeSchema,ec as plannedObjectSchema,ai as presentationOf,tc as proposedDefaultViewTargetSchema,Ta as providerNameSchema,au as qualifiedPropertyDefs,rg as readFormFieldValue,KA as registry,Ae as relation,ou as relationPropertyDefs,Ht as renderLabelExpression,Zu as resetViewToDefault,zd as resolveAttributeDefaultValue,tg as resolveFieldRequired,Yi as resolvePropertyDefinitions,he as richtext,eA as rollup,Ad as rollupToFormulaExpression,xx as schemaPlanSchema,q as select,kx as sessionInferencePatchSchema,db as sessionStateToLegacyStatus,Hh as status,wu as stringFlag,f as text,ni as toAttribute,Np as toDraftableAttributes,Cp as toDraftableObject,dm as toDraftableView,Fs as toUndefinedIfEmpty,mc as todoItemSchema,fc as todoPlanSchema,Ia as toolImpactSchema,Xh as user,Ce as validateAttributeName,Xs as validateLabelExpression,De as validateObjectName,Ze as validateViewName,Wu as viewRegistry,Rg as viewStateKey,Hd as viewSyncPayload};
60
+ `)}debug(t){let r=this.summary();return t?.(r),r}makeKey(t,r,n){return `${t}:${r}:${n}`}};a(On,"ViewRegistry");var kn=On,Ku=new kn;function Eo(e,t=[]){return e.filter(r=>!(!j(r).lifecycle.visibleInRuntime||r.system||t.includes(r.name)))}a(Eo,"getRuntimeAttributes");function Do(e){return [...e].sort((t,r)=>{let n=t.order??999,o=r.order??999;return n!==o?n-o:t.name.localeCompare(r.name)})}a(Do,"sortAttributes");function Yu(e){if(e.type==="text"&&e.multiline)return 12;switch(e.type){case "richtext":case "location":return 12;case "checkbox":return 4;default:return 6}}a(Yu,"getDefaultFieldSpan");function Hu(e){return {attribute:e.name,span:Yu(e)}}a(Hu,"attributeToField");function _n(e,t={}){let{includeActivityTab:r=true,includeDocumentsTab:n=true,excludeAttributes:o=[]}=t,a=Eo(e.attributes,o),p=[{id:"form",name:"form",label:"Details",type:"form",groups:[{id:"general",label:"General",type:"fields",fields:Do(a.filter(ae=>j(ae).presentation.formField)).map(Hu),order:0}],order:0}],I=1,X=e.attributes.some(ae=>ae.type==="document");n&&X&&p.push({id:"documents",name:"documents",label:"Documents",type:"documents",order:I++,allowUpload:true,allowRemove:true}),r&&p.push({id:"activity",name:"activity",label:"Activity",type:"activity",order:I++});let B={tabs:p};return {name:"default",label:"Default View",object:e.name,type:"detail",config:B,default:true}}a(_n,"generateDefaultDetailView");function Pn(e,t={}){let{excludeAttributes:r=[],maxListColumns:n=5}=t,o=Eo(e.attributes,r),l={tabs:[{id:"all",label:"All",default:true,visibility:"workspace",layout:"table",columns:Do(o.filter(p=>j(p).presentation.defaultColumn)).slice(0,n).map(p=>p.name)}]};return {name:"default",label:"All Records",object:e.name,type:"list",config:l,default:true}}a(Pn,"generateDefaultListView");function Qu(e,t){let{preserveCustomTabs:r=true,preserveTableTabs:n=true}=t,o=[];for(let a of e.config.tabs)r&&a.type==="custom"&&o.push(a),n&&a.type==="table"&&o.push(a);return o}a(Qu,"getPreservedDetailTabs");function Ju(e,t){if(t.length===0)return e;let r=e.find(s=>s.type==="form"),n=e.filter(s=>s.type!=="form"),o=[];r&&o.push(r);let a=1;for(let s of t)o.push({...s,order:a++});for(let s of n)o.push({...s,order:a++});return o}a(Ju,"mergeDetailTabs");function Xu(e,t,r){let{preserveMetadata:n=true,...o}=r,a=_n(t,o),s=Qu(e,r),l=Ju(a.config.tabs,s),p={...a.config,tabs:l},I={...a,config:p};return n&&(I.id=e.id,I.name=e.name,I.label=e.label,I.description=e.description,I.icon=e.icon),I}a(Xu,"resetDetailViewToDefault");function Zu(e,t,r){let{preserveMetadata:n=true,...o}=r,s={...Pn(t,o)};return n&&(s.id=e.id,s.name=e.name,s.label=e.label,s.description=e.description,s.icon=e.icon),s}a(Zu,"resetListViewToDefault");function el(e,t,r={}){if(Ke(e))return Xu(e,t,r);if(Hi(e))return Zu(e,t,r);throw new Error(`Reset not supported for view type: ${e.type}`)}a(el,"resetViewToDefault");function NT(e,t){if(t){let r=e.tabs.find(n=>n.id===t);if(r)return r}return e.tabs.find(r=>r.default)??e.tabs[0]}a(NT,"getActiveTab");function Fn(e){return structuredClone(e)}a(Fn,"cloneFormDefinition");var Vn=class Vn{constructor(){this.forms=new Map;}register(t){let r$1=Array.isArray(t)?t:[t];for(let n of r$1){if(this.forms.has(n.name))throw new r("form",n.name,`[FormRegistry] Duplicate form: "${n.name}"`);this.forms.set(n.name,Fn(n));}return this}get(t){let r=this.forms.get(t);return r?Fn(r):void 0}getAll(){return Array.from(this.forms.values(),Fn)}listNames(){return Array.from(this.forms.keys())}};a(Vn,"FormRegistry");var Oe=Vn;var Co=new Oe;function UT(e,t){return `${e}:${t}`}a(UT,"formatAgentStreamFrameId");function $T(e){let t=e.lastIndexOf(":");if(t<=0)return null;let r=e.slice(0,t),n=Number(e.slice(t+1));return !Number.isInteger(n)||n<=0?null:{streamId:r,sequence:n}}a($T,"parseAgentStreamFrameId");var GT=204800,WT=256;function Mn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a(Mn,"isRecord");function Ln(e,t){let r=Object.keys(e);return r.length===t.length&&r.every(n=>t.includes(n))}a(Ln,"hasExactKeys");function jn(e){return typeof e=="number"&&Number.isInteger(e)&&e>0}a(jn,"isPositiveInteger");function No(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0}a(No,"isNonNegativeInteger");function tl(e){return Mn(e)&&Ln(e,["kind","startOffset","endOffset"])?(e.kind==="text"||e.kind==="reasoning")&&No(e.startOffset)&&No(e.endOffset)&&e.endOffset>=e.startOffset:false}a(tl,"isContentRange");function rl(e){if(!Mn(e))return false;let t=e.content===void 0?["sequence","chunk"]:["sequence","content","chunk"];return Ln(e,t)&&jn(e.sequence)&&e.chunk!==void 0&&(e.content===void 0||tl(e.content))}a(rl,"isBatchItem");function nl(e){try{return new TextEncoder().encode(JSON.stringify(e)).byteLength}catch{return}}a(nl,"encodedSize");function KT(e){if(!(Mn(e)&&Ln(e,["schemaVersion","batchId","tenantId","sessionId","streamId","sequenceStart","sequenceEnd","items"]))||e.schemaVersion!==1||typeof e.batchId!="string"||e.batchId.trim()===""||typeof e.tenantId!="string"||e.tenantId.trim()===""||typeof e.sessionId!="string"||e.sessionId.trim()===""||typeof e.streamId!="string"||e.streamId.trim()===""||!jn(e.sequenceStart)||!jn(e.sequenceEnd)||!Array.isArray(e.items)||e.items.length===0||e.items.length>256||!e.items.every(rl))return false;let t=0;for(let n of e.items){if(n.sequence<=t)return false;t=n.sequence;}if(e.items[0]?.sequence!==e.sequenceStart||e.items.at(-1)?.sequence!==e.sequenceEnd)return false;let r=nl(e);return r!==void 0&&r<=204800}a(KT,"isAgentUIMessageBatch");function QT(e){switch(e.kind){case "workspace":return `workspace:${encodeURIComponent(e.tenantId)}`;case "object":return `object:${encodeURIComponent(e.objectId)}`;case "record":return `record:${encodeURIComponent(e.objectId)}:${encodeURIComponent(e.recordId)}`;case "view":return `view:${encodeURIComponent(e.viewId)}`;case "user":return `user:${encodeURIComponent(e.actorId)}`;case "conversation":return `conversation:${encodeURIComponent(e.sessionId)}`;case "architect-draft":return `architect-draft:${encodeURIComponent(e.actorId)}`}}a(QT,"liveChannelKey");function te(e){try{return decodeURIComponent(e)}catch{return null}}a(te,"decodeLiveChannelPart");function ko(e){let t=e.split(":");if(t[0]==="workspace"&&t.length===2&&t[1]){let r=te(t[1]);return r?{kind:"workspace",tenantId:r}:null}if(t[0]==="object"&&t.length===2&&t[1]){let r=te(t[1]);return r?{kind:"object",objectId:r}:null}if(t[0]==="record"&&t.length===3&&t[1]&&t[2]){let r=te(t[1]),n=te(t[2]);return r&&n?{kind:"record",objectId:r,recordId:n}:null}if(t[0]==="view"&&t.length===2&&t[1]){let r=te(t[1]);return r?{kind:"view",viewId:r}:null}if(t[0]==="user"&&t.length===2&&t[1]){let r=te(t[1]);return r?{kind:"user",actorId:r}:null}if(t[0]==="architect-draft"&&t.length===2&&t[1]){let r=te(t[1]);return r?{kind:"architect-draft",actorId:r}:null}if(t[0]==="conversation"&&t.length===2&&t[1]){let r=te(t[1]);return r?{kind:"conversation",sessionId:r}:null}return null}a(ko,"parseLiveChannelKey");var il={"record.patch":true,"record.deleted":true,"record.removed":true,"record.created":true,"view.projection.stale":true,"agent.session.patch":true,"notification.created":true,"notification.recipient.patch":true,"notification.count.patch":true,"notification.inbox.archived":true,"reflex.state.changed":true,"reflex.run.completed":true,"reflex.authoring.progress":true,"architect.draft.updated":true,"meeting.recording.patch":true,"wallet.state":true,"channel.revoked":true},ol=Object.keys(il),al=["membership-unknown","sort-unknown","permissions-changed"],sl=["permission-revoked","workspace-left","object-deleted"],ul=["inboxState","workState","lockedAt","lockedByActorId","readAt","archivedAt","snoozedUntil","completedAt","dismissedAt","updatedAt"],ll=["type","objectId","recordId","recordVersion"],dl=["type","objectId","recordId","recordVersion","record"],cl=["id","objectId","visibility","ownedBy","label","values","metadata","createdAt","updatedAt","createdBy","lastUpdatedBy","schemaVersion"],pl=["type","targetActorId","archivedCount","version","updatedAt"];function ml(e){return typeof e=="string"&&ol.includes(e)}a(ml,"isLiveEventType");function ew(e){return C(e)&&ml(e.type)?fl(e.type,e):false}a(ew,"isLiveEventPayload");function fl(e,t){if(!C(t))return false;switch(e){case "record.patch":return wl(t);case "record.deleted":return xl(t);case "record.removed":return Il(t);case "record.created":return vl(t);case "view.projection.stale":return Rl(t);case "agent.session.patch":return El(t);case "notification.created":return kl(t);case "notification.recipient.patch":return Ol(t);case "notification.count.patch":return _l(t);case "notification.inbox.archived":return Pl(t);case "reflex.state.changed":return Bl(t);case "reflex.run.completed":return Ul(t);case "reflex.authoring.progress":return $l(t);case "architect.draft.updated":return Ll(t);case "meeting.recording.patch":return zl(t);case "wallet.state":return Kl(t);case "channel.revoked":return Yl(t);default:return false}}a(fl,"isLiveEventPayloadForType");function C(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a(C,"isRecord");function F(e){return typeof e=="string"}a(F,"isString");function Oo(e){return F(e)&&e.length>0}a(Oo,"isNonEmptyString");function mt(e){return e===null||F(e)}a(mt,"isNullableString");function bl(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}a(bl,"isVersion");function W(e){if(!F(e))return false;let t=Date.parse(e);return Number.isFinite(t)&&new Date(t).toISOString()===e}a(W,"isIsoDateString");function we(e){return e===null||W(e)}a(we,"isNullableIsoDateString");function x(e,t){return F(e[t])}a(x,"hasString");function re(e,t){return Oo(e[t])}a(re,"hasNonEmptyString");function N(e,t){return bl(e[t])}a(N,"hasVersion");function k(e,t){return W(e[t])}a(k,"hasIsoDateString");function w(e,t,r){return !Object.hasOwn(e,t)||r(e[t])}a(w,"hasOptional");function ft(e,t){return Object.keys(e).every(r=>t.includes(r))}a(ft,"hasOnlyKeys");function O(e,t){return typeof e=="string"&&t.includes(e)}a(O,"isOneOf");function gl(e){return O(e,ki)}a(gl,"isNotificationKind");function yl(e){return O(e,Oi)}a(yl,"isNotificationPriority");function hl(e){return O(e,_i)}a(hl,"isNotificationSensitivity");function _o(e){return O(e,Pi)}a(_o,"isNotificationInboxState");function Po(e){return O(e,Fi)}a(Po,"isNotificationWorkState");function Al(e){return C(e)&&x(e,"type")&&x(e,"id")}a(Al,"isNotificationSubject");function Tl(e){return C(e)&&x(e,"fieldKey")&&Object.hasOwn(e,"value")&&N(e,"version")}a(Tl,"isRecordFieldPatch");function wl(e){return e.type==="record.patch"&&x(e,"objectId")&&x(e,"recordId")&&N(e,"recordVersion")&&w(e,"label",F)&&w(e,"metadata",C)&&w(e,"fieldsWithheld",t=>t===true)&&Array.isArray(e.fieldPatches)&&e.fieldPatches.every(Tl)&&x(e,"updatedAt")}a(wl,"isRecordPatchPayload");function xl(e){return e.type==="record.deleted"&&x(e,"objectId")&&x(e,"recordId")&&N(e,"recordVersion")&&x(e,"deletedAt")}a(xl,"isRecordDeletedPayload");function Il(e){return e.type==="record.removed"&&ft(e,ll)&&x(e,"objectId")&&x(e,"recordId")&&N(e,"recordVersion")}a(Il,"isRecordRemovedPayload");function Sl(e){return C(e)&&ft(e,cl)&&x(e,"id")&&x(e,"objectId")&&O(e.visibility,["workspace","private"])&&mt(e.ownedBy)&&(e.visibility==="workspace"&&e.ownedBy===null||e.visibility==="private"&&Oo(e.ownedBy))&&x(e,"label")&&C(e.values)&&w(e,"metadata",C)&&k(e,"createdAt")&&k(e,"updatedAt")&&w(e,"createdBy",F)&&w(e,"lastUpdatedBy",F)&&N(e,"schemaVersion")}a(Sl,"isRecordLiveSnapshot");function vl(e){return e.type==="record.created"&&ft(e,dl)&&x(e,"objectId")&&x(e,"recordId")&&N(e,"recordVersion")&&Sl(e.record)&&e.record.id===e.recordId&&e.record.objectId===e.objectId}a(vl,"isRecordCreatedPayload");function Rl(e){return e.type==="view.projection.stale"&&x(e,"viewId")&&O(e.reason,al)}a(Rl,"isViewProjectionStalePayload");function El(e){return e.type==="agent.session.patch"&&x(e,"sessionId")&&C(e.patch)&&N(e,"version")&&x(e,"updatedAt")}a(El,"isAgentSessionPatchPayload");function Dl(e){return C(e)&&x(e,"id")&&x(e,"tenantId")&&w(e,"senderActorId",F)&&w(e,"rootActorId",F)&&w(e,"triggeredByActorId",F)&&gl(e.kind)&&x(e,"type")&&w(e,"subject",Al)&&x(e,"title")&&w(e,"summary",F)&&C(e.payload)&&yl(e.priority)&&hl(e.sensitivity)&&w(e,"threadKey",F)&&w(e,"idempotencyKey",F)&&w(e,"expiresAt",W)&&k(e,"createdAt")&&k(e,"updatedAt")}a(Dl,"isLiveNotification");function Cl(e){return C(e)&&x(e,"id")&&x(e,"tenantId")&&x(e,"notificationId")&&x(e,"recipientActorId")&&_o(e.inboxState)&&Po(e.workState)&&w(e,"lockedAt",W)&&w(e,"lockedByActorId",F)&&w(e,"readAt",W)&&w(e,"archivedAt",W)&&w(e,"snoozedUntil",W)&&w(e,"completedAt",W)&&w(e,"dismissedAt",W)&&k(e,"createdAt")&&k(e,"updatedAt")}a(Cl,"isLiveNotificationRecipient");function Nl(e){return C(e)?Object.keys(e).every(t=>ul.includes(t))&&w(e,"inboxState",_o)&&w(e,"workState",Po)&&w(e,"lockedAt",we)&&w(e,"lockedByActorId",mt)&&w(e,"readAt",we)&&w(e,"archivedAt",we)&&w(e,"snoozedUntil",we)&&w(e,"completedAt",we)&&w(e,"dismissedAt",we)&&w(e,"updatedAt",W):false}a(Nl,"isNotificationRecipientPatch");function kl(e){let t=Dl(e.notification)?e.notification:null;return e.type==="notification.created"&&t!==null&&Array.isArray(e.recipients)&&e.recipients.length>0&&e.recipients.every(r=>Cl(r)&&r.notificationId===t.id)&&N(e,"version")&&k(e,"updatedAt")}a(kl,"isNotificationCreatedPayload");function Ol(e){return e.type==="notification.recipient.patch"&&x(e,"recipientId")&&x(e,"recipientActorId")&&Nl(e.patch)&&N(e,"version")&&k(e,"updatedAt")}a(Ol,"isNotificationRecipientPatchPayload");function _l(e){return e.type==="notification.count.patch"&&x(e,"targetActorId")&&N(e,"unread")&&N(e,"pendingWork")&&N(e,"version")&&k(e,"updatedAt")}a(_l,"isNotificationCountPatchPayload");function Pl(e){return e.type==="notification.inbox.archived"&&ft(e,pl)&&re(e,"targetActorId")&&N(e,"archivedCount")&&N(e,"version")&&k(e,"updatedAt")}a(Pl,"isNotificationInboxArchivedPayload");var Fl=["armed","disarmed"],Vl=["authoring","compiling","replaying","promoted","failed"],jl=["promoted","lkg"],Ml=["composing","published","discarded"];function Ll(e){if(e.type!=="architect.draft.updated"||!C(e.draft))return false;let t=e.draft;return re(t,"id")&&re(t,"actorId")&&mt(t.agentSessionId)&&Array.isArray(t.operations)&&t.operations.every(C)&&C(t.baselines)&&O(t.status,Ml)}a(Ll,"isArchitectDraftUpdatedPayload");function Bl(e){return e.type==="reflex.state.changed"&&re(e,"reflexId")&&O(e.state,Fl)&&k(e,"updatedAt")}a(Bl,"isReflexStateChangedPayload");function Ul(e){return e.type==="reflex.run.completed"&&re(e,"reflexId")&&re(e,"runId")&&O(e.served,jl)&&N(e,"version")&&N(e,"wallMs")&&k(e,"completedAt")}a(Ul,"isReflexRunCompletedPayload");function $l(e){return e.type==="reflex.authoring.progress"&&re(e,"reflexId")&&O(e.status,Vl)&&k(e,"updatedAt")}a($l,"isReflexAuthoringProgressPayload");var ql=["none","scheduled","recording","completed","failed"];function zl(e){return e.type==="meeting.recording.patch"&&re(e,"meetingId")&&O(e.status,ql)&&mt(e.failureReason)&&k(e,"updatedAt")}a(zl,"isMeetingRecordingPatchPayload");var Gl=["ok","low","exhausted","paused"],Wl=["metering-only","contract","wallet"];function Kl(e){return e.type==="wallet.state"&&O(e.status,Gl)&&O(e.mode,Wl)&&k(e,"updatedAt")}a(Kl,"isWalletStatePayload");function Yl(e){return e.type==="channel.revoked"&&x(e,"channel")&&O(e.reason,sl)}a(Yl,"isChannelRevokedPayload");function Bn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a(Bn,"isRecord");function Hl(e){let{channel:t}=e;return typeof t=="string"&&ko(t)?t:null}a(Hl,"payloadChannel");function iw(e){return Bn(e)?Hl(e):null}a(iw,"getLiveProtocolPayloadChannel");function ow(e){return Bn(e)?typeof e.id=="string"&&e.id.length>0&&typeof e.channel=="string"&&typeof e.type=="string"&&typeof e.tenantId=="string"&&e.tenantId.length>0&&typeof e.occurredAt=="string"&&Bn(e.payload):false}a(ow,"isLiveEventEnvelope");var uw=["if","concat","sum","avg","count","min","max","earliest","latest","unique","first","percent_empty","percent_not_empty","count_empty","count_not_empty","count_unique"],_e={if:{name:"if",returnType:"branch",minArgs:3,maxArgs:3},concat:{name:"concat",returnType:{kind:"scalar",type:"text"},minArgs:1},sum:{name:"sum",returnType:{kind:"scalar",type:"number"},minArgs:1,maxArgs:1},avg:{name:"avg",returnType:{kind:"scalar",type:"number"},minArgs:1,maxArgs:1},count:{name:"count",returnType:{kind:"scalar",type:"number"},minArgs:1,maxArgs:1},min:{name:"min",returnType:"source_item",minArgs:1,maxArgs:1},max:{name:"max",returnType:"source_item",minArgs:1,maxArgs:1},earliest:{name:"earliest",returnType:{kind:"scalar",type:"date"},minArgs:1,maxArgs:1},latest:{name:"latest",returnType:{kind:"scalar",type:"date"},minArgs:1,maxArgs:1},unique:{name:"unique",returnType:"argument",minArgs:1,maxArgs:1},first:{name:"first",returnType:"source_item",minArgs:1,maxArgs:1},percent_empty:{name:"percent_empty",returnType:{kind:"scalar",type:"number"},minArgs:1,maxArgs:1},percent_not_empty:{name:"percent_not_empty",returnType:{kind:"scalar",type:"number"},minArgs:1,maxArgs:1},count_empty:{name:"count_empty",returnType:{kind:"scalar",type:"number"},minArgs:1,maxArgs:1},count_not_empty:{name:"count_not_empty",returnType:{kind:"scalar",type:"number"},minArgs:1,maxArgs:1},count_unique:{name:"count_unique",returnType:{kind:"scalar",type:"number"},minArgs:1,maxArgs:1}};function bt(e){return Object.hasOwn(_e,e)}a(bt,"isComputedFunctionName");var zn=class zn extends Error{constructor(t){super(t),this.name="ComputedFormulaCompileError";}};a(zn,"ComputedFormulaCompileError");var b=zn;function Bo(e){let t=Ql(e.expression),r=gt(t,e.schema),n=hd(r.valueType);if(n!==e.returnType)throw new b(`Computed formula "${e.attributeName}" returns "${n}", expected "${e.returnType}"`);if(Uo(e.returnType)&&r.optionsSource===void 0)throw new b(`Computed formula "${e.attributeName}" returns "${e.returnType}" without optionsSource`);let o=r.optionsSource===void 0?[]:[{kind:"options",source:r.optionsSource}],a=qn([...r.dependencies,...o]);return {kind:"formula",attributeName:e.attributeName,expression:e.expression,returnType:e.returnType,valueType:r.valueType,dependencies:a,ast:t,...r.optionsSource?{optionsSource:r.optionsSource}:{},...r.targetAttributeType?{targetAttributeType:r.targetAttributeType}:{},dependenciesHash:Ad({expression:e.expression,returnType:e.returnType,dependencies:a})}}a(Bo,"compileComputedFormula");function mw(e){let t=new Map(e.map(o=>[o.attributeName,o])),r=new Set,n=a((o,a)=>{let s=a.indexOf(o);if(s!==-1){let I=[...a.slice(s),o];throw new b(`Computed field cycle detected: ${I.join(" -> ")}`)}if(r.has(o))return;let l=t.get(o);if(l===void 0)return;let p=[...a,o];for(let I of l.dependencies)I.kind==="computed"&&n(I.attributeName,p);r.add(o);},"visit");for(let o of e)n(o.attributeName,[]);}a(mw,"assertAcyclicComputedDependencies");function Ql(e){try{return e$1(e)}catch(t){throw t instanceof Error?new b(t.message):t}}a(Ql,"parseCompileFormula");function gt(e,t){switch(e.kind){case "literal":return {valueType:Jl(e.value),dependencies:[],...typeof e.value=="string"?{literalString:e.value}:{}};case "path":return Xl(e.parts,t);case "call":return id(e.functionName,e.args,t);case "binary":return ld(e.operator,gt(e.left,t),gt(e.right,t));default:return e}}a(gt,"inferNode");function Jl(e){switch(typeof e){case "string":return {kind:"scalar",type:"text"};case "number":return {kind:"scalar",type:"number"};case "boolean":return {kind:"scalar",type:"boolean"};case "object":return {kind:"scalar",type:"text"};default:return e}}a(Jl,"literalToValueType");function Xl(e,t){if(e.length===1){let r=e[0],n=Un(t,r);if(n===void 0)throw new b(`Unknown attribute "${r}" on object "${t.objectName}"`);return n.type==="relation"?{valueType:td(),dependencies:[{kind:"relation",relationName:n.name,cardinality:Fo(n)}],targetAttributeType:n.type}:{valueType:Vo(n),dependencies:[ed(n)],optionsSource:jo(t.objectName,n),targetAttributeType:n.type}}if(e.length===2){let[r,n]=e,o=Un(t,r);if(o===void 0)throw new b(`Unknown attribute "${r}" on object "${t.objectName}"`);if(o.type!=="relation")throw new b(`Attribute "${r}" on object "${t.objectName}" is not a relation`);let a=Zl(o);if(a===void 0)throw new b(`Relation "${r}" on object "${t.objectName}" is missing targetObjectName`);let s=t.relatedObjects?.[a];if(s===void 0)throw new b(`Unknown related object "${a}"`);let l=Un(s,n);if(l===void 0)throw new b(`Unknown attribute "${n}" on object "${s.objectName}"`);let p=Vo(l);return {valueType:o.cardinality==="many"?nd(p):p,dependencies:[{kind:"relation",relationName:r,targetAttributeName:n,cardinality:Fo(o)}],optionsSource:jo(s.objectName,l),targetAttributeType:l.type}}throw new b("Computed paths support at most one relation hop")}a(Xl,"inferPath");function Un(e,t){return e.attributes.find(r=>r.name===t)}a(Un,"findAttribute");function Zl(e){if(e.targetObjectName!==void 0)return e.targetObjectName;if(e.targets?.length===1){let[t]=e.targets;return t?.object==="*"?void 0:t?.object}}a(Zl,"getRelationTargetObjectName");function Fo(e){return e.cardinality??"one"}a(Fo,"relationCardinality");function ed(e){return e.type==="formula"||e.type==="rollup"?{kind:"computed",attributeName:e.name}:{kind:"local",attributeName:e.name}}a(ed,"localDependencyFor");function Vo(e){if(e.type==="formula"||e.type==="rollup"){if(e.returnType===void 0)throw new b(`Computed attribute "${e.name}" is missing returnType`);return rd(e.returnType)}switch(e.type){case "number":case "currency":return {kind:"scalar",type:"number"};case "checkbox":return {kind:"scalar",type:"boolean"};case "date":return {kind:"scalar",type:"date"};case "select":case "status":return {kind:"scalar",type:"select"};case "multiselect":return {kind:"collection",itemType:"select"};case "text":case "richtext":case "phone":case "user":case "location":case "relation":case "document":return {kind:"scalar",type:"text"};default:return e.type}}a(Vo,"attributeToValueType");function td(){return {kind:"collection",itemType:"text"}}a(td,"relationToValueType");function rd(e){return e==="multiselect"?{kind:"collection",itemType:"select"}:{kind:"scalar",type:e}}a(rd,"returnTypeToValueType");function nd(e){return e.kind==="collection"?e:{kind:"collection",itemType:e.type}}a(nd,"asCollectionValueType");function jo(e,t){if(t.type==="formula"||t.type==="rollup")return Uo(t.returnType)?t.optionsSource:void 0;if(!(t.type!=="select"&&t.type!=="status"&&t.type!=="multiselect"))return t.optionsSource??{objectName:e,attributeName:t.name,...t.id?{attributeId:t.id}:{}}}a(jo,"optionsSourceForAttribute");function id(e,t,r){if(!bt(e))throw new b(`Unknown computed function "${e}"`);let n=_e[e];if(t.length<n.minArgs||n.maxArgs!==void 0&&t.length>n.maxArgs){let a=n.maxArgs===void 0||n.maxArgs===n.minArgs?String(n.minArgs):`${n.minArgs}-${n.maxArgs}`;throw new b(`Function "${e}" expects ${a} arguments, received ${t.length}`)}let o=t.map(a=>gt(a,r));return od(e,o)}a(id,"inferCall");function od(e,t){let r=qn(t.flatMap(n=>n.dependencies));switch(e){case "if":return ad(t,r);case "concat":return dd(t,`Function "${e}" does not accept collection values`),{valueType:{kind:"scalar",type:"text"},dependencies:r};case "sum":case "avg":return Mo(e,t[0],"number"),{valueType:{kind:"scalar",type:"number"},dependencies:r};case "count":case "count_empty":case "count_not_empty":case "count_unique":case "percent_empty":case "percent_not_empty":return pd(e,t[0]),{valueType:{kind:"scalar",type:"number"},dependencies:r};case "min":case "max":return cd(e,t[0]),{valueType:md(t[0]),dependencies:r,optionsSource:t[0].optionsSource,targetAttributeType:t[0].targetAttributeType};case "earliest":case "latest":return Mo(e,t[0],"date"),{valueType:{kind:"scalar",type:"date"},dependencies:r,targetAttributeType:t[0].targetAttributeType};case "unique":return sd(t[0],r);case "first":return ud(t[0],r);default:return e}}a(od,"inferFunctionReturn");function ad(e,t){$n(e[0].valueType,"boolean",'Function "if" condition must be boolean');let r=e[1],n=e[2],o=bd(r,n),a=gd(r,n);if(o===void 0)throw new b('Function "if" branches must return the same type');return {valueType:o,dependencies:t,...a?{optionsSource:a}:{},targetAttributeType:r.targetAttributeType??n.targetAttributeType}}a(ad,"inferIfFunction");function sd(e,t){if(e.valueType.kind!=="collection"||e.valueType.itemType!=="select")throw new b('Function "unique" expects a select collection');return {valueType:{kind:"collection",itemType:"select"},dependencies:t,optionsSource:e.optionsSource,targetAttributeType:e.targetAttributeType}}a(sd,"inferUniqueFunction");function ud(e,t){if(e.valueType.kind!=="collection")throw new b('Function "first" expects a collection');return {valueType:{kind:"scalar",type:e.valueType.itemType},dependencies:t,optionsSource:e.optionsSource,targetAttributeType:e.targetAttributeType}}a(ud,"inferFirstFunction");function ld(e,t,r){let n=qn([...t.dependencies,...r.dependencies]),o=e==="+"||e==="-"||e==="*"||e==="/";if(t.valueType.kind==="collection"||r.valueType.kind==="collection")throw new b(`Cannot use collection values with ${o?"arithmetic":"comparison"} operator "${e}"`);if(o)return e==="+"&&(t.valueType.type==="text"||r.valueType.type==="text")?{valueType:{kind:"scalar",type:"text"},dependencies:n}:($n(t.valueType,"number",`Operator "${e}" expects number operands`),$n(r.valueType,"number",`Operator "${e}" expects number operands`),{valueType:{kind:"scalar",type:"number"},dependencies:n});if(e==="=="||e==="!="){if(t.valueType.type!==r.valueType.type)throw new b(`Operator "${e}" expects operands with the same scalar type`);return {valueType:{kind:"scalar",type:"boolean"},dependencies:n}}if((t.valueType.type!=="number"||r.valueType.type!=="number")&&(t.valueType.type!=="date"||r.valueType.type!=="date"))throw new b(`Operator "${e}" expects number or date operands of the same type`);return {valueType:{kind:"scalar",type:"boolean"},dependencies:n}}a(ld,"inferBinary");function dd(e,t){for(let r of e)if(r.valueType.kind==="collection")throw new b(t)}a(dd,"ensureNoCollections");function Mo(e,t,r){if((t.valueType.kind==="collection"?t.valueType.itemType:t.valueType.type)!==r)throw new b(`Function "${e}" expects ${r} values`)}a(Mo,"ensureCollectionOrScalarType");function cd(e,t){if(t.valueType.kind!=="collection")throw new b(`Function "${e}" expects a collection`);let r=t.valueType.itemType;if(r!=="number"&&r!=="date")throw new b(`Function "${e}" expects number or date values`)}a(cd,"ensureMinMaxSource");function pd(e,t){if(t.valueType.kind!=="collection")throw new b(`Function "${e}" expects a collection`)}a(pd,"ensureCollectionSource");function $n(e,t,r){if(e.kind!=="scalar"||e.type!==t)throw new b(r)}a($n,"ensureScalarType");function md(e){return e.valueType.kind==="scalar"?e.valueType:{kind:"scalar",type:e.valueType.itemType}}a(md,"sourceItemValueType");function fd(e,t){return e.kind==="scalar"?t.kind==="scalar"&&e.type===t.type:t.kind==="collection"&&e.itemType===t.itemType}a(fd,"sameValueType");function bd(e,t){if(fd(e.valueType,t.valueType)||Lo(e,t))return e.valueType;if(Lo(t,e))return t.valueType}a(bd,"resolveIfBranchValueType");function Lo(e,t){return e.valueType.kind==="scalar"&&e.valueType.type==="select"&&t.valueType.kind==="scalar"&&t.valueType.type==="text"&&t.literalString!==void 0}a(Lo,"isSelectScalarWithStringLiteral");function gd(e,t){let r=e.optionsSource,n=t.optionsSource;if(r!==void 0&&n!==void 0&&!yd(r,n))throw new b('Function "if" branches use incompatible options sources');return r??n}a(gd,"resolveIfOptionsSource");function yd(e,t){return e.objectName===t.objectName&&e.attributeName===t.attributeName&&e.attributeId===t.attributeId}a(yd,"sameOptionsSource");function Uo(e){return e==="select"||e==="multiselect"}a(Uo,"isSelectLikeReturnType");function hd(e){if(e.kind==="scalar")return e.type;if(e.itemType==="select")return "multiselect";throw new b(`Collection item type "${e.itemType}" cannot be used as a computed return type`)}a(hd,"valueTypeToReturnType");function qn(e){let t=new Set,r=[];for(let n of e){let o=JSON.stringify(Pe(n));t.has(o)||(t.add(o),r.push(n));}return r}a(qn,"uniqueDependencies");function Ad(e){let t=e.dependencies.map(r=>Pe(r)).sort((r,n)=>$o(JSON.stringify(r),JSON.stringify(n)));return JSON.stringify(Pe({expression:e.expression,returnType:e.returnType,dependencies:t}))}a(Ad,"createDependenciesHash");function Pe(e){return Array.isArray(e)?e.map(t=>Pe(t)):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0).sort(([t],[r])=>$o(t,r)).map(([t,r])=>[t,Pe(r)])):e}a(Pe,"stableNormalize");function $o(e,t){return e<t?-1:e>t?1:0}a($o,"compareStrings");function Td(e){return e.function==="count"?`count(${e.relationAttribute})`:`${Id(e.function)}(${e.relationAttribute}.${e.targetAttribute})`}a(Td,"rollupToFormulaExpression");function wd(e,t){if(e.function==="count")return "number";let r=Sd(e,t);switch(e.function){case "countValues":case "countEmpty":case "percentEmpty":case "percentNotEmpty":case "countUniqueValues":return "number";case "sum":case "avg":return "number";case "earliest":case "latest":return "date";case "original":if(!Rd(r.type))throw new b('Rollup "original" requires a select, status, or multiselect target');return "multiselect";default:return e.function}}a(wd,"inferRollupReturnType");function yw(e,t){let r=Td(e),n=wd(e,t);return {...Bo({attributeName:e.name,expression:r,returnType:n,schema:xd(e,t)}),kind:"rollup"}}a(yw,"compileRollupAttribute");function xd(e,t){return {...t,attributes:t.attributes.map(r=>r.name===e.relationAttribute&&r.type==="relation"?{...r,cardinality:"many"}:r)}}a(xd,"schemaWithRollupRelationAsMany");function Id(e){switch(e){case "sum":case "avg":case "earliest":case "latest":return e;case "original":return "unique";case "countValues":return "count_not_empty";case "countEmpty":return "count_empty";case "percentEmpty":return "percent_empty";case "percentNotEmpty":return "percent_not_empty";case "countUniqueValues":return "count_unique";default:return e}}a(Id,"rollupFunctionToFormulaFunction");function Sd(e,t){let r=qo(t,e.relationAttribute);if(r===void 0)throw new b(`Unknown relation attribute "${e.relationAttribute}" on object "${t.objectName}"`);if(r.type!=="relation")throw new b(`Attribute "${e.relationAttribute}" on object "${t.objectName}" is not a relation`);let n=vd(r);if(n===void 0)throw new b(`Relation "${e.relationAttribute}" on object "${t.objectName}" is missing targetObjectName`);let o=t.relatedObjects?.[n];if(o===void 0)throw new b(`Unknown related object "${n}"`);let a=qo(o,e.targetAttribute);if(a===void 0)throw new b(`Unknown attribute "${e.targetAttribute}" on object "${o.objectName}"`);return a}a(Sd,"findRollupTargetAttribute");function qo(e,t){return e.attributes.find(r=>r.name===t)}a(qo,"findAttribute");function vd(e){if(e.targetObjectName!==void 0)return e.targetObjectName;if(e.targets?.length===1){let[t]=e.targets;return t?.object==="*"?void 0:t?.object}}a(vd,"getRelationTargetObjectName");function Rd(e){return e==="select"||e==="status"||e==="multiselect"}a(Rd,"isSelectLikeAttributeType");function J(e,t){switch(e.kind){case "literal":return e.value;case "path":return Dd(t,e.parts);case "binary":return Cd(e.operator,J(e.left,t),J(e.right,t));case "call":return Ed(e.functionName,e.args,t);default:return e}}a(J,"evaluateAst");function Ed(e,t,r){if(kd(e),Od(e,t.length),e==="if"){let n=J(t[0],r);return n===null?null:J(n?t[1]:t[2],r)}return _d(e,t.map(n=>J(n,r)))}a(Ed,"evaluateCallNode");function Dd(e,t){return t.reduce((r,n)=>Ho(r,n),e)}a(Dd,"resolvePath");function Ho(e,t){if(Array.isArray(e))return e.map(n=>Ho(n,t));if(!Yo(e))return null;if(Object.hasOwn(e,t))return e[t]??null;let r=e.values;return Yo(r)&&Object.hasOwn(r,t)?r[t]??null:null}a(Ho,"resolvePathPart");function Cd(e,t,r){switch(e){case "+":return Nd(t,r);case "-":return ht(t,r,(n,o)=>n-o);case "*":return ht(t,r,(n,o)=>n*o);case "/":return ht(t,r,(n,o)=>n/o);case ">":return yt(t,r,n=>n>0);case "<":return yt(t,r,n=>n<0);case ">=":return yt(t,r,n=>n>=0);case "<=":return yt(t,r,n=>n<=0);case "==":return zo(t,r);case "!=":{let n=zo(t,r);return n===null?null:!n}default:return e}}a(Cd,"evaluateBinary");function Nd(e,t){return typeof e=="string"||typeof t=="string"?`${e??""}${t??""}`:ht(e,t,(r,n)=>r+n)}a(Nd,"add");function yt(e,t,r){let n=Qo(e,t);return n===null?null:r(n)}a(yt,"compareWith");function Qo(e,t){if(!xe([e,t]))return null;let r=Ie(e),n=Ie(t);if(r!==null&&n!==null)return r-n;let o=Kn(e),a=Kn(t);return o&&a?o.getTime()-a.getTime():null}a(Qo,"compare");function zo(e,t){return e===t?true:e==null||t===null||t===void 0?false:xe([e,t])?Qo(e,t)===0:null}a(zo,"equalScalar");function kd(e){if(!bt(e))throw new Error(`Unknown computed function "${e}"`)}a(kd,"assertComputedFunctionName");function Od(e,t){let{minArgs:r,maxArgs:n}=_e[e];if(t>=r&&t<=(n??Number.POSITIVE_INFINITY))return;let o=n===void 0?`at least ${r}`:`between ${r} and ${n}`;throw new Error(`Function "${e}" expects ${o} arguments, received ${t}`)}a(Od,"validateArity");function _d(e,t){switch(e){case "concat":return t.filter(r=>r!=null).map(String).join("");case "sum":return xe(t)?Gn(t).reduce((r,n)=>r+n,0):null;case "avg":{if(!xe(t))return null;let r=Gn(t);return r.length>0?r.reduce((n,o)=>n+o,0)/r.length:null}case "count":return de(t[0]).length;case "min":return Go(t,"min");case "max":return Go(t,"max");case "earliest":return Wn(t,"min");case "latest":return Wn(t,"max");case "unique":return Ko(de(t[0]));case "first":return de(t[0]).find(r=>r!=null)??null;case "percent_empty":return Wo(t[0],true);case "percent_not_empty":return Wo(t[0],false);case "count_empty":return de(t[0]).filter(a$1).length;case "count_not_empty":return de(t[0]).filter(r=>!a$1(r)).length;case "count_unique":return Ko(de(t[0])).length;default:return e}}a(_d,"evaluateCall");function Gn(e){return At(e).map(Ie).filter(t=>t!==null)}a(Gn,"numericValues");function xe(e){let t=new Set;for(let r of At(e))Yn(r)&&t.add(Jo(r));return t.size<=1}a(xe,"areCommensurable");function Jo(e){return e.code.toUpperCase()}a(Jo,"currencyCode");function ht(e,t,r){if(!xe([e,t]))return null;let n=Ie(e),o=Ie(t);if(n===null||o===null)return null;let a=r(n,o);return Number.isFinite(a)?a:null}a(ht,"numericBinary");function Go(e,t){if(!xe(e))return null;let r=Gn(e);return r.length>0?t==="min"?Math.min(...r):Math.max(...r):Wn(e,t)}a(Go,"minMax");function Wn(e,t){let r=At(e).map(Kn).filter(a=>a!==null);if(r.length===0)return null;let n=r.map(a=>a.getTime()),o=t==="min"?Math.min(...n):Math.max(...n);return new Date(o).toISOString()}a(Wn,"dateMinMax");function Wo(e,t){let r=de(e);return r.length===0?0:r.filter(o=>a$1(o)===t).length/r.length}a(Wo,"percentByEmptyState");function Ko(e){let t=new Set,r=[];for(let n of e){if(a$1(n))continue;let o=Pd(n);t.has(o)||(t.add(o),r.push(n));}return r}a(Ko,"uniqueNonEmpty");function de(e){return e==null?[]:Array.isArray(e)?At(e):[e]}a(de,"collectionItems");function At(e){return e.flat(Number.POSITIVE_INFINITY)}a(At,"flatten");function Ie(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){let t=Number(e);return Number.isFinite(t)?t:null}return Yn(e)&&Number.isFinite(e.value)?e.value:null}a(Ie,"toFiniteNumber");function Yn(e){return typeof e=="object"&&e!==null&&typeof e.value=="number"&&typeof e.code=="string"}a(Yn,"isCurrencyValue");function Kn(e){if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;if(typeof e!="string"){let r=fe(e);if(r===null)return null;let n=new Date(r);return Number.isNaN(n.getTime())?null:n}let t=new Date(e);return Number.isNaN(t.getTime())?null:t}a(Kn,"toDate");function Pd(e){if(Yn(e))return `currency:${Jo(e)}:${e.value}`;let t=Ie(e);return t!==null?`number:${t}`:e instanceof Date?`date:${e.toISOString()}`:`${typeof e}:${JSON.stringify(e)}`}a(Pd,"uniqueKey");function Yo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a(Yo,"isPlainRecord");function Fd(e,t,r){if(e==null)return null;let n=a(o=>typeof o=="string"||typeof o=="number"||typeof o=="boolean"||o instanceof Date?String(o):null,"stringifyScalar");switch(t){case "number":{let o=typeof e=="number"?e:Number(e);return Number.isNaN(o)?null:r!==void 0?Number(o.toFixed(r)):o}case "boolean":return !!e;case "date":return e instanceof Date?e.toISOString():typeof e=="string"?e:null;case "text":return String(e);case "select":if(Array.isArray(e)){for(let o of e){if(o==null)continue;let a=n(o);if(a!==null)return a}return null}return n(e);case "multiselect":return Array.isArray(e)?e.flatMap(o=>{if(o==null)return [];let a=n(o);return a===null?[]:[a]}):n(e)===null?[]:[String(e)];default:{let o=t;throw new Error(`Unsupported computed return type: ${o}`)}}}a(Fd,"formatComputedResult");function Sw(e,t){return J(e,t)}a(Sw,"evaluateComputedAst");function vw(e,t){return J(e$1(e),t)}a(vw,"evaluateComputedFormula");function Rw(e,t,r,n){try{let o=J(e$1(e),t);return {value:r?Fd(o,r,n):o}}catch(o){return {value:null,error:o instanceof Error?o.message:String(o)}}}a(Rw,"evaluateComputedFormulaWithResult");var Cw=[{name:"if",signature:"if(condition, then, else)",description:"Conditional value",category:"logic",example:"if(amount > 100, 'big', 'small')"},{name:"concat",signature:"concat(a, b, ...)",description:"Join values into text",category:"text",example:"concat(firstName, ' ', lastName)"},{name:"sum",signature:"sum(collection)",description:"Total of values",category:"number",example:"sum(orders.amount)"},{name:"avg",signature:"avg(collection)",description:"Average of values",category:"number",example:"avg(orders.amount)"},{name:"min",signature:"min(collection)",description:"Smallest value",category:"number",example:"min(orders.amount)"},{name:"max",signature:"max(collection)",description:"Largest value",category:"number",example:"max(orders.amount)"},{name:"count",signature:"count(collection)",description:"Number of items",category:"collection",example:"count(orders)"},{name:"count_empty",signature:"count_empty(collection)",description:"Items with no value",category:"collection",example:"count_empty(orders.note)"},{name:"count_not_empty",signature:"count_not_empty(collection)",description:"Items with a value",category:"collection",example:"count_not_empty(orders.note)"},{name:"count_unique",signature:"count_unique(collection)",description:"Distinct values",category:"collection",example:"count_unique(orders.status)"},{name:"percent_empty",signature:"percent_empty(collection)",description:"Fraction with no value",category:"collection",example:"percent_empty(orders.note)"},{name:"percent_not_empty",signature:"percent_not_empty(collection)",description:"Fraction with a value",category:"collection",example:"percent_not_empty(orders.note)"},{name:"unique",signature:"unique(collection)",description:"Distinct values as a list",category:"collection",example:"unique(orders.status)"},{name:"first",signature:"first(collection)",description:"First non-empty value",category:"collection",example:"first(orders.status)"},{name:"earliest",signature:"earliest(collection)",description:"Earliest date",category:"date",example:"earliest(orders.closeDate)"},{name:"latest",signature:"latest(collection)",description:"Latest date",category:"date",example:"latest(orders.closeDate)"}];var Xo=a(e=>a$1(e)||Array.isArray(e)&&e.length===0,"isEmpty"),V=a(e=>e==null?"":String(e),"toStr"),xt=a(e=>{if(a$1(e))return null;let t=typeof e=="number"?e:Number(e);return Number.isFinite(t)?t:null},"toNum"),It=a(e=>{if(e==null)return null;let t=e instanceof Date?e:new Date(String(e));return Number.isNaN(t.getTime())?null:t},"toDate"),Tt=a(e=>Array.isArray(e)?e:e==null?[]:[e],"toArr"),Vd=a((e,t,r)=>{let n=xt(e),o=xt(t);return n!==null&&o!==null&&r(n,o)},"compareNumbers"),jd=a((e,t,r)=>{let n=It(e),o=It(t);return n!==null&&o!==null&&r(n.getTime(),o.getTime())},"compareDates"),Zo=a((e,t,r)=>{if(r.type==="number"||r.type==="currency"){let n=xt(e),o=xt(t);if(n!==null&&o!==null)return n===o}return V(e)===V(t)},"equalsForAttr");function _w(e,t){return e?e==="checkbox":typeof t=="boolean"}a(_w,"isCheckboxEquality");var wt=a(e=>({appliesTo:["number","currency","date","formula"],evaluateInMemory:a((t,r,n)=>n.type==="date"?jd(t,r,e):Vd(t,r,e),"evaluateInMemory")}),"orderingSpec"),St={is:{appliesTo:["text","phone","number","currency","checkbox","status","select","date","user","relation","formula"],evaluateInMemory:a((e,t,r)=>r.type==="checkbox"?e===true==(t===true):Zo(e,t,r),"evaluateInMemory")},is_not:{appliesTo:["text","phone","number","currency","status","select","date","user","relation","formula"],evaluateInMemory:a((e,t,r)=>!Zo(e,t,r),"evaluateInMemory")},contains:{appliesTo:["text","phone","formula"],evaluateInMemory:a((e,t)=>V(e).toLowerCase().includes(V(t).toLowerCase()),"evaluateInMemory")},not_contains:{appliesTo:["text","phone","formula"],evaluateInMemory:a((e,t)=>!V(e).toLowerCase().includes(V(t).toLowerCase()),"evaluateInMemory")},starts_with:{appliesTo:["text","phone"],evaluateInMemory:a((e,t)=>V(e).toLowerCase().startsWith(V(t).toLowerCase()),"evaluateInMemory")},ends_with:{appliesTo:["text"],evaluateInMemory:a((e,t)=>V(e).toLowerCase().endsWith(V(t).toLowerCase()),"evaluateInMemory")},is_empty:{appliesTo:["text","richtext","number","phone","currency","status","select","date","multiselect","location","user","relation","formula","document"],evaluateInMemory:a(e=>Xo(e),"evaluateInMemory")},is_not_empty:{appliesTo:["text","richtext","number","phone","currency","status","select","date","multiselect","location","user","relation","formula","document"],evaluateInMemory:a(e=>!Xo(e),"evaluateInMemory")},less_than:wt((e,t)=>e<t),greater_than:wt((e,t)=>e>t),less_or_equal:wt((e,t)=>e<=t),greater_or_equal:wt((e,t)=>e>=t),is_within:{appliesTo:["date"],evaluateInMemory:a((e,t)=>{let r=It(e),n=Q$1(t);return r&&n?r.getTime()>=n.startMs&&r.getTime()<n.endMs:false},"evaluateInMemory")},on_day_month:{appliesTo:["date"],evaluateInMemory:a((e,t)=>{let r=It(e);if(!r)return false;let n=t;return r.getMonth()+1===n.month&&r.getDate()===n.day},"evaluateInMemory")},any_of:{appliesTo:["status","select","multiselect","user","relation"],evaluateInMemory:a((e,t)=>{let r=Tt(t).map(V);return Tt(e).map(V).some(o=>r.includes(o))},"evaluateInMemory")},none_of:{appliesTo:["status","select","multiselect","user","relation"],evaluateInMemory:a((e,t)=>{let r=Tt(t).map(V);return !Tt(e).map(V).some(o=>r.includes(o))},"evaluateInMemory")}};var Md=a((e,t)=>({id:`system:${e}`,name:e,label:e,type:t,system:true}),"systemAttribute"),Ld=[...Object.entries(T$1).map(([e,t])=>Md(e,t))];function zw(e,t,r){let n=t;return Bd(e,{...t.values,id:t.id,objectId:t.objectId,objectName:n.objectName,tenantId:n.tenantId,label:t.label,createdAt:t.createdAt,updatedAt:t.updatedAt,createdBy:t.createdBy,lastUpdatedBy:t.lastUpdatedBy,deletedAt:t.deletedAt,deletedBy:t.deletedBy,visibility:t.visibility,ownedBy:t.ownedBy},[...r,...Ld])}a(zw,"evaluateRecordFilterState");function Bd(e,t,r){if(e.rules.length===0)return true;let n=new Map(r.map(a=>[a.name,a])),o=e.combinator==="or"?"some":"every";return e.rules[o](a=>Ud(a,t,n))}a(Bd,"evaluateFilterState");function Ud(e,t,r){let n=r.get(e.attribute);if(!n)return false;if(e.property&&n.type==="location"){if(!(g(e.property)&&h$1(e.operator)))return false;let l=St[e.operator];if(!l)return false;let p=t[e.attribute],I=typeof p=="object"&&p!==null?p[e.property]:void 0;return Hn(l,"text",e.operator,I,e.value,n)}if(e.property){let l=Yi(n).find(j=>j.name===e.property);if(!l)return false;let p=I(e.operator),I$1=St[p];if(!I$1?.appliesTo.includes(l.type))return false;let X=t[e.attribute],ae=(Array.isArray(X)?X:X==null?[]:[X]).some(j=>{if(typeof j!="object"||j===null)return false;let Y=j.props;return typeof Y!="object"||Y===null?false:Hn(I$1,l.type,p,Y[e.property],e.value,l)});return (e.quantifier??H(e.operator))==="none"?!ae:ae}let o=St[e.operator];if(!o||!o.appliesTo.includes(n.type))return false;let a=t[e.attribute],s=n.type==="relation"||n.type==="document"||n.type==="user"?zd(a):a;return Hn(o,n.type,e.operator,s,e.value,n)}a(Ud,"evaluateRule");function Hn(e,t,r,n,o,a){let[s,l]=$d(t,r,n,o);return t==="phone"&&l===""&&r==="contains"?false:t==="phone"&&l===""&&r==="not_contains"?true:e.evaluateInMemory(s,l,a)}a(Hn,"evaluateNormalizedComparands");function $d(e,t,r,n){return e==="date"&&(t==="is"||t==="is_not")?[ea(r),ea(n)]:e==="phone"?qd(r,n):[ta(e,r),ta(e,n)]}a($d,"normalizeOperatorComparands");function ea(e){let t=Z(e)?fe(e):e;if(t instanceof Date)return Number.isNaN(t.getTime())?null:t.toISOString().slice(0,10);if(typeof t!="string"||t==="")return null;if(/^\d{4}-\d{2}-\d{2}$/.test(t))return t;let r=new Date(t);return Number.isNaN(r.getTime())?null:r.toISOString().slice(0,10)}a(ea,"normalizeUtcCalendarDay");function qd(e,t){let r=typeof t=="object"&&t!==null?t:{},n=typeof r.countryCode=="string"?r.countryCode:void 0,o=a(a=>{let s=typeof a=="object"&&a!==null?a:{phoneNumber:a};if(typeof s.phoneNumber!="string")return null;if(!n)return a$3(s.phoneNumber);let l=typeof s.countryCode=="string"?s.countryCode:n;return `${l}:${b$2(s.phoneNumber,l)}`},"normalizeOne");return [o(e),o(t)]}a(qd,"normalizePhoneComparands");function ta(e,t){return e==="currency"?F$1(t):e==="date"?Z(t)?fe(t):t instanceof Date?Number.isNaN(t.getTime())?null:t.toISOString():t:t}a(ta,"normalizeComparableValue");function zd(e){let t=a(r=>typeof r!="object"||r===null?r:r.id,"normalizeOne");return Array.isArray(e)?e.map(t):t(e)}a(zd,"normalizeReferenceIds");var ra="today";function vt(e,t){return new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).format(e)}a(vt,"dateInTimezone");function Gd(e,t){if(!("defaultValue"in e))return;let{defaultValue:r}=e;return e.type!=="date"||r!==ra?r:e.includeTime?t.now.toISOString():vt(t.now,t.timezone)}a(Gd,"resolveAttributeDefaultValue");function Xw(e,t,r){if(e.combinator==="or"&&e.rules.length>1)return {};let n=new Map(t.map(a=>[a.name,a])),o={};for(let a of e.rules){if(a.property!==void 0||Object.hasOwn(o,a.attribute))continue;let s=n.get(a.attribute);if(!s)continue;let l=Wd(a,r);l!==void 0&&(o[a.attribute]=j(s).storage.cardinality==="many"?[l]:l);}return o}a(Xw,"deriveCreateDefaultsFromFilters");function Wd(e,t){if(e.operator==="is")return B(e.value)?na(e.value,t):e.value===null||Array.isArray(e.value)?void 0:e.value;if(e.operator==="any_of"){if(!Array.isArray(e.value)||e.value.length!==1)return;let r=e.value[0];return B(r)?na(r,t):r}}a(Wd,"extractDeterministicValue");function na(e,t){if(t){if(e.dynamic==="actor")return t.userId;if(e.anchor==="today")return vt(t.now,t.timezone);if(e.anchor==="now")return t.now.toISOString()}}a(na,"resolveDynamicValue");var tx={status:"connector_status",error:"connector_error",provider:"connector_provider"};var Kd=(t=>(t.Desktop="desktop",t))(Kd||{});var ix=["force","skip"],ox=["none","all","external_only"],ax="x-fake-signature",sx={override:null,status:"none",failureReason:null,botId:null};var Yd=/^Session \d+$/;function ia(e){let t=e.replace(/\s+/g," ").trim().replace(/[.!?]+$/,"");return t?t.length>60?`${t.slice(0,59).trimEnd()}...`:t:"New conversation"}a(ia,"buildAgentFallbackTitle");function Hd(e){let t=e.generated?.trim();return t&&!Yd.test(t)?t:e.firstUserText?ia(e.firstUserText):e.emptyLabel}a(Hd,"conversationDisplayTitle");var Qn=/^[a-z0-9][a-z0-9-]{0,62}$/;function Qd(e){if(!Qn.test(e))throw new h(`Invalid schema source id "${e}": expected a lowercase slug matching ${Qn}`,[])}a(Qd,"assertSchemaSourceId");function Jd(e){return {label:e.label,description:e.description??null,icon:e.icon??null,config:e.config,default:e.default??false,metadata:e.metadata??null}}a(Jd,"viewSyncPayload");function gx(e){let{attributeRemovals:t,objectRemovals:r,renames:n}=e.destructive;return t.length>0||r.length>0||n.length>0}a(gx,"hasDestructiveEntries");var $={objectAdditions:20,totalMutations:500,serializedBytes:512*1024};function Xn(e){return e instanceof Error?e.message:String(e)}a(Xn,"errorMessage");var Xd=z$1.enum(["text","richtext","number","checkbox","date","phone","currency","status","location","select","multiselect","user","relation","formula","rollup","document"]).describe('The attribute\'s data type. Determines which keys `config` accepts and requires: `status`/`select`/`multiselect` need a non-empty `options` array (each `status` option carrying its own `group`); `relation` needs `targets` (non-empty) and `cardinality` ("one" or "many"); `formula` needs `expression` and `returnType`; `rollup` needs `targetAttribute` and `function`. Every other type accepts only the shared presentation keys (`placeholder`, `defaultValue`, `icon`, ...) plus a few type-specific optionals (e.g. `number.decimals`, `date.dateFormat`). An attribute\'s type can never be changed later through this tool \u2014 only through a code migration \u2014 so pick it correctly now.');var ca=z$1.string().min(1).superRefine((e,t)=>{try{Ce(e);}catch(r){t.addIssue({code:z$1.ZodIssueCode.custom,message:Xn(r)});}}).describe('The attribute\'s machine name \u2014 the record\'s field key, and what `{{ name }}` refers to in a labelExpression. Must be a valid identifier: starts with a letter or underscore, then only letters/digits/underscores ("montantHt", "first_name", "FIRST_NAME" are valid; "first-name", "first name", "123name" are not). Max 63 characters. Cannot be a name reserved by the record shape itself (id, createdAt, updatedAt, createdBy, lastUpdatedBy, objectId, label, embeddingText, values, metadata, deletedAt, deletedBy, schemaVersion).'),Zd=z$1.string().min(1).superRefine((e,t)=>{A$1.includes(e)&&t.addIssue({code:z$1.ZodIssueCode.custom,message:`"${e}" is a reserved object name (${A$1.join(", ")}) and cannot be used for a new object.`});try{De(e);}catch(r){t.addIssue({code:z$1.ZodIssueCode.custom,message:Xn(r)});}}).describe(`The new object's machine name: kebab-case slug, lowercase letters/digits/hyphens only, starting with a letter ("products", "user-profiles", "order-items" are valid; "Products", "userProfiles", "user_profiles" are not). Max 63 characters. Cannot be a name the platform reserves for its own system objects, and cannot already exist.`);function pa(e){return e.superRefine((t,r)=>{try{let n$1=n(t.type,{...t.config??{},description:t.description}),o=Object.keys(t.config??{}).filter(a=>!Object.hasOwn(n$1,a));o.length>0&&r.addIssue({code:"unrecognized_keys",keys:o,path:["config"],message:`Unrecognized attribute config key${o.length===1?"":"s"}: ${o.join(", ")}`});}catch(n){if(n instanceof h){for(let o of n.errors)r.addIssue({code:z$1.ZodIssueCode.custom,path:["config",...o.path.map(a=>/^\d+$/.test(a)?Number(a):a)],message:`Config for type "${t.type}" is invalid or incomplete: ${o.message}`});return}r.addIssue({code:z$1.ZodIssueCode.custom,path:["config"],message:`Config for type "${t.type}" is invalid or incomplete: ${Xn(n)}`});}})}a(pa,"withConfigCheck");var ma=z$1.object({objectName:z$1.string().min(1).describe("Name of the existing (or, elsewhere in the same plan, newly created) object this attribute is added to. Ignored for an attribute declared inline in `additive.objects[].attributes` \u2014 there the parent object's own `name` is used instead."),name:ca,label:z$1.string().min(1).max(128).describe("Human-readable display label shown in the UI. 1-128 characters, cannot be empty."),type:Xd,config:z$1.record(z$1.string(),z$1.unknown()).optional().describe('Type-specific configuration; required keys depend on `type` (see `type`\'s description). Shared optional keys on every type: `placeholder`, `defaultValue`, `icon`, `order`, `hidden`, `archived`, `deprecated`, `metadata`. Per-type keys: `text` \u2014 `multiline`, `minLength`, `maxLength`, `pattern`, `format` ("email"|"url"|"slug"); `number` \u2014 `renderAs` ("number"|"rating"), `min`, `max`, `unit`, `decimals`; `date` \u2014 `dateFormat`, `minDate`, `maxDate`, `includeTime`, `endDate`, `timeFormat` ("12h"|"24h"); `phone` \u2014 `defaultCountryCode` (3-letter); `currency` \u2014 `defaultCurrency`, `allowedCurrencies`, `allowNegative`; `status`/`select`/`multiselect` \u2014 `options` (REQUIRED, non-empty array of `{ value, label, color }`, unique `value`s; for `status` every OPTION also carries `group` as idle|in_progress|finished \u2014 `group` belongs on each option, never on `config` itself; select/multiselect accept `renderAs: "badges"`); `location` \u2014 `granularity`, `defaultCountry`, `allowedCountries`; `user` \u2014 `types` ("user"|"agent"), `multiple`; `relation` \u2014 `targets` (REQUIRED, non-empty array of `{ object }`) and `cardinality` (REQUIRED, "one"|"many"); `formula` \u2014 `expression` (REQUIRED formula string) and `returnType` (REQUIRED); `rollup` \u2014 `targetAttribute` (REQUIRED) and `function` (REQUIRED, e.g. "sum"|"avg"|"count"); `document` \u2014 `properties`, `accepts`, `maxFileSize`. Omit entirely for `richtext`/`checkbox`, which take no type-specific keys.'),required:z$1.boolean().optional().describe("Whether the attribute must have a value on every record. Defaults to false (optional)."),description:z$1.string().optional().describe("Help text shown under the field in the UI. Not the same as the plan's `summary`.")}).strict(),ec=pa(ma),tc=pa(ma.omit({objectName:true})),rc=z$1.object({name:Zd,label:z$1.string().min(1).describe('Human-readable singular display label (e.g. "Devis").'),pluralLabel:z$1.string().optional().describe('Human-readable plural display label (e.g. "Devis"/"Invoices"). Defaults from `label` if omitted.'),description:z$1.string().optional().describe("Help text describing what this object represents."),icon:c.describe("Required icon name for the object. Must be a catalogue value \u2014 call `search_icons` and use a name it returns verbatim. A name that is not in the catalogue is rejected without any hint as to what would have worked, so never guess one."),labelExpression:be.describe('Template used to render a human-readable label for every record of this object \u2014 e.g. shown in relations, search results, and breadcrumbs. MUST contain at least one `{{ attributeName }}` interpolation referencing an attribute this object will actually have (either declared in this same `attributes` array, or an existing attribute if this is an update) \u2014 a plain string with no `{{ }}` at all (e.g. "Devis") is rejected. Interpolations cannot be empty (`{{ }}` is rejected) and only these pipes are allowed: UPPER, LOWER, capitalize, trim, prefix:"...", suffix:"...", wrap:"..." "...", default:"...". `{{ a || b }}` falls back to `b` when `a` is empty. Examples: "{{ firstName }} {{ lastName }}", "{{ numero | UPPER }}", "{{ name || reference }}".'),attributes:z$1.array(tc).default([]).describe("Attributes to create on this new object, inline. Same rules as a standalone entry in `additive.attributes`, minus `objectName` (implied by this object). At least one attribute referenced by `labelExpression` should be included here.")}).strict(),fa=z$1.object({attributeRemovals:z$1.array(z$1.object({objectName:z$1.string().min(1).describe("Object the attribute is removed from."),attributeName:z$1.string().min(1).describe("Attribute to delete, together with every record's stored value for it. Must not be a system (code-declared) attribute, and must not be referenced by the object's own `labelExpression` or `embeddingExpression` \u2014 update those first.")}).strict()).default([]).describe("Attributes to permanently delete. Irreversible: record values for the attribute are purged."),objectRemovals:z$1.array(z$1.object({objectName:z$1.string().min(1).describe("Object to delete entirely, together with all its records. Must not be a system (code-declared) object, and must not still be targeted by a `relation` attribute on another object \u2014 retarget or remove that relation first.")}).strict()).default([]).describe("Objects to permanently delete, records included. Irreversible."),renames:z$1.array(z$1.object({objectName:z$1.string().min(1).describe("Object the renamed attribute belongs to."),from:z$1.string().min(1).describe("Current attribute name. Must already exist and not be a system attribute."),to:ca.describe("New attribute name \u2014 same identifier rules as any attribute `name` (see `name` on a planned attribute), and must not collide with another name already on the object, including one added elsewhere in this same plan.")}).strict()).default([]).describe("Attribute renames. Every reference to the old name (labelExpression, views, formulas) must be updated separately \u2014 a rename does not follow references automatically.")}).strict().default({attributeRemovals:[],objectRemovals:[],renames:[]}),ba=z$1.string().min(1).describe("ONE sentence naming the intent of the change \u2014 what it is for, not what it contains. The human approving it has already watched every entry land in the preview window and can read every row of the plan itself, so a recap tells them nothing they do not have. A second sentence is warranted only when `destructive` is non-empty: say plainly what will be lost (e.g. 'deletes the \"ancienMontant\" column and its data on every devis'). Never restate the plan \u2014 explain intent."),oa="The COMPLETE config this view should end up with \u2014 not a patch. Copy the baseline returned by get_default_view and edit it, preserving every tab and setting you are not changing: anything you omit is dropped. To change the columns shown, set `tabs[].columns` (an array of attribute names) \u2014 there is no top-level `columns` on either view type. For a detail view's side panel, set `sidePanel.attributes`. Every attribute name listed must already exist on the object, or be created earlier in this same plan. ONE EXCEPTION to omit-is-dropped: a tab with `type: \"custom\"` renders a component belonging to the application, which you cannot describe or recreate. Copy every such tab through from the baseline exactly as it came, `name`, `component` and `props` untouched \u2014 dropping one, inventing one, or altering any of those three is rejected rather than applied (`name` is the tab's address in links, not its wording). Its `label` and `icon` you may change.",aa="Opaque token returned by get_default_view alongside the baseline you edited. REQUIRED when the object already exists \u2014 it proves you authored against the baseline that is still current. Must be OMITTED when this plan creates the object, which has no baseline yet.",sa=z$1.string().min(1).describe("Name of the object whose default view of this type is replaced. Not a view name \u2014 a plan can only replace an object's deterministic default view, never create a view or target a non-default one."),nc=z$1.discriminatedUnion("viewType",[z$1.object({objectName:sa,viewType:z$1.literal("list").describe("Targets the object's default list view (the grid)."),canonicalConfig:ka$1.describe(oa),baselineToken:z$1.string().min(1).optional().describe(aa)}).strict(),z$1.object({objectName:sa,viewType:z$1.literal("detail").describe("Targets the object's default detail view (the single-record view)."),canonicalConfig:la$1.describe(oa),baselineToken:z$1.string().min(1).optional().describe(aa)}).strict()]);var ua=z$1.string().regex(/^[0-9a-f]{64}$/,"Expected a lowercase SHA-256 hash"),la={baseConfigHash:ua.nullable(),targetConfigHash:ua,baselineOrigin:z$1.enum(["persisted","generated","absent"])},ic=z$1.discriminatedUnion("viewType",[z$1.object({objectName:z$1.string().min(1),viewType:z$1.literal("list"),canonicalConfig:ka$1,...la}).strict(),z$1.object({objectName:z$1.string().min(1),viewType:z$1.literal("detail"),canonicalConfig:la$1,...la}).strict()]).superRefine((e,t)=>{let r=e.baselineOrigin!=="absent";r!==(e.baseConfigHash!==null)&&t.addIssue({code:"custom",path:["baseConfigHash"],message:r?`A ${e.baselineOrigin} baseline requires baseConfigHash`:"An absent baseline requires baseConfigHash to be null"});});function ga(e){return z$1.object({objects:z$1.array(rc).default([]).describe("New objects to create, with their attributes inline."),attributes:z$1.array(ec).default([]).describe("Attributes to add to existing or same-plan objects."),viewUpdates:z$1.array(e).default([]).describe("Complete target configs for deterministic default views; never view names.")}).strict().default({objects:[],attributes:[],viewUpdates:[]})}a(ga,"buildAdditiveSchema");function Jn(e,t=[],r=new WeakSet){if(e===null||typeof e=="string"||typeof e=="boolean")return null;if(typeof e=="number")return Number.isFinite(e)?null:{path:t,message:"Plan input contains a non-finite number"};if(typeof e!="object")return {path:t,message:"Plan input must contain only JSON-safe values"};if(r.has(e))return {path:t,message:"Plan input cannot contain circular references"};if(Array.isArray(e)){r.add(e);for(let s of Reflect.ownKeys(e))if(s!=="length"&&(typeof s=="symbol"||!/^(0|[1-9]\d*)$/.test(s)))return r.delete(e),{path:[...t,s],message:"Plan input arrays cannot contain non-index JSON properties"};for(let s=0;s<e.length;s++){if(!Object.hasOwn(e,s))return r.delete(e),{path:[...t,s],message:"Plan input cannot contain sparse arrays"};let l=Jn(e[s],[...t,s],r);if(l)return r.delete(e),l}return r.delete(e),null}let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)return {path:t,message:"Plan input must contain only plain JSON objects"};r.add(e);let o=e,a=Reflect.ownKeys(o);for(let s of a){let l=Object.getOwnPropertyDescriptor(o,s);if(typeof s=="symbol"||!(l?.enumerable&&"value"in l))return r.delete(e),{path:[...t,s],message:"Plan input objects must contain enumerable JSON data properties only"}}for(let s of a.sort()){let l=Jn(o[s],[...t,s],r);if(l)return r.delete(e),l}return r.delete(e),null}a(Jn,"findJsonSafetyIssue");function oc(e){let t=[];return e.additive.objects.forEach((r,n)=>{t.push(["additive","objects",n]),r.attributes.forEach((o,a)=>{t.push(["additive","objects",n,"attributes",a]);});}),e.additive.attributes.forEach((r,n)=>{t.push(["additive","attributes",n]);}),e.additive.viewUpdates.forEach((r,n)=>{t.push(["additive","viewUpdates",n]);}),e.destructive.attributeRemovals.forEach((r,n)=>{t.push(["destructive","attributeRemovals",n]);}),e.destructive.objectRemovals.forEach((r,n)=>{t.push(["destructive","objectRemovals",n]);}),e.destructive.renames.forEach((r,n)=>{t.push(["destructive","renames",n]);}),t}a(oc,"mutationPaths");function ya(e,t){e.additive.objects.length>$.objectAdditions&&t.addIssue({code:"too_big",origin:"array",maximum:$.objectAdditions,inclusive:true,path:["additive","objects",$.objectAdditions],message:`A schema plan can add at most ${$.objectAdditions} objects`});let r=oc(e);r.length>$.totalMutations&&t.addIssue({code:"too_big",origin:"array",maximum:$.totalMutations,inclusive:true,path:r[$.totalMutations],message:`A schema plan can contain at most ${$.totalMutations} mutations; received ${r.length}`});}a(ya,"addPlanLimitIssues");function ha(e,t){let r=Jn(e);if(r)return t.addIssue({code:"custom",path:r.path,message:r.message}),z$1.NEVER;let n=new TextEncoder().encode(a$4(e)).byteLength;return n>$.serializedBytes?(t.addIssue({code:"too_big",origin:"string",maximum:$.serializedBytes,inclusive:true,path:[],message:`A schema plan can serialize to at most ${$.serializedBytes} UTF-8 bytes; received ${n}`}),z$1.NEVER):e}a(ha,"boundSerializedPlanInput");var ac=ga(nc),sc=ga(ic),da=z$1.object({schemaPlanVersion:z$1.literal(2).describe("Required proposal contract version."),summary:ba,additive:ac,destructive:fa}).strict().superRefine((e,t)=>{let r=new Set(e.additive.objects.map(n=>n.name));e.additive.viewUpdates.forEach((n,o)=>{let a=["additive","viewUpdates",o,"baselineToken"];if(r.has(n.objectName)){n.baselineToken!==void 0&&t.addIssue({code:"custom",path:a,message:"A view target for an object added by this plan must not include baselineToken"});return}n.baselineToken===void 0&&t.addIssue({code:"custom",path:a,message:"A view target for an existing object requires baselineToken"});}),ya(e,t);}),Dx=Object.assign(z$1.preprocess(ha,da),{shape:da.shape}),uc=z$1.object({schemaPlanVersion:z$1.literal(2),summary:ba,additive:sc,destructive:fa}).strict().superRefine(ya),Cx=z$1.preprocess(ha,uc);var A=z$1.number().finite().nonnegative(),Ta=z$1.enum(Li),Zn=z$1.enum(Bi),ei=z$1.enum(Ui),wa=z$1.object({provider:Ta,model:z$1.string().min(1)}).strict(),Fx=z$1.object({speed:Zn.optional(),reasoning:ei.optional()}).strict(),xa=z$1.string().regex(/^[a-z0-9][a-z0-9-]*\/[a-z0-9][a-z0-9._-]*$/),lc=z$1.object({model:wa.optional(),speed:Zn.optional(),reasoning:ei.optional(),imageModel:xa.optional()}).strict(),Vx=lc.refine(e=>e.model!==void 0||e.speed!==void 0||e.reasoning!==void 0||e.imageModel!==void 0,{message:"At least one inference override is required"}),jx=z$1.object({model:wa.nullable().optional(),speed:Zn.nullable().optional(),reasoning:ei.nullable().optional(),imageModel:xa.nullable().optional()}).strict().refine(e=>Object.keys(e).length>0&&Object.values(e).every(t=>t!==void 0),{message:"At least one inference override is required"}),Ia=z$1.object({label:z$1.string(),denied:z$1.boolean().optional(),deletion:z$1.object({target:z$1.string().optional(),count:A.optional(),restorableDays:A.optional()}).strict().optional(),counts:z$1.record(z$1.string(),A).optional(),warnings:z$1.array(z$1.string()).optional()}).strict(),dc=z$1.union([z$1.object({type:z$1.literal("text"),text:z$1.string()}).strict(),z$1.object({type:z$1.literal("reasoning"),text:z$1.string()}).strict(),z$1.object({type:z$1.literal("system"),code:z$1.enum(qt)}).strict(),z$1.object({type:z$1.literal("error"),error:z$1.string(),errorClass:z$1.string().optional()}).strict(),z$1.object({type:z$1.literal("tool"),toolCallId:z$1.string(),name:z$1.string(),args:z$1.record(z$1.string(),z$1.unknown()),result:z$1.unknown().optional(),error:z$1.string().optional(),errorCode:z$1.enum(["output_limit_reached","interrupted"]).optional(),state:z$1.enum(["streaming","running","completed","error","approval-requested","approval-responded","approval-dispatched"]),durationMs:A.optional(),approvalId:z$1.string().optional(),approvalImpact:Ia.optional(),approved:z$1.boolean().optional(),approvalReason:z$1.string().optional(),approvalRelaxableByAuto:z$1.boolean().optional()}).strict(),z$1.object({type:z$1.literal("file"),fileId:z$1.string(),name:z$1.string(),mimeType:z$1.string()}).strict(),z$1.object({type:z$1.literal("compaction"),state:z$1.literal("in-progress"),reason:z$1.enum(["preflight_threshold","overflow_recovery"]),estimatedTokens:A.optional(),reportedTokens:A.optional()}).strict(),z$1.object({type:z$1.literal("compaction"),state:z$1.literal("completed"),tokensBefore:A,tokensAfter:A,tokensSaved:A,strategy:z$1.enum(["no-op","summary","truncation"]),durationMs:A,summary:z$1.string().optional()}).strict(),z$1.object({type:z$1.literal("compaction"),state:z$1.literal("failed"),reason:z$1.string(),durationMs:A.optional()}).strict()]),cc=z$1.object({id:z$1.string(),name:z$1.string(),mimeType:z$1.string(),size:A}).strict(),pc=z$1.object({id:z$1.string(),type:z$1.string().transform(e=>e),entityId:z$1.string(),label:z$1.string(),objectName:z$1.string().optional(),startIndex:A,endIndex:A}).strict(),mc=z$1.object({provider:Ta,model:z$1.string(),maxTokens:A.optional(),contextWindow:A.optional()}).strict(),fc=z$1.union([z$1.date(),z$1.string().datetime({offset:true}).transform(e=>new Date(e))]),Aa=z$1.object({id:z$1.string(),sessionId:z$1.string(),tenantId:z$1.string().optional(),runId:z$1.string().optional(),role:z$1.enum(["user","assistant","system","tool"]),parts:z$1.array(dc),attachments:z$1.array(cc).optional(),mentions:z$1.array(pc).optional(),model:mc.optional(),tokenUsage:z$1.object({input:A,output:A}).strict().optional(),metadata:z$1.record(z$1.string(),z$1.unknown()).optional(),createdAt:fc}).strict(),bc=z$1.object({id:z$1.string(),description:z$1.string(),status:z$1.enum(["pending","in_progress","completed","blocked"]),result:z$1.string().optional(),updatedAt:A.optional()}).strict(),gc=z$1.object({id:z$1.string(),sessionId:z$1.string(),status:z$1.enum(["active","completed","abandoned"]),todos:z$1.array(bc),version:A,createdAt:z$1.string(),updatedAt:z$1.string(),completedAt:z$1.string().optional()}).strict(),Sa={"session-named":z$1.object({name:z$1.string()}).strict(),"compaction-start":z$1.object({reason:z$1.enum(["preflight_threshold","overflow_recovery"]),estimatedTokens:A.optional(),reportedTokens:A.optional()}).strict(),"compaction-end":z$1.object({tokensBefore:A,tokensAfter:A,tokensSaved:A,strategy:z$1.enum(["no-op","summary","truncation"]),durationMs:A,summary:z$1.string().optional()}).strict(),"compaction-failed":z$1.object({reason:z$1.string()}).strict(),usage:z$1.object({messageId:z$1.string().min(1).optional(),inputTokens:A,outputTokens:A,totalTokens:A,cacheReadTokens:A.optional(),cacheCreationTokens:A.optional(),contextWindow:A,residentTokens:A,utilization:z$1.number().finite().min(0).max(1),costUsd:A.optional()}).strict(),"message-persisted":z$1.object({message:Aa}).strict(),"message-updated":z$1.object({message:Aa}).strict(),"todo-plan-update":z$1.object({plan:gc}).strict(),"approval-context":z$1.object({approvalId:z$1.string(),toolCallId:z$1.string(),impact:Ia.optional(),relaxableByAuto:z$1.boolean().optional()}).strict(),"session-state":z$1.object({state:z$1.object({phase:z$1.enum(["queued","running","parked","terminal"]),parkedOn:z$1.enum(["human","agents"]).optional(),humanRequestIds:z$1.array(z$1.string()).optional(),outcome:z$1.enum(["completed","failed","cancelled","timeout","expired"]).optional()}).strict(),version:z$1.number().int().positive(),updatedAt:z$1.string().datetime({offset:true})}).strict()};function yc(e){return e in Sa}a(yc,"isAgentUIDataName");function hc(e){return new h("Invalid agent UI message chunk",e.map(t=>({path:t.path.map(String),message:t.message,code:t.code})))}a(hc,"agentUIValidationError");function Ac(e){if(typeof e!="object"||e===null||typeof e.type!="string")throw new h("Invalid agent UI message chunk",[{path:["type"],message:"Expected UI message chunk type",code:"invalid_type"}]);let t=e.type;if(!t.startsWith("data-"))throw new h("Invalid agent UI message chunk",[{path:["type"],message:"Expected agent data chunk type",code:"invalid_value"}]);let r=t.slice(5);if(!yc(r))throw new h("Invalid agent UI message chunk",[{path:["type"],message:`Unknown agent UI data type: ${r}`,code:"invalid_value"}]);let n=z$1.object({type:z$1.literal(`data-${r}`),id:z$1.string().optional(),data:Sa[r],transient:z$1.boolean().optional()}).strict().safeParse(e);if(!n.success)throw hc(n.error.issues);return n.data}a(Ac,"assertCustomAgentUIMessageChunk");function Mx(e,t,r){return Ac({type:`data-${e}`,...r?.id!==void 0?{id:r.id}:{},data:t,...r?.transient!==void 0?{transient:r.transient}:{}})}a(Mx,"agentDataChunk");function Rt(e){return e}a(Rt,"defineOperation");function y(e,t,r){let n=t==="atomic"?"none":t==="local"?"if-not-visible":"follow";return o=>{let a=r?.(o);return {impact:t,navigation:n,focus:{...e(o),...a===void 0?{}:{propertyPath:a}}}}}a(y,"definePresentation");var ti={id:z$1.string().min(1)},v={...ti,viewId:z$1.string().min(1)};function S(e,t,r){if(!e.views.some(n=>n.id===t))throw new h(`View "${t}" is not in the draftable state`,[]);return {...e,views:e.views.map(n=>n.id===t?r(n):n)}}a(S,"mapView");function Ra(e,t,r){let n=[...e],[o]=n.splice(t,1);return n.splice(r,0,o),n}a(Ra,"moveWithin");function Fe(e,t,r){if(t.length!==e.length)throw new h(`${r} order lists ${t.length} ids for ${e.length} items`,[]);return t.map(n=>{let o=e.find(a=>a.id===n);if(!o)throw new h(`${r} "${n}" is not in this collection`,[]);return o})}a(Fe,"reorderById");function ne(e,t,r){let n=e.tabs.find(o=>o.id===t);if(!n)throw new h(`Tab "${t}" is not in view "${e.id}"`,[]);if(n.type!=="form")throw new h(`Tab "${t}" is not a form tab`,[]);return {...e,tabs:e.tabs.map(o=>o.id===t?r(n):o)}}a(ne,"mapFormTab");function Ct(e,t){let r=e.groups.find(n=>n.id===t);if(!r)throw new h(`Group "${t}" is not in tab "${e.id}"`,[]);return r}a(Ct,"requireGroup");function ri(e,t){for(let r of e.groups){let n=r.fields.find(o=>o.id===t);if(n)return {group:r,field:n}}throw new h(`Field slot "${t}" is not in tab "${e.id}"`,[])}a(ri,"locateField");function Et(e){return {viewId:e.viewId}}a(Et,"viewFocus");function Dt(e){return {viewId:e.viewId,tabId:e.tabId}}a(Dt,"tabFocus");function Ea(e){return {viewId:e.viewId,tabId:e.tabId,groupId:e.groupId}}a(Ea,"groupFocus");function Da(e){return {viewId:e.viewId,tabId:e.tabId,fieldId:e.fieldId}}a(Da,"fieldFocus");function Ca(e){return {viewId:e.viewId,tabId:e.tab.id}}a(Ca,"addTabFocus");function Na(e){return {viewId:e.viewId,tabId:e.tabId,groupId:e.group.id}}a(Na,"addGroupFocus");function ka(e){return {viewId:e.viewId,tabId:e.tabId,groupId:e.groupId,fieldId:e.field.id}}a(ka,"addFieldFocus");function Oa(e){return {viewId:e.viewId,tabId:e.tabId,groupId:e.toGroupId,fieldId:e.fieldId}}a(Oa,"moveFieldFocus");function Ve(e){let t=Object.keys(e.changes).sort();return t.length===1?[t[0]]:void 0}a(Ve,"firstChangedProperty");var Tc=ia$1,wc=da$1,xc=ca$1,Ic=z$1.object({...v,type:z$1.literal("add_tab"),tab:Tc}),Sc={type:"add_tab",schema:Ic,apply:a((e,t)=>S(e,t.viewId,r=>{if(r.tabs.some(n=>n.id===t.tab.id))throw new h(`Tab "${t.tab.id}" already exists in view "${t.viewId}"`,[]);return {...r,tabs:[...r.tabs,t.tab]}}),"apply"),focus:Ca,presentation:y(Ca,"local"),describe:a(e=>`Ajoute l'onglet \xAB ${e.tab.label} \xBB`,"describe")},vc=z$1.object({...v,type:z$1.literal("remove_tab"),tabId:z$1.string().min(1)}),Rc={type:"remove_tab",schema:vc,apply:a((e,t)=>S(e,t.viewId,r=>{if(!r.tabs.some(n=>n.id===t.tabId))throw new h(`Tab "${t.tabId}" is not in view "${t.viewId}"`,[]);return {...r,tabs:r.tabs.filter(n=>n.id!==t.tabId)}}),"apply"),focus:Dt,presentation:y(Dt,"local"),describe:a(e=>`Supprime l'onglet ${e.tabId}`,"describe")},Ma=z$1.object({label:z$1.string().min(1).optional(),icon:c.optional(),order:z$1.number().int().optional()}),Ec=Object.keys(Ma.shape),Dc=z$1.object({...v,type:z$1.literal("update_tab"),tabId:z$1.string().min(1),changes:Ma.refine(e=>Object.keys(e).length>0,"update_tab needs at least one change")}),_a=a(e=>({viewId:e.viewId,tabId:e.tabId}),"updateTabFocus"),Cc={type:"update_tab",schema:Dc,apply:a((e,t)=>S(e,t.viewId,r=>{if(!r.tabs.some(n=>n.id===t.tabId))throw new h(`Tab "${t.tabId}" is not in view "${t.viewId}"`,[]);return {...r,tabs:r.tabs.map(n=>n.id===t.tabId?{...n,...t.changes}:n)}}),"apply"),focus:_a,presentation:y(_a,"atomic",Ve),describe:a(e=>e.changes.label?`Renomme l'onglet en \xAB ${e.changes.label} \xBB`:`Modifie l'onglet ${e.tabId}`,"describe")},Nc=z$1.object({...v,type:z$1.literal("reorder_tabs"),tabOrder:z$1.array(z$1.string().min(1))}),kc={type:"reorder_tabs",schema:Nc,apply:a((e,t)=>S(e,t.viewId,r=>({...r,tabs:Fe(r.tabs,t.tabOrder,"Tab")})),"apply"),focus:Et,presentation:y(Et,"local"),describe:a(()=>"R\xE9ordonne les onglets","describe")},Oc=z$1.object({...v,type:z$1.literal("add_group"),tabId:z$1.string().min(1),group:wc}),_c={type:"add_group",schema:Oc,apply:a((e,t)=>S(e,t.viewId,r=>ne(r,t.tabId,n=>{if(n.groups.some(o=>o.id===t.group.id))throw new h(`Group "${t.group.id}" already exists in tab "${t.tabId}"`,[]);return {...n,groups:[...n.groups,t.group]}})),"apply"),focus:Na,presentation:y(Na,"local"),describe:a(e=>`Ajoute le groupe \xAB ${e.group.label} \xBB`,"describe")},Pc=z$1.object({...v,type:z$1.literal("remove_group"),tabId:z$1.string().min(1),groupId:z$1.string().min(1)}),Fc={type:"remove_group",schema:Pc,apply:a((e,t)=>S(e,t.viewId,r=>ne(r,t.tabId,n=>(Ct(n,t.groupId),{...n,groups:n.groups.filter(o=>o.id!==t.groupId)}))),"apply"),focus:Ea,presentation:y(Ea,"local"),describe:a(e=>`Supprime le groupe ${e.groupId}`,"describe")},Vc=z$1.object({...v,type:z$1.literal("update_group"),tabId:z$1.string().min(1),groupId:z$1.string().min(1),changes:z$1.object({label:z$1.string().min(1).optional(),description:z$1.string().optional(),collapsible:z$1.boolean().optional(),collapsed:z$1.boolean().optional(),order:z$1.number().int().optional()}).refine(e=>Object.keys(e).length>0,"update_group needs at least one change")}),Pa=a(e=>({viewId:e.viewId,tabId:e.tabId,groupId:e.groupId}),"updateGroupFocus"),jc={type:"update_group",schema:Vc,apply:a((e,t)=>S(e,t.viewId,r=>ne(r,t.tabId,n=>(Ct(n,t.groupId),{...n,groups:n.groups.map(o=>o.id===t.groupId?{...o,...t.changes}:o)}))),"apply"),focus:Pa,presentation:y(Pa,"atomic",Ve),describe:a(e=>e.changes.label?`Renomme le groupe en \xAB ${e.changes.label} \xBB`:"Modifie le groupe","describe")},Mc=z$1.object({...v,type:z$1.literal("reorder_groups"),tabId:z$1.string().min(1),groupOrder:z$1.array(z$1.string().min(1))}),Lc={type:"reorder_groups",schema:Mc,apply:a((e,t)=>S(e,t.viewId,r=>ne(r,t.tabId,n=>({...n,groups:Fe(n.groups,t.groupOrder,"Group")}))),"apply"),focus:Dt,presentation:y(Dt,"local"),describe:a(()=>"R\xE9ordonne les groupes","describe")},Bc=z$1.object({...v,type:z$1.literal("add_field"),tabId:z$1.string().min(1),groupId:z$1.string().min(1),field:xc,index:z$1.number().int().min(0).optional()}),Uc={type:"add_field",schema:Bc,apply:a((e,t)=>S(e,t.viewId,r=>ne(r,t.tabId,n=>{if(Ct(n,t.groupId),n.groups.some(o=>o.fields.some(a=>a.id===t.field.id)))throw new h(`Field slot "${t.field.id}" already exists in tab "${t.tabId}"`,[]);return {...n,groups:n.groups.map(o=>{if(o.id!==t.groupId)return o;let a=t.index??o.fields.length;return {...o,fields:[...o.fields.slice(0,a),t.field,...o.fields.slice(a)]}})}})),"apply"),focus:ka,presentation:y(ka,"local"),describe:a(e=>`Ajoute le champ ${e.field.attribute??e.field.id}`,"describe")},$c=z$1.object({...v,type:z$1.literal("remove_field"),tabId:z$1.string().min(1),fieldId:z$1.string().min(1)}),qc={type:"remove_field",schema:$c,apply:a((e,t)=>S(e,t.viewId,r=>ne(r,t.tabId,n=>{let{group:o}=ri(n,t.fieldId);return {...n,groups:n.groups.map(a=>a.id===o.id?{...a,fields:a.fields.filter(s=>s.id!==t.fieldId)}:a)}})),"apply"),focus:Da,presentation:y(Da,"local"),describe:a(e=>`Retire le champ ${e.fieldId}`,"describe")},zc=z$1.object({...v,type:z$1.literal("move_field"),tabId:z$1.string().min(1),fieldId:z$1.string().min(1),toGroupId:z$1.string().min(1),toIndex:z$1.number().int().min(0)}),Gc={type:"move_field",schema:zc,apply:a((e,t)=>S(e,t.viewId,r=>ne(r,t.tabId,n=>{let{group:o,field:a}=ri(n,t.fieldId),s=Ct(n,t.toGroupId);if(o.id===s.id){let l=o.fields.findIndex(p=>p.id===t.fieldId);return {...n,groups:n.groups.map(p=>p.id===o.id?{...p,fields:Ra(p.fields,l,t.toIndex)}:p)}}return {...n,groups:n.groups.map(l=>l.id===o.id?{...l,fields:l.fields.filter(p=>p.id!==t.fieldId)}:l.id===s.id?{...l,fields:[...l.fields.slice(0,t.toIndex),a,...l.fields.slice(t.toIndex)]}:l)}})),"apply"),focus:Oa,presentation:y(Oa,"local"),describe:a(e=>`D\xE9place le champ ${e.fieldId} vers le groupe ${e.toGroupId}`,"describe")},Wc=z$1.object({...v,type:z$1.literal("update_field"),tabId:z$1.string().min(1),fieldId:z$1.string().min(1),changes:z$1.object({label:z$1.string().optional(),readOnly:z$1.boolean().optional(),span:z$1.number().int().min(1).max(12).optional()}).refine(e=>Object.keys(e).length>0,"update_field needs at least one change")}),Fa=a(e=>({viewId:e.viewId,tabId:e.tabId,fieldId:e.fieldId}),"updateFieldFocus"),Kc={type:"update_field",schema:Wc,apply:a((e,t)=>S(e,t.viewId,r=>ne(r,t.tabId,n=>(ri(n,t.fieldId),{...n,groups:n.groups.map(o=>({...o,fields:o.fields.map(a=>a.id===t.fieldId?{...a,...t.changes}:a)}))}))),"apply"),focus:Fa,presentation:y(Fa,"atomic",Ve),describe:a(e=>`Modifie le champ ${e.fieldId}`,"describe")},La=z$1.object({source:ga$1.optional(),columns:X.optional(),filters:_.nullable().optional(),sorts:Z$1.nullable().optional(),allowCreate:z$1.boolean().optional(),allowEdit:z$1.boolean().optional(),allowDelete:z$1.boolean().optional(),createMode:z$1.enum(["redirect","inline","peek"]).optional()}),Yc=Object.keys(La.shape),Ba=z$1.object({emailAttributeIds:z$1.array(z$1.string().min(1)).optional(),attribute:z$1.string().min(1).optional(),titleAttribute:z$1.string().min(1).nullable().optional(),component:z$1.string().nullable().optional(),props:z$1.record(z$1.string(),z$1.unknown()).nullable().optional()}),Hc=Object.keys(Ba.shape),Qc={emailAttributeIds:["emails","meetings"],attribute:["richtext"],titleAttribute:["richtext"],component:["custom"],props:["custom"]},Jc=z$1.object({...v,type:z$1.literal("update_tab_config"),tabId:z$1.string().min(1),changes:Ba.refine(e=>Object.keys(e).length>0,"update_tab_config needs at least one change")}),Va=a(e=>({viewId:e.viewId,tabId:e.tabId}),"updateTabConfigFocus"),Xc={type:"update_tab_config",schema:Jc,apply:a((e,t)=>S(e,t.viewId,r=>{let n=r.tabs.find(o=>o.id===t.tabId);if(!n)throw new h(`Tab "${t.tabId}" is not in view "${r.id}"`,[]);for(let o of Object.keys(t.changes)){let a=Qc[o];if(a&&!a.includes(n.type))throw new h(`"${o}" is not a setting of a "${n.type}" tab`,[])}return {...r,tabs:r.tabs.map(o=>o.id===t.tabId?{...o,...t.changes}:o)}}),"apply"),focus:Va,presentation:y(Va,"atomic",Ve),describe:a(e=>`Configure ${Object.keys(e.changes).join(", ")} sur l'onglet ${e.tabId}`,"describe")},Zc=z$1.object({...v,type:z$1.literal("update_table_tab"),tabId:z$1.string().min(1),changes:La.refine(e=>Object.keys(e).length>0,"update_table_tab needs at least one change")}),ja=a(e=>({viewId:e.viewId,tabId:e.tabId}),"updateTableTabFocus"),ep={type:"update_table_tab",schema:Zc,apply:a((e,t)=>S(e,t.viewId,r=>{let n=r.tabs.find(l=>l.id===t.tabId);if(!n)throw new h(`Tab "${t.tabId}" is not in view "${r.id}"`,[]);if(n.type!=="table")throw new h(`Tab "${t.tabId}" is not a table tab`,[]);let o=Object.entries(t.changes),a=Object.fromEntries(o.filter(([,l])=>l!==null)),s=new Set(o.filter(([,l])=>l===null).map(([l])=>l));return {...r,tabs:r.tabs.map(l=>l.id===t.tabId?Object.fromEntries(Object.entries({...l,...a}).filter(([p])=>!s.has(p))):l)}}),"apply"),focus:ja,presentation:y(ja,"atomic",Ve),describe:a(e=>e.changes.columns?`Affiche ${e.changes.columns.length} colonne(s) dans l'onglet ${e.tabId}`:`Modifie l'onglet ${e.tabId}`,"describe")},tp=z$1.object({...v,type:z$1.literal("set_side_panel"),sidePanel:z$1.object({attributes:z$1.array(z$1.string().min(1)),width:z$1.number().int().min(1).optional()}).nullable()}),rp={type:"set_side_panel",schema:tp,apply:a((e,t)=>S(e,t.viewId,r=>({...r,config:{...r.config,sidePanel:t.sidePanel??void 0}})),"apply"),focus:Et,presentation:y(Et,"atomic",()=>["config","sidePanel"]),describe:a(e=>e.sidePanel?"Active le panneau lat\xE9ral":"Retire le panneau lat\xE9ral","describe")},Ua=[Sc,Rc,Cc,kc,_c,Fc,jc,Lc,Uc,qc,Gc,Kc,ep,Xc,rp];var je={...v,tabId:z$1.string().min(1)};function Nt(e){return {viewId:e.viewId}}a(Nt,"viewFocus");function ie(e){return {viewId:e.viewId,tabId:e.tabId}}a(ie,"tabFocus");function $a(e){return {viewId:e.viewId,tabId:e.tab.id}}a($a,"addTabFocus");function np(e){let t=Object.keys(e.changes).sort();return t.length===1?[t[0]]:void 0}a(np,"firstChangedProperty");function za(e){let t={...e};for(let r of qa$1)delete t[r];return t}a(za,"withoutKanbanKeys");function Ga(e){let t={...e};for(let r of pa$1)delete t[r];return t}a(Ga,"withoutTableKeys");function ip(e,t,r,n){let o=ja$1.safeParse(t);if(!o.success){if(!ja$1.safeParse(e).success)return t;let a=o.error.issues.map(s=>s.path.length?`${s.path.join(".")}: ${s.message}`:s.message).join(", ");throw new h(`List tab "${n}" in view "${r}" would no longer be publishable: ${a}`,[])}return t}a(ip,"assertStillPublishableTab");function kt(e,t,r,n){return S(e,t,o=>{let a=o.config.tabs??[];if(!a.some(s=>s.id===r))throw new h(`List tab "${r}" is not in view "${t}"`,[]);return {...o,config:{...o.config,tabs:a.map(s=>s.id===r?ip(s,n(s),t,r):s)}}})}a(kt,"mapListTab");var op=ja$1,Wa=$$1,ap=Z$1;function K(e,t,r,n){let o=z$1.object({...je,type:z$1.literal(e),value:r});return {type:e,schema:o,apply:a((a,s)=>kt(a,s.viewId,s.tabId,l=>{if(s.value===null){let{[t]:p,...I}=l;return I}return {...l,[t]:s.value}}),"apply"),focus:ie,presentation:y(ie,"atomic",()=>[String(t)]),describe:a(a=>n(a.value),"describe")}}a(K,"setOnTab");var sp=z$1.object({...v,type:z$1.literal("add_list_tab"),tab:op}),up={type:"add_list_tab",schema:sp,apply:a((e,t)=>S(e,t.viewId,r=>{let n=r.config.tabs??[];if(n.some(o=>o.id===t.tab.id))throw new h(`List tab "${t.tab.id}" already exists in view "${t.viewId}"`,[]);return {...r,config:{...r.config,tabs:[...n,t.tab]}}}),"apply"),focus:$a,presentation:y($a,"local"),describe:a(e=>`Ajoute l'onglet \xAB ${e.tab.label} \xBB`,"describe")},lp=z$1.object({...je,type:z$1.literal("remove_list_tab")}),dp={type:"remove_list_tab",schema:lp,apply:a((e,t)=>S(e,t.viewId,r=>{let n=r.config.tabs??[];if(!n.some(o=>o.id===t.tabId))throw new h(`List tab "${t.tabId}" is not in view "${t.viewId}"`,[]);return {...r,config:{...r.config,tabs:n.filter(o=>o.id!==t.tabId)}}}),"apply"),focus:ie,presentation:y(ie,"local"),describe:a(e=>`Supprime l'onglet ${e.tabId}`,"describe")},cp=z$1.object({...je,type:z$1.literal("update_list_tab"),changes:z$1.object({label:z$1.string().min(1).optional(),icon:c.optional(),default:z$1.boolean().optional(),visibility:z$1.enum(w$1).optional()}).refine(e=>Object.keys(e).length>0,"update_list_tab needs at least one change")}),qa=a(e=>({viewId:e.viewId,tabId:e.tabId}),"updateListTabFocus"),pp={type:"update_list_tab",schema:cp,apply:a((e,t)=>kt(e,t.viewId,t.tabId,r=>({...r,...t.changes})),"apply"),focus:qa,presentation:y(qa,"atomic",np),describe:a(e=>e.changes.label?`Renomme l'onglet en \xAB ${e.changes.label} \xBB`:`Modifie l'onglet ${e.tabId}`,"describe")},mp=z$1.object({...v,type:z$1.literal("reorder_list_tabs"),tabOrder:z$1.array(z$1.string().min(1))}),fp={type:"reorder_list_tabs",schema:mp,apply:a((e,t)=>S(e,t.viewId,r=>({...r,config:{...r.config,tabs:Fe(r.config.tabs??[],t.tabOrder,"List tab")}})),"apply"),focus:Nt,presentation:y(Nt,"local"),describe:a(()=>"R\xE9ordonne les onglets","describe")},bp=K("set_columns","columns",z$1.array(z$1.string().min(1)),e=>`Affiche ${Array.isArray(e)?e.length:0} colonne(s)`),gp=K("set_column_sizing","columnSizing",z$1.record(z$1.string(),z$1.number().int().positive()),()=>"Ajuste la largeur des colonnes"),yp=z$1.object({...je,type:z$1.literal("set_layout"),value:z$1.enum(["table","list","kanban"])}),hp={type:"set_layout",schema:yp,apply:a((e,t)=>kt(e,t.viewId,t.tabId,r=>{if(t.value!=="kanban")return {...za(r),layout:t.value};if(r.groupByAttribute===void 0)throw new h(`List tab "${t.tabId}" cannot switch to kanban without a group attribute \u2014 use set_group_by, which switches the layout itself`,[]);return {...Ga(r),layout:"kanban"}}),"apply"),focus:ie,presentation:y(ie,"atomic",()=>["layout"]),describe:a(e=>`Passe en affichage ${e.value}`,"describe")},Ap=z$1.object({...je,type:z$1.literal("set_group_by"),value:z$1.string().min(1).nullable()}),Tp={type:"set_group_by",schema:Ap,apply:a((e,t)=>kt(e,t.viewId,t.tabId,r=>t.value===null?{...za(r),layout:"table"}:{...Ga(r),layout:"kanban",groupByAttribute:t.value}),"apply"),focus:ie,presentation:y(ie,"atomic",()=>["groupByAttribute"]),describe:a(e=>e.value?`Regroupe par ${e.value} en kanban`:"Retire le regroupement, retour en table","describe")},wp=K("set_filters","filters",Wa.nullable(),e=>e?"Modifie les filtres":"Retire les filtres"),xp=K("set_sorts","sorts",ap.nullable(),e=>e?"Modifie le tri":"Retire le tri"),Ip=K("set_create_mode","createMode",z$1.enum(["redirect","inline","peek"]),e=>`Cr\xE9ation en mode ${e}`),Sp=K("set_read_only","readOnly",z$1.boolean(),e=>e?"Passe l'onglet en lecture seule":"Rend l'onglet modifiable"),vp=K("set_card_user_attribute","cardUserAttribute",z$1.string().min(1).nullable(),e=>e?`Affiche ${e} sur les cartes`:"Retire l'utilisateur des cartes"),Rp=K("set_card_date_attribute","cardDateAttribute",z$1.string().min(1).nullable(),e=>e?`Affiche ${e} sur les cartes`:"Retire la date des cartes"),Ep=K("set_description_attribute","descriptionAttribute",z$1.string().min(1).nullable(),e=>e?`Affiche ${e} en description`:"Retire la description"),Dp=K("set_display_attributes","displayAttributes",Y.nullable(),e=>`Affiche ${Array.isArray(e)?e.length:0} attribut(s)`),Cp=z$1.object({...v,type:z$1.literal("set_default_filters"),filters:Wa.nullable()}),Np={type:"set_default_filters",schema:Cp,apply:a((e,t)=>S(e,t.viewId,r=>{if(t.filters===null){let{defaultFilters:n,...o}=r.config;return {...r,config:o}}return {...r,config:{...r.config,defaultFilters:t.filters}}}),"apply"),focus:Nt,presentation:y(Nt,"atomic",()=>["config","defaultFilters"]),describe:a(e=>e.filters?"Modifie les filtres de la vue":"Retire les filtres de la vue","describe")},Ka=[Np,up,dp,pp,fp,bp,gp,hp,Tp,wp,xp,Ip,Sp,vp,Rp,Ep,Dp];function kp(e){return {id:e.id??e.name,name:e.name,label:e.label,...e.icon===void 0?{}:{icon:e.icon}}}a(kp,"toDraftableObject");function Op(e){let t=e.id??e.name;return (e.attributes??[]).map(r=>_p(r,t))}a(Op,"toDraftableAttributes");function ni(e){return {id:e.id,name:e.name,label:e.label,type:e.attributeType,...e.config}}a(ni,"toAttribute");function _p(e,t){let{id:r,name:n,label:o,type:a,...s}=e;return {id:e.id??e.name,objectId:t,name:e.name,label:e.label??e.name,attributeType:e.type,config:s}}a(_p,"toDraftableAttribute");function Pt(e,t){if(!e.objects.some(r=>r.id===t))throw new h(`Object "${t}" is not in the draftable state`,[])}a(Pt,"requireObject");function Ot(e){return {objectId:e.objectId}}a(Ot,"objectFocus");function _t(e){return {objectId:e.objectId,recordId:e.recordId}}a(_t,"recordFocus");function Se(e){return {objectId:e.objectId,attributeId:e.attributeId}}a(Se,"attributeFocus");function Pp(e){let t=Object.keys(e.changes).sort();return t.length===1?[t[0]]:void 0}a(Pp,"firstChangedProperty");var oe={...ti,objectId:z$1.string().uuid()},Fp=z$1.object({...oe,type:z$1.literal("add_object"),name:Xe,label:z$1.string().min(1),icon:z$1.string().min(1).optional()}),Vp={type:"add_object",schema:Fp,apply:a((e,t)=>{if(e.objects.some(n=>n.name===t.name))throw new h(`Object "${t.name}" already exists`,[]);if(e.objects.some(n=>n.id===t.objectId))throw new h(`Object id "${t.objectId}" is already taken`,[]);let r={id:t.objectId,name:t.name,label:t.label,...t.icon===void 0?{}:{icon:t.icon}};return {...e,objects:[...e.objects,r]}},"apply"),focus:Ot,presentation:y(Ot,"structural"),describe:a(e=>`Cr\xE9e l'objet \xAB ${e.label} \xBB`,"describe")},jp=z$1.object({...oe,type:z$1.literal("update_object"),changes:z$1.object({label:z$1.string().min(1).optional(),icon:z$1.string().min(1).optional()}).refine(e=>Object.keys(e).length>0,"update_object needs at least one change")}),Ya=a(e=>({objectId:e.objectId}),"updateObjectFocus"),Mp={type:"update_object",schema:jp,apply:a((e,t)=>(Pt(e,t.objectId),{...e,objects:e.objects.map(r=>r.id===t.objectId?{...r,...t.changes}:r)}),"apply"),focus:Ya,presentation:y(Ya,"atomic",Pp),describe:a(e=>e.changes.label?`Renomme l'objet en \xAB ${e.changes.label} \xBB`:"Modifie l'objet","describe")},Lp=z$1.object({...oe,type:z$1.literal("remove_object")}),Bp={type:"remove_object",schema:Lp,apply:a((e,t)=>{Pt(e,t.objectId);let r=e.objects.find(n=>n.id===t.objectId)?.name;return {...e,objects:e.objects.filter(n=>n.id!==t.objectId),attributes:e.attributes.filter(n=>n.objectId!==t.objectId),sampleRecords:e.sampleRecords.filter(n=>n.objectId!==t.objectId),views:e.views.filter(n=>n.objectName!==r)}},"apply"),focus:Ot,presentation:y(Ot,"structural"),describe:a(e=>`Supprime l'objet ${e.objectId}`,"describe")},Me=Vi.filter(e=>e!=="formula"&&e!=="rollup"),Up=z$1.object({...oe,type:z$1.literal("add_attribute"),attributeId:z$1.string().min(1),name:po,label:z$1.string().min(1),attributeType:z$1.enum(Me),config:z$1.record(z$1.string(),z$1.unknown()).optional()}).superRefine((e,t)=>{try{n(e.attributeType,e.config??{});}catch(r){if(r instanceof h){for(let n of r.errors)t.addIssue({code:"custom",message:n.message,path:["config",...n.path??[]]});return}throw r}}),$p={type:"add_attribute",schema:Up,apply:a((e,t)=>{if(Pt(e,t.objectId),e.attributes.some(n=>n.objectId===t.objectId&&n.name===t.name))throw new h(`Attribute "${t.name}" already exists on object "${t.objectId}"`,[]);let r={id:t.attributeId,objectId:t.objectId,name:t.name,label:t.label,attributeType:t.attributeType,...t.config===void 0?{}:{config:t.config}};for(let n of e.sampleRecords)n.objectId===t.objectId&&Ha(n.id,r,n.values);return {...e,attributes:[...e.attributes,r]}},"apply"),focus:Se,presentation:y(Se,"local"),describe:a(e=>`Ajoute l'attribut \xAB ${e.label} \xBB`,"describe")},qp=z$1.object({...oe,type:z$1.literal("update_attribute"),attributeId:z$1.string().min(1),changes:z$1.object({label:z$1.string().min(1).optional()}).refine(e=>Object.keys(e).length>0,"update_attribute needs at least one change")}),zp={type:"update_attribute",schema:qp,apply:a((e,t)=>{if(!e.attributes.some(r=>r.id===t.attributeId))throw new h(`Attribute "${t.attributeId}" is not in the draftable state`,[]);return {...e,attributes:e.attributes.map(r=>r.id===t.attributeId?{...r,...t.changes}:r)}},"apply"),focus:Se,presentation:y(Se,"atomic"),describe:a(e=>e.changes.label?`Renomme l'attribut en \xAB ${e.changes.label} \xBB`:"Modifie l'attribut","describe")},Gp=z$1.object({...oe,type:z$1.literal("remove_attribute"),attributeId:z$1.string().min(1)}),Wp={type:"remove_attribute",schema:Gp,apply:a((e,t)=>{let r=e.attributes.find(o=>o.id===t.attributeId);if(!r)throw new h(`Attribute "${t.attributeId}" is not in the draftable state`,[]);let n=e.sampleRecords.find(o=>o.objectId===r.objectId&&r.name in o.values);if(n)throw new h(`Attribute "${r.name}" is still used by sample record "${n.id}"`,[]);return {...e,attributes:e.attributes.filter(o=>o.id!==t.attributeId)}},"apply"),focus:Se,presentation:y(Se,"local"),describe:a(e=>`Supprime l'attribut ${e.attributeId}`,"describe")};function Kp(e,t,r,n){let o=ni(r);try{c$2(o);}catch{return}let a=g$1(o,n);if(a.success)return;let s=a.errors??[],l=s.map(p=>p.message).join(", ");throw new h(`Sample record "${e}" has an invalid value for "${t}": ${l}`,s.map(p=>({path:p.path,message:p.message})))}a(Kp,"assertSampleValue");function Ha(e,t,r){if(t.config?.required===true&&t.config?.defaultValue===void 0&&!(t.name in r&&r[t.name]!==void 0))throw new h(`Sample record "${e}" is missing a value for required attribute "${t.name}"`,[])}a(Ha,"assertRequiredCovered");var Yp=z$1.object({...oe,type:z$1.literal("add_sample_record"),recordId:z$1.string().uuid(),values:z$1.record(z$1.string(),z$1.unknown())}),Hp={type:"add_sample_record",schema:Yp,apply:a((e,t)=>{if(Pt(e,t.objectId),e.sampleRecords.some(n=>n.id===t.recordId))throw new h(`Sample record "${t.recordId}" already exists`,[]);let r=new Map(e.attributes.filter(n=>n.objectId===t.objectId).map(n=>[n.name,n]));for(let[n,o]of Object.entries(t.values)){let a=r.get(n);if(!a)throw new h(`Sample record "${t.recordId}" uses unknown attribute "${n}"`,[]);Kp(t.recordId,n,a,o);}for(let n of r.values())Ha(t.recordId,n,t.values);return {...e,sampleRecords:[...e.sampleRecords,{id:t.recordId,objectId:t.objectId,values:t.values}]}},"apply"),focus:_t,presentation:y(_t,"local"),describe:a(()=>"Ajoute un exemple","describe")},Qp=z$1.object({...oe,type:z$1.literal("remove_sample_record"),recordId:z$1.string().min(1)}),Jp={type:"remove_sample_record",schema:Qp,apply:a((e,t)=>{if(!e.sampleRecords.some(r=>r.id===t.recordId&&r.objectId===t.objectId))throw new h(`Sample record "${t.recordId}" is not in object "${t.objectId}"`,[]);return {...e,sampleRecords:e.sampleRecords.filter(r=>r.id!==t.recordId)}},"apply"),focus:_t,presentation:y(_t,"local"),describe:a(()=>"Retire un exemple","describe")},Qa=[Vp,Mp,Bp,$p,zp,Wp,Hp,Jp];function Xp(){let e=new Map;for(let t of [...Qa,...Ua,...Ka]){if(e.has(t.type))throw new r("architect operation",t.type);e.set(t.type,t);}return e}a(Xp,"build");var ce=Xp(),ii=[...ce.keys()];function Le(e){let t=ce.get(e.type);if(!t)throw new h(`Operation "${e.id}" has unknown type "${e.type}"`,[]);return t}a(Le,"defOf");function oi(e,t){return t.reduce((r,n)=>Le(n).apply(r,n),e)}a(oi,"applyOperations");function Zp(e){return Le(e).focus(e)}a(Zp,"focusOf");function em(e,t){return e.map(r=>Le(r).describe(r,t))}a(em,"describeOperations");function tm(e){if(typeof e!="object"||e===null||!("type"in e))throw new h("An operation must be an object carrying a type",[]);let t=e.type;if(typeof t!="string")throw new h("An operation's type must be a string",[]);let r=ce.get(t);if(!r)throw new h(`Unknown operation type "${t}"`,[]);let n=r.schema.safeParse(e);if(!n.success)throw new h(`Operation "${t}" is invalid: ${n.error.issues.map(o=>`${o.path.join(".")} ${o.message}`).join("; ")}`,[]);return n.data}a(tm,"parseOperation");function Ja(e){return z$1.toJSONSchema(e,{io:"input"})}a(Ja,"toJsonSchema");function nm(e){let t=ce.get(e);if(!t)throw new h(`Unknown operation type "${e}"`,[]);return Ja(t.schema)}a(nm,"describeOperationInput");function im(e){let t=Me.find(r=>r===e);if(!t)throw new h(`Unknown attribute type "${e}"`,[]);return Ja(m(t))}a(im,"describeAttributeConfig");function om(){return {operations:[...ii],attributeTypes:[...Me]}}a(om,"listDescribableNames");function Xa(e,t,r){let n=`fld_${e}_${t}`;return r===0?n:`${n}_${r}`}a(Xa,"makeFieldId");function am(e,t){return e.attributeGroup?e.attributeGroup.id:e.attribute?e.attribute:`slot${t}`}a(am,"seedOf");function sm(e){let t=new Map,r=e.fields.map((n,o)=>{if(n.id)return n;let a=am(n,o),s=t.get(a)??0;return t.set(a,s+1),{...n,id:Xa(e.id,a,s)}});return {...e,fields:r}}a(sm,"withIds");function um(e){return e.map(t=>t.type==="form"?{...t,groups:t.groups.map(sm)}:t)}a(um,"ensureFieldIds");function ai(e){return Le(e).presentation(e)}a(ai,"presentationOf");function lm(e){let t=e.map(ai);return new Set(t.map(({focus:n})=>n.viewId??n.objectId).filter(n=>n!==void 0)).size>1||t.some(({impact:n})=>n==="structural")?"structural":t.some(({impact:n})=>n==="local")?"local":"atomic"}a(lm,"episodeImpactOf");function dm(e,t){return e.config.tabs?.find(r=>r.id===t)}a(dm,"listTabOf");function Za(e,t){let r=t.viewId?e.views.find(o=>o.id===t.viewId):void 0,n=t.tabId?r?.tabs.find(o=>o.id===t.tabId):void 0;if(t.attributeId)return e.attributes.find(o=>o.id===t.attributeId);if(t.fieldId){if(n?.type!=="form")return;for(let o of n.groups){let a=o.fields.find(s=>s.id===t.fieldId);if(a)return a}return}if(t.groupId)return n?.type!=="form"?void 0:n.groups.find(o=>o.id===t.groupId);if(t.tabId)return r?n??dm(r,t.tabId):void 0;if(t.recordId)return e.sampleRecords.find(o=>o.id===t.recordId);if(r)return r;if(t.objectId)return e.objects.find(o=>o.id===t.objectId)}a(Za,"snapshotArchitectTarget");function cm(e,t){let r=e;return t.map(n=>{let o=ai(n),a=Za(r,o.focus);r=oi(r,[n]);let s=Za(r,o.focus);return {operationId:n.id,operationType:n.type,presentation:o,before:a,after:s}})}a(cm,"deriveArchitectChanges");function pm(e){return {id:e.id??"",objectName:e.object,type:e.type,label:e.label,tabs:Ke(e)?e.config.tabs??[]:[],config:e.config}}a(pm,"toDraftableView");function mm(e,t){return e.type==="detail"?{...e,label:t.label,config:{...t.config,tabs:t.tabs}}:{...e,label:t.label,config:t.config}}a(mm,"fromDraftableView");export{GT as AGENT_UI_BATCH_MAX_BYTES,WT as AGENT_UI_BATCH_MAX_ITEMS,Xi as ALLOWED_PROPERTY_TYPES,Kt as ALL_ACTIONS,ii as ALL_OPERATION_TYPES,Ih as ALL_SYSTEM_RESOURCES,Kb as ARTIFACT_FILE_ROLES,Gb as ARTIFACT_KINDS,qu as ARTIFACT_LIST_VIEW,$u as ARTIFACT_OBJECT,Nn as ARTIFACT_OBJECT_NAME,Wb as ARTIFACT_RETENTIONS,Vi as ATTRIBUTE_TYPES,ub as AUDIT_ACTIONS,sb as AUDIT_RESOURCE_TYPES,Kr as ActivityTabConfig,Xt as AgentBuilder,Xf as BEHAVIOR_PROPERTIES,js as BYTE_UNIT_LABELS,xs as CLAIMABLE_SESSION_STATUSES,_e as COMPUTED_FUNCTIONS,Cw as COMPUTED_FUNCTION_METADATA,uw as COMPUTED_FUNCTION_NAMES,tx as CONNECTOR_CALLBACK_PARAM,Qi as COUNT_MODES,b as ComputedFormulaCompileError,Gr as CustomTabConfig,wh as DB_COLUMN_FIELDS,bo as DEFAULT_AGENT_EXECUTION_CONFIG,Mi as DEFAULT_APPROVAL_POLICY,qb as DEFAULT_DICTATION_LIMITS,ro as DEFAULT_LABEL_FALLBACK,ks as DEFAULT_MEETING_BOT_DISPLAY_NAME,pu as DEFAULT_ROLES,Rh as DEFAULT_ROLE_DESCRIPTIONS,vh as DEFAULT_ROLE_LABELS,Eh as DEFAULT_ROLE_PERMISSIONS,Ig as DEFAULT_TENANT_SETTINGS,Ub as DICTATION_FINALIZATION_TIMEOUT_MS,Fb as DICTATION_FRAME_BYTES,jb as DICTATION_MAX_BUFFER_BYTES,Vb as DICTATION_MAX_FRAME_BYTES,Mb as DICTATION_MAX_TRANSCRIPT_BYTES,$b as DICTATION_MODEL_ID,Bb as DICTATION_PREPARATION_TIMEOUT_MS,Pb as DICTATION_SAMPLE_RATE,Lb as DICTATION_TICKET_TTL_MS,My as DOCUMENT_SYSTEM_ATTRIBUTES,Me as DRAFTABLE_ATTRIBUTE_TYPES,Uu as DRIVE_LIST_VIEW,Lu as DRIVE_OBJECT,ct as DRIVE_OBJECT_NAME,Bu as DRIVE_VIEW,Jr as DetailViewBuilder,Qr as DocumentsTabConfig,He as EMPTY_VALUE_PLACEHOLDER,jg as ESTIMATED_COUNT_CAP,Yr as EmailsTabConfig,ax as FAKE_MEETING_BOT_SIGNATURE_HEADER,zt as FORM_FORBIDDEN_ATTRIBUTE_TYPES,Ne as FlagRegistry,dt as FlagService,Mr as FormBuilder,Oe as FormRegistry,Vr as FormRowBuilder,jr as FormStepBuilder,ot as GroupBuilder,Jf as IDENTITY_PROPERTIES,_g as IMAGE_FORMATS,Ui as INFERENCE_REASONING_OPTIONS,Bi as INFERENCE_SPEEDS,ol as LIVE_EVENT_TYPES,Xr as ListViewBuilder,Zr as ListViewTabConfigBuilder,zi as MAX_PRESET_DEPTH,Ib as MAX_TODOS,vb as MAX_TODO_DESCRIPTION_CHARS,Sb as MAX_TODO_ID_CHARS,Rb as MAX_TODO_RESULT_CHARS,T as MEETING_ATTRIBUTES,Ro as MEETING_DETAIL_VIEW_ID,Wu as MEETING_LIST_VIEW,So as MEETING_LIST_VIEW_ID,zu as MEETING_OBJECT,pt as MEETING_OBJECT_NAME,Gu as MEETING_VIEW,vo as MEETING_WRITE_SOURCE,Mu as MEMORY_LIST_VIEW,Vu as MEMORY_OBJECT,ju as MEMORY_VIEW,Kd as McpOAuthCompletionMode,Hr as MeetingsTabConfig,vs as NATIVE_AGENT_UI_PART_IDS_METADATA_KEY,Rs as NATIVE_AGENT_UI_PART_IDS_METADATA_SCHEMA_VERSION,Pi as NOTIFICATION_INBOX_STATES,ki as NOTIFICATION_KINDS,Oi as NOTIFICATION_PRIORITIES,_i as NOTIFICATION_SENSITIVITIES,Hf as NOTIFICATION_TYPES_V1,Ts as NOTIFICATION_TYPE_AGENT_QUESTION_REQUESTED,hs as NOTIFICATION_TYPE_AGENT_SESSION_WAITING_HUMAN,As as NOTIFICATION_TYPE_AGENT_TASK_ASSIGNED,Fi as NOTIFICATION_WORK_STATES,sx as NO_RECORDING,Ki as NoopGeocodingAdapter,Xe as OBJECT_NAME_SCHEMA,Is as OPEN_TOOL_PART_STATES,ce as OPERATION_REGISTRY,St as OPERATOR_SPECS,qr as ObjectBuilder,Zf as PRESENTATION_PROPERTIES,Li as PROVIDER_NAMES,Gy as QUALIFIED_SEPARATOR,Bg as QUOTA_KEYS,ix as RECORDING_OVERRIDES,ox as RECORDING_POLICIES,uo as RECORD_CREATOR_ROOT_ACTOR_METADATA_KEY,$t as RELATION_TARGET_ANY,Wr as RichtextTabConfig,$ as SCHEMA_PLAN_LIMITS,Qn as SCHEMA_SOURCE_ID_PATTERN,Nb as SESSION_STATE_STREAM_ID,ws as SESSION_TERMINAL_STATUSES,wo as SKILL_CONTENT_TEMPLATE,_u as SKILL_LIST_VIEW,ku as SKILL_OBJECT,Ou as SKILL_VIEW,yu as STANDARD_SCHEMA_VENDOR,qt as SYSTEM_PART_CODES,M as SYSTEM_RESOURCES,Sh as SYSTEM_RESOURCE_LABELS,ra as TODAY_DEFAULT,gb as TODO_PLAN_STATUSES,xb as TODO_STATUSES,$i as TOOL_APPROVAL_STATES,Q as TabBuilder,at as TableTabConfig,Yc as UPDATE_TABLE_TAB_CHANGE_KEYS,Ec as UPDATE_TAB_CHANGE_KEYS,Hc as UPDATE_TAB_CONFIG_CHANGE_KEYS,vg as USER_STATUSES,Rg as USER_WORK_POSTURES,yg as accessLevelToActions,gg as actionsToAccessLevel,Bh as agent,Mx as agentDataChunk,yb as agentDisplayName,Fx as agentInferencePreferencesSchema,cc as agentMessageAttachmentSchema,dc as agentMessagePartSchema,lc as agentSessionInferenceOverridesInputSchema,Vx as agentSessionInferenceOverridesSchema,Aa as agentSessionMessageSchema,hc as agentUIValidationError,oi as applyOperations,Zs as applyPipes,iu as applyRelationProps,mw as assertAcyclicComputedDependencies,Ac as assertCustomAgentUIMessageChunk,Qd as assertSchemaSourceId,wu as booleanFlag,ia as buildAgentFallbackTitle,cu as buildPermissionFlags,Ye as buildPropertySchema,Ky as buildQualifiedAttribute,go as checkbox,Ss as compareAgentSessionMessages,Bo as compileComputedFormula,yw as compileRollupAttribute,Vs as computeByteMagnitude,Hd as conversationDisplayTitle,Ru as createFlagRegistry,Du as createFlagService,et as createStandardSchemaProps,Zh as currency,Sa as customDataChunkSchemas,U as date,vt as dateInTimezone,fe as dateValueStart,Rt as defineOperation,y as definePresentation,cm as deriveArchitectChanges,Xw as deriveCreateDefaultsFromFilters,lu as deriveInitials,im as describeAttributeConfig,nm as describeOperationInput,em as describeOperations,fa as destructiveSchema,ee as detailView,yo as document,fc as durableDateSchema,um as ensureFieldIds,lm as episodeImpactOf,Sw as evaluateComputedAst,vw as evaluateComputedFormula,Rw as evaluateComputedFormulaWithResult,Bd as evaluateFilterState,zw as evaluateRecordFilterState,oo as extractAttributeNames,so as extractValueRefs,vu as flagRegistry,Zp as focusOf,pA as form,Ns as formFieldFlatKey,Cs as formFieldKey,Co as formRegistry,UT as formatAgentStreamFrameId,Zi as formatAttributeValue,_y as formatByteSize,Fd as formatComputedResult,Gs as formatLocationValue,iA as formula,mm as fromDraftableView,_n as generateDefaultDetailView,Pn as generateDefaultListView,NT as getActiveTab,ru as getEditableLabelAttribute,Qb as getErrorMessage,Ms as getListViewDisplayAttributeNames,iw as getLiveProtocolPayloadChannel,du as getRecordCreatorPrincipalId,ao as getSingleAttributeFromExpression,Wi as getSlotFieldTargets,su as getUserDisplayName,CA as group,gx as hasDestructiveEntries,Tg as hasOptions,xa as imageModelIdSchema,ge as includesAction,nb as inferInverseCardinality,wd as inferRollupReturnType,ei as inferenceReasoningSchema,Zn as inferenceSpeedSchema,yc as isAgentUIDataName,KT as isAgentUIMessageBatch,ib as isAttributeSortable,rb as isBilateralRelation,_w as isCheckboxEquality,bb as isClaimableSessionStatus,bt as isComputedFunctionName,Z as isDateRangeValue,Dh as isDefaultRole,Ke as isDetailView,Ly as isDocumentAttribute,Ps as isEmptyObject,Os as isFieldGroup,eg as isFormDefinition,We as isFormFieldsRow,Gt as isFormFreeFieldRef,sg as isFormHeadingRow,ug as isFormSeparatorRow,Gi as isFormSlotFieldRef,lg as isFormTextRow,Je as isLabelExpression,Hi as isListView,ow as isLiveEventEnvelope,ew as isLiveEventPayload,fl as isLiveEventPayloadForType,ml as isLiveEventType,Ji as isNotEmpty,hb as isOpenToolPartState,Yo as isPlainRecord,qh as isStandardSchema,Tb as isSystemPartCode,fb as isTerminalSessionStatus,cb as isTerminalState,Ab as isToolApprovalState,ji as isUniversalRelation,Su as jsonFlag,mb as legacyStatusToSessionState,om as listDescribableNames,G as listView,QT as liveChannelKey,rA as location,Xa as makeFieldId,By as matchesAccepts,pc as mentionReferenceSchema,mc as modelDefinitionSchema,wa as modelReferenceSchema,tA as multiselect,Ds as nativeAgentUIPartIdMetadataKey,Ls as normalizeDateValue,rt as number,Iu as numberFlag,z as object,wb as orderAgentSessionMessages,$T as parseAgentStreamFrameId,_s as parseCountMode,ko as parseLiveChannelKey,kb as parseNativeAgentUIPartIdsMetadata,tm as parseOperation,Vg as parseOptionalCountMode,Wy as parseQualifiedAttribute,ic as persistedDefaultViewTargetSchema,Cx as persistedSchemaPlanSchema,Xh as phone,ec as plannedAttributeSchema,tc as plannedInlineAttributeSchema,rc as plannedObjectSchema,ai as presentationOf,nc as proposedDefaultViewTargetSchema,Ta as providerNameSchema,au as qualifiedPropertyDefs,ig as readFormFieldValue,XA as registry,Ae as relation,ou as relationPropertyDefs,Ht as renderLabelExpression,el as resetViewToDefault,Gd as resolveAttributeDefaultValue,ng as resolveFieldRequired,Yi as resolvePropertyDefinitions,he as richtext,oA as rollup,Td as rollupToFormulaExpression,Dx as schemaPlanSchema,q as select,jx as sessionInferencePatchSchema,pb as sessionStateToLegacyStatus,eA as status,xu as stringFlag,f as text,ni as toAttribute,Op as toDraftableAttributes,kp as toDraftableObject,pm as toDraftableView,Fs as toUndefinedIfEmpty,bc as todoItemSchema,gc as todoPlanSchema,Ia as toolImpactSchema,nA as user,Ce as validateAttributeName,Xs as validateLabelExpression,Au as validateObjectExpressions,De as validateObjectName,Ze as validateViewName,Ku as viewRegistry,Dg as viewStateKey,Jd as viewSyncPayload};