@svgrid/enterprise 3.1.61 → 3.1.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/SvGridBoard.svelte +4 -4
  2. package/dist/cdn/svgrid-enterprise.svelte-external.js +40 -40
  3. package/dist/designer/assets/{index-BpMDBdMi.js → index-BxlgvZk3.js} +1 -1
  4. package/dist/designer/index.html +1 -1
  5. package/dist/fields/AutomationAction.svelte +2 -0
  6. package/dist/fields/AutomationTrigger.svelte +11 -1
  7. package/dist/fields/BaseImport.svelte +22 -3
  8. package/dist/fields/SvBase.svelte +1 -1
  9. package/dist/fields/SvBaseAutomations.svelte +2 -1
  10. package/dist/fields/airtable.js +1 -1
  11. package/dist/fields/automation-edit.js +2 -2
  12. package/dist/fields/automation-server.js +1 -1
  13. package/dist/fields/automations.svelte.d.ts +17 -0
  14. package/dist/fields/automations.svelte.js +1 -1
  15. package/dist/fields/base-import.d.ts +16 -0
  16. package/dist/fields/base-import.js +2 -2
  17. package/dist/fields/formula-docs.js +1 -1
  18. package/dist/fields/formula.js +1 -1
  19. package/dist/fields/index.d.ts +1 -1
  20. package/dist/fields/index.js +1 -1
  21. package/dist/fields/messages/extras.d.ts +18 -0
  22. package/dist/fields/messages/extras.js +1 -1
  23. package/dist/fields/messages/shell.d.ts +8 -0
  24. package/dist/fields/messages/shell.js +1 -1
  25. package/dist/fields/messages/viewbar.d.ts +6 -0
  26. package/dist/fields/messages/viewbar.js +1 -1
  27. package/dist/fields/messages.svelte.d.ts +32 -0
  28. package/dist/fields/view-model.d.ts +2 -0
  29. package/dist/fields/view-model.js +1 -1
  30. package/dist/fields/viewbar/GanttPanel.svelte +7 -1
  31. package/dist/fields/viewbar/GanttPanel.svelte.d.ts +1 -1
  32. package/dist/node/studio.js +1 -1
  33. package/dist/version.d.ts +1 -1
  34. package/dist/version.js +1 -1
  35. package/dist/wc/board-Cha_fBZ4.js +28 -0
  36. package/dist/wc/sv-base-element.js +96 -96
  37. package/package.json +1 -1
  38. package/dist/wc/board-DZwH78Ub.js +0 -28
