@standards/schema 0.0.0-stage → 1.0.0-alpha.382

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 (133) hide show
  1. package/LICENSE +111 -0
  2. package/README.md +8 -2
  3. package/dist/all-BgYwavNm.d.mts +2956 -0
  4. package/dist/all-DjdKldjX.d.ts +2956 -0
  5. package/dist/api/index.d.mts +11838 -0
  6. package/dist/api/index.d.ts +11838 -0
  7. package/dist/api/index.js +2 -0
  8. package/dist/api/index.mjs +2 -0
  9. package/dist/attribute-validators-DRqhAt2t.mjs +11 -0
  10. package/dist/attribute-validators-WAoJbap5.js +11 -0
  11. package/dist/attributes-aTeqx6cK.d.mts +557 -0
  12. package/dist/attributes-kAhQzg8-.d.ts +557 -0
  13. package/dist/checkbox-BZvZOraX.d.mts +11 -0
  14. package/dist/checkbox-n0YV1O13.d.ts +11 -0
  15. package/dist/config-BIxnbUN8.mjs +2 -0
  16. package/dist/config-DdjlHdPg.js +2 -0
  17. package/dist/core-397tQy5q.js +2 -0
  18. package/dist/core-BLHhNykL.mjs +2 -0
  19. package/dist/date-CxqDOhA0.d.mts +24 -0
  20. package/dist/date-D007KyTI.d.ts +24 -0
  21. package/dist/exceptions-DjPVyS-Q.d.mts +761 -0
  22. package/dist/exceptions-DjPVyS-Q.d.ts +761 -0
  23. package/dist/exceptions.d.mts +3 -0
  24. package/dist/exceptions.d.ts +3 -0
  25. package/dist/exceptions.js +2 -0
  26. package/dist/exceptions.mjs +2 -0
  27. package/dist/index-3HZjBOpj.d.mts +53 -0
  28. package/dist/index-BmNMneu3.d.mts +278 -0
  29. package/dist/index-Bu9xF5Nq.d.ts +278 -0
  30. package/dist/index-CiTBL4gH.d.ts +101 -0
  31. package/dist/index-D7TEaPqX.d.ts +16519 -0
  32. package/dist/index-DLO8JpnY.d.ts +53 -0
  33. package/dist/index-DPO5w-fC.d.mts +101 -0
  34. package/dist/index-DwQWBzYJ.d.mts +16519 -0
  35. package/dist/index.d.mts +15 -0
  36. package/dist/index.d.ts +15 -0
  37. package/dist/index.js +2 -0
  38. package/dist/index.mjs +2 -0
  39. package/dist/number-CgBxEbjI.d.mts +11 -0
  40. package/dist/number-DncH-WRO.d.ts +11 -0
  41. package/dist/object-DcgxLvip.js +4 -0
  42. package/dist/object-Dzl7sfq8.mjs +4 -0
  43. package/dist/objects-B4DgFZ82.d.ts +398 -0
  44. package/dist/objects-C9f6hFW_.d.mts +398 -0
  45. package/dist/phone-BB-tzcSr.js +2 -0
  46. package/dist/phone-Bca_xiOX.mjs +2 -0
  47. package/dist/record-aggregates-CzG86pUS.mjs +2 -0
  48. package/dist/record-aggregates-DwpIJ2Dv.js +2 -0
  49. package/dist/record-operation-BSXczk7v.js +2 -0
  50. package/dist/record-operation-C9oXHmfF.mjs +2 -0
  51. package/dist/text-A9AJ1wUO.js +2 -0
  52. package/dist/text-C8Lb-NFo.mjs +2 -0
  53. package/dist/text-DDoY_LcQ.d.ts +11 -0
  54. package/dist/text-DeUqCFp9.d.mts +11 -0
  55. package/dist/utils-B7Dlrtnx.d.ts +163 -0
  56. package/dist/utils-DbRMK8NI.d.mts +163 -0
  57. package/dist/utils-fXIvFFl6.mjs +2 -0
  58. package/dist/utils-gY3d9Dwp.js +2 -0
  59. package/dist/utils.d.mts +3 -0
  60. package/dist/utils.d.ts +3 -0
  61. package/dist/utils.js +2 -0
  62. package/dist/utils.mjs +2 -0
  63. package/dist/validation/all.d.mts +6 -0
  64. package/dist/validation/all.d.ts +6 -0
  65. package/dist/validation/all.js +2 -0
  66. package/dist/validation/all.mjs +2 -0
  67. package/dist/validation/complex/currency.d.mts +13 -0
  68. package/dist/validation/complex/currency.d.ts +13 -0
  69. package/dist/validation/complex/currency.js +2 -0
  70. package/dist/validation/complex/currency.mjs +2 -0
  71. package/dist/validation/complex/location.d.mts +20 -0
  72. package/dist/validation/complex/location.d.ts +20 -0
  73. package/dist/validation/complex/location.js +2 -0
  74. package/dist/validation/complex/location.mjs +2 -0
  75. package/dist/validation/complex/phone.d.mts +20 -0
  76. package/dist/validation/complex/phone.d.ts +20 -0
  77. package/dist/validation/complex/phone.js +2 -0
  78. package/dist/validation/complex/phone.mjs +2 -0
  79. package/dist/validation/complex/relation.d.mts +23 -0
  80. package/dist/validation/complex/relation.d.ts +23 -0
  81. package/dist/validation/complex/relation.js +2 -0
  82. package/dist/validation/complex/relation.mjs +2 -0
  83. package/dist/validation/complex/richtext.d.mts +11 -0
  84. package/dist/validation/complex/richtext.d.ts +11 -0
  85. package/dist/validation/complex/richtext.js +2 -0
  86. package/dist/validation/complex/richtext.mjs +2 -0
  87. package/dist/validation/complex/select.d.mts +18 -0
  88. package/dist/validation/complex/select.d.ts +18 -0
  89. package/dist/validation/complex/select.js +2 -0
  90. package/dist/validation/complex/select.mjs +2 -0
  91. package/dist/validation/complex/user.d.mts +11 -0
  92. package/dist/validation/complex/user.d.ts +11 -0
  93. package/dist/validation/complex/user.js +2 -0
  94. package/dist/validation/complex/user.mjs +2 -0
  95. package/dist/validation/computed/formula.d.mts +12 -0
  96. package/dist/validation/computed/formula.d.ts +12 -0
  97. package/dist/validation/computed/formula.js +2 -0
  98. package/dist/validation/computed/formula.mjs +2 -0
  99. package/dist/validation/computed/rollup.d.mts +12 -0
  100. package/dist/validation/computed/rollup.d.ts +12 -0
  101. package/dist/validation/computed/rollup.js +2 -0
  102. package/dist/validation/computed/rollup.mjs +2 -0
  103. package/dist/validation/config/index.d.mts +3 -0
  104. package/dist/validation/config/index.d.ts +3 -0
  105. package/dist/validation/config/index.js +2 -0
  106. package/dist/validation/config/index.mjs +2 -0
  107. package/dist/validation/core/index.d.mts +3 -0
  108. package/dist/validation/core/index.d.ts +3 -0
  109. package/dist/validation/core/index.js +2 -0
  110. package/dist/validation/core/index.mjs +2 -0
  111. package/dist/validation/object/index.d.mts +3 -0
  112. package/dist/validation/object/index.d.ts +3 -0
  113. package/dist/validation/object/index.js +2 -0
  114. package/dist/validation/object/index.mjs +2 -0
  115. package/dist/validation/primitives/checkbox.d.mts +3 -0
  116. package/dist/validation/primitives/checkbox.d.ts +3 -0
  117. package/dist/validation/primitives/checkbox.js +2 -0
  118. package/dist/validation/primitives/checkbox.mjs +2 -0
  119. package/dist/validation/primitives/date.d.mts +3 -0
  120. package/dist/validation/primitives/date.d.ts +3 -0
  121. package/dist/validation/primitives/date.js +2 -0
  122. package/dist/validation/primitives/date.mjs +2 -0
  123. package/dist/validation/primitives/number.d.mts +3 -0
  124. package/dist/validation/primitives/number.d.ts +3 -0
  125. package/dist/validation/primitives/number.js +2 -0
  126. package/dist/validation/primitives/number.mjs +2 -0
  127. package/dist/validation/primitives/text.d.mts +3 -0
  128. package/dist/validation/primitives/text.d.ts +3 -0
  129. package/dist/validation/primitives/text.js +2 -0
  130. package/dist/validation/primitives/text.mjs +2 -0
  131. package/dist/view-config.schema-BQ9tU_9G.js +2 -0
  132. package/dist/view-config.schema-BmjCQJ51.mjs +2 -0
  133. package/package.json +279 -3
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
2
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./attribute-validators-WAoJbap5.js"),t=require("./record-aggregates-DwpIJ2Dv.js"),n=require("./view-config.schema-BQ9tU_9G.js"),r=require("./exceptions.js"),i=require("./record-operation-BSXczk7v.js"),a=require("./text-A9AJ1wUO.js"),o=require("./core-397tQy5q.js"),s=require("./validation/primitives/number.js"),c=require("./validation/primitives/checkbox.js"),l=require("./validation/primitives/date.js"),u=require("./config-DdjlHdPg.js"),d=require("./utils-gY3d9Dwp.js"),f=require("./object-DcgxLvip.js"),p=require("./phone-BB-tzcSr.js");let m=require("zod"),h=require("@standards/constants"),g=require("libphonenumber-js");const _=`__stndrdsNativeUiPartIds`;function invalidNativePartIds(){throw new r.ValidationError(`Native agent UI part IDs metadata is invalid`,[])}function isPlainRecord$1(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function nativeAgentUIPartIdMetadataKey(e,t){if(e.type===`text`||e.type===`reasoning`)return`${e.type}:${t}`;if(e.type===`tool`)return`tool:${e.toolCallId}`}function parseNativeAgentUIPartIdsMetadata(e){let t=e.metadata?.[_];isPlainRecord$1(t)||invalidNativePartIds(),(Object.keys(t).length!==2||t.schemaVersion!==1||!isPlainRecord$1(t.partIds))&&invalidNativePartIds();let n=new Map;for(let[t,r]of e.parts.entries()){let e=nativeAgentUIPartIdMetadataKey(r,t);if(!e||n.has(e)){e&&invalidNativePartIds();continue}n.set(e,r)}let r=Object.entries(t.partIds);r.length!==n.size&&invalidNativePartIds();let i=new Map,a={};for(let[e,t]of r){let r=n.get(e);r&&typeof t==`string`&&t.length>0||invalidNativePartIds();let o=i.get(t);o&&(r.type===`tool`||o!==r.type)&&invalidNativePartIds(),r.type===`tool`&&t!==r.toolCallId&&invalidNativePartIds(),i.set(t,r.type),a[e]=t}return a}const v=`/v1/device-worker/channel`,ee={initialMs:1e3,maxMs:3e4};function deviceChannelUrl(e){let t=new URL(e);return`${t.protocol===`https:`?`wss:`:`ws:`}//${t.host}${v}`}function computeRetryDelay(e,t,n){return Math.min(n.initialMs*2**e,n.maxMs)+Math.floor(t()*250)}function computeReconnectDelay(e,t=Math.random){return computeRetryDelay(e,t,ee)}const y=[`worker_disconnected`,`cancelled`,`timed_out`,`execution_failed`,`stale_reference`,`tab_unavailable`,`debugger_unavailable`,`blocked_by_user`,`not_actionable`,`javascript_error`,`batch_cap_exceeded`,`no_reference_screenshot`];var DeviceChannelProtocolError=class extends r.SchemaError{constructor(e){super(e,r.SchemaErrorCode.DEVICE_CHANNEL_PROTOCOL),this._tag=`DeviceChannelProtocolError`,this.name=`DeviceChannelProtocolError`}};const b={id:m.z.uuid(),leaseToken:m.z.string().min(1)},x=m.z.record(m.z.string(),m.z.unknown());function defineDeviceChannelFrames(e){return{worker:m.z.discriminatedUnion(`type`,[m.z.strictObject({type:m.z.literal(`authenticate`),credential:m.z.string().regex(/^(Device|Bearer) \S+$/),protocol:m.z.number().int().positive().optional()}),m.z.strictObject({type:m.z.literal(`running`),...b}),m.z.strictObject({type:m.z.literal(`heartbeat`),...b}),m.z.strictObject({type:m.z.literal(`output`),...b,stdout:m.z.string().optional(),stderr:m.z.string().optional()}),m.z.strictObject({type:m.z.literal(`complete`),...b,result:m.z.strictObject({stdout:m.z.string().optional(),stderr:m.z.string().optional(),exitCode:m.z.number().int(),success:m.z.boolean(),errorCode:m.z.enum(y).optional(),result:e.result.optional()})}),m.z.strictObject({type:m.z.literal(`pong`)})]),server:m.z.discriminatedUnion(`type`,[m.z.strictObject({type:m.z.literal(`ready`),device:m.z.strictObject({id:m.z.string(),name:m.z.string(),capability:m.z.enum([`shell`,`browser`])}),protocol:m.z.number().int().positive().optional()}),m.z.strictObject({type:m.z.literal(`command`),...b,kind:m.z.enum([`shell`,`browser`]),intent:m.z.string(),timeoutMs:m.z.number().int(),command:m.z.string().optional(),cwd:m.z.string().nullable().optional(),action:e.action.optional()}),m.z.strictObject({type:m.z.literal(`cancel`),id:m.z.uuid(),reason:m.z.enum([`cancelled`,`timed_out`,`revoked`])}),m.z.strictObject({type:m.z.literal(`reauthenticate`)}),m.z.strictObject({type:m.z.literal(`revoked`)}),m.z.strictObject({type:m.z.literal(`ping`)})])}}const S=defineDeviceChannelFrames({action:x,result:x}),C=S.worker,w=S.server;function parseDeviceChannelFrame(e,t){let n;try{n=JSON.parse(t)}catch{throw new DeviceChannelProtocolError(`Frame is not JSON`)}let r=e.safeParse(n);if(!r.success)throw new DeviceChannelProtocolError(`Frame does not match the channel protocol`);return r.data}function parseWorkerFrame(e){return parseDeviceChannelFrame(C,e)}function parseServerFrame(e){return parseDeviceChannelFrame(w,e)}function isFormDefinition(e){return typeof e==`object`&&!!e&&`slots`in e&&`steps`in e&&`name`in e&&typeof e.name==`string`&&Array.isArray(e.slots)&&Array.isArray(e.steps)}const T=[`relation`,`multiRelation`,`formula`,`rollup`,`document`,`richtext`,`user`];function isFormSlotFieldRef(e){return e.type===`slot`}function isFormFreeFieldRef(e){return e.type===`free`}function resolveFieldRequired(e){return e.readOnly===!0?!1:e.fieldRequired===void 0?e.slotMode===`create`&&e.attributeRequired===!0:e.fieldRequired}function getSlotFieldTargets(e){return e.additionalSlotIds?.length?[e.slotId,...e.additionalSlotIds]:[e.slotId]}function formFieldKey(e){return isFormSlotFieldRef(e)?`${e.slotId}.${e.attribute}`:`free.${e.attribute.name}`}function formFieldFlatKey(e){return isFormSlotFieldRef(e)?e.attribute:e.attribute.name}function readFormFieldValue(e,t){return e[formFieldKey(t)]??e[formFieldFlatKey(t)]}function isFormFieldsRow(e){return e.type===`fields`}function isFormHeadingRow(e){return e.type===`heading`}function isFormSeparatorRow(e){return e.type===`separator`}function isFormTextRow(e){return e.type===`text`}function resolvePropertyDefinitions(e){let t=e.properties;if(!t)return[];if(Array.isArray(t))return t;let n=t;return Array.isArray(n.definitions)?n.definitions:[]}function hasOptions(e){return e.type===`select`||e.type===`status`||e.type===`multiselect`}function schemaGroupKey(e){return`${e.kind}:${e.id}`}function refuse$2(e,t){throw new r.ValidationError(t,[{path:[e],message:t}])}function parseSchemaGroupPresentation(t){let n=t??{},r={};if(n.label!==void 0){let t=n.label;if(t===null)r.label=null;else if(typeof t!=`string`)refuse$2(`label`,`Label must be a string`);else{let n=t.trim();n.length===0&&refuse$2(`label`,`Label must not be empty`),n.length>e.p.labelLength&&refuse$2(`label`,`Label is too long (max ${e.p.labelLength} characters)`),r.label=n}}if(n.icon!==void 0){let t=n.icon;if(t===null)r.icon=null;else{let n=e.f.safeParse(t);n.success||refuse$2(`icon`,`Invalid icon name`),r.icon=n.data}}return r}const E=[`none`,`estimated`,`exact`];function parseCountMode(e){if(typeof e==`string`&&E.includes(e))return e;throw new r.ValidationError(`countMode must be one of: ${E.join(`, `)} (received: ${String(e)})`,[])}function parseOptionalCountMode(e){return e===void 0?void 0:parseCountMode(e)}const te={maxDurationMs:3e5,dailyDurationMs:36e5,monthlyDurationMs:72e6,tenantMonthlyBudgetMicrousd:5e7,globalMonthlyBudgetMicrousd:5e7,estimatedMicrousdPerSecond:150,reservationMultiplier:2},ne=[`web`,`presentation`,`document`,`spreadsheet`,`image`,`code`,`other`],re=[`ephemeral`,`conversation`,`persistent`],ie=[`source`,`preview`,`entrypoint`,`asset`];var NoopGeocodingAdapter=class{async autocomplete(){return await Promise.resolve([])}async geocode(){return await Promise.resolve(null)}};const ae=[`square`,`landscape`,`portrait`];function imageModelFormatDefect(e){if(e.formats.length===0)return`declares no output format`;for(let t of e.formats)if(e.requests[t]===void 0)return`declares the format "${t}" without a request`;for(let t of Object.keys(e.requests))if(!e.formats.includes(t))return`carries a request for the undeclared format "${t}"`}function declaredImageRequests(e){let t={};for(let n of e.formats){let r=e.requests[n];r!==void 0&&(t[n]=r)}return t}const oe=[`storage.bytes`,`members.seats`,`data.live_records`];function computeByteMagnitude(e){if(e<=0)return{value:0,unitIndex:0};let t=1e3,n=Math.min(4,Math.floor(Math.log(e)/Math.log(t)));return{value:Number.parseFloat((e/t**n).toFixed(1)),unitIndex:n}}const se=[`B`,`KB`,`MB`,`GB`,`TB`];function formatByteSize(e){let{value:t,unitIndex:n}=computeByteMagnitude(e);return`${t} ${se[n]}`}const ce=Object.freeze([`text`,`number`,`checkbox`,`date`,`phone`,`currency`,`status`,`select`,`multiselect`,`location`]);function buildPropertySchema(e){let t=[];for(let n of e){let e=n.build();if(!ce.includes(e.type))throw Error(`Property type "${e.type}" is not supported in .qualifyWith()`);t.push(e)}return{definitions:t}}const le=[`UPPER`,`LOWER`,`capitalize`,`trim`],ue=[`prefix`,`suffix`,`wrap`,`default`],D=[...le,...ue],O=/^\s*where\s*(?::(.*))?$/s,k=`[A-Za-z_][A-Za-z0-9_]*`,A=/^[^\s,()|{}="']+$/,de=RegExp(`^(${k})\\s*=\\s*(.*)$`),fe=RegExp(`^(${k})\\s+in\\s*\\(([^()]*)\\)$`);function isWherePipe(e){return O.test(e)}function parseWherePipe(e){let t=e.match(O)?.[1]?.trim();if(!t)return null;let n=t.match(fe);if(n){let e=n[2].split(`,`).map(e=>e.trim());return e.every(e=>A.test(e))?{property:n[1],values:e}:null}let r=t.match(de);return r&&A.test(r[2])?{property:r[1],values:[r[2]]}:null}const j=m.z.string().min(1,`labelExpression cannot be empty`).refine(e=>isLabelExpression(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,n;for(;(n=t.exec(e))!==null;){let e=n[1];if(!D.includes(e))return!1}return!0},{message:`Invalid pipe name. Valid pipes: ${D.join(`, `)}`});function validateLabelExpression(e){let t=j.safeParse(e);return t.success?{success:!0,attributes:extractAttributeNames(e)}:{success:!1,error:t.error.issues[0]?.message??`Invalid labelExpression`}}function applyPipe(e,t){let{name:n,args:r}=parsePipeExpression(t);switch(n){case`UPPER`:return e.toUpperCase();case`LOWER`:return e.toLowerCase();case`capitalize`:return e.replace(/(^|\s)\S/g,e=>e.toUpperCase());case`trim`:return e.trim();case`prefix`:return e?`${r[0]??``}${e}`:``;case`suffix`:return e?`${e}${r[0]??``}`:``;case`wrap`:return e?`${r[0]??``}${e}${r[1]??``}`:``;case`default`:return e||r[0]||``;default:return e}}function applyPipes(e,t){let n=e;for(let e of t)n=applyPipe(n,e);return n}function getValue(e,t){return t.split(`.`).reduce((e,t)=>{if(typeof e==`object`&&e)return e[t]},e)}const M=`(Untitled)`;function parsePipeExpression(e){let t=e.match(/^(\w+)(?::(.*))?$/);if(!t)return{name:e,args:[]};let n=t[1],r=t[2];if(!r)return{name:n,args:[]};let i=[],a=/["']([^"']*?)["']/g,o;for(;(o=a.exec(r))!==null;)i.push(o[1]);return{name:n,args:i}}function*templateBlocks(e){let t=0;for(;t<e.length;){let n=e.indexOf(`{{`,t);if(n<0)return;let r=e.indexOf(`}`,n+2);if(r<0)return;if(e[r+1]!==`}`){t=r+1;continue}t=r+2;let i=e.slice(n+2,r);i.length>0&&(yield{start:n,end:t,expr:i})}}function resolveLabelBlock(e,t){let n=e.split(`||`).map(e=>e.trim()),r=n[n.length-1].split(`|`).map(e=>e.trim());n[n.length-1]=r[0];let i=r.slice(1).filter(Boolean),a=n.filter(Boolean),o=``;for(let e of a){let n=toText(getValue(t,e));if(n!==``){o=n;break}}return applyPipes(o,i)}function renderLabelExpression(e,t,n=M){let r=[],i=0;for(let n of templateBlocks(e))r.push(e.slice(i,n.start),resolveLabelBlock(n.expr,t)),i=n.end;return r.push(e.slice(i)),r.join(``).trim()||n}function toText(e){if(e==null||typeof e==`function`)return``;if(typeof e!=`object`)return String(e);if(Array.isArray(e))return e.map(toText).filter(Boolean).join(`,`);let t=e.toString;return typeof t==`function`&&t!==Object.prototype.toString?String(e):``}function isLabelExpression(e){let t=0;for(;t<e.length;){let n=e.indexOf(`{{`,t);if(n<0)return!1;let r=e.indexOf(`}}`,n+2);if(r<0)return!1;if(e.slice(n+2,r).trim().length>0)return!0;t=r+2}return!1}function extractAttributeNames(e){let t=[];for(let n of templateBlocks(e)){let e=n.expr.trim();if(!e)continue;let r=e.split(`||`).map(e=>e.trim()),i=r[r.length-1];r[r.length-1]=i.split(`|`)[0].trim();for(let e of r){if(!e)continue;let n=e.split(`.`)[0];n&&!t.includes(n)&&t.push(n)}}return t}const pe=/^\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}$/;function getSingleAttributeFromExpression(e){let t=e.trim().match(pe);return t?t[1]:null}function getEditableLabelAttribute(e,t){let r=getSingleAttributeFromExpression(e);if(r===null)return null;let i=t.find(e=>e.name===r);return!i||i.type!==`text`||n.dn(i).authoring.readOnly?null:i}const N=[{id:`data`,capabilities:[{id:`forms`,resources:[`forms`],levels:[{id:`fill`,add:[`read`]},{id:`edit`,add:[`create`,`update`,`delete`]},{id:`manage`,add:[`manage`]}]}]},{id:`structure`,capabilities:[{id:`schema`,resources:[`architect`],levels:[{id:`use`,add:[`read`]},{id:`edit`,add:[`create`,`update`,`delete`]}]},{id:`pages`,resources:[`pages`],levels:[{id:`read`,add:[`read`]},{id:`create`,add:[`create`,`update`,`delete`]}]}]},{id:`ai`,capabilities:[{id:`agents`,resources:[`agents`],levels:[{id:`chat`,add:[`read`]},{id:`build`,add:[`create`,`update`,`delete`]},{id:`manage`,add:[`manage`]}]},{id:`environments`,resources:[`environments`],levels:[{id:`use`,add:[`read`]},{id:`create`,add:[`create`]}]},{id:`browser-profiles`,resources:[`browser-profiles`],levels:[{id:`use`,add:[`create`]}]},{id:`routine-audiences`,resources:[`routine-audiences`],levels:[{id:`use`,add:[`create`]}]}]},{id:`files`,capabilities:[{id:`files`,resources:[`files`,`documents`],levels:[{id:`read`,add:[`read`]},{id:`edit`,add:[`create`,`update`]},{id:`full`,add:[`delete`]}]}]},{id:`team`,capabilities:[{id:`people`,resources:[`people`],levels:[{id:`view`,add:[`read`]},{id:`invite`,add:[`create`]},{id:`manage`,add:[`update`,`delete`]}]}]},{id:`integrations`,capabilities:[{id:`connectors`,resources:[`connectors`],levels:[{id:`use`,add:[`read`,`create`,`update`,`delete`]}]},{id:`api-keys`,resources:[`api-keys`],levels:[{id:`view`,add:[`read`]},{id:`manage`,add:[`create`,`delete`]}]},{id:`env-vars`,resources:[`env-vars`],levels:[{id:`view`,add:[`read`]},{id:`manage`,add:[`create`,`delete`]}]}]},{id:`administration`,capabilities:[{id:`settings`,resources:[`settings`],levels:[{id:`view`,add:[`read`]},{id:`manage`,add:[`update`,`delete`,`manage`]}]},{id:`audit`,resources:[`audit`],levels:[{id:`view`,add:[`read`]}]},{id:`billing`,resources:[`billing`],levels:[{id:`view`,add:[`read`]}]}]}],P=`none`,F=`custom`,I={actions:[`read`,`create`,`update`,`delete`],purge:`manage`,levels:[{id:`read`,add:[`read`]},{id:`edit`,add:[`create`,`update`]},{id:`full`,add:[`delete`]}]},L=N.flatMap(e=>e.capabilities),me=L.flatMap(e=>e.resources),R=new Map(L.flatMap(e=>e.resources.map(t=>[t,e])));function isCatalogResource(e){return R.has(e)}function capabilityForResource(e){let t=R.get(e);if(!t)throw new r.SchemaError(`Unknown catalog resource "${e}"`,r.SchemaErrorCode.INVARIANT_VIOLATION);return t}function sameActions(e,t){let n=new Set(e),r=new Set(t);return n.size===r.size&&[...n].every(e=>r.has(e))}function levelActions(e,t){let n=new Set;for(let r of e.levels){for(let e of r.add)n.add(e);if(r.id===t)return[...n]}return[]}function levelFloor(e,t){let n=e.levels[e.levels.length-1];if(t.includes(`*`)&&n)return n.id;let r=new Set(t),i=P;for(let t of e.levels){if(!t.add.every(e=>r.has(e)))break;i=t.id}return i}function levelOf(e,t){if(t.length===0)return P;let n=e.levels[e.levels.length-1];if(t.includes(`*`)&&n)return n.id;let r=new Set(t),i=new Set;for(let t of e.levels){for(let e of t.add)i.add(e);if(i.size===r.size&&[...r].every(e=>i.has(e)))return t.id}return F}const z=[`read`,`create`,`update`,`delete`,`manage`],B=m.z.object({scope:m.z.enum([`object`,`system`]),target:m.z.string().min(1),actions:m.z.array(m.z.enum(z))}).strict();function findGrantIssues(e,t){let n=[],r=new Map;for(let i of e){let e=B.safeParse(i);if(!e.success){let e=typeof i==`object`&&i&&`target`in i?String(i.target):`?`;n.push({target:e,reason:`shape`});continue}let a=e.data;if(a.scope===`system`){if(!isCatalogResource(a.target)){n.push({target:a.target,reason:`unknown-resource`});continue}if(levelOf(capabilityForResource(a.target),a.actions)===`custom`){n.push({target:a.target,reason:`off-level`});continue}r.set(a.target,a.actions);continue}if(a.target!==`*`&&!t.objectNames.has(a.target)){n.push({target:a.target,reason:`unknown-object`});continue}let o=a.target===`*`?[...I.actions,I.purge]:I.actions;a.actions.every(e=>o.includes(e))||n.push({target:a.target,reason:`object-action`})}let i=new Set;for(let[e,t]of r){let a=capabilityForResource(e);if(!i.has(a)){for(let o of a.resources)if(!sameActions(t,r.get(o)??[])){n.push({target:e,reason:`split-capability`}),i.add(a);break}}}return n}const V={name:`name`,description:`description`,content:`content`,profileOf:`profileOf`,subjects:`subjects`,subjectId:`subjectId`};function textValue(e){return typeof e==`string`?e:``}function memoryPageViewOf(e){let{values:t}=e;return{id:e.id,name:textValue(t[V.name]),description:textValue(t[V.description]),content:textValue(t[V.content]),visibility:e.visibility,ownedBy:e.ownedBy,updatedAt:new Date(e.updatedAt).toISOString()}}const H=`@standards/schema`;function createStandardSchemaProps(e){return{version:1,vendor:H,validate:t=>{let n=e.safeParse(t);return n.success?{value:n.data}:{issues:n.error.issues.map(e=>({message:e.message,path:e.path}))}}}}function isStandardSchema(e){return typeof e==`object`&&!!e&&`~standard`in e&&typeof e[`~standard`]==`object`&&e[`~standard`].version===1}function asMutableArray(e){return e}var BaseAttributeBuilder=class{get"~standard"(){return createStandardSchemaProps(f.d(this.build()))}constructor(t,n,r){e.i(n),e.o(r),this.attr={name:n,label:r,type:t,required:!1,system:!0}}setRequired(e){this.attr.required=e}asRequiredState(){return this}asPhantomState(){return this}runtime(){return this.attr.system=!1,this}hidden(){return this.attr.hidden=!0,this}placeholder(e){return this.attr.placeholder=e,this}description(e){return this.attr.description=e,this}icon(t){return e.a(t,`attribute "${this.attr.name}"`),this.attr.icon=t,this}order(e){return this.attr.order=e,this}defaultValue(e){return(`defaultValue`in this.attr||![`formula`,`rollup`].includes(this.attr.type))&&(this.attr.defaultValue=e),this}metadata(e){return this.attr.metadata=e,this}build(){return this.attr}},TextAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`text`,e,t)}minLength(e){return this.attr.minLength=e,this}maxLength(e){return this.attr.maxLength=e,this}pattern(e){return this.attr.pattern=e,this.attr.format=void 0,this}multiline(e=!0){return this.attr.multiline=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),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}};function text(e,t){return new TextAttributeBuilder(e,t)}var RichtextAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`richtext`,e,t)}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function richtext(e,t){return new RichtextAttributeBuilder(e,t)}var NumberAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`number`,e,t)}min(e){return this.attr.min=e,this}max(e){return this.attr.max=e,this}integer(){return this.attr.unit=`integer`,this.attr.decimals=0,this}decimal(e=2){return this.attr.unit=`decimal`,this.attr.decimals=e,this}percentage(){return this.attr.unit=`percentage`,this}renderAs(e){return this.attr.renderAs=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function number(e,t){return new NumberAttributeBuilder(e,t)}var CheckboxAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`checkbox`,e,t)}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function checkbox(e,t){return new CheckboxAttributeBuilder(e,t)}var DateAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`date`,e,t)}format(e){return this.attr.dateFormat=e,this}precision(e){return this.attr.precision=e,this}build(){let[e]=u.a(`date`,this.attr);if(e!==void 0)throw new r.ValidationError(e.message,[{path:[`precision`],message:e.message}]);return super.build()}minDate(e){return this.attr.minDate=e,this}maxDate(e){return this.attr.maxDate=e,this}endDate(){return this.attr.endDate=!0,this.asPhantomState()}includeTime(){return this.attr.includeTime=!0,this}timeFormat(e){return this.attr.timeFormat=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function date(e,t){return new DateAttributeBuilder(e,t)}var PhoneAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`phone`,e,t)}defaultCountry(e){return this.attr.defaultCountryCode=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function phone(e,t){return new PhoneAttributeBuilder(e,t)}var CurrencyAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`currency`,e,t)}defaultCurrency(e){return this.attr.defaultCurrency=e,this}allowedCurrencies(e){return this.attr.allowedCurrencies=e,this}allowNegative(e=!0){return this.attr.allowNegative=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function currency(e,t){return new CurrencyAttributeBuilder(e,t)}var StatusAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`status`,e,t)}options(t){let n=asMutableArray(t);return e.c(this.attr.name??`unknown`,n),this.attr.options=n,this.asPhantomState()}option(t){this.attr.options||(this.attr.options=[]);let n=[...this.attr.options,t];return e.c(this.attr.name??`unknown`,n),this.attr.options.push(t),this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function status(e,t){return new StatusAttributeBuilder(e,t)}var SelectAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`select`,e,t)}options(t){let n=asMutableArray(t);return e.c(this.attr.name??`unknown`,n),this.attr.options=n,this.asPhantomState()}option(t){this.attr.options||(this.attr.options=[]);let n=[...this.attr.options,t];return e.c(this.attr.name??`unknown`,n),this.attr.options.push(t),this}renderAs(e){return this.attr.renderAs=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function select(e,t){return new SelectAttributeBuilder(e,t)}var MultiselectAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`multiselect`,e,t)}options(t){let n=asMutableArray(t);return e.c(this.attr.name??`unknown`,n),this.attr.options=n,this.asPhantomState()}option(t){this.attr.options||(this.attr.options=[]);let n=[...this.attr.options,t];return e.c(this.attr.name??`unknown`,n),this.attr.options.push(t),this}renderAs(e){return this.attr.renderAs=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function multiselect(e,t){return new MultiselectAttributeBuilder(e,t)}var LocationAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`location`,e,t)}granularity(e){return this.attr.granularity=e,this}defaultCountry(e){return this.attr.defaultCountry=e,this}allowedCountries(e){return this.attr.allowedCountries=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function location(e,t){return new LocationAttributeBuilder(e,t)}var UserAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`user`,e,t),this.attr.types=[`user`,`agent`]}types(e){let t=[...new Set(e)];if(t.length===0)throw Error(`[AttributeBuilder] user.types must contain at least one type.`);return this.attr.types=t,this}multiple(){return this.attr.multiple=!0,this}notifiesOnAssign(){return this.attr.notifiesOnAssign=!0,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function user(e,t){return new UserAttributeBuilder(e,t)}var BaseRelationAttributeBuilder=class extends BaseAttributeBuilder{to(e,t){let n={object:e,...t};return this.attr.targets?.push(n),this}toAny(){return this.attr.targets=[{object:`*`}],this}qualifyWith(...e){let t=this.attr.targets;if(!t||t.length===0)throw Error(`.qualifyWith() must be called AFTER .to(). Example: relation("companies", "Companies").to("companies").qualifyWith(...)`);return this.attr.properties=buildPropertySchema(e),this}bilateral(e){let t=this.attr.targets;if(!t||t.length===0)throw Error(`.bilateral() must be called AFTER .to(). Example: relation("company", "Company").to("companies").bilateral({ ... })`);if(t.length>1)throw Error(`Bilateral relations are not supported for polymorphic relations (multiple .to() targets).`);if(n.sn(this.attr))throw Error(`Bilateral relations are not supported for universal relations (.toAny()).`);let i=t[0]?.object;if(!i)throw new r.ValidationError(`Bilateral relation requires one target object`,[{path:[`bilateral`,`object`],message:`Bilateral relation requires one target object`}]);if(e.object&&e.object!==i){let t=`Bilateral inverse object ${e.object} must match relation target ${i}`;throw new r.ValidationError(t,[{path:[`bilateral`,`object`],message:t}])}return this.attr.bilateral={...e,object:i},this}},SingleRelationAttributeBuilder=class extends BaseRelationAttributeBuilder{constructor(e,t){super(`relation`,e,t),this.attr.cardinality=`one`,this.attr.targets=[]}many(){let e=new MultiRelationAttributeBuilder(this.attr.name,this.attr.label??``,{targets:this.attr.targets,isRequired:this.attr.required});return this.attr.system===!1&&e.runtime(),this.attr.hidden&&e.hidden(),this.attr.placeholder&&e.placeholder(this.attr.placeholder),this.attr.description&&e.description(this.attr.description),this.attr.icon&&e.icon(this.attr.icon),this.attr.order!==void 0&&e.order(this.attr.order),this.attr.metadata&&e.metadata(this.attr.metadata),e}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}},MultiRelationAttributeBuilder=class extends BaseRelationAttributeBuilder{constructor(e,t,n){super(`relation`,e,t),this.attr.cardinality=`many`,this.attr.targets=n?.targets??[],this.attr.defaultValue=[],n?.isRequired&&this.setRequired(!0)}maxItems(e){return this.attr.maxItems=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function relation(e,t){return new SingleRelationAttributeBuilder(e,t)}var FormulaAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`formula`,e,t),this.attr.required=!1}expression(e){return this.attr.expression=e,this}returns(e){return this.attr.returnType=e,this}decimals(e){return this.attr.decimals=e,this}currency(e){return this.attr.currencyCode=e,this}required(){throw Error(`Formula attributes cannot be required: they are computed read-only values. Remove .required() from this attribute definition.`)}optional(){return this}};function formula(e,t){return new FormulaAttributeBuilder(e,t)}var RollupAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`rollup`,e,t),this.attr.required=!1}from(e){return this.attr.relationAttribute=e,this}aggregate(e){return this.attr.targetAttribute=e,this}using(e){return this.attr.function=e,this}decimals(e){return this.attr.decimals=e,this}path(e){return this.attr.relationPath=e,this}targetType(e){return this.attr.targetAttributeType=e,this}targetOptions(e){return this.attr.targetAttributeOptions=asMutableArray(e),this}targetCurrency(e){return this.attr.targetCurrencyCode=e,this}build(){let e=this.attr.function,t=this.attr.targetAttributeType;if(e===`original`&&t!==void 0&&t!==`select`&&t!==`status`&&t!==`multiselect`){let e=this.attr.relationAttribute??`relation`,n=this.attr.targetAttribute??`field`;throw new r.SchemaError(`Rollup "${this.attr.name}": .using("original") only supports a "select", "status", or "multiselect" target, but .targetType("${t}") was given. To surface a plain ${t} value from a related record, use a formula instead — e.g. formula("${this.attr.name}", "…").expression("${e}.${n}").`,r.SchemaErrorCode.VALIDATION_FAILED)}return super.build()}required(){throw Error(`Rollup attributes cannot be required: they are computed read-only values. Remove .required() from this attribute definition.`)}optional(){return this}};function rollup(e,t){return new RollupAttributeBuilder(e,t)}var DocumentAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`document`,e,t)}accepts(e){return this.attr.accepts=e,this}maxFileSize(e){return this.attr.maxFileSize=e,this}qualifyWith(...e){return this.attr.properties=buildPropertySchema(e),this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function document(e,t){return new DocumentAttributeBuilder(e,t)}function readOnlyOption(e){return e?.readOnly===void 0?{}:{readOnly:e.readOnly}}function buildFreeFieldRef(e,t){return{type:`free`,attribute:e.build(),label:t?.label,required:t?.required,prefillExpression:t?.prefillExpression,...readOnlyOption(t)}}function buildSlotFieldRef(e,t,n){let[r,...i]=Array.isArray(e)?e:[e];return{type:`slot`,slotId:r,additionalSlotIds:i.length>0?i:void 0,attribute:t,label:n?.label,required:n?.required,tooltip:n?.tooltip,...readOnlyOption(n)}}const he=m.z.boolean().optional();var FormRowBuilder=class{constructor(e,t,n){this._finalized=!1,this.stepBuilder=e,this.rowData={id:t,order:n,type:`fields`,fields:[]}}field(e,t,n){return this.rowData.fields.push(buildSlotFieldRef(e,t,n)),this}freeField(e,t){return this.rowData.fields.push(buildFreeFieldRef(e,t)),this}row(e){return this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData).row(e)}heading(e,t){return this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData).heading(e,t)}separator(){return this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData).separator()}text(e){return this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData).text(e)}endRow(){return this._finalized?this.stepBuilder:(this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData))}},FormStepBuilder=class{constructor(e,t,n){this.rowOrder=0,this.formBuilder=e,this.stepData={id:t,label:n,rows:[]}}description(e){return this.stepData.description=e,this}field(e,t,n){this.rowOrder++;let r=`row-${this.stepData.id}-${this.rowOrder}`,i=buildSlotFieldRef(e,t,n),a={id:r,order:this.rowOrder,type:`fields`,fields:[i]};return this.stepData.rows.push(a),this}freeField(e,t){this.rowOrder++;let n=`row-${this.stepData.id}-${this.rowOrder}`,r=buildFreeFieldRef(e,t),i={id:n,order:this.rowOrder,type:`fields`,fields:[r]};return this.stepData.rows.push(i),this}row(e){return this.rowOrder++,new FormRowBuilder(this,e,this.rowOrder)}heading(e,t){this.rowOrder++;let n={id:`heading-${this.stepData.id}-${this.rowOrder}`,order:this.rowOrder,type:`heading`,content:e,level:t};return this.stepData.rows.push(n),this}separator(){this.rowOrder++;let e={id:`sep-${this.stepData.id}-${this.rowOrder}`,order:this.rowOrder,type:`separator`};return this.stepData.rows.push(e),this}text(e){this.rowOrder++;let t={id:`text-${this.stepData.id}-${this.rowOrder}`,order:this.rowOrder,type:`text`,content:e};return this.stepData.rows.push(t),this}step(e,t){return this.formBuilder._finalizeStep(this.stepData).step(e,t)}build(){return this.formBuilder._finalizeStep(this.stepData).build()}_finalizeRow(e){return e.fields.length>0&&this.stepData.rows.push(e),this}_getData(){return this.stepData}},FormBuilder=class{constructor(e,t){this.data={slots:[],steps:[],status:`draft`,version:1},this.validateName(e),this.data.name=e,this.data.label=t}description(e){return this.data.description=e,this}icon(e){return this.data.icon=e,this}status(e){return this.data.status=e,this}metadata(e){return this.data.metadata=e,this}slot(e,t,n){if(this.data.slots.some(t=>t.id===e))throw Error(`[FormBuilder] Duplicate slot id: "${e}"`);let r={id:e,objectName:t,label:n.label,mode:n.mode??`create`,color:n.color,icon:n.icon};return this.data.slots.push(r),this}step(e,t){if(this.data.steps.some(t=>t.id===e))throw Error(`[FormBuilder] Duplicate step id: "${e}"`);return new FormStepBuilder(this,e,t)}build(){return this.validateRequiredData(),this.validateSlotReferences(),this.validateFreeFields(),this.validatePrefillExpressions(),this.validateReadOnly(),this.data}_finalizeStep(e){return this.data.steps.push(e),this}validateName(e){let t=m.z.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{t.parse(e)}catch(e){throw e instanceof m.z.ZodError?Error(`[FormBuilder] ${e.issues[0].message}`):e}}validateRequiredData(){if(this.data.slots.length===0)throw Error(`[FormBuilder] At least one slot is required. Use .slot() to add slots.`);if(this.data.steps.length===0)throw Error(`[FormBuilder] At least one step is required. Use .step() to add steps.`)}validateSlotReferences(){let e=new Map(this.data.slots.map(e=>[e.id,e.objectName]));for(let t of this.data.steps)for(let n of t.rows)if(isFormFieldsRow(n))for(let r of n.fields){if(r.type!==`slot`)continue;let n=getSlotFieldTargets(r);for(let r of n)if(!e.has(r))throw Error(`[FormBuilder] Step "${t.id}" references unknown slot "${r}". Declare it with .slot("${r}", ...) first.`);let i=new Set(n.map(t=>e.get(t)));if(i.size>1)throw Error(`[FormBuilder] Step "${t.id}" field on attribute "${r.attribute}" targets slots of different objects (${[...i].join(`, `)}). A multi-slot field must target slots of the same object.`)}}validatePrefillExpressions(){let e=[...D,`join`,`where`];for(let t of this.data.steps)for(let n of t.rows)if(isFormFieldsRow(n))for(let i of n.fields){if(!isFormFreeFieldRef(i)||!i.prefillExpression)continue;let n=i.prefillExpression,a=`prefillExpression on free field "${i.attribute.name}" in step "${t.id}"`;if(!isLabelExpression(n))throw Error(`[FormBuilder] ${a} must contain at least one {{ attribute }} interpolation.`);if(/\{\{\s*\}\}/.test(n))throw Error(`[FormBuilder] ${a} contains empty {{ }} interpolation.`);for(let o of n.matchAll(/(?<!\|)\|(?!\|)\s*(\w+)(?:\s*:[^|}]*)?/g)){let n=o[1];if(!e.includes(n))throw Error(`[FormBuilder] ${a} uses invalid pipe "${n}". Valid pipes: ${e.join(`, `)}`);let s=o[0].replace(/^\|/,``);if(isWherePipe(s)&&!parseWherePipe(s))throw new r.ValidationError(`[FormBuilder] ${a} has a malformed where: pipe "${s.trim()}". Write where:property=value or where:property in (a,b).`,[{path:[t.id,i.attribute.name,`prefillExpression`],message:`Malformed where: pipe`}])}}}validateReadOnly(){for(let e of this.data.steps)for(let t of e.rows)if(isFormFieldsRow(t))for(let n of t.fields){if(he.safeParse(n.readOnly).success)continue;let t=isFormFreeFieldRef(n)?n.attribute.name:n.attribute,i=isFormFreeFieldRef(n)?`free field`:`field`;throw new r.ValidationError(`[FormBuilder] readOnly on ${i} "${t}" in step "${e.id}" must be a boolean.`,[{path:[e.id,t,`readOnly`],message:`Expected a boolean`}])}}validateFreeFields(){let e=new Set(T);for(let t of this.data.steps)for(let n of t.rows)if(isFormFieldsRow(n)){for(let r of n.fields)if(isFormFreeFieldRef(r)){let n=r.attribute.type;if(e.has(n))throw Error(`[FormBuilder] Free field in step "${t.id}" uses forbidden attribute type "${n}". Forbidden types: ${T.join(`, `)}`)}}}};function form(e,t){return new FormBuilder(e,t)}function validateObjectExpressions(e){let{name:t,labelExpression:n,embeddingExpression:i}=e;if(!n)throw new r.SchemaError(`Object "${t}" must have a labelExpression. The labelExpression defines how records are displayed in lists and relations (e.g. "{{ name }}").`,r.SchemaErrorCode.VALIDATION_FAILED);let a=j.safeParse(n);if(!a.success){let e=a.error.issues[0]?.message??`Invalid labelExpression`;throw new r.SchemaError(`Invalid labelExpression for "${t}": ${e}`,r.SchemaErrorCode.VALIDATION_FAILED)}if(i!==void 0){let e=j.safeParse(i);if(!e.success){let n=e.error.issues[0]?.message??`Invalid embeddingExpression`;throw new r.SchemaError(`Invalid embeddingExpression for "${t}": ${n}`,r.SchemaErrorCode.VALIDATION_FAILED)}}}var ObjectBuilder=class{get"~standard"(){return createStandardSchemaProps(f.u(this.build()))}constructor(e,t){this._sealed=!1,this._toleratedAttributes=[],this.validateName(e),this.obj={name:e,label:t,attributes:[],system:!0}}id(e){return this.obj.id=e,this}description(e){return this.obj.description=e,this}pluralLabel(e){return this._pluralLabel=e,this}icon(e){return this.obj.icon=e,this}color(e){return this.obj.color=e,this}imageShape(e){return this.obj.imageShape=e,this}runtime(){return this.obj.system=!1,this}sealed(){return this._sealed=!0,this}tolerate(e){return this._toleratedAttributes=[...this._toleratedAttributes,...e],this}attribute(e){return this.pushAttributes([e]),this}attributes(e){return this.pushAttributes(e),this}pushAttributes(t){let n=t.map(e=>`build`in e&&typeof e.build==`function`?e.build():e);e.r([...this.obj.attributes,...n],e=>e.name,e=>new r.DuplicateError(`attribute`,e,`Object "${this.obj.name}": duplicate attribute name "${e}"`)),this.obj.attributes.push(...n)}metadata(e){return this.obj.metadata={...this.obj.metadata,...e},this}order(e){return this.obj.metadata={...this.obj.metadata,order:e},this}hidden(){return this.obj.metadata={...this.obj.metadata,hidden:!0},this}labelExpression(e){return this._labelExpression=e,this}embeddingExpression(e){return this._embeddingExpression=e,this}documentLayout(e){if(e.presets)for(let t of e.presets)validatePresetStructure(t.id,t.structure,1);return this.obj.documentLayout=e,this}build(){if(!this.obj.name)throw new r.ValidationError(`[ObjectBuilder] Missing required field: name`,[{path:[`name`],message:`name is required`}]);if(!this.obj.label)throw new r.ValidationError(`[ObjectBuilder] Missing required field: label`,[{path:[`label`],message:`label is required`}]);return validateObjectExpressions({name:this.obj.name,labelExpression:this._labelExpression,embeddingExpression:this._embeddingExpression}),{...this.obj,pluralLabel:this._pluralLabel,labelExpression:this._labelExpression,embeddingExpression:this._embeddingExpression,sealed:this._sealed,toleratedAttributes:this._toleratedAttributes}}validateName(t){t!==void 0&&e.s(t)}};function object(t,n){if(e.C(t))throw new r.ReservedObjectNameError(t,`builder`);return new ObjectBuilder(t,n)}function validatePresetStructure(e,t,n){let fail=(t,n)=>{throw new r.ValidationError(t,[{path:[`documentLayout`,`presets`,e],message:n}])};n>5&&fail(`Preset structure exceeds max depth of 5`,`Preset structure too deep`);let i=new Set;for(let r of t){let t=r.title.trim();t.length===0&&fail(`Folder preset node title is required`,`Empty folder title`),t.includes(`/`)&&fail(`Folder preset node title cannot contain /`,`Folder title contains /: "${t}"`),i.has(t)&&fail(`Folder preset sibling titles must be unique`,`Duplicate folder title: "${t}"`),i.add(t),r.children&&r.children.length>0&&validatePresetStructure(e,r.children,n+1)}}function cloneBuilderValue(e,t){try{return structuredClone(e)}catch{let e=`Builder configuration must contain cloneable data`;throw new r.ValidationError(e,[{path:t,message:e}])}}function requireBuilderName(e,t){if(typeof e!=`string`||e.trim().length===0)throw new r.ValidationError(`Name must not be blank`,[{path:t,message:`Name must not be blank`}])}function validateContentConfiguration(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw new r.ValidationError(`Invalid content configuration`,[{path:t,message:`Expected content configuration`}]);for(let n of[`name`,`label`,`placement`])if(Object.hasOwn(e,n)){let e=`Independent content configuration cannot define ${n}`;throw new r.ValidationError(e,[{path:[...t,n],message:e}])}let i=n.o.safeParse({...e,name:`content`,placement:e.type===`group`?`grid`:`main`});if(!i.success)throw r.ValidationError.fromZodErrors(i.error.issues.map(e=>({path:[...t,...e.path.map(String)],message:e.message})));i.data.type===`form`&&i.data.groups.forEach((e,n)=>requireBuilderName(e.name,[...t,`groups`,String(n),`name`]));let{name:a,label:o,placement:s,...c}=i.data;return cloneBuilderValue(c,t)}function validateLiteralContent(e,t){return validateContentConfiguration(e,t),cloneBuilderValue(e,t)}function spanContent(e,t){if(!n.F.includes(t)){let e=`A block spans ${n.F.join(`, `)} columns, not ${String(t)}`;throw new r.ValidationError(e,[{path:[`content`,`span`],message:e}])}return{content:e,span:t}}function configureContent(e,t){try{return typeof e==`object`&&e&&`build`in e&&typeof e.build==`function`?{configuration:validateContentConfiguration(e.build(),t),extension:e.extension}:{configuration:validateContentConfiguration(e,t)}}catch(e){throw e instanceof r.ValidationError?new r.ValidationError(e.message,e.errors.map(e=>({...e,path:e.path[0]===`content`?[...t,...e.path.slice(1)]:e.path}))):e}}var U=class ViewBuilder{constructor(e,t=[]){this.kind=`view`,this.data=cloneBuilderValue(e,[`views`,`0`]),this.extensions=t.map(e=>e&&{...e})}for(e){let t=typeof e==`string`?e:e.build().name;return new ViewBuilder({...this.data,object:t},this.extensions)}default(){return new ViewBuilder({...this.data,default:!0},this.extensions)}description(e){return new ViewBuilder({...this.data,description:e},this.extensions)}icon(e){return new ViewBuilder({...this.data,icon:e},this.extensions)}place(e,t,n,r){let{configuration:i,extension:a}=configureContent(n,[`views`,`0`,`contents`,String(this.data.contents.length)]),o={...i,name:e,label:t,placement:r},s=[...this.data.contents,o];return new ViewBuilder({...this.data,contents:s},[...this.extensions,a])}tab(e,t,n){return this.place(e,t,n,`main`)}aside(e,t,n){return this.place(e,t,n,`aside`)}build(){let e=[`views`,`0`];requireBuilderName(this.data.name,[...e,`name`]),requireBuilderName(this.data.object,[...e,`object`]);let t=n.t.safeParse(this.data);if(!t.success)throw r.ValidationError.fromZodErrors(t.error.issues.map(t=>({path:[...e,...t.path.map(String)],message:t.message})));return this.data.contents.forEach((t,r)=>{let i=[...e,`contents`,String(r)];requireBuilderName(t.name,[...i,`name`]),t.type===`form`&&t.groups.forEach((e,t)=>requireBuilderName(e.name,[...i,`groups`,String(t),`name`])),n.g(t,this.extensions[r],t.name,this.data.context,i)}),{kind:`view`,definition:cloneBuilderValue(this.data,e)}}};function detailView(e,t){return new U({name:e,label:t,object:void 0,context:`record`,contents:[]})}function listView(e,t){return new U({name:e,label:t,object:void 0,context:`collection`,contents:[]})}function storedQuery(e,t){let n=[`search`,`offset`].filter(t=>e.state[t]!==void 0);if(n.length>0)throw new r.ValidationError(`A ${t} cannot keep a query's ${n.join(` or `)}`,n.map(e=>({path:[t,e],message:`A ${t} stores no ${e}; use filters and limit instead`})));return e.toDefinition()}function checkInputs(e,t){for(let[r,i]of Object.entries(t)){let t=e.inputs[r];i!==void 0&&t!==void 0&&n.Jt({parameters:t.schema},i,[`content`,`parameters`,r])}return t}var BlockContentBuilder=class{constructor(e,t,n){this.extension=e,this.parameters=t,this.heightMode=n}copy(e,t){let n=this.constructor;return new n(this.extension,e,t)}with(e){let t={...this.parameters};for(let[n,r]of Object.entries(e)){if(r===void 0){delete t[n];continue}t[n]=r}return checkInputs(this.extension,e),this.copy(t,this.heightMode)}height(e){return this.copy(this.parameters,e)}build(){let e={type:`custom`,extension:this.extension.name,parameters:cloneBuilderValue(this.parameters,[`content`,`parameters`]),...this.heightMode===void 0?{}:{height:this.heightMode}};return validateContentConfiguration(e,[`content`]),n.Jt(this.extension,e.parameters,[`content`,`parameters`]),e}span(e){return spanContent(this,e)}},Measures=class{count(){return this.measured(`count`)}sum(e){return this.measured(`sum`,e)}avg(e){return this.measured(`avg`,e)}min(e){return this.measured(`min`,e)}max(e){return this.measured(`max`,e)}};function measure(e,t,n){return{query:e,measure:t,...n===void 0?{}:{attribute:n}}}var MetricBuilder=class extends BlockContentBuilder{label(e){return this.with({label:e})}trend(e,t){return this.with({trend:e,trendBucket:t})}compare(e,t){return this.with({compare:e,period:t})}target(e){return this.with({target:e})}},MetricQuery=class extends Measures{constructor(e){super(),this.query=e}measured(e,t){return new MetricBuilder(n.Z,checkInputs(n.Z,measure(this.query,e,t)))}};function groupBy(e){return typeof e==`string`?[e,void 0]:[e.attribute,e.bucket]}var ChartBuilder=class extends BlockContentBuilder{label(e){return this.with({label:e})}by(e){let[t,n]=groupBy(e);return this.with({by:t,byBucket:n})}by2(e){let[t,n]=groupBy(e);return this.with({by2:t,by2Bucket:n})}kind(e){return this.with({kind:e})}bar(){return this.kind(`bar`)}line(){return this.kind(`line`)}area(){return this.kind(`area`)}donut(){return this.kind(`donut`)}funnel(){return this.kind(`funnel`)}treemap(){return this.kind(`treemap`)}calendar(){return this.kind(`calendar`)}},ChartQuery=class extends Measures{constructor(e){super(),this.query=e}measured(e,t){return new ChartBuilder(n.U,checkInputs(n.U,{...measure(this.query,e,t),kind:`bar`}))}};const ge={"7d":7,"30d":30};var AgendaBuilder=class extends BlockContentBuilder{label(e){return this.with({label:e})}next(e){let t=typeof e==`number`?e:ge[e];if(!Number.isInteger(t)||t<1){let e=`An agenda looks ahead a whole number of days, at least 1`;throw new r.ValidationError(e,[{path:[`content`,`parameters`,`next`],message:e}])}return this.with({next:t})}yearly(){return this.with({yearly:!0})}},CardBuilder=class extends BlockContentBuilder{fields(...e){return this.with({fields:e})}record(e){return this.with({record:e})}},InboxBuilder=class extends BlockContentBuilder{kinds(...e){return this.with({kinds:e})}limit(e){return this.with({limit:e})}},MailboxBuilder=class extends BlockContentBuilder{category(e){return this.with({category:e})}important(){return this.with({important:!0})}unread(){return this.with({unread:!0})}limit(e){return this.with({limit:e})}label(e){return this.with({label:e})}};function metric(e){return new MetricQuery(storedQuery(e,`metric`))}function chart(e){return new ChartQuery(storedQuery(e,`chart`))}function agenda(e,t){return new AgendaBuilder(n.B,checkInputs(n.B,{query:storedQuery(e,`agenda`),attribute:t}))}function card(e){let t=e===void 0||typeof e==`string`?e:e.build().name;return new CardBuilder(n.H,t===void 0?{}:checkInputs(n.H,{object:t}))}function text$1(e){return new BlockContentBuilder(n.tt,checkInputs(n.tt,{markdown:e}))}function inbox(){return new InboxBuilder(n.q,{})}function meetingsUpcoming(){return new BlockContentBuilder(n.X,{})}function mailbox(){return new MailboxBuilder(n.J,{})}function relationProperty(e){return requireBuilderName(e,[`relationProperty`]),{relationProperty:e}}var W=class ContentBuilder{constructor(e,t){this.data=cloneBuilderValue(e,[`content`]),this.extension=t===void 0?void 0:Object.freeze({name:t.name,contexts:t.contexts,parameters:t.parameters,refine:t.refine})}set(e){return new ContentBuilder({...this.data,...e},this.extension)}icon(e){return this.set({icon:e})}object(e){return this.set({objectName:e})}layout(e){let{layout:t,groupByAttribute:n,columnSizing:r,kanbanColumnOrder:i,kanbanColumnVisibility:a,kanbanPinnedColumns:o,...s}={...this.data,layout:void 0,groupByAttribute:void 0,columnSizing:void 0,kanbanColumnOrder:void 0,kanbanColumnVisibility:void 0,kanbanPinnedColumns:void 0};return new ContentBuilder({...s,...e},this.extension)}table(){return this.layout({layout:`table`})}list(){return this.layout({layout:`list`})}kanban(e){return this.layout({layout:`kanban`,groupByAttribute:e})}columns(...e){return this.set({columns:e})}actions(...e){return this.set({actions:e})}openMode(e){return this.set({openMode:e})}createMode(e){return this.set({createMode:e})}visibility(e){return this.set({visibility:e})}descriptionAttribute(e){return this.set({descriptionAttribute:e})}displayAttributes(...e){return this.set({displayAttributes:e})}columnSizing(e){return this.set({columnSizing:e})}kanbanColumnOrder(...e){return this.set({kanbanColumnOrder:e})}kanbanColumnVisibility(e){return this.set({kanbanColumnVisibility:e})}kanbanPinnedColumns(...e){return this.set({kanbanPinnedColumns:e})}formColumns(e){return this.set({formColumns:e})}density(e){return this.set({density:e})}titleAttribute(e){return this.set({titleAttribute:e})}allowUpload(e){return this.set({allowUpload:e})}allowRemove(e){return this.set({allowRemove:e})}hideAttachments(e){return this.set({hideAttachments:e})}relations(...e){return this.set({relations:e})}span(e){return spanContent(this,e)}height(e){return this.set({height:e})}build(){let e=validateLiteralContent(this.data,[`content`]);return this.extension&&e.type===`custom`&&n.Jt(this.extension,e.parameters,[`content`,`parameters`]),e}},G=class GroupBuilder{constructor(e,t,n,r={}){this.data=cloneBuilderValue({name:e,label:t,fields:n,...r},[`group`])}field(e,t){let{name:n,label:r,fields:i,...a}=this.data;return new GroupBuilder(n,r,[...i,{attribute:e,...t}],a)}fields(...e){let{name:t,label:n,fields:r,...i}=this.data;return new GroupBuilder(t,n,[...r,...e.map(e=>({attribute:e}))],i)}description(e){return new GroupBuilder(this.data.name,this.data.label,this.data.fields,{...this.presentation(),description:e})}collapsible(e=!1){return new GroupBuilder(this.data.name,this.data.label,this.data.fields,{...this.presentation(),collapsible:!0,collapsed:e})}presentation(){let{name:e,label:t,fields:n,...r}=this.data;return r}build(){requireBuilderName(this.data.name,[`group`,`name`]);try{validateLiteralContent({type:`form`,groups:[this.data]},[`group`])}catch(e){throw e instanceof r.ValidationError?new r.ValidationError(e.message,e.errors.map(e=>({...e,path:e.path[1]===`groups`?[`group`,...e.path.slice(3)]:e.path}))):e}return cloneBuilderValue(this.data,[`group`])}};function group(e,t){return new G(e,t,[])}function collection(e){return new W({type:`collection`,...storedQuery(e,`collection`)})}function form$1(...e){return new W({type:`form`,groups:e.map(e=>`build`in e?e.build():e)})}function activity(){return new W({type:`activity`})}function richtext$1(e){return new W({type:`richtext`,attribute:e})}function documents(){return new W({type:`documents`})}function forms(){return new W({type:`forms`})}function emails(...e){return new W({type:`emails`,emailAttributes:e})}function meetings(...e){return new W({type:`meetings`,emailAttributes:e})}function custom(e,t){if(typeof e!=`object`||!e||typeof e.name!=`string`)throw new r.ValidationError(`Expected registered extension declaration`,[{path:[`content`,`extension`],message:`Expected registered extension declaration`}]);let n=validateContentConfiguration({type:`custom`,extension:e.name,parameters:t},[`content`]);if(n.type!==`custom`)throw new r.ValidationError(`Expected custom content`,[]);let i=new W({...n,extension:e.name},e);return i.build(),i}function recordLinksTab(){return[n.et.name,n.et.label,custom(n.$,{}).icon(n.et.icon)]}function page$1(e){let{object:t,name:n}=e.definition;if(typeof t!=`string`){let e=`Page "${n}" is standalone; a record tab renders a record page (\`page(...).for(object)\`)`;throw new r.ValidationError(e,[{path:[`content`,`page`,`object`],message:e}])}return new W({type:`page`,page:{object:t,name:n}})}const _e={collection,metric,chart,agenda,card,text:text$1,inbox,meetingsUpcoming,mailbox,page:page$1,form:form$1,activity,richtext:richtext$1,documents,forms,emails,meetings,custom};function nameSlug(e,t){return e.normalize(`NFKD`).replace(/\p{M}/gu,``).toLowerCase().replace(/[^a-z0-9]+/g,`_`).slice(0,t).replace(/^_+|_+$/g,``)}function positionOf(e){return{x:e.x,y:e.y,w:e.w,h:e.h}}function bottomOf(e){return e.y+e.h}function collides(e,t){return e.x<t.x+t.w&&t.x<e.x+e.w&&e.y<t.y+t.h&&t.y<e.y+e.h}function firstCollision(e,t){return t.find(t=>collides(e,t))}function inReadingOrder$1(e){return[...e].sort((e,t)=>e.y-t.y||e.x-t.x)}function snapWidth(e,t,r){let i=12-t,a=n.F.filter(e=>e>=r&&e<=i);return a.length===0?n.F.find(e=>e>=r)??r:a.reduce((t,n)=>{let r=Math.abs(n-e),i=Math.abs(t-e);return r<i||r===i&&n>t?n:t})}function sharesColumns(e,t){return e.x<t.x+t.w&&t.x<e.x+e.w}function risenRow(e,t){return t.reduce((t,n)=>n.y<e.y&&sharesColumns(e,n)?Math.max(t,bottomOf(n)):t,0)}function packLayout(e,t){let n=e.map(e=>{let n=t?.get(e.i);return n===void 0?e:{...e,h:n}}),r=n.filter(e=>e.static===!0),i=new Map(r.map(e=>[e.i,e]));for(let e of inReadingOrder$1(n.filter(e=>e.static!==!0))){let t=risenRow(e,r),n=firstCollision({...e,y:t},r);for(;n!==void 0;)t=bottomOf(n),n=firstCollision({...e,y:t},r);let a={...e,y:t};r.push(a),i.set(e.i,a)}return n.map(e=>i.get(e.i)??e)}function settleLayout(e,t){let n=e.filter(e=>e.static===!0),r=e.filter(e=>e.static!==!0),i=new Map;for(let e of[...inReadingOrder$1(r.filter(e=>t.has(e.i))),...inReadingOrder$1(r.filter(e=>!t.has(e.i)))]){let t=e,r=firstCollision(t,n);for(;r!==void 0;)t={...t,y:bottomOf(r)},r=firstCollision(t,n);n.push(t),i.set(e.i,t)}return packLayout(e.map(e=>i.get(e.i)??e))}function pageCompactor(){return{type:`vertical`,allowOverlap:!1,preventCollision:!1,compact:e=>packLayout(e).map(e=>({...e,moved:!1}))}}function clampHeight(e,t){let n=t.minHeight??1,r=t.maxHeight??1/0;return Math.max(1,n,Math.min(r,e))}function widthStepConstraint(e){return{name:`width-steps`,constrainSize:(t,n,r)=>{let i=e(t.i),a=snapWidth(n,t.x,i.minWidth);return i.height===`fit`?{w:a,h:t.h}:i.height===`flexible`?{w:a,h:clampHeight(r,i)}:{w:a,h:Math.max(1,r)}}}}function snapCell(e,t){let n=Math.max(0,Math.min(e.x,11)),r=snapWidth(e.w,n,t(e.i).minWidth);return{...e,x:Math.min(n,12-r),y:Math.max(0,e.y),w:r,h:Math.max(1,e.h)}}function samePosition(e,t){return e.x===t.x&&e.y===t.y&&e.w===t.w&&e.h===t.h}function pushApart(e){let t=e.filter(e=>e.static===!0),n=new Map;for(let r of inReadingOrder$1(e.filter(e=>e.static!==!0))){let e=r,i=firstCollision(e,t);for(;i!==void 0;){let n={...e,x:i.x+i.w};e=n.x+n.w<=12&&firstCollision(n,t)===void 0?n:{...e,y:bottomOf(i)},i=firstCollision(e,t)}t.push(e),n.set(r.i,e)}return e.map(e=>n.get(e.i)??e)}function isValidStatic(e){return[e.x,e.y,e.w,e.h].every(Number.isInteger)&&e.x>=0&&e.y>=0&&e.h>=1&&n.F.includes(e.w)&&e.x+e.w<=12}function keptStatics(e){let t=[],n=new Set;for(let r of inReadingOrder$1(e.filter(e=>e.static===!0)))isValidStatic(r)&&firstCollision(r,t)===void 0?t.push(r):n.add(r.i);return e.map(e=>n.has(e.i)?{...e,static:!1}:e)}function boundedHeight(e,t){let n=t(e.i);if(e.static===!0||n.height!==`flexible`)return e;let r=clampHeight(e.h,n);return r===e.h?e:{...e,h:r}}function repairPageGrid(e,t){let n=[],r=keptStatics(e).map(e=>{let r=boundedHeight(e,t);return r!==e&&n.push({name:e.i,kind:`height`,from:positionOf(e),to:positionOf(r)}),r}).map(e=>{if(e.static===!0)return e;let r=snapCell(e,t);return samePosition(e,r)||n.push({name:e.i,kind:`width`,from:positionOf(e),to:positionOf(r)}),r}),i=pushApart(r);i.forEach((e,t)=>{let i=r[t];i!==void 0&&!samePosition(i,e)&&n.push({name:e.i,kind:`pushed`,from:positionOf(i),to:positionOf(e)})});let a=packLayout(i),o=keptFill(a,t);for(let e of inReadingOrder$1(a))e.i!==o&&t(e.i).height===`fill`&&n.push({name:e.i,kind:`fill`});return{cells:a,repairs:n}}function keptFill(e,t){return inReadingOrder$1(e).find(e=>e.static!==!0&&t(e.i).height===`fill`)?.i}function deriveLayout6(e,t){let n=[],r=0,i=0,a=0;for(let o of inReadingOrder$1(e)){let e=Math.min(6,Math.max(t(o.i).minWidth,Math.ceil(o.w/2)));r+e>6&&(r=0,i+=a,a=0),n.push({i:o.i,x:r,y:i,w:e,h:o.h}),r+=e,a=Math.max(a,o.h)}return packLayout(n)}function figureSlot(e,t,n){for(let r of inReadingOrder$1(e.filter(e=>n.has(e.i)))){let n={x:r.x+r.w,y:r.y,...t};if(n.x+n.w<=12&&firstCollision(n,e)===void 0)return n}}function placeNew(e,t,n,r){let i={w:snapWidth(n.size.w,0,n.minWidth),h:Math.max(1,n.size.h)};return n.figure?{i:t,...figureSlot(e,i,r)??{x:0,y:0,...i}}:{i:t,x:0,y:e.reduce((e,t)=>Math.max(e,bottomOf(t)),0),...i}}function isSpanned(e){return typeof e==`object`&&!!e&&`span`in e&&`content`in e}function total(e){return e.reduce((e,t)=>e+t,0)}function spread(e){return e.length===0?0:Math.max(...e)-Math.min(...e)}function betterSplit(e,t){let n=total(e)-total(t);if(n!==0)return n>0;let r=spread(t)-spread(e);if(r!==0)return r>0;let i=e.findIndex((e,n)=>e!==t[n]);return i!==-1&&(e[i]??0)>(t[i]??0)}function splitColumns(e,t){let r=[...t];function visit(i,a){let o=t[i.length];if(o===void 0){betterSplit(i,r)&&(r=i);return}for(let t of n.F)t>=o&&a+t<=e&&visit([...i,t],a+t)}return visit([],0),r}function rowWidths(e,t){let n=e.filter(e=>e.span===void 0);n.length>4&&reject(t,`A row holds at most 4 unsized blocks`);let r=total(e.map(e=>e.span??e.minWidth));r>12&&reject(t,`Blocks ${e.map(e=>`"${e.key}"`).join(`, `)} do not fit one row: they need at least ${r} of 12 columns`);let i=splitColumns(12-total(e.map(e=>e.span??0)),n.map(e=>e.minWidth)),a=0;return e.map(e=>{if(e.span!==void 0)return e.span;let t=i[a]??e.minWidth;return a+=1,t})}function reject(e,t){throw new r.ValidationError(t,[{path:e,message:t}])}function traitsOf(e,t=[]){return n.c(e,n.z,new Map(t.map(e=>[e.name,e])))}function headingNames(e){let t=new Set(e.flatMap(e=>e.kind===`heading`?e.meta.name===void 0?[]:[e.meta.name]:[...Object.keys(e.blocks),...e.group?.name===void 0?[]:[e.group.name]]));return e.flatMap(e=>{if(e.kind!==`heading`)return[];if(e.meta.name!==void 0)return[e.meta.name];let n=nameSlug(e.title,40),r=n===``?`heading`:`heading_${n}`,i=r;for(let e=2;t.has(i);e+=1)i=`${r}_${e}`;return t.add(i),[i]})}function headingEntry(e,t,r){let i={title:t,...r.description===void 0?{}:{description:r.description},...r.icon===void 0?{}:{icon:r.icon}};return{key:e,content:new BlockContentBuilder(n.K,i),span:12}}function groupOf(e,t,r){let[i]=e.map(e=>e.name).sort(),a=n.M(e.length);return(a!==void 0||i===void 0)&&reject(r,String(a)),{type:`group`,name:t.name??`group_${i}`,placement:`grid`,...t.label===void 0?{}:{label:t.label},members:e.map(e=>e.name)}}function requirePlacement(e,t,r,i,a){if(e.type===`page`&&reject(a,`Content "${r}" cannot reference a page from a page`),n.g(e,t,r,i,a),e.type!==`custom`)return;let o=t?.refine?.(e.parameters??{},i);o&&reject([...a,`parameters`,o.input],o.message)}var ve=class PageBuilder{constructor(e){this.kind=`view`,this.data=e}icon(e){return new PageBuilder({...this.data,icon:e})}description(e){return new PageBuilder({...this.data,description:e})}home(){return new PageBuilder({...this.data,home:!0})}for(e){let t=typeof e==`string`?e:e.build().name;return new PageBuilder({...this.data,object:t})}row(e,t={}){let n=t.group===void 0?{kind:`row`,blocks:e}:{kind:`row`,blocks:e,group:t.group};return new PageBuilder({...this.data,sections:[...this.data.sections,n]})}heading(e,t={}){let n={kind:`heading`,title:e,meta:t};return new PageBuilder({...this.data,sections:[...this.data.sections,n]})}build(){let e=[`views`,`0`],{name:t,label:i,object:a,icon:o,description:s,home:c,sections:l}=this.data;requireBuilderName(t,[...e,`name`]),a!==void 0&&requireBuilderName(a,[...e,`object`]),c&&a!==void 0&&reject([...e,`home`],`Only a standalone page can be the home`),l.every(e=>e.kind===`row`&&Object.keys(e.blocks).length===0)&&reject([...e,`contents`],`A page declares at least one block`);let u=a===void 0?`page`:`record`,d=[],f=[],p=headingNames(l),m=0;for(let t of l){let n=[...e,`contents`,String(d.length)],r=(t.kind===`heading`?[headingEntry(p[m++]??``,t.title,t.meta)]:Object.entries(t.blocks).map(([e,t])=>isSpanned(t)?{key:e,content:t.content,span:t.span}:{key:e,content:t,span:void 0})).map(t=>{let n=[...e,`contents`,String(d.length)];requireBuilderName(t.key,[...n,`name`]);let{configuration:r,extension:i}=configureContent(t.content,n);requirePlacement(r,i,t.key,u,n);let a={...r,name:t.key,placement:`grid`};return d.push(a),{content:a,span:t.span}}),i=rowWidths(r.map(({content:e,span:t})=>({key:e.name,...t===void 0?{}:{span:t},minWidth:traitsOf(e).minWidth})),n),a=f.reduce((e,t)=>Math.max(e,t.y+t.h),0);if(t.kind===`row`&&t.group!==void 0){let e=groupOf(r.map(({content:e})=>e),t.group,n);d.push(e),f.push({i:e.name,x:0,y:a,w:12,h:traitsOf(e,d).size.h});continue}let o=0;r.forEach(({content:e},t)=>{let n=i[t]??0;f.push({i:e.name,x:o,y:a,w:n,h:traitsOf(e).size.h}),o+=n})}let h=Object.fromEntries(packLayout(f).map(({i:e,x:t,y:n,w:r,h:i})=>[e,{x:t,y:n,w:r,h:i}])),g={name:t,label:i,...a===void 0?{}:{object:a},context:`page`,...o===void 0?{}:{icon:o},...s===void 0?{}:{description:s},...c?{home:!0}:{},contents:d,grid:h},_=n.t.safeParse(g);if(!_.success)throw r.ValidationError.fromZodErrors(_.error.issues.map(t=>({path:[...e,...t.path.map(String)],message:t.message})));return{kind:`view`,definition:cloneBuilderValue(g,e)}}};function page(e,t){return new ve({name:e,label:t,object:void 0,sections:[]})}function contentDefinition(e,t){if(t.suppressed)return null;let n=t.workspaceDefinition??t.sourceDefinition;return n===null?null:{...structuredClone(n),name:e}}function storedContentDefinition(e){let{name:t,...n}=e;return structuredClone(n)}function workspaceViewAuthoring(e,t={}){let n={main:0,aside:0};return{origin:`runtime`,mainOrderCustomized:!1,asideOrderCustomized:!1,gridCustomized:Object.keys(t).length>0,homeCustomized:!1,contents:Object.fromEntries(e.map(e=>[e.name,{sourceDefinition:null,workspaceDefinition:storedContentDefinition(e),suppressed:!1,sourcePosition:null,workspacePosition:e.placement===`grid`?null:n[e.placement]++,sourceGrid:null,workspaceGrid:t[e.name]??null}]))}}function byKind(e,t){let rank=e=>Number(e.definition.type===`group`);return rank(e)-rank(t)||e.name.localeCompare(t.name)}function inReadingOrder(e){return(t,n)=>{let r=e(t.name),i=e(n.name);return r===null||i===null?r===i?byKind(t,n):r?-1:1:r.y-i.y||r.x-i.x||byKind(t,n)}}function overLimit(t,n){let r=new Set;if(t.length<=e.p.tabsPerView)return r;let i=new Map(t.map(e=>[e.name,e])),a=new Map;for(let{name:e,definition:n}of t)if(n.type===`group`)for(let t of n.members)a.has(t)||a.set(t,e);let cellOf=e=>{let t=i.get(e),r=t?n(t.state):null;if(r!==null)return r;let o=i.get(a.get(e)??``);return o?n(o.state):null},o=t.filter(e=>e.state.sourceDefinition===null).sort(inReadingOrder(cellOf)).reverse();for(let n of o){if(t.length-r.size<=e.p.tabsPerView)break;if(r.has(n.name))continue;let a=n.definition.type===`group`?n.definition.members.flatMap(e=>{let t=i.get(e);return t&&t.definition.type!==`group`?[t]:[]}):[];if(!a.some(e=>e.state.sourceDefinition!==null))for(let e of[n,...a])r.add(e.name)}return r}function resolvePageGrid(e,t={}){let rawCell=t=>e.gridCustomized||t.sourceDefinition===null?t.workspaceGrid:t.sourceGrid,r=Object.entries(e.contents).flatMap(([e,t])=>{let n=contentDefinition(e,t);return n?[{name:e,state:t,definition:n}]:[]}),i=n.P(r.map(e=>e.definition)),a=r.filter(e=>!i.has(e.name)).sort((e,t)=>e.name.localeCompare(t.name)),o=overLimit(a,rawCell),s=a.filter(e=>!o.has(e.name)),c=new Map(s.map(e=>[e.name,e.definition])),l=t.traitsOf??n.l(c,n.z),u=n.N([...c.values()]),d=s.filter(e=>!u.has(e.name)),f={},p=[],place=(e,t)=>{t&&!Object.values(f).some(e=>n.R(t,e))?f[e]={...t}:p.push(e)};if(e.gridCustomized)for(let{name:e,state:t}of d)place(e,t.workspaceGrid);else{for(let{name:e,state:t}of d)t.sourceDefinition!==null&&place(e,t.sourceGrid);for(let{name:e,state:t}of d)t.sourceDefinition===null&&place(e,t.workspaceGrid)}let m=Math.max(0,...Object.values(f).map(e=>e.y+e.h));for(let t of p.sort()){let n=e.contents[t],{w:r,h:i}=n.workspaceGrid??n.sourceGrid??l(t).size;f[t]={x:0,y:m,w:r,h:i},m+=i}let h=repairPageGrid(Object.entries(f).map(([e,n])=>({i:e,...n,...t.statics?.has(e)?{static:!0}:{}})),l);return{grid:Object.fromEntries(h.cells.map(({i:e,x:t,y:n,w:r,h:i})=>[e,{x:t,y:n,w:r,h:i}])),repairs:[...[...o].map(e=>({name:e,kind:`dropped`})),...h.repairs]}}function droppedContents(e){return new Set(e.flatMap(e=>e.kind===`dropped`?[e.name]:[]))}function resolveViewContents(e){let t=Object.entries(e.contents).flatMap(([e,t])=>{let n=contentDefinition(e,t);return n?[{definition:n,...t}]:[]}),r=[`main`,`aside`].flatMap(n=>{let r=n===`main`?e.mainOrderCustomized:e.asideOrderCustomized;return t.filter(e=>e.definition.placement===n).sort((e,t)=>{let n=r?e.workspacePosition:e.sourcePosition,i=r?t.workspacePosition:t.sourcePosition;if(n!==null&&i!==null&&n!==i)return n-i;if(n!==null&&i===null)return-1;if(i!==null&&n===null)return 1;let a=e.sourcePosition??e.workspacePosition,o=t.sourcePosition??t.workspacePosition;return a!==null&&o!==null&&a!==o?a-o:a!==null&&o===null?-1:o!==null&&a===null?1:e.definition.name.localeCompare(t.definition.name)}).map(e=>e.definition)}),i=n.P(t.map(e=>e.definition)),a=t.filter(e=>e.definition.placement===`grid`&&!i.has(e.definition.name)).map(e=>e.definition).sort((e,t)=>e.name.localeCompare(t.name));return[...r,...a]}const K=[`record`,`document`,`file`,`email`,`thread`,`event`,`memory`,`skill`,`schema`,`user`,`guide`],ye=new Set([`memory`,`schema`]),be=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function isReferenceKind(e){return K.includes(e)}function refuse$1(e,t){return{ok:!1,reason:e,expected:t}}function parseReference(e){let t=e.trim();if(be.test(t))return refuse$1(`bare_uuid`,`record:<id>`);let n=t.indexOf(`:`);if(n===-1)return refuse$1(`malformed`,`<kind>:<id>`);let r=t.slice(0,n).toLowerCase();if(!isReferenceKind(r))return refuse$1(`unknown_kind`,`<kind>:<id> with kind one of ${K.join(`, `)}`);let i=t.slice(n+1).trim();return i===``?refuse$1(`malformed`,`${r}:<id>`):r===`record`&&i.includes(`:`)?refuse$1(`legacy_mention`,`record:${i.slice(i.lastIndexOf(`:`)+1)}`):i===`*`&&!ye.has(r)?refuse$1(`malformed`,`${r}:<id>`):{ok:!0,ref:{kind:r,id:i}}}function formatReference(e){return`${e.kind}:${e.id}`}function isWildcard(e){return e.id===`*`&&ye.has(e.kind)}function requestedCapabilities(e){let t=[];return e.canModify&&t.push(`modify`),e.canSend&&t.push(`send`),t}const xe={status:`connector_status`,error:`connector_error`,provider:`connector_provider`},Se=[`circle`,`square`],Ce={object:[`icon`,`color`],record:[`icon`,`image`],emailCategory:[`icon`,`color`],option:[`color`],view:[`icon`],agent:[`color`],user:[`image`]};function resolveAppearance(e,t){if(e.imageFileId)return{kind:`image`,imageFileId:e.imageFileId,shape:t?.imageShape??`square`};let n=t?.name??e.name,r=e.color??t?.color??(n?(0,h.colorIdFromString)(n):void 0),i=e.icon??t?.icon??`box`;return r?{kind:`tile`,icon:i,color:r}:{kind:`glyph`,icon:i}}const q=/^[a-z0-9][a-z0-9-]{0,62}$/;function assertSchemaSourceId(e){if(!q.test(e))throw new r.ValidationError(`Invalid schema source id "${e}": expected a lowercase slug matching ${q}`,[])}const we={phone:`text`,currency:`number`},Te={rename:[`kind`,`object`,`from`,`to`],phone:[`kind`,`object`,`attribute`,`to`,`defaultCountryCode`],currency:[`kind`,`object`,`attribute`,`to`,`currencyCode`]};function refuse(e,t,n){throw new r.ValidationError(n,[{path:t===void 0?[`resolutions`,String(e)]:[`resolutions`,String(e),t],message:n}])}function assertKeys(e,t,n){for(let r of n)(typeof t[r]!=`string`||t[r]===``)&&refuse(e,r,`Resolution ${e} needs a non-empty string \`${r}\``);let r=Object.keys(t).find(e=>!n.includes(e));r!==void 0&&refuse(e,r,`Resolution ${e} has an unknown field \`${r}\``)}function assertResolution(t,n){if(e.u(n)||refuse(t,void 0,`Resolution ${t} must be an object`),n.kind===`rename`){assertKeys(t,n,Te.rename),n.from===n.to&&refuse(t,`to`,`Resolution ${t} renames "${n.from}" to itself`);return}if(n.kind!==`retype`&&refuse(t,`kind`,`Unknown resolution kind ${JSON.stringify(n.kind)}: expected "rename" or "retype"`),n.to!==`phone`&&n.to!==`currency`&&refuse(t,`to`,`Unsupported retype to ${JSON.stringify(n.to)}: a push converts text → phone and number → currency only`),assertKeys(t,n,Te[n.to]),n.to===`phone`){let e=n.defaultCountryCode;/^[A-Z]{3}$/.test(e)&&(0,h.isValidIso3)(e)||refuse(t,`defaultCountryCode`,`Resolution ${t}: "${e}" is not an ISO 3166-1 alpha-3 country code`);return}let r=n.currencyCode;/^[A-Z]{3}$/.test(r)&&(0,h.isValidCurrencyCode)(r)||refuse(t,`currencyCode`,`Resolution ${t}: "${r}" is not a supported ISO 4217 currency code`)}function addressesOf(e){return e.kind===`rename`?{reads:e.from,lands:e.to}:{reads:e.attribute,lands:e.attribute}}function assertSchemaSourceResolutions(e){if(!Array.isArray(e))throw new r.ValidationError("`resolutions` must be an array",[{path:[`resolutions`],message:"`resolutions` must be an array"}]);if(e.length>100)throw new r.ValidationError(`A push carries ${e.length} resolutions; the limit is 100`,[]);let t=new Set;for(let[n,r]of e.entries()){assertResolution(n,r);let{reads:e,lands:i}=addressesOf(r);for(let[a,o]of[[`${r.kind}:${r.object}.${e}`,`of "${r.object}.${e}"`],[`${r.kind}>${r.object}.${i}`,`onto "${r.object}.${i}"`]])t.has(a)&&refuse(n,void 0,`Resolution ${n} repeats a ${r.kind} ${o}`),t.add(a)}}function phoneFromText(e,t){let n=e.trim();if(n===``)return{value:null};let r=(0,g.parsePhoneNumberFromString)(n,p.r(t));if(!r?.isPossible()||r.country===void 0||r.ext!==void 0)return;let i=(0,h.getCountryByIso2)(r.country)?.iso3;if(i!==void 0)return{value:{countryCode:i,phoneNumber:p.a(n,i)}}}function convertRetypedValue(e,t,n={}){if(t===null)return{value:null};if(e.to===`phone`)return typeof t==`string`?phoneFromText(t,e.defaultCountryCode):void 0;if(typeof t==`number`&&Math.abs(t)<=2**53-1&&!(t<0&&n.allowNegative!==!0))return{value:{code:e.currencyCode,value:t}}}const J=m.z.string().refine(e=>e.trim().length>0,`Must not be blank`),Ee=m.z.union([m.z.tuple([m.z.literal(`object`),J]),m.z.tuple([m.z.literal(`attribute`),J,J]),m.z.tuple([m.z.literal(`view`),J,J]),m.z.tuple([m.z.literal(`content`),J,J,J])]),De=m.z.object({label:J,pluralLabel:m.z.string().optional(),description:m.z.string().optional(),icon:e.f.optional(),color:e.d.optional(),imageShape:m.z.enum(Se).optional(),labelExpression:m.z.string(),embeddingExpression:m.z.string().optional(),sealed:m.z.boolean().optional(),toleratedAttributes:m.z.array(J).optional(),metadata:m.z.record(m.z.string(),m.z.unknown()).optional(),documentLayout:m.z.record(m.z.string(),m.z.unknown()).optional()}).strict();function failure(e){throw new r.ValidationError(e,[])}function definitionSchema(t){return m.z.custom(r=>{let i=m.z.record(m.z.string(),m.z.unknown()).parse(r);for(let e of t[0]===`view`?[`object`,`name`]:[`name`])Object.hasOwn(i,e)&&failure(`Invalid schema state: unrecognized definition key ${e}`);switch(t[0]){case`object`:De.parse(i);break;case`attribute`:{let t=m.z.enum(n.nn).parse(i.type);u.o(t).extend({type:m.z.literal(t),label:J,required:m.z.boolean().optional(),unique:m.z.boolean().optional(),icon:e.f.optional()}).strict().parse(i);break}case`view`:{let{contents:e,...r}=i,a=m.z.array(J).parse(e);new Set(a).size!==a.length&&failure(`Invalid schema state: duplicate content membership`),n.r.parse({...r,object:t[1],name:t[2],contents:[]});break}case`content`:n.o.parse({...i,name:t[3]})}return!0})}function compareSchemaStateEntries(e,t){let n=JSON.stringify(e.address),r=JSON.stringify(t.address);return n<r?-1:+(n>r)}function schemaStateSourcePayload(e){return{modelVersion:1,hashVersion:1,entries:[...e].sort(compareSchemaStateEntries).filter(e=>e.source!==null).map(({address:e,source:t})=>({address:e,source:t}))}}function parseState(e){let t=m.z.record(m.z.string(),m.z.unknown()).parse(e);for(let[e,n]of[[`modelVersion`,`model`],[`hashVersion`,`hash`]])t[e]!==1&&failure(`Unsupported schema ${n} version: expected 1, received ${t[e]===void 0?`missing`:String(t[e])}`);let n=m.z.object({modelVersion:m.z.literal(1),hashVersion:m.z.literal(1),tenant:J,sourceFingerprint:m.z.string().regex(/^[a-f0-9]{64}$/),entries:m.z.array(m.z.unknown())}).strict().safeParse(e);if(!n.success){let e=n.error.issues.find(e=>e.code===`unrecognized_keys`);throw e?.code===`unrecognized_keys`&&failure(`Invalid schema state: unrecognized key ${e.keys[0]}`),r.ValidationError.fromZodErrors(n.error.issues.map(e=>({path:e.path.map(String),message:e.message})))}let i=new Set,a=n.data.entries.map(e=>{let t=Ee.parse(m.z.object({address:m.z.unknown()}).parse(e).address),n=JSON.stringify(t);i.has(n)&&failure(`Invalid schema state: duplicate address ${n}`),i.add(n);let r=definitionSchema(t).nullable(),a=t[0]===`object`||t[0]===`attribute`?m.z.object({id:m.z.string().uuid(),updatedAt:m.z.string().datetime()}).strict():m.z.object({id:m.z.string().uuid(),revision:m.z.number().int().nonnegative()}).strict(),o=m.z.object({address:Ee,source:r,effective:r,status:m.z.enum([`source`,`runtime`,`copy`,`suppressed`]),sourceOwner:m.z.union([m.z.literal(`core`),m.z.string().regex(/^(bundle|source):.+$/)]).nullable(),guard:a.nullable()}).strict().parse(e);(o.status===`runtime`&&(o.source!==null||o.effective===null||o.sourceOwner!==null)||o.status===`suppressed`&&(t[0]!==`content`||o.source===null||o.effective!==null||o.guard===null)||o.status===`copy`&&(o.source===null||o.effective===null)||o.effective!==null&&o.guard===null||o.source===null&&o.effective===null)&&failure(`Invalid schema state: inconsistent status at ${n}`);let s=o.sourceOwner;s!==null&&s!==`core`&&!s.startsWith(`bundle:`)&&!s.startsWith(`source:`)&&failure(`Invalid source owner`);let c=s===null||s===`core`?s:s.startsWith(`bundle:`)?`bundle:${s.slice(7)}`:`source:${s.slice(7)}`;return{...o,sourceOwner:c}});return{...n.data,entries:a.sort(compareSchemaStateEntries)}}function parseSchemaState(e){try{return parseState(e)}catch(e){throw e instanceof m.z.ZodError?r.ValidationError.fromZodErrors(e.issues.map(e=>({path:e.path.map(String),message:e.message}))):e}}function diffSchemaState(e){let t=[];for(let n of[...e.entries].sort(compareSchemaStateEntries)){let e=n.source===null?`added`:n.status===`suppressed`?`suppressed`:n.effective===null?`removed`:d.s(n.source)===d.s(n.effective)?n.status===`copy`?`copied`:null:`changed`;e&&t.push({...n,change:e})}return{modelVersion:1,tenant:e.tenant,sourceFingerprint:e.sourceFingerprint,changes:t}}const Y=m.z.string().min(1),Oe=m.z.union([m.z.object({objectName:Y,viewName:Y,contentName:Y.optional()}).strict().describe(`Full configuration of a view, or of one content when contentName is given`),m.z.object({objectId:Y}).strict().describe(`An object with its attributes, by id`),m.z.object({objectName:Y}).strict().describe(`An object with its attributes`),m.z.object({objectId:Y,attributeName:Y}).strict().describe(`One attribute's config, by name`),m.z.object({objectId:Y,attributeId:Y}).strict().describe(`One attribute's config, by id`),m.z.object({objectId:Y,recordId:Y}).strict().describe(`One sample record`)]);function parseNamedTarget(e){let t=Oe.safeParse(e);if(!t.success)throw new r.ValidationError(`Invalid scoped target`,[{path:[`target`],message:`Expected exactly one named target branch`}]);return t.data}const ke=m.z.object({mode:m.z.enum([`inline`,`window`]),interaction:m.z.enum([`static`,`interactive`]),size:m.z.enum([`compact`,`regular`]),aspectRatio:m.z.number().positive().finite().optional()}).strict(),Ae=m.z.object({artifactId:m.z.string().min(1),revision:m.z.number().int().positive(),name:m.z.string().min(1),kind:m.z.string().min(1),retention:m.z.enum(re),display:ke}).strict();function readArtifactResult(e){let t=Ae.safeParse(e);return t.success?t.data:null}const je=m.z.string().regex(/^[^/\s]+\/[^/\s]+$/),Me=m.z.object({kind:m.z.literal(`generated-image`),artifact:m.z.unknown(),generation:m.z.object({attemptId:m.z.uuid(),requestedModelId:je,executedModelId:je.nullable(),format:m.z.enum(ae),mimeType:m.z.enum([`image/png`,`image/jpeg`,`image/webp`])}).strict()}).strict();function readGeneratedImageResult(e){let t=Me.safeParse(e);if(!t.success)return null;let n=readArtifactResult(t.data.artifact);return!n||n.kind!==`image`?null:{...t.data,artifact:{...n,kind:`image`}}}function isCompletedToolPart(e){return e.type===`tool`&&e.state===`completed`}function readString(e,t){let n=e[t];return typeof n==`string`?n:void 0}function upsertWithPrecedence(e,t,n,r){let i=e.get(t),a=i&&r[i.kind]>r[n.kind]?i:n;e.delete(t),e.set(t,a)}function asRecord(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function readRefId(e,t,n){let r=readString(e,t),i=`${n}:`;return r?.startsWith(i)&&r.length>i.length?r.slice(i.length):void 0}function verbResultEntries(e){let t=asRecord(e);if(!t)return[];let n=[t];for(let e of[`members`,`created`,`updated`]){let r=t[e];if(Array.isArray(r))for(let e of r){let t=asRecord(e);t&&n.push(t)}}return n.filter(e=>!(`error`in e))}const Ne={created:1,modified:0};function readSingleRecordEntry(e){if(typeof e!=`object`||!e)return null;let t=e,n=typeof t.record==`object`&&t.record!==null?t.record:void 0,r=(n&&readString(n,`id`))??readString(t,`recordId`);return r?{id:r,label:(n&&readString(n,`label`))??r,objectName:(n&&readString(n,`objectName`))??``}:null}function readBulkRecordEntries(e,t,n){if(typeof e!=`object`||!e)return[];let r=e[t];if(!Array.isArray(r))return[];let i=[];for(let e of r){if(typeof e!=`object`||!e)continue;let t=e,r=readString(t,`id`);r&&i.push({id:r,label:readString(t,`label`)??r,objectName:readString(t,`objectName`)??n})}return i}function readVerbRecordEntries(e){let t=asRecord(asRecord(e.result)?.record),n=readString(e.args,`object`)??(t&&readString(t,`objectName`))??``,r=[];for(let t of verbResultEntries(e.result)){let e=readRefId(t,`ref`,`record`);e&&r.push({id:e,label:readString(t,`title`)||readString(t,`label`)||e,objectName:readString(t,`objectName`)??n})}return r}function extractTouchedRecords(e){let t=new Map;for(let n of e)if(n.role===`assistant`)for(let e of n.parts){if(!isCompletedToolPart(e))continue;let n=[],r;if(e.name===`create_record`||e.name===`update_record`||e.name===`edit_content`){let t=readSingleRecordEntry(e.result);n=t?[t]:[],r=e.name===`create_record`?`created`:`modified`}else if(e.name===`bulk_create_records`||e.name===`bulk_update_records`){let t=readString(e.args,`objectId`)??``,i=e.name===`bulk_create_records`?`created`:`updated`;n=readBulkRecordEntries(e.result,i,t),r=e.name===`bulk_create_records`?`created`:`modified`}else if(e.name===`write`)n=readVerbRecordEntries(e),r=readString(e.args,`action`)===`create`?`created`:`modified`;else continue;for(let e of n){let n={recordId:e.id,objectName:e.objectName,label:e.label,kind:r};upsertWithPrecedence(t,e.id,n,Ne)}}return[...t.values()]}const X={modified:1,consulted:0};function isFilePart(e){return e.type===`file`}function entryFromDocumentMutation(e,t){if(typeof e.result!=`object`||e.result===null)return null;let n=e.result,r=readString(n,`documentId`)??(t===`folderId`?readString(n,t):void 0);return r?{id:r,title:readString(e.args,`name`)??readString(e.args,`title`)??r,kind:`modified`}:null}function entryFromReadDocument(e){let t=readString(e.args,`documentId`);return t?{id:t,title:t,kind:`consulted`}:null}function entryFromRef(e,t,n){let r=readRefId(e,`ref`,`file`),i=r??readRefId(e,`ref`,`document`);return i?{id:i,...r?{fileId:r}:{},title:n||readString(e,`title`)||i,kind:t,mimeType:readString(e,`mimeType`)}:null}function entriesFromOrganize(e){let t=asRecord(e.result);if(!t||`error`in t)return[];let n=readString(e.args,`action`),r=readString(e.args,`name`)??readString(e.args,`title`),i=readString(t,`documentId`);if(i)return[{id:i,title:r??i,kind:`modified`}];let a=readString(t,`folderId`);if(a)return n===`create_folder`?[{id:a,title:r??a,kind:`modified`}]:[];let o=entryFromRef(t,`modified`,r);return o?[o]:[]}function entriesFromCopy(e){let t=asRecord(e.result);if(!t||`error`in t)return[];let n=(Array.isArray(t.copied)?t.copied:[]).flatMap(e=>{let t=asRecord(e),n=t?entryFromRef(t,`modified`,void 0):null;return n?[n]:[]});if(n.length>0)return n;let r=entryFromRef(t,t.ref!==void 0&&t.ref===readString(e.args,`from`)?`consulted`:`modified`,void 0);return r?[r]:[]}function entriesFromRead(e){let t=asRecord(e.result);return(Array.isArray(t?.members)?t.members:[]).flatMap(e=>{let t=asRecord(e);if(!t||`error`in t||!readRefId(t,`ref`,`document`))return[];let n=entryFromRef(t,`consulted`,void 0);return n?[n]:[]})}function entriesFromToolPart(e){switch(e.name){case`organize`:return entriesFromOrganize(e);case`copy`:return entriesFromCopy(e);case`read`:return entriesFromRead(e);default:{let t=entryFromToolPart(e);return t?[t]:[]}}}function entryFromSandboxUpload(e){if(typeof e.result!=`object`||e.result===null)return null;let t=e.result,n=readString(t,`fileId`);return n?{id:n,fileId:n,title:readString(t,`title`)??n,kind:`modified`,mimeType:readString(t,`mimeType`)}:null}function entryFromToolPart(e){switch(e.name){case`update_document`:case`attach_file`:return entryFromDocumentMutation(e,`documentId`);case`create_folder`:return entryFromDocumentMutation(e,`folderId`);case`read_document`:return entryFromReadDocument(e);case`sandbox_upload_file`:return entryFromSandboxUpload(e);default:return null}}function extractTouchedDocuments(e){let t=new Map;for(let n of e)if(n.role===`assistant`){for(let e of n.parts)if(isCompletedToolPart(e))for(let n of entriesFromToolPart(e))upsertWithPrecedence(t,n.id,n,X);else if(isFilePart(e)&&e.fileId){let n={id:e.fileId,fileId:e.fileId,title:e.name||e.fileId,kind:`modified`,mimeType:e.mimeType};upsertWithPrecedence(t,n.id,n,X)}}return[...t.values()]}function extractTouchedArtifacts(e){let t=new Map;for(let n of e)if(n.role===`assistant`)for(let e of n.parts){if(!isCompletedToolPart(e)||e.error)continue;let n=e.name===`generate_image`?readGeneratedImageResult(e.result)?.artifact:e.name===`publish_artifact`?readArtifactResult(e.result):null;if(!n)continue;let r=`${n.artifactId}:${n.revision}`;t.delete(r),t.set(r,n)}return[...t.values()]}function isNonBlankString(e){return typeof e==`string`&&/\S/u.test(e)}const Pe=m.z.object({provider:m.z.custom(e=>isNonBlankString(e)&&e.length<=200,{message:`must be a non-blank string of at most 200 characters`}),model:m.z.string().max(200).regex(/\S/u)});function normalizeNewsLocale(e){return e.toLowerCase().split(`-`)[0]===`fr`?`fr`:`en`}function resolveLocalized(e,t){return e[normalizeNewsLocale(t)]||(e.en?e.en:e.fr||void 0)}function hasLocale(e){return!!(e.fr||e.en)}const Fe=Object.keys({home:!0,agents:!0,routines:!0,object:!0,settings:!0}),Ie=[`dot`,`label`,`bubble`];function parseNewsIntensity(e){return Ie.find(t=>t===e)??`dot`}function parseNewsTarget(e){let[t,...n]=e.split(`:`),r=n.join(`:`);switch(t){case`home`:case`agents`:case`routines`:return r===``?{kind:t}:null;case`object`:return r?{kind:t,name:r}:null;case`settings`:return r?{kind:t,section:r}:null;default:return null}}function formatNewsTarget(e){return e.kind===`object`?`object:${e.name}`:e.kind===`settings`?`settings:${e.section}`:e.kind}function withoutTrailingSlashes(e){let t=e.length;for(;t>0&&e[t-1]===`/`;)--t;return e.slice(0,t)}const Z=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/;function compareIdentifiers(e,t){let n=/^\d+$/.test(e),r=/^\d+$/.test(t);return n&&r?Math.sign(Number(e)-Number(t)):n?-1:r?1:e<t?-1:+(e>t)}function compareVersions(e,t){let n=Z.exec(e),r=Z.exec(t);if(!(n&&r))return null;for(let e=1;e<=3;e+=1){let t=Number(n[e])-Number(r[e]);if(t!==0)return t<0?-1:1}let i=n[4],a=r[4];if(i===void 0&&a===void 0)return 0;if(i===void 0)return 1;if(a===void 0)return-1;let o=i.split(`.`),s=a.split(`.`);for(let e=0;e<Math.max(o.length,s.length);e+=1){let t=o[e],n=s[e];if(t===void 0)return-1;if(n===void 0)return 1;let r=compareIdentifiers(t,n);if(r!==0)return r<0?-1:1}return 0}function isSemver(e){return Z.test(e)}const Q=m.z.looseObject({fr:m.z.string().optional(),en:m.z.string().optional()}),$=m.z.iso.datetime({offset:!0}),Le=m.z.looseObject({id:m.z.string().min(1),slug:m.z.string().min(1),updatedAt:$,publishedAt:$,since:m.z.string(),displayDays:m.z.number().int().positive().optional(),requires:m.z.looseObject({capability:m.z.string(),level:m.z.string()}).optional(),target:m.z.string().optional(),intensity:m.z.unknown().optional(),title:Q,summary:Q});function knownRequirement(e){let t=L.find(t=>t.id===e.capability);return t!==void 0&&levelActions(t,e.level).length>0}function parseEntry(e){let t=Le.safeParse(e);if(!t.success)return`malformed entry: ${t.error.issues[0]?.message??`invalid`}`;let n=t.data;if(!isSemver(n.since))return`entry ${n.id}: since "${n.since}" is not semver`;if(!hasLocale(n.title))return`entry ${n.id}: title has no locale`;if(!hasLocale(n.summary))return`entry ${n.id}: summary has no locale`;if(n.requires&&!knownRequirement(n.requires))return`entry ${n.id}: unknown requirement ${n.requires.capability}/${n.requires.level}`;let r=n.target?parseNewsTarget(n.target):null;return{...n,displayDays:n.displayDays??30,intensity:parseNewsIntensity(n.intensity),target:r??void 0}}function httpsUrl(e){return typeof e==`string`&&e.startsWith(`https://`)?e:void 0}function parseNewsIndex(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw new r.ValidationError(`News feed: document must be an object`,[]);let n=e;if(!Array.isArray(n.entries))throw new r.ValidationError(`News feed: entries must be an array`,[]);let i=[];for(let e of n.entries){let n=parseEntry(e);typeof n==`string`?t?.(n):i.push(n)}let a=httpsUrl(n.blogUrl),o=httpsUrl(n.mediaBaseUrl),s=o?withoutTrailingSlashes(o):void 0;return{...a?{blogUrl:a}:{},...s?{mediaBaseUrl:s}:{},entries:i.slice(0,50)}}const Re=m.z.looseObject({id:m.z.string().min(1),slug:m.z.string().min(1),updatedAt:$,body:Q});function parseNewsBody(e){let t=Re.safeParse(e);if(!t.success)throw new r.ValidationError(`News body: malformed document`,[]);if(!hasLocale(t.data.body))throw new r.ValidationError(`News body: body needs at least one locale`,[]);return t.data}function preference(e,t){return{key:e,value:t.value,default:t.default,audited:t.audited??!1,...t.parameter===void 0?{}:{parameter:t.parameter},...t.parameters===void 0?{}:{parameters:t.parameters},...t.refine===void 0?{}:{refine:t.refine}}}function refusal(e,t){return{ok:!1,field:e,message:t,issues:[{path:[e],message:t}]}}function declarationOf(e,t){return`get`in e?e.get(t):e.find(e=>e.key===t)}function locatePreference(e,t,n){let r=declarationOf(e,t);return r?r.parameter===void 0?n===void 0?{ok:!0,declaration:r,parameter:``}:refusal(`parameter`,`Preference "${t}" takes no parameter`):n===void 0||n===``||n.trim()!==n?refusal(`parameter`,`Preference "${t}" is keyed by ${r.parameter}`):r.parameters&&!r.parameters.includes(n)?refusal(`parameter`,`"${n}" is not a ${r.parameter} of "${t}"`):{ok:!0,declaration:r,parameter:n}:refusal(`key`,`Unknown preference "${t}"`)}function judgePreferenceWrite(e,t,n,r){let i=locatePreference(e,t,n);if(!i.ok)return i;let a=i.declaration.value.safeParse(r);if(a.success){let e=i.declaration.refine?.(a.data,i.parameter);return e===void 0?{...i,value:a.data}:refusal(`value`,e)}return{ok:!1,field:`value`,message:`Invalid value for preference "${t}"`,issues:a.error.issues.map(e=>({path:[`value`,...e.path.map(String)],message:e.message}))}}const ze=m.z.strictObject({model:Pe.optional(),routing:m.z.literal(`auto`).optional()}),Be=m.z.strictObject({inApp:m.z.boolean(),email:m.z.boolean()});function isActionableType(e){let n=t.S[e];return n!==void 0&&t.T(n.kind)}const Ve=[preference(`workPosture`,{value:m.z.enum(i.Tn),default:`auto`,audited:!0}),preference(`chat.default`,{value:ze,default:{},audited:!0}),preference(`conversationSurface`,{value:m.z.enum(i.Cn),default:`panel`}),preference(`mailboxListMode`,{value:m.z.enum(i.Y),default:`threads`}),preference(`home`,{value:m.z.string().uuid().nullable(),default:null}),preference(`memory.observeActivity`,{value:m.z.boolean(),default:!0,audited:!0}),preference(`memory.learnFromEmail`,{value:m.z.boolean(),default:!0,audited:!0}),preference(`notifications.briefingSeenAt`,{value:m.z.iso.datetime().nullable(),default:null}),preference(`notifications.delivery`,{value:Be,default:{inApp:!0,email:!1},parameter:`notification type`,parameters:Object.keys(t.S),refine:(e,t)=>!e.inApp&&isActionableType(t)?`A "${t}" notification asks you to act: it is always shown in-app`:void 0})];function preferenceEntry(e,t,n){return n===void 0?{key:e,value:t}:{key:e,parameter:n,value:t}}function withPreferenceEntry(e,t){if(t.parameter===void 0)return{...e,values:{...e.values,[t.key]:t.value}};let n=e.entries.findIndex(e=>e.key===t.key&&e.parameter===t.parameter),r=n===-1?[...e.entries,t]:e.entries.map((e,r)=>r===n?t:e);return{...e,entries:r}}exports.ACCESS_ROLES=i.rr,exports.ACTIONABLE_NOTIFICATION_KINDS=t.i,exports.AGENDA_BLOCK=n.B,exports.AGENT_ASIDE_ANSWER_MAX_LENGTH=i.yr,exports.AGENT_ASIDE_HISTORY_LIMIT=i.br,exports.AGENT_ASIDE_QUESTION_MAX_LENGTH=i.xr,exports.AGENT_AVATAR_EXPRESSIONS=i.Sr,exports.AGENT_AVATAR_TYPES=i.Cr,exports.AGENT_MESSAGE_KIND=i.wr,exports.AGENT_NOTIFICATION_KIND=i.Tr,exports.AGENT_SESSION_LIST_ORDERS=i.Er,exports.AGENT_SESSION_ORIGINS=i.hr,exports.AGENT_STARTERS_MAX=i.Dr,exports.AGENT_STARTER_MAX_LENGTH=i.Or,exports.AGENT_TASK_KINDS=i.kr,exports.AGGREGATE_BUCKETS=t.t,exports.AGGREGATE_MEASURES=t.n,exports.ALLOWED_PROPERTY_TYPES=ce,exports.ALL_CATALOG_TOOL_NAMES=i.Rt,exports.ALL_PIPES=D,exports.ALWAYS_KINDS=i.zt,exports.APPEARANCE_FACETS=Ce,exports.APPROVAL_FAMILY_TOOL_NAMES=i.Nn,exports.ARTIFACT_FILE_ROLES=ie,exports.ARTIFACT_KINDS=ne,exports.ARTIFACT_PREVIEW_EXTENSION=n.V,exports.ARTIFACT_RETENTIONS=re,exports.ASK_QUESTIONS_ANSWER_MAX_LENGTH=i.Pn,exports.ASK_QUESTIONS_ANSWER_MAX_VALUES=i.Fn,exports.ASK_QUESTIONS_MAX_BATCH=i.In,exports.ASK_QUESTIONS_TOOL_NAME=i.Ln,exports.ATTRIBUTE_FILTER_OPERATORS=n.ln,exports.ATTRIBUTE_NAME_SCHEMA=e.t,exports.ATTRIBUTE_TYPES=n.nn,exports.AUDIT_ACTIONS=i.$n,exports.AUDIT_AGENT_SESSION_METADATA_KEY=i.er,exports.AUDIT_RESOURCE_TYPES=i.tr,exports.AccessDeniedError=r.AccessDeniedError,exports.AgendaBuilder=AgendaBuilder,exports.AgentBuilder=i.Ct,exports.AggregateValidationError=r.AggregateValidationError,exports.AmbiguousSchemaChangeError=r.AmbiguousSchemaChangeError,exports.AttributeInUseError=r.AttributeInUseError,exports.AttributeNotFoundError=r.AttributeNotFoundError,exports.BLOCK_CONTEXTS=n.Gt,exports.BLOCK_PERIODS=n.rt,exports.BLOCK_WIDTHS=n.F,exports.BROWSER_IMAGE_MAX_BYTES=15e4,exports.BROWSER_LAUNCH_TOOL_NAME=i.gr,exports.BYTE_UNIT_LABELS=se,exports.BlockContentBuilder=BlockContentBuilder,exports.CARD_BLOCK=n.H,exports.CATALOG_RESOURCES=me,exports.CHART_BLOCK=n.U,exports.CHART_KINDS=n.W,exports.COMPUTED_RETURN_TYPES=u.C,exports.CONNECTION_GRANT_PROVIDERS=i.Bt,exports.CONNECTOR_CALLBACK_PARAM=xe,exports.CONTENT_PLACEMENT_CONTEXTS=n.u,exports.CONTINUATION_KEY_PATTERN=i.r,exports.CONVERSATION_SURFACES=i.Cn,exports.CORE_PREFERENCES=Ve,exports.CORE_RECORD_TOOL_NAMES=i.Vt,exports.CORE_TOOL_NAMES=i.Ht,exports.COUNT_MODES=E,exports.CUSTOM_LEVEL=F,exports.CardBuilder=CardBuilder,exports.ChartBuilder=ChartBuilder,exports.ChartQuery=ChartQuery,exports.ConcurrentModificationError=r.ConcurrentModificationError,exports.ContentBuilder=W,exports.DEFAULT_AGENT_EXECUTION_CONFIG=i.wt,exports.DEFAULT_AGENT_TOOL_GROUPS=i.Ut,exports.DEFAULT_APPEARANCE_ICON=`box`,exports.DEFAULT_APPROVAL_POLICY=i.Ar,exports.DEFAULT_BLUEPRINT_TOOL_GROUPS=i.Wt,exports.DEFAULT_DAILY_ACTIVITY_DAYS=i.jr,exports.DEFAULT_DICTATION_LIMITS=te,exports.DEFAULT_LABEL_FALLBACK=M,exports.DEFAULT_LAYOUT_TRAITS=n.s,exports.DEFAULT_MEETING_BOT_DISPLAY_NAME=i.En,exports.DEFAULT_TENANT_SETTINGS=i.Dn,exports.DEFAULT_VALIDATION_MESSAGES=o.n,exports.DEVICE_CHANNEL_AUTHENTICATE_TIMEOUT_MS=1e4,exports.DEVICE_CHANNEL_IDLE_POLL_MS=2e3,exports.DEVICE_CHANNEL_KEEPALIVE_MS=2e4,exports.DEVICE_CHANNEL_MAX_FRAME_BYTES=262144,exports.DEVICE_CHANNEL_PATH=v,exports.DEVICE_CHANNEL_PRESENCE_MS=2e3,exports.DEVICE_CHANNEL_UPGRADE_REQUIRED_REASON=`UPGRADE_REQUIRED`,exports.DEVICE_CHANNEL_WORKER_CLOSE_PROTOCOL_VIOLATION=4008,exports.DEVICE_COMMAND_ERROR_CODES=y,exports.DICTATION_FINALIZATION_TIMEOUT_MS=5e3,exports.DICTATION_FRAME_BYTES=3200,exports.DICTATION_MAX_BUFFER_BYTES=16e3,exports.DICTATION_MAX_FRAME_BYTES=6400,exports.DICTATION_MAX_TRANSCRIPT_BYTES=65536,exports.DICTATION_MODEL_ID=`google/gemini-3.5-transcribe-live`,exports.DICTATION_PREPARATION_TIMEOUT_MS=1e4,exports.DICTATION_SAMPLE_RATE=16e3,exports.DICTATION_TICKET_TTL_MS=15e3,exports.DISCARD_ARCHITECT_DRAFT_TOOL_NAME=i.Yn,exports.DOCUMENT_SORT_MODES=i.dr,exports.DRAFT_WRITE_TOOL_NAMES=i.Xn,exports.DeviceChannelProtocolError=DeviceChannelProtocolError,exports.DeviceChannelServerFrameSchema=w,exports.DeviceChannelWorkerFrameSchema=C,exports.DuplicateError=r.DuplicateError,exports.EMAIL_CATEGORY_DEFAULT_COLOR=i.Et,exports.EMAIL_CATEGORY_DEFAULT_ICON=i.Dt,exports.EMAIL_CATEGORY_DESCRIPTION_MAX=i.Ot,exports.EMAIL_CATEGORY_DESCRIPTION_MIN=i.kt,exports.EMAIL_CATEGORY_LIMIT=i.At,exports.EMAIL_CATEGORY_NAME_MAX=i.jt,exports.ENVIRONMENT_HARNESSES=i.an,exports.ENVIRONMENT_HARNESS_SANDBOX_WORKDIR=i.on,exports.ENVIRONMENT_HARNESS_WORKDIR=i.sn,exports.ENVIRONMENT_NAME_MAX_CHARS=i.cn,exports.ENVIRONMENT_STANDARDS_WORKDIR=i.ln,exports.ENV_VAR_KEY_PATTERN=i.i,exports.ESTIMATED_COUNT_CAP=1e4,exports.ExportTooLargeError=r.ExportTooLargeError,exports.FILE_URLS_MAX_IDS=i.kn,exports.FORM_FORBIDDEN_ATTRIBUTE_TYPES=T,exports.ForbiddenError=r.ForbiddenError,exports.FormBuilder=FormBuilder,exports.FormRowBuilder=FormRowBuilder,exports.FormStepBuilder=FormStepBuilder,exports.GET_ARCHITECT_DRAFT_TOOL_NAME=i.Zn,exports.GITHUB_TRIGGER_CATALOG=i.gt,exports.GRANT_ENABLES=i.Gt,exports.GROUPABLE_ATTRIBUTE_TYPES=n.G,exports.GroupBuilder=G,exports.HEADING_BLOCK=n.K,exports.HITL_TOOL_NAMES=i.Rn,exports.IMAGE_FORMATS=ae,exports.IMAGE_SHAPES=Se,exports.INBOX_BLOCK=n.q,exports.INFERENCE_REASONING_OPTIONS=i.Mr,exports.INFERENCE_ROUTING_MODES=i.Nr,exports.INFERENCE_SPEEDS=i.Pr,exports.INVENTORY_LIMIT=n.d,exports.InboxBuilder=InboxBuilder,exports.InvalidPermissionGrantError=r.InvalidPermissionGrantError,exports.LAST_RUN_ERROR_MAX_LENGTH=i.Fr,exports.LIST_VIEW_TAB_VISIBILITIES=e.m,exports.LOCATION_FILTER_PROPERTIES=n.un,exports.MAILBOX_BLOCK=n.J,exports.MAILBOX_LIST_MODES=i.Y,exports.MAIL_DRAFT_BODY_MAX_CHARS=i.X,exports.MAIL_SUBJECT_MAX_CHARS=i.Z,exports.MAX_AGGREGATE_GROUPS=t.r,exports.MAX_DAILY_ACTIVITY_DAYS=i.Ir,exports.MAX_PRESET_DEPTH=5,exports.MAX_TODOS=i.Lr,exports.MAX_TODO_DESCRIPTION_CHARS=i.Rr,exports.MAX_TODO_ID_CHARS=i.zr,exports.MCP_SERVER_NAME_MAX_LENGTH=i.it,exports.MEASURABLE_ATTRIBUTE_TYPES=n.Y,exports.MEETINGS_UPCOMING_BLOCK=n.X,exports.MEETING_BOT_IMAGE=i.ot,exports.MEETING_BOT_IMAGE_BASE64_MAX_LENGTH=i.st,exports.MEMORY_ATTRIBUTES=V,exports.MEMORY_PAGE_MAX_CHARS=4e3,exports.MEMORY_SPEND_LIMIT_PATTERN=i.On,exports.MEMORY_WORKSPACE_PROFILE=`workspace`,exports.MEMORY_WRITE_SOURCE=`memory`,exports.METRIC_BLOCK=n.Z,exports.MailboxBuilder=MailboxBuilder,exports.McpOAuthCompletionMode=i.at,exports.MemoryNotFoundError=r.MemoryNotFoundError,exports.MetricBuilder=MetricBuilder,exports.MetricQuery=MetricQuery,exports.MultiRelationAttributeBuilder=MultiRelationAttributeBuilder,exports.NATIVE_AGENT_UI_PART_IDS_METADATA_KEY=_,exports.NATIVE_AGENT_UI_PART_IDS_METADATA_SCHEMA_VERSION=1,exports.NATIVE_BLOCKS=n.Q,exports.NATIVE_OBJECT_NAMES=e.S,exports.NATIVE_TOOL_GROUPS=i._r,exports.NATIVE_TOOL_GROUP_CATALOG=i.Kt,exports.NEWS_DEFAULT_DISPLAY_DAYS=30,exports.NEWS_DISPLAY_CAP_DAYS=90,exports.NEWS_INDEX_MAX_ENTRIES=50,exports.NEWS_INTENSITIES=Ie,exports.NEWS_TARGET_KINDS=Fe,exports.NOTIFICATION_CHANNELS=t.a,exports.NOTIFICATION_INBOX_STATES=t.o,exports.NOTIFICATION_KINDS=t.s,exports.NOTIFICATION_PRIORITIES=t.c,exports.NOTIFICATION_PRIORITY_RANK=t.l,exports.NOTIFICATION_SENSITIVITIES=t.u,exports.NOTIFICATION_SETTINGS_AREAS=t.d,exports.NOTIFICATION_SUBJECT_TYPES=t.f,exports.NOTIFICATION_TYPES_V1=t.p,exports.NOTIFICATION_TYPE_ACCESS_GRANTED=t.m,exports.NOTIFICATION_TYPE_AGENT_QUESTION_REQUESTED=t.h,exports.NOTIFICATION_TYPE_AGENT_ROUTINE_RUN_FAILED=t.g,exports.NOTIFICATION_TYPE_AGENT_ROUTINE_RUN_NOTICE=t._,exports.NOTIFICATION_TYPE_AGENT_SESSION_WAITING_HUMAN=t.v,exports.NOTIFICATION_TYPE_AGENT_TASK_ASSIGNED=t.y,exports.NOTIFICATION_TYPE_CONNECTOR_CONNECTION_ERROR=t.b,exports.NOTIFICATION_TYPE_CONNECTOR_CONNECTION_REAUTH_REQUIRED=t.x,exports.NOTIFICATION_TYPE_KINDS=t.S,exports.NOTIFICATION_TYPE_RECORD_ASSIGNED=t.C,exports.NOTIFICATION_WORK_STATES=t.w,exports.NO_ACCESS=P,exports.NO_PREFERENCE_PARAMETER=``,exports.NO_RECORDING=i.ct,exports.NO_VALUE_OPERATORS=n.Qt,exports.NonJsonValueError=d.o,exports.NoopGeocodingAdapter=NoopGeocodingAdapter,exports.NotFoundError=r.NotFoundError,exports.NotImplementedError=r.NotImplementedError,exports.OBJECT_GRANT=I,exports.OBJECT_NAME_SCHEMA=e.n,exports.OPEN_TOOL_PART_STATES=i.Br,exports.OPERATION_MAX_STEPS=i.t,exports.OPERATORS_BY_TYPE=n.$t,exports.ObjectBuilder=ObjectBuilder,exports.ObjectNotFoundError=r.ObjectNotFoundError,exports.ObjectReferencedError=r.ObjectReferencedError,exports.OrphanSystemAttributeError=r.OrphanSystemAttributeError,exports.PAGE_GRID_COLUMNS=n.I,exports.PERMISSION_ACTIONS=z,exports.PERMISSION_CAPABILITIES=L,exports.PERMISSION_CATALOG=N,exports.PIPES_WITH_ARGS=ue,exports.PROVIDER_DRAFT_LABEL=i.Q,exports.PROVIDER_NAMES=i.Vr,exports.PUBLIC_MAIL_DOMAINS=i.Mt,exports.PageBuilder=ve,exports.PageReferencedError=r.PageReferencedError,exports.ProtectedResourceError=r.ProtectedResourceError,exports.ProtectedRoleError=r.ProtectedRoleError,exports.QUALIFIED_SEPARATOR=n.Yt,exports.QUERY_OBJECT=n.it,exports.QUESTION_FAMILY_TOOL_NAMES=i.zn,exports.QUOTA_KEYS=oe,exports.QueryTimeoutError=r.QueryTimeoutError,exports.RECENT_ACTIVITY_LEDGER_LIMIT=i.jn,exports.RECORDING_OVERRIDES=i.lt,exports.RECORDING_POLICIES=i.ut,exports.RECORD_ACCESS_ROLES=i.ir,exports.RECORD_ACCESS_SOURCES=i.ar,exports.RECORD_DRIVE_CURSOR_MAX_LENGTH=i.fr,exports.RECORD_DRIVE_PAGE_DEFAULT_LIMIT=i.pr,exports.RECORD_DRIVE_PAGE_MAX_LIMIT=i.mr,exports.RECORD_GRAPH_DEFAULT_LIMIT_PER_NODE=i.vn,exports.RECORD_GRAPH_MAX_LIMIT_PER_NODE=i.yn,exports.RECORD_GRAPH_MAX_NODES=i.bn,exports.RECORD_IMAGE_MAX_BYTES=i.An,exports.RECORD_LINKS_BLOCK=n.$,exports.RECORD_LINKS_CONTENT=n.et,exports.RECORD_LIST_SCOPES=e.h,exports.RECORD_OBJECT=n.at,exports.REFERENCE_KINDS=K,exports.RELATION_TARGET_ANY=n.rn,exports.REMOVED_OPERATOR_REPLACEMENTS=n.ht,exports.REPLY_MODES=i.$,exports.REQUEST_DESIGN_REVIEW_TOOL_NAME=i.Qn,exports.REQUEST_SETUP_TOOL_NAME=i.Bn,exports.RESERVED_ATTRIBUTE_NAMES=e.g,exports.RESERVED_OBJECT_NAMES=e._,exports.RESOURCE_GRANT_KINDS=i.vr,exports.RESOURCE_KIND_CATALOG=i.qt,exports.RESOURCE_VISIBILITIES=e.v,exports.ROUTING_PRICE_CEILINGS=i.Hr,exports.RealtimeDeliveryError=r.RealtimeDeliveryError,exports.RealtimeRateLimitedError=r.RealtimeRateLimitedError,exports.RealtimeSubscriptionError=r.RealtimeSubscriptionError,exports.RecordNotFoundError=r.RecordNotFoundError,exports.RecordQuery=n.st,exports.RecordReferencedError=r.RecordReferencedError,exports.RepositoryError=r.RepositoryError,exports.ReservedObjectNameError=r.ReservedObjectNameError,exports.RoleNotFoundError=r.RoleNotFoundError,exports.SCHEMA_LIMITS=e.p,exports.SCHEMA_SOURCE_ID_PATTERN=q,exports.SCHEMA_SOURCE_RETYPE_FROM=we,exports.SESSION_INFERENCE_PATCH_KEYS=i.Ur,exports.SETUP_SCRIPT_MAX_CHARS=i.un,exports.SIMPLE_PIPES=le,exports.SIMPLE_PROPERTY_TYPES=u.t,exports.SLACK_TRIGGER_CATALOG=i._t,exports.STANDARD_SCHEMA_VENDOR=H,exports.SURFACE_TOOL_NAMES=i.Jt,exports.SYNONYM_ALIASES=n.Ct,exports.SYSTEM_ATTRIBUTES=n.yn,exports.SYSTEM_ATTRIBUTE_I18N_KEYS=n.bn,exports.SYSTEM_EMAIL_CATEGORIES=i.Nt,exports.SYSTEM_EMAIL_CATEGORY_NAMES=i.Pt,exports.SYSTEM_FIELD_NAMES=e.y,exports.SYSTEM_FILTER_ATTRIBUTE_TYPES=n.gt,exports.SYSTEM_PART_CODES=i.Wr,exports.SchemaError=r.SchemaError,exports.SchemaErrorCode=r.SchemaErrorCode,exports.SearchBackendError=r.SearchBackendError,exports.SearchPathNotIndexedError=r.SearchPathNotIndexedError,exports.SingleRelationAttributeBuilder=SingleRelationAttributeBuilder,exports.StorageError=r.StorageError,exports.SyncCascadeError=r.SyncCascadeError,exports.SyncConflictError=r.SyncConflictError,exports.SyncError=r.SyncError,exports.SystemEntityImmutableError=r.SystemEntityImmutableError,exports.TASK_DEMAND_LEVELS=i.Gr,exports.TENANT_INVITATION_DEFAULT_TTL_MS=6048e5,exports.TENANT_INVITATION_MAX_TTL_MS=2592e6,exports.TENANT_INVITATION_MIN_TTL_MS=36e5,exports.TENANT_INVITATION_RESEND_INTERVAL_MS=6e4,exports.TEXT_BLOCK=n.tt,exports.TEXT_FORMAT_PATTERNS=a.n,exports.TODO_PLAN_STATUSES=i.Kr,exports.TODO_STATUSES=i.qr,exports.TOOL_APPROVAL_STATES=i.Jr,exports.TRIGGER_EVENT_TYPES=i.a,exports.TURN_OUTCOMES=i.Yr,exports.ToolGroupGrantError=r.ToolGroupGrantError,exports.UNSHAREABLE_OBJECT_NAMES=i.or,exports.USER_STATUSES=i.wn,exports.USER_WORK_POSTURES=i.Tn,exports.VERB_NAMES=i.Yt,exports.ValidationError=r.ValidationError,exports.ViewBuilder=U,exports.WIRE_OFFERED_BASE_CONFIG=u.n,exports.WIRE_OMITTED_CONFIG_KEYS=u.r,exports.agent=i.Tt,exports.agentAvatarFromMetadata=i.f,exports.agentAvatarSchema=i.p,exports.agentDataChunk=i.S,exports.agentDisplayName=i.Xr,exports.agentInferencePreferencesSchema=i.C,exports.agentMessageAttachmentSchema=i.w,exports.agentMessagePartSchema=i.T,exports.agentScheduleSchema=i.o,exports.agentSessionInferenceOverridesInputSchema=i.E,exports.agentSessionInferenceOverridesSchema=i.D,exports.agentSessionMessageSchema=i.O,exports.agentStartersSchema=i.m,exports.agentTriggerBaseSchema=i.s,exports.agentTriggerPatchSchema=i.c,exports.agentTriggerSchema=i.l,exports.agentUIValidationError=i.k,exports.applyPipes=applyPipes,exports.artifactQuoteSchema=i.A,exports.asTenantId=d.t,exports.asUserId=d.n,exports.askQuestionsOutputSchema=i.Vn,exports.assertCustomAgentUIMessageChunk=i.j,exports.assertSchemaSourceId=assertSchemaSourceId,exports.assertSchemaSourceResolutions=assertSchemaSourceResolutions,exports.assertSessionState=i.Zr,exports.attributeConfigSchemas=u.i,exports.attributeFilterTarget=n.Et,exports.attributeInventory=n.f,exports.blockObjectInputs=n.Kt,exports.buildPropertySchema=buildPropertySchema,exports.buildQualifiedAttribute=n.Xt,exports.canonicalStringify=d.s,exports.canonicalToolGroups=i.Xt,exports.canonicalizeFilterValue=n.Nt,exports.capabilityForResource=capabilityForResource,exports.capped=n.p,exports.checkbox=checkbox,exports.classificationRestoreSchema=i.h,exports.classifyEmailSchema=i.g,exports.cliDefaultModelOf=i.dn,exports.collectContentViewCatalogue=n.m,exports.collectQualifiedRuleIssues=n._t,exports.collectionContentSourceSchema=n.ut,exports.collectionSourceAddress=n.S,exports.collectionSourceAddressOf=n.C,exports.colorIdSchema=e.d,exports.columnsSchema=n.dt,exports.compareAgentSessionMessages=i.Qr,exports.compareSchemaStateEntries=compareSchemaStateEntries,exports.compareVersions=compareVersions,exports.compiledHarnessModels=i.fn,exports.computeByteMagnitude=computeByteMagnitude,exports.computeReconnectDelay=computeReconnectDelay,exports.computeRetryDelay=computeRetryDelay,exports.connectionGrantKindOf=i.Zt,exports.connectionGrantKindsOf=i.Qt,exports.connectorTriggerMatchSchema=i.vt,exports.content=_e,exports.contentDefinition=contentDefinition,exports.contentExtensionRegistry=n.z,exports.contentReadObjects=n.h,exports.contentViewDefinitionSchema=n.t,exports.contentViewDefinitionSchemaFor=n.n,exports.convertRetypedValue=convertRetypedValue,exports.createAttributeValidator=f.d,exports.createCheckboxValidator=c.createCheckboxValidator,exports.createDateValidator=l.createDateValidator,exports.createFormAttributeValidator=f.f,exports.createNumberValidator=s.createNumberValidator,exports.createStandardSchemaProps=createStandardSchemaProps,exports.createTextValidator=a.t,exports.currency=currency,exports.currentActor=n.Bt,exports.customDataChunkSchemas=i.M,exports.date=date,exports.declaredImageRequests=declaredImageRequests,exports.deepEqual=d.r,exports.defineBlock=n.qt,exports.defineDeviceChannelFrames=defineDeviceChannelFrames,exports.deriveLayout6=deriveLayout6,exports.deriveViewerAccess=i.sr,exports.detailView=detailView,exports.deviceChannelUrl=deviceChannelUrl,exports.diffSchemaState=diffSchemaState,exports.displayAttributesSchema=n.ft,exports.document=document,exports.draftContentViewDefinitionSchema=n.r,exports.draftContentViewDefinitionSchemaFor=n.i,exports.droppedContents=droppedContents,exports.durableDateSchema=i.N,exports.edgePropertyFilterTarget=n.Dt,exports.emailCategoryCreateSchema=i._,exports.emailCategoryDeleteSchema=i.v,exports.emailCategoryScopeQuerySchema=i.y,exports.emailCategoryUpdateSchema=i.b,exports.emailRuleScopeSchema=i.x,exports.environmentHarness=i.pn,exports.environmentWorkdir=i.mn,exports.extractAttributeNames=extractAttributeNames,exports.extractCurrencyFilterValue=n.Rt,exports.extractFilterValue=n.zt,exports.extractTouchedArtifacts=extractTouchedArtifacts,exports.extractTouchedDocuments=extractTouchedDocuments,exports.extractTouchedRecords=extractTouchedRecords,exports.filterOperatorsOfType=n.Ot,exports.filterStateSchema=n.pt,exports.filterTargetsOf=n.kt,exports.findEnvironmentHarness=i.hn,exports.findGrantIssues=findGrantIssues,exports.findGridViolation=n.L,exports.findGroupViolation=n.k,exports.findLayoutRuleViolation=n.A,exports.findRelationAttribute=n.T,exports.findRowLimitViolation=n.j,exports.form=form,exports.formFieldFlatKey=formFieldFlatKey,exports.formFieldKey=formFieldKey,exports.formatByteSize=formatByteSize,exports.formatNewsTarget=formatNewsTarget,exports.formatPhoneForDisplay=p.n,exports.formatReference=formatReference,exports.formatZodErrors=o.t,exports.formula=formula,exports.generateId=d.i,exports.getAttributeCapabilities=n.dn,exports.getAttributeConfigSchema=u.o,exports.getAttributeConfigWriteSchema=u.s,exports.getAttributeFilterOperators=n.fn,exports.getEditableLabelAttribute=getEditableLabelAttribute,exports.getOperatorPolarity=n.Pt,exports.getRollupFilterOperators=n.en,exports.getSingleAttributeFromExpression=getSingleAttributeFromExpression,exports.getSlotFieldTargets=getSlotFieldTargets,exports.getSystemAttributeI18nKey=n.xn,exports.getSystemAttributeList=n.Sn,exports.githubConditionSchema=i.yt,exports.githubTriggerMatchSchema=i.bt,exports.grantKindOf=i.$t,exports.gridPositionSchema=n.a,exports.group=group,exports.groupSizeMessage=n.M,exports.groupedMembers=n.N,exports.harnessModelChoices=i.gn,exports.hasLocale=hasLocale,exports.hasOptions=hasOptions,exports.humanRequestId=i.Hn,exports.humanRequestKind=i.Un,exports.iconNameSchema=e.f,exports.imageModelFormatDefect=imageModelFormatDefect,exports.imageModelIdSchema=i.P,exports.indexBy=d.a,exports.inferInverseCardinality=n.in,exports.inferenceReasoningSchema=i.F,exports.inferenceRoutingSchema=i.I,exports.inferenceSpeedSchema=i.L,exports.input=n.ot,exports.isActionableNotificationKind=t.T,exports.isAgentMessageMetadata=i.$r,exports.isAgentNotificationMetadata=i.ei,exports.isAgentUIDataName=i.R,exports.isAgentWrittenAuditEntry=i.nr,exports.isAttributeFilterable=n.pn,exports.isAttributeGroupable=n.mn,exports.isAttributeInUseError=r.isAttributeInUseError,exports.isAttributeKanbanGroupable=n.hn,exports.isAttributeSearchable=n.gn,exports.isAttributeSortable=n.an,exports.isAwaitingHuman=i.Wn,exports.isBilateralRelation=n.on,exports.isBlocking=i.Gn,exports.isCalendarDay=n.Wt,exports.isCatalogResource=isCatalogResource,exports.isDynamicValue=n.Vt,exports.isEmptyValue=f.p,exports.isEnvironmentHarnessId=i._n,exports.isFormDefinition=isFormDefinition,exports.isFormFieldsRow=isFormFieldsRow,exports.isFormFreeFieldRef=isFormFreeFieldRef,exports.isFormHeadingRow=isFormHeadingRow,exports.isFormSeparatorRow=isFormSeparatorRow,exports.isFormSlotFieldRef=isFormSlotFieldRef,exports.isFormTextRow=isFormTextRow,exports.isLabelExpression=isLabelExpression,exports.isLocationFilterProperty=n._n,exports.isLocationPartOperator=n.At,exports.isMailProvider=i.et,exports.isMailboxListMode=i.tt,exports.isManagedSystemAttribute=n.Cn,exports.isNativeObjectName=e.C,exports.isNativeToolGroup=i.en,exports.isNoValueOperator=n.tn,exports.isNotFoundError=r.isNotFoundError,exports.isNullishOrEmptyString=f.m,exports.isObjectReferencedError=r.isObjectReferencedError,exports.isOpenToolPartState=i.ti,exports.isParkedOnHuman=i.Kn,exports.isPlainRecord=e.u,exports.isProtectedResourceError=r.isProtectedResourceError,exports.isProviderDraft=i.nt,exports.isPublicMailDomain=i.Ft,exports.isRecordReferencedError=r.isRecordReferencedError,exports.isRelativeDateValue=n.yt,exports.isReplyMode=i.rt,exports.isResourceGrant=i.tn,exports.isRoutineActorMetadata=i.ni,exports.isSchemaError=r.isSchemaError,exports.isSemver=isSemver,exports.isSessionInferencePatch=i.z,exports.isSetMembershipOperator=n.Ft,exports.isStandardSchema=isStandardSchema,exports.isSystemEmailCategory=i.It,exports.isSystemEmailCategoryName=i.Lt,exports.isSystemPartCode=i.ri,exports.isToolApprovalState=i.ii,exports.isUniversalRelation=n.sn,exports.isValidationError=r.isValidationError,exports.isValuePresent=f.h,exports.isWherePipe=isWherePipe,exports.isWildcard=isWildcard,exports.judgePreferenceWrite=judgePreferenceWrite,exports.keptFill=keptFill,exports.labelExpressionSchema=j,exports.layoutTraitsOf=n.c,exports.levelActions=levelActions,exports.levelFloor=levelFloor,exports.levelOf=levelOf,exports.listView=listView,exports.locatePreference=locatePreference,exports.location=location,exports.locationPartFilterTarget=n.jt,exports.meetingBotDispatchRequestSchema=i.dt,exports.meetingBotDispatchResponseSchema=i.ft,exports.meetingBotNotificationSchema=i.pt,exports.meetingTranscriptSegmentSchema=i.mt,exports.memberlessGroups=n.P,exports.memoryPageViewOf=memoryPageViewOf,exports.mentionReferenceSchema=i.B,exports.mergeSessionInferencePatch=i.ai,exports.metricComparePeriod=n.nt,exports.modelDefinitionSchema=i.V,exports.modelIdentitySchema=Pe,exports.modelReferenceSchema=i.H,exports.multiselect=multiselect,exports.multiselectOptionWriteSchema=u.c,exports.nameSlug=nameSlug,exports.namedTargetSchema=Oe,exports.nativeAgentUIPartIdMetadataKey=nativeAgentUIPartIdMetadataKey,exports.needsManageWhenUnattended=i.nn,exports.normalizeCountrylessPhoneNumber=p.i,exports.normalizeFilterRule=n.wt,exports.normalizeForEdgeRpc=n.It,exports.normalizeNewsLocale=normalizeNewsLocale,exports.normalizeOperator=n.Tt,exports.normalizePhoneNumber=p.a,exports.normalizedMeetingTranscriptSchema=i.ht,exports.now=n.Ht,exports.number=number,exports.object=object,exports.openRequests=i.qn,exports.orderAgentSessionMessages=i.oi,exports.packLayout=packLayout,exports.page=page,exports.pageCompactor=pageCompactor,exports.pageTraitsOf=n.l,exports.parseAgentDefinitionAccessRole=i.cr,exports.parseAttributeConfig=u.l,exports.parseAttributeConfigForCreate=u.u,exports.parseAttributeConfigForUpdate=u.d,exports.parseBlockParameters=n.Jt,exports.parseCountMode=parseCountMode,exports.parseDeviceChannelFrame=parseDeviceChannelFrame,exports.parseMergedAgentTrigger=i.u,exports.parseNamedTarget=parseNamedTarget,exports.parseNativeAgentUIPartIdsMetadata=parseNativeAgentUIPartIdsMetadata,exports.parseNewsBody=parseNewsBody,exports.parseNewsIndex=parseNewsIndex,exports.parseNewsIntensity=parseNewsIntensity,exports.parseNewsTarget=parseNewsTarget,exports.parseOptionalCountMode=parseOptionalCountMode,exports.parsePageAccessRole=i.lr,exports.parseQualifiedAttribute=n.Zt,exports.parseRecordAccessRole=i.ur,exports.parseRecordListScope=e.b,exports.parseReference=parseReference,exports.parseResourceVisibility=e.x,exports.parseSchemaGroupPresentation=parseSchemaGroupPresentation,exports.parseSchemaState=parseSchemaState,exports.parseServerFrame=parseServerFrame,exports.parseToolGroupGrant=i.rn,exports.parseWherePipe=parseWherePipe,exports.parseWorkerFrame=parseWorkerFrame,exports.permissionGrantSchema=B,exports.phone=phone,exports.placeNew=placeNew,exports.preference=preference,exports.preferenceEntry=preferenceEntry,exports.propertyAttributeSchema=u.f,exports.propertyAttributeWireSchema=u.p,exports.propertySchemaSchema=u.m,exports.propertySchemaWireSchema=u.h,exports.providerNameSchema=i.U,exports.publishedViewContentDefinitionSchema=n.o,exports.query=n.ct,exports.readArtifactResult=readArtifactResult,exports.readAskQuestionsResult=i.Jn,exports.readFormFieldValue=readFormFieldValue,exports.readGeneratedImageResult=readGeneratedImageResult,exports.recentActivityEntryKey=i.Mn,exports.recordGraphNodeKey=i.xn,exports.recordGraphRequestSchema=i.Sn,exports.recordLinksTab=recordLinksTab,exports.recordOperationSchema=i.n,exports.recordQueryDefinitionSchema=n.lt,exports.refineTrigger=i.d,exports.refuseForeignKeys=u.g,exports.rejectUnknownAttributesOrThrow=f.r,exports.relation=relation,exports.relationAcceptsObject=n.E,exports.relationProperty=relationProperty,exports.relationTargetsOf=n.cn,exports.renderLabelExpression=renderLabelExpression,exports.repairPageGrid=repairPageGrid,exports.requestedCapabilities=requestedCapabilities,exports.requireRecordContentContext=n.y,exports.requireSingleRelationTarget=n.D,exports.resolveAppearance=resolveAppearance,exports.resolveCollectionActions=n.b,exports.resolveContentNavigation=n.x,exports.resolveEffectiveFilterType=n.vn,exports.resolveFieldRequired=resolveFieldRequired,exports.resolveIsWithinBounds=n.bt,exports.resolveLocalized=resolveLocalized,exports.resolvePageGrid=resolvePageGrid,exports.resolvePropertyDefinitions=resolvePropertyDefinitions,exports.resolveTextPattern=a.r,exports.resolveUtcDayBounds=n.xt,exports.resolveViewContents=resolveViewContents,exports.resourceGrant=i.in,exports.richtext=richtext,exports.rollup=rollup,exports.routedMessageInferenceSchema=i.W,exports.sameActions=sameActions,exports.sameStableValue=d.c,exports.schemaGroupKey=schemaGroupKey,exports.schemaStateSourcePayload=schemaStateSourcePayload,exports.select=select,exports.selectOptionWriteSchema=u._,exports.serializeCanonicalJson=d.l,exports.serializeStableJson=d.u,exports.sessionInferencePatchSchema=i.G,exports.settleLayout=settleLayout,exports.singleRelationTarget=n.O,exports.slackConditionSchema=i.xt,exports.slackTriggerMatchSchema=i.St,exports.snapWidth=snapWidth,exports.sortsSchema=n.mt,exports.sourcedAttributeOf=n.w,exports.status=status,exports.statusGroupSchema=u.v,exports.statusOptionWriteSchema=u.y,exports.storedContentDefinition=storedContentDefinition,exports.systemColumnFilterTarget=n.Mt,exports.text=text,exports.toMultiValueOperator=n.Lt,exports.toUtcDayString=n.St,exports.today=n.Ut,exports.todoItemSchema=i.K,exports.todoPlanSchema=i.q,exports.toolImpactSchema=i.J,exports.user=user,exports.validateAttribute=f.i,exports.validateAttributeName=e.i,exports.validateContentViewCatalogue=n._,exports.validateDraft=f.a,exports.validateDraftOrThrow=f.o,exports.validateLabelExpression=validateLabelExpression,exports.validateObject=f.s,exports.validateObjectExpressions=validateObjectExpressions,exports.validateObjectName=e.s,exports.validateObjectOrThrow=f.c,exports.validateQualifiedRule=n.vt,exports.validateStoredViews=n.v,exports.validateViewName=e.l,exports.widthStepConstraint=widthStepConstraint,exports.wireHiddenTypeConfigMask=u.b,exports.wireOmittedConfigKeysFor=u.x,exports.withPreferenceEntry=withPreferenceEntry,exports.withoutTrailingSlashes=withoutTrailingSlashes,exports.withoutUnknownOptionKeys=u.S,exports.workspaceViewAuthoring=workspaceViewAuthoring;
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ /*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
2
+ import{C as e,S as t,T as n,_ as r,a as i,b as a,c as o,d as s,f as c,g as l,h as u,i as d,l as f,m as p,n as m,o as h,p as ee,r as te,s as ne,t as re,u as ie,v as ae,w as oe,x as se,y as ce}from"./record-aggregates-CzG86pUS.mjs";import{$ as le,$t as ue,A as de,At as fe,B as g,Bt as pe,C as me,Cn as he,Ct as ge,D as _e,Dt as ve,E as ye,Et as be,F as _,Ft as xe,G as Se,Gt as Ce,H as v,Ht as we,I as Te,It as Ee,J as De,Jt as y,K as Oe,Kt as ke,L as Ae,Lt as je,M as Me,Mt as Ne,N as Pe,Nt as Fe,O as Ie,Ot as Le,P as b,Pt as Re,Q as ze,Qt as Be,R as Ve,Rt as He,S as Ue,Sn as We,St as Ge,T as Ke,Tt as qe,U as x,Ut as Je,V as Ye,Vt as Xe,W as Ze,Wt as Qe,X as $e,Xt as et,Y as tt,Yt as nt,Z as S,Zt as rt,_ as it,_n as at,_t as ot,a as st,an as ct,at as lt,b as ut,bn as dt,bt as ft,c as pt,cn as mt,ct as ht,d as gt,dn as _t,dt as vt,en as yt,et as C,f as bt,fn as xt,ft as St,g as Ct,gn as wt,gt as Tt,h as Et,hn as Dt,ht as Ot,i as kt,in as At,it as jt,j as Mt,jt as Nt,k as Pt,kt as Ft,l as It,ln as Lt,lt as Rt,m as zt,mn as Bt,mt as Vt,n as Ht,nn as Ut,nt as Wt,o as w,on as Gt,ot as Kt,p as qt,pn as Jt,pt as Yt,q as Xt,qt as Zt,r as Qt,rn as $t,rt as en,s as tn,sn as nn,st as rn,t as T,tn as an,tt as E,u as on,un as sn,ut as cn,v as ln,vn as un,vt as dn,w as fn,wt as pn,x as mn,xn as hn,xt as gn,y as _n,yn as vn,yt as yn,z as D,zt as bn}from"./view-config.schema-BmjCQJ51.mjs";import{AccessDeniedError as xn,AggregateValidationError as Sn,AmbiguousSchemaChangeError as Cn,AttributeInUseError as wn,AttributeNotFoundError as Tn,ConcurrentModificationError as En,DuplicateError as Dn,ExportTooLargeError as On,ForbiddenError as kn,InvalidPermissionGrantError as An,MemoryNotFoundError as jn,NotFoundError as Mn,NotImplementedError as Nn,ObjectNotFoundError as Pn,ObjectReferencedError as Fn,OrphanSystemAttributeError as In,PageReferencedError as Ln,ProtectedResourceError as Rn,ProtectedRoleError as zn,QueryTimeoutError as Bn,RealtimeDeliveryError as Vn,RealtimeRateLimitedError as Hn,RealtimeSubscriptionError as Un,RecordNotFoundError as Wn,RecordReferencedError as Gn,RepositoryError as Kn,ReservedObjectNameError as qn,RoleNotFoundError as Jn,SchemaError as O,SchemaErrorCode as k,SearchBackendError as Yn,SearchPathNotIndexedError as Xn,StorageError as Zn,SyncCascadeError as Qn,SyncConflictError as $n,SyncError as er,SystemEntityImmutableError as tr,ToolGroupGrantError as nr,ValidationError as A,isAttributeInUseError as rr,isNotFoundError as ir,isObjectReferencedError as ar,isProtectedResourceError as or,isRecordReferencedError as sr,isSchemaError as cr,isValidationError as lr}from"./exceptions.mjs";import{$ as ur,$n as dr,$r as fr,$t as pr,A as mr,An as hr,Ar as gr,At as _r,B as vr,Bn as yr,Br as br,Bt as xr,C as Sr,Cn as Cr,Cr as wr,Ct as Tr,D as Er,Dn as Dr,Dr as Or,Dt as kr,E as Ar,En as jr,Er as Mr,Et as Nr,F as Pr,Fn as Fr,Fr as Ir,Ft as Lr,G as Rr,Gn as zr,Gr as Br,Gt as Vr,H as Hr,Hn as Ur,Hr as Wr,Ht as Gr,I as Kr,In as qr,Ir as Jr,It as Yr,J as Xr,Jn as Zr,Jr as Qr,Jt as $r,K as ei,Kn as ti,Kr as ni,Kt as ri,L as ii,Ln as ai,Lr as oi,Lt as si,M as ci,Mn as li,Mr as ui,Mt as di,N as fi,Nn as pi,Nr as mi,Nt as hi,O as gi,On as _i,Or as vi,Ot as yi,P as bi,Pn as xi,Pr as Si,Pt as Ci,Q as wi,Qn as Ti,Qr as Ei,Qt as Di,R as Oi,Rn as ki,Rr as Ai,Rt as ji,S as Mi,Sn as Ni,Sr as Pi,St as Fi,T as Ii,Tn as Li,Tr as Ri,Tt as zi,U as Bi,Un as Vi,Ur as Hi,Ut as Ui,V as Wi,Vn as Gi,Vr as Ki,Vt as qi,W as Ji,Wn as Yi,Wr as Xi,Wt as Zi,X as Qi,Xn as $i,Xr as ea,Xt as ta,Y as na,Yn as ra,Yr as ia,Yt as aa,Z as oa,Zn as sa,Zr as ca,Zt as la,_ as ua,_n as da,_r as fa,_t as pa,a as ma,ai as ha,an as ga,ar as _a,at as va,b as ya,bn as ba,br as xa,bt as Sa,c as Ca,cn as wa,cr as Ta,ct as Ea,d as Da,dn as Oa,dr as ka,dt as Aa,ei as ja,en as Ma,er as Na,et as Pa,f as Fa,fn as Ia,fr as La,ft as Ra,g as za,gn as Ba,gr as Va,gt as Ha,h as Ua,hn as Wa,hr as Ga,ht as Ka,i as qa,ii as Ja,in as Ya,ir as Xa,it as Za,j as Qa,jn as $a,jr as eo,jt as to,k as no,kn as ro,kr as io,kt as ao,l as oo,ln as so,lr as co,lt as lo,m as uo,mn as fo,mr as po,mt as mo,n as ho,ni as go,nn as _o,nr as vo,nt as yo,o as bo,oi as xo,on as So,or as Co,ot as wo,p as To,pn as Eo,pr as Do,pt as Oo,q as ko,qn as Ao,qr as jo,qt as Mo,r as No,ri as Po,rn as Fo,rr as Io,rt as Lo,s as Ro,sn as zo,sr as Bo,st as Vo,t as Ho,ti as Uo,tn as Wo,tr as Go,tt as Ko,u as qo,un as Jo,ur as Yo,ut as Xo,v as Zo,vn as Qo,vr as $o,vt as es,w as ts,wn as ns,wr as rs,wt as is,x as as,xn as os,xr as ss,xt as cs,y as ls,yn as us,yr as ds,yt as fs,z as ps,zn as ms,zr as hs,zt as gs}from"./record-operation-C9oXHmfF.mjs";import{C as _s,S as vs,_ as ys,a as bs,b as xs,c as j,d as Ss,f as M,g as Cs,h as ws,i as Ts,l as Es,m as Ds,n as Os,o as ks,p as N,r as As,s as js,t as Ms,u as Ns,v as Ps,x as Fs,y as Is}from"./attribute-validators-DRqhAt2t.mjs";import{n as Ls,r as Rs,t as zs}from"./text-C8Lb-NFo.mjs";import{n as Bs,t as Vs}from"./core-BLHhNykL.mjs";import{createNumberValidator as Hs}from"./validation/primitives/number.mjs";import{createCheckboxValidator as Us}from"./validation/primitives/checkbox.mjs";import{createDateValidator as Ws}from"./validation/primitives/date.mjs";import{C as Gs,S as Ks,_ as qs,a as Js,b as Ys,c as Xs,d as Zs,f as Qs,g as $s,h as ec,i as tc,l as nc,m as rc,n as ic,o as ac,p as oc,r as sc,s as cc,t as lc,u as uc,v as dc,x as fc,y as pc}from"./config-BIxnbUN8.mjs";import{a as mc,c as hc,i as gc,l as _c,n as vc,o as yc,r as bc,s as P,t as xc,u as Sc}from"./utils-fXIvFFl6.mjs";import{a as Cc,c as wc,d as Tc,f as Ec,h as Dc,i as Oc,m as kc,o as Ac,p as jc,r as Mc,s as Nc,u as Pc}from"./object-Dzl7sfq8.mjs";import{a as Fc,i as Ic,n as Lc,r as Rc}from"./phone-Bca_xiOX.mjs";import{z as F}from"zod";import{colorIdFromString as zc,getCountryByIso2 as Bc,isValidCurrencyCode as Vc,isValidIso3 as Hc}from"@standards/constants";import{parsePhoneNumberFromString as Uc}from"libphonenumber-js";const Wc=`__stndrdsNativeUiPartIds`,Gc=1;function invalidNativePartIds(){throw new A(`Native agent UI part IDs metadata is invalid`,[])}function isPlainRecord$1(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function nativeAgentUIPartIdMetadataKey(e,t){if(e.type===`text`||e.type===`reasoning`)return`${e.type}:${t}`;if(e.type===`tool`)return`tool:${e.toolCallId}`}function parseNativeAgentUIPartIdsMetadata(e){let t=e.metadata?.[Wc];isPlainRecord$1(t)||invalidNativePartIds(),(Object.keys(t).length!==2||t.schemaVersion!==1||!isPlainRecord$1(t.partIds))&&invalidNativePartIds();let n=new Map;for(let[t,r]of e.parts.entries()){let e=nativeAgentUIPartIdMetadataKey(r,t);if(!e||n.has(e)){e&&invalidNativePartIds();continue}n.set(e,r)}let r=Object.entries(t.partIds);r.length!==n.size&&invalidNativePartIds();let i=new Map,a={};for(let[e,t]of r){let r=n.get(e);r&&typeof t==`string`&&t.length>0||invalidNativePartIds();let o=i.get(t);o&&(r.type===`tool`||o!==r.type)&&invalidNativePartIds(),r.type===`tool`&&t!==r.toolCallId&&invalidNativePartIds(),i.set(t,r.type),a[e]=t}return a}const Kc=`/v1/device-worker/channel`,qc=262144,Jc=15e4,Yc=1e4,Xc=2e3,Zc=2e3,Qc=2e4,$c=4008,el={initialMs:1e3,maxMs:3e4};function deviceChannelUrl(e){let t=new URL(e);return`${t.protocol===`https:`?`wss:`:`ws:`}//${t.host}${Kc}`}function computeRetryDelay(e,t,n){return Math.min(n.initialMs*2**e,n.maxMs)+Math.floor(t()*250)}function computeReconnectDelay(e,t=Math.random){return computeRetryDelay(e,t,el)}const tl=[`worker_disconnected`,`cancelled`,`timed_out`,`execution_failed`,`stale_reference`,`tab_unavailable`,`debugger_unavailable`,`blocked_by_user`,`not_actionable`,`javascript_error`,`batch_cap_exceeded`,`no_reference_screenshot`],nl=`UPGRADE_REQUIRED`;var DeviceChannelProtocolError=class extends O{constructor(e){super(e,k.DEVICE_CHANNEL_PROTOCOL),this._tag=`DeviceChannelProtocolError`,this.name=`DeviceChannelProtocolError`}};const I={id:F.uuid(),leaseToken:F.string().min(1)},rl=F.record(F.string(),F.unknown());function defineDeviceChannelFrames(e){return{worker:F.discriminatedUnion(`type`,[F.strictObject({type:F.literal(`authenticate`),credential:F.string().regex(/^(Device|Bearer) \S+$/),protocol:F.number().int().positive().optional()}),F.strictObject({type:F.literal(`running`),...I}),F.strictObject({type:F.literal(`heartbeat`),...I}),F.strictObject({type:F.literal(`output`),...I,stdout:F.string().optional(),stderr:F.string().optional()}),F.strictObject({type:F.literal(`complete`),...I,result:F.strictObject({stdout:F.string().optional(),stderr:F.string().optional(),exitCode:F.number().int(),success:F.boolean(),errorCode:F.enum(tl).optional(),result:e.result.optional()})}),F.strictObject({type:F.literal(`pong`)})]),server:F.discriminatedUnion(`type`,[F.strictObject({type:F.literal(`ready`),device:F.strictObject({id:F.string(),name:F.string(),capability:F.enum([`shell`,`browser`])}),protocol:F.number().int().positive().optional()}),F.strictObject({type:F.literal(`command`),...I,kind:F.enum([`shell`,`browser`]),intent:F.string(),timeoutMs:F.number().int(),command:F.string().optional(),cwd:F.string().nullable().optional(),action:e.action.optional()}),F.strictObject({type:F.literal(`cancel`),id:F.uuid(),reason:F.enum([`cancelled`,`timed_out`,`revoked`])}),F.strictObject({type:F.literal(`reauthenticate`)}),F.strictObject({type:F.literal(`revoked`)}),F.strictObject({type:F.literal(`ping`)})])}}const il=defineDeviceChannelFrames({action:rl,result:rl}),al=il.worker,ol=il.server;function parseDeviceChannelFrame(e,t){let n;try{n=JSON.parse(t)}catch{throw new DeviceChannelProtocolError(`Frame is not JSON`)}let r=e.safeParse(n);if(!r.success)throw new DeviceChannelProtocolError(`Frame does not match the channel protocol`);return r.data}function parseWorkerFrame(e){return parseDeviceChannelFrame(al,e)}function parseServerFrame(e){return parseDeviceChannelFrame(ol,e)}const sl=5;function isFormDefinition(e){return typeof e==`object`&&!!e&&`slots`in e&&`steps`in e&&`name`in e&&typeof e.name==`string`&&Array.isArray(e.slots)&&Array.isArray(e.steps)}const L=[`relation`,`multiRelation`,`formula`,`rollup`,`document`,`richtext`,`user`];function isFormSlotFieldRef(e){return e.type===`slot`}function isFormFreeFieldRef(e){return e.type===`free`}function resolveFieldRequired(e){return e.readOnly===!0?!1:e.fieldRequired===void 0?e.slotMode===`create`&&e.attributeRequired===!0:e.fieldRequired}function getSlotFieldTargets(e){return e.additionalSlotIds?.length?[e.slotId,...e.additionalSlotIds]:[e.slotId]}function formFieldKey(e){return isFormSlotFieldRef(e)?`${e.slotId}.${e.attribute}`:`free.${e.attribute.name}`}function formFieldFlatKey(e){return isFormSlotFieldRef(e)?e.attribute:e.attribute.name}function readFormFieldValue(e,t){return e[formFieldKey(t)]??e[formFieldFlatKey(t)]}function isFormFieldsRow(e){return e.type===`fields`}function isFormHeadingRow(e){return e.type===`heading`}function isFormSeparatorRow(e){return e.type===`separator`}function isFormTextRow(e){return e.type===`text`}function resolvePropertyDefinitions(e){let t=e.properties;if(!t)return[];if(Array.isArray(t))return t;let n=t;return Array.isArray(n.definitions)?n.definitions:[]}function hasOptions(e){return e.type===`select`||e.type===`status`||e.type===`multiselect`}function schemaGroupKey(e){return`${e.kind}:${e.id}`}function refuse$2(e,t){throw new A(t,[{path:[e],message:t}])}function parseSchemaGroupPresentation(e){let t=e??{},n={};if(t.label!==void 0){let e=t.label;if(e===null)n.label=null;else if(typeof e!=`string`)refuse$2(`label`,`Label must be a string`);else{let t=e.trim();t.length===0&&refuse$2(`label`,`Label must not be empty`),t.length>N.labelLength&&refuse$2(`label`,`Label is too long (max ${N.labelLength} characters)`),n.label=t}}if(t.icon!==void 0){let e=t.icon;if(e===null)n.icon=null;else{let t=M.safeParse(e);t.success||refuse$2(`icon`,`Invalid icon name`),n.icon=t.data}}return n}const R=[`none`,`estimated`,`exact`];function parseCountMode(e){if(typeof e==`string`&&R.includes(e))return e;throw new A(`countMode must be one of: ${R.join(`, `)} (received: ${String(e)})`,[])}function parseOptionalCountMode(e){return e===void 0?void 0:parseCountMode(e)}const cl=1e4,ll=16e3,ul=3200,dl=6400,fl=16e3,pl=65536,ml=15e3,hl=1e4,gl=5e3,_l=`google/gemini-3.5-transcribe-live`,vl={maxDurationMs:3e5,dailyDurationMs:36e5,monthlyDurationMs:72e6,tenantMonthlyBudgetMicrousd:5e7,globalMonthlyBudgetMicrousd:5e7,estimatedMicrousdPerSecond:150,reservationMultiplier:2},yl=[`web`,`presentation`,`document`,`spreadsheet`,`image`,`code`,`other`],bl=[`ephemeral`,`conversation`,`persistent`],xl=[`source`,`preview`,`entrypoint`,`asset`];var NoopGeocodingAdapter=class{async autocomplete(){return await Promise.resolve([])}async geocode(){return await Promise.resolve(null)}};const Sl=6048e5,Cl=36e5,wl=2592e6,Tl=6e4,El=[`square`,`landscape`,`portrait`];function imageModelFormatDefect(e){if(e.formats.length===0)return`declares no output format`;for(let t of e.formats)if(e.requests[t]===void 0)return`declares the format "${t}" without a request`;for(let t of Object.keys(e.requests))if(!e.formats.includes(t))return`carries a request for the undeclared format "${t}"`}function declaredImageRequests(e){let t={};for(let n of e.formats){let r=e.requests[n];r!==void 0&&(t[n]=r)}return t}const Dl=[`storage.bytes`,`members.seats`,`data.live_records`];function computeByteMagnitude(e){if(e<=0)return{value:0,unitIndex:0};let t=1e3,n=Math.min(4,Math.floor(Math.log(e)/Math.log(t)));return{value:Number.parseFloat((e/t**n).toFixed(1)),unitIndex:n}}const Ol=[`B`,`KB`,`MB`,`GB`,`TB`];function formatByteSize(e){let{value:t,unitIndex:n}=computeByteMagnitude(e);return`${t} ${Ol[n]}`}const kl=Object.freeze([`text`,`number`,`checkbox`,`date`,`phone`,`currency`,`status`,`select`,`multiselect`,`location`]);function buildPropertySchema(e){let t=[];for(let n of e){let e=n.build();if(!kl.includes(e.type))throw Error(`Property type "${e.type}" is not supported in .qualifyWith()`);t.push(e)}return{definitions:t}}const Al=[`UPPER`,`LOWER`,`capitalize`,`trim`],jl=[`prefix`,`suffix`,`wrap`,`default`],z=[...Al,...jl],Ml=/^\s*where\s*(?::(.*))?$/s,Nl=`[A-Za-z_][A-Za-z0-9_]*`,Pl=/^[^\s,()|{}="']+$/,Fl=RegExp(`^(${Nl})\\s*=\\s*(.*)$`),Il=RegExp(`^(${Nl})\\s+in\\s*\\(([^()]*)\\)$`);function isWherePipe(e){return Ml.test(e)}function parseWherePipe(e){let t=e.match(Ml)?.[1]?.trim();if(!t)return null;let n=t.match(Il);if(n){let e=n[2].split(`,`).map(e=>e.trim());return e.every(e=>Pl.test(e))?{property:n[1],values:e}:null}let r=t.match(Fl);return r&&Pl.test(r[2])?{property:r[1],values:[r[2]]}:null}const B=F.string().min(1,`labelExpression cannot be empty`).refine(e=>isLabelExpression(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,n;for(;(n=t.exec(e))!==null;){let e=n[1];if(!z.includes(e))return!1}return!0},{message:`Invalid pipe name. Valid pipes: ${z.join(`, `)}`});function validateLabelExpression(e){let t=B.safeParse(e);return t.success?{success:!0,attributes:extractAttributeNames(e)}:{success:!1,error:t.error.issues[0]?.message??`Invalid labelExpression`}}function applyPipe(e,t){let{name:n,args:r}=parsePipeExpression(t);switch(n){case`UPPER`:return e.toUpperCase();case`LOWER`:return e.toLowerCase();case`capitalize`:return e.replace(/(^|\s)\S/g,e=>e.toUpperCase());case`trim`:return e.trim();case`prefix`:return e?`${r[0]??``}${e}`:``;case`suffix`:return e?`${e}${r[0]??``}`:``;case`wrap`:return e?`${r[0]??``}${e}${r[1]??``}`:``;case`default`:return e||r[0]||``;default:return e}}function applyPipes(e,t){let n=e;for(let e of t)n=applyPipe(n,e);return n}function getValue(e,t){return t.split(`.`).reduce((e,t)=>{if(typeof e==`object`&&e)return e[t]},e)}const Ll=`(Untitled)`;function parsePipeExpression(e){let t=e.match(/^(\w+)(?::(.*))?$/);if(!t)return{name:e,args:[]};let n=t[1],r=t[2];if(!r)return{name:n,args:[]};let i=[],a=/["']([^"']*?)["']/g,o;for(;(o=a.exec(r))!==null;)i.push(o[1]);return{name:n,args:i}}function*templateBlocks(e){let t=0;for(;t<e.length;){let n=e.indexOf(`{{`,t);if(n<0)return;let r=e.indexOf(`}`,n+2);if(r<0)return;if(e[r+1]!==`}`){t=r+1;continue}t=r+2;let i=e.slice(n+2,r);i.length>0&&(yield{start:n,end:t,expr:i})}}function resolveLabelBlock(e,t){let n=e.split(`||`).map(e=>e.trim()),r=n[n.length-1].split(`|`).map(e=>e.trim());n[n.length-1]=r[0];let i=r.slice(1).filter(Boolean),a=n.filter(Boolean),o=``;for(let e of a){let n=toText(getValue(t,e));if(n!==``){o=n;break}}return applyPipes(o,i)}function renderLabelExpression(e,t,n=Ll){let r=[],i=0;for(let n of templateBlocks(e))r.push(e.slice(i,n.start),resolveLabelBlock(n.expr,t)),i=n.end;return r.push(e.slice(i)),r.join(``).trim()||n}function toText(e){if(e==null||typeof e==`function`)return``;if(typeof e!=`object`)return String(e);if(Array.isArray(e))return e.map(toText).filter(Boolean).join(`,`);let t=e.toString;return typeof t==`function`&&t!==Object.prototype.toString?String(e):``}function isLabelExpression(e){let t=0;for(;t<e.length;){let n=e.indexOf(`{{`,t);if(n<0)return!1;let r=e.indexOf(`}}`,n+2);if(r<0)return!1;if(e.slice(n+2,r).trim().length>0)return!0;t=r+2}return!1}function extractAttributeNames(e){let t=[];for(let n of templateBlocks(e)){let e=n.expr.trim();if(!e)continue;let r=e.split(`||`).map(e=>e.trim()),i=r[r.length-1];r[r.length-1]=i.split(`|`)[0].trim();for(let e of r){if(!e)continue;let n=e.split(`.`)[0];n&&!t.includes(n)&&t.push(n)}}return t}const Rl=/^\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}$/;function getSingleAttributeFromExpression(e){let t=e.trim().match(Rl);return t?t[1]:null}function getEditableLabelAttribute(e,t){let n=getSingleAttributeFromExpression(e);if(n===null)return null;let r=t.find(e=>e.name===n);return!r||r.type!==`text`||_t(r).authoring.readOnly?null:r}const zl=[{id:`data`,capabilities:[{id:`forms`,resources:[`forms`],levels:[{id:`fill`,add:[`read`]},{id:`edit`,add:[`create`,`update`,`delete`]},{id:`manage`,add:[`manage`]}]}]},{id:`structure`,capabilities:[{id:`schema`,resources:[`architect`],levels:[{id:`use`,add:[`read`]},{id:`edit`,add:[`create`,`update`,`delete`]}]},{id:`pages`,resources:[`pages`],levels:[{id:`read`,add:[`read`]},{id:`create`,add:[`create`,`update`,`delete`]}]}]},{id:`ai`,capabilities:[{id:`agents`,resources:[`agents`],levels:[{id:`chat`,add:[`read`]},{id:`build`,add:[`create`,`update`,`delete`]},{id:`manage`,add:[`manage`]}]},{id:`environments`,resources:[`environments`],levels:[{id:`use`,add:[`read`]},{id:`create`,add:[`create`]}]},{id:`browser-profiles`,resources:[`browser-profiles`],levels:[{id:`use`,add:[`create`]}]},{id:`routine-audiences`,resources:[`routine-audiences`],levels:[{id:`use`,add:[`create`]}]}]},{id:`files`,capabilities:[{id:`files`,resources:[`files`,`documents`],levels:[{id:`read`,add:[`read`]},{id:`edit`,add:[`create`,`update`]},{id:`full`,add:[`delete`]}]}]},{id:`team`,capabilities:[{id:`people`,resources:[`people`],levels:[{id:`view`,add:[`read`]},{id:`invite`,add:[`create`]},{id:`manage`,add:[`update`,`delete`]}]}]},{id:`integrations`,capabilities:[{id:`connectors`,resources:[`connectors`],levels:[{id:`use`,add:[`read`,`create`,`update`,`delete`]}]},{id:`api-keys`,resources:[`api-keys`],levels:[{id:`view`,add:[`read`]},{id:`manage`,add:[`create`,`delete`]}]},{id:`env-vars`,resources:[`env-vars`],levels:[{id:`view`,add:[`read`]},{id:`manage`,add:[`create`,`delete`]}]}]},{id:`administration`,capabilities:[{id:`settings`,resources:[`settings`],levels:[{id:`view`,add:[`read`]},{id:`manage`,add:[`update`,`delete`,`manage`]}]},{id:`audit`,resources:[`audit`],levels:[{id:`view`,add:[`read`]}]},{id:`billing`,resources:[`billing`],levels:[{id:`view`,add:[`read`]}]}]}],V=`none`,Bl=`custom`,H={actions:[`read`,`create`,`update`,`delete`],purge:`manage`,levels:[{id:`read`,add:[`read`]},{id:`edit`,add:[`create`,`update`]},{id:`full`,add:[`delete`]}]},U=zl.flatMap(e=>e.capabilities),Vl=U.flatMap(e=>e.resources),Hl=new Map(U.flatMap(e=>e.resources.map(t=>[t,e])));function isCatalogResource(e){return Hl.has(e)}function capabilityForResource(e){let t=Hl.get(e);if(!t)throw new O(`Unknown catalog resource "${e}"`,k.INVARIANT_VIOLATION);return t}function sameActions(e,t){let n=new Set(e),r=new Set(t);return n.size===r.size&&[...n].every(e=>r.has(e))}function levelActions(e,t){let n=new Set;for(let r of e.levels){for(let e of r.add)n.add(e);if(r.id===t)return[...n]}return[]}function levelFloor(e,t){let n=e.levels[e.levels.length-1];if(t.includes(`*`)&&n)return n.id;let r=new Set(t),i=V;for(let t of e.levels){if(!t.add.every(e=>r.has(e)))break;i=t.id}return i}function levelOf(e,t){if(t.length===0)return V;let n=e.levels[e.levels.length-1];if(t.includes(`*`)&&n)return n.id;let r=new Set(t),i=new Set;for(let t of e.levels){for(let e of t.add)i.add(e);if(i.size===r.size&&[...r].every(e=>i.has(e)))return t.id}return Bl}const Ul=[`read`,`create`,`update`,`delete`,`manage`],Wl=F.object({scope:F.enum([`object`,`system`]),target:F.string().min(1),actions:F.array(F.enum(Ul))}).strict();function findGrantIssues(e,t){let n=[],r=new Map;for(let i of e){let e=Wl.safeParse(i);if(!e.success){let e=typeof i==`object`&&i&&`target`in i?String(i.target):`?`;n.push({target:e,reason:`shape`});continue}let a=e.data;if(a.scope===`system`){if(!isCatalogResource(a.target)){n.push({target:a.target,reason:`unknown-resource`});continue}if(levelOf(capabilityForResource(a.target),a.actions)===`custom`){n.push({target:a.target,reason:`off-level`});continue}r.set(a.target,a.actions);continue}if(a.target!==`*`&&!t.objectNames.has(a.target)){n.push({target:a.target,reason:`unknown-object`});continue}let o=a.target===`*`?[...H.actions,H.purge]:H.actions;a.actions.every(e=>o.includes(e))||n.push({target:a.target,reason:`object-action`})}let i=new Set;for(let[e,t]of r){let a=capabilityForResource(e);if(!i.has(a)){for(let o of a.resources)if(!sameActions(t,r.get(o)??[])){n.push({target:e,reason:`split-capability`}),i.add(a);break}}}return n}const Gl=`memory`,Kl=4e3,ql=`workspace`,W={name:`name`,description:`description`,content:`content`,profileOf:`profileOf`,subjects:`subjects`,subjectId:`subjectId`};function textValue(e){return typeof e==`string`?e:``}function memoryPageViewOf(e){let{values:t}=e;return{id:e.id,name:textValue(t[W.name]),description:textValue(t[W.description]),content:textValue(t[W.content]),visibility:e.visibility,ownedBy:e.ownedBy,updatedAt:new Date(e.updatedAt).toISOString()}}const Jl=`@standards/schema`;function createStandardSchemaProps(e){return{version:1,vendor:Jl,validate:t=>{let n=e.safeParse(t);return n.success?{value:n.data}:{issues:n.error.issues.map(e=>({message:e.message,path:e.path}))}}}}function isStandardSchema(e){return typeof e==`object`&&!!e&&`~standard`in e&&typeof e[`~standard`]==`object`&&e[`~standard`].version===1}function asMutableArray(e){return e}var BaseAttributeBuilder=class{get"~standard"(){return createStandardSchemaProps(Tc(this.build()))}constructor(e,t,n){Ts(t),ks(n),this.attr={name:t,label:n,type:e,required:!1,system:!0}}setRequired(e){this.attr.required=e}asRequiredState(){return this}asPhantomState(){return this}runtime(){return this.attr.system=!1,this}hidden(){return this.attr.hidden=!0,this}placeholder(e){return this.attr.placeholder=e,this}description(e){return this.attr.description=e,this}icon(e){return bs(e,`attribute "${this.attr.name}"`),this.attr.icon=e,this}order(e){return this.attr.order=e,this}defaultValue(e){return(`defaultValue`in this.attr||![`formula`,`rollup`].includes(this.attr.type))&&(this.attr.defaultValue=e),this}metadata(e){return this.attr.metadata=e,this}build(){return this.attr}},TextAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`text`,e,t)}minLength(e){return this.attr.minLength=e,this}maxLength(e){return this.attr.maxLength=e,this}pattern(e){return this.attr.pattern=e,this.attr.format=void 0,this}multiline(e=!0){return this.attr.multiline=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),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}};function text(e,t){return new TextAttributeBuilder(e,t)}var RichtextAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`richtext`,e,t)}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function richtext(e,t){return new RichtextAttributeBuilder(e,t)}var NumberAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`number`,e,t)}min(e){return this.attr.min=e,this}max(e){return this.attr.max=e,this}integer(){return this.attr.unit=`integer`,this.attr.decimals=0,this}decimal(e=2){return this.attr.unit=`decimal`,this.attr.decimals=e,this}percentage(){return this.attr.unit=`percentage`,this}renderAs(e){return this.attr.renderAs=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function number(e,t){return new NumberAttributeBuilder(e,t)}var CheckboxAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`checkbox`,e,t)}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function checkbox(e,t){return new CheckboxAttributeBuilder(e,t)}var DateAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`date`,e,t)}format(e){return this.attr.dateFormat=e,this}precision(e){return this.attr.precision=e,this}build(){let[e]=Js(`date`,this.attr);if(e!==void 0)throw new A(e.message,[{path:[`precision`],message:e.message}]);return super.build()}minDate(e){return this.attr.minDate=e,this}maxDate(e){return this.attr.maxDate=e,this}endDate(){return this.attr.endDate=!0,this.asPhantomState()}includeTime(){return this.attr.includeTime=!0,this}timeFormat(e){return this.attr.timeFormat=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function date(e,t){return new DateAttributeBuilder(e,t)}var PhoneAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`phone`,e,t)}defaultCountry(e){return this.attr.defaultCountryCode=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function phone(e,t){return new PhoneAttributeBuilder(e,t)}var CurrencyAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`currency`,e,t)}defaultCurrency(e){return this.attr.defaultCurrency=e,this}allowedCurrencies(e){return this.attr.allowedCurrencies=e,this}allowNegative(e=!0){return this.attr.allowNegative=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function currency(e,t){return new CurrencyAttributeBuilder(e,t)}var StatusAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`status`,e,t)}options(e){let t=asMutableArray(e);return j(this.attr.name??`unknown`,t),this.attr.options=t,this.asPhantomState()}option(e){this.attr.options||(this.attr.options=[]);let t=[...this.attr.options,e];return j(this.attr.name??`unknown`,t),this.attr.options.push(e),this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function status(e,t){return new StatusAttributeBuilder(e,t)}var SelectAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`select`,e,t)}options(e){let t=asMutableArray(e);return j(this.attr.name??`unknown`,t),this.attr.options=t,this.asPhantomState()}option(e){this.attr.options||(this.attr.options=[]);let t=[...this.attr.options,e];return j(this.attr.name??`unknown`,t),this.attr.options.push(e),this}renderAs(e){return this.attr.renderAs=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function select(e,t){return new SelectAttributeBuilder(e,t)}var MultiselectAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`multiselect`,e,t)}options(e){let t=asMutableArray(e);return j(this.attr.name??`unknown`,t),this.attr.options=t,this.asPhantomState()}option(e){this.attr.options||(this.attr.options=[]);let t=[...this.attr.options,e];return j(this.attr.name??`unknown`,t),this.attr.options.push(e),this}renderAs(e){return this.attr.renderAs=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function multiselect(e,t){return new MultiselectAttributeBuilder(e,t)}var LocationAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`location`,e,t)}granularity(e){return this.attr.granularity=e,this}defaultCountry(e){return this.attr.defaultCountry=e,this}allowedCountries(e){return this.attr.allowedCountries=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function location(e,t){return new LocationAttributeBuilder(e,t)}var UserAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`user`,e,t),this.attr.types=[`user`,`agent`]}types(e){let t=[...new Set(e)];if(t.length===0)throw Error(`[AttributeBuilder] user.types must contain at least one type.`);return this.attr.types=t,this}multiple(){return this.attr.multiple=!0,this}notifiesOnAssign(){return this.attr.notifiesOnAssign=!0,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function user(e,t){return new UserAttributeBuilder(e,t)}var BaseRelationAttributeBuilder=class extends BaseAttributeBuilder{to(e,t){let n={object:e,...t};return this.attr.targets?.push(n),this}toAny(){return this.attr.targets=[{object:`*`}],this}qualifyWith(...e){let t=this.attr.targets;if(!t||t.length===0)throw Error(`.qualifyWith() must be called AFTER .to(). Example: relation("companies", "Companies").to("companies").qualifyWith(...)`);return this.attr.properties=buildPropertySchema(e),this}bilateral(e){let t=this.attr.targets;if(!t||t.length===0)throw Error(`.bilateral() must be called AFTER .to(). Example: relation("company", "Company").to("companies").bilateral({ ... })`);if(t.length>1)throw Error(`Bilateral relations are not supported for polymorphic relations (multiple .to() targets).`);if(nn(this.attr))throw Error(`Bilateral relations are not supported for universal relations (.toAny()).`);let n=t[0]?.object;if(!n)throw new A(`Bilateral relation requires one target object`,[{path:[`bilateral`,`object`],message:`Bilateral relation requires one target object`}]);if(e.object&&e.object!==n){let t=`Bilateral inverse object ${e.object} must match relation target ${n}`;throw new A(t,[{path:[`bilateral`,`object`],message:t}])}return this.attr.bilateral={...e,object:n},this}},SingleRelationAttributeBuilder=class extends BaseRelationAttributeBuilder{constructor(e,t){super(`relation`,e,t),this.attr.cardinality=`one`,this.attr.targets=[]}many(){let e=new MultiRelationAttributeBuilder(this.attr.name,this.attr.label??``,{targets:this.attr.targets,isRequired:this.attr.required});return this.attr.system===!1&&e.runtime(),this.attr.hidden&&e.hidden(),this.attr.placeholder&&e.placeholder(this.attr.placeholder),this.attr.description&&e.description(this.attr.description),this.attr.icon&&e.icon(this.attr.icon),this.attr.order!==void 0&&e.order(this.attr.order),this.attr.metadata&&e.metadata(this.attr.metadata),e}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}},MultiRelationAttributeBuilder=class extends BaseRelationAttributeBuilder{constructor(e,t,n){super(`relation`,e,t),this.attr.cardinality=`many`,this.attr.targets=n?.targets??[],this.attr.defaultValue=[],n?.isRequired&&this.setRequired(!0)}maxItems(e){return this.attr.maxItems=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function relation(e,t){return new SingleRelationAttributeBuilder(e,t)}var FormulaAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`formula`,e,t),this.attr.required=!1}expression(e){return this.attr.expression=e,this}returns(e){return this.attr.returnType=e,this}decimals(e){return this.attr.decimals=e,this}currency(e){return this.attr.currencyCode=e,this}required(){throw Error(`Formula attributes cannot be required: they are computed read-only values. Remove .required() from this attribute definition.`)}optional(){return this}};function formula(e,t){return new FormulaAttributeBuilder(e,t)}var RollupAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`rollup`,e,t),this.attr.required=!1}from(e){return this.attr.relationAttribute=e,this}aggregate(e){return this.attr.targetAttribute=e,this}using(e){return this.attr.function=e,this}decimals(e){return this.attr.decimals=e,this}path(e){return this.attr.relationPath=e,this}targetType(e){return this.attr.targetAttributeType=e,this}targetOptions(e){return this.attr.targetAttributeOptions=asMutableArray(e),this}targetCurrency(e){return this.attr.targetCurrencyCode=e,this}build(){let e=this.attr.function,t=this.attr.targetAttributeType;if(e===`original`&&t!==void 0&&t!==`select`&&t!==`status`&&t!==`multiselect`){let e=this.attr.relationAttribute??`relation`,n=this.attr.targetAttribute??`field`;throw new O(`Rollup "${this.attr.name}": .using("original") only supports a "select", "status", or "multiselect" target, but .targetType("${t}") was given. To surface a plain ${t} value from a related record, use a formula instead — e.g. formula("${this.attr.name}", "…").expression("${e}.${n}").`,k.VALIDATION_FAILED)}return super.build()}required(){throw Error(`Rollup attributes cannot be required: they are computed read-only values. Remove .required() from this attribute definition.`)}optional(){return this}};function rollup(e,t){return new RollupAttributeBuilder(e,t)}var DocumentAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`document`,e,t)}accepts(e){return this.attr.accepts=e,this}maxFileSize(e){return this.attr.maxFileSize=e,this}qualifyWith(...e){return this.attr.properties=buildPropertySchema(e),this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function document(e,t){return new DocumentAttributeBuilder(e,t)}function readOnlyOption(e){return e?.readOnly===void 0?{}:{readOnly:e.readOnly}}function buildFreeFieldRef(e,t){return{type:`free`,attribute:e.build(),label:t?.label,required:t?.required,prefillExpression:t?.prefillExpression,...readOnlyOption(t)}}function buildSlotFieldRef(e,t,n){let[r,...i]=Array.isArray(e)?e:[e];return{type:`slot`,slotId:r,additionalSlotIds:i.length>0?i:void 0,attribute:t,label:n?.label,required:n?.required,tooltip:n?.tooltip,...readOnlyOption(n)}}const Yl=F.boolean().optional();var FormRowBuilder=class{constructor(e,t,n){this._finalized=!1,this.stepBuilder=e,this.rowData={id:t,order:n,type:`fields`,fields:[]}}field(e,t,n){return this.rowData.fields.push(buildSlotFieldRef(e,t,n)),this}freeField(e,t){return this.rowData.fields.push(buildFreeFieldRef(e,t)),this}row(e){return this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData).row(e)}heading(e,t){return this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData).heading(e,t)}separator(){return this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData).separator()}text(e){return this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData).text(e)}endRow(){return this._finalized?this.stepBuilder:(this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData))}},FormStepBuilder=class{constructor(e,t,n){this.rowOrder=0,this.formBuilder=e,this.stepData={id:t,label:n,rows:[]}}description(e){return this.stepData.description=e,this}field(e,t,n){this.rowOrder++;let r=`row-${this.stepData.id}-${this.rowOrder}`,i=buildSlotFieldRef(e,t,n),a={id:r,order:this.rowOrder,type:`fields`,fields:[i]};return this.stepData.rows.push(a),this}freeField(e,t){this.rowOrder++;let n=`row-${this.stepData.id}-${this.rowOrder}`,r=buildFreeFieldRef(e,t),i={id:n,order:this.rowOrder,type:`fields`,fields:[r]};return this.stepData.rows.push(i),this}row(e){return this.rowOrder++,new FormRowBuilder(this,e,this.rowOrder)}heading(e,t){this.rowOrder++;let n={id:`heading-${this.stepData.id}-${this.rowOrder}`,order:this.rowOrder,type:`heading`,content:e,level:t};return this.stepData.rows.push(n),this}separator(){this.rowOrder++;let e={id:`sep-${this.stepData.id}-${this.rowOrder}`,order:this.rowOrder,type:`separator`};return this.stepData.rows.push(e),this}text(e){this.rowOrder++;let t={id:`text-${this.stepData.id}-${this.rowOrder}`,order:this.rowOrder,type:`text`,content:e};return this.stepData.rows.push(t),this}step(e,t){return this.formBuilder._finalizeStep(this.stepData).step(e,t)}build(){return this.formBuilder._finalizeStep(this.stepData).build()}_finalizeRow(e){return e.fields.length>0&&this.stepData.rows.push(e),this}_getData(){return this.stepData}},FormBuilder=class{constructor(e,t){this.data={slots:[],steps:[],status:`draft`,version:1},this.validateName(e),this.data.name=e,this.data.label=t}description(e){return this.data.description=e,this}icon(e){return this.data.icon=e,this}status(e){return this.data.status=e,this}metadata(e){return this.data.metadata=e,this}slot(e,t,n){if(this.data.slots.some(t=>t.id===e))throw Error(`[FormBuilder] Duplicate slot id: "${e}"`);let r={id:e,objectName:t,label:n.label,mode:n.mode??`create`,color:n.color,icon:n.icon};return this.data.slots.push(r),this}step(e,t){if(this.data.steps.some(t=>t.id===e))throw Error(`[FormBuilder] Duplicate step id: "${e}"`);return new FormStepBuilder(this,e,t)}build(){return this.validateRequiredData(),this.validateSlotReferences(),this.validateFreeFields(),this.validatePrefillExpressions(),this.validateReadOnly(),this.data}_finalizeStep(e){return this.data.steps.push(e),this}validateName(e){let t=F.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{t.parse(e)}catch(e){throw e instanceof F.ZodError?Error(`[FormBuilder] ${e.issues[0].message}`):e}}validateRequiredData(){if(this.data.slots.length===0)throw Error(`[FormBuilder] At least one slot is required. Use .slot() to add slots.`);if(this.data.steps.length===0)throw Error(`[FormBuilder] At least one step is required. Use .step() to add steps.`)}validateSlotReferences(){let e=new Map(this.data.slots.map(e=>[e.id,e.objectName]));for(let t of this.data.steps)for(let n of t.rows)if(isFormFieldsRow(n))for(let r of n.fields){if(r.type!==`slot`)continue;let n=getSlotFieldTargets(r);for(let r of n)if(!e.has(r))throw Error(`[FormBuilder] Step "${t.id}" references unknown slot "${r}". Declare it with .slot("${r}", ...) first.`);let i=new Set(n.map(t=>e.get(t)));if(i.size>1)throw Error(`[FormBuilder] Step "${t.id}" field on attribute "${r.attribute}" targets slots of different objects (${[...i].join(`, `)}). A multi-slot field must target slots of the same object.`)}}validatePrefillExpressions(){let e=[...z,`join`,`where`];for(let t of this.data.steps)for(let n of t.rows)if(isFormFieldsRow(n))for(let r of n.fields){if(!isFormFreeFieldRef(r)||!r.prefillExpression)continue;let n=r.prefillExpression,i=`prefillExpression on free field "${r.attribute.name}" in step "${t.id}"`;if(!isLabelExpression(n))throw Error(`[FormBuilder] ${i} must contain at least one {{ attribute }} interpolation.`);if(/\{\{\s*\}\}/.test(n))throw Error(`[FormBuilder] ${i} contains empty {{ }} interpolation.`);for(let a of n.matchAll(/(?<!\|)\|(?!\|)\s*(\w+)(?:\s*:[^|}]*)?/g)){let n=a[1];if(!e.includes(n))throw Error(`[FormBuilder] ${i} uses invalid pipe "${n}". Valid pipes: ${e.join(`, `)}`);let o=a[0].replace(/^\|/,``);if(isWherePipe(o)&&!parseWherePipe(o))throw new A(`[FormBuilder] ${i} has a malformed where: pipe "${o.trim()}". Write where:property=value or where:property in (a,b).`,[{path:[t.id,r.attribute.name,`prefillExpression`],message:`Malformed where: pipe`}])}}}validateReadOnly(){for(let e of this.data.steps)for(let t of e.rows)if(isFormFieldsRow(t))for(let n of t.fields){if(Yl.safeParse(n.readOnly).success)continue;let t=isFormFreeFieldRef(n)?n.attribute.name:n.attribute,r=isFormFreeFieldRef(n)?`free field`:`field`;throw new A(`[FormBuilder] readOnly on ${r} "${t}" in step "${e.id}" must be a boolean.`,[{path:[e.id,t,`readOnly`],message:`Expected a boolean`}])}}validateFreeFields(){let e=new Set(L);for(let t of this.data.steps)for(let n of t.rows)if(isFormFieldsRow(n)){for(let r of n.fields)if(isFormFreeFieldRef(r)){let n=r.attribute.type;if(e.has(n))throw Error(`[FormBuilder] Free field in step "${t.id}" uses forbidden attribute type "${n}". Forbidden types: ${L.join(`, `)}`)}}}};function form(e,t){return new FormBuilder(e,t)}function validateObjectExpressions(e){let{name:t,labelExpression:n,embeddingExpression:r}=e;if(!n)throw new O(`Object "${t}" must have a labelExpression. The labelExpression defines how records are displayed in lists and relations (e.g. "{{ name }}").`,k.VALIDATION_FAILED);let i=B.safeParse(n);if(!i.success){let e=i.error.issues[0]?.message??`Invalid labelExpression`;throw new O(`Invalid labelExpression for "${t}": ${e}`,k.VALIDATION_FAILED)}if(r!==void 0){let e=B.safeParse(r);if(!e.success){let n=e.error.issues[0]?.message??`Invalid embeddingExpression`;throw new O(`Invalid embeddingExpression for "${t}": ${n}`,k.VALIDATION_FAILED)}}}var ObjectBuilder=class{get"~standard"(){return createStandardSchemaProps(Pc(this.build()))}constructor(e,t){this._sealed=!1,this._toleratedAttributes=[],this.validateName(e),this.obj={name:e,label:t,attributes:[],system:!0}}id(e){return this.obj.id=e,this}description(e){return this.obj.description=e,this}pluralLabel(e){return this._pluralLabel=e,this}icon(e){return this.obj.icon=e,this}color(e){return this.obj.color=e,this}imageShape(e){return this.obj.imageShape=e,this}runtime(){return this.obj.system=!1,this}sealed(){return this._sealed=!0,this}tolerate(e){return this._toleratedAttributes=[...this._toleratedAttributes,...e],this}attribute(e){return this.pushAttributes([e]),this}attributes(e){return this.pushAttributes(e),this}pushAttributes(e){let t=e.map(e=>`build`in e&&typeof e.build==`function`?e.build():e);As([...this.obj.attributes,...t],e=>e.name,e=>new Dn(`attribute`,e,`Object "${this.obj.name}": duplicate attribute name "${e}"`)),this.obj.attributes.push(...t)}metadata(e){return this.obj.metadata={...this.obj.metadata,...e},this}order(e){return this.obj.metadata={...this.obj.metadata,order:e},this}hidden(){return this.obj.metadata={...this.obj.metadata,hidden:!0},this}labelExpression(e){return this._labelExpression=e,this}embeddingExpression(e){return this._embeddingExpression=e,this}documentLayout(e){if(e.presets)for(let t of e.presets)validatePresetStructure(t.id,t.structure,1);return this.obj.documentLayout=e,this}build(){if(!this.obj.name)throw new A(`[ObjectBuilder] Missing required field: name`,[{path:[`name`],message:`name is required`}]);if(!this.obj.label)throw new A(`[ObjectBuilder] Missing required field: label`,[{path:[`label`],message:`label is required`}]);return validateObjectExpressions({name:this.obj.name,labelExpression:this._labelExpression,embeddingExpression:this._embeddingExpression}),{...this.obj,pluralLabel:this._pluralLabel,labelExpression:this._labelExpression,embeddingExpression:this._embeddingExpression,sealed:this._sealed,toleratedAttributes:this._toleratedAttributes}}validateName(e){e!==void 0&&js(e)}};function object(e,t){if(_s(e))throw new qn(e,`builder`);return new ObjectBuilder(e,t)}function validatePresetStructure(e,t,n){let fail=(t,n)=>{throw new A(t,[{path:[`documentLayout`,`presets`,e],message:n}])};n>5&&fail(`Preset structure exceeds max depth of 5`,`Preset structure too deep`);let r=new Set;for(let i of t){let t=i.title.trim();t.length===0&&fail(`Folder preset node title is required`,`Empty folder title`),t.includes(`/`)&&fail(`Folder preset node title cannot contain /`,`Folder title contains /: "${t}"`),r.has(t)&&fail(`Folder preset sibling titles must be unique`,`Duplicate folder title: "${t}"`),r.add(t),i.children&&i.children.length>0&&validatePresetStructure(e,i.children,n+1)}}function cloneBuilderValue(e,t){try{return structuredClone(e)}catch{let e=`Builder configuration must contain cloneable data`;throw new A(e,[{path:t,message:e}])}}function requireBuilderName(e,t){if(typeof e!=`string`||e.trim().length===0)throw new A(`Name must not be blank`,[{path:t,message:`Name must not be blank`}])}function validateContentConfiguration(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw new A(`Invalid content configuration`,[{path:t,message:`Expected content configuration`}]);for(let n of[`name`,`label`,`placement`])if(Object.hasOwn(e,n)){let e=`Independent content configuration cannot define ${n}`;throw new A(e,[{path:[...t,n],message:e}])}let n=w.safeParse({...e,name:`content`,placement:e.type===`group`?`grid`:`main`});if(!n.success)throw A.fromZodErrors(n.error.issues.map(e=>({path:[...t,...e.path.map(String)],message:e.message})));n.data.type===`form`&&n.data.groups.forEach((e,n)=>requireBuilderName(e.name,[...t,`groups`,String(n),`name`]));let{name:r,label:i,placement:a,...o}=n.data;return cloneBuilderValue(o,t)}function validateLiteralContent(e,t){return validateContentConfiguration(e,t),cloneBuilderValue(e,t)}function spanContent(e,t){if(!_.includes(t)){let e=`A block spans ${_.join(`, `)} columns, not ${String(t)}`;throw new A(e,[{path:[`content`,`span`],message:e}])}return{content:e,span:t}}function configureContent(e,t){try{return typeof e==`object`&&e&&`build`in e&&typeof e.build==`function`?{configuration:validateContentConfiguration(e.build(),t),extension:e.extension}:{configuration:validateContentConfiguration(e,t)}}catch(e){throw e instanceof A?new A(e.message,e.errors.map(e=>({...e,path:e.path[0]===`content`?[...t,...e.path.slice(1)]:e.path}))):e}}var G=class ViewBuilder{constructor(e,t=[]){this.kind=`view`,this.data=cloneBuilderValue(e,[`views`,`0`]),this.extensions=t.map(e=>e&&{...e})}for(e){let t=typeof e==`string`?e:e.build().name;return new ViewBuilder({...this.data,object:t},this.extensions)}default(){return new ViewBuilder({...this.data,default:!0},this.extensions)}description(e){return new ViewBuilder({...this.data,description:e},this.extensions)}icon(e){return new ViewBuilder({...this.data,icon:e},this.extensions)}place(e,t,n,r){let{configuration:i,extension:a}=configureContent(n,[`views`,`0`,`contents`,String(this.data.contents.length)]),o={...i,name:e,label:t,placement:r},s=[...this.data.contents,o];return new ViewBuilder({...this.data,contents:s},[...this.extensions,a])}tab(e,t,n){return this.place(e,t,n,`main`)}aside(e,t,n){return this.place(e,t,n,`aside`)}build(){let e=[`views`,`0`];requireBuilderName(this.data.name,[...e,`name`]),requireBuilderName(this.data.object,[...e,`object`]);let t=T.safeParse(this.data);if(!t.success)throw A.fromZodErrors(t.error.issues.map(t=>({path:[...e,...t.path.map(String)],message:t.message})));return this.data.contents.forEach((t,n)=>{let r=[...e,`contents`,String(n)];requireBuilderName(t.name,[...r,`name`]),t.type===`form`&&t.groups.forEach((e,t)=>requireBuilderName(e.name,[...r,`groups`,String(t),`name`])),Ct(t,this.extensions[n],t.name,this.data.context,r)}),{kind:`view`,definition:cloneBuilderValue(this.data,e)}}};function detailView(e,t){return new G({name:e,label:t,object:void 0,context:`record`,contents:[]})}function listView(e,t){return new G({name:e,label:t,object:void 0,context:`collection`,contents:[]})}function storedQuery(e,t){let n=[`search`,`offset`].filter(t=>e.state[t]!==void 0);if(n.length>0)throw new A(`A ${t} cannot keep a query's ${n.join(` or `)}`,n.map(e=>({path:[t,e],message:`A ${t} stores no ${e}; use filters and limit instead`})));return e.toDefinition()}function checkInputs(e,t){for(let[n,r]of Object.entries(t)){let t=e.inputs[n];r!==void 0&&t!==void 0&&y({parameters:t.schema},r,[`content`,`parameters`,n])}return t}var BlockContentBuilder=class{constructor(e,t,n){this.extension=e,this.parameters=t,this.heightMode=n}copy(e,t){let n=this.constructor;return new n(this.extension,e,t)}with(e){let t={...this.parameters};for(let[n,r]of Object.entries(e)){if(r===void 0){delete t[n];continue}t[n]=r}return checkInputs(this.extension,e),this.copy(t,this.heightMode)}height(e){return this.copy(this.parameters,e)}build(){let e={type:`custom`,extension:this.extension.name,parameters:cloneBuilderValue(this.parameters,[`content`,`parameters`]),...this.heightMode===void 0?{}:{height:this.heightMode}};return validateContentConfiguration(e,[`content`]),y(this.extension,e.parameters,[`content`,`parameters`]),e}span(e){return spanContent(this,e)}},Measures=class{count(){return this.measured(`count`)}sum(e){return this.measured(`sum`,e)}avg(e){return this.measured(`avg`,e)}min(e){return this.measured(`min`,e)}max(e){return this.measured(`max`,e)}};function measure(e,t,n){return{query:e,measure:t,...n===void 0?{}:{attribute:n}}}var MetricBuilder=class extends BlockContentBuilder{label(e){return this.with({label:e})}trend(e,t){return this.with({trend:e,trendBucket:t})}compare(e,t){return this.with({compare:e,period:t})}target(e){return this.with({target:e})}},MetricQuery=class extends Measures{constructor(e){super(),this.query=e}measured(e,t){return new MetricBuilder(S,checkInputs(S,measure(this.query,e,t)))}};function groupBy(e){return typeof e==`string`?[e,void 0]:[e.attribute,e.bucket]}var ChartBuilder=class extends BlockContentBuilder{label(e){return this.with({label:e})}by(e){let[t,n]=groupBy(e);return this.with({by:t,byBucket:n})}by2(e){let[t,n]=groupBy(e);return this.with({by2:t,by2Bucket:n})}kind(e){return this.with({kind:e})}bar(){return this.kind(`bar`)}line(){return this.kind(`line`)}area(){return this.kind(`area`)}donut(){return this.kind(`donut`)}funnel(){return this.kind(`funnel`)}treemap(){return this.kind(`treemap`)}calendar(){return this.kind(`calendar`)}},ChartQuery=class extends Measures{constructor(e){super(),this.query=e}measured(e,t){return new ChartBuilder(x,checkInputs(x,{...measure(this.query,e,t),kind:`bar`}))}};const Xl={"7d":7,"30d":30};var AgendaBuilder=class extends BlockContentBuilder{label(e){return this.with({label:e})}next(e){let t=typeof e==`number`?e:Xl[e];if(!Number.isInteger(t)||t<1){let e=`An agenda looks ahead a whole number of days, at least 1`;throw new A(e,[{path:[`content`,`parameters`,`next`],message:e}])}return this.with({next:t})}yearly(){return this.with({yearly:!0})}},CardBuilder=class extends BlockContentBuilder{fields(...e){return this.with({fields:e})}record(e){return this.with({record:e})}},InboxBuilder=class extends BlockContentBuilder{kinds(...e){return this.with({kinds:e})}limit(e){return this.with({limit:e})}},MailboxBuilder=class extends BlockContentBuilder{category(e){return this.with({category:e})}important(){return this.with({important:!0})}unread(){return this.with({unread:!0})}limit(e){return this.with({limit:e})}label(e){return this.with({label:e})}};function metric(e){return new MetricQuery(storedQuery(e,`metric`))}function chart(e){return new ChartQuery(storedQuery(e,`chart`))}function agenda(e,t){return new AgendaBuilder(g,checkInputs(g,{query:storedQuery(e,`agenda`),attribute:t}))}function card(e){let t=e===void 0||typeof e==`string`?e:e.build().name;return new CardBuilder(v,t===void 0?{}:checkInputs(v,{object:t}))}function text$1(e){return new BlockContentBuilder(E,checkInputs(E,{markdown:e}))}function inbox(){return new InboxBuilder(Xt,{})}function meetingsUpcoming(){return new BlockContentBuilder($e,{})}function mailbox(){return new MailboxBuilder(De,{})}function relationProperty(e){return requireBuilderName(e,[`relationProperty`]),{relationProperty:e}}var K=class ContentBuilder{constructor(e,t){this.data=cloneBuilderValue(e,[`content`]),this.extension=t===void 0?void 0:Object.freeze({name:t.name,contexts:t.contexts,parameters:t.parameters,refine:t.refine})}set(e){return new ContentBuilder({...this.data,...e},this.extension)}icon(e){return this.set({icon:e})}object(e){return this.set({objectName:e})}layout(e){let{layout:t,groupByAttribute:n,columnSizing:r,kanbanColumnOrder:i,kanbanColumnVisibility:a,kanbanPinnedColumns:o,...s}={...this.data,layout:void 0,groupByAttribute:void 0,columnSizing:void 0,kanbanColumnOrder:void 0,kanbanColumnVisibility:void 0,kanbanPinnedColumns:void 0};return new ContentBuilder({...s,...e},this.extension)}table(){return this.layout({layout:`table`})}list(){return this.layout({layout:`list`})}kanban(e){return this.layout({layout:`kanban`,groupByAttribute:e})}columns(...e){return this.set({columns:e})}actions(...e){return this.set({actions:e})}openMode(e){return this.set({openMode:e})}createMode(e){return this.set({createMode:e})}visibility(e){return this.set({visibility:e})}descriptionAttribute(e){return this.set({descriptionAttribute:e})}displayAttributes(...e){return this.set({displayAttributes:e})}columnSizing(e){return this.set({columnSizing:e})}kanbanColumnOrder(...e){return this.set({kanbanColumnOrder:e})}kanbanColumnVisibility(e){return this.set({kanbanColumnVisibility:e})}kanbanPinnedColumns(...e){return this.set({kanbanPinnedColumns:e})}formColumns(e){return this.set({formColumns:e})}density(e){return this.set({density:e})}titleAttribute(e){return this.set({titleAttribute:e})}allowUpload(e){return this.set({allowUpload:e})}allowRemove(e){return this.set({allowRemove:e})}hideAttachments(e){return this.set({hideAttachments:e})}relations(...e){return this.set({relations:e})}span(e){return spanContent(this,e)}height(e){return this.set({height:e})}build(){let e=validateLiteralContent(this.data,[`content`]);return this.extension&&e.type===`custom`&&y(this.extension,e.parameters,[`content`,`parameters`]),e}},Zl=class GroupBuilder{constructor(e,t,n,r={}){this.data=cloneBuilderValue({name:e,label:t,fields:n,...r},[`group`])}field(e,t){let{name:n,label:r,fields:i,...a}=this.data;return new GroupBuilder(n,r,[...i,{attribute:e,...t}],a)}fields(...e){let{name:t,label:n,fields:r,...i}=this.data;return new GroupBuilder(t,n,[...r,...e.map(e=>({attribute:e}))],i)}description(e){return new GroupBuilder(this.data.name,this.data.label,this.data.fields,{...this.presentation(),description:e})}collapsible(e=!1){return new GroupBuilder(this.data.name,this.data.label,this.data.fields,{...this.presentation(),collapsible:!0,collapsed:e})}presentation(){let{name:e,label:t,fields:n,...r}=this.data;return r}build(){requireBuilderName(this.data.name,[`group`,`name`]);try{validateLiteralContent({type:`form`,groups:[this.data]},[`group`])}catch(e){throw e instanceof A?new A(e.message,e.errors.map(e=>({...e,path:e.path[1]===`groups`?[`group`,...e.path.slice(3)]:e.path}))):e}return cloneBuilderValue(this.data,[`group`])}};function group(e,t){return new Zl(e,t,[])}function collection(e){return new K({type:`collection`,...storedQuery(e,`collection`)})}function form$1(...e){return new K({type:`form`,groups:e.map(e=>`build`in e?e.build():e)})}function activity(){return new K({type:`activity`})}function richtext$1(e){return new K({type:`richtext`,attribute:e})}function documents(){return new K({type:`documents`})}function forms(){return new K({type:`forms`})}function emails(...e){return new K({type:`emails`,emailAttributes:e})}function meetings(...e){return new K({type:`meetings`,emailAttributes:e})}function custom(e,t){if(typeof e!=`object`||!e||typeof e.name!=`string`)throw new A(`Expected registered extension declaration`,[{path:[`content`,`extension`],message:`Expected registered extension declaration`}]);let n=validateContentConfiguration({type:`custom`,extension:e.name,parameters:t},[`content`]);if(n.type!==`custom`)throw new A(`Expected custom content`,[]);let r=new K({...n,extension:e.name},e);return r.build(),r}function recordLinksTab(){return[C.name,C.label,custom(le,{}).icon(C.icon)]}function page$1(e){let{object:t,name:n}=e.definition;if(typeof t!=`string`){let e=`Page "${n}" is standalone; a record tab renders a record page (\`page(...).for(object)\`)`;throw new A(e,[{path:[`content`,`page`,`object`],message:e}])}return new K({type:`page`,page:{object:t,name:n}})}const Ql={collection,metric,chart,agenda,card,text:text$1,inbox,meetingsUpcoming,mailbox,page:page$1,form:form$1,activity,richtext:richtext$1,documents,forms,emails,meetings,custom};function nameSlug(e,t){return e.normalize(`NFKD`).replace(/\p{M}/gu,``).toLowerCase().replace(/[^a-z0-9]+/g,`_`).slice(0,t).replace(/^_+|_+$/g,``)}function positionOf(e){return{x:e.x,y:e.y,w:e.w,h:e.h}}function bottomOf(e){return e.y+e.h}function collides(e,t){return e.x<t.x+t.w&&t.x<e.x+e.w&&e.y<t.y+t.h&&t.y<e.y+e.h}function firstCollision(e,t){return t.find(t=>collides(e,t))}function inReadingOrder$1(e){return[...e].sort((e,t)=>e.y-t.y||e.x-t.x)}function snapWidth(e,t,n){let r=12-t,i=_.filter(e=>e>=n&&e<=r);return i.length===0?_.find(e=>e>=n)??n:i.reduce((t,n)=>{let r=Math.abs(n-e),i=Math.abs(t-e);return r<i||r===i&&n>t?n:t})}function sharesColumns(e,t){return e.x<t.x+t.w&&t.x<e.x+e.w}function risenRow(e,t){return t.reduce((t,n)=>n.y<e.y&&sharesColumns(e,n)?Math.max(t,bottomOf(n)):t,0)}function packLayout(e,t){let n=e.map(e=>{let n=t?.get(e.i);return n===void 0?e:{...e,h:n}}),r=n.filter(e=>e.static===!0),i=new Map(r.map(e=>[e.i,e]));for(let e of inReadingOrder$1(n.filter(e=>e.static!==!0))){let t=risenRow(e,r),n=firstCollision({...e,y:t},r);for(;n!==void 0;)t=bottomOf(n),n=firstCollision({...e,y:t},r);let a={...e,y:t};r.push(a),i.set(e.i,a)}return n.map(e=>i.get(e.i)??e)}function settleLayout(e,t){let n=e.filter(e=>e.static===!0),r=e.filter(e=>e.static!==!0),i=new Map;for(let e of[...inReadingOrder$1(r.filter(e=>t.has(e.i))),...inReadingOrder$1(r.filter(e=>!t.has(e.i)))]){let t=e,r=firstCollision(t,n);for(;r!==void 0;)t={...t,y:bottomOf(r)},r=firstCollision(t,n);n.push(t),i.set(e.i,t)}return packLayout(e.map(e=>i.get(e.i)??e))}function pageCompactor(){return{type:`vertical`,allowOverlap:!1,preventCollision:!1,compact:e=>packLayout(e).map(e=>({...e,moved:!1}))}}function clampHeight(e,t){let n=t.minHeight??1,r=t.maxHeight??1/0;return Math.max(1,n,Math.min(r,e))}function widthStepConstraint(e){return{name:`width-steps`,constrainSize:(t,n,r)=>{let i=e(t.i),a=snapWidth(n,t.x,i.minWidth);return i.height===`fit`?{w:a,h:t.h}:i.height===`flexible`?{w:a,h:clampHeight(r,i)}:{w:a,h:Math.max(1,r)}}}}function snapCell(e,t){let n=Math.max(0,Math.min(e.x,11)),r=snapWidth(e.w,n,t(e.i).minWidth);return{...e,x:Math.min(n,12-r),y:Math.max(0,e.y),w:r,h:Math.max(1,e.h)}}function samePosition(e,t){return e.x===t.x&&e.y===t.y&&e.w===t.w&&e.h===t.h}function pushApart(e){let t=e.filter(e=>e.static===!0),n=new Map;for(let r of inReadingOrder$1(e.filter(e=>e.static!==!0))){let e=r,i=firstCollision(e,t);for(;i!==void 0;){let n={...e,x:i.x+i.w};e=n.x+n.w<=12&&firstCollision(n,t)===void 0?n:{...e,y:bottomOf(i)},i=firstCollision(e,t)}t.push(e),n.set(r.i,e)}return e.map(e=>n.get(e.i)??e)}function isValidStatic(e){return[e.x,e.y,e.w,e.h].every(Number.isInteger)&&e.x>=0&&e.y>=0&&e.h>=1&&_.includes(e.w)&&e.x+e.w<=12}function keptStatics(e){let t=[],n=new Set;for(let r of inReadingOrder$1(e.filter(e=>e.static===!0)))isValidStatic(r)&&firstCollision(r,t)===void 0?t.push(r):n.add(r.i);return e.map(e=>n.has(e.i)?{...e,static:!1}:e)}function boundedHeight(e,t){let n=t(e.i);if(e.static===!0||n.height!==`flexible`)return e;let r=clampHeight(e.h,n);return r===e.h?e:{...e,h:r}}function repairPageGrid(e,t){let n=[],r=keptStatics(e).map(e=>{let r=boundedHeight(e,t);return r!==e&&n.push({name:e.i,kind:`height`,from:positionOf(e),to:positionOf(r)}),r}).map(e=>{if(e.static===!0)return e;let r=snapCell(e,t);return samePosition(e,r)||n.push({name:e.i,kind:`width`,from:positionOf(e),to:positionOf(r)}),r}),i=pushApart(r);i.forEach((e,t)=>{let i=r[t];i!==void 0&&!samePosition(i,e)&&n.push({name:e.i,kind:`pushed`,from:positionOf(i),to:positionOf(e)})});let a=packLayout(i),o=keptFill(a,t);for(let e of inReadingOrder$1(a))e.i!==o&&t(e.i).height===`fill`&&n.push({name:e.i,kind:`fill`});return{cells:a,repairs:n}}function keptFill(e,t){return inReadingOrder$1(e).find(e=>e.static!==!0&&t(e.i).height===`fill`)?.i}function deriveLayout6(e,t){let n=[],r=0,i=0,a=0;for(let o of inReadingOrder$1(e)){let e=Math.min(6,Math.max(t(o.i).minWidth,Math.ceil(o.w/2)));r+e>6&&(r=0,i+=a,a=0),n.push({i:o.i,x:r,y:i,w:e,h:o.h}),r+=e,a=Math.max(a,o.h)}return packLayout(n)}function figureSlot(e,t,n){for(let r of inReadingOrder$1(e.filter(e=>n.has(e.i)))){let n={x:r.x+r.w,y:r.y,...t};if(n.x+n.w<=12&&firstCollision(n,e)===void 0)return n}}function placeNew(e,t,n,r){let i={w:snapWidth(n.size.w,0,n.minWidth),h:Math.max(1,n.size.h)};return n.figure?{i:t,...figureSlot(e,i,r)??{x:0,y:0,...i}}:{i:t,x:0,y:e.reduce((e,t)=>Math.max(e,bottomOf(t)),0),...i}}function isSpanned(e){return typeof e==`object`&&!!e&&`span`in e&&`content`in e}function total(e){return e.reduce((e,t)=>e+t,0)}function spread(e){return e.length===0?0:Math.max(...e)-Math.min(...e)}function betterSplit(e,t){let n=total(e)-total(t);if(n!==0)return n>0;let r=spread(t)-spread(e);if(r!==0)return r>0;let i=e.findIndex((e,n)=>e!==t[n]);return i!==-1&&(e[i]??0)>(t[i]??0)}function splitColumns(e,t){let n=[...t];function visit(r,i){let a=t[r.length];if(a===void 0){betterSplit(r,n)&&(n=r);return}for(let t of _)t>=a&&i+t<=e&&visit([...r,t],i+t)}return visit([],0),n}function rowWidths(e,t){let n=e.filter(e=>e.span===void 0);n.length>4&&reject(t,`A row holds at most 4 unsized blocks`);let r=total(e.map(e=>e.span??e.minWidth));r>12&&reject(t,`Blocks ${e.map(e=>`"${e.key}"`).join(`, `)} do not fit one row: they need at least ${r} of 12 columns`);let i=splitColumns(12-total(e.map(e=>e.span??0)),n.map(e=>e.minWidth)),a=0;return e.map(e=>{if(e.span!==void 0)return e.span;let t=i[a]??e.minWidth;return a+=1,t})}function reject(e,t){throw new A(t,[{path:e,message:t}])}function traitsOf(e,t=[]){return pt(e,D,new Map(t.map(e=>[e.name,e])))}function headingNames(e){let t=new Set(e.flatMap(e=>e.kind===`heading`?e.meta.name===void 0?[]:[e.meta.name]:[...Object.keys(e.blocks),...e.group?.name===void 0?[]:[e.group.name]]));return e.flatMap(e=>{if(e.kind!==`heading`)return[];if(e.meta.name!==void 0)return[e.meta.name];let n=nameSlug(e.title,40),r=n===``?`heading`:`heading_${n}`,i=r;for(let e=2;t.has(i);e+=1)i=`${r}_${e}`;return t.add(i),[i]})}function headingEntry(e,t,n){let r={title:t,...n.description===void 0?{}:{description:n.description},...n.icon===void 0?{}:{icon:n.icon}};return{key:e,content:new BlockContentBuilder(Oe,r),span:12}}function groupOf(e,t,n){let[r]=e.map(e=>e.name).sort(),i=Me(e.length);return(i!==void 0||r===void 0)&&reject(n,String(i)),{type:`group`,name:t.name??`group_${r}`,placement:`grid`,...t.label===void 0?{}:{label:t.label},members:e.map(e=>e.name)}}function requirePlacement(e,t,n,r,i){if(e.type===`page`&&reject(i,`Content "${n}" cannot reference a page from a page`),Ct(e,t,n,r,i),e.type!==`custom`)return;let a=t?.refine?.(e.parameters??{},r);a&&reject([...i,`parameters`,a.input],a.message)}var $l=class PageBuilder{constructor(e){this.kind=`view`,this.data=e}icon(e){return new PageBuilder({...this.data,icon:e})}description(e){return new PageBuilder({...this.data,description:e})}home(){return new PageBuilder({...this.data,home:!0})}for(e){let t=typeof e==`string`?e:e.build().name;return new PageBuilder({...this.data,object:t})}row(e,t={}){let n=t.group===void 0?{kind:`row`,blocks:e}:{kind:`row`,blocks:e,group:t.group};return new PageBuilder({...this.data,sections:[...this.data.sections,n]})}heading(e,t={}){let n={kind:`heading`,title:e,meta:t};return new PageBuilder({...this.data,sections:[...this.data.sections,n]})}build(){let e=[`views`,`0`],{name:t,label:n,object:r,icon:i,description:a,home:o,sections:s}=this.data;requireBuilderName(t,[...e,`name`]),r!==void 0&&requireBuilderName(r,[...e,`object`]),o&&r!==void 0&&reject([...e,`home`],`Only a standalone page can be the home`),s.every(e=>e.kind===`row`&&Object.keys(e.blocks).length===0)&&reject([...e,`contents`],`A page declares at least one block`);let c=r===void 0?`page`:`record`,l=[],u=[],d=headingNames(s),f=0;for(let t of s){let n=[...e,`contents`,String(l.length)],r=(t.kind===`heading`?[headingEntry(d[f++]??``,t.title,t.meta)]:Object.entries(t.blocks).map(([e,t])=>isSpanned(t)?{key:e,content:t.content,span:t.span}:{key:e,content:t,span:void 0})).map(t=>{let n=[...e,`contents`,String(l.length)];requireBuilderName(t.key,[...n,`name`]);let{configuration:r,extension:i}=configureContent(t.content,n);requirePlacement(r,i,t.key,c,n);let a={...r,name:t.key,placement:`grid`};return l.push(a),{content:a,span:t.span}}),i=rowWidths(r.map(({content:e,span:t})=>({key:e.name,...t===void 0?{}:{span:t},minWidth:traitsOf(e).minWidth})),n),a=u.reduce((e,t)=>Math.max(e,t.y+t.h),0);if(t.kind===`row`&&t.group!==void 0){let e=groupOf(r.map(({content:e})=>e),t.group,n);l.push(e),u.push({i:e.name,x:0,y:a,w:12,h:traitsOf(e,l).size.h});continue}let o=0;r.forEach(({content:e},t)=>{let n=i[t]??0;u.push({i:e.name,x:o,y:a,w:n,h:traitsOf(e).size.h}),o+=n})}let p=Object.fromEntries(packLayout(u).map(({i:e,x:t,y:n,w:r,h:i})=>[e,{x:t,y:n,w:r,h:i}])),m={name:t,label:n,...r===void 0?{}:{object:r},context:`page`,...i===void 0?{}:{icon:i},...a===void 0?{}:{description:a},...o?{home:!0}:{},contents:l,grid:p},h=T.safeParse(m);if(!h.success)throw A.fromZodErrors(h.error.issues.map(t=>({path:[...e,...t.path.map(String)],message:t.message})));return{kind:`view`,definition:cloneBuilderValue(m,e)}}};function page(e,t){return new $l({name:e,label:t,object:void 0,sections:[]})}function contentDefinition(e,t){if(t.suppressed)return null;let n=t.workspaceDefinition??t.sourceDefinition;return n===null?null:{...structuredClone(n),name:e}}function storedContentDefinition(e){let{name:t,...n}=e;return structuredClone(n)}function workspaceViewAuthoring(e,t={}){let n={main:0,aside:0};return{origin:`runtime`,mainOrderCustomized:!1,asideOrderCustomized:!1,gridCustomized:Object.keys(t).length>0,homeCustomized:!1,contents:Object.fromEntries(e.map(e=>[e.name,{sourceDefinition:null,workspaceDefinition:storedContentDefinition(e),suppressed:!1,sourcePosition:null,workspacePosition:e.placement===`grid`?null:n[e.placement]++,sourceGrid:null,workspaceGrid:t[e.name]??null}]))}}function byKind(e,t){let rank=e=>Number(e.definition.type===`group`);return rank(e)-rank(t)||e.name.localeCompare(t.name)}function inReadingOrder(e){return(t,n)=>{let r=e(t.name),i=e(n.name);return r===null||i===null?r===i?byKind(t,n):r?-1:1:r.y-i.y||r.x-i.x||byKind(t,n)}}function overLimit(e,t){let n=new Set;if(e.length<=N.tabsPerView)return n;let r=new Map(e.map(e=>[e.name,e])),i=new Map;for(let{name:t,definition:n}of e)if(n.type===`group`)for(let e of n.members)i.has(e)||i.set(e,t);let cellOf=e=>{let n=r.get(e),a=n?t(n.state):null;if(a!==null)return a;let o=r.get(i.get(e)??``);return o?t(o.state):null},a=e.filter(e=>e.state.sourceDefinition===null).sort(inReadingOrder(cellOf)).reverse();for(let t of a){if(e.length-n.size<=N.tabsPerView)break;if(n.has(t.name))continue;let i=t.definition.type===`group`?t.definition.members.flatMap(e=>{let t=r.get(e);return t&&t.definition.type!==`group`?[t]:[]}):[];if(!i.some(e=>e.state.sourceDefinition!==null))for(let e of[t,...i])n.add(e.name)}return n}function resolvePageGrid(e,t={}){let rawCell=t=>e.gridCustomized||t.sourceDefinition===null?t.workspaceGrid:t.sourceGrid,n=Object.entries(e.contents).flatMap(([e,t])=>{let n=contentDefinition(e,t);return n?[{name:e,state:t,definition:n}]:[]}),r=b(n.map(e=>e.definition)),i=n.filter(e=>!r.has(e.name)).sort((e,t)=>e.name.localeCompare(t.name)),a=overLimit(i,rawCell),o=i.filter(e=>!a.has(e.name)),s=new Map(o.map(e=>[e.name,e.definition])),c=t.traitsOf??It(s,D),l=Pe([...s.values()]),u=o.filter(e=>!l.has(e.name)),d={},f=[],place=(e,t)=>{t&&!Object.values(d).some(e=>Ve(t,e))?d[e]={...t}:f.push(e)};if(e.gridCustomized)for(let{name:e,state:t}of u)place(e,t.workspaceGrid);else{for(let{name:e,state:t}of u)t.sourceDefinition!==null&&place(e,t.sourceGrid);for(let{name:e,state:t}of u)t.sourceDefinition===null&&place(e,t.workspaceGrid)}let p=Math.max(0,...Object.values(d).map(e=>e.y+e.h));for(let t of f.sort()){let n=e.contents[t],{w:r,h:i}=n.workspaceGrid??n.sourceGrid??c(t).size;d[t]={x:0,y:p,w:r,h:i},p+=i}let m=repairPageGrid(Object.entries(d).map(([e,n])=>({i:e,...n,...t.statics?.has(e)?{static:!0}:{}})),c);return{grid:Object.fromEntries(m.cells.map(({i:e,x:t,y:n,w:r,h:i})=>[e,{x:t,y:n,w:r,h:i}])),repairs:[...[...a].map(e=>({name:e,kind:`dropped`})),...m.repairs]}}function droppedContents(e){return new Set(e.flatMap(e=>e.kind===`dropped`?[e.name]:[]))}function resolveViewContents(e){let t=Object.entries(e.contents).flatMap(([e,t])=>{let n=contentDefinition(e,t);return n?[{definition:n,...t}]:[]}),n=[`main`,`aside`].flatMap(n=>{let r=n===`main`?e.mainOrderCustomized:e.asideOrderCustomized;return t.filter(e=>e.definition.placement===n).sort((e,t)=>{let n=r?e.workspacePosition:e.sourcePosition,i=r?t.workspacePosition:t.sourcePosition;if(n!==null&&i!==null&&n!==i)return n-i;if(n!==null&&i===null)return-1;if(i!==null&&n===null)return 1;let a=e.sourcePosition??e.workspacePosition,o=t.sourcePosition??t.workspacePosition;return a!==null&&o!==null&&a!==o?a-o:a!==null&&o===null?-1:o!==null&&a===null?1:e.definition.name.localeCompare(t.definition.name)}).map(e=>e.definition)}),r=b(t.map(e=>e.definition)),i=t.filter(e=>e.definition.placement===`grid`&&!r.has(e.definition.name)).map(e=>e.definition).sort((e,t)=>e.name.localeCompare(t.name));return[...n,...i]}const q=[`record`,`document`,`file`,`email`,`thread`,`event`,`memory`,`skill`,`schema`,`user`,`guide`],eu=new Set([`memory`,`schema`]),tu=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function isReferenceKind(e){return q.includes(e)}function refuse$1(e,t){return{ok:!1,reason:e,expected:t}}function parseReference(e){let t=e.trim();if(tu.test(t))return refuse$1(`bare_uuid`,`record:<id>`);let n=t.indexOf(`:`);if(n===-1)return refuse$1(`malformed`,`<kind>:<id>`);let r=t.slice(0,n).toLowerCase();if(!isReferenceKind(r))return refuse$1(`unknown_kind`,`<kind>:<id> with kind one of ${q.join(`, `)}`);let i=t.slice(n+1).trim();return i===``?refuse$1(`malformed`,`${r}:<id>`):r===`record`&&i.includes(`:`)?refuse$1(`legacy_mention`,`record:${i.slice(i.lastIndexOf(`:`)+1)}`):i===`*`&&!eu.has(r)?refuse$1(`malformed`,`${r}:<id>`):{ok:!0,ref:{kind:r,id:i}}}function formatReference(e){return`${e.kind}:${e.id}`}function isWildcard(e){return e.id===`*`&&eu.has(e.kind)}function requestedCapabilities(e){let t=[];return e.canModify&&t.push(`modify`),e.canSend&&t.push(`send`),t}const nu={status:`connector_status`,error:`connector_error`,provider:`connector_provider`},ru=`box`,iu=[`circle`,`square`],au={object:[`icon`,`color`],record:[`icon`,`image`],emailCategory:[`icon`,`color`],option:[`color`],view:[`icon`],agent:[`color`],user:[`image`]};function resolveAppearance(e,t){if(e.imageFileId)return{kind:`image`,imageFileId:e.imageFileId,shape:t?.imageShape??`square`};let n=t?.name??e.name,r=e.color??t?.color??(n?zc(n):void 0),i=e.icon??t?.icon??`box`;return r?{kind:`tile`,icon:i,color:r}:{kind:`glyph`,icon:i}}const J=/^[a-z0-9][a-z0-9-]{0,62}$/;function assertSchemaSourceId(e){if(!J.test(e))throw new A(`Invalid schema source id "${e}": expected a lowercase slug matching ${J}`,[])}const ou={phone:`text`,currency:`number`},su={rename:[`kind`,`object`,`from`,`to`],phone:[`kind`,`object`,`attribute`,`to`,`defaultCountryCode`],currency:[`kind`,`object`,`attribute`,`to`,`currencyCode`]};function refuse(e,t,n){throw new A(n,[{path:t===void 0?[`resolutions`,String(e)]:[`resolutions`,String(e),t],message:n}])}function assertKeys(e,t,n){for(let r of n)(typeof t[r]!=`string`||t[r]===``)&&refuse(e,r,`Resolution ${e} needs a non-empty string \`${r}\``);let r=Object.keys(t).find(e=>!n.includes(e));r!==void 0&&refuse(e,r,`Resolution ${e} has an unknown field \`${r}\``)}function assertResolution(e,t){if(Ns(t)||refuse(e,void 0,`Resolution ${e} must be an object`),t.kind===`rename`){assertKeys(e,t,su.rename),t.from===t.to&&refuse(e,`to`,`Resolution ${e} renames "${t.from}" to itself`);return}if(t.kind!==`retype`&&refuse(e,`kind`,`Unknown resolution kind ${JSON.stringify(t.kind)}: expected "rename" or "retype"`),t.to!==`phone`&&t.to!==`currency`&&refuse(e,`to`,`Unsupported retype to ${JSON.stringify(t.to)}: a push converts text → phone and number → currency only`),assertKeys(e,t,su[t.to]),t.to===`phone`){let n=t.defaultCountryCode;/^[A-Z]{3}$/.test(n)&&Hc(n)||refuse(e,`defaultCountryCode`,`Resolution ${e}: "${n}" is not an ISO 3166-1 alpha-3 country code`);return}let n=t.currencyCode;/^[A-Z]{3}$/.test(n)&&Vc(n)||refuse(e,`currencyCode`,`Resolution ${e}: "${n}" is not a supported ISO 4217 currency code`)}function addressesOf(e){return e.kind===`rename`?{reads:e.from,lands:e.to}:{reads:e.attribute,lands:e.attribute}}function assertSchemaSourceResolutions(e){if(!Array.isArray(e))throw new A("`resolutions` must be an array",[{path:[`resolutions`],message:"`resolutions` must be an array"}]);if(e.length>100)throw new A(`A push carries ${e.length} resolutions; the limit is 100`,[]);let t=new Set;for(let[n,r]of e.entries()){assertResolution(n,r);let{reads:e,lands:i}=addressesOf(r);for(let[a,o]of[[`${r.kind}:${r.object}.${e}`,`of "${r.object}.${e}"`],[`${r.kind}>${r.object}.${i}`,`onto "${r.object}.${i}"`]])t.has(a)&&refuse(n,void 0,`Resolution ${n} repeats a ${r.kind} ${o}`),t.add(a)}}function phoneFromText(e,t){let n=e.trim();if(n===``)return{value:null};let r=Uc(n,Rc(t));if(!r?.isPossible()||r.country===void 0||r.ext!==void 0)return;let i=Bc(r.country)?.iso3;if(i!==void 0)return{value:{countryCode:i,phoneNumber:Fc(n,i)}}}function convertRetypedValue(e,t,n={}){if(t===null)return{value:null};if(e.to===`phone`)return typeof t==`string`?phoneFromText(t,e.defaultCountryCode):void 0;if(typeof t==`number`&&Math.abs(t)<=2**53-1&&!(t<0&&n.allowNegative!==!0))return{value:{code:e.currencyCode,value:t}}}const Y=F.string().refine(e=>e.trim().length>0,`Must not be blank`),cu=F.union([F.tuple([F.literal(`object`),Y]),F.tuple([F.literal(`attribute`),Y,Y]),F.tuple([F.literal(`view`),Y,Y]),F.tuple([F.literal(`content`),Y,Y,Y])]),lu=F.object({label:Y,pluralLabel:F.string().optional(),description:F.string().optional(),icon:M.optional(),color:Ss.optional(),imageShape:F.enum(iu).optional(),labelExpression:F.string(),embeddingExpression:F.string().optional(),sealed:F.boolean().optional(),toleratedAttributes:F.array(Y).optional(),metadata:F.record(F.string(),F.unknown()).optional(),documentLayout:F.record(F.string(),F.unknown()).optional()}).strict();function failure(e){throw new A(e,[])}function definitionSchema(e){return F.custom(t=>{let n=F.record(F.string(),F.unknown()).parse(t);for(let t of e[0]===`view`?[`object`,`name`]:[`name`])Object.hasOwn(n,t)&&failure(`Invalid schema state: unrecognized definition key ${t}`);switch(e[0]){case`object`:lu.parse(n);break;case`attribute`:{let e=F.enum(Ut).parse(n.type);ac(e).extend({type:F.literal(e),label:Y,required:F.boolean().optional(),unique:F.boolean().optional(),icon:M.optional()}).strict().parse(n);break}case`view`:{let{contents:t,...r}=n,i=F.array(Y).parse(t);new Set(i).size!==i.length&&failure(`Invalid schema state: duplicate content membership`),Qt.parse({...r,object:e[1],name:e[2],contents:[]});break}case`content`:w.parse({...n,name:e[3]})}return!0})}function compareSchemaStateEntries(e,t){let n=JSON.stringify(e.address),r=JSON.stringify(t.address);return n<r?-1:+(n>r)}function schemaStateSourcePayload(e){return{modelVersion:1,hashVersion:1,entries:[...e].sort(compareSchemaStateEntries).filter(e=>e.source!==null).map(({address:e,source:t})=>({address:e,source:t}))}}function parseState(e){let t=F.record(F.string(),F.unknown()).parse(e);for(let[e,n]of[[`modelVersion`,`model`],[`hashVersion`,`hash`]])t[e]!==1&&failure(`Unsupported schema ${n} version: expected 1, received ${t[e]===void 0?`missing`:String(t[e])}`);let n=F.object({modelVersion:F.literal(1),hashVersion:F.literal(1),tenant:Y,sourceFingerprint:F.string().regex(/^[a-f0-9]{64}$/),entries:F.array(F.unknown())}).strict().safeParse(e);if(!n.success){let e=n.error.issues.find(e=>e.code===`unrecognized_keys`);throw e?.code===`unrecognized_keys`&&failure(`Invalid schema state: unrecognized key ${e.keys[0]}`),A.fromZodErrors(n.error.issues.map(e=>({path:e.path.map(String),message:e.message})))}let r=new Set,i=n.data.entries.map(e=>{let t=cu.parse(F.object({address:F.unknown()}).parse(e).address),n=JSON.stringify(t);r.has(n)&&failure(`Invalid schema state: duplicate address ${n}`),r.add(n);let i=definitionSchema(t).nullable(),a=t[0]===`object`||t[0]===`attribute`?F.object({id:F.string().uuid(),updatedAt:F.string().datetime()}).strict():F.object({id:F.string().uuid(),revision:F.number().int().nonnegative()}).strict(),o=F.object({address:cu,source:i,effective:i,status:F.enum([`source`,`runtime`,`copy`,`suppressed`]),sourceOwner:F.union([F.literal(`core`),F.string().regex(/^(bundle|source):.+$/)]).nullable(),guard:a.nullable()}).strict().parse(e);(o.status===`runtime`&&(o.source!==null||o.effective===null||o.sourceOwner!==null)||o.status===`suppressed`&&(t[0]!==`content`||o.source===null||o.effective!==null||o.guard===null)||o.status===`copy`&&(o.source===null||o.effective===null)||o.effective!==null&&o.guard===null||o.source===null&&o.effective===null)&&failure(`Invalid schema state: inconsistent status at ${n}`);let s=o.sourceOwner;s!==null&&s!==`core`&&!s.startsWith(`bundle:`)&&!s.startsWith(`source:`)&&failure(`Invalid source owner`);let c=s===null||s===`core`?s:s.startsWith(`bundle:`)?`bundle:${s.slice(7)}`:`source:${s.slice(7)}`;return{...o,sourceOwner:c}});return{...n.data,entries:i.sort(compareSchemaStateEntries)}}function parseSchemaState(e){try{return parseState(e)}catch(e){throw e instanceof F.ZodError?A.fromZodErrors(e.issues.map(e=>({path:e.path.map(String),message:e.message}))):e}}function diffSchemaState(e){let t=[];for(let n of[...e.entries].sort(compareSchemaStateEntries)){let e=n.source===null?`added`:n.status===`suppressed`?`suppressed`:n.effective===null?`removed`:P(n.source)===P(n.effective)?n.status===`copy`?`copied`:null:`changed`;e&&t.push({...n,change:e})}return{modelVersion:1,tenant:e.tenant,sourceFingerprint:e.sourceFingerprint,changes:t}}const X=F.string().min(1),uu=F.union([F.object({objectName:X,viewName:X,contentName:X.optional()}).strict().describe(`Full configuration of a view, or of one content when contentName is given`),F.object({objectId:X}).strict().describe(`An object with its attributes, by id`),F.object({objectName:X}).strict().describe(`An object with its attributes`),F.object({objectId:X,attributeName:X}).strict().describe(`One attribute's config, by name`),F.object({objectId:X,attributeId:X}).strict().describe(`One attribute's config, by id`),F.object({objectId:X,recordId:X}).strict().describe(`One sample record`)]);function parseNamedTarget(e){let t=uu.safeParse(e);if(!t.success)throw new A(`Invalid scoped target`,[{path:[`target`],message:`Expected exactly one named target branch`}]);return t.data}const du=F.object({mode:F.enum([`inline`,`window`]),interaction:F.enum([`static`,`interactive`]),size:F.enum([`compact`,`regular`]),aspectRatio:F.number().positive().finite().optional()}).strict(),fu=F.object({artifactId:F.string().min(1),revision:F.number().int().positive(),name:F.string().min(1),kind:F.string().min(1),retention:F.enum(bl),display:du}).strict();function readArtifactResult(e){let t=fu.safeParse(e);return t.success?t.data:null}const pu=F.string().regex(/^[^/\s]+\/[^/\s]+$/),mu=F.object({kind:F.literal(`generated-image`),artifact:F.unknown(),generation:F.object({attemptId:F.uuid(),requestedModelId:pu,executedModelId:pu.nullable(),format:F.enum(El),mimeType:F.enum([`image/png`,`image/jpeg`,`image/webp`])}).strict()}).strict();function readGeneratedImageResult(e){let t=mu.safeParse(e);if(!t.success)return null;let n=readArtifactResult(t.data.artifact);return!n||n.kind!==`image`?null:{...t.data,artifact:{...n,kind:`image`}}}function isCompletedToolPart(e){return e.type===`tool`&&e.state===`completed`}function readString(e,t){let n=e[t];return typeof n==`string`?n:void 0}function upsertWithPrecedence(e,t,n,r){let i=e.get(t),a=i&&r[i.kind]>r[n.kind]?i:n;e.delete(t),e.set(t,a)}function asRecord(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function readRefId(e,t,n){let r=readString(e,t),i=`${n}:`;return r?.startsWith(i)&&r.length>i.length?r.slice(i.length):void 0}function verbResultEntries(e){let t=asRecord(e);if(!t)return[];let n=[t];for(let e of[`members`,`created`,`updated`]){let r=t[e];if(Array.isArray(r))for(let e of r){let t=asRecord(e);t&&n.push(t)}}return n.filter(e=>!(`error`in e))}const hu={created:1,modified:0};function readSingleRecordEntry(e){if(typeof e!=`object`||!e)return null;let t=e,n=typeof t.record==`object`&&t.record!==null?t.record:void 0,r=(n&&readString(n,`id`))??readString(t,`recordId`);return r?{id:r,label:(n&&readString(n,`label`))??r,objectName:(n&&readString(n,`objectName`))??``}:null}function readBulkRecordEntries(e,t,n){if(typeof e!=`object`||!e)return[];let r=e[t];if(!Array.isArray(r))return[];let i=[];for(let e of r){if(typeof e!=`object`||!e)continue;let t=e,r=readString(t,`id`);r&&i.push({id:r,label:readString(t,`label`)??r,objectName:readString(t,`objectName`)??n})}return i}function readVerbRecordEntries(e){let t=asRecord(asRecord(e.result)?.record),n=readString(e.args,`object`)??(t&&readString(t,`objectName`))??``,r=[];for(let t of verbResultEntries(e.result)){let e=readRefId(t,`ref`,`record`);e&&r.push({id:e,label:readString(t,`title`)||readString(t,`label`)||e,objectName:readString(t,`objectName`)??n})}return r}function extractTouchedRecords(e){let t=new Map;for(let n of e)if(n.role===`assistant`)for(let e of n.parts){if(!isCompletedToolPart(e))continue;let n=[],r;if(e.name===`create_record`||e.name===`update_record`||e.name===`edit_content`){let t=readSingleRecordEntry(e.result);n=t?[t]:[],r=e.name===`create_record`?`created`:`modified`}else if(e.name===`bulk_create_records`||e.name===`bulk_update_records`){let t=readString(e.args,`objectId`)??``,i=e.name===`bulk_create_records`?`created`:`updated`;n=readBulkRecordEntries(e.result,i,t),r=e.name===`bulk_create_records`?`created`:`modified`}else if(e.name===`write`)n=readVerbRecordEntries(e),r=readString(e.args,`action`)===`create`?`created`:`modified`;else continue;for(let e of n){let n={recordId:e.id,objectName:e.objectName,label:e.label,kind:r};upsertWithPrecedence(t,e.id,n,hu)}}return[...t.values()]}const gu={modified:1,consulted:0};function isFilePart(e){return e.type===`file`}function entryFromDocumentMutation(e,t){if(typeof e.result!=`object`||e.result===null)return null;let n=e.result,r=readString(n,`documentId`)??(t===`folderId`?readString(n,t):void 0);return r?{id:r,title:readString(e.args,`name`)??readString(e.args,`title`)??r,kind:`modified`}:null}function entryFromReadDocument(e){let t=readString(e.args,`documentId`);return t?{id:t,title:t,kind:`consulted`}:null}function entryFromRef(e,t,n){let r=readRefId(e,`ref`,`file`),i=r??readRefId(e,`ref`,`document`);return i?{id:i,...r?{fileId:r}:{},title:n||readString(e,`title`)||i,kind:t,mimeType:readString(e,`mimeType`)}:null}function entriesFromOrganize(e){let t=asRecord(e.result);if(!t||`error`in t)return[];let n=readString(e.args,`action`),r=readString(e.args,`name`)??readString(e.args,`title`),i=readString(t,`documentId`);if(i)return[{id:i,title:r??i,kind:`modified`}];let a=readString(t,`folderId`);if(a)return n===`create_folder`?[{id:a,title:r??a,kind:`modified`}]:[];let o=entryFromRef(t,`modified`,r);return o?[o]:[]}function entriesFromCopy(e){let t=asRecord(e.result);if(!t||`error`in t)return[];let n=(Array.isArray(t.copied)?t.copied:[]).flatMap(e=>{let t=asRecord(e),n=t?entryFromRef(t,`modified`,void 0):null;return n?[n]:[]});if(n.length>0)return n;let r=entryFromRef(t,t.ref!==void 0&&t.ref===readString(e.args,`from`)?`consulted`:`modified`,void 0);return r?[r]:[]}function entriesFromRead(e){let t=asRecord(e.result);return(Array.isArray(t?.members)?t.members:[]).flatMap(e=>{let t=asRecord(e);if(!t||`error`in t||!readRefId(t,`ref`,`document`))return[];let n=entryFromRef(t,`consulted`,void 0);return n?[n]:[]})}function entriesFromToolPart(e){switch(e.name){case`organize`:return entriesFromOrganize(e);case`copy`:return entriesFromCopy(e);case`read`:return entriesFromRead(e);default:{let t=entryFromToolPart(e);return t?[t]:[]}}}function entryFromSandboxUpload(e){if(typeof e.result!=`object`||e.result===null)return null;let t=e.result,n=readString(t,`fileId`);return n?{id:n,fileId:n,title:readString(t,`title`)??n,kind:`modified`,mimeType:readString(t,`mimeType`)}:null}function entryFromToolPart(e){switch(e.name){case`update_document`:case`attach_file`:return entryFromDocumentMutation(e,`documentId`);case`create_folder`:return entryFromDocumentMutation(e,`folderId`);case`read_document`:return entryFromReadDocument(e);case`sandbox_upload_file`:return entryFromSandboxUpload(e);default:return null}}function extractTouchedDocuments(e){let t=new Map;for(let n of e)if(n.role===`assistant`){for(let e of n.parts)if(isCompletedToolPart(e))for(let n of entriesFromToolPart(e))upsertWithPrecedence(t,n.id,n,gu);else if(isFilePart(e)&&e.fileId){let n={id:e.fileId,fileId:e.fileId,title:e.name||e.fileId,kind:`modified`,mimeType:e.mimeType};upsertWithPrecedence(t,n.id,n,gu)}}return[...t.values()]}function extractTouchedArtifacts(e){let t=new Map;for(let n of e)if(n.role===`assistant`)for(let e of n.parts){if(!isCompletedToolPart(e)||e.error)continue;let n=e.name===`generate_image`?readGeneratedImageResult(e.result)?.artifact:e.name===`publish_artifact`?readArtifactResult(e.result):null;if(!n)continue;let r=`${n.artifactId}:${n.revision}`;t.delete(r),t.set(r,n)}return[...t.values()]}function isNonBlankString(e){return typeof e==`string`&&/\S/u.test(e)}const _u=F.object({provider:F.custom(e=>isNonBlankString(e)&&e.length<=200,{message:`must be a non-blank string of at most 200 characters`}),model:F.string().max(200).regex(/\S/u)});function normalizeNewsLocale(e){return e.toLowerCase().split(`-`)[0]===`fr`?`fr`:`en`}function resolveLocalized(e,t){return e[normalizeNewsLocale(t)]||(e.en?e.en:e.fr||void 0)}function hasLocale(e){return!!(e.fr||e.en)}const vu=Object.keys({home:!0,agents:!0,routines:!0,object:!0,settings:!0}),yu=[`dot`,`label`,`bubble`];function parseNewsIntensity(e){return yu.find(t=>t===e)??`dot`}function parseNewsTarget(e){let[t,...n]=e.split(`:`),r=n.join(`:`);switch(t){case`home`:case`agents`:case`routines`:return r===``?{kind:t}:null;case`object`:return r?{kind:t,name:r}:null;case`settings`:return r?{kind:t,section:r}:null;default:return null}}function formatNewsTarget(e){return e.kind===`object`?`object:${e.name}`:e.kind===`settings`?`settings:${e.section}`:e.kind}function withoutTrailingSlashes(e){let t=e.length;for(;t>0&&e[t-1]===`/`;)--t;return e.slice(0,t)}const Z=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/;function compareIdentifiers(e,t){let n=/^\d+$/.test(e),r=/^\d+$/.test(t);return n&&r?Math.sign(Number(e)-Number(t)):n?-1:r?1:e<t?-1:+(e>t)}function compareVersions(e,t){let n=Z.exec(e),r=Z.exec(t);if(!(n&&r))return null;for(let e=1;e<=3;e+=1){let t=Number(n[e])-Number(r[e]);if(t!==0)return t<0?-1:1}let i=n[4],a=r[4];if(i===void 0&&a===void 0)return 0;if(i===void 0)return 1;if(a===void 0)return-1;let o=i.split(`.`),s=a.split(`.`);for(let e=0;e<Math.max(o.length,s.length);e+=1){let t=o[e],n=s[e];if(t===void 0)return-1;if(n===void 0)return 1;let r=compareIdentifiers(t,n);if(r!==0)return r<0?-1:1}return 0}function isSemver(e){return Z.test(e)}const bu=30,xu=90,Su=50,Q=F.looseObject({fr:F.string().optional(),en:F.string().optional()}),$=F.iso.datetime({offset:!0}),Cu=F.looseObject({id:F.string().min(1),slug:F.string().min(1),updatedAt:$,publishedAt:$,since:F.string(),displayDays:F.number().int().positive().optional(),requires:F.looseObject({capability:F.string(),level:F.string()}).optional(),target:F.string().optional(),intensity:F.unknown().optional(),title:Q,summary:Q});function knownRequirement(e){let t=U.find(t=>t.id===e.capability);return t!==void 0&&levelActions(t,e.level).length>0}function parseEntry(e){let t=Cu.safeParse(e);if(!t.success)return`malformed entry: ${t.error.issues[0]?.message??`invalid`}`;let n=t.data;if(!isSemver(n.since))return`entry ${n.id}: since "${n.since}" is not semver`;if(!hasLocale(n.title))return`entry ${n.id}: title has no locale`;if(!hasLocale(n.summary))return`entry ${n.id}: summary has no locale`;if(n.requires&&!knownRequirement(n.requires))return`entry ${n.id}: unknown requirement ${n.requires.capability}/${n.requires.level}`;let r=n.target?parseNewsTarget(n.target):null;return{...n,displayDays:n.displayDays??30,intensity:parseNewsIntensity(n.intensity),target:r??void 0}}function httpsUrl(e){return typeof e==`string`&&e.startsWith(`https://`)?e:void 0}function parseNewsIndex(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw new A(`News feed: document must be an object`,[]);let n=e;if(!Array.isArray(n.entries))throw new A(`News feed: entries must be an array`,[]);let r=[];for(let e of n.entries){let n=parseEntry(e);typeof n==`string`?t?.(n):r.push(n)}let i=httpsUrl(n.blogUrl),a=httpsUrl(n.mediaBaseUrl),o=a?withoutTrailingSlashes(a):void 0;return{...i?{blogUrl:i}:{},...o?{mediaBaseUrl:o}:{},entries:r.slice(0,50)}}const wu=F.looseObject({id:F.string().min(1),slug:F.string().min(1),updatedAt:$,body:Q});function parseNewsBody(e){let t=wu.safeParse(e);if(!t.success)throw new A(`News body: malformed document`,[]);if(!hasLocale(t.data.body))throw new A(`News body: body needs at least one locale`,[]);return t.data}function preference(e,t){return{key:e,value:t.value,default:t.default,audited:t.audited??!1,...t.parameter===void 0?{}:{parameter:t.parameter},...t.parameters===void 0?{}:{parameters:t.parameters},...t.refine===void 0?{}:{refine:t.refine}}}const Tu=``;function refusal(e,t){return{ok:!1,field:e,message:t,issues:[{path:[e],message:t}]}}function declarationOf(e,t){return`get`in e?e.get(t):e.find(e=>e.key===t)}function locatePreference(e,t,n){let r=declarationOf(e,t);return r?r.parameter===void 0?n===void 0?{ok:!0,declaration:r,parameter:``}:refusal(`parameter`,`Preference "${t}" takes no parameter`):n===void 0||n===``||n.trim()!==n?refusal(`parameter`,`Preference "${t}" is keyed by ${r.parameter}`):r.parameters&&!r.parameters.includes(n)?refusal(`parameter`,`"${n}" is not a ${r.parameter} of "${t}"`):{ok:!0,declaration:r,parameter:n}:refusal(`key`,`Unknown preference "${t}"`)}function judgePreferenceWrite(e,t,n,r){let i=locatePreference(e,t,n);if(!i.ok)return i;let a=i.declaration.value.safeParse(r);if(a.success){let e=i.declaration.refine?.(a.data,i.parameter);return e===void 0?{...i,value:a.data}:refusal(`value`,e)}return{ok:!1,field:`value`,message:`Invalid value for preference "${t}"`,issues:a.error.issues.map(e=>({path:[`value`,...e.path.map(String)],message:e.message}))}}const Eu=F.strictObject({model:_u.optional(),routing:F.literal(`auto`).optional()}),Du=F.strictObject({inApp:F.boolean(),email:F.boolean()});function isActionableType(e){let r=t[e];return r!==void 0&&n(r.kind)}const Ou=[preference(`workPosture`,{value:F.enum(Li),default:`auto`,audited:!0}),preference(`chat.default`,{value:Eu,default:{},audited:!0}),preference(`conversationSurface`,{value:F.enum(Cr),default:`panel`}),preference(`mailboxListMode`,{value:F.enum(na),default:`threads`}),preference(`home`,{value:F.string().uuid().nullable(),default:null}),preference(`memory.observeActivity`,{value:F.boolean(),default:!0,audited:!0}),preference(`memory.learnFromEmail`,{value:F.boolean(),default:!0,audited:!0}),preference(`notifications.briefingSeenAt`,{value:F.iso.datetime().nullable(),default:null}),preference(`notifications.delivery`,{value:Du,default:{inApp:!0,email:!1},parameter:`notification type`,parameters:Object.keys(t),refine:(e,t)=>!e.inApp&&isActionableType(t)?`A "${t}" notification asks you to act: it is always shown in-app`:void 0})];function preferenceEntry(e,t,n){return n===void 0?{key:e,value:t}:{key:e,parameter:n,value:t}}function withPreferenceEntry(e,t){if(t.parameter===void 0)return{...e,values:{...e.values,[t.key]:t.value}};let n=e.entries.findIndex(e=>e.key===t.key&&e.parameter===t.parameter),r=n===-1?[...e.entries,t]:e.entries.map((e,r)=>r===n?t:e);return{...e,entries:r}}export{Io as ACCESS_ROLES,d as ACTIONABLE_NOTIFICATION_KINDS,g as AGENDA_BLOCK,ds as AGENT_ASIDE_ANSWER_MAX_LENGTH,xa as AGENT_ASIDE_HISTORY_LIMIT,ss as AGENT_ASIDE_QUESTION_MAX_LENGTH,Pi as AGENT_AVATAR_EXPRESSIONS,wr as AGENT_AVATAR_TYPES,rs as AGENT_MESSAGE_KIND,Ri as AGENT_NOTIFICATION_KIND,Mr as AGENT_SESSION_LIST_ORDERS,Ga as AGENT_SESSION_ORIGINS,Or as AGENT_STARTERS_MAX,vi as AGENT_STARTER_MAX_LENGTH,io as AGENT_TASK_KINDS,re as AGGREGATE_BUCKETS,m as AGGREGATE_MEASURES,kl as ALLOWED_PROPERTY_TYPES,ji as ALL_CATALOG_TOOL_NAMES,z as ALL_PIPES,gs as ALWAYS_KINDS,au as APPEARANCE_FACETS,pi as APPROVAL_FAMILY_TOOL_NAMES,xl as ARTIFACT_FILE_ROLES,yl as ARTIFACT_KINDS,Ye as ARTIFACT_PREVIEW_EXTENSION,bl as ARTIFACT_RETENTIONS,xi as ASK_QUESTIONS_ANSWER_MAX_LENGTH,Fr as ASK_QUESTIONS_ANSWER_MAX_VALUES,qr as ASK_QUESTIONS_MAX_BATCH,ai as ASK_QUESTIONS_TOOL_NAME,Lt as ATTRIBUTE_FILTER_OPERATORS,Ms as ATTRIBUTE_NAME_SCHEMA,Ut as ATTRIBUTE_TYPES,dr as AUDIT_ACTIONS,Na as AUDIT_AGENT_SESSION_METADATA_KEY,Go as AUDIT_RESOURCE_TYPES,xn as AccessDeniedError,AgendaBuilder,Tr as AgentBuilder,Sn as AggregateValidationError,Cn as AmbiguousSchemaChangeError,wn as AttributeInUseError,Tn as AttributeNotFoundError,Ce as BLOCK_CONTEXTS,en as BLOCK_PERIODS,_ as BLOCK_WIDTHS,Jc as BROWSER_IMAGE_MAX_BYTES,Va as BROWSER_LAUNCH_TOOL_NAME,Ol as BYTE_UNIT_LABELS,BlockContentBuilder,v as CARD_BLOCK,Vl as CATALOG_RESOURCES,x as CHART_BLOCK,Ze as CHART_KINDS,Gs as COMPUTED_RETURN_TYPES,xr as CONNECTION_GRANT_PROVIDERS,nu as CONNECTOR_CALLBACK_PARAM,on as CONTENT_PLACEMENT_CONTEXTS,No as CONTINUATION_KEY_PATTERN,Cr as CONVERSATION_SURFACES,Ou as CORE_PREFERENCES,qi as CORE_RECORD_TOOL_NAMES,Gr as CORE_TOOL_NAMES,R as COUNT_MODES,Bl as CUSTOM_LEVEL,CardBuilder,ChartBuilder,ChartQuery,En as ConcurrentModificationError,K as ContentBuilder,is as DEFAULT_AGENT_EXECUTION_CONFIG,Ui as DEFAULT_AGENT_TOOL_GROUPS,ru as DEFAULT_APPEARANCE_ICON,gr as DEFAULT_APPROVAL_POLICY,Zi as DEFAULT_BLUEPRINT_TOOL_GROUPS,eo as DEFAULT_DAILY_ACTIVITY_DAYS,vl as DEFAULT_DICTATION_LIMITS,Ll as DEFAULT_LABEL_FALLBACK,tn as DEFAULT_LAYOUT_TRAITS,jr as DEFAULT_MEETING_BOT_DISPLAY_NAME,Dr as DEFAULT_TENANT_SETTINGS,Bs as DEFAULT_VALIDATION_MESSAGES,Yc as DEVICE_CHANNEL_AUTHENTICATE_TIMEOUT_MS,Xc as DEVICE_CHANNEL_IDLE_POLL_MS,Qc as DEVICE_CHANNEL_KEEPALIVE_MS,qc as DEVICE_CHANNEL_MAX_FRAME_BYTES,Kc as DEVICE_CHANNEL_PATH,Zc as DEVICE_CHANNEL_PRESENCE_MS,nl as DEVICE_CHANNEL_UPGRADE_REQUIRED_REASON,$c as DEVICE_CHANNEL_WORKER_CLOSE_PROTOCOL_VIOLATION,tl as DEVICE_COMMAND_ERROR_CODES,gl as DICTATION_FINALIZATION_TIMEOUT_MS,ul as DICTATION_FRAME_BYTES,fl as DICTATION_MAX_BUFFER_BYTES,dl as DICTATION_MAX_FRAME_BYTES,pl as DICTATION_MAX_TRANSCRIPT_BYTES,_l as DICTATION_MODEL_ID,hl as DICTATION_PREPARATION_TIMEOUT_MS,ll as DICTATION_SAMPLE_RATE,ml as DICTATION_TICKET_TTL_MS,ra as DISCARD_ARCHITECT_DRAFT_TOOL_NAME,ka as DOCUMENT_SORT_MODES,$i as DRAFT_WRITE_TOOL_NAMES,DeviceChannelProtocolError,ol as DeviceChannelServerFrameSchema,al as DeviceChannelWorkerFrameSchema,Dn as DuplicateError,Nr as EMAIL_CATEGORY_DEFAULT_COLOR,kr as EMAIL_CATEGORY_DEFAULT_ICON,yi as EMAIL_CATEGORY_DESCRIPTION_MAX,ao as EMAIL_CATEGORY_DESCRIPTION_MIN,_r as EMAIL_CATEGORY_LIMIT,to as EMAIL_CATEGORY_NAME_MAX,ga as ENVIRONMENT_HARNESSES,So as ENVIRONMENT_HARNESS_SANDBOX_WORKDIR,zo as ENVIRONMENT_HARNESS_WORKDIR,wa as ENVIRONMENT_NAME_MAX_CHARS,so as ENVIRONMENT_STANDARDS_WORKDIR,qa as ENV_VAR_KEY_PATTERN,cl as ESTIMATED_COUNT_CAP,On as ExportTooLargeError,ro as FILE_URLS_MAX_IDS,L as FORM_FORBIDDEN_ATTRIBUTE_TYPES,kn as ForbiddenError,FormBuilder,FormRowBuilder,FormStepBuilder,sa as GET_ARCHITECT_DRAFT_TOOL_NAME,Ha as GITHUB_TRIGGER_CATALOG,Vr as GRANT_ENABLES,Se as GROUPABLE_ATTRIBUTE_TYPES,Zl as GroupBuilder,Oe as HEADING_BLOCK,ki as HITL_TOOL_NAMES,El as IMAGE_FORMATS,iu as IMAGE_SHAPES,Xt as INBOX_BLOCK,ui as INFERENCE_REASONING_OPTIONS,mi as INFERENCE_ROUTING_MODES,Si as INFERENCE_SPEEDS,gt as INVENTORY_LIMIT,InboxBuilder,An as InvalidPermissionGrantError,Ir as LAST_RUN_ERROR_MAX_LENGTH,Ds as LIST_VIEW_TAB_VISIBILITIES,sn as LOCATION_FILTER_PROPERTIES,De as MAILBOX_BLOCK,na as MAILBOX_LIST_MODES,Qi as MAIL_DRAFT_BODY_MAX_CHARS,oa as MAIL_SUBJECT_MAX_CHARS,te as MAX_AGGREGATE_GROUPS,Jr as MAX_DAILY_ACTIVITY_DAYS,sl as MAX_PRESET_DEPTH,oi as MAX_TODOS,Ai as MAX_TODO_DESCRIPTION_CHARS,hs as MAX_TODO_ID_CHARS,Za as MCP_SERVER_NAME_MAX_LENGTH,tt as MEASURABLE_ATTRIBUTE_TYPES,$e as MEETINGS_UPCOMING_BLOCK,wo as MEETING_BOT_IMAGE,Vo as MEETING_BOT_IMAGE_BASE64_MAX_LENGTH,W as MEMORY_ATTRIBUTES,Kl as MEMORY_PAGE_MAX_CHARS,_i as MEMORY_SPEND_LIMIT_PATTERN,ql as MEMORY_WORKSPACE_PROFILE,Gl as MEMORY_WRITE_SOURCE,S as METRIC_BLOCK,MailboxBuilder,va as McpOAuthCompletionMode,jn as MemoryNotFoundError,MetricBuilder,MetricQuery,MultiRelationAttributeBuilder,Wc as NATIVE_AGENT_UI_PART_IDS_METADATA_KEY,Gc as NATIVE_AGENT_UI_PART_IDS_METADATA_SCHEMA_VERSION,ze as NATIVE_BLOCKS,vs as NATIVE_OBJECT_NAMES,fa as NATIVE_TOOL_GROUPS,ri as NATIVE_TOOL_GROUP_CATALOG,bu as NEWS_DEFAULT_DISPLAY_DAYS,xu as NEWS_DISPLAY_CAP_DAYS,Su as NEWS_INDEX_MAX_ENTRIES,yu as NEWS_INTENSITIES,vu as NEWS_TARGET_KINDS,i as NOTIFICATION_CHANNELS,h as NOTIFICATION_INBOX_STATES,ne as NOTIFICATION_KINDS,o as NOTIFICATION_PRIORITIES,f as NOTIFICATION_PRIORITY_RANK,ie as NOTIFICATION_SENSITIVITIES,s as NOTIFICATION_SETTINGS_AREAS,c as NOTIFICATION_SUBJECT_TYPES,ee as NOTIFICATION_TYPES_V1,p as NOTIFICATION_TYPE_ACCESS_GRANTED,u as NOTIFICATION_TYPE_AGENT_QUESTION_REQUESTED,l as NOTIFICATION_TYPE_AGENT_ROUTINE_RUN_FAILED,r as NOTIFICATION_TYPE_AGENT_ROUTINE_RUN_NOTICE,ae as NOTIFICATION_TYPE_AGENT_SESSION_WAITING_HUMAN,ce as NOTIFICATION_TYPE_AGENT_TASK_ASSIGNED,a as NOTIFICATION_TYPE_CONNECTOR_CONNECTION_ERROR,se as NOTIFICATION_TYPE_CONNECTOR_CONNECTION_REAUTH_REQUIRED,t as NOTIFICATION_TYPE_KINDS,e as NOTIFICATION_TYPE_RECORD_ASSIGNED,oe as NOTIFICATION_WORK_STATES,V as NO_ACCESS,Tu as NO_PREFERENCE_PARAMETER,Ea as NO_RECORDING,Be as NO_VALUE_OPERATORS,yc as NonJsonValueError,NoopGeocodingAdapter,Mn as NotFoundError,Nn as NotImplementedError,H as OBJECT_GRANT,Os as OBJECT_NAME_SCHEMA,br as OPEN_TOOL_PART_STATES,Ho as OPERATION_MAX_STEPS,ue as OPERATORS_BY_TYPE,ObjectBuilder,Pn as ObjectNotFoundError,Fn as ObjectReferencedError,In as OrphanSystemAttributeError,Te as PAGE_GRID_COLUMNS,Ul as PERMISSION_ACTIONS,U as PERMISSION_CAPABILITIES,zl as PERMISSION_CATALOG,jl as PIPES_WITH_ARGS,wi as PROVIDER_DRAFT_LABEL,Ki as PROVIDER_NAMES,di as PUBLIC_MAIL_DOMAINS,$l as PageBuilder,Ln as PageReferencedError,Rn as ProtectedResourceError,zn as ProtectedRoleError,nt as QUALIFIED_SEPARATOR,jt as QUERY_OBJECT,ms as QUESTION_FAMILY_TOOL_NAMES,Dl as QUOTA_KEYS,Bn as QueryTimeoutError,$a as RECENT_ACTIVITY_LEDGER_LIMIT,lo as RECORDING_OVERRIDES,Xo as RECORDING_POLICIES,Xa as RECORD_ACCESS_ROLES,_a as RECORD_ACCESS_SOURCES,La as RECORD_DRIVE_CURSOR_MAX_LENGTH,Do as RECORD_DRIVE_PAGE_DEFAULT_LIMIT,po as RECORD_DRIVE_PAGE_MAX_LIMIT,Qo as RECORD_GRAPH_DEFAULT_LIMIT_PER_NODE,us as RECORD_GRAPH_MAX_LIMIT_PER_NODE,ba as RECORD_GRAPH_MAX_NODES,hr as RECORD_IMAGE_MAX_BYTES,le as RECORD_LINKS_BLOCK,C as RECORD_LINKS_CONTENT,ws as RECORD_LIST_SCOPES,lt as RECORD_OBJECT,q as REFERENCE_KINDS,$t as RELATION_TARGET_ANY,Ot as REMOVED_OPERATOR_REPLACEMENTS,ur as REPLY_MODES,Ti as REQUEST_DESIGN_REVIEW_TOOL_NAME,yr as REQUEST_SETUP_TOOL_NAME,Cs as RESERVED_ATTRIBUTE_NAMES,ys as RESERVED_OBJECT_NAMES,$o as RESOURCE_GRANT_KINDS,Mo as RESOURCE_KIND_CATALOG,Ps as RESOURCE_VISIBILITIES,Wr as ROUTING_PRICE_CEILINGS,Vn as RealtimeDeliveryError,Hn as RealtimeRateLimitedError,Un as RealtimeSubscriptionError,Wn as RecordNotFoundError,rn as RecordQuery,Gn as RecordReferencedError,Kn as RepositoryError,qn as ReservedObjectNameError,Jn as RoleNotFoundError,N as SCHEMA_LIMITS,J as SCHEMA_SOURCE_ID_PATTERN,ou as SCHEMA_SOURCE_RETYPE_FROM,Hi as SESSION_INFERENCE_PATCH_KEYS,Jo as SETUP_SCRIPT_MAX_CHARS,Al as SIMPLE_PIPES,lc as SIMPLE_PROPERTY_TYPES,pa as SLACK_TRIGGER_CATALOG,Jl as STANDARD_SCHEMA_VENDOR,$r as SURFACE_TOOL_NAMES,ge as SYNONYM_ALIASES,vn as SYSTEM_ATTRIBUTES,dt as SYSTEM_ATTRIBUTE_I18N_KEYS,hi as SYSTEM_EMAIL_CATEGORIES,Ci as SYSTEM_EMAIL_CATEGORY_NAMES,Is as SYSTEM_FIELD_NAMES,Tt as SYSTEM_FILTER_ATTRIBUTE_TYPES,Xi as SYSTEM_PART_CODES,O as SchemaError,k as SchemaErrorCode,Yn as SearchBackendError,Xn as SearchPathNotIndexedError,SingleRelationAttributeBuilder,Zn as StorageError,Qn as SyncCascadeError,$n as SyncConflictError,er as SyncError,tr as SystemEntityImmutableError,Br as TASK_DEMAND_LEVELS,Sl as TENANT_INVITATION_DEFAULT_TTL_MS,wl as TENANT_INVITATION_MAX_TTL_MS,Cl as TENANT_INVITATION_MIN_TTL_MS,Tl as TENANT_INVITATION_RESEND_INTERVAL_MS,E as TEXT_BLOCK,Ls as TEXT_FORMAT_PATTERNS,ni as TODO_PLAN_STATUSES,jo as TODO_STATUSES,Qr as TOOL_APPROVAL_STATES,ma as TRIGGER_EVENT_TYPES,ia as TURN_OUTCOMES,nr as ToolGroupGrantError,Co as UNSHAREABLE_OBJECT_NAMES,ns as USER_STATUSES,Li as USER_WORK_POSTURES,aa as VERB_NAMES,A as ValidationError,G as ViewBuilder,ic as WIRE_OFFERED_BASE_CONFIG,sc as WIRE_OMITTED_CONFIG_KEYS,zi as agent,Fa as agentAvatarFromMetadata,To as agentAvatarSchema,Mi as agentDataChunk,ea as agentDisplayName,Sr as agentInferencePreferencesSchema,ts as agentMessageAttachmentSchema,Ii as agentMessagePartSchema,bo as agentScheduleSchema,Ar as agentSessionInferenceOverridesInputSchema,Er as agentSessionInferenceOverridesSchema,gi as agentSessionMessageSchema,uo as agentStartersSchema,Ro as agentTriggerBaseSchema,Ca as agentTriggerPatchSchema,oo as agentTriggerSchema,no as agentUIValidationError,applyPipes,mr as artifactQuoteSchema,xc as asTenantId,vc as asUserId,Gi as askQuestionsOutputSchema,Qa as assertCustomAgentUIMessageChunk,assertSchemaSourceId,assertSchemaSourceResolutions,ca as assertSessionState,tc as attributeConfigSchemas,be as attributeFilterTarget,bt as attributeInventory,ke as blockObjectInputs,buildPropertySchema,et as buildQualifiedAttribute,P as canonicalStringify,ta as canonicalToolGroups,Fe as canonicalizeFilterValue,capabilityForResource,qt as capped,checkbox,Ua as classificationRestoreSchema,za as classifyEmailSchema,Oa as cliDefaultModelOf,zt as collectContentViewCatalogue,ot as collectQualifiedRuleIssues,cn as collectionContentSourceSchema,Ue as collectionSourceAddress,me as collectionSourceAddressOf,Ss as colorIdSchema,vt as columnsSchema,Ei as compareAgentSessionMessages,compareSchemaStateEntries,compareVersions,Ia as compiledHarnessModels,computeByteMagnitude,computeReconnectDelay,computeRetryDelay,la as connectionGrantKindOf,Di as connectionGrantKindsOf,es as connectorTriggerMatchSchema,Ql as content,contentDefinition,D as contentExtensionRegistry,Et as contentReadObjects,T as contentViewDefinitionSchema,Ht as contentViewDefinitionSchemaFor,convertRetypedValue,Tc as createAttributeValidator,Us as createCheckboxValidator,Ws as createDateValidator,Ec as createFormAttributeValidator,Hs as createNumberValidator,createStandardSchemaProps,zs as createTextValidator,currency,pe as currentActor,ci as customDataChunkSchemas,date,declaredImageRequests,bc as deepEqual,Zt as defineBlock,defineDeviceChannelFrames,deriveLayout6,Bo as deriveViewerAccess,detailView,deviceChannelUrl,diffSchemaState,St as displayAttributesSchema,document,Qt as draftContentViewDefinitionSchema,kt as draftContentViewDefinitionSchemaFor,droppedContents,fi as durableDateSchema,ve as edgePropertyFilterTarget,ua as emailCategoryCreateSchema,Zo as emailCategoryDeleteSchema,ls as emailCategoryScopeQuerySchema,ya as emailCategoryUpdateSchema,as as emailRuleScopeSchema,Eo as environmentHarness,fo as environmentWorkdir,extractAttributeNames,He as extractCurrencyFilterValue,bn as extractFilterValue,extractTouchedArtifacts,extractTouchedDocuments,extractTouchedRecords,Le as filterOperatorsOfType,Yt as filterStateSchema,Ft as filterTargetsOf,Wa as findEnvironmentHarness,findGrantIssues,Ae as findGridViolation,Pt as findGroupViolation,de as findLayoutRuleViolation,Ke as findRelationAttribute,Mt as findRowLimitViolation,form,formFieldFlatKey,formFieldKey,formatByteSize,formatNewsTarget,Lc as formatPhoneForDisplay,formatReference,Vs as formatZodErrors,formula,gc as generateId,_t as getAttributeCapabilities,ac as getAttributeConfigSchema,cc as getAttributeConfigWriteSchema,xt as getAttributeFilterOperators,getEditableLabelAttribute,Re as getOperatorPolarity,yt as getRollupFilterOperators,getSingleAttributeFromExpression,getSlotFieldTargets,hn as getSystemAttributeI18nKey,We as getSystemAttributeList,fs as githubConditionSchema,Sa as githubTriggerMatchSchema,pr as grantKindOf,st as gridPositionSchema,group,Me as groupSizeMessage,Pe as groupedMembers,Ba as harnessModelChoices,hasLocale,hasOptions,Ur as humanRequestId,Vi as humanRequestKind,M as iconNameSchema,imageModelFormatDefect,bi as imageModelIdSchema,mc as indexBy,At as inferInverseCardinality,Pr as inferenceReasoningSchema,Kr as inferenceRoutingSchema,ii as inferenceSpeedSchema,Kt as input,n as isActionableNotificationKind,fr as isAgentMessageMetadata,ja as isAgentNotificationMetadata,Oi as isAgentUIDataName,vo as isAgentWrittenAuditEntry,Jt as isAttributeFilterable,Bt as isAttributeGroupable,rr as isAttributeInUseError,Dt as isAttributeKanbanGroupable,wt as isAttributeSearchable,ct as isAttributeSortable,Yi as isAwaitingHuman,Gt as isBilateralRelation,zr as isBlocking,Qe as isCalendarDay,isCatalogResource,Xe as isDynamicValue,jc as isEmptyValue,da as isEnvironmentHarnessId,isFormDefinition,isFormFieldsRow,isFormFreeFieldRef,isFormHeadingRow,isFormSeparatorRow,isFormSlotFieldRef,isFormTextRow,isLabelExpression,at as isLocationFilterProperty,fe as isLocationPartOperator,Pa as isMailProvider,Ko as isMailboxListMode,he as isManagedSystemAttribute,_s as isNativeObjectName,Ma as isNativeToolGroup,an as isNoValueOperator,ir as isNotFoundError,kc as isNullishOrEmptyString,ar as isObjectReferencedError,Uo as isOpenToolPartState,ti as isParkedOnHuman,Ns as isPlainRecord,or as isProtectedResourceError,yo as isProviderDraft,Lr as isPublicMailDomain,sr as isRecordReferencedError,yn as isRelativeDateValue,Lo as isReplyMode,Wo as isResourceGrant,go as isRoutineActorMetadata,cr as isSchemaError,isSemver,ps as isSessionInferencePatch,xe as isSetMembershipOperator,isStandardSchema,Yr as isSystemEmailCategory,si as isSystemEmailCategoryName,Po as isSystemPartCode,Ja as isToolApprovalState,nn as isUniversalRelation,lr as isValidationError,Dc as isValuePresent,isWherePipe,isWildcard,judgePreferenceWrite,keptFill,B as labelExpressionSchema,pt as layoutTraitsOf,levelActions,levelFloor,levelOf,listView,locatePreference,location,Nt as locationPartFilterTarget,Aa as meetingBotDispatchRequestSchema,Ra as meetingBotDispatchResponseSchema,Oo as meetingBotNotificationSchema,mo as meetingTranscriptSegmentSchema,b as memberlessGroups,memoryPageViewOf,vr as mentionReferenceSchema,ha as mergeSessionInferencePatch,Wt as metricComparePeriod,Wi as modelDefinitionSchema,_u as modelIdentitySchema,Hr as modelReferenceSchema,multiselect,Xs as multiselectOptionWriteSchema,nameSlug,uu as namedTargetSchema,nativeAgentUIPartIdMetadataKey,_o as needsManageWhenUnattended,Ic as normalizeCountrylessPhoneNumber,pn as normalizeFilterRule,Ee as normalizeForEdgeRpc,normalizeNewsLocale,qe as normalizeOperator,Fc as normalizePhoneNumber,Ka as normalizedMeetingTranscriptSchema,we as now,number,object,Ao as openRequests,xo as orderAgentSessionMessages,packLayout,page,pageCompactor,It as pageTraitsOf,Ta as parseAgentDefinitionAccessRole,nc as parseAttributeConfig,uc as parseAttributeConfigForCreate,Zs as parseAttributeConfigForUpdate,y as parseBlockParameters,parseCountMode,parseDeviceChannelFrame,qo as parseMergedAgentTrigger,parseNamedTarget,parseNativeAgentUIPartIdsMetadata,parseNewsBody,parseNewsIndex,parseNewsIntensity,parseNewsTarget,parseOptionalCountMode,co as parsePageAccessRole,rt as parseQualifiedAttribute,Yo as parseRecordAccessRole,xs as parseRecordListScope,parseReference,Fs as parseResourceVisibility,parseSchemaGroupPresentation,parseSchemaState,parseServerFrame,Fo as parseToolGroupGrant,parseWherePipe,parseWorkerFrame,Wl as permissionGrantSchema,phone,placeNew,preference,preferenceEntry,Qs as propertyAttributeSchema,oc as propertyAttributeWireSchema,rc as propertySchemaSchema,ec as propertySchemaWireSchema,Bi as providerNameSchema,w as publishedViewContentDefinitionSchema,ht as query,readArtifactResult,Zr as readAskQuestionsResult,readFormFieldValue,readGeneratedImageResult,li as recentActivityEntryKey,os as recordGraphNodeKey,Ni as recordGraphRequestSchema,recordLinksTab,ho as recordOperationSchema,Rt as recordQueryDefinitionSchema,Da as refineTrigger,$s as refuseForeignKeys,Mc as rejectUnknownAttributesOrThrow,relation,ye as relationAcceptsObject,relationProperty,mt as relationTargetsOf,renderLabelExpression,repairPageGrid,requestedCapabilities,_n as requireRecordContentContext,_e as requireSingleRelationTarget,resolveAppearance,ut as resolveCollectionActions,mn as resolveContentNavigation,un as resolveEffectiveFilterType,resolveFieldRequired,ft as resolveIsWithinBounds,resolveLocalized,resolvePageGrid,resolvePropertyDefinitions,Rs as resolveTextPattern,gn as resolveUtcDayBounds,resolveViewContents,Ya as resourceGrant,richtext,rollup,Ji as routedMessageInferenceSchema,sameActions,hc as sameStableValue,schemaGroupKey,schemaStateSourcePayload,select,qs as selectOptionWriteSchema,_c as serializeCanonicalJson,Sc as serializeStableJson,Rr as sessionInferencePatchSchema,settleLayout,Ie as singleRelationTarget,cs as slackConditionSchema,Fi as slackTriggerMatchSchema,snapWidth,Vt as sortsSchema,fn as sourcedAttributeOf,status,dc as statusGroupSchema,pc as statusOptionWriteSchema,storedContentDefinition,Ne as systemColumnFilterTarget,text,je as toMultiValueOperator,Ge as toUtcDayString,Je as today,ei as todoItemSchema,ko as todoPlanSchema,Xr as toolImpactSchema,user,Oc as validateAttribute,Ts as validateAttributeName,it as validateContentViewCatalogue,Cc as validateDraft,Ac as validateDraftOrThrow,validateLabelExpression,Nc as validateObject,validateObjectExpressions,js as validateObjectName,wc as validateObjectOrThrow,dn as validateQualifiedRule,ln as validateStoredViews,Es as validateViewName,widthStepConstraint,Ys as wireHiddenTypeConfigMask,fc as wireOmittedConfigKeysFor,withPreferenceEntry,withoutTrailingSlashes,Ks as withoutUnknownOptionKeys,workspaceViewAuthoring};
@@ -0,0 +1,11 @@
1
+
2
+ import { C as NumberAttribute } from "./attributes-aTeqx6cK.mjs";
3
+ import { r as ValidationMessages } from "./index-3HZjBOpj.mjs";
4
+ import { z as z$1 } from "zod";
5
+ //#region src/validation/primitives/number.d.ts
6
+ /**
7
+ * Create a Zod schema for a number attribute
8
+ */
9
+ declare function createNumberValidator(attr: NumberAttribute, messages?: ValidationMessages): z$1.ZodNumber;
10
+ //#endregion
11
+ export { createNumberValidator as t };
@@ -0,0 +1,11 @@
1
+
2
+ import { C as NumberAttribute } from "./attributes-kAhQzg8-.js";
3
+ import { r as ValidationMessages } from "./index-DLO8JpnY.js";
4
+ import { z as z$1 } from "zod";
5
+ //#region src/validation/primitives/number.d.ts
6
+ /**
7
+ * Create a Zod schema for a number attribute
8
+ */
9
+ declare function createNumberValidator(attr: NumberAttribute, messages?: ValidationMessages): z$1.ZodNumber;
10
+ //#endregion
11
+ export { createNumberValidator as t };
@@ -0,0 +1,4 @@
1
+ /*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
2
+ const e=require("./exceptions.js"),t=require("./text-A9AJ1wUO.js"),n=require("./core-397tQy5q.js"),r=require("./validation/primitives/number.js"),i=require("./validation/primitives/checkbox.js"),a=require("./validation/primitives/date.js"),o=require("./validation/complex/currency.js"),s=require("./validation/complex/location.js"),c=require("./phone-BB-tzcSr.js"),l=require("./validation/complex/relation.js"),u=require("./validation/complex/richtext.js"),d=require("./validation/complex/select.js"),f=require("./validation/complex/user.js"),p=require("./validation/computed/formula.js"),m=require("./validation/computed/rollup.js");let h=require("zod");function isNullishOrEmptyString(e){return e==null||e===``}function isValuePresent(e){return e==null?!1:typeof e==`string`?e.trim()!==``:!Array.isArray(e)||e.length>0}const g={phone:[`countryCode`]};function isEmptyValue(e,t=[]){return e==null||typeof e==`string`&&e.trim()===``?!0:e instanceof Date?!1:typeof e==`object`&&!Array.isArray(e)&&Object.entries(e).filter(([e])=>!t.includes(e)).every(([,e])=>e==null||typeof e==`string`&&e.trim()===``)}function withEmptyToNull(e,t){return h.z.preprocess(e=>isEmptyValue(e,t)?null:e,e.nullish())}function createAttributeValidator(e,g=n.n){switch(e.type){case`text`:return t.t(e,g);case`richtext`:return u.createRichtextValidator(e,g);case`number`:return r.createNumberValidator(e,g);case`checkbox`:return i.createCheckboxValidator(e,g);case`date`:return a.createDateValidator(e,g);case`phone`:return c.t(e,g);case`currency`:return o.createCurrencyValidator(e,g);case`status`:return d.createStatusValidator(e,g);case`location`:return s.createLocationValidator(e,g);case`select`:return d.createSelectValidator(e,g);case`multiselect`:return d.createMultiselectValidator(e,g);case`user`:return f.createUserValidator(e,g);case`relation`:return l.createRelationValidator(e,g);case`formula`:return p.createFormulaValidator(e,g);case`rollup`:return m.createRollupValidator(e,g);default:return h.z.unknown()}}function createFormAttributeValidator(e,t=n.n){let r=createAttributeValidator(e,t);return e.required?r:withEmptyToNull(r,g[e.type])}const _=new WeakMap,v=new WeakMap;function createObjectValidator(e){let t=_.get(e);if(t)return t;let r={};for(let t of e.attributes){let e=createAttributeValidator(t);t.required?r[t.name]=e.refine(isValuePresent,{message:n.n.required(t)}):r[t.name]=withEmptyToNull(e,g[t.type])}let i=h.z.object(r).passthrough();return _.set(e,i),i}function createDraftValidator(e){let t=v.get(e);if(t)return t;let n={};for(let t of e.attributes){let e=createAttributeValidator(t);n[t.name]=withEmptyToNull(e,g[t.type])}let r=h.z.object(n).passthrough();return v.set(e,r),r}function validateAttribute(e,t){let r=createAttributeValidator(e);if(!e.required&&t==null)return{success:!0,data:{[e.name]:t}};let i=r.safeParse(t);return i.success?{success:!0,data:{[e.name]:i.data}}:{success:!1,errors:n.t(i.error).map(t=>({path:[e.name,...t.path],message:t.message}))}}function validateObject(e,t){let r=createObjectValidator(e).safeParse(t);return r.success?{success:!0,data:r.data}:{success:!1,errors:n.t(r.error)}}function validateObjectOrThrow(t,n){let r=validateObject(t,n);if(!r.success){let n=r.errors??[],i=n.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`
3
+ `)||`Unknown validation error`;throw new e.ValidationError(`Validation failed for ${t.label}:\n${i}`,n.map(e=>({path:e.path,message:e.message})))}return r.data}function validateDraft(e,t){let r=createDraftValidator(e).safeParse(t);return r.success?{success:!0,data:r.data}:{success:!1,errors:n.t(r.error)}}function validateDraftOrThrow(t,n){let r=validateDraft(t,n);if(!r.success){let n=r.errors??[],i=n.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`
4
+ `)||`Unknown validation error`;throw new e.ValidationError(`Draft validation failed for ${t.label}:\n${i}`,n.map(e=>({path:e.path,message:e.message})))}return r.data}function rejectUnknownAttributesOrThrow(t,n){let r=new Set(t.attributes.map(e=>e.name)),i=Object.keys(n).filter(e=>!r.has(e));if(i.length>0)throw new e.ValidationError(`Unknown attribute${i.length>1?`s`:``} for ${t.label}: ${i.join(`, `)}`,i.map(e=>({path:[e],message:`Unknown attribute`})))}function getMissingRequiredAttributes(e,t){let n=[];for(let r of e.attributes)r.required&&!isValuePresent(t[r.name])&&n.push(r);return n}function isRecordComplete(e,t){return getMissingRequiredAttributes(e,t).length>0?!1:validateObject(e,t).success}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return validateDraft}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return validateObjectOrThrow}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return createAttributeValidator}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return createFormAttributeValidator}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return isValuePresent}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return validateAttribute}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return createDraftValidator}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return isNullishOrEmptyString}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return isRecordComplete}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return validateDraftOrThrow}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return isEmptyValue}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return rejectUnknownAttributesOrThrow}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return validateObject}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return getMissingRequiredAttributes}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return createObjectValidator}});