import{i as e}from"./preload-helper-B45gAKPr.js";function t(e){let t=[],n=0,r=``,i=()=>{r&&=(t.push({kind:`literal`,text:r}),``)};for(;n<e.length;){let a=null;for(let t of l)if(e.slice(n,n+t.length)===t){a=t;break}if(!a){r+=e[n],n+=1;continue}i(),t.push({kind:`editable`,token:a,...c[a]}),n+=a.length}return i(),t}function n(e){return e.kind===`editable`}function r(e,t){let r=new Map;return t.forEach((t,i)=>{if(!n(t))return;if(!(e instanceof Date)||Number.isNaN(e.getTime())){r.set(i,``);return}let a=o(e,t);r.set(i,a)}),r}function i(e,t){return e.every((e,r)=>!n(e)||!(t.get(r)??``))}function a(e,t,r){let i=e.map((e,t)=>({segment:e,index:t})).filter(e=>n(e.segment));for(let{segment:e,index:n}of i)if((t.get(n)??``).length<e.length)return null;let a=r?.defaultDate??new Date(1970,0,1,0,0,0,0),o=s(i,t,`year`)??a.getFullYear(),c=s(i,t,`month`)??a.getMonth()+1,l=s(i,t,`day`)??a.getDate(),u=s(i,t,`hours`)??a.getHours(),d=s(i,t,`minutes`)??a.getMinutes(),f=s(i,t,`seconds`)??a.getSeconds();if(c<1||c>12||l<1||l>31||u<0||u>23||d<0||d>59||f<0||f>59)return null;let p=new Date(o,c-1,l,u,d,f,0);return p.getFullYear()===o&&p.getMonth()===c-1&&p.getDate()===l&&p.getHours()===u&&p.getMinutes()===d&&p.getSeconds()===f?p:null}function o(e,t){let n=String(e.getFullYear());switch(t.id){case`year`:return t.length===2?n.slice(-2):n.padStart(t.length,`0`);case`month`:return String(e.getMonth()+1).padStart(t.length,`0`);case`day`:return String(e.getDate()).padStart(t.length,`0`);case`hours`:return String(e.getHours()).padStart(t.length,`0`);case`minutes`:return String(e.getMinutes()).padStart(t.length,`0`);case`seconds`:return String(e.getSeconds()).padStart(t.length,`0`)}}function s(e,t,n){let r=e.find(({segment:e})=>e.id===n);if(!r)return null;let i=t.get(r.index);if(!i)return null;let a=Number.parseInt(i,10);return Number.isFinite(a)?n===`year`&&r.segment.length===2?a<70?2e3+a:1900+a:a:null}var c,l,u=e((()=>{c={YYYY:{id:`year`,length:4,min:1,max:9999,placeholder:`ГГГГ`,ariaLabel:`Год`},yyyy:{id:`year`,length:4,min:1,max:9999,placeholder:`гггг`,ariaLabel:`Год`},yy:{id:`year`,length:2,min:0,max:99,placeholder:`гг`,ariaLabel:`Год`},MM:{id:`month`,length:2,min:1,max:12,placeholder:`мм`,ariaLabel:`Месяц`},DD:{id:`day`,length:2,min:1,max:31,placeholder:`ДД`,ariaLabel:`День`},dd:{id:`day`,length:2,min:1,max:31,placeholder:`дд`,ariaLabel:`День`},hh:{id:`hours`,length:2,min:0,max:23,placeholder:`чч`,ariaLabel:`Часы`},HH:{id:`hours`,length:2,min:0,max:23,placeholder:`чч`,ariaLabel:`Часы`},mm:{id:`minutes`,length:2,min:0,max:59,placeholder:`мм`,ariaLabel:`Минуты`},ss:{id:`seconds`,length:2,min:0,max:59,placeholder:`сс`,ariaLabel:`Секунды`}},l=Object.keys(c).sort((e,t)=>t.length-e.length)}));export{a,t as i,r as n,u as r,i as t};