function n(n,r){if(!n)return null;const u=r.match(/[^A-Z]/i);if(!u)return null;const t=u[0];if(!n.includes(t))return null;const l=n.split(t),e=r.split(t);let i=null,f=null,Y=null;for(let n=0;n<e.length;n++){const r=e[n],u=l[n];if(!u)return null;if("DD"===r){if(2!==u.length)return null;i=Number(u)}if("MM"===r){if(2!==u.length)return null;f=Number(u)-1}if("YYYY"===r){if(4!==u.length)return null;Y=Number(u)}}if(null==i||null==f||null==Y)return null;const s=new Date(Y,f,i);return s.getFullYear()!==Y||s.getMonth()!==f||s.getDate()!==i?null:s}function r(n,r){if(!n)return"";const u=String(n.getDate()).padStart(2,"0"),t=String(n.getMonth()+1).padStart(2,"0"),l=n.getFullYear();switch(r){case"DD/MM/YYYY":default:return`${u}/${t}/${l}`;case"MM/DD/YYYY":return`${t}/${u}/${l}`;case"YYYY/MM/DD":return`${l}/${t}/${u}`;case"YYYY.MM.DD":return`${l}.${t}.${u}`;case"DD.MM.YYYY":return`${u}.${t}.${l}`}}function u(r,u,t,l){if(!t)return{first:n(r,u),second:null};if(!r.includes(l))return{first:n(r,u),second:null};const[e,i]=r.split(l);return{first:n(e,u),second:i?n(i,u):null}}function t(n,r){return n&&r&&n.getTime()>r.getTime()?[r,n]:[n,r]}export{r as f,t as n,u as p};