@@ -1 +1 @@
1
- export const FORMULA_DOCS={IF:{syntax:"IF(condition, value if true, [value if false])",summary:"One value when the condition is true, another when it is not (empty if left out).",example:'IF({Qty} > 10, "Bulk", "Small")',group:"logic"},AND:{syntax:"AND(condition1, [condition2, ...])",summary:"True when every condition is true.",example:'AND({Paid}, {Status} = "Shipped")',group:"logic"},OR:{syntax:"OR(condition1, [condition2, ...])",summary:"True when at least one condition is true.",example:'OR({Status} = "Late", {Status} = "Lost")',group:"logic"},NOT:{syntax:"NOT(condition)",summary:"True when the condition is false or empty, false when it is true.",example:"NOT({Paid})",group:"logic"},XOR:{syntax:"XOR(condition1, [condition2, ...])",summary:"True when an odd number of the conditions are true.",example:"XOR({Paid}, {Refunded})",group:"logic"},TRUE:{syntax:"TRUE()",summary:"The value true. You can also write TRUE without the brackets.",example:"IF({Qty} > 0, TRUE(), FALSE())",group:"logic"},FALSE:{syntax:"FALSE()",summary:"The value false. You can also write FALSE without the brackets.",example:'IF({Status} = "Cancelled", FALSE(), TRUE())',group:"logic"},BLANK:{syntax:"BLANK()",summary:"An empty value, for leaving the cell empty.",example:"IF({Qty} = 0, BLANK(), {Qty} * {Unit price})",group:"logic"},ERROR:{syntax:"ERROR()",summary:"Makes the cell show #ERROR, to flag a record that needs a look.",example:"IF({Qty} < 0, ERROR(), {Qty})",group:"logic"},ISERROR:{syntax:"ISERROR(value)",summary:"True when the value is an error, such as ERROR() or a number that cannot be worked out.",example:"IF(ISERROR({Discount}), 0, {Discount})",group:"logic"},SWITCH:{syntax:"SWITCH(value, match1, result1, [match2, result2, ...], [default])",summary:"The result next to the first match for the value, or the default when none match.",example:'SWITCH({Status}, "New", 1, "Paid", 2, "Shipped", 3, 0)',group:"logic"},RECORD_ID:{syntax:"RECORD_ID()",summary:"The id of this record, as text.",example:'"https://example.com/orders/" & RECORD_ID()',group:"records"},CONCATENATE:{syntax:"CONCATENATE(text1, [text2, ...])",summary:"All the values joined into one text, in order. The & sign does the same.",example:'CONCATENATE({First name}, " ", {Last name})',group:"text"},LEN:{syntax:"LEN(text)",summary:"The number of characters in the text.",example:"LEN({Phone})",group:"text"},UPPER:{syntax:"UPPER(text)",summary:"The text in capital letters.",example:"UPPER({Country code})",group:"text"},LOWER:{syntax:"LOWER(text)",summary:"The text in small letters.",example:"LOWER({Email})",group:"text"},TRIM:{syntax:"TRIM(text)",summary:"The text without spaces at the start and the end.",example:"TRIM({Client})",group:"text"},LEFT:{syntax:"LEFT(text, [count])",summary:"The first characters of the text; one character if no count is given.",example:"LEFT({Postcode}, 2)",group:"text"},RIGHT:{syntax:"RIGHT(text, [count])",summary:"The last characters of the text; one character if no count is given.",example:"RIGHT({Phone}, 4)",group:"text"},MID:{syntax:"MID(text, start, [count])",summary:"Characters from a position (1 is the first); the rest of the text if no count.",example:"MID({Invoice no}, 5, 3)",group:"text"},FIND:{syntax:"FIND(text to find, text, [start])",summary:"Where the text is found (1 is the first character), or 0 if not. Case matters.",example:'FIND("@", {Email})',group:"text"},SEARCH:{syntax:"SEARCH(text to find, text, [start])",summary:"Where the text is found (1 is the first character), or empty if not. Case matters.",example:'SEARCH("urgent", {Notes})',group:"text"},SUBSTITUTE:{syntax:"SUBSTITUTE(text, old text, new text, [which one])",summary:"The text with the old text swapped for the new; only the nth one if you give n.",example:'SUBSTITUTE({Phone}, " ", "")',group:"text"},REPLACE:{syntax:"REPLACE(text, start, count, new text)",summary:"The text with count characters from the start position swapped for the new text.",example:'REPLACE({Card number}, 1, 12, "************")',group:"text"},ENCODE_URL_COMPONENT:{syntax:"ENCODE_URL_COMPONENT(text)",summary:"The text made safe to put in a web address.",example:'"https://maps.google.com/?q=" & ENCODE_URL_COMPONENT({Address})',group:"text"},REGEX_MATCH:{syntax:"REGEX_MATCH(text, pattern)",summary:"True when the text fits the pattern (a regular expression).",example:'REGEX_MATCH({Email}, "^[^@ ]+@[^@ ]+[.][a-z]+$")',group:"text"},REGEX_EXTRACT:{syntax:"REGEX_EXTRACT(text, pattern)",summary:"The first part of the text that fits the pattern, or empty if none does.",example:'REGEX_EXTRACT({Notes}, "[0-9]+")',group:"text"},REGEX_REPLACE:{syntax:"REGEX_REPLACE(text, pattern, new text)",summary:"The text with every part that fits the pattern swapped for the new text.",example:'REGEX_REPLACE({Phone}, "[^0-9]", "")',group:"text"},REPT:{syntax:"REPT(text, times)",summary:"The text repeated a number of times (at most 1,000).",example:'REPT("*", {Rating})',group:"text"},T:{syntax:"T(value)",summary:"The value if it is text, otherwise empty text.",example:"T({Notes})",group:"text"},VALUE:{syntax:"VALUE(text)",summary:"The number in the text, ignoring signs like $ and spaces; empty if there is none.",example:"VALUE({Price text}) * {Qty}",group:"text"},ARRAYJOIN:{syntax:"ARRAYJOIN(list, [separator])",summary:'The items of a list joined into one text, with ", " between them unless you say.',example:'ARRAYJOIN({Tags}, " / ")',group:"text"},ARRAYCOMPACT:{syntax:"ARRAYCOMPACT(list)",summary:"The list without its empty items.",example:"ARRAYCOMPACT({Phone numbers})",group:"lists"},ARRAYFLATTEN:{syntax:"ARRAYFLATTEN(list1, [list2, ...])",summary:"One flat list of all the items, with lists inside lists opened up.",example:"ARRAYFLATTEN({Tags}, {Categories})",group:"lists"},ARRAYUNIQUE:{syntax:"ARRAYUNIQUE(list)",summary:"The list with each item only once.",example:"ARRAYUNIQUE({Order cities})",group:"lists"},ARRAYSLICE:{syntax:"ARRAYSLICE(list, start, [end])",summary:"The items from start to end (1 is the first; a negative number counts from the end).",example:"ARRAYSLICE({Tags}, 1, 3)",group:"lists"},SUM:{syntax:"SUM(number1, [number2, ...])",summary:"All the numbers added up.",example:"SUM({Subtotal}, {Shipping}, {Tax})",group:"numbers"},AVERAGE:{syntax:"AVERAGE(number1, [number2, ...])",summary:"The average of the numbers, leaving out empty ones.",example:"AVERAGE({Q1 sales}, {Q2 sales}, {Q3 sales})",group:"numbers"},MAX:{syntax:"MAX(number1, [number2, ...])",summary:"The largest of the numbers.",example:"MAX({Quote A}, {Quote B})",group:"numbers"},MIN:{syntax:"MIN(number1, [number2, ...])",summary:"The smallest of the numbers.",example:"MIN({Stock}, {Qty})",group:"numbers"},COUNT:{syntax:"COUNT(value1, [value2, ...])",summary:"How many of the values are numbers.",example:"COUNT({Mon hours}, {Tue hours}, {Wed hours})",group:"numbers"},COUNTA:{syntax:"COUNTA(value1, [value2, ...])",summary:"How many of the values are not empty.",example:"COUNTA({Phone}, {Email}, {Address})",group:"numbers"},COUNTALL:{syntax:"COUNTALL(value1, [value2, ...])",summary:"How many values there are, empty ones included.",example:"COUNTALL({Attendees})",group:"numbers"},ROUND:{syntax:"ROUND(number, [decimals])",summary:"The number rounded to that many decimal places (none if left out).",example:"ROUND({Qty} * {Unit price}, 2)",group:"numbers"},ROUNDUP:{syntax:"ROUNDUP(number, [decimals])",summary:"The number rounded away from zero to that many decimal places.",example:"ROUNDUP({Hours worked}, 0)",group:"numbers"},ROUNDDOWN:{syntax:"ROUNDDOWN(number, [decimals])",summary:"The number rounded toward zero to that many decimal places.",example:"ROUNDDOWN({Total} * 0.1, 2)",group:"numbers"},INT:{syntax:"INT(number)",summary:"The number rounded down to a whole number.",example:"INT({Hours worked})",group:"numbers"},ABS:{syntax:"ABS(number)",summary:"The number without its minus sign.",example:"ABS({Balance})",group:"numbers"},MOD:{syntax:"MOD(number, divisor)",summary:"What is left after dividing; it takes the sign of the first number.",example:"MOD({Qty}, 12)",group:"numbers"},POWER:{syntax:"POWER(number, power)",summary:"The number raised to the power.",example:"{Deposit} * POWER(1 + {Rate}, {Years})",group:"numbers"},SQRT:{syntax:"SQRT(number)",summary:"The square root of the number.",example:"SQRT({Floor area})",group:"numbers"},EXP:{syntax:"EXP(number)",summary:"The number e (about 2.718) raised to the power you give.",example:"{Deposit} * EXP({Rate} * {Years})",group:"numbers"},LOG:{syntax:"LOG(number, [base])",summary:"The logarithm of the number, in base 10 unless you give another base.",example:"LOG({Visitors}, 10)",group:"numbers"},EVEN:{syntax:"EVEN(number)",summary:"The number rounded away from zero to the next even whole number.",example:"EVEN({Guests})",group:"numbers"},ODD:{syntax:"ODD(number)",summary:"The number rounded away from zero to the next odd whole number.",example:"ODD({Team size})",group:"numbers"},CEILING:{syntax:"CEILING(number, [multiple])",summary:"The number rounded up to a multiple (1 if left out): CEILING(7, 5) is 10.",example:"CEILING({Qty}, 6)",group:"numbers"},FLOOR:{syntax:"FLOOR(number, [multiple])",summary:"The number rounded down to a multiple (1 if left out): FLOOR(7, 5) is 5.",example:"FLOOR({Price}, 0.5)",group:"numbers"},DISTANCE:{syntax:"DISTANCE(place, place)",summary:'Metres between two places given as coordinates ("42.6977, 23.3219"), as a phone saves them.',example:"DISTANCE({Where the phone was}, '42.6977, 23.3219')",group:"numbers"},TODAY:{syntax:"TODAY()",summary:"Today's date, at midnight.",example:'DATETIME_DIFF({Due date}, TODAY(), "days")',group:"dates"},NOW:{syntax:"NOW()",summary:"The date and time right now.",example:'DATETIME_DIFF(NOW(), {Created}, "hours")',group:"dates"},YEAR:{syntax:"YEAR(date)",summary:"The year of a date, such as 2026.",example:"YEAR({Invoice date})",group:"dates"},MONTH:{syntax:"MONTH(date)",summary:"The month of a date, from 1 (January) to 12 (December).",example:"MONTH({Invoice date})",group:"dates"},DAY:{syntax:"DAY(date)",summary:"The day of the month of a date, from 1 to 31.",example:"DAY({Due date})",group:"dates"},HOUR:{syntax:"HOUR(date)",summary:"The hour of a date and time, from 0 to 23.",example:"HOUR({Appointment})",group:"dates"},MINUTE:{syntax:"MINUTE(date)",summary:"The minute of a date and time, from 0 to 59.",example:"MINUTE({Appointment})",group:"dates"},SECOND:{syntax:"SECOND(date)",summary:"The second of a date and time, from 0 to 59.",example:"SECOND({Logged at})",group:"dates"},WEEKDAY:{syntax:"WEEKDAY(date, [first day])",summary:'The day of the week, 0 for Sunday to 6; with "Monday" as first day, 0 is Monday.',example:'WEEKDAY({Delivery date}, "Monday")',group:"dates"},WEEKNUM:{syntax:"WEEKNUM(date, [first day])",summary:'The week of the year (week 1 holds January 1); weeks start Sunday, or "Monday".',example:'WEEKNUM({Order date}, "Monday")',group:"dates"},DATEADD:{syntax:"DATEADD(date, count, [unit])",summary:"The date moved on by a number of days, weeks, months, years... (days if no unit).",example:'DATEADD({Invoice date}, 30, "days")',group:"dates"},DATETIME_DIFF:{syntax:"DATETIME_DIFF(date1, date2, [unit])",summary:"The time between two dates: the first minus the second, in days or another unit.",example:'DATETIME_DIFF({Due date}, TODAY(), "days")',group:"dates"},IS_BEFORE:{syntax:"IS_BEFORE(date1, date2)",summary:"True when the first date is before the second.",example:"IS_BEFORE({Due date}, TODAY())",group:"dates"},IS_AFTER:{syntax:"IS_AFTER(date1, date2)",summary:"True when the first date is after the second.",example:"IS_AFTER({Delivered on}, {Due date})",group:"dates"},IS_SAME:{syntax:"IS_SAME(date1, date2, [unit])",summary:"True when two dates are the same moment, or the same day, month, year... by unit.",example:'IS_SAME({Order date}, TODAY(), "month")',group:"dates"},DATESTR:{syntax:"DATESTR(date)",summary:"The date as text, year first: 2026-12-04.",example:"DATESTR({Due date})",group:"dates"},TIMESTR:{syntax:"TIMESTR(date)",summary:"The time of a date as text, in 24 hours: 14:30:00.",example:"TIMESTR({Appointment})",group:"dates"},DATETIME_FORMAT:{syntax:"DATETIME_FORMAT(date, [format])",summary:'The date as text in the format you write, such as "DD/MM/YYYY" or "MMMM D".',example:'DATETIME_FORMAT({Due date}, "DD/MM/YYYY")',group:"dates"},DATETIME_PARSE:{syntax:"DATETIME_PARSE(text, [format])",summary:"The date written in the text, read with the format if you give one.",example:'DATETIME_PARSE({Date text}, "DD.MM.YYYY")',group:"dates"},SET_LOCALE:{syntax:"SET_LOCALE(date, locale)",summary:'The date, set to show month and day names in a language, such as "fr" or "de".',example:'DATETIME_FORMAT(SET_LOCALE({Due date}, "fr"), "D MMMM YYYY")',group:"dates"},SET_TIMEZONE:{syntax:"SET_TIMEZONE(date, time zone)",summary:'The date, set to show the clock of a time zone, such as "Europe/London".',example:'DATETIME_FORMAT(SET_TIMEZONE({Appointment}, "Europe/London"), "HH:mm")',group:"dates"},TONOW:{syntax:"TONOW(date)",summary:"The number of days from the date to today.",example:"TONOW({Last contacted})",group:"dates"},FROMNOW:{syntax:"FROMNOW(date)",summary:"The number of days from today to the date.",example:"FROMNOW({Due date})",group:"dates"},WORKDAY:{syntax:"WORKDAY(start date, days, [holidays])",summary:"The date that many working days on, skipping weekends and the holidays.",example:'WORKDAY({Order date}, 5, "2026-12-25, 2026-12-26")',group:"dates"},WORKDAY_DIFF:{syntax:"WORKDAY_DIFF(start date, end date, [holidays])",summary:"The working days from start to end, both days counted, skipping the holidays.",example:'WORKDAY_DIFF({Start date}, {End date}, "2026-12-25")',group:"dates"}};export function syntaxArgs(e){const t=e.indexOf("("),a=e.lastIndexOf(")");return t<0||a<=t?[]:e.slice(t+1,a).replace(/[[\]]/g,"").split(",").map(s=>s.replace(/\.{3}|…/g,"").trim()).filter(Boolean)}
1
+ export const FORMULA_DOCS={IF:{syntax:"IF(condition, value if true, [value if false])",summary:"One value when the condition is true, another when it is not (empty if left out).",example:'IF({Qty} > 10, "Bulk", "Small")',group:"logic"},AND:{syntax:"AND(condition1, [condition2, ...])",summary:"True when every condition is true.",example:'AND({Paid}, {Status} = "Shipped")',group:"logic"},OR:{syntax:"OR(condition1, [condition2, ...])",summary:"True when at least one condition is true.",example:'OR({Status} = "Late", {Status} = "Lost")',group:"logic"},NOT:{syntax:"NOT(condition)",summary:"True when the condition is false or empty, false when it is true.",example:"NOT({Paid})",group:"logic"},XOR:{syntax:"XOR(condition1, [condition2, ...])",summary:"True when an odd number of the conditions are true.",example:"XOR({Paid}, {Refunded})",group:"logic"},TRUE:{syntax:"TRUE()",summary:"The value true. You can also write TRUE without the brackets.",example:"IF({Qty} > 0, TRUE(), FALSE())",group:"logic"},FALSE:{syntax:"FALSE()",summary:"The value false. You can also write FALSE without the brackets.",example:'IF({Status} = "Cancelled", FALSE(), TRUE())',group:"logic"},BLANK:{syntax:"BLANK()",summary:"An empty value, for leaving the cell empty.",example:"IF({Qty} = 0, BLANK(), {Qty} * {Unit price})",group:"logic"},ERROR:{syntax:"ERROR()",summary:"Makes the cell show #ERROR, to flag a record that needs a look.",example:"IF({Qty} < 0, ERROR(), {Qty})",group:"logic"},ISERROR:{syntax:"ISERROR(value)",summary:"True when the value is an error, such as ERROR() or a number that cannot be worked out.",example:"IF(ISERROR({Discount}), 0, {Discount})",group:"logic"},SWITCH:{syntax:"SWITCH(value, match1, result1, [match2, result2, ...], [default])",summary:"The result next to the first match for the value, or the default when none match.",example:'SWITCH({Status}, "New", 1, "Paid", 2, "Shipped", 3, 0)',group:"logic"},RECORD_ID:{syntax:"RECORD_ID()",summary:"The id of this record, as text.",example:'"https://example.com/orders/" & RECORD_ID()',group:"records"},CREATED_TIME:{syntax:"CREATED_TIME()",summary:"When this record was made.",example:'DATETIME_DIFF(NOW(), CREATED_TIME(), "days")',group:"records"},LAST_MODIFIED_TIME:{syntax:"LAST_MODIFIED_TIME()",summary:"When this record was last changed.",example:'IF(DATETIME_DIFF(NOW(), LAST_MODIFIED_TIME(), "days") > 14, "Stale")',group:"records"},CONCATENATE:{syntax:"CONCATENATE(text1, [text2, ...])",summary:"All the values joined into one text, in order. The & sign does the same.",example:'CONCATENATE({First name}, " ", {Last name})',group:"text"},LEN:{syntax:"LEN(text)",summary:"The number of characters in the text.",example:"LEN({Phone})",group:"text"},UPPER:{syntax:"UPPER(text)",summary:"The text in capital letters.",example:"UPPER({Country code})",group:"text"},LOWER:{syntax:"LOWER(text)",summary:"The text in small letters.",example:"LOWER({Email})",group:"text"},TRIM:{syntax:"TRIM(text)",summary:"The text without spaces at the start and the end.",example:"TRIM({Client})",group:"text"},LEFT:{syntax:"LEFT(text, [count])",summary:"The first characters of the text; one character if no count is given.",example:"LEFT({Postcode}, 2)",group:"text"},RIGHT:{syntax:"RIGHT(text, [count])",summary:"The last characters of the text; one character if no count is given.",example:"RIGHT({Phone}, 4)",group:"text"},MID:{syntax:"MID(text, start, [count])",summary:"Characters from a position (1 is the first); the rest of the text if no count.",example:"MID({Invoice no}, 5, 3)",group:"text"},FIND:{syntax:"FIND(text to find, text, [start])",summary:"Where the text is found (1 is the first character), or 0 if not. Case matters.",example:'FIND("@", {Email})',group:"text"},SEARCH:{syntax:"SEARCH(text to find, text, [start])",summary:"Where the text is found (1 is the first character), or empty if not. Case matters.",example:'SEARCH("urgent", {Notes})',group:"text"},SUBSTITUTE:{syntax:"SUBSTITUTE(text, old text, new text, [which one])",summary:"The text with the old text swapped for the new; only the nth one if you give n.",example:'SUBSTITUTE({Phone}, " ", "")',group:"text"},REPLACE:{syntax:"REPLACE(text, start, count, new text)",summary:"The text with count characters from the start position swapped for the new text.",example:'REPLACE({Card number}, 1, 12, "************")',group:"text"},ENCODE_URL_COMPONENT:{syntax:"ENCODE_URL_COMPONENT(text)",summary:"The text made safe to put in a web address.",example:'"https://maps.google.com/?q=" & ENCODE_URL_COMPONENT({Address})',group:"text"},REGEX_MATCH:{syntax:"REGEX_MATCH(text, pattern)",summary:"True when the text fits the pattern (a regular expression).",example:'REGEX_MATCH({Email}, "^[^@ ]+@[^@ ]+[.][a-z]+$")',group:"text"},REGEX_EXTRACT:{syntax:"REGEX_EXTRACT(text, pattern)",summary:"The first part of the text that fits the pattern, or empty if none does.",example:'REGEX_EXTRACT({Notes}, "[0-9]+")',group:"text"},REGEX_REPLACE:{syntax:"REGEX_REPLACE(text, pattern, new text)",summary:"The text with every part that fits the pattern swapped for the new text.",example:'REGEX_REPLACE({Phone}, "[^0-9]", "")',group:"text"},REPT:{syntax:"REPT(text, times)",summary:"The text repeated a number of times (at most 1,000).",example:'REPT("*", {Rating})',group:"text"},T:{syntax:"T(value)",summary:"The value if it is text, otherwise empty text.",example:"T({Notes})",group:"text"},VALUE:{syntax:"VALUE(text)",summary:"The number in the text, ignoring signs like $ and spaces; empty if there is none.",example:"VALUE({Price text}) * {Qty}",group:"text"},ARRAYJOIN:{syntax:"ARRAYJOIN(list, [separator])",summary:'The items of a list joined into one text, with ", " between them unless you say.',example:'ARRAYJOIN({Tags}, " / ")',group:"text"},ARRAYCOMPACT:{syntax:"ARRAYCOMPACT(list)",summary:"The list without its empty items.",example:"ARRAYCOMPACT({Phone numbers})",group:"lists"},ARRAYFLATTEN:{syntax:"ARRAYFLATTEN(list1, [list2, ...])",summary:"One flat list of all the items, with lists inside lists opened up.",example:"ARRAYFLATTEN({Tags}, {Categories})",group:"lists"},ARRAYUNIQUE:{syntax:"ARRAYUNIQUE(list)",summary:"The list with each item only once.",example:"ARRAYUNIQUE({Order cities})",group:"lists"},ARRAYSLICE:{syntax:"ARRAYSLICE(list, start, [end])",summary:"The items from start to end (1 is the first; a negative number counts from the end).",example:"ARRAYSLICE({Tags}, 1, 3)",group:"lists"},SUM:{syntax:"SUM(number1, [number2, ...])",summary:"All the numbers added up.",example:"SUM({Subtotal}, {Shipping}, {Tax})",group:"numbers"},AVERAGE:{syntax:"AVERAGE(number1, [number2, ...])",summary:"The average of the numbers, leaving out empty ones.",example:"AVERAGE({Q1 sales}, {Q2 sales}, {Q3 sales})",group:"numbers"},MAX:{syntax:"MAX(number1, [number2, ...])",summary:"The largest of the numbers.",example:"MAX({Quote A}, {Quote B})",group:"numbers"},MIN:{syntax:"MIN(number1, [number2, ...])",summary:"The smallest of the numbers.",example:"MIN({Stock}, {Qty})",group:"numbers"},COUNT:{syntax:"COUNT(value1, [value2, ...])",summary:"How many of the values are numbers.",example:"COUNT({Mon hours}, {Tue hours}, {Wed hours})",group:"numbers"},COUNTA:{syntax:"COUNTA(value1, [value2, ...])",summary:"How many of the values are not empty.",example:"COUNTA({Phone}, {Email}, {Address})",group:"numbers"},COUNTALL:{syntax:"COUNTALL(value1, [value2, ...])",summary:"How many values there are, empty ones included.",example:"COUNTALL({Attendees})",group:"numbers"},ROUND:{syntax:"ROUND(number, [decimals])",summary:"The number rounded to that many decimal places (none if left out).",example:"ROUND({Qty} * {Unit price}, 2)",group:"numbers"},ROUNDUP:{syntax:"ROUNDUP(number, [decimals])",summary:"The number rounded away from zero to that many decimal places.",example:"ROUNDUP({Hours worked}, 0)",group:"numbers"},ROUNDDOWN:{syntax:"ROUNDDOWN(number, [decimals])",summary:"The number rounded toward zero to that many decimal places.",example:"ROUNDDOWN({Total} * 0.1, 2)",group:"numbers"},INT:{syntax:"INT(number)",summary:"The number rounded down to a whole number.",example:"INT({Hours worked})",group:"numbers"},ABS:{syntax:"ABS(number)",summary:"The number without its minus sign.",example:"ABS({Balance})",group:"numbers"},MOD:{syntax:"MOD(number, divisor)",summary:"What is left after dividing; it takes the sign of the first number.",example:"MOD({Qty}, 12)",group:"numbers"},POWER:{syntax:"POWER(number, power)",summary:"The number raised to the power.",example:"{Deposit} * POWER(1 + {Rate}, {Years})",group:"numbers"},SQRT:{syntax:"SQRT(number)",summary:"The square root of the number.",example:"SQRT({Floor area})",group:"numbers"},EXP:{syntax:"EXP(number)",summary:"The number e (about 2.718) raised to the power you give.",example:"{Deposit} * EXP({Rate} * {Years})",group:"numbers"},LOG:{syntax:"LOG(number, [base])",summary:"The logarithm of the number, in base 10 unless you give another base.",example:"LOG({Visitors}, 10)",group:"numbers"},EVEN:{syntax:"EVEN(number)",summary:"The number rounded away from zero to the next even whole number.",example:"EVEN({Guests})",group:"numbers"},ODD:{syntax:"ODD(number)",summary:"The number rounded away from zero to the next odd whole number.",example:"ODD({Team size})",group:"numbers"},CEILING:{syntax:"CEILING(number, [multiple])",summary:"The number rounded up to a multiple (1 if left out): CEILING(7, 5) is 10.",example:"CEILING({Qty}, 6)",group:"numbers"},FLOOR:{syntax:"FLOOR(number, [multiple])",summary:"The number rounded down to a multiple (1 if left out): FLOOR(7, 5) is 5.",example:"FLOOR({Price}, 0.5)",group:"numbers"},DISTANCE:{syntax:"DISTANCE(place, place)",summary:'Metres between two places given as coordinates ("42.6977, 23.3219"), as a phone saves them.',example:"DISTANCE({Where the phone was}, '42.6977, 23.3219')",group:"numbers"},TODAY:{syntax:"TODAY()",summary:"Today's date, at midnight.",example:'DATETIME_DIFF({Due date}, TODAY(), "days")',group:"dates"},NOW:{syntax:"NOW()",summary:"The date and time right now.",example:'DATETIME_DIFF(NOW(), {Created}, "hours")',group:"dates"},YEAR:{syntax:"YEAR(date)",summary:"The year of a date, such as 2026.",example:"YEAR({Invoice date})",group:"dates"},MONTH:{syntax:"MONTH(date)",summary:"The month of a date, from 1 (January) to 12 (December).",example:"MONTH({Invoice date})",group:"dates"},DAY:{syntax:"DAY(date)",summary:"The day of the month of a date, from 1 to 31.",example:"DAY({Due date})",group:"dates"},HOUR:{syntax:"HOUR(date)",summary:"The hour of a date and time, from 0 to 23.",example:"HOUR({Appointment})",group:"dates"},MINUTE:{syntax:"MINUTE(date)",summary:"The minute of a date and time, from 0 to 59.",example:"MINUTE({Appointment})",group:"dates"},SECOND:{syntax:"SECOND(date)",summary:"The second of a date and time, from 0 to 59.",example:"SECOND({Logged at})",group:"dates"},WEEKDAY:{syntax:"WEEKDAY(date, [first day])",summary:'The day of the week, 0 for Sunday to 6; with "Monday" as first day, 0 is Monday.',example:'WEEKDAY({Delivery date}, "Monday")',group:"dates"},WEEKNUM:{syntax:"WEEKNUM(date, [first day])",summary:'The week of the year (week 1 holds January 1); weeks start Sunday, or "Monday".',example:'WEEKNUM({Order date}, "Monday")',group:"dates"},DATEADD:{syntax:"DATEADD(date, count, [unit])",summary:"The date moved on by a number of days, weeks, months, years... (days if no unit).",example:'DATEADD({Invoice date}, 30, "days")',group:"dates"},DATETIME_DIFF:{syntax:"DATETIME_DIFF(date1, date2, [unit])",summary:"The time between two dates: the first minus the second, in days or another unit.",example:'DATETIME_DIFF({Due date}, TODAY(), "days")',group:"dates"},IS_BEFORE:{syntax:"IS_BEFORE(date1, date2)",summary:"True when the first date is before the second.",example:"IS_BEFORE({Due date}, TODAY())",group:"dates"},IS_AFTER:{syntax:"IS_AFTER(date1, date2)",summary:"True when the first date is after the second.",example:"IS_AFTER({Delivered on}, {Due date})",group:"dates"},IS_SAME:{syntax:"IS_SAME(date1, date2, [unit])",summary:"True when two dates are the same moment, or the same day, month, year... by unit.",example:'IS_SAME({Order date}, TODAY(), "month")',group:"dates"},DATESTR:{syntax:"DATESTR(date)",summary:"The date as text, year first: 2026-12-04.",example:"DATESTR({Due date})",group:"dates"},TIMESTR:{syntax:"TIMESTR(date)",summary:"The time of a date as text, in 24 hours: 14:30:00.",example:"TIMESTR({Appointment})",group:"dates"},DATETIME_FORMAT:{syntax:"DATETIME_FORMAT(date, [format])",summary:'The date as text in the format you write, such as "DD/MM/YYYY" or "MMMM D".',example:'DATETIME_FORMAT({Due date}, "DD/MM/YYYY")',group:"dates"},DATETIME_PARSE:{syntax:"DATETIME_PARSE(text, [format])",summary:"The date written in the text, read with the format if you give one.",example:'DATETIME_PARSE({Date text}, "DD.MM.YYYY")',group:"dates"},SET_LOCALE:{syntax:"SET_LOCALE(date, locale)",summary:'The date, set to show month and day names in a language, such as "fr" or "de".',example:'DATETIME_FORMAT(SET_LOCALE({Due date}, "fr"), "D MMMM YYYY")',group:"dates"},SET_TIMEZONE:{syntax:"SET_TIMEZONE(date, time zone)",summary:'The date, set to show the clock of a time zone, such as "Europe/London".',example:'DATETIME_FORMAT(SET_TIMEZONE({Appointment}, "Europe/London"), "HH:mm")',group:"dates"},TONOW:{syntax:"TONOW(date)",summary:"The number of days from the date to today.",example:"TONOW({Last contacted})",group:"dates"},FROMNOW:{syntax:"FROMNOW(date)",summary:"The number of days from today to the date.",example:"FROMNOW({Due date})",group:"dates"},WORKDAY:{syntax:"WORKDAY(start date, days, [holidays])",summary:"The date that many working days on, skipping weekends and the holidays.",example:'WORKDAY({Order date}, 5, "2026-12-25, 2026-12-26")',group:"dates"},WORKDAY_DIFF:{syntax:"WORKDAY_DIFF(start date, end date, [holidays])",summary:"The working days from start to end, both days counted, skipping the holidays.",example:'WORKDAY_DIFF({Start date}, {End date}, "2026-12-25")',group:"dates"}};export function syntaxArgs(e){const t=e.indexOf("("),a=e.lastIndexOf(")");return t<0||a<=t?[]:e.slice(t+1,a).replace(/[[\]]/g,"").split(",").map(s=>s.replace(/\.{3}|…/g,"").trim()).filter(Boolean)}
@@ -1 +1 @@
1
- import{toDate as b}from"./format.js";import{maxOf as nt,minOf as rt}from"../extent.js";export class FormulaError extends Error{}export function tokenize(t){const n=[];let e=0;for(;e<t.length;){const r=t[e];if(/\s/.test(r)){e++;continue}if(r==="{"){const i=t.indexOf("}",e);if(i<0)throw new FormulaError(`Unclosed "{" at ${e+1}`);n.push({k:"ref",v:t.slice(e+1,i).trim(),at:e}),e=i+1;continue}if(r==='"'||r==="'"){let i=e+1,c="";for(;i<t.length&&t[i]!==r;){if(t[i]==="\\"&&i+1<t.length){c+=t[i+1],i+=2;continue}c+=t[i++]}if(i>=t.length)throw new FormulaError(`Unclosed text at ${e+1}`);n.push({k:"str",v:c,at:e}),e=i+1;continue}const l=/^\d+(\.\d+)?|^\.\d+/.exec(t.slice(e));if(l){n.push({k:"num",v:l[0],at:e}),e+=l[0].length;continue}const s=/^[A-Za-z_][A-Za-z0-9_]*/.exec(t.slice(e));if(s){n.push({k:"id",v:s[0],at:e}),e+=s[0].length;continue}const f=/^(!=|<=|>=|<>|[-+*/&=<>])/.exec(t.slice(e));if(f){n.push({k:"op",v:f[0]==="<>"?"!=":f[0],at:e}),e+=f[0].length;continue}if(r==="("||r===")"||r===","){n.push({k:r,v:r,at:e}),e++;continue}throw new FormulaError(`Unexpected "${r}" at ${e+1}`)}return n}const S=t=>t==null||t===""||Array.isArray(t)&&t.length===0,u=t=>{if(typeof t=="number")return t;if(typeof t=="boolean")return t?1:0;if(t instanceof Date)return t.getTime();if(t==null||t==="")return 0;if(Array.isArray(t))return t.reduce((e,r)=>e+u(r),0);const n=Number(t);return Number.isFinite(n)?n:NaN},o=t=>t==null?"":t instanceof Date?t.toISOString():Array.isArray(t)?t.map(o).join(", "):String(t),A=t=>!S(t)&&t!==!1&&t!==0,lt=/^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/;export function isoDate(t){const n=t.trim();return lt.test(n)?b(n):null}const h=t=>{if(t instanceof Date)return Number.isNaN(t.getTime())?null:t;if(t==null||t===""||typeof t=="boolean")return null;if(typeof t=="number")return b(t);const n=o(t).trim();return isoDate(n)??(/\d{4}/.test(n)&&/[/\s,.-]/.test(n)?b(n):null)},d=t=>t.flatMap(n=>Array.isArray(n)?n:[n]),k=t=>{const n=o(Array.isArray(t)?t.find(s=>!S(s))??null:t).replace(/%2C/gi,","),e=/(?<![\d.])(-?\d{1,2}(?:\.\d+)?)\s*,\s*(-?\d{1,3}(?:\.\d+)?)/.exec(n);if(!e)return null;const r=Number(e[1]),l=Number(e[2]);return Math.abs(r)<=90&&Math.abs(l)<=180?{lat:r,lng:l}:null},st=(t,n)=>{const e=l=>l*Math.PI/180,r=Math.sin(e(n.lat-t.lat)/2)**2+Math.cos(e(t.lat))*Math.cos(e(n.lat))*Math.sin(e(n.lng-t.lng)/2)**2;return Math.round(2*6371e3*Math.asin(Math.min(1,Math.sqrt(r))))},M=t=>String(t).padStart(2,"0"),R=t=>Number(t.toPrecision(12)),ot={milliseconds:"ms",millisecond:"ms",ms:"ms",seconds:"s",second:"s",s:"s",minutes:"m",minute:"m",m:"m",hours:"h",hour:"h",h:"h",days:"d",day:"d",d:"d",weeks:"w",week:"w",w:"w",months:"mo",month:"mo",quarters:"q",quarter:"q",q:"q",years:"y",year:"y",y:"y"},x={ms:1,s:1e3,m:6e4,h:36e5},L=t=>ot[o(t).trim().toLowerCase()]??null;function W(t,n){const e=new Date(t),r=e.getDate();return e.setDate(1),e.setMonth(e.getMonth()+n),e.setDate(Math.min(r,new Date(e.getFullYear(),e.getMonth()+1,0).getDate())),e}function ut(t,n,e){if(x[e])return new Date(t.getTime()+n*x[e]);if(e==="mo"||e==="q"||e==="y")return W(t,Math.trunc(n)*(e==="y"?12:e==="q"?3:1));const r=n*(e==="w"?7:1),l=new Date(t);return l.setDate(l.getDate()+Math.trunc(r)),new Date(l.getTime()+(r-Math.trunc(r))*864e5)}const I=t=>t.getTime()-t.getTimezoneOffset()*6e4;function _(t,n,e){if(x[e])return Math.trunc((t.getTime()-n.getTime())/x[e]);if(e==="d"||e==="w")return Math.trunc((I(t)-I(n))/(e==="w"?6048e5:864e5));let r=(t.getFullYear()-n.getFullYear())*12+t.getMonth()-n.getMonth();const l=W(n,r).getTime();return r>0&&l>t.getTime()?r-=1:r<0&&l<t.getTime()&&(r+=1),e==="y"?Math.trunc(r/12):e==="q"?Math.trunc(r/3):r}function O(t,n){if(n==="ms")return t.getTime();const e=new Date(t);return n==="s"?e.setMilliseconds(0):n==="m"?e.setSeconds(0,0):n==="h"?e.setMinutes(0,0,0):(e.setHours(0,0,0,0),n==="w"&&e.setDate(e.getDate()-e.getDay()),(n==="mo"||n==="q"||n==="y")&&e.setDate(1),n==="q"&&e.setMonth(e.getMonth()-e.getMonth()%3),n==="y"&&e.setMonth(0),e.getTime())}const N=t=>`${t.getFullYear()}-${M(t.getMonth()+1)}-${M(t.getDate())}`;function z(t){const n=d([t??null]).flatMap(e=>typeof e=="string"?e.split(","):[e]);return new Set(n.map(e=>h(typeof e=="string"?e.trim():e)).filter(e=>!!e).map(N))}const X=(t,n)=>t.getDay()!==0&&t.getDay()!==6&&!n.has(N(t)),q=1e5;class it extends Date{}function j(t,n){const e=new it(t.getTime()),r=t;return e.locale=n.locale??r.locale,e.zone=n.zone??r.zone,e}const v=new Map;function G(t){let n=v.get(t);return n||(n=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",weekday:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),v.set(t,n)),n}const ct=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function at(t){const n=t.zone,e=t.getMilliseconds();if(!n)return{y:t.getFullYear(),mo:t.getMonth(),d:t.getDate(),h:t.getHours(),mi:t.getMinutes(),s:t.getSeconds(),ms:e,wd:t.getDay(),offset:-t.getTimezoneOffset()};const r={};for(const s of G(n).formatToParts(t))r[s.type]=s.value;const l={y:+r.year,mo:+r.month-1,d:+r.day,h:+r.hour%24,mi:+r.minute,s:+r.second,ms:e,wd:ct.indexOf(r.weekday),offset:0};return l.offset=Math.round((Date.UTC(l.y,l.mo,l.d,l.h,l.mi,l.s,e)-t.getTime())/6e4),l}const K=new Map;function $(t,n,e,r){const l=`${t??"en"}|${n}|${e}`;let s=K.get(l);return s||K.set(l,s=new Intl.DateTimeFormat(t??"en",{[n]:e,timeZone:"UTC"})),s.format(n==="month"?Date.UTC(2023,r,1):Date.UTC(2023,0,1+r))}const ft=t=>{const n=t%100;return`${t}${n>=11&&n<=13?"th":["th","st","nd","rd"][t%10]??"th"}`},B=(t,n)=>{const e=Math.abs(t);return`${t<0?"-":"+"}${M(Math.floor(e/60))}${n?":":""}${M(e%60)}`},ht={LTS:"h:mm:ss A",LT:"h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A",LLL:"MMMM D, YYYY h:mm A",LL:"MMMM D, YYYY",L:"MM/DD/YYYY"},mt=/\[([^\]]*)]|YYYY|YY|Q|MMMM|MMM|MM|M|DDDD|DDD|Do|DD|D|dddd|ddd|d|HH|H|hh|h|mm|m|ss|s|SSS|SS|S|A|a|ZZ|Z|X|x/g;function dt(t,n){const e=at(t),r=t.locale,l=n.replace(/\[[^\]]*]|LTS|LT|LLLL|LLL|LL|L/g,i=>ht[i]??i),s=e.h%12||12,f=Math.round((Date.UTC(e.y,e.mo,e.d)-Date.UTC(e.y,0,1))/864e5)+1;return l.replace(mt,(i,c)=>{if(c!==void 0)return c;switch(i){case"YYYY":return String(e.y).padStart(4,"0");case"YY":return M(e.y%100);case"Q":return String(Math.floor(e.mo/3)+1);case"MMMM":return $(r,"month","long",e.mo);case"MMM":return $(r,"month","short",e.mo);case"MM":return M(e.mo+1);case"M":return String(e.mo+1);case"DDDD":return String(f).padStart(3,"0");case"DDD":return String(f);case"Do":return ft(e.d);case"DD":return M(e.d);case"D":return String(e.d);case"dddd":return $(r,"weekday","long",e.wd);case"ddd":return $(r,"weekday","short",e.wd);case"d":return String(e.wd);case"HH":return M(e.h);case"H":return String(e.h);case"hh":return M(s);case"h":return String(s);case"mm":return M(e.mi);case"m":return String(e.mi);case"ss":return M(e.s);case"s":return String(e.s);case"SSS":return String(e.ms).padStart(3,"0");case"SS":return M(Math.floor(e.ms/10));case"S":return String(Math.floor(e.ms/100));case"A":return e.h<12?"AM":"PM";case"a":return e.h<12?"am":"pm";case"ZZ":return B(e.offset,!1);case"Z":return B(e.offset,!0);case"X":return String(Math.floor(t.getTime()/1e3));default:return String(t.getTime())}})}const Mt=["january","february","march","april","may","june","july","august","september","october","november","december"],gt=/\[([^\]]*)]|YYYY|YY|MMMM|MMM|MM|M|Do|DD|D|dddd|ddd|HH|H|hh|h|mm|m|ss|s|SSS|A|a|ZZ|Z|X|x/g;function Dt(t,n){const e=[];let r="^\\s*",l=0;const s=D=>D.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+");for(const D of n.matchAll(gt)){if(r+=s(n.slice(l,D.index)),l=D.index+D[0].length,D[1]!==void 0){r+=s(D[1]);continue}const a=D[0];e.push(a),r+=a==="YYYY"?"(\\d{4})":a==="MMMM"||a==="MMM"||a==="dddd"||a==="ddd"?"([A-Za-z]+)\\.?":a==="Do"?"(\\d{1,2})(?:st|nd|rd|th)":a==="SSS"?"(\\d{1,3})":a==="A"||a==="a"?"([AaPp][Mm])":a==="Z"||a==="ZZ"?"(Z|[+-]\\d{2}:?\\d{2})":a==="X"||a==="x"?"(-?\\d+)":"(\\d{1,2})"}r+=`${s(n.slice(l))}\\s*$`;const f=new RegExp(r,"i").exec(t);if(!f)return null;let i=new Date().getFullYear(),c=0,m=1,g=0,E=0,y=0,w=0,C=null,Y=null;for(let D=0;D<e.length;D++){const a=e[D],T=f[D+1],p=Number(T);if(a==="X"||a==="x")return new Date(a==="X"?p*1e3:p);if(a==="YYYY")i=p;else if(a==="YY")i=p+(p<69?2e3:1900);else if(a==="MMMM"||a==="MMM"){const P=Mt.findIndex(et=>et.startsWith(T.toLowerCase().slice(0,3)));if(P<0)return null;c=P}else a==="MM"||a==="M"?c=p-1:a==="DD"||a==="D"||a==="Do"?m=p:a==="HH"||a==="H"||a==="hh"||a==="h"?g=p:a==="mm"||a==="m"?E=p:a==="ss"||a==="s"?y=p:a==="SSS"?w=Number(T.padEnd(3,"0")):a==="A"||a==="a"?C=T.toLowerCase()==="pm":(a==="Z"||a==="ZZ")&&(Y=T.toUpperCase()==="Z"?0:(T[0]==="-"?-1:1)*(Number(T.slice(1,3))*60+Number(T.slice(-2))))}if(C!=null&&(g=g%12+(C?12:0)),c<0||c>11||m<1||m>31||g>23||E>59||y>59)return null;const U=Y==null?new Date(i,c,m,g,E,y,w):new Date(Date.UTC(i,c,m,g,E,y,w)-Y*6e4);return Y==null&&U.getDate()!==m||Number.isNaN(U.getTime())?null:U}const F=new Map;function H(t,n=!1){const e=`${n?"g":""}|${t}`;let r=F.get(e);if(!r){const l=/^\(\?([ims]+)\)/.exec(t);r=new RegExp(l?t.slice(l[0].length):t,`${l?.[1]??""}${n?"g":""}`),F.size>200&&F.clear(),F.set(e,r)}return r.lastIndex=0,r}const Z="#ERROR",V=t=>`${t instanceof Date?"d":typeof t}:${o(t)}`;function pt(t,n,e){const r=n<0?t.length+n:Math.max(0,n-1),l=e==null?t.length:e<0?t.length+e+1:e;return t.slice(r,l)}function Q(t,n){const e=t<0?-1:1;let r=Math.ceil(Math.abs(t));return r%2===1!==n&&(r+=1),e*r}const J={IF:t=>A(t[0]??null)?t[1]??null:t[2]??null,AND:t=>d(t).every(A),OR:t=>d(t).some(A),NOT:t=>!A(t[0]??null),XOR:t=>d(t).filter(A).length%2===1,TRUE:()=>!0,FALSE:()=>!1,BLANK:()=>null,ERROR:()=>{throw new FormulaError("ERROR()")},ISERROR:t=>t[0]===Z,RECORD_ID:()=>null,SWITCH:t=>{for(let n=1;n+1<t.length;n+=2)if(o(t[0]??null)===o(t[n]??null))return t[n+1]??null;return t.length%2===0?t[t.length-1]??null:null},CONCATENATE:t=>t.map(o).join(""),LEN:t=>o(t[0]??null).length,UPPER:t=>o(t[0]??null).toUpperCase(),LOWER:t=>o(t[0]??null).toLowerCase(),TRIM:t=>o(t[0]??null).trim(),LEFT:t=>o(t[0]??null).slice(0,u(t[1]??1)),RIGHT:t=>{const n=o(t[0]??null),e=u(t[1]??1);return e<=0?"":n.slice(-e)},MID:t=>{const n=o(t[0]??null),e=Math.max(0,u(t[1]??1)-1);return t.length>2?n.slice(e,e+Math.max(0,u(t[2]??0))):n.slice(e)},FIND:t=>o(t[1]??null).indexOf(o(t[0]??null),Math.max(0,u(t[2]??1)-1))+1,SEARCH:t=>{const n=o(t[1]??null).indexOf(o(t[0]??null),Math.max(0,u(t[2]??1)-1));return n<0?null:n+1},SUBSTITUTE:t=>{const n=o(t[0]??null).split(o(t[1]??null));if(t.length<4)return n.join(o(t[2]??null));const e=u(t[3]??null);return n.reduce((r,l,s)=>s===0?l:r+o(s===e?t[2]??null:t[1]??null)+l,"")},REPLACE:t=>{const n=o(t[0]??null),e=Math.max(0,u(t[1]??1)-1);return n.slice(0,e)+o(t[3]??null)+n.slice(e+Math.max(0,u(t[2]??0)))},ENCODE_URL_COMPONENT:t=>encodeURIComponent(o(t[0]??null)),REGEX_MATCH:t=>H(o(t[1]??null)).test(o(t[0]??null)),REGEX_EXTRACT:t=>H(o(t[1]??null)).exec(o(t[0]??null))?.[0]??null,REGEX_REPLACE:t=>o(t[0]??null).replace(H(o(t[1]??null),!0),o(t[2]??null)),REPT:t=>o(t[0]??null).repeat(Math.max(0,Math.min(1e3,u(t[1]??0)))),T:t=>typeof t[0]=="string"?t[0]:"",VALUE:t=>{const n=o(t[0]??null).replace(/[^0-9.eE+-]/g,""),e=/\d/.test(n)?Number(n):NaN;return Number.isFinite(e)?e:null},ARRAYJOIN:t=>d([t[0]??null]).map(o).filter(Boolean).join(t.length>1?o(t[1]??null):", "),ARRAYCOMPACT:t=>d([t[0]??null]).filter(n=>n!=null&&n!==""),ARRAYFLATTEN:t=>t.flat(1/0),ARRAYUNIQUE:t=>{const n=new Set;return d([t[0]??null]).filter(e=>!n.has(V(e))&&!!n.add(V(e)))},ARRAYSLICE:t=>pt(d([t[0]??null]),u(t[1]??1),t.length>2?u(t[2]??null):void 0),SUM:t=>d(t).reduce((n,e)=>n+u(e),0),AVERAGE:t=>{const n=d(t).filter(e=>!S(e));return n.length?n.reduce((e,r)=>e+u(r),0)/n.length:null},MAX:t=>{const n=d(t).filter(e=>!S(e)).map(u);return n.length?nt(n):null},MIN:t=>{const n=d(t).filter(e=>!S(e)).map(u);return n.length?rt(n):null},COUNT:t=>d(t).filter(n=>typeof n=="number").length,COUNTA:t=>d(t).filter(n=>!S(n)).length,COUNTALL:t=>d(t).length,ROUND:t=>{const n=10**u(t[1]??0);return Math.round(u(t[0]??null)*n)/n},ROUNDUP:t=>{const n=10**u(t[1]??0),e=u(t[0]??null);return Math.sign(e)*Math.ceil(R(Math.abs(e)*n))/n},ROUNDDOWN:t=>{const n=10**u(t[1]??0),e=u(t[0]??null);return Math.sign(e)*Math.floor(R(Math.abs(e)*n))/n},INT:t=>Math.floor(u(t[0]??null)),ABS:t=>Math.abs(u(t[0]??null)),MOD:t=>u(t[0]??null)%u(t[1]??1),POWER:t=>u(t[0]??null)**u(t[1]??1),SQRT:t=>Math.sqrt(u(t[0]??null)),EXP:t=>Math.exp(u(t[0]??null)),LOG:t=>Math.log(u(t[0]??null))/Math.log(t.length>1?u(t[1]??null):10),EVEN:t=>Q(u(t[0]??null),!1),ODD:t=>Q(u(t[0]??null),!0),CEILING:t=>{const n=u(t[1]??1);return n===0?0:R(Math.ceil(R(u(t[0]??null)/n))*n)},FLOOR:t=>{const n=u(t[1]??1);return n===0?0:R(Math.floor(R(u(t[0]??null)/n))*n)},DISTANCE:t=>{const n=t.length>=4?k(`${o(t[0]??null)}, ${o(t[1]??null)}`):k(t[0]??null),e=t.length>=4?k(`${o(t[2]??null)}, ${o(t[3]??null)}`):k(t[1]??null);return n&&e?st(n,e):null},TODAY:()=>{const t=new Date;return t.setHours(0,0,0,0),t},NOW:()=>new Date,YEAR:t=>h(t[0]??null)?.getFullYear()??null,MONTH:t=>{const n=h(t[0]??null);return n?n.getMonth()+1:null},DAY:t=>h(t[0]??null)?.getDate()??null,HOUR:t=>h(t[0]??null)?.getHours()??null,MINUTE:t=>h(t[0]??null)?.getMinutes()??null,SECOND:t=>h(t[0]??null)?.getSeconds()??null,WEEKDAY:t=>{const n=h(t[0]??null);return n?/^mon/i.test(o(t[1]??null))?(n.getDay()+6)%7:n.getDay():null},WEEKNUM:t=>{const n=h(t[0]??null);if(!n)return null;const e=/^mon/i.test(o(t[1]??null))?1:0,r=new Date(n.getFullYear(),0,1),l=Math.round((I(new Date(n.getFullYear(),n.getMonth(),n.getDate()))-I(r))/864e5);return Math.floor((l+(r.getDay()-e+7)%7)/7)+1},DATEADD:t=>{const n=h(t[0]??null),e=t.length>2?L(t[2]??null):"d";return n&&e?ut(n,u(t[1]??0),e):null},DATETIME_DIFF:t=>{const n=h(t[0]??null),e=h(t[1]??null),r=t.length>2?L(t[2]??null):"s";return n&&e&&r?_(n,e,r):null},IS_BEFORE:t=>{const n=h(t[0]??null),e=h(t[1]??null);return!!n&&!!e&&n<e},IS_AFTER:t=>{const n=h(t[0]??null),e=h(t[1]??null);return!!n&&!!e&&n>e},IS_SAME:t=>{const n=h(t[0]??null),e=h(t[1]??null),r=t.length>2?L(t[2]??null):"ms";return!!n&&!!e&&!!r&&O(n,r)===O(e,r)},DATESTR:t=>{const n=h(t[0]??null);return n?N(n):null},TIMESTR:t=>{const n=h(t[0]??null);return n?`${M(n.getHours())}:${M(n.getMinutes())}:${M(n.getSeconds())}`:null},DATETIME_FORMAT:t=>{const n=h(t[0]??null);return n?dt(n,t.length>1&&!S(t[1]??null)?o(t[1]??null):"YYYY-MM-DDTHH:mm:ss.SSSZ"):null},DATETIME_PARSE:t=>t.length>1&&!S(t[1]??null)?Dt(o(t[0]??null),o(t[1]??null)):h(t[0]??null),SET_LOCALE:t=>{const n=h(t[0]??null),e=o(t[1]??null).trim();return!n||!e?n:j(n,{locale:Intl.DateTimeFormat.supportedLocalesOf(e)[0]??e})},SET_TIMEZONE:t=>{const n=h(t[0]??null),e=o(t[1]??null).trim();return!n||!e?n:(G(e),j(n,{zone:e}))},TONOW:t=>{const n=h(t[0]??null);return n?_(new Date(O(new Date,"d")),new Date(O(n,"d")),"d"):null},FROMNOW:t=>{const n=h(t[0]??null);return n?_(new Date(O(n,"d")),new Date(O(new Date,"d")),"d"):null},WORKDAY:t=>{const n=h(t[0]??null);if(!n)return null;const e=Math.trunc(u(t[1]??0)),r=e<0?-1:1,l=z(t[2]),s=new Date(n);for(let f=Math.abs(e),i=0;f>0;){if(++i>q)return null;s.setDate(s.getDate()+r),X(s,l)&&(f-=1)}return s},WORKDAY_DIFF:t=>{const n=h(t[0]??null),e=h(t[1]??null);if(!n||!e)return null;const r=z(t[2]),l=n>e?-1:1,s=new Date(l>0?n:e),f=N(l>0?e:n);let i=0;for(let c=0;N(s)<=f;c++){if(c>q)return null;X(s,r)&&(i+=1),s.setDate(s.getDate()+1)}return l*i}};function tt(t,n,e){switch(t){case"=":return n===e;case"!=":return n!==e;case"<":return n<e;case">":return n>e;case"<=":return n<=e;default:return n>=e}}const Tt=new Set(["DATEADD","DATETIME_DIFF","IS_SAME"]);export const FORMULA_FUNCTIONS=Object.keys(J).sort(),selfReferenceError=t=>new FormulaError(`A formula cannot read its own field {${t.trim()}}`);export function columnResolver(t,n=[]){const e=new Set(n.filter(r=>r!=null&&String(r).trim()!=="").map(r=>String(r).trim().toLowerCase()));return r=>{const l=r.trim().toLowerCase();if(e.has(l))throw selfReferenceError(r);const s=t.find(f=>String(f.header??"").trim().toLowerCase()===l||String(f.field??"").toLowerCase()===l);return s?String(s.field??s.id):null}}class St{constructor(n,e,r){this.toks=n,this.resolve=e,this.refs=r,this.i=0}peek(){return this.toks[this.i]}next(){return this.toks[this.i++]}expect(n,e){const r=this.next();if(!r||r.k!==n||e&&r.v!==e)throw new FormulaError(`Expected "${e??n}"${r?` at ${r.at+1}`:" at the end"}`);return r}parse(){const n=this.compare();if(this.peek())throw new FormulaError(`Unexpected "${this.peek().v}" at ${this.peek().at+1}`);return n}compare(){let n=this.concat();for(let e=this.peek();e&&e.k==="op"&&["=","!=","<",">","<=",">="].includes(e.v);e=this.peek()){this.next();const r=e.v,l=n,s=this.concat();n=f=>{const i=l(f),c=s(f);if(i instanceof Date||c instanceof Date){const y=h(i),w=h(c);return!y||!w?r==="!=":tt(r,y.getTime(),w.getTime())}const m=typeof i=="number"||typeof c=="number",g=m?u(i):o(i),E=m?u(c):o(c);return tt(r,g,E)}}return n}concat(){let n=this.add();for(;this.peek()?.k==="op"&&this.peek().v==="&";){this.next();const e=n,r=this.add();n=l=>o(e(l))+o(r(l))}return n}add(){let n=this.mul();for(let e=this.peek();e&&e.k==="op"&&(e.v==="+"||e.v==="-");e=this.peek()){this.next();const r=n,l=this.mul(),s=e.v==="+";n=f=>s?u(r(f))+u(l(f)):u(r(f))-u(l(f))}return n}mul(){let n=this.unary();for(let e=this.peek();e&&e.k==="op"&&(e.v==="*"||e.v==="/");e=this.peek()){this.next();const r=n,l=this.unary(),s=e.v==="*";n=f=>{if(s)return u(r(f))*u(l(f));const i=u(l(f));return i===0?null:u(r(f))/i}}return n}unary(){const n=this.peek();if(n?.k==="op"&&n.v==="-"){this.next();const e=this.unary();return r=>-u(e(r))}return this.primary()}primary(){const n=this.next();if(!n)throw new FormulaError("The formula ends too early");if(n.k==="num"){const e=Number(n.v);return()=>e}if(n.k==="str"){const e=n.v;return()=>e}if(n.k==="ref"){const e=this.resolve(n.v);if(e==null)throw new FormulaError(`No field named "${n.v}"`);return this.refs.add(e),r=>r?.[e]??null}if(n.k==="("){const e=this.compare();return this.expect(")"),e}if(n.k==="id"){const e=n.v.toUpperCase();if(e==="TRUE"&&this.peek()?.k!=="(")return()=>!0;if(e==="FALSE"&&this.peek()?.k!=="(")return()=>!1;const r=J[e];if(!r)throw new FormulaError(`Unknown function ${n.v}`);this.expect("(");const l=[],s=[],f=()=>{const c=this.i;l.push(this.compare());const m=this.i===c+1?this.toks[c]:void 0;s.push(m?.k==="str"?m.v:void 0)};if(this.peek()?.k!==")")for(f();this.peek()?.k===",";)this.next(),f();this.expect(")");const i=s[2];if(Tt.has(e)&&i!==void 0&&!L(i))throw new FormulaError(`Unknown unit "${i}" in ${e}: use ms, seconds, minutes, hours, days, weeks, months, quarters or years`);return e==="RECORD_ID"?c=>c?.id==null?null:String(c.id):e==="ISERROR"?c=>{try{const m=l[0]?.(c)??null;return m===Z||typeof m=="number"&&!Number.isFinite(m)}catch{return!0}}:e==="IF"?c=>A(l[0]?.(c)??null)?l[1]?.(c)??null:l[2]?.(c)??null:e==="SWITCH"?c=>{if(!l.length)return null;const m=o(l[0](c));for(let g=1;g+1<l.length;g+=2)if(m===o(l[g](c)))return l[g+1](c);return l.length%2===0?l[l.length-1](c):null}:c=>r(l.map(m=>m(c)))}throw new FormulaError(`Unexpected "${n.v}" at ${n.at+1}`)}}export function compileFormula(t,n){if(!t.trim())throw new FormulaError("The formula is empty");const e=new Set,r=new St(tokenize(t),n,e).parse();return{fn:l=>{try{const s=r(l);return typeof s=="number"&&!Number.isFinite(s)?null:s}catch(s){return s instanceof FormulaError?Z:null}},refs:[...e]}}export function renameFormulaRefs(t,n){let e;try{e=tokenize(t)}catch{return t}let r="",l=0;for(const s of e){if(s.k!=="ref")continue;const f=n(s.v);if(f==null)continue;const i=t.indexOf("}",s.at);r+=`${t.slice(l,s.at)}{${f}}`,l=i+1}return l?r+t.slice(l):t}export function formulaRefs(t,n){let e;try{e=tokenize(t)}catch{return[]}const r=new Set;for(const l of e)if(l.k==="ref")try{const s=n(l.v);s!=null&&r.add(s)}catch{}return[...r]}export function formulaReaders(t,n){const e=new Set([n.field,n.id].filter(l=>l!=null&&l!=="").map(String));if(!e.size)return[];const r=columnResolver(t);return t.filter(l=>l.fieldType!=="formula"||e.has(String(l.field??l.id??""))?!1:formulaRefs(String(l.fieldProps?.formula??""),r).some(s=>e.has(s)))}export function formulaError(t,n){try{return compileFormula(t,n),null}catch(e){return e instanceof FormulaError?e.message:"The formula is not valid"}}
1
+ import{toDate as _}from"./format.js";import{maxOf as nt,minOf as rt}from"../extent.js";export class FormulaError extends Error{}export function tokenize(t){const n=[];let e=0;for(;e<t.length;){const r=t[e];if(/\s/.test(r)){e++;continue}if(r==="{"){const c=t.indexOf("}",e);if(c<0)throw new FormulaError(`Unclosed "{" at ${e+1}`);n.push({k:"ref",v:t.slice(e+1,c).trim(),at:e}),e=c+1;continue}if(r==='"'||r==="'"){let c=e+1,i="";for(;c<t.length&&t[c]!==r;){if(t[c]==="\\"&&c+1<t.length){i+=t[c+1],c+=2;continue}i+=t[c++]}if(c>=t.length)throw new FormulaError(`Unclosed text at ${e+1}`);n.push({k:"str",v:i,at:e}),e=c+1;continue}const l=/^\d+(\.\d+)?|^\.\d+/.exec(t.slice(e));if(l){n.push({k:"num",v:l[0],at:e}),e+=l[0].length;continue}const s=/^[A-Za-z_][A-Za-z0-9_]*/.exec(t.slice(e));if(s){n.push({k:"id",v:s[0],at:e}),e+=s[0].length;continue}const f=/^(!=|<=|>=|<>|[-+*/&=<>])/.exec(t.slice(e));if(f){n.push({k:"op",v:f[0]==="<>"?"!=":f[0],at:e}),e+=f[0].length;continue}if(r==="("||r===")"||r===","){n.push({k:r,v:r,at:e}),e++;continue}throw new FormulaError(`Unexpected "${r}" at ${e+1}`)}return n}const S=t=>t==null||t===""||Array.isArray(t)&&t.length===0,o=t=>{if(typeof t=="number")return t;if(typeof t=="boolean")return t?1:0;if(t instanceof Date)return t.getTime();if(t==null||t==="")return 0;if(Array.isArray(t))return t.reduce((e,r)=>e+o(r),0);const n=Number(t);return Number.isFinite(n)?n:NaN},u=t=>t==null?"":t instanceof Date?t.toISOString():Array.isArray(t)?t.map(u).join(", "):String(t),w=t=>!S(t)&&t!==!1&&t!==0,lt=/^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/;export function isoDate(t){const n=t.trim();return lt.test(n)?_(n):null}const h=t=>{if(t instanceof Date)return Number.isNaN(t.getTime())?null:t;if(t==null||t===""||typeof t=="boolean")return null;if(typeof t=="number")return _(t);const n=u(t).trim();return isoDate(n)??(/\d{4}/.test(n)&&/[/\s,.-]/.test(n)?_(n):null)},d=t=>t.flatMap(n=>Array.isArray(n)?n:[n]),k=t=>{const n=u(Array.isArray(t)?t.find(s=>!S(s))??null:t).replace(/%2C/gi,","),e=/(?<![\d.])(-?\d{1,2}(?:\.\d+)?)\s*,\s*(-?\d{1,3}(?:\.\d+)?)/.exec(n);if(!e)return null;const r=Number(e[1]),l=Number(e[2]);return Math.abs(r)<=90&&Math.abs(l)<=180?{lat:r,lng:l}:null},st=(t,n)=>{const e=l=>l*Math.PI/180,r=Math.sin(e(n.lat-t.lat)/2)**2+Math.cos(e(t.lat))*Math.cos(e(n.lat))*Math.sin(e(n.lng-t.lng)/2)**2;return Math.round(2*6371e3*Math.asin(Math.min(1,Math.sqrt(r))))},M=t=>String(t).padStart(2,"0"),R=t=>Number(t.toPrecision(12)),ut={milliseconds:"ms",millisecond:"ms",ms:"ms",seconds:"s",second:"s",s:"s",minutes:"m",minute:"m",m:"m",hours:"h",hour:"h",h:"h",days:"d",day:"d",d:"d",weeks:"w",week:"w",w:"w",months:"mo",month:"mo",quarters:"q",quarter:"q",q:"q",years:"y",year:"y",y:"y"},x={ms:1,s:1e3,m:6e4,h:36e5},I=t=>ut[u(t).trim().toLowerCase()]??null;function W(t,n){const e=new Date(t),r=e.getDate();return e.setDate(1),e.setMonth(e.getMonth()+n),e.setDate(Math.min(r,new Date(e.getFullYear(),e.getMonth()+1,0).getDate())),e}function ot(t,n,e){if(x[e])return new Date(t.getTime()+n*x[e]);if(e==="mo"||e==="q"||e==="y")return W(t,Math.trunc(n)*(e==="y"?12:e==="q"?3:1));const r=n*(e==="w"?7:1),l=new Date(t);return l.setDate(l.getDate()+Math.trunc(r)),new Date(l.getTime()+(r-Math.trunc(r))*864e5)}const L=t=>t.getTime()-t.getTimezoneOffset()*6e4;function b(t,n,e){if(x[e])return Math.trunc((t.getTime()-n.getTime())/x[e]);if(e==="d"||e==="w")return Math.trunc((L(t)-L(n))/(e==="w"?6048e5:864e5));let r=(t.getFullYear()-n.getFullYear())*12+t.getMonth()-n.getMonth();const l=W(n,r).getTime();return r>0&&l>t.getTime()?r-=1:r<0&&l<t.getTime()&&(r+=1),e==="y"?Math.trunc(r/12):e==="q"?Math.trunc(r/3):r}function O(t,n){if(n==="ms")return t.getTime();const e=new Date(t);return n==="s"?e.setMilliseconds(0):n==="m"?e.setSeconds(0,0):n==="h"?e.setMinutes(0,0,0):(e.setHours(0,0,0,0),n==="w"&&e.setDate(e.getDate()-e.getDay()),(n==="mo"||n==="q"||n==="y")&&e.setDate(1),n==="q"&&e.setMonth(e.getMonth()-e.getMonth()%3),n==="y"&&e.setMonth(0),e.getTime())}const N=t=>`${t.getFullYear()}-${M(t.getMonth()+1)}-${M(t.getDate())}`;function z(t){const n=d([t??null]).flatMap(e=>typeof e=="string"?e.split(","):[e]);return new Set(n.map(e=>h(typeof e=="string"?e.trim():e)).filter(e=>!!e).map(N))}const X=(t,n)=>t.getDay()!==0&&t.getDay()!==6&&!n.has(N(t)),q=1e5;class it extends Date{}function j(t,n){const e=new it(t.getTime()),r=t;return e.locale=n.locale??r.locale,e.zone=n.zone??r.zone,e}const v=new Map;function G(t){let n=v.get(t);return n||(n=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",weekday:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),v.set(t,n)),n}const ct=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function at(t){const n=t.zone,e=t.getMilliseconds();if(!n)return{y:t.getFullYear(),mo:t.getMonth(),d:t.getDate(),h:t.getHours(),mi:t.getMinutes(),s:t.getSeconds(),ms:e,wd:t.getDay(),offset:-t.getTimezoneOffset()};const r={};for(const s of G(n).formatToParts(t))r[s.type]=s.value;const l={y:+r.year,mo:+r.month-1,d:+r.day,h:+r.hour%24,mi:+r.minute,s:+r.second,ms:e,wd:ct.indexOf(r.weekday),offset:0};return l.offset=Math.round((Date.UTC(l.y,l.mo,l.d,l.h,l.mi,l.s,e)-t.getTime())/6e4),l}const K=new Map;function F(t,n,e,r){const l=`${t??"en"}|${n}|${e}`;let s=K.get(l);return s||K.set(l,s=new Intl.DateTimeFormat(t??"en",{[n]:e,timeZone:"UTC"})),s.format(n==="month"?Date.UTC(2023,r,1):Date.UTC(2023,0,1+r))}const ft=t=>{const n=t%100;return`${t}${n>=11&&n<=13?"th":["th","st","nd","rd"][t%10]??"th"}`},B=(t,n)=>{const e=Math.abs(t);return`${t<0?"-":"+"}${M(Math.floor(e/60))}${n?":":""}${M(e%60)}`},ht={LTS:"h:mm:ss A",LT:"h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A",LLL:"MMMM D, YYYY h:mm A",LL:"MMMM D, YYYY",L:"MM/DD/YYYY"},mt=/\[([^\]]*)]|YYYY|YY|Q|MMMM|MMM|MM|M|DDDD|DDD|Do|DD|D|dddd|ddd|d|HH|H|hh|h|mm|m|ss|s|SSS|SS|S|A|a|ZZ|Z|X|x/g;function dt(t,n){const e=at(t),r=t.locale,l=n.replace(/\[[^\]]*]|LTS|LT|LLLL|LLL|LL|L/g,c=>ht[c]??c),s=e.h%12||12,f=Math.round((Date.UTC(e.y,e.mo,e.d)-Date.UTC(e.y,0,1))/864e5)+1;return l.replace(mt,(c,i)=>{if(i!==void 0)return i;switch(c){case"YYYY":return String(e.y).padStart(4,"0");case"YY":return M(e.y%100);case"Q":return String(Math.floor(e.mo/3)+1);case"MMMM":return F(r,"month","long",e.mo);case"MMM":return F(r,"month","short",e.mo);case"MM":return M(e.mo+1);case"M":return String(e.mo+1);case"DDDD":return String(f).padStart(3,"0");case"DDD":return String(f);case"Do":return ft(e.d);case"DD":return M(e.d);case"D":return String(e.d);case"dddd":return F(r,"weekday","long",e.wd);case"ddd":return F(r,"weekday","short",e.wd);case"d":return String(e.wd);case"HH":return M(e.h);case"H":return String(e.h);case"hh":return M(s);case"h":return String(s);case"mm":return M(e.mi);case"m":return String(e.mi);case"ss":return M(e.s);case"s":return String(e.s);case"SSS":return String(e.ms).padStart(3,"0");case"SS":return M(Math.floor(e.ms/10));case"S":return String(Math.floor(e.ms/100));case"A":return e.h<12?"AM":"PM";case"a":return e.h<12?"am":"pm";case"ZZ":return B(e.offset,!1);case"Z":return B(e.offset,!0);case"X":return String(Math.floor(t.getTime()/1e3));default:return String(t.getTime())}})}const Mt=["january","february","march","april","may","june","july","august","september","october","november","december"],gt=/\[([^\]]*)]|YYYY|YY|MMMM|MMM|MM|M|Do|DD|D|dddd|ddd|HH|H|hh|h|mm|m|ss|s|SSS|A|a|ZZ|Z|X|x/g;function Dt(t,n){const e=[];let r="^\\s*",l=0;const s=D=>D.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+");for(const D of n.matchAll(gt)){if(r+=s(n.slice(l,D.index)),l=D.index+D[0].length,D[1]!==void 0){r+=s(D[1]);continue}const a=D[0];e.push(a),r+=a==="YYYY"?"(\\d{4})":a==="MMMM"||a==="MMM"||a==="dddd"||a==="ddd"?"([A-Za-z]+)\\.?":a==="Do"?"(\\d{1,2})(?:st|nd|rd|th)":a==="SSS"?"(\\d{1,3})":a==="A"||a==="a"?"([AaPp][Mm])":a==="Z"||a==="ZZ"?"(Z|[+-]\\d{2}:?\\d{2})":a==="X"||a==="x"?"(-?\\d+)":"(\\d{1,2})"}r+=`${s(n.slice(l))}\\s*$`;const f=new RegExp(r,"i").exec(t);if(!f)return null;let c=new Date().getFullYear(),i=0,m=1,g=0,y=0,E=0,A=0,$=null,Y=null;for(let D=0;D<e.length;D++){const a=e[D],T=f[D+1],p=Number(T);if(a==="X"||a==="x")return new Date(a==="X"?p*1e3:p);if(a==="YYYY")c=p;else if(a==="YY")c=p+(p<69?2e3:1900);else if(a==="MMMM"||a==="MMM"){const P=Mt.findIndex(et=>et.startsWith(T.toLowerCase().slice(0,3)));if(P<0)return null;i=P}else a==="MM"||a==="M"?i=p-1:a==="DD"||a==="D"||a==="Do"?m=p:a==="HH"||a==="H"||a==="hh"||a==="h"?g=p:a==="mm"||a==="m"?y=p:a==="ss"||a==="s"?E=p:a==="SSS"?A=Number(T.padEnd(3,"0")):a==="A"||a==="a"?$=T.toLowerCase()==="pm":(a==="Z"||a==="ZZ")&&(Y=T.toUpperCase()==="Z"?0:(T[0]==="-"?-1:1)*(Number(T.slice(1,3))*60+Number(T.slice(-2))))}if($!=null&&(g=g%12+($?12:0)),i<0||i>11||m<1||m>31||g>23||y>59||E>59)return null;const U=Y==null?new Date(c,i,m,g,y,E,A):new Date(Date.UTC(c,i,m,g,y,E,A)-Y*6e4);return Y==null&&U.getDate()!==m||Number.isNaN(U.getTime())?null:U}const C=new Map;function H(t,n=!1){const e=`${n?"g":""}|${t}`;let r=C.get(e);if(!r){const l=/^\(\?([ims]+)\)/.exec(t);r=new RegExp(l?t.slice(l[0].length):t,`${l?.[1]??""}${n?"g":""}`),C.size>200&&C.clear(),C.set(e,r)}return r.lastIndex=0,r}const Z="#ERROR",V=t=>`${t instanceof Date?"d":typeof t}:${u(t)}`;function pt(t,n,e){const r=n<0?t.length+n:Math.max(0,n-1),l=e==null?t.length:e<0?t.length+e+1:e;return t.slice(r,l)}function Q(t,n){const e=t<0?-1:1;let r=Math.ceil(Math.abs(t));return r%2===1!==n&&(r+=1),e*r}const J={IF:t=>w(t[0]??null)?t[1]??null:t[2]??null,AND:t=>d(t).every(w),OR:t=>d(t).some(w),NOT:t=>!w(t[0]??null),XOR:t=>d(t).filter(w).length%2===1,TRUE:()=>!0,FALSE:()=>!1,BLANK:()=>null,ERROR:()=>{throw new FormulaError("ERROR()")},ISERROR:t=>t[0]===Z,RECORD_ID:()=>null,CREATED_TIME:()=>null,LAST_MODIFIED_TIME:()=>null,SWITCH:t=>{for(let n=1;n+1<t.length;n+=2)if(u(t[0]??null)===u(t[n]??null))return t[n+1]??null;return t.length%2===0?t[t.length-1]??null:null},CONCATENATE:t=>t.map(u).join(""),LEN:t=>u(t[0]??null).length,UPPER:t=>u(t[0]??null).toUpperCase(),LOWER:t=>u(t[0]??null).toLowerCase(),TRIM:t=>u(t[0]??null).trim(),LEFT:t=>u(t[0]??null).slice(0,o(t[1]??1)),RIGHT:t=>{const n=u(t[0]??null),e=o(t[1]??1);return e<=0?"":n.slice(-e)},MID:t=>{const n=u(t[0]??null),e=Math.max(0,o(t[1]??1)-1);return t.length>2?n.slice(e,e+Math.max(0,o(t[2]??0))):n.slice(e)},FIND:t=>u(t[1]??null).indexOf(u(t[0]??null),Math.max(0,o(t[2]??1)-1))+1,SEARCH:t=>{const n=u(t[1]??null).indexOf(u(t[0]??null),Math.max(0,o(t[2]??1)-1));return n<0?null:n+1},SUBSTITUTE:t=>{const n=u(t[0]??null).split(u(t[1]??null));if(t.length<4)return n.join(u(t[2]??null));const e=o(t[3]??null);return n.reduce((r,l,s)=>s===0?l:r+u(s===e?t[2]??null:t[1]??null)+l,"")},REPLACE:t=>{const n=u(t[0]??null),e=Math.max(0,o(t[1]??1)-1);return n.slice(0,e)+u(t[3]??null)+n.slice(e+Math.max(0,o(t[2]??0)))},ENCODE_URL_COMPONENT:t=>encodeURIComponent(u(t[0]??null)),REGEX_MATCH:t=>H(u(t[1]??null)).test(u(t[0]??null)),REGEX_EXTRACT:t=>H(u(t[1]??null)).exec(u(t[0]??null))?.[0]??null,REGEX_REPLACE:t=>u(t[0]??null).replace(H(u(t[1]??null),!0),u(t[2]??null)),REPT:t=>u(t[0]??null).repeat(Math.max(0,Math.min(1e3,o(t[1]??0)))),T:t=>typeof t[0]=="string"?t[0]:"",VALUE:t=>{const n=u(t[0]??null).replace(/[^0-9.eE+-]/g,""),e=/\d/.test(n)?Number(n):NaN;return Number.isFinite(e)?e:null},ARRAYJOIN:t=>d([t[0]??null]).map(u).filter(Boolean).join(t.length>1?u(t[1]??null):", "),ARRAYCOMPACT:t=>d([t[0]??null]).filter(n=>n!=null&&n!==""),ARRAYFLATTEN:t=>t.flat(1/0),ARRAYUNIQUE:t=>{const n=new Set;return d([t[0]??null]).filter(e=>!n.has(V(e))&&!!n.add(V(e)))},ARRAYSLICE:t=>pt(d([t[0]??null]),o(t[1]??1),t.length>2?o(t[2]??null):void 0),SUM:t=>d(t).reduce((n,e)=>n+o(e),0),AVERAGE:t=>{const n=d(t).filter(e=>!S(e));return n.length?n.reduce((e,r)=>e+o(r),0)/n.length:null},MAX:t=>{const n=d(t).filter(e=>!S(e)).map(o);return n.length?nt(n):null},MIN:t=>{const n=d(t).filter(e=>!S(e)).map(o);return n.length?rt(n):null},COUNT:t=>d(t).filter(n=>typeof n=="number").length,COUNTA:t=>d(t).filter(n=>!S(n)).length,COUNTALL:t=>d(t).length,ROUND:t=>{const n=10**o(t[1]??0);return Math.round(o(t[0]??null)*n)/n},ROUNDUP:t=>{const n=10**o(t[1]??0),e=o(t[0]??null);return Math.sign(e)*Math.ceil(R(Math.abs(e)*n))/n},ROUNDDOWN:t=>{const n=10**o(t[1]??0),e=o(t[0]??null);return Math.sign(e)*Math.floor(R(Math.abs(e)*n))/n},INT:t=>Math.floor(o(t[0]??null)),ABS:t=>Math.abs(o(t[0]??null)),MOD:t=>o(t[0]??null)%o(t[1]??1),POWER:t=>o(t[0]??null)**o(t[1]??1),SQRT:t=>Math.sqrt(o(t[0]??null)),EXP:t=>Math.exp(o(t[0]??null)),LOG:t=>Math.log(o(t[0]??null))/Math.log(t.length>1?o(t[1]??null):10),EVEN:t=>Q(o(t[0]??null),!1),ODD:t=>Q(o(t[0]??null),!0),CEILING:t=>{const n=o(t[1]??1);return n===0?0:R(Math.ceil(R(o(t[0]??null)/n))*n)},FLOOR:t=>{const n=o(t[1]??1);return n===0?0:R(Math.floor(R(o(t[0]??null)/n))*n)},DISTANCE:t=>{const n=t.length>=4?k(`${u(t[0]??null)}, ${u(t[1]??null)}`):k(t[0]??null),e=t.length>=4?k(`${u(t[2]??null)}, ${u(t[3]??null)}`):k(t[1]??null);return n&&e?st(n,e):null},TODAY:()=>{const t=new Date;return t.setHours(0,0,0,0),t},NOW:()=>new Date,YEAR:t=>h(t[0]??null)?.getFullYear()??null,MONTH:t=>{const n=h(t[0]??null);return n?n.getMonth()+1:null},DAY:t=>h(t[0]??null)?.getDate()??null,HOUR:t=>h(t[0]??null)?.getHours()??null,MINUTE:t=>h(t[0]??null)?.getMinutes()??null,SECOND:t=>h(t[0]??null)?.getSeconds()??null,WEEKDAY:t=>{const n=h(t[0]??null);return n?/^mon/i.test(u(t[1]??null))?(n.getDay()+6)%7:n.getDay():null},WEEKNUM:t=>{const n=h(t[0]??null);if(!n)return null;const e=/^mon/i.test(u(t[1]??null))?1:0,r=new Date(n.getFullYear(),0,1),l=Math.round((L(new Date(n.getFullYear(),n.getMonth(),n.getDate()))-L(r))/864e5);return Math.floor((l+(r.getDay()-e+7)%7)/7)+1},DATEADD:t=>{const n=h(t[0]??null),e=t.length>2?I(t[2]??null):"d";return n&&e?ot(n,o(t[1]??0),e):null},DATETIME_DIFF:t=>{const n=h(t[0]??null),e=h(t[1]??null),r=t.length>2?I(t[2]??null):"s";return n&&e&&r?b(n,e,r):null},IS_BEFORE:t=>{const n=h(t[0]??null),e=h(t[1]??null);return!!n&&!!e&&n<e},IS_AFTER:t=>{const n=h(t[0]??null),e=h(t[1]??null);return!!n&&!!e&&n>e},IS_SAME:t=>{const n=h(t[0]??null),e=h(t[1]??null),r=t.length>2?I(t[2]??null):"ms";return!!n&&!!e&&!!r&&O(n,r)===O(e,r)},DATESTR:t=>{const n=h(t[0]??null);return n?N(n):null},TIMESTR:t=>{const n=h(t[0]??null);return n?`${M(n.getHours())}:${M(n.getMinutes())}:${M(n.getSeconds())}`:null},DATETIME_FORMAT:t=>{const n=h(t[0]??null);return n?dt(n,t.length>1&&!S(t[1]??null)?u(t[1]??null):"YYYY-MM-DDTHH:mm:ss.SSSZ"):null},DATETIME_PARSE:t=>t.length>1&&!S(t[1]??null)?Dt(u(t[0]??null),u(t[1]??null)):h(t[0]??null),SET_LOCALE:t=>{const n=h(t[0]??null),e=u(t[1]??null).trim();return!n||!e?n:j(n,{locale:Intl.DateTimeFormat.supportedLocalesOf(e)[0]??e})},SET_TIMEZONE:t=>{const n=h(t[0]??null),e=u(t[1]??null).trim();return!n||!e?n:(G(e),j(n,{zone:e}))},TONOW:t=>{const n=h(t[0]??null);return n?b(new Date(O(new Date,"d")),new Date(O(n,"d")),"d"):null},FROMNOW:t=>{const n=h(t[0]??null);return n?b(new Date(O(n,"d")),new Date(O(new Date,"d")),"d"):null},WORKDAY:t=>{const n=h(t[0]??null);if(!n)return null;const e=Math.trunc(o(t[1]??0)),r=e<0?-1:1,l=z(t[2]),s=new Date(n);for(let f=Math.abs(e),c=0;f>0;){if(++c>q)return null;s.setDate(s.getDate()+r),X(s,l)&&(f-=1)}return s},WORKDAY_DIFF:t=>{const n=h(t[0]??null),e=h(t[1]??null);if(!n||!e)return null;const r=z(t[2]),l=n>e?-1:1,s=new Date(l>0?n:e),f=N(l>0?e:n);let c=0;for(let i=0;N(s)<=f;i++){if(i>q)return null;X(s,r)&&(c+=1),s.setDate(s.getDate()+1)}return l*c}};function tt(t,n,e){switch(t){case"=":return n===e;case"!=":return n!==e;case"<":return n<e;case">":return n>e;case"<=":return n<=e;default:return n>=e}}const Tt=new Set(["DATEADD","DATETIME_DIFF","IS_SAME"]);export const FORMULA_FUNCTIONS=Object.keys(J).sort(),selfReferenceError=t=>new FormulaError(`A formula cannot read its own field {${t.trim()}}`);export function columnResolver(t,n=[]){const e=new Set(n.filter(r=>r!=null&&String(r).trim()!=="").map(r=>String(r).trim().toLowerCase()));return r=>{const l=r.trim().toLowerCase();if(e.has(l))throw selfReferenceError(r);const s=t.find(f=>String(f.header??"").trim().toLowerCase()===l||String(f.field??"").toLowerCase()===l);return s?String(s.field??s.id):null}}class St{constructor(n,e,r){this.toks=n,this.resolve=e,this.refs=r,this.i=0}peek(){return this.toks[this.i]}next(){return this.toks[this.i++]}expect(n,e){const r=this.next();if(!r||r.k!==n||e&&r.v!==e)throw new FormulaError(`Expected "${e??n}"${r?` at ${r.at+1}`:" at the end"}`);return r}parse(){const n=this.compare();if(this.peek())throw new FormulaError(`Unexpected "${this.peek().v}" at ${this.peek().at+1}`);return n}compare(){let n=this.concat();for(let e=this.peek();e&&e.k==="op"&&["=","!=","<",">","<=",">="].includes(e.v);e=this.peek()){this.next();const r=e.v,l=n,s=this.concat();n=f=>{const c=l(f),i=s(f);if(c instanceof Date||i instanceof Date){const E=h(c),A=h(i);return!E||!A?r==="!=":tt(r,E.getTime(),A.getTime())}const m=typeof c=="number"||typeof i=="number",g=m?o(c):u(c),y=m?o(i):u(i);return tt(r,g,y)}}return n}concat(){let n=this.add();for(;this.peek()?.k==="op"&&this.peek().v==="&";){this.next();const e=n,r=this.add();n=l=>u(e(l))+u(r(l))}return n}add(){let n=this.mul();for(let e=this.peek();e&&e.k==="op"&&(e.v==="+"||e.v==="-");e=this.peek()){this.next();const r=n,l=this.mul(),s=e.v==="+";n=f=>s?o(r(f))+o(l(f)):o(r(f))-o(l(f))}return n}mul(){let n=this.unary();for(let e=this.peek();e&&e.k==="op"&&(e.v==="*"||e.v==="/");e=this.peek()){this.next();const r=n,l=this.unary(),s=e.v==="*";n=f=>{if(s)return o(r(f))*o(l(f));const c=o(l(f));return c===0?null:o(r(f))/c}}return n}unary(){const n=this.peek();if(n?.k==="op"&&n.v==="-"){this.next();const e=this.unary();return r=>-o(e(r))}return this.primary()}primary(){const n=this.next();if(!n)throw new FormulaError("The formula ends too early");if(n.k==="num"){const e=Number(n.v);return()=>e}if(n.k==="str"){const e=n.v;return()=>e}if(n.k==="ref"){const e=this.resolve(n.v);if(e==null)throw new FormulaError(`No field named "${n.v}"`);return this.refs.add(e),r=>r?.[e]??null}if(n.k==="("){const e=this.compare();return this.expect(")"),e}if(n.k==="id"){const e=n.v.toUpperCase();if(e==="TRUE"&&this.peek()?.k!=="(")return()=>!0;if(e==="FALSE"&&this.peek()?.k!=="(")return()=>!1;const r=J[e];if(!r)throw new FormulaError(`Unknown function ${n.v}`);this.expect("(");const l=[],s=[],f=()=>{const i=this.i;l.push(this.compare());const m=this.i===i+1?this.toks[i]:void 0;s.push(m?.k==="str"?m.v:void 0)};if(this.peek()?.k!==")")for(f();this.peek()?.k===",";)this.next(),f();this.expect(")");const c=s[2];if(Tt.has(e)&&c!==void 0&&!I(c))throw new FormulaError(`Unknown unit "${c}" in ${e}: use ms, seconds, minutes, hours, days, weeks, months, quarters or years`);return e==="RECORD_ID"?i=>i?.id==null?null:String(i.id):e==="CREATED_TIME"?i=>h(i?.created_at??i?.createdTime??null):e==="LAST_MODIFIED_TIME"?i=>h(i?.updated_at??i?.lastModifiedTime??i?.created_at??i?.createdTime??null):e==="ISERROR"?i=>{try{const m=l[0]?.(i)??null;return m===Z||typeof m=="number"&&!Number.isFinite(m)}catch{return!0}}:e==="IF"?i=>w(l[0]?.(i)??null)?l[1]?.(i)??null:l[2]?.(i)??null:e==="SWITCH"?i=>{if(!l.length)return null;const m=u(l[0](i));for(let g=1;g+1<l.length;g+=2)if(m===u(l[g](i)))return l[g+1](i);return l.length%2===0?l[l.length-1](i):null}:i=>r(l.map(m=>m(i)))}throw new FormulaError(`Unexpected "${n.v}" at ${n.at+1}`)}}export function compileFormula(t,n){if(!t.trim())throw new FormulaError("The formula is empty");const e=new Set,r=new St(tokenize(t),n,e).parse();return{fn:l=>{try{const s=r(l);return typeof s=="number"&&!Number.isFinite(s)?null:s}catch(s){return s instanceof FormulaError?Z:null}},refs:[...e]}}export function renameFormulaRefs(t,n){let e;try{e=tokenize(t)}catch{return t}let r="",l=0;for(const s of e){if(s.k!=="ref")continue;const f=n(s.v);if(f==null)continue;const c=t.indexOf("}",s.at);r+=`${t.slice(l,s.at)}{${f}}`,l=c+1}return l?r+t.slice(l):t}export function formulaRefs(t,n){let e;try{e=tokenize(t)}catch{return[]}const r=new Set;for(const l of e)if(l.k==="ref")try{const s=n(l.v);s!=null&&r.add(s)}catch{}return[...r]}export function formulaReaders(t,n){const e=new Set([n.field,n.id].filter(l=>l!=null&&l!=="").map(String));if(!e.size)return[];const r=columnResolver(t);return t.filter(l=>l.fieldType!=="formula"||e.has(String(l.field??l.id??""))?!1:formulaRefs(String(l.fieldProps?.formula??""),r).some(s=>e.has(s)))}export function formulaError(t,n){try{return compileFormula(t,n),null}catch(e){return e instanceof FormulaError?e.message:"The formula is not valid"}}
@@ -23,7 +23,7 @@ export { baseFieldsFromSchema, baseTablesFromSchemas, baseSpecFromSchemas, baseT
23
23
  export { baseToSql, sqlName, type BaseToSqlOptions, type BaseTableComment, type BaseJunctionComment } from './base-sql.js';
24
24
  export { applyBaseComments, withInverses, type BaseComments } from './base-schema.js';
25
25
  export { restoreItems, trashLabel, type BaseTrashItem, type BaseTrashStore } from './base-trash.js';
26
- export { guessField, tableFromMatrix, recordsFromMatrix, matchColumns, type BaseImportResult, type ImportedField, type ImportReader } from './base-import.js';
26
+ export { guessField, tableFromMatrix, recordsFromMatrix, matchColumns, mergeByKey, type BaseImportResult, type ImportedField, type ImportReader } from './base-import.js';
27
27
  export { baseFromDatabase, describeDatabase, createBaseEndpoint, baseFromEndpoint, createBaseFeed, baseFromSupabase, isSecretColumn, type DatabaseOptions, type BaseEndpointOptions, type BaseFromEndpointOptions, type SupabaseBaseOptions, type SoftDeleteOption } from './base-connect.js';
28
28
  export { baseFromAirtable, airtableFormulaSupport, airtableColor, formulaFunctionsUsed, type AirtableSchema, type AirtableTable, type AirtableField, type AirtableView, type AirtableRecord, type AirtableRecords, type AirtableCollaborator, type AirtableImportOptions, type AirtableImport, type AirtableReportItem, type AirtableFormulaSupport, type AirtableFormulaStatus, type AirtableFormulaGroup } from './airtable.js';
29
29
  export { registerAutomationAction, listAutomationActions, MAX_DEPTH as AUTOMATION_MAX_DEPTH, type BaseAutomation, type AutomationTrigger, type AutomationAction, type AutomationRun, type AutomationStep, type AutomationActionContext, type RegisteredAutomationAction, type RunValues, REPEAT_MOST as AUTOMATION_REPEAT_MOST, allActions as allAutomationActions, scriptRecord, scriptInput, webhookValues, triggerValues, } from './automations.svelte.js';
@@ -1 +1 @@
1
- import{registerCellEditor as f,registerGridExtension as O,registerGridShortcuts as g}from"@svgrid/grid";import{nudgeEnterpriseFor as P}from"../license.js";import B from"./FieldCell.svelte";import L from"./RowAdder.svelte";import V from"./FootRowAdder.svelte";import H from"./AttachmentEditor.svelte";import N from"./FieldsHeaderEnd.svelte";import{askDeleteField as U,openFieldEditor as C,openRecord as _}from"./editor-request.svelte.js";import{enableAdvancedFilter as K,registerFilterKind as G}from"../advanced-filter-enable.js";import{compileFieldFilter as z,newCondition as h,resolveMeWith as $}from"./filter-model.js";import{hasBar as q,openBarPanel as w}from"./bar-request.svelte.js";import{groupRules as X,userSorts as W,writeSortState as j}from"./viewbar/sort-state.js";import{sortLabels as Y}from"./view-model.js";import{changesOf as J,noteChange as T}from"./activity.svelte.js";import{fieldUses as Q}from"./field-uses.js";import{getLinkedTable as Z}from"./sources.svelte.js";import{linkNames as ee,registerBaseCondition as oe}from"./base-alerts.js";import{duplicateField as re,hideField as ie,indexBeside as v,removeField as te}from"./field-ops.js";import{linkReaders as ne}from"./base-tables.js";import{viewOnlyItems as le}from"./base-share.js";import{canEditSchemaIn as se}from"./base-permissions.js";import{formulaReaders as de}from"./formula.js";import{BUILTIN_FIELD_TYPES as ae}from"./builtin-types.js";import{rowColorOf as me,rowColorRootClass as fe,tallRowClass as pe,rowMarkColor as ue,rowMarkLabel as ce}from"./row-colors.js";import{chooseRowColor as M}from"./row-color-choice.svelte.js";import{fieldPropsOf as x,fillFieldColumn as ge,getFieldType as A,isServerGroupRow as Ce,originalColumn as b,registerFieldType as be,ruleFieldNames as ye,typeDrawsCell as Fe}from"./registry.svelte.js";import he from"./RatingEditor.svelte";import we from"./LinkPickerEditor.svelte";import Te from"./DateEditor.svelte";import ve from"./SelectEditor.svelte";import Me from"./NumberEditor.svelte";import xe from"./LongTextEditor.svelte";import Ae from"./RichTextEditor.svelte";import Ee from"./VoteEditor.svelte";import ke from"./TimerEditor.svelte";import Se from"./ChecklistEditor.svelte";import Re from"./ColorEditor.svelte";import De from"./TimeOfDayEditor.svelte";import Ie from"./RowHeader.svelte";import Oe from"./GroupHeader.svelte";import Pe from"./SummaryCell.svelte";import{getCurrentUser as E}from"./sources.svelte.js";import{fieldColumns as Be,gridOf as y,primaryIdOf as F,rememberGrid as Le}from"./grid-access.js";import{bm as p}from"./messages.svelte.js";export{registerFieldType,getFieldType,listFieldTypes,fieldPropsOf,fillFieldColumn}from"./registry.svelte.js";export{linkHref,linkText}from"./links.js";export{setFieldUsers,getFieldUsers,setCurrentUser,getCurrentUser,registerLinkedTable,unregisterLinkedTable,getLinkedTable,listLinkedTables}from"./sources.svelte.js";export{canEditField,canPickChoice,defaultCanEditField,fieldEditorChoices,fieldEditors,setCanEditField,setFieldProtection}from"./field-access.svelte.js";export{FIELD_PREFIX,fieldToken,isFieldToken,personIds,recordOf,ruleFields,ruleNames,ruleUsers,tokenField}from"./people-rule.js";import{protectionText as Ve}from"./field-access.svelte.js";export{compileFormula,formulaError,FORMULA_FUNCTIONS,FormulaError}from"./formula.js";export{FORMULA_DOCS,syntaxArgs}from"./formula-docs.js";export{formatNumber,formatCurrency,formatPercent,formatDuration,parseDuration,formatDate}from"./format.js";export{timerRunning,timerSeconds,timerToggle,timerTotal}from"./timer.js";export{BRIGHT,OPTION_COLORS}from"./palette.js";export{convertValue,countCleared}from"./convert.js";export{openFieldEditor,closeFieldEditor,openRecord,closeRecord}from"./editor-request.svelte.js";export{setBarcodeScanner,barcodeScanSupported,scanBarcode}from"./barcode-scan.js";export{setDictation,dictationSupported,dictate}from"./dictation.svelte.js";export{default as SvBaseViewBar}from"./SvBaseViewBar.svelte";export{default as SvBaseForm}from"./SvBaseForm.svelte";export{default as SvBaseAutomations}from"./SvBaseAutomations.svelte";export{formPrefillLink,readFormPrefill}from"./form-logic.js";export{default as SvBase}from"./SvBase.svelte";export{addSubtasks,blankTable,newRecordId}from"./base-tables.js";export{baseSource,createBaseSync}from"./base-sync.js";export{baseFieldsFromSchema,baseTablesFromSchemas,baseSpecFromSchemas,baseTablesFromSpec}from"./base-schema.js";export{baseToSql,sqlName}from"./base-sql.js";export{applyBaseComments,withInverses}from"./base-schema.js";export{restoreItems,trashLabel}from"./base-trash.js";export{guessField,tableFromMatrix,recordsFromMatrix,matchColumns}from"./base-import.js";export{baseFromDatabase,describeDatabase,createBaseEndpoint,baseFromEndpoint,createBaseFeed,baseFromSupabase,isSecretColumn}from"./base-connect.js";export{baseFromAirtable,airtableFormulaSupport,airtableColor,formulaFunctionsUsed}from"./airtable.js";export{registerAutomationAction,listAutomationActions,MAX_DEPTH as AUTOMATION_MAX_DEPTH,REPEAT_MOST as AUTOMATION_REPEAT_MOST,allActions as allAutomationActions,scriptRecord,scriptInput,webhookValues,triggerValues}from"./automations.svelte.js";export{createAutomationServer}from"./automation-server.js";export{chatPayload,chatHostOk}from"./automation-outbound.js";export{runScript,SCRIPT_MAX_LENGTH}from"./automation-script.js";export{newWebhookToken}from"./automation-edit.js";export{setViewActions}from"./view-actions.js";export{setRecordActions}from"./record-actions.js";export{setAutomationDrafter}from"./automation-drafter.js";export{setRecordSeries,refreshRecordSeries}from"./record-series.svelte.js";export{cronWords}from"./cron-words.js";export{setRecordComments}from"./activity.svelte.js";export{setCommentSnippets}from"./comment-snippets.svelte.js";export{setFormSuggestions}from"./form-suggestions.svelte.js";export{setBaseMessages,baseMessages,BASE_MESSAGES}from"./messages.svelte.js";export{setDateLocale,dateLocale}from"../date-locale.js";export{setRecordHistory,historyOf,loadHistory}from"./activity.svelte.js";export{setMentionHandler}from"./activity.svelte.js";export{mentionToken,mentionIds,mentionText,parseMentions,encodeMentions}from"./mentions.js";export{baseCondition,baseFilterOf}from"./base-alerts.js";export{compileFieldFilter,describeFieldFilter,filterKindOf,operatorsFor,ME}from"./filter-model.js";export{BUILTIN_FIELD_TYPES}from"./builtin-types.js";export{setAttachmentUploader,setAttachmentSources,attachmentsFromText,attachmentsText,toAttachments}from"./attachments.js";const m={edit:"M4 20h4L19 9l-4-4L4 16zM14 6l4 4",left:"M10 6l-6 6 6 6M4 12h11M20 5v14",right:"M14 6l6 6-6 6M20 12H9M4 5v14",duplicate:"M8 8h12v12H8zM16 8V4H4v12h4",hide:"M3 3l18 18M10.6 10.6a2 2 0 0 0 2.8 2.8M9.9 5.1A9.8 9.8 0 0 1 12 5c5 0 9 5 10 7a13.4 13.4 0 0 1-3 3.9M6.6 6.6A13.5 13.5 0 0 0 2 12c1 2 5 7 10 7a9.6 9.6 0 0 0 4.4-1.1",remove:"M4 7h16M9 7V4h6v3M6 7l1 13h10l1-13",color:"M12 3l6 7a6.5 6.5 0 1 1-12 0l6-7z",filter:"M4 5h16l-6 7v6l-4 2v-8z",group:"M4 5h16M4 10h10M4 15h16M4 20h10",info:"M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18zM12 11v5M12 8h.01",lock:"M6 11h12v9H6zM8.5 11V8a3.5 3.5 0 0 1 7 0v3"};function He(o,r){const e=(o?.internalColumns??[]).find(d=>String(d.id??d.field)===r),i=e?.fieldType==="singleSelect"&&e.field?me(o)?.field===e.field?{key:"field-rowcolor",label:p("fields.menuStopColoring"),icon:m.color,run:()=>M(o,null)}:{key:"field-rowcolor",label:p("fields.menuColorRows"),icon:m.color,run:()=>M(o,{field:String(e.field),...o.props.rowColor?.target?{target:o.props.rowColor.target}:{}})}:null,t=F(o)===r,l=e&&q(o)?[...h(r,e)?[{key:"field-filter",label:p("fields.menuFilter"),icon:m.filter,separatorBefore:!0,run:()=>Ne(o,r,e)}]:[],...o.groupingControlsEnabled?[]:[{key:"field-group",label:p("fields.menuGroup"),icon:m.group,run:()=>Ue(o,r)}]]:[];return[...i?[i]:[],{key:"field-edit",label:p("fields.menuEdit"),icon:m.edit,run:()=>C({ctrl:o,mode:"edit",columnId:r})},...t?[]:[{key:"field-left",label:p("fields.menuInsertLeft"),icon:m.left,run:()=>C({ctrl:o,mode:"add",index:v(o,r,"left")})}],{key:"field-right",label:p("fields.menuInsertRight"),icon:m.right,run:()=>C({ctrl:o,mode:"add",index:v(o,r,"right")})},{key:"field-duplicate",label:p("fields.menuDuplicate"),icon:m.duplicate,run:()=>{o.props.baseRefuseDuplicate?.(r)||re(o,r)}},...t?[]:[{key:"field-move-left",label:p("fields.menuMoveLeft"),icon:m.left,disabled:!S(o,r,-1),run:()=>R(o,r,-1)},{key:"field-move-right",label:p("fields.menuMoveRight"),icon:m.right,disabled:!S(o,r,1),run:()=>R(o,r,1)}],...l,...Je(o,r,e),...t?[]:[{key:"field-hide",label:p("fields.menuHide"),icon:m.hide,run:()=>ie(o,r)},{key:"field-delete",label:p("fields.menuDelete"),icon:m.remove,separatorBefore:!0,run:()=>e?.fieldType==="link"&&(e.fieldProps?.inverse&&Z(e.fieldProps.table)||ne({columns:o.internalColumns},e).length)||e&&de(o.internalColumns??[],e).length||Q(o,e).length?U({ctrl:o,columnId:r}):te(o,r)}]]}function k(o,r,e){const i=(o.allColumns??[]).map(l=>l.id),t=i[i.indexOf(r)+e];if(!(!t||t===F(o)||o.isColumnPinned?.(t)!==o.isColumnPinned?.(r)))return t}const S=(o,r,e)=>!!k(o,r,e);function R(o,r,e){const i=k(o,r,e);if(!i)return;const t=o.allColumns.map(n=>n.id),l=t.indexOf(r),d=t.indexOf(i);t[l]=i,t[d]=r;const a=o.grid.getAllColumns().map(n=>n.id),s=o.userColumnOrder??[];o.moveColumnsByUser(je(s.length?[...s,...a.filter(n=>!s.includes(n))]:a,t))}function Ne(o,r,e){const i=h(r,e);if(!i)return;const t=o.advancedFilter,l=t?.kind==="fieldFilter"?t:{kind:"fieldFilter",conjunction:"and",conditions:[]};o.buildApi().setAdvancedFilter({...l,conditions:[...l.conditions,i]}),w(o,"filter")}function Ue(o,r){const e=X(o);e.some(i=>i.id===r)||j(o.buildApi(),[...e,{id:r,desc:!1}],W(o)),w(o,"group")}function D(o,r,e,i,t){if(!r)return;const l=E()?.id,d=i??o.buildApi?.().getRowId?.(r),a=(s,n)=>{d!=null&&!t&&o.editedCellValues&&(o.editedCellValues={...o.editedCellValues,[`${d}:${s}`]:n})};for(const s of o?.internalColumns??[]){if(s.fieldType!=="lastModifiedTime"&&s.fieldType!=="lastModifiedBy")continue;const n=String(s.id??s.field);if(n===e||!s.field)continue;const u=x(b(s));u.watch==="specific"&&!(u.watchFields??[]).includes(e)||(s.fieldType==="lastModifiedTime"?a(n,r[s.field]=new Date().toISOString()):l!==void 0&&a(n,r[s.field]=l))}}export function baseReviewApplied(o){return(r,e,i)=>{const t=y(typeof o=="function"?o():o);if(!t)return;const l=t.buildApi?.(),d=l?.getOption?.("getRowId"),a=new Map;(i??l?.getData?.()??[]).forEach((n,u)=>a.set(String(d?d(n,u):u),n));const s=new Map((t.allColumns??[]).map(n=>[n.columnDef?.field,n.id]));for(const n of r){const u=a.get(n.rowId),c=s.get(n.field);!u||!c||(D(t,u,c),T(t,n.rowId,c,u[n.field],void 0,e==="undo"?void 0:n.source.label))}}}function _e(o,r,e,i){if(!r)return;const t=(o?.allColumns??[]).find(c=>c.id===e)?.columnDef;if(!t?.field)return;const l=i??o.buildApi?.().getRowId?.(r);if(l==null)return;const d=String(l),a=r[t.field],s=o.history?.[o.historyPtr],n=[...J(o,d)].reverse().find(c=>c.columnId===e),u=s?.rowId===d&&s.columnId===e&&s.after===a?{from:s.before}:n?{from:n.value}:void 0;T(o,d,e,a,void 0,void 0,u)}function Ke(o,r){if(o.key!==" "||o.ctrlKey||o.metaKey||o.altKey||o.shiftKey||r.editing||!r.activeCell)return!1;const e=y(r.api);if(!e?.props?.expandRows)return!1;const i=(e.allColumns??[]).find(l=>l.id===r.activeCell.columnId);if(i?.columnDef.editorType==="checkbox"||i?.columnDef.editorType==="fieldVote")return!1;const t=(e.allRows??[])[r.activeCell.rowIndex];return!t||e.isGroupRow?.(t)||Ce(t.original)?!1:(o.preventDefault(),_({ctrl:e,rowId:t.id}),!0)}function Ge(o,r){if(o.key!=="Enter"&&o.key!==" "||o.ctrlKey||o.metaKey||o.altKey||o.shiftKey||r.editing||!r.activeCell)return!1;const e=y(r.api);if(!e?.props?.baseDeleteSelection)return!1;const{rowIndex:i,colIndex:t}=r.activeCell,l=e.allColumns?.[t]?.columnDef.editorType,d=l==="checkbox";if(o.key===" "&&!d&&l!=="fieldVote")return!1;const a=r.ranges.at(-1);return o.key==="Enter"&&(r.ranges.length>1||a&&(a[0]!==a[2]||a[1]!==a[3]))||!e.isCellEditableAt(i,t)?!1:(o.preventDefault(),d?(e.toggleBooleanCell(i,t),!0):(r.startEditing(i,t),!!e.editingCell))}import{baseGridKey as ze}from"./base-keys.svelte.js";import{treeGridKey as $e}from"./tree-edit.js";import{fillDownKey as qe}from"./base-fill.js";import{autoSumKey as Xe,formatKey as We}from"./excel-habits.svelte.js";import{orderKeepingScreen as je}from"./column-order.js";let I=!1;export function enableFields(){if(I)return;I=!0;for(const e of ae)A(e.id)||be(e);O({column:(e,i)=>ge(e,i),cell:B,hasCell:e=>Fe(e??{}),cellEdited:(e,i)=>{D(e,i.row,i.columnId,i.rowId,i.offGrid),_e(e,i.row,i.columnId,i.rowId),Ye(e,i.row,i.columnId,i.rowId)},rangeAction:(e,i)=>e.props?.baseRangeAction?.(i)===!0,bodyEnd:L,footEnd:V,rowMarkColor:(e,i)=>ue(e,i),rowMarkLabel:(e,i)=>ce(e,i),headerIcon:e=>e?.fieldType?A(e.fieldType)?.icon:null,headerNote:e=>{if(!e?.fieldType)return null;const i=typeof e.description=="string"?e.description:"",t=Ve(b(e),x(b(e)),ye(e));return t?{text:i?`${t} ${i}`:t,icon:m.lock}:i?{text:i,icon:m.info}:null},sortLabels:e=>e?.fieldType?Y(e):null,lockColumn:(e,i)=>F(e)===i,rowHeader:e=>e?.props?.expandRows?Ie:null,groupRow:e=>!e?.props?.rowModel&&Be(e).some(i=>i.fieldType)?Oe:null,summaryCell:e=>e?.props?.rowModel?null:Pe,rootClass:e=>{Le(e);const i=e?.advancedFilter?.kind==="fieldFilter"?"sv-fields-own-filter":"",t=i&&!e?.toolPanelEnabled&&!e?.chartingEnabled?"sv-fields-filter-only":"",l=e?.groupingColumns?.length?"sv-fields-grouped":"";return[fe(e),pe(e),i,t,l].filter(Boolean).join(" ")||null},headerEnd:N,columnMenuItems:(e,i)=>e?.props?.fieldMenu?le(e,He(e,i),!se(e)):[]});const o=e=>({value:e.value,typed:e.typed,columnDef:e.columnDef,columnId:e.columnId,row:e.row,onCommit:e.onCommit,onCancel:e.onCancel});f("fieldRating",{component:he,props:o,typeToEdit:e=>/^[0-9]$/.test(e)}),f("fieldLink",{component:we,props:o,typeToEdit:e=>e!==" "}),f("fieldNumber",{component:Me,props:e=>({...o(e),onCommitAndMove:e.onCommitAndMove,onCommitAndMoveDown:e.onCommitAndMoveDown}),typeToEdit:e=>/[0-9.,:+\-(=]/.test(e)}),f("fieldLongText",{component:xe,props:e=>({...o(e),onCommitAndMove:e.onCommitAndMove})}),f("fieldSelect",{component:ve,props:e=>({...o(e),grid:e.grid,onChange:e.onChange,onCommitAndMove:e.onCommitAndMove})}),f("attachment",{component:H,props:e=>({value:e.value,columnDef:e.columnDef,columnId:e.columnId,row:e.row,onCommit:e.onCommit,onCancel:e.onCancel}),typeToEdit:!1});const r=e=>({...o(e),onCommitAndMove:e.onCommitAndMove});f("fieldChecklist",{component:Se,props:r}),f("fieldRichText",{component:Ae,props:r}),f("fieldVote",{component:Ee,props:r,typeToEdit:e=>e===" "}),f("fieldTimer",{component:ke,props:e=>({...r(e),rowId:e.rowId,onCommitAndMoveDown:e.onCommitAndMoveDown}),typeToEdit:e=>e===" "||/[0-9:]/.test(e)}),f("fieldColor",{component:Re,props:r}),f("fieldTime",{component:De,props:e=>({...r(e),onCommitAndMoveDown:e.onCommitAndMoveDown}),typeToEdit:e=>/[0-9]/.test(e)}),f("fieldDate",{component:Te,props:e=>({...r(e),onCommitAndMoveDown:e.onCommitAndMoveDown}),typeToEdit:e=>/[0-9a-z]/i.test(e)}),G("fieldFilter",(e,i)=>z(e,i.getValue,ee)),$(()=>E()?.id),oe(),K(),g(Ke,{id:"svgrid-fields-space"}),g(ze,{id:"svgrid-fields-keys"}),g(Ge,{id:"svgrid-base-keys"}),g(qe,{id:"svgrid-base-fill-down"}),g(Xe,{id:"svgrid-base-autosum",priority:200}),g(We,{id:"svgrid-base-format-keys",priority:200}),g($e,{id:"svgrid-base-tree"}),P("base","SvGrid Base")}export{inboxRecords,listColumns,listGroups,viewRecords}from"./list-view.js";import{aiFieldEdited as Ye,aiFieldMenuItems as Je}from"./ai-field.svelte.js";export{generateAIField,regenerateAIFields,cancelAIField,pendingAIField,setAIFieldConcurrency}from"./ai-field.svelte.js";export{aiPromptError,readAIAnswer}from"./ai-prompt.js";export{moveTile,newTile,putTile,removeTile,tileResult,tileRows,tileTitle}from"./dashboard.js";export{sharedTables,sharedViews,shareOf}from"./base-share.js";export{recordsAsShown,downloadAsShown,filesFolders,safeFolder}from"./base-export.js";export{permittedTables,permittedRecords,permittedViews,tablePermissions,gridPermissions,canDeleteRecord}from"./base-permissions.js";export{computeRecords,computeRecord,computedValues,computedFields,evaluateFilter,filterRecords}from"./base-compute.js";export{queryRecords,fieldFilterToSql,fieldFilterToPostgrest,supabaseFieldFilter,viewFilterOf}from"./base-query.js";export{searchBase}from"./base-search.js";export{toChecklist,parseChecklist,checklistText,checklistProgress}from"./checklist.js";export{parseColor}from"./color-value.js";export{parseTimeOfDay,formatTimeOfDay,timeSeconds}from"./time-of-day.js";
1
+ import{registerCellEditor as f,registerGridExtension as O,registerGridShortcuts as g}from"@svgrid/grid";import{nudgeEnterpriseFor as B}from"../license.js";import P from"./FieldCell.svelte";import L from"./RowAdder.svelte";import V from"./FootRowAdder.svelte";import H from"./AttachmentEditor.svelte";import K from"./FieldsHeaderEnd.svelte";import{askDeleteField as N,openFieldEditor as C,openRecord as U}from"./editor-request.svelte.js";import{enableAdvancedFilter as _,registerFilterKind as G}from"../advanced-filter-enable.js";import{compileFieldFilter as z,newCondition as h,resolveMeWith as $}from"./filter-model.js";import{hasBar as q,openBarPanel as w}from"./bar-request.svelte.js";import{groupRules as X,userSorts as W,writeSortState as j}from"./viewbar/sort-state.js";import{sortLabels as Y}from"./view-model.js";import{changesOf as J,noteChange as T}from"./activity.svelte.js";import{fieldUses as Q}from"./field-uses.js";import{getLinkedTable as Z}from"./sources.svelte.js";import{linkNames as ee,registerBaseCondition as oe}from"./base-alerts.js";import{duplicateField as re,hideField as ie,indexBeside as v,removeField as te}from"./field-ops.js";import{linkReaders as ne}from"./base-tables.js";import{viewOnlyItems as le}from"./base-share.js";import{canEditSchemaIn as se}from"./base-permissions.js";import{formulaReaders as de}from"./formula.js";import{BUILTIN_FIELD_TYPES as ae}from"./builtin-types.js";import{rowColorOf as me,rowColorRootClass as fe,tallRowClass as pe,rowMarkColor as ue,rowMarkLabel as ce}from"./row-colors.js";import{chooseRowColor as M}from"./row-color-choice.svelte.js";import{fieldPropsOf as x,fillFieldColumn as ge,getFieldType as A,isServerGroupRow as Ce,originalColumn as b,registerFieldType as be,ruleFieldNames as ye,typeDrawsCell as Fe}from"./registry.svelte.js";import he from"./RatingEditor.svelte";import we from"./LinkPickerEditor.svelte";import Te from"./DateEditor.svelte";import ve from"./SelectEditor.svelte";import Me from"./NumberEditor.svelte";import xe from"./LongTextEditor.svelte";import Ae from"./RichTextEditor.svelte";import Ee from"./VoteEditor.svelte";import ke from"./TimerEditor.svelte";import Se from"./ChecklistEditor.svelte";import Re from"./ColorEditor.svelte";import De from"./TimeOfDayEditor.svelte";import Ie from"./RowHeader.svelte";import Oe from"./GroupHeader.svelte";import Be from"./SummaryCell.svelte";import{getCurrentUser as E}from"./sources.svelte.js";import{fieldColumns as Pe,gridOf as y,primaryIdOf as F,rememberGrid as Le}from"./grid-access.js";import{bm as p}from"./messages.svelte.js";export{registerFieldType,getFieldType,listFieldTypes,fieldPropsOf,fillFieldColumn}from"./registry.svelte.js";export{linkHref,linkText}from"./links.js";export{setFieldUsers,getFieldUsers,setCurrentUser,getCurrentUser,registerLinkedTable,unregisterLinkedTable,getLinkedTable,listLinkedTables}from"./sources.svelte.js";export{canEditField,canPickChoice,defaultCanEditField,fieldEditorChoices,fieldEditors,setCanEditField,setFieldProtection}from"./field-access.svelte.js";export{FIELD_PREFIX,fieldToken,isFieldToken,personIds,recordOf,ruleFields,ruleNames,ruleUsers,tokenField}from"./people-rule.js";import{protectionText as Ve}from"./field-access.svelte.js";export{compileFormula,formulaError,FORMULA_FUNCTIONS,FormulaError}from"./formula.js";export{FORMULA_DOCS,syntaxArgs}from"./formula-docs.js";export{formatNumber,formatCurrency,formatPercent,formatDuration,parseDuration,formatDate}from"./format.js";export{timerRunning,timerSeconds,timerToggle,timerTotal}from"./timer.js";export{BRIGHT,OPTION_COLORS}from"./palette.js";export{convertValue,countCleared}from"./convert.js";export{openFieldEditor,closeFieldEditor,openRecord,closeRecord}from"./editor-request.svelte.js";export{setBarcodeScanner,barcodeScanSupported,scanBarcode}from"./barcode-scan.js";export{setDictation,dictationSupported,dictate}from"./dictation.svelte.js";export{default as SvBaseViewBar}from"./SvBaseViewBar.svelte";export{default as SvBaseForm}from"./SvBaseForm.svelte";export{default as SvBaseAutomations}from"./SvBaseAutomations.svelte";export{formPrefillLink,readFormPrefill}from"./form-logic.js";export{default as SvBase}from"./SvBase.svelte";export{addSubtasks,blankTable,newRecordId}from"./base-tables.js";export{baseSource,createBaseSync}from"./base-sync.js";export{baseFieldsFromSchema,baseTablesFromSchemas,baseSpecFromSchemas,baseTablesFromSpec}from"./base-schema.js";export{baseToSql,sqlName}from"./base-sql.js";export{applyBaseComments,withInverses}from"./base-schema.js";export{restoreItems,trashLabel}from"./base-trash.js";export{guessField,tableFromMatrix,recordsFromMatrix,matchColumns,mergeByKey}from"./base-import.js";export{baseFromDatabase,describeDatabase,createBaseEndpoint,baseFromEndpoint,createBaseFeed,baseFromSupabase,isSecretColumn}from"./base-connect.js";export{baseFromAirtable,airtableFormulaSupport,airtableColor,formulaFunctionsUsed}from"./airtable.js";export{registerAutomationAction,listAutomationActions,MAX_DEPTH as AUTOMATION_MAX_DEPTH,REPEAT_MOST as AUTOMATION_REPEAT_MOST,allActions as allAutomationActions,scriptRecord,scriptInput,webhookValues,triggerValues}from"./automations.svelte.js";export{createAutomationServer}from"./automation-server.js";export{chatPayload,chatHostOk}from"./automation-outbound.js";export{runScript,SCRIPT_MAX_LENGTH}from"./automation-script.js";export{newWebhookToken}from"./automation-edit.js";export{setViewActions}from"./view-actions.js";export{setRecordActions}from"./record-actions.js";export{setAutomationDrafter}from"./automation-drafter.js";export{setRecordSeries,refreshRecordSeries}from"./record-series.svelte.js";export{cronWords}from"./cron-words.js";export{setRecordComments}from"./activity.svelte.js";export{setCommentSnippets}from"./comment-snippets.svelte.js";export{setFormSuggestions}from"./form-suggestions.svelte.js";export{setBaseMessages,baseMessages,BASE_MESSAGES}from"./messages.svelte.js";export{setDateLocale,dateLocale}from"../date-locale.js";export{setRecordHistory,historyOf,loadHistory}from"./activity.svelte.js";export{setMentionHandler}from"./activity.svelte.js";export{mentionToken,mentionIds,mentionText,parseMentions,encodeMentions}from"./mentions.js";export{baseCondition,baseFilterOf}from"./base-alerts.js";export{compileFieldFilter,describeFieldFilter,filterKindOf,operatorsFor,ME}from"./filter-model.js";export{BUILTIN_FIELD_TYPES}from"./builtin-types.js";export{setAttachmentUploader,setAttachmentSources,attachmentsFromText,attachmentsText,toAttachments}from"./attachments.js";const m={edit:"M4 20h4L19 9l-4-4L4 16zM14 6l4 4",left:"M10 6l-6 6 6 6M4 12h11M20 5v14",right:"M14 6l6 6-6 6M20 12H9M4 5v14",duplicate:"M8 8h12v12H8zM16 8V4H4v12h4",hide:"M3 3l18 18M10.6 10.6a2 2 0 0 0 2.8 2.8M9.9 5.1A9.8 9.8 0 0 1 12 5c5 0 9 5 10 7a13.4 13.4 0 0 1-3 3.9M6.6 6.6A13.5 13.5 0 0 0 2 12c1 2 5 7 10 7a9.6 9.6 0 0 0 4.4-1.1",remove:"M4 7h16M9 7V4h6v3M6 7l1 13h10l1-13",color:"M12 3l6 7a6.5 6.5 0 1 1-12 0l6-7z",filter:"M4 5h16l-6 7v6l-4 2v-8z",group:"M4 5h16M4 10h10M4 15h16M4 20h10",info:"M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18zM12 11v5M12 8h.01",lock:"M6 11h12v9H6zM8.5 11V8a3.5 3.5 0 0 1 7 0v3"};function He(o,r){const e=(o?.internalColumns??[]).find(d=>String(d.id??d.field)===r),i=e?.fieldType==="singleSelect"&&e.field?me(o)?.field===e.field?{key:"field-rowcolor",label:p("fields.menuStopColoring"),icon:m.color,run:()=>M(o,null)}:{key:"field-rowcolor",label:p("fields.menuColorRows"),icon:m.color,run:()=>M(o,{field:String(e.field),...o.props.rowColor?.target?{target:o.props.rowColor.target}:{}})}:null,t=F(o)===r,l=e&&q(o)?[...h(r,e)?[{key:"field-filter",label:p("fields.menuFilter"),icon:m.filter,separatorBefore:!0,run:()=>Ke(o,r,e)}]:[],...o.groupingControlsEnabled?[]:[{key:"field-group",label:p("fields.menuGroup"),icon:m.group,run:()=>Ne(o,r)}]]:[];return[...i?[i]:[],{key:"field-edit",label:p("fields.menuEdit"),icon:m.edit,run:()=>C({ctrl:o,mode:"edit",columnId:r})},...t?[]:[{key:"field-left",label:p("fields.menuInsertLeft"),icon:m.left,run:()=>C({ctrl:o,mode:"add",index:v(o,r,"left")})}],{key:"field-right",label:p("fields.menuInsertRight"),icon:m.right,run:()=>C({ctrl:o,mode:"add",index:v(o,r,"right")})},{key:"field-duplicate",label:p("fields.menuDuplicate"),icon:m.duplicate,run:()=>{o.props.baseRefuseDuplicate?.(r)||re(o,r)}},...t?[]:[{key:"field-move-left",label:p("fields.menuMoveLeft"),icon:m.left,disabled:!S(o,r,-1),run:()=>R(o,r,-1)},{key:"field-move-right",label:p("fields.menuMoveRight"),icon:m.right,disabled:!S(o,r,1),run:()=>R(o,r,1)}],...l,...Je(o,r,e),...t?[]:[{key:"field-hide",label:p("fields.menuHide"),icon:m.hide,run:()=>ie(o,r)},{key:"field-delete",label:p("fields.menuDelete"),icon:m.remove,separatorBefore:!0,run:()=>e?.fieldType==="link"&&(e.fieldProps?.inverse&&Z(e.fieldProps.table)||ne({columns:o.internalColumns},e).length)||e&&de(o.internalColumns??[],e).length||Q(o,e).length?N({ctrl:o,columnId:r}):te(o,r)}]]}function k(o,r,e){const i=(o.allColumns??[]).map(l=>l.id),t=i[i.indexOf(r)+e];if(!(!t||t===F(o)||o.isColumnPinned?.(t)!==o.isColumnPinned?.(r)))return t}const S=(o,r,e)=>!!k(o,r,e);function R(o,r,e){const i=k(o,r,e);if(!i)return;const t=o.allColumns.map(n=>n.id),l=t.indexOf(r),d=t.indexOf(i);t[l]=i,t[d]=r;const a=o.grid.getAllColumns().map(n=>n.id),s=o.userColumnOrder??[];o.moveColumnsByUser(je(s.length?[...s,...a.filter(n=>!s.includes(n))]:a,t))}function Ke(o,r,e){const i=h(r,e);if(!i)return;const t=o.advancedFilter,l=t?.kind==="fieldFilter"?t:{kind:"fieldFilter",conjunction:"and",conditions:[]};o.buildApi().setAdvancedFilter({...l,conditions:[...l.conditions,i]}),w(o,"filter")}function Ne(o,r){const e=X(o);e.some(i=>i.id===r)||j(o.buildApi(),[...e,{id:r,desc:!1}],W(o)),w(o,"group")}function D(o,r,e,i,t){if(!r)return;const l=E()?.id,d=i??o.buildApi?.().getRowId?.(r),a=(s,n)=>{d!=null&&!t&&o.editedCellValues&&(o.editedCellValues={...o.editedCellValues,[`${d}:${s}`]:n})};for(const s of o?.internalColumns??[]){if(s.fieldType!=="lastModifiedTime"&&s.fieldType!=="lastModifiedBy")continue;const n=String(s.id??s.field);if(n===e||!s.field)continue;const u=x(b(s));u.watch==="specific"&&!(u.watchFields??[]).includes(e)||(s.fieldType==="lastModifiedTime"?a(n,r[s.field]=new Date().toISOString()):l!==void 0&&a(n,r[s.field]=l))}}export function baseReviewApplied(o){return(r,e,i)=>{const t=y(typeof o=="function"?o():o);if(!t)return;const l=t.buildApi?.(),d=l?.getOption?.("getRowId"),a=new Map;(i??l?.getData?.()??[]).forEach((n,u)=>a.set(String(d?d(n,u):u),n));const s=new Map((t.allColumns??[]).map(n=>[n.columnDef?.field,n.id]));for(const n of r){const u=a.get(n.rowId),c=s.get(n.field);!u||!c||(D(t,u,c),T(t,n.rowId,c,u[n.field],void 0,e==="undo"?void 0:n.source.label))}}}function Ue(o,r,e,i){if(!r)return;const t=(o?.allColumns??[]).find(c=>c.id===e)?.columnDef;if(!t?.field)return;const l=i??o.buildApi?.().getRowId?.(r);if(l==null)return;const d=String(l),a=r[t.field],s=o.history?.[o.historyPtr],n=[...J(o,d)].reverse().find(c=>c.columnId===e),u=s?.rowId===d&&s.columnId===e&&s.after===a?{from:s.before}:n?{from:n.value}:void 0;T(o,d,e,a,void 0,void 0,u)}function _e(o,r){if(o.key!==" "||o.ctrlKey||o.metaKey||o.altKey||o.shiftKey||r.editing||!r.activeCell)return!1;const e=y(r.api);if(!e?.props?.expandRows)return!1;const i=(e.allColumns??[]).find(l=>l.id===r.activeCell.columnId);if(i?.columnDef.editorType==="checkbox"||i?.columnDef.editorType==="fieldVote")return!1;const t=(e.allRows??[])[r.activeCell.rowIndex];return!t||e.isGroupRow?.(t)||Ce(t.original)?!1:(o.preventDefault(),U({ctrl:e,rowId:t.id}),!0)}function Ge(o,r){if(o.key!=="Enter"&&o.key!==" "||o.ctrlKey||o.metaKey||o.altKey||o.shiftKey||r.editing||!r.activeCell)return!1;const e=y(r.api);if(!e?.props?.baseDeleteSelection)return!1;const{rowIndex:i,colIndex:t}=r.activeCell,l=e.allColumns?.[t]?.columnDef.editorType,d=l==="checkbox";if(o.key===" "&&!d&&l!=="fieldVote")return!1;const a=r.ranges.at(-1);return o.key==="Enter"&&(r.ranges.length>1||a&&(a[0]!==a[2]||a[1]!==a[3]))||!e.isCellEditableAt(i,t)?!1:(o.preventDefault(),d?(e.toggleBooleanCell(i,t),!0):(r.startEditing(i,t),!!e.editingCell))}import{baseGridKey as ze}from"./base-keys.svelte.js";import{treeGridKey as $e}from"./tree-edit.js";import{fillDownKey as qe}from"./base-fill.js";import{autoSumKey as Xe,formatKey as We}from"./excel-habits.svelte.js";import{orderKeepingScreen as je}from"./column-order.js";let I=!1;export function enableFields(){if(I)return;I=!0;for(const e of ae)A(e.id)||be(e);O({column:(e,i)=>ge(e,i),cell:P,hasCell:e=>Fe(e??{}),cellEdited:(e,i)=>{D(e,i.row,i.columnId,i.rowId,i.offGrid),Ue(e,i.row,i.columnId,i.rowId),Ye(e,i.row,i.columnId,i.rowId)},rangeAction:(e,i)=>e.props?.baseRangeAction?.(i)===!0,bodyEnd:L,footEnd:V,rowMarkColor:(e,i)=>ue(e,i),rowMarkLabel:(e,i)=>ce(e,i),headerIcon:e=>e?.fieldType?A(e.fieldType)?.icon:null,headerNote:e=>{if(!e?.fieldType)return null;const i=typeof e.description=="string"?e.description:"",t=Ve(b(e),x(b(e)),ye(e));return t?{text:i?`${t} ${i}`:t,icon:m.lock}:i?{text:i,icon:m.info}:null},sortLabels:e=>e?.fieldType?Y(e):null,lockColumn:(e,i)=>F(e)===i,rowHeader:e=>e?.props?.expandRows?Ie:null,groupRow:e=>!e?.props?.rowModel&&Pe(e).some(i=>i.fieldType)?Oe:null,summaryCell:e=>e?.props?.rowModel?null:Be,rootClass:e=>{Le(e);const i=e?.advancedFilter?.kind==="fieldFilter"?"sv-fields-own-filter":"",t=i&&!e?.toolPanelEnabled&&!e?.chartingEnabled?"sv-fields-filter-only":"",l=e?.groupingColumns?.length?"sv-fields-grouped":"";return[fe(e),pe(e),i,t,l].filter(Boolean).join(" ")||null},headerEnd:K,columnMenuItems:(e,i)=>e?.props?.fieldMenu?le(e,He(e,i),!se(e)):[]});const o=e=>({value:e.value,typed:e.typed,columnDef:e.columnDef,columnId:e.columnId,row:e.row,onCommit:e.onCommit,onCancel:e.onCancel});f("fieldRating",{component:he,props:o,typeToEdit:e=>/^[0-9]$/.test(e)}),f("fieldLink",{component:we,props:o,typeToEdit:e=>e!==" "}),f("fieldNumber",{component:Me,props:e=>({...o(e),onCommitAndMove:e.onCommitAndMove,onCommitAndMoveDown:e.onCommitAndMoveDown}),typeToEdit:e=>/[0-9.,:+\-(=]/.test(e)}),f("fieldLongText",{component:xe,props:e=>({...o(e),onCommitAndMove:e.onCommitAndMove})}),f("fieldSelect",{component:ve,props:e=>({...o(e),grid:e.grid,onChange:e.onChange,onCommitAndMove:e.onCommitAndMove})}),f("attachment",{component:H,props:e=>({value:e.value,columnDef:e.columnDef,columnId:e.columnId,row:e.row,onCommit:e.onCommit,onCancel:e.onCancel}),typeToEdit:!1});const r=e=>({...o(e),onCommitAndMove:e.onCommitAndMove});f("fieldChecklist",{component:Se,props:r}),f("fieldRichText",{component:Ae,props:r}),f("fieldVote",{component:Ee,props:r,typeToEdit:e=>e===" "}),f("fieldTimer",{component:ke,props:e=>({...r(e),rowId:e.rowId,onCommitAndMoveDown:e.onCommitAndMoveDown}),typeToEdit:e=>e===" "||/[0-9:]/.test(e)}),f("fieldColor",{component:Re,props:r}),f("fieldTime",{component:De,props:e=>({...r(e),onCommitAndMoveDown:e.onCommitAndMoveDown}),typeToEdit:e=>/[0-9]/.test(e)}),f("fieldDate",{component:Te,props:e=>({...r(e),onCommitAndMoveDown:e.onCommitAndMoveDown}),typeToEdit:e=>/[0-9a-z]/i.test(e)}),G("fieldFilter",(e,i)=>z(e,i.getValue,ee)),$(()=>E()?.id),oe(),_(),g(_e,{id:"svgrid-fields-space"}),g(ze,{id:"svgrid-fields-keys"}),g(Ge,{id:"svgrid-base-keys"}),g(qe,{id:"svgrid-base-fill-down"}),g(Xe,{id:"svgrid-base-autosum",priority:200}),g(We,{id:"svgrid-base-format-keys",priority:200}),g($e,{id:"svgrid-base-tree"}),B("base","SvGrid Base")}export{inboxRecords,listColumns,listGroups,viewRecords}from"./list-view.js";import{aiFieldEdited as Ye,aiFieldMenuItems as Je}from"./ai-field.svelte.js";export{generateAIField,regenerateAIFields,cancelAIField,pendingAIField,setAIFieldConcurrency}from"./ai-field.svelte.js";export{aiPromptError,readAIAnswer}from"./ai-prompt.js";export{moveTile,newTile,putTile,removeTile,tileResult,tileRows,tileTitle}from"./dashboard.js";export{sharedTables,sharedViews,shareOf}from"./base-share.js";export{recordsAsShown,downloadAsShown,filesFolders,safeFolder}from"./base-export.js";export{permittedTables,permittedRecords,permittedViews,tablePermissions,gridPermissions,canDeleteRecord}from"./base-permissions.js";export{computeRecords,computeRecord,computedValues,computedFields,evaluateFilter,filterRecords}from"./base-compute.js";export{queryRecords,fieldFilterToSql,fieldFilterToPostgrest,supabaseFieldFilter,viewFilterOf}from"./base-query.js";export{searchBase}from"./base-search.js";export{toChecklist,parseChecklist,checklistText,checklistProgress}from"./checklist.js";export{parseColor}from"./color-value.js";export{parseTimeOfDay,formatTimeOfDay,timeSeconds}from"./time-of-day.js";
@@ -180,6 +180,24 @@ export declare const EXTRAS_MESSAGES: {
180
180
  readonly 'extras.delete': "Delete";
181
181
  readonly 'extras.keep': "Keep";
182
182
  readonly 'extras.deleteAutomation': "Delete automation";
183
+ readonly 'extras.triggerEntersView': "A record enters a view";
184
+ readonly 'extras.view': "View";
185
+ readonly 'extras.pickView': "Pick a view";
186
+ readonly 'extras.aView': "a view";
187
+ readonly 'extras.entersViewHint': "Runs once when a record starts to show in this view, through its filter, as the view has it then. It runs again only after the record has left the view.";
188
+ readonly 'extras.addViewFilterFirst': "First give a view of this table a filter: this trigger runs when a record starts to show in it.";
189
+ readonly 'extras.whenEntersView': "When a record enters {view}";
190
+ readonly 'extras.whenEntersViewWhere': "When a record enters {view}, where {condition}";
191
+ readonly 'extras.doDeleteRecord': "Delete the record";
192
+ readonly 'extras.actionDeleteRecord': "Delete record";
193
+ readonly 'extras.deleteRecordHint': "Deletes the record that started the automation (inside Find records, each record found). It goes to the trash, where it can be restored for 30 days.";
194
+ readonly 'extras.noRecordToDelete': "No record to delete";
195
+ readonly 'extras.deletedRecord': "Deleted {name}";
196
+ readonly 'extras.cannotDeleteHere': "This table cannot delete records from an automation.";
197
+ readonly 'extras.summaryDelete': "Deletes the record";
198
+ readonly 'extras.duplicateAutomation': "Duplicate";
199
+ readonly 'extras.copyOf': "{name} copy";
200
+ readonly 'extras.duplicated': "Copied. The copy is off until you turn it on.";
183
201
  readonly 'extras.runsOnServer': "Runs on your server when its trigger happens.";
184
202
  readonly 'extras.tryRecord': "Record to try it on";
185
203
  readonly 'extras.noRecord': "No record";
@@ -1 +1 @@
1
- export const EXTRAS_MESSAGES={"extras.whenCreated":"When a record is created","extras.whenCreatedWhere":"When a record is created, where {condition}","extras.whenRecordChanges":"When a record changes","extras.whenRecordChangesWhere":"When a record changes, where {condition}","extras.whenFieldsChange":"When {fields} changes","extras.whenFieldsChangeWhere":"When {fields} changes, where {condition}","extras.fieldsOr":" or ","extras.whenMatches":"When a record matches: {condition}","extras.noConditionYet":"no condition yet","extras.whenForm":"When a form is sent","extras.whenFormWhere":"When a form is sent, where {condition}","extras.whenPressed":"When {field} is pressed","extras.onSchedule":"{cron}","extras.onScheduleWhere":"{cron}, for records where {condition}","extras.cronOther":"On a schedule ({cron})","extras.cronEveryMinute":"Every minute","extras.cronEveryMinutes":"Every {n} minutes","extras.cronHourly":"Every hour, on the hour","extras.cronHourlyAt":"Every hour at {minute} past","extras.cronDaily":"Every day at {time}","extras.cronWeekdays":"Every weekday at {time}","extras.cronWeekly0":"Every Sunday at {time}","extras.cronWeekly1":"Every Monday at {time}","extras.cronWeekly2":"Every Tuesday at {time}","extras.cronWeekly3":"Every Wednesday at {time}","extras.cronWeekly4":"Every Thursday at {time}","extras.cronWeekly5":"Every Friday at {time}","extras.cronWeekly6":"Every Saturday at {time}","extras.cronDays":"Every {days} at {time}","extras.cronDay0":"Sunday","extras.cronDay1":"Monday","extras.cronDay2":"Tuesday","extras.cronDay3":"Wednesday","extras.cronDay4":"Thursday","extras.cronDay5":"Friday","extras.cronDay6":"Saturday","extras.cronMonthly":"Day {day} of every month at {time}","extras.actionUpdateRecord":"Update record","extras.actionCreateRecord":"Create record","extras.actionNotify":"Show a notice","extras.actionHighlight":"Color the record","extras.actionWebhook":"Call a webhook","extras.actionEmail":"Send an email","extras.stepStopped":"Stopped","extras.stepLoop":"Automations set each other off {max} times in a row; this one did not run, so they cannot loop.","extras.stepNotice":"Notice","extras.stepWebhook":"Webhook","extras.stepEmail":"Email","extras.stepNotRun":"Not run","extras.stepNoMatch":"The record does not match the condition","extras.stepDone":"Done","extras.noRecordToUpdate":"No record to update","extras.alreadySet":"Already set","extras.noTable":'No table "{table}"',"extras.noAction":'No action "{action}" is registered',"extras.aRecord":"a record","extras.createdIn":"{name} in {table}","extras.saidValue":"{field}: {value}","extras.saidChecked":"{field}: checked","extras.saidUnchecked":"{field}: unchecked","extras.saidEmpty":"empty","extras.title":"Automations in {table}","extras.listLabel":"Automations","extras.untitled":"Untitled","extras.switchOn":"{name} on","extras.noAutomations":"No automations yet. An automation does something when a record is added, changes or matches a condition.","extras.addAutomation":"+ New automation","extras.describeLabel":"Describe what should happen","extras.describePlaceholder":"For example: every Monday at 8:00, e-mail me the tasks that are not done","extras.describeButton":"Draft it","extras.describing":"Drafting...","extras.describeAgain":"Say a little more about what should happen, then try again.","extras.drafted":"Drafted from your words and switched off. Check each part, then switch it on.","extras.newAutomation":"New automation","extras.newRecordMessage":"New record: {{field}}","extras.nameFallback":"Name","extras.runs":"Runs","extras.clearRuns":"Clear this page's runs","extras.serverRunsFailed":"The server's runs did not load: {message}","extras.statusDone":"Done","extras.statusFailed":"Failed","extras.statusStopped":"Stopped","extras.runOn":"on {record}","extras.runIn":"in {table}","extras.serverTag":"Server","extras.noRuns":"Nothing has run yet. Runs show here with what each action did.","extras.name":"Name","extras.runsIn":"Runs in","extras.runsInBrowser":"This browser","extras.runsInServer":"The server","extras.serverHint":"Your server runs it (createAutomationServer): it hears changes from the database, whoever made them, reads secrets and sends email.","extras.browserHint":"It runs in the browser of the person who makes the change, right away.","extras.when":"When","extras.trigger":"Trigger","extras.triggerCreated":"A record is created","extras.triggerUpdated":"A record changes","extras.triggerMatches":"A record matches a condition","extras.triggerForm":"A form is sent","extras.triggerButton":"A button is pressed","extras.triggerScheduled":"At a scheduled time","extras.watchSome":"Only when one of these fields changes:","extras.watchAny":"Any field. Pick fields to watch only those:","extras.form":"Form","extras.anyForm":"Any form of this table","extras.buttonField":"Button field","extras.addButtonFirst":"Add a Button field to the table first.","extras.schedule":"Schedule","extras.customSchedule":"Custom","extras.cronExpression":"Cron expression","extras.scheduleHint":"Runs while the base is open in a browser. With a condition, it runs once for each record that matches at that time.","extras.condition":"Condition","extras.onlyWhere":"Only for records where","extras.startsToMatch":"Runs when a record starts to match","extras.addMatchCondition":"Add the condition a record has to start matching.","extras.everyRecord":"Every record. Add a condition to narrow it.","extras.do":"Do","extras.action":"Action","extras.doUpdateRecord":"Update the record","extras.doCreateRecord":"Create a record","extras.doHighlight":"Color the record while it matches","extras.moveUp":"Move up","extras.moveDown":"Move down","extras.moveStepUp":"Move step {step} up","extras.moveStepDown":"Move step {step} down","extras.removeStep":"Remove step {step}","extras.stepMoved":"Step {from} is now step {to}.","extras.removeAction":"Remove action","extras.message":"Message","extras.notifyPlaceholder":"{{field}} needs a look","extras.kind":"Kind","extras.severityInfo":"Info","extras.severitySuccess":"Success","extras.severityWarning":"Warning","extras.severityError":"Error","extras.notifyHint":"Name a field in braces for its value: {fields}.","extras.notifyTo":"Also send it to the notifications of:","extras.notifyToField":"The people in {field}","extras.highlightNeedsCondition":"Colors records while they match the condition above; add one.","extras.fill":"Fill","extras.text":"Text","extras.sample":"Sample","extras.wholeRow":"Whole row","extras.in":"In","extras.table":"Table","extras.linkBack":"Link it back","extras.linkField":"Link field","extras.noLink":"No link","extras.through":"through {field}","extras.valueOf":"{field} value","extras.valuePlaceholder":"a value, or {Field}","extras.numberPlaceholder":"0, or 100% for a percent","extras.linkPlaceholder":"a record name, or {record}","extras.userPlaceholder":"a name","extras.doNotSet":"Do not set {field}","extras.remove":"Remove","extras.setField":"Set a field","extras.addSetField":"+ Set a field","extras.runsApp":"Runs {action}, an action the app registered.","extras.method":"Method","extras.url":"URL","extras.headers":"Headers","extras.body":"Body","extras.webhookHintServer":"Empty body: the record as JSON. {secret} is read on the server only.","extras.webhookHintBrowser":"Empty body: the record as JSON. {secret} is read on the server only; set Runs in to The server to use one.","extras.emailNeedsServer":"Email is sent by the server: set Runs in to The server.","extras.to":"To","extras.toPlaceholder":"team@example.com, {Owner email}","extras.subject":"Subject","extras.emailText":"Email text","extras.addAction":"Add an action","extras.addActionOption":"+ Add an action","extras.deleteIt":"Delete it?","extras.delete":"Delete","extras.keep":"Keep","extras.deleteAutomation":"Delete automation","extras.runsOnServer":"Runs on your server when its trigger happens.","extras.tryRecord":"Record to try it on","extras.noRecord":"No record","extras.runNow":"Run now","extras.pickAutomation":"Pick an automation, or add one.","extras.noName":"(no name)","extras.noRecordValue":"(no record)","extras.pageLabel":"Automations of the base","extras.createAutomation":"+ Create automation","extras.runHistory":"Run history","extras.pageEmpty":"No automations yet. An automation does something on its own: when a record is added or changes, a form is sent, a button is pressed or at a time you set.","extras.pickOne":"Pick an automation on the left, or create one.","extras.triggerCard":"Trigger","extras.whenIn":"{when}, in {table}","extras.conditionCard":"Only for records where","extras.conditionEvery":"Every record","extras.conditionCount.one":"{count} condition","extras.conditionCount.other":"{count} conditions","extras.addCondition":"+ Add a condition","extras.actionCard":"Action {n}","extras.insertAction":"Add an action here","extras.addActionPage":"+ Add an action","extras.flowLabel":"What {name} does","extras.summarySet":"Set {fields}","extras.summaryNothing":"No fields set yet","extras.summaryCreate":"A new record in {table}","extras.summaryEmail":"To {to}","extras.summaryNoTo":"No address yet","extras.summaryColor":"While it matches","extras.tableOfTrigger":"Table","extras.tableMoveHint":"Its trigger, condition and fields are for this table: a new table starts them again.","extras.settingsOf":"Settings","extras.testOn":"Test on","extras.test":"Test","extras.testRuns":"Its runs show in the run history.","extras.allRunsOf":"Runs of {name}","extras.allRuns":"All runs","extras.showAllRuns":"Show every automation's runs","extras.whenWebhook":"When a webhook is received","extras.triggerWebhook":"A webhook is received","extras.webhookAddress":"Webhook address","extras.webhookNoUrl":"This automation listens for the token {token}: give it to your server runner (webhookReceived).","extras.webhookHint":"Send a POST with a JSON body to this address. Its values are {webhook.name} in the steps ({webhook.order.id} inside objects). Anyone with the address can start the automation: keep it secret.","extras.newAddress":"Make a new address","extras.copy":"Copy","extras.copied":"Copied","extras.actionChat":"Send a message","extras.actionRepeat":"Find records","extras.actionIf":"If","extras.actionAi":"Ask AI","extras.actionScript":"Run a script","extras.doChat":"Send a Slack, Teams or Google Chat message","extras.doRepeat":"Find records and, for each, do","extras.doIf":"If a condition holds, do","extras.doAi":"Ask AI","extras.doScript":"Run a script","extras.stepChat":"Message","extras.stepIf":"If","extras.stepIfThen":"It matched: the Then steps ran","extras.stepIfElse":"It did not match: the Otherwise steps ran","extras.stepFound":"Find records","extras.foundIn":"{count} in {table}","extras.stepAi":"AI","extras.stepScript":"Script","extras.noAi":"No AI model is set up here.","extras.aiNoPrompt":"The prompt is empty.","extras.scriptFailed":"The script failed.","extras.noField":"No field named {field}.","extras.noRecordId":"No record {id}.","extras.stepKind":"{list}, step {n}","extras.addStep":"+ Add a step","extras.addStepTo":"Add a step to {list}","extras.chatApp":"Chat app","extras.chatUrl":"Webhook address","extras.chatHintSlack":"In Slack: Apps, Incoming Webhooks, Add to a channel; paste the address it gives here.","extras.chatHintTeams":`In Teams: the channel's Workflows, "Post to a channel when a webhook request is received"; paste the address it gives here.`,"extras.chatHintGoogle":"In Google Chat: the space's Apps and integrations, Webhooks, Add webhook; paste the address it gives here.","extras.actionText":"Send a text message","extras.doText":"Send a text message (SMS or Viber)","extras.stepText":"Text message","extras.textNeedsServer":"Text messages are sent by the server: set Runs in to The server.","extras.textBy":"Send by","extras.textSms":"SMS","extras.textViber":"Viber (SMS if not on Viber)","extras.textTo":"To","extras.textToPlaceholder":"+359 88 123 4567, {Phone}","extras.textMessage":"Message","extras.textHint":"Phone numbers with their country code, or a phone field in braces; several apart with commas. The text names fields in braces.","extras.summarySms":"SMS to {to}","extras.summaryViber":"Viber to {to}","extras.summaryNoPhone":"No phone yet","extras.ifHint":"When the record matches this condition the Then steps run, otherwise the Otherwise steps.","extras.ifAlways":"No condition: Then always runs","extras.then":"Then","extras.otherwise":"Otherwise","extras.findIn":"Find in","extras.whichRecords":"Records where","extras.atMost":"At most","extras.forEach":"For each record found","extras.repeatHint":"In these steps {Field} is the found record's field, {trigger.Field} the field of the record that set the automation off, and {found} how many were found.","extras.aiPrompt":"Prompt","extras.aiPlaceholder":"Write a two-line summary of {{field}} for a weekly report.","extras.aiInto":"Put the answer in","extras.aiNowhere":"No field (use {ai} in the next steps)","extras.aiHint":"Name fields in braces. The answer is {ai} in the next steps.","extras.scriptCode":"Script","extras.scriptNeedsBrowser":"A script runs in the browser: set Runs in to The browser.","extras.scriptHint":"JavaScript, as in Airtable: input.config() has the record's fields by name; base.getTable('Name') reads and changes a table (selectRecordsAsync, updateRecordAsync, createRecordAsync, deleteRecordAsync); output.set('name', value) is {script.name} in the next steps; fetch() calls https addresses that allow it. It runs in a sandbox for up to 30 seconds.","extras.scriptInPageHint":"It runs in the page of the person who made the change, with what they may do. A run with no one's page behind it (a schedule, a webhook, a change through the API) stops at this step and says so.","extras.summaryNoText":"Nothing written yet","extras.stepCount.one":"{count} step","extras.stepCount.other":"{count} steps","extras.summaryRepeat":"{steps} for each record in {table}","extras.summaryIf":"Then {then}; otherwise {otherwise}","extras.summaryScript":"{lines} lines"};
1
+ export const EXTRAS_MESSAGES={"extras.whenCreated":"When a record is created","extras.whenCreatedWhere":"When a record is created, where {condition}","extras.whenRecordChanges":"When a record changes","extras.whenRecordChangesWhere":"When a record changes, where {condition}","extras.whenFieldsChange":"When {fields} changes","extras.whenFieldsChangeWhere":"When {fields} changes, where {condition}","extras.fieldsOr":" or ","extras.whenMatches":"When a record matches: {condition}","extras.noConditionYet":"no condition yet","extras.whenForm":"When a form is sent","extras.whenFormWhere":"When a form is sent, where {condition}","extras.whenPressed":"When {field} is pressed","extras.onSchedule":"{cron}","extras.onScheduleWhere":"{cron}, for records where {condition}","extras.cronOther":"On a schedule ({cron})","extras.cronEveryMinute":"Every minute","extras.cronEveryMinutes":"Every {n} minutes","extras.cronHourly":"Every hour, on the hour","extras.cronHourlyAt":"Every hour at {minute} past","extras.cronDaily":"Every day at {time}","extras.cronWeekdays":"Every weekday at {time}","extras.cronWeekly0":"Every Sunday at {time}","extras.cronWeekly1":"Every Monday at {time}","extras.cronWeekly2":"Every Tuesday at {time}","extras.cronWeekly3":"Every Wednesday at {time}","extras.cronWeekly4":"Every Thursday at {time}","extras.cronWeekly5":"Every Friday at {time}","extras.cronWeekly6":"Every Saturday at {time}","extras.cronDays":"Every {days} at {time}","extras.cronDay0":"Sunday","extras.cronDay1":"Monday","extras.cronDay2":"Tuesday","extras.cronDay3":"Wednesday","extras.cronDay4":"Thursday","extras.cronDay5":"Friday","extras.cronDay6":"Saturday","extras.cronMonthly":"Day {day} of every month at {time}","extras.actionUpdateRecord":"Update record","extras.actionCreateRecord":"Create record","extras.actionNotify":"Show a notice","extras.actionHighlight":"Color the record","extras.actionWebhook":"Call a webhook","extras.actionEmail":"Send an email","extras.stepStopped":"Stopped","extras.stepLoop":"Automations set each other off {max} times in a row; this one did not run, so they cannot loop.","extras.stepNotice":"Notice","extras.stepWebhook":"Webhook","extras.stepEmail":"Email","extras.stepNotRun":"Not run","extras.stepNoMatch":"The record does not match the condition","extras.stepDone":"Done","extras.noRecordToUpdate":"No record to update","extras.alreadySet":"Already set","extras.noTable":'No table "{table}"',"extras.noAction":'No action "{action}" is registered',"extras.aRecord":"a record","extras.createdIn":"{name} in {table}","extras.saidValue":"{field}: {value}","extras.saidChecked":"{field}: checked","extras.saidUnchecked":"{field}: unchecked","extras.saidEmpty":"empty","extras.title":"Automations in {table}","extras.listLabel":"Automations","extras.untitled":"Untitled","extras.switchOn":"{name} on","extras.noAutomations":"No automations yet. An automation does something when a record is added, changes or matches a condition.","extras.addAutomation":"+ New automation","extras.describeLabel":"Describe what should happen","extras.describePlaceholder":"For example: every Monday at 8:00, e-mail me the tasks that are not done","extras.describeButton":"Draft it","extras.describing":"Drafting...","extras.describeAgain":"Say a little more about what should happen, then try again.","extras.drafted":"Drafted from your words and switched off. Check each part, then switch it on.","extras.newAutomation":"New automation","extras.newRecordMessage":"New record: {{field}}","extras.nameFallback":"Name","extras.runs":"Runs","extras.clearRuns":"Clear this page's runs","extras.serverRunsFailed":"The server's runs did not load: {message}","extras.statusDone":"Done","extras.statusFailed":"Failed","extras.statusStopped":"Stopped","extras.runOn":"on {record}","extras.runIn":"in {table}","extras.serverTag":"Server","extras.noRuns":"Nothing has run yet. Runs show here with what each action did.","extras.name":"Name","extras.runsIn":"Runs in","extras.runsInBrowser":"This browser","extras.runsInServer":"The server","extras.serverHint":"Your server runs it (createAutomationServer): it hears changes from the database, whoever made them, reads secrets and sends email.","extras.browserHint":"It runs in the browser of the person who makes the change, right away.","extras.when":"When","extras.trigger":"Trigger","extras.triggerCreated":"A record is created","extras.triggerUpdated":"A record changes","extras.triggerMatches":"A record matches a condition","extras.triggerForm":"A form is sent","extras.triggerButton":"A button is pressed","extras.triggerScheduled":"At a scheduled time","extras.watchSome":"Only when one of these fields changes:","extras.watchAny":"Any field. Pick fields to watch only those:","extras.form":"Form","extras.anyForm":"Any form of this table","extras.buttonField":"Button field","extras.addButtonFirst":"Add a Button field to the table first.","extras.schedule":"Schedule","extras.customSchedule":"Custom","extras.cronExpression":"Cron expression","extras.scheduleHint":"Runs while the base is open in a browser. With a condition, it runs once for each record that matches at that time.","extras.condition":"Condition","extras.onlyWhere":"Only for records where","extras.startsToMatch":"Runs when a record starts to match","extras.addMatchCondition":"Add the condition a record has to start matching.","extras.everyRecord":"Every record. Add a condition to narrow it.","extras.do":"Do","extras.action":"Action","extras.doUpdateRecord":"Update the record","extras.doCreateRecord":"Create a record","extras.doHighlight":"Color the record while it matches","extras.moveUp":"Move up","extras.moveDown":"Move down","extras.moveStepUp":"Move step {step} up","extras.moveStepDown":"Move step {step} down","extras.removeStep":"Remove step {step}","extras.stepMoved":"Step {from} is now step {to}.","extras.removeAction":"Remove action","extras.message":"Message","extras.notifyPlaceholder":"{{field}} needs a look","extras.kind":"Kind","extras.severityInfo":"Info","extras.severitySuccess":"Success","extras.severityWarning":"Warning","extras.severityError":"Error","extras.notifyHint":"Name a field in braces for its value: {fields}.","extras.notifyTo":"Also send it to the notifications of:","extras.notifyToField":"The people in {field}","extras.highlightNeedsCondition":"Colors records while they match the condition above; add one.","extras.fill":"Fill","extras.text":"Text","extras.sample":"Sample","extras.wholeRow":"Whole row","extras.in":"In","extras.table":"Table","extras.linkBack":"Link it back","extras.linkField":"Link field","extras.noLink":"No link","extras.through":"through {field}","extras.valueOf":"{field} value","extras.valuePlaceholder":"a value, or {Field}","extras.numberPlaceholder":"0, or 100% for a percent","extras.linkPlaceholder":"a record name, or {record}","extras.userPlaceholder":"a name","extras.doNotSet":"Do not set {field}","extras.remove":"Remove","extras.setField":"Set a field","extras.addSetField":"+ Set a field","extras.runsApp":"Runs {action}, an action the app registered.","extras.method":"Method","extras.url":"URL","extras.headers":"Headers","extras.body":"Body","extras.webhookHintServer":"Empty body: the record as JSON. {secret} is read on the server only.","extras.webhookHintBrowser":"Empty body: the record as JSON. {secret} is read on the server only; set Runs in to The server to use one.","extras.emailNeedsServer":"Email is sent by the server: set Runs in to The server.","extras.to":"To","extras.toPlaceholder":"team@example.com, {Owner email}","extras.subject":"Subject","extras.emailText":"Email text","extras.addAction":"Add an action","extras.addActionOption":"+ Add an action","extras.deleteIt":"Delete it?","extras.delete":"Delete","extras.keep":"Keep","extras.deleteAutomation":"Delete automation","extras.triggerEntersView":"A record enters a view","extras.view":"View","extras.pickView":"Pick a view","extras.aView":"a view","extras.entersViewHint":"Runs once when a record starts to show in this view, through its filter, as the view has it then. It runs again only after the record has left the view.","extras.addViewFilterFirst":"First give a view of this table a filter: this trigger runs when a record starts to show in it.","extras.whenEntersView":"When a record enters {view}","extras.whenEntersViewWhere":"When a record enters {view}, where {condition}","extras.doDeleteRecord":"Delete the record","extras.actionDeleteRecord":"Delete record","extras.deleteRecordHint":"Deletes the record that started the automation (inside Find records, each record found). It goes to the trash, where it can be restored for 30 days.","extras.noRecordToDelete":"No record to delete","extras.deletedRecord":"Deleted {name}","extras.cannotDeleteHere":"This table cannot delete records from an automation.","extras.summaryDelete":"Deletes the record","extras.duplicateAutomation":"Duplicate","extras.copyOf":"{name} copy","extras.duplicated":"Copied. The copy is off until you turn it on.","extras.runsOnServer":"Runs on your server when its trigger happens.","extras.tryRecord":"Record to try it on","extras.noRecord":"No record","extras.runNow":"Run now","extras.pickAutomation":"Pick an automation, or add one.","extras.noName":"(no name)","extras.noRecordValue":"(no record)","extras.pageLabel":"Automations of the base","extras.createAutomation":"+ Create automation","extras.runHistory":"Run history","extras.pageEmpty":"No automations yet. An automation does something on its own: when a record is added or changes, a form is sent, a button is pressed or at a time you set.","extras.pickOne":"Pick an automation on the left, or create one.","extras.triggerCard":"Trigger","extras.whenIn":"{when}, in {table}","extras.conditionCard":"Only for records where","extras.conditionEvery":"Every record","extras.conditionCount.one":"{count} condition","extras.conditionCount.other":"{count} conditions","extras.addCondition":"+ Add a condition","extras.actionCard":"Action {n}","extras.insertAction":"Add an action here","extras.addActionPage":"+ Add an action","extras.flowLabel":"What {name} does","extras.summarySet":"Set {fields}","extras.summaryNothing":"No fields set yet","extras.summaryCreate":"A new record in {table}","extras.summaryEmail":"To {to}","extras.summaryNoTo":"No address yet","extras.summaryColor":"While it matches","extras.tableOfTrigger":"Table","extras.tableMoveHint":"Its trigger, condition and fields are for this table: a new table starts them again.","extras.settingsOf":"Settings","extras.testOn":"Test on","extras.test":"Test","extras.testRuns":"Its runs show in the run history.","extras.allRunsOf":"Runs of {name}","extras.allRuns":"All runs","extras.showAllRuns":"Show every automation's runs","extras.whenWebhook":"When a webhook is received","extras.triggerWebhook":"A webhook is received","extras.webhookAddress":"Webhook address","extras.webhookNoUrl":"This automation listens for the token {token}: give it to your server runner (webhookReceived).","extras.webhookHint":"Send a POST with a JSON body to this address. Its values are {webhook.name} in the steps ({webhook.order.id} inside objects). Anyone with the address can start the automation: keep it secret.","extras.newAddress":"Make a new address","extras.copy":"Copy","extras.copied":"Copied","extras.actionChat":"Send a message","extras.actionRepeat":"Find records","extras.actionIf":"If","extras.actionAi":"Ask AI","extras.actionScript":"Run a script","extras.doChat":"Send a Slack, Teams or Google Chat message","extras.doRepeat":"Find records and, for each, do","extras.doIf":"If a condition holds, do","extras.doAi":"Ask AI","extras.doScript":"Run a script","extras.stepChat":"Message","extras.stepIf":"If","extras.stepIfThen":"It matched: the Then steps ran","extras.stepIfElse":"It did not match: the Otherwise steps ran","extras.stepFound":"Find records","extras.foundIn":"{count} in {table}","extras.stepAi":"AI","extras.stepScript":"Script","extras.noAi":"No AI model is set up here.","extras.aiNoPrompt":"The prompt is empty.","extras.scriptFailed":"The script failed.","extras.noField":"No field named {field}.","extras.noRecordId":"No record {id}.","extras.stepKind":"{list}, step {n}","extras.addStep":"+ Add a step","extras.addStepTo":"Add a step to {list}","extras.chatApp":"Chat app","extras.chatUrl":"Webhook address","extras.chatHintSlack":"In Slack: Apps, Incoming Webhooks, Add to a channel; paste the address it gives here.","extras.chatHintTeams":`In Teams: the channel's Workflows, "Post to a channel when a webhook request is received"; paste the address it gives here.`,"extras.chatHintGoogle":"In Google Chat: the space's Apps and integrations, Webhooks, Add webhook; paste the address it gives here.","extras.actionText":"Send a text message","extras.doText":"Send a text message (SMS or Viber)","extras.stepText":"Text message","extras.textNeedsServer":"Text messages are sent by the server: set Runs in to The server.","extras.textBy":"Send by","extras.textSms":"SMS","extras.textViber":"Viber (SMS if not on Viber)","extras.textTo":"To","extras.textToPlaceholder":"+359 88 123 4567, {Phone}","extras.textMessage":"Message","extras.textHint":"Phone numbers with their country code, or a phone field in braces; several apart with commas. The text names fields in braces.","extras.summarySms":"SMS to {to}","extras.summaryViber":"Viber to {to}","extras.summaryNoPhone":"No phone yet","extras.ifHint":"When the record matches this condition the Then steps run, otherwise the Otherwise steps.","extras.ifAlways":"No condition: Then always runs","extras.then":"Then","extras.otherwise":"Otherwise","extras.findIn":"Find in","extras.whichRecords":"Records where","extras.atMost":"At most","extras.forEach":"For each record found","extras.repeatHint":"In these steps {Field} is the found record's field, {trigger.Field} the field of the record that set the automation off, and {found} how many were found.","extras.aiPrompt":"Prompt","extras.aiPlaceholder":"Write a two-line summary of {{field}} for a weekly report.","extras.aiInto":"Put the answer in","extras.aiNowhere":"No field (use {ai} in the next steps)","extras.aiHint":"Name fields in braces. The answer is {ai} in the next steps.","extras.scriptCode":"Script","extras.scriptNeedsBrowser":"A script runs in the browser: set Runs in to The browser.","extras.scriptHint":"JavaScript, as in Airtable: input.config() has the record's fields by name; base.getTable('Name') reads and changes a table (selectRecordsAsync, updateRecordAsync, createRecordAsync, deleteRecordAsync); output.set('name', value) is {script.name} in the next steps; fetch() calls https addresses that allow it. It runs in a sandbox for up to 30 seconds.","extras.scriptInPageHint":"It runs in the page of the person who made the change, with what they may do. A run with no one's page behind it (a schedule, a webhook, a change through the API) stops at this step and says so.","extras.summaryNoText":"Nothing written yet","extras.stepCount.one":"{count} step","extras.stepCount.other":"{count} steps","extras.summaryRepeat":"{steps} for each record in {table}","extras.summaryIf":"Then {then}; otherwise {otherwise}","extras.summaryScript":"{lines} lines"};
@@ -379,6 +379,14 @@ export declare const SHELL_MESSAGES: {
379
379
  readonly 'shell.importWarnLost.other': "{count} values do not fit the fields they go to and would be left empty. Change those field types or skip the columns to keep them.";
380
380
  readonly 'shell.importWarnUnmatched.one': "1 cell names a person or a record that was not found, so that name is not imported.";
381
381
  readonly 'shell.importWarnUnmatched.other': "{count} cells name a person or a record that was not found, so those names are not imported.";
382
+ readonly 'shell.importRepeatedLabel': "Records already in the table";
383
+ readonly 'shell.importAddAll': "Add every row as a new record";
384
+ readonly 'shell.importUpdateMatching': "Update the records that match, add the rest";
385
+ readonly 'shell.importUpdateTooBig': "This table is read a page at a time, so its records cannot all be matched here: every row is added.";
386
+ readonly 'shell.importMatchBy': "Match by";
387
+ readonly 'shell.importWillMerge': "{updated} records will be updated and {added} added. Blank cells leave a field as it is.";
388
+ readonly 'shell.stepImportMerge': "Import: {updated} updated, {added} added";
389
+ readonly 'shell.importedMerged': "{updated} records updated and {added} added in {table}.";
382
390
  readonly 'shell.importWarnRepeated.one': "1 record has the same name as a record already in this table. Importing adds it as a second record.";
383
391
  readonly 'shell.importWarnRepeated.other': "{count} records have the same name as records already in this table. Importing adds them as second records.";
384
392
  readonly 'shell.importSummary.one': "{file}: {count} record, {columns} columns";