@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.
- package/LICENSE +111 -0
- package/README.md +8 -2
- package/dist/all-BgYwavNm.d.mts +2956 -0
- package/dist/all-DjdKldjX.d.ts +2956 -0
- package/dist/api/index.d.mts +11838 -0
- package/dist/api/index.d.ts +11838 -0
- package/dist/api/index.js +2 -0
- package/dist/api/index.mjs +2 -0
- package/dist/attribute-validators-DRqhAt2t.mjs +11 -0
- package/dist/attribute-validators-WAoJbap5.js +11 -0
- package/dist/attributes-aTeqx6cK.d.mts +557 -0
- package/dist/attributes-kAhQzg8-.d.ts +557 -0
- package/dist/checkbox-BZvZOraX.d.mts +11 -0
- package/dist/checkbox-n0YV1O13.d.ts +11 -0
- package/dist/config-BIxnbUN8.mjs +2 -0
- package/dist/config-DdjlHdPg.js +2 -0
- package/dist/core-397tQy5q.js +2 -0
- package/dist/core-BLHhNykL.mjs +2 -0
- package/dist/date-CxqDOhA0.d.mts +24 -0
- package/dist/date-D007KyTI.d.ts +24 -0
- package/dist/exceptions-DjPVyS-Q.d.mts +761 -0
- package/dist/exceptions-DjPVyS-Q.d.ts +761 -0
- package/dist/exceptions.d.mts +3 -0
- package/dist/exceptions.d.ts +3 -0
- package/dist/exceptions.js +2 -0
- package/dist/exceptions.mjs +2 -0
- package/dist/index-3HZjBOpj.d.mts +53 -0
- package/dist/index-BmNMneu3.d.mts +278 -0
- package/dist/index-Bu9xF5Nq.d.ts +278 -0
- package/dist/index-CiTBL4gH.d.ts +101 -0
- package/dist/index-D7TEaPqX.d.ts +16519 -0
- package/dist/index-DLO8JpnY.d.ts +53 -0
- package/dist/index-DPO5w-fC.d.mts +101 -0
- package/dist/index-DwQWBzYJ.d.mts +16519 -0
- package/dist/index.d.mts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +2 -0
- package/dist/index.mjs +2 -0
- package/dist/number-CgBxEbjI.d.mts +11 -0
- package/dist/number-DncH-WRO.d.ts +11 -0
- package/dist/object-DcgxLvip.js +4 -0
- package/dist/object-Dzl7sfq8.mjs +4 -0
- package/dist/objects-B4DgFZ82.d.ts +398 -0
- package/dist/objects-C9f6hFW_.d.mts +398 -0
- package/dist/phone-BB-tzcSr.js +2 -0
- package/dist/phone-Bca_xiOX.mjs +2 -0
- package/dist/record-aggregates-CzG86pUS.mjs +2 -0
- package/dist/record-aggregates-DwpIJ2Dv.js +2 -0
- package/dist/record-operation-BSXczk7v.js +2 -0
- package/dist/record-operation-C9oXHmfF.mjs +2 -0
- package/dist/text-A9AJ1wUO.js +2 -0
- package/dist/text-C8Lb-NFo.mjs +2 -0
- package/dist/text-DDoY_LcQ.d.ts +11 -0
- package/dist/text-DeUqCFp9.d.mts +11 -0
- package/dist/utils-B7Dlrtnx.d.ts +163 -0
- package/dist/utils-DbRMK8NI.d.mts +163 -0
- package/dist/utils-fXIvFFl6.mjs +2 -0
- package/dist/utils-gY3d9Dwp.js +2 -0
- package/dist/utils.d.mts +3 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +2 -0
- package/dist/utils.mjs +2 -0
- package/dist/validation/all.d.mts +6 -0
- package/dist/validation/all.d.ts +6 -0
- package/dist/validation/all.js +2 -0
- package/dist/validation/all.mjs +2 -0
- package/dist/validation/complex/currency.d.mts +13 -0
- package/dist/validation/complex/currency.d.ts +13 -0
- package/dist/validation/complex/currency.js +2 -0
- package/dist/validation/complex/currency.mjs +2 -0
- package/dist/validation/complex/location.d.mts +20 -0
- package/dist/validation/complex/location.d.ts +20 -0
- package/dist/validation/complex/location.js +2 -0
- package/dist/validation/complex/location.mjs +2 -0
- package/dist/validation/complex/phone.d.mts +20 -0
- package/dist/validation/complex/phone.d.ts +20 -0
- package/dist/validation/complex/phone.js +2 -0
- package/dist/validation/complex/phone.mjs +2 -0
- package/dist/validation/complex/relation.d.mts +23 -0
- package/dist/validation/complex/relation.d.ts +23 -0
- package/dist/validation/complex/relation.js +2 -0
- package/dist/validation/complex/relation.mjs +2 -0
- package/dist/validation/complex/richtext.d.mts +11 -0
- package/dist/validation/complex/richtext.d.ts +11 -0
- package/dist/validation/complex/richtext.js +2 -0
- package/dist/validation/complex/richtext.mjs +2 -0
- package/dist/validation/complex/select.d.mts +18 -0
- package/dist/validation/complex/select.d.ts +18 -0
- package/dist/validation/complex/select.js +2 -0
- package/dist/validation/complex/select.mjs +2 -0
- package/dist/validation/complex/user.d.mts +11 -0
- package/dist/validation/complex/user.d.ts +11 -0
- package/dist/validation/complex/user.js +2 -0
- package/dist/validation/complex/user.mjs +2 -0
- package/dist/validation/computed/formula.d.mts +12 -0
- package/dist/validation/computed/formula.d.ts +12 -0
- package/dist/validation/computed/formula.js +2 -0
- package/dist/validation/computed/formula.mjs +2 -0
- package/dist/validation/computed/rollup.d.mts +12 -0
- package/dist/validation/computed/rollup.d.ts +12 -0
- package/dist/validation/computed/rollup.js +2 -0
- package/dist/validation/computed/rollup.mjs +2 -0
- package/dist/validation/config/index.d.mts +3 -0
- package/dist/validation/config/index.d.ts +3 -0
- package/dist/validation/config/index.js +2 -0
- package/dist/validation/config/index.mjs +2 -0
- package/dist/validation/core/index.d.mts +3 -0
- package/dist/validation/core/index.d.ts +3 -0
- package/dist/validation/core/index.js +2 -0
- package/dist/validation/core/index.mjs +2 -0
- package/dist/validation/object/index.d.mts +3 -0
- package/dist/validation/object/index.d.ts +3 -0
- package/dist/validation/object/index.js +2 -0
- package/dist/validation/object/index.mjs +2 -0
- package/dist/validation/primitives/checkbox.d.mts +3 -0
- package/dist/validation/primitives/checkbox.d.ts +3 -0
- package/dist/validation/primitives/checkbox.js +2 -0
- package/dist/validation/primitives/checkbox.mjs +2 -0
- package/dist/validation/primitives/date.d.mts +3 -0
- package/dist/validation/primitives/date.d.ts +3 -0
- package/dist/validation/primitives/date.js +2 -0
- package/dist/validation/primitives/date.mjs +2 -0
- package/dist/validation/primitives/number.d.mts +3 -0
- package/dist/validation/primitives/number.d.ts +3 -0
- package/dist/validation/primitives/number.js +2 -0
- package/dist/validation/primitives/number.mjs +2 -0
- package/dist/validation/primitives/text.d.mts +3 -0
- package/dist/validation/primitives/text.d.ts +3 -0
- package/dist/validation/primitives/text.js +2 -0
- package/dist/validation/primitives/text.mjs +2 -0
- package/dist/view-config.schema-BQ9tU_9G.js +2 -0
- package/dist/view-config.schema-BmjCQJ51.mjs +2 -0
- package/package.json +279 -3
|
@@ -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
|
+
const e=require("./attribute-validators-WAoJbap5.js"),t=require("./record-aggregates-DwpIJ2Dv.js"),n=require("./exceptions.js");let r=require("zod");const i={createdAt:`createdAt`,updatedAt:`updatedAt`,createdBy:`createdBy`,lastUpdatedBy:`lastUpdatedBy`,attachments:`attachments`};function getSystemAttributeI18nKey(e){return i[e]}const a={createdAt:{id:`system:createdAt`,name:`createdAt`,label:`Created time`,type:`date`,required:!1,system:!0,icon:`clock-circle`,description:`When this record was created`},updatedAt:{id:`system:updatedAt`,name:`updatedAt`,label:`Last edited time`,type:`date`,required:!1,system:!0,icon:`clock-circle`,description:`When this record was last modified`},createdBy:{id:`system:createdBy`,name:`createdBy`,label:`Created by`,type:`user`,required:!1,system:!0,multiple:!1,icon:`user`,description:`Actor who created this record`},lastUpdatedBy:{id:`system:lastUpdatedBy`,name:`lastUpdatedBy`,label:`Last edited by`,type:`user`,required:!1,system:!0,multiple:!1,icon:`user`,description:`Actor who last modified this record`},attachments:{id:`system:attachments`,name:`attachments`,label:`Attachments`,type:`document`,required:!1,system:!0,hidden:!0,icon:`paperclip`,description:`Free-form document attachments`}};function getSystemAttributeList(){return Object.values(a)}function isManagedSystemAttribute(e){return e.id?.startsWith(`system:`)??!1}const o=[`is`,`is_not`,`contains`,`not_contains`,`starts_with`,`ends_with`,`is_empty`,`is_not_empty`],s=[`is`,`is_not`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`is_empty`,`is_not_empty`],c=[`is`],l=[`is`,`is_not`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`is_within`,`on_day_month`,`is_empty`,`is_not_empty`],u=[`is`,`is_not`,`any_of`,`none_of`,`is_empty`,`is_not_empty`],d=[`any_of`,`none_of`,`is_empty`,`is_not_empty`],f=[`is`,`is_not`,`any_of`,`none_of`,`is_empty`,`is_not_empty`],ee=[`is_empty`,`is_not_empty`],p=[`is`,`is_not`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`contains`,`not_contains`,`is_empty`,`is_not_empty`],m=[`city`,`postalCode`,`country`];function isLocationFilterProperty(e){return m.includes(e)}const h={text:o,richtext:[],number:s,checkbox:c,date:l,phone:[`is`,`is_not`,`contains`,`not_contains`,`starts_with`,`is_empty`,`is_not_empty`],currency:s,status:u,select:u,multiselect:d,location:[],user:f,relation:f,formula:p,document:ee},te=new Set([`formula`,`rollup`]),ne=new Set([`user`,`relation`,`document`]),g=new Set([`text`,`richtext`,`number`,`select`,`multiselect`,`status`,`date`,`phone`,`currency`,`location`,`user`,`relation`,`document`]),re=new Set([`text`,`number`,`date`,`phone`,`currency`,`select`,`multiselect`]),ie=new Set([`text`,`richtext`,`phone`,`status`,`select`,`multiselect`]),ae=new Set([`text`,`number`,`checkbox`,`date`,`phone`,`currency`,`status`,`select`]);function getAttributeCapabilities(e){let t=!!(e.hidden||e.archived),n=!e.archived,r=te.has(e.type),i=e.type===`document`,a=ne.has(e.type),o=getAttributeCardinality(e),s=t?[]:getRawFilterOperators(e),c=s.length>0&&!t,l=!t&&ie.has(e.type),u=!t&&ae.has(e.type),d=!t&&isGroupableType(e.type),f=!t&&e.type===`status`,ee=isManagedSystemAttribute(e),p=r||i||ee,m=!(t||p),h=isRequiredForbidden(e.type)?`forbidden`:`allowed`,g=getDefaultValueCapability(e.type),_=supportsMaxItems(e),v=re.has(e.type),y=!(!e.deprecated||t),b=resolveEditMode(e);return{lifecycle:{active:n,deprecated:!!e.deprecated,visibleInArchitect:!0,visibleInRuntime:!t,warningWhenDeprecated:y},storage:{mode:r?`computed`:a?`edge`:`value`,cardinality:o,edgeBacked:a,preservesExistingValues:!!e.archived,qualifiedProperties:supportsQualifiedProperties(e.type),polymorphic:getPolymorphicCapability(e),maxItems:_},authoring:{editable:m,readOnly:p,directEdit:m&&b===`inline`,required:h,defaultValue:g,placeholder:v,maxItems:_},presentation:{formField:!t&&isFormFieldType(e.type),tableCell:!t&&isTableCellType(e.type),defaultColumn:!t&&isDefaultColumnType(e.type),compactDisplay:!t,popoverEditor:!t&&b===`popover`,placeholder:v,warningWhenDeprecated:y},query:{filterable:c,searchable:l,sortable:u,groupable:d,kanbanGroupable:f,operators:s},agent:{readable:!t,writable:m&&!i,compactReadable:!t,contentReadable:!t&&isContentReadableType(e.type),requiresDedicatedTool:i},exchange:{importable:!t,exportable:!t,schemaExportable:!0,metadataExportable:!1}}}function getAttributeFilterOperators(e){return getAttributeCapabilities(e).query.operators}function isAttributeFilterable(e){return getAttributeCapabilities(e).query.filterable}function isAttributeSearchable(e){return getAttributeCapabilities(e).query.searchable}function isAttributeSortable$1(e){return getAttributeCapabilities(e).query.sortable}function isAttributeGroupable(e){return getAttributeCapabilities(e).query.groupable}function isAttributeKanbanGroupable(e){return getAttributeCapabilities(e).query.kanbanGroupable}function resolveEffectiveFilterType(e){if(e.type!==`rollup`)return e.type;let t=e;if(t.function===`earliest`||t.function===`latest`)return`date`;if(t.function===`original`){let e=t.targetAttributeType;if(e&&hasFilterOperatorEntry(e))return e}return`number`}function getRollupFilterOperators$1(e){let t=resolveEffectiveFilterType(e);return hasFilterOperatorEntry(t)?h[t]:h.number}function getRawFilterOperators(e){return e.type===`rollup`?getRollupFilterOperators$1(e):h[e.type]??[]}function getAttributeCardinality(e){return e.type===`multiselect`||e.type===`document`||e.type===`user`&&e.multiple===!0||e.type===`relation`&&e.cardinality===`many`?`many`:`one`}function getPolymorphicCapability(e){if(e.type!==`relation`)return`none`;let t=e.targets??[];return t.length===1&&t[0]?.object===`*`?`internal`:t.length>1?`code-only`:`none`}function supportsMaxItems(e){return e.type===`multiselect`||e.type===`relation`&&e.cardinality===`many`}function supportsQualifiedProperties(e){return e===`relation`||e===`document`}function isRequiredForbidden(e){return e===`checkbox`||e===`formula`||e===`rollup`}function getDefaultValueCapability(e){return e===`checkbox`?`automatic`:e===`formula`||e===`rollup`?`forbidden`:g.has(e)?`static`:`forbidden`}function isDefaultColumnType(e){return isTableCellType(e)}function isTableCellType(e){return e!==`richtext`&&e!==`document`}function isFormFieldType(e){return e!==`richtext`}function resolveEditMode(e){switch(e.type){case`checkbox`:return`inline`;case`number`:return e.renderAs===`rating`?`inline`:`default`;case`select`:case`multiselect`:return e.renderAs===`badges`?`inline`:`popover`;case`status`:case`relation`:case`user`:case`date`:return`popover`;default:return`default`}}function isGroupableType(e){return e===`status`||e===`currency`}function isContentReadableType(e){return e===`richtext`||e===`document`}function hasFilterOperatorEntry(e){return Object.prototype.hasOwnProperty.call(h,e)}const _=[`text`,`richtext`,`number`,`checkbox`,`date`,`phone`,`currency`,`status`,`location`,`select`,`multiselect`,`user`,`relation`,`formula`,`rollup`,`document`];function relationTargetsOf(e){return e.type!==`relation`||!Array.isArray(e.targets)?[]:e.targets.map(e=>e.object).filter(e=>e!==`*`)}function isUniversalRelation(e){return e.targets.length===1&&e.targets[0].object===`*`}function isBilateralRelation(e){return e.bilateral!==void 0}function inferInverseCardinality(e){return`many`}function isAttributeSortable(e){return isAttributeSortable$1(e)}const v=h,y=[`is_empty`,`is_not_empty`];function isNoValueOperator(e){return y.includes(e)}function getRollupFilterOperators(e){return getRollupFilterOperators$1(e)}function parseQualifiedAttribute(e){let t=e.indexOf(`__`);return t<=0||t+2>=e.length?{kind:`scalar`,attribute:e}:{kind:`qualified`,root:e.slice(0,t),property:e.slice(t+2)}}function buildQualifiedAttribute(e,t){return`${e}__${t}`}const b=[`page`,`record`,`display`];function defineBlock(e){let t=Object.fromEntries(Object.entries(e.inputs).map(([e,t])=>[e,t.isOptional?t.schema.optional():t.schema]));return Object.freeze({name:e.name,label:e.label,icon:e.icon,family:e.family,contexts:Object.freeze([...e.contexts]),inputs:Object.freeze({...e.inputs}),...e.layout===void 0?{}:{layout:Object.freeze({...e.layout})},parameters:r.z.object(t).strict().superRefine((t,n)=>{let r=e.refine?.(t);r&&n.addIssue({code:`custom`,path:[r.input],message:r.message})}),...e.refine===void 0?{}:{refine:(t,n)=>e.refine?.(t,n)}})}function parseBlockParameters(e,t,r){let i=e.parameters.safeParse(structuredClone(t??{}));if(!i.success)throw n.ValidationError.fromZodErrors(i.error.issues.map(e=>({path:[...r,...e.path.map(String)],message:e.message})));return i.data}function blockObjectInputs(e,t,n){return Object.entries(e.inputs).flatMap(([e,r])=>{let i=t[e];if(r.kind===`object`&&typeof i==`string`)return[i];if(r.kind===`query`&&typeof i==`object`&&i){let e=i.source;if(!e)return[];if(`object`in e&&typeof e.object==`string`)return[e.object];let t=n?.attributes.find(t=>t.name===e.relation);return t?relationTargetsOf(t):[]}return[]})}const oe=/^\d{4}-\d{2}-\d{2}$/u;function isCalendarDay(e){if(!oe.test(e))return!1;let t=new Date(`${e}T00:00:00Z`);return!Number.isNaN(t.getTime())&&t.toISOString().slice(0,10)===e}function isDynamicValue(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&`dynamic`in e}function currentActor(){return{dynamic:`actor`,ref:`current`}}function today(){return{dynamic:`date`,anchor:`today`}}function now(){return{dynamic:`date`,anchor:`now`}}function toAmount(e){if(typeof e==`number`)return Number.isFinite(e)?e:null;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:null}return null}function extractCurrencyFilterValue(e){return typeof e==`object`&&e?`value`in e?toAmount(e.value):null:toAmount(e)}function extractFilterValue(e){return e==null?null:typeof e==`object`&&`value`in e?e.value??null:e}const se=new Set([`is_not`,`not_contains`,`none_of`,`is_empty`]),ce={is_not:`is`,not_contains:`contains`,none_of:`any_of`,is_empty:`is_not_empty`};function getOperatorPolarity(e){return se.has(e)?`none`:`any`}function normalizeForEdgeRpc(e){return ce[e]??e}const x={is:`any_of`,is_not:`none_of`};function toMultiValueOperator(e){return x[e]??e}const le=new Set(Object.values(x).filter(e=>e!==void 0));function isSetMembershipOperator(e){return le.has(e)}function canonicalizeFilterValue(e,t){let r=e.value;if(isNoValueOperator(e.operator)||r==null||isDynamicValue(r))return;if(isSetMembershipOperator(e.operator)){Array.isArray(r)||(e.value=[r]);return}if(t!==`currency`)return;let i=extractCurrencyFilterValue(r);if(i!==null){e.value=i;return}if(!hasCurrencyAmount(r))return;let a=`Filter on a currency attribute expected a numeric amount, received ${JSON.stringify(r)}`;throw new n.ValidationError(a,[{path:[`value`],message:a}])}function hasCurrencyAmount(e){return typeof e!=`object`||`value`in e&&e.value!=null}const S=h.text,ue=[`is`,`is_not`,`is_empty`,`is_not_empty`],C=[`is`,`is_not`,`any_of`,`none_of`,`is_empty`,`is_not_empty`],w={id:C,objectId:C,tenantId:C,label:h.text,createdAt:h.date,updatedAt:h.date,deletedAt:h.date,createdBy:h.user,lastUpdatedBy:h.user},de=new Set([`createdAt`,`updatedAt`,`deletedAt`]);function offeredOn(e,t){return de.has(e)?t.filter(e=>e!==`on_day_month`):t}function fullyOffered(e,t,n,r){return{target:e,attribute:t,...r?{property:r}:{},operators:n,offered:n}}function attributeFilterTarget(e){let t=getAttributeFilterOperators(e);return{target:e.name,attribute:e.name,operators:t,offered:offeredOn(e.name,t)}}function locationPartFilterTarget(e,t){return{target:buildQualifiedAttribute(e,t),attribute:e,property:t,operators:S,offered:t===`country`?ue:S}}function edgePropertyFilterTarget(e,t){let n=hasOperatorEntry(t.type)?h[t.type]:[];return fullyOffered(buildQualifiedAttribute(e,t.name),e,n,t.name)}function hasOperatorEntry(e){return Object.prototype.hasOwnProperty.call(h,e)}function systemColumnFilterTarget(e){let t=Object.prototype.hasOwnProperty.call(w,e)?w[e]:void 0;return t?{target:e,attribute:e,operators:t,offered:offeredOn(e,t)}:void 0}function filterOperatorsOfType(e){return isAttributeType(e)?getAttributeFilterOperators({type:e}):[]}function isAttributeType(e){return _.includes(e)}function isLocationPartOperator(e){return S.includes(e)}function carriesEdgeProperties(e){return e.type===`relation`||e.type===`document`}function filterTargetsOf(e){let t=[];for(let n of e){if(n.type===`location`){for(let e of m)t.push(locationPartFilterTarget(n.name,e));continue}if(t.push(attributeFilterTarget(n)),!carriesEdgeProperties(n))continue;let e=n.properties?.definitions;for(let r of e??[])t.push(edgePropertyFilterTarget(n.name,r))}let n=new Set(e.map(e=>e.name));for(let e of Object.keys(w)){if(n.has(e))continue;let r=systemColumnFilterTarget(e);r&&t.push(r)}return t.filter(e=>e.operators.length>0)}const fe={eq:`is`,equals:`is`,equal:`is`,"==":`is`,"=":`is`,neq:`is_not`,notEqual:`is_not`,isNot:`is_not`,"!=":`is_not`,"<>":`is_not`,lt:`less_than`,"<":`less_than`,gt:`greater_than`,">":`greater_than`,lte:`less_or_equal`,"<=":`less_or_equal`,gte:`greater_or_equal`,">=":`greater_or_equal`,in:`any_of`,isAnyOf:`any_of`,anyOf:`any_of`,oneOf:`any_of`,notIn:`none_of`,not_in:`none_of`,isNoneOf:`none_of`,noneOf:`none_of`,notOneOf:`none_of`,startsWith:`starts_with`,beginsWith:`starts_with`,endsWith:`ends_with`,doesNotContain:`not_contains`,notContain:`not_contains`,isEmpty:`is_empty`,isNotEmpty:`is_not_empty`};function normalizeOperator(e){return fe[e]??e}function normalizeFilterRule(e){let t=normalizeOperator(e.operator);return t===e.operator?e:{...e,operator:t}}const T=864e5,pe=new Set([`days`,`weeks`,`months`,`years`]),me=new Set([`past`,`future`]);function isRelativeDateValue(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.amount==`number`&&Number.isFinite(t.amount)&&t.amount>0&&typeof t.unit==`string`&&pe.has(t.unit)&&typeof t.direction==`string`&&me.has(t.direction)}function utcDayStart(e){return Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())}function shiftUtcDay(e,t,n){if(n===`days`)return e+t*T;if(n===`weeks`)return e+t*7*T;let r=new Date(e),i=r.getUTCFullYear()+(n===`years`?t:0),a=r.getUTCMonth()+(n===`months`?t:0),o=new Date(Date.UTC(i,a+1,0)).getUTCDate();return Date.UTC(i,a,Math.min(r.getUTCDate(),o))}function resolveIsWithinBounds(e,t=new Date){if(!isRelativeDateValue(e))return null;let n=utcDayStart(t),r=Math.trunc(e.amount),i=e.direction===`past`?{startMs:shiftUtcDay(n,-r,e.unit),endMs:n+T}:{startMs:n,endMs:shiftUtcDay(n,r,e.unit)+T};return Number.isFinite(i.startMs)&&Number.isFinite(i.endMs)?i:null}function resolveUtcDayBounds(e){if(!Number.isFinite(e))return null;let t=utcDayStart(new Date(e));return Number.isFinite(t)?{startMs:t,endMs:t+T}:null}function toUtcDayString(e){return new Date(e).toISOString().slice(0,10)}const he=new Set([`relation`,`document`,`user`]),E={id:`text`,objectId:`text`,objectName:`text`,tenantId:`text`,label:`text`,createdAt:`date`,updatedAt:`date`,deletedAt:`date`,deletedBy:`user`,createdBy:`user`,lastUpdatedBy:`user`,visibility:`select`,ownedBy:`user`},D={before:`"less_than"`,after:`"greater_than"`,on_or_before:`"less_or_equal"`,on_or_after:`"greater_or_equal"`,is_checked:`"is" with value true`,is_not_checked:`"is" with value false`,day_month_eq:`"on_day_month"`},ge=new Set(Object.entries(h).filter(([,e])=>e.includes(`any_of`)&&!e.includes(`contains`)).map(([e])=>e)),_e={contains:`any_of`,not_contains:`none_of`};function resolveCanonicalOperator(e,t){let r=D[e];if(r){let t=`Unknown filter operator "${e}" — use ${r}`;throw new n.ValidationError(t,[{path:[`operator`],message:t}])}let i=normalizeOperator(e),a=_e[i];if(a&&ge.has(t)){let e=`Operator "${i}" is not valid for type "${t}" — use "${a}"`;throw new n.ValidationError(e,[{path:[`operator`],message:e}])}return i}function assertPropertyOperator(e,t,r){let i=resolveCanonicalOperator(e,t);if(!r.includes(i)){let i=`Operator "${e}" is not valid for property type "${t}". Valid operators: ${r.length?r.join(`, `):`(no operators registered for this type)`}.`;throw new n.ValidationError(i,[{path:[`operator`],message:i}])}return i}function assertRelativeDateValue(e){if(e.operator===`is_within`&&!isRelativeDateValue(e.value)){let e=`Operator "is_within" requires a relative-date value { amount: positive number, unit: days|weeks|months|years, direction: past|future }`;throw new n.ValidationError(e,[{path:[`value`],message:e}])}}const ve=/^(\d{4}-\d{2}-\d{2})(?:[T ](?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z|[+-](?:(?:0\d|1[0-3])(?::[0-5]\d)?|14(?::00)?))?)?$/,ye=new Set([`is`,`is_not`,`less_than`,`less_or_equal`,`greater_than`,`greater_or_equal`]);function assertAbsoluteDateValue(e,t){if(t!==`date`||!ye.has(e.operator))return;let r=e.value;if(r==null||isDynamicValue(r)||typeof r==`string`&&isCastableDay(r))return;let i=`Filter on a date attribute expected a YYYY-MM-DD day, optionally followed by a time, received ${JSON.stringify(r)}`;throw new n.ValidationError(i,[{path:[`value`],message:i}])}function isCastableDay(e){let t=ve.exec(e)?.[1];return!t||t.startsWith(`0000-`)?!1:isCalendarDay(t)}function resolveComparandType(e){return e.type===`formula`&&e.returnType===`date`?`date`:resolveEffectiveFilterType(e)}function applyCanonicalForm(e,t,n){e.operator=t,canonicalizeFilterValue(e,n),assertRelativeDateValue(e),assertAbsoluteDateValue(e,n)}function assertDynamicValueForAttribute(e,t){if(!isDynamicValue(e.value))return;let r=e.value;if(r.dynamic===`actor`&&t!==`user`){let e=`actor token (@me) is only valid on user attributes, not "${t}"`;throw new n.ValidationError(e,[{path:[`value`],message:e}])}if(r.dynamic===`date`&&t!==`date`){let e=`date token (@today/@now) is only valid on date attributes, not "${t}"`;throw new n.ValidationError(e,[{path:[`value`],message:e}])}}const O=m.map(e=>`"${e}"`).join(`, `);function operatorList(e){return e.length?e.join(`, `):`(not filterable)`}function qualifyWithSchema(e){if(he.has(e.type))return e.properties}function locationPartsHint(e){return e===`location`?` A location is filtered on one of its parts: set "property" to one of ${O} and use a text operator (e.g. contains).`:``}function dottedPathHint(e,t,n){let r=` Dotted paths are not supported — `;if(n.type===`location`)return`${r}set "attribute" to "${e}" and "property" to ${isLocationFilterProperty(t)?`"${t}"`:`one of ${O}`}.`;let i=qualifyWithSchema(n);if(i){let n=i.definitions.map(e=>`"${e.name}"`).join(`, `);return`${r}set "attribute" to "${e}" and "property" to ${i.definitions.some(e=>e.name===t)?`"${t}"`:`one of ${n}`} to filter on the edge property.`}let a=attributeFilterTarget(n).operators;return`${r}${a.length?`set "attribute" to "${e}" and use one of ${a.join(`, `)}`:`"${e}" is not filterable`}; the full-text "query" parameter matches tokens by relevance, not values.`}function collectQualifiedRuleIssues(e,t){try{return validateQualifiedRule({...e},t),[]}catch(e){if(!(e instanceof n.ValidationError))throw e;return e.errors.map(e=>({...e,path:[...e.path]}))}}function validateQualifiedRule(e,t){if(typeof e.attribute!=`string`){let e=`A filter rule needs an attribute: filters are one combinator and a flat list of rules`;throw new n.ValidationError(e,[{path:[`attribute`],message:e}])}let r=t.attributes.find(t=>t.name===e.attribute),i=r?[]:systemColumnFilterTarget(e.attribute)?.operators??[];if(!r&&i.length===0){let[r,...i]=e.attribute.split(`.`),a=i.length>0?t.attributes.find(e=>e.name===r):void 0,o=a?dottedPathHint(r??``,i[0]??``,a):e.attribute.includes(`.`)?` Dotted paths are not supported — filter on the attribute name alone with a structured operator (contains, any_of, …); the full-text "query" parameter matches tokens by relevance, not values.`:``,s=`Unknown attribute: ${e.attribute}${o}`;throw new n.ValidationError(s,[{path:[`attribute`],message:s}])}if(e.quantifier!==void 0&&!e.property){let e=`quantifier is only valid on qualified edge rules (set "property")`;throw new n.ValidationError(e,[{path:[`quantifier`],message:e}])}if(!r){if(e.property)throw new n.ValidationError(`Cannot qualify system attribute "${e.attribute}"`,[{path:[`property`],message:`"${e.attribute}" is a system column, not a reference`}]);let t=E[e.attribute]??`text`,r=resolveCanonicalOperator(e.operator,t);if(!i.includes(r)){let t=`Operator "${e.operator}" is not valid for system attribute "${e.attribute}". Valid operators: ${i.join(`, `)}.`;throw new n.ValidationError(t,[{path:[`operator`],message:t}])}applyCanonicalForm(e,r,t);return}if(!e.property){assertDynamicValueForAttribute(e,r.type);let t=attributeFilterTarget(r).operators,i=resolveCanonicalOperator(e.operator,r.type);if(!t.includes(i)){let i=`Operator "${e.operator}" is not valid for attribute "${r.name}". Valid operators: ${operatorList(t)}.${locationPartsHint(r.type)}`;throw new n.ValidationError(i,[{path:[`operator`],message:i}])}applyCanonicalForm(e,i,resolveComparandType(r));return}if(r.type===`location`){if(e.quantifier!==void 0){let e=`quantifier is not valid on a location part — a location is one value, not a set of edges`;throw new n.ValidationError(e,[{path:[`quantifier`],message:e}])}if(!isLocationFilterProperty(e.property)){let t=`Property "${e.property}" is not a part of location "${e.attribute}". Valid parts: ${O}.`;throw new n.ValidationError(t,[{path:[`property`],message:t}])}assertDynamicValueForAttribute(e,`text`);let{operators:t}=locationPartFilterTarget(r.name,e.property);applyCanonicalForm(e,assertPropertyOperator(e.operator,`text`,t),`text`);return}if(!he.has(r.type))throw new n.ValidationError(`Cannot qualify ${r.type} attribute "${e.attribute}"`,[{path:[`property`],message:`Attribute "${e.attribute}" is not a reference type`}]);let a=r.properties;if(!a)throw new n.ValidationError(`Attribute "${e.attribute}" has no qualifyWith schema`,[{path:[`property`],message:`"${e.attribute}" has no qualifyWith`}]);let o=a.definitions.find(t=>t.name===e.property);if(!o)throw new n.ValidationError(`Property "${e.property}" not defined on "${e.attribute}".qualifyWith()`,[{path:[`property`],message:`Unknown property: ${e.property}`}]);let{operators:s}=edgePropertyFilterTarget(r.name,o);applyCanonicalForm(e,assertPropertyOperator(e.operator,o.type,s),o.type)}const be=r.z.array(r.z.string()).max(e.p.columnsPerTab),k=r.z.array(r.z.string().min(1)).max(e.p.columnsPerTab).refine(e=>new Set(e).size===e.length,{message:`Displayed attribute names must be unique`}),xe=r.z.object({attribute:r.z.string().describe(`Attribute to sort by`),direction:r.z.enum([`asc`,`desc`]).describe(`asc or desc`)}).strict(),A=r.z.array(xe).max(e.p.sortsPerTab),Se=r.z.object({amount:r.z.number().describe(`Count`),unit:r.z.enum([`days`,`weeks`,`months`,`years`]).describe(`Unit`),direction:r.z.enum([`past`,`future`]).describe(`Past or future`)}).strict(),Ce=r.z.object({value:r.z.number().nullable().describe(`Amount`),code:r.z.array(r.z.string()).optional().describe(`Currency codes`)}).strict(),we=r.z.object({phoneNumber:r.z.string().nullable().describe(`Number`),countryCode:r.z.string().optional().describe(`ISO country code`)}).strict(),Te=r.z.discriminatedUnion(`dynamic`,[r.z.object({dynamic:r.z.literal(`actor`).describe(`Resolved at filter time`),ref:r.z.literal(`current`).describe(`The current actor`)}).strict(),r.z.object({dynamic:r.z.literal(`date`).describe(`Resolved at filter time`),anchor:r.z.enum([`today`,`now`]).describe(`Anchor`)}).strict()]),Ee=r.z.object({month:r.z.number().describe(`1-12`),day:r.z.number().describe(`Day`)}).strict(),De=r.z.union([r.z.string(),r.z.number(),r.z.boolean(),r.z.array(r.z.string()),Se,Ce,we,Ee,Te,r.z.null()]),Oe=r.z.enum([`is`,`is_not`,`contains`,`not_contains`,`starts_with`,`ends_with`,`is_empty`,`is_not_empty`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`is_within`,`on_day_month`,`any_of`,`none_of`],{error:e=>{let t=e.input,n=typeof t==`string`?D[t]:void 0;return n?`Unknown filter operator "${t}" — use ${n}`:void 0}}),ke=r.z.object({attribute:r.z.string().describe(`Attribute to filter on`),property:r.z.string().optional().describe(`Qualified edge property`),quantifier:r.z.enum([`any`,`none`]).optional().describe(`For a multi-value attribute`),operator:Oe.describe(`Comparison`),value:De.describe(`Comparison value, by attribute type`)}).strict(),Ae=r.z.array(ke).max(e.p.filterRulesPerTab),j=r.z.object({combinator:r.z.enum([`and`,`or`]).describe(`Match every rule or any rule`),rules:Ae.describe(`The rules`)}).strict(),M=r.z.object({object:r.z.string().optional().describe(`Every record of this object`),relation:r.z.string().optional().describe(`Records linked through this relation`)}).strict().superRefine((e,t)=>{e.object===void 0&&e.relation===void 0&&t.addIssue({code:`custom`,message:`Collection source must define an object, a relation, or both`})}).transform(e=>e.relation===void 0?{object:e.object}:e.object===void 0?{relation:e.relation}:{object:e.object,relation:e.relation}),N=r.z.object({source:M,filters:j.optional(),sorts:A.optional(),limit:r.z.number().int().nonnegative().optional()}).strict();var RecordQuery=class{constructor(e){this.state=e}with(e){return new this.constructor({...this.state,...e})}rule(e,t,n){return this.with({rules:[...this.state.rules,{attribute:e,operator:t,value:n}]})}eq(e,t){return this.rule(e,`is`,t)}neq(e,t){return this.rule(e,`is_not`,t)}gt(e,t){return this.rule(e,`greater_than`,t)}gte(e,t){return this.rule(e,`greater_or_equal`,t)}lt(e,t){return this.rule(e,`less_than`,t)}lte(e,t){return this.rule(e,`less_or_equal`,t)}contains(e,t){return this.rule(e,`contains`,t)}notContains(e,t){return this.rule(e,`not_contains`,t)}startsWith(e,t){return this.rule(e,`starts_with`,t)}endsWith(e,t){return this.rule(e,`ends_with`,t)}in(e,t){return this.rule(e,`any_of`,t)}notIn(e,t){return this.rule(e,`none_of`,t)}isEmpty(e){return this.rule(e,`is_empty`,null)}isNotEmpty(e){return this.rule(e,`is_not_empty`,null)}where(...e){return this.with({rules:[...this.state.rules,...e.map(e=>({...e}))]})}or(){return this.with({combinator:`or`})}orderBy(e,t=`asc`){return this.with({sorts:[...this.state.sorts,{attribute:e,direction:t}]})}limit(e){return this.with({limit:e})}offset(e){return this.with({offset:e})}search(e){return this.with({search:e})}related(e){return this.with({scope:{kind:`related`,relation:e}})}relatedFrom(e){return this.with({scope:{kind:`relatedFrom`,relation:e}})}toDefinition(){let{object:e,scope:t,rules:n,combinator:r,sorts:i,limit:a}=this.state;return{source:t?.kind===`related`?{relation:t.relation}:t?.kind===`relatedFrom`?{object:e,relation:t.relation}:{object:e},...n.length>0?{filters:{combinator:r,rules:n.map(e=>({...e}))}}:{},...i.length>0?{sorts:i.map(e=>({...e}))}:{},...a===void 0?{}:{limit:a}}}};function query(e){return new RecordQuery({object:typeof e==`string`?e:e.build().name,combinator:`and`,rules:[],sorts:[]})}const P=[`day`,`week`,`month`,`quarter`,`year`],F=`$query`,I=`$record`;function createInput(e){return Object.freeze({...e,optional:()=>createInput({...e,isOptional:!0}),inSection:t=>createInput({...e,section:t}),showWhen:(t,n)=>createInput({...e,when:{key:t,...n}}),many:()=>createInput({...e,isMany:!0,schema:r.z.array(e.schema).min(1)})})}function objectNameOf(e){return e===void 0||typeof e==`string`?e:e.build().name}function scalar(e,t,n){return createInput({kind:e,of:objectNameOf(n),isOptional:!1,isMany:!1,schema:t})}function name(){return r.z.string().min(1)}const L={object:e=>scalar(`object`,name(),e),attribute:(e,t)=>createInput({kind:`attribute`,of:objectNameOf(e),options:t,isOptional:!1,isMany:!1,schema:name()}),query:e=>scalar(`query`,N,e),record:e=>scalar(`record`,name(),e),agent:()=>scalar(`agent`,name()),routine:()=>scalar(`routine`,name()),view:()=>scalar(`view`,name()),url:()=>scalar(`url`,r.z.url().refine(e=>/^https?:\/\//.test(e),`Only http(s) links`)),emailCategory:()=>scalar(`emailCategory`,name()),enum:e=>createInput({kind:`enum`,isOptional:!1,isMany:!1,schema:r.z.enum(e)}),text:()=>scalar(`text`,name()),number:()=>scalar(`number`,r.z.number()),boolean:()=>scalar(`boolean`,r.z.boolean()),period:()=>scalar(`period`,r.z.enum(P))},R={size:{w:4,h:4},minWidth:3,height:`flexible`,minHeight:3,maxHeight:10},z=defineBlock({name:`artifact_preview`,label:`Preview`,icon:`eye`,family:`context`,contexts:[`record`],layout:{size:{w:6,h:8},minWidth:4,height:`flexible`,minHeight:4,maxHeight:20},inputs:{}}),B=[`number`,`currency`],V=[`status`,`select`,`user`,`relation`,`date`],H=[`bar`,`line`,`area`,`donut`,`funnel`,`treemap`,`calendar`];function measureIssue({measure:e,attribute:t}){return e===`count`?t===void 0?void 0:{input:`attribute`,message:`count measures records; it takes no attribute`}:t===void 0?{input:`attribute`,message:`${String(e)} needs a number or currency attribute`}:void 0}function requires(e,t,n){return e[t]!==void 0&&e[n]===void 0?{input:t,message:`${t} needs ${n}`}:void 0}function together(e,t,n){return requires(e,t,n)??requires(e,n,t)}function kindIssue(e){let{kind:t,by:n,byBucket:r,by2:i,measure:a}=e;if(i!==void 0&&i===n)return{input:`by2`,message:`by2 must differ from by`};if((t===`donut`||t===`funnel`)&&i!==void 0)return{input:`kind`,message:`a ${String(t)} splits one grouping (by), and no second`};if(t===`funnel`&&a!==`count`&&a!==`sum`)return{input:`kind`,message:`a funnel adds stages up: its measure is count or sum`};if(t===`area`&&i===void 0)return{input:`kind`,message:`an area stacks a second grouping (by2); one series is a line`};if(t===`treemap`&&(n===void 0||i!==void 0))return{input:`kind`,message:`a treemap needs one grouping (by), and no second`};if(t===`calendar`&&(r!==`day`||i!==void 0))return{input:`kind`,message:`a calendar needs a date grouping by day, and no second`}}function measuredInputs(){return{query:L.query(),measure:L.enum(t.n).inSection(`data`),attribute:L.attribute(F,{types:B}).optional().showWhen(`measure`,{not:[`count`]}),label:L.text().optional()}}function metricComparePeriod(e){if(e.period)return e.period;if(!e.trendBucket)return`month`;let t=P.indexOf(e.trendBucket);return P[Math.min(t+1,P.length-1)]??`month`}function comparedSpanIssue(e){let{trendBucket:t,compare:n}=e;if(n===void 0||typeof t!=`string`)return;let r=t;if(r===P.at(-1))return{input:`compare`,message:`compare needs a trendBucket finer than year`};let i=metricComparePeriod({trendBucket:r,period:e.period});return P.indexOf(i)>P.indexOf(r)?void 0:{input:`period`,message:`period must be wider than trendBucket (unset, it is one step above)`}}const U=defineBlock({name:`metric`,label:`Indicateur`,icon:`trending-up`,family:`data`,contexts:[`page`,`record`,`display`],layout:{size:{w:3,h:2},minWidth:3,height:`fit`,maxHeight:4,figure:!0},inputs:{...measuredInputs(),trend:L.attribute(F,{types:[`date`]}).optional().inSection(`display`),trendBucket:L.period().optional().showWhen(`trend`),compare:L.enum([`previous_period`]).optional(),period:L.period().optional().showWhen(`compare`),target:L.number().optional()},refine:e=>measureIssue(e)??together(e,`trend`,`trendBucket`)??requires(e,`period`,`compare`)??comparedSpanIssue(e)??(e.target!==void 0&&e.target<=0?{input:`target`,message:`target must be above zero`}:void 0)}),W=defineBlock({name:`chart`,label:`Graphique`,icon:`chart-bar`,family:`data`,contexts:[`page`,`record`,`display`],layout:{size:{w:4,h:6},minWidth:4,height:`flexible`,minHeight:4,maxHeight:12},inputs:{...measuredInputs(),kind:L.enum(H),by:L.attribute(F,{types:V}).optional(),byBucket:L.period().optional().inSection(`data`).showWhen(`by`),by2:L.attribute(F,{types:V}).optional().showWhen(`by`),by2Bucket:L.period().optional().inSection(`data`).showWhen(`by2`)},refine:e=>measureIssue(e)??requires(e,`byBucket`,`by`)??requires(e,`by2`,`by`)??requires(e,`by2Bucket`,`by2`)??kindIssue(e)}),G=defineBlock({name:`agenda`,label:`Agenda`,icon:`calendar`,family:`data`,contexts:[`page`,`record`,`display`],layout:R,inputs:{query:L.query(),attribute:L.attribute(F,{types:[`date`]}),next:L.number().optional(),yearly:L.boolean().optional(),label:L.text().optional()}}),K=defineBlock({name:`card`,label:`Fiche`,icon:`user-square`,family:`data`,contexts:[`page`,`record`,`display`],layout:{size:{w:4,h:4},minWidth:3,height:`fit`,maxHeight:10},inputs:{object:L.object().optional(),record:L.record().optional(),fields:L.attribute(I).many().optional()},refine:(e,t)=>requires(e,`record`,`object`)??(t===`page`&&e.record===void 0?{input:`record`,message:`A card outside a record shows a chosen record: content.card(object).record(id)`}:void 0)}),je=defineBlock({name:`text_block`,label:`Texte`,icon:`type-text`,family:`layout`,contexts:[`page`,`record`,`display`],layout:{size:{w:12,h:2},minWidth:3,height:`fit`,maxHeight:16},inputs:{markdown:L.text()}}),Me=defineBlock({name:`heading`,label:`Titre`,icon:`type-text`,family:`layout`,contexts:[`page`,`record`],layout:{size:{w:12,h:1},minWidth:6,height:`fit`,maxHeight:3},inputs:{title:L.text(),description:L.text().optional(),icon:L.text().optional()}}),Ne=defineBlock({name:`inbox`,label:`Boîte de réception`,icon:`inbox`,family:`people`,contexts:[`page`],layout:R,inputs:{kinds:L.enum(t.s).inSection(`data`).many().optional(),limit:L.number().optional()}}),Pe=defineBlock({name:`meetings_upcoming`,label:`Réunions à venir`,icon:`video`,family:`people`,contexts:[`page`],layout:R,inputs:{}}),Fe=defineBlock({name:`mailbox`,label:`E-mails`,icon:`envelope`,family:`people`,contexts:[`page`],layout:R,inputs:{category:L.emailCategory().optional(),important:L.boolean().optional().inSection(`data`),unread:L.boolean().optional().inSection(`data`),limit:L.number().optional(),label:L.text().optional()},refine:({limit:e})=>e===void 0||Number.isInteger(e)&&e>=1&&e<=50?void 0:{input:`limit`,message:`limit is a whole number from 1 to 50`}}),q=defineBlock({name:`record_links`,label:`Bubble`,icon:`share`,family:`context`,contexts:[`record`,`page`],layout:{size:{w:6,h:8},minWidth:6,height:`flexible`,minHeight:6,maxHeight:16},inputs:{center:L.enum([`record`,`me`]).optional().inSection(`data`),object:L.object().optional(),record:L.record().optional(),depth:L.enum([`1`,`2`]).optional()},refine:(e,t)=>requires(e,`record`,`object`)??(t===`page`&&e.center!==`me`&&e.record===void 0?{input:`record`,message:`Links outside a record centre on a chosen record or on the viewer: { object, record } or { center: "me" }`}:void 0)}),Ie={name:`bubble`,type:`custom`,extension:q.name,placement:`main`,label:q.label,icon:q.icon,parameters:{}},Le=[z,U,W,G,K,je,Me,Ne,Pe,Fe,q],Re=new Set([`name`,`label`,`icon`,`family`,`contexts`,`inputs`,`parameters`,`layout`,`refine`]),ze=Le;var ContentExtensionRegistry=class{constructor(){this.extensions=new Map,this.seed()}register(e){let t=Array.isArray(e)?e:[e],r=new Set;t.forEach((e,t)=>{if(this.prepare(e,t),r.has(e.name))throw new n.DuplicateError(`content extension`,e.name);r.add(e.name)});for(let e of t)this.extensions.set(e.name,e);return this}prepare(e,t){let r=[`extensions`,String(t)],reject=e=>{throw new n.ValidationError(e,[{path:r,message:e}])};if((typeof e!=`object`||!e||Array.isArray(e))&&reject(`Expected a content extension declaration`),Object.keys(e).some(e=>!Re.has(e))&&reject(`Expected only ${[...Re].join(`, `)}`),(typeof e.name!=`string`||e.name.trim().length===0)&&reject(`API name must not be empty`),(!Array.isArray(e.contexts)||e.contexts.length===0||e.contexts.some(e=>!b.includes(e)))&&reject(`contexts must be a non-empty list of ${b.join(`, `)}`),typeof e.parameters?.safeParse!=`function`&&reject(`parameters must be a Zod schema`),this.extensions.has(e.name))throw new n.DuplicateError(`content extension`,e.name)}get(e){return this.extensions.get(e)}has(e){return this.extensions.has(e)}getAll(){return[...this.extensions.values()]}get size(){return this.extensions.size}clear(){this.extensions.clear(),this.seed()}seed(){for(let e of ze)this.extensions.set(e.name,e)}};const Be=new ContentExtensionRegistry,J=[3,4,6,8,9,12];function overlaps(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 findGridViolation(e,t={}){let n=Object.entries(e);for(let[e,{x:t,y:r,w:i,h:a}]of n){if(![t,r,i,a].every(Number.isInteger))return{path:[e],message:`Block "${e}" needs integer grid coordinates`};if(t<0||r<0||i<1||a<1)return{path:[e],message:`Block "${e}" needs x >= 0, y >= 0, w >= 1 and h >= 1`};if(t+i>12)return{path:[e],message:`Block "${e}" overflows the 12-column grid (x + w = ${t+i})`}}let r=n.filter(([e])=>t.exempt?.has(e)!==!0);for(let[e,[t,n]]of r.entries())for(let[i,a]of r.slice(e+1))if(overlaps(n,a))return{path:[i],message:`Blocks "${t}" and "${i}" overlap`}}function groupedMembers(e){let t=new Set(e.filter(e=>e.type!==`group`).map(e=>e.name)),n=new Set;for(let r of e)if(r.type===`group`)for(let e of r.members)t.has(e)&&n.add(e);return n}function memberlessGroups(e){let t=new Set(e.filter(e=>e.type!==`group`).map(e=>e.name));return new Set(e.flatMap(e=>e.type===`group`&&!e.members.some(e=>t.has(e))?[e.name]:[]))}function groupSizeMessage(t){return t>=2&&t<=e.p.membersPerGroup?void 0:`A group holds 2 to ${e.p.membersPerGroup} blocks, not ${t}`}function findGroupViolation(e){let t=new Map(e.map(e=>[e.name,e])),n=new Map;for(let r of e)if(r.type===`group`)for(let e of r.members){let i=t.get(e);if(i===void 0)return{path:[r.name],message:`Group "${r.name}" names "${e}", which is not a content of this page`};if(i.type===`group`)return{path:[r.name],message:`Group "${r.name}" cannot hold the group "${e}"`};let a=n.get(e);if(a!==void 0)return{path:[r.name],message:a===r.name?`Group "${r.name}" names "${e}" twice`:`"${e}" already belongs to the group "${a}"`};n.set(e,r.name)}}function boundsOf(e){let{minHeight:t,maxHeight:n}=e;return t!==void 0&&n!==void 0?`${t} to ${n} rows`:t===void 0?`at most ${String(n)} rows`:`at least ${t} rows`}function findRowLimitViolation(t){let n=Object.entries(t).find(([,t])=>t.y+t.h>e.p.pageRows);if(n===void 0)return;let[r,i]=n;return{path:[r],message:`Block "${r}" ends at row ${i.y+i.h}, past the page's ${e.p.pageRows} rows`}}function cellViolation(e,t,n){if(!J.includes(t.w))return{path:[e],message:`Block "${e}" width ${t.w} is not one of ${J.join(`, `)}`};if(t.w<n.minWidth)return{path:[e],message:`Block "${e}" width ${t.w} is below its minimum width ${n.minWidth}`};if(n.height===`flexible`&&(n.minHeight!==void 0&&t.h<n.minHeight||n.maxHeight!==void 0&&t.h>n.maxHeight))return{path:[e],message:`Block "${e}" height ${t.h} is outside its bounds (${boundsOf(n)})`}}function sharesRows(e,t){return e.y<t.y+t.h&&t.y<e.y+e.h}function findLayoutRuleViolation(e,t,n,r=new Set){let i=findRowLimitViolation(e);if(i!==void 0)return i;let a=groupedMembers(t),o=Object.entries(e).filter(([e])=>!a.has(e));for(let[e,t]of o){if(r.has(e))continue;let i=cellViolation(e,t,n(e));if(i!==void 0)return i}let[s,c]=o.filter(([e])=>!r.has(e)&&n(e).height===`fill`);if(s!==void 0&&c!==void 0)return{path:[c[0]],message:`Only one block may fill the page: "${s[0]}" and "${c[0]}" both do`};if(s===void 0)return;let[l,u]=s,d=o.find(([e,t])=>e!==l&&sharesRows(t,u));if(d!==void 0)return{path:[l],message:`Block "${l}" fills the page and must be alone in its rows; "${d[0]}" shares them`}}function findRelationAttribute(e,t){return e.attributes.find(e=>e.name===t&&e.type===`relation`)}function relationAcceptsObject(e,t){return e.targets.some(e=>e.object===t||e.object===`*`)}function singleRelationTarget(e){let[t,...n]=e.targets;return t&&n.length===0&&t.object!==`*`?t.object:void 0}function requireSingleRelationTarget(e,t=[e.name,`targets`]){let r=singleRelationTarget(e);if(r===void 0){let r=`Relation "${e.name}" requires one concrete collection target`;throw new n.ValidationError(r,[{path:t,message:r}])}return r}function collectionSourceAddress(e){return e.relation===void 0?{kind:`object`,object:e.object}:e.object===void 0?{kind:`related`,relation:e.relation}:{kind:`relatedFrom`,object:e.object,relation:e.relation}}function collectionSourceAddressOf(e){if(!e||typeof e!=`object`)return;let t=`object`in e?e.object:void 0,n=`relation`in e?e.relation:void 0;if(typeof t==`string`&&typeof n==`string`)return{kind:`relatedFrom`,object:t,relation:n};if(typeof t==`string`&&n===void 0)return{kind:`object`,object:t};if(typeof n==`string`&&t===void 0)return{kind:`related`,relation:n}}function sourcedAttributeOf(e,t){if(t.type===`richtext`)return typeof t.attribute==`string`&&e!==void 0?{object:e,attribute:t.attribute}:void 0;if(t.type!==`collection`)return;let n=collectionSourceAddressOf(t.source);if(n?.kind===`related`)return e===void 0?void 0:{object:e,attribute:n.relation};if(n?.kind===`relatedFrom`)return{object:n.object,attribute:n.relation}}function requireRecordContentContext(e,t,r){if(t!==`record`){let i=`Content "${e}" requires record context. In ${t===`page`?`a standalone page`:`a collection view`} only a collection that lists a whole object, or a custom content that does not require a record, is allowed.`;throw new n.ValidationError(i,[{path:r,message:i}])}}function resolveContentNavigation(e){let t=e.openMode??`page`;return{openMode:t,createMode:e.createMode??t}}function resolveCollectionActions(e,t){return[...new Set(t)].filter(t=>e.actions===void 0||e.actions.includes(t))}const Ve={collection:[`page`,`record`,`display`],group:[`page`,`record`],form:[`record`],activity:[`record`],richtext:[`record`],documents:[`record`],forms:[`record`],emails:[`record`],meetings:[`record`]},Y={collection:{size:{w:12,h:8},minWidth:6,height:`flexible`,minHeight:4,maxHeight:20},activity:{size:{w:12,h:8},minWidth:6,height:`flexible`},page:{size:{w:12,h:8},minWidth:6,height:`flexible`},group:{size:{w:6,h:4},minWidth:6,height:`flexible`}};function contentReadObjects(e,t,n){if(e.type!==`group`)return[...n(e)];let r=new Set;for(let i of e.members){let e=t.get(i);if(e!==void 0&&e.type!==`group`)for(let t of n(e))r.add(t)}return[...r]}function contentPlacementContexts(e,t){return e.type===`custom`?t?.contexts:e.type===`page`||e.type===`collection`&&collectionSourceAddress(e.source).kind!==`object`?[`record`]:Ve[e.type]}function requireContentPlacement(e,t,n,r,i){let a=contentPlacementContexts(e,t);a&&!a.includes(hostPlacementContext(r))&&(requireRecordContentContext(n,r,i),reject(i,`Content "${n}" cannot be placed in a record view or a record page`))}function hostPlacementContext(e){return e===`record`?`record`:`page`}function contentContextOf(e){return e.context===`page`&&e.object!==void 0?`record`:e.context}function violationOf(e,t,r,i){if(!(e instanceof n.SchemaError))throw e;let a=e instanceof n.ValidationError?e.errors[0]:void 0;return{key:JSON.stringify([t,r,e.code,e.message]),contentName:r,path:a?.path??i,message:e.message,code:e.code,error:e}}const He=new Map(getSystemAttributeList().map(e=>[e.name,e]));function reject(e,t){throw new n.ValidationError(t,[{path:e,message:t}])}function requireName(e,t){e.trim().length===0&&reject(t,`API name must not be empty`)}function indexUnique(e,t,r){let i=new Map;return e.forEach((e,a)=>{if(requireName(e.name,[...r,String(a),`name`]),i.has(e.name))throw new n.DuplicateError(t,e.name);i.set(e.name,e)}),i}function capped(e,t){let n=e.slice(0,t).join(`, `);return e.length>t?`${n} … and ${e.length-t} more`:n}function attributeInventory(e,t){return t.length===0?`Object "${e}" has no attributes yet.`:`Attributes of "${e}": ${capped(t,30)}`}function requireAttribute(e,t,n,r,i){if(requireName(t,n),!e)return;let a=e.attributes?.get(t)??He.get(t);if(!a){if(!e.attributes)return;let r=attributeInventory(e.name,[...e.attributes.keys()]);reject(n,`Unknown attribute "${e.name}.${t}". ${r}${i?.()??``}`)}let o=r===void 0?[]:[r].flat();return o.length>0&&!o.includes(a.type)&&reject(n,`Attribute "${e.name}.${t}" must have type ${o.join(` or `)}`),a}function collectContentViewCatalogue(e,t=`authoring`){let r=e.mode??`published`,i=new Map;e.objects.forEach((e,t)=>{if(requireName(e.name,[`objects`,String(t),`name`]),i.has(e.name))throw new n.DuplicateError(`object`,e.name);i.set(e.name,{name:e.name,attributes:indexUnique(e.attributes,`attribute`,[`objects`,String(t),`attributes`])})});let a=new Set;(e.reservedObjects??[]).forEach((e,t)=>{let n=[`reservedObjects`,String(t)];requireName(e,n),!i.has(e)&&(r!==`draft`&&reject(n,`Unresolved reserved object "${e}"`),a.add(e),i.set(e,{name:e}))});let o=indexUnique(e.extensions??[],`extension`,[`extensions`]);function resolveObject(e,t){requireName(e,t);let n=i.get(e);return n||reject(t,`Unknown object "${e}"`),n}function inverseAddresses(e){let t=[];for(let[n,r]of i)if(n!==e)for(let i of r.attributes?.values()??[])i.type===`relation`&&relationAcceptsObject(i,e)&&t.push(`relatedFrom("${n}", "${i.name}")`);return t.sort().slice(0,3)}let authoringSchemaWith=n=>r===`draft`?draftContentViewDefinitionSchemaFor():contentViewDefinitionSchemaFor({traits:t===`structural`?null:(e,t)=>layoutTraitsOf(e,o,t),viewerFiltered:e.viewerFiltered,...n===void 0?{}:{statics:n}}),s=authoringSchemaWith(),c=r===`draft`||t===`structural`?s:contentViewDefinitionSchemaFor({traits:null,viewerFiltered:e.viewerFiltered}),schemaFor=t=>{if(e.authoringViews!==void 0&&!e.authoringViews.has(t))return c;let n=e.staticsOf?.(t);return n===void 0||n.size===0?s:authoringSchemaWith(n)},l=new Map,u=new Map,d=[],f=[];function parseView(e,t,r){let i=schemaFor(r).safeParse(e);if(!i.success)throw new n.ValidationError(`Invalid content view`,i.error.issues.map(e=>({path:[...t,...e.path.map(String)],message:e.message,code:e.code})));let a=i.data;requireName(a.name,[...t,`name`]);let o=a.object??``,s=l.get(o)??new Set;if(s.has(a.name))throw new n.DuplicateError(`view`,`${o}.${a.name}`);if(s.add(a.name),l.set(o,s),a.context!==`page`&&a.default){let e=u.get(a.object)??new Set;if(e.has(a.context))throw new n.DuplicateError(`default view`,`${a.object}.${a.context}`);e.add(a.context),u.set(a.object,e)}return a}return e.views.forEach((e,t)=>{let n=[`views`,String(t)],r=e,i=`${String(r?.object??`?`)}.${String(r?.name??t)}`,a,s;try{a=parseView(e,n,t),s=a.object===void 0?void 0:resolveObject(a.object,[...n,`object`])}catch(e){d.push(violationOf(e,i,null,n));return}a.contents.forEach((e,t)=>{let r=[...n,`contents`,String(t)];try{requireName(e.name,[...r,`name`]),validateContent(e,r,s,contentContextOf(a),o,resolveObject,inverseAddresses)}catch(t){d.push(violationOf(t,i,e.name,r))}}),f.push(a)}),f.forEach((t,r)=>{t.contents.forEach((i,a)=>{if(i.type!==`page`)return;let o=[`views`,String(r),`contents`,String(a),`page`],s=f.find(e=>e.context===`page`&&e.object===i.page.object&&e.name===i.page.name),c=t.context===`page`?`Content "${i.name}" cannot reference a page from a page`:t.object===i.page.object?s||e.complete!==!0?void 0:`Unknown page "${i.page.object}.${i.page.name}"`:`Content "${i.name}" must reference a page of "${String(t.object)}", not of "${i.page.object}"`;c!==void 0&&d.push(violationOf(new n.ValidationError(c,[{path:o,message:c}]),`${String(t.object)}.${t.name}`,i.name,o))})}),{views:f,unresolvedObjects:[...a].sort(),violations:d}}function validateStoredViews(e){let t=collectContentViewCatalogue(e,`structural`).violations[0];if(t)throw t.error}function validateContentViewCatalogue(e){let{views:t,unresolvedObjects:n,violations:r}=collectContentViewCatalogue(e),i=r[0];if(i)throw i.error;return{views:t,unresolvedObjects:n}}function resolveStoredQuery(e,t,n,{owner:r,requireRecord:i,resolveObject:a,inverseAddresses:o}){let s=collectionSourceAddress(e.source),c,l;if(s.kind===`object`)c=a(s.object,[...t,`source`,`object`]);else if(s.kind===`related`){i();let e=[...t,`source`,`relation`],hint=()=>{if(!r)return``;let e=o(r.name);return e.length===0?``:`. Records pointing at "${r.name}" are addressed from the other side: ${e.join(`, `)}`},n=requireAttribute(r,s.relation,e,`relation`,hint);n?.type===`relation`&&(l=n,c=a(requireSingleRelationTarget(n,e),e))}else{i(),c=a(s.object,[...t,`source`,`object`]);let o=[...t,`source`,`relation`],l=requireAttribute(c,s.relation,o,`relation`);if(l?.type===`relation`&&r&&!relationAcceptsObject(l,r.name)){let e=l.targets.map(e=>`"${e.object}"`).join(`, `);reject(o,`Relation "${s.object}.${s.relation}" targets ${e}, not "${r.name}"`)}e.filters?.combinator===`or`&&reject([...t,`filters`,`combinator`],`${n} addresses "${s.object}" from the far side, so its filters must use the "and" combinator`)}return e.sorts?.forEach((e,n)=>requireAttribute(c,e.attribute,[...t,`sorts`,String(n),`attribute`])),e.filters?.rules.forEach((e,n)=>requireAttribute(c,e.attribute,[...t,`filters`,`rules`,String(n),`attribute`])),{target:c,relationAttribute:l}}function validateBlockReferences(e,t,n,r){let i=Object.entries(e.inputs),a;for(let[o,s]of i){let i=t[o];s.kind===`query`&&i!==void 0&&(a=resolveStoredQuery(i,[...n,o],`Block "${e.name}"`,r).target)}function attributeScope(o){if(o===void 0)return;if(o===`$query`)return a;if(o!==`$record`)return r.resolveObject(o,n);let s=i.find(([,e])=>e.kind===`object`)?.[0],c=s===void 0?void 0:t[s];return typeof c==`string`?r.resolveObject(c,[...n,s??`object`]):(r.owner||reject(n,`Block "${e.name}" names attributes, so it needs an object or a record host`),r.owner)}for(let[e,r]of i){let i=t[e];if(r.kind!==`attribute`||i===void 0)continue;let a=attributeScope(r.of);(Array.isArray(i)?i:[i]).forEach((t,o)=>{if(typeof t!=`string`)return;let s=Array.isArray(i)?[...n,e,String(o)]:[...n,e];requireAttribute(a,t,s,r.options?.types)})}for(let[r,a]of i){let i=a.when?.key,o=i===void 0?void 0:e.inputs[i],s=i===void 0?void 0:t[i];a.kind===`period`&&t[r]!==void 0&&o?.kind===`attribute`&&typeof s==`string`&&requireAttribute(attributeScope(o.of),s,[...n,i??r],[`date`])}}function validateContent(e,t,r,i,a,o,s){function requireRecord(){requireRecordContentContext(e.name,i,t)}let c={owner:r,requireRecord,resolveObject:o,inverseAddresses:s},l=hostPlacementContext(i);if(e.type===`custom`){let r=a.get(e.extension);r||reject([...t,`extension`],`Unknown extension "${e.extension}"`),contentPlacementContexts(e,r)?.includes(l)||reject([...t,`extension`],`${e.extension} cannot be placed here`);let i=r.parameters.safeParse(structuredClone(e.parameters??{}));if(!i.success)throw new n.ValidationError(`Invalid extension parameters`,i.error.issues.map(e=>({path:[...t,`parameters`,...e.path.map(String)],message:e.message,code:e.code})));let o=i.data,s=r.refine?.(o,l);s&&reject([...t,`parameters`,s.input],s.message),validateBlockReferences(r,o,[...t,`parameters`],c);return}if(requireContentPlacement(e,void 0,e.name,i,t),e.type!==`page`&&e.type!==`group`){if(e.type===`collection`){let{target:n,relationAttribute:r}=resolveStoredQuery(e,t,`Collection "${e.name}"`,c);e.columns?.forEach((e,i)=>{let a=[...t,`columns`,String(i)];if(typeof e==`string`){requireAttribute(n,e,a);return}let o=[...a,`relationProperty`];r||reject(o,`Relation property columns require a relation source`),r.properties?.definitions.some(t=>t.name===e.relationProperty)||reject(o,`Unknown relation property "${e.relationProperty}"`)}),e.displayAttributes?.forEach((e,r)=>requireAttribute(n,e,[...t,`displayAttributes`,String(r)])),e.descriptionAttribute!==void 0&&requireAttribute(n,e.descriptionAttribute,[...t,`descriptionAttribute`]),e.layout===`kanban`&&e.groupByAttribute!==void 0&&requireAttribute(n,e.groupByAttribute,[...t,`groupByAttribute`]);return}switch(e.type){case`form`:e.groups.forEach((e,n)=>{let i=[...t,`groups`,String(n)];requireName(e.name,[...i,`name`]),e.fields.forEach((e,t)=>requireAttribute(r,e.attribute,[...i,`fields`,String(t),`attribute`]))});break;case`richtext`:requireAttribute(r,e.attribute,[...t,`attribute`],`richtext`),e.titleAttribute!==void 0&&requireAttribute(r,e.titleAttribute,[...t,`titleAttribute`],`text`);break;case`emails`:case`meetings`:e.emailAttributes.forEach((e,n)=>requireAttribute(r,e,[...t,`emailAttributes`,String(n)],`text`));break;case`documents`:e.relations?.forEach((e,n)=>requireAttribute(r,e,[...t,`relations`,String(n)],`relation`));break;case`forms`:e.objectName!==void 0&&o(e.objectName,[...t,`objectName`]);break;case`activity`:break;default:reject(t,`Unknown content type: ${String(e)}`)}}}const X=Object.freeze({size:Object.freeze({w:4,h:4}),minWidth:3,height:`flexible`,minHeight:2,figure:!1});function resolveLayout(e){return e===void 0?X:{size:e.size??X.size,minWidth:e.minWidth??X.minWidth,height:e.height??X.height,...e.minHeight===void 0?{}:{minHeight:e.minHeight},...e.maxHeight===void 0?{}:{maxHeight:e.maxHeight},figure:e.figure??!1}}function baseTraitsOf(e,t){return e.type===`custom`?resolveLayout(t.get(e.extension)?.layout):e.type in Y?resolveLayout(Y[e.type]):X}function widthCovering(e){return J.find(t=>t>=e)??12}function boundOf(e,t){let n=e.filter(e=>e!==void 0);return n.length===0?void 0:t(...n)}function groupTraitsOf(e){if(e.length===0)return resolveLayout(Y.group);let sum=t=>e.reduce((e,n)=>e+t(n),0),t={w:widthCovering(sum(e=>e.size.w)),h:Math.max(...e.map(e=>e.size.h))},n=widthCovering(sum(e=>e.minWidth)),r=e.every(e=>e.figure);if(e.every(e=>e.height===`fit`)){let i=boundOf(e.map(e=>e.maxHeight),Math.max);return{size:t,minWidth:n,height:`fit`,...i===void 0?{}:{maxHeight:i},figure:r}}let i=e.filter(e=>e.height!==`fit`),a=boundOf(i.map(e=>e.minHeight),Math.max),o=boundOf(i.map(e=>e.maxHeight),Math.min),s=o===void 0?void 0:Math.max(o,a??o);return{size:t,minWidth:n,height:`flexible`,...a===void 0?{}:{minHeight:a},...s===void 0?{}:{maxHeight:s},figure:r}}function layoutTraitsOf(e,t,n){let r=e.type===`group`?groupTraitsOf(e.members.flatMap(e=>{let r=n?.get(e);return r===void 0||r.type===`group`?[]:[layoutTraitsOf(r,t)]})):baseTraitsOf(e,t);return e.height===void 0?r:{...r,height:e.height}}function pageTraitsOf(e,t){return n=>{let r=e.get(n);return r?layoutTraitsOf(r,t,e):X}}const Ue=1e4;function isPlainJsonObject(e){let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype||Object.getPrototypeOf(t)===null&&t.constructor?.name===`Object`}function addJsonIssue(e,t,n=[]){e.addIssue({code:`custom`,message:t,path:n})}function pushJsonArrayChildren(e,t,n,r){for(let n of Reflect.ownKeys(e))if(n!==`length`){if(n===`__proto__`){addJsonIssue(r,`The __proto__ key is not allowed in custom props`,[...t.path,n]);continue}(typeof n==`symbol`||!/^(0|[1-9]\d*)$/.test(n))&&addJsonIssue(r,`Arrays cannot contain non-index JSON properties`,[...t.path,n])}for(let i=e.length-1;i>=0;i--){let a=Object.getOwnPropertyDescriptor(e,String(i)),o=[...t.path,i];if(!(a&&`value`in a)){addJsonIssue(r,`Sparse arrays are not valid JSON values`,o);continue}n.push({kind:`enter`,value:a.value,path:o,depth:t.depth+1})}}function pushJsonObjectChildren(e,t,n,r){let i=Reflect.ownKeys(e);for(let a=i.length-1;a>=0;a--){let o=i[a],s=[...t.path,o];if(o===`__proto__`){addJsonIssue(r,`The __proto__ key is not allowed in custom props`,s);continue}if(typeof o==`symbol`){addJsonIssue(r,`Symbol keys are not valid JSON keys`,s);continue}let c=Object.getOwnPropertyDescriptor(e,o);if(!(c?.enumerable&&`value`in c)){addJsonIssue(r,`Custom props must contain enumerable data properties only`,s);continue}n.push({kind:`enter`,value:c.value,path:s,depth:t.depth+1})}}function validateJsonProps(e,t){if(typeof e!=`object`||!e){addJsonIssue(t,`Expected a plain JSON object`);return}try{if(Array.isArray(e)||!isPlainJsonObject(e)){addJsonIssue(t,`Expected a plain JSON object`);return}}catch{addJsonIssue(t,`Custom props contain an object that cannot be safely inspected`);return}let n=new WeakSet,r=[{kind:`enter`,value:e,path:[],depth:0}],i=0;for(;r.length>0;){let e=r.pop();if(!e)break;if(e.kind===`exit`){n.delete(e.value);continue}if(i++,i>Ue){addJsonIssue(t,`Custom props cannot exceed ${Ue.toLocaleString(`en-US`)} total JSON nodes`,e.path);return}if(e.depth>64){addJsonIssue(t,`Custom props cannot exceed depth 64`,e.path);continue}let a=e.value;if(!(a===null||typeof a==`string`||typeof a==`boolean`||typeof a==`number`&&Number.isFinite(a))){if(typeof a!=`object`){addJsonIssue(t,`Expected a JSON value`,e.path);continue}if(n.has(a)){addJsonIssue(t,`Custom props cannot contain circular references`,e.path);continue}try{if(Array.isArray(a)){n.add(a),r.push({kind:`exit`,value:a}),pushJsonArrayChildren(a,e,r,t);continue}if(!isPlainJsonObject(a)){addJsonIssue(t,`Expected an array or plain JSON object`,e.path);continue}n.add(a),r.push({kind:`exit`,value:a}),pushJsonObjectChildren(a,e,r,t)}catch{addJsonIssue(t,`Custom props contain an object that cannot be safely inspected`,e.path)}}}}const We=r.z.unknown().superRefine(validateJsonProps).transform(e=>e),Ge={span:r.z.union([r.z.literal(1),r.z.literal(2),r.z.literal(3),r.z.literal(4),r.z.literal(5),r.z.literal(6),r.z.literal(7),r.z.literal(8),r.z.literal(9),r.z.literal(10),r.z.literal(11),r.z.literal(12)]).optional().describe(`Columns of 12 this field occupies`),label:r.z.string().optional().describe(`Overrides the attribute's label`),readOnly:r.z.boolean().optional().describe(`Shows the value, not editable`)},Ke=r.z.object({attribute:r.z.string().describe(`Attribute API name shown by this field`),...Ge}).strict(),qe=r.z.object({name:r.z.string().describe(`Group API name, unique in the form`),label:r.z.string().describe(`Label people see`),description:r.z.string().optional().describe(`Extra context under the label`),collapsible:r.z.boolean().optional().describe(`Whether the group can be collapsed`),collapsed:r.z.boolean().optional().describe(`Whether the group starts collapsed`),fields:r.z.array(Ke).max(e.p.fieldsPerGroup).describe(`Fields in this group, in order`)}).strict();function refineFormContent(t,n){t.groups.reduce((e,t)=>e+t.fields.length,0)>e.p.fieldsPerFormTab&&n.addIssue({code:`too_big`,origin:`array`,maximum:e.p.fieldsPerFormTab,inclusive:!0,message:`A form content can contain at most ${e.p.fieldsPerFormTab} fields`,path:[`groups`]});let r=new Set,i=new Set;t.groups.forEach((e,t)=>{r.has(e.name)&&n.addIssue({code:`custom`,message:`Duplicate group name "${e.name}"`,path:[`groups`,t,`name`]}),r.add(e.name),e.fields.forEach((e,r)=>{i.has(e.attribute)&&n.addIssue({code:`custom`,message:`Duplicate field attribute "${e.attribute}"`,path:[`groups`,t,`fields`,r,`attribute`]}),i.add(e.attribute)})})}const Z={name:r.z.string().describe(`Content API name, unique in the view`),label:r.z.string().optional().describe(`Label people see`),icon:e.f.optional().describe(`Icon name`),placement:r.z.enum([`main`,`aside`,`grid`]).describe(`main: the tab strip. aside: the side panel. grid: a page block`),height:r.z.enum([`fit`,`flexible`,`fill`]).optional().describe(`Page block height: fit (content), flexible (between bounds) or fill (whole page, one per page)`)},Je={...Z,type:r.z.literal(`collection`),source:M.describe(`object: every record; relation: records linked to this record; both: records of object whose relation points at this record`),visibility:r.z.enum(e.m).optional().describe(`all: no scope; workspace: every member; private: viewer's own; shared: private records other members shared with the viewer`),columns:r.z.array(r.z.union([r.z.string(),r.z.object({relationProperty:r.z.string().refine(e=>e.trim().length>0).describe(`Qualified edge property shown as a column`)}).strict()])).max(e.p.columnsPerTab).optional().describe(`Table columns, in order`),descriptionAttribute:r.z.string().optional().describe(`Secondary line under each row's title (list layout)`),displayAttributes:k.optional().describe(`Attributes shown on each card`),filters:j.optional().describe(`Restricts which records show`),sorts:A.optional().describe(`Sort order`),actions:r.z.enum([`create`,`update`,`delete`,`attach`,`detach`]).array().optional().describe(`Offered actions; absent = every action, [] = none`),openMode:r.z.enum([`page`,`peek`]).optional().describe(`page or peek (the record panel)`),createMode:r.z.enum([`page`,`peek`,`inline`]).optional().describe(`page, peek, or inline (creates without opening)`)},Ye=r.z.object({...Je,layout:r.z.enum([`table`,`list`,`kanban`]).describe(`table columns, list cards, kanban board grouped by a select/status attribute`),columnSizing:r.z.record(r.z.string(),r.z.number()).optional().describe(`Column widths in pixels, by attribute name`),groupByAttribute:r.z.string().optional().describe(`Kanban only: the select or status attribute that names the columns`),kanbanColumnOrder:r.z.array(r.z.string()).optional().describe(`Kanban: column order by option value`),kanbanColumnVisibility:r.z.record(r.z.string(),r.z.boolean()).optional().describe(`Kanban: which columns are shown`),kanbanPinnedColumns:r.z.array(r.z.string()).optional().describe(`Kanban: columns pinned first`)}).strict().superRefine((e,t)=>{let n=[`groupByAttribute`,`kanbanColumnOrder`,`kanbanColumnVisibility`,`kanbanPinnedColumns`];if(e.layout===`kanban`){e.groupByAttribute===void 0&&t.addIssue({code:`custom`,path:[`groupByAttribute`],message:`A kanban layout requires groupByAttribute`});return}for(let r of n)e[r]!==void 0&&t.addIssue({code:`custom`,path:[r],message:`Only a kanban layout groups by an attribute`})}),Q={...Z,type:r.z.literal(`form`),groups:r.z.array(qe).max(e.p.groupsPerFormTab).describe(`Field groups, in order`),formColumns:r.z.union([r.z.literal(1),r.z.literal(2),r.z.literal(3)]).optional().describe(`Grid columns, 1-3`),density:r.z.enum([`compact`,`comfortable`,`spacious`]).optional().describe(`Vertical spacing between fields`)},Xe=r.z.object(Q).strict().superRefine(refineFormContent),Ze=r.z.object({...Q,groups:Q.groups.min(1,`A published form content requires at least one group`)}).strict().superRefine(refineFormContent),$=[Ye,r.z.object({...Z,type:r.z.literal(`group`),placement:r.z.literal(`grid`).describe(`Always grid`),members:r.z.array(r.z.string()).min(1).max(e.p.membersPerGroup).describe(`Contents side by side`)}).strict(),r.z.object({...Z,type:r.z.literal(`custom`),extension:r.z.string().describe(`Name of a registered extension`),parameters:r.z.lazy(()=>We).optional().describe(`Extension parameters`)}).strict(),r.z.object({...Z,type:r.z.literal(`activity`)}).strict(),r.z.object({...Z,type:r.z.literal(`richtext`),attribute:r.z.string().describe(`Richtext attribute edited in place`),titleAttribute:r.z.string().optional().describe(`Text attribute shown as the title`)}).strict(),r.z.object({...Z,type:r.z.literal(`documents`),allowUpload:r.z.boolean().optional().describe(`Lets people add files here`),allowRemove:r.z.boolean().optional().describe(`Lets people remove files here`),hideAttachments:r.z.boolean().optional().describe(`Hides files attached elsewhere (e.g. emails)`),relations:r.z.array(r.z.string()).optional().describe(`Document relations shown; the record's own files if absent`)}).strict(),r.z.object({...Z,type:r.z.literal(`forms`),objectName:r.z.string().optional().describe(`Limits to this object's published forms`)}).strict(),r.z.object({...Z,type:r.z.literal(`emails`),emailAttributes:r.z.array(r.z.string()).max(e.p.emailAttributesPerTab).describe(`Addresses`)}).strict(),r.z.object({...Z,type:r.z.literal(`meetings`),emailAttributes:r.z.array(r.z.string()).max(e.p.emailAttributesPerTab).describe(`Addresses`)}).strict(),r.z.object({...Z,type:r.z.literal(`page`),page:r.z.object({object:r.z.string().describe(`Its object`),name:r.z.string().describe(`Its name`)}).strict().describe(`The record page this tab renders`)}).strict()],Qe=r.z.discriminatedUnion(`type`,[Xe,...$]),$e=r.z.discriminatedUnion(`type`,[Ze,...$]),et={name:r.z.string(),label:r.z.string(),description:r.z.string().optional(),icon:e.f.optional()},tt=r.z.object({x:r.z.number().describe(`Column`),y:r.z.number().describe(`Row`),w:r.z.number().describe(`Width: 3, 4, 6, 8, 9 or 12; x + w ≤ 12`),h:r.z.number().describe(`Height`)}).strict();function contentViewBaseSchemaFor(t){let n=r.z.array(t).max(e.p.tabsPerView);return r.z.discriminatedUnion(`context`,[r.z.object({...et,object:r.z.string(),context:r.z.enum([`collection`,`record`]),default:r.z.boolean().optional(),contents:n}).strict(),r.z.object({...et,object:r.z.string().optional(),context:r.z.literal(`page`),home:r.z.boolean().optional(),grid:r.z.record(r.z.string(),tt).refine(t=>Object.keys(t).length<=e.p.tabsPerView,{message:`A page holds at most ${e.p.tabsPerView} blocks`}),contents:n}).strict()])}const nt=contentViewBaseSchemaFor(Qe),rt=contentViewBaseSchemaFor($e);function registryTraits(e,t){return layoutTraitsOf(e,Be,t)}function addGroupSizeIssues(e,t){for(let n of e.contents){let e=n.type===`group`?groupSizeMessage(n.members.length):void 0;e&&t.addIssue({code:`custom`,message:e,path:[`contents`]})}}function addDuplicateContentNameIssues(e,t){let n=new Set;e.contents.forEach((e,r)=>{n.has(e.name)&&t.addIssue({code:`custom`,message:`Duplicate content name "${e.name}"`,path:[`contents`,r,`name`]}),n.add(e.name)})}function addPlacementIssues(e,t){e.contents.forEach((n,r)=>{let i=n.placement===`grid`;e.context===`page`&&!i&&t.addIssue({code:`custom`,message:`Content "${n.name}" of a page must be placed on the grid`,path:[`contents`,r,`placement`]}),e.context!==`page`&&i&&t.addIssue({code:`custom`,message:`Content "${n.name}" cannot be placed on a grid outside a page`,path:[`contents`,r,`placement`]})})}function addIssue(e,t){e.addIssue({code:`custom`,message:t.message,path:[`grid`,...t.path]})}function addGridIssues(e,t,n,r){if(e.context!==`page`||!e.grid)return;let i=new Set(e.contents.map(e=>e.name)),a=groupedMembers(e.contents);for(let n of i)a.has(n)||Object.hasOwn(e.grid,n)||t.addIssue({code:`custom`,message:`Content "${n}" has no grid position`,path:[`grid`]});let o=Object.keys(e.grid).filter(e=>!i.has(e));for(let e of o)t.addIssue({code:`custom`,message:`Grid position "${e}" matches no content`,path:[`grid`,e]});if(e.home&&e.object!==void 0&&t.addIssue({code:`custom`,message:`Only a standalone page can be the home`,path:[`home`]}),o.length>0)return;let s=findGridViolation(e.grid,{exempt:a});if(s){addIssue(t,s);return}if(n===null)return;let c=findGroupViolation(e.contents);if(c){t.addIssue({code:`custom`,message:c.message,path:[`contents`]});return}let l=new Map(e.contents.map(e=>[e.name,e])),u=findLayoutRuleViolation(e.grid,e.contents,e=>n(l.get(e),l),r);u&&addIssue(t,u)}function draftContentViewDefinitionSchemaFor(){return nt.superRefine((e,t)=>{let n=e;addDuplicateContentNameIssues(n,t),addPlacementIssues(n,t),addGridIssues(n,t,null)})}function contentViewDefinitionSchemaFor(e={}){let t=e.traits===void 0?registryTraits:e.traits;return rt.superRefine((n,r)=>{let i=n;addDuplicateContentNameIssues(i,r),addPlacementIssues(i,r),addGridIssues(i,r,t,e.statics),e.viewerFiltered||addGroupSizeIssues(i,r),n.context!==`page`&&!n.contents.some(e=>e.placement===`main`)&&r.addIssue({code:`custom`,message:`A published view requires at least one main content`,path:[`contents`]})})}const it=draftContentViewDefinitionSchemaFor(),at=contentViewDefinitionSchemaFor();Object.defineProperty(exports,"$",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"$t",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return findLayoutRuleViolation}}),Object.defineProperty(exports,"At",{enumerable:!0,get:function(){return isLocationPartOperator}}),Object.defineProperty(exports,"B",{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,"Bt",{enumerable:!0,get:function(){return currentActor}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return collectionSourceAddressOf}}),Object.defineProperty(exports,"Cn",{enumerable:!0,get:function(){return isManagedSystemAttribute}}),Object.defineProperty(exports,"Ct",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return requireSingleRelationTarget}}),Object.defineProperty(exports,"Dt",{enumerable:!0,get:function(){return edgePropertyFilterTarget}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return relationAcceptsObject}}),Object.defineProperty(exports,"Et",{enumerable:!0,get:function(){return attributeFilterTarget}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"Ft",{enumerable:!0,get:function(){return isSetMembershipOperator}}),Object.defineProperty(exports,"G",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"Gt",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"H",{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,"Ht",{enumerable:!0,get:function(){return now}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return 12}}),Object.defineProperty(exports,"It",{enumerable:!0,get:function(){return normalizeForEdgeRpc}}),Object.defineProperty(exports,"J",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(exports,"Jt",{enumerable:!0,get:function(){return parseBlockParameters}}),Object.defineProperty(exports,"K",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(exports,"Kt",{enumerable:!0,get:function(){return blockObjectInputs}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return findGridViolation}}),Object.defineProperty(exports,"Lt",{enumerable:!0,get:function(){return toMultiValueOperator}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return groupSizeMessage}}),Object.defineProperty(exports,"Mt",{enumerable:!0,get:function(){return systemColumnFilterTarget}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return groupedMembers}}),Object.defineProperty(exports,"Nt",{enumerable:!0,get:function(){return canonicalizeFilterValue}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return singleRelationTarget}}),Object.defineProperty(exports,"Ot",{enumerable:!0,get:function(){return filterOperatorsOfType}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return memberlessGroups}}),Object.defineProperty(exports,"Pt",{enumerable:!0,get:function(){return getOperatorPolarity}}),Object.defineProperty(exports,"Q",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(exports,"Qt",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"R",{enumerable:!0,get:function(){return overlaps}}),Object.defineProperty(exports,"Rt",{enumerable:!0,get:function(){return extractCurrencyFilterValue}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return collectionSourceAddress}}),Object.defineProperty(exports,"Sn",{enumerable:!0,get:function(){return getSystemAttributeList}}),Object.defineProperty(exports,"St",{enumerable:!0,get:function(){return toUtcDayString}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return findRelationAttribute}}),Object.defineProperty(exports,"Tt",{enumerable:!0,get:function(){return normalizeOperator}}),Object.defineProperty(exports,"U",{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,"Ut",{enumerable:!0,get:function(){return today}}),Object.defineProperty(exports,"V",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"Vt",{enumerable:!0,get:function(){return isDynamicValue}}),Object.defineProperty(exports,"W",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"Wt",{enumerable:!0,get:function(){return isCalendarDay}}),Object.defineProperty(exports,"X",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(exports,"Xt",{enumerable:!0,get:function(){return buildQualifiedAttribute}}),Object.defineProperty(exports,"Y",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"Yt",{enumerable:!0,get:function(){return`__`}}),Object.defineProperty(exports,"Z",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"Zt",{enumerable:!0,get:function(){return parseQualifiedAttribute}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return validateContentViewCatalogue}}),Object.defineProperty(exports,"_n",{enumerable:!0,get:function(){return isLocationFilterProperty}}),Object.defineProperty(exports,"_t",{enumerable:!0,get:function(){return collectQualifiedRuleIssues}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return tt}}),Object.defineProperty(exports,"an",{enumerable:!0,get:function(){return isAttributeSortable}}),Object.defineProperty(exports,"at",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return resolveCollectionActions}}),Object.defineProperty(exports,"bn",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"bt",{enumerable:!0,get:function(){return resolveIsWithinBounds}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return layoutTraitsOf}}),Object.defineProperty(exports,"cn",{enumerable:!0,get:function(){return relationTargetsOf}}),Object.defineProperty(exports,"ct",{enumerable:!0,get:function(){return query}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return 30}}),Object.defineProperty(exports,"dn",{enumerable:!0,get:function(){return getAttributeCapabilities}}),Object.defineProperty(exports,"dt",{enumerable:!0,get:function(){return be}}),Object.defineProperty(exports,"en",{enumerable:!0,get:function(){return getRollupFilterOperators}}),Object.defineProperty(exports,"et",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return attributeInventory}}),Object.defineProperty(exports,"fn",{enumerable:!0,get:function(){return getAttributeFilterOperators}}),Object.defineProperty(exports,"ft",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return requireContentPlacement}}),Object.defineProperty(exports,"gn",{enumerable:!0,get:function(){return isAttributeSearchable}}),Object.defineProperty(exports,"gt",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return contentReadObjects}}),Object.defineProperty(exports,"hn",{enumerable:!0,get:function(){return isAttributeKanbanGroupable}}),Object.defineProperty(exports,"ht",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return draftContentViewDefinitionSchemaFor}}),Object.defineProperty(exports,"in",{enumerable:!0,get:function(){return inferInverseCardinality}}),Object.defineProperty(exports,"it",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return findRowLimitViolation}}),Object.defineProperty(exports,"jt",{enumerable:!0,get:function(){return locationPartFilterTarget}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return findGroupViolation}}),Object.defineProperty(exports,"kt",{enumerable:!0,get:function(){return filterTargetsOf}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return pageTraitsOf}}),Object.defineProperty(exports,"ln",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"lt",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return collectContentViewCatalogue}}),Object.defineProperty(exports,"mn",{enumerable:!0,get:function(){return isAttributeGroupable}}),Object.defineProperty(exports,"mt",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return contentViewDefinitionSchemaFor}}),Object.defineProperty(exports,"nn",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"nt",{enumerable:!0,get:function(){return metricComparePeriod}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(exports,"on",{enumerable:!0,get:function(){return isBilateralRelation}}),Object.defineProperty(exports,"ot",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return capped}}),Object.defineProperty(exports,"pn",{enumerable:!0,get:function(){return isAttributeFilterable}}),Object.defineProperty(exports,"pt",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"q",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(exports,"qt",{enumerable:!0,get:function(){return defineBlock}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return it}}),Object.defineProperty(exports,"rn",{enumerable:!0,get:function(){return`*`}}),Object.defineProperty(exports,"rt",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,"sn",{enumerable:!0,get:function(){return isUniversalRelation}}),Object.defineProperty(exports,"st",{enumerable:!0,get:function(){return RecordQuery}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return at}}),Object.defineProperty(exports,"tn",{enumerable:!0,get:function(){return isNoValueOperator}}),Object.defineProperty(exports,"tt",{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(exports,"un",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"ut",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return validateStoredViews}}),Object.defineProperty(exports,"vn",{enumerable:!0,get:function(){return resolveEffectiveFilterType}}),Object.defineProperty(exports,"vt",{enumerable:!0,get:function(){return validateQualifiedRule}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return sourcedAttributeOf}}),Object.defineProperty(exports,"wt",{enumerable:!0,get:function(){return normalizeFilterRule}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return resolveContentNavigation}}),Object.defineProperty(exports,"xn",{enumerable:!0,get:function(){return getSystemAttributeI18nKey}}),Object.defineProperty(exports,"xt",{enumerable:!0,get:function(){return resolveUtcDayBounds}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return requireRecordContentContext}}),Object.defineProperty(exports,"yn",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"yt",{enumerable:!0,get:function(){return isRelativeDateValue}}),Object.defineProperty(exports,"z",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(exports,"zt",{enumerable:!0,get:function(){return extractFilterValue}});
|
|
@@ -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{n as e,s as t}from"./record-aggregates-CzG86pUS.mjs";import{DuplicateError as n,SchemaError as r,ValidationError as i}from"./exceptions.mjs";import{f as a,m as o,p as s}from"./attribute-validators-DRqhAt2t.mjs";import{z as c}from"zod";const l={createdAt:`createdAt`,updatedAt:`updatedAt`,createdBy:`createdBy`,lastUpdatedBy:`lastUpdatedBy`,attachments:`attachments`};function getSystemAttributeI18nKey(e){return l[e]}const u={createdAt:{id:`system:createdAt`,name:`createdAt`,label:`Created time`,type:`date`,required:!1,system:!0,icon:`clock-circle`,description:`When this record was created`},updatedAt:{id:`system:updatedAt`,name:`updatedAt`,label:`Last edited time`,type:`date`,required:!1,system:!0,icon:`clock-circle`,description:`When this record was last modified`},createdBy:{id:`system:createdBy`,name:`createdBy`,label:`Created by`,type:`user`,required:!1,system:!0,multiple:!1,icon:`user`,description:`Actor who created this record`},lastUpdatedBy:{id:`system:lastUpdatedBy`,name:`lastUpdatedBy`,label:`Last edited by`,type:`user`,required:!1,system:!0,multiple:!1,icon:`user`,description:`Actor who last modified this record`},attachments:{id:`system:attachments`,name:`attachments`,label:`Attachments`,type:`document`,required:!1,system:!0,hidden:!0,icon:`paperclip`,description:`Free-form document attachments`}};function getSystemAttributeList(){return Object.values(u)}function isManagedSystemAttribute(e){return e.id?.startsWith(`system:`)??!1}const d=[`is`,`is_not`,`contains`,`not_contains`,`starts_with`,`ends_with`,`is_empty`,`is_not_empty`],f=[`is`,`is_not`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`is_empty`,`is_not_empty`],p=[`is`],m=[`is`,`is_not`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`is_within`,`on_day_month`,`is_empty`,`is_not_empty`],h=[`is`,`is_not`,`any_of`,`none_of`,`is_empty`,`is_not_empty`],g=[`any_of`,`none_of`,`is_empty`,`is_not_empty`],_=[`is`,`is_not`,`any_of`,`none_of`,`is_empty`,`is_not_empty`],v=[`is_empty`,`is_not_empty`],y=[`is`,`is_not`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`contains`,`not_contains`,`is_empty`,`is_not_empty`],b=[`city`,`postalCode`,`country`];function isLocationFilterProperty(e){return b.includes(e)}const x={text:d,richtext:[],number:f,checkbox:p,date:m,phone:[`is`,`is_not`,`contains`,`not_contains`,`starts_with`,`is_empty`,`is_not_empty`],currency:f,status:h,select:h,multiselect:g,location:[],user:_,relation:_,formula:y,document:v},ee=new Set([`formula`,`rollup`]),te=new Set([`user`,`relation`,`document`]),ne=new Set([`text`,`richtext`,`number`,`select`,`multiselect`,`status`,`date`,`phone`,`currency`,`location`,`user`,`relation`,`document`]),re=new Set([`text`,`number`,`date`,`phone`,`currency`,`select`,`multiselect`]),ie=new Set([`text`,`richtext`,`phone`,`status`,`select`,`multiselect`]),ae=new Set([`text`,`number`,`checkbox`,`date`,`phone`,`currency`,`status`,`select`]);function getAttributeCapabilities(e){let t=!!(e.hidden||e.archived),n=!e.archived,r=ee.has(e.type),i=e.type===`document`,a=te.has(e.type),o=getAttributeCardinality(e),s=t?[]:getRawFilterOperators(e),c=s.length>0&&!t,l=!t&&ie.has(e.type),u=!t&&ae.has(e.type),d=!t&&isGroupableType(e.type),f=!t&&e.type===`status`,p=isManagedSystemAttribute(e),m=r||i||p,h=!(t||m),g=isRequiredForbidden(e.type)?`forbidden`:`allowed`,_=getDefaultValueCapability(e.type),v=supportsMaxItems(e),y=re.has(e.type),b=!(!e.deprecated||t),x=resolveEditMode(e);return{lifecycle:{active:n,deprecated:!!e.deprecated,visibleInArchitect:!0,visibleInRuntime:!t,warningWhenDeprecated:b},storage:{mode:r?`computed`:a?`edge`:`value`,cardinality:o,edgeBacked:a,preservesExistingValues:!!e.archived,qualifiedProperties:supportsQualifiedProperties(e.type),polymorphic:getPolymorphicCapability(e),maxItems:v},authoring:{editable:h,readOnly:m,directEdit:h&&x===`inline`,required:g,defaultValue:_,placeholder:y,maxItems:v},presentation:{formField:!t&&isFormFieldType(e.type),tableCell:!t&&isTableCellType(e.type),defaultColumn:!t&&isDefaultColumnType(e.type),compactDisplay:!t,popoverEditor:!t&&x===`popover`,placeholder:y,warningWhenDeprecated:b},query:{filterable:c,searchable:l,sortable:u,groupable:d,kanbanGroupable:f,operators:s},agent:{readable:!t,writable:h&&!i,compactReadable:!t,contentReadable:!t&&isContentReadableType(e.type),requiresDedicatedTool:i},exchange:{importable:!t,exportable:!t,schemaExportable:!0,metadataExportable:!1}}}function getAttributeFilterOperators(e){return getAttributeCapabilities(e).query.operators}function isAttributeFilterable(e){return getAttributeCapabilities(e).query.filterable}function isAttributeSearchable(e){return getAttributeCapabilities(e).query.searchable}function isAttributeSortable$1(e){return getAttributeCapabilities(e).query.sortable}function isAttributeGroupable(e){return getAttributeCapabilities(e).query.groupable}function isAttributeKanbanGroupable(e){return getAttributeCapabilities(e).query.kanbanGroupable}function resolveEffectiveFilterType(e){if(e.type!==`rollup`)return e.type;let t=e;if(t.function===`earliest`||t.function===`latest`)return`date`;if(t.function===`original`){let e=t.targetAttributeType;if(e&&hasFilterOperatorEntry(e))return e}return`number`}function getRollupFilterOperators$1(e){let t=resolveEffectiveFilterType(e);return hasFilterOperatorEntry(t)?x[t]:x.number}function getRawFilterOperators(e){return e.type===`rollup`?getRollupFilterOperators$1(e):x[e.type]??[]}function getAttributeCardinality(e){return e.type===`multiselect`||e.type===`document`||e.type===`user`&&e.multiple===!0||e.type===`relation`&&e.cardinality===`many`?`many`:`one`}function getPolymorphicCapability(e){if(e.type!==`relation`)return`none`;let t=e.targets??[];return t.length===1&&t[0]?.object===`*`?`internal`:t.length>1?`code-only`:`none`}function supportsMaxItems(e){return e.type===`multiselect`||e.type===`relation`&&e.cardinality===`many`}function supportsQualifiedProperties(e){return e===`relation`||e===`document`}function isRequiredForbidden(e){return e===`checkbox`||e===`formula`||e===`rollup`}function getDefaultValueCapability(e){return e===`checkbox`?`automatic`:e===`formula`||e===`rollup`?`forbidden`:ne.has(e)?`static`:`forbidden`}function isDefaultColumnType(e){return isTableCellType(e)}function isTableCellType(e){return e!==`richtext`&&e!==`document`}function isFormFieldType(e){return e!==`richtext`}function resolveEditMode(e){switch(e.type){case`checkbox`:return`inline`;case`number`:return e.renderAs===`rating`?`inline`:`default`;case`select`:case`multiselect`:return e.renderAs===`badges`?`inline`:`popover`;case`status`:case`relation`:case`user`:case`date`:return`popover`;default:return`default`}}function isGroupableType(e){return e===`status`||e===`currency`}function isContentReadableType(e){return e===`richtext`||e===`document`}function hasFilterOperatorEntry(e){return Object.prototype.hasOwnProperty.call(x,e)}const oe=[`text`,`richtext`,`number`,`checkbox`,`date`,`phone`,`currency`,`status`,`location`,`select`,`multiselect`,`user`,`relation`,`formula`,`rollup`,`document`],se=`*`;function relationTargetsOf(e){return e.type!==`relation`||!Array.isArray(e.targets)?[]:e.targets.map(e=>e.object).filter(e=>e!==`*`)}function isUniversalRelation(e){return e.targets.length===1&&e.targets[0].object===`*`}function isBilateralRelation(e){return e.bilateral!==void 0}function inferInverseCardinality(e){return`many`}function isAttributeSortable(e){return isAttributeSortable$1(e)}const ce=x,le=[`is_empty`,`is_not_empty`];function isNoValueOperator(e){return le.includes(e)}function getRollupFilterOperators(e){return getRollupFilterOperators$1(e)}const ue=`__`;function parseQualifiedAttribute(e){let t=e.indexOf(`__`);return t<=0||t+2>=e.length?{kind:`scalar`,attribute:e}:{kind:`qualified`,root:e.slice(0,t),property:e.slice(t+2)}}function buildQualifiedAttribute(e,t){return`${e}__${t}`}const S=[`page`,`record`,`display`];function defineBlock(e){let t=Object.fromEntries(Object.entries(e.inputs).map(([e,t])=>[e,t.isOptional?t.schema.optional():t.schema]));return Object.freeze({name:e.name,label:e.label,icon:e.icon,family:e.family,contexts:Object.freeze([...e.contexts]),inputs:Object.freeze({...e.inputs}),...e.layout===void 0?{}:{layout:Object.freeze({...e.layout})},parameters:c.object(t).strict().superRefine((t,n)=>{let r=e.refine?.(t);r&&n.addIssue({code:`custom`,path:[r.input],message:r.message})}),...e.refine===void 0?{}:{refine:(t,n)=>e.refine?.(t,n)}})}function parseBlockParameters(e,t,n){let r=e.parameters.safeParse(structuredClone(t??{}));if(!r.success)throw i.fromZodErrors(r.error.issues.map(e=>({path:[...n,...e.path.map(String)],message:e.message})));return r.data}function blockObjectInputs(e,t,n){return Object.entries(e.inputs).flatMap(([e,r])=>{let i=t[e];if(r.kind===`object`&&typeof i==`string`)return[i];if(r.kind===`query`&&typeof i==`object`&&i){let e=i.source;if(!e)return[];if(`object`in e&&typeof e.object==`string`)return[e.object];let t=n?.attributes.find(t=>t.name===e.relation);return t?relationTargetsOf(t):[]}return[]})}const de=/^\d{4}-\d{2}-\d{2}$/u;function isCalendarDay(e){if(!de.test(e))return!1;let t=new Date(`${e}T00:00:00Z`);return!Number.isNaN(t.getTime())&&t.toISOString().slice(0,10)===e}function isDynamicValue(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&`dynamic`in e}function currentActor(){return{dynamic:`actor`,ref:`current`}}function today(){return{dynamic:`date`,anchor:`today`}}function now(){return{dynamic:`date`,anchor:`now`}}function toAmount(e){if(typeof e==`number`)return Number.isFinite(e)?e:null;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:null}return null}function extractCurrencyFilterValue(e){return typeof e==`object`&&e?`value`in e?toAmount(e.value):null:toAmount(e)}function extractFilterValue(e){return e==null?null:typeof e==`object`&&`value`in e?e.value??null:e}const fe=new Set([`is_not`,`not_contains`,`none_of`,`is_empty`]),pe={is_not:`is`,not_contains:`contains`,none_of:`any_of`,is_empty:`is_not_empty`};function getOperatorPolarity(e){return fe.has(e)?`none`:`any`}function normalizeForEdgeRpc(e){return pe[e]??e}const C={is:`any_of`,is_not:`none_of`};function toMultiValueOperator(e){return C[e]??e}const me=new Set(Object.values(C).filter(e=>e!==void 0));function isSetMembershipOperator(e){return me.has(e)}function canonicalizeFilterValue(e,t){let n=e.value;if(isNoValueOperator(e.operator)||n==null||isDynamicValue(n))return;if(isSetMembershipOperator(e.operator)){Array.isArray(n)||(e.value=[n]);return}if(t!==`currency`)return;let r=extractCurrencyFilterValue(n);if(r!==null){e.value=r;return}if(!hasCurrencyAmount(n))return;let a=`Filter on a currency attribute expected a numeric amount, received ${JSON.stringify(n)}`;throw new i(a,[{path:[`value`],message:a}])}function hasCurrencyAmount(e){return typeof e!=`object`||`value`in e&&e.value!=null}const w=x.text,he=[`is`,`is_not`,`is_empty`,`is_not_empty`],T=[`is`,`is_not`,`any_of`,`none_of`,`is_empty`,`is_not_empty`],E={id:T,objectId:T,tenantId:T,label:x.text,createdAt:x.date,updatedAt:x.date,deletedAt:x.date,createdBy:x.user,lastUpdatedBy:x.user},ge=new Set([`createdAt`,`updatedAt`,`deletedAt`]);function offeredOn(e,t){return ge.has(e)?t.filter(e=>e!==`on_day_month`):t}function fullyOffered(e,t,n,r){return{target:e,attribute:t,...r?{property:r}:{},operators:n,offered:n}}function attributeFilterTarget(e){let t=getAttributeFilterOperators(e);return{target:e.name,attribute:e.name,operators:t,offered:offeredOn(e.name,t)}}function locationPartFilterTarget(e,t){return{target:buildQualifiedAttribute(e,t),attribute:e,property:t,operators:w,offered:t===`country`?he:w}}function edgePropertyFilterTarget(e,t){let n=hasOperatorEntry(t.type)?x[t.type]:[];return fullyOffered(buildQualifiedAttribute(e,t.name),e,n,t.name)}function hasOperatorEntry(e){return Object.prototype.hasOwnProperty.call(x,e)}function systemColumnFilterTarget(e){let t=Object.prototype.hasOwnProperty.call(E,e)?E[e]:void 0;return t?{target:e,attribute:e,operators:t,offered:offeredOn(e,t)}:void 0}function filterOperatorsOfType(e){return isAttributeType(e)?getAttributeFilterOperators({type:e}):[]}function isAttributeType(e){return oe.includes(e)}function isLocationPartOperator(e){return w.includes(e)}function carriesEdgeProperties(e){return e.type===`relation`||e.type===`document`}function filterTargetsOf(e){let t=[];for(let n of e){if(n.type===`location`){for(let e of b)t.push(locationPartFilterTarget(n.name,e));continue}if(t.push(attributeFilterTarget(n)),!carriesEdgeProperties(n))continue;let e=n.properties?.definitions;for(let r of e??[])t.push(edgePropertyFilterTarget(n.name,r))}let n=new Set(e.map(e=>e.name));for(let e of Object.keys(E)){if(n.has(e))continue;let r=systemColumnFilterTarget(e);r&&t.push(r)}return t.filter(e=>e.operators.length>0)}const _e={eq:`is`,equals:`is`,equal:`is`,"==":`is`,"=":`is`,neq:`is_not`,notEqual:`is_not`,isNot:`is_not`,"!=":`is_not`,"<>":`is_not`,lt:`less_than`,"<":`less_than`,gt:`greater_than`,">":`greater_than`,lte:`less_or_equal`,"<=":`less_or_equal`,gte:`greater_or_equal`,">=":`greater_or_equal`,in:`any_of`,isAnyOf:`any_of`,anyOf:`any_of`,oneOf:`any_of`,notIn:`none_of`,not_in:`none_of`,isNoneOf:`none_of`,noneOf:`none_of`,notOneOf:`none_of`,startsWith:`starts_with`,beginsWith:`starts_with`,endsWith:`ends_with`,doesNotContain:`not_contains`,notContain:`not_contains`,isEmpty:`is_empty`,isNotEmpty:`is_not_empty`};function normalizeOperator(e){return _e[e]??e}function normalizeFilterRule(e){let t=normalizeOperator(e.operator);return t===e.operator?e:{...e,operator:t}}const D=864e5,ve=new Set([`days`,`weeks`,`months`,`years`]),ye=new Set([`past`,`future`]);function isRelativeDateValue(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.amount==`number`&&Number.isFinite(t.amount)&&t.amount>0&&typeof t.unit==`string`&&ve.has(t.unit)&&typeof t.direction==`string`&&ye.has(t.direction)}function utcDayStart(e){return Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())}function shiftUtcDay(e,t,n){if(n===`days`)return e+t*D;if(n===`weeks`)return e+t*7*D;let r=new Date(e),i=r.getUTCFullYear()+(n===`years`?t:0),a=r.getUTCMonth()+(n===`months`?t:0),o=new Date(Date.UTC(i,a+1,0)).getUTCDate();return Date.UTC(i,a,Math.min(r.getUTCDate(),o))}function resolveIsWithinBounds(e,t=new Date){if(!isRelativeDateValue(e))return null;let n=utcDayStart(t),r=Math.trunc(e.amount),i=e.direction===`past`?{startMs:shiftUtcDay(n,-r,e.unit),endMs:n+D}:{startMs:n,endMs:shiftUtcDay(n,r,e.unit)+D};return Number.isFinite(i.startMs)&&Number.isFinite(i.endMs)?i:null}function resolveUtcDayBounds(e){if(!Number.isFinite(e))return null;let t=utcDayStart(new Date(e));return Number.isFinite(t)?{startMs:t,endMs:t+D}:null}function toUtcDayString(e){return new Date(e).toISOString().slice(0,10)}const O=new Set([`relation`,`document`,`user`]),be={id:`text`,objectId:`text`,objectName:`text`,tenantId:`text`,label:`text`,createdAt:`date`,updatedAt:`date`,deletedAt:`date`,deletedBy:`user`,createdBy:`user`,lastUpdatedBy:`user`,visibility:`select`,ownedBy:`user`},k={before:`"less_than"`,after:`"greater_than"`,on_or_before:`"less_or_equal"`,on_or_after:`"greater_or_equal"`,is_checked:`"is" with value true`,is_not_checked:`"is" with value false`,day_month_eq:`"on_day_month"`},xe=new Set(Object.entries(x).filter(([,e])=>e.includes(`any_of`)&&!e.includes(`contains`)).map(([e])=>e)),Se={contains:`any_of`,not_contains:`none_of`};function resolveCanonicalOperator(e,t){let n=k[e];if(n){let t=`Unknown filter operator "${e}" — use ${n}`;throw new i(t,[{path:[`operator`],message:t}])}let r=normalizeOperator(e),a=Se[r];if(a&&xe.has(t)){let e=`Operator "${r}" is not valid for type "${t}" — use "${a}"`;throw new i(e,[{path:[`operator`],message:e}])}return r}function assertPropertyOperator(e,t,n){let r=resolveCanonicalOperator(e,t);if(!n.includes(r)){let r=`Operator "${e}" is not valid for property type "${t}". Valid operators: ${n.length?n.join(`, `):`(no operators registered for this type)`}.`;throw new i(r,[{path:[`operator`],message:r}])}return r}function assertRelativeDateValue(e){if(e.operator===`is_within`&&!isRelativeDateValue(e.value)){let e=`Operator "is_within" requires a relative-date value { amount: positive number, unit: days|weeks|months|years, direction: past|future }`;throw new i(e,[{path:[`value`],message:e}])}}const Ce=/^(\d{4}-\d{2}-\d{2})(?:[T ](?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z|[+-](?:(?:0\d|1[0-3])(?::[0-5]\d)?|14(?::00)?))?)?$/,we=new Set([`is`,`is_not`,`less_than`,`less_or_equal`,`greater_than`,`greater_or_equal`]);function assertAbsoluteDateValue(e,t){if(t!==`date`||!we.has(e.operator))return;let n=e.value;if(n==null||isDynamicValue(n)||typeof n==`string`&&isCastableDay(n))return;let r=`Filter on a date attribute expected a YYYY-MM-DD day, optionally followed by a time, received ${JSON.stringify(n)}`;throw new i(r,[{path:[`value`],message:r}])}function isCastableDay(e){let t=Ce.exec(e)?.[1];return!t||t.startsWith(`0000-`)?!1:isCalendarDay(t)}function resolveComparandType(e){return e.type===`formula`&&e.returnType===`date`?`date`:resolveEffectiveFilterType(e)}function applyCanonicalForm(e,t,n){e.operator=t,canonicalizeFilterValue(e,n),assertRelativeDateValue(e),assertAbsoluteDateValue(e,n)}function assertDynamicValueForAttribute(e,t){if(!isDynamicValue(e.value))return;let n=e.value;if(n.dynamic===`actor`&&t!==`user`){let e=`actor token (@me) is only valid on user attributes, not "${t}"`;throw new i(e,[{path:[`value`],message:e}])}if(n.dynamic===`date`&&t!==`date`){let e=`date token (@today/@now) is only valid on date attributes, not "${t}"`;throw new i(e,[{path:[`value`],message:e}])}}const A=b.map(e=>`"${e}"`).join(`, `);function operatorList(e){return e.length?e.join(`, `):`(not filterable)`}function qualifyWithSchema(e){if(O.has(e.type))return e.properties}function locationPartsHint(e){return e===`location`?` A location is filtered on one of its parts: set "property" to one of ${A} and use a text operator (e.g. contains).`:``}function dottedPathHint(e,t,n){let r=` Dotted paths are not supported — `;if(n.type===`location`)return`${r}set "attribute" to "${e}" and "property" to ${isLocationFilterProperty(t)?`"${t}"`:`one of ${A}`}.`;let i=qualifyWithSchema(n);if(i){let n=i.definitions.map(e=>`"${e.name}"`).join(`, `);return`${r}set "attribute" to "${e}" and "property" to ${i.definitions.some(e=>e.name===t)?`"${t}"`:`one of ${n}`} to filter on the edge property.`}let a=attributeFilterTarget(n).operators;return`${r}${a.length?`set "attribute" to "${e}" and use one of ${a.join(`, `)}`:`"${e}" is not filterable`}; the full-text "query" parameter matches tokens by relevance, not values.`}function collectQualifiedRuleIssues(e,t){try{return validateQualifiedRule({...e},t),[]}catch(e){if(!(e instanceof i))throw e;return e.errors.map(e=>({...e,path:[...e.path]}))}}function validateQualifiedRule(e,t){if(typeof e.attribute!=`string`){let e=`A filter rule needs an attribute: filters are one combinator and a flat list of rules`;throw new i(e,[{path:[`attribute`],message:e}])}let n=t.attributes.find(t=>t.name===e.attribute),r=n?[]:systemColumnFilterTarget(e.attribute)?.operators??[];if(!n&&r.length===0){let[n,...r]=e.attribute.split(`.`),a=r.length>0?t.attributes.find(e=>e.name===n):void 0,o=a?dottedPathHint(n??``,r[0]??``,a):e.attribute.includes(`.`)?` Dotted paths are not supported — filter on the attribute name alone with a structured operator (contains, any_of, …); the full-text "query" parameter matches tokens by relevance, not values.`:``,s=`Unknown attribute: ${e.attribute}${o}`;throw new i(s,[{path:[`attribute`],message:s}])}if(e.quantifier!==void 0&&!e.property){let e=`quantifier is only valid on qualified edge rules (set "property")`;throw new i(e,[{path:[`quantifier`],message:e}])}if(!n){if(e.property)throw new i(`Cannot qualify system attribute "${e.attribute}"`,[{path:[`property`],message:`"${e.attribute}" is a system column, not a reference`}]);let t=be[e.attribute]??`text`,n=resolveCanonicalOperator(e.operator,t);if(!r.includes(n)){let t=`Operator "${e.operator}" is not valid for system attribute "${e.attribute}". Valid operators: ${r.join(`, `)}.`;throw new i(t,[{path:[`operator`],message:t}])}applyCanonicalForm(e,n,t);return}if(!e.property){assertDynamicValueForAttribute(e,n.type);let t=attributeFilterTarget(n).operators,r=resolveCanonicalOperator(e.operator,n.type);if(!t.includes(r)){let r=`Operator "${e.operator}" is not valid for attribute "${n.name}". Valid operators: ${operatorList(t)}.${locationPartsHint(n.type)}`;throw new i(r,[{path:[`operator`],message:r}])}applyCanonicalForm(e,r,resolveComparandType(n));return}if(n.type===`location`){if(e.quantifier!==void 0){let e=`quantifier is not valid on a location part — a location is one value, not a set of edges`;throw new i(e,[{path:[`quantifier`],message:e}])}if(!isLocationFilterProperty(e.property)){let t=`Property "${e.property}" is not a part of location "${e.attribute}". Valid parts: ${A}.`;throw new i(t,[{path:[`property`],message:t}])}assertDynamicValueForAttribute(e,`text`);let{operators:t}=locationPartFilterTarget(n.name,e.property);applyCanonicalForm(e,assertPropertyOperator(e.operator,`text`,t),`text`);return}if(!O.has(n.type))throw new i(`Cannot qualify ${n.type} attribute "${e.attribute}"`,[{path:[`property`],message:`Attribute "${e.attribute}" is not a reference type`}]);let a=n.properties;if(!a)throw new i(`Attribute "${e.attribute}" has no qualifyWith schema`,[{path:[`property`],message:`"${e.attribute}" has no qualifyWith`}]);let o=a.definitions.find(t=>t.name===e.property);if(!o)throw new i(`Property "${e.property}" not defined on "${e.attribute}".qualifyWith()`,[{path:[`property`],message:`Unknown property: ${e.property}`}]);let{operators:s}=edgePropertyFilterTarget(n.name,o);applyCanonicalForm(e,assertPropertyOperator(e.operator,o.type,s),o.type)}const Te=c.array(c.string()).max(s.columnsPerTab),Ee=c.array(c.string().min(1)).max(s.columnsPerTab).refine(e=>new Set(e).size===e.length,{message:`Displayed attribute names must be unique`}),De=c.object({attribute:c.string().describe(`Attribute to sort by`),direction:c.enum([`asc`,`desc`]).describe(`asc or desc`)}).strict(),j=c.array(De).max(s.sortsPerTab),Oe=c.object({amount:c.number().describe(`Count`),unit:c.enum([`days`,`weeks`,`months`,`years`]).describe(`Unit`),direction:c.enum([`past`,`future`]).describe(`Past or future`)}).strict(),ke=c.object({value:c.number().nullable().describe(`Amount`),code:c.array(c.string()).optional().describe(`Currency codes`)}).strict(),Ae=c.object({phoneNumber:c.string().nullable().describe(`Number`),countryCode:c.string().optional().describe(`ISO country code`)}).strict(),je=c.discriminatedUnion(`dynamic`,[c.object({dynamic:c.literal(`actor`).describe(`Resolved at filter time`),ref:c.literal(`current`).describe(`The current actor`)}).strict(),c.object({dynamic:c.literal(`date`).describe(`Resolved at filter time`),anchor:c.enum([`today`,`now`]).describe(`Anchor`)}).strict()]),Me=c.object({month:c.number().describe(`1-12`),day:c.number().describe(`Day`)}).strict(),Ne=c.union([c.string(),c.number(),c.boolean(),c.array(c.string()),Oe,ke,Ae,Me,je,c.null()]),Pe=c.enum([`is`,`is_not`,`contains`,`not_contains`,`starts_with`,`ends_with`,`is_empty`,`is_not_empty`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`is_within`,`on_day_month`,`any_of`,`none_of`],{error:e=>{let t=e.input,n=typeof t==`string`?k[t]:void 0;return n?`Unknown filter operator "${t}" — use ${n}`:void 0}}),Fe=c.object({attribute:c.string().describe(`Attribute to filter on`),property:c.string().optional().describe(`Qualified edge property`),quantifier:c.enum([`any`,`none`]).optional().describe(`For a multi-value attribute`),operator:Pe.describe(`Comparison`),value:Ne.describe(`Comparison value, by attribute type`)}).strict(),Ie=c.array(Fe).max(s.filterRulesPerTab),M=c.object({combinator:c.enum([`and`,`or`]).describe(`Match every rule or any rule`),rules:Ie.describe(`The rules`)}).strict(),N=c.object({object:c.string().optional().describe(`Every record of this object`),relation:c.string().optional().describe(`Records linked through this relation`)}).strict().superRefine((e,t)=>{e.object===void 0&&e.relation===void 0&&t.addIssue({code:`custom`,message:`Collection source must define an object, a relation, or both`})}).transform(e=>e.relation===void 0?{object:e.object}:e.object===void 0?{relation:e.relation}:{object:e.object,relation:e.relation}),Le=c.object({source:N,filters:M.optional(),sorts:j.optional(),limit:c.number().int().nonnegative().optional()}).strict();var RecordQuery=class{constructor(e){this.state=e}with(e){return new this.constructor({...this.state,...e})}rule(e,t,n){return this.with({rules:[...this.state.rules,{attribute:e,operator:t,value:n}]})}eq(e,t){return this.rule(e,`is`,t)}neq(e,t){return this.rule(e,`is_not`,t)}gt(e,t){return this.rule(e,`greater_than`,t)}gte(e,t){return this.rule(e,`greater_or_equal`,t)}lt(e,t){return this.rule(e,`less_than`,t)}lte(e,t){return this.rule(e,`less_or_equal`,t)}contains(e,t){return this.rule(e,`contains`,t)}notContains(e,t){return this.rule(e,`not_contains`,t)}startsWith(e,t){return this.rule(e,`starts_with`,t)}endsWith(e,t){return this.rule(e,`ends_with`,t)}in(e,t){return this.rule(e,`any_of`,t)}notIn(e,t){return this.rule(e,`none_of`,t)}isEmpty(e){return this.rule(e,`is_empty`,null)}isNotEmpty(e){return this.rule(e,`is_not_empty`,null)}where(...e){return this.with({rules:[...this.state.rules,...e.map(e=>({...e}))]})}or(){return this.with({combinator:`or`})}orderBy(e,t=`asc`){return this.with({sorts:[...this.state.sorts,{attribute:e,direction:t}]})}limit(e){return this.with({limit:e})}offset(e){return this.with({offset:e})}search(e){return this.with({search:e})}related(e){return this.with({scope:{kind:`related`,relation:e}})}relatedFrom(e){return this.with({scope:{kind:`relatedFrom`,relation:e}})}toDefinition(){let{object:e,scope:t,rules:n,combinator:r,sorts:i,limit:a}=this.state;return{source:t?.kind===`related`?{relation:t.relation}:t?.kind===`relatedFrom`?{object:e,relation:t.relation}:{object:e},...n.length>0?{filters:{combinator:r,rules:n.map(e=>({...e}))}}:{},...i.length>0?{sorts:i.map(e=>({...e}))}:{},...a===void 0?{}:{limit:a}}}};function query(e){return new RecordQuery({object:typeof e==`string`?e:e.build().name,combinator:`and`,rules:[],sorts:[]})}const P=[`day`,`week`,`month`,`quarter`,`year`],F=`$query`,Re=`$record`;function createInput(e){return Object.freeze({...e,optional:()=>createInput({...e,isOptional:!0}),inSection:t=>createInput({...e,section:t}),showWhen:(t,n)=>createInput({...e,when:{key:t,...n}}),many:()=>createInput({...e,isMany:!0,schema:c.array(e.schema).min(1)})})}function objectNameOf(e){return e===void 0||typeof e==`string`?e:e.build().name}function scalar(e,t,n){return createInput({kind:e,of:objectNameOf(n),isOptional:!1,isMany:!1,schema:t})}function name(){return c.string().min(1)}const I={object:e=>scalar(`object`,name(),e),attribute:(e,t)=>createInput({kind:`attribute`,of:objectNameOf(e),options:t,isOptional:!1,isMany:!1,schema:name()}),query:e=>scalar(`query`,Le,e),record:e=>scalar(`record`,name(),e),agent:()=>scalar(`agent`,name()),routine:()=>scalar(`routine`,name()),view:()=>scalar(`view`,name()),url:()=>scalar(`url`,c.url().refine(e=>/^https?:\/\//.test(e),`Only http(s) links`)),emailCategory:()=>scalar(`emailCategory`,name()),enum:e=>createInput({kind:`enum`,isOptional:!1,isMany:!1,schema:c.enum(e)}),text:()=>scalar(`text`,name()),number:()=>scalar(`number`,c.number()),boolean:()=>scalar(`boolean`,c.boolean()),period:()=>scalar(`period`,c.enum(P))},L={size:{w:4,h:4},minWidth:3,height:`flexible`,minHeight:3,maxHeight:10},R=defineBlock({name:`artifact_preview`,label:`Preview`,icon:`eye`,family:`context`,contexts:[`record`],layout:{size:{w:6,h:8},minWidth:4,height:`flexible`,minHeight:4,maxHeight:20},inputs:{}}),z=[`number`,`currency`],B=[`status`,`select`,`user`,`relation`,`date`],V=[`bar`,`line`,`area`,`donut`,`funnel`,`treemap`,`calendar`];function measureIssue({measure:e,attribute:t}){return e===`count`?t===void 0?void 0:{input:`attribute`,message:`count measures records; it takes no attribute`}:t===void 0?{input:`attribute`,message:`${String(e)} needs a number or currency attribute`}:void 0}function requires(e,t,n){return e[t]!==void 0&&e[n]===void 0?{input:t,message:`${t} needs ${n}`}:void 0}function together(e,t,n){return requires(e,t,n)??requires(e,n,t)}function kindIssue(e){let{kind:t,by:n,byBucket:r,by2:i,measure:a}=e;if(i!==void 0&&i===n)return{input:`by2`,message:`by2 must differ from by`};if((t===`donut`||t===`funnel`)&&i!==void 0)return{input:`kind`,message:`a ${String(t)} splits one grouping (by), and no second`};if(t===`funnel`&&a!==`count`&&a!==`sum`)return{input:`kind`,message:`a funnel adds stages up: its measure is count or sum`};if(t===`area`&&i===void 0)return{input:`kind`,message:`an area stacks a second grouping (by2); one series is a line`};if(t===`treemap`&&(n===void 0||i!==void 0))return{input:`kind`,message:`a treemap needs one grouping (by), and no second`};if(t===`calendar`&&(r!==`day`||i!==void 0))return{input:`kind`,message:`a calendar needs a date grouping by day, and no second`}}function measuredInputs(){return{query:I.query(),measure:I.enum(e).inSection(`data`),attribute:I.attribute(F,{types:z}).optional().showWhen(`measure`,{not:[`count`]}),label:I.text().optional()}}function metricComparePeriod(e){if(e.period)return e.period;if(!e.trendBucket)return`month`;let t=P.indexOf(e.trendBucket);return P[Math.min(t+1,P.length-1)]??`month`}function comparedSpanIssue(e){let{trendBucket:t,compare:n}=e;if(n===void 0||typeof t!=`string`)return;let r=t;if(r===P.at(-1))return{input:`compare`,message:`compare needs a trendBucket finer than year`};let i=metricComparePeriod({trendBucket:r,period:e.period});return P.indexOf(i)>P.indexOf(r)?void 0:{input:`period`,message:`period must be wider than trendBucket (unset, it is one step above)`}}const H=defineBlock({name:`metric`,label:`Indicateur`,icon:`trending-up`,family:`data`,contexts:[`page`,`record`,`display`],layout:{size:{w:3,h:2},minWidth:3,height:`fit`,maxHeight:4,figure:!0},inputs:{...measuredInputs(),trend:I.attribute(F,{types:[`date`]}).optional().inSection(`display`),trendBucket:I.period().optional().showWhen(`trend`),compare:I.enum([`previous_period`]).optional(),period:I.period().optional().showWhen(`compare`),target:I.number().optional()},refine:e=>measureIssue(e)??together(e,`trend`,`trendBucket`)??requires(e,`period`,`compare`)??comparedSpanIssue(e)??(e.target!==void 0&&e.target<=0?{input:`target`,message:`target must be above zero`}:void 0)}),U=defineBlock({name:`chart`,label:`Graphique`,icon:`chart-bar`,family:`data`,contexts:[`page`,`record`,`display`],layout:{size:{w:4,h:6},minWidth:4,height:`flexible`,minHeight:4,maxHeight:12},inputs:{...measuredInputs(),kind:I.enum(V),by:I.attribute(F,{types:B}).optional(),byBucket:I.period().optional().inSection(`data`).showWhen(`by`),by2:I.attribute(F,{types:B}).optional().showWhen(`by`),by2Bucket:I.period().optional().inSection(`data`).showWhen(`by2`)},refine:e=>measureIssue(e)??requires(e,`byBucket`,`by`)??requires(e,`by2`,`by`)??requires(e,`by2Bucket`,`by2`)??kindIssue(e)}),W=defineBlock({name:`agenda`,label:`Agenda`,icon:`calendar`,family:`data`,contexts:[`page`,`record`,`display`],layout:L,inputs:{query:I.query(),attribute:I.attribute(F,{types:[`date`]}),next:I.number().optional(),yearly:I.boolean().optional(),label:I.text().optional()}}),G=defineBlock({name:`card`,label:`Fiche`,icon:`user-square`,family:`data`,contexts:[`page`,`record`,`display`],layout:{size:{w:4,h:4},minWidth:3,height:`fit`,maxHeight:10},inputs:{object:I.object().optional(),record:I.record().optional(),fields:I.attribute(Re).many().optional()},refine:(e,t)=>requires(e,`record`,`object`)??(t===`page`&&e.record===void 0?{input:`record`,message:`A card outside a record shows a chosen record: content.card(object).record(id)`}:void 0)}),K=defineBlock({name:`text_block`,label:`Texte`,icon:`type-text`,family:`layout`,contexts:[`page`,`record`,`display`],layout:{size:{w:12,h:2},minWidth:3,height:`fit`,maxHeight:16},inputs:{markdown:I.text()}}),q=defineBlock({name:`heading`,label:`Titre`,icon:`type-text`,family:`layout`,contexts:[`page`,`record`],layout:{size:{w:12,h:1},minWidth:6,height:`fit`,maxHeight:3},inputs:{title:I.text(),description:I.text().optional(),icon:I.text().optional()}}),ze=defineBlock({name:`inbox`,label:`Boîte de réception`,icon:`inbox`,family:`people`,contexts:[`page`],layout:L,inputs:{kinds:I.enum(t).inSection(`data`).many().optional(),limit:I.number().optional()}}),Be=defineBlock({name:`meetings_upcoming`,label:`Réunions à venir`,icon:`video`,family:`people`,contexts:[`page`],layout:L,inputs:{}}),Ve=defineBlock({name:`mailbox`,label:`E-mails`,icon:`envelope`,family:`people`,contexts:[`page`],layout:L,inputs:{category:I.emailCategory().optional(),important:I.boolean().optional().inSection(`data`),unread:I.boolean().optional().inSection(`data`),limit:I.number().optional(),label:I.text().optional()},refine:({limit:e})=>e===void 0||Number.isInteger(e)&&e>=1&&e<=50?void 0:{input:`limit`,message:`limit is a whole number from 1 to 50`}}),J=defineBlock({name:`record_links`,label:`Bubble`,icon:`share`,family:`context`,contexts:[`record`,`page`],layout:{size:{w:6,h:8},minWidth:6,height:`flexible`,minHeight:6,maxHeight:16},inputs:{center:I.enum([`record`,`me`]).optional().inSection(`data`),object:I.object().optional(),record:I.record().optional(),depth:I.enum([`1`,`2`]).optional()},refine:(e,t)=>requires(e,`record`,`object`)??(t===`page`&&e.center!==`me`&&e.record===void 0?{input:`record`,message:`Links outside a record centre on a chosen record or on the viewer: { object, record } or { center: "me" }`}:void 0)}),He={name:`bubble`,type:`custom`,extension:J.name,placement:`main`,label:J.label,icon:J.icon,parameters:{}},Ue=[R,H,U,W,G,K,q,ze,Be,Ve,J],We=new Set([`name`,`label`,`icon`,`family`,`contexts`,`inputs`,`parameters`,`layout`,`refine`]),Ge=Ue;var ContentExtensionRegistry=class{constructor(){this.extensions=new Map,this.seed()}register(e){let t=Array.isArray(e)?e:[e],r=new Set;t.forEach((e,t)=>{if(this.prepare(e,t),r.has(e.name))throw new n(`content extension`,e.name);r.add(e.name)});for(let e of t)this.extensions.set(e.name,e);return this}prepare(e,t){let r=[`extensions`,String(t)],reject=e=>{throw new i(e,[{path:r,message:e}])};if((typeof e!=`object`||!e||Array.isArray(e))&&reject(`Expected a content extension declaration`),Object.keys(e).some(e=>!We.has(e))&&reject(`Expected only ${[...We].join(`, `)}`),(typeof e.name!=`string`||e.name.trim().length===0)&&reject(`API name must not be empty`),(!Array.isArray(e.contexts)||e.contexts.length===0||e.contexts.some(e=>!S.includes(e)))&&reject(`contexts must be a non-empty list of ${S.join(`, `)}`),typeof e.parameters?.safeParse!=`function`&&reject(`parameters must be a Zod schema`),this.extensions.has(e.name))throw new n(`content extension`,e.name)}get(e){return this.extensions.get(e)}has(e){return this.extensions.has(e)}getAll(){return[...this.extensions.values()]}get size(){return this.extensions.size}clear(){this.extensions.clear(),this.seed()}seed(){for(let e of Ge)this.extensions.set(e.name,e)}};const Ke=new ContentExtensionRegistry,qe=12,Y=[3,4,6,8,9,12];function overlaps(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 findGridViolation(e,t={}){let n=Object.entries(e);for(let[e,{x:t,y:r,w:i,h:a}]of n){if(![t,r,i,a].every(Number.isInteger))return{path:[e],message:`Block "${e}" needs integer grid coordinates`};if(t<0||r<0||i<1||a<1)return{path:[e],message:`Block "${e}" needs x >= 0, y >= 0, w >= 1 and h >= 1`};if(t+i>12)return{path:[e],message:`Block "${e}" overflows the 12-column grid (x + w = ${t+i})`}}let r=n.filter(([e])=>t.exempt?.has(e)!==!0);for(let[e,[t,n]]of r.entries())for(let[i,a]of r.slice(e+1))if(overlaps(n,a))return{path:[i],message:`Blocks "${t}" and "${i}" overlap`}}function groupedMembers(e){let t=new Set(e.filter(e=>e.type!==`group`).map(e=>e.name)),n=new Set;for(let r of e)if(r.type===`group`)for(let e of r.members)t.has(e)&&n.add(e);return n}function memberlessGroups(e){let t=new Set(e.filter(e=>e.type!==`group`).map(e=>e.name));return new Set(e.flatMap(e=>e.type===`group`&&!e.members.some(e=>t.has(e))?[e.name]:[]))}function groupSizeMessage(e){return e>=2&&e<=s.membersPerGroup?void 0:`A group holds 2 to ${s.membersPerGroup} blocks, not ${e}`}function findGroupViolation(e){let t=new Map(e.map(e=>[e.name,e])),n=new Map;for(let r of e)if(r.type===`group`)for(let e of r.members){let i=t.get(e);if(i===void 0)return{path:[r.name],message:`Group "${r.name}" names "${e}", which is not a content of this page`};if(i.type===`group`)return{path:[r.name],message:`Group "${r.name}" cannot hold the group "${e}"`};let a=n.get(e);if(a!==void 0)return{path:[r.name],message:a===r.name?`Group "${r.name}" names "${e}" twice`:`"${e}" already belongs to the group "${a}"`};n.set(e,r.name)}}function boundsOf(e){let{minHeight:t,maxHeight:n}=e;return t!==void 0&&n!==void 0?`${t} to ${n} rows`:t===void 0?`at most ${String(n)} rows`:`at least ${t} rows`}function findRowLimitViolation(e){let t=Object.entries(e).find(([,e])=>e.y+e.h>s.pageRows);if(t===void 0)return;let[n,r]=t;return{path:[n],message:`Block "${n}" ends at row ${r.y+r.h}, past the page's ${s.pageRows} rows`}}function cellViolation(e,t,n){if(!Y.includes(t.w))return{path:[e],message:`Block "${e}" width ${t.w} is not one of ${Y.join(`, `)}`};if(t.w<n.minWidth)return{path:[e],message:`Block "${e}" width ${t.w} is below its minimum width ${n.minWidth}`};if(n.height===`flexible`&&(n.minHeight!==void 0&&t.h<n.minHeight||n.maxHeight!==void 0&&t.h>n.maxHeight))return{path:[e],message:`Block "${e}" height ${t.h} is outside its bounds (${boundsOf(n)})`}}function sharesRows(e,t){return e.y<t.y+t.h&&t.y<e.y+e.h}function findLayoutRuleViolation(e,t,n,r=new Set){let i=findRowLimitViolation(e);if(i!==void 0)return i;let a=groupedMembers(t),o=Object.entries(e).filter(([e])=>!a.has(e));for(let[e,t]of o){if(r.has(e))continue;let i=cellViolation(e,t,n(e));if(i!==void 0)return i}let[s,c]=o.filter(([e])=>!r.has(e)&&n(e).height===`fill`);if(s!==void 0&&c!==void 0)return{path:[c[0]],message:`Only one block may fill the page: "${s[0]}" and "${c[0]}" both do`};if(s===void 0)return;let[l,u]=s,d=o.find(([e,t])=>e!==l&&sharesRows(t,u));if(d!==void 0)return{path:[l],message:`Block "${l}" fills the page and must be alone in its rows; "${d[0]}" shares them`}}function findRelationAttribute(e,t){return e.attributes.find(e=>e.name===t&&e.type===`relation`)}function relationAcceptsObject(e,t){return e.targets.some(e=>e.object===t||e.object===`*`)}function singleRelationTarget(e){let[t,...n]=e.targets;return t&&n.length===0&&t.object!==`*`?t.object:void 0}function requireSingleRelationTarget(e,t=[e.name,`targets`]){let n=singleRelationTarget(e);if(n===void 0){let n=`Relation "${e.name}" requires one concrete collection target`;throw new i(n,[{path:t,message:n}])}return n}function collectionSourceAddress(e){return e.relation===void 0?{kind:`object`,object:e.object}:e.object===void 0?{kind:`related`,relation:e.relation}:{kind:`relatedFrom`,object:e.object,relation:e.relation}}function collectionSourceAddressOf(e){if(!e||typeof e!=`object`)return;let t=`object`in e?e.object:void 0,n=`relation`in e?e.relation:void 0;if(typeof t==`string`&&typeof n==`string`)return{kind:`relatedFrom`,object:t,relation:n};if(typeof t==`string`&&n===void 0)return{kind:`object`,object:t};if(typeof n==`string`&&t===void 0)return{kind:`related`,relation:n}}function sourcedAttributeOf(e,t){if(t.type===`richtext`)return typeof t.attribute==`string`&&e!==void 0?{object:e,attribute:t.attribute}:void 0;if(t.type!==`collection`)return;let n=collectionSourceAddressOf(t.source);if(n?.kind===`related`)return e===void 0?void 0:{object:e,attribute:n.relation};if(n?.kind===`relatedFrom`)return{object:n.object,attribute:n.relation}}function requireRecordContentContext(e,t,n){if(t!==`record`){let r=`Content "${e}" requires record context. In ${t===`page`?`a standalone page`:`a collection view`} only a collection that lists a whole object, or a custom content that does not require a record, is allowed.`;throw new i(r,[{path:n,message:r}])}}function resolveContentNavigation(e){let t=e.openMode??`page`;return{openMode:t,createMode:e.createMode??t}}function resolveCollectionActions(e,t){return[...new Set(t)].filter(t=>e.actions===void 0||e.actions.includes(t))}const Je={collection:[`page`,`record`,`display`],group:[`page`,`record`],form:[`record`],activity:[`record`],richtext:[`record`],documents:[`record`],forms:[`record`],emails:[`record`],meetings:[`record`]},X={collection:{size:{w:12,h:8},minWidth:6,height:`flexible`,minHeight:4,maxHeight:20},activity:{size:{w:12,h:8},minWidth:6,height:`flexible`},page:{size:{w:12,h:8},minWidth:6,height:`flexible`},group:{size:{w:6,h:4},minWidth:6,height:`flexible`}};function contentReadObjects(e,t,n){if(e.type!==`group`)return[...n(e)];let r=new Set;for(let i of e.members){let e=t.get(i);if(e!==void 0&&e.type!==`group`)for(let t of n(e))r.add(t)}return[...r]}function contentPlacementContexts(e,t){return e.type===`custom`?t?.contexts:e.type===`page`||e.type===`collection`&&collectionSourceAddress(e.source).kind!==`object`?[`record`]:Je[e.type]}function requireContentPlacement(e,t,n,r,i){let a=contentPlacementContexts(e,t);a&&!a.includes(hostPlacementContext(r))&&(requireRecordContentContext(n,r,i),reject(i,`Content "${n}" cannot be placed in a record view or a record page`))}function hostPlacementContext(e){return e===`record`?`record`:`page`}function contentContextOf(e){return e.context===`page`&&e.object!==void 0?`record`:e.context}function violationOf(e,t,n,a){if(!(e instanceof r))throw e;let o=e instanceof i?e.errors[0]:void 0;return{key:JSON.stringify([t,n,e.code,e.message]),contentName:n,path:o?.path??a,message:e.message,code:e.code,error:e}}const Ye=new Map(getSystemAttributeList().map(e=>[e.name,e]));function reject(e,t){throw new i(t,[{path:e,message:t}])}function requireName(e,t){e.trim().length===0&&reject(t,`API name must not be empty`)}function indexUnique(e,t,r){let i=new Map;return e.forEach((e,a)=>{if(requireName(e.name,[...r,String(a),`name`]),i.has(e.name))throw new n(t,e.name);i.set(e.name,e)}),i}const Xe=30;function capped(e,t){let n=e.slice(0,t).join(`, `);return e.length>t?`${n} … and ${e.length-t} more`:n}function attributeInventory(e,t){return t.length===0?`Object "${e}" has no attributes yet.`:`Attributes of "${e}": ${capped(t,30)}`}function requireAttribute(e,t,n,r,i){if(requireName(t,n),!e)return;let a=e.attributes?.get(t)??Ye.get(t);if(!a){if(!e.attributes)return;let r=attributeInventory(e.name,[...e.attributes.keys()]);reject(n,`Unknown attribute "${e.name}.${t}". ${r}${i?.()??``}`)}let o=r===void 0?[]:[r].flat();return o.length>0&&!o.includes(a.type)&&reject(n,`Attribute "${e.name}.${t}" must have type ${o.join(` or `)}`),a}function collectContentViewCatalogue(e,t=`authoring`){let r=e.mode??`published`,a=new Map;e.objects.forEach((e,t)=>{if(requireName(e.name,[`objects`,String(t),`name`]),a.has(e.name))throw new n(`object`,e.name);a.set(e.name,{name:e.name,attributes:indexUnique(e.attributes,`attribute`,[`objects`,String(t),`attributes`])})});let o=new Set;(e.reservedObjects??[]).forEach((e,t)=>{let n=[`reservedObjects`,String(t)];requireName(e,n),!a.has(e)&&(r!==`draft`&&reject(n,`Unresolved reserved object "${e}"`),o.add(e),a.set(e,{name:e}))});let s=indexUnique(e.extensions??[],`extension`,[`extensions`]);function resolveObject(e,t){requireName(e,t);let n=a.get(e);return n||reject(t,`Unknown object "${e}"`),n}function inverseAddresses(e){let t=[];for(let[n,r]of a)if(n!==e)for(let i of r.attributes?.values()??[])i.type===`relation`&&relationAcceptsObject(i,e)&&t.push(`relatedFrom("${n}", "${i.name}")`);return t.sort().slice(0,3)}let authoringSchemaWith=n=>r===`draft`?draftContentViewDefinitionSchemaFor():contentViewDefinitionSchemaFor({traits:t===`structural`?null:(e,t)=>layoutTraitsOf(e,s,t),viewerFiltered:e.viewerFiltered,...n===void 0?{}:{statics:n}}),c=authoringSchemaWith(),l=r===`draft`||t===`structural`?c:contentViewDefinitionSchemaFor({traits:null,viewerFiltered:e.viewerFiltered}),schemaFor=t=>{if(e.authoringViews!==void 0&&!e.authoringViews.has(t))return l;let n=e.staticsOf?.(t);return n===void 0||n.size===0?c:authoringSchemaWith(n)},u=new Map,d=new Map,f=[],p=[];function parseView(e,t,r){let a=schemaFor(r).safeParse(e);if(!a.success)throw new i(`Invalid content view`,a.error.issues.map(e=>({path:[...t,...e.path.map(String)],message:e.message,code:e.code})));let o=a.data;requireName(o.name,[...t,`name`]);let s=o.object??``,c=u.get(s)??new Set;if(c.has(o.name))throw new n(`view`,`${s}.${o.name}`);if(c.add(o.name),u.set(s,c),o.context!==`page`&&o.default){let e=d.get(o.object)??new Set;if(e.has(o.context))throw new n(`default view`,`${o.object}.${o.context}`);e.add(o.context),d.set(o.object,e)}return o}return e.views.forEach((e,t)=>{let n=[`views`,String(t)],r=e,i=`${String(r?.object??`?`)}.${String(r?.name??t)}`,a,o;try{a=parseView(e,n,t),o=a.object===void 0?void 0:resolveObject(a.object,[...n,`object`])}catch(e){f.push(violationOf(e,i,null,n));return}a.contents.forEach((e,t)=>{let r=[...n,`contents`,String(t)];try{requireName(e.name,[...r,`name`]),validateContent(e,r,o,contentContextOf(a),s,resolveObject,inverseAddresses)}catch(t){f.push(violationOf(t,i,e.name,r))}}),p.push(a)}),p.forEach((t,n)=>{t.contents.forEach((r,a)=>{if(r.type!==`page`)return;let o=[`views`,String(n),`contents`,String(a),`page`],s=p.find(e=>e.context===`page`&&e.object===r.page.object&&e.name===r.page.name),c=t.context===`page`?`Content "${r.name}" cannot reference a page from a page`:t.object===r.page.object?s||e.complete!==!0?void 0:`Unknown page "${r.page.object}.${r.page.name}"`:`Content "${r.name}" must reference a page of "${String(t.object)}", not of "${r.page.object}"`;c!==void 0&&f.push(violationOf(new i(c,[{path:o,message:c}]),`${String(t.object)}.${t.name}`,r.name,o))})}),{views:p,unresolvedObjects:[...o].sort(),violations:f}}function validateStoredViews(e){let t=collectContentViewCatalogue(e,`structural`).violations[0];if(t)throw t.error}function validateContentViewCatalogue(e){let{views:t,unresolvedObjects:n,violations:r}=collectContentViewCatalogue(e),i=r[0];if(i)throw i.error;return{views:t,unresolvedObjects:n}}function resolveStoredQuery(e,t,n,{owner:r,requireRecord:i,resolveObject:a,inverseAddresses:o}){let s=collectionSourceAddress(e.source),c,l;if(s.kind===`object`)c=a(s.object,[...t,`source`,`object`]);else if(s.kind===`related`){i();let e=[...t,`source`,`relation`],hint=()=>{if(!r)return``;let e=o(r.name);return e.length===0?``:`. Records pointing at "${r.name}" are addressed from the other side: ${e.join(`, `)}`},n=requireAttribute(r,s.relation,e,`relation`,hint);n?.type===`relation`&&(l=n,c=a(requireSingleRelationTarget(n,e),e))}else{i(),c=a(s.object,[...t,`source`,`object`]);let o=[...t,`source`,`relation`],l=requireAttribute(c,s.relation,o,`relation`);if(l?.type===`relation`&&r&&!relationAcceptsObject(l,r.name)){let e=l.targets.map(e=>`"${e.object}"`).join(`, `);reject(o,`Relation "${s.object}.${s.relation}" targets ${e}, not "${r.name}"`)}e.filters?.combinator===`or`&&reject([...t,`filters`,`combinator`],`${n} addresses "${s.object}" from the far side, so its filters must use the "and" combinator`)}return e.sorts?.forEach((e,n)=>requireAttribute(c,e.attribute,[...t,`sorts`,String(n),`attribute`])),e.filters?.rules.forEach((e,n)=>requireAttribute(c,e.attribute,[...t,`filters`,`rules`,String(n),`attribute`])),{target:c,relationAttribute:l}}function validateBlockReferences(e,t,n,r){let i=Object.entries(e.inputs),a;for(let[o,s]of i){let i=t[o];s.kind===`query`&&i!==void 0&&(a=resolveStoredQuery(i,[...n,o],`Block "${e.name}"`,r).target)}function attributeScope(o){if(o===void 0)return;if(o===`$query`)return a;if(o!==`$record`)return r.resolveObject(o,n);let s=i.find(([,e])=>e.kind===`object`)?.[0],c=s===void 0?void 0:t[s];return typeof c==`string`?r.resolveObject(c,[...n,s??`object`]):(r.owner||reject(n,`Block "${e.name}" names attributes, so it needs an object or a record host`),r.owner)}for(let[e,r]of i){let i=t[e];if(r.kind!==`attribute`||i===void 0)continue;let a=attributeScope(r.of);(Array.isArray(i)?i:[i]).forEach((t,o)=>{if(typeof t!=`string`)return;let s=Array.isArray(i)?[...n,e,String(o)]:[...n,e];requireAttribute(a,t,s,r.options?.types)})}for(let[r,a]of i){let i=a.when?.key,o=i===void 0?void 0:e.inputs[i],s=i===void 0?void 0:t[i];a.kind===`period`&&t[r]!==void 0&&o?.kind===`attribute`&&typeof s==`string`&&requireAttribute(attributeScope(o.of),s,[...n,i??r],[`date`])}}function validateContent(e,t,n,r,a,o,s){function requireRecord(){requireRecordContentContext(e.name,r,t)}let c={owner:n,requireRecord,resolveObject:o,inverseAddresses:s},l=hostPlacementContext(r);if(e.type===`custom`){let n=a.get(e.extension);n||reject([...t,`extension`],`Unknown extension "${e.extension}"`),contentPlacementContexts(e,n)?.includes(l)||reject([...t,`extension`],`${e.extension} cannot be placed here`);let r=n.parameters.safeParse(structuredClone(e.parameters??{}));if(!r.success)throw new i(`Invalid extension parameters`,r.error.issues.map(e=>({path:[...t,`parameters`,...e.path.map(String)],message:e.message,code:e.code})));let o=r.data,s=n.refine?.(o,l);s&&reject([...t,`parameters`,s.input],s.message),validateBlockReferences(n,o,[...t,`parameters`],c);return}if(requireContentPlacement(e,void 0,e.name,r,t),e.type!==`page`&&e.type!==`group`){if(e.type===`collection`){let{target:n,relationAttribute:r}=resolveStoredQuery(e,t,`Collection "${e.name}"`,c);e.columns?.forEach((e,i)=>{let a=[...t,`columns`,String(i)];if(typeof e==`string`){requireAttribute(n,e,a);return}let o=[...a,`relationProperty`];r||reject(o,`Relation property columns require a relation source`),r.properties?.definitions.some(t=>t.name===e.relationProperty)||reject(o,`Unknown relation property "${e.relationProperty}"`)}),e.displayAttributes?.forEach((e,r)=>requireAttribute(n,e,[...t,`displayAttributes`,String(r)])),e.descriptionAttribute!==void 0&&requireAttribute(n,e.descriptionAttribute,[...t,`descriptionAttribute`]),e.layout===`kanban`&&e.groupByAttribute!==void 0&&requireAttribute(n,e.groupByAttribute,[...t,`groupByAttribute`]);return}switch(e.type){case`form`:e.groups.forEach((e,r)=>{let i=[...t,`groups`,String(r)];requireName(e.name,[...i,`name`]),e.fields.forEach((e,t)=>requireAttribute(n,e.attribute,[...i,`fields`,String(t),`attribute`]))});break;case`richtext`:requireAttribute(n,e.attribute,[...t,`attribute`],`richtext`),e.titleAttribute!==void 0&&requireAttribute(n,e.titleAttribute,[...t,`titleAttribute`],`text`);break;case`emails`:case`meetings`:e.emailAttributes.forEach((e,r)=>requireAttribute(n,e,[...t,`emailAttributes`,String(r)],`text`));break;case`documents`:e.relations?.forEach((e,r)=>requireAttribute(n,e,[...t,`relations`,String(r)],`relation`));break;case`forms`:e.objectName!==void 0&&o(e.objectName,[...t,`objectName`]);break;case`activity`:break;default:reject(t,`Unknown content type: ${String(e)}`)}}}const Z=Object.freeze({size:Object.freeze({w:4,h:4}),minWidth:3,height:`flexible`,minHeight:2,figure:!1});function resolveLayout(e){return e===void 0?Z:{size:e.size??Z.size,minWidth:e.minWidth??Z.minWidth,height:e.height??Z.height,...e.minHeight===void 0?{}:{minHeight:e.minHeight},...e.maxHeight===void 0?{}:{maxHeight:e.maxHeight},figure:e.figure??!1}}function baseTraitsOf(e,t){return e.type===`custom`?resolveLayout(t.get(e.extension)?.layout):e.type in X?resolveLayout(X[e.type]):Z}function widthCovering(e){return Y.find(t=>t>=e)??12}function boundOf(e,t){let n=e.filter(e=>e!==void 0);return n.length===0?void 0:t(...n)}function groupTraitsOf(e){if(e.length===0)return resolveLayout(X.group);let sum=t=>e.reduce((e,n)=>e+t(n),0),t={w:widthCovering(sum(e=>e.size.w)),h:Math.max(...e.map(e=>e.size.h))},n=widthCovering(sum(e=>e.minWidth)),r=e.every(e=>e.figure);if(e.every(e=>e.height===`fit`)){let i=boundOf(e.map(e=>e.maxHeight),Math.max);return{size:t,minWidth:n,height:`fit`,...i===void 0?{}:{maxHeight:i},figure:r}}let i=e.filter(e=>e.height!==`fit`),a=boundOf(i.map(e=>e.minHeight),Math.max),o=boundOf(i.map(e=>e.maxHeight),Math.min),s=o===void 0?void 0:Math.max(o,a??o);return{size:t,minWidth:n,height:`flexible`,...a===void 0?{}:{minHeight:a},...s===void 0?{}:{maxHeight:s},figure:r}}function layoutTraitsOf(e,t,n){let r=e.type===`group`?groupTraitsOf(e.members.flatMap(e=>{let r=n?.get(e);return r===void 0||r.type===`group`?[]:[layoutTraitsOf(r,t)]})):baseTraitsOf(e,t);return e.height===void 0?r:{...r,height:e.height}}function pageTraitsOf(e,t){return n=>{let r=e.get(n);return r?layoutTraitsOf(r,t,e):Z}}const Ze=1e4;function isPlainJsonObject(e){let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype||Object.getPrototypeOf(t)===null&&t.constructor?.name===`Object`}function addJsonIssue(e,t,n=[]){e.addIssue({code:`custom`,message:t,path:n})}function pushJsonArrayChildren(e,t,n,r){for(let n of Reflect.ownKeys(e))if(n!==`length`){if(n===`__proto__`){addJsonIssue(r,`The __proto__ key is not allowed in custom props`,[...t.path,n]);continue}(typeof n==`symbol`||!/^(0|[1-9]\d*)$/.test(n))&&addJsonIssue(r,`Arrays cannot contain non-index JSON properties`,[...t.path,n])}for(let i=e.length-1;i>=0;i--){let a=Object.getOwnPropertyDescriptor(e,String(i)),o=[...t.path,i];if(!(a&&`value`in a)){addJsonIssue(r,`Sparse arrays are not valid JSON values`,o);continue}n.push({kind:`enter`,value:a.value,path:o,depth:t.depth+1})}}function pushJsonObjectChildren(e,t,n,r){let i=Reflect.ownKeys(e);for(let a=i.length-1;a>=0;a--){let o=i[a],s=[...t.path,o];if(o===`__proto__`){addJsonIssue(r,`The __proto__ key is not allowed in custom props`,s);continue}if(typeof o==`symbol`){addJsonIssue(r,`Symbol keys are not valid JSON keys`,s);continue}let c=Object.getOwnPropertyDescriptor(e,o);if(!(c?.enumerable&&`value`in c)){addJsonIssue(r,`Custom props must contain enumerable data properties only`,s);continue}n.push({kind:`enter`,value:c.value,path:s,depth:t.depth+1})}}function validateJsonProps(e,t){if(typeof e!=`object`||!e){addJsonIssue(t,`Expected a plain JSON object`);return}try{if(Array.isArray(e)||!isPlainJsonObject(e)){addJsonIssue(t,`Expected a plain JSON object`);return}}catch{addJsonIssue(t,`Custom props contain an object that cannot be safely inspected`);return}let n=new WeakSet,r=[{kind:`enter`,value:e,path:[],depth:0}],i=0;for(;r.length>0;){let e=r.pop();if(!e)break;if(e.kind===`exit`){n.delete(e.value);continue}if(i++,i>Ze){addJsonIssue(t,`Custom props cannot exceed ${Ze.toLocaleString(`en-US`)} total JSON nodes`,e.path);return}if(e.depth>64){addJsonIssue(t,`Custom props cannot exceed depth 64`,e.path);continue}let a=e.value;if(!(a===null||typeof a==`string`||typeof a==`boolean`||typeof a==`number`&&Number.isFinite(a))){if(typeof a!=`object`){addJsonIssue(t,`Expected a JSON value`,e.path);continue}if(n.has(a)){addJsonIssue(t,`Custom props cannot contain circular references`,e.path);continue}try{if(Array.isArray(a)){n.add(a),r.push({kind:`exit`,value:a}),pushJsonArrayChildren(a,e,r,t);continue}if(!isPlainJsonObject(a)){addJsonIssue(t,`Expected an array or plain JSON object`,e.path);continue}n.add(a),r.push({kind:`exit`,value:a}),pushJsonObjectChildren(a,e,r,t)}catch{addJsonIssue(t,`Custom props contain an object that cannot be safely inspected`,e.path)}}}}const Qe=c.unknown().superRefine(validateJsonProps).transform(e=>e),$e={span:c.union([c.literal(1),c.literal(2),c.literal(3),c.literal(4),c.literal(5),c.literal(6),c.literal(7),c.literal(8),c.literal(9),c.literal(10),c.literal(11),c.literal(12)]).optional().describe(`Columns of 12 this field occupies`),label:c.string().optional().describe(`Overrides the attribute's label`),readOnly:c.boolean().optional().describe(`Shows the value, not editable`)},et=c.object({attribute:c.string().describe(`Attribute API name shown by this field`),...$e}).strict(),tt=c.object({name:c.string().describe(`Group API name, unique in the form`),label:c.string().describe(`Label people see`),description:c.string().optional().describe(`Extra context under the label`),collapsible:c.boolean().optional().describe(`Whether the group can be collapsed`),collapsed:c.boolean().optional().describe(`Whether the group starts collapsed`),fields:c.array(et).max(s.fieldsPerGroup).describe(`Fields in this group, in order`)}).strict();function refineFormContent(e,t){e.groups.reduce((e,t)=>e+t.fields.length,0)>s.fieldsPerFormTab&&t.addIssue({code:`too_big`,origin:`array`,maximum:s.fieldsPerFormTab,inclusive:!0,message:`A form content can contain at most ${s.fieldsPerFormTab} fields`,path:[`groups`]});let n=new Set,r=new Set;e.groups.forEach((e,i)=>{n.has(e.name)&&t.addIssue({code:`custom`,message:`Duplicate group name "${e.name}"`,path:[`groups`,i,`name`]}),n.add(e.name),e.fields.forEach((e,n)=>{r.has(e.attribute)&&t.addIssue({code:`custom`,message:`Duplicate field attribute "${e.attribute}"`,path:[`groups`,i,`fields`,n,`attribute`]}),r.add(e.attribute)})})}const Q={name:c.string().describe(`Content API name, unique in the view`),label:c.string().optional().describe(`Label people see`),icon:a.optional().describe(`Icon name`),placement:c.enum([`main`,`aside`,`grid`]).describe(`main: the tab strip. aside: the side panel. grid: a page block`),height:c.enum([`fit`,`flexible`,`fill`]).optional().describe(`Page block height: fit (content), flexible (between bounds) or fill (whole page, one per page)`)},nt={...Q,type:c.literal(`collection`),source:N.describe(`object: every record; relation: records linked to this record; both: records of object whose relation points at this record`),visibility:c.enum(o).optional().describe(`all: no scope; workspace: every member; private: viewer's own; shared: private records other members shared with the viewer`),columns:c.array(c.union([c.string(),c.object({relationProperty:c.string().refine(e=>e.trim().length>0).describe(`Qualified edge property shown as a column`)}).strict()])).max(s.columnsPerTab).optional().describe(`Table columns, in order`),descriptionAttribute:c.string().optional().describe(`Secondary line under each row's title (list layout)`),displayAttributes:Ee.optional().describe(`Attributes shown on each card`),filters:M.optional().describe(`Restricts which records show`),sorts:j.optional().describe(`Sort order`),actions:c.enum([`create`,`update`,`delete`,`attach`,`detach`]).array().optional().describe(`Offered actions; absent = every action, [] = none`),openMode:c.enum([`page`,`peek`]).optional().describe(`page or peek (the record panel)`),createMode:c.enum([`page`,`peek`,`inline`]).optional().describe(`page, peek, or inline (creates without opening)`)},rt=c.object({...nt,layout:c.enum([`table`,`list`,`kanban`]).describe(`table columns, list cards, kanban board grouped by a select/status attribute`),columnSizing:c.record(c.string(),c.number()).optional().describe(`Column widths in pixels, by attribute name`),groupByAttribute:c.string().optional().describe(`Kanban only: the select or status attribute that names the columns`),kanbanColumnOrder:c.array(c.string()).optional().describe(`Kanban: column order by option value`),kanbanColumnVisibility:c.record(c.string(),c.boolean()).optional().describe(`Kanban: which columns are shown`),kanbanPinnedColumns:c.array(c.string()).optional().describe(`Kanban: columns pinned first`)}).strict().superRefine((e,t)=>{let n=[`groupByAttribute`,`kanbanColumnOrder`,`kanbanColumnVisibility`,`kanbanPinnedColumns`];if(e.layout===`kanban`){e.groupByAttribute===void 0&&t.addIssue({code:`custom`,path:[`groupByAttribute`],message:`A kanban layout requires groupByAttribute`});return}for(let r of n)e[r]!==void 0&&t.addIssue({code:`custom`,path:[r],message:`Only a kanban layout groups by an attribute`})}),$={...Q,type:c.literal(`form`),groups:c.array(tt).max(s.groupsPerFormTab).describe(`Field groups, in order`),formColumns:c.union([c.literal(1),c.literal(2),c.literal(3)]).optional().describe(`Grid columns, 1-3`),density:c.enum([`compact`,`comfortable`,`spacious`]).optional().describe(`Vertical spacing between fields`)},it=c.object($).strict().superRefine(refineFormContent),at=c.object({...$,groups:$.groups.min(1,`A published form content requires at least one group`)}).strict().superRefine(refineFormContent),ot=[rt,c.object({...Q,type:c.literal(`group`),placement:c.literal(`grid`).describe(`Always grid`),members:c.array(c.string()).min(1).max(s.membersPerGroup).describe(`Contents side by side`)}).strict(),c.object({...Q,type:c.literal(`custom`),extension:c.string().describe(`Name of a registered extension`),parameters:c.lazy(()=>Qe).optional().describe(`Extension parameters`)}).strict(),c.object({...Q,type:c.literal(`activity`)}).strict(),c.object({...Q,type:c.literal(`richtext`),attribute:c.string().describe(`Richtext attribute edited in place`),titleAttribute:c.string().optional().describe(`Text attribute shown as the title`)}).strict(),c.object({...Q,type:c.literal(`documents`),allowUpload:c.boolean().optional().describe(`Lets people add files here`),allowRemove:c.boolean().optional().describe(`Lets people remove files here`),hideAttachments:c.boolean().optional().describe(`Hides files attached elsewhere (e.g. emails)`),relations:c.array(c.string()).optional().describe(`Document relations shown; the record's own files if absent`)}).strict(),c.object({...Q,type:c.literal(`forms`),objectName:c.string().optional().describe(`Limits to this object's published forms`)}).strict(),c.object({...Q,type:c.literal(`emails`),emailAttributes:c.array(c.string()).max(s.emailAttributesPerTab).describe(`Addresses`)}).strict(),c.object({...Q,type:c.literal(`meetings`),emailAttributes:c.array(c.string()).max(s.emailAttributesPerTab).describe(`Addresses`)}).strict(),c.object({...Q,type:c.literal(`page`),page:c.object({object:c.string().describe(`Its object`),name:c.string().describe(`Its name`)}).strict().describe(`The record page this tab renders`)}).strict()],st=c.discriminatedUnion(`type`,[it,...ot]),ct=c.discriminatedUnion(`type`,[at,...ot]),lt={name:c.string(),label:c.string(),description:c.string().optional(),icon:a.optional()},ut=c.object({x:c.number().describe(`Column`),y:c.number().describe(`Row`),w:c.number().describe(`Width: 3, 4, 6, 8, 9 or 12; x + w ≤ 12`),h:c.number().describe(`Height`)}).strict();function contentViewBaseSchemaFor(e){let t=c.array(e).max(s.tabsPerView);return c.discriminatedUnion(`context`,[c.object({...lt,object:c.string(),context:c.enum([`collection`,`record`]),default:c.boolean().optional(),contents:t}).strict(),c.object({...lt,object:c.string().optional(),context:c.literal(`page`),home:c.boolean().optional(),grid:c.record(c.string(),ut).refine(e=>Object.keys(e).length<=s.tabsPerView,{message:`A page holds at most ${s.tabsPerView} blocks`}),contents:t}).strict()])}const dt=contentViewBaseSchemaFor(st),ft=contentViewBaseSchemaFor(ct);function registryTraits(e,t){return layoutTraitsOf(e,Ke,t)}function addGroupSizeIssues(e,t){for(let n of e.contents){let e=n.type===`group`?groupSizeMessage(n.members.length):void 0;e&&t.addIssue({code:`custom`,message:e,path:[`contents`]})}}function addDuplicateContentNameIssues(e,t){let n=new Set;e.contents.forEach((e,r)=>{n.has(e.name)&&t.addIssue({code:`custom`,message:`Duplicate content name "${e.name}"`,path:[`contents`,r,`name`]}),n.add(e.name)})}function addPlacementIssues(e,t){e.contents.forEach((n,r)=>{let i=n.placement===`grid`;e.context===`page`&&!i&&t.addIssue({code:`custom`,message:`Content "${n.name}" of a page must be placed on the grid`,path:[`contents`,r,`placement`]}),e.context!==`page`&&i&&t.addIssue({code:`custom`,message:`Content "${n.name}" cannot be placed on a grid outside a page`,path:[`contents`,r,`placement`]})})}function addIssue(e,t){e.addIssue({code:`custom`,message:t.message,path:[`grid`,...t.path]})}function addGridIssues(e,t,n,r){if(e.context!==`page`||!e.grid)return;let i=new Set(e.contents.map(e=>e.name)),a=groupedMembers(e.contents);for(let n of i)a.has(n)||Object.hasOwn(e.grid,n)||t.addIssue({code:`custom`,message:`Content "${n}" has no grid position`,path:[`grid`]});let o=Object.keys(e.grid).filter(e=>!i.has(e));for(let e of o)t.addIssue({code:`custom`,message:`Grid position "${e}" matches no content`,path:[`grid`,e]});if(e.home&&e.object!==void 0&&t.addIssue({code:`custom`,message:`Only a standalone page can be the home`,path:[`home`]}),o.length>0)return;let s=findGridViolation(e.grid,{exempt:a});if(s){addIssue(t,s);return}if(n===null)return;let c=findGroupViolation(e.contents);if(c){t.addIssue({code:`custom`,message:c.message,path:[`contents`]});return}let l=new Map(e.contents.map(e=>[e.name,e])),u=findLayoutRuleViolation(e.grid,e.contents,e=>n(l.get(e),l),r);u&&addIssue(t,u)}function draftContentViewDefinitionSchemaFor(){return dt.superRefine((e,t)=>{let n=e;addDuplicateContentNameIssues(n,t),addPlacementIssues(n,t),addGridIssues(n,t,null)})}function contentViewDefinitionSchemaFor(e={}){let t=e.traits===void 0?registryTraits:e.traits;return ft.superRefine((n,r)=>{let i=n;addDuplicateContentNameIssues(i,r),addPlacementIssues(i,r),addGridIssues(i,r,t,e.statics),e.viewerFiltered||addGroupSizeIssues(i,r),n.context!==`page`&&!n.contents.some(e=>e.placement===`main`)&&r.addIssue({code:`custom`,message:`A published view requires at least one main content`,path:[`contents`]})})}const pt=draftContentViewDefinitionSchemaFor(),mt=contentViewDefinitionSchemaFor();export{J as $,ce as $t,findLayoutRuleViolation as A,isLocationPartOperator as At,W as B,currentActor as Bt,collectionSourceAddressOf as C,isManagedSystemAttribute as Cn,_e as Ct,requireSingleRelationTarget as D,edgePropertyFilterTarget as Dt,relationAcceptsObject as E,attributeFilterTarget as Et,Y as F,isSetMembershipOperator as Ft,B as G,S as Gt,G as H,now as Ht,qe as I,normalizeForEdgeRpc as It,Ve as J,parseBlockParameters as Jt,q as K,blockObjectInputs as Kt,findGridViolation as L,toMultiValueOperator as Lt,groupSizeMessage as M,systemColumnFilterTarget as Mt,groupedMembers as N,canonicalizeFilterValue as Nt,singleRelationTarget as O,filterOperatorsOfType as Ot,memberlessGroups as P,getOperatorPolarity as Pt,Ue as Q,le as Qt,overlaps as R,extractCurrencyFilterValue as Rt,collectionSourceAddress as S,getSystemAttributeList as Sn,toUtcDayString as St,findRelationAttribute as T,normalizeOperator as Tt,U,today as Ut,R as V,isDynamicValue as Vt,V as W,isCalendarDay as Wt,Be as X,buildQualifiedAttribute as Xt,z as Y,ue as Yt,H as Z,parseQualifiedAttribute as Zt,validateContentViewCatalogue as _,isLocationFilterProperty as _n,collectQualifiedRuleIssues as _t,ut as a,isAttributeSortable as an,Re as at,resolveCollectionActions as b,l as bn,resolveIsWithinBounds as bt,layoutTraitsOf as c,relationTargetsOf as cn,query as ct,Xe as d,getAttributeCapabilities as dn,Te as dt,getRollupFilterOperators as en,He as et,attributeInventory as f,getAttributeFilterOperators as fn,Ee as ft,requireContentPlacement as g,isAttributeSearchable as gn,be as gt,contentReadObjects as h,isAttributeKanbanGroupable as hn,k as ht,draftContentViewDefinitionSchemaFor as i,inferInverseCardinality as in,F as it,findRowLimitViolation as j,locationPartFilterTarget as jt,findGroupViolation as k,filterTargetsOf as kt,pageTraitsOf as l,x as ln,Le as lt,collectContentViewCatalogue as m,isAttributeGroupable as mn,j as mt,contentViewDefinitionSchemaFor as n,oe as nn,metricComparePeriod as nt,ct as o,isBilateralRelation as on,I as ot,capped as p,isAttributeFilterable as pn,M as pt,ze as q,defineBlock as qt,pt as r,se as rn,P as rt,Z as s,isUniversalRelation as sn,RecordQuery as st,mt as t,isNoValueOperator as tn,K as tt,Je as u,b as un,N as ut,validateStoredViews as v,resolveEffectiveFilterType as vn,validateQualifiedRule as vt,sourcedAttributeOf as w,normalizeFilterRule as wt,resolveContentNavigation as x,getSystemAttributeI18nKey as xn,resolveUtcDayBounds as xt,requireRecordContentContext as y,u as yn,isRelativeDateValue as yt,Ke as z,extractFilterValue as zt};
|