@tempo-kit/plugin-roman 0.0.0-stage → 2.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -0
- package/LICENSE +21 -0
- package/README.md +119 -2
- package/dist/constants.d.ts +49 -0
- package/dist/consul-engine.d.ts +62 -0
- package/dist/consuls.d.ts +5 -0
- package/dist/consuls.data.d.ts +18 -0
- package/dist/consuls.global.min.js +1 -0
- package/dist/consuls.js +1899 -0
- package/dist/format.d.ts +30 -0
- package/dist/index.d.ts +80 -0
- package/dist/index.global.min.js +1 -0
- package/dist/index.js +906 -0
- package/dist/install.d.ts +2 -0
- package/dist/install.global.min.js +1 -0
- package/dist/install.js +909 -0
- package/dist/math.d.ts +20 -0
- package/dist/parser.d.ts +19 -0
- package/dist/types.d.ts +317 -0
- package/package.json +74 -4
package/dist/format.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ClassicalRomanDate, RomanFormatOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Formats a classical Roman calendar date into a Latin phrase or abbreviation.
|
|
4
|
+
*
|
|
5
|
+
* @param roman - The structured ClassicalRomanDate
|
|
6
|
+
* @param options - Formatting configuration (case, style, AUC, words, casing)
|
|
7
|
+
* @returns Formatted classical Roman string
|
|
8
|
+
*/
|
|
9
|
+
export declare function formatClassicalRomanDate(roman: ClassicalRomanDate, options?: RomanFormatOptions): string;
|
|
10
|
+
/**
|
|
11
|
+
* Creates the token evaluator callback registered with Tempo's format registry (`tokens.roman`).
|
|
12
|
+
* Supports:
|
|
13
|
+
* - `{roman}`: Full classical date (customary case)
|
|
14
|
+
* - `{roman:classical}`: Full classical date
|
|
15
|
+
* - `{roman:short}`: Abbreviated classical date
|
|
16
|
+
* - `{roman:auc}`: Year AUC (e.g. "AUC MMDCCLXXIX")
|
|
17
|
+
* - `{roman:auc:num}`: Numeric year AUC (e.g. "2779")
|
|
18
|
+
* - `{roman:nominative}`: Nominative case date
|
|
19
|
+
* - `{roman:accusative}`: Accusative case date
|
|
20
|
+
* - `{roman:ablative}`: Ablative case date
|
|
21
|
+
* - Combined with `:upper`, `:lower`, `:capitalize`, `:words`, `:auc`
|
|
22
|
+
*/
|
|
23
|
+
export declare function createRomanTokenEvaluator(calculator: (year: number, month: number, day: number) => ClassicalRomanDate): (zdt: {
|
|
24
|
+
year: number;
|
|
25
|
+
month: number;
|
|
26
|
+
day: number;
|
|
27
|
+
}, context?: {
|
|
28
|
+
modifiers?: string[];
|
|
29
|
+
config?: any;
|
|
30
|
+
}) => string;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { type TempoPlugin } from 'tempo-kit/plugin/sdk';
|
|
2
|
+
import type { ClassicalRomanDate, RomanCalculationOptions, RomanFormatOptions, RomanNamespace } from './types.js';
|
|
3
|
+
export * from './types.js';
|
|
4
|
+
export * from './constants.js';
|
|
5
|
+
export * from './math.js';
|
|
6
|
+
export * from './format.js';
|
|
7
|
+
export * from './parser.js';
|
|
8
|
+
export * from './consul-engine.js';
|
|
9
|
+
declare module 'tempo-kit' {
|
|
10
|
+
/** Registers `{roman}` (and `{roman:...}` modifiers) for compile-time format validation. */
|
|
11
|
+
interface TempoFormatTokens {
|
|
12
|
+
roman: true;
|
|
13
|
+
}
|
|
14
|
+
namespace Tempo {
|
|
15
|
+
/**
|
|
16
|
+
* Classical Roman calendar and Ab Urbe Condita (AUC) namespace.
|
|
17
|
+
*/
|
|
18
|
+
const roman: RomanNamespace;
|
|
19
|
+
}
|
|
20
|
+
interface Tempo {
|
|
21
|
+
/**
|
|
22
|
+
* Computes the classical Roman calendar date representation (Kalends, Nones, Ides, Ante Diem).
|
|
23
|
+
*
|
|
24
|
+
* @param options - Calculation options (Julian leap rules, bissextile leap day)
|
|
25
|
+
* @returns Classical Roman date structure including Latin phrases and AUC year
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const t = new Tempo('2026-10-16');
|
|
29
|
+
* const roman = t.toRomanClassical();
|
|
30
|
+
* console.log(roman.latin); // "ante diem XVII Kalendas Novembres"
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
toRomanClassical(options?: RomanCalculationOptions): ClassicalRomanDate;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the year reckoned Ab Urbe Condita (AUC) from the traditional founding of Rome in 753 BCE.
|
|
36
|
+
*
|
|
37
|
+
* @returns The year in AUC
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* const t = new Tempo('2026-10-16');
|
|
41
|
+
* console.log(t.toAUC()); // 2779
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
toAUC(): number;
|
|
45
|
+
/**
|
|
46
|
+
* Year reckoned Ab Urbe Condita (AUC).
|
|
47
|
+
*/
|
|
48
|
+
readonly auc: number;
|
|
49
|
+
/**
|
|
50
|
+
* Formats this instance using classical Roman calendar conventions and Latin declensions.
|
|
51
|
+
*
|
|
52
|
+
* @param options - Formatting configuration (case, style, AUC, words, casing)
|
|
53
|
+
* @returns Formatted classical Roman date string
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* const t = new Tempo('2026-10-16');
|
|
57
|
+
* console.log(t.formatRoman({ case: 'nominative' }));
|
|
58
|
+
* console.log(t.format('{roman:classical}')); // "ante diem XVII Kalendas Novembres"
|
|
59
|
+
* console.log(t.format('{roman:short}')); // "a.d. XVII Kal. Nov."
|
|
60
|
+
* console.log(t.format('{roman:auc}')); // "AUC MMDCCLXXIX"
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
formatRoman(options?: RomanFormatOptions): string;
|
|
64
|
+
/**
|
|
65
|
+
* Structured Classical Roman calendar date.
|
|
66
|
+
*/
|
|
67
|
+
readonly roman: ClassicalRomanDate;
|
|
68
|
+
/**
|
|
69
|
+
* Formatted classical Roman consular dating formula (e.g. `"M. Tullio Cicerone, C. Antonio Hybrida coss."`),
|
|
70
|
+
* or undefined if no ordinary consuls are recorded in the Fasti for this year.
|
|
71
|
+
*/
|
|
72
|
+
readonly consuls?: string;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* ## RomanPlugin
|
|
77
|
+
* Tempo Community Plugin providing classical Roman calendar arithmetic and AUC conversions.
|
|
78
|
+
*/
|
|
79
|
+
export declare const RomanPlugin: TempoPlugin;
|
|
80
|
+
export default RomanPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var Magma;((Magma||={}).plugins||={}).roman=(()=>{var Ze=Object.create;var ee=Object.defineProperty;var Ve=Object.getOwnPropertyDescriptor;var Ge=Object.getOwnPropertyNames;var Je=Object.getPrototypeOf,qe=Object.prototype.hasOwnProperty;var Xe=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},Ie=(e,t)=>{for(var r in t)ee(e,r,{get:t[r],enumerable:!0})},j=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ge(t))!qe.call(e,n)&&n!==r&&ee(e,n,{get:()=>t[n],enumerable:!(i=Ve(t,n))||i.enumerable});return e},z=(e,t,r)=>(j(e,t,"default"),r&&j(r,t,"default")),Ne=(e,t,r)=>(r=e!=null?Ze(Je(e)):{},j(t||!e||!e.__esModule?ee(r,"default",{value:e,enumerable:!0}):r,e)),Qe=e=>j(ee({},"__esModule",{value:!0}),e);var pe=Xe((Dt,_e)=>{"use strict";_e.exports=window.Magma.pluginSdk});var Nt={};Ie(Nt,{ANCHOR_ABLATIVE:()=>M,ANCHOR_ACCUSATIVE:()=>_,ANCHOR_NOMINATIVE:()=>K,ANCHOR_SHORT:()=>A,AUC_OFFSET:()=>Y,COUNT_WORDS_ABLATIVE:()=>Se,COUNT_WORDS_ACCUSATIVE:()=>W,LANDMARK_CONSULS:()=>Re,MOMJ_MONTHS:()=>le,MONTH_ABLATIVE:()=>x,MONTH_ACCUSATIVE:()=>D,MONTH_NOMINATIVE:()=>Z,MONTH_SHORT:()=>w,RomanPlugin:()=>Ke,aucToYear:()=>Ae,calculateClassicalRomanDate:()=>C,calculateGregorianFromRoman:()=>X,createRomanTokenEvaluator:()=>Ce,default:()=>It,findConsulYears:()=>G,formatClassicalRomanDate:()=>E,formatConsuls:()=>$,getConsulCatalog:()=>St,getConsulsByYear:()=>Ee,getIdesDay:()=>q,getNonesDay:()=>J,parseClassicalRomanDate:()=>me,registerConsuls:()=>Oe,resetConsulCatalog:()=>Rt,toAblativeConsulName:()=>Be,yearToAuc:()=>B});var m={};Ie(m,{definePlugin:()=>de,defineTerm:()=>je});z(m,Ne(pe()));var te=Ne(pe()),de=e=>(0,te.definePlugin)({...e,version:"2.0.0-rc.0"}),je=e=>(0,te.defineTerm)({...e,version:"2.0.0-rc.0"});function ne(e,t,r,i,n,o){function s(b){if(b!==void 0&&typeof b!="function")throw new TypeError("Function expected");return b}for(var a=i.kind,c=a==="getter"?"get":a==="setter"?"set":"value",d=!t&&e?i.static?e:e.prototype:null,u=t||(d?Object.getOwnPropertyDescriptor(d,i.name):{}),p,l=!1,f=r.length-1;f>=0;f--){var y={};for(var g in i)y[g]=g==="access"?{}:i[g];for(var g in i.access)y.access[g]=i.access[g];y.addInitializer=function(b){if(l)throw new TypeError("Cannot add initializers after decoration has completed");o.push(s(b||null))};var h=(0,r[f])(a==="accessor"?{get:u.get,set:u.set}:u[c],y);if(a==="accessor"){if(h===void 0)continue;if(h===null||typeof h!="object")throw new TypeError("Object expected");(p=s(h.get))&&(u.get=p),(p=s(h.set))&&(u.set=p),(p=s(h.init))&&n.unshift(p)}else(p=s(h))&&(a==="field"?n.unshift(p):u[c]=p)}d&&Object.defineProperty(d,i.name,u),l=!0}function re(e,t,r){for(var i=arguments.length>2,n=0;n<t.length;n++)r=i?t[n].call(e,r):t[n].call(e);return i?r:void 0}var et=Symbol.for("$LibraryTarget"),tt=Symbol.for("$LibraryDiscover"),nt=Symbol.for("$LibraryExtensible"),rt=Symbol.for("nodejs.util.inspect.custom"),it=Symbol.for("$LibraryLogConfig"),ot=Symbol.for("$LibraryRegistry"),st=Symbol.for("$LibraryRegister"),at=Symbol.for("$LibrarySerializerRegistry"),ct=Symbol.for("$LibraryMutable"),lt=Symbol.for("$LibraryIdentity"),ut=Symbol.for("$LibraryUnwrapped"),O={$Target:et,$Discover:tt,$Extensible:nt,$Inspect:rt,$LogConfig:it,$Registry:ot,$Register:st,$SerializerRegistry:at,$Identity:lt,$Mutable:ct,$Unwrapped:ut};function ie(e){let t=e,r=0,i=50;for(;t;){let n=t[O.$Target];if(!n||r>=i)break;t=n,r++}return t}function L(e,t,...r){if(e===null||typeof e!="object"&&typeof e!="function")return!1;let i=ie(e);if(!Object.hasOwn(i,t))return!1;if(r.length===0)return!0;let n=i[t];return De(n,r)}function v(e,t,...r){if(e===null||typeof e!="object"&&typeof e!="function")return!1;let i=ie(e);if(!(t in i))return!1;if(r.length===0)return!0;let n=i[t];return De(n,r)}function De(e,t){for(let r=0;r<t.length;r++){let i=t[r];if(typeof i=="function"){if(i(e))return!0}else if(typeof i=="string"&&ft(e,i.trim().toLowerCase()))return!0}return!1}function ft(e,t){switch(t){case"string":case"number":case"boolean":case"function":case"bigint":case"symbol":case"undefined":return typeof e===t;case"array":return Array.isArray(e);case"null":return e===null;case"object":return e!==null&&!Array.isArray(e)&&typeof e=="object";case"any":case"unknown":return!0;default:return!1}}var mt=[],Pe=e=>{if(e===null)return"Null";if(e===void 0)return"Undefined";let t=typeof e;if(t==="string")return"String";if(t==="number")return"Number";if(t==="boolean")return"Boolean";if(t==="bigint")return"BigInt";if(t==="symbol")return"Symbol";try{let r=t==="object"?ie(e):e;return Object.prototype.toString.call(r).slice(8,-1)}catch{return t==="function"?"Function":"Object"}},ye=e=>{try{let t=e?.[Symbol.toStringTag]??e?.prototype?.[Symbol.toStringTag];if(typeof t=="string")return t}catch{}},Me=(e,...t)=>{let r=e;try{r=e?.[O.$Target]??e}catch{r=e}let i=Pe(r);switch(i){case"Function":try{return dt(r)?"Class":"Function"}catch{return"Function"}case"Object":{try{if("length"in r&&Object.keys(r).every(o=>o==="length"||Number.isFinite(Number(o))))return"ArrayLike";for(let o of t){let s=o.class?.[O.$Target]??o.class;if(r===s||s&&r instanceof s)return o.type}let n=globalThis[O.$Registry]??[];for(let o of[...mt,...n]){let s=o.class?.[O.$Target]??o.class;if(r===s||s&&r instanceof s)return o.type}}catch{return"Object"}return"Object"}default:return i}};var pt=/^\s*(class\s|\[native code\])/,dt=e=>{if(typeof e!="function")return!1;let t=e?.[O.$Target]??e;if(!("prototype"in t))return!1;let r=t?.name,i=ye(t);if(t?.[O.$Identity]||t?.prototype?.[O.$Identity]||typeof i=="string"&&i.startsWith("Temporal."))return!0;if(typeof i=="string"&&i.endsWith("Function"))return!1;if((globalThis[O.$Registry]??[]).some(o=>(o.class?.[O.$Target]??o.class)===t||r&&o.type===r||i&&o.type===i))return!0;try{let o=Function.prototype.toString.call(t);if(pt.test(o))return!0;let s=Object.getOwnPropertyDescriptor(t,"prototype");if(s&&s.writable===!1&&!Object.isFrozen(t))return!0;let a=t.prototype;if(a&&Object.getOwnPropertyNames(a).length>2)return!0}catch{return!1}return!1};var ge=(e,...t)=>t.includes(Me(e)),yt=e=>e===null||typeof e!="object"&&typeof e!="function",he=e=>!yt(e);var I=e=>typeof e=="string";var xe=e=>ge(e,"Object");var oe=e=>typeof e=="symbol";var H=e=>e!=null,k=e=>e===void 0;var $e=e=>ge(e,"Function","AsyncFunction","GeneratorFunction","AsyncGeneratorFunction"),be=e=>typeof e=="function";var Fe=(e,t)=>ge(e,"Error")&&(t?e instanceof t:!0);var Le=(e,t)=>{if(!e||typeof e!="object"&&typeof e!="function")return!1;try{return e[t]===!0}catch{return!1}};var ve=e=>e?e.charAt(0).toUpperCase()+e.slice(1):"";function gt(e,t){return ye(e)??(k(t)?e.name||void 0:String(t))}function se(e,t){let r=(i,n,o,s)=>{let a=o??(I(n)?n:void 0)??(oe(n)&&n.description?n.description:void 0)??gt(i,s),c=a?String(a).replace(/^\$/,""):"Instance",d=I(n)||I(o),u=oe(n)?n:d?Symbol.for(`Brand.${c}`):Symbol(`Brand.${c}`),p=y=>Le(y,u),l=i.prototype;if(l&&!L(l,u)&&Object.defineProperty(l,u,{value:!0,configurable:!1,writable:!1,enumerable:!1}),l&&!L(l,Symbol.toStringTag)&&Object.defineProperty(l,Symbol.toStringTag,{value:c,configurable:!0,writable:!1,enumerable:!1}),!i.name||i.name!==c)try{Object.defineProperty(i,"name",{value:c,configurable:!0,writable:!1,enumerable:!1})}catch{}let f=`is${ve(c)}`;if(!L(i,f))try{Object.defineProperty(i,f,{value:p,configurable:!0,writable:!1,enumerable:!1})}catch{}if(!L(i,Symbol.hasInstance))try{Object.defineProperty(i,Symbol.hasInstance,{value:function(y){if(L(this,f)){let g=this[f];if(be(g))return g.call(this,y)}return he(y)&&he(this?.prototype)&&Object.prototype.isPrototypeOf.call(this.prototype,y)},configurable:!0,writable:!1,enumerable:!1})}catch{}return i};return be(e)&&t?.kind==="class"?r(e,void 0,void 0,t.name):(i,n)=>{let o=I(e)||oe(e)?e:void 0,s=I(t)?t:void 0;return r(i,o,s,n?.name)}}var cn=BigInt(Number.MAX_SAFE_INTEGER),ln=BigInt(Number.MIN_SAFE_INTEGER);function ke(e){if(Fe(e))return e;let t=new Error(v(e,"message",I)?e.message:String(e));return xe(e)&&(t.name=v(e,"name","string")?e.name:"Error",v(e,"code","string","number")&&(t.code=e.code),v(e,"stack","string")&&(t.stack=e.stack)),t}var ae=new FinalizationRegistry(e=>{try{$e(e)&&e()}catch(t){console.error("Finalizer callback error:",t)}}),Te=(()=>{let e=[se("Finalizer")],t,r=[],i;return class{static{i=this}static{let n=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;ne(null,t={value:i},e,{kind:"class",name:i.name,metadata:n},null,r),i=t.value,n&&Object.defineProperty(i,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:n}),re(i,r)}#e;constructor(n){this.#e=n}register(n,o,s){let a=s??Object.create(null),c=this.#e;ae.register(n,()=>{c(o)},a)}unregister(n){return ae.unregister(n)}static register(n,o,s){let a=s??Object.create(null);return ae.register(n,o,a),()=>ae.unregister(a)}},i})(),dn=Te.isFinalizer;if(typeof globalThis.Temporal>"u")throw new Error("Temporal API is not available. Node 20+ with a polyfill (e.g. @js-temporal/polyfill) is highly recommended. Native Temporal is fully reliable only on Node 26+ (while Node 22 may have instabilities).");try{if(typeof Temporal.Now.zonedDateTimeISO=="function"&&typeof Temporal.Now.zonedDateTimeISO().add!="function")throw new Error("Incomplete Temporal implementation")}catch(e){let t=ke(e);if(console.warn("Tempo: Native Temporal implementation appears incomplete. Consider loading a polyfill.",t),t.message!=="Incomplete Temporal implementation")throw t}var ce=(()=>{let e=[se("WeakCache")],t,r=[],i;return class{static{i=this}static{let n=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;ne(null,t={value:i},e,{kind:"class",name:i.name,metadata:n},null,r),i=t.value,n&&Object.defineProperty(i,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:n})}#e=new Map;#t;static isWeakCache=n=>typeof n=="object"&&n!==null&&#e in n;constructor(){this.#t=new Te(n=>{let o=this.#e.get(n.key);o&&o.token===n.token&&this.#e.delete(n.key)})}set(n,o){this.delete(n);let s=Object.create(null);return this.#e.set(n,{ref:new WeakRef(o),token:s}),this.#t.register(o,{key:n,token:s},s),this}get(n){let o=this.#e.get(n);if(k(o))return;let s=o.ref.deref();if(k(s)){this.#t.unregister(o.token),this.#e.delete(n);return}return s}has(n){return H(this.get(n))}getOrSet(n,o){let s=this.get(n);if(H(s))return s;let a=o(n);return this.set(n,a),a}delete(n){let o=this.#e.get(n);return H(o)?(this.#e.delete(n),this.#t.unregister(o.token),!0):!1}clear(){for(let n of this.#e.values())this.#t.unregister(n.token);this.#e.clear()}static{re(i,r)}},i})(),On=ce.isWeakCache;var In=new ce,Nn=new ce;var ht=Object.freeze({MO:1,TU:2,WE:3,TH:4,FR:5,SA:6,SU:7,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6,SUN:7}),bt=Object.freeze({JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12}),Tt=Object.freeze({1:"Monday",2:"Tuesday",3:"Wednesday",4:"Thursday",5:"Friday",6:"Saturday",7:"Sunday"}),Ue=[0,31,28,31,30,31,30,31,31,30,31,30,31];function N(e,t=!1){return t?(e%4+4)%4===0:e%4===0&&e%100!==0||e%400===0}function U(e,t,r=!1){if(t>=1&&t<=12)return t===2?N(e,r)?29:28:Ue[t];let i=e+Math.floor((t-1)/12),n=((t-1)%12+12)%12+1;return n===2?N(i,r)?29:28:Ue[n]}var Y=753,le=new Set([3,5,7,10]),K=Object.freeze({Kalends:"Kalendae",Nones:"Nonae",Ides:"Idus"}),M=Object.freeze({Kalends:"Kalendis",Nones:"Nonis",Ides:"Idibus"}),_=Object.freeze({Kalends:"Kalendas",Nones:"Nonas",Ides:"Idus"}),A=Object.freeze({Kalends:"Kal.",Nones:"Non.",Ides:"Id."}),Z=Object.freeze(["","Januariae","Februariae","Martiae","Apriles","Maiae","Juniae","Juliae","Augustae","Septembres","Octobres","Novembres","Decembres"]),D=Object.freeze(["","Januarias","Februarias","Martias","Apriles","Maias","Junias","Julias","Augustas","Septembres","Octobres","Novembres","Decembres"]),x=Object.freeze(["","Januariis","Februariis","Martiis","Aprilibus","Maiis","Juniis","Juliis","Augustis","Septembribus","Octobribus","Novembribus","Decembribus"]),w=Object.freeze(["","Jan.","Feb.","Mart.","Apr.","Mai.","Jun.","Jul.","Aug.","Sept.","Oct.","Nov.","Dec."]),W=Object.freeze(["","","pridie","tertium","quartum","quintum","sextum","septimum","octavum","nonum","decimum","undecimum","duodecimum","tertium decimum","quartum decimum","quintum decimum","sextum decimum","septimum decimum","duodevicesimum","undevicesimum"]),Se=Object.freeze(["","","pridie","tertio","quarto","quinto","sexto","septimo","octavo","nono","decimo","undecimo","duodecimo","tertio decimo","quarto decimo","quinto decimo","sexto decimo","septimo decimo","duodevicesimo","undevicesimo"]);var Re=Object.freeze({"-508":["L. Junius Brutus","L. Tarquinius Collatinus"],"-320":["T. Veturius Calvinus II","Sp. Postumius Albinus Caudinus II"],"-279":["P. Valerius Laevinus","Ti. Coruncanius"],"-215":["C. Terentius Varro","L. Aemilius Paullus II"],"-201":["M. Servilius Pulex Geminus","Ti. Claudius Nero"],"-132":["P. Mucius Scaevola","L. Calpurnius Piso Frugi"],"-106":["C. Marius I","L. Cassius Longinus"],"-62":["M. Tullius Cicero","C. Antonius Hybrida"],"-58":["C. Julius Caesar","M. Calpurnius Bibulus"],"-54":["Cn. Pompeius Magnus II","M. Licinius Crassus II"],"-47":["C. Julius Caesar II","P. Servilius Isauricus"],"-43":["C. Julius Caesar V","M. Antonius"],"-42":["C. Vibius Pansa Caetronianus","A. Hirtius"],"-30":["M. Antonius III","Imp. Caesar III"],"-27":["Imp. Caesar VI","M. Agrippa II"],"-26":["Imp. Caesar Augustus VII","M. Agrippa III"],14:["Sex. Pompeius","Sex. Appuleius"],69:["Ser. Galba Caesar Augustus II","T. Vinius"],541:["Anicius Faustus Albinus Basilius"]}),ue=Symbol.for("@tempo-kit/plugin-roman/consuls");function V(){let e=globalThis;return e[ue]||(e[ue]={...Re}),e[ue]}function Oe(e){let t=V();Object.assign(t,e)}function St(){return V()}function Rt(){let e=globalThis;e[ue]={...Re}}function Ee(e){return V()[e]}function $(e,t="ablative"){let r=V()[e];if(!r||r.length===0)return;if(t==="nominative")return r.join(", ");let i=r.map(Be),n=r.length>1?"coss.":"cos.";return`${i.join(", ")} ${n}`}var We=Object.freeze({Pulex:"Pulice",pulex:"pulice",Pulcher:"Pulchro",pulcher:"pulchro",Niger:"Nigro",niger:"nigro",Aper:"Apro",aper:"apro"});function Be(e){return e.split(" ").map(t=>/^[A-Z]['a-z]?\.$/.test(t)||/^[IVXLCDM]+$/.test(t)?t:We[t]?We[t]:t.endsWith("ius")?t.slice(0,-3)+"io":t.endsWith("us")?t.slice(0,-2)+"o":t.endsWith("o")?t+"ne":t.endsWith("or")||t.endsWith("ar")?t+"e":t.endsWith("as")?t.slice(0,-2)+"a":t.endsWith("es")||t.endsWith("is")?t.slice(0,-2)+"e":t.endsWith("x")?t.slice(0,-1)+"ce":/[bcdfghjklmnpqrstvz]$/i.test(t)?t+"e":t).join(" ")}function G(e){let t=e.trim().toLowerCase();if(!t)return[];let r=t.replace(/[.,;:!?]/g," ").split(/\s+/).filter(o=>o&&!["et","ac","atque","coss","cos","consulibus","consule"].includes(o));if(r.length===0)return[];let i=[],n=V();for(let[o,s]of Object.entries(n)){let a=Number(o),c=s.join(" ").toLowerCase();r.every(u=>!!(c.includes(u)||u.endsWith("one")&&c.includes(u.slice(0,-3)+"o")||u.endsWith("e")&&c.includes(u.slice(0,-1))||u.endsWith("o")&&c.includes(u.slice(0,-1))))&&i.push({year:a,consuls:s,formatted:$(a)})}return i.sort((o,s)=>o.year-s.year)}function E(e,t){let r=t?.case??"customary",i=t?.style??"classical",n=t?.words??!1,o=i==="short",s="";if(e.isBissextile)o?s="a.d. bis VI Kal. Mart.":s="ante diem bis sextum Kalendas Martias";else if(e.relation==="on")if(o)s=`${A[e.anchor]} ${w[e.anchorMonth]}`;else switch(r){case"nominative":s=`${K[e.anchor]} ${Z[e.anchorMonth]}`;break;case"accusative":s=`${_[e.anchor]} ${D[e.anchorMonth]}`;break;default:s=`${M[e.anchor]} ${x[e.anchorMonth]}`;break}else if(e.relation==="pridie")if(o)s=`Prid. ${A[e.anchor]} ${w[e.anchorMonth]}`;else switch(r){case"nominative":s=`Pridie ${K[e.anchor]} ${Z[e.anchorMonth]}`;break;case"ablative":s=`Pridie ${M[e.anchor]} ${x[e.anchorMonth]}`;break;default:s=`Pridie ${_[e.anchor]} ${D[e.anchorMonth]}`;break}else{let a=n&&W[e.count]?W[e.count]:e.romanNumeral||(0,m.toRoman)(e.count);if(o)s=`a.d. ${e.romanNumeral||(0,m.toRoman)(e.count)} ${A[e.anchor]} ${w[e.anchorMonth]}`;else switch(r){case"nominative":s=`ante diem ${a} ${K[e.anchor]} ${Z[e.anchorMonth]}`;break;case"ablative":s=`ante diem ${a} ${M[e.anchor]} ${x[e.anchorMonth]}`;break;default:s=`ante diem ${a} ${_[e.anchor]} ${D[e.anchorMonth]}`;break}}if(t?.auc){let a=t.aucFormat==="numeric"?`AUC ${e.auc}`:`AUC ${(0,m.toRoman)(e.auc)}`;s=`${s} ${a}`}if(t?.casing)switch(t.casing){case"upper":s=s.toUpperCase();break;case"lower":s=s.toLowerCase();break;case"capitalize":s=s.charAt(0).toUpperCase()+s.slice(1);break;default:break}return s}function Ce(e){return(t,r)=>{let n=(r?.modifiers??[]).map(a=>a.toLowerCase());if(n.includes("auc")&&!n.includes("classical")&&!n.includes("short")&&!n.includes("nominative")&&!n.includes("accusative")&&!n.includes("ablative")&&!n.includes("consul")){let a=t.year+753,c=n.includes("num")||n.includes("numeric")?String(a):n.includes("raw")?(0,m.toRoman)(a)||String(a):`AUC ${(0,m.toRoman)(a)||a}`;return n.includes("upper")&&(c=c.toUpperCase()),n.includes("lower")&&(c=c.toLowerCase()),c}if(n.includes("consul")||n.includes("consuls")){let a=n.includes("nominative")||n.includes("nom")?"nominative":"ablative",c=$(t.year,a)??"";return n.includes("upper")&&(c=c.toUpperCase()),n.includes("lower")&&(c=c.toLowerCase()),c}let o=e(t.year,t.month,t.day),s={};return n.includes("short")?s.style="short":s.style="classical",n.includes("nominative")?s.case="nominative":n.includes("accusative")?s.case="accusative":n.includes("ablative")?s.case="ablative":s.case="customary",n.includes("words")&&(s.words=!0),n.includes("auc")&&(s.auc=!0),(n.includes("num")||n.includes("numeric"))&&(s.aucFormat="numeric"),n.includes("upper")?s.casing="upper":n.includes("lower")?s.casing="lower":n.includes("capitalize")&&(s.casing="capitalize"),E(o,s)}}function J(e){return le.has(e)?7:5}function q(e){return le.has(e)?15:13}function B(e,t){return t==="BCE"?754-Math.abs(e):t==="CE"?Math.abs(e)+753:e+753}function Ae(e,t="astronomical"){return t==="historical"?e>=754?Object.freeze({year:e-753,era:"CE"}):e>=1?Object.freeze({year:754-e,era:"BCE"}):Object.freeze({year:Math.abs(e-754)+1,era:"BCE"}):e-753}function C(e,t,r,i){let n=i?.isJulian??!1,o=i?.bissextile??!0,s=N(e,n),a=J(t),c=q(t),d,u=t,p=e,l,f=1,y=!1;r===1?(d="Kalends",l="on",f=1):r<a?(d="Nones",f=a-r+1,l=f===2?"pridie":"ante_diem"):r===a?(d="Nones",l="on",f=1):r<c?(d="Ides",f=c-r+1,l=f===2?"pridie":"ante_diem"):r===c?(d="Ides",l="on",f=1):(d="Kalends",u=t===12?1:t+1,p=t===12?e+1:e,t===2&&s&&o?r===24?(f=6,l="ante_diem",y=!0):r===25?(f=6,l="ante_diem",y=!1):r>25?(f=29-r+2,l=f===2?"pridie":"ante_diem"):(f=30-r,l="ante_diem"):(f=U(e,t,n)-r+2,l=f===2?"pridie":"ante_diem"));let g=l==="ante_diem"&&!y?(0,m.toRoman)(f):"",h="",b="";y?(h="ante diem bis sextum Kalendas Martias",b="a.d. bis VI Kal. Mart."):l==="on"?(h=`${M[d]} ${x[u]}`,b=`${A[d]} ${w[u]}`):l==="pridie"?(h=`Pridie ${_[d]} ${D[u]}`,b=`Prid. ${A[d]} ${w[u]}`):(h=`ante diem ${g} ${_[d]} ${D[u]}`,b=`a.d. ${g} ${A[d]} ${w[u]}`);let we=B(e),T={anchor:d,anchorMonth:u,anchorYear:p,relation:l,count:f,romanNumeral:y?"bis VI":g,isBissextile:y,day:r,month:t,year:e,auc:we,latin:h,shortLatin:b},S=E(T,{case:"nominative",style:"classical"}),R=E(T,{case:"accusative",style:"classical"}),F=E(T,{case:"ablative",style:"classical"});return Object.freeze({...T,nominative:S,accusative:R,ablative:F,format(Q){return E(this,Q)}})}function X(e,t,r,i,n=1,o=!1,s=!1,a=!0){if(e==="Kalends"){if(i==="on")return Object.freeze({year:r,month:t,day:1});let u=t===1?12:t-1,p=t===1?r-1:r,l=N(p,s),f=i==="pridie"?2:n;if(u===2&&l&&a)return o?Object.freeze({year:p,month:2,day:24}):f===6&&!o?Object.freeze({year:p,month:2,day:25}):f<6?Object.freeze({year:p,month:2,day:29-f+2}):Object.freeze({year:p,month:2,day:30-f});let y=U(p,u,s);return Object.freeze({year:p,month:u,day:y-f+2})}if(e==="Nones"){let u=J(t);return Object.freeze(i==="on"?{year:r,month:t,day:u}:{year:r,month:t,day:u-(i==="pridie"?2:n)+1})}let c=q(t);return Object.freeze(i==="on"?{year:r,month:t,day:c}:{year:r,month:t,day:c-(i==="pridie"?2:n)+1})}var Ye=e=>e.toLowerCase().replace(/j/g,"i"),Ot=Object.freeze({ian:1,feb:2,mar:3,apr:4,mai:5,iun:6,iul:7,aug:8,sep:9,oct:10,nov:11,dec:12}),fe=(()=>{let e=new Map;for(let t of[W,Se])t.forEach((r,i)=>{r&&i>2&&e.set(Ye(r),i)});return e})(),Et=new Set(["bce","bc","ac","aec"]),Ct=new Set(["ce","ad","ce."]);function ze(e){if(e){if(e==="kal"||e.startsWith("kalend")||e==="cal"||e.startsWith("calend"))return"Kalends";if(e==="non"||e==="nonis"||e==="nonas"||e==="nonae"||e==="nones")return"Nones";if(e==="id"||e==="idus"||e==="idibus")return"Ides"}}function At(e){if(!(!e||e.length<3))return Ot[e.slice(0,3)]}function He(e){return/^\d+$/.test(e)?Number(e):(0,m.fromRoman)(e)}function me(e,t){if(typeof e!="string"||!e.trim())throw new TypeError("Tempo.roman.parse requires a non-empty Latin date string");let r=S=>{throw new RangeError(`Unrecognised classical Roman date "${e}": ${S}`)},i=Ye(e).replace(/ab urbe condita/g,"auc").replace(/[.,;()]/g," ").split(/\s+/).filter(Boolean),n=0,o=(S=0)=>i[n+S],s=!1;o()==="ante"&&o(1)==="diem"||o()==="a"&&o(1)==="d"?(n+=2,s=!0):(o()==="ad"||o()==="die")&&(n+=1,s=!0);let a,c=1,d=!1;if(o()==="pridie"||o()==="prid")n+=1,a="pridie",c=2;else if(ze(o())&&!s)a="on";else{o()==="bis"&&(n+=1,d=!0);let S=o(1)?`${o()} ${o(1)}`:void 0,R=o()?He(o()):NaN;if(S&&fe.has(S))c=fe.get(S),n+=2;else if(o()&&fe.has(o()))c=fe.get(o()),n+=1;else if(Number.isFinite(R)&&R>=2)c=R,n+=1;else return r('expected a day count, "pridie", or an anchor (Kalends, Nones, Ides)');c>19&&r("the day count is out of range"),a=c===2?"pridie":"ante_diem"}o()==="ante"&&(n+=1);let u=ze(o());if(!u)return r("expected Kalends, Nones or Ides");n+=1;let p=At(o());if(!p)return r("expected a Latin month name");n+=1,d&&!(c===6&&u==="Kalends"&&p===3)&&r('"bis" is only valid for "ante diem bis sextum Kalendas Martias"');let l=i.slice(n),f;if(l.length){let S=l.indexOf("auc");if(S>=0){let R=He(l[S===0?1:S-1]??"");if(!Number.isFinite(R)||R<1||l.length!==2)return r("invalid AUC year");f=R-753}else if(l.length===2&&Et.has(l[1])&&/^\d+$/.test(l[0]))f=1-Number(l[0]);else if(l.length===2&&Ct.has(l[1])&&/^\d+$/.test(l[0]))f=Number(l[0]);else if(l.length===1&&/^-?\d+$/.test(l[0]))f=Number(l[0]);else{let R=l.join(" ").replace(/\b(coss?|consulibus|consule)\b/g,"").trim(),F=R?G(R):[];if(F.length===1)f=F[0].year;else return F.length>1?r(`ambiguous consular dating "${R}": multiple years match (${F.map(Q=>Q.year).join(", ")})`):r(`unexpected trailing text "${l.join(" ")}"`)}}if(f??=t?.year,f===void 0)return r('no year given; add "AUC", "BCE"/"CE", or pass options.year');let y=u==="Kalends"&&p===1&&a!=="on"?f+1:f,{month:g,day:h,year:b}=X(u,p,y,a,c,d,t?.isJulian??!1,t?.bissextile??!0),T=g>=1&&g<=12&&h>=1&&h<=U(b,g,t?.isJulian??!1)?C(b,g,h,t):void 0;return!T||T.anchor!==u||T.anchorMonth!==p||T.relation!==a||T.count!==c||T.isBissextile!==d?r("that expression does not describe a real calendar date"):Object.freeze({year:b,month:g,day:h,auc:T.auc,classical:T})}function P(e){if(!e)throw new TypeError("Invalid date input provided to Tempo.roman");if((0,m.isNumber)(e.yy)&&(0,m.isNumber)(e.mm)&&(0,m.isNumber)(e.dd))return{year:e.yy,month:e.mm,day:e.dd};if((0,m.isNumber)(e.year)&&(0,m.isNumber)(e.month)&&(0,m.isNumber)(e.day))return{year:e.year,month:e.month,day:e.day};if(e instanceof Date)return{year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()};if((0,m.isFunction)(e.toDateTime)){let t=e.toDateTime();return{year:t.year,month:t.month,day:t.day}}throw new TypeError("Invalid date input provided to Tempo.roman")}function wt(e){return{parse(t,r){let{year:i,month:n,day:o}=me(t,r);return new e({year:i,month:n,day:o})},parseDate(t,r){return me(t,r)},toClassical(t,r){let{year:i,month:n,day:o}=P(t);return C(i,n,o,r)},yearToAuc(t,r){return B(t,r)},aucToYear(t,r="astronomical"){return Ae(t,r)},getNonesDay(t){return J(t)},getIdesDay(t){return q(t)},isLeapYear(t,r){return N(t,r)},fromClassical(t,r,i,n,o=1,s=!1,a=!1,c=!0){return X(t,r,i,n,o,s,a,c)},format(t,r){let{year:i,month:n,day:o}=P(t),s=C(i,n,o,r);return E(s,r)},getConsuls(t){return Ee(t)},formatConsuls(t,r){return $(t,r)},findConsuls(t){return G(t)},registerConsuls(t){Oe(t)}}}var Ke=de({name:"roman",install(e){let t=wt(e);Object.defineProperty(e,"roman",{value:(0,m.deepFreeze)(t),writable:!1,configurable:!0,enumerable:!1}),e.prototype.toRomanClassical||(e.prototype.toRomanClassical=function(i){let{year:n,month:o,day:s}=P(this);return C(n,o,s,i)}),e.prototype.formatRoman||(e.prototype.formatRoman=function(i){let{year:n,month:o,day:s}=P(this),a=C(n,o,s,i);return E(a,i)}),e.prototype.toAUC||(e.prototype.toAUC=function(){let{year:i}=P(this);return B(i)}),Object.getOwnPropertyDescriptor(e.prototype,"auc")||Object.defineProperty(e.prototype,"auc",{get(){let{year:i}=P(this);return B(i)},configurable:!0,enumerable:!1}),Object.getOwnPropertyDescriptor(e.prototype,"roman")||Object.defineProperty(e.prototype,"roman",{get(){let{year:i,month:n,day:o}=P(this);return C(i,n,o)},configurable:!0,enumerable:!1}),Object.getOwnPropertyDescriptor(e.prototype,"consuls")||Object.defineProperty(e.prototype,"consuls",{get(){let{year:i}=P(this);return $(i)},configurable:!0,enumerable:!1});let r=Ce((i,n,o)=>C(i,n,o));e.use({registry:{tokens:{roman:r}}})}}),It=Ke;return Qe(Nt);})();
|