@opengis/form 0.1.20 → 0.1.22

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 (34) hide show
  1. package/dist/index-B1zV9Aax.js +1958 -0
  2. package/dist/index-B3op5uFx.js +68 -0
  3. package/dist/index-BABsOLAW.js +3085 -0
  4. package/dist/{index-C9G5e-HL.js → index-BEJfwrlY.js} +4251 -4198
  5. package/dist/index-CkUvn8lm.js +153 -0
  6. package/dist/index-D49VHc9h.js +237 -0
  7. package/dist/index-DZ7xh8lh.js +50 -0
  8. package/dist/index-MfTTOwHR.js +89 -0
  9. package/dist/index-RwV1hx3A.js +47 -0
  10. package/dist/index-W4UOw8lU.js +1159 -0
  11. package/dist/index-ietpNeqa.js +2843 -0
  12. package/dist/index-pYkcVgEL.js +12134 -0
  13. package/dist/index-qhd_7MCX.js +41 -0
  14. package/dist/index-sFkGqyu8.js +41 -0
  15. package/dist/index.js +1 -1
  16. package/dist/index.umd.cjs +185 -26
  17. package/dist/src/components/inputs/date/datepicker/Datepicker.vue.d.ts +5 -5
  18. package/dist/src/components/inputs/date/datepicker/DayPicker.vue.d.ts +2 -2
  19. package/dist/src/components/inputs/date/datepicker/MonthPicker.vue.d.ts +1 -1
  20. package/dist/src/components/inputs/date/datepicker/PickerPopup.vue.d.ts +1 -1
  21. package/dist/src/components/inputs/date/datepicker/Timepicker.vue.d.ts +1 -1
  22. package/dist/src/components/inputs/date/datepicker/YearPicker.vue.d.ts +1 -1
  23. package/dist/src/components/inputs/index.d.ts +7 -7
  24. package/dist/src/components/inputs/vs-input-inline-select.vue.d.ts +1 -1
  25. package/dist/src/components/inputs/vs-input-select.vue.d.ts +2 -2
  26. package/dist/src/components/layouts/vs-compact-form-layout.vue.d.ts +1 -1
  27. package/dist/src/components/ui/vs-info-tooltip.vue.d.ts.map +1 -1
  28. package/dist/src/richtext/components/shared-components/vs-dialog.vue.d.ts +1 -1
  29. package/dist/src/richtext/components/shared-components/vs-form-color-picker.vue.d.ts +1 -1
  30. package/dist/src/richtext/components/shared-components/vs-popover.vue.d.ts +4 -4
  31. package/dist/src/richtext/components/shared-components/vs-text.vue.d.ts +1 -1
  32. package/dist/src/richtext/components/vs-richtext.vue.d.ts +2 -2
  33. package/dist/{vs-richtext-Brf5R9Os.js → vs-richtext-3YmHHrZJ.js} +863 -881
  34. package/package.json +18 -5
@@ -1,51 +1,210 @@
1
- (function(be,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@opengis/core"),require("lucide-vue-next")):typeof define=="function"&&define.amd?define(["exports","vue","@opengis/core","lucide-vue-next"],e):(be=typeof globalThis<"u"?globalThis:be||self,e(be.FormBuilder={},be.Vue,be.OpenGISCore,be.lucide))})(this,function(be,e,he,X){"use strict";function _n(o,t,n){if(!Array.isArray(n)||!n.length)return null;const r=String(o?.preset??o?.renderer??"").trim().toLowerCase();if(r){const a=n.find(l=>String(l.id).trim().toLowerCase()===r);if(a)return a}return n.find(a=>typeof a.match=="function"&&a.match(o,t))??null}function nr(o,t,n){return!!_n(o,t,n)}const or=e.defineComponent({__name:"vs-info-tooltip",props:{text:{}},setup(o){const t=o,n=e.ref(!1),r=e.ref({top:"0px",left:"0px"});function a(s){if(!t.text)return;const c=s.currentTarget.getBoundingClientRect();r.value={top:`${c.bottom+4}px`,left:`${Math.min(c.left,window.innerWidth-230)}px`},n.value=!0}function l(){n.value=!1}return(s,c)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("span",{class:"inline-flex items-center",onMouseenter:a,onMouseleave:l},[e.renderSlot(s.$slots,"default",{},()=>[e.createVNode(e.unref(X.Info),{class:"h-4 w-4 text-gray-400 cursor-help"})])],32),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[n.value&&s.text?(e.openBlock(),e.createElementBlock("div",{key:0,style:e.normalizeStyle(r.value),class:"fixed z-[9999] max-w-xs p-2 bg-gray-900 text-white text-xs rounded-lg shadow-lg pointer-events-none"},e.toDisplayString(s.text),5)):e.createCommentVNode("",!0)]))],64))}}),ao={form:{autofillFrom:"Filled from",richtext:{paragraph:"Paragraph",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",heading4:"Heading 4",heading5:"Heading 5",heading6:"Heading 6",createTable:"Create Table",addColumn:"Add Column",addRow:"Add Row",deleteColumn:"Delete Column",deleteRow:"Delete Row",deleteTable:"Delete Table",mergeCells:"Merge Cells",splitCells:"Split Cells",linkTitle:"Enter Link",link:"Link",linkUrl:"Enter URL",editLink:"Edit Link",openLink:"Open Link",removeLink:"Remove Link",openInNewTab:"Open in New Tab",editor:"Editor",html:"HTML",markdown:"Markdown",create:"Create",update:"Update",cancel:"Cancel"}}},so={form:{autofillFrom:"Підставлено з",richtext:{paragraph:"Звичайний текст",heading1:"Заголовок 1",heading2:"Заголовок 2",heading3:"Заголовок 3",heading4:"Заголовок 4",heading5:"Заголовок 5",heading6:"Заголовок 6",createTable:"Створити таблицю",addColumn:"Додати колонку",addRow:"Додати рядок",deleteColumn:"Видалити колонку",deleteRow:"Видалити рядок",deleteTable:"Видалити таблицю",mergeCells:"Об'єднати комірки",splitCells:"Розділити комірки",linkTitle:"Додати посилання",link:"Посилання",linkUrl:"Введіть URL",editLink:"Редагувати посилання",openLink:"Відкрити посилання",removeLink:"Видалити посилання",openInNewTab:"Відкривати в новій вкладці",editor:"Редактор",html:"HTML",markdown:"Markdown",create:"Створити",update:"Оновити",cancel:"Скасувати"}}},Jl={class:"w-full relative"},Ql={key:0,class:"text-[14px] font-medium text-gray-900 mb-2 flex items-center gap-1"},ea={class:"opacity-100"},ta={key:0,class:"text-red-500 text-[14px]"},na={key:2,class:"text-[11px] text-slate-500 font-normal"},oa={key:1,class:"text-red-500 text-[10px] absolute bottom-[-14px]"},ra=e.defineComponent({__name:"vs-layout-default",props:{ua:{default:""},uk:{},en:{},de:{},es:{},fr:{},item:{default:()=>({})},error:{type:[String,Boolean],default:""},label:{default:""},columns:{}},setup(o){const t=o,n=e.computed(()=>typeof t.item?.label=="string"&&t.item.label?t.item.label:t.item?.ua||t.label||t.ua),r=e.computed(()=>!!n.value),a=e.computed(()=>!!t.item?.rules?.includes("required")),l=e.computed(()=>t.item?.info||""),s=e.inject("schema-by-name"),c={en:ao?.form?.autofillFrom,uk:so?.form?.autofillFrom},i=e.computed(()=>{const d=t.item?.__autoMeta;if(!d||d?.source!=="parent-auto"||!d?.parentField)return"";const h=String(t.item?.__locale||"uk"),g=String(d.parentField),p=s?.value?.[g],f=p?.[`label:${h}`]||(h!=="uk"?p?.[h]:void 0)||p?.label||p?.ua||p?.en||g;return`${c[h]||c.uk}: ${f}`});return(d,h)=>(e.openBlock(),e.createElementBlock("div",Jl,[r.value?(e.openBlock(),e.createElementBlock("div",Ql,[e.createElementVNode("span",ea,e.toDisplayString(n.value),1),a.value?(e.openBlock(),e.createElementBlock("span",ta,"*")):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createBlock(or,{key:1,text:l.value},null,8,["text"])):e.createCommentVNode("",!0),i.value?(e.openBlock(),e.createElementBlock("span",na," ("+e.toDisplayString(i.value)+") ",1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.renderSlot(d.$slots,"default",e.mergeProps(d.$attrs,{class:{"opacity-60":d.item.disabled}})),d.error?(e.openBlock(),e.createElementBlock("span",oa,e.toDisplayString(d.error),1)):e.createCommentVNode("",!0)]))}}),la={class:"w-full relative flex flex-row items-center gap-2"},aa={key:0,class:"text-red-500 text-[14px]"},sa={key:2,class:"text-[11px] text-slate-500 font-normal"},ia={key:1,class:"text-red-500 text-[10px] absolute bottom-[-14px]"},ca=e.defineComponent({__name:"vs-layout-horizontal",props:{ua:{default:""},uk:{},en:{},de:{},es:{},fr:{},item:{default:()=>({})},error:{type:[String,Boolean],default:""},label:{default:""},columns:{default:()=>({container:12,label:3})}},setup(o){const t=o,n=e.computed(()=>t.item?.label||t.label||t.ua),r=e.computed(()=>t.item?.info||""),a=e.inject("schema-by-name"),l={en:ao?.form?.autofillFrom,uk:so?.form?.autofillFrom},s=e.computed(()=>{const p=t.item?.__autoMeta;if(!p||p?.source!=="parent-auto"||!p?.parentField)return"";const f=String(t.item?.__locale||"uk"),m=String(p.parentField),k=a?.value?.[m],b=k?.[`label:${f}`]||(f!=="uk"?k?.[f]:void 0)||k?.label||k?.ua||k?.en||m;return`${l[f]||l.uk}: ${b}`}),c=e.computed(()=>t.columns??{container:12,label:3}),i=e.computed(()=>{const{container:p,label:f}=c.value;return!p||p<=0?0:Math.min(Math.max(f??0,0),p)/p}),d=e.computed(()=>t.item?.type==="html"||i.value<=0?!1:!!n.value),h=e.computed(()=>{if(!d.value)return{};const p=`${i.value*100}%`;return{flexBasis:p,maxWidth:p}}),g=e.computed(()=>{const{container:p,label:f}=c.value;if(!p||p<=0)return{};if(t.item?.type==="html")return{flexBasis:"100%",maxWidth:"100%"};if(!d.value)return{flexBasis:"100%",maxWidth:"100%"};const m=Math.max(p-Math.max(f??0,0),0)/p;if(!m)return{};const k=`${m*100}%`;return{flexBasis:k,maxWidth:k}});return(p,f)=>(e.openBlock(),e.createElementBlock("div",la,[d.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:"text-sm text-gray-900 font-medium flex shrink-0 items-center gap-1",style:e.normalizeStyle(h.value)},[e.createTextVNode(e.toDisplayString(n.value)+" ",1),p.item?.rules?.includes("required")&&n.value?(e.openBlock(),e.createElementBlock("span",aa,"*")):e.createCommentVNode("",!0),r.value?(e.openBlock(),e.createBlock(or,{key:1,text:r.value},null,8,["text"])):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",sa," ("+e.toDisplayString(s.value)+") ",1)):e.createCommentVNode("",!0)],4)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"flex-1 min-w-0",style:e.normalizeStyle(g.value)},[e.renderSlot(p.$slots,"default",e.normalizeProps(e.guardReactiveProps(p.$attrs)))],4),p.error?(e.openBlock(),e.createElementBlock("span",ia,e.toDisplayString(p.error),1)):e.createCommentVNode("",!0)]))}}),da={class:"w-full relative"},ua={key:0,class:"text-red-500 text-[10px] absolute bottom-[-14px]"},pa=e.defineComponent({__name:"vs-layout-inline",props:{ua:{default:""},uk:{},en:{},de:{},es:{},fr:{},item:{default:()=>({})},error:{type:[String,Boolean],default:""},label:{default:""},columns:{}},setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("div",da,[e.renderSlot(t.$slots,"default",e.normalizeProps(e.guardReactiveProps(t.$attrs))),t.error?(e.openBlock(),e.createElementBlock("span",ua,e.toDisplayString(t.error),1)):e.createCommentVNode("",!0)]))}}),ma={class:"flex-1 min-w-0"},fa={key:0,class:"text-sm font-medium text-slate-700 dark:text-slate-200 flex items-center gap-1"},ha={class:"truncate"},ga={key:0,class:"text-red-500 text-[14px]"},ya=["innerHTML"],ba={key:0,class:"mt-1 text-xs text-red-500"},ka={default:ra,horizontal:ca,inline:pa,settings:e.defineComponent({__name:"vs-layout-settings",props:{ua:{default:""},uk:{},en:{},de:{},es:{},fr:{},item:{default:()=>({})},error:{type:[String,Boolean],default:""},label:{default:""},columns:{}},setup(o){const t=o,n=e.ref("uk");e.computed(()=>(t.item??{})?.[n.value]??t.ua??t.label??"");const r=e.computed(()=>t.item?.description??""),a=e.computed(()=>Array.isArray(t.item?.rules)&&t.item.rules.includes("required")),l=e.computed(()=>(typeof t.error=="string"?t.error:"")??""),s=()=>{const c=typeof localStorage<"u"?localStorage.getItem("locale"):null;n.value=c||"uk"};return e.onMounted(()=>{try{typeof localStorage<"u"&&localStorage.locale&&(n.value=localStorage.locale)}catch{}window.addEventListener("storage",s)}),e.onUnmounted(()=>{window.removeEventListener("storage",s)}),(c,i)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["w-full relative",{"opacity-60":c.item?.disabled}])},[e.createElementVNode("div",{class:e.normalizeClass(["gap-2 md:flex-row md:items-center md:justify-between",[["switcher","native-select"].includes(c.item.type)?"flex flex-col":""]])},[e.createElementVNode("div",ma,[c.ua||c.label?(e.openBlock(),e.createElementBlock("p",fa,[e.createElementVNode("span",ha,e.toDisplayString(c.item[n.value]||c.ua||c.label),1),a.value?(e.openBlock(),e.createElementBlock("span",ga,"*")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),r.value?(e.openBlock(),e.createElementBlock("p",{key:1,class:"text-xs text-slate-500 dark:text-slate-400",innerHTML:r.value},null,8,ya)):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:e.normalizeClass(["w-full",["select","native-select"].includes(c.item.type)?"md:w-[30%]":"md:w-auto"])},[e.renderSlot(c.$slots,"default",e.normalizeProps(e.guardReactiveProps(c.$attrs)))],2)],2),l.value?(e.openBlock(),e.createElementBlock("p",ba,e.toDisplayString(l.value),1)):e.createCommentVNode("",!0)],2))}})};function Qe(o){return{inputClass:e.computed(()=>{const n=`disabled:opacity-50 disabled:cursor-not-allowed outline-none focus:ring-2 focus:ring-ring focus:ring-${o?.primaryColor||"blue"}-500 border border-solid border-stone-200 rounded-md text-sm text-stone-800 placeholder:text-stone-400 `;return o?.size==="sm"?`${n}h-[32px]`:`${n}h-[38px]`})}}const wa=["placeholder","disabled"],xa=e.defineComponent({__name:"vs-input-password",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,{inputClass:n}=Qe(t.style),r=e.useModel(o,"modelValue"),a=e.computed(()=>!!t.disabled),l=e.computed(()=>t.placeholder??"");return(s,c)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",{type:"password","onUpdate:modelValue":c[0]||(c[0]=i=>r.value=i),placeholder:l.value,disabled:a.value,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(n),{"!border-red-600":s.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,wa)),[[e.vModelText,r.value]])}}),va=["placeholder","disabled","maxlength","minlength"],Yt=e.defineComponent({__name:"vs-input-text",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:null},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,{inputClass:n}=Qe(t.style),r=e.useModel(o,"modelValue"),a=e.computed({get:()=>r.value??"",set:h=>{r.value=h===""?null:h}}),l=e.computed(()=>!!t.disabled),s=e.computed(()=>t.placeholder??""),c=e.computed(()=>t.maxlength??void 0),i=e.computed(()=>t.minlength??void 0);function d(){if(typeof r.value=="string"){const h=r.value.trim();r.value=h===""?null:h}}return(h,g)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",{type:"text","onUpdate:modelValue":g[0]||(g[0]=p=>a.value=p),placeholder:s.value,disabled:l.value,maxlength:c.value,minlength:i.value,onBlur:d,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[h.customClass,e.unref(n),{"!border-red-600":h.error}]]),style:{border:"1px solid #CFD9E0"}},null,42,va)),[[e.vModelText,a.value]])}}),_a=["step","placeholder","disabled","min","max"],rr=e.defineComponent({__name:"vs-input-number",props:e.mergeModels({style:{type:Object,default:()=>({})},placeholder:{type:String,default:""},disabled:{type:Boolean,default:!1},min:{type:Number,default:void 0},max:{type:Number,default:void 0},step:{type:[Number,String],default:void 0}},{modelValue:{default:null},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,{inputClass:n}=Qe(t.style),r=e.useAttrs(),a=e.useModel(o,"modelValue"),l=e.computed(()=>!!t.disabled),s=h=>{if(h==null||h==="")return;const g=typeof h=="string"?h.trim().replace(",","."):h,p=Number(g);return Number.isFinite(p)?p:void 0},c=e.computed(()=>s(t.min??r.min)),i=e.computed(()=>s(t.max??r.max)),d=e.computed(()=>{if(t.step!==void 0&&t.step!==null&&t.step!=="")return t.step;const h=r.step;return typeof h=="number"||typeof h=="string"?h:"any"});return(h,g)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",{type:"number",step:d.value,"onUpdate:modelValue":g[0]||(g[0]=p=>a.value=p),placeholder:o.placeholder,disabled:l.value,class:e.normalizeClass(["py-1.5 px-3 block w-full bg-white",[e.unref(n)]]),style:{border:"1px solid #CFD9E0"},min:c.value,max:i.value},null,10,_a)),[[e.vModelText,a.value]])}}),Cn=o=>!!String(o??"").trim(),Dt=o=>o?.color?String(o.color):"",on=o=>{const t=o?.icon;if(typeof t=="string")return t;const n=o?.imgUrl;return typeof n=="string"?n:""},rn=o=>{const t=o?.icon;return t&&typeof t!="string"?t:null},Ca={class:"flex items-center gap-[4px]"},Ea=["value","id","disabled"],Ba=["for"],Va=["innerHTML"],Sa={key:1,class:"text-[14px] text-gray-700 flex items-center gap-2 dark:text-neutral-400"},$a=["src"],Aa=e.defineComponent({__name:"vs-checkbox-default",props:{value:{default:""},label:{default:""},html:{default:""},disabled:{type:Boolean,default:!1},id:{},modelValue:{default:""},info:{},error:{},option:{default:null}},emits:["update:modelValue"],setup(o,{emit:t}){const n=t,r=o,a=e.computed({get:()=>r.modelValue,set:f=>n("update:modelValue",f)}),l=e.computed(()=>!!r.disabled),s=e.computed(()=>on(r.option)),c=e.computed(()=>rn(r.option)),i=e.computed(()=>Dt(r.option)),d=e.computed(()=>!!(i.value&&!s.value&&!c.value)),h=e.computed(()=>!!(s.value&&i.value)),g=e.computed(()=>i.value?{color:i.value}:void 0),p=e.computed(()=>{if(!(!s.value||!i.value))return{backgroundColor:i.value,WebkitMaskImage:`url(${s.value})`,maskImage:`url(${s.value})`,WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskPosition:"center",maskPosition:"center"}});return(f,m)=>(e.openBlock(),e.createElementBlock("div",Ca,[e.withDirectives(e.createElementVNode("input",{type:"checkbox",value:f.value,"onUpdate:modelValue":m[0]||(m[0]=k=>a.value=k),class:e.normalizeClass(["shrink-0 border border-solid hidden border-gray-700 w-3.5 h-3.5 rounded text-blue-600 focus:ring-offset-0 dark:bg-neutral-800 dark:border-neutral-700 cursor-pointer",{"!cursor-not-allowed":l.value}]),id:f.id,disabled:l.value},null,10,Ea),[[e.vModelCheckbox,a.value]]),e.createElementVNode("label",{for:f.id,class:e.normalizeClass(["flex flex-1 checkbox-label items-center gap-x-2 cursor-pointer text-sm text-gray-800 dark:text-neutral-300",{"!cursor-not-allowed":l.value}])},[e.createElementVNode("div",{class:e.normalizeClass(["h-[16px] text-white w-[16px] flex items-center justify-center shrink-0 border rounded",[a.value?"bg-blue-600 border-blue-600":"bg-white border-gray-600",f.error?"border-red-600":""]])},[e.createVNode(e.unref(X.Check),{class:"h-4 w-4"})],2),f.html?(e.openBlock(),e.createElementBlock("div",{key:0,class:"w-full",innerHTML:f.html},null,8,Va)):(e.openBlock(),e.createElementBlock("span",Sa,[d.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:"inline-flex h-3 w-3 rounded-full border border-gray-200",style:e.normalizeStyle({background:i.value})},null,4)):e.createCommentVNode("",!0),h.value?(e.openBlock(),e.createElementBlock("span",{key:1,class:"inline-block h-4 w-4",style:e.normalizeStyle(p.value)},null,4)):s.value?(e.openBlock(),e.createElementBlock("img",{key:2,class:"block",height:"16",width:"16",src:s.value,alt:"icon"},null,8,$a)):c.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(c.value),{key:3,class:"h-4 w-4",style:e.normalizeStyle(g.value)},null,8,["style"])):e.createCommentVNode("",!0),e.renderSlot(f.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(f.label),1)])]))],10,Ba)]))}}),Na=["name","value","disabled"],Ma=["innerHTML"],Fa={key:1,class:"flex items-center gap-[6px] text-[14px]"},Da={key:2,class:"text-[16px] inline-flex items-center justify-center"},Ta=["src"],La=e.defineComponent({__name:"vs-checkbox-buttons",props:{value:{type:[String,Number,Boolean],default:""},label:{default:""},html:{default:""},modelValue:{default:""},disabled:{type:Boolean},id:{},icon:{},imgUrl:{},style:{},option:{}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o,r=t,a=e.computed({get:()=>n.modelValue,set:k=>{r("update:modelValue",k)}}),l=e.computed(()=>Array.isArray(a.value)?a.value.includes(n.value):a.value===!0||a.value===n.value),s=e.computed(()=>n.style?.size==="xs"?"p-1.5 text-xs":n.style?.size==="lg"?"p-3.5 text-[20px]":"p-2.5 text-xs"),c=e.computed(()=>({...n.option??{},icon:n.option?.icon??n.icon,imgUrl:n.option?.imgUrl??n.imgUrl,color:n.option?.color})),i=e.computed(()=>on(c.value)),d=e.computed(()=>rn(c.value)),h=e.computed(()=>Dt(c.value)),g=e.computed(()=>!!(h.value&&!i.value&&!d.value)),p=e.computed(()=>!!(i.value&&h.value)),f=e.computed(()=>h.value?{color:h.value}:void 0),m=e.computed(()=>{if(!(!i.value||!h.value))return{backgroundColor:h.value,WebkitMaskImage:`url(${i.value})`,maskImage:`url(${i.value})`,WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskPosition:"center",maskPosition:"center"}});return(k,b)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(["group relative flex justify-center items-center gap-x-3 text-center bg-white text-gray-800 ring-ring ring-2 cursor-pointer rounded-lg",[s.value,l.value?"ring-blue-500":"border border-gray-200 ring-transparent"]])},[e.withDirectives(e.createElementVNode("input",{type:"checkbox",class:"hidden",name:k.id,value:k.value,"onUpdate:modelValue":b[0]||(b[0]=_=>a.value=_),disabled:k.disabled},null,8,Na),[[e.vModelCheckbox,a.value]]),k.html?(e.openBlock(),e.createElementBlock("span",{key:0,class:"w-full",innerHTML:k.html},null,8,Ma)):(e.openBlock(),e.createElementBlock("span",Fa,[g.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:"inline-flex h-3 w-3 rounded-full border border-gray-200",style:e.normalizeStyle({background:h.value})},null,4)):e.createCommentVNode("",!0),p.value?(e.openBlock(),e.createElementBlock("span",{key:1,class:"inline-block h-4 w-4",style:e.normalizeStyle(m.value)},null,4)):i.value||d.value?(e.openBlock(),e.createElementBlock("span",Da,[i.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:i.value,width:"16",height:"16",alt:"icon"},null,8,Ta)):d.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(d.value),{key:1,class:"h-4 w-4",style:e.normalizeStyle(f.value)},null,8,["style"])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.renderSlot(k.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(k.label),1)])]))],2))}}),Ia={class:"flex items-center"},io=e.defineComponent({__name:"vs-input-checkbox-item",props:{value:{default:""},label:{default:""},labelHtml:{default:""},disabled:{type:Boolean,default:!1},view:{default:"default"},modelValue:{type:[Boolean,Array],default:!1},icon:{},imgUrl:{},slots:{},option:{},style:{},error:{default:""}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o,r=t,a=`radio-${Math.floor(Math.random()*1e4)}`,l=e.computed({get:()=>Array.isArray(n.modelValue)?Array.isArray(n.modelValue)&&n.modelValue.includes(n.value):n.modelValue,set:c=>{if(Array.isArray(n.modelValue)){let i=[...n.modelValue];c?i.includes(n.value)||i.push(n.value):i=i.filter(d=>d!==n.value),r("update:modelValue",i)}else r("update:modelValue",c)}}),s=e.ref(`vs-checkbox-${n.view||"default"}`);return(c,i)=>(e.openBlock(),e.createElementBlock("div",Ia,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(s.value==="vs-checkbox-buttons"?e.unref(La):e.unref(Aa)),{value:c.value,label:c.label,html:c.labelHtml,info:c.option?.info,disabled:c.disabled,modelValue:l.value,"onUpdate:modelValue":i[0]||(i[0]=d=>l.value=d),id:a,icon:c.icon,imgUrl:c.imgUrl,option:c.option,style:e.normalizeStyle(c.style),error:c.error},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(c.label),1)]),_:1},8,["value","label","html","info","disabled","modelValue","icon","imgUrl","option","style","error"]))]))}}),Oa={key:0,class:"flex items-start gap-x-1"},Pa={key:0,class:"text-red-500 text-[14px]"},Ra=["title"],za=["disabled"],co=e.defineComponent({__name:"vs-input-switcher",props:e.mergeModels({rules:{default:()=>[]},view:{default:"checkbox"},label:{default:""},i:{default:""},text:{default:""},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue");return(r,a)=>t.view==="checkbox"?(e.openBlock(),e.createElementBlock("div",Oa,[e.createVNode(io,{modelValue:n.value,"onUpdate:modelValue":a[0]||(a[0]=l=>n.value=l),error:r.error||""},null,8,["modelValue","error"]),r.rules?.includes("required")?(e.openBlock(),e.createElementBlock("span",Pa,"*")):e.createCommentVNode("",!0),r.i?(e.openBlock(),e.createElementBlock("button",{key:1,class:"cursor-pointer",title:r.i,onClick:a[1]||(a[1]=e.withModifiers(()=>{},["prevent"]))},[e.createVNode(e.unref(X.Info),{class:"h-4 w-4 text-gray-500"})],8,Ra)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:e.normalizeClass(["inline-flex h-5 w-9 shrink-0 px-[2px] cursor-pointer items-center rounded-full shadow-sm disabled:cursor-not-allowed disabled:opacity-50",[n.value?`bg-${r.style?.primaryColor||"blue"}-500`:"bg-stone-200",r.customClass]]),disabled:r.disabled,onClick:a[2]||(a[2]=l=>n.value=!n.value)},[e.createElementVNode("span",{"data-state":"checked",class:e.normalizeClass(["pointer-events-none block h-4 w-4 rounded-full bg-white shadow-lg ring-0 transition-transform",[n.value?"translate-x-4":"translate-x-0"]])},null,2)],10,za))}}),ja=["id","innerHTML"],uo=e.defineComponent({__name:"vs-input-static",props:{text:{default:""},html:{default:""},style:{},customClass:{default:""},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("div",{id:t.name,class:e.normalizeClass(["text-gray-900",t.customClass]),innerHTML:t.html?t.html:t.text},null,10,ja))}}),Ua=["placeholder","disabled","name"],En=e.defineComponent({__name:"vs-input-mask",props:e.mergeModels({name:{},mask:{default:""},unmask:{type:Boolean,default:!1},placeholder:{default:"_"},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,{inputClass:n}=Qe(t.style),r=e.useModel(o,"modelValue"),a=e.ref(null);let l=null;function s(c){const i=c==null?"":String(c),d={9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},h=new Set;let g=!1;for(let f=0;f<i.length;f+=1){const m=i[f];m==="{"?g=!0:m==="}"?g=!1:g&&h.add(m)}const p={};return Object.keys(d).forEach(f=>{h.has(f)||(p[f]=d[f])}),{mask:i,definitions:p,lazy:!1}}return e.onMounted(async()=>{if(a.value){const{default:c}=await Promise.resolve().then(()=>Qn),i=s(t.mask||"");l=c(a.value,i),l.on("accept",()=>{r.value=t.unmask?l.unmaskedValue:l.value}),l.on("complete",()=>{r.value=t.unmask?l.unmaskedValue:l.value}),l.value=r.value!=null?String(r.value):""}}),e.onBeforeUnmount(()=>{l?.destroy()}),e.watch(()=>t.mask,c=>{if(l){const i=s(c||"");l.updateOptions(i)}}),e.watch(r,c=>{l&&l.unmaskedValue!==c&&(l.value=c!=null?String(c):"")}),(c,i)=>(e.openBlock(),e.createElementBlock("input",{type:"text",ref_key:"inputEl",ref:a,placeholder:c.placeholder,disabled:c.disabled,name:c.name,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(n)]]),style:{border:"1px solid #CFD9E0"}},null,10,Ua))}}),Ha={class:"relative w-full bg-white rounded-lg"},qa={class:"absolute bottom-2/4 translate-y-2/4 left-[10px] cursor-pointer"},Wa=["placeholder","disabled"],po=e.defineComponent({__name:"vs-input-email",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:null},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,{inputClass:n}=Qe(t.style),r=e.useModel(o,"modelValue");return(a,l)=>(e.openBlock(),e.createElementBlock("div",Ha,[e.createElementVNode("div",qa,[e.createVNode(e.unref(X.Mail),{class:"h-4 w-4 stroke-gray-500 transition-all"})]),e.withDirectives(e.createElementVNode("input",{type:"email","onUpdate:modelValue":l[0]||(l[0]=s=>r.value=s),placeholder:a.placeholder,disabled:a.disabled,class:e.normalizeClass(["!pl-8 py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(n),{"!border-red-600":a.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,Wa),[[e.vModelText,r.value]])]))}}),Et="+99(999)-999-99-99";function Tt(o){if(!o?.trim())return 0;const t=new Set(["9","0","a","A","*"]);let n=!1,r=0;for(let a=0;a<o.length;a+=1){const l=o[a];if(l==="{"){n=!0;continue}if(l==="}"){n=!1;continue}!n&&t.has(l)&&(r+=1)}return r}const Ka={class:"relative w-full bg-white rounded-lg"},Ga={class:"absolute bottom-2/4 translate-y-2/4 left-[10px] pointer-events-none"},Ya=["name","placeholder","disabled","pattern"],mo=e.defineComponent({__name:"vs-input-tel",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:null},name:{},placeholder:{default:""},maxlength:{},minlength:{},mask:{default:Et}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.computed(()=>`^\\+[1-9]\\d{${(Tt(t.mask||Et)||Tt(Et))-1}}$`),{inputClass:r}=Qe(t.style),a=e.useModel(o,"modelValue"),l=e.ref(null);let s=null;function c(h){const g={9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},p=new Set;let f=!1;for(let k=0;k<h.length;k+=1){const b=h[k];b==="{"?f=!0:b==="}"?f=!1:f&&p.add(b)}const m={};return Object.keys(g).forEach(k=>{p.has(k)||(m[k]=g[k])}),{mask:h,definitions:m,lazy:!1,disabled:t.disabled}}function i(h){if(h==null||h==="")return"";const g=String(h).trim();return g?g.replace(/\D/g,""):""}function d(){if(!s)return;const h=s.unmaskedValue??"";a.value=h?`+${h}`:""}return e.onMounted(async()=>{if(!l.value)return;const{default:h}=await Promise.resolve().then(()=>Qn),g=c(t.mask||"");s=h(l.value,g),s.on("accept",d),s.on("complete",d);const p=i(a.value);s.unmaskedValue=p}),e.onBeforeUnmount(()=>{s?.destroy(),s=null}),e.watch(()=>t.mask,h=>{s&&s.updateOptions(c(h||""))}),e.watch(()=>t.disabled,h=>{s&&s.updateOptions({disabled:h})}),e.watch(a,h=>{if(!s)return;const g=i(h);s.unmaskedValue!==g&&(s.unmaskedValue=g)}),(h,g)=>(e.openBlock(),e.createElementBlock("div",Ka,[e.createElementVNode("div",Ga,[e.createVNode(e.unref(X.Phone),{class:"h-4 w-4 stroke-gray-500 transition-all"})]),e.createElementVNode("input",{ref_key:"inputEl",ref:l,type:"tel",name:h.name,placeholder:h.placeholder,disabled:h.disabled,pattern:n.value,title:"Міжнародний номер (E.164), наприклад +380XXXXXXXXX",autocomplete:"tel",class:e.normalizeClass(["!pl-10 py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(r),{"!border-red-600":h.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,Ya)]))}}),Xa=["value","disabled"],Za=["innerHTML"],Ja={key:1,class:"flex items-center gap-2"},Qa=["src"],es={class:"text-[13px] text-gray-700"},ts=e.defineComponent({__name:"vs-input-radio-default",props:e.mergeModels({style:{},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{},value:{},text:{},html:{default:""},option:{default:null}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.computed(()=>!!t.disabled),a=e.computed(()=>on(t.option)),l=e.computed(()=>rn(t.option)),s=e.computed(()=>Dt(t.option)),c=e.computed(()=>!!(s.value&&!a.value&&!l.value)),i=e.computed(()=>!!(a.value&&s.value)),d=e.computed(()=>s.value?{color:s.value}:void 0),h=e.computed(()=>{if(!(!a.value||!s.value))return{backgroundColor:s.value,WebkitMaskImage:`url(${a.value})`,maskImage:`url(${a.value})`,WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskPosition:"center",maskPosition:"center"}});return(g,p)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(["flex items-center gap-0",[t.customClass,r.value?"cursor-not-allowed opacity-60":""]])},[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":p[0]||(p[0]=f=>n.value=f),type:"radio",value:t.value,disabled:r.value,class:"hidden"},null,8,Xa),[[e.vModelRadio,n.value]]),e.createElementVNode("span",{class:e.normalizeClass(["w-[16px] shrink-0 h-[16px] border rounded-full flex items-center justify-center mr-[10px]",[`border-${t.style?.primaryColor||"blue"}-500`,r.value?"opacity-50 cursor-not-allowed":""]])},[n.value==t.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["w-[12px] h-[12px] shrink-0 rounded-full",[`bg-${t.style?.primaryColor||"blue"}-500`]])},null,2)):e.createCommentVNode("",!0)],2),t.html?(e.openBlock(),e.createElementBlock("div",{key:0,class:"w-full",innerHTML:t.html},null,8,Za)):(e.openBlock(),e.createElementBlock("div",Ja,[c.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:"inline-flex h-3 w-3 rounded-full border border-gray-200",style:e.normalizeStyle({background:s.value})},null,4)):e.createCommentVNode("",!0),i.value?(e.openBlock(),e.createElementBlock("span",{key:1,class:"inline-block h-4 w-4",style:e.normalizeStyle(h.value)},null,4)):a.value?(e.openBlock(),e.createElementBlock("img",{key:2,class:"block",height:"16",width:"16",src:a.value,alt:"icon"},null,8,Qa)):l.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(l.value),{key:3,class:"h-4 w-4",style:e.normalizeStyle(d.value)},null,8,["style"])):e.createCommentVNode("",!0),e.createElementVNode("span",es,e.toDisplayString(t.text),1)]))],2))}}),ns=["value","disabled"],os=["innerHTML"],rs={key:1,class:"flex items-center gap-2"},ls=["src"],as={class:"text-[13px] text-gray-700"},ss={"vs-input-radio-default":ts,"vs-input-radio-buttons":e.defineComponent({__name:"vs-input-radio-buttons",props:e.mergeModels({style:{},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{},value:{},text:{},html:{default:""},option:{default:null}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.computed(()=>!!t.disabled),a=e.computed(()=>on(t.option)),l=e.computed(()=>rn(t.option)),s=e.computed(()=>Dt(t.option)),c=e.computed(()=>!!(s.value&&!a.value&&!l.value)),i=e.computed(()=>!!(a.value&&s.value)),d=e.computed(()=>s.value?{color:s.value}:void 0),h=e.computed(()=>{if(!(!a.value||!s.value))return{backgroundColor:s.value,WebkitMaskImage:`url(${a.value})`,maskImage:`url(${a.value})`,WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskPosition:"center",maskPosition:"center"}});return(g,p)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(["flex h-full w-full items-center border rounded-lg px-2 py-1",[n.value==t.value?`ring-2 ring-ring ring-${t.style?.primaryColor||"blue"}-500`:"",t.customClass,r.value?"cursor-not-allowed opacity-60":""]])},[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":p[0]||(p[0]=f=>n.value=f),type:"radio",value:t.value,disabled:r.value,class:"hidden"},null,8,ns),[[e.vModelRadio,n.value]]),t.html?(e.openBlock(),e.createElementBlock("div",{key:0,class:"w-full",innerHTML:t.html},null,8,os)):(e.openBlock(),e.createElementBlock("div",rs,[c.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:"inline-flex h-3 w-3 rounded-full border border-gray-200",style:e.normalizeStyle({background:s.value})},null,4)):e.createCommentVNode("",!0),i.value?(e.openBlock(),e.createElementBlock("span",{key:1,class:"inline-block h-4 w-4",style:e.normalizeStyle(h.value)},null,4)):a.value?(e.openBlock(),e.createElementBlock("img",{key:2,class:"block",height:"16",width:"16",src:a.value,alt:"icon"},null,8,ls)):l.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(l.value),{key:3,class:"h-4 w-4",style:e.normalizeStyle(d.value)},null,8,["style"])):e.createCommentVNode("",!0),e.createElementVNode("span",as,e.toDisplayString(t.text),1)]))],2))}})},lr=o=>Array.isArray(o)?o:Array.isArray(o?.data)?o.data:[],ar=o=>{const t=o.host??"",n=o.prefix??"api",r=o.api??`/${n}/suggest/${o.data}`;return`${t}${r}`},is=o=>({fetchOptions:async(r="")=>{const a=o();if(!a.data)return a.options?[...a.options]:[];try{const l=new URLSearchParams;r&&l.set("key",r),a.parentValue!==void 0&&a.parentValue!==null&&a.parentValue!==""&&l.set("parent",String(a.parentValue)),a.start===1&&l.set("start","1");const c=await(await fetch(`${ar(a)}?${l.toString()}`)).json();return lr(c)}catch{return[]}},fetchOptionByValue:async r=>{if(r==null||r==="")return null;const a=o();if(!a.data)return(a.options??[]).find(s=>s?.id?.toString()===String(r))??null;try{const l=new URLSearchParams;l.set("val",String(r)),a.parentValue!==void 0&&a.parentValue!==null&&a.parentValue!==""&&l.set("parent",String(a.parentValue)),a.start===1&&l.set("start","1");const c=await(await fetch(`${ar(a)}?${l.toString()}`)).json();return lr(c)[0]??null}catch{return null}}}),Bn=({props:o,formValues:t=null,watchParent:n=!0})=>{const r=e.ref([]),a=e.computed(()=>o.parent?t?.value?.[o.parent]?.toString?.()??null:null),{fetchOptions:l,fetchOptionByValue:s}=is(()=>({data:o.data,options:o.options,api:o.api,prefix:o.prefix,host:o.host,start:o.start,parentValue:a.value})),c=async(i="")=>{const d=o.data?await l(i):o.options?[...o.options]:[];return r.value=d,r.value};return e.watch(()=>o.options,()=>{o.data||(r.value=o.options?[...o.options]:[])},{immediate:!0,deep:!0}),n&&e.watch(a,async()=>{o.data&&(r.value=await l())},{immediate:!1}),{optionsList:r,parentValue:a,fetchOptions:l,fetchOptionByValue:s,loadOptions:c}},cs=/\{\{\s*([^}]+?)\s*\}\}/g,ds=o=>(o?String(o):"").replace(/<[^>]*>/g,"").trim(),us=(o,t)=>t.split(".").reduce((n,r)=>n==null?n:n[r.trim()],o),Vn=(o,t)=>{if(!o)return"";const n=(t??"").trim();return n?n.replace(cs,(r,a)=>{const l=String(a).trim(),s=o,i=(l.includes(".")?us(s,l):void 0)??s[l];return i!=null?String(i):""}):o.text??""},Sn=(o,t)=>{if(!o)return"";const n=Vn(o,t);return ds(n)||o.text||""},fo=e.defineComponent({__name:"vs-input-radio",props:e.mergeModels({options:{},slot:{},data:{},api:{},prefix:{},host:{},start:{},parent:{},position:{default:"vertical"},view:{default:"default"},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.computed(()=>ss[`vs-input-radio-${t.view}`]),a=e.computed(()=>t.slot??t?.optionTemplate??""),l=e.computed(()=>Cn(a.value)),s=f=>Vn(f,a.value),c=f=>Sn(f,a.value),i=e.computed(()=>t.position==="horizontal"?"flex w-full flex-row flex-wrap gap-[10px]":"flex w-full flex-col gap-2"),d=e.computed(()=>{if(t.position==="horizontal"&&t.customClass?.includes("50%"))return{flex:"0 0 calc(50% - 5px)"}}),h=e.inject("values",null),{optionsList:g,loadOptions:p}=Bn({props:t,formValues:h});return e.onMounted(async()=>{await p()}),(f,m)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(i.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g),k=>(e.openBlock(),e.createElementBlock("div",{key:k?.id,class:e.normalizeClass(["flex items-stretch",f.position==="horizontal"?t.customClass:""]),style:e.normalizeStyle(d.value)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r.value),e.mergeProps({text:c(k),html:l.value?s(k):"",option:k,value:k.id.toString(),checked:n.value?.toString?.()===k.id?.toString?.(),"custom-class":f.position==="horizontal"?"":t.customClass,modelValue:n.value,"onUpdate:modelValue":m[0]||(m[0]=b=>n.value=b)},{ref_for:!0},f.$attrs),null,16,["text","html","option","value","checked","custom-class","modelValue"]))],6))),128))],2))}}),ps={key:1,class:"w-full flex flex-col gap-4"},ms={key:0,class:"text-sm font-medium text-muted-foreground my-2"},fs="Без категорії",hs=e.defineComponent({__name:"vs-input-checkbox",props:{options:{default:()=>[]},position:{default:"vertical"},slots:{default:null},slot:{},colSpan:{default:0},data:{},api:{},prefix:{},host:{},start:{},parent:{},view:{},group:{default:void 0},values:{default:()=>[]},style:{},customClass:{},disabled:{type:Boolean},modelValue:{default:!1},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o,r=t,a=e.reactive({}),l=e.inject("values",null),{optionsList:s,loadOptions:c}=Bn({props:{...n,options:n.options},formValues:l}),i=e.computed(()=>s.value),d=C=>C?.value||C?.id||C?.text||C,h=e.computed(()=>n.slot??n?.optionTemplate??""),g=e.computed(()=>Cn(h.value)),p=C=>Vn(C,h.value),f=C=>Sn(C,h.value),m=C=>`lg:col-span-${C||12}`,k=e.computed(()=>[n.position==="vertical"?"flex flex-col":"",n.colSpan?"grid":"flex justify-start"]),b=C=>C==null||C===""?null:typeof C=="string"||typeof C=="number"?C:String(C),_=e.computed(()=>{if(!n.group)return[];const C=new Map;i.value.forEach(I=>{const E=I[n.group],V=b(E);C.has(V)||C.set(V,[]),C.get(V)?.push(I)});const N=[];n.values?.length&&n.values.forEach(I=>{const E=b(I);N.push(E)});const $=new Set,q=I=>{const E=C.get(I)||[];if(!E.length)return null;const V=I===null?"group-null":`group-${String(I)}`,v=I===null?fs:String(I);return $.add(I),{key:V,label:v,options:E}},G=[];return N.forEach(I=>{const E=q(I);E&&G.push(E)}),C.forEach((I,E)=>{if($.has(E))return;const V=q(E);V&&G.push(V)}),G});return e.watch(()=>n.modelValue,C=>{if(typeof C=="boolean"&&i.value.length===1){const N=d(i.value[0]);a[N]=C}else if(Array.isArray(C)){const N=new Set(C);i.value.forEach($=>{if(!$.disabled){const q=d($);a[q]=N.has(q)}})}},{immediate:!0}),e.watch(a,()=>{if(!i.value.length){r("update:modelValue",null);return}const C=Object.entries(a).filter(([,N])=>N).map(([N])=>N);r("update:modelValue",C.length===0?[]:C)},{deep:!0}),e.onMounted(async()=>{if(await c(),typeof n.modelValue=="boolean"&&i.value.length===1){const C=d(i.value[0]);a[C]=n.modelValue}else if(Array.isArray(n.modelValue)){const C=new Set(n.modelValue);i.value.forEach(N=>{if(!N.disabled){const $=d(N);a[$]=C.has($)}})}}),(C,N)=>n.group?(e.openBlock(),e.createElementBlock("div",ps,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_.value,$=>(e.openBlock(),e.createElementBlock("div",{key:$.key,class:"flex flex-col gap-2"},[$.label?(e.openBlock(),e.createElementBlock("span",ms,e.toDisplayString($.label),1)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["p-0 w-full gap-[12px]",k.value])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList($.options,q=>(e.openBlock(),e.createBlock(io,{modelValue:a[d(q)],"onUpdate:modelValue":G=>a[d(q)]=G,value:d(q),class:e.normalizeClass(m(C.colSpan)),disabled:n.disabled||q.disabled,label:f(q),labelHtml:g.value?p(q):"",key:`${$.key}-${d(q)}`,icon:q?.icon,imgUrl:q?.imgUrl,option:q,view:C.view},null,8,["modelValue","onUpdate:modelValue","value","class","disabled","label","labelHtml","icon","imgUrl","option","view"]))),128))],2)]))),128))])):(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["p-0 w-full gap-[10px]",k.value])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,$=>(e.openBlock(),e.createBlock(io,{modelValue:a[d($)],"onUpdate:modelValue":q=>a[d($)]=q,value:d($),class:e.normalizeClass(m(C.colSpan)),disabled:n.disabled||$.disabled,label:f($),labelHtml:g.value?p($):"",key:d($),icon:$?.icon,imgUrl:$?.imgUrl,option:$,view:C.view},null,8,["modelValue","onUpdate:modelValue","value","class","disabled","label","labelHtml","icon","imgUrl","option","view"]))),128))],2))}}),Ce=(o,t)=>{const n=o.__vccOpts||o;for(const[r,a]of t)n[r]=a;return n},sr=Ce(hs,[["__scopeId","data-v-9056e0ec"]]),gs=1440*60*1e3,ys=["січень","лютий","березень","квітень","травень","червень","липень","серпень","вересень","жовтень","листопад","грудень"],bs=["січ","лют","бер","квіт","трав","черв","лип","серп","вер","жовт","лист","груд"],ks=["нд","пн","вт","ср","чт","пт","сб"];function Ke(o){return o instanceof Date&&!Number.isNaN(o.getTime())}const Xt=o=>new Date(o.getTime());function Ut(o){const t=Xt(o);return t.setHours(0,0,0,0),t}function ln(o){const t=Xt(o);return t.setHours(23,59,59,999),t}function ho(o){return Ut(new Date(o.getFullYear(),o.getMonth(),1))}function go(o){return ln(new Date(o.getFullYear(),o.getMonth()+1,0))}function yo(o,t){const n=new Date(o),r=n.getDate();n.setDate(1),n.setMonth(n.getMonth()+t);const a=new Date(n.getFullYear(),n.getMonth()+1,0).getDate();return n.setDate(Math.min(r,a)),n}function ws(o,t){return yo(o,-1)}function $n(o,t){const n=new Date(o);return n.setFullYear(n.getFullYear()+t),n}function ir(o,t){return $n(o,-t)}function cr(o){return Ut(new Date(o.getFullYear(),0,1))}function dr(o){return ln(new Date(o.getFullYear(),11,31))}function xs(o){const t=Math.floor(o.getFullYear()/10)*10;return Ut(new Date(t,0,1))}function vs(o){const t=Math.floor(o.getFullYear()/10)*10+9;return ln(new Date(t,11,31))}const ht=o=>o.getFullYear(),An=o=>Math.floor(o.getFullYear()/10)*10;function _s(o){const t=[];let n=Ut(o.start);const r=Ut(o.end);for(;n<=r;)t.push(Xt(n)),n=new Date(n.getTime()+gs);return t}function Cs(o){const t=[];let n=ho(o.start);const r=go(o.end);for(;n<=r;)t.push(Xt(n)),n=yo(n,1);return t}function Es(o){const t=[];let n=cr(o.start);const r=dr(o.end);for(;n<=r;)t.push(Xt(n)),n=$n(n,1);return t}function bo(o,t=1){const n=Ut(o),r=(n.getDay()-t+7)%7;return n.setDate(n.getDate()-r),n}function Bs(o,t=1){const n=bo(o,t);return n.setDate(n.getDate()+6),ln(n)}function Vs(o,t,n=0){const r=bo(o,n),a=(t-n+7)%7;return r.setDate(r.getDate()+a),r}const Nn=(o,t)=>!!o&&!!t&&o.getFullYear()===t.getFullYear()&&o.getMonth()===t.getMonth()&&o.getDate()===t.getDate(),ko=(o,t)=>!!o&&!!t&&o.getFullYear()===t.getFullYear()&&o.getMonth()===t.getMonth(),ur=(o,t)=>!!o&&!!t&&o.getFullYear()===t.getFullYear(),pr=(o,t)=>!!o&&!!t&&Nn(o,t)&&o.getHours()===t.getHours(),Ss=(o,t)=>!!o&&!!t&&pr(o,t)&&o.getMinutes()===t.getMinutes();function $s(o,t){const n=o.getTime();return n>=t.start.getTime()&&n<=t.end.getTime()}const an=(o,t)=>!!o&&!!t&&o.getTime()<t.getTime(),sn=(o,t)=>!!o&&!!t&&o.getTime()>t.getTime();function As(o){const t=o.filter(n=>Ke(n));if(t.length)return t.reduce((n,r)=>n.getTime()>=r.getTime()?n:r)}function Ns(o){const t=o.filter(n=>Ke(n));if(t.length)return t.reduce((n,r)=>n.getTime()<=r.getTime()?n:r)}function Ms(o,t){const n=Xt(o);return typeof t.year=="number"&&n.setFullYear(t.year),typeof t.month=="number"&&n.setMonth(t.month),typeof t.date=="number"&&n.setDate(t.date),typeof t.hours=="number"&&n.setHours(t.hours),typeof t.minutes=="number"&&n.setMinutes(t.minutes),typeof t.seconds=="number"&&n.setSeconds(t.seconds),typeof t.milliseconds=="number"&&n.setMilliseconds(t.milliseconds),n}const Mn=(o,t=2)=>String(o).padStart(t,"0");function mr(o,t){return t==="wide"?ys[o]:bs[o]}function Fs(o){return ks[o]}const Ds=[{token:"LLLL",format:o=>mr(o.getMonth(),"wide")},{token:"LLL",format:o=>mr(o.getMonth(),"abbreviated")},{token:"EE",format:o=>Fs(o.getDay())},{token:"yyyy",format:o=>String(o.getFullYear())},{token:"MM",format:o=>Mn(o.getMonth()+1)},{token:"dd",format:o=>Mn(o.getDate())},{token:"HH",format:o=>Mn(o.getHours())},{token:"mm",format:o=>Mn(o.getMinutes())}];function cn(o,t){if(!Ke(o))return"";let n="",r=0;for(;r<t.length;){const a=Ds.find(l=>t.startsWith(l.token,r));a?(n+=a.format(o),r+=a.token.length):(n+=t[r],r+=1)}return n}const Ts={"yyyy-MM-dd":/^(\d{4})-(\d{2})-(\d{2})$/,"dd.MM.yyyy":/^(\d{2})\.(\d{2})\.(\d{4})$/,"dd.MM.yyyy HH:mm":/^(\d{2})\.(\d{2})\.(\d{4}) (\d{1,2}):(\d{2})(?::(\d{2}))?$/,"HH:mm":/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/,"MM.yyyy":/^(\d{2})\.(\d{4})$/,yyyy:/^(\d{4})$/};function fr(o,t){const n=Ts[t];if(!n){const a=new Date(o);return Ke(a)?a:null}const r=o.match(n);if(!r)return null;switch(t){case"yyyy-MM-dd":{const[,a,l,s]=r,c=new Date(Number(a),Number(l)-1,Number(s));return Ke(c)?c:null}case"dd.MM.yyyy":{const[,a,l,s]=r,c=new Date(Number(s),Number(l)-1,Number(a));return Ke(c)?c:null}case"dd.MM.yyyy HH:mm":{const[,a,l,s,c,i,d]=r,h=new Date(Number(s),Number(l)-1,Number(a),Number(c),Number(i),Number(d||0));return Ke(h)?h:null}case"HH:mm":{const[,a,l,s]=r,c=new Date;return c.setHours(Number(a),Number(l),Number(s||0),0),c}case"MM.yyyy":{const[,a,l]=r;return new Date(Number(l),Number(a)-1,1)}case"yyyy":{const[,a]=r;return new Date(Number(a),0,1)}default:return null}}const Ls=["year","month","day","time","custom"],Is=e.defineComponent({components:{ChevronLeft:X.ChevronLeft,ChevronRight:X.ChevronRight},emits:{elementClick:o=>Ke(o),left:()=>!0,right:()=>!0,heading:()=>!0,today:()=>!0,clear:()=>!0},props:{headingClickable:{type:Boolean,default:!1},leftDisabled:{type:Boolean,default:!1},rightDisabled:{type:Boolean,default:!1},columnCount:{type:Number,default:7},items:{type:Array,default:()=>[]},viewMode:{type:String,required:!0,validate:o=>typeof o=="string"&&Ls.includes(o)},showButtonBar:{type:Boolean,default:!1},hideHeader:{type:Boolean,default:!1}},setup(){const t=e.getCurrentInstance()?.appContext?.config?.globalProperties?.$t,n=e.computed(()=>{const a=t?.("form.date.today");return a&&a!=="form.date.today"?a:"Сьогодні"}),r=e.computed(()=>{const a=t?.("form.date.clear");return a&&a!=="form.date.clear"?a:"Очистити"});return{todayLabel:n,clearLabel:r}}}),Os={key:0,class:"p-datepicker-header flex items-center justify-between mb-1.5"},Ps=["disabled"],Rs=["disabled"],zs={key:0,class:"p-datepicker-weekheader grid [grid-template-columns:var(--popout-column-definition)] text-[12px] text-slate-400 font-medium mb-1.5"},js=["disabled","onClick"],Us={key:1,class:"p-datepicker-buttonbar mt-2 pt-2 border-t border-slate-200 flex items-center justify-between"};function Hs(o,t,n,r,a,l){const s=e.resolveComponent("ChevronLeft"),c=e.resolveComponent("ChevronRight");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["p-datepicker-panel p-component text-center text-slate-700 overflow-x-hidden bg-white border border-slate-200 rounded-xl shadow-[0_4px_12px_rgba(0,0,0,0.1)] p-2",o.viewMode==="month"||o.viewMode==="year"?"w-[182px] min-w-[182px]":"w-[268px] min-w-[182px]"]),style:e.normalizeStyle({"--popout-column-definition":`repeat(${o.columnCount}, 1fr)`}),onMousedown:t[5]||(t[5]=e.withModifiers(()=>{},["prevent"]))},[o.hideHeader?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Os,[e.createElementVNode("button",{class:"p-datepicker-prev-button inline-flex items-center justify-center size-8 rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300 disabled:hover:bg-transparent",disabled:o.leftDisabled,onClick:t[0]||(t[0]=e.withModifiers(i=>o.$emit("left"),["stop","prevent"]))},[e.renderSlot(o.$slots,"arrow-left",{},()=>[e.createVNode(s,{class:"h-3.5 w-3.5"})])],8,Ps),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.headingClickable?"button":"span"),{class:e.normalizeClass(["p-datepicker-title min-w-0 rounded-md px-2 py-1 text-sm font-semibold leading-snug text-slate-700",o.headingClickable?"hover:bg-slate-100":"",o.viewMode==="month"?"p-datepicker-select-year":"",o.viewMode==="year"?"p-datepicker-decade whitespace-nowrap text-xs px-1":""]),onClick:t[1]||(t[1]=e.withModifiers(i=>o.$emit("heading"),["stop","prevent"]))},{default:e.withCtx(()=>[e.renderSlot(o.$slots,"heading")]),_:3},8,["class"])),e.createElementVNode("button",{class:"p-datepicker-next-button inline-flex items-center justify-center size-8 rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300 disabled:hover:bg-transparent",disabled:o.rightDisabled,onClick:t[2]||(t[2]=e.withModifiers(i=>o.$emit("right"),["stop","prevent"]))},[e.renderSlot(o.$slots,"arrow-right",{},()=>[e.createVNode(c,{class:"h-3.5 w-3.5"})])],8,Rs)])),e.createElementVNode("div",null,["subheading"in o.$slots?(e.openBlock(),e.createElementBlock("div",zs,[e.renderSlot(o.$slots,"subheading")])):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["p-datepicker-calendar grid [grid-template-columns:var(--popout-column-definition)] text-[12px] text-slate-700",o.viewMode==="month"?"p-datepicker-month-view":"",o.viewMode==="year"?"p-datepicker-year-view":"",o.viewMode==="month"?"gap-y-1":""])},[e.renderSlot(o.$slots,"body",{},()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.items,i=>(e.openBlock(),e.createElementBlock("button",{key:i.key,disabled:i.disabled,class:e.normalizeClass(["p-[2px] disabled:text-slate-300"]),onClick:e.withModifiers(d=>o.$emit("elementClick",i.value),["stop","prevent"])},[e.createElementVNode("span",{class:e.normalizeClass([o.viewMode==="month"||o.viewMode==="year"?"inline-flex w-full h-8 items-center justify-center rounded-md text-[13px] font-normal transition-colors":"inline-flex w-8 h-8 items-center justify-center rounded-full text-[13px] font-normal transition-colors",o.viewMode==="month"?"p-datepicker-month":"",o.viewMode==="year"?"p-datepicker-year":"",o.viewMode==="day"?"p-datepicker-day":"",i.selected?"bg-blue-500 text-white font-semibold":"",i.current&&!i.selected&&o.viewMode!=="month"&&o.viewMode!=="year"?"border border-slate-300 font-medium":"",!i.disabled&&!i.selected?"hover:bg-slate-100 hover:text-slate-700":"",!i.current&&!i.selected&&i.disabled?"text-slate-300":""])},e.toDisplayString(i.display),3)],8,js))),128))])],2),e.renderSlot(o.$slots,"after-calendar"),o.showButtonBar?(e.openBlock(),e.createElementBlock("div",Us,[e.createElementVNode("button",{type:"button",class:"p-datepicker-today-button text-xs font-medium text-slate-500 hover:text-slate-700 transition-colors px-1.5 py-1 rounded-md hover:bg-slate-100",onClick:t[3]||(t[3]=e.withModifiers(i=>o.$emit("today"),["stop","prevent"]))},e.toDisplayString(o.todayLabel),1),e.createElementVNode("button",{type:"button",class:"p-datepicker-clear-button text-xs font-medium text-slate-500 hover:text-slate-700 transition-colors px-1.5 py-1 rounded-md hover:bg-slate-100",onClick:t[4]||(t[4]=e.withModifiers(i=>o.$emit("clear"),["stop","prevent"]))},e.toDisplayString(o.clearLabel),1)])):e.createCommentVNode("",!0)])],38)}const Fn=Ce(Is,[["render",Hs]]),qs=e.defineComponent({components:{PickerPopup:Fn},emits:{"update:pageDate":o=>Ke(o),select:o=>Ke(o)},props:{selected:{type:Date,required:!1},pageDate:{type:Date,required:!0},lowerLimit:{type:Date,required:!1},upperLimit:{type:Date,required:!1}},setup(o,{emit:t}){const n=e.computed(()=>xs(o.pageDate)),r=e.computed(()=>vs(o.pageDate)),a=(g,p,f)=>!p&&!f?!0:!(p&&ht(g)<ht(p)||f&&ht(g)>ht(f)),l=e.computed(()=>Es({start:n.value,end:r.value}).map(g=>({value:g,key:String(ht(g)),display:ht(g),selected:!!o.selected&&ht(g)===ht(o.selected),disabled:!a(g,o.lowerLimit,o.upperLimit)}))),s=e.computed(()=>{const g=ht(n.value),p=ht(r.value);return`${g} - ${p}`}),c=e.computed(()=>o.lowerLimit&&(An(o.lowerLimit)===An(o.pageDate)||an(o.pageDate,o.lowerLimit))),i=e.computed(()=>o.upperLimit&&(An(o.upperLimit)===An(o.pageDate)||sn(o.pageDate,o.upperLimit)));return{years:l,heading:s,leftDisabled:c,rightDisabled:i,previousPage:()=>t("update:pageDate",ir(o.pageDate,10)),nextPage:()=>t("update:pageDate",$n(o.pageDate,10))}}});function Ws(o,t,n,r,a,l){const s=e.resolveComponent("picker-popup");return e.openBlock(),e.createBlock(s,{columnCount:2,leftDisabled:o.leftDisabled,rightDisabled:o.rightDisabled,items:o.years,viewMode:"year",onLeft:o.previousPage,onRight:o.nextPage,onElementClick:t[0]||(t[0]=c=>o.$emit("select",c))},{heading:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.heading),1)]),_:1},8,["leftDisabled","rightDisabled","items","onLeft","onRight"])}const Ks=Ce(qs,[["render",Ws]]),Gs=e.defineComponent({components:{PickerPopup:Fn},emits:{"update:pageDate":o=>Ke(o),select:o=>Ke(o),back:()=>!0},props:{selected:{type:Date,required:!1},pageDate:{type:Date,required:!0},format:{type:String,required:!1,default:"LLL"},lowerLimit:{type:Date,required:!1},upperLimit:{type:Date,required:!1}},setup(o,{emit:t}){const n=e.computed(()=>cr(o.pageDate)),r=e.computed(()=>dr(o.pageDate)),a=e.computed(()=>p=>cn(p,o.format)),l=(p,f,m)=>!f&&!m?!0:!(f&&an(p,ho(f))||m&&sn(p,go(m))),s=e.computed(()=>Cs({start:n.value,end:r.value}).map(p=>({value:p,display:a.value(p),key:a.value(p),selected:!!o.selected&&ko(o.selected,p),disabled:!l(p,o.lowerLimit,o.upperLimit)}))),c=e.computed(()=>ht(n.value)),i=e.computed(()=>o.lowerLimit&&(ur(o.lowerLimit,o.pageDate)||an(o.pageDate,o.lowerLimit))),d=e.computed(()=>o.upperLimit&&(ur(o.upperLimit,o.pageDate)||sn(o.pageDate,o.upperLimit)));return{months:s,heading:c,leftDisabled:i,rightDisabled:d,previousPage:()=>t("update:pageDate",ir(o.pageDate,1)),nextPage:()=>t("update:pageDate",$n(o.pageDate,1))}}});function Ys(o,t,n,r,a,l){const s=e.resolveComponent("picker-popup");return e.openBlock(),e.createBlock(s,{headingClickable:"",columnCount:3,items:o.months,leftDisabled:o.leftDisabled,rightDisabled:o.rightDisabled,viewMode:"month",onLeft:o.previousPage,onRight:o.nextPage,onHeading:t[0]||(t[0]=c=>o.$emit("back")),onElementClick:t[1]||(t[1]=c=>o.$emit("select",c))},{heading:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.heading),1)]),_:1},8,["items","leftDisabled","rightDisabled","onLeft","onRight"])}const Xs=Ce(Gs,[["render",Ys]]),Zs=e.defineComponent({components:{PickerPopup:Fn},emits:{"update:pageDate":o=>Ke(o),select:o=>Ke(o),back:()=>!0,today:()=>!0,clear:()=>!0},props:{selected:{type:Date,required:!1},pageDate:{type:Date,required:!0},format:{type:String,required:!1,default:"dd"},headingFormat:{type:String,required:!1,default:"LLLL yyyy"},weekdayFormat:{type:String,required:!1,default:"EE"},weekStartsOn:{type:Number,required:!1,default:1,validator:o=>typeof o=="number"&&Number.isInteger(o)&&o>=0&&o<=6},customWeekdays:{type:Array,required:!1},lowerLimit:{type:Date,required:!1},upperLimit:{type:Date,required:!1},disabledDates:{type:Object,required:!1},allowOutsideInterval:{type:Boolean,required:!1,default:!1}},setup(o,{emit:t}){const n=e.computed(()=>b=>_=>cn(_,b)),r=e.computed(()=>ho(o.pageDate)),a=e.computed(()=>go(o.pageDate)),l=e.computed(()=>({start:r.value,end:a.value})),s=e.computed(()=>({start:bo(r.value,o.weekStartsOn),end:Bs(a.value,o.weekStartsOn)})),c=e.computed(()=>o.customWeekdays?.length===7?o.customWeekdays:null),i=e.computed(()=>{const b=o.weekStartsOn,_=c.value;if(_)return Array.from({length:7}).map((N,$)=>_[(b+$)%7]);const C=n.value(o.weekdayFormat);return Array.from(Array(7)).map((N,$)=>(b+$)%7).map(N=>Vs(new Date,N,o.weekStartsOn)).map(C)}),d=(b,_,C,N)=>N?.dates?.some($=>Nn(b,$))||N?.predicate?.(b)?!1:!_&&!C?!0:!(_&&an(b,Ut(_))||C&&sn(b,ln(C))),h=e.computed(()=>{const b=new Date,_=n.value(o.format);return _s(s.value).map(C=>({value:C,display:_(C),selected:!!o.selected&&Nn(o.selected,C),current:Nn(b,C),disabled:!o.allowOutsideInterval&&!$s(C,l.value)||!d(C,o.lowerLimit,o.upperLimit,o.disabledDates),key:n.value("yyyy-MM-dd")(C)}))}),g=e.computed(()=>n.value(o.headingFormat)(o.pageDate)),p=e.computed(()=>o.lowerLimit&&(ko(o.lowerLimit,o.pageDate)||an(o.pageDate,o.lowerLimit))),f=e.computed(()=>o.upperLimit&&(ko(o.upperLimit,o.pageDate)||sn(o.pageDate,o.upperLimit)));return{weekDays:i,days:h,heading:g,leftDisabled:p,rightDisabled:f,previousPage:()=>t("update:pageDate",ws(o.pageDate)),nextPage:()=>t("update:pageDate",yo(o.pageDate,1))}}});function Js(o,t,n,r,a,l){const s=e.resolveComponent("picker-popup");return e.openBlock(),e.createBlock(s,{headingClickable:"",leftDisabled:o.leftDisabled,rightDisabled:o.rightDisabled,items:o.days,showButtonBar:!0,viewMode:"day",onLeft:o.previousPage,onRight:o.nextPage,onHeading:t[0]||(t[0]=c=>o.$emit("back")),onElementClick:t[1]||(t[1]=c=>o.$emit("select",c)),onToday:t[2]||(t[2]=c=>o.$emit("today")),onClear:t[3]||(t[3]=c=>o.$emit("clear"))},e.createSlots({heading:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.heading),1)]),subheading:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.weekDays,(c,i)=>(e.openBlock(),e.createElementBlock("span",{key:c,class:e.normalizeClass(`v3dp__subheading__weekday__${i}`)},e.toDisplayString(c),3))),128))]),_:2},[o.$slots["after-calendar"]?{name:"after-calendar",fn:e.withCtx(()=>[e.renderSlot(o.$slots,"after-calendar")]),key:"0"}:void 0]),1032,["leftDisabled","rightDisabled","items","onLeft","onRight"])}const Qs=Ce(Zs,[["render",Js]]),ei=e.defineComponent({components:{PickerPopup:Fn,ChevronUp:X.ChevronUp,ChevronDown:X.ChevronDown},emits:{select:o=>Ke(o),back:()=>!0},props:{selected:{type:Date,required:!1},pageDate:{type:Date,required:!0},visible:{type:Boolean,required:!0},disabledTime:{type:Object,required:!1},embedded:{type:Boolean,default:!1}},setup(o,{emit:t}){const n=e.computed(()=>o.pageDate??o.selected),r=e.ref(n.value.getHours()),a=e.ref(n.value.getMinutes());e.watch(()=>o.selected,f=>{let m=0,k=0;f&&(m=f.getHours(),k=f.getMinutes()),r.value=m,a.value=k});const l=(f,m)=>{const k=Ms(new Date(n.value.getTime()),{hours:f,minutes:m,seconds:0});g(k)&&(r.value=f,a.value=m,t("select",k))},s=(f,m)=>f<0?m:f>m?0:f,c=()=>l(s(r.value+1,23),a.value),i=()=>l(s(r.value-1,23),a.value),d=()=>l(r.value,s(a.value+1,59)),h=()=>l(r.value,s(a.value-1,59)),g=f=>!(o.disabledTime?.dates?.some(m=>pr(f,m)&&Ss(f,m))||o.disabledTime?.predicate?.(f));return{hours:r,minutes:a,padStartZero:f=>`0${f}`.substr(-2),isEnabled:g,incrementHours:c,decrementHours:i,incrementMinutes:d,decrementMinutes:h}}}),ti={key:0,class:"p-datepicker-time-picker mt-2 pt-2 border-t border-slate-200 flex items-center justify-center gap-2 py-1"},ni={class:"p-datepicker-hour-picker flex flex-col items-center gap-1"},oi={class:"min-w-8 text-center text-sm font-medium text-slate-700"},ri={class:"p-datepicker-minute-picker flex flex-col items-center gap-1"},li={class:"min-w-8 text-center text-sm font-medium text-slate-700"},ai={class:"col-span-2"},si={class:"p-datepicker-time-picker flex items-center justify-center gap-2 py-1"},ii={class:"p-datepicker-hour-picker flex flex-col items-center gap-1"},ci={class:"min-w-8 text-center text-sm font-medium text-slate-700"},di={class:"p-datepicker-minute-picker flex flex-col items-center gap-1"},ui={class:"min-w-8 text-center text-sm font-medium text-slate-700"};function pi(o,t,n,r,a,l){const s=e.resolveComponent("ChevronUp"),c=e.resolveComponent("ChevronDown"),i=e.resolveComponent("picker-popup");return o.embedded?(e.openBlock(),e.createElementBlock("div",ti,[e.createElementVNode("div",ni,[e.createElementVNode("button",{type:"button",class:"p-datepicker-increment-button inline-flex size-8 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300",onClick:t[0]||(t[0]=e.withModifiers((...d)=>o.incrementHours&&o.incrementHours(...d),["stop","prevent"]))},[e.createVNode(s,{class:"h-3.5 w-3.5"})]),e.createElementVNode("span",oi,e.toDisplayString(o.padStartZero(o.hours)),1),e.createElementVNode("button",{type:"button",class:"p-datepicker-decrement-button inline-flex size-8 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300",onClick:t[1]||(t[1]=e.withModifiers((...d)=>o.decrementHours&&o.decrementHours(...d),["stop","prevent"]))},[e.createVNode(c,{class:"h-3.5 w-3.5"})])]),t[8]||(t[8]=e.createElementVNode("div",{class:"text-base font-medium text-slate-500"},":",-1)),e.createElementVNode("div",ri,[e.createElementVNode("button",{type:"button",class:"p-datepicker-increment-button inline-flex size-8 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300",onClick:t[2]||(t[2]=e.withModifiers((...d)=>o.incrementMinutes&&o.incrementMinutes(...d),["stop","prevent"]))},[e.createVNode(s,{class:"h-3.5 w-3.5"})]),e.createElementVNode("span",li,e.toDisplayString(o.padStartZero(o.minutes)),1),e.createElementVNode("button",{type:"button",class:"p-datepicker-decrement-button inline-flex size-8 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300",onClick:t[3]||(t[3]=e.withModifiers((...d)=>o.decrementMinutes&&o.decrementMinutes(...d),["stop","prevent"]))},[e.createVNode(c,{class:"h-3.5 w-3.5"})])])])):(e.openBlock(),e.createBlock(i,{key:1,hideHeader:!0,columnCount:2,viewMode:"time"},{body:e.withCtx(()=>[e.createElementVNode("div",ai,[e.createElementVNode("div",si,[e.createElementVNode("div",ii,[e.createElementVNode("button",{type:"button",class:"p-datepicker-increment-button inline-flex size-8 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300",onClick:t[4]||(t[4]=e.withModifiers((...d)=>o.incrementHours&&o.incrementHours(...d),["stop","prevent"]))},[e.createVNode(s,{class:"h-3.5 w-3.5"})]),e.createElementVNode("span",ci,e.toDisplayString(o.padStartZero(o.hours)),1),e.createElementVNode("button",{type:"button",class:"p-datepicker-decrement-button inline-flex size-8 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300",onClick:t[5]||(t[5]=e.withModifiers((...d)=>o.decrementHours&&o.decrementHours(...d),["stop","prevent"]))},[e.createVNode(c,{class:"h-3.5 w-3.5"})])]),t[9]||(t[9]=e.createElementVNode("div",{class:"text-base font-medium text-slate-500"},":",-1)),e.createElementVNode("div",di,[e.createElementVNode("button",{type:"button",class:"p-datepicker-increment-button inline-flex size-8 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300",onClick:t[6]||(t[6]=e.withModifiers((...d)=>o.incrementMinutes&&o.incrementMinutes(...d),["stop","prevent"]))},[e.createVNode(s,{class:"h-3.5 w-3.5"})]),e.createElementVNode("span",ui,e.toDisplayString(o.padStartZero(o.minutes)),1),e.createElementVNode("button",{type:"button",class:"p-datepicker-decrement-button inline-flex size-8 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300",onClick:t[7]||(t[7]=e.withModifiers((...d)=>o.decrementMinutes&&o.decrementMinutes(...d),["stop","prevent"]))},[e.createVNode(c,{class:"h-3.5 w-3.5"})])])])])]),_:1}))}const mi=Ce(ei,[["render",pi]]),Dn=["time","day","month","year"],fi=(o,t,n=void 0)=>{let r=n||new Date;const a=As([o,r]);a&&(r=a);const l=Ns([t,r]);return l&&(r=l),r},hi=e.defineComponent({components:{YearPicker:Ks,MonthPicker:Xs,DayPicker:Qs,TimePicker:mi,CalendarDays:X.CalendarDays,Clock3:X.Clock3,X:X.X},inheritAttrs:!1,props:{placeholder:{type:String,default:""},modelValue:{type:Date,required:!1},disabledDates:{type:Object,required:!1},allowOutsideInterval:{type:Boolean,required:!1,default:!1},disabledTime:{type:Object,required:!1},upperLimit:{type:Date,required:!1},lowerLimit:{type:Date,required:!1},startingView:{type:String,required:!1,default:"day",validate:o=>typeof o=="string"&&Dn.includes(o)},startingViewDate:{type:Date,required:!1,default:()=>new Date},dayPickerHeadingFormat:{type:String,required:!1,default:"LLLL yyyy"},monthListFormat:{type:String,required:!1,default:"LLL"},weekdayFormat:{type:String,required:!1,default:"EE"},dayFormat:{type:String,required:!1,default:"dd"},inputFormat:{type:String,required:!1,default:"yyyy-MM-dd"},weekDayNames:{type:Array,required:!1},weekStartsOn:{type:Number,required:!1,default:1,validator:o=>[0,1,2,3,4,5,6].includes(o)},disabled:{type:Boolean,required:!1,default:!1},clearable:{type:Boolean,required:!1,default:!1},typeable:{type:Boolean,required:!1,default:!1},minimumView:{type:String,required:!1,default:"day",validate:o=>typeof o=="string"&&Dn.includes(o)}},emits:{"update:modelValue":o=>o==null||Ke(o),decadePageChanged:o=>!0,yearPageChanged:o=>!0,monthPageChanged:o=>!0,opened:()=>!0,closed:()=>!0},setup(o,{emit:t}){const n=e.ref("none"),r=e.ref(o.startingViewDate),a=e.ref(null),l=e.ref(null),s=e.ref(null),c=e.ref({}),i=e.ref(!1),d=e.ref(!1),h=e.ref(!1);let g=null;const p=e.ref(""),f=ne=>{const de=ne.replace(/[a-zA-Z]/g,"0");return/0/.test(de)?de:""},m=e.computed(()=>f(o.inputFormat));let k=null,b=null;const _=()=>{k?.destroy(),k=null},C=async()=>{if(!b){const{default:ne}=await Promise.resolve().then(()=>Qn);b=ne}return b},N=()=>{k&&k.value!==p.value&&(k.value=p.value??"")},$=ne=>{const de=ne&&Ke(ne)?cn(ne,o.inputFormat):"";p.value!==de&&(p.value=de),N()},q=async()=>{if(_(),!l.value||!m.value)return;k=(await C())(l.value,{mask:m.value,lazy:!0,overwrite:!1}),N()};e.watch(()=>o.modelValue,ne=>{d.value&&o.typeable||$(ne)},{immediate:!0}),e.watch(()=>o.inputFormat,()=>{d.value&&o.typeable||$(o.modelValue)}),e.onMounted(()=>{h.value=!0,m.value&&e.nextTick(()=>{q()})}),e.onBeforeUnmount(()=>{_()}),e.watch(m,ne=>{ne?e.nextTick(()=>{q()}):_()});const G=e.computed(()=>n.value!=="none"),I=e.computed(()=>o.startingView==="time"&&o.minimumView==="time"),E=e.computed(()=>o.startingView==="day"&&o.minimumView==="time"),V=ne=>{o.disabled||(G.value||(r.value=o.modelValue||fi(o.lowerLimit,o.upperLimit,r.value),t("opened")),n.value=ne,e.nextTick(()=>Oe()))},v=()=>{G.value&&(g!==null&&(cancelAnimationFrame(g),g=null),n.value="none",t("closed"))},T=(ne="none")=>{ne==="none"?v():V(ne)};e.watchEffect(()=>{o.disabled&&v()});const j=(ne,de)=>{r.value=de,ne==="year"?t("decadePageChanged",de):ne==="month"?t("yearPageChanged",de):ne==="day"&&t("monthPageChanged",de)},te=ne=>{r.value=ne,o.minimumView==="year"?(v(),$(ne),t("update:modelValue",ne)):V("month")},D=ne=>{r.value=ne,o.minimumView==="month"?(v(),$(ne),t("update:modelValue",ne)):V("day")},U=ne=>{const de=E.value?(()=>{const xe=o.modelValue||r.value||new Date,ve=new Date(ne);return ve.setHours(xe.getHours(),xe.getMinutes(),0,0),ve})():ne;r.value=de,o.minimumView==="day"?(v(),$(de),t("update:modelValue",de)):E.value?($(de),t("update:modelValue",de),V("day")):V("time")},oe=ne=>{$(ne),t("update:modelValue",ne)},R=()=>{U(new Date)},H=()=>{o.clearable&&(v(),$(null),t("update:modelValue",null),r.value=o.startingViewDate)},Z=()=>{G.value||V(se.value)},ae=()=>{d.value=!0,i.value=!1,V(se.value)},O=()=>{d.value=!1,o.typeable&&M({closeOnSuccess:!1,revertOnInvalid:!0})},A=ne=>{const de=ne.target;if(p.value=de?.value??"",!o.typeable)return;const xe=fr(p.value,o.inputFormat);xe&&p.value===cn(xe,o.inputFormat)&&(r.value=xe)},M=({closeOnSuccess:ne,revertOnInvalid:de})=>{const xe=l.value?.value??p.value,ve=fr(xe,o.inputFormat);return!!ve&&xe===cn(ve,o.inputFormat)&&ve?(r.value=ve,$(ve),t("update:modelValue",ve),ne&&v(),!0):($(o.modelValue),!1)},Q=ne=>{const de=ne.keyCode?ne.keyCode:ne.which,xe=de===27,ve=de===13;if(xe){v(),l.value?.blur();return}o.typeable&&ve&&(M({closeOnSuccess:!0,revertOnInvalid:!0})||l.value?.focus())},se=e.computed(()=>{const ne=Dn.indexOf(o.startingView),de=Dn.indexOf(o.minimumView);return ne<de?o.minimumView:o.startingView}),ee=e.computed(()=>o.weekDayNames?.length===7?o.weekDayNames:void 0),me=()=>o.startingView==="time"&&o.minimumView==="time"?null:V("day"),ke=()=>{if(!l.value||!s.value)return;const ne=4,de=8,xe=l.value.getBoundingClientRect(),ve=s.value.getBoundingClientRect(),Te=s.value.firstElementChild?.getBoundingClientRect(),Je=window.innerWidth,Ae=window.innerHeight,Fe=window.scrollX||window.pageXOffset,ut=window.scrollY||window.pageYOffset,z=Math.max(160,Ae-de*2),J=Math.min(ve.height||0,z),ie=Ae-xe.bottom-ne-de,F=xe.top-ne-de,w=ie<J&&F>ie;let S=w?xe.top-ne-J:xe.bottom+ne;S=Math.max(de,Math.min(S,Ae-de-J));const P=Te?.width||ve.width||268;let le=xe.left;le+P>Je-de&&(le=Je-de-P),le<de&&(le=de);const we=w?Math.max(120,xe.top-ne-de):Math.max(120,Ae-xe.bottom-ne-de);c.value={position:"absolute",top:`${Math.round(S+ut)}px`,left:`${Math.round(le+Fe)}px`,maxHeight:`${Math.round(Math.min(z,we))}px`,overflowX:"hidden",overflowY:"auto",zIndex:"2147483000"},E.value&&n.value==="day"&&(c.value.minWidth="345px")},ge=(ne,de)=>ne.bottom>de.top&&ne.top<de.bottom&&ne.right>de.left&&ne.left<de.right,Se=ne=>{const de=[];let xe=ne.parentElement;for(;xe;){const ve=window.getComputedStyle(xe),ze=ve.overflowY,Te=ve.overflowX,Je=["auto","scroll","hidden","clip"].includes(ze),Ae=["auto","scroll","hidden","clip"].includes(Te);(Je||Ae)&&de.push(xe),xe=xe.parentElement}return de},Ne=()=>{if(!l.value)return!1;const ne=l.value.getBoundingClientRect(),de=new DOMRect(0,0,window.innerWidth,window.innerHeight);return ge(ne,de)?Se(l.value).every(ve=>ge(ne,ve.getBoundingClientRect())):!1},$e=()=>{if(G.value){if(!Ne()){i.value=!0,v();return}Oe();return}i.value&&document.activeElement===l.value&&Ne()&&(i.value=!1,V(se.value))};e.watch(n,()=>{G.value&&e.nextTick(()=>Oe())});const Oe=()=>{ke(),g!==null&&cancelAnimationFrame(g),g=requestAnimationFrame(()=>{ke(),g=null})};e.onMounted(()=>{window.addEventListener("resize",$e),window.addEventListener("scroll",$e,!0),document.addEventListener("pointerdown",Me,!0)}),e.onBeforeUnmount(()=>{g!==null&&(cancelAnimationFrame(g),g=null),window.removeEventListener("resize",$e),window.removeEventListener("scroll",$e,!0),document.removeEventListener("pointerdown",Me,!0)});const Me=ne=>{if(n.value==="none")return;const de=ne.target;if(!de)return;const xe=!!a.value?.contains(de),ve=!!s.value?.contains(de);!xe&&!ve&&(i.value=!1,v())};return{rootRef:a,blur:O,focus:ae,click:Z,input:p,inputRef:l,pageDate:r,renderView:T,updatePageDate:j,selectYear:te,selectMonth:D,selectDay:U,selectToday:R,selectTime:oe,keyUp:Q,onInput:A,isTimeOnlyMode:I,isDateTimeMode:E,normalizedWeekdayNames:ee,viewShown:n,goBackFromTimepicker:me,clearModelValue:H,initialView:se,log:ne=>console.log(ne),popupAnchorStyle:c,popupRef:s,isMounted:h}}}),gi={ref:"rootRef",class:"relative"},yi={class:"p-datepicker p-component p-inputwrapper relative"},bi=["readonly","value","placeholder","disabled","tabindex"],ki={class:"p-datepicker-input-icon-container absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none text-slate-400"},wi={class:"absolute right-8 top-1/2 -translate-y-1/2"};function xi(o,t,n,r,a,l){const s=e.resolveComponent("Clock3"),c=e.resolveComponent("CalendarDays"),i=e.resolveComponent("X"),d=e.resolveComponent("year-picker"),h=e.resolveComponent("month-picker"),g=e.resolveComponent("time-picker"),p=e.resolveComponent("day-picker");return e.openBlock(),e.createElementBlock("div",gi,[e.createElementVNode("div",yi,[e.createElementVNode("input",e.mergeProps({type:"text",ref:"inputRef",class:"p-inputtext p-component p-datepicker-input",readonly:!o.typeable,value:o.input},o.$attrs,{placeholder:o.placeholder,disabled:o.disabled,tabindex:o.disabled?-1:0,onInput:t[0]||(t[0]=(...f)=>o.onInput&&o.onInput(...f)),onKeyup:t[1]||(t[1]=(...f)=>o.keyUp&&o.keyUp(...f)),onBlur:t[2]||(t[2]=(...f)=>o.blur&&o.blur(...f)),onFocus:t[3]||(t[3]=(...f)=>o.focus&&o.focus(...f)),onClick:t[4]||(t[4]=(...f)=>o.click&&o.click(...f))}),null,16,bi),e.createElementVNode("span",ki,[o.isTimeOnlyMode?(e.openBlock(),e.createBlock(s,{key:0,class:"h-4 w-4"})):(e.openBlock(),e.createBlock(c,{key:1,class:"h-4 w-4"}))]),e.withDirectives(e.createElementVNode("div",wi,[e.renderSlot(o.$slots,"clear",{onClear:o.clearModelValue},()=>[e.createElementVNode("button",{type:"button",class:"inline-flex h-5 w-5 items-center justify-center rounded-full text-slate-400 transition-colors hover:bg-slate-100 hover:text-slate-600 focus:outline-none focus:ring-2 focus:ring-blue-500/30","aria-label":"Очистити дату",onClick:t[5]||(t[5]=f=>o.clearModelValue())},[e.createVNode(i,{class:"h-3 w-3"})])])],512),[[e.vShow,o.clearable&&o.modelValue]])]),o.isMounted?(e.openBlock(),e.createBlock(e.Teleport,{key:0,to:"body"},[e.withDirectives(e.createElementVNode("div",{ref:"popupRef",style:e.normalizeStyle(o.popupAnchorStyle)},[e.withDirectives(e.createVNode(d,{pageDate:o.pageDate,"onUpdate:pageDate":t[6]||(t[6]=f=>o.updatePageDate("year",f)),selected:o.modelValue,lowerLimit:o.lowerLimit,upperLimit:o.upperLimit,onSelect:o.selectYear},null,8,["pageDate","selected","lowerLimit","upperLimit","onSelect"]),[[e.vShow,o.viewShown==="year"]]),e.withDirectives(e.createVNode(h,{pageDate:o.pageDate,"onUpdate:pageDate":t[7]||(t[7]=f=>o.updatePageDate("month",f)),selected:o.modelValue,onSelect:o.selectMonth,lowerLimit:o.lowerLimit,upperLimit:o.upperLimit,format:o.monthListFormat,onBack:t[8]||(t[8]=f=>o.viewShown="year")},null,8,["pageDate","selected","onSelect","lowerLimit","upperLimit","format"]),[[e.vShow,o.viewShown==="month"]]),e.withDirectives(e.createVNode(p,{pageDate:o.pageDate,"onUpdate:pageDate":t[9]||(t[9]=f=>o.updatePageDate("day",f)),selected:o.modelValue,weekStartsOn:o.weekStartsOn,lowerLimit:o.lowerLimit,upperLimit:o.upperLimit,headingFormat:o.dayPickerHeadingFormat,disabledDates:o.disabledDates,weekdayFormat:o.weekdayFormat,"allow-outside-interval":o.allowOutsideInterval,format:o.dayFormat,"custom-weekdays":o.normalizedWeekdayNames,onSelect:o.selectDay,onToday:o.selectToday,onClear:o.clearModelValue,onBack:t[10]||(t[10]=f=>o.viewShown="month")},e.createSlots({_:2},[o.isDateTimeMode?{name:"after-calendar",fn:e.withCtx(()=>[e.createVNode(g,{embedded:!0,pageDate:o.pageDate,visible:o.viewShown==="day"&&o.isDateTimeMode,selected:o.modelValue,disabledTime:o.disabledTime,onSelect:o.selectTime,onBack:o.goBackFromTimepicker},null,8,["pageDate","visible","selected","disabledTime","onSelect","onBack"])]),key:"0"}:void 0]),1032,["pageDate","selected","weekStartsOn","lowerLimit","upperLimit","headingFormat","disabledDates","weekdayFormat","allow-outside-interval","format","custom-weekdays","onSelect","onToday","onClear"]),[[e.vShow,o.viewShown==="day"]]),e.withDirectives(e.createVNode(g,{pageDate:o.pageDate,visible:o.viewShown==="time",selected:o.modelValue,disabledTime:o.disabledTime,onSelect:o.selectTime,onBack:o.goBackFromTimepicker},null,8,["pageDate","visible","selected","disabledTime","onSelect","onBack"]),[[e.vShow,o.viewShown==="time"&&!o.isDateTimeMode]])],4),[[e.vShow,o.viewShown!=="none"]])])):e.createCommentVNode("",!0)],512)}const vi=Ce(hi,[["render",xi]]),hr=Ce(e.defineComponent({__name:"vs-input-date2",props:{clearable:{type:Boolean,default:!0},now:{type:Boolean},editable:{type:Boolean,default:!0},time:{type:Boolean},isInfinity:{type:Boolean},dateFormat:{},mode:{default:"date"},weekStart:{},dayNames:{},maxDaysFromNow:{},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{default:""},maxlength:{},minlength:{}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o,r=t,{inputClass:a}=Qe(n.style),l=e.getCurrentInstance(),s=e.computed(()=>n.mode?n.mode:n.time?"datetime":"date"),c=e.computed(()=>["py-1.5 px-3 block w-full placeholder:text-[#767f8f] bg-white",a.value,n.customClass,{"!border-red-600":n.error}]),i=e.computed(()=>!n.modelValue&&n.now?new Date:null),d=e.computed({get:()=>E(n.modelValue??i.value,s.value)||void 0,set:O=>r("update:modelValue",V(O,s.value))}),h=["Пн","Вт","Ср","Чт","Пт","Сб","Нд"],g=e.computed(()=>{if(n.dayNames?.length)return n.dayNames.length===7?n.dayNames:h}),p=e.computed(()=>{const O=n.weekStart,A=typeof O=="string"?Number(O):O;return A===void 0||Number.isNaN(A)?1:Math.min(6,Math.max(0,A))}),f=e.computed(()=>{const O=n.maxDaysFromNow;if(O==null||O==="")return;const A=typeof O=="string"?Number(O):O;if(!Number.isFinite(A)||A<0)return;const M=new Date;return M.setHours(0,0,0,0),M.setDate(M.getDate()+A),M.setHours(23,59,59,999),M}),m=e.computed(()=>{switch(s.value){case"time":return{startingView:"time",minimumView:"time"};case"month":return{startingView:"month",minimumView:"month"};case"year":return{startingView:"year",minimumView:"year"};case"datetime":return{startingView:"day",minimumView:"time"};default:return{startingView:"day",minimumView:"day"}}}),k={date:"dd.MM.yyyy",datetime:"dd.MM.yyyy HH:mm",month:"MM.yyyy",time:"HH:mm",week:"dd.MM.yyyy",year:"yyyy"};function b(){const O=l?.appContext?.config?.globalProperties?.$i18n?.locale;if(typeof O=="string"&&O)return O;if(O&&typeof O=="object"&&"value"in O&&O.value)return String(O.value);if(typeof localStorage<"u"){const A=localStorage.getItem("locale")||localStorage.getItem("language");if(A)return A}return"uk"}function _(){const A=l?.appContext?.config?.globalProperties?.$settings?.dateFormat;if(!A)return"";if(typeof A=="string")return A;if(typeof A=="object"){const M=b();return A[M]||A[M.split("-")[0]]||A.uk||A.en||""}return""}function C(O){return O?O.replaceAll("dd","__DAY2__").replaceAll("d","__DAY1__").replaceAll("mm","__MONTH2__").replaceAll("m","__MONTH1__").replaceAll("yy","__YEAR2__").replaceAll("y","__YEAR1__").replaceAll("__DAY2__","dd").replaceAll("__DAY1__","d").replaceAll("__MONTH2__","MM").replaceAll("__MONTH1__","M").replaceAll("__YEAR2__","yy").replaceAll("__YEAR1__","yyyy"):""}const N=e.computed(()=>{const O=k[s.value]||"dd.MM.yyyy";if(s.value==="time")return O;const A=n.dateFormat||_();if(!A)return O;const M=C(A);return M?s.value==="datetime"?`${M} HH:mm`:M:O});function $(O,A){return O?A==="week"?"рррр-тиждень":O.replaceAll("yyyy","рррр").replaceAll("yy","рр").replaceAll("MM","мм").replaceAll("M","м").replaceAll("dd","дд").replaceAll("d","д").replaceAll("HH","гг").replaceAll("H","г").replaceAll("mm",A==="time"||A==="datetime"?"хх":"мм"):""}const q={date:"дд.мм.рррр",datetime:"дд.мм.рррр гг:хх",month:"мм.рррр",week:"рррр-тиждень",time:"гг:хх",year:"рррр"},G=e.computed(()=>{if(n.placeholder)return n.placeholder;const O=s.value;return $(N.value,O)||q[O]||""}),I=e.ref(!1);e.watch(()=>n.modelValue,O=>{O?I.value=!0:n.now||(I.value=!1)},{immediate:!0}),e.watchEffect(()=>{n.now&&!n.modelValue&&!I.value&&(r("update:modelValue",V(new Date,s.value)),I.value=!0)}),e.watch(N,()=>{r("update:modelValue",V(d.value,s.value))});function E(O,A){if(!O)return null;if(O instanceof Date&&!Number.isNaN(O.getTime()))return O;if(typeof O!="string")return null;switch(A){case"datetime":return te(O);case"time":return oe(O);case"month":return D(O);case"year":return U(O);case"week":return R(O);case"date":default:return j(O)}}function V(O,A){if(!O)return null;const M=O instanceof Date?O:E(O,A);if(!M)return null;switch(A){case"datetime":return`${v(M)}T${T(M)}`;case"time":return T(M);case"month":return`${M.getFullYear()}-${ae(M.getMonth()+1)}`;case"year":return`${M.getFullYear()}`;case"week":{const{year:Q,week:se}=H(M);return`${Q}-W${ae(se)}`}case"date":default:return v(M)}}function v(O){return`${O.getFullYear()}-${ae(O.getMonth()+1)}-${ae(O.getDate())}`}function T(O){return`${ae(O.getHours())}:${ae(O.getMinutes())}`}function j(O){const A=O.split("-");if(A.length<3)return null;const M=Number(A[0]),Q=Number(A[1]),se=parseInt(A[2],10);return!M||!Q||!se?null:new Date(M,Q-1,se)}function te(O){const A=O.includes("T")?O:O.replace(" ","T"),M=new Date(A);return Number.isNaN(M.getTime())?null:M}function D(O){const[A,M]=O.split("-").map(Number);return!A||Number.isNaN(M)?null:new Date(A,(M||1)-1,1)}function U(O){const A=Number(O);return A?new Date(A,0,1):null}function oe(O){const A=O.trim().match(/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/);if(!A)return null;const[,M,Q,se]=A,ee=new Date;return ee.setHours(Number(M),Number(Q),Number(se||0),0),ee}function R(O){const A=O.match(/^(\d{4})-W(\d{2})$/);if(!A)return null;const[,M,Q]=A,se=Number(Q);return Z(Number(M),se)}function H(O){const A=new Date(Date.UTC(O.getFullYear(),O.getMonth(),O.getDate())),M=A.getUTCDay()||7;A.setUTCDate(A.getUTCDate()+4-M);const Q=new Date(Date.UTC(A.getUTCFullYear(),0,1)),se=Math.ceil(((A.getTime()-Q.getTime())/864e5+1)/7);return{year:A.getUTCFullYear(),week:se}}function Z(O,A){if(!O||!A)return null;const M=new Date(O,0,1+(A-1)*7),Q=M.getDay(),se=M;return Q<=4?se.setDate(M.getDate()-M.getDay()+1):se.setDate(M.getDate()+8-M.getDay()),se}function ae(O){return String(O).padStart(2,"0")}return(O,A)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["vs-date-picker",n.customClass])},[e.createVNode(vi,{modelValue:d.value,"onUpdate:modelValue":A[0]||(A[0]=M=>d.value=M),placeholder:G.value,disabled:n.disabled,clearable:n.clearable,typeable:n.editable,"week-day-names":g.value,"week-starts-on":p.value,"starting-view":m.value.startingView,"minimum-view":m.value.minimumView,"input-format":N.value,"upper-limit":f.value,name:n.name,class:e.normalizeClass(c.value)},null,8,["modelValue","placeholder","disabled","clearable","typeable","week-day-names","week-starts-on","starting-view","minimum-view","input-format","upper-limit","name","class"])],2))}}),[["__scopeId","data-v-637c8950"]]),_i=(o,t)=>{if(!t||!Object.keys(t).length)return o;const[n,r=""]=o.split("?"),a=new URLSearchParams(r);Object.entries(t).forEach(([s,c])=>{c==null||c===""||a.set(s,String(c))});const l=a.toString();return l?`${n}?${l}`:n},Ci=(o,t,n)=>new Promise((r,a)=>{const l=new FormData;l.append("unique","true"),l.append("file",o);const s=new XMLHttpRequest;s.open("POST",t),s.upload.addEventListener("progress",c=>{if(n){if(c.lengthComputable&&c.total>0){n(Math.min(100,Math.round(c.loaded/c.total*100)));return}n(0)}}),s.addEventListener("load",()=>{try{const c=s.responseText?JSON.parse(s.responseText):{};if(s.status>=200&&s.status<300){r(c?.result??null);return}a(new Error(c?.message||c?.error||`Код помилки: ${s.status}`))}catch(c){a(c)}}),s.addEventListener("error",()=>a(new Error("Помилка мережі під час завантаження файлу"))),s.addEventListener("abort",()=>a(new Error("Завантаження файлу скасовано"))),s.send(l)}),Ei=async(o,t={})=>{try{const{api:n,id:r="1",form:a="form",table:l="table",customParams:s,onProgress:c}=t,i=n||`/file/upload/uploads?id=${r||""}&form=${a||""}&table=${l||""}`,d=_i(i,s);if(o instanceof File)return await Ci(o,d,c);const h=new FormData;return h.append("unique","true"),h.append("file",o),(await fetch(d,{method:"POST",body:h}).then(p=>p.json()))?.result}catch(n){return he.notify({type:"error",title:"Помилка!",message:"Сталась помилка під час завантаження файлу",position:"right-bottom"}),console.error("Сталась помилка завантаження файлу",n),null}},Bi=async o=>{try{return await fetch(`file/delete/${o}`),!0}catch(t){return console.error(t),!1}},gr=async o=>{try{const t=await fetch(`/file/download/${o}`);if(!t.ok)throw new Error(`Download failed with status ${t.status}`);const n=await t.blob(),a=(t.headers.get("content-disposition")||"").match(/filename\*?=(?:UTF-8''|")?([^\";]+)/i),l=a?.[1]?decodeURIComponent(a[1].replace(/"/g,"").trim()):"",s=o.split("/").filter(Boolean).pop()||"download",c=l||s,i=document.createElement("a");i.setAttribute("download",c),i.href=window.URL.createObjectURL(n),i.click(),window.URL.revokeObjectURL(i.href)}catch(t){console.error(t.message)}},Vi=o=>{if(!o)return"";const t=o?.split(".");return t[t.length-1]},wo=o=>{const t=Vi(o),n={imageFormat:["tiff","jpg","jpeg","png","svg","ico","webp"],sheetsFormat:["xls","csv","xlsx"],archivesFormat:["zip","rar"],textsFormat:["json","geojson","txt","yml","yaml","shp"],documentsFormat:["pdf"]};return n.imageFormat.includes(t)?"img":n.sheetsFormat.includes(t)?X.Table:n.textsFormat.includes(t)?X.FileCode:n.documentsFormat.includes(t)?X.FileText:n.archivesFormat.includes(t)?X.FileArchive:X.FileText},Si=["title"],$i={key:0,class:"absolute inset-0 flex flex-col items-center justify-center gap-1 rounded-lg bg-white/90 px-2 text-center text-xs font-medium text-slate-600"},Ai=["title"],Ni={class:"absolute hidden top-0 right-0 flex items-center gap-x-2 w-full h-full justify-center"},gt=Ce(e.defineComponent({__name:"vs-input-file-list-item",props:e.mergeModels({format:{},multiple:{type:Boolean},max_size:{},api:{},customParams:{},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{},action:{type:Boolean,default:!1},isUploading:{type:Boolean,default:!1},progressPercent:{default:0},title:{default:""}},{value:{},valueModifiers:{},item:{},itemModifiers:{}}),emits:e.mergeModels(["click"],["update:value","update:item"]),setup(o,{emit:t}){const n=e.useModel(o,"value"),r=e.useModel(o,"item"),a=t,l=o,s=e.computed(()=>l.action),c=e.computed(()=>r.value?typeof r.value=="string"?r.value:r.value.file_path:""),i=e.computed(()=>l.disabled?"opacity-50 cursor-not-allowed":l.isUploading?"cursor-default text-blue-500":"cursor-pointer hover:border-blue-500 hover:bg-blue-50 hover:text-blue-500"),d=e.computed(()=>l.progressPercent>0?`${l.progressPercent}%`:"Завантаження..."),h=m=>typeof m=="string"?m:m?.file_path||"",g=()=>{const m=c.value;Bi(m),l.multiple&&Array.isArray(n.value)?n.value=n.value.filter(k=>h(k)!==m):n.value=""},p=()=>{c.value&&window.open(c.value,"_blank")},f=()=>{l.disabled||l.isUploading||a("click")};return(m,k)=>s.value?(e.openBlock(),e.createElementBlock("div",{key:0,title:m.title,class:e.normalizeClass(["relative h-[120px] w-[120px] border text-gray-300 border-dashed border-[#CFD9E0] rounded-lg flex items-center justify-center transition-all duration-300",i.value]),onClick:f},[m.isUploading?(e.openBlock(),e.createElementBlock("div",$i,[k[2]||(k[2]=e.createElementVNode("div",{class:"loader"},null,-1)),e.createElementVNode("span",null,e.toDisplayString(d.value),1)])):(e.openBlock(),e.createBlock(e.unref(X.Plus),{key:1,class:"h-4 w-4"}))],10,Si)):(e.openBlock(),e.createElementBlock("div",{key:1,title:c.value,class:"h-[120px] w-[120px] border text-gray-300 border-dashed border-[#CFD9E0] rounded-lg overflow-hidden relative item-file"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(wo)(c.value)),{src:`${e.unref(wo)(c.value)} === 'img'`?`/file/resize?filepath=${c.value}&format=webp`:c.value,alt:"file",class:"w-full h-full object-cover cursor-pointer",onClick:k[0]||(k[0]=b=>e.unref(gr)(c.value))},null,8,["src"])),e.createElementVNode("div",Ni,[e.createElementVNode("button",{type:"button",onClick:g,class:"w-6 h-6 flex items-center justify-center text-gray-500 bg-gray-200 rounded-lg hover:text-red-500"},[e.createVNode(e.unref(X.Trash2),{class:"w-4 h-4"})]),e.createElementVNode("button",{type:"button",onClick:p,class:"w-6 h-6 flex items-center justify-center text-gray-500 bg-gray-200 rounded-lg hover:text-emerald-600"},[e.createVNode(e.unref(X.Eye),{class:"w-4 h-4"})]),e.createElementVNode("button",{type:"button",onClick:k[1]||(k[1]=b=>e.unref(gr)(c.value)),class:"w-6 h-6 flex items-center justify-center text-gray-500 bg-gray-200 rounded-lg hover:text-blue-500"},[e.createVNode(e.unref(X.Download),{class:"w-4 h-4"})])])],8,Ai))}}),[["__scopeId","data-v-b03cac5c"]]),xo=o=>o?o.split(",").map(t=>t.trim().toLowerCase()).filter(Boolean).map(t=>t.startsWith(".")?t.slice(1):t):[],vo=(o,t)=>!t||o.size<=t*1024*1024?!0:(he.notify({type:"error",title:"Помилка!",message:`Файл "${o.name}" занадто великий. Максимальний розмір: ${t} МБ`,position:"right-bottom"}),!1),_o=(o,t)=>{if(!t.length)return!0;const n=o.name.split(".").pop()?.toLowerCase()||"";return t.includes(n)?!0:(he.notify({type:"error",title:"Помилка!",message:`Неприпустимий формат файлу "${o.name}". Дозволені формати: ${t.map(r=>`.${r}`).join(", ")}`,position:"right-bottom"}),!1)},yr=(o,t)=>{const n={},r=[];if(!o?.length)return{ok:!0,params:n,missingSources:r};const a=t?.value??{};return o.forEach(l=>{if(!l)return;const[s,c]=l.split("="),i=s?.trim(),d=c?.trim();if(!i||!d)return;const h=a[d];if(h==null||h===""){r.push(d);return}n[i]=h}),r.length?(he.notify({type:"warning",title:"Заповніть поля",message:`Поля (${r.join(", ")}) необхідні для завантаження файлу`,position:"right-bottom"}),{ok:!1,params:n,missingSources:r}):{ok:!0,params:n,missingSources:r}},br=(o,t)=>!t||!Array.isArray(o)?[]:o,kr=(o,t)=>t||Array.isArray(o)?null:o,wr=o=>{if(!o)return"";const t=o.split(/[/\\]/).pop()||"",n=t.lastIndexOf(".");return n<=0||n===t.length-1?"":t.slice(n+1).toLowerCase()},Mi={class:"flex items-center flex-wrap gap-2"},Fi=["accept","multiple","disabled"],xr=e.defineComponent({__name:"vs-input-file",props:e.mergeModels({format:{},multiple:{type:Boolean},max_size:{},api:{},customParams:{},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{},modelModifiers:{}}),emits:e.mergeModels(["change"],["update:modelValue"]),setup(o,{emit:t}){const n=o,r=e.useModel(o,"modelValue"),a=t,l=e.ref(null),s=e.ref(!1),c=e.ref([]),i=e.inject("values"),d=e.inject("map-file-import-uploading",null),h=e.computed(()=>br(r.value,!!n.multiple)),g=e.computed(()=>kr(r.value,!!n.multiple)),p=e.computed(()=>xo(n.format)),f=e.computed(()=>yr(n.customParams,i)),m=G=>{he.notify({type:"error",title:"Помилка завантаження",message:G||"Не вдалося завантажити файл. Спробуйте ще раз.",position:"right-bottom"})},k=()=>{n.disabled||s.value||f.value.ok&&l.value?.click()},b=async(G,I)=>{const E={api:n.api,customParams:Object.keys(f.value.params).length?f.value.params:void 0,onProgress:v=>{I&&(I.status="uploading",I.progressPercent=v)}},V=await Ei(G,E);return V?.file_path?V.file_path:null};e.watch(s,G=>{d&&(d.value=G)},{immediate:!0});const _=e.computed(()=>c.value.filter(G=>G.status!=="done")),C=e.computed(()=>_.value[0]||null),N=G=>typeof G=="string"?G:G?.file_path||"",$=(G,I)=>({key:`${Date.now()}-${I}-${G.name}`,file:G,size:G.size,uploaded:0,status:"pending",error:null,path:null,progressPercent:0}),q=async G=>{const{files:I}=G.target;if(!I||I.length===0)return;if(!f.value.ok){l.value&&(l.value.value="");return}const E=Array.from(I);if(n.max_size&&E.filter(T=>!vo(T,n.max_size)).length>0){l.value&&(l.value.value="");return}if(E.filter(v=>!_o(v,p.value)).length>0){l.value&&(l.value.value="");return}s.value=!0,c.value=E.map((v,T)=>$(v,T));try{if(n.multiple){const te=await Promise.all(E.map(async(R,H)=>{const Z=c.value[H];Z.status="uploading",Z.progressPercent=0;const ae=await b(R,Z);return ae?(Z.status="done",Z.path=ae,Z.uploaded=Z.size,Z.progressPercent=100):(Z.status="error",Z.error="Помилка при завантаженні"),ae})),D=te.filter(R=>!!R);if(D.length===0){m();return}D.length<te.length&&m("Деякі файли не вдалося завантажити. Перевірте їх та спробуйте знову.");const U=D,oe=Array.isArray(r.value)?r.value:r.value?[r.value]:[];r.value=[...oe,...U],a("change",r.value);return}const v=E[0],T=c.value[0];T.status="uploading",T.progressPercent=0;const j=await b(v,T);if(!j){T.status="error",T.error="Помилка при завантаженні",m();return}T.status="done",T.path=j,T.uploaded=T.size,T.progressPercent=100,r.value=j,a("change",j)}catch(v){m(v?.message||void 0)}finally{s.value=!1,c.value=[],l.value&&(l.value.value="")}};return(G,I)=>(e.openBlock(),e.createElementBlock("div",Mi,[e.createElementVNode("input",{class:"hidden",ref_key:"fileInput",ref:l,type:"file",accept:n.format,multiple:n.multiple,onChange:q,disabled:s.value||G.disabled},null,40,Fi),g.value?(e.openBlock(),e.createBlock(gt,{key:0,item:g.value,value:r.value,"onUpdate:value":I[0]||(I[0]=E=>r.value=E)},null,8,["item","value"])):e.createCommentVNode("",!0),n.multiple?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,(E,V)=>(e.openBlock(),e.createBlock(gt,{key:`${V}-${N(E)}`,multiple:!0,item:E,value:r.value,"onUpdate:value":I[1]||(I[1]=v=>r.value=v)},null,8,["item","value"]))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_.value,E=>(e.openBlock(),e.createBlock(gt,{key:E.key,action:"","is-uploading":!0,disabled:!0,"progress-percent":E.progressPercent,title:E.file.name},null,8,["progress-percent","title"]))),128)),e.createVNode(gt,{action:"","is-uploading":!1,disabled:G.disabled||s.value,title:"Добавить файлы",onClick:k},null,8,["disabled"])],64)):!n.multiple&&!C.value?(e.openBlock(),e.createBlock(gt,{key:2,action:"","is-uploading":!1,disabled:G.disabled||s.value,title:"Обновить файл",onClick:k},null,8,["disabled"])):C.value?(e.openBlock(),e.createBlock(gt,{key:3,action:"","is-uploading":!0,disabled:!0,"progress-percent":C.value.progressPercent,title:C.value.file.name},null,8,["progress-percent","title"])):e.createCommentVNode("",!0)]))}}),Di={class:"vs-input-file2 flex flex-col gap-4"},Ti={class:"flex items-center flex-wrap gap-2"},Li=["multiple","accept","disabled"],Ii={key:0,class:"text-sm text-rose-600"},Tn=e.defineComponent({__name:"vs-input-file2",props:e.mergeModels({format:{},max_size:{},api:{},multiple:{type:Boolean,default:!1},chunkSize:{default:5*1024*1024},subdir:{default:""},customParams:{},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.ref(null),a=e.ref(!1),l=e.ref(""),s=e.ref([]),c=e.inject("values"),i=e.computed(()=>!!t.multiple),d=e.computed(()=>xo(t.format)),h=e.computed(()=>{if(d.value.length)return d.value.map(E=>`.${E}`).join(",")}),g=e.computed(()=>br(n.value,i.value)),p=e.computed(()=>kr(n.value,i.value)),f=e.computed(()=>yr(t.customParams,c)),m=e.computed(()=>s.value.filter(E=>E.status!=="done")),k=e.computed(()=>i.value?null:m.value[0]||null),b=e.computed(()=>{const E=m.value,V=E.reduce((T,j)=>T+j.size,0);if(!V)return 0;const v=E.reduce((T,j)=>T+Math.min(j.uploaded,j.size),0);return Math.min(100,Math.round(v/V*100))}),_=()=>{t.disabled||a.value||f.value.ok&&r.value?.click()},C=async(E,V)=>{const v=V||G(E,0);try{v.status="uploading";const T={id:"",fileName:v.file.name,subdir:t.subdir,size:v.file.size,...f.value.params},j=await fetch(`${t.api||"/file/upload2"}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(T)});if(!j.ok)throw new Error("Не вдалося ініціалізувати завантаження");const te=await j.json().catch(()=>({}));v.uploadId=te.id||"",v.uploaded=Number(te.uploaded)||0,v.progressPercent=v.size?Math.min(100,Math.round(v.uploaded/v.size*100)):0;const D=t.chunkSize??5*1024*1024;for(;v.uploaded<v.size;){const R=v.uploaded,H=Math.min(R+D,v.size),ae=await v.file.slice(R,H).arrayBuffer(),O=await fetch(`${t.api||"/file/upload2"}/${v.uploadId}`,{method:"PATCH",headers:{"Content-Range":`bytes ${R}-${H-1}/${v.size}`,"Content-Type":"application/octet-stream"},body:ae});if(!O.ok)throw new Error("Помилка завантаження частини");const A=await O.json().catch(()=>({})),M=A.uploaded!=null?Number(A.uploaded):H;if(v.uploaded=M,v.progressPercent=v.size?Math.min(100,Math.round(v.uploaded/v.size*100)):0,A.finished||M>=v.size){const Q=wr(v.file.name),se=A.file_path||A.filepath||A.url||(Q?`/files/uploads/${v.uploadId}.${Q}`:`/files/uploads/${v.uploadId}`);return v.path=se,v.status="done",q(se),se}}const U=wr(v.file.name),oe=`/files/uploads/${v.uploadId}${U?`.${U}`:""}`;return v.path=oe,v.status="done",q(oe),oe}catch(T){return v.status="error",v.error=T?.message||"Помилка при завантаженні",l.value=T?.message||"Помилка при завантаженні",null}},N=E=>typeof E=="string"?E:E?.file_path||"",$=E=>!E||E.length===0?[]:Array.from(E),q=E=>{if(i.value){const V=Array.isArray(n.value)?[...n.value]:n.value?[n.value]:[];V.push(E),n.value=V;return}n.value=E},G=(E,V)=>({key:`${Date.now()}-${V}-${E.name}`,file:E,size:E.size,uploaded:0,uploadId:"",status:"pending",error:null,path:null,progressPercent:0}),I=async E=>{const V=E.target,v=$(V.files);if(!v.length)return;if(!f.value.ok){V.value="";return}const T=v.filter(j=>vo(j,t.max_size)&&_o(j,d.value));if(!T.length){V.value="";return}try{a.value=!0,l.value="",s.value=T.map((U,oe)=>G(U,oe));const te=(await Promise.allSettled(s.value.map(U=>C(U.file,U)))).filter(U=>U.status==="fulfilled").map(U=>U.value).filter(U=>!!U),D=s.value.filter(U=>U.status==="error").map(U=>U.file.name);if(te.length===0){l.value="Не вдалося завантажити файл";return}D.length>0?he.notify({type:"warning",title:"Частина файлів не завантажилась",message:D.join(", "),position:"right-bottom"}):he.notify({type:"success",title:"Файл завантажено",message:T.length>1?`Завантажено ${te.length} файлів`:T[0].name,position:"right-bottom"})}finally{a.value=!1,s.value=[],V.value=""}};return(E,V)=>(e.openBlock(),e.createElementBlock("div",Di,[e.createElementVNode("div",Ti,[e.createElementVNode("input",{ref_key:"fileInput",ref:r,type:"file",class:"hidden",multiple:i.value,accept:h.value,disabled:a.value||t.disabled,onChange:I},null,40,Li),i.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(g.value,(v,T)=>(e.openBlock(),e.createBlock(gt,{key:`${T}-${N(v)}`,multiple:!0,item:v,value:n.value,"onUpdate:value":V[0]||(V[0]=j=>n.value=j)},null,8,["item","value"]))),128)):p.value?(e.openBlock(),e.createBlock(gt,{key:1,item:p.value,value:n.value,"onUpdate:value":V[1]||(V[1]=v=>n.value=v)},null,8,["item","value"])):e.createCommentVNode("",!0),i.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:2},e.renderList(m.value,v=>(e.openBlock(),e.createBlock(gt,{key:v.key,action:"","is-uploading":!0,disabled:!0,"progress-percent":v.progressPercent,title:v.file.name},null,8,["progress-percent","title"]))),128)):k.value?(e.openBlock(),e.createBlock(gt,{key:3,action:"","is-uploading":!0,disabled:!0,"progress-percent":k.value.progressPercent,title:k.value.file.name},null,8,["progress-percent","title"])):e.createCommentVNode("",!0),e.createVNode(gt,{action:"","is-uploading":!1,disabled:t.disabled||a.value,"progress-percent":b.value,title:i.value?"Добавить файлы":"Обновить файл",onClick:_},null,8,["disabled","progress-percent","title"])]),l.value?(e.openBlock(),e.createElementBlock("p",Ii,e.toDisplayString(l.value),1)):e.createCommentVNode("",!0)]))}});function Oi(o){let t="";for(let r=0;r<o.length;r+=32768)t+=String.fromCharCode(...o.subarray(r,r+32768));return btoa(t)}async function vr(o){const t=await o.arrayBuffer();return{name:o.name,content:Oi(new Uint8Array(t))}}function Co(o,t="application/octet-stream"){const n=atob(o),r=new Uint8Array(n.length);for(let a=0;a<n.length;a++)r[a]=n.charCodeAt(a);return new Blob([r],{type:t})}function _r(o,t="application/octet-stream"){return URL.createObjectURL(Co(o,t))}function Cr(o){const t=Co(o.content),n=document.createElement("a");n.href=window.URL.createObjectURL(t),n.setAttribute("download",o.name),n.click(),window.URL.revokeObjectURL(n.href)}function Eo(o){if(!o||typeof o!="object"||Array.isArray(o))return!1;const t=o;return typeof t.name=="string"&&typeof t.content=="string"&&!!t.content}const Pi={class:"vs-input-file64 flex flex-col gap-2"},Ri={class:"flex items-center flex-wrap gap-2"},zi=["multiple","accept","disabled"],ji=["title"],Ui=["src"],Hi={key:1,class:"flex h-full w-full flex-col items-center justify-center gap-1 px-2 text-slate-500"},qi={class:"line-clamp-2 text-center text-[10px] text-slate-600"},Wi={class:"absolute inset-0 hidden items-center justify-center gap-x-2 bg-black/50 group-hover:flex"},Ki=["disabled","onClick"],Gi=["onClick"],Yi=["onClick"],Xi=["title"],Zi={class:"line-clamp-2 max-w-full break-words text-center text-[11px] font-semibold leading-snug"},Ji=["title"],Qi={key:0,class:"text-sm text-rose-600"},Ln=e.defineComponent({__name:"vs-input-file64",props:e.mergeModels({format:{},multiple:{type:Boolean,default:!1},multi:{type:Boolean},max_size:{default:10},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=new Set(["tiff","jpg","jpeg","png","svg","ico","webp"]),n=o,r=e.useModel(o,"modelValue"),a=e.ref(null),l=e.ref(!1),s=e.ref("Обробка…"),c=e.ref(""),i=e.ref([]),d=e.ref([]),h=e.computed(()=>!!(n.multiple||n.multi)),g=e.computed(()=>xo(n.format)),p=e.computed(()=>{if(g.value.length)return g.value.map(I=>`.${I}`).join(",")});function f(){i.value.forEach(I=>URL.revokeObjectURL(I)),i.value=[]}function m(I){return i.value.push(I),I}function k(I){const E=I.name.split(".").pop()?.toLowerCase()||"",V=wo(I.name);return{...I,url:m(_r(I.content)),isImage:t.has(E),icon:V==="img"?"img":V}}function b(){if(f(),h.value){const I=Array.isArray(r.value)?r.value.filter(Eo):[];d.value=I.map(k);return}d.value=Eo(r.value)?[k(r.value)]:[]}async function _(){await e.nextTick(),await new Promise(I=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>I())})})}e.watch([()=>r.value,h],()=>b(),{immediate:!0,deep:!0}),e.onBeforeUnmount(()=>{f()});const C=()=>{n.disabled||l.value||a.value?.click()},N=I=>{if(h.value&&Array.isArray(r.value)){r.value=r.value.filter((E,V)=>V!==I);return}r.value=null},$=I=>{I.url&&window.open(I.url,"_blank")},q=I=>{Cr({name:I.name,content:I.content})},G=async I=>{const E=I.target,V=E.files?Array.from(E.files):[];if(!V.length)return;const v=V.filter(T=>vo(T,n.max_size)&&_o(T,g.value));if(!v.length){E.value="";return}l.value=!0,s.value=v.length>1?`Обробка… (${v.length})`:`Обробка… ${v[0].name}`,c.value="",await _();try{const T=await Promise.all(v.map(j=>vr(j)));if(h.value){const j=Array.isArray(r.value)?r.value.filter(Eo):[];r.value=[...j,...T]}else r.value=T[0]||null;he.notify({type:"success",title:"Файл додано",message:T.length>1?`Додано ${T.length} файлів`:T[0].name,position:"right-bottom"})}catch(T){console.error(T),c.value="Помилка при обробці файлу",he.notify({type:"error",title:"Помилка!",message:"Помилка при обробці файлу",position:"right-bottom"})}finally{l.value=!1,E.value=""}};return(I,E)=>(e.openBlock(),e.createElementBlock("div",Pi,[e.createElementVNode("div",Ri,[e.createElementVNode("input",{ref_key:"fileInput",ref:a,type:"file",class:"hidden",multiple:h.value,accept:p.value,disabled:I.disabled||l.value,onChange:G},null,40,zi),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,(V,v)=>(e.openBlock(),e.createElementBlock("div",{key:`${v}-${V.name}`,class:"group relative h-[120px] w-[120px] overflow-hidden rounded-lg border border-dashed border-[#CFD9E0] text-gray-300",title:V.name},[V.isImage?(e.openBlock(),e.createElementBlock("img",{key:0,src:V.url,alt:"",class:"h-full w-full object-cover"},null,8,Ui)):(e.openBlock(),e.createElementBlock("div",Hi,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(V.icon),{class:"h-8 w-8"})),e.createElementVNode("span",qi,e.toDisplayString(V.name),1)])),e.createElementVNode("div",Wi,[e.createElementVNode("button",{type:"button",class:"flex h-6 w-6 items-center justify-center rounded-lg bg-gray-200 text-gray-500 hover:text-red-500",disabled:I.disabled||l.value,onClick:T=>N(v)},[e.createVNode(e.unref(X.Trash2),{class:"h-4 w-4"})],8,Ki),e.createElementVNode("button",{type:"button",class:"flex h-6 w-6 items-center justify-center rounded-lg bg-gray-200 text-gray-500 hover:text-emerald-600",onClick:T=>$(V)},[e.createVNode(e.unref(X.Eye),{class:"h-4 w-4"})],8,Gi),e.createElementVNode("button",{type:"button",class:"flex h-6 w-6 items-center justify-center rounded-lg bg-gray-200 text-gray-500 hover:text-blue-500",onClick:T=>q(V)},[e.createVNode(e.unref(X.Download),{class:"h-4 w-4"})],8,Yi)])],8,ji))),128)),l.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"box-border flex h-[120px] w-[120px] flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-blue-400 bg-blue-50 p-2 text-blue-600",title:s.value},[E[0]||(E[0]=e.createElementVNode("div",{class:"h-6 w-6 shrink-0 animate-spin rounded-full border-[3px] border-blue-100 border-t-blue-600"},null,-1)),e.createElementVNode("span",Zi,e.toDisplayString(s.value),1)],8,Xi)):!I.disabled&&(h.value||!d.value.length)?(e.openBlock(),e.createElementBlock("div",{key:1,class:"flex h-[120px] w-[120px] cursor-pointer items-center justify-center rounded-lg border border-dashed border-[#CFD9E0] text-gray-300 transition-all hover:border-blue-500 hover:bg-blue-50 hover:text-blue-500",title:h.value?"Добавить файлы":"Выбрать файл",onClick:C},[e.createVNode(e.unref(X.Plus),{class:"h-4 w-4"})],8,Ji)):e.createCommentVNode("",!0)]),c.value?(e.openBlock(),e.createElementBlock("p",Qi,e.toDisplayString(c.value),1)):e.createCommentVNode("",!0)]))}}),ec={class:"flex items-center justify-center h-[30px] w-[30px]"},tc={class:"max-w-[55vw]"},nc={class:"text-sm font-semibold text-gray-800 truncate dark:text-neutral-200"},oc={class:"flex items-center text-xs text-gray-500 truncate dark:text-neutral-500"},rc={class:"px-[5px]"},lc={class:""},In=e.defineComponent({__name:"vs-widget-file-info",props:{item:{default:null}},setup(o){const t=o,n=e.computed(()=>{try{return new Date(t.item.cdate).toLocaleDateString("uk-UA",{day:"2-digit",month:"long",year:"numeric"})}catch{return""}});function r(a){if(a<1024)return`${a} B`;const l=a/1024;return l<1024?`${l.toFixed(2)} KB`:`${(l/1024).toFixed(2)} MB`}return(a,l)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",ec,[e.createVNode(e.unref(X.FileText),{class:"icon icon-tabler icons-tabler-outline icon-tabler-file h-4 w-4"})]),e.createElementVNode("div",tc,[e.createElementVNode("p",nc,e.toDisplayString(a.item?.uploaded_name),1),e.createElementVNode("p",oc,[e.createElementVNode("span",null,e.toDisplayString(a.item?.username),1),e.withDirectives(e.createElementVNode("span",rc,"|",512),[[e.vShow,a.item?.username]]),e.createElementVNode("span",null,e.toDisplayString(n.value),1),l[0]||(l[0]=e.createElementVNode("span",{class:"px-[5px]"},"|",-1)),e.createElementVNode("span",lc,e.toDisplayString(r(a.item?.size)),1)])])],64))}}),ac={class:"p-3 relative group flex items-center gap-x-3 border border-gray-200 bg-white rounded-md w-full"},sc={key:0,class:"flex w-full gap-x-3 items-center"},ic={key:1,class:"flex gap-x-3 w-full items-center"},cc={key:2,class:"flex gap-x-3 w-full items-center"},dc=["href"],uc={key:3,class:"flex gap-x-3 w-full items-center"},pc={class:"lg:absolute lg:top-3 lg:end-1 opacity-100"},mc={class:"p-0.5 sm:p-1 inline-flex items-center gap-0.5 bg-white rounded-lg dark:bg-neutral-800 dark:border-neutral-700"},fc={class:"inline-block"},hc={class:"inline-block"},gc={class:"inline-block"},yc=e.defineComponent({__name:"vs-widget-file-item",props:{item:{default:null},index:{default:0},prefix:{default:"/api"}},emits:["update","openModal","openLightbox"],setup(o,{emit:t}){const n=o,r=t;function a(g){return["pdf","json"].includes(g.ext)}function l(g){return["ppt","pptx","doc","docx","xls","xlsx"].includes(g.ext)}function s(g){const p=document.createElement("a");p.setAttribute("download",g?.uploaded_name),p.href=g?.file_path,p.click()}function c(g){g?.file_path&&window.open(g.file_path,"_blank")}async function i(){try{await fetch(`${n.prefix}/widget/file/${n.item.entity_id}/${n.item.file_id}`,{method:"DELETE"}),r("update")}catch(g){console.error(g)}}function d(){r("openModal",{title:"Ви впевнені?",message:"Ви впевнені, що хочете видалити цей файл?",confirmButtonText:"Так, я впевнена/ий",cancelButtonText:"Скасувати",confirm:i,updateListOnConfirm:!0})}function h(g){(n.item.ext==="jpg"||n.item.ext==="png")&&r("openLightbox",{item:n.item,index:g})}return(g,p)=>(e.openBlock(),e.createElementBlock("div",ac,[g.item.ext==="jpg"||g.item.ext==="png"?(e.openBlock(),e.createElementBlock("div",sc,[e.createElementVNode("div",{class:"max-w-[55vw] cursor-pointer flex gap-x-3 w-full items-center",onClick:p[0]||(p[0]=f=>h(g.index))},[e.createVNode(In,{item:g.item},null,8,["item"])])])):a(g.item)?(e.openBlock(),e.createElementBlock("div",ic,[e.createVNode(In,{item:g.item},null,8,["item"])])):l(g.item)?(e.openBlock(),e.createElementBlock("div",cc,[e.createElementVNode("a",{href:`/api/file-preview?id=${g.item.file_id}`,target:"_blank",class:"flex gap-x-3 w-full items-center"},[e.createVNode(In,{item:g.item},null,8,["item"])],8,dc)])):(e.openBlock(),e.createElementBlock("div",uc,[e.createVNode(In,{item:g.item},null,8,["item"])])),e.createElementVNode("div",pc,[e.createElementVNode("div",mc,[e.createElementVNode("div",fc,[e.createElementVNode("button",{class:"inline-flex p-[6px] justify-center items-center gap-x-2 rounded-lg border border-transparent text-gray-500 hover:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none dark:text-neutral-400 focus:outline-none focus:bg-gray-100 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700",onClick:p[1]||(p[1]=f=>c(g.item))},[e.createVNode(e.unref(X.Eye),{class:"h-4 w-4"})])]),e.createElementVNode("div",hc,[e.createElementVNode("button",{class:"inline-flex p-[6px] justify-center items-center gap-x-2 rounded-lg border border-transparent text-gray-500 hover:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none dark:text-neutral-400 focus:outline-none focus:bg-gray-100 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700",onClick:p[2]||(p[2]=f=>s(g.item))},[e.createVNode(e.unref(X.Download),{class:"h-4 w-4"})])]),p[4]||(p[4]=e.createElementVNode("div",{class:"w-px h-5 mx-1 bg-gray-200 dark:bg-neutral-700"},null,-1)),e.createElementVNode("div",gc,[e.createElementVNode("button",{type:"button",class:"size-[30px] inline-flex justify-center items-center gap-x-2 rounded-lg border border-transparent text-red-600 hover:bg-red-100 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-red-100 dark:text-red-500 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20",onClick:p[3]||(p[3]=f=>d())},[e.createVNode(e.unref(X.Trash2),{class:"h-4 w-4"})])])])])]))}}),bc={class:"flex flex-col widget-file xl:bg-white xl:rounded-xl dark:xl:bg-neutral-800 dark:xl:border-neutral-700 w-full"},kc={class:"flex w-full mb-[12px] items-center gap-x-2"},wc={class:"font-semibold text-gray-800 dark:text-neutral-200 text-[14px]"},xc={class1:"ml-auto"},vc={class:"py-1.5 px-4 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg bg-gray-100 cursor-pointer hover:bg-gray-200 text-gray-800 shadow-2xs hover:bg-gray-50 focus:outline-hidden focus:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-800 dark:border-neutral-700 dark:text-white dark:hover:bg-neutral-700 dark:focus:bg-neutral-700"},_c={key:0,class:"py-4 mb-4 space-y-4 border-gray-200 border-y dark:border-neutral-700"},Cc={class:"relative"},Ec={class:"absolute inset-y-0 start-0 flex items-center pointer-events-none z-[1] ps-3.5"},Bc={key:1,class:"space-y-3 max-h-[300px] overflow-y-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"},Vc={key:0},Er=e.defineComponent({__name:"vs-input-file-list",props:{id:{default:""},prefix:{default:"/api"},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},emits:["update"],setup(o,{emit:t}){const n=o,r=e.inject("form"),a=e.computed(()=>r.value.formId),l=e.ref(!1),s=e.ref(0),c=t,i=e.ref(!1),d=e.ref({}),h=e.ref([]),g=e.ref(""),p=e.computed(()=>Array.isArray(h.value)?h.value.filter(N=>N.ext==="jpg"||N.ext==="png").map(N=>N?.file_path):[]),f=e.computed(()=>g.value===""?h.value:h.value.filter(N=>N?.uploaded_name?.includes(g.value))),m=N=>{const $=p.value.findIndex(q=>q===N.item.file_path);$!==-1&&(l.value=!0,s.value=$)},k=async()=>{try{const N=await fetch(`${n.prefix}/widget/file/${a.value}`).then($=>$.json());h.value=N?.rows}catch(N){console.error(N)}},b=async N=>{await Promise.all(Array.from(N.target.files).map(async $=>{const q=new FormData;q.append("file",$);try{const G=`${n.prefix}/widget/file/${a.value}`,I=await fetch(G,{method:"POST",body:q});return I.ok?(c("update","file-list"),$):(he.notify({type:I.status>=400&&I.status<500?"warning":"error",title:"Error",message:`Error code: ${I.status}`}),null)}catch(G){return he.notify({type:"error",title:"Error",message:G.message||"Unknown error"}),console.error(G),null}})),await k()},_=N=>{const $={...N};return N.cancel||($.cancel=()=>{i.value=!1}),N.updateListOnConfirm&&($.confirm=async()=>{await N.confirm(),i.value=!1,k()}),$},C=N=>{d.value=_(N),i.value=!0};return e.watch(a,N=>{N&&k()}),e.onMounted(()=>{a.value&&k()}),(N,$)=>{const q=e.resolveComponent("Lightbox"),G=e.resolveComponent("MessageBox");return e.openBlock(),e.createElementBlock("div",bc,[e.createElementVNode("div",kc,[e.createElementVNode("h2",wc," Файлів: "+e.toDisplayString(h.value?.length),1),e.createElementVNode("div",xc,[e.createElementVNode("label",null,[e.createElementVNode("input",{type:"file",class:"hidden",onChange:$[0]||($[0]=I=>b(I))},null,32),e.createElementVNode("div",vc,[e.createVNode(e.unref(X.Upload),{class:"h-4 w-4"})])])])]),h.value?.length>4?(e.openBlock(),e.createElementBlock("div",_c,[e.createElementVNode("div",null,[e.createElementVNode("div",Cc,[e.createElementVNode("div",Ec,[e.createVNode(e.unref(X.Search),{class:"flex-shrink-0 text-gray-500 size-4 dark:text-neutral-400"})]),e.withDirectives(e.createElementVNode("input",{type:"text","onUpdate:modelValue":$[1]||($[1]=I=>g.value=I),class:"py-2 px-3 ps-10 pe-16 block w-full bg-gray-200 xl:bg-gray-100 rounded-lg text-sm focus:border-blue-500 h-[40px] focus:border-2 focus:outline-none disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-700 dark:border-transparent dark:text-neutral-400 dark:placeholder:text-neutral-400 dark:focus:ring-neutral-600",placeholder:"Введіть назву файлу"},null,512),[[e.vModelText,g.value,void 0,{trim:!0}]])])])])):e.createCommentVNode("",!0),h.value?.length?(e.openBlock(),e.createElementBlock("div",Bc,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,(I,E)=>(e.openBlock(),e.createBlock(yc,{key:E,prefix:N.prefix,item:I,index:E,onUpdate:$[2]||($[2]=V=>N.$emit("update","file-list")),onOpenModal:$[3]||($[3]=V=>C(V)),onOpenLightbox:$[4]||($[4]=V=>m(V))},null,8,["prefix","item","index"]))),128)),f.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Vc,$[8]||($[8]=[e.createElementVNode("p",{class:"text-sm text-gray-600 font-sm"}," Файлів з такою назвою не існує, введіть інше пошукове слово ",-1)])))])):e.createCommentVNode("",!0),e.createVNode(q,{modelValue:l.value,"onUpdate:modelValue":$[5]||($[5]=I=>l.value=I),startIndex:s.value,"onUpdate:index":$[6]||($[6]=I=>s.value=I),images:p.value},null,8,["modelValue","startIndex","images"]),e.createVNode(G,e.mergeProps({modelValue:i.value,"onUpdate:modelValue":$[7]||($[7]=I=>i.value=I),onConfirm:d.value.confirm},d.value),null,16,["modelValue","onConfirm"])])}}}),Sc={class:"flex items-center justify-between"},$c={class:"text-[16px] text-gray-900 font-medium"},Ac={class:"grid gap-3"},Nc=Ce(e.defineComponent({__name:"vs-container-switcher",props:{title:{type:String,default:""},style:{type:Object,default:()=>({})},isOpen:{type:Boolean,default:!1}},setup(o){const t=o,n=e.ref(t.isOpen);return e.watch(()=>t.isOpen,r=>{n.value=r}),(r,a)=>(e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("div",Sc,[e.createElementVNode("p",$c,e.toDisplayString(o.title),1),e.createVNode(co,{modelValue:n.value,"onUpdate:modelValue":a[0]||(a[0]=l=>n.value=l),style:e.normalizeStyle(o.style)},null,8,["modelValue","style"])]),e.createVNode(e.Transition,{name:"slide-fade"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",Ac,[e.renderSlot(r.$slots,"default",{},void 0,!0)],512),[[e.vShow,n.value]])]),_:3})]))}}),[["__scopeId","data-v-90320b87"]]),Mc={class:"text-[16px] text-gray-900 font-medium"},Fc={class:"grid gap-3"},Dc=Ce(e.defineComponent({__name:"vs-container-accordion",props:{title:{type:String,default:""},style:{type:Object,default:()=>({})},isOpen:{type:Boolean,default:!1}},setup(o){const t=o,n=e.ref(t.isOpen);return e.watch(()=>t.isOpen,r=>{n.value=r}),(r,a)=>(e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("button",{type:"button",onClick:a[0]||(a[0]=l=>n.value=!n.value),class:"flex items-center gap-2"},[e.createVNode(e.unref(X.ChevronDown),{class:e.normalizeClass(["h-4 w-4 duration-300",[n.value?"-rotate-180":""]])},null,8,["class"]),e.createElementVNode("span",Mc,e.toDisplayString(o.title),1)]),e.createVNode(e.Transition,{name:"slide-fade"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",Fc,[e.renderSlot(r.$slots,"default",{},void 0,!0)],512),[[e.vShow,n.value]])]),_:3})]))}}),[["__scopeId","data-v-0c825d65"]]),Tc={class:"flex items-center justify-between"},Lc={switcher:Nc,accordion:Dc,default:e.defineComponent({__name:"vs-container-default",props:{title:{type:String,default:""},style:{type:Object,default:()=>({})}},setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("div",Tc,[e.createElementVNode("p",null,e.toDisplayString(o.title),1)]),e.renderSlot(t.$slots,"default")]))}})},ct={Equal:"==",Inequal:"!=",Higer:">",HigerOrEqual:">=",Lower:"<",LowerOrEqual:"<=",Between:"between",StartWith:"^",EndWith:"$",Contain:"*",In:"in",NotIn:"not_in"},Ic=(o,t)=>String(o)===String(t),Oc=(o,t)=>String(o)!==String(t),Pc=(o,t)=>o>t,Rc=(o,t)=>o>=t,zc=(o,t)=>o<t,jc=(o,t)=>o<=t,Uc=(o,t)=>Array.isArray(t)&&t.length===2?o>=t[0]&&o<=t[1]:!1,Hc=(o,t)=>String(o).startsWith(String(t)),qc=(o,t)=>String(o).endsWith(String(t)),Wc=(o,t)=>String(o).includes(String(t)),Kc=(o,t)=>Array.isArray(t)?t.includes(o):!1,Gc=(o,t)=>Array.isArray(t)?!t.includes(o):!0,Yc=(o,t)=>{if(!t)return!0;switch(t?.[1]){case ct.Equal:return Ic(o,t?.[2]);case ct.Inequal:return Oc(o,t?.[2]);case ct.Higer:return Pc(o,t?.[2]);case ct.HigerOrEqual:return Rc(o,t?.[2]);case ct.Lower:return zc(o,t?.[2]);case ct.LowerOrEqual:return jc(o,t?.[2]);case ct.Between:return Uc(o,t?.[2]);case ct.StartWith:return Hc(o,t?.[2]);case ct.EndWith:return qc(o,t?.[2]);case ct.Contain:return Wc(o,t?.[2]);case ct.In:return Kc(o,t?.[2]);case ct.NotIn:return Gc(o,t?.[2]);default:return!0}};function Br(o,t,n){return t==null||!Array.isArray(t)||t.length===0?!0:(Array.isArray(t[0])?t:[t]).every(a=>{if(!Array.isArray(a)||a.length<2)return!0;const l=a[0],s=n?o?.[n]?.[l]??o?.[l]:o?.[l];return Yc(s,a)})}const Vr=e.defineComponent({__name:"vs-input-container",props:{style:{type:Object,default:()=>({})},title:{type:String,default:""},view:{type:String,default:"default"},name:{type:String,default:""},schema:{type:Array,default:()=>[]}},setup(o){const t=o,n=e.inject("values",e.ref({})),r=e.inject("form"),a=e.computed(()=>t.schema?.filter(c=>Br(n.value,c?.conditions,t.name||void 0))),l=e.computed(()=>Lc[t.view]),s=e.computed(()=>{if(n.value||(n.value={}),!t.name)return n.value;const c=n.value[t.name];if(c)return c;const i={};return n.value={...n.value,[t.name]:i},i});return(c,i)=>o.schema?.length?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(l.value),{key:0,title:o.title,style:e.normalizeStyle(o.style)},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,d=>(e.openBlock(),e.createBlock(Qr,e.mergeProps({key:d.name},{ref_for:!0},d,{item:d,modelValue:s.value[d.name],"onUpdate:modelValue":h=>s.value[d.name]=h,style:o.style,error:e.unref(r)?.errors?.[d.name]}),null,16,["item","modelValue","onUpdate:modelValue","style","error"]))),128))]),_:1},8,["title","style"])):e.createCommentVNode("",!0)}}),Sr=({props:o,fetchOptionByValue:t,optionsList:n,selectedOption:r,modelValue:a,onCreated:l})=>{const s=e.ref(!1),c=e.ref({}),i=e.ref([]),d=e.ref(null),h=e.computed(()=>o.add?.title||"Додати"),g=e.computed(()=>o.add?.token||o.add?.model||""),p=e.computed(()=>o.add?.pk||"id");return{isOpenAdd:s,addData:c,addSchema:i,addForm:d,addTitle:h,addOption:async()=>{if(!(!g.value||d?.value.validate()))try{const b=o.add?.api??`/api/table/${g.value}`,_=await fetch(b,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c.value)}),C=await _.json().catch(()=>({})),N=C?.error||C?.message,$=Number(C?.code)>=400;if(!_.ok||$){he.notify({title:"Помилка",type:"error",message:N||`Код помилки: ${C?.code||_.status}`});return}const q=C?.rows?.[0],G=C?.[p.value]??C?.id??q?.[p.value]??q?.id;if(!G){he.notify({title:"Помилка",type:"error",message:"Обʼєкт створено, але в відповіді відсутній ID."});return}const I=await t(G);I&&(n.value.some(V=>String(V?.id)===String(I.id))||n.value.push(I)),l?await l(I,G):I&&(r.value=I,a.value=G),s.value=!1,he.notify({title:"Успіх",message:"Обʼєкт успішно створено."})}catch(b){he.notify({title:"Помилка",type:"error",message:b?.message||"Не вдалося створити обʼєкт."})}},onAddValue:async()=>{if(!o.add)return null;const k=await fetch(`/api/template/form/${o.add.form}`).then(b=>b.json());return i.value=k.schema,c.value={},s.value=!0,null}}},Xc=["aria-expanded","data-focus"],Zc={class:"vs-input-select__value-area relative flex flex-1 items-center gap-1 py-0.5 pl-1 pr-0 overflow-hidden h-full min-w-0"},Jc={key:0,class:"flex flex-nowrap items-center gap-1 overflow-x-auto overflow-y-hidden min-w-0 flex-1 py-0.5"},Qc={class:"flex items-center gap-1 min-w-0"},ed=["title"],td=["innerHTML"],nd=["onClick"],od={class:"flex-1 min-w-[2px]"},rd=["placeholder"],ld=["title"],ad=["innerHTML"],sd={key:3,class:"truncate flex-1 min-w-0"},id={key:2,class:"flex-1 min-w-[2px]"},cd=["placeholder"],dd={key:3,class:"flex-1 flex items-center min-h-[30px] py-0.5 pl-2 text-sm truncate text-inherit"},ud={class:"vs-input-select__actions relative z-10 flex items-center shrink-0 bg-white"},pd=["disabled"],md={key:1,class:"self-stretch w-px bg-[#ccc] my-[1px]"},fd=["disabled","title"],hd=e.defineComponent({__name:"vs-select-control",props:{disabled:{type:Boolean},isOpen:{type:Boolean},inputFocus:{type:Boolean},isMulti:{type:Boolean},selectedOptions:{},selectedIds:{},placeholder:{},search:{type:Boolean},optionTemplate:{default:""},iconWrapperClass:{},selectedOptionLabel:{},selectedOption:{},showClear:{type:Boolean},keyWord:{default:""},setTriggerRef:{},setInputRef:{},shouldShowColorDot:{},optionHasIcon:{},getIconColorStyle:{},resolveOptionIcon:{},renderTemplate:{},getLabel:{},onControlKeydown:{},onControlClick:{},onInputFocus:{},onInputBlur:{},onInputKeydown:{},onRemoveSelected:{},onClearSelected:{},onToggleSelect:{}},emits:["update:keyWord"],setup(o,{emit:t}){const n=o,r=t,a=e.computed({get:()=>n.keyWord,set:l=>r("update:keyWord",l)});return(l,s)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["vs-input-select__control flex min-h-[38px] items-center justify-between rounded transition-colors bg-white",l.disabled?"bg-gray-100 text-gray-400 cursor-not-allowed":""]),role:"combobox","aria-expanded":l.isOpen,"aria-haspopup":"listbox",onKeydown:s[10]||(s[10]=(...c)=>l.onControlKeydown&&l.onControlKeydown(...c)),onClick:s[11]||(s[11]=(...c)=>l.onControlClick&&l.onControlClick(...c)),"data-focus":l.isOpen||l.inputFocus?"true":"false",ref:l.setTriggerRef},[e.createElementVNode("div",Zc,[l.isMulti?(e.openBlock(),e.createElementBlock("div",Jc,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.selectedOptions,c=>(e.openBlock(),e.createElementBlock("div",{key:c.id,class:"flex min-w-0 bg-[rgb(230,230,230)] rounded-[2px] m-[2px] box-border max-w-full"},[e.createElementVNode("div",Qc,[l.shouldShowColorDot(c)?(e.openBlock(),e.createElementBlock("span",{key:0,class:"w-[16px] h-[16px] rounded-md block ml-1.5 flex-shrink-0",style:e.normalizeStyle({backgroundColor:c?.color})},null,4)):e.createCommentVNode("",!0),!l.optionTemplate&&l.optionHasIcon(c)?(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass(l.iconWrapperClass),style:e.normalizeStyle(l.getIconColorStyle(c)),"aria-hidden":"true"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(l.resolveOptionIcon(c)),{class:"w-full h-full",focusable:"false"}))],6)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"truncate text-[#172b4d] overflow-hidden max-w-[200px] px-0.5 pl-1.5",title:l.getLabel(c)},[l.optionTemplate?(e.openBlock(),e.createElementBlock("div",{key:0,innerHTML:l.renderTemplate(c)},null,8,td)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(c.text),1)],64))],8,ed)]),e.createElementVNode("div",{role:"button",class:"flex items-center rounded-sm px-1 box-border text-[#172b4d] hover:bg-[rgb(255,189,173)] hover:text-[rgb(222,53,11)] flex-shrink-0",onClick:e.withModifiers(i=>l.onRemoveSelected(c.id),["stop"])},[e.createVNode(e.unref(X.X),{"aria-hidden":"true",focusable:"false",class:"inline-block h-4 w-4"})],8,nd)]))),128)),e.createElementVNode("div",od,[!l.disabled&&l.search?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,ref:l.setInputRef,class:"w-full bg-transparent outline-none border-0 m-0 p-0 text-gray-900 hover:cursor-pointer",autocapitalize:"none",autocomplete:"off",autocorrect:"off",spellcheck:"false",type:"text",tabindex:"0","aria-autocomplete":"list",placeholder:l.selectedIds.length?" ":l.placeholder,"onUpdate:modelValue":s[0]||(s[0]=c=>a.value=c),onFocus:s[1]||(s[1]=(...c)=>l.onInputFocus&&l.onInputFocus(...c)),onBlur:s[2]||(s[2]=(...c)=>l.onInputBlur&&l.onInputBlur(...c)),onKeydown:s[3]||(s[3]=(...c)=>l.onInputKeydown&&l.onInputKeydown(...c))},null,40,rd)),[[e.vModelText,a.value]]):e.createCommentVNode("",!0)])])):!l.isMulti&&l.selectedOptionLabel&&a.value===""?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["truncate flex items-center gap-1 min-w-0 pl-2",l.disabled||!l.search?"relative z-0 flex-1 min-h-[30px] py-0.5 text-inherit":"absolute inset-x-0 top-0 bottom-0 z-[1] text-gray-900 pointer-events-none"]),title:l.selectedOptionLabel},[l.shouldShowColorDot(l.selectedOption)?(e.openBlock(),e.createElementBlock("span",{key:0,class:"w-[14px] h-[14px] rounded-md block flex-shrink-0",style:e.normalizeStyle({backgroundColor:l.selectedOption?.color})},null,4)):e.createCommentVNode("",!0),!l.optionTemplate&&l.optionHasIcon(l.selectedOption)?(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass(l.iconWrapperClass),style:e.normalizeStyle(l.getIconColorStyle(l.selectedOption)),"aria-hidden":"true"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(l.resolveOptionIcon(l.selectedOption)),{class:"w-full h-full",focusable:"false"}))],6)):e.createCommentVNode("",!0),l.optionTemplate?(e.openBlock(),e.createElementBlock("div",{key:2,class:"truncate flex-1 min-w-0",innerHTML:l.renderTemplate(l.selectedOption)},null,8,ad)):(e.openBlock(),e.createElementBlock("span",sd,e.toDisplayString(l.selectedOption?.text),1))],10,ld)):e.createCommentVNode("",!0),!l.isMulti&&!l.disabled&&l.search?(e.openBlock(),e.createElementBlock("div",id,[e.withDirectives(e.createElementVNode("input",{ref:l.setInputRef,class:"w-full bg-transparent outline-none border-0 m-0 p-0 text-gray-900 hover:cursor-pointer",autocapitalize:"none",autocomplete:"off",autocorrect:"off",spellcheck:"false",type:"text",tabindex:"0","aria-autocomplete":"list",placeholder:l.selectedOptionLabel?" ":l.placeholder,"onUpdate:modelValue":s[4]||(s[4]=c=>a.value=c),onFocus:s[5]||(s[5]=(...c)=>l.onInputFocus&&l.onInputFocus(...c)),onBlur:s[6]||(s[6]=(...c)=>l.onInputBlur&&l.onInputBlur(...c)),onKeydown:s[7]||(s[7]=(...c)=>l.onInputKeydown&&l.onInputKeydown(...c))},null,40,cd),[[e.vModelText,a.value]])])):!l.isMulti&&l.disabled&&(!l.selectedOptionLabel||a.value!=="")?(e.openBlock(),e.createElementBlock("div",dd,e.toDisplayString(l.placeholder),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",ud,[l.showClear?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"px-2 text-gray-400 hover:text-gray-500 transition-colors disabled:opacity-50","aria-hidden":"true",disabled:l.disabled,onClick:s[8]||(s[8]=e.withModifiers((...c)=>l.onClearSelected&&l.onClearSelected(...c),["stop"]))},[e.createVNode(e.unref(X.X),{class:"h-4 w-4"})],8,pd)):e.createCommentVNode("",!0),l.showClear?(e.openBlock(),e.createElementBlock("div",md)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"px-2 text-gray-400 hover:text-gray-500 transition-colors disabled:opacity-50","aria-hidden":"true",disabled:l.disabled,onClick:s[9]||(s[9]=e.withModifiers((...c)=>l.onToggleSelect&&l.onToggleSelect(...c),["stop"])),title:l.isOpen?"Закрити список":"Відкрити список"},[e.createVNode(e.unref(X.ChevronDown),{class:"h-4 w-4"})],8,fd)])],42,Xc))}}),gd=["aria-disabled","onMousedown"],yd={class:"leading-[19px]"},bd=["innerHTML"],kd={key:1,class:"px-3 py-2 text-center text-gray-500"},wd=e.defineComponent({__name:"vs-select-dropdown",props:{isOpen:{type:Boolean},dropdownStyle:{},filteredOptionsList:{},selectedNavIndex:{},optionTemplate:{},iconWrapperClass:{},setDropdownRef:{type:Function},setListRef:{type:Function},setItemRef:{type:Function},isSelected:{type:Function},onOptionClick:{type:Function},shouldShowColorDot:{type:Function},optionHasIcon:{type:Function},getIconColorStyle:{type:Function},resolveOptionIcon:{type:Function},renderTemplate:{type:Function}},setup(o){return(t,n)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[t.isOpen?(e.openBlock(),e.createElementBlock("div",{key:0,ref:t.setDropdownRef,class:"fixed z-[3000] rounded bg-white shadow-[0_0_0_1px_rgba(0,0,0,0.1),0_4px_11px_rgba(0,0,0,0.1)]",style:e.normalizeStyle(t.dropdownStyle),role:"listbox"},[e.createElementVNode("div",{class:"overflow-y-auto py-1",style:e.normalizeStyle({maxHeight:t.dropdownStyle.maxHeight||"300px"}),ref:t.setListRef},[t.filteredOptionsList.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(t.filteredOptionsList,(r,a)=>(e.openBlock(),e.createElementBlock("div",{key:r.id,ref_for:!0,ref:l=>t.setItemRef(l,a),class:e.normalizeClass(["flex px-3 py-2 gap-2 cursor-pointer select-none text-gray-900",t.isSelected(r.id)?"bg-[#2684ff] text-white":"bg-white hover:bg-[#deebff] hover:text-[#172b4d]",t.selectedNavIndex===a&&!t.isSelected(r.id)?"bg-[#deebff] text-[#172b4d]":""]),"aria-disabled":t.isSelected(r.id)?"true":"false",role:"option",tabindex:"-1",onMousedown:e.withModifiers(l=>t.onOptionClick(r),["prevent","stop"])},[t.shouldShowColorDot(r)?(e.openBlock(),e.createElementBlock("span",{key:0,class:"w-[11px] h-[11px] rounded-full block flex-shrink-0",style:e.normalizeStyle({backgroundColor:r?.color})},null,4)):e.createCommentVNode("",!0),!t.optionTemplate&&t.optionHasIcon(r)?(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass(t.iconWrapperClass),style:e.normalizeStyle(t.getIconColorStyle(r)),"aria-hidden":"true"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.resolveOptionIcon(r)),{class:"w-full h-full",focusable:"false"}))],6)):e.createCommentVNode("",!0),e.createElementVNode("div",yd,[t.optionTemplate?(e.openBlock(),e.createElementBlock("div",{key:0,innerHTML:t.renderTemplate(r)},null,8,bd)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(r.text),1)],64))])],42,gd))),128)):(e.openBlock(),e.createElementBlock("div",kd," No options "))],4)],4)):e.createCommentVNode("",!0)]))}}),xd={class:"flex justify-end items-center gap-x-2 py-3 px-4 border-t border-gray-200 w-full"},vd=["onClick"],_d=["disabled"],Cd="__autoMeta",$r="w-[16px] h-[16px] flex items-center justify-center flex-shrink-0 text-current",Bo=Ce(e.defineComponent({__name:"vs-input-select",props:{multiple:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},mode:{},defaultValue:{},search:{type:Boolean,default:!0},placeholder:{default:"Оберіть значення"},prefix:{default:"api"},host:{default:""},data:{default:""},options:{default:()=>[]},api:{default:null},maxHeight:{default:400},parent:{},set:{},slot:{},add:{},teleport:{default:"body"},auto:{default:0},start:{default:0},style:{default:()=>({})},customClass:{default:""},modelValue:{},error:{default:null},name:{},maxlength:{},minlength:{}},emits:["change","update:modelValue","value-selected"],setup(o,{emit:t}){const n=o,r=t,a=e.computed(()=>n.multiple),l=e.computed(()=>n.disabled),s=e.computed(()=>n.search);Qe(n.style);const c=e.computed({get:()=>n.modelValue,set:W=>r("update:modelValue",W)});(c.value===null||c.value===void 0||c.value==="")&&n.defaultValue!=null&&(c.value=n.defaultValue);const i=e.ref(null),d=e.ref(null),h=e.ref(null),g=e.ref(null),p=e.ref(!1),f=e.ref(!1),m=e.ref(null),k=e.ref(-1),b=e.ref([]),_=e.ref(""),C=e.ref(null),N=W=>{d.value=W},$=W=>{C.value=W},q=W=>{g.value=W},G=W=>{h.value=W},I=(W,re)=>{b.value[re]=W},E=e.ref({}),V=e.ref([]),v=e.computed(()=>{if(!V.value.length)return[];const W=ge.value,re=new Map(W.map(pe=>[pe.id?.toString(),pe]));return V.value.map(pe=>re.get(pe?.toString())).filter(pe=>!!pe)}),T=e.computed(()=>n.placeholder||"Select..."),j=e.computed(()=>ae(m.value)),te=e.computed(()=>l.value?!1:a.value?V.value.length>0:c.value!==null&&c.value!==void 0&&c.value!==""),D=W=>a.value?V.value.some(re=>re?.toString()===W?.toString()):c.value?.toString()===W?.toString(),U=e.computed(()=>{let W=ge.value??[];if(!n.data&&_.value.trim()!==""){const re=_.value.toLowerCase();W=W.filter(pe=>{const Ve=ae(pe).toLowerCase(),Pe=pe.text?.toLowerCase?.()||"";return Ve.includes(re)||Pe.includes(re)})}if(a.value&&V.value.length){const re=new Set(V.value.map(pe=>pe?.toString()));W=W.filter(pe=>!re.has(pe.id?.toString()))}return W}),oe=e.inject("values"),R=e.inject("field-props"),H=e.computed(()=>n.slot??n?.optionTemplate??""),Z=W=>Vn(W,H.value),ae=W=>Sn(W,H.value),O=e.computed(()=>Cn(H.value)),A=W=>rn(W),M=W=>!!(!O.value&&Dt(W)&&!A(W)),Q=W=>{const re=Dt(W);return re?{color:re}:void 0},se=W=>!!(!O.value&&(on(W)||A(W))),ee=(W,re,pe)=>{if(!R)return!1;const Ve=R.value?.[W]??{},Pe=(Re,Ze,xt)=>{if(!Ze.length)return Re;const[mt,...vt]=Ze,ft={...Re};if(!vt.length)return ft[mt]=xt,ft;const zt=typeof Re[mt]=="object"&&Re[mt]!==null?Re[mt]:{};return ft[mt]=Pe(zt,vt,xt),ft},Xe=Pe(Ve,re,pe);return R.value={...R.value||{},[W]:Xe},!0},me=W=>{if(!R||!n.name)return;const re=R.value?.[n.name]??{};R.value={...R.value||{},[n.name]:{...re,[Cd]:W}}},ke=W=>{if(!n.set)return;const re=oe?.value;!re&&!R||Object.entries(n.set).forEach(([pe,Ve])=>{if(!pe)return;const Pe=W?W[Ve]:null,Xe=pe.split(".").map(xt=>xt.trim()).filter(Boolean);if(!Xe.length)return;const[Re,...Ze]=Xe;Ze.length&&ee(Re,Ze,Pe??null)||re&&(re[Re]=Pe??null)})},{optionsList:ge,parentValue:Se,fetchOptions:Ne,fetchOptionByValue:$e,loadOptions:Oe}=Bn({props:n,formValues:oe,watchParent:!1}),Me=W=>W==null?"":String(W),ne=W=>{if(a.value){if(!V.value.length){ge.value=W;return}}else if(!m.value){ge.value=W;return}const re=new Set(W.map(Ve=>Me(Ve.id)).filter(Boolean));if(a.value){const Ve=new Set(V.value.map(Xe=>Me(Xe)).filter(Boolean)),Pe=(ge.value??[]).filter(Xe=>{const Re=Me(Xe.id);return!Re||!Ve.has(Re)?!1:!re.has(Re)});ge.value=[...Pe,...W];return}const pe=Me(m.value?.id);if(pe&&!re.has(pe)){ge.value=[m.value,...W];return}ge.value=W},de=e.ref(0),xe=async W=>{const re=++de.value,pe=await Ne(W);return re!==de.value?null:pe},ve=async()=>{if(n.data){const W=await xe(_.value);return W&&ne(W),ge.value}return Oe()},ze=async W=>{if(W==null||W==="")return null;const re=ge.value?.find(pe=>pe?.id?.toString()===String(W));return re||$e(W)},Te=async W=>{const re=new Set(ge.value.map(Ve=>Ve.id?.toString())),pe=W.filter(Ve=>!re.has(Ve?.toString()));pe.length&&await pe.reduce(async(Ve,Pe)=>{await Ve;const Xe=await ze(Pe);Xe&&ge.value.push(Xe)},Promise.resolve())},Je=()=>{if(!U.value.length){k.value=-1;return}let W=0;if(!a.value&&m.value){const re=m.value.id?.toString(),pe=U.value.findIndex(Ve=>Ve.id?.toString()===re);pe>=0&&(W=pe)}k.value=W,e.nextTick(()=>{P(b.value[W],h.value)})},Ae=async()=>{l.value||(p.value=!0,await e.nextTick(()=>{we()}),await ve(),await e.nextTick(()=>{we(),C.value?.focus()}),Je())},Fe=()=>{p.value=!1,k.value=-1,e.nextTick(()=>{C.value?.blur()})},ut=async W=>{if(l.value)return;(W!==void 0?W:!p.value)?await Ae():Fe()},z=async()=>{if(!l.value){if(p.value){Fe();return}await Ae()}},J=()=>{a.value?(V.value=[],c.value=[],r("change",[]),F(null,[])):(m.value=null,c.value=null,r("change",null),F(null,null)),ke(null),me(null),_.value="",Fe(),e.nextTick(()=>{C.value?.focus()})},ie=W=>{a.value&&(V.value=V.value.filter(re=>re?.toString()!==W?.toString()),c.value=[...V.value],r("change",c.value),F(null),e.nextTick(()=>C.value?.focus()))},F=(W,re)=>{const pe=re??(a.value?[...V.value]:W?.id??null);r("value-selected",{name:n.name,value:pe,option:W})},w=(W,re="manual")=>{a.value?(D(W.id)||(V.value=[...V.value,W.id],c.value=[...V.value],r("change",c.value),F(W)),_.value="",e.nextTick(()=>{C.value?.focus(),k.value=Math.min(k.value,U.value.length-1)}),ke(null)):(m.value=W,c.value=W.id,r("change",c.value),F(W),_.value="",Fe(),ke(W),re==="parent-auto"&&me({source:re,parentField:n.parent??null,parentValue:Se.value??null}))},S=W=>{if(D(W.id)){a.value||Fe();return}w(W)},P=(W,re)=>{if(!W||!re)return;const pe=W.offsetTop,Ve=pe+W.offsetHeight,Pe=re.scrollTop,Xe=Pe+re.clientHeight;let Re=re.scrollTop;pe<Pe?Re=pe-80:Ve>Xe&&(Re=Ve-re.clientHeight+4);const Ze=re;Ze.scrollTop=Re},le=W=>{let re=W.parentElement;for(;re;){if(re.classList.contains("ui-dialog__content"))return re;const pe=window.getComputedStyle(re),Ve=pe.overflow+pe.overflowY+pe.overflowX;if(Ve.includes("auto")||Ve.includes("scroll")||re===document.body||re===document.documentElement)return re;re=re.parentElement}return document.body},we=()=>{if(!d.value)return;const W=d.value.getBoundingClientRect(),re=window.innerHeight||document.documentElement.clientHeight,pe=window.innerWidth||document.documentElement.clientWidth,Ve=8,Pe=8,Xe=n.maxHeight||300,Re=re-W.bottom-Pe-Ve,Ze=W.top-Pe-Ve,xt=Re>=Ze,mt=Math.max(pe-Ve*2,0);let{width:vt}=W;mt>0&&vt>mt&&(vt=mt);let{left:ft}=W;ft+vt+Ve>pe&&(ft=pe-vt-Ve),ft=Math.max(ft,Ve);const zt=Math.min(Xe,Math.max(xt?Re:Ze,50));E.value={position:"fixed",left:`${ft}px`,width:`${vt}px`,maxHeight:`${zt}px`,transform:xt?"none":"translateY(-100%)",top:xt?`${W.bottom+Pe}px`:`${W.top-Pe}px`}},Le=async W=>{l.value||!p.value&&(W.key==="ArrowDown"||W.key==="ArrowUp")&&(W.preventDefault(),await Ae())},De=W=>{if(!p.value)return;const{key:re}=W;if(re==="ArrowDown")W.preventDefault(),k.value+1<U.value.length&&(k.value+=1,P(b.value[k.value],h.value));else if(re==="ArrowUp")W.preventDefault(),k.value>0&&(k.value-=1,P(b.value[k.value],h.value));else if(re==="Enter"){W.preventDefault();const pe=U.value[k.value];pe&&w(pe),C.value?.blur()}else re==="Escape"?(W.preventDefault(),Fe()):re==="Backspace"?a.value&&_.value===""&&V.value.length&&(V.value=V.value.slice(0,-1),c.value=[...V.value],r("change",c.value)):re==="Home"?(k.value=0,P(b.value[0],h.value)):re==="End"?(k.value=U.value.length-1,P(b.value[k.value],h.value)):re==="Tab"&&Fe()},je=()=>{l.value||(f.value=!0)},He=()=>{f.value=!1,_.value=""},pt=W=>{W.key==="Escape"&&p.value&&Fe()},qe=W=>{const re=W.target;i.value?.contains(re)||g.value?.contains(re)||Fe()},it=W=>{p.value&&h.value&&!h.value.contains(W.target)&&we()},Pt=()=>{p.value&&we()},to=()=>{p.value&&we()};async function Qt(){if(a.value)Array.isArray(c.value)?V.value=[...c.value]:(V.value=c.value==null?[]:[c.value],c.value=[...V.value]),n.data&&V.value.length&&(await Te(V.value),await e.nextTick());else{if(Array.isArray(c.value)){const W=c.value[0]??null;c.value=W??null}c.value!=null&&c.value!==""?m.value=await ze(c.value):m.value=null,ke(m.value??null)}}e.watch(c,()=>{Qt()}),e.onMounted(async()=>{if(addEventListener("keydown",pt),addEventListener("scroll",it,!0),addEventListener("resize",Pt),document.addEventListener("click",qe,!0),d.value&&le(d.value).addEventListener("scroll",to,!0),n.options?.length&&!n.data)ge.value=[...n.options];else if(n.data){const W=await xe("");W&&ne(W)}await Qt(),Gt.value=!1}),e.onUnmounted(()=>{removeEventListener("keydown",pt),removeEventListener("scroll",it,!0),removeEventListener("resize",Pt),document.removeEventListener("click",qe,!0),d.value&&le(d.value).removeEventListener("scroll",to,!0)});const{isOpenAdd:$t,addData:Rt,addSchema:K,addForm:fe,addTitle:tt,addOption:At,onAddValue:wt}=Sr({props:n,fetchOptionByValue:$e,optionsList:ge,selectedOption:m,modelValue:c});function We(W,re=200){let pe;return(...Ve)=>{pe&&clearTimeout(pe),pe=window.setTimeout(()=>W(...Ve),re)}}const en=We(async W=>{const re=await xe(W);re&&ne(re)},200);e.watch(_,W=>{n.data&&en(W.trim())}),e.watch(()=>n.options,W=>{!n.data&&W?.length&&(ge.value=[...W],Qt())},{immediate:!0});const Gt=e.ref(!0);return e.watch(Se,async()=>{if(n.data&&(Gt.value||(a.value?(V.value=[],c.value=[],r("change",[])):(m.value=null,c.value=null,r("change",null))),await ve(),n.auto===1&&Se.value&&ge.value.length>0)){const W=ge.value[0];W&&w(W,"parent-auto")}}),(W,re)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(he.VsModal),{visible:e.unref($t),"onUpdate:visible":re[2]||(re[2]=pe=>e.isRef($t)?$t.value=pe:null),class:"z-[1000]",title:e.unref(tt),teleport:W.teleport},{footer:e.withCtx(({handleClose:pe})=>[e.createElementVNode("div",xd,[e.createElementVNode("button",{type:"button",class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-gray-200 bg-white text-gray-800 hover:bg-gray-50",onClick:pe}," Скасувати ",8,vd),e.createElementVNode("button",{type:"button",class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-transparent bg-blue-600 text-white hover:bg-blue-700",onClick:re[1]||(re[1]=(...Ve)=>e.unref(At)&&e.unref(At)(...Ve))}," Додати ")])]),default:e.withCtx(()=>[e.createVNode(ot,{schema:e.unref(K),modelValue:e.unref(Rt),"onUpdate:modelValue":re[0]||(re[0]=pe=>e.isRef(Rt)?Rt.value=pe:null),ref_key:"addForm",ref:fe},null,8,["schema","modelValue"])]),_:1},8,["visible","title","teleport"]),e.createElementVNode("div",{class:"flex gap-1 w-full",ref_key:"selectRoot",ref:i,onClick:re[5]||(re[5]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",{class:e.normalizeClass(["relative w-full font-sans",n.customClass])},[re[6]||(re[6]=e.createElementVNode("span",{id:"react-select-live-region",class:"sr-only"},null,-1)),re[7]||(re[7]=e.createElementVNode("span",{"aria-live":"polite","aria-atomic":"false","aria-relevant":"additions text",role:"log",class:"sr-only"},null,-1)),e.createVNode(hd,{keyWord:_.value,"onUpdate:keyWord":re[3]||(re[3]=pe=>_.value=pe),disabled:l.value,"is-open":p.value,"input-focus":f.value,"is-multi":a.value,"selected-options":v.value,"selected-ids":V.value,placeholder:T.value,search:s.value,"option-template":H.value,"icon-wrapper-class":$r,"selected-option-label":j.value,"selected-option":m.value,"show-clear":te.value,"set-trigger-ref":N,"set-input-ref":$,"should-show-color-dot":M,"option-has-icon":se,"get-icon-color-style":Q,"resolve-option-icon":A,"render-template":Z,"get-label":ae,"on-control-keydown":Le,"on-control-click":z,"on-input-focus":je,"on-input-blur":He,"on-input-keydown":De,"on-remove-selected":ie,"on-clear-selected":J,"on-toggle-select":ut},null,8,["keyWord","disabled","is-open","input-focus","is-multi","selected-options","selected-ids","placeholder","search","option-template","selected-option-label","selected-option","show-clear"]),e.createVNode(wd,{"is-open":p.value,"dropdown-style":E.value,"filtered-options-list":U.value,"selected-nav-index":k.value,"option-template":H.value,"icon-wrapper-class":$r,"set-dropdown-ref":q,"set-list-ref":G,"set-item-ref":I,"is-selected":D,"on-option-click":S,"should-show-color-dot":M,"option-has-icon":se,"get-icon-color-style":Q,"resolve-option-icon":A,"render-template":Z},null,8,["is-open","dropdown-style","filtered-options-list","selected-nav-index","option-template"])],2),n.add?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:re[4]||(re[4]=(...pe)=>e.unref(wt)&&e.unref(wt)(...pe)),class:"bg-white hover:bg-gray-100 text-sm text-gray-900 py-[10px] px-3 border border-stone-200 rounded-md h-[38px] flex items-center gap-2",disabled:l.value,type:"button"},[e.createVNode(e.unref(X.Plus),{class:"h-4 w-4"}),re[8]||(re[8]=e.createElementVNode("span",null,"Додати",-1))],8,_d)):e.createCommentVNode("",!0)],512)],64))}}),[["__scopeId","data-v-9b686f27"]]),Vo=(o="")=>`${o}${Math.floor(Math.random()*1e4)}`,Ed=["disabled","aria-expanded"],Bd={class:"truncate"},Vd={class:"py-2 px-4"},Sd={class:"block font-medium text-[13px] text-foreground"},$d={class:"truncate"},Ad={class:"p-1 border-t border-gray-200"},Nd={class:"space-y-0.5 max-h-48 overflow-y-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-none [&::-webkit-scrollbar-track]:bg-scrollbar-track [&::-webkit-scrollbar-thumb]:bg-scrollbar-thumb"},Md=["onClick"],Fd=["checked"],Dd={class:"shrink-0 size-3.5 flex justify-center items-center"},Td={key:1,class:"shrink-0 size-2 block mx-auto rounded-full bg-secondary/60"},Ld={class:"truncate"},Id={key:0,class:"px-3 py-2 text-xs text-stone-500"},On=e.defineComponent({__name:"vs-input-inline-select",props:{multiple:{type:Boolean},disabled:{type:Boolean,default:!1},mode:{},defaultValue:{},search:{type:Boolean},placeholder:{default:"Оберіть значення"},prefix:{default:"api"},host:{default:""},data:{default:""},options:{default:()=>[]},api:{default:null},maxHeight:{},parent:{},set:{},slot:{},add:{},teleport:{default:"body"},auto:{},start:{default:0},style:{default:()=>({})},customClass:{default:""},modelValue:{},error:{default:null},name:{},maxlength:{},minlength:{}},emits:["change","update:modelValue","value-selected"],setup(o,{emit:t}){const n=o,r=t;Qe(n.style);const a=e.computed({get:()=>Array.isArray(n.modelValue)?n.modelValue[0]??null:n.modelValue??null,set:ee=>r("update:modelValue",ee)});a.value==null&&n.defaultValue!=null&&(a.value=n.defaultValue);const l=e.inject("values"),s=e.inject("field-props"),c=e.computed(()=>!!n.disabled),i=e.ref(null),d=e.ref(!1),h=e.ref(null),g=e.ref(null),p=e.ref(null),f=e.ref({}),m=`vs-input-inline-select-${Vo()}`,k=e.computed(()=>n.placeholder||"Оберіть значення"),b=e.computed(()=>q(i.value)||n.placeholder||"Оберіть значення"),_=e.computed(()=>n.slot??""),C=e.computed(()=>Cn(_.value)),N=e.computed(()=>n.teleport||"body"),$=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6}|[\da-fA-F]{8})$/,q=ee=>Sn(ee,_.value),G=ee=>!!(!C.value&&Dt(ee)),I=e.computed(()=>{const ee=Dt(i.value).trim();return ee?$.test(ee)?`bg-[${ee}] border-[${ee}]`:`bg-${ee.toLowerCase()}-500 border-${ee.toLowerCase()}-500`:""}),{optionsList:E,parentValue:V,fetchOptions:v,fetchOptionByValue:T,loadOptions:j}=Bn({props:n,formValues:l,watchParent:!1}),te=(ee,me,ke)=>{if(!s)return!1;const ge=s.value?.[ee]??{},Se=($e,Oe,Me)=>{if(!Oe.length)return $e;const[ne,...de]=Oe,xe={...$e};if(!de.length)return xe[ne]=Me,xe;const ve=typeof $e[ne]=="object"&&$e[ne]!==null?$e[ne]:{};return xe[ne]=Se(ve,de,Me),xe},Ne=Se(ge,me,ke);return s.value={...s.value||{},[ee]:Ne},!0},D=ee=>{if(!n.set)return;const me=l?.value;!me&&!s||Object.entries(n.set).forEach(([ke,ge])=>{if(!ke)return;const Se=ee?ee[ge]:null,Ne=ke.split(".").map(Me=>Me.trim()).filter(Boolean);if(!Ne.length)return;const[$e,...Oe]=Ne;Oe.length&&te($e,Oe,Se??null)||me&&(me[$e]=Se??null)})},U=ee=>a.value?.toString?.()===ee?.toString?.(),oe=()=>{if(!g.value||typeof window>"u")return;const ee=g.value.getBoundingClientRect(),me=8,ke=8,ge=window.innerHeight||document.documentElement.clientHeight,Se=window.innerWidth||document.documentElement.clientWidth,Ne=p.value?.offsetHeight||260,$e=Math.max(ee.width,176),Oe=Math.max(Se-me*2,120),Me=Math.min($e,Oe);let ne=ee.left;ne+Me+me>Se&&(ne=Se-Me-me),ne=Math.max(ne,me);const de=ge-ee.bottom-ke-me,xe=ee.top-ke-me,ve=de<Math.min(Ne,260)&&xe>de,ze=Math.max(120,Math.min(320,ve?xe:de));f.value={position:"fixed",left:`${ne}px`,top:ve?`${ee.top-ke}px`:`${ee.bottom+ke}px`,transform:ve?"translateY(-100%)":"none",width:`${Me}px`,maxHeight:`${ze}px`}},R=async()=>{if(n.data){E.value=await v("");return}await j()},H=async()=>{if(a.value==null||a.value===""){i.value=null,D(null);return}const ee=E.value.find(me=>me.id?.toString()===String(a.value));if(ee){i.value=ee,D(ee);return}i.value=await T(a.value),D(i.value??null)},Z=async()=>{c.value||(d.value=!0,await e.nextTick(),oe(),await R(),await e.nextTick(),oe())},ae=()=>{d.value=!1},O=async()=>{if(d.value){ae();return}await Z()},A=ee=>{r("value-selected",{name:n.name,value:ee?.id??null,option:ee})},M=ee=>{i.value=ee,a.value=ee.id,r("change",ee.id),A(ee),D(ee),ae()},Q=ee=>{const me=ee.target;h.value?.contains(me)||p.value?.contains(me)||ae()},se=()=>{d.value&&oe()};return e.watch(()=>n.options,ee=>{n.data||(E.value=ee?[...ee]:[],H())},{immediate:!0,deep:!0}),e.watch(a,()=>{H()}),e.watch(V,async()=>{n.data&&(await R(),i.value&&!E.value.some(ee=>ee.id?.toString()===i.value?.id?.toString())&&(i.value=null,a.value=null,r("change",null),A(null),D(null)))}),e.onMounted(async()=>{document.addEventListener("click",Q,!0),window.addEventListener("resize",se),window.addEventListener("scroll",se,!0),await R(),await H()}),e.onUnmounted(()=>{document.removeEventListener("click",Q,!0),window.removeEventListener("resize",se),window.removeEventListener("scroll",se,!0)}),(ee,me)=>(e.openBlock(),e.createElementBlock("div",{class:"relative inline-flex w-full max-w-full",ref_key:"rootRef",ref:h,onClick:me[0]||(me[0]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("button",{ref_key:"triggerRef",ref:g,type:"button",disabled:c.value,"aria-expanded":d.value?"true":"false","aria-haspopup":"menu",class:e.normalizeClass(["py-1.5 px-2.5 inline-flex items-center gap-2 text-nowrap text-xs sm:text-[13px] rounded-lg focus:outline-hidden disabled:opacity-50 disabled:pointer-events-none max-w-full border",I.value?`${I.value} text-white`:"bg-secondary text-secondary-foreground hover:bg-secondary-hover focus:bg-secondary-focus border-gray-300 hover:border-gray-400"]),onClick:O},[e.createElementVNode("span",Bd,e.toDisplayString(b.value),1)],10,Ed),(e.openBlock(),e.createBlock(e.Teleport,{to:N.value},[d.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:p,class:"z-[3000] w-44 transition-[opacity,margin] duration-150 bg-white text-gray-900 border border-gray-200 rounded-xl shadow-lg",style:e.normalizeStyle(f.value),role:"menu","aria-orientation":"vertical"},[e.createElementVNode("div",Vd,[e.createElementVNode("span",Sd,[e.createElementVNode("span",$d,e.toDisplayString(k.value),1)])]),e.createElementVNode("div",Ad,[e.createElementVNode("div",Nd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(E),ke=>(e.openBlock(),e.createElementBlock("label",{key:ke.id,class:"py-1.5 px-3 group flex items-center gap-x-3 rounded-lg cursor-pointer text-[13px] text-gray-800 hover:bg-gray-100",onClick:e.withModifiers(ge=>M(ke),["prevent"])},[e.createElementVNode("input",{type:"radio",class:"hidden",name:m,checked:U(ke.id),tabindex:"-1"},null,8,Fd),e.createElementVNode("span",Dd,[G(ke)?(e.openBlock(),e.createElementBlock("span",{key:0,class:"shrink-0 size-2 block mx-auto rounded-full",style:e.normalizeStyle({backgroundColor:ke.color})},null,4)):(e.openBlock(),e.createElementBlock("span",Td))]),e.createElementVNode("span",Ld,e.toDisplayString(q(ke)),1),e.createVNode(e.unref(X.Check),{class:e.normalizeClass(["shrink-0 size-3.5 ms-auto transition-opacity",U(ke.id)?"opacity-100":"opacity-0"])},null,8,["class"])],8,Md))),128))]),e.unref(E).length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("p",Id,"Немає варіантів"))])],4)):e.createCommentVNode("",!0)],8,["to"]))],512))}}),Od=["placeholder","disabled"],Ar=e.defineComponent({__name:"vs-input-textarea",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,{inputClass:n}=Qe(t.style),r=e.useModel(o,"modelValue"),a=e.computed(()=>!!t.disabled),l=e.computed(()=>t.placeholder??"");function s(){typeof r.value=="string"&&(r.value=r.value.trim())}return(c,i)=>e.withDirectives((e.openBlock(),e.createElementBlock("textarea",{"onUpdate:modelValue":i[0]||(i[0]=d=>r.value=d),placeholder:l.value,disabled:a.value,row:"2",onBlur:s,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] h-auto bg-white",[e.unref(n)]]),style:{border:"1px solid #CFD9E0"}},null,42,Od)),[[e.vModelText,r.value]])}}),Nr=e.defineComponent({__name:"vs-input-richtext",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{},format:{default:"html"},richtextProps:{default:()=>({})}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=e.defineAsyncComponent(()=>Promise.resolve().then(()=>pb)),n=o,r=e.useModel(o,"modelValue"),a=e.computed(()=>!!n.disabled),l=e.computed(()=>n.placeholder??""),s=e.computed(()=>({height:n.richtextProps.height||"300px",format:n.format,...n.richtextProps}));return(c,i)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["!h-full overflow-hidden rounded-md border border-solid border-stone-200 disabled:opacity-50 disabled:cursor-not-allowed",c.customClass]),style:e.normalizeStyle(a.value?{pointerEvents:"none",opacity:.6}:{})},[e.createVNode(e.unref(t),e.mergeProps({modelValue:r.value,"onUpdate:modelValue":i[0]||(i[0]=d=>r.value=d),placeholder:l.value},s.value),null,16,["modelValue","placeholder"])],6))}}),Pd={},Rd={viewBox:"0 0 178 90",fill:"none",xmlns:"http://www.w3.org/2000/svg"};function zd(o,t){return e.openBlock(),e.createElementBlock("svg",Rd,t[0]||(t[0]=[e.createStaticVNode('<rect x="27" y="50.5" width="124" height="39" rx="7.5" fill="currentColor" class="fill-white dark:fill-neutral-800"></rect><rect x="27" y="50.5" width="124" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-50 dark:stroke-neutral-700/10"></rect><rect x="34.5" y="58" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="66.5" y="61" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="66.5" y="73" width="77" height="6" rx="3" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="19.5" y="28.5" width="139" height="39" rx="7.5" fill="currentColor" class="fill-white dark:fill-neutral-800"></rect><rect x="19.5" y="28.5" width="139" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-100 dark:stroke-neutral-700/30"></rect><rect x="27" y="36" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><rect x="59" y="39" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><rect x="59" y="51" width="92" height="6" rx="3" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><g filter="url(#filter1)"><rect x="12" y="6" width="154" height="40" rx="8" fill="currentColor" class="fill-white dark:fill-neutral-800" shape-rendering="crispEdges"></rect><rect x="12.5" y="6.5" width="153" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-100 dark:stroke-neutral-700/60" shape-rendering="crispEdges"></rect><rect x="20" y="14" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect><rect x="52" y="17" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect><rect x="52" y="29" width="106" height="6" rx="3" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect></g><defs><filter id="filter1" x="0" y="0" width="178" height="64" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"></feColorMatrix><feOffset dy="6"></feOffset><feGaussianBlur stdDeviation="6"></feGaussianBlur><feComposite in2="hardAlpha" operator="out"></feComposite><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.03 0"></feColorMatrix><feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_1187_14810"></feBlend><feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_1187_14810" result="shape"></feBlend></filter></defs>',12)]))}const jd=Ce(Pd,[["render",zd]]),Ud={class:"bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden flex flex-col"},Hd={key:0,class:"flex flex-col gap-2 !p-4 border-b border-gray-200 md:flex-row md:items-center md:justify-between bg-gray-50"},qd={key:0,class:"relative flex-1 min-w-0"},Wd={class:"flex md:flex-nowrap flex-wrap items-center md:justify-end justify-start gap-2 shrink-0"},Kd={class:"w-full overflow-x-auto"},Gd={class:"w-full min-w-[640px] table-auto divide-y divide-gray-200"},Yd={class:"bg-gray-50"},Xd={class:"border-b border-gray-200"},Zd={class:"px-4 py-3 text-left text-xs font-semibold text-gray-900 w-12 text-center"},Jd=["onClick"],Qd={key:0,class:"text-gray-400"},eu={key:0,colspan:"100%",class:"text-center"},tu={class:"w-full"},nu={class:"p-5 min-h-[200px] flex flex-col justify-center items-center text-center"},ou=["data-row-index","onDragstart","onDragover","onDrop"],ru=["onPointerdown"],lu={class:"flex items-center justify-center"},au=["innerHTML"],su={key:0,class:"flex items-center gap-3 text-sm text-gray-700"},iu={key:0},cu=["src"],du={key:1,class:"rounded-md max-w-[45px] w-[45px] max-h-[45px] h-[45px] bg-gray-200 flex items-center justify-center"},uu={key:1,class:"flex items-center justify-center"},pu=["innerHTML"],mu={key:3,class:"text-sm font-medium text-gray-900"},fu={class:"px-4 py-3 text-right whitespace-nowrap"},hu={class:"flex items-center justify-end gap-2"},gu=["onClick"],yu=["onClick"],bu={class:"vs-form__head mr-5 mt-3 flex items-center justify-end sticky top-0 left-0 z-[60] bg-white"},Mr=Ce(e.defineComponent({__name:"vs-input-datatable",props:e.mergeModels({actions:{},colModel:{},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useSlots(),r=e.inject("values",null),a=e.inject("form-root-values",null),l=z=>t.actions===void 0?!0:t.actions.includes(z),s=["search","import","export","add"],c=e.computed(()=>s.some(z=>l(z))),i=e.useModel(o,"modelValue"),d=e.ref({}),h=e.ref(""),g=e.ref(null),p=e.ref("asc"),f=e.computed(()=>{const z=i.value??[],J=h.value?z.filter(w=>m.value?.some(S=>{const P=S.key||S.name;if(!P)return!1;const le=w[P];return le?Array.isArray(le)?le.join(", ").toLowerCase().includes(h.value.toLowerCase()):String(le).toLowerCase().includes(h.value.toLowerCase()):!1})):z;if(!g.value)return J;const ie=g.value,F=[...J].sort((w,S)=>{const P=$e(w?.[ie]),le=$e(S?.[ie]);return typeof P=="number"&&typeof le=="number"?P-le:String(P).localeCompare(String(le))});return p.value==="asc"?F:F.reverse()}),m=e.computed(()=>(t.colModel??[]).filter(z=>!z.tableHidden)),k=e.ref(null),b=e.ref(null),_=e.ref(null);function C(z){return z.pointerType==="touch"||z.pointerType==="pen"}function N(z,J){const F=document.elementFromPoint(z,J)?.closest?.("[data-row-index]")??null;if(!F)return null;const w=F.getAttribute("data-row-index");if(w==null)return null;const S=Number.parseInt(w,10);return Number.isNaN(S)?null:S}function $(z,J){C(z)&&(z.preventDefault(),z.currentTarget.setPointerCapture(z.pointerId),k.value=J,b.value=J)}function q(z){if(k.value===null||!C(z))return;z.preventDefault();const J=N(z.clientX,z.clientY);J!==null&&(b.value=J)}function G(z){if(k.value===null||!C(z))return;z.preventDefault();const J=N(z.clientX,z.clientY);v(J??k.value);try{z.currentTarget.releasePointerCapture(z.pointerId)}catch{}}function I(z){if(C(z)){k.value=null,b.value=null;try{z.currentTarget.releasePointerCapture(z.pointerId)}catch{}}}const E=z=>{k.value=z},V=z=>{b.value=z},v=z=>{if(k.value===null||k.value===z){k.value=null,b.value=null;return}const J=[...i.value],[ie]=J.splice(k.value,1);J.splice(z,0,ie),i.value=J,k.value=null,b.value=null},T=()=>{_.value&&_.value.click()},j=z=>{const J=[".jpg",".jpeg",".png",".gif",".bmp",".webp",".svg",".ico",".tiff",".tif"],ie=z.toLowerCase();return J.some(F=>ie.endsWith(F))},te=z=>{const ie=z.target.files?.[0];if(!ie)return;const F=new FileReader;F.onload=w=>{try{const S=w.target?.result;if(typeof S=="string"){const P=JSON.parse(S);Array.isArray(P)&&i.value.push(...P)}}catch(S){console.error("Error parsing file:",S)}},F.readAsText(ie)},D=()=>{const z=JSON.stringify(i.value,null,2),J=new Blob([z],{type:"application/json"}),ie=URL.createObjectURL(J),F=document.createElement("a");F.href=ie,F.download="data.json",F.click(),URL.revokeObjectURL(ie)},U=new Set(["autocomplete","select","radio","checkbox","combobox"]),oe=new Map,R=(z,J)=>{const ie=`/api/suggest/${z}`,F=ie.includes("?")?"&":"?",w=J?`&val=${J}`:"";return`${ie}${F}${w}`},H=z=>z==null||z===""?null:typeof z=="object"?z?.id!==void 0&&z.id!==null&&z.id!==""?z.id:null:z,Z=z=>{const J=new Set;return Array.isArray(i.value)&&i.value.forEach(ie=>{const F=ie?.[z];if(F==null||F==="")return;if(Array.isArray(F)){F.forEach(S=>{const P=H(S);P!==null&&J.add(P)});return}const w=H(F);w!==null&&J.add(w)}),J},ae=async()=>{if(!t.colModel?.length)return;const z=t.colModel.filter(J=>J.data&&U.has(J.type?.toLowerCase()||""));z.length&&await Promise.all(z.map(async J=>{const ie=J.key||J.name;if(!ie)return;const F=Z(ie),w=Array.from(F).map(le=>String(le)).sort(),S=w.join(",");if(!w.length||oe.get(ie)===S)return;oe.set(ie,S);const P=w.map(encodeURIComponent).join(",");try{const we=await(await fetch(R(J.data,P))).json();d.value[ie]=we?.data??we}catch(le){console.error("Failed to fetch column values",le)}}))};e.watch([()=>t.colModel,()=>i.value],()=>{ae()},{immediate:!0,deep:!0});const O=e.ref(""),A=e.ref(!1);let M="edit",Q=0;const se=z=>(z?.format||z?.type||"").toString().toLowerCase(),ee=e.computed(()=>(t.colModel?.filter(J=>se(J)!=="slot")??[]).map(J=>{const ie=J.key||J.name;return ie?{...J,name:ie,key:ie}:J})),me=e.ref({}),ke=e.ref({}),ge=z=>typeof z!="string"?!1:!!n[z],Se=(z,J)=>J?J.split(".").reduce((ie,F)=>ie==null?ie:ie[F.trim()],z):z,Ne=(z,J)=>typeof z!="string"?"":z.replace(/{{\s*([^}]+)\s*}}/g,(ie,F)=>{const w=Se(J,F.trim());return w??""}),$e=z=>{if(z==null||z==="")return"";if(typeof z=="number")return z;if(typeof z=="boolean")return z?1:0;if(typeof z=="string")return z.toLowerCase();if(Array.isArray(z))return z.map(J=>$e(J)).join(", ");if(typeof z=="object"){if(z.text!==void 0)return String(z.text).toLowerCase();if(z.label!==void 0)return String(z.label).toLowerCase();if(z.id!==void 0)return String(z.id).toLowerCase()}return String(z).toLowerCase()},Oe=z=>{const J=z.key||z.name;if(J){if(g.value===J){p.value=p.value==="asc"?"desc":"asc";return}g.value=J,p.value="asc"}};async function Me(){O.value="Додати",A.value=!0,M="add",me.value=ze({})}function ne(z,J){if(!z?.length)return null;const ie=typeof J=="object"?J?.id:J;if(ie==null||ie==="")return null;const F=z.find(w=>w?.id?.toString()===ie.toString());return F?F.text??F.label??null:null}function de(z){return z==null||z===""?"-":Array.isArray(z)?z.map(J=>typeof J=="object"?J?.text??J?.label??J?.id??"-":J).join(", "):typeof z=="object"?z?.text??z?.label??z?.id??"-":z}function xe(z){const J=z.key||z.name,ie=J?d.value[J]:null;return Array.isArray(ie)&&ie.length?ie:Array.isArray(z?.options)&&z.options.length?z.options:null}function ve(z,J){const ie=J.key||J.name,F=z?.[ie],w=xe(J);if(F==null||F==="")return"-";if(Array.isArray(F)){const P=F.map(le=>ne(w,le)).filter(Boolean);return P.length?P.join(", "):de(F)}const S=ne(w,F);return S||de(F)}function ze(z){const J=r?.value?.content_id??a?.value?.id??a?.value?.content_id??r?.value?.id??null;return{...z,content_id:J}}function Te(z){if(!z||typeof z!="object")return z;const{content_id:J,...ie}=z;return ie}async function Je(z,J){O.value="Редагувати",A.value=!0,M="edit",Q=J,me.value=ze({...z})}function Ae(){const z=ke.value.validate();if(z){he.notify({type:"warning",title:"Помилка валідації",message:Object.entries(z).map(([ie,F])=>`${ie}: ${F}`).join(`
2
- `)});return}const J=Te(me.value);M==="add"?Array.isArray(i.value)?i.value=[...i.value,J]:i.value=[J]:i.value=i.value.map((ie,F)=>F===Q?J:ie),A.value=!1}function Fe(z){i.value=i.value.filter((J,ie)=>ie!==z)}function ut(){A.value=!1}return(z,J)=>(e.openBlock(),e.createElementBlock("div",Ud,[c.value?(e.openBlock(),e.createElementBlock("div",Hd,[l("search")?(e.openBlock(),e.createElementBlock("div",qd,[e.createVNode(e.unref(X.Search),{class:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.withDirectives(e.createElementVNode("input",{type:"text","onUpdate:modelValue":J[0]||(J[0]=ie=>h.value=ie),placeholder:"Пошук",class:"w-full rounded-md border border-gray-200 bg-white pl-10 pr-3 py-2 text-sm text-gray-900 placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100"},null,512),[[e.vModelText,h.value]])])):e.createCommentVNode("",!0),e.createElementVNode("div",Wd,[l("import")?(e.openBlock(),e.createElementBlock("input",{key:0,ref_key:"fileInput",ref:_,onChange:te,class:"hidden",accept:".json",type:"file"},null,544)):e.createCommentVNode("",!0),l("import")?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",onClick:T,class:"inline-flex items-center gap-2 rounded-md border border-gray-200 bg-white px-3 py-2 text-sm font-medium text-gray-700 hover:border-gray-300 hover:bg-gray-50 transition-colors"},[e.createVNode(e.unref(X.Upload),{class:"h-4 w-4 text-gray-700"}),J[4]||(J[4]=e.createTextVNode(" Імпорт ",-1))])):e.createCommentVNode("",!0),l("export")?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",onClick:D,class:"inline-flex items-center gap-2 rounded-md border border-gray-200 bg-white px-3 py-2 text-sm font-medium text-gray-700 hover:border-gray-300 hover:bg-gray-50 transition-colors"},[e.createVNode(e.unref(X.Download),{class:"h-4 w-4 text-gray-700"}),J[5]||(J[5]=e.createTextVNode(" Експорт ",-1))])):e.createCommentVNode("",!0),l("add")?(e.openBlock(),e.createElementBlock("button",{key:3,onClick:Me,type:"button",class:"inline-flex items-center gap-2 rounded-md bg-blue-500 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-blue-600 transition-colors"},[e.createVNode(e.unref(X.Plus),{class:"h-4 w-4 text-white"}),J[6]||(J[6]=e.createTextVNode(" Додати ",-1))])):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0),e.createElementVNode("div",Kd,[e.createElementVNode("table",Gd,[e.createElementVNode("thead",Yd,[e.createElementVNode("tr",Xd,[e.createElementVNode("th",Zd,[e.createVNode(e.unref(X.GripVertical),{class:"mx-auto h-4 w-4 text-gray-400"})]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,ie=>(e.openBlock(),e.createElementBlock("th",{key:ie.key,class:"px-4 py-3 text-left text-xs font-semibold text-gray-900"},[e.createElementVNode("button",{type:"button",onClick:F=>Oe(ie),class:"flex items-center gap-1 text-xs font-semibold text-gray-700 hover:text-gray-900 transition-colors"},[e.createElementVNode("span",null,e.toDisplayString(ie.ua||ie.label),1),g.value===(ie.key||ie.name)?(e.openBlock(),e.createElementBlock("span",Qd,e.toDisplayString(p.value==="asc"?"▲":"▼"),1)):e.createCommentVNode("",!0)],8,Jd)]))),128)),J[7]||(J[7]=e.createElementVNode("th",{class:"px-4 py-3 text-left text-xs font-semibold text-gray-900 text-center w-[1%] whitespace-nowrap"}," Дії ",-1))])]),e.createElementVNode("tbody",{class:e.normalizeClass(["divide-y divide-gray-200",{"[&_tr:last-child]:border-0":!b.value}])},[f.value.length===0?(e.openBlock(),e.createElementBlock("td",eu,[e.createElementVNode("div",tu,[e.createElementVNode("div",nu,[e.createVNode(jd,{class:"w-48 mx-auto"}),J[8]||(J[8]=e.createElementVNode("div",{class:"max-w-sm mx-auto mt-6"},[e.createElementVNode("p",{class:"font-medium text-gray-800 dark:text-neutral-200"},"Нічого не знайдено"),e.createElementVNode("p",{class:"mt-2 text-sm text-gray-500 dark:text-neutral-500"})],-1))])])])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,(ie,F)=>(e.openBlock(),e.createElementBlock("tr",{key:ie.id,"data-row-index":F,class:e.normalizeClass(["border-b transition-colors hover:bg-gray-50 cursor-move text-sm text-gray-700",{"opacity-50":k.value===F,"border-t-2 border-b-2 border-blue-500 bg-blue-50 dark:bg-blue-900/20":b.value===F}]),draggable:"true",onDragstart:w=>E(F),onDragover:e.withModifiers(w=>V(F),["prevent"]),onDrop:w=>v(F)},[e.createElementVNode("td",{class:"px-4 py-3 text-center align-middle touch-none select-none",onPointerdown:w=>$(w,F),onPointermove:q,onPointerup:G,onPointercancel:I},[e.createElementVNode("div",lu,[e.createVNode(e.unref(X.GripVertical),{class:"mx-auto h-4 w-4 text-slate-400 dark:text-slate-500"})])],40,ru),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,w=>(e.openBlock(),e.createElementBlock("td",{key:w.key,class:"px-4 py-3 align-middle"},[se(w)==="slot"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[ge(w.slot)?e.renderSlot(z.$slots,w.slot,{key:0,row:ie,value:ie[w.key],column:w},void 0,!0):(e.openBlock(),e.createElementBlock("div",{key:1,class:"text-sm text-gray-900",innerHTML:Ne(w.slot,ie)},null,8,au))],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[se(w)==="file"?(e.openBlock(),e.createElementBlock("div",su,[j(ve(ie,w))?(e.openBlock(),e.createElementBlock("div",iu,[e.createElementVNode("img",{src:`/file/resize?filepath=${ve(ie,w)}&format=webp`,alt:"alt",width:"45",class:"rounded-md max-w-[45px] h-[45px] object-cover"},null,8,cu)])):(e.openBlock(),e.createElementBlock("div",du,[e.createVNode(e.unref(X.FileText),{class:"h-4 w-4 min-w-4"})]))])):se(w)==="color"?(e.openBlock(),e.createElementBlock("div",uu,[e.createElementVNode("span",{class:"inline-flex h-6 w-6 rounded border border-gray-200",style:e.normalizeStyle({backgroundColor:ve(ie,w)||"#ffffff"})},null,4)])):se(w)==="tiptap-editor"?(e.openBlock(),e.createElementBlock("div",{key:2,class:"text-sm font-medium text-gray-900 datatable-tiptap-editor line-clamp-4",innerHTML:ve(ie,w)},null,8,pu)):(e.openBlock(),e.createElementBlock("div",mu,e.toDisplayString(ve(ie,w)),1))],64))]))),128)),e.createElementVNode("td",fu,[e.createElementVNode("div",hu,[e.createElementVNode("button",{onClick:w=>Je(ie,F),class:"p-1.5 text-gray-600 hover:text-blue-600 hover:bg-blue-50 rounded transition-colors"},[e.createVNode(e.unref(X.Pencil),{class:"h-4 w-4"})],8,gu),e.createElementVNode("button",{onClick:w=>Fe(F),class:"p-1.5 text-gray-600 hover:text-red-600 hover:bg-red-50 rounded transition-colors"},[e.createVNode(e.unref(X.Trash2),{class:"h-4 w-4"})],8,yu)])])],42,ou))),128))],2)])]),e.createVNode(e.unref(he.VsModal),{visible:A.value,title:O.value,size:"lg",onClose:ut,teleport:"#modal"},{default:e.withCtx(()=>[e.createVNode(ot,{schema:ee.value,"allow-id-field":"",values:me.value,"onUpdate:values":J[1]||(J[1]=ie=>me.value=ie),form:ke.value,"onUpdate:form":J[2]||(J[2]=ie=>ke.value=ie)},null,8,["schema","values","form"]),e.createElementVNode("div",bu,[e.createElementVNode("button",{type:"button",onClick:J[3]||(J[3]=ie=>A.value=!1),class:"vs-button inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border !border-gray-200 hover:text-white bg-white text-red-500 hover:border-red-500 hover:bg-red-500 focus:ring-red-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1 mr-2"}," Скасувати "),e.createElementVNode("button",{onClick:Ae,type:"button",class:"vs-button inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border-1 border-transparent text-white bg-blue-500 hover:bg-blue-600 focus:ring-blue-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1"}," Зберегти ")])]),_:1},8,["visible","title"])]))}}),[["__scopeId","data-v-ef50558b"]]),ku={},wu={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none","stroke-width":"2",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-line"};function xu(o,t){return e.openBlock(),e.createElementBlock("svg",wu,t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.createElementVNode("path",{d:"M6 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},null,-1),e.createElementVNode("path",{d:"M18 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},null,-1),e.createElementVNode("path",{d:"M7.5 16.5l9 -9"},null,-1)]))}const vu=Ce(ku,[["render",xu]]),_u={},Cu={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-polygon"};function Eu(o,t){return e.openBlock(),e.createElementBlock("svg",Cu,t[0]||(t[0]=[e.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"></path><path d="M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"></path><path d="M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"></path><path d="M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"></path><path d="M6.5 9.5l3.5 -3"></path><path d="M14 5.5l3 1.5"></path><path d="M18.5 10l-2.5 7"></path><path d="M13.5 17.5l-7 -5"></path>',9)]))}const Bu=Ce(_u,[["render",Eu]]),Vu={},Su={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-topology-ring-3"};function $u(o,t){return e.openBlock(),e.createElementBlock("svg",Su,t[0]||(t[0]=[e.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M8 18a2 2 0 1 0 -4 0a2 2 0 0 0 4 0z"></path><path d="M20 18a2 2 0 1 0 -4 0a2 2 0 0 0 4 0z"></path><path d="M20 6a2 2 0 1 0 -4 0a2 2 0 0 0 4 0z"></path><path d="M8 6a2 2 0 1 0 -4 0a2 2 0 0 0 4 0z"></path><path d="M6 8v8"></path><path d="M18 16v-8"></path><path d="M8 6h8"></path><path d="M16 18h-8"></path>',9)]))}const Au=Ce(Vu,[["render",$u]]);function Nu(o,t,n){const r=Math.max(0,Math.min(22,Math.floor(n))),a=2**r,l=Math.floor((o+180)/360*a),s=t*Math.PI/180,c=Math.floor((1-Math.log(Math.tan(s)+1/Math.cos(s))/Math.PI)/2*a);return{z:r,x:l,y:c}}function Mu(o,t){if(typeof o!="string"||!o.trim()||!/\{z\}/i.test(o))return;const n={"{z}":t.z,"{x}":t.x,"{y}":t.y,"{-y}":2**t.z-t.y-1,"{s}":"a"};let r=o;return Object.entries(n).forEach(([a,l])=>{r=r.replace(new RegExp(a.replace(/[{}-]/g,"\\$&"),"gi"),String(l))}),r}const Fr=/\/(\d+)\/(\d+)\/(\d+)(\.(?:png|jpe?g|webp))(?:\?.*)?$/i;function Dr(o,t){if(typeof o!="string"||!o.trim()||!Fr.test(o))return;const n=o.replace(Fr,`/${t.z}/${t.x}/${t.y}$4`);return n!==o?n:void 0}function Fu(o,t){if(o?.url){const n=Mu(o.url,t);if(n)return n;const r=Dr(o.url,t);if(r)return r}if(o?.preview){const n=Dr(o.preview,t);return n||o.preview}}const Du=["title","aria-expanded"],Tu=["src"],Lu={class:"map-layers__header"},Iu={class:"map-layers__body"},Ou={key:0,class:"map-layers__section"},Pu={class:"map-layers__grid map-layers__grid--4"},Ru=["disabled","title","onClick"],zu={class:"map-layers__thumb"},ju=["src"],Uu={class:"map-layers__option-label"},Hu={key:1,class:"map-layers__section"},qu={class:"map-layers__grid map-layers__grid--4"},Wu=["title","onClick"],Ku={class:"map-layers__thumb"},Gu=["src"],Yu={class:"map-layers__option-label"},Xu={key:2,class:"map-layers__section map-layers__section--vector"},Zu={class:"map-layers__vector-list"},Ju=["checked","disabled","onChange"],Pn=.8,Qu=Ce(e.defineComponent({__name:"map-layers",props:{basemaps:{},activeBaseKey:{},tileOverlays:{},activeTileOverlayKeys:{},vectorOverlays:{},previewTile:{},disabled:{type:Boolean},compact:{type:Boolean}},emits:["onLayerChange","onOverlayToggle","onVectorOverlayToggle"],setup(o,{emit:t}){const n=o,r=t,a=10*Pn,l=400*Pn,s=400*Pn,c=320*Pn,i=e.ref(null),d=e.ref(null),h=e.ref(null),g=e.ref(!1),p=e.ref({}),f=e.computed(()=>Object.keys(n.basemaps||{}).length>0),m=e.computed(()=>Object.keys(n.tileOverlays||{}).length>0),k=e.computed(()=>n.vectorOverlays??[]),b=e.computed(()=>k.value.length>0),_=e.computed(()=>f.value||m.value||b.value),C=e.computed(()=>n.basemaps?.[n.activeBaseKey]?.name||n.activeBaseKey||"Шари"),N=e.computed(()=>q(n.basemaps)),$=e.computed(()=>q(n.tileOverlays||{}));function q(H){const Z=n.previewTile;return Z?Object.fromEntries(Object.entries(H).map(([ae,O])=>[String(ae),Fu(O,Z)??O.preview??""])):{}}function G(H){return N.value[H]||n.basemaps?.[H]?.preview||""}function I(H){return $.value[H]||n.tileOverlays?.[H]?.preview||""}const E=e.computed(()=>G(n.activeBaseKey));function V(H){return Array.isArray(n.activeTileOverlayKeys)&&n.activeTileOverlayKeys.includes(H)}function v(){const H=d.value;if(!H)return;const Z=H.getBoundingClientRect(),ae=Math.min(l,window.innerWidth-16);let O=Z.left;O+ae>window.innerWidth-8&&(O=window.innerWidth-ae-8),O=Math.max(8,O);const A=Z.top-a-8,M=n.compact?c:s,Q=Math.min(M,Math.max(96,A));p.value={position:"fixed",left:`${O}px`,bottom:`${window.innerHeight-Z.top+a}px`,width:`${ae}px`,maxHeight:`${Q}px`,zIndex:"10050"}}async function T(){g.value=!g.value,g.value&&(await e.nextTick(),v())}function j(){g.value=!1}function te(H){H!==n.activeBaseKey&&r("onLayerChange",H)}function D(H){n.disabled||r("onOverlayToggle",H)}function U(H){n.disabled||r("onVectorOverlayToggle",H)}function oe(H){if(!g.value)return;const Z=H.target;i.value?.contains(Z)||h.value?.contains(Z)||j()}function R(H){H.key==="Escape"&&j()}return e.watch(g,async H=>{H&&(await e.nextTick(),v())}),e.onMounted(()=>{document.addEventListener("click",oe),document.addEventListener("keydown",R),window.addEventListener("resize",v),window.addEventListener("scroll",v,!0)}),e.onBeforeUnmount(()=>{document.removeEventListener("click",oe),document.removeEventListener("keydown",R),window.removeEventListener("resize",v),window.removeEventListener("scroll",v,!0)}),(H,Z)=>_.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"rootRef",ref:i,class:e.normalizeClass(["map-layers relative",{"map-layers--compact":H.compact}])},[e.createElementVNode("button",{ref_key:"triggerRef",ref:d,type:"button",class:"map-layers__trigger",title:C.value,"aria-haspopup":"dialog","aria-expanded":g.value,onClick:e.withModifiers(T,["stop"])},[E.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:E.value,alt:"",class:"map-layers__trigger-img"},null,8,Tu)):e.createCommentVNode("",!0)],8,Du),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"map-layers-panel"},{default:e.withCtx(()=>[g.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"panelRef",ref:h,class:"map-layers__panel",style:e.normalizeStyle(p.value),role:"dialog","aria-label":"Шари карти"},[e.createElementVNode("header",Lu,[Z[0]||(Z[0]=e.createElementVNode("h3",{class:"map-layers__title"},"Шари карти",-1)),e.createElementVNode("button",{type:"button",class:"map-layers__close","aria-label":"Закрити",onClick:j},[e.createVNode(e.unref(X.X),{class:"map-layers__close-icon"})])]),e.createElementVNode("div",Iu,[m.value?(e.openBlock(),e.createElementBlock("section",Ou,[Z[1]||(Z[1]=e.createElementVNode("h4",{class:"map-layers__section-title"},"Додаткові шари",-1)),e.createElementVNode("div",Pu,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(H.tileOverlays,(ae,O)=>(e.openBlock(),e.createElementBlock("button",{key:`tile-${O}`,type:"button",class:e.normalizeClass(["map-layers__option",{"map-layers__option--active":V(String(O))}]),disabled:H.disabled,title:ae.name||String(O),onClick:A=>D(String(O))},[e.createElementVNode("span",zu,[e.createElementVNode("img",{src:I(String(O)),alt:""},null,8,ju)]),e.createElementVNode("span",Uu,e.toDisplayString(ae.name||O),1)],10,Ru))),128))])])):e.createCommentVNode("",!0),f.value?(e.openBlock(),e.createElementBlock("section",Hu,[Z[2]||(Z[2]=e.createElementVNode("h4",{class:"map-layers__section-title"},"Базові шари",-1)),e.createElementVNode("div",qu,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(H.basemaps,(ae,O)=>(e.openBlock(),e.createElementBlock("button",{key:`base-${O}`,type:"button",class:e.normalizeClass(["map-layers__option",{"map-layers__option--active":H.activeBaseKey===String(O)}]),title:ae.name||String(O),onClick:A=>te(String(O))},[e.createElementVNode("span",Ku,[e.createElementVNode("img",{src:G(String(O)),alt:""},null,8,Gu)]),e.createElementVNode("span",Yu,e.toDisplayString(ae.name||O),1)],10,Wu))),128))])])):e.createCommentVNode("",!0),b.value?(e.openBlock(),e.createElementBlock("section",Xu,[Z[3]||(Z[3]=e.createElementVNode("h4",{class:"map-layers__section-title"},"Дані",-1)),e.createElementVNode("div",Zu,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k.value,ae=>(e.openBlock(),e.createElementBlock("label",{key:ae.id,class:"map-layers__vector-item"},[e.createElementVNode("input",{type:"checkbox",class:"map-layers__checkbox",checked:ae.visible,disabled:H.disabled,onChange:O=>U(ae.id)},null,40,Ju),e.createElementVNode("span",null,e.toDisplayString(ae.label),1)]))),128))])])):e.createCommentVNode("",!0)])],4)):e.createCommentVNode("",!0)]),_:1})]))],2)):e.createCommentVNode("",!0)}}),[["__scopeId","data-v-c1206d48"]]),Ht=1e-10,Rn=/([+-]?\d{1,3})\s*[°º˚]\s*(\d{1,2})\s*['’′`]\s*(\d{1,2}(?:\.\d+)?)\s*["”″]\s*([NSEW])/gi,ep=/^[+-]?\d+(?:\.\d+)?$/;function tp(o,t,n){const r=o.split(/\r?\n/).map(d=>d.trim()).filter(Boolean);if(r.length<3)return{ok:!1,errors:[{line:0,message:"Має бути щонайменше 3 рядки координат."}]};if(r.length>100)return{ok:!1,errors:[{line:0,message:"Допускається не більше 100 рядків координат."}]};const a=[],l=[];if(r.forEach((d,h)=>{const g=h+1,p=t==="decimal"?np(d,g,n):Lr(d,g,n);if(!p.ok){a.push(...p.errors);return}const f=l[l.length-1];if(f&&Or(f,p.point)){a.push({line:g,message:"Послідовні точки не повинні дублюватися."});return}l.push(p.point)}),a.length)return{ok:!1,errors:a};if(new Set(l.map(rp)).size<3)return{ok:!1,errors:[{line:0,message:"Полігон повинен містити мінімум 3 унікальні точки."}]};const c=[...l];let i=!1;return Or(c[0],c[c.length-1])||(c.push(c[0]),i=!0),lp(c)?{ok:!1,errors:[{line:0,message:"Полігон має самоперетин."}]}:{ok:!0,ring:c,wasClosedAutomatically:i}}function np(o,t,n){return Tr(o,"decimal",n,t)}function Tr(o,t,n,r=1){return t==="decimal"?op(o,r,n):Lr(o,r,n)}function op(o,t,n){const r=[];if(/[A-Za-zА-Яа-яІіЇїЄєҐґ]/.test(o))return{ok:!1,errors:[{line:t,message:"У десятковому форматі не допускаються літери."}]};const a=o.split(/[\s,;]+/).filter(Boolean);if(a.length<2)return{ok:!1,errors:[{line:t,message:"Кожен рядок має містити дві координати."}]};if(a.length>2)return{ok:!1,errors:[{line:t,message:"У рядку дозволено лише одну пару координат."}]};if(!a.every(d=>ep.test(d)))return{ok:!1,errors:[{line:t,message:"Не вдалося розпізнати десяткові координати."}]};const l=Number(a[0]),s=Number(a[1]);if(!Number.isFinite(l)||!Number.isFinite(s))return{ok:!1,errors:[{line:t,message:"Не вдалося розпізнати десяткові координати."}]};const c=n==="lat-lon"?l:s,i=n==="lat-lon"?s:l;return(c<-90||c>90)&&r.push({line:t,message:"Широта поза діапазоном (-90..90)."}),(i<-180||i>180)&&r.push({line:t,message:"Довгота поза діапазоном (-180..180)."}),r.length?{ok:!1,errors:r}:{ok:!0,point:[i,c]}}function Lr(o,t,n){Rn.lastIndex=0;const r=[...o.matchAll(Rn)];if(r.length<2)return{ok:!1,errors:[{line:t,message:"Не вдалося розпізнати DMS-координати."}]};if(r.length>2)return{ok:!1,errors:[{line:t,message:"У рядку дозволено лише одну пару координат."}]};if(Rn.lastIndex=0,o.replace(Rn," ").replace(/[\s,;]+/g,"").trim().length)return{ok:!1,errors:[{line:t,message:"У рядку виявлено зайві символи або значення."}]};const l=Ir(r[0],t,n==="lat-lon"?"lat":"lon"),s=Ir(r[1],t,n==="lat-lon"?"lon":"lat"),c=[];if(l.ok||c.push(l.error),s.ok||c.push(s.error),c.length)return{ok:!1,errors:c};const i=n==="lat-lon"?l.value:s.value;return{ok:!0,point:[n==="lat-lon"?s.value:l.value,i]}}function Ir(o,t,n){const r=Number(o[1]),a=Number(o[2]),l=Number(o[3]),s=String(o[4]).toUpperCase();if(!Number.isFinite(r)||!Number.isFinite(a)||!Number.isFinite(l))return{ok:!1,error:{line:t,message:"Невірні значення DMS-координат."}};if(n==="lat"&&!(s==="N"||s==="S")||n==="lon"&&!(s==="E"||s==="W"))return{ok:!1,error:{line:t,message:n==="lat"?"Для широти напрям повинен бути N або S.":"Для довготи напрям повинен бути E або W."}};if(a<0||a>59)return{ok:!1,error:{line:t,message:"Хвилини повинні бути в діапазоні 0..59."}};if(l<0||l>60)return{ok:!1,error:{line:t,message:"Секунди повинні бути в діапазоні 0..60."}};const d=Math.abs(r),h=n==="lat"?90:180;if(d>h)return{ok:!1,error:{line:t,message:n==="lat"?"Градуси широти повинні бути в діапазоні 0..90.":"Градуси довготи повинні бути в діапазоні 0..180."}};if(d===h&&(a!==0||l!==0))return{ok:!1,error:{line:t,message:n==="lat"?"Для 90° широти хвилини й секунди мають бути 0.":"Для 180° довготи хвилини й секунди мають бути 0."}};const g=d+a/60+l/3600;return{ok:!0,value:s==="S"||s==="W"?-g:g}}function rp(o){return`${o[0].toFixed(12)}:${o[1].toFixed(12)}`}function Or(o,t){return Math.abs(o[0]-t[0])<Ht&&Math.abs(o[1]-t[1])<Ht}function lp(o){if(o.length<4)return!1;for(let t=0;t<o.length-1;t+=1){const n=o[t],r=o[t+1];for(let a=t+1;a<o.length-1;a+=1){if(Math.abs(t-a)<=1||t===0&&a===o.length-2)continue;const l=o[a],s=o[a+1];if(ap(n,r,l,s))return!0}}return!1}function ap(o,t,n,r){const a=zn(o,t,n),l=zn(o,t,r),s=zn(n,r,o),c=zn(n,r,t);return!!(a!==l&&s!==c||a===0&&jn(o,n,t)||l===0&&jn(o,r,t)||s===0&&jn(n,o,r)||c===0&&jn(n,t,r))}function zn(o,t,n){const r=(t[1]-o[1])*(n[0]-t[0])-(t[0]-o[0])*(n[1]-t[1]);return Math.abs(r)<Ht?0:r>0?1:2}function jn(o,t,n){return t[0]<=Math.max(o[0],n[0])+Ht&&t[0]+Ht>=Math.min(o[0],n[0])&&t[1]<=Math.max(o[1],n[1])+Ht&&t[1]+Ht>=Math.min(o[1],n[1])}const sp=["title"],ip={key:0,class:"vs-select__options absolute z-50 mt-1 w-auto min-w-full bg-white border border-gray-300 shadow-lg rounded-lg text-sm text-gray-900"},cp=["onClick"],dp=["placeholder"],up={class:"absolute inset-y-0 right-2 flex items-center gap-1"},pp={class:"flex items-center justify-between gap-2 px-3 py-2 border-b border-gray-100"},mp={class:"text-xs font-semibold uppercase tracking-wide text-gray-500"},fp={class:"max-h-[260px] overflow-auto"},hp={key:0,class:"divide-y divide-gray-100"},gp=["onClick"],yp={key:1,class:"px-3 py-3 text-xs text-gray-500"},Pr="formMapSearchAddressHistory",bp=12,kp="https://geo.rv.ua/api-user/dzk.api",wp="https://nominatim.openstreetmap.org/search",xp=Ce(e.defineComponent({__name:"map-search",props:{config:{}},emits:["goToCoordinates"],setup(o,{emit:t}){const n={mounted(F,w){if(typeof document>"u")return;let S=null;const P=8,le=()=>{const Le=String(w?.value??"");if(!Le)return;S=document.createElement("div"),S.textContent=Le,Object.assign(S.style,{position:"absolute",background:"#333",color:"#fff",padding:"4px 8px",borderRadius:"4px",fontSize:"12px",whiteSpace:"nowrap",pointerEvents:"none",zIndex:"9999"}),document.body.appendChild(S);const De=F.getBoundingClientRect();S.style.left=`${De.right+window.scrollX+P}px`,S.style.top=`${De.top+window.scrollY+(De.height-S.offsetHeight)/2}px`},we=()=>{S?.parentNode&&S.parentNode.removeChild(S),S=null};F.addEventListener("mouseenter",le),F.addEventListener("mouseleave",we),Object.assign(F,{tooltipRightHandlers:{show:le,hide:we}})},unmounted(F){if(typeof document>"u")return;const w=F.tooltipRightHandlers;w&&(F.removeEventListener("mouseenter",w.show),F.removeEventListener("mouseleave",w.hide))}},r=o,a=t,l=e.getCurrentInstance();function s(){return typeof globalThis<"u"&&globalThis.proxy?globalThis.proxy:typeof window<"u"&&window.proxy?window.proxy:null}function c(){const w=l?.appContext.config.globalProperties?.$settings?.map?.searchViewbox;if(w)return Array.isArray(w)?w.join(","):String(w);const P=s()?.map?.searchViewbox;if(P)return Array.isArray(P)?P.join(","):String(P)}function i(){const w=l?.appContext.config.globalProperties?.$settings?.map?.addressSuggest;if(typeof w=="string"&&w.trim())return w.trim();const P=s()?.map?.addressSuggest;if(typeof P=="string"&&P.trim())return P.trim()}function d(){if(typeof r.config?.cadastreSuggest=="string"&&r.config.cadastreSuggest.trim())return r.config.cadastreSuggest.trim();const F=l?.appContext.config.globalProperties?.$settings,w=F?.map?.cadastreSuggest??F?.map?.parcelSuggest??F?.map?.parcelSearch;if(typeof w=="string"&&w.trim())return w.trim();const S=s(),P=S?.map?.cadastreSuggest??S?.map?.parcelSuggest??S?.map?.parcelSearch;if(typeof P=="string"&&P.trim())return P.trim()}const h=!!i(),g=!!c(),p=e.computed(()=>{const F=["nominatim","xy","parcel"];return h&&F.unshift("address"),g?F:F.filter(w=>w!=="nominatim")}),f=e.computed(()=>{const F=p.value,w=r.config?.tools?.filter(S=>F.includes(S));return w&&w.length?w:F}),m=e.computed(()=>r.config?.placeholder?.trim()||"Пошук…"),k=e.ref(f.value[0]);e.watch(f,F=>{F.includes(k.value)||(k.value=F[0])});const b=e.ref(""),_=e.ref(!1),C=e.ref(null),N=e.ref(null),$=e.ref(null),q=e.ref(null),G=e.ref([]),I=e.ref(null),E=e.ref(!1),V=e.ref([]),v=e.computed(()=>(k.value==="address"||k.value==="nominatim")&&E.value),T=e.computed(()=>r.config?.addressDebounceMs??1e3);let j=null;const te=e.ref(!1),D=e.computed(()=>b.value.trim().length>0?G.value:V.value),U=e.computed(()=>b.value.trim().length?`Знайдено ${G.value.length}`:"Історія пошуку"),oe=e.computed(()=>b.value.trim().length?"Нічого не знайдено":"Історія порожня");function R(){if(typeof window>"u")return[];try{const F=window.localStorage?.getItem?.(Pr);if(!F)return[];const w=JSON.parse(F);return Array.isArray(w)?w:[]}catch{return[]}}function H(F){typeof window>"u"||window.localStorage?.setItem?.(Pr,JSON.stringify(F))}function Z(F){const S=[F,...V.value.filter(P=>P.id!==F.id)].slice(0,10);V.value=S,H(S)}const ae=e.reactive({position:"absolute",left:"0px",top:"0px",width:"100%",display:"none"});function O(){if(!q.value)return;const F=q.value.getBoundingClientRect(),w=$.value?.getBoundingClientRect(),S=w?.width??F.width,P=(w?.left??F.left)+window.scrollX,le=F.bottom+window.scrollY+bp;ae.left=`${P}px`,ae.top=`${le}px`,ae.width=`${S}px`,ae.display="block"}const A=()=>{v.value&&O()};function M(){j&&(clearTimeout(j),j=null)}e.watch(k,()=>{b.value="",_.value=!1,G.value=[],E.value=!1,M(),te.value=!1}),e.watch(v,F=>{F?e.nextTick(()=>{O()}):ae.display="none"}),e.watch(b,F=>{if(k.value!=="address"&&k.value!=="nominatim"){G.value=[],M();return}if(!F.trim()){G.value=[],E.value=V.value.length>0,M();return}M(),E.value=!0,j=window.setTimeout(()=>{Ae(F).catch(w=>{const S=w?.message||"Помилка пошуку адреси";he.notify({type:"error",title:"Пошук адреси",message:S})})},T.value)});function Q(F){const w=[];N.value&&w.push(N.value),F instanceof HTMLElement&&w.push(F),C.value?.querySelectorAll("li")?.forEach(P=>{w.push(P)}),w.forEach(P=>{P.dispatchEvent(new MouseEvent("mouseleave",{bubbles:!0}))})}function se(F){_.value&&Q(F.target),_.value=!_.value}function ee(F,w){Q(w?.target),k.value=F}function me(){b.value="",G.value=[],E.value=!1,te.value=!1}function ke(F){const w=F.target;if(_.value){const S=C.value;S&&!S.contains(w)&&(Q(w),_.value=!1)}if(v.value){const S=I.value,P=q.value;S&&!S.contains(w)&&(!P||!P.contains(w))&&(E.value=!1)}}e.onMounted(()=>{V.value=R(),window.addEventListener("click",ke,!0),window.addEventListener("scroll",A,!0),window.addEventListener("resize",A)}),e.onBeforeUnmount(()=>{window.removeEventListener("click",ke,!0),window.removeEventListener("scroll",A,!0),window.removeEventListener("resize",A),M()});function ge(F){return F==="xy"?"Координати":F==="parcel"?"Кадастр":F==="nominatim"?"Адреса":"Адресний"}function Se(F){switch(F){case"xy":return"Пошук за географічними координатами. Введіть широту і довготу через пробіл або кому (lat lng або lng lat).";case"parcel":return"Пошук земельної ділянки за кадастровим номером у форматі 0000000000:00:000:0000.";case"nominatim":return"Пошук адрес та обʼєктів через Nominatim.";case"address":return"Пошук адрес через локальний сервіс addressSuggest.";default:return""}}function Ne(F){const w=Tr(F.trim(),"dms","lat-lon");if(w.ok){const[qe,it]=w.point;return{lat:it,lng:qe}}const S=F.replace(/[,]+/g," ").trim();if(!S)return null;const P=S.split(/\s+/).filter(Boolean);if(P.length<2)return null;const le=P.slice(0,2).map(Number);if(!le.every(qe=>Number.isFinite(qe)))return null;let[we,Le]=le,De=we,je=Le;const He=qe=>Math.abs(qe)<=90,pt=qe=>Math.abs(qe)<=180;if(!He(De)||!pt(je))if(He(je)&&pt(De))De=Le,je=we;else return null;return{lat:De,lng:je}}function $e(F){const w=F?.result||F?.data||F;return(Array.isArray(w)?w:w?[w]:[]).map((P,le)=>{const we=P?.geom_centroid,Le=Array.isArray(we?.coordinates)?we.coordinates:null;if(!Le||Le.length<2)return null;const De=Number(Le[0]),je=Number(Le[1]);return!Number.isFinite(je)||!Number.isFinite(De)?null:{id:String(P?.parcel_id??P?.cad_num??le),title:P?.cadnum||P?.cad_num||"Земельна ділянка",lat:je,lng:De}}).filter(P=>!!P)}function Oe(F){return(Array.isArray(F?.features)?F.features:[]).map((S,P)=>{const le=S?.geometry?.coordinates,we=Number(le?.[0]),Le=Number(le?.[1]);if(!Number.isFinite(Le)||!Number.isFinite(we))return null;const De=S?.properties||{},je=De?.geocoding?.label||De?.display_name||De?.label||"Адреса";return{id:String(De?.geocoding?.place_id||De?.place_id||P),title:je,lat:Le,lng:we}}).filter(S=>!!S)}function Me(F){return Number.isFinite(F.lat)&&Number.isFinite(F.lng)}function ne(F){if(F==null||typeof F=="string"&&!F.trim())return null;const w=Number(F);return Number.isFinite(w)?w:null}function de(F){const w=ne(F.lng)??ne(F.lon)??ne(F.longitude)??ne(F.x),S=ne(F.lat)??ne(F.latitude)??ne(F.y);if(w!=null&&S!=null)return{lat:S,lng:w};const P=F?.geometry?.coordinates??F?.geom_centroid?.coordinates??F?.centroid?.coordinates??F?.geojson?.geometry?.coordinates??F?.geom?.coordinates;if(Array.isArray(P)&&P.length>=2){const le=ne(P[0]),we=ne(P[1]);if(le!=null&&we!=null)return{lat:we,lng:le}}return null}function xe(F){return(Array.isArray(F?.data)?F.data:[]).map((S,P)=>{const le=de(S),we=String(S.text??S.title??S.label??S.name??S.address??S.display_name??S.id??"Адреса"),Le=String(S.id??S.code??S.value??P);return le?{id:Le,title:we,...le}:{id:Le,title:we}}).filter(S=>!!S?.title)}function ve(F){const w=d()||kp;if(w.includes(":id"))return w.replace(":id",encodeURIComponent(F));if(w.includes(":name"))return w.replace(":name",encodeURIComponent(F));try{const S=new URL(w,window.location.origin),P=r.config?.parcelQueryParam?.trim()||"cad_num";return S.searchParams.set(P,F),S.toString()}catch{return w}}function ze(F){const w=i();if(!w)return null;if(w.includes(":name"))return w.replace(":name",encodeURIComponent(F));try{const S=new URL(w,window.location.origin);return F.trim()&&S.searchParams.set("q",F),S.toString()}catch{return w}}async function Te(F){const w=ze(F);if(!w)return[];const S=await fetch(w);if(!S.ok)throw new Error(`HTTP ${S.status}`);const P=await S.json();return xe(P)}async function Je(F){const w=new URL(wp);w.searchParams.set("format","geojson"),w.searchParams.set("q",F),w.searchParams.set("addressdetails","1"),w.searchParams.set("bounded","1");const S=c();S&&w.searchParams.set("viewbox",S);const P=await fetch(w.toString());if(!P.ok)throw new Error(`HTTP ${P.status}`);const le=await P.json();return Oe(le)}async function Ae(F){if(G.value=[],M(),k.value==="address"){if(!i()){he.notify({type:"warning",title:"Пошук адреси",message:"Не налаштовано addressSuggest"});return}const P=await Te(F);if(!P.length){he.notify({type:"warning",title:"Пошук адреси",message:"Не знайдено результатів"});return}G.value=P;return}const w=await Je(F);if(!w.length){he.notify({type:"warning",title:"Пошук адреси",message:"Не знайдено результатів"});return}G.value=w}async function Fe(F){if(Me(F)){J(F),Z(F);return}he.notify({type:"warning",title:"Пошук адреси",message:"Геометрія для обраної адреси відсутня"})}function ut(){k.value!=="address"&&k.value!=="nominatim"||(E.value=!0,e.nextTick(()=>{O()}))}function z(F){const S=F.replace(/\s+/g,"").split(":");if(S.length!==4)return!1;const P=[10,2,3,4];return S.every((le,we)=>le.length===P[we]&&/^\d+$/.test(le))}function J(F){a("goToCoordinates",[F.lat,F.lng]),te.value=!0}async function ie(){const F=b.value.trim();if(F){if(k.value==="xy"){const w=Ne(F);if(!w){he.notify({type:"warning",title:"Пошук координат",message:"Використайте `lat lon` або DMS у форматі `50°27'00\"N 30°31'24\"E`."});return}J(w);return}if(k.value==="address"||k.value==="nominatim"){try{await Ae(F)}catch(w){const S=w?.message||"Помилка пошуку адреси";he.notify({type:"error",title:"Пошук адреси",message:S})}return}try{if(!z(F)){he.notify({type:"warning",title:"Пошук кадастру",message:"Кадастровий номер має формат ХХХХХХХХХХ:ХХ:ХХХ:ХХХХ"});return}const w=await fetch(ve(F));if(!w.ok)throw new Error(`HTTP ${w.status}`);const S=await w.json(),P=$e(S);if(!P.length)he.notify({type:"warning",title:"Пошук",message:"Не знайдено результатів"});else{const le=P.find(Me);if(!le){he.notify({type:"warning",title:"Пошук",message:"Геометрія ділянки відсутня"});return}J(le)}}catch(w){const S=w?.message||"Помилка пошуку";he.notify({type:"error",title:"Пошук",message:S})}}}return(F,w)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"widgetRef",ref:$,class:"map-search-widget flex flex-col gap-2 rounded-xl widget min-w-[200px]"},[e.createElementVNode("form",{class:"flex gap-2 text-gray-900",onSubmit:e.withModifiers(ie,["prevent"])},[f.value.length>1?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:C,class:"relative search-type w-[100px]"},[e.createElementVNode("button",{type:"button",class:"vstSelect-input transition-all text-left bg-white border border-gray-200 text-gray-900 rounded-lg focus:ring-blue-500 focus:border-blue-100 block w-full py-1.5 px-3 text-sm cursor-pointer flex items-center justify-between gap-2",onClick:se},[e.withDirectives((e.openBlock(),e.createElementBlock("span",{ref_key:"selectedToolLabelRef",ref:N,class:"block w-full truncate",title:ge(k.value)},[e.createTextVNode(e.toDisplayString(ge(k.value)),1)],8,sp)),[[n,Se(k.value)]]),(e.openBlock(),e.createElementBlock("svg",{class:e.normalizeClass(["w-4 h-4 text-gray-500 transition-transform",{"rotate-180":_.value}]),viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},w[3]||(w[3]=[e.createElementVNode("path",{d:"M6 9l6 6 6-6",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)]),2))]),_.value?(e.openBlock(),e.createElementBlock("div",ip,[e.createElementVNode("ul",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,S=>e.withDirectives((e.openBlock(),e.createElementBlock("li",{key:S,class:"px-3 py-2 cursor-pointer hover:bg-gray-100 text-gray-900",onClick:P=>ee(S,P)},[e.createTextVNode(e.toDisplayString(ge(S)),1)],8,cp)),[[n,Se(S)]])),128))])])):e.createCommentVNode("",!0)],512)):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"searchWrapperRef",ref:q,class:"relative flex-1 min-w-[140px]"},[k.value==="parcel"?(e.openBlock(),e.createBlock(En,{key:0,modelValue:b.value,"onUpdate:modelValue":w[0]||(w[0]=S=>b.value=S),mask:"0000000000:00:000:0000",class:e.normalizeClass(["vs-input !h-[34px] transition-all border block w-full border-gray-200 rounded-md focus:border-blue-100 border-solid py-1.5 pl-3 text-sm",te.value?"!pr-14":"!pr-8"])},null,8,["modelValue","class"])):e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:1,"onUpdate:modelValue":w[1]||(w[1]=S=>b.value=S),placeholder:m.value,type:"text",class:e.normalizeClass(["vs-input transition-all border block w-full border-gray-200 rounded-md focus:border-blue-100 border-solid py-1.5 pl-3 text-sm",te.value?"!pr-14":"!pr-8"]),onFocus:ut},null,42,dp)),[[e.vModelText,b.value,void 0,{trim:!0}]]),e.createElementVNode("div",up,[te.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"flex items-center text-gray-400 hover:text-gray-600","aria-label":"Очистити",onClick:me},w[4]||(w[4]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})],-1)]))):e.createCommentVNode("",!0),w[5]||(w[5]=e.createElementVNode("button",{type:"submit",class:"flex items-center text-gray-400 hover:text-gray-600","aria-label":"Пошук"},[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m21 21-4.35-4.35m0 0A7.5 7.5 0 1 0 5 5a7.5 7.5 0 0 0 11.65 11.65Z"})])],-1))]),v.value?(e.openBlock(),e.createBlock(e.Teleport,{key:2,to:"body"},[e.createElementVNode("div",{ref_key:"addressResultsRef",ref:I,class:"vs-select__options mt-1 bg-white border border-gray-300 rounded-lg shadow-lg text-sm text-gray-900 z-50",style:e.normalizeStyle(ae)},[e.createElementVNode("div",pp,[e.createElementVNode("span",mp,e.toDisplayString(U.value),1),e.createElementVNode("button",{type:"button",class:"text-gray-400 hover:text-gray-600","aria-label":"Закрити",onClick:w[2]||(w[2]=S=>E.value=!1)}," ✕ ")]),e.createElementVNode("div",fp,[D.value.length?(e.openBlock(),e.createElementBlock("ul",hp,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(D.value,S=>(e.openBlock(),e.createElementBlock("li",{key:S.id,class:"px-3 py-2 cursor-pointer hover:bg-gray-50",onClick:P=>Fe(S)},e.toDisplayString(S.title),9,gp))),128))])):(e.openBlock(),e.createElementBlock("div",yp,e.toDisplayString(oe.value),1))])],4)])):e.createCommentVNode("",!0)],512)],32)],512))}}),[["__scopeId","data-v-4d528cf7"]]),vp={class:"pt-1 border-t border-gray-100"},_p={class:"space-y-1"},Cp=e.defineComponent({__name:"AddCoordinates",emits:["submit","cancel"],setup(o,{emit:t}){const n=t,r=e.ref(null),a=e.ref(null),l=(i,d,h)=>Math.min(Math.max(i,d),h),s=()=>{if(r.value===null||a.value===null||!Number.isFinite(r.value)||!Number.isFinite(a.value))return;const i=l(r.value,-90,90),d=l(a.value,-180,180);n("submit",{lat:i,lng:d}),r.value=null,a.value=null},c=()=>{r.value=null,a.value=null,n("cancel")};return(i,d)=>(e.openBlock(),e.createElementBlock("div",vp,[d[2]||(d[2]=e.createElementVNode("p",{class:"text-xs text-gray-600 mb-1"},"Додати точку за координатами:",-1)),e.createElementVNode("div",_p,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":d[0]||(d[0]=h=>r.value=h),type:"number",step:"0.0001",class:"w-full px-2 py-1 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Широта (50.4501)"},null,512),[[e.vModelText,r.value,void 0,{number:!0}]]),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":d[1]||(d[1]=h=>a.value=h),type:"number",step:"0.0001",class:"w-full px-2 py-1 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Довгота (30.5234)"},null,512),[[e.vModelText,a.value,void 0,{number:!0}]]),e.createElementVNode("div",{class:"flex gap-1.5"},[e.createElementVNode("button",{class:"flex-1 px-2 py-1 bg-blue-500 hover:bg-blue-600 text-white text-xs font-medium rounded transition-colors",type:"button",onClick:s}," Додати "),e.createElementVNode("button",{class:"px-2 py-1 bg-gray-200 hover:bg-gray-300 text-gray-700 text-xs font-medium rounded transition-colors",type:"button",onClick:c}," Скасувати ")])])]))}}),Ep=e.defineComponent({__name:"BtnAdd",emits:["click"],setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("button",{class:"flex-1 px-2 py-1.5 bg-blue-500 hover:bg-blue-600 text-white text-xs font-medium rounded transition-colors duration-150 flex items-center justify-center gap-1",onClick:n[0]||(n[0]=r=>t.$emit("click"))},[e.createVNode(e.unref(X.Plus),{size:12,"stroke-width":2}),n[1]||(n[1]=e.createTextVNode(" Додати ",-1))]))}}),Bp=e.defineComponent({__name:"BtnClear",emits:["click"],setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("button",{class:"w-full px-2 py-1.5 bg-rose-500 hover:bg-rose-600 text-white text-xs font-medium rounded transition-colors duration-150 flex items-center justify-center gap-1",onClick:n[0]||(n[0]=r=>t.$emit("click"))},[e.createVNode(e.unref(X.Trash2),{size:12,"stroke-width":2}),n[1]||(n[1]=e.createTextVNode(" Очистити ",-1))]))}}),Vp=e.defineComponent({__name:"BtnComplete",emits:["click"],setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("button",{class:"flex-1 px-2 py-1.5 bg-emerald-500 hover:bg-emerald-600 text-white text-xs font-medium rounded transition-colors duration-150 flex items-center justify-center gap-1",onClick:n[0]||(n[0]=r=>t.$emit("click"))},[e.createVNode(e.unref(X.Circle),{size:12,"stroke-width":2}),n[1]||(n[1]=e.createTextVNode("Замкнути ",-1))]))}}),Sp=new Intl.NumberFormat("uk-UA",{minimumFractionDigits:2,maximumFractionDigits:2});function qt(o){return Sp.format(o)}function Rr(o){return o>=1e3?`${qt(o/1e3)} км`:`${qt(o)} м`}const $p={class:"flex items-center gap-1.5 text-xs bg-gray-50 rounded p-1.5"},Ap={key:0,class:"flex-1 flex gap-1"},Np={key:1,class:"flex-1 font-mono text-gray-700"},Mp=e.defineComponent({__name:"DotListItem",props:{id:{},index:{},coords:{}},emits:["update","delete"],setup(o,{emit:t}){const n=o,r=t,a=e.computed(()=>`${n.coords.lat.toFixed(4)}°, ${n.coords.lng.toFixed(4)}°`),l=e.ref(!1),s=e.ref(n.coords.lat),c=e.ref(n.coords.lng);e.watch(()=>n.coords,p=>{s.value=p.lat,c.value=p.lng},{deep:!0,immediate:!0});const i=(p,f,m)=>Math.min(Math.max(p,f),m),d=()=>{l.value=!0},h=()=>{if(!Number.isFinite(s.value)||!Number.isFinite(c.value))return;const p=i(s.value,-90,90),f=i(c.value,-180,180);r("update",{id:n.id,coords:{lat:p,lng:f}}),l.value=!1},g=()=>{r("delete",n.id)};return(p,f)=>(e.openBlock(),e.createElementBlock("div",$p,[e.createVNode(e.unref(X.MapPin),{size:12,"stroke-width":2,class:"text-gray-400 flex-shrink-0"}),l.value?(e.openBlock(),e.createElementBlock("div",Ap,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[0]||(f[0]=m=>s.value=m),type:"number",step:"0.0001",min:"-90",max:"90",class:"flex-1 px-1.5 py-0.5 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Широта"},null,512),[[e.vModelText,s.value,void 0,{number:!0}]]),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[1]||(f[1]=m=>c.value=m),type:"number",step:"0.0001",min:"-180",max:"180",class:"flex-1 px-1.5 py-0.5 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Довгота"},null,512),[[e.vModelText,c.value,void 0,{number:!0}]]),e.createElementVNode("button",{class:"px-1.5 py-0.5 bg-emerald-500 text-white rounded hover:bg-emerald-600 text-xs",type:"button",onClick:h}," ✓ ")])):(e.openBlock(),e.createElementBlock("span",Np,e.toDisplayString(a.value),1)),l.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:2,class:"text-blue-500 hover:text-blue-600 px-0.5",type:"button",onClick:d}," ✎ ")),e.createElementVNode("button",{class:"text-rose-500 hover:text-rose-600 px-0.5",type:"button",onClick:g}," ✕ ")]))}}),Fp={class:"ruler-control px-3 py-2.5 space-y-2"},Dp={type:"button",class:"ruler-row w-full flex items-center gap-2 cursor-pointer group text-left"},Tp={class:e.normalizeClass(["flex items-center justify-center w-5 h-5 rounded-full shrink-0 transition-colors pointer-events-none"]),title:"Сумарна довжина всіх відрізків","aria-hidden":"true"},Lp={class:"text-sm font-semibold text-slate-700"},Ip={class:"ruler-row"},Op={type:"button",class:"w-full flex items-center gap-2 cursor-pointer group text-left"},Pp={class:e.normalizeClass(["flex items-center justify-center w-5 h-5 rounded-full shrink-0 transition-colors pointer-events-none"]),title:"Площа замкнутого контуру","aria-hidden":"true"},Rp={class:"inline-flex rounded-md overflow-hidden border border-gray-200 bg-gray-100"},zp=["onClick"],jp={class:"flex items-center gap-2 mt-0.5 pl-7"},Up={key:0,class:"text-base font-semibold text-green-600"},Hp={key:1,class:"text-xs text-gray-400"},qp={class:"ruler-row flex items-center gap-2 cursor-pointer"},Wp={class:e.normalizeClass(["flex items-center justify-center w-5 h-5 rounded-full shrink-0 transition-colors pointer-events-none"]),title:"Список точок","aria-hidden":"true"},Kp={class:"text-xs font-medium text-gray-600 flex-1"},Gp={key:0,class:"pt-1.5 border-t border-gray-100 max-h-32 overflow-y-auto space-y-1"},Yp=e.defineComponent({__name:"ControlPanel",props:{points:{},isShapeClosed:{type:Boolean}},emits:["update-point","delete-point"],setup(o){const t=o,n=e.ref(!1),r=e.ref("km2"),a=[{id:"km2",label:"км²"},{id:"ha",label:"га"},{id:"m2",label:"м²"}],l=()=>{n.value=!n.value},s=(m,k)=>{const b=V=>V*Math.PI/180,_=b(k.lat-m.lat),C=b(k.lng-m.lng),N=b(m.lat),$=b(k.lat),q=Math.sin(_/2),G=Math.sin(C/2);return 6371e3*(2*Math.asin(Math.sqrt(q*q+Math.cos(N)*Math.cos($)*G*G)))},c=e.computed(()=>{if(t.points.length<2)return 0;let m=0;for(let k=1;k<t.points.length;k+=1)m+=s(t.points[k-1].coords,t.points[k].coords);return t.isShapeClosed&&t.points.length>=2&&(m+=s(t.points[t.points.length-1].coords,t.points[0].coords)),m}),i=e.computed(()=>c.value>=1e3?`${qt(c.value/1e3)} км`:`${qt(c.value)} м`);function d(m){if(m.length<3)return 0;const k=m[0].lat,b=m[0].lng,_=(N,$)=>{const q=(N-k)*110574;return{x:($-b)*111320*Math.cos(k*Math.PI/180),y:q}};let C=0;for(let N=0;N<m.length;N++){const $=(N+1)%m.length,q=_(m[N].lat,m[N].lng),G=_(m[$].lat,m[$].lng);C+=q.x*G.y-q.y*G.x}return Math.abs(C)*.5}const h=e.computed(()=>{if(!t.isShapeClosed||t.points.length<3)return 0;const m=t.points.map(k=>k.coords);return d(m)}),g=e.computed(()=>h.value>0),p=e.computed(()=>{const m=h.value;if(m===0)return"—";if(r.value==="km2"){const b=m/1e6;return`${qt(b)} км²`}if(r.value==="ha"){const b=m/1e4;return`${qt(b)} га`}const k=m>=1?Math.round(m):m;return`${qt(k)} м²`}),f=e.computed(()=>{const m=t.points.length;return m===1?"1 точка":m>=2&&m<=4?`${m} точки`:`${m} точок`});return e.watch(()=>t.points.length,()=>{t.points.length===0&&(n.value=!1)}),(m,k)=>(e.openBlock(),e.createElementBlock("div",Fp,[e.createElementVNode("button",Dp,[e.createElementVNode("span",Tp,[e.createVNode(e.unref(X.Info),{size:12,"stroke-width":2.5})]),k[1]||(k[1]=e.createElementVNode("span",{class:"text-xs font-medium text-gray-600 flex-1"},"Загальна відстань",-1)),e.createElementVNode("span",Lp,e.toDisplayString(i.value),1)]),e.createElementVNode("div",Ip,[e.createElementVNode("button",Op,[e.createElementVNode("span",Pp,[e.createVNode(e.unref(X.Info),{size:12,"stroke-width":2.5})]),k[2]||(k[2]=e.createElementVNode("span",{class:"text-xs font-medium text-gray-600 flex-1"},"Площа",-1)),e.createElementVNode("div",Rp,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(a,(b,_)=>e.createElementVNode("button",{key:b.id,type:"button",class:e.normalizeClass(["px-2.5 py-1 text-xs font-medium transition-colors border-r border-gray-200 last:border-r-0",_===0&&"rounded-l-md",_===a.length-1&&"rounded-r-md",r.value===b.id?"bg-white text-green-600 font-semibold shadow-sm":"text-gray-600 hover:bg-gray-50"]),onClick:e.withModifiers(C=>r.value=b.id,["stop"])},e.toDisplayString(b.label),11,zp)),64))])]),e.createElementVNode("div",jp,[g.value?(e.openBlock(),e.createElementBlock("span",Up,e.toDisplayString(p.value),1)):(e.openBlock(),e.createElementBlock("span",Hp,"—"))])]),e.createElementVNode("div",qp,[e.createElementVNode("span",Wp,[e.createVNode(e.unref(X.Info),{size:12,"stroke-width":2.5})]),e.createElementVNode("span",Kp,e.toDisplayString(f.value),1),e.createElementVNode("button",{type:"button",class:"text-xs text-blue-500 hover:text-blue-600 font-medium transition-colors",onClick:e.withModifiers(l,["stop"])}," Координати ")]),n.value?(e.openBlock(),e.createElementBlock("div",Gp,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.points,(b,_)=>(e.openBlock(),e.createBlock(Mp,{key:b.id,id:b.id,index:_+1,coords:b.coords,onUpdate:k[0]||(k[0]=C=>m.$emit("update-point",C)),onDelete:C=>m.$emit("delete-point",b.id)},null,8,["id","index","coords","onDelete"]))),128))])):e.createCommentVNode("",!0)]))}}),Xp={class:"px-3 py-3 bg-blue-50/50 border-b border-blue-100"},Zp={class:"flex items-start gap-2"},Jp=e.defineComponent({__name:"InfoHint",setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("div",Xp,[e.createElementVNode("div",Zp,[e.createVNode(e.unref(X.Info),{size:16,"stroke-width":2,class:"text-blue-600 flex-shrink-0 mt-0.5"}),n[0]||(n[0]=e.createElementVNode("div",{class:"space-y-1"},[e.createElementVNode("p",{class:"text-xs font-medium text-blue-900"}," Натискайте на карту, щоб додати точки вимірювання "),e.createElementVNode("p",{class:"text-[10px] text-blue-700"},' Або скористайтесь кнопкою "Додати" внизу для введення координат вручну ')],-1))])]))}}),Qp={class:"space-y-1.5"},em={class:"space-y-1 max-h-40 overflow-y-auto"},tm={class:"text-gray-700"},nm={class:"font-semibold text-slate-800"},om=e.defineComponent({__name:"ToPointList",props:{points:{},isShapeClosed:{type:Boolean}},setup(o){const t=o;function n(l,s){const c=f=>f*Math.PI/180,i=c(s.lat-l.lat),d=c(s.lng-l.lng),h=c(l.lat),g=c(s.lat);return 6371e3*(2*Math.asin(Math.sqrt(Math.sin(i/2)**2+Math.cos(h)*Math.cos(g)*Math.sin(d/2)**2)))}function r(l){return Rr(l)}const a=e.computed(()=>{const l=[],s=t.points;if(s.length<2)return l;for(let c=0;c<s.length;c++){const i=c===s.length-1&&t.isShapeClosed?0:c+1;if(i>=s.length)break;const d=n(s[c].coords,s[i].coords);l.push({from:c+1,to:i+1,label:r(d)})}return l});return(l,s)=>(e.openBlock(),e.createElementBlock("div",Qp,[s[0]||(s[0]=e.createElementVNode("p",{class:"text-xs font-medium text-gray-600 mb-1.5"},"Відстань між точками:",-1)),e.createElementVNode("div",em,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(c,i)=>(e.openBlock(),e.createElementBlock("div",{key:i,class:"flex items-center justify-between text-xs py-1 px-2 rounded bg-gray-50"},[e.createElementVNode("span",tm,"Точка "+e.toDisplayString(c.from)+" → Точка "+e.toDisplayString(c.to),1),e.createElementVNode("span",nm,e.toDisplayString(c.label),1)]))),128))])]))}}),rm={class:"ruler-panel-wrap absolute bottom-12 right-4 z-[1001] animate-slide-up"},lm={class:"bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden w-72"},am={class:"bg-gradient-to-r from-blue-400 to-blue-500 px-3 py-2 flex items-center justify-between"},sm={class:"flex items-center gap-2"},im={class:"w-6 h-6 bg-white/20 rounded-lg flex items-center justify-center"},cm={class:"flex border-b border-gray-200"},dm={key:1,class:"px-3 py-2.5"},um={key:1,class:"text-xs text-gray-500"},pm={class:"px-2.5 py-1.5 bg-gray-50 border-t border-gray-200 space-y-1.5"},mm={class:"flex gap-1.5"},fm=e.defineComponent({name:"RulerPanel",__name:"RulerPanel",emits:["close","tab-change","points-change","add-request","complete","shape-closed-change"],setup(o,{expose:t,emit:n}){const r=n,a=e.ref([]),l=e.computed(()=>a.value.length>0),s=e.ref(!1),c=e.ref(!1),i=e.ref("general");function d(v){i.value=v,r("tab-change",v)}e.onMounted(()=>{r("tab-change",i.value)});const h=e.computed(()=>a.value.length>=3&&!c.value);let g=1;const p=()=>a.value.map(v=>({id:v.id,coords:{...v.coords}})),f=()=>{a.value.length<3&&c.value&&(c.value=!1,r("shape-closed-change",!1)),r("points-change",p())},m=()=>{const v=g;return g+=1,v},k=v=>{a.value=[...a.value,{id:m(),coords:{lat:v.lat,lng:v.lng}}],f()},b=({id:v,coords:T})=>{const j=a.value.findIndex(D=>D.id===v);if(j===-1)return;const te=[...a.value];te[j]={id:v,coords:{...T}},a.value=te,f()},_=v=>{a.value=a.value.filter(T=>T.id!==v),f()},C=()=>{a.value=[],c.value&&(c.value=!1,r("shape-closed-change",!1)),f()},N=v=>{b(v)},$=v=>{_(v)},q=()=>{s.value=!0,r("add-request")},G=v=>{k(v),s.value=!1},I=()=>{s.value=!1},E=()=>{h.value&&(c.value=!0,r("complete"),r("shape-closed-change",!0))},V=()=>{C(),s.value=!1,r("close")};return t({addPoint:k,clearPoints:C}),(v,T)=>(e.openBlock(),e.createElementBlock("div",rm,[e.createElementVNode("div",lm,[e.createElementVNode("div",am,[e.createElementVNode("div",sm,[e.createElementVNode("div",im,[e.createVNode(e.unref(X.Ruler),{size:14,"stroke-width":2,class:"text-white"})]),T[2]||(T[2]=e.createElementVNode("h3",{class:"text-white font-semibold text-xs"},"Вимірювання",-1))]),e.createElementVNode("button",{class:"w-5 h-5 flex items-center justify-center rounded hover:bg-white/20 transition-colors","aria-label":"Закрити",onClick:V},[e.createVNode(e.unref(X.X),{size:14,"stroke-width":2,class:"text-white"})])]),e.createElementVNode("div",cm,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["flex-1 px-3 py-2 text-xs font-medium transition-colors",i.value==="general"?"text-blue-600 border-b-2 border-blue-500 bg-blue-50/50":"text-gray-500 hover:text-gray-700"]),onClick:T[0]||(T[0]=j=>d("general"))}," Загальна ",2),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["flex-1 px-3 py-2 text-xs font-medium transition-colors",i.value==="topoint"?"text-blue-600 border-b-2 border-blue-500 bg-blue-50/50":"text-gray-500 hover:text-gray-700"]),onClick:T[1]||(T[1]=j=>d("topoint"))}," До точки ",2)]),i.value==="general"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[l.value?(e.openBlock(),e.createBlock(Yp,{key:1,points:a.value,"is-shape-closed":c.value,onUpdatePoint:N,onDeletePoint:$},null,8,["points","is-shape-closed"])):(e.openBlock(),e.createBlock(Jp,{key:0}))],64)):(e.openBlock(),e.createElementBlock("div",dm,[l.value?(e.openBlock(),e.createBlock(om,{key:0,points:a.value,"is-shape-closed":c.value},null,8,["points","is-shape-closed"])):(e.openBlock(),e.createElementBlock("p",um,"Додайте точки на карті, щоб бачити відстані між ними."))])),e.createElementVNode("div",pm,[e.createElementVNode("div",mm,[s.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(Ep,{key:0,onClick:q})),h.value?(e.openBlock(),e.createBlock(Vp,{key:1,onClick:E})):e.createCommentVNode("",!0)]),s.value?(e.openBlock(),e.createBlock(Cp,{key:0,onSubmit:G,onCancel:I})):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createBlock(Bp,{key:1,onClick:C})):e.createCommentVNode("",!0)])])]))}}),nt="ruler-points",Bt="ruler-line",Vt="ruler-polygon",St="ruler-segments",hm=e.defineComponent({__name:"RulerLayer",props:{map:{},points:{},isShapeClosed:{type:Boolean},labelMode:{}},setup(o){function t(m,k){const b=G=>G*Math.PI/180,_=b(k.lat-m.lat),C=b(k.lng-m.lng),N=b(m.lat),$=b(k.lat);return 6371e3*(2*Math.asin(Math.sqrt(Math.sin(_/2)**2+Math.cos(N)*Math.cos($)*Math.sin(C/2)**2)))}function n(m){return Rr(m)}const r=o;function a(){return{type:"FeatureCollection",features:[]}}function l(m,k,b){const _=b??"general",C=[];let N=0;C.push(0);for(let $=1;$<m.length;$++)N+=t(m[$-1].coords,m[$].coords),C.push(N);return k&&m.length>=2&&(N+=t(m[m.length-1].coords,m[0].coords)),{type:"FeatureCollection",features:m.map(($,q)=>{const G=_==="general"?q===0?"0":n(C[q]):q===0?"0":n(t(m[q-1].coords,m[q].coords));return{type:"Feature",geometry:{type:"Point",coordinates:[$.coords.lng,$.coords.lat]},properties:{id:$.id,index:q+1,label:G}}})}}function s(m,k){if(m.length<2)return a();const b=[];for(let _=0;_<m.length;_++){const C=_===m.length-1&&k?0:_+1;if(C>=m.length)break;const N=m[_].coords,$=m[C].coords,q=t(N,$);b.push({type:"Feature",geometry:{type:"LineString",coordinates:[[N.lng,N.lat],[$.lng,$.lat]]},properties:{distance:n(q)}})}return{type:"FeatureCollection",features:b}}function c(m,k){if(m.length<2)return a();const b=m.map(_=>[_.coords.lng,_.coords.lat]);return k&&b.push(b[0]),{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"LineString",coordinates:b},properties:{}}]}}function i(m){if(m.length<3)return a();const k=m.map(b=>[b.coords.lng,b.coords.lat]);return k.push(k[0]),{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Polygon",coordinates:[k]},properties:{}}]}}let d=!1;function h(m){m.getSource(nt)||(m.addSource(nt,{type:"geojson",data:a()}),m.addLayer({id:`${nt}-circle`,type:"circle",source:nt,paint:{"circle-radius":5,"circle-color":"#1e293b","circle-stroke-width":2,"circle-stroke-color":"#ffffff"}}),m.addLayer({id:`${nt}-labels`,type:"symbol",source:nt,layout:{"text-field":["get","label"],"text-size":14,"text-offset":[0,1.3]},paint:{"text-color":"#0f172a","text-halo-color":"#ffffff","text-halo-width":1}})),m.getSource(St)||(m.addSource(St,{type:"geojson",data:a()}),m.addLayer({id:`${St}-labels`,type:"symbol",source:St,layout:{"text-field":["get","distance"],"text-size":13,"symbol-placement":"line-center","text-rotation-alignment":"map","text-pitch-alignment":"map"},paint:{"text-color":"#1e293b","text-halo-color":"#ffffff","text-halo-width":1.5}})),m.getSource(Bt)||(m.addSource(Bt,{type:"geojson",data:a()}),m.addLayer({id:`${Bt}-layer`,type:"line",source:Bt,paint:{"line-color":"#3b82f6","line-width":2}})),m.getSource(Vt)||(m.addSource(Vt,{type:"geojson",data:a()}),m.addLayer({id:`${Vt}-layer`,type:"fill",source:Vt,paint:{"fill-color":"#93c5fd","fill-opacity":.25}})),d=!0}function g(m){if(m){try{m.getLayer(`${Vt}-layer`)&&m.removeLayer(`${Vt}-layer`),m.getSource(Vt)&&m.removeSource(Vt),m.getLayer(`${Bt}-layer`)&&m.removeLayer(`${Bt}-layer`),m.getSource(Bt)&&m.removeSource(Bt),m.getLayer(`${St}-labels`)&&m.removeLayer(`${St}-labels`),m.getSource(St)&&m.removeSource(St),m.getLayer(`${nt}-labels`)&&m.removeLayer(`${nt}-labels`),m.getLayer(`${nt}-circle`)&&m.removeLayer(`${nt}-circle`),m.getSource(nt)&&m.removeSource(nt)}catch{}d=!1}}function p(m){if(!m)return;const k=m.getSource(nt),b=m.getSource(Bt),_=m.getSource(Vt),C=m.getSource(St),N=r.points,$=r.labelMode??"general";k&&k.setData(l(N,r.isShapeClosed,$)),b&&b.setData(c(N,r.isShapeClosed)),_&&_.setData(i(N)),C&&C.setData($==="topoint"?s(N,r.isShapeClosed):a())}function f(){const m=r.map;m&&(d||h(m),p(m))}return e.watch(()=>[r.points,r.isShapeClosed,r.labelMode],()=>f(),{deep:!0,immediate:!0}),e.watch(()=>r.map,()=>f(),{immediate:!0}),e.onBeforeUnmount(()=>{g(r.map)}),(m,k)=>null}});function gm(o={}){const t=e.ref(!1),n=e.ref([]),r=e.ref(!1),a=e.ref("general"),l=e.ref(null);function s(){t.value?c():(t.value=!0,o.onActivate?.())}function c(){t.value=!1,n.value=[],r.value=!1,l.value?.clearPoints(),o.onDeactivate?.()}function i(f){n.value=f}function d(f){a.value=f}function h(f){r.value=f}function g(f){t.value&&l.value?.addPoint({lat:f.lat,lng:f.lng})}const p=e.computed(()=>n.value.length>0);return{isRulerActive:t,rulerPoints:n,rulerShapeClosed:r,rulerActiveTab:a,rulerPanelRef:l,hasRulerPoints:p,toggleRuler:s,closeRuler:c,onRulerPointsChange:i,onRulerTabChange:d,onRulerShapeClosedChange:h,handleRulerMapClick:g}}const So="vs-safe-raster",dn=new ArrayBuffer(0);let $o=!1;function ym(o){const t=`${So}://`;return typeof o!="string"||!o.startsWith(t)?o:o.slice(t.length)}function bm(o){if(!o||o.byteLength<4)return!1;const t=new Uint8Array(o);return t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71||t[0]===255&&t[1]===216&&t[2]===255||t[0]===82&&t[1]===73&&t[2]===70&&t[3]===70&&o.byteLength>=12&&String.fromCharCode(t[8],t[9],t[10],t[11])==="WEBP"}async function km(o,t){try{const n=await fetch(o,{signal:t});if(!n.ok||n.status===204)return dn;const r=await n.arrayBuffer();return!r.byteLength||!bm(r)?dn:r}catch{return dn}}function wm(o){$o||!o?.addProtocol||($o=!0,o.addProtocol(So,(t,n)=>{const r=ym(String(t?.url??""));if(!r)return n(null,{data:dn}),{cancel:()=>{}};const a=new AbortController;return km(r,a.signal).then(l=>n(null,{data:l})).catch(()=>n(null,{data:dn})),{cancel:()=>a.abort()}}))}function xm(o){const t=typeof o=="string"?o.trim():"";if(!t)return t;const n=`${So}://`;return t.startsWith(n)?t:`${n}${t}`}function vm(o,t){const n=typeof o=="string"?o.trim():"";return n?t&&$o?[xm(n)]:[n]:[]}function Ao(o,t,n){const r={type:"raster",tiles:vm(o,!!n?.safe),tileSize:typeof t?.tileSize=="number"?t.tileSize:256};return typeof t?.minzoom=="number"&&(r.minzoom=t.minzoom),typeof t?.maxzoom=="number"&&(r.maxzoom=t.maxzoom),Array.isArray(t?.bounds)&&t.bounds.length===4&&(r.bounds=t.bounds),r}function _m(o){const t=String(o??"").toLowerCase();return t.includes("could not be decoded")||t.includes("source image could not be decoded")||t.includes("unsupported image type")}const Cm={class:"vs-map-body"},Em={key:0,class:"absolute top-2 left-2 z-[1000] w-[calc(100%-16px)] sm:w-[320px]"},Bm={key:1,class:"form-geom__panel flex items-center gap-1 mt-1"},Vm={class:"flex items-center gap-1"},Sm=["disabled"],$m={key:0,class:"absolute z-[1600] left-0 top-full mt-1 w-full min-w-[140px] bg-white border border-gray-200 shadow-lg rounded-lg text-sm overflow-hidden"},Am=["disabled"],Nm={key:0,class:"mb-3 flex items-center gap-2 rounded-md border border-blue-100 bg-blue-50 px-3 py-2 text-sm text-blue-700"},Mm={class:"mt-4 flex justify-end gap-2"},Fm=["disabled"],Dm=["disabled"],Tm={class:"mt-4 flex justify-end gap-2"},Lm=["disabled"],Im={class:"vs-map-controls vs-map-controls--tr"},Om={class:"vs-map-toolbar"},Pm=["disabled"],Rm=["disabled"],zm=["disabled"],jm=["disabled"],Um={key:1,class:"vs-map-toolbar__divider"},Hm=["title"],qm={class:"bg-white/95 border border-gray-200 rounded-md shadow-xl px-3 py-2 max-w-[240px] text-[11px] sm:text-xs text-gray-900"},Wm={class:"space-y-0.5"},Km={class:"text-gray-500"},Gm={class:"text-gray-900 text-right break-all"},Ym={class:"absolute left-2 bottom-2 z-[1000]"},Xm={key:0,class:"vs-map-status"},Zm={class:"form-geom__feature vs-map-status__inner"},Jm={class:"vs-map-status__type"},Qm={class:"vs-map-status__values"},ef=["onClick","disabled"],tf={key:1,class:"vs-map-status__chip"},nf={key:2,class:"vs-map-status__sep"},of={key:1,class:"vs-map-status__chip"},rf={class:"vs-map-status__meta"},lf={class:"vs-map-status__coords"},af={key:0,class:"vs-map-status__value"},sf={key:1,class:"vs-map-status__value"},cf={key:0,class:"vs-map-status__area"},df={class:"vs-map-status__value"},uf={class:"vs-map-status__actions"},pf=["disabled"],mf=["disabled"],ff=11,hf=15,gf=.7,yf="vs-tile-ov-src-",bf="vs-tile-ov-raster-",Un="__vs_form_maplibre_loader__",kf="https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf",Hn="vs-global-bounds-src",Zt="vs-global-bounds-line",zr="rasterLayer",jr=Ce(e.defineComponent({__name:"vs-input-map",props:{tools:{},multi:{type:Boolean,default:!1},multiple:{type:Boolean,default:!1},handleZoom:{type:Boolean,default:!0},ctrlZoom:{type:Boolean,default:!0},geomType:{default:()=>[]},prefix:{default:""},katottg:{default:""},layers:{default:()=>[]},bounds:{},api:{},center:{default:void 0},zoom:{default:void 0},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},emits:["update:modelValue","valueSelected"],setup(o,{emit:t}){const n=o,r=t,a=e.useAttrs(),l=e.inject("values",e.ref({})),s=typeof document<"u"&&document.querySelector("#modal")?"#modal":"body",c=e.computed(()=>{const u=a?.multiple,y=a?.multi,x=B=>B===""||B===!0||B==="true"||B===1||B==="1";return!!n.multi||!!n.multiple||x(y)||x(u)}),i=e.computed(()=>!!n.disabled),d=e.ref(!1),h=e.ref(null),g=e.ref(0),p=e.ref(""),f=e.ref(null),m=e.ref([]),k=e.ref(null),b=e.ref(null),_=gm({onActivate(){if(fe)try{fe.changeMode("simple_select",{featureIds:[]})}catch{}p.value=""},onDeactivate(){}});function C(){_.toggleRuler()}const N=e.getCurrentInstance(),$=N?.appContext?.config?.globalProperties?.$settings??{},q=$?.map??{},G=e.computed(()=>{const u=q.layerPresets;return Array.isArray(u)?u:[]}),I=N?.vnode?.props??{};function E(u){return Object.prototype.hasOwnProperty.call(I,u)||Object.prototype.hasOwnProperty.call(I,u.replace(/[A-Z]/g,y=>`-${y.toLowerCase()}`))}const V=Array.isArray(q.center)&&q.center.length===2?q.center:Array.isArray($.center)&&$.center.length===2?$.center:[30,50],v=typeof q.zoom=="number"?q.zoom:typeof $.zoom=="number"?$.zoom:typeof $.defaultZoom=="number"?$.defaultZoom:10;function T(u){if(u!=null){if(Array.isArray(u)&&u.length>=2){const y=Number(u[0]),x=Number(u[1]);return!Number.isFinite(y)||!Number.isFinite(x)?void 0:[y,x]}if(typeof u=="object"){const y=u,x=y.geom;if(y.type==="Point"&&Array.isArray(y.coordinates)){const Y=y.coordinates,ce=Number(Y[0]),ue=Number(Y[1]);if(Number.isFinite(ce)&&Number.isFinite(ue))return[ce,ue]}if(x?.type==="Point"&&Array.isArray(x.coordinates)){const Y=x.coordinates,ce=Number(Y[0]),ue=Number(Y[1]);if(Number.isFinite(ce)&&Number.isFinite(ue))return[ce,ue]}const B=Number(y.lat),L=Number(y.lng??y.lon);if(Number.isFinite(B)&&Number.isFinite(L))return[L,B]}}}const j=e.computed(()=>{const u=T(n.center);if(u)return u;if(!E("center"))return T(q.center)??T($.center)}),te=e.computed(()=>E("zoom")?n.zoom:q.zoom??n.zoom),D=e.computed(()=>E("katottg")?String(n.katottg??""):String(q.katottg??n.katottg??"")),U=e.computed(()=>E("layers")?n.layers??[]:q.layers??n.layers??[]),oe=e.computed(()=>E("bounds")?n.bounds:q.bounds??n.bounds),R=e.ref(Array.isArray(j.value)&&j.value.length===2?[...j.value]:V),H=e.ref(typeof te.value=="number"?te.value:v),Z=e.ref(null);let ae=null;function O(u){const y=typeof u=="number"&&Number.isFinite(u)?u:H.value;return Math.min(hf,Math.max(ff,Math.round(y)))}function A(u,y,x){if(!Number.isFinite(u)||!Number.isFinite(y))return;const B=Nu(u,y,O(x)),L=Z.value;L&&L.z===B.z&&L.x===B.x&&L.y===B.y||(Z.value=B)}function M(){if(K){const u=K.getCenter?.(),y=K.getZoom?.();if(u&&Number.isFinite(y)){A(u.lng,u.lat,y);return}}Array.isArray(R.value)&&R.value.length===2&&A(R.value[0],R.value[1])}function Q(){ae&&clearTimeout(ae),ae=setTimeout(()=>{ae=null,M()},120)}A(R.value[0],R.value[1]);const se=e.ref(n.modelValue),ee=e.ref(null),me=e.ref([]),ke=e.ref(!1),ge=e.ref(!1),Se=e.ref(!1),Ne=e.ref(!1),$e=e.ref(!1);e.provide("map-file-import-uploading",$e);const Oe=e.computed(()=>$e.value?"Завантаження файлу на сервер...":Ne.value?"Конвертація геометрії...":""),Me=e.ref([]),ne=e.ref({srid:"",encoding:"UTF-8",file:""}),de=e.computed(()=>{const u=l.value??{},y=u.id??a.id??"1",x=a.form??u.form??"form",B=a.table??u.table??"table",L=n.name??a.field??"geom";return`/file/upload/temp?${new URLSearchParams({id:String(y),form:String(x),table:String(B),field:String(L)}).toString()}`}),xe=e.computed(()=>({srid:{type:"Autocomplete",label:"Система координат",info:"Оберіть одну із систем координат в якій знаходяться ваші геодані",data:"gis.srid_from_setting",placeholder:"Обрати",rules:["required"]},encoding:{type:"Select",label:"Кодування файлу",info:"Вкажіть кодування в якому зберігається інформація в ваших файлах. Зазвичай це UTF-8",options:[{id:"UTF-8",text:"UTF-8"},{id:"CP1251",text:"CP1251"},{id:"LATIN-1",text:"LATIN-1"}],default:"UTF-8",rules:["required"]},file:{type:"File",label:"Файл",info:"Завантажте файл із геоданими у форматі GeoJson або Zip (Shapefiles)",format:".geojson,.zip",api:de.value,rules:["required"]}})),ve=e.ref({coordinates:"",format:"decimal",order:"lat-lon"}),ze={coordinates:{type:"Textarea",label:"Координати вершин полігону (3-100 точок)",placeholder:`50.4501, 30.5234
1
+ (function(Se,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("vue"),require("@opengis/core"),require("lucide-vue-next")):typeof define=="function"&&define.amd?define(["exports","vue","@opengis/core","lucide-vue-next"],s):(Se=typeof globalThis<"u"?globalThis:Se||self,s(Se.FormBuilder={},Se.Vue,Se.OpenGISCore,Se.lucide))})(this,(function(Se,s,we,Y){"use strict";function Us(n,e,t){if(!Array.isArray(t)||!t.length)return null;const r=String(n?.preset??n?.renderer??"").trim().toLowerCase();if(r){const o=t.find(i=>String(i.id).trim().toLowerCase()===r);if(o)return o}return t.find(o=>typeof o.match=="function"&&o.match(n,e))??null}function Cu(n,e,t){return!!Us(n,e,t)}const Ws=6,Nn=8,Su=s.defineComponent({__name:"vs-info-tooltip",props:{text:{}},setup(n){const e=n,t=s.ref(!1),r=s.ref(null),o=s.ref(null),i=s.ref({top:"0px",left:"0px",visibility:"hidden"});let l=null;const a=()=>typeof window<"u";function c(m,g){if(!a())return null;const y=window.innerWidth,b=window.innerHeight,{top:w,bottom:v,left:E,right:N}=m,{width:R,height:T}=g,M=b-v-Ws-Nn,_=w-Ws-Nn;let L=M>=T||M>=_?v+Ws:w-Ws-T,z=E;return z+R>y-Nn&&(z=N-R),z<Nn&&(z=Nn),z+R>y-Nn&&(z=y-Nn-R),L=Math.max(Nn,Math.min(L,b-Nn-T)),{top:L,left:z}}function d(){if(!a())return;const m=r.value,g=o.value;if(!m||!g)return;const y=m.getBoundingClientRect(),b=g.getBoundingClientRect(),w=c(y,b);if(!w)return;const{top:v,left:E}=w;i.value={top:`${Math.round(v)}px`,left:`${Math.round(E)}px`,visibility:"visible"}}function u(){a()&&(l!==null&&cancelAnimationFrame(l),l=requestAnimationFrame(()=>{d(),l=null}))}async function f(){!e.text||!a()||(i.value={top:"0px",left:"0px",visibility:"hidden"},t.value=!0,await s.nextTick(),u())}function p(){t.value=!1,i.value={top:"0px",left:"0px",visibility:"hidden"}}function h(){t.value&&u()}return s.onMounted(()=>{window.addEventListener("scroll",h,!0),window.addEventListener("resize",h)}),s.onBeforeUnmount(()=>{l!==null&&(cancelAnimationFrame(l),l=null),window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}),(m,g)=>(s.openBlock(),s.createElementBlock(s.Fragment,null,[s.createElementVNode("span",{ref_key:"triggerRef",ref:r,class:"inline-flex items-center",onMouseenter:f,onMouseleave:p},[s.renderSlot(m.$slots,"default",{},()=>[s.createVNode(s.unref(Y.Info),{class:"h-4 w-4 text-gray-400 cursor-help"})])],544),(s.openBlock(),s.createBlock(s.Teleport,{to:"body"},[t.value&&m.text?(s.openBlock(),s.createElementBlock("div",{key:0,ref_key:"tooltipRef",ref:o,style:s.normalizeStyle(i.value),class:"fixed z-[9999] max-w-xs p-2 bg-gray-900 text-white text-xs rounded-lg shadow-lg pointer-events-none",role:"tooltip"},s.toDisplayString(m.text),5)):s.createCommentVNode("",!0)]))],64))}}),ua={form:{autofillFrom:"Filled from",richtext:{paragraph:"Paragraph",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",heading4:"Heading 4",heading5:"Heading 5",heading6:"Heading 6",createTable:"Create Table",addColumn:"Add Column",addRow:"Add Row",deleteColumn:"Delete Column",deleteRow:"Delete Row",deleteTable:"Delete Table",mergeCells:"Merge Cells",splitCells:"Split Cells",linkTitle:"Enter Link",link:"Link",linkUrl:"Enter URL",editLink:"Edit Link",openLink:"Open Link",removeLink:"Remove Link",openInNewTab:"Open in New Tab",editor:"Editor",html:"HTML",markdown:"Markdown",create:"Create",update:"Update",cancel:"Cancel"}}},fa={form:{autofillFrom:"Підставлено з",richtext:{paragraph:"Звичайний текст",heading1:"Заголовок 1",heading2:"Заголовок 2",heading3:"Заголовок 3",heading4:"Заголовок 4",heading5:"Заголовок 5",heading6:"Заголовок 6",createTable:"Створити таблицю",addColumn:"Додати колонку",addRow:"Додати рядок",deleteColumn:"Видалити колонку",deleteRow:"Видалити рядок",deleteTable:"Видалити таблицю",mergeCells:"Об'єднати комірки",splitCells:"Розділити комірки",linkTitle:"Додати посилання",link:"Посилання",linkUrl:"Введіть URL",editLink:"Редагувати посилання",openLink:"Відкрити посилання",removeLink:"Видалити посилання",openInNewTab:"Відкривати в новій вкладці",editor:"Редактор",html:"HTML",markdown:"Markdown",create:"Створити",update:"Оновити",cancel:"Скасувати"}}},ib={class:"w-full relative"},lb={key:0,class:"text-[14px] font-medium text-gray-900 mb-2 flex items-center gap-1"},ab={class:"opacity-100"},cb={key:0,class:"text-red-500 text-[14px]"},db={key:2,class:"text-[11px] text-slate-500 font-normal"},ub={key:1,class:"text-red-500 text-[10px] absolute bottom-[-14px]"},fb=s.defineComponent({__name:"vs-layout-default",props:{ua:{default:""},uk:{},en:{},de:{},es:{},fr:{},item:{default:()=>({})},error:{type:[String,Boolean],default:""},label:{default:""},columns:{}},setup(n){const e=n,t=s.computed(()=>typeof e.item?.label=="string"&&e.item.label?e.item.label:e.item?.ua||e.label||e.ua),r=s.computed(()=>!!t.value),o=s.computed(()=>!!e.item?.rules?.includes("required")),i=s.computed(()=>e.item?.info||""),l=s.inject("schema-by-name"),a={en:ua?.form?.autofillFrom,uk:fa?.form?.autofillFrom},c=s.computed(()=>{const d=e.item?.__autoMeta;if(!d||d?.source!=="parent-auto"||!d?.parentField)return"";const u=String(e.item?.__locale||"uk"),f=String(d.parentField),p=l?.value?.[f],h=p?.[`label:${u}`]||(u!=="uk"?p?.[u]:void 0)||p?.label||p?.ua||p?.en||f;return`${a[u]||a.uk}: ${h}`});return(d,u)=>(s.openBlock(),s.createElementBlock("div",ib,[r.value?(s.openBlock(),s.createElementBlock("div",lb,[s.createElementVNode("span",ab,s.toDisplayString(t.value),1),o.value?(s.openBlock(),s.createElementBlock("span",cb,"*")):s.createCommentVNode("",!0),i.value?(s.openBlock(),s.createBlock(Su,{key:1,text:i.value},null,8,["text"])):s.createCommentVNode("",!0),c.value?(s.openBlock(),s.createElementBlock("span",db," ("+s.toDisplayString(c.value)+") ",1)):s.createCommentVNode("",!0)])):s.createCommentVNode("",!0),s.renderSlot(d.$slots,"default",s.mergeProps(d.$attrs,{class:{"opacity-60":d.item.disabled}})),d.error?(s.openBlock(),s.createElementBlock("span",ub,s.toDisplayString(d.error),1)):s.createCommentVNode("",!0)]))}}),pb={class:"w-full relative flex flex-row items-center gap-2"},hb={key:0,class:"text-red-500 text-[14px]"},mb={key:2,class:"text-[11px] text-slate-500 font-normal"},gb={key:1,class:"text-red-500 text-[10px] absolute bottom-[-14px]"},yb=s.defineComponent({__name:"vs-layout-horizontal",props:{ua:{default:""},uk:{},en:{},de:{},es:{},fr:{},item:{default:()=>({})},error:{type:[String,Boolean],default:""},label:{default:""},columns:{default:()=>({container:12,label:3})}},setup(n){const e=n,t=s.computed(()=>e.item?.label||e.label||e.ua),r=s.computed(()=>e.item?.info||""),o=s.inject("schema-by-name"),i={en:ua?.form?.autofillFrom,uk:fa?.form?.autofillFrom},l=s.computed(()=>{const p=e.item?.__autoMeta;if(!p||p?.source!=="parent-auto"||!p?.parentField)return"";const h=String(e.item?.__locale||"uk"),m=String(p.parentField),g=o?.value?.[m],y=g?.[`label:${h}`]||(h!=="uk"?g?.[h]:void 0)||g?.label||g?.ua||g?.en||m;return`${i[h]||i.uk}: ${y}`}),a=s.computed(()=>e.columns??{container:12,label:3}),c=s.computed(()=>{const{container:p,label:h}=a.value;return!p||p<=0?0:Math.min(Math.max(h??0,0),p)/p}),d=s.computed(()=>e.item?.type==="html"||c.value<=0?!1:!!t.value),u=s.computed(()=>{if(!d.value)return{};const p=`${c.value*100}%`;return{flexBasis:p,maxWidth:p}}),f=s.computed(()=>{const{container:p,label:h}=a.value;if(!p||p<=0)return{};if(e.item?.type==="html")return{flexBasis:"100%",maxWidth:"100%"};if(!d.value)return{flexBasis:"100%",maxWidth:"100%"};const m=Math.max(p-Math.max(h??0,0),0)/p;if(!m)return{};const g=`${m*100}%`;return{flexBasis:g,maxWidth:g}});return(p,h)=>(s.openBlock(),s.createElementBlock("div",pb,[d.value?(s.openBlock(),s.createElementBlock("span",{key:0,class:"text-sm text-gray-900 font-medium flex shrink-0 items-center gap-1",style:s.normalizeStyle(u.value)},[s.createTextVNode(s.toDisplayString(t.value)+" ",1),p.item?.rules?.includes("required")&&t.value?(s.openBlock(),s.createElementBlock("span",hb,"*")):s.createCommentVNode("",!0),r.value?(s.openBlock(),s.createBlock(Su,{key:1,text:r.value},null,8,["text"])):s.createCommentVNode("",!0),l.value?(s.openBlock(),s.createElementBlock("span",mb," ("+s.toDisplayString(l.value)+") ",1)):s.createCommentVNode("",!0)],4)):s.createCommentVNode("",!0),s.createElementVNode("div",{class:"flex-1 min-w-0",style:s.normalizeStyle(f.value)},[s.renderSlot(p.$slots,"default",s.normalizeProps(s.guardReactiveProps(p.$attrs)))],4),p.error?(s.openBlock(),s.createElementBlock("span",gb,s.toDisplayString(p.error),1)):s.createCommentVNode("",!0)]))}}),bb={class:"w-full relative"},kb={key:0,class:"text-red-500 text-[10px] absolute bottom-[-14px]"},wb=s.defineComponent({__name:"vs-layout-inline",props:{ua:{default:""},uk:{},en:{},de:{},es:{},fr:{},item:{default:()=>({})},error:{type:[String,Boolean],default:""},label:{default:""},columns:{}},setup(n){return(e,t)=>(s.openBlock(),s.createElementBlock("div",bb,[s.renderSlot(e.$slots,"default",s.normalizeProps(s.guardReactiveProps(e.$attrs))),e.error?(s.openBlock(),s.createElementBlock("span",kb,s.toDisplayString(e.error),1)):s.createCommentVNode("",!0)]))}}),xb={class:"flex-1 min-w-0"},vb={key:0,class:"text-sm font-medium text-slate-700 dark:text-slate-200 flex items-center gap-1"},Cb={class:"truncate"},Sb={key:0,class:"text-red-500 text-[14px]"},Eb=["innerHTML"],Mb={key:0,class:"mt-1 text-xs text-red-500"},Ab={default:fb,horizontal:yb,inline:wb,settings:s.defineComponent({__name:"vs-layout-settings",props:{ua:{default:""},uk:{},en:{},de:{},es:{},fr:{},item:{default:()=>({})},error:{type:[String,Boolean],default:""},label:{default:""},columns:{}},setup(n){const e=n,t=s.ref("uk");s.computed(()=>(e.item??{})?.[t.value]??e.ua??e.label??"");const r=s.computed(()=>e.item?.description??""),o=s.computed(()=>Array.isArray(e.item?.rules)&&e.item.rules.includes("required")),i=s.computed(()=>(typeof e.error=="string"?e.error:"")??""),l=()=>{const a=typeof localStorage<"u"?localStorage.getItem("locale"):null;t.value=a||"uk"};return s.onMounted(()=>{try{typeof localStorage<"u"&&localStorage.locale&&(t.value=localStorage.locale)}catch{}window.addEventListener("storage",l)}),s.onUnmounted(()=>{window.removeEventListener("storage",l)}),(a,c)=>(s.openBlock(),s.createElementBlock("div",{class:s.normalizeClass(["w-full relative",{"opacity-60":a.item?.disabled}])},[s.createElementVNode("div",{class:s.normalizeClass(["gap-2 md:flex-row md:items-center md:justify-between",[["switcher","native-select"].includes(a.item.type)?"flex flex-col":""]])},[s.createElementVNode("div",xb,[a.ua||a.label?(s.openBlock(),s.createElementBlock("p",vb,[s.createElementVNode("span",Cb,s.toDisplayString(a.item[t.value]||a.ua||a.label),1),o.value?(s.openBlock(),s.createElementBlock("span",Sb,"*")):s.createCommentVNode("",!0)])):s.createCommentVNode("",!0),r.value?(s.openBlock(),s.createElementBlock("p",{key:1,class:"text-xs text-slate-500 dark:text-slate-400",innerHTML:r.value},null,8,Eb)):s.createCommentVNode("",!0)]),s.createElementVNode("div",{class:s.normalizeClass(["w-full",["select","native-select"].includes(a.item.type)?"md:w-[30%]":"md:w-auto"])},[s.renderSlot(a.$slots,"default",s.normalizeProps(s.guardReactiveProps(a.$attrs)))],2)],2),i.value?(s.openBlock(),s.createElementBlock("p",Mb,s.toDisplayString(i.value),1)):s.createCommentVNode("",!0)],2))}})};function Vt(n){return{inputClass:s.computed(()=>{const t=`disabled:opacity-50 disabled:cursor-not-allowed outline-none focus:ring-2 focus:ring-ring focus:ring-${n?.primaryColor||"blue"}-500 border border-solid border-stone-200 rounded-md text-sm text-stone-800 placeholder:text-stone-400 `;return n?.size==="sm"?`${t}h-[32px]`:`${t}h-[38px]`})}}const _b=["placeholder","disabled"],Tb=s.defineComponent({__name:"vs-input-password",props:s.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const e=n,{inputClass:t}=Vt(e.style),r=s.useModel(n,"modelValue"),o=s.computed(()=>!!e.disabled),i=s.computed(()=>e.placeholder??"");return(l,a)=>s.withDirectives((s.openBlock(),s.createElementBlock("input",{type:"password","onUpdate:modelValue":a[0]||(a[0]=c=>r.value=c),placeholder:i.value,disabled:o.value,class:s.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[s.unref(t),{"!border-red-600":l.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,_b)),[[s.vModelText,r.value]])}}),Bb=["placeholder","disabled","maxlength","minlength"],no=s.defineComponent({__name:"vs-input-text",props:s.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:null},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const e=n,{inputClass:t}=Vt(e.style),r=s.useModel(n,"modelValue"),o=s.computed({get:()=>r.value??"",set:u=>{r.value=u===""?null:u}}),i=s.computed(()=>!!e.disabled),l=s.computed(()=>e.placeholder??""),a=s.computed(()=>e.maxlength??void 0),c=s.computed(()=>e.minlength??void 0);function d(){if(typeof r.value=="string"){const u=r.value.trim();r.value=u===""?null:u}}return(u,f)=>s.withDirectives((s.openBlock(),s.createElementBlock("input",{type:"text","onUpdate:modelValue":f[0]||(f[0]=p=>o.value=p),placeholder:l.value,disabled:i.value,maxlength:a.value,minlength:c.value,onBlur:d,class:s.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[u.customClass,s.unref(t),{"!border-red-600":u.error}]]),style:{border:"1px solid #CFD9E0"}},null,42,Bb)),[[s.vModelText,o.value]])}}),Nb=["step","placeholder","disabled","min","max"],Eu=s.defineComponent({__name:"vs-input-number",props:s.mergeModels({style:{type:Object,default:()=>({})},placeholder:{type:String,default:""},disabled:{type:Boolean,default:!1},min:{type:Number,default:void 0},max:{type:Number,default:void 0},step:{type:[Number,String],default:void 0}},{modelValue:{default:null},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const e=n,{inputClass:t}=Vt(e.style),r=s.useAttrs(),o=s.useModel(n,"modelValue"),i=s.computed(()=>!!e.disabled),l=u=>{if(u==null||u==="")return;const f=typeof u=="string"?u.trim().replace(",","."):u,p=Number(f);return Number.isFinite(p)?p:void 0},a=s.computed(()=>l(e.min??r.min)),c=s.computed(()=>l(e.max??r.max)),d=s.computed(()=>{if(e.step!==void 0&&e.step!==null&&e.step!=="")return e.step;const u=r.step;return typeof u=="number"||typeof u=="string"?u:"any"});return(u,f)=>s.withDirectives((s.openBlock(),s.createElementBlock("input",{type:"number",step:d.value,"onUpdate:modelValue":f[0]||(f[0]=p=>o.value=p),placeholder:n.placeholder,disabled:i.value,class:s.normalizeClass(["py-1.5 px-3 block w-full bg-white",[s.unref(t)]]),style:{border:"1px solid #CFD9E0"},min:a.value,max:c.value},null,10,Nb)),[[s.vModelText,o.value]])}}),Ks=n=>!!String(n??"").trim(),Zn=n=>n?.color?String(n.color):"",Bo=n=>{const e=n?.icon;if(typeof e=="string")return e;const t=n?.imgUrl;return typeof t=="string"?t:""},No=n=>{const e=n?.icon;return e&&typeof e!="string"?e:null},Db={class:"flex items-center gap-[4px]"},Vb=["value","id","disabled"],$b=["for"],Lb=["innerHTML"],Ib={key:1,class:"text-[14px] text-gray-700 flex items-center gap-2 dark:text-neutral-400"},Ob=["src"],Rb=s.defineComponent({__name:"vs-checkbox-default",props:{value:{default:""},label:{default:""},html:{default:""},disabled:{type:Boolean,default:!1},id:{},modelValue:{default:""},info:{},error:{},option:{default:null}},emits:["update:modelValue"],setup(n,{emit:e}){const t=e,r=n,o=s.computed({get:()=>r.modelValue,set:h=>t("update:modelValue",h)}),i=s.computed(()=>!!r.disabled),l=s.computed(()=>Bo(r.option)),a=s.computed(()=>No(r.option)),c=s.computed(()=>Zn(r.option)),d=s.computed(()=>!!(c.value&&!l.value&&!a.value)),u=s.computed(()=>!!(l.value&&c.value)),f=s.computed(()=>c.value?{color:c.value}:void 0),p=s.computed(()=>{if(!(!l.value||!c.value))return{backgroundColor:c.value,WebkitMaskImage:`url(${l.value})`,maskImage:`url(${l.value})`,WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskPosition:"center",maskPosition:"center"}});return(h,m)=>(s.openBlock(),s.createElementBlock("div",Db,[s.withDirectives(s.createElementVNode("input",{type:"checkbox",value:h.value,"onUpdate:modelValue":m[0]||(m[0]=g=>o.value=g),class:s.normalizeClass(["shrink-0 border border-solid hidden border-gray-700 w-3.5 h-3.5 rounded text-blue-600 focus:ring-offset-0 dark:bg-neutral-800 dark:border-neutral-700 cursor-pointer",{"!cursor-not-allowed":i.value}]),id:h.id,disabled:i.value},null,10,Vb),[[s.vModelCheckbox,o.value]]),s.createElementVNode("label",{for:h.id,class:s.normalizeClass(["flex flex-1 checkbox-label items-center gap-x-2 cursor-pointer text-sm text-gray-800 dark:text-neutral-300",{"!cursor-not-allowed":i.value}])},[s.createElementVNode("div",{class:s.normalizeClass(["h-[16px] text-white w-[16px] flex items-center justify-center shrink-0 border rounded",[o.value?"bg-blue-600 border-blue-600":"bg-white border-gray-600",h.error?"border-red-600":""]])},[s.createVNode(s.unref(Y.Check),{class:"h-4 w-4"})],2),h.html?(s.openBlock(),s.createElementBlock("div",{key:0,class:"w-full",innerHTML:h.html},null,8,Lb)):(s.openBlock(),s.createElementBlock("span",Ib,[d.value?(s.openBlock(),s.createElementBlock("span",{key:0,class:"inline-flex h-3 w-3 rounded-full border border-gray-200",style:s.normalizeStyle({background:c.value})},null,4)):s.createCommentVNode("",!0),u.value?(s.openBlock(),s.createElementBlock("span",{key:1,class:"inline-block h-4 w-4",style:s.normalizeStyle(p.value)},null,4)):l.value?(s.openBlock(),s.createElementBlock("img",{key:2,class:"block",height:"16",width:"16",src:l.value,alt:"icon"},null,8,Ob)):a.value?(s.openBlock(),s.createBlock(s.resolveDynamicComponent(a.value),{key:3,class:"h-4 w-4",style:s.normalizeStyle(f.value)},null,8,["style"])):s.createCommentVNode("",!0),s.renderSlot(h.$slots,"default",{},()=>[s.createTextVNode(s.toDisplayString(h.label),1)])]))],10,$b)]))}}),Fb=["name","value","disabled"],Pb=["innerHTML"],zb={key:1,class:"flex items-center gap-[6px] text-[14px]"},Hb={key:2,class:"text-[16px] inline-flex items-center justify-center"},jb=["src"],Ub=s.defineComponent({__name:"vs-checkbox-buttons",props:{value:{type:[String,Number,Boolean],default:""},label:{default:""},html:{default:""},modelValue:{default:""},disabled:{type:Boolean},id:{},icon:{},imgUrl:{},style:{},option:{}},emits:["update:modelValue"],setup(n,{emit:e}){const t=n,r=e,o=s.computed({get:()=>t.modelValue,set:g=>{r("update:modelValue",g)}}),i=s.computed(()=>Array.isArray(o.value)?o.value.includes(t.value):o.value===!0||o.value===t.value),l=s.computed(()=>t.style?.size==="xs"?"p-1.5 text-xs":t.style?.size==="lg"?"p-3.5 text-[20px]":"p-2.5 text-xs"),a=s.computed(()=>({...t.option??{},icon:t.option?.icon??t.icon,imgUrl:t.option?.imgUrl??t.imgUrl,color:t.option?.color})),c=s.computed(()=>Bo(a.value)),d=s.computed(()=>No(a.value)),u=s.computed(()=>Zn(a.value)),f=s.computed(()=>!!(u.value&&!c.value&&!d.value)),p=s.computed(()=>!!(c.value&&u.value)),h=s.computed(()=>u.value?{color:u.value}:void 0),m=s.computed(()=>{if(!(!c.value||!u.value))return{backgroundColor:u.value,WebkitMaskImage:`url(${c.value})`,maskImage:`url(${c.value})`,WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskPosition:"center",maskPosition:"center"}});return(g,y)=>(s.openBlock(),s.createElementBlock("label",{class:s.normalizeClass(["group relative flex justify-center items-center gap-x-3 text-center bg-white text-gray-800 ring-ring ring-2 cursor-pointer rounded-lg",[l.value,i.value?"ring-blue-500":"border border-gray-200 ring-transparent"]])},[s.withDirectives(s.createElementVNode("input",{type:"checkbox",class:"hidden",name:g.id,value:g.value,"onUpdate:modelValue":y[0]||(y[0]=b=>o.value=b),disabled:g.disabled},null,8,Fb),[[s.vModelCheckbox,o.value]]),g.html?(s.openBlock(),s.createElementBlock("span",{key:0,class:"w-full",innerHTML:g.html},null,8,Pb)):(s.openBlock(),s.createElementBlock("span",zb,[f.value?(s.openBlock(),s.createElementBlock("span",{key:0,class:"inline-flex h-3 w-3 rounded-full border border-gray-200",style:s.normalizeStyle({background:u.value})},null,4)):s.createCommentVNode("",!0),p.value?(s.openBlock(),s.createElementBlock("span",{key:1,class:"inline-block h-4 w-4",style:s.normalizeStyle(m.value)},null,4)):c.value||d.value?(s.openBlock(),s.createElementBlock("span",Hb,[c.value?(s.openBlock(),s.createElementBlock("img",{key:0,src:c.value,width:"16",height:"16",alt:"icon"},null,8,jb)):d.value?(s.openBlock(),s.createBlock(s.resolveDynamicComponent(d.value),{key:1,class:"h-4 w-4",style:s.normalizeStyle(h.value)},null,8,["style"])):s.createCommentVNode("",!0)])):s.createCommentVNode("",!0),s.renderSlot(g.$slots,"default",{},()=>[s.createTextVNode(s.toDisplayString(g.label),1)])]))],2))}}),Wb={class:"flex items-center"},pa=s.defineComponent({__name:"vs-input-checkbox-item",props:{value:{default:""},label:{default:""},labelHtml:{default:""},disabled:{type:Boolean,default:!1},view:{default:"default"},modelValue:{type:[Boolean,Array],default:!1},icon:{},imgUrl:{},slots:{},option:{},style:{},error:{default:""}},emits:["update:modelValue"],setup(n,{emit:e}){const t=n,r=e,o=`radio-${Math.floor(Math.random()*1e4)}`,i=s.computed({get:()=>Array.isArray(t.modelValue)?Array.isArray(t.modelValue)&&t.modelValue.includes(t.value):t.modelValue,set:a=>{if(Array.isArray(t.modelValue)){let c=[...t.modelValue];a?c.includes(t.value)||c.push(t.value):c=c.filter(d=>d!==t.value),r("update:modelValue",c)}else r("update:modelValue",a)}}),l=s.ref(`vs-checkbox-${t.view||"default"}`);return(a,c)=>(s.openBlock(),s.createElementBlock("div",Wb,[(s.openBlock(),s.createBlock(s.resolveDynamicComponent(l.value==="vs-checkbox-buttons"?s.unref(Ub):s.unref(Rb)),{value:a.value,label:a.label,html:a.labelHtml,info:a.option?.info,disabled:a.disabled,modelValue:i.value,"onUpdate:modelValue":c[0]||(c[0]=d=>i.value=d),id:o,icon:a.icon,imgUrl:a.imgUrl,option:a.option,style:s.normalizeStyle(a.style),error:a.error},{default:s.withCtx(()=>[s.createTextVNode(s.toDisplayString(a.label),1)]),_:1},8,["value","label","html","info","disabled","modelValue","icon","imgUrl","option","style","error"]))]))}}),Kb={key:0,class:"flex items-start gap-x-1"},qb={key:0,class:"text-red-500 text-[14px]"},Gb=["title"],Jb=["disabled"],ha=s.defineComponent({__name:"vs-input-switcher",props:s.mergeModels({rules:{default:()=>[]},view:{default:"checkbox"},label:{default:""},i:{default:""},text:{default:""},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const e=n,t=s.useModel(n,"modelValue");return(r,o)=>e.view==="checkbox"?(s.openBlock(),s.createElementBlock("div",Kb,[s.createVNode(pa,{modelValue:t.value,"onUpdate:modelValue":o[0]||(o[0]=i=>t.value=i),error:r.error||""},null,8,["modelValue","error"]),r.rules?.includes("required")?(s.openBlock(),s.createElementBlock("span",qb,"*")):s.createCommentVNode("",!0),r.i?(s.openBlock(),s.createElementBlock("button",{key:1,class:"cursor-pointer",title:r.i,onClick:o[1]||(o[1]=s.withModifiers(()=>{},["prevent"]))},[s.createVNode(s.unref(Y.Info),{class:"h-4 w-4 text-gray-500"})],8,Gb)):s.createCommentVNode("",!0)])):(s.openBlock(),s.createElementBlock("button",{key:1,type:"button",class:s.normalizeClass(["inline-flex h-5 w-9 shrink-0 px-[2px] cursor-pointer items-center rounded-full shadow-sm disabled:cursor-not-allowed disabled:opacity-50",[t.value?`bg-${r.style?.primaryColor||"blue"}-500`:"bg-stone-200",r.customClass]]),disabled:r.disabled,onClick:o[2]||(o[2]=i=>t.value=!t.value)},[s.createElementVNode("span",{"data-state":"checked",class:s.normalizeClass(["pointer-events-none block h-4 w-4 rounded-full bg-white shadow-lg ring-0 transition-transform",[t.value?"translate-x-4":"translate-x-0"]])},null,2)],10,Jb))}}),Yb=["id","innerHTML"],ma=s.defineComponent({__name:"vs-input-static",props:{text:{default:""},html:{default:""},style:{},customClass:{default:""},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},setup(n){return(e,t)=>(s.openBlock(),s.createElementBlock("div",{id:e.name,class:s.normalizeClass(["text-gray-900",e.customClass]),innerHTML:e.html?e.html:e.text},null,10,Yb))}}),Xb=["placeholder","disabled","name"],qs=s.defineComponent({__name:"vs-input-mask",props:s.mergeModels({name:{},mask:{default:""},unmask:{type:Boolean,default:!1},placeholder:{default:"_"},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const e=n,{inputClass:t}=Vt(e.style),r=s.useModel(n,"modelValue"),o=s.ref(null);let i=null;function l(a){const c=a==null?"":String(a),d={9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},u=new Set;let f=!1;for(let h=0;h<c.length;h+=1){const m=c[h];m==="{"?f=!0:m==="}"?f=!1:f&&u.add(m)}const p={};return Object.keys(d).forEach(h=>{u.has(h)||(p[h]=d[h])}),{mask:c,definitions:p,lazy:!1}}return s.onMounted(async()=>{if(o.value){const{default:a}=await Promise.resolve().then(()=>xi),c=l(e.mask||"");i=a(o.value,c),i.on("accept",()=>{r.value=e.unmask?i.unmaskedValue:i.value}),i.on("complete",()=>{r.value=e.unmask?i.unmaskedValue:i.value}),i.value=r.value!=null?String(r.value):""}}),s.onBeforeUnmount(()=>{i?.destroy()}),s.watch(()=>e.mask,a=>{if(i){const c=l(a||"");i.updateOptions(c)}}),s.watch(r,a=>{i&&i.unmaskedValue!==a&&(i.value=a!=null?String(a):"")}),(a,c)=>(s.openBlock(),s.createElementBlock("input",{type:"text",ref_key:"inputEl",ref:o,placeholder:a.placeholder,disabled:a.disabled,name:a.name,class:s.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[s.unref(t)]]),style:{border:"1px solid #CFD9E0"}},null,10,Xb))}}),Zb={class:"relative w-full bg-white rounded-lg"},Qb={class:"absolute bottom-2/4 translate-y-2/4 left-[10px] cursor-pointer"},ek=["placeholder","disabled"],ga=s.defineComponent({__name:"vs-input-email",props:s.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:null},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const e=n,{inputClass:t}=Vt(e.style),r=s.useModel(n,"modelValue");return(o,i)=>(s.openBlock(),s.createElementBlock("div",Zb,[s.createElementVNode("div",Qb,[s.createVNode(s.unref(Y.Mail),{class:"h-4 w-4 stroke-gray-500 transition-all"})]),s.withDirectives(s.createElementVNode("input",{type:"email","onUpdate:modelValue":i[0]||(i[0]=l=>r.value=l),placeholder:o.placeholder,disabled:o.disabled,class:s.normalizeClass(["!pl-8 py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[s.unref(t),{"!border-red-600":o.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,ek),[[s.vModelText,r.value]])]))}}),Dn="+99(999)-999-99-99";function Qn(n){if(!n?.trim())return 0;const e=new Set(["9","0","a","A","*"]);let t=!1,r=0;for(let o=0;o<n.length;o+=1){const i=n[o];if(i==="{"){t=!0;continue}if(i==="}"){t=!1;continue}!t&&e.has(i)&&(r+=1)}return r}const tk={class:"relative w-full bg-white rounded-lg"},nk={class:"absolute bottom-2/4 translate-y-2/4 left-[10px] pointer-events-none"},rk=["name","placeholder","disabled","pattern"],ya=s.defineComponent({__name:"vs-input-tel",props:s.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:null},name:{},placeholder:{default:""},maxlength:{},minlength:{},mask:{default:Dn}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const e=n,t=s.computed(()=>`^\\+[1-9]\\d{${(Qn(e.mask||Dn)||Qn(Dn))-1}}$`),{inputClass:r}=Vt(e.style),o=s.useModel(n,"modelValue"),i=s.ref(null);let l=null;function a(u){const f={9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},p=new Set;let h=!1;for(let g=0;g<u.length;g+=1){const y=u[g];y==="{"?h=!0:y==="}"?h=!1:h&&p.add(y)}const m={};return Object.keys(f).forEach(g=>{p.has(g)||(m[g]=f[g])}),{mask:u,definitions:m,lazy:!1,disabled:e.disabled}}function c(u){if(u==null||u==="")return"";const f=String(u).trim();return f?f.replace(/\D/g,""):""}function d(){if(!l)return;const u=l.unmaskedValue??"";o.value=u?`+${u}`:""}return s.onMounted(async()=>{if(!i.value)return;const{default:u}=await Promise.resolve().then(()=>xi),f=a(e.mask||"");l=u(i.value,f),l.on("accept",d),l.on("complete",d);const p=c(o.value);l.unmaskedValue=p}),s.onBeforeUnmount(()=>{l?.destroy(),l=null}),s.watch(()=>e.mask,u=>{l&&l.updateOptions(a(u||""))}),s.watch(()=>e.disabled,u=>{l&&l.updateOptions({disabled:u})}),s.watch(o,u=>{if(!l)return;const f=c(u);l.unmaskedValue!==f&&(l.unmaskedValue=f)}),(u,f)=>(s.openBlock(),s.createElementBlock("div",tk,[s.createElementVNode("div",nk,[s.createVNode(s.unref(Y.Phone),{class:"h-4 w-4 stroke-gray-500 transition-all"})]),s.createElementVNode("input",{ref_key:"inputEl",ref:i,type:"tel",name:u.name,placeholder:u.placeholder,disabled:u.disabled,pattern:t.value,title:"Міжнародний номер (E.164), наприклад +380XXXXXXXXX",autocomplete:"tel",class:s.normalizeClass(["!pl-10 py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[s.unref(r),{"!border-red-600":u.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,rk)]))}}),ok=["value","disabled"],sk=["innerHTML"],ik={key:1,class:"flex items-center gap-2"},lk=["src"],ak={class:"text-[13px] text-gray-700"},ck=s.defineComponent({__name:"vs-input-radio-default",props:s.mergeModels({style:{},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{},value:{},text:{},html:{default:""},option:{default:null}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const e=n,t=s.useModel(n,"modelValue"),r=s.computed(()=>!!e.disabled),o=s.computed(()=>Bo(e.option)),i=s.computed(()=>No(e.option)),l=s.computed(()=>Zn(e.option)),a=s.computed(()=>!!(l.value&&!o.value&&!i.value)),c=s.computed(()=>!!(o.value&&l.value)),d=s.computed(()=>l.value?{color:l.value}:void 0),u=s.computed(()=>{if(!(!o.value||!l.value))return{backgroundColor:l.value,WebkitMaskImage:`url(${o.value})`,maskImage:`url(${o.value})`,WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskPosition:"center",maskPosition:"center"}});return(f,p)=>(s.openBlock(),s.createElementBlock("label",{class:s.normalizeClass(["flex items-center gap-0",[e.customClass,r.value?"cursor-not-allowed opacity-60":""]])},[s.withDirectives(s.createElementVNode("input",{"onUpdate:modelValue":p[0]||(p[0]=h=>t.value=h),type:"radio",value:e.value,disabled:r.value,class:"hidden"},null,8,ok),[[s.vModelRadio,t.value]]),s.createElementVNode("span",{class:s.normalizeClass(["w-[16px] shrink-0 h-[16px] border rounded-full flex items-center justify-center mr-[10px]",[`border-${e.style?.primaryColor||"blue"}-500`,r.value?"opacity-50 cursor-not-allowed":""]])},[t.value==e.value?(s.openBlock(),s.createElementBlock("span",{key:0,class:s.normalizeClass(["w-[12px] h-[12px] shrink-0 rounded-full",[`bg-${e.style?.primaryColor||"blue"}-500`]])},null,2)):s.createCommentVNode("",!0)],2),e.html?(s.openBlock(),s.createElementBlock("div",{key:0,class:"w-full",innerHTML:e.html},null,8,sk)):(s.openBlock(),s.createElementBlock("div",ik,[a.value?(s.openBlock(),s.createElementBlock("span",{key:0,class:"inline-flex h-3 w-3 rounded-full border border-gray-200",style:s.normalizeStyle({background:l.value})},null,4)):s.createCommentVNode("",!0),c.value?(s.openBlock(),s.createElementBlock("span",{key:1,class:"inline-block h-4 w-4",style:s.normalizeStyle(u.value)},null,4)):o.value?(s.openBlock(),s.createElementBlock("img",{key:2,class:"block",height:"16",width:"16",src:o.value,alt:"icon"},null,8,lk)):i.value?(s.openBlock(),s.createBlock(s.resolveDynamicComponent(i.value),{key:3,class:"h-4 w-4",style:s.normalizeStyle(d.value)},null,8,["style"])):s.createCommentVNode("",!0),s.createElementVNode("span",ak,s.toDisplayString(e.text),1)]))],2))}}),dk=["value","disabled"],uk=["innerHTML"],fk={key:1,class:"flex items-center gap-2"},pk=["src"],hk={class:"text-[13px] text-gray-700"},mk={"vs-input-radio-default":ck,"vs-input-radio-buttons":s.defineComponent({__name:"vs-input-radio-buttons",props:s.mergeModels({style:{},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{},value:{},text:{},html:{default:""},option:{default:null}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const e=n,t=s.useModel(n,"modelValue"),r=s.computed(()=>!!e.disabled),o=s.computed(()=>Bo(e.option)),i=s.computed(()=>No(e.option)),l=s.computed(()=>Zn(e.option)),a=s.computed(()=>!!(l.value&&!o.value&&!i.value)),c=s.computed(()=>!!(o.value&&l.value)),d=s.computed(()=>l.value?{color:l.value}:void 0),u=s.computed(()=>{if(!(!o.value||!l.value))return{backgroundColor:l.value,WebkitMaskImage:`url(${o.value})`,maskImage:`url(${o.value})`,WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskPosition:"center",maskPosition:"center"}});return(f,p)=>(s.openBlock(),s.createElementBlock("label",{class:s.normalizeClass(["flex h-full w-full items-center border rounded-lg px-2 py-1",[t.value==e.value?`ring-2 ring-ring ring-${e.style?.primaryColor||"blue"}-500`:"",e.customClass,r.value?"cursor-not-allowed opacity-60":""]])},[s.withDirectives(s.createElementVNode("input",{"onUpdate:modelValue":p[0]||(p[0]=h=>t.value=h),type:"radio",value:e.value,disabled:r.value,class:"hidden"},null,8,dk),[[s.vModelRadio,t.value]]),e.html?(s.openBlock(),s.createElementBlock("div",{key:0,class:"w-full",innerHTML:e.html},null,8,uk)):(s.openBlock(),s.createElementBlock("div",fk,[a.value?(s.openBlock(),s.createElementBlock("span",{key:0,class:"inline-flex h-3 w-3 rounded-full border border-gray-200",style:s.normalizeStyle({background:l.value})},null,4)):s.createCommentVNode("",!0),c.value?(s.openBlock(),s.createElementBlock("span",{key:1,class:"inline-block h-4 w-4",style:s.normalizeStyle(u.value)},null,4)):o.value?(s.openBlock(),s.createElementBlock("img",{key:2,class:"block",height:"16",width:"16",src:o.value,alt:"icon"},null,8,pk)):i.value?(s.openBlock(),s.createBlock(s.resolveDynamicComponent(i.value),{key:3,class:"h-4 w-4",style:s.normalizeStyle(d.value)},null,8,["style"])):s.createCommentVNode("",!0),s.createElementVNode("span",hk,s.toDisplayString(e.text),1)]))],2))}})},Mu=n=>Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[],Au=n=>{const e=n.host??"",t=n.prefix??"api",r=n.api??`/${t}/suggest/${n.data}`;return`${e}${r}`},gk=n=>({fetchOptions:async(r="")=>{const o=n();if(!o.data)return o.options?[...o.options]:[];try{const i=new URLSearchParams;r&&i.set("key",r),o.parentValue!==void 0&&o.parentValue!==null&&o.parentValue!==""&&i.set("parent",String(o.parentValue)),o.start===1&&i.set("start","1");const a=await(await fetch(`${Au(o)}?${i.toString()}`)).json();return Mu(a)}catch{return[]}},fetchOptionByValue:async r=>{if(r==null||r==="")return null;const o=n();if(!o.data)return(o.options??[]).find(l=>l?.id?.toString()===String(r))??null;try{const i=new URLSearchParams;i.set("val",String(r)),o.parentValue!==void 0&&o.parentValue!==null&&o.parentValue!==""&&i.set("parent",String(o.parentValue)),o.start===1&&i.set("start","1");const a=await(await fetch(`${Au(o)}?${i.toString()}`)).json();return Mu(a)[0]??null}catch{return null}}}),Gs=({props:n,formValues:e=null,watchParent:t=!0})=>{const r=s.ref([]),o=s.computed(()=>n.parent?e?.value?.[n.parent]?.toString?.()??null:null),{fetchOptions:i,fetchOptionByValue:l}=gk(()=>({data:n.data,options:n.options,api:n.api,prefix:n.prefix,host:n.host,start:n.start,parentValue:o.value})),a=async(c="")=>{const d=n.data?await i(c):n.options?[...n.options]:[];return r.value=d,r.value};return s.watch(()=>n.options,()=>{n.data||(r.value=n.options?[...n.options]:[])},{immediate:!0,deep:!0}),t&&s.watch(o,async()=>{n.data&&(r.value=await i())},{immediate:!1}),{optionsList:r,parentValue:o,fetchOptions:i,fetchOptionByValue:l,loadOptions:a}},yk=/\{\{\s*([^}]+?)\s*\}\}/g,bk=n=>(n?String(n):"").replace(/<[^>]*>/g,"").trim(),kk=(n,e)=>e.split(".").reduce((t,r)=>t==null?t:t[r.trim()],n),Js=(n,e)=>{if(!n)return"";const t=(e??"").trim();return t?t.replace(yk,(r,o)=>{const i=String(o).trim(),l=n,c=(i.includes(".")?kk(l,i):void 0)??l[i];return c!=null?String(c):""}):n.text??""},Ys=(n,e)=>{if(!n)return"";const t=Js(n,e);return bk(t)||n.text||""},ba=s.defineComponent({__name:"vs-input-radio",props:s.mergeModels({options:{},slot:{},data:{},api:{},prefix:{},host:{},start:{},parent:{},position:{default:"vertical"},view:{default:"default"},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const e=n,t=s.useModel(n,"modelValue"),r=s.computed(()=>mk[`vs-input-radio-${e.view}`]),o=s.computed(()=>e.slot??e?.optionTemplate??""),i=s.computed(()=>Ks(o.value)),l=h=>Js(h,o.value),a=h=>Ys(h,o.value),c=s.computed(()=>e.position==="horizontal"?"flex w-full flex-row flex-wrap gap-[10px]":"flex w-full flex-col gap-2"),d=s.computed(()=>{if(e.position==="horizontal"&&e.customClass?.includes("50%"))return{flex:"0 0 calc(50% - 5px)"}}),u=s.inject("values",null),{optionsList:f,loadOptions:p}=Gs({props:e,formValues:u});return s.onMounted(async()=>{await p()}),(h,m)=>(s.openBlock(),s.createElementBlock("div",{class:s.normalizeClass(c.value)},[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(s.unref(f),g=>(s.openBlock(),s.createElementBlock("div",{key:g?.id,class:s.normalizeClass(["flex items-stretch",h.position==="horizontal"?e.customClass:""]),style:s.normalizeStyle(d.value)},[(s.openBlock(),s.createBlock(s.resolveDynamicComponent(r.value),s.mergeProps({text:a(g),html:i.value?l(g):"",option:g,value:g.id.toString(),checked:t.value?.toString?.()===g.id?.toString?.(),"custom-class":h.position==="horizontal"?"":e.customClass,modelValue:t.value,"onUpdate:modelValue":m[0]||(m[0]=y=>t.value=y)},{ref_for:!0},h.$attrs),null,16,["text","html","option","value","checked","custom-class","modelValue"]))],6))),128))],2))}}),wk={key:1,class:"w-full flex flex-col gap-4"},xk={key:0,class:"text-sm font-medium text-muted-foreground my-2"},vk="Без категорії",Ck=s.defineComponent({__name:"vs-input-checkbox",props:{options:{default:()=>[]},position:{default:"vertical"},slots:{default:null},slot:{},colSpan:{default:0},data:{},api:{},prefix:{},host:{},start:{},parent:{},view:{},group:{default:void 0},values:{default:()=>[]},style:{},customClass:{},disabled:{type:Boolean},modelValue:{default:!1},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},emits:["update:modelValue"],setup(n,{emit:e}){const t=n,r=e,o=s.reactive({}),i=s.inject("values",null),{optionsList:l,loadOptions:a}=Gs({props:{...t,options:t.options},formValues:i}),c=s.computed(()=>l.value),d=w=>w?.value||w?.id||w?.text||w,u=s.computed(()=>t.slot??t?.optionTemplate??""),f=s.computed(()=>Ks(u.value)),p=w=>Js(w,u.value),h=w=>Ys(w,u.value),m=w=>`lg:col-span-${w||12}`,g=s.computed(()=>[t.position==="vertical"?"flex flex-col":"",t.colSpan?"grid":"flex justify-start"]),y=w=>w==null||w===""?null:typeof w=="string"||typeof w=="number"?w:String(w),b=s.computed(()=>{if(!t.group)return[];const w=new Map;c.value.forEach(T=>{const M=T[t.group],_=y(M);w.has(_)||w.set(_,[]),w.get(_)?.push(T)});const v=[];t.values?.length&&t.values.forEach(T=>{const M=y(T);v.push(M)});const E=new Set,N=T=>{const M=w.get(T)||[];if(!M.length)return null;const _=T===null?"group-null":`group-${String(T)}`,A=T===null?vk:String(T);return E.add(T),{key:_,label:A,options:M}},R=[];return v.forEach(T=>{const M=N(T);M&&R.push(M)}),w.forEach((T,M)=>{if(E.has(M))return;const _=N(M);_&&R.push(_)}),R});return s.watch(()=>t.modelValue,w=>{if(typeof w=="boolean"&&c.value.length===1){const v=d(c.value[0]);o[v]=w}else if(Array.isArray(w)){const v=new Set(w);c.value.forEach(E=>{if(!E.disabled){const N=d(E);o[N]=v.has(N)}})}},{immediate:!0}),s.watch(o,()=>{if(!c.value.length){r("update:modelValue",null);return}const w=Object.entries(o).filter(([,v])=>v).map(([v])=>v);r("update:modelValue",w.length===0?[]:w)},{deep:!0}),s.onMounted(async()=>{if(await a(),typeof t.modelValue=="boolean"&&c.value.length===1){const w=d(c.value[0]);o[w]=t.modelValue}else if(Array.isArray(t.modelValue)){const w=new Set(t.modelValue);c.value.forEach(v=>{if(!v.disabled){const E=d(v);o[E]=w.has(E)}})}}),(w,v)=>t.group?(s.openBlock(),s.createElementBlock("div",wk,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(b.value,E=>(s.openBlock(),s.createElementBlock("div",{key:E.key,class:"flex flex-col gap-2"},[E.label?(s.openBlock(),s.createElementBlock("span",xk,s.toDisplayString(E.label),1)):s.createCommentVNode("",!0),s.createElementVNode("div",{class:s.normalizeClass(["p-0 w-full gap-[12px]",g.value])},[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(E.options,N=>(s.openBlock(),s.createBlock(pa,{modelValue:o[d(N)],"onUpdate:modelValue":R=>o[d(N)]=R,value:d(N),class:s.normalizeClass(m(w.colSpan)),disabled:t.disabled||N.disabled,label:h(N),labelHtml:f.value?p(N):"",key:`${E.key}-${d(N)}`,icon:N?.icon,imgUrl:N?.imgUrl,option:N,view:w.view},null,8,["modelValue","onUpdate:modelValue","value","class","disabled","label","labelHtml","icon","imgUrl","option","view"]))),128))],2)]))),128))])):(s.openBlock(),s.createElementBlock("div",{key:0,class:s.normalizeClass(["p-0 w-full gap-[10px]",g.value])},[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(c.value,E=>(s.openBlock(),s.createBlock(pa,{modelValue:o[d(E)],"onUpdate:modelValue":N=>o[d(E)]=N,value:d(E),class:s.normalizeClass(m(w.colSpan)),disabled:t.disabled||E.disabled,label:h(E),labelHtml:f.value?p(E):"",key:d(E),icon:E?.icon,imgUrl:E?.imgUrl,option:E,view:w.view},null,8,["modelValue","onUpdate:modelValue","value","class","disabled","label","labelHtml","icon","imgUrl","option","view"]))),128))],2))}}),Ne=(n,e)=>{const t=n.__vccOpts||n;for(const[r,o]of e)t[r]=o;return t},_u=Ne(Ck,[["__scopeId","data-v-9056e0ec"]]),Sk=1440*60*1e3,Ek=["січень","лютий","березень","квітень","травень","червень","липень","серпень","вересень","жовтень","листопад","грудень"],Mk=["січ","лют","бер","квіт","трав","черв","лип","серп","вер","жовт","лист","груд"],Ak=["нд","пн","вт","ср","чт","пт","сб"];function bt(n){return n instanceof Date&&!Number.isNaN(n.getTime())}const ro=n=>new Date(n.getTime());function Er(n){const e=ro(n);return e.setHours(0,0,0,0),e}function Do(n){const e=ro(n);return e.setHours(23,59,59,999),e}function ka(n){return Er(new Date(n.getFullYear(),n.getMonth(),1))}function wa(n){return Do(new Date(n.getFullYear(),n.getMonth()+1,0))}function xa(n,e){const t=new Date(n),r=t.getDate();t.setDate(1),t.setMonth(t.getMonth()+e);const o=new Date(t.getFullYear(),t.getMonth()+1,0).getDate();return t.setDate(Math.min(r,o)),t}function _k(n,e){return xa(n,-1)}function Xs(n,e){const t=new Date(n);return t.setFullYear(t.getFullYear()+e),t}function Tu(n,e){return Xs(n,-e)}function Bu(n){return Er(new Date(n.getFullYear(),0,1))}function Nu(n){return Do(new Date(n.getFullYear(),11,31))}function Tk(n){const e=Math.floor(n.getFullYear()/10)*10;return Er(new Date(e,0,1))}function Bk(n){const e=Math.floor(n.getFullYear()/10)*10+9;return Do(new Date(e,11,31))}const sn=n=>n.getFullYear(),Zs=n=>Math.floor(n.getFullYear()/10)*10;function Nk(n){const e=[];let t=Er(n.start);const r=Er(n.end);for(;t<=r;)e.push(ro(t)),t=new Date(t.getTime()+Sk);return e}function Dk(n){const e=[];let t=ka(n.start);const r=wa(n.end);for(;t<=r;)e.push(ro(t)),t=xa(t,1);return e}function Vk(n){const e=[];let t=Bu(n.start);const r=Nu(n.end);for(;t<=r;)e.push(ro(t)),t=Xs(t,1);return e}function va(n,e=1){const t=Er(n),r=(t.getDay()-e+7)%7;return t.setDate(t.getDate()-r),t}function $k(n,e=1){const t=va(n,e);return t.setDate(t.getDate()+6),Do(t)}function Lk(n,e,t=0){const r=va(n,t),o=(e-t+7)%7;return r.setDate(r.getDate()+o),r}const Qs=(n,e)=>!!n&&!!e&&n.getFullYear()===e.getFullYear()&&n.getMonth()===e.getMonth()&&n.getDate()===e.getDate(),Ca=(n,e)=>!!n&&!!e&&n.getFullYear()===e.getFullYear()&&n.getMonth()===e.getMonth(),Du=(n,e)=>!!n&&!!e&&n.getFullYear()===e.getFullYear(),Vu=(n,e)=>!!n&&!!e&&Qs(n,e)&&n.getHours()===e.getHours(),Ik=(n,e)=>!!n&&!!e&&Vu(n,e)&&n.getMinutes()===e.getMinutes();function Ok(n,e){const t=n.getTime();return t>=e.start.getTime()&&t<=e.end.getTime()}const Vo=(n,e)=>!!n&&!!e&&n.getTime()<e.getTime(),$o=(n,e)=>!!n&&!!e&&n.getTime()>e.getTime();function Rk(n){const e=n.filter(t=>bt(t));if(e.length)return e.reduce((t,r)=>t.getTime()>=r.getTime()?t:r)}function Fk(n){const e=n.filter(t=>bt(t));if(e.length)return e.reduce((t,r)=>t.getTime()<=r.getTime()?t:r)}function Pk(n,e){const t=ro(n);return typeof e.year=="number"&&t.setFullYear(e.year),typeof e.month=="number"&&t.setMonth(e.month),typeof e.date=="number"&&t.setDate(e.date),typeof e.hours=="number"&&t.setHours(e.hours),typeof e.minutes=="number"&&t.setMinutes(e.minutes),typeof e.seconds=="number"&&t.setSeconds(e.seconds),typeof e.milliseconds=="number"&&t.setMilliseconds(e.milliseconds),t}const ei=(n,e=2)=>String(n).padStart(e,"0");function $u(n,e){return e==="wide"?Ek[n]:Mk[n]}function zk(n){return Ak[n]}const Hk=[{token:"LLLL",format:n=>$u(n.getMonth(),"wide")},{token:"LLL",format:n=>$u(n.getMonth(),"abbreviated")},{token:"EE",format:n=>zk(n.getDay())},{token:"yyyy",format:n=>String(n.getFullYear())},{token:"MM",format:n=>ei(n.getMonth()+1)},{token:"dd",format:n=>ei(n.getDate())},{token:"HH",format:n=>ei(n.getHours())},{token:"mm",format:n=>ei(n.getMinutes())}];function Lo(n,e){if(!bt(n))return"";let t="",r=0;for(;r<e.length;){const o=Hk.find(i=>e.startsWith(i.token,r));o?(t+=o.format(n),r+=o.token.length):(t+=e[r],r+=1)}return t}const jk={"yyyy-MM-dd":/^(\d{4})-(\d{2})-(\d{2})$/,"dd.MM.yyyy":/^(\d{2})\.(\d{2})\.(\d{4})$/,"dd.MM.yyyy HH:mm":/^(\d{2})\.(\d{2})\.(\d{4}) (\d{1,2}):(\d{2})(?::(\d{2}))?$/,"HH:mm":/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/,"MM.yyyy":/^(\d{2})\.(\d{4})$/,yyyy:/^(\d{4})$/};function Lu(n,e){const t=jk[e];if(!t){const o=new Date(n);return bt(o)?o:null}const r=n.match(t);if(!r)return null;switch(e){case"yyyy-MM-dd":{const[,o,i,l]=r,a=new Date(Number(o),Number(i)-1,Number(l));return bt(a)?a:null}case"dd.MM.yyyy":{const[,o,i,l]=r,a=new Date(Number(l),Number(i)-1,Number(o));return bt(a)?a:null}case"dd.MM.yyyy HH:mm":{const[,o,i,l,a,c,d]=r,u=new Date(Number(l),Number(i)-1,Number(o),Number(a),Number(c),Number(d||0));return bt(u)?u:null}case"HH:mm":{const[,o,i,l]=r,a=new Date;return a.setHours(Number(o),Number(i),Number(l||0),0),a}case"MM.yyyy":{const[,o,i]=r;return new Date(Number(i),Number(o)-1,1)}case"yyyy":{const[,o]=r;return new Date(Number(o),0,1)}default:return null}}const Uk=["year","month","day","time","custom"],Wk=s.defineComponent({components:{ChevronLeft:Y.ChevronLeft,ChevronRight:Y.ChevronRight},emits:{elementClick:n=>bt(n),left:()=>!0,right:()=>!0,heading:()=>!0,today:()=>!0,clear:()=>!0},props:{headingClickable:{type:Boolean,default:!1},leftDisabled:{type:Boolean,default:!1},rightDisabled:{type:Boolean,default:!1},columnCount:{type:Number,default:7},items:{type:Array,default:()=>[]},viewMode:{type:String,required:!0,validate:n=>typeof n=="string"&&Uk.includes(n)},showButtonBar:{type:Boolean,default:!1},hideHeader:{type:Boolean,default:!1}},setup(){const e=s.getCurrentInstance()?.appContext?.config?.globalProperties?.$t,t=s.computed(()=>{const o=e?.("form.date.today");return o&&o!=="form.date.today"?o:"Сьогодні"}),r=s.computed(()=>{const o=e?.("form.date.clear");return o&&o!=="form.date.clear"?o:"Очистити"});return{todayLabel:t,clearLabel:r}}}),Kk={key:0,class:"p-datepicker-header flex items-center justify-between mb-1.5"},qk=["disabled"],Gk=["disabled"],Jk={key:0,class:"p-datepicker-weekheader grid [grid-template-columns:var(--popout-column-definition)] text-[12px] text-slate-400 font-medium mb-1.5"},Yk=["disabled","onClick"],Xk={key:1,class:"p-datepicker-buttonbar mt-2 pt-2 border-t border-slate-200 flex items-center justify-between"};function Zk(n,e,t,r,o,i){const l=s.resolveComponent("ChevronLeft"),a=s.resolveComponent("ChevronRight");return s.openBlock(),s.createElementBlock("div",{class:s.normalizeClass(["p-datepicker-panel p-component text-center text-slate-700 overflow-x-hidden bg-white border border-slate-200 rounded-xl shadow-[0_4px_12px_rgba(0,0,0,0.1)] p-2",n.viewMode==="month"||n.viewMode==="year"?"w-[182px] min-w-[182px]":"w-[268px] min-w-[182px]"]),style:s.normalizeStyle({"--popout-column-definition":`repeat(${n.columnCount}, 1fr)`}),onMousedown:e[5]||(e[5]=s.withModifiers(()=>{},["prevent"]))},[n.hideHeader?s.createCommentVNode("",!0):(s.openBlock(),s.createElementBlock("div",Kk,[s.createElementVNode("button",{class:"p-datepicker-prev-button inline-flex items-center justify-center size-8 rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300 disabled:hover:bg-transparent",disabled:n.leftDisabled,onClick:e[0]||(e[0]=s.withModifiers(c=>n.$emit("left"),["stop","prevent"]))},[s.renderSlot(n.$slots,"arrow-left",{},()=>[s.createVNode(l,{class:"h-3.5 w-3.5"})])],8,qk),(s.openBlock(),s.createBlock(s.resolveDynamicComponent(n.headingClickable?"button":"span"),{class:s.normalizeClass(["p-datepicker-title min-w-0 rounded-md px-2 py-1 text-sm font-semibold leading-snug text-slate-700",n.headingClickable?"hover:bg-slate-100":"",n.viewMode==="month"?"p-datepicker-select-year":"",n.viewMode==="year"?"p-datepicker-decade whitespace-nowrap text-xs px-1":""]),onClick:e[1]||(e[1]=s.withModifiers(c=>n.$emit("heading"),["stop","prevent"]))},{default:s.withCtx(()=>[s.renderSlot(n.$slots,"heading")]),_:3},8,["class"])),s.createElementVNode("button",{class:"p-datepicker-next-button inline-flex items-center justify-center size-8 rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300 disabled:hover:bg-transparent",disabled:n.rightDisabled,onClick:e[2]||(e[2]=s.withModifiers(c=>n.$emit("right"),["stop","prevent"]))},[s.renderSlot(n.$slots,"arrow-right",{},()=>[s.createVNode(a,{class:"h-3.5 w-3.5"})])],8,Gk)])),s.createElementVNode("div",null,["subheading"in n.$slots?(s.openBlock(),s.createElementBlock("div",Jk,[s.renderSlot(n.$slots,"subheading")])):s.createCommentVNode("",!0),s.createElementVNode("div",{class:s.normalizeClass(["p-datepicker-calendar grid [grid-template-columns:var(--popout-column-definition)] text-[12px] text-slate-700",n.viewMode==="month"?"p-datepicker-month-view":"",n.viewMode==="year"?"p-datepicker-year-view":"",n.viewMode==="month"?"gap-y-1":""])},[s.renderSlot(n.$slots,"body",{},()=>[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(n.items,c=>(s.openBlock(),s.createElementBlock("button",{key:c.key,disabled:c.disabled,class:s.normalizeClass(["p-[2px] disabled:text-slate-300"]),onClick:s.withModifiers(d=>n.$emit("elementClick",c.value),["stop","prevent"])},[s.createElementVNode("span",{class:s.normalizeClass([n.viewMode==="month"||n.viewMode==="year"?"inline-flex w-full h-8 items-center justify-center rounded-md text-[13px] font-normal transition-colors":"inline-flex w-8 h-8 items-center justify-center rounded-full text-[13px] font-normal transition-colors",n.viewMode==="month"?"p-datepicker-month":"",n.viewMode==="year"?"p-datepicker-year":"",n.viewMode==="day"?"p-datepicker-day":"",c.selected?"bg-blue-500 text-white font-semibold":"",c.current&&!c.selected&&n.viewMode!=="month"&&n.viewMode!=="year"?"border border-slate-300 font-medium":"",!c.disabled&&!c.selected?"hover:bg-slate-100 hover:text-slate-700":"",!c.current&&!c.selected&&c.disabled?"text-slate-300":""])},s.toDisplayString(c.display),3)],8,Yk))),128))])],2),s.renderSlot(n.$slots,"after-calendar"),n.showButtonBar?(s.openBlock(),s.createElementBlock("div",Xk,[s.createElementVNode("button",{type:"button",class:"p-datepicker-today-button text-xs font-medium text-slate-500 hover:text-slate-700 transition-colors px-1.5 py-1 rounded-md hover:bg-slate-100",onClick:e[3]||(e[3]=s.withModifiers(c=>n.$emit("today"),["stop","prevent"]))},s.toDisplayString(n.todayLabel),1),s.createElementVNode("button",{type:"button",class:"p-datepicker-clear-button text-xs font-medium text-slate-500 hover:text-slate-700 transition-colors px-1.5 py-1 rounded-md hover:bg-slate-100",onClick:e[4]||(e[4]=s.withModifiers(c=>n.$emit("clear"),["stop","prevent"]))},s.toDisplayString(n.clearLabel),1)])):s.createCommentVNode("",!0)])],38)}const ti=Ne(Wk,[["render",Zk]]),Qk=s.defineComponent({components:{PickerPopup:ti},emits:{"update:pageDate":n=>bt(n),select:n=>bt(n)},props:{selected:{type:Date,required:!1},pageDate:{type:Date,required:!0},lowerLimit:{type:Date,required:!1},upperLimit:{type:Date,required:!1}},setup(n,{emit:e}){const t=s.computed(()=>Tk(n.pageDate)),r=s.computed(()=>Bk(n.pageDate)),o=(f,p,h)=>!p&&!h?!0:!(p&&sn(f)<sn(p)||h&&sn(f)>sn(h)),i=s.computed(()=>Vk({start:t.value,end:r.value}).map(f=>({value:f,key:String(sn(f)),display:sn(f),selected:!!n.selected&&sn(f)===sn(n.selected),disabled:!o(f,n.lowerLimit,n.upperLimit)}))),l=s.computed(()=>{const f=sn(t.value),p=sn(r.value);return`${f} - ${p}`}),a=s.computed(()=>n.lowerLimit&&(Zs(n.lowerLimit)===Zs(n.pageDate)||Vo(n.pageDate,n.lowerLimit))),c=s.computed(()=>n.upperLimit&&(Zs(n.upperLimit)===Zs(n.pageDate)||$o(n.pageDate,n.upperLimit)));return{years:i,heading:l,leftDisabled:a,rightDisabled:c,previousPage:()=>e("update:pageDate",Tu(n.pageDate,10)),nextPage:()=>e("update:pageDate",Xs(n.pageDate,10))}}});function ew(n,e,t,r,o,i){const l=s.resolveComponent("picker-popup");return s.openBlock(),s.createBlock(l,{columnCount:2,leftDisabled:n.leftDisabled,rightDisabled:n.rightDisabled,items:n.years,viewMode:"year",onLeft:n.previousPage,onRight:n.nextPage,onElementClick:e[0]||(e[0]=a=>n.$emit("select",a))},{heading:s.withCtx(()=>[s.createTextVNode(s.toDisplayString(n.heading),1)]),_:1},8,["leftDisabled","rightDisabled","items","onLeft","onRight"])}const tw=Ne(Qk,[["render",ew]]),nw=s.defineComponent({components:{PickerPopup:ti},emits:{"update:pageDate":n=>bt(n),select:n=>bt(n),back:()=>!0},props:{selected:{type:Date,required:!1},pageDate:{type:Date,required:!0},format:{type:String,required:!1,default:"LLL"},lowerLimit:{type:Date,required:!1},upperLimit:{type:Date,required:!1}},setup(n,{emit:e}){const t=s.computed(()=>Bu(n.pageDate)),r=s.computed(()=>Nu(n.pageDate)),o=s.computed(()=>p=>Lo(p,n.format)),i=(p,h,m)=>!h&&!m?!0:!(h&&Vo(p,ka(h))||m&&$o(p,wa(m))),l=s.computed(()=>Dk({start:t.value,end:r.value}).map(p=>({value:p,display:o.value(p),key:o.value(p),selected:!!n.selected&&Ca(n.selected,p),disabled:!i(p,n.lowerLimit,n.upperLimit)}))),a=s.computed(()=>sn(t.value)),c=s.computed(()=>n.lowerLimit&&(Du(n.lowerLimit,n.pageDate)||Vo(n.pageDate,n.lowerLimit))),d=s.computed(()=>n.upperLimit&&(Du(n.upperLimit,n.pageDate)||$o(n.pageDate,n.upperLimit)));return{months:l,heading:a,leftDisabled:c,rightDisabled:d,previousPage:()=>e("update:pageDate",Tu(n.pageDate,1)),nextPage:()=>e("update:pageDate",Xs(n.pageDate,1))}}});function rw(n,e,t,r,o,i){const l=s.resolveComponent("picker-popup");return s.openBlock(),s.createBlock(l,{headingClickable:"",columnCount:3,items:n.months,leftDisabled:n.leftDisabled,rightDisabled:n.rightDisabled,viewMode:"month",onLeft:n.previousPage,onRight:n.nextPage,onHeading:e[0]||(e[0]=a=>n.$emit("back")),onElementClick:e[1]||(e[1]=a=>n.$emit("select",a))},{heading:s.withCtx(()=>[s.createTextVNode(s.toDisplayString(n.heading),1)]),_:1},8,["items","leftDisabled","rightDisabled","onLeft","onRight"])}const ow=Ne(nw,[["render",rw]]),sw=s.defineComponent({components:{PickerPopup:ti},emits:{"update:pageDate":n=>bt(n),select:n=>bt(n),back:()=>!0,today:()=>!0,clear:()=>!0},props:{selected:{type:Date,required:!1},pageDate:{type:Date,required:!0},format:{type:String,required:!1,default:"dd"},headingFormat:{type:String,required:!1,default:"LLLL yyyy"},weekdayFormat:{type:String,required:!1,default:"EE"},weekStartsOn:{type:Number,required:!1,default:1,validator:n=>typeof n=="number"&&Number.isInteger(n)&&n>=0&&n<=6},customWeekdays:{type:Array,required:!1},lowerLimit:{type:Date,required:!1},upperLimit:{type:Date,required:!1},disabledDates:{type:Object,required:!1},allowOutsideInterval:{type:Boolean,required:!1,default:!1}},setup(n,{emit:e}){const t=s.computed(()=>y=>b=>Lo(b,y)),r=s.computed(()=>ka(n.pageDate)),o=s.computed(()=>wa(n.pageDate)),i=s.computed(()=>({start:r.value,end:o.value})),l=s.computed(()=>({start:va(r.value,n.weekStartsOn),end:$k(o.value,n.weekStartsOn)})),a=s.computed(()=>n.customWeekdays?.length===7?n.customWeekdays:null),c=s.computed(()=>{const y=n.weekStartsOn,b=a.value;if(b)return Array.from({length:7}).map((v,E)=>b[(y+E)%7]);const w=t.value(n.weekdayFormat);return Array.from(Array(7)).map((v,E)=>(y+E)%7).map(v=>Lk(new Date,v,n.weekStartsOn)).map(w)}),d=(y,b,w,v)=>v?.dates?.some(E=>Qs(y,E))||v?.predicate?.(y)?!1:!b&&!w?!0:!(b&&Vo(y,Er(b))||w&&$o(y,Do(w))),u=s.computed(()=>{const y=new Date,b=t.value(n.format);return Nk(l.value).map(w=>({value:w,display:b(w),selected:!!n.selected&&Qs(n.selected,w),current:Qs(y,w),disabled:!n.allowOutsideInterval&&!Ok(w,i.value)||!d(w,n.lowerLimit,n.upperLimit,n.disabledDates),key:t.value("yyyy-MM-dd")(w)}))}),f=s.computed(()=>t.value(n.headingFormat)(n.pageDate)),p=s.computed(()=>n.lowerLimit&&(Ca(n.lowerLimit,n.pageDate)||Vo(n.pageDate,n.lowerLimit))),h=s.computed(()=>n.upperLimit&&(Ca(n.upperLimit,n.pageDate)||$o(n.pageDate,n.upperLimit)));return{weekDays:c,days:u,heading:f,leftDisabled:p,rightDisabled:h,previousPage:()=>e("update:pageDate",_k(n.pageDate)),nextPage:()=>e("update:pageDate",xa(n.pageDate,1))}}});function iw(n,e,t,r,o,i){const l=s.resolveComponent("picker-popup");return s.openBlock(),s.createBlock(l,{headingClickable:"",leftDisabled:n.leftDisabled,rightDisabled:n.rightDisabled,items:n.days,showButtonBar:!0,viewMode:"day",onLeft:n.previousPage,onRight:n.nextPage,onHeading:e[0]||(e[0]=a=>n.$emit("back")),onElementClick:e[1]||(e[1]=a=>n.$emit("select",a)),onToday:e[2]||(e[2]=a=>n.$emit("today")),onClear:e[3]||(e[3]=a=>n.$emit("clear"))},s.createSlots({heading:s.withCtx(()=>[s.createTextVNode(s.toDisplayString(n.heading),1)]),subheading:s.withCtx(()=>[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(n.weekDays,(a,c)=>(s.openBlock(),s.createElementBlock("span",{key:a,class:s.normalizeClass(`v3dp__subheading__weekday__${c}`)},s.toDisplayString(a),3))),128))]),_:2},[n.$slots["after-calendar"]?{name:"after-calendar",fn:s.withCtx(()=>[s.renderSlot(n.$slots,"after-calendar")]),key:"0"}:void 0]),1032,["leftDisabled","rightDisabled","items","onLeft","onRight"])}const lw=Ne(sw,[["render",iw]]),aw=s.defineComponent({components:{PickerPopup:ti,ChevronUp:Y.ChevronUp,ChevronDown:Y.ChevronDown},emits:{select:n=>bt(n),back:()=>!0},props:{selected:{type:Date,required:!1},pageDate:{type:Date,required:!0},visible:{type:Boolean,required:!0},disabledTime:{type:Object,required:!1},embedded:{type:Boolean,default:!1}},setup(n,{emit:e}){const t=s.computed(()=>n.pageDate??n.selected),r=s.ref(t.value.getHours()),o=s.ref(t.value.getMinutes());s.watch(()=>n.selected,h=>{let m=0,g=0;h&&(m=h.getHours(),g=h.getMinutes()),r.value=m,o.value=g});const i=(h,m)=>{const g=Pk(new Date(t.value.getTime()),{hours:h,minutes:m,seconds:0});f(g)&&(r.value=h,o.value=m,e("select",g))},l=(h,m)=>h<0?m:h>m?0:h,a=()=>i(l(r.value+1,23),o.value),c=()=>i(l(r.value-1,23),o.value),d=()=>i(r.value,l(o.value+1,59)),u=()=>i(r.value,l(o.value-1,59)),f=h=>!(n.disabledTime?.dates?.some(m=>Vu(h,m)&&Ik(h,m))||n.disabledTime?.predicate?.(h));return{hours:r,minutes:o,padStartZero:h=>`0${h}`.substr(-2),isEnabled:f,incrementHours:a,decrementHours:c,incrementMinutes:d,decrementMinutes:u}}}),cw={key:0,class:"p-datepicker-time-picker mt-2 pt-2 border-t border-slate-200 flex items-center justify-center gap-2 py-1"},dw={class:"p-datepicker-hour-picker flex flex-col items-center gap-1"},uw={class:"min-w-8 text-center text-sm font-medium text-slate-700"},fw={class:"p-datepicker-minute-picker flex flex-col items-center gap-1"},pw={class:"min-w-8 text-center text-sm font-medium text-slate-700"},hw={class:"col-span-2"},mw={class:"p-datepicker-time-picker flex items-center justify-center gap-2 py-1"},gw={class:"p-datepicker-hour-picker flex flex-col items-center gap-1"},yw={class:"min-w-8 text-center text-sm font-medium text-slate-700"},bw={class:"p-datepicker-minute-picker flex flex-col items-center gap-1"},kw={class:"min-w-8 text-center text-sm font-medium text-slate-700"};function ww(n,e,t,r,o,i){const l=s.resolveComponent("ChevronUp"),a=s.resolveComponent("ChevronDown"),c=s.resolveComponent("picker-popup");return n.embedded?(s.openBlock(),s.createElementBlock("div",cw,[s.createElementVNode("div",dw,[s.createElementVNode("button",{type:"button",class:"p-datepicker-increment-button inline-flex size-8 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300",onClick:e[0]||(e[0]=s.withModifiers((...d)=>n.incrementHours&&n.incrementHours(...d),["stop","prevent"]))},[s.createVNode(l,{class:"h-3.5 w-3.5"})]),s.createElementVNode("span",uw,s.toDisplayString(n.padStartZero(n.hours)),1),s.createElementVNode("button",{type:"button",class:"p-datepicker-decrement-button inline-flex size-8 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300",onClick:e[1]||(e[1]=s.withModifiers((...d)=>n.decrementHours&&n.decrementHours(...d),["stop","prevent"]))},[s.createVNode(a,{class:"h-3.5 w-3.5"})])]),e[8]||(e[8]=s.createElementVNode("div",{class:"text-base font-medium text-slate-500"},":",-1)),s.createElementVNode("div",fw,[s.createElementVNode("button",{type:"button",class:"p-datepicker-increment-button inline-flex size-8 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300",onClick:e[2]||(e[2]=s.withModifiers((...d)=>n.incrementMinutes&&n.incrementMinutes(...d),["stop","prevent"]))},[s.createVNode(l,{class:"h-3.5 w-3.5"})]),s.createElementVNode("span",pw,s.toDisplayString(n.padStartZero(n.minutes)),1),s.createElementVNode("button",{type:"button",class:"p-datepicker-decrement-button inline-flex size-8 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300",onClick:e[3]||(e[3]=s.withModifiers((...d)=>n.decrementMinutes&&n.decrementMinutes(...d),["stop","prevent"]))},[s.createVNode(a,{class:"h-3.5 w-3.5"})])])])):(s.openBlock(),s.createBlock(c,{key:1,hideHeader:!0,columnCount:2,viewMode:"time"},{body:s.withCtx(()=>[s.createElementVNode("div",hw,[s.createElementVNode("div",mw,[s.createElementVNode("div",gw,[s.createElementVNode("button",{type:"button",class:"p-datepicker-increment-button inline-flex size-8 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300",onClick:e[4]||(e[4]=s.withModifiers((...d)=>n.incrementHours&&n.incrementHours(...d),["stop","prevent"]))},[s.createVNode(l,{class:"h-3.5 w-3.5"})]),s.createElementVNode("span",yw,s.toDisplayString(n.padStartZero(n.hours)),1),s.createElementVNode("button",{type:"button",class:"p-datepicker-decrement-button inline-flex size-8 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300",onClick:e[5]||(e[5]=s.withModifiers((...d)=>n.decrementHours&&n.decrementHours(...d),["stop","prevent"]))},[s.createVNode(a,{class:"h-3.5 w-3.5"})])]),e[9]||(e[9]=s.createElementVNode("div",{class:"text-base font-medium text-slate-500"},":",-1)),s.createElementVNode("div",bw,[s.createElementVNode("button",{type:"button",class:"p-datepicker-increment-button inline-flex size-8 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300",onClick:e[6]||(e[6]=s.withModifiers((...d)=>n.incrementMinutes&&n.incrementMinutes(...d),["stop","prevent"]))},[s.createVNode(l,{class:"h-3.5 w-3.5"})]),s.createElementVNode("span",kw,s.toDisplayString(n.padStartZero(n.minutes)),1),s.createElementVNode("button",{type:"button",class:"p-datepicker-decrement-button inline-flex size-8 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300",onClick:e[7]||(e[7]=s.withModifiers((...d)=>n.decrementMinutes&&n.decrementMinutes(...d),["stop","prevent"]))},[s.createVNode(a,{class:"h-3.5 w-3.5"})])])])])]),_:1}))}const xw=Ne(aw,[["render",ww]]),ni=["time","day","month","year"],vw=(n,e,t=void 0)=>{let r=t||new Date;const o=Rk([n,r]);o&&(r=o);const i=Fk([e,r]);return i&&(r=i),r},Cw=s.defineComponent({components:{YearPicker:tw,MonthPicker:ow,DayPicker:lw,TimePicker:xw,CalendarDays:Y.CalendarDays,Clock3:Y.Clock3,X:Y.X},inheritAttrs:!1,props:{placeholder:{type:String,default:""},modelValue:{type:Date,required:!1},disabledDates:{type:Object,required:!1},allowOutsideInterval:{type:Boolean,required:!1,default:!1},disabledTime:{type:Object,required:!1},upperLimit:{type:Date,required:!1},lowerLimit:{type:Date,required:!1},startingView:{type:String,required:!1,default:"day",validate:n=>typeof n=="string"&&ni.includes(n)},startingViewDate:{type:Date,required:!1,default:()=>new Date},dayPickerHeadingFormat:{type:String,required:!1,default:"LLLL yyyy"},monthListFormat:{type:String,required:!1,default:"LLL"},weekdayFormat:{type:String,required:!1,default:"EE"},dayFormat:{type:String,required:!1,default:"dd"},inputFormat:{type:String,required:!1,default:"yyyy-MM-dd"},weekDayNames:{type:Array,required:!1},weekStartsOn:{type:Number,required:!1,default:1,validator:n=>[0,1,2,3,4,5,6].includes(n)},disabled:{type:Boolean,required:!1,default:!1},clearable:{type:Boolean,required:!1,default:!1},typeable:{type:Boolean,required:!1,default:!1},minimumView:{type:String,required:!1,default:"day",validate:n=>typeof n=="string"&&ni.includes(n)}},emits:{"update:modelValue":n=>n==null||bt(n),decadePageChanged:n=>!0,yearPageChanged:n=>!0,monthPageChanged:n=>!0,opened:()=>!0,closed:()=>!0},setup(n,{emit:e}){const t=s.ref("none"),r=s.ref(n.startingViewDate),o=s.ref(null),i=s.ref(null),l=s.ref(null),a=s.ref({}),c=s.ref(!1),d=s.ref(!1),u=s.ref(!1);let f=null;const p=s.ref(""),h=oe=>{const pe=oe.replace(/[a-zA-Z]/g,"0");return/0/.test(pe)?pe:""},m=s.computed(()=>h(n.inputFormat));let g=null,y=null;const b=()=>{g?.destroy(),g=null},w=async()=>{if(!y){const{default:oe}=await Promise.resolve().then(()=>xi);y=oe}return y},v=()=>{g&&g.value!==p.value&&(g.value=p.value??"")},E=oe=>{const pe=oe&&bt(oe)?Lo(oe,n.inputFormat):"";p.value!==pe&&(p.value=pe),v()},N=async()=>{if(b(),!i.value||!m.value)return;g=(await w())(i.value,{mask:m.value,lazy:!0,overwrite:!1}),v()};s.watch(()=>n.modelValue,oe=>{d.value&&n.typeable||E(oe)},{immediate:!0}),s.watch(()=>n.inputFormat,()=>{d.value&&n.typeable||E(n.modelValue)}),s.onMounted(()=>{u.value=!0,m.value&&s.nextTick(()=>{N()})}),s.onBeforeUnmount(()=>{b()}),s.watch(m,oe=>{oe?s.nextTick(()=>{N()}):b()});const R=s.computed(()=>t.value!=="none"),T=s.computed(()=>n.startingView==="time"&&n.minimumView==="time"),M=s.computed(()=>n.startingView==="day"&&n.minimumView==="time"),_=oe=>{n.disabled||(R.value||(r.value=n.modelValue||vw(n.lowerLimit,n.upperLimit,r.value),e("opened")),t.value=oe,s.nextTick(()=>ot()))},A=()=>{R.value&&(f!==null&&(cancelAnimationFrame(f),f=null),t.value="none",e("closed"))},L=(oe="none")=>{oe==="none"?A():_(oe)};s.watchEffect(()=>{n.disabled&&A()});const z=(oe,pe)=>{r.value=pe,oe==="year"?e("decadePageChanged",pe):oe==="month"?e("yearPageChanged",pe):oe==="day"&&e("monthPageChanged",pe)},Z=oe=>{r.value=oe,n.minimumView==="year"?(A(),E(oe),e("update:modelValue",oe)):_("month")},D=oe=>{r.value=oe,n.minimumView==="month"?(A(),E(oe),e("update:modelValue",oe)):_("day")},P=oe=>{const pe=M.value?(()=>{const _e=n.modelValue||r.value||new Date,Te=new Date(oe);return Te.setHours(_e.getHours(),_e.getMinutes(),0,0),Te})():oe;r.value=pe,n.minimumView==="day"?(A(),E(pe),e("update:modelValue",pe)):M.value?(E(pe),e("update:modelValue",pe),_("day")):_("time")},ne=oe=>{E(oe),e("update:modelValue",oe)},U=()=>{P(new Date)},K=()=>{n.clearable&&(A(),E(null),e("update:modelValue",null),r.value=n.startingViewDate)},X=()=>{R.value||_(ae.value)},le=()=>{d.value=!0,c.value=!1,_(ae.value)},H=()=>{d.value=!1,n.typeable&&I({closeOnSuccess:!1,revertOnInvalid:!0})},$=oe=>{const pe=oe.target;if(p.value=pe?.value??"",!n.typeable)return;const _e=Lu(p.value,n.inputFormat);_e&&p.value===Lo(_e,n.inputFormat)&&(r.value=_e)},I=({closeOnSuccess:oe,revertOnInvalid:pe})=>{const _e=i.value?.value??p.value,Te=Lu(_e,n.inputFormat);return!!Te&&_e===Lo(Te,n.inputFormat)&&Te?(r.value=Te,E(Te),e("update:modelValue",Te),oe&&A(),!0):(E(n.modelValue),!1)},te=oe=>{const pe=oe.keyCode?oe.keyCode:oe.which,_e=pe===27,Te=pe===13;if(_e){A(),i.value?.blur();return}n.typeable&&Te&&(I({closeOnSuccess:!0,revertOnInvalid:!0})||i.value?.focus())},ae=s.computed(()=>{const oe=ni.indexOf(n.startingView),pe=ni.indexOf(n.minimumView);return oe<pe?n.minimumView:n.startingView}),re=s.computed(()=>n.weekDayNames?.length===7?n.weekDayNames:void 0),ge=()=>n.startingView==="time"&&n.minimumView==="time"?null:_("day"),Ee=()=>{if(!i.value||!l.value)return;const oe=4,pe=8,_e=i.value.getBoundingClientRect(),Te=l.value.getBoundingClientRect(),Ye=l.value.firstElementChild?.getBoundingClientRect(),Dt=window.innerWidth,Pe=window.innerHeight,qe=window.scrollX||window.pageXOffset,tn=window.scrollY||window.pageYOffset,W=Math.max(160,Pe-pe*2),Q=Math.min(Te.height||0,W),de=Pe-_e.bottom-oe-pe,O=_e.top-oe-pe,C=de<Q&&O>de;let V=C?_e.top-oe-Q:_e.bottom+oe;V=Math.max(pe,Math.min(V,Pe-pe-Q));const j=Ye?.width||Te.width||268;let ie=_e.left;ie+j>Dt-pe&&(ie=Dt-pe-j),ie<pe&&(ie=pe);const Me=C?Math.max(120,_e.top-oe-pe):Math.max(120,Pe-_e.bottom-oe-pe);a.value={position:"absolute",top:`${Math.round(V+tn)}px`,left:`${Math.round(ie+qe)}px`,maxHeight:`${Math.round(Math.min(W,Me))}px`,overflowX:"hidden",overflowY:"auto",zIndex:"2147483000"},M.value&&t.value==="day"&&(a.value.minWidth="345px")},xe=(oe,pe)=>oe.bottom>pe.top&&oe.top<pe.bottom&&oe.right>pe.left&&oe.left<pe.right,Ie=oe=>{const pe=[];let _e=oe.parentElement;for(;_e;){const Te=window.getComputedStyle(_e),dt=Te.overflowY,Ye=Te.overflowX,Dt=["auto","scroll","hidden","clip"].includes(dt),Pe=["auto","scroll","hidden","clip"].includes(Ye);(Dt||Pe)&&pe.push(_e),_e=_e.parentElement}return pe},je=()=>{if(!i.value)return!1;const oe=i.value.getBoundingClientRect(),pe=new DOMRect(0,0,window.innerWidth,window.innerHeight);return xe(oe,pe)?Ie(i.value).every(Te=>xe(oe,Te.getBoundingClientRect())):!1},Fe=()=>{if(R.value){if(!je()){c.value=!0,A();return}ot();return}c.value&&document.activeElement===i.value&&je()&&(c.value=!1,_(ae.value))};s.watch(t,()=>{R.value&&s.nextTick(()=>ot())});const ot=()=>{Ee(),f!==null&&cancelAnimationFrame(f),f=requestAnimationFrame(()=>{Ee(),f=null})};s.onMounted(()=>{window.addEventListener("resize",Fe),window.addEventListener("scroll",Fe,!0),document.addEventListener("pointerdown",We,!0)}),s.onBeforeUnmount(()=>{f!==null&&(cancelAnimationFrame(f),f=null),window.removeEventListener("resize",Fe),window.removeEventListener("scroll",Fe,!0),document.removeEventListener("pointerdown",We,!0)});const We=oe=>{if(t.value==="none")return;const pe=oe.target;if(!pe)return;const _e=!!o.value?.contains(pe),Te=!!l.value?.contains(pe);!_e&&!Te&&(c.value=!1,A())};return{rootRef:o,blur:H,focus:le,click:X,input:p,inputRef:i,pageDate:r,renderView:L,updatePageDate:z,selectYear:Z,selectMonth:D,selectDay:P,selectToday:U,selectTime:ne,keyUp:te,onInput:$,isTimeOnlyMode:T,isDateTimeMode:M,normalizedWeekdayNames:re,viewShown:t,goBackFromTimepicker:ge,clearModelValue:K,initialView:ae,log:oe=>console.log(oe),popupAnchorStyle:a,popupRef:l,isMounted:u}}}),Sw={ref:"rootRef",class:"relative"},Ew={class:"p-datepicker p-component p-inputwrapper relative"},Mw=["readonly","value","placeholder","disabled","tabindex"],Aw={class:"p-datepicker-input-icon-container absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none text-slate-400"},_w={class:"absolute right-8 top-1/2 -translate-y-1/2"};function Tw(n,e,t,r,o,i){const l=s.resolveComponent("Clock3"),a=s.resolveComponent("CalendarDays"),c=s.resolveComponent("X"),d=s.resolveComponent("year-picker"),u=s.resolveComponent("month-picker"),f=s.resolveComponent("time-picker"),p=s.resolveComponent("day-picker");return s.openBlock(),s.createElementBlock("div",Sw,[s.createElementVNode("div",Ew,[s.createElementVNode("input",s.mergeProps({type:"text",ref:"inputRef",class:"p-inputtext p-component p-datepicker-input",readonly:!n.typeable,value:n.input},n.$attrs,{placeholder:n.placeholder,disabled:n.disabled,tabindex:n.disabled?-1:0,onInput:e[0]||(e[0]=(...h)=>n.onInput&&n.onInput(...h)),onKeyup:e[1]||(e[1]=(...h)=>n.keyUp&&n.keyUp(...h)),onBlur:e[2]||(e[2]=(...h)=>n.blur&&n.blur(...h)),onFocus:e[3]||(e[3]=(...h)=>n.focus&&n.focus(...h)),onClick:e[4]||(e[4]=(...h)=>n.click&&n.click(...h))}),null,16,Mw),s.createElementVNode("span",Aw,[n.isTimeOnlyMode?(s.openBlock(),s.createBlock(l,{key:0,class:"h-4 w-4"})):(s.openBlock(),s.createBlock(a,{key:1,class:"h-4 w-4"}))]),s.withDirectives(s.createElementVNode("div",_w,[s.renderSlot(n.$slots,"clear",{onClear:n.clearModelValue},()=>[s.createElementVNode("button",{type:"button",class:"inline-flex h-5 w-5 items-center justify-center rounded-full text-slate-400 transition-colors hover:bg-slate-100 hover:text-slate-600 focus:outline-none focus:ring-2 focus:ring-blue-500/30","aria-label":"Очистити дату",onClick:e[5]||(e[5]=h=>n.clearModelValue())},[s.createVNode(c,{class:"h-3 w-3"})])])],512),[[s.vShow,n.clearable&&n.modelValue]])]),n.isMounted?(s.openBlock(),s.createBlock(s.Teleport,{key:0,to:"body"},[s.withDirectives(s.createElementVNode("div",{ref:"popupRef",style:s.normalizeStyle(n.popupAnchorStyle)},[s.withDirectives(s.createVNode(d,{pageDate:n.pageDate,"onUpdate:pageDate":e[6]||(e[6]=h=>n.updatePageDate("year",h)),selected:n.modelValue,lowerLimit:n.lowerLimit,upperLimit:n.upperLimit,onSelect:n.selectYear},null,8,["pageDate","selected","lowerLimit","upperLimit","onSelect"]),[[s.vShow,n.viewShown==="year"]]),s.withDirectives(s.createVNode(u,{pageDate:n.pageDate,"onUpdate:pageDate":e[7]||(e[7]=h=>n.updatePageDate("month",h)),selected:n.modelValue,onSelect:n.selectMonth,lowerLimit:n.lowerLimit,upperLimit:n.upperLimit,format:n.monthListFormat,onBack:e[8]||(e[8]=h=>n.viewShown="year")},null,8,["pageDate","selected","onSelect","lowerLimit","upperLimit","format"]),[[s.vShow,n.viewShown==="month"]]),s.withDirectives(s.createVNode(p,{pageDate:n.pageDate,"onUpdate:pageDate":e[9]||(e[9]=h=>n.updatePageDate("day",h)),selected:n.modelValue,weekStartsOn:n.weekStartsOn,lowerLimit:n.lowerLimit,upperLimit:n.upperLimit,headingFormat:n.dayPickerHeadingFormat,disabledDates:n.disabledDates,weekdayFormat:n.weekdayFormat,"allow-outside-interval":n.allowOutsideInterval,format:n.dayFormat,"custom-weekdays":n.normalizedWeekdayNames,onSelect:n.selectDay,onToday:n.selectToday,onClear:n.clearModelValue,onBack:e[10]||(e[10]=h=>n.viewShown="month")},s.createSlots({_:2},[n.isDateTimeMode?{name:"after-calendar",fn:s.withCtx(()=>[s.createVNode(f,{embedded:!0,pageDate:n.pageDate,visible:n.viewShown==="day"&&n.isDateTimeMode,selected:n.modelValue,disabledTime:n.disabledTime,onSelect:n.selectTime,onBack:n.goBackFromTimepicker},null,8,["pageDate","visible","selected","disabledTime","onSelect","onBack"])]),key:"0"}:void 0]),1032,["pageDate","selected","weekStartsOn","lowerLimit","upperLimit","headingFormat","disabledDates","weekdayFormat","allow-outside-interval","format","custom-weekdays","onSelect","onToday","onClear"]),[[s.vShow,n.viewShown==="day"]]),s.withDirectives(s.createVNode(f,{pageDate:n.pageDate,visible:n.viewShown==="time",selected:n.modelValue,disabledTime:n.disabledTime,onSelect:n.selectTime,onBack:n.goBackFromTimepicker},null,8,["pageDate","visible","selected","disabledTime","onSelect","onBack"]),[[s.vShow,n.viewShown==="time"&&!n.isDateTimeMode]])],4),[[s.vShow,n.viewShown!=="none"]])])):s.createCommentVNode("",!0)],512)}const Bw=Ne(Cw,[["render",Tw]]),Iu=Ne(s.defineComponent({__name:"vs-input-date2",props:{clearable:{type:Boolean,default:!0},now:{type:Boolean},editable:{type:Boolean,default:!0},time:{type:Boolean},isInfinity:{type:Boolean},dateFormat:{},mode:{default:"date"},weekStart:{},dayNames:{},maxDaysFromNow:{},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{default:""},maxlength:{},minlength:{}},emits:["update:modelValue"],setup(n,{emit:e}){const t=n,r=e,{inputClass:o}=Vt(t.style),i=s.getCurrentInstance(),l=s.computed(()=>t.mode?t.mode:t.time?"datetime":"date"),a=s.computed(()=>["py-1.5 px-3 block w-full placeholder:text-[#767f8f] bg-white",o.value,t.customClass,{"!border-red-600":t.error}]),c=s.computed(()=>!t.modelValue&&t.now?new Date:null),d=s.computed({get:()=>M(t.modelValue??c.value,l.value)||void 0,set:H=>r("update:modelValue",_(H,l.value))}),u=["Пн","Вт","Ср","Чт","Пт","Сб","Нд"],f=s.computed(()=>{if(t.dayNames?.length)return t.dayNames.length===7?t.dayNames:u}),p=s.computed(()=>{const H=t.weekStart,$=typeof H=="string"?Number(H):H;return $===void 0||Number.isNaN($)?1:Math.min(6,Math.max(0,$))}),h=s.computed(()=>{const H=t.maxDaysFromNow;if(H==null||H==="")return;const $=typeof H=="string"?Number(H):H;if(!Number.isFinite($)||$<0)return;const I=new Date;return I.setHours(0,0,0,0),I.setDate(I.getDate()+$),I.setHours(23,59,59,999),I}),m=s.computed(()=>{switch(l.value){case"time":return{startingView:"time",minimumView:"time"};case"month":return{startingView:"month",minimumView:"month"};case"year":return{startingView:"year",minimumView:"year"};case"datetime":return{startingView:"day",minimumView:"time"};default:return{startingView:"day",minimumView:"day"}}}),g={date:"dd.MM.yyyy",datetime:"dd.MM.yyyy HH:mm",month:"MM.yyyy",time:"HH:mm",week:"dd.MM.yyyy",year:"yyyy"};function y(){const H=i?.appContext?.config?.globalProperties?.$i18n?.locale;if(typeof H=="string"&&H)return H;if(H&&typeof H=="object"&&"value"in H&&H.value)return String(H.value);if(typeof localStorage<"u"){const $=localStorage.getItem("locale")||localStorage.getItem("language");if($)return $}return"uk"}function b(){const $=i?.appContext?.config?.globalProperties?.$settings?.dateFormat;if(!$)return"";if(typeof $=="string")return $;if(typeof $=="object"){const I=y();return $[I]||$[I.split("-")[0]]||$.uk||$.en||""}return""}function w(H){return H?H.replaceAll("dd","__DAY2__").replaceAll("d","__DAY1__").replaceAll("mm","__MONTH2__").replaceAll("m","__MONTH1__").replaceAll("yy","__YEAR2__").replaceAll("y","__YEAR1__").replaceAll("__DAY2__","dd").replaceAll("__DAY1__","d").replaceAll("__MONTH2__","MM").replaceAll("__MONTH1__","M").replaceAll("__YEAR2__","yy").replaceAll("__YEAR1__","yyyy"):""}const v=s.computed(()=>{const H=g[l.value]||"dd.MM.yyyy";if(l.value==="time")return H;const $=t.dateFormat||b();if(!$)return H;const I=w($);return I?l.value==="datetime"?`${I} HH:mm`:I:H});function E(H,$){return H?$==="week"?"рррр-тиждень":H.replaceAll("yyyy","рррр").replaceAll("yy","рр").replaceAll("MM","мм").replaceAll("M","м").replaceAll("dd","дд").replaceAll("d","д").replaceAll("HH","гг").replaceAll("H","г").replaceAll("mm",$==="time"||$==="datetime"?"хх":"мм"):""}const N={date:"дд.мм.рррр",datetime:"дд.мм.рррр гг:хх",month:"мм.рррр",week:"рррр-тиждень",time:"гг:хх",year:"рррр"},R=s.computed(()=>{if(t.placeholder)return t.placeholder;const H=l.value;return E(v.value,H)||N[H]||""}),T=s.ref(!1);s.watch(()=>t.modelValue,H=>{H?T.value=!0:t.now||(T.value=!1)},{immediate:!0}),s.watchEffect(()=>{t.now&&!t.modelValue&&!T.value&&(r("update:modelValue",_(new Date,l.value)),T.value=!0)}),s.watch(v,()=>{r("update:modelValue",_(d.value,l.value))});function M(H,$){if(!H)return null;if(H instanceof Date&&!Number.isNaN(H.getTime()))return H;if(typeof H!="string")return null;switch($){case"datetime":return Z(H);case"time":return ne(H);case"month":return D(H);case"year":return P(H);case"week":return U(H);case"date":default:return z(H)}}function _(H,$){if(!H)return null;const I=H instanceof Date?H:M(H,$);if(!I)return null;switch($){case"datetime":return`${A(I)}T${L(I)}`;case"time":return L(I);case"month":return`${I.getFullYear()}-${le(I.getMonth()+1)}`;case"year":return`${I.getFullYear()}`;case"week":{const{year:te,week:ae}=K(I);return`${te}-W${le(ae)}`}case"date":default:return A(I)}}function A(H){return`${H.getFullYear()}-${le(H.getMonth()+1)}-${le(H.getDate())}`}function L(H){return`${le(H.getHours())}:${le(H.getMinutes())}`}function z(H){const $=H.split("-");if($.length<3)return null;const I=Number($[0]),te=Number($[1]),ae=parseInt($[2],10);return!I||!te||!ae?null:new Date(I,te-1,ae)}function Z(H){const $=H.includes("T")?H:H.replace(" ","T"),I=new Date($);return Number.isNaN(I.getTime())?null:I}function D(H){const[$,I]=H.split("-").map(Number);return!$||Number.isNaN(I)?null:new Date($,(I||1)-1,1)}function P(H){const $=Number(H);return $?new Date($,0,1):null}function ne(H){const $=H.trim().match(/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/);if(!$)return null;const[,I,te,ae]=$,re=new Date;return re.setHours(Number(I),Number(te),Number(ae||0),0),re}function U(H){const $=H.match(/^(\d{4})-W(\d{2})$/);if(!$)return null;const[,I,te]=$,ae=Number(te);return X(Number(I),ae)}function K(H){const $=new Date(Date.UTC(H.getFullYear(),H.getMonth(),H.getDate())),I=$.getUTCDay()||7;$.setUTCDate($.getUTCDate()+4-I);const te=new Date(Date.UTC($.getUTCFullYear(),0,1)),ae=Math.ceil((($.getTime()-te.getTime())/864e5+1)/7);return{year:$.getUTCFullYear(),week:ae}}function X(H,$){if(!H||!$)return null;const I=new Date(H,0,1+($-1)*7),te=I.getDay(),ae=I;return te<=4?ae.setDate(I.getDate()-I.getDay()+1):ae.setDate(I.getDate()+8-I.getDay()),ae}function le(H){return String(H).padStart(2,"0")}return(H,$)=>(s.openBlock(),s.createElementBlock("div",{class:s.normalizeClass(["vs-date-picker",t.customClass])},[s.createVNode(Bw,{modelValue:d.value,"onUpdate:modelValue":$[0]||($[0]=I=>d.value=I),placeholder:R.value,disabled:t.disabled,clearable:t.clearable,typeable:t.editable,"week-day-names":f.value,"week-starts-on":p.value,"starting-view":m.value.startingView,"minimum-view":m.value.minimumView,"input-format":v.value,"upper-limit":h.value,name:t.name,class:s.normalizeClass(a.value)},null,8,["modelValue","placeholder","disabled","clearable","typeable","week-day-names","week-starts-on","starting-view","minimum-view","input-format","upper-limit","name","class"])],2))}}),[["__scopeId","data-v-637c8950"]]),Nw=(n,e)=>{if(!e||!Object.keys(e).length)return n;const[t,r=""]=n.split("?"),o=new URLSearchParams(r);Object.entries(e).forEach(([l,a])=>{a==null||a===""||o.set(l,String(a))});const i=o.toString();return i?`${t}?${i}`:t},Dw=(n,e,t)=>new Promise((r,o)=>{const i=new FormData;i.append("unique","true"),i.append("file",n);const l=new XMLHttpRequest;l.open("POST",e),l.upload.addEventListener("progress",a=>{if(t){if(a.lengthComputable&&a.total>0){t(Math.min(100,Math.round(a.loaded/a.total*100)));return}t(0)}}),l.addEventListener("load",()=>{try{const a=l.responseText?JSON.parse(l.responseText):{};if(l.status>=200&&l.status<300){r(a?.result??null);return}o(new Error(a?.message||a?.error||`Код помилки: ${l.status}`))}catch(a){o(a)}}),l.addEventListener("error",()=>o(new Error("Помилка мережі під час завантаження файлу"))),l.addEventListener("abort",()=>o(new Error("Завантаження файлу скасовано"))),l.send(i)}),Vw=async(n,e={})=>{try{const{api:t,id:r="1",form:o="form",table:i="table",customParams:l,onProgress:a}=e,c=t||`/file/upload/uploads?id=${r||""}&form=${o||""}&table=${i||""}`,d=Nw(c,l);if(n instanceof File)return await Dw(n,d,a);const u=new FormData;return u.append("unique","true"),u.append("file",n),(await fetch(d,{method:"POST",body:u}).then(p=>p.json()))?.result}catch(t){return we.notify({type:"error",title:"Помилка!",message:"Сталась помилка під час завантаження файлу",position:"right-bottom"}),console.error("Сталась помилка завантаження файлу",t),null}},$w=async n=>{try{return await fetch(`file/delete/${n}`),!0}catch(e){return console.error(e),!1}},Ou=async n=>{try{const e=await fetch(`/file/download/${n}`);if(!e.ok)throw new Error(`Download failed with status ${e.status}`);const t=await e.blob(),o=(e.headers.get("content-disposition")||"").match(/filename\*?=(?:UTF-8''|")?([^\";]+)/i),i=o?.[1]?decodeURIComponent(o[1].replace(/"/g,"").trim()):"",l=n.split("/").filter(Boolean).pop()||"download",a=i||l,c=document.createElement("a");c.setAttribute("download",a),c.href=window.URL.createObjectURL(t),c.click(),window.URL.revokeObjectURL(c.href)}catch(e){console.error(e.message)}},Lw=n=>{if(!n)return"";const e=n?.split(".");return e[e.length-1]},Sa=n=>{const e=Lw(n),t={imageFormat:["tiff","jpg","jpeg","png","svg","ico","webp"],sheetsFormat:["xls","csv","xlsx"],archivesFormat:["zip","rar"],textsFormat:["json","geojson","txt","yml","yaml","shp"],documentsFormat:["pdf"]};return t.imageFormat.includes(e)?"img":t.sheetsFormat.includes(e)?Y.Table:t.textsFormat.includes(e)?Y.FileCode:t.documentsFormat.includes(e)?Y.FileText:t.archivesFormat.includes(e)?Y.FileArchive:Y.FileText},Iw=["title"],Ow={key:0,class:"absolute inset-0 flex flex-col items-center justify-center gap-1 rounded-lg bg-white/90 px-2 text-center text-xs font-medium text-slate-600"},Rw=["title"],Fw={class:"absolute hidden top-0 right-0 flex items-center gap-x-2 w-full h-full justify-center"},ln=Ne(s.defineComponent({__name:"vs-input-file-list-item",props:s.mergeModels({format:{},multiple:{type:Boolean},max_size:{},api:{},customParams:{},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{},action:{type:Boolean,default:!1},isUploading:{type:Boolean,default:!1},progressPercent:{default:0},title:{default:""}},{value:{},valueModifiers:{},item:{},itemModifiers:{}}),emits:s.mergeModels(["click"],["update:value","update:item"]),setup(n,{emit:e}){const t=s.useModel(n,"value"),r=s.useModel(n,"item"),o=e,i=n,l=s.computed(()=>i.action),a=s.computed(()=>r.value?typeof r.value=="string"?r.value:r.value.file_path:""),c=s.computed(()=>i.disabled?"opacity-50 cursor-not-allowed":i.isUploading?"cursor-default text-blue-500":"cursor-pointer hover:border-blue-500 hover:bg-blue-50 hover:text-blue-500"),d=s.computed(()=>i.progressPercent>0?`${i.progressPercent}%`:"Завантаження..."),u=m=>typeof m=="string"?m:m?.file_path||"",f=()=>{const m=a.value;$w(m),i.multiple&&Array.isArray(t.value)?t.value=t.value.filter(g=>u(g)!==m):t.value=""},p=()=>{a.value&&window.open(a.value,"_blank")},h=()=>{i.disabled||i.isUploading||o("click")};return(m,g)=>l.value?(s.openBlock(),s.createElementBlock("div",{key:0,title:m.title,class:s.normalizeClass(["relative h-[120px] w-[120px] border text-gray-300 border-dashed border-[#CFD9E0] rounded-lg flex items-center justify-center transition-all duration-300",c.value]),onClick:h},[m.isUploading?(s.openBlock(),s.createElementBlock("div",Ow,[g[2]||(g[2]=s.createElementVNode("div",{class:"loader"},null,-1)),s.createElementVNode("span",null,s.toDisplayString(d.value),1)])):(s.openBlock(),s.createBlock(s.unref(Y.Plus),{key:1,class:"h-4 w-4"}))],10,Iw)):(s.openBlock(),s.createElementBlock("div",{key:1,title:a.value,class:"h-[120px] w-[120px] border text-gray-300 border-dashed border-[#CFD9E0] rounded-lg overflow-hidden relative item-file"},[(s.openBlock(),s.createBlock(s.resolveDynamicComponent(s.unref(Sa)(a.value)),{src:`${s.unref(Sa)(a.value)} === 'img'`?`/file/resize?filepath=${a.value}&format=webp`:a.value,alt:"file",class:"w-full h-full object-cover cursor-pointer",onClick:g[0]||(g[0]=y=>s.unref(Ou)(a.value))},null,8,["src"])),s.createElementVNode("div",Fw,[s.createElementVNode("button",{type:"button",onClick:f,class:"w-6 h-6 flex items-center justify-center text-gray-500 bg-gray-200 rounded-lg hover:text-red-500"},[s.createVNode(s.unref(Y.Trash2),{class:"w-4 h-4"})]),s.createElementVNode("button",{type:"button",onClick:p,class:"w-6 h-6 flex items-center justify-center text-gray-500 bg-gray-200 rounded-lg hover:text-emerald-600"},[s.createVNode(s.unref(Y.Eye),{class:"w-4 h-4"})]),s.createElementVNode("button",{type:"button",onClick:g[1]||(g[1]=y=>s.unref(Ou)(a.value)),class:"w-6 h-6 flex items-center justify-center text-gray-500 bg-gray-200 rounded-lg hover:text-blue-500"},[s.createVNode(s.unref(Y.Download),{class:"w-4 h-4"})])])],8,Rw))}}),[["__scopeId","data-v-b03cac5c"]]),Ea=n=>n?n.split(",").map(e=>e.trim().toLowerCase()).filter(Boolean).map(e=>e.startsWith(".")?e.slice(1):e):[],Ma=(n,e)=>!e||n.size<=e*1024*1024?!0:(we.notify({type:"error",title:"Помилка!",message:`Файл "${n.name}" занадто великий. Максимальний розмір: ${e} МБ`,position:"right-bottom"}),!1),Aa=(n,e)=>{if(!e.length)return!0;const t=n.name.split(".").pop()?.toLowerCase()||"";return e.includes(t)?!0:(we.notify({type:"error",title:"Помилка!",message:`Неприпустимий формат файлу "${n.name}". Дозволені формати: ${e.map(r=>`.${r}`).join(", ")}`,position:"right-bottom"}),!1)},Ru=(n,e)=>{const t={},r=[];if(!n?.length)return{ok:!0,params:t,missingSources:r};const o=e?.value??{};return n.forEach(i=>{if(!i)return;const[l,a]=i.split("="),c=l?.trim(),d=a?.trim();if(!c||!d)return;const u=o[d];if(u==null||u===""){r.push(d);return}t[c]=u}),r.length?(we.notify({type:"warning",title:"Заповніть поля",message:`Поля (${r.join(", ")}) необхідні для завантаження файлу`,position:"right-bottom"}),{ok:!1,params:t,missingSources:r}):{ok:!0,params:t,missingSources:r}},Fu=(n,e)=>!e||!Array.isArray(n)?[]:n,Pu=(n,e)=>e||Array.isArray(n)?null:n,zu=n=>{if(!n)return"";const e=n.split(/[/\\]/).pop()||"",t=e.lastIndexOf(".");return t<=0||t===e.length-1?"":e.slice(t+1).toLowerCase()},Pw={class:"flex items-center flex-wrap gap-2"},zw=["accept","multiple","disabled"],Hu=s.defineComponent({__name:"vs-input-file",props:s.mergeModels({format:{},multiple:{type:Boolean},max_size:{},api:{},customParams:{},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{},modelModifiers:{}}),emits:s.mergeModels(["change"],["update:modelValue"]),setup(n,{emit:e}){const t=n,r=s.useModel(n,"modelValue"),o=e,i=s.ref(null),l=s.ref(!1),a=s.ref([]),c=s.inject("values"),d=s.inject("map-file-import-uploading",null),u=s.computed(()=>Fu(r.value,!!t.multiple)),f=s.computed(()=>Pu(r.value,!!t.multiple)),p=s.computed(()=>Ea(t.format)),h=s.computed(()=>Ru(t.customParams,c)),m=R=>{we.notify({type:"error",title:"Помилка завантаження",message:R||"Не вдалося завантажити файл. Спробуйте ще раз.",position:"right-bottom"})},g=()=>{t.disabled||l.value||h.value.ok&&i.value?.click()},y=async(R,T)=>{const M={api:t.api,customParams:Object.keys(h.value.params).length?h.value.params:void 0,onProgress:A=>{T&&(T.status="uploading",T.progressPercent=A)}},_=await Vw(R,M);return _?.file_path?_.file_path:null};s.watch(l,R=>{d&&(d.value=R)},{immediate:!0});const b=s.computed(()=>a.value.filter(R=>R.status!=="done")),w=s.computed(()=>b.value[0]||null),v=R=>typeof R=="string"?R:R?.file_path||"",E=(R,T)=>({key:`${Date.now()}-${T}-${R.name}`,file:R,size:R.size,uploaded:0,status:"pending",error:null,path:null,progressPercent:0}),N=async R=>{const{files:T}=R.target;if(!T||T.length===0)return;if(!h.value.ok){i.value&&(i.value.value="");return}const M=Array.from(T);if(t.max_size&&M.filter(L=>!Ma(L,t.max_size)).length>0){i.value&&(i.value.value="");return}if(M.filter(A=>!Aa(A,p.value)).length>0){i.value&&(i.value.value="");return}l.value=!0,a.value=M.map((A,L)=>E(A,L));try{if(t.multiple){const Z=await Promise.all(M.map(async(U,K)=>{const X=a.value[K];X.status="uploading",X.progressPercent=0;const le=await y(U,X);return le?(X.status="done",X.path=le,X.uploaded=X.size,X.progressPercent=100):(X.status="error",X.error="Помилка при завантаженні"),le})),D=Z.filter(U=>!!U);if(D.length===0){m();return}D.length<Z.length&&m("Деякі файли не вдалося завантажити. Перевірте їх та спробуйте знову.");const P=D,ne=Array.isArray(r.value)?r.value:r.value?[r.value]:[];r.value=[...ne,...P],o("change",r.value);return}const A=M[0],L=a.value[0];L.status="uploading",L.progressPercent=0;const z=await y(A,L);if(!z){L.status="error",L.error="Помилка при завантаженні",m();return}L.status="done",L.path=z,L.uploaded=L.size,L.progressPercent=100,r.value=z,o("change",z)}catch(A){m(A?.message||void 0)}finally{l.value=!1,a.value=[],i.value&&(i.value.value="")}};return(R,T)=>(s.openBlock(),s.createElementBlock("div",Pw,[s.createElementVNode("input",{class:"hidden",ref_key:"fileInput",ref:i,type:"file",accept:t.format,multiple:t.multiple,onChange:N,disabled:l.value||R.disabled},null,40,zw),f.value?(s.openBlock(),s.createBlock(ln,{key:0,item:f.value,value:r.value,"onUpdate:value":T[0]||(T[0]=M=>r.value=M)},null,8,["item","value"])):s.createCommentVNode("",!0),t.multiple?(s.openBlock(),s.createElementBlock(s.Fragment,{key:1},[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(u.value,(M,_)=>(s.openBlock(),s.createBlock(ln,{key:`${_}-${v(M)}`,multiple:!0,item:M,value:r.value,"onUpdate:value":T[1]||(T[1]=A=>r.value=A)},null,8,["item","value"]))),128)),(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(b.value,M=>(s.openBlock(),s.createBlock(ln,{key:M.key,action:"","is-uploading":!0,disabled:!0,"progress-percent":M.progressPercent,title:M.file.name},null,8,["progress-percent","title"]))),128)),s.createVNode(ln,{action:"","is-uploading":!1,disabled:R.disabled||l.value,title:"Добавить файлы",onClick:g},null,8,["disabled"])],64)):!t.multiple&&!w.value?(s.openBlock(),s.createBlock(ln,{key:2,action:"","is-uploading":!1,disabled:R.disabled||l.value,title:"Обновить файл",onClick:g},null,8,["disabled"])):w.value?(s.openBlock(),s.createBlock(ln,{key:3,action:"","is-uploading":!0,disabled:!0,"progress-percent":w.value.progressPercent,title:w.value.file.name},null,8,["progress-percent","title"])):s.createCommentVNode("",!0)]))}}),Hw={class:"vs-input-file2 flex flex-col gap-4"},jw={class:"flex items-center flex-wrap gap-2"},Uw=["multiple","accept","disabled"],Ww={key:0,class:"text-sm text-rose-600"},ri=s.defineComponent({__name:"vs-input-file2",props:s.mergeModels({format:{},max_size:{},api:{},multiple:{type:Boolean,default:!1},chunkSize:{default:5*1024*1024},subdir:{default:""},customParams:{},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const e=n,t=s.useModel(n,"modelValue"),r=s.ref(null),o=s.ref(!1),i=s.ref(""),l=s.ref([]),a=s.inject("values"),c=s.computed(()=>!!e.multiple),d=s.computed(()=>Ea(e.format)),u=s.computed(()=>{if(d.value.length)return d.value.map(M=>`.${M}`).join(",")}),f=s.computed(()=>Fu(t.value,c.value)),p=s.computed(()=>Pu(t.value,c.value)),h=s.computed(()=>Ru(e.customParams,a)),m=s.computed(()=>l.value.filter(M=>M.status!=="done")),g=s.computed(()=>c.value?null:m.value[0]||null),y=s.computed(()=>{const M=m.value,_=M.reduce((L,z)=>L+z.size,0);if(!_)return 0;const A=M.reduce((L,z)=>L+Math.min(z.uploaded,z.size),0);return Math.min(100,Math.round(A/_*100))}),b=()=>{e.disabled||o.value||h.value.ok&&r.value?.click()},w=async(M,_)=>{const A=_||R(M,0);try{A.status="uploading";const L={id:"",fileName:A.file.name,subdir:e.subdir,size:A.file.size,...h.value.params},z=await fetch(`${e.api||"/file/upload2"}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(L)});if(!z.ok)throw new Error("Не вдалося ініціалізувати завантаження");const Z=await z.json().catch(()=>({}));A.uploadId=Z.id||"",A.uploaded=Number(Z.uploaded)||0,A.progressPercent=A.size?Math.min(100,Math.round(A.uploaded/A.size*100)):0;const D=e.chunkSize??5*1024*1024;for(;A.uploaded<A.size;){const U=A.uploaded,K=Math.min(U+D,A.size),le=await A.file.slice(U,K).arrayBuffer(),H=await fetch(`${e.api||"/file/upload2"}/${A.uploadId}`,{method:"PATCH",headers:{"Content-Range":`bytes ${U}-${K-1}/${A.size}`,"Content-Type":"application/octet-stream"},body:le});if(!H.ok)throw new Error("Помилка завантаження частини");const $=await H.json().catch(()=>({})),I=$.uploaded!=null?Number($.uploaded):K;if(A.uploaded=I,A.progressPercent=A.size?Math.min(100,Math.round(A.uploaded/A.size*100)):0,$.finished||I>=A.size){const te=zu(A.file.name),ae=$.file_path||$.filepath||$.url||(te?`/files/uploads/${A.uploadId}.${te}`:`/files/uploads/${A.uploadId}`);return A.path=ae,A.status="done",N(ae),ae}}const P=zu(A.file.name),ne=`/files/uploads/${A.uploadId}${P?`.${P}`:""}`;return A.path=ne,A.status="done",N(ne),ne}catch(L){return A.status="error",A.error=L?.message||"Помилка при завантаженні",i.value=L?.message||"Помилка при завантаженні",null}},v=M=>typeof M=="string"?M:M?.file_path||"",E=M=>!M||M.length===0?[]:Array.from(M),N=M=>{if(c.value){const _=Array.isArray(t.value)?[...t.value]:t.value?[t.value]:[];_.push(M),t.value=_;return}t.value=M},R=(M,_)=>({key:`${Date.now()}-${_}-${M.name}`,file:M,size:M.size,uploaded:0,uploadId:"",status:"pending",error:null,path:null,progressPercent:0}),T=async M=>{const _=M.target,A=E(_.files);if(!A.length)return;if(!h.value.ok){_.value="";return}const L=A.filter(z=>Ma(z,e.max_size)&&Aa(z,d.value));if(!L.length){_.value="";return}try{o.value=!0,i.value="",l.value=L.map((P,ne)=>R(P,ne));const Z=(await Promise.allSettled(l.value.map(P=>w(P.file,P)))).filter(P=>P.status==="fulfilled").map(P=>P.value).filter(P=>!!P),D=l.value.filter(P=>P.status==="error").map(P=>P.file.name);if(Z.length===0){i.value="Не вдалося завантажити файл";return}D.length>0?we.notify({type:"warning",title:"Частина файлів не завантажилась",message:D.join(", "),position:"right-bottom"}):we.notify({type:"success",title:"Файл завантажено",message:L.length>1?`Завантажено ${Z.length} файлів`:L[0].name,position:"right-bottom"})}finally{o.value=!1,l.value=[],_.value=""}};return(M,_)=>(s.openBlock(),s.createElementBlock("div",Hw,[s.createElementVNode("div",jw,[s.createElementVNode("input",{ref_key:"fileInput",ref:r,type:"file",class:"hidden",multiple:c.value,accept:u.value,disabled:o.value||e.disabled,onChange:T},null,40,Uw),c.value?(s.openBlock(!0),s.createElementBlock(s.Fragment,{key:0},s.renderList(f.value,(A,L)=>(s.openBlock(),s.createBlock(ln,{key:`${L}-${v(A)}`,multiple:!0,item:A,value:t.value,"onUpdate:value":_[0]||(_[0]=z=>t.value=z)},null,8,["item","value"]))),128)):p.value?(s.openBlock(),s.createBlock(ln,{key:1,item:p.value,value:t.value,"onUpdate:value":_[1]||(_[1]=A=>t.value=A)},null,8,["item","value"])):s.createCommentVNode("",!0),c.value?(s.openBlock(!0),s.createElementBlock(s.Fragment,{key:2},s.renderList(m.value,A=>(s.openBlock(),s.createBlock(ln,{key:A.key,action:"","is-uploading":!0,disabled:!0,"progress-percent":A.progressPercent,title:A.file.name},null,8,["progress-percent","title"]))),128)):g.value?(s.openBlock(),s.createBlock(ln,{key:3,action:"","is-uploading":!0,disabled:!0,"progress-percent":g.value.progressPercent,title:g.value.file.name},null,8,["progress-percent","title"])):s.createCommentVNode("",!0),s.createVNode(ln,{action:"","is-uploading":!1,disabled:e.disabled||o.value,"progress-percent":y.value,title:c.value?"Добавить файлы":"Обновить файл",onClick:b},null,8,["disabled","progress-percent","title"])]),i.value?(s.openBlock(),s.createElementBlock("p",Ww,s.toDisplayString(i.value),1)):s.createCommentVNode("",!0)]))}});function Kw(n){let e="";for(let r=0;r<n.length;r+=32768)e+=String.fromCharCode(...n.subarray(r,r+32768));return btoa(e)}async function ju(n){const e=await n.arrayBuffer();return{name:n.name,content:Kw(new Uint8Array(e))}}function _a(n,e="application/octet-stream"){const t=atob(n),r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t.charCodeAt(o);return new Blob([r],{type:e})}function Uu(n,e="application/octet-stream"){return URL.createObjectURL(_a(n,e))}function Wu(n){const e=_a(n.content),t=document.createElement("a");t.href=window.URL.createObjectURL(e),t.setAttribute("download",n.name),t.click(),window.URL.revokeObjectURL(t.href)}function Ta(n){if(!n||typeof n!="object"||Array.isArray(n))return!1;const e=n;return typeof e.name=="string"&&typeof e.content=="string"&&!!e.content}const qw={class:"vs-input-file64 flex flex-col gap-2"},Gw={class:"flex items-center flex-wrap gap-2"},Jw=["multiple","accept","disabled"],Yw=["title"],Xw=["src"],Zw={key:1,class:"flex h-full w-full flex-col items-center justify-center gap-1 px-2 text-slate-500"},Qw={class:"line-clamp-2 text-center text-[10px] text-slate-600"},ex={class:"absolute inset-0 hidden items-center justify-center gap-x-2 bg-black/50 group-hover:flex"},tx=["disabled","onClick"],nx=["onClick"],rx=["onClick"],ox=["title"],sx={class:"line-clamp-2 max-w-full break-words text-center text-[11px] font-semibold leading-snug"},ix=["title"],lx={key:0,class:"text-sm text-rose-600"},oi=s.defineComponent({__name:"vs-input-file64",props:s.mergeModels({format:{},multiple:{type:Boolean,default:!1},multi:{type:Boolean},max_size:{default:10},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const e=new Set(["tiff","jpg","jpeg","png","svg","ico","webp"]),t=n,r=s.useModel(n,"modelValue"),o=s.ref(null),i=s.ref(!1),l=s.ref("Обробка…"),a=s.ref(""),c=s.ref([]),d=s.ref([]),u=s.computed(()=>!!(t.multiple||t.multi)),f=s.computed(()=>Ea(t.format)),p=s.computed(()=>{if(f.value.length)return f.value.map(T=>`.${T}`).join(",")});function h(){c.value.forEach(T=>URL.revokeObjectURL(T)),c.value=[]}function m(T){return c.value.push(T),T}function g(T){const M=T.name.split(".").pop()?.toLowerCase()||"",_=Sa(T.name);return{...T,url:m(Uu(T.content)),isImage:e.has(M),icon:_==="img"?"img":_}}function y(){if(h(),u.value){const T=Array.isArray(r.value)?r.value.filter(Ta):[];d.value=T.map(g);return}d.value=Ta(r.value)?[g(r.value)]:[]}async function b(){await s.nextTick(),await new Promise(T=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>T())})})}s.watch([()=>r.value,u],()=>y(),{immediate:!0,deep:!0}),s.onBeforeUnmount(()=>{h()});const w=()=>{t.disabled||i.value||o.value?.click()},v=T=>{if(u.value&&Array.isArray(r.value)){r.value=r.value.filter((M,_)=>_!==T);return}r.value=null},E=T=>{T.url&&window.open(T.url,"_blank")},N=T=>{Wu({name:T.name,content:T.content})},R=async T=>{const M=T.target,_=M.files?Array.from(M.files):[];if(!_.length)return;const A=_.filter(L=>Ma(L,t.max_size)&&Aa(L,f.value));if(!A.length){M.value="";return}i.value=!0,l.value=A.length>1?`Обробка… (${A.length})`:`Обробка… ${A[0].name}`,a.value="",await b();try{const L=await Promise.all(A.map(z=>ju(z)));if(u.value){const z=Array.isArray(r.value)?r.value.filter(Ta):[];r.value=[...z,...L]}else r.value=L[0]||null;we.notify({type:"success",title:"Файл додано",message:L.length>1?`Додано ${L.length} файлів`:L[0].name,position:"right-bottom"})}catch(L){console.error(L),a.value="Помилка при обробці файлу",we.notify({type:"error",title:"Помилка!",message:"Помилка при обробці файлу",position:"right-bottom"})}finally{i.value=!1,M.value=""}};return(T,M)=>(s.openBlock(),s.createElementBlock("div",qw,[s.createElementVNode("div",Gw,[s.createElementVNode("input",{ref_key:"fileInput",ref:o,type:"file",class:"hidden",multiple:u.value,accept:p.value,disabled:T.disabled||i.value,onChange:R},null,40,Jw),(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(d.value,(_,A)=>(s.openBlock(),s.createElementBlock("div",{key:`${A}-${_.name}`,class:"group relative h-[120px] w-[120px] overflow-hidden rounded-lg border border-dashed border-[#CFD9E0] text-gray-300",title:_.name},[_.isImage?(s.openBlock(),s.createElementBlock("img",{key:0,src:_.url,alt:"",class:"h-full w-full object-cover"},null,8,Xw)):(s.openBlock(),s.createElementBlock("div",Zw,[(s.openBlock(),s.createBlock(s.resolveDynamicComponent(_.icon),{class:"h-8 w-8"})),s.createElementVNode("span",Qw,s.toDisplayString(_.name),1)])),s.createElementVNode("div",ex,[s.createElementVNode("button",{type:"button",class:"flex h-6 w-6 items-center justify-center rounded-lg bg-gray-200 text-gray-500 hover:text-red-500",disabled:T.disabled||i.value,onClick:L=>v(A)},[s.createVNode(s.unref(Y.Trash2),{class:"h-4 w-4"})],8,tx),s.createElementVNode("button",{type:"button",class:"flex h-6 w-6 items-center justify-center rounded-lg bg-gray-200 text-gray-500 hover:text-emerald-600",onClick:L=>E(_)},[s.createVNode(s.unref(Y.Eye),{class:"h-4 w-4"})],8,nx),s.createElementVNode("button",{type:"button",class:"flex h-6 w-6 items-center justify-center rounded-lg bg-gray-200 text-gray-500 hover:text-blue-500",onClick:L=>N(_)},[s.createVNode(s.unref(Y.Download),{class:"h-4 w-4"})],8,rx)])],8,Yw))),128)),i.value?(s.openBlock(),s.createElementBlock("div",{key:0,class:"box-border flex h-[120px] w-[120px] flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-blue-400 bg-blue-50 p-2 text-blue-600",title:l.value},[M[0]||(M[0]=s.createElementVNode("div",{class:"h-6 w-6 shrink-0 animate-spin rounded-full border-[3px] border-blue-100 border-t-blue-600"},null,-1)),s.createElementVNode("span",sx,s.toDisplayString(l.value),1)],8,ox)):!T.disabled&&(u.value||!d.value.length)?(s.openBlock(),s.createElementBlock("div",{key:1,class:"flex h-[120px] w-[120px] cursor-pointer items-center justify-center rounded-lg border border-dashed border-[#CFD9E0] text-gray-300 transition-all hover:border-blue-500 hover:bg-blue-50 hover:text-blue-500",title:u.value?"Добавить файлы":"Выбрать файл",onClick:w},[s.createVNode(s.unref(Y.Plus),{class:"h-4 w-4"})],8,ix)):s.createCommentVNode("",!0)]),a.value?(s.openBlock(),s.createElementBlock("p",lx,s.toDisplayString(a.value),1)):s.createCommentVNode("",!0)]))}}),ax={class:"flex items-center justify-center h-[30px] w-[30px]"},cx={class:"max-w-[55vw]"},dx={class:"text-sm font-semibold text-gray-800 truncate dark:text-neutral-200"},ux={class:"flex items-center text-xs text-gray-500 truncate dark:text-neutral-500"},fx={class:"px-[5px]"},px={class:""},si=s.defineComponent({__name:"vs-widget-file-info",props:{item:{default:null}},setup(n){const e=n,t=s.computed(()=>{try{return new Date(e.item.cdate).toLocaleDateString("uk-UA",{day:"2-digit",month:"long",year:"numeric"})}catch{return""}});function r(o){if(o<1024)return`${o} B`;const i=o/1024;return i<1024?`${i.toFixed(2)} KB`:`${(i/1024).toFixed(2)} MB`}return(o,i)=>(s.openBlock(),s.createElementBlock(s.Fragment,null,[s.createElementVNode("div",ax,[s.createVNode(s.unref(Y.FileText),{class:"icon icon-tabler icons-tabler-outline icon-tabler-file h-4 w-4"})]),s.createElementVNode("div",cx,[s.createElementVNode("p",dx,s.toDisplayString(o.item?.uploaded_name),1),s.createElementVNode("p",ux,[s.createElementVNode("span",null,s.toDisplayString(o.item?.username),1),s.withDirectives(s.createElementVNode("span",fx,"|",512),[[s.vShow,o.item?.username]]),s.createElementVNode("span",null,s.toDisplayString(t.value),1),i[0]||(i[0]=s.createElementVNode("span",{class:"px-[5px]"},"|",-1)),s.createElementVNode("span",px,s.toDisplayString(r(o.item?.size)),1)])])],64))}}),hx={class:"p-3 relative group flex items-center gap-x-3 border border-gray-200 bg-white rounded-md w-full"},mx={key:0,class:"flex w-full gap-x-3 items-center"},gx={key:1,class:"flex gap-x-3 w-full items-center"},yx={key:2,class:"flex gap-x-3 w-full items-center"},bx=["href"],kx={key:3,class:"flex gap-x-3 w-full items-center"},wx={class:"lg:absolute lg:top-3 lg:end-1 opacity-100"},xx={class:"p-0.5 sm:p-1 inline-flex items-center gap-0.5 bg-white rounded-lg dark:bg-neutral-800 dark:border-neutral-700"},vx={class:"inline-block"},Cx={class:"inline-block"},Sx={class:"inline-block"},Ex=s.defineComponent({__name:"vs-widget-file-item",props:{item:{default:null},index:{default:0},prefix:{default:"/api"}},emits:["update","openModal","openLightbox"],setup(n,{emit:e}){const t=n,r=e;function o(f){return["pdf","json"].includes(f.ext)}function i(f){return["ppt","pptx","doc","docx","xls","xlsx"].includes(f.ext)}function l(f){const p=document.createElement("a");p.setAttribute("download",f?.uploaded_name),p.href=f?.file_path,p.click()}function a(f){f?.file_path&&window.open(f.file_path,"_blank")}async function c(){try{await fetch(`${t.prefix}/widget/file/${t.item.entity_id}/${t.item.file_id}`,{method:"DELETE"}),r("update")}catch(f){console.error(f)}}function d(){r("openModal",{title:"Ви впевнені?",message:"Ви впевнені, що хочете видалити цей файл?",confirmButtonText:"Так, я впевнена/ий",cancelButtonText:"Скасувати",confirm:c,updateListOnConfirm:!0})}function u(f){(t.item.ext==="jpg"||t.item.ext==="png")&&r("openLightbox",{item:t.item,index:f})}return(f,p)=>(s.openBlock(),s.createElementBlock("div",hx,[f.item.ext==="jpg"||f.item.ext==="png"?(s.openBlock(),s.createElementBlock("div",mx,[s.createElementVNode("div",{class:"max-w-[55vw] cursor-pointer flex gap-x-3 w-full items-center",onClick:p[0]||(p[0]=h=>u(f.index))},[s.createVNode(si,{item:f.item},null,8,["item"])])])):o(f.item)?(s.openBlock(),s.createElementBlock("div",gx,[s.createVNode(si,{item:f.item},null,8,["item"])])):i(f.item)?(s.openBlock(),s.createElementBlock("div",yx,[s.createElementVNode("a",{href:`/api/file-preview?id=${f.item.file_id}`,target:"_blank",class:"flex gap-x-3 w-full items-center"},[s.createVNode(si,{item:f.item},null,8,["item"])],8,bx)])):(s.openBlock(),s.createElementBlock("div",kx,[s.createVNode(si,{item:f.item},null,8,["item"])])),s.createElementVNode("div",wx,[s.createElementVNode("div",xx,[s.createElementVNode("div",vx,[s.createElementVNode("button",{class:"inline-flex p-[6px] justify-center items-center gap-x-2 rounded-lg border border-transparent text-gray-500 hover:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none dark:text-neutral-400 focus:outline-none focus:bg-gray-100 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700",onClick:p[1]||(p[1]=h=>a(f.item))},[s.createVNode(s.unref(Y.Eye),{class:"h-4 w-4"})])]),s.createElementVNode("div",Cx,[s.createElementVNode("button",{class:"inline-flex p-[6px] justify-center items-center gap-x-2 rounded-lg border border-transparent text-gray-500 hover:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none dark:text-neutral-400 focus:outline-none focus:bg-gray-100 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700",onClick:p[2]||(p[2]=h=>l(f.item))},[s.createVNode(s.unref(Y.Download),{class:"h-4 w-4"})])]),p[4]||(p[4]=s.createElementVNode("div",{class:"w-px h-5 mx-1 bg-gray-200 dark:bg-neutral-700"},null,-1)),s.createElementVNode("div",Sx,[s.createElementVNode("button",{type:"button",class:"size-[30px] inline-flex justify-center items-center gap-x-2 rounded-lg border border-transparent text-red-600 hover:bg-red-100 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-red-100 dark:text-red-500 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20",onClick:p[3]||(p[3]=h=>d())},[s.createVNode(s.unref(Y.Trash2),{class:"h-4 w-4"})])])])])]))}}),Mx={class:"flex flex-col widget-file xl:bg-white xl:rounded-xl dark:xl:bg-neutral-800 dark:xl:border-neutral-700 w-full"},Ax={class:"flex w-full mb-[12px] items-center gap-x-2"},_x={class:"font-semibold text-gray-800 dark:text-neutral-200 text-[14px]"},Tx={class1:"ml-auto"},Bx={class:"py-1.5 px-4 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg bg-gray-100 cursor-pointer hover:bg-gray-200 text-gray-800 shadow-2xs hover:bg-gray-50 focus:outline-hidden focus:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-800 dark:border-neutral-700 dark:text-white dark:hover:bg-neutral-700 dark:focus:bg-neutral-700"},Nx={key:0,class:"py-4 mb-4 space-y-4 border-gray-200 border-y dark:border-neutral-700"},Dx={class:"relative"},Vx={class:"absolute inset-y-0 start-0 flex items-center pointer-events-none z-[1] ps-3.5"},$x={key:1,class:"space-y-3 max-h-[300px] overflow-y-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"},Lx={key:0},Ku=s.defineComponent({__name:"vs-input-file-list",props:{id:{default:""},prefix:{default:"/api"},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},emits:["update"],setup(n,{emit:e}){const t=n,r=s.inject("form"),o=s.computed(()=>r.value.formId),i=s.ref(!1),l=s.ref(0),a=e,c=s.ref(!1),d=s.ref({}),u=s.ref([]),f=s.ref(""),p=s.computed(()=>Array.isArray(u.value)?u.value.filter(v=>v.ext==="jpg"||v.ext==="png").map(v=>v?.file_path):[]),h=s.computed(()=>f.value===""?u.value:u.value.filter(v=>v?.uploaded_name?.includes(f.value))),m=v=>{const E=p.value.findIndex(N=>N===v.item.file_path);E!==-1&&(i.value=!0,l.value=E)},g=async()=>{try{const v=await fetch(`${t.prefix}/widget/file/${o.value}`).then(E=>E.json());u.value=v?.rows}catch(v){console.error(v)}},y=async v=>{await Promise.all(Array.from(v.target.files).map(async E=>{const N=new FormData;N.append("file",E);try{const R=`${t.prefix}/widget/file/${o.value}`,T=await fetch(R,{method:"POST",body:N});return T.ok?(a("update","file-list"),E):(we.notify({type:T.status>=400&&T.status<500?"warning":"error",title:"Error",message:`Error code: ${T.status}`}),null)}catch(R){return we.notify({type:"error",title:"Error",message:R.message||"Unknown error"}),console.error(R),null}})),await g()},b=v=>{const E={...v};return v.cancel||(E.cancel=()=>{c.value=!1}),v.updateListOnConfirm&&(E.confirm=async()=>{await v.confirm(),c.value=!1,g()}),E},w=v=>{d.value=b(v),c.value=!0};return s.watch(o,v=>{v&&g()}),s.onMounted(()=>{o.value&&g()}),(v,E)=>{const N=s.resolveComponent("Lightbox"),R=s.resolveComponent("MessageBox");return s.openBlock(),s.createElementBlock("div",Mx,[s.createElementVNode("div",Ax,[s.createElementVNode("h2",_x," Файлів: "+s.toDisplayString(u.value?.length),1),s.createElementVNode("div",Tx,[s.createElementVNode("label",null,[s.createElementVNode("input",{type:"file",class:"hidden",onChange:E[0]||(E[0]=T=>y(T))},null,32),s.createElementVNode("div",Bx,[s.createVNode(s.unref(Y.Upload),{class:"h-4 w-4"})])])])]),u.value?.length>4?(s.openBlock(),s.createElementBlock("div",Nx,[s.createElementVNode("div",null,[s.createElementVNode("div",Dx,[s.createElementVNode("div",Vx,[s.createVNode(s.unref(Y.Search),{class:"flex-shrink-0 text-gray-500 size-4 dark:text-neutral-400"})]),s.withDirectives(s.createElementVNode("input",{type:"text","onUpdate:modelValue":E[1]||(E[1]=T=>f.value=T),class:"py-2 px-3 ps-10 pe-16 block w-full bg-gray-200 xl:bg-gray-100 rounded-lg text-sm focus:border-blue-500 h-[40px] focus:border-2 focus:outline-none disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-700 dark:border-transparent dark:text-neutral-400 dark:placeholder:text-neutral-400 dark:focus:ring-neutral-600",placeholder:"Введіть назву файлу"},null,512),[[s.vModelText,f.value,void 0,{trim:!0}]])])])])):s.createCommentVNode("",!0),u.value?.length?(s.openBlock(),s.createElementBlock("div",$x,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(h.value,(T,M)=>(s.openBlock(),s.createBlock(Ex,{key:M,prefix:v.prefix,item:T,index:M,onUpdate:E[2]||(E[2]=_=>v.$emit("update","file-list")),onOpenModal:E[3]||(E[3]=_=>w(_)),onOpenLightbox:E[4]||(E[4]=_=>m(_))},null,8,["prefix","item","index"]))),128)),h.value.length?s.createCommentVNode("",!0):(s.openBlock(),s.createElementBlock("div",Lx,E[8]||(E[8]=[s.createElementVNode("p",{class:"text-sm text-gray-600 font-sm"}," Файлів з такою назвою не існує, введіть інше пошукове слово ",-1)])))])):s.createCommentVNode("",!0),s.createVNode(N,{modelValue:i.value,"onUpdate:modelValue":E[5]||(E[5]=T=>i.value=T),startIndex:l.value,"onUpdate:index":E[6]||(E[6]=T=>l.value=T),images:p.value},null,8,["modelValue","startIndex","images"]),s.createVNode(R,s.mergeProps({modelValue:c.value,"onUpdate:modelValue":E[7]||(E[7]=T=>c.value=T),onConfirm:d.value.confirm},d.value),null,16,["modelValue","onConfirm"])])}}}),Ix={class:"flex items-center justify-between"},Ox={class:"text-[16px] text-gray-900 font-medium"},Rx={class:"grid gap-3"},Fx=Ne(s.defineComponent({__name:"vs-container-switcher",props:{title:{type:String,default:""},style:{type:Object,default:()=>({})},isOpen:{type:Boolean,default:!1}},setup(n){const e=n,t=s.ref(e.isOpen);return s.watch(()=>e.isOpen,r=>{t.value=r}),(r,o)=>(s.openBlock(),s.createElementBlock("div",null,[s.createElementVNode("div",Ix,[s.createElementVNode("p",Ox,s.toDisplayString(n.title),1),s.createVNode(ha,{modelValue:t.value,"onUpdate:modelValue":o[0]||(o[0]=i=>t.value=i),style:s.normalizeStyle(n.style)},null,8,["modelValue","style"])]),s.createVNode(s.Transition,{name:"slide-fade"},{default:s.withCtx(()=>[s.withDirectives(s.createElementVNode("div",Rx,[s.renderSlot(r.$slots,"default",{},void 0,!0)],512),[[s.vShow,t.value]])]),_:3})]))}}),[["__scopeId","data-v-90320b87"]]),Px={class:"text-[16px] text-gray-900 font-medium"},zx={class:"grid gap-3"},Hx=Ne(s.defineComponent({__name:"vs-container-accordion",props:{title:{type:String,default:""},style:{type:Object,default:()=>({})},isOpen:{type:Boolean,default:!1}},setup(n){const e=n,t=s.ref(e.isOpen);return s.watch(()=>e.isOpen,r=>{t.value=r}),(r,o)=>(s.openBlock(),s.createElementBlock("div",null,[s.createElementVNode("button",{type:"button",onClick:o[0]||(o[0]=i=>t.value=!t.value),class:"flex items-center gap-2"},[s.createVNode(s.unref(Y.ChevronDown),{class:s.normalizeClass(["h-4 w-4 duration-300",[t.value?"-rotate-180":""]])},null,8,["class"]),s.createElementVNode("span",Px,s.toDisplayString(n.title),1)]),s.createVNode(s.Transition,{name:"slide-fade"},{default:s.withCtx(()=>[s.withDirectives(s.createElementVNode("div",zx,[s.renderSlot(r.$slots,"default",{},void 0,!0)],512),[[s.vShow,t.value]])]),_:3})]))}}),[["__scopeId","data-v-0c825d65"]]),jx={class:"flex items-center justify-between"},Ux={switcher:Fx,accordion:Hx,default:s.defineComponent({__name:"vs-container-default",props:{title:{type:String,default:""},style:{type:Object,default:()=>({})}},setup(n){return(e,t)=>(s.openBlock(),s.createElementBlock("div",null,[s.createElementVNode("div",jx,[s.createElementVNode("p",null,s.toDisplayString(n.title),1)]),s.renderSlot(e.$slots,"default")]))}})},Kt={Equal:"==",Inequal:"!=",Higer:">",HigerOrEqual:">=",Lower:"<",LowerOrEqual:"<=",Between:"between",StartWith:"^",EndWith:"$",Contain:"*",In:"in",NotIn:"not_in"},Wx=(n,e)=>String(n)===String(e),Kx=(n,e)=>String(n)!==String(e),qx=(n,e)=>n>e,Gx=(n,e)=>n>=e,Jx=(n,e)=>n<e,Yx=(n,e)=>n<=e,Xx=(n,e)=>Array.isArray(e)&&e.length===2?n>=e[0]&&n<=e[1]:!1,Zx=(n,e)=>String(n).startsWith(String(e)),Qx=(n,e)=>String(n).endsWith(String(e)),e1=(n,e)=>String(n).includes(String(e)),t1=(n,e)=>Array.isArray(e)?e.includes(n):!1,n1=(n,e)=>Array.isArray(e)?!e.includes(n):!0,r1=(n,e)=>{if(!e)return!0;switch(e?.[1]){case Kt.Equal:return Wx(n,e?.[2]);case Kt.Inequal:return Kx(n,e?.[2]);case Kt.Higer:return qx(n,e?.[2]);case Kt.HigerOrEqual:return Gx(n,e?.[2]);case Kt.Lower:return Jx(n,e?.[2]);case Kt.LowerOrEqual:return Yx(n,e?.[2]);case Kt.Between:return Xx(n,e?.[2]);case Kt.StartWith:return Zx(n,e?.[2]);case Kt.EndWith:return Qx(n,e?.[2]);case Kt.Contain:return e1(n,e?.[2]);case Kt.In:return t1(n,e?.[2]);case Kt.NotIn:return n1(n,e?.[2]);default:return!0}};function qu(n,e,t){return e==null||!Array.isArray(e)||e.length===0?!0:(Array.isArray(e[0])?e:[e]).every(o=>{if(!Array.isArray(o)||o.length<2)return!0;const i=o[0],l=t?n?.[t]?.[i]??n?.[i]:n?.[i];return r1(l,o)})}const Gu=s.defineComponent({__name:"vs-input-container",props:{style:{type:Object,default:()=>({})},title:{type:String,default:""},view:{type:String,default:"default"},name:{type:String,default:""},schema:{type:Array,default:()=>[]}},setup(n){const e=n,t=s.inject("values",s.ref({})),r=s.inject("form"),o=s.computed(()=>e.schema?.filter(a=>qu(t.value,a?.conditions,e.name||void 0))),i=s.computed(()=>Ux[e.view]),l=s.computed(()=>{if(t.value||(t.value={}),!e.name)return t.value;const a=t.value[e.name];if(a)return a;const c={};return t.value={...t.value,[e.name]:c},c});return(a,c)=>n.schema?.length?(s.openBlock(),s.createBlock(s.resolveDynamicComponent(i.value),{key:0,title:n.title,style:s.normalizeStyle(n.style)},{default:s.withCtx(()=>[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(o.value,d=>(s.openBlock(),s.createBlock(xf,s.mergeProps({key:d.name},{ref_for:!0},d,{item:d,modelValue:l.value[d.name],"onUpdate:modelValue":u=>l.value[d.name]=u,style:n.style,error:s.unref(r)?.errors?.[d.name]}),null,16,["item","modelValue","onUpdate:modelValue","style","error"]))),128))]),_:1},8,["title","style"])):s.createCommentVNode("",!0)}}),Ju=({props:n,fetchOptionByValue:e,optionsList:t,selectedOption:r,modelValue:o,onCreated:i})=>{const l=s.ref(!1),a=s.ref({}),c=s.ref([]),d=s.ref(null),u=s.computed(()=>n.add?.title||"Додати"),f=s.computed(()=>n.add?.token||n.add?.model||""),p=s.computed(()=>n.add?.pk||"id");return{isOpenAdd:l,addData:a,addSchema:c,addForm:d,addTitle:u,addOption:async()=>{if(!(!f.value||d?.value.validate()))try{const y=n.add?.api??`/api/table/${f.value}`,b=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a.value)}),w=await b.json().catch(()=>({})),v=w?.error||w?.message,E=Number(w?.code)>=400;if(!b.ok||E){we.notify({title:"Помилка",type:"error",message:v||`Код помилки: ${w?.code||b.status}`});return}const N=w?.rows?.[0],R=w?.[p.value]??w?.id??N?.[p.value]??N?.id;if(!R){we.notify({title:"Помилка",type:"error",message:"Обʼєкт створено, але в відповіді відсутній ID."});return}const T=await e(R);T&&(t.value.some(_=>String(_?.id)===String(T.id))||t.value.push(T)),i?await i(T,R):T&&(r.value=T,o.value=R),l.value=!1,we.notify({title:"Успіх",message:"Обʼєкт успішно створено."})}catch(y){we.notify({title:"Помилка",type:"error",message:y?.message||"Не вдалося створити обʼєкт."})}},onAddValue:async()=>{if(!n.add)return null;const g=await fetch(`/api/template/form/${n.add.form}`).then(y=>y.json());return c.value=g.schema,a.value={},l.value=!0,null}}},o1=["aria-expanded","data-focus"],s1={class:"vs-input-select__value-area relative flex flex-1 items-center gap-1 py-0.5 pl-1 pr-0 overflow-hidden h-full min-w-0"},i1={key:0,class:"flex flex-nowrap items-center gap-1 overflow-x-auto overflow-y-hidden min-w-0 flex-1 py-0.5"},l1={class:"flex items-center gap-1 min-w-0"},a1=["title"],c1=["innerHTML"],d1=["onClick"],u1={class:"flex-1 min-w-[2px]"},f1=["placeholder"],p1=["title"],h1=["innerHTML"],m1={key:3,class:"truncate flex-1 min-w-0"},g1={key:2,class:"flex-1 min-w-[2px]"},y1=["placeholder"],b1={key:3,class:"flex-1 flex items-center min-h-[30px] py-0.5 pl-2 text-sm truncate text-inherit"},k1={class:"vs-input-select__actions relative z-10 flex items-center shrink-0 bg-white"},w1=["disabled"],x1={key:1,class:"self-stretch w-px bg-[#ccc] my-[1px]"},v1=["disabled","title"],C1=s.defineComponent({__name:"vs-select-control",props:{disabled:{type:Boolean},isOpen:{type:Boolean},inputFocus:{type:Boolean},isMulti:{type:Boolean},selectedOptions:{},selectedIds:{},placeholder:{},search:{type:Boolean},optionTemplate:{default:""},iconWrapperClass:{},selectedOptionLabel:{},selectedOption:{},showClear:{type:Boolean},keyWord:{default:""},setTriggerRef:{},setInputRef:{},shouldShowColorDot:{},optionHasIcon:{},getIconColorStyle:{},resolveOptionIcon:{},renderTemplate:{},getLabel:{},onControlKeydown:{},onControlClick:{},onInputFocus:{},onInputBlur:{},onInputKeydown:{},onRemoveSelected:{},onClearSelected:{},onToggleSelect:{}},emits:["update:keyWord"],setup(n,{emit:e}){const t=n,r=e,o=s.computed({get:()=>t.keyWord,set:i=>r("update:keyWord",i)});return(i,l)=>(s.openBlock(),s.createElementBlock("div",{class:s.normalizeClass(["vs-input-select__control flex min-h-[38px] items-center justify-between rounded transition-colors bg-white",i.disabled?"bg-gray-100 text-gray-400 cursor-not-allowed":""]),role:"combobox","aria-expanded":i.isOpen,"aria-haspopup":"listbox",onKeydown:l[10]||(l[10]=(...a)=>i.onControlKeydown&&i.onControlKeydown(...a)),onClick:l[11]||(l[11]=(...a)=>i.onControlClick&&i.onControlClick(...a)),"data-focus":i.isOpen||i.inputFocus?"true":"false",ref:i.setTriggerRef},[s.createElementVNode("div",s1,[i.isMulti?(s.openBlock(),s.createElementBlock("div",i1,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(i.selectedOptions,a=>(s.openBlock(),s.createElementBlock("div",{key:a.id,class:"flex min-w-0 bg-[rgb(230,230,230)] rounded-[2px] m-[2px] box-border max-w-full"},[s.createElementVNode("div",l1,[i.shouldShowColorDot(a)?(s.openBlock(),s.createElementBlock("span",{key:0,class:"w-[16px] h-[16px] rounded-md block ml-1.5 flex-shrink-0",style:s.normalizeStyle({backgroundColor:a?.color})},null,4)):s.createCommentVNode("",!0),!i.optionTemplate&&i.optionHasIcon(a)?(s.openBlock(),s.createElementBlock("span",{key:1,class:s.normalizeClass(i.iconWrapperClass),style:s.normalizeStyle(i.getIconColorStyle(a)),"aria-hidden":"true"},[(s.openBlock(),s.createBlock(s.resolveDynamicComponent(i.resolveOptionIcon(a)),{class:"w-full h-full",focusable:"false"}))],6)):s.createCommentVNode("",!0),s.createElementVNode("div",{class:"truncate text-[#172b4d] overflow-hidden max-w-[200px] px-0.5 pl-1.5",title:i.getLabel(a)},[i.optionTemplate?(s.openBlock(),s.createElementBlock("div",{key:0,innerHTML:i.renderTemplate(a)},null,8,c1)):(s.openBlock(),s.createElementBlock(s.Fragment,{key:1},[s.createTextVNode(s.toDisplayString(a.text),1)],64))],8,a1)]),s.createElementVNode("div",{role:"button",class:"flex items-center rounded-sm px-1 box-border text-[#172b4d] hover:bg-[rgb(255,189,173)] hover:text-[rgb(222,53,11)] flex-shrink-0",onClick:s.withModifiers(c=>i.onRemoveSelected(a.id),["stop"])},[s.createVNode(s.unref(Y.X),{"aria-hidden":"true",focusable:"false",class:"inline-block h-4 w-4"})],8,d1)]))),128)),s.createElementVNode("div",u1,[!i.disabled&&i.search?s.withDirectives((s.openBlock(),s.createElementBlock("input",{key:0,ref:i.setInputRef,class:"w-full bg-transparent outline-none border-0 m-0 p-0 text-gray-900 hover:cursor-pointer",autocapitalize:"none",autocomplete:"off",autocorrect:"off",spellcheck:"false",type:"text",tabindex:"0","aria-autocomplete":"list",placeholder:i.selectedIds.length?" ":i.placeholder,"onUpdate:modelValue":l[0]||(l[0]=a=>o.value=a),onFocus:l[1]||(l[1]=(...a)=>i.onInputFocus&&i.onInputFocus(...a)),onBlur:l[2]||(l[2]=(...a)=>i.onInputBlur&&i.onInputBlur(...a)),onKeydown:l[3]||(l[3]=(...a)=>i.onInputKeydown&&i.onInputKeydown(...a))},null,40,f1)),[[s.vModelText,o.value]]):s.createCommentVNode("",!0)])])):!i.isMulti&&i.selectedOptionLabel&&o.value===""?(s.openBlock(),s.createElementBlock("div",{key:1,class:s.normalizeClass(["truncate flex items-center gap-1 min-w-0 pl-2",i.disabled||!i.search?"relative z-0 flex-1 min-h-[30px] py-0.5 text-inherit":"absolute inset-x-0 top-0 bottom-0 z-[1] text-gray-900 pointer-events-none"]),title:i.selectedOptionLabel},[i.shouldShowColorDot(i.selectedOption)?(s.openBlock(),s.createElementBlock("span",{key:0,class:"w-[14px] h-[14px] rounded-md block flex-shrink-0",style:s.normalizeStyle({backgroundColor:i.selectedOption?.color})},null,4)):s.createCommentVNode("",!0),!i.optionTemplate&&i.optionHasIcon(i.selectedOption)?(s.openBlock(),s.createElementBlock("span",{key:1,class:s.normalizeClass(i.iconWrapperClass),style:s.normalizeStyle(i.getIconColorStyle(i.selectedOption)),"aria-hidden":"true"},[(s.openBlock(),s.createBlock(s.resolveDynamicComponent(i.resolveOptionIcon(i.selectedOption)),{class:"w-full h-full",focusable:"false"}))],6)):s.createCommentVNode("",!0),i.optionTemplate?(s.openBlock(),s.createElementBlock("div",{key:2,class:"truncate flex-1 min-w-0",innerHTML:i.renderTemplate(i.selectedOption)},null,8,h1)):(s.openBlock(),s.createElementBlock("span",m1,s.toDisplayString(i.selectedOption?.text),1))],10,p1)):s.createCommentVNode("",!0),!i.isMulti&&!i.disabled&&i.search?(s.openBlock(),s.createElementBlock("div",g1,[s.withDirectives(s.createElementVNode("input",{ref:i.setInputRef,class:"w-full bg-transparent outline-none border-0 m-0 p-0 text-gray-900 hover:cursor-pointer",autocapitalize:"none",autocomplete:"off",autocorrect:"off",spellcheck:"false",type:"text",tabindex:"0","aria-autocomplete":"list",placeholder:i.selectedOptionLabel?" ":i.placeholder,"onUpdate:modelValue":l[4]||(l[4]=a=>o.value=a),onFocus:l[5]||(l[5]=(...a)=>i.onInputFocus&&i.onInputFocus(...a)),onBlur:l[6]||(l[6]=(...a)=>i.onInputBlur&&i.onInputBlur(...a)),onKeydown:l[7]||(l[7]=(...a)=>i.onInputKeydown&&i.onInputKeydown(...a))},null,40,y1),[[s.vModelText,o.value]])])):!i.isMulti&&i.disabled&&(!i.selectedOptionLabel||o.value!=="")?(s.openBlock(),s.createElementBlock("div",b1,s.toDisplayString(i.placeholder),1)):s.createCommentVNode("",!0)]),s.createElementVNode("div",k1,[i.showClear?(s.openBlock(),s.createElementBlock("button",{key:0,type:"button",class:"px-2 text-gray-400 hover:text-gray-500 transition-colors disabled:opacity-50","aria-hidden":"true",disabled:i.disabled,onClick:l[8]||(l[8]=s.withModifiers((...a)=>i.onClearSelected&&i.onClearSelected(...a),["stop"]))},[s.createVNode(s.unref(Y.X),{class:"h-4 w-4"})],8,w1)):s.createCommentVNode("",!0),i.showClear?(s.openBlock(),s.createElementBlock("div",x1)):s.createCommentVNode("",!0),s.createElementVNode("button",{type:"button",class:"px-2 text-gray-400 hover:text-gray-500 transition-colors disabled:opacity-50","aria-hidden":"true",disabled:i.disabled,onClick:l[9]||(l[9]=s.withModifiers((...a)=>i.onToggleSelect&&i.onToggleSelect(...a),["stop"])),title:i.isOpen?"Закрити список":"Відкрити список"},[s.createVNode(s.unref(Y.ChevronDown),{class:"h-4 w-4"})],8,v1)])],42,o1))}}),S1=["aria-disabled","onMousedown"],E1={class:"leading-[19px]"},M1=["innerHTML"],A1={key:1,class:"px-3 py-2 text-center text-gray-500"},_1=s.defineComponent({__name:"vs-select-dropdown",props:{isOpen:{type:Boolean},dropdownStyle:{},filteredOptionsList:{},selectedNavIndex:{},optionTemplate:{},iconWrapperClass:{},setDropdownRef:{type:Function},setListRef:{type:Function},setItemRef:{type:Function},isSelected:{type:Function},onOptionClick:{type:Function},shouldShowColorDot:{type:Function},optionHasIcon:{type:Function},getIconColorStyle:{type:Function},resolveOptionIcon:{type:Function},renderTemplate:{type:Function}},setup(n){return(e,t)=>(s.openBlock(),s.createBlock(s.Teleport,{to:"body"},[e.isOpen?(s.openBlock(),s.createElementBlock("div",{key:0,ref:e.setDropdownRef,class:"fixed z-[3000] rounded bg-white shadow-[0_0_0_1px_rgba(0,0,0,0.1),0_4px_11px_rgba(0,0,0,0.1)]",style:s.normalizeStyle(e.dropdownStyle),role:"listbox"},[s.createElementVNode("div",{class:"overflow-y-auto py-1",style:s.normalizeStyle({maxHeight:e.dropdownStyle.maxHeight||"300px"}),ref:e.setListRef},[e.filteredOptionsList.length?(s.openBlock(!0),s.createElementBlock(s.Fragment,{key:0},s.renderList(e.filteredOptionsList,(r,o)=>(s.openBlock(),s.createElementBlock("div",{key:r.id,ref_for:!0,ref:i=>e.setItemRef(i,o),class:s.normalizeClass(["flex px-3 py-2 gap-2 cursor-pointer select-none text-gray-900",e.isSelected(r.id)?"bg-[#2684ff] text-white":"bg-white hover:bg-[#deebff] hover:text-[#172b4d]",e.selectedNavIndex===o&&!e.isSelected(r.id)?"bg-[#deebff] text-[#172b4d]":""]),"aria-disabled":e.isSelected(r.id)?"true":"false",role:"option",tabindex:"-1",onMousedown:s.withModifiers(i=>e.onOptionClick(r),["prevent","stop"])},[e.shouldShowColorDot(r)?(s.openBlock(),s.createElementBlock("span",{key:0,class:"w-[11px] h-[11px] rounded-full block flex-shrink-0",style:s.normalizeStyle({backgroundColor:r?.color})},null,4)):s.createCommentVNode("",!0),!e.optionTemplate&&e.optionHasIcon(r)?(s.openBlock(),s.createElementBlock("span",{key:1,class:s.normalizeClass(e.iconWrapperClass),style:s.normalizeStyle(e.getIconColorStyle(r)),"aria-hidden":"true"},[(s.openBlock(),s.createBlock(s.resolveDynamicComponent(e.resolveOptionIcon(r)),{class:"w-full h-full",focusable:"false"}))],6)):s.createCommentVNode("",!0),s.createElementVNode("div",E1,[e.optionTemplate?(s.openBlock(),s.createElementBlock("div",{key:0,innerHTML:e.renderTemplate(r)},null,8,M1)):(s.openBlock(),s.createElementBlock(s.Fragment,{key:1},[s.createTextVNode(s.toDisplayString(r.text),1)],64))])],42,S1))),128)):(s.openBlock(),s.createElementBlock("div",A1," No options "))],4)],4)):s.createCommentVNode("",!0)]))}}),T1={class:"flex justify-end items-center gap-x-2 py-3 px-4 border-t border-gray-200 w-full"},B1=["onClick"],N1=["disabled"],D1="__autoMeta",Yu="w-[16px] h-[16px] flex items-center justify-center flex-shrink-0 text-current",Ba=Ne(s.defineComponent({__name:"vs-input-select",props:{multiple:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},mode:{},defaultValue:{},search:{type:Boolean,default:!0},placeholder:{default:"Оберіть значення"},prefix:{default:"api"},host:{default:""},data:{default:""},options:{default:()=>[]},api:{default:null},maxHeight:{default:400},parent:{},set:{},slot:{},add:{},teleport:{default:"body"},auto:{default:0},start:{default:0},style:{default:()=>({})},customClass:{default:""},modelValue:{},error:{default:null},name:{},maxlength:{},minlength:{}},emits:["change","update:modelValue","value-selected"],setup(n,{emit:e}){const t=n,r=e,o=s.computed(()=>t.multiple),i=s.computed(()=>t.disabled),l=s.computed(()=>t.search);Vt(t.style);const a=s.computed({get:()=>t.modelValue,set:q=>r("update:modelValue",q)});(a.value===null||a.value===void 0||a.value==="")&&t.defaultValue!=null&&(a.value=t.defaultValue);const c=s.ref(null),d=s.ref(null),u=s.ref(null),f=s.ref(null),p=s.ref(!1),h=s.ref(!1),m=s.ref(null),g=s.ref(-1),y=s.ref([]),b=s.ref(""),w=s.ref(null),v=q=>{d.value=q},E=q=>{w.value=q},N=q=>{f.value=q},R=q=>{u.value=q},T=(q,se)=>{y.value[se]=q},M=s.ref({}),_=s.ref([]),A=s.computed(()=>{if(!_.value.length)return[];const q=xe.value,se=new Map(q.map(me=>[me.id?.toString(),me]));return _.value.map(me=>se.get(me?.toString())).filter(me=>!!me)}),L=s.computed(()=>t.placeholder||"Select..."),z=s.computed(()=>le(m.value)),Z=s.computed(()=>i.value?!1:o.value?_.value.length>0:a.value!==null&&a.value!==void 0&&a.value!==""),D=q=>o.value?_.value.some(se=>se?.toString()===q?.toString()):a.value?.toString()===q?.toString(),P=s.computed(()=>{let q=xe.value??[];if(!t.data&&b.value.trim()!==""){const se=b.value.toLowerCase();q=q.filter(me=>{const Le=le(me).toLowerCase(),st=me.text?.toLowerCase?.()||"";return Le.includes(se)||st.includes(se)})}if(o.value&&_.value.length){const se=new Set(_.value.map(me=>me?.toString()));q=q.filter(me=>!se.has(me.id?.toString()))}return q}),ne=s.inject("values"),U=s.inject("field-props"),K=s.computed(()=>t.slot??t?.optionTemplate??""),X=q=>Js(q,K.value),le=q=>Ys(q,K.value),H=s.computed(()=>Ks(K.value)),$=q=>No(q),I=q=>!!(!H.value&&Zn(q)&&!$(q)),te=q=>{const se=Zn(q);return se?{color:se}:void 0},ae=q=>!!(!H.value&&(Bo(q)||$(q))),re=(q,se,me)=>{if(!U)return!1;const Le=U.value?.[q]??{},st=(it,Mt,An)=>{if(!Mt.length)return it;const[rn,..._n]=Mt,on={...it};if(!_n.length)return on[rn]=An,on;const Cr=typeof it[rn]=="object"&&it[rn]!==null?it[rn]:{};return on[rn]=st(Cr,_n,An),on},Et=st(Le,se,me);return U.value={...U.value||{},[q]:Et},!0},ge=q=>{if(!U||!t.name)return;const se=U.value?.[t.name]??{};U.value={...U.value||{},[t.name]:{...se,[D1]:q}}},Ee=q=>{if(!t.set)return;const se=ne?.value;!se&&!U||Object.entries(t.set).forEach(([me,Le])=>{if(!me)return;const st=q?q[Le]:null,Et=me.split(".").map(An=>An.trim()).filter(Boolean);if(!Et.length)return;const[it,...Mt]=Et;Mt.length&&re(it,Mt,st??null)||se&&(se[it]=st??null)})},{optionsList:xe,parentValue:Ie,fetchOptions:je,fetchOptionByValue:Fe,loadOptions:ot}=Gs({props:t,formValues:ne,watchParent:!1}),We=q=>q==null?"":String(q),oe=q=>{if(o.value){if(!_.value.length){xe.value=q;return}}else if(!m.value){xe.value=q;return}const se=new Set(q.map(Le=>We(Le.id)).filter(Boolean));if(o.value){const Le=new Set(_.value.map(Et=>We(Et)).filter(Boolean)),st=(xe.value??[]).filter(Et=>{const it=We(Et.id);return!it||!Le.has(it)?!1:!se.has(it)});xe.value=[...st,...q];return}const me=We(m.value?.id);if(me&&!se.has(me)){xe.value=[m.value,...q];return}xe.value=q},pe=s.ref(0),_e=async q=>{const se=++pe.value,me=await je(q);return se!==pe.value?null:me},Te=async()=>{if(t.data){const q=await _e(b.value);return q&&oe(q),xe.value}return ot()},dt=async q=>{if(q==null||q==="")return null;const se=xe.value?.find(me=>me?.id?.toString()===String(q));return se||Fe(q)},Ye=async q=>{const se=new Set(xe.value.map(Le=>Le.id?.toString())),me=q.filter(Le=>!se.has(Le?.toString()));me.length&&await me.reduce(async(Le,st)=>{await Le;const Et=await dt(st);Et&&xe.value.push(Et)},Promise.resolve())},Dt=()=>{if(!P.value.length){g.value=-1;return}let q=0;if(!o.value&&m.value){const se=m.value.id?.toString(),me=P.value.findIndex(Le=>Le.id?.toString()===se);me>=0&&(q=me)}g.value=q,s.nextTick(()=>{j(y.value[q],u.value)})},Pe=async()=>{i.value||(p.value=!0,await s.nextTick(()=>{Me()}),await Te(),await s.nextTick(()=>{Me(),w.value?.focus()}),Dt())},qe=()=>{p.value=!1,g.value=-1,s.nextTick(()=>{w.value?.blur()})},tn=async q=>{if(i.value)return;(q!==void 0?q:!p.value)?await Pe():qe()},W=async()=>{if(!i.value){if(p.value){qe();return}await Pe()}},Q=()=>{o.value?(_.value=[],a.value=[],r("change",[]),O(null,[])):(m.value=null,a.value=null,r("change",null),O(null,null)),Ee(null),ge(null),b.value="",qe(),s.nextTick(()=>{w.value?.focus()})},de=q=>{o.value&&(_.value=_.value.filter(se=>se?.toString()!==q?.toString()),a.value=[..._.value],r("change",a.value),O(null),s.nextTick(()=>w.value?.focus()))},O=(q,se)=>{const me=se??(o.value?[..._.value]:q?.id??null);r("value-selected",{name:t.name,value:me,option:q})},C=(q,se="manual")=>{o.value?(D(q.id)||(_.value=[..._.value,q.id],a.value=[..._.value],r("change",a.value),O(q)),b.value="",s.nextTick(()=>{w.value?.focus(),g.value=Math.min(g.value,P.value.length-1)}),Ee(null)):(m.value=q,a.value=q.id,r("change",a.value),O(q),b.value="",qe(),Ee(q),se==="parent-auto"&&ge({source:se,parentField:t.parent??null,parentValue:Ie.value??null}))},V=q=>{if(D(q.id)){o.value||qe();return}C(q)},j=(q,se)=>{if(!q||!se)return;const me=q.offsetTop,Le=me+q.offsetHeight,st=se.scrollTop,Et=st+se.clientHeight;let it=se.scrollTop;me<st?it=me-80:Le>Et&&(it=Le-se.clientHeight+4);const Mt=se;Mt.scrollTop=it},ie=q=>{let se=q.parentElement;for(;se;){if(se.classList.contains("ui-dialog__content"))return se;const me=window.getComputedStyle(se),Le=me.overflow+me.overflowY+me.overflowX;if(Le.includes("auto")||Le.includes("scroll")||se===document.body||se===document.documentElement)return se;se=se.parentElement}return document.body},Me=()=>{if(!d.value)return;const q=d.value.getBoundingClientRect(),se=window.innerHeight||document.documentElement.clientHeight,me=window.innerWidth||document.documentElement.clientWidth,Le=8,st=8,Et=t.maxHeight||300,it=se-q.bottom-st-Le,Mt=q.top-st-Le,An=it>=Mt,rn=Math.max(me-Le*2,0);let{width:_n}=q;rn>0&&_n>rn&&(_n=rn);let{left:on}=q;on+_n+Le>me&&(on=me-_n-Le),on=Math.max(on,Le);const Cr=Math.min(Et,Math.max(An?it:Mt,50));M.value={position:"fixed",left:`${on}px`,width:`${_n}px`,maxHeight:`${Cr}px`,transform:An?"none":"translateY(-100%)",top:An?`${q.bottom+st}px`:`${q.top-st}px`}},Ze=async q=>{i.value||!p.value&&(q.key==="ArrowDown"||q.key==="ArrowUp")&&(q.preventDefault(),await Pe())},Ge=q=>{if(!p.value)return;const{key:se}=q;if(se==="ArrowDown")q.preventDefault(),g.value+1<P.value.length&&(g.value+=1,j(y.value[g.value],u.value));else if(se==="ArrowUp")q.preventDefault(),g.value>0&&(g.value-=1,j(y.value[g.value],u.value));else if(se==="Enter"){q.preventDefault();const me=P.value[g.value];me&&C(me),w.value?.blur()}else se==="Escape"?(q.preventDefault(),qe()):se==="Backspace"?o.value&&b.value===""&&_.value.length&&(_.value=_.value.slice(0,-1),a.value=[..._.value],r("change",a.value)):se==="Home"?(g.value=0,j(y.value[0],u.value)):se==="End"?(g.value=P.value.length-1,j(y.value[g.value],u.value)):se==="Tab"&&qe()},ut=()=>{i.value||(h.value=!0)},mt=()=>{h.value=!1,b.value=""},nn=q=>{q.key==="Escape"&&p.value&&qe()},gt=q=>{const se=q.target;c.value?.contains(se)||f.value?.contains(se)||qe()},Wt=q=>{p.value&&u.value&&!u.value.contains(q.target)&&Me()},xr=()=>{p.value&&Me()},sa=()=>{p.value&&Me()};async function Mo(){if(o.value)Array.isArray(a.value)?_.value=[...a.value]:(_.value=a.value==null?[]:[a.value],a.value=[..._.value]),t.data&&_.value.length&&(await Ye(_.value),await s.nextTick());else{if(Array.isArray(a.value)){const q=a.value[0]??null;a.value=q??null}a.value!=null&&a.value!==""?m.value=await dt(a.value):m.value=null,Ee(m.value??null)}}s.watch(a,()=>{Mo()}),s.onMounted(async()=>{if(addEventListener("keydown",nn),addEventListener("scroll",Wt,!0),addEventListener("resize",xr),document.addEventListener("click",gt,!0),d.value&&ie(d.value).addEventListener("scroll",sa,!0),t.options?.length&&!t.data)xe.value=[...t.options];else if(t.data){const q=await _e("");q&&oe(q)}await Mo(),to.value=!1}),s.onUnmounted(()=>{removeEventListener("keydown",nn),removeEventListener("scroll",Wt,!0),removeEventListener("resize",xr),document.removeEventListener("click",gt,!0),d.value&&ie(d.value).removeEventListener("scroll",sa,!0)});const{isOpenAdd:Kn,addData:vr,addSchema:G,addForm:ye,addTitle:Ft,addOption:qn,onAddValue:Mn}=Ju({props:t,fetchOptionByValue:Fe,optionsList:xe,selectedOption:m,modelValue:a});function yt(q,se=200){let me;return(...Le)=>{me&&clearTimeout(me),me=window.setTimeout(()=>q(...Le),se)}}const Ao=yt(async q=>{const se=await _e(q);se&&oe(se)},200);s.watch(b,q=>{t.data&&Ao(q.trim())}),s.watch(()=>t.options,q=>{!t.data&&q?.length&&(xe.value=[...q],Mo())},{immediate:!0});const to=s.ref(!0);return s.watch(Ie,async()=>{if(t.data&&(to.value||(o.value?(_.value=[],a.value=[],r("change",[])):(m.value=null,a.value=null,r("change",null))),await Te(),t.auto===1&&Ie.value&&xe.value.length>0)){const q=xe.value[0];q&&C(q,"parent-auto")}}),(q,se)=>(s.openBlock(),s.createElementBlock(s.Fragment,null,[s.createVNode(s.unref(we.VsModal),{visible:s.unref(Kn),"onUpdate:visible":se[2]||(se[2]=me=>s.isRef(Kn)?Kn.value=me:null),class:"z-[1000]",title:s.unref(Ft),teleport:q.teleport},{footer:s.withCtx(({handleClose:me})=>[s.createElementVNode("div",T1,[s.createElementVNode("button",{type:"button",class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-gray-200 bg-white text-gray-800 hover:bg-gray-50",onClick:me}," Скасувати ",8,B1),s.createElementVNode("button",{type:"button",class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-transparent bg-blue-600 text-white hover:bg-blue-700",onClick:se[1]||(se[1]=(...Le)=>s.unref(qn)&&s.unref(qn)(...Le))}," Додати ")])]),default:s.withCtx(()=>[s.createVNode(zt,{schema:s.unref(G),modelValue:s.unref(vr),"onUpdate:modelValue":se[0]||(se[0]=me=>s.isRef(vr)?vr.value=me:null),ref_key:"addForm",ref:ye},null,8,["schema","modelValue"])]),_:1},8,["visible","title","teleport"]),s.createElementVNode("div",{class:"flex gap-1 w-full",ref_key:"selectRoot",ref:c,onClick:se[5]||(se[5]=s.withModifiers(()=>{},["stop"]))},[s.createElementVNode("div",{class:s.normalizeClass(["relative w-full font-sans",t.customClass])},[se[6]||(se[6]=s.createElementVNode("span",{id:"react-select-live-region",class:"sr-only"},null,-1)),se[7]||(se[7]=s.createElementVNode("span",{"aria-live":"polite","aria-atomic":"false","aria-relevant":"additions text",role:"log",class:"sr-only"},null,-1)),s.createVNode(C1,{keyWord:b.value,"onUpdate:keyWord":se[3]||(se[3]=me=>b.value=me),disabled:i.value,"is-open":p.value,"input-focus":h.value,"is-multi":o.value,"selected-options":A.value,"selected-ids":_.value,placeholder:L.value,search:l.value,"option-template":K.value,"icon-wrapper-class":Yu,"selected-option-label":z.value,"selected-option":m.value,"show-clear":Z.value,"set-trigger-ref":v,"set-input-ref":E,"should-show-color-dot":I,"option-has-icon":ae,"get-icon-color-style":te,"resolve-option-icon":$,"render-template":X,"get-label":le,"on-control-keydown":Ze,"on-control-click":W,"on-input-focus":ut,"on-input-blur":mt,"on-input-keydown":Ge,"on-remove-selected":de,"on-clear-selected":Q,"on-toggle-select":tn},null,8,["keyWord","disabled","is-open","input-focus","is-multi","selected-options","selected-ids","placeholder","search","option-template","selected-option-label","selected-option","show-clear"]),s.createVNode(_1,{"is-open":p.value,"dropdown-style":M.value,"filtered-options-list":P.value,"selected-nav-index":g.value,"option-template":K.value,"icon-wrapper-class":Yu,"set-dropdown-ref":N,"set-list-ref":R,"set-item-ref":T,"is-selected":D,"on-option-click":V,"should-show-color-dot":I,"option-has-icon":ae,"get-icon-color-style":te,"resolve-option-icon":$,"render-template":X},null,8,["is-open","dropdown-style","filtered-options-list","selected-nav-index","option-template"])],2),t.add?(s.openBlock(),s.createElementBlock("button",{key:0,onClick:se[4]||(se[4]=(...me)=>s.unref(Mn)&&s.unref(Mn)(...me)),class:"bg-white hover:bg-gray-100 text-sm text-gray-900 py-[10px] px-3 border border-stone-200 rounded-md h-[38px] flex items-center gap-2",disabled:i.value,type:"button"},[s.createVNode(s.unref(Y.Plus),{class:"h-4 w-4"}),se[8]||(se[8]=s.createElementVNode("span",null,"Додати",-1))],8,N1)):s.createCommentVNode("",!0)],512)],64))}}),[["__scopeId","data-v-9b686f27"]]),Na=(n="")=>`${n}${Math.floor(Math.random()*1e4)}`,V1=["disabled","aria-expanded"],$1={class:"truncate"},L1={class:"py-2 px-4"},I1={class:"block font-medium text-[13px] text-foreground"},O1={class:"truncate"},R1={class:"p-1 border-t border-gray-200"},F1={class:"space-y-0.5 max-h-48 overflow-y-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-none [&::-webkit-scrollbar-track]:bg-scrollbar-track [&::-webkit-scrollbar-thumb]:bg-scrollbar-thumb"},P1=["onClick"],z1=["checked"],H1={class:"shrink-0 size-3.5 flex justify-center items-center"},j1={key:1,class:"shrink-0 size-2 block mx-auto rounded-full bg-secondary/60"},U1={class:"truncate"},W1={key:0,class:"px-3 py-2 text-xs text-stone-500"},ii=s.defineComponent({__name:"vs-input-inline-select",props:{multiple:{type:Boolean},disabled:{type:Boolean,default:!1},mode:{},defaultValue:{},search:{type:Boolean},placeholder:{default:"Оберіть значення"},prefix:{default:"api"},host:{default:""},data:{default:""},options:{default:()=>[]},api:{default:null},maxHeight:{},parent:{},set:{},slot:{},add:{},teleport:{default:"body"},auto:{},start:{default:0},style:{default:()=>({})},customClass:{default:""},modelValue:{},error:{default:null},name:{},maxlength:{},minlength:{}},emits:["change","update:modelValue","value-selected"],setup(n,{emit:e}){const t=n,r=e;Vt(t.style);const o=s.computed({get:()=>Array.isArray(t.modelValue)?t.modelValue[0]??null:t.modelValue??null,set:re=>r("update:modelValue",re)});o.value==null&&t.defaultValue!=null&&(o.value=t.defaultValue);const i=s.inject("values"),l=s.inject("field-props"),a=s.computed(()=>!!t.disabled),c=s.ref(null),d=s.ref(!1),u=s.ref(null),f=s.ref(null),p=s.ref(null),h=s.ref({}),m=`vs-input-inline-select-${Na()}`,g=s.computed(()=>t.placeholder||"Оберіть значення"),y=s.computed(()=>N(c.value)||t.placeholder||"Оберіть значення"),b=s.computed(()=>t.slot??""),w=s.computed(()=>Ks(b.value)),v=s.computed(()=>t.teleport||"body"),E=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6}|[\da-fA-F]{8})$/,N=re=>Ys(re,b.value),R=re=>!!(!w.value&&Zn(re)),T=s.computed(()=>{const re=Zn(c.value).trim();return re?E.test(re)?`bg-[${re}] border-[${re}]`:`bg-${re.toLowerCase()}-500 border-${re.toLowerCase()}-500`:""}),{optionsList:M,parentValue:_,fetchOptions:A,fetchOptionByValue:L,loadOptions:z}=Gs({props:t,formValues:i,watchParent:!1}),Z=(re,ge,Ee)=>{if(!l)return!1;const xe=l.value?.[re]??{},Ie=(Fe,ot,We)=>{if(!ot.length)return Fe;const[oe,...pe]=ot,_e={...Fe};if(!pe.length)return _e[oe]=We,_e;const Te=typeof Fe[oe]=="object"&&Fe[oe]!==null?Fe[oe]:{};return _e[oe]=Ie(Te,pe,We),_e},je=Ie(xe,ge,Ee);return l.value={...l.value||{},[re]:je},!0},D=re=>{if(!t.set)return;const ge=i?.value;!ge&&!l||Object.entries(t.set).forEach(([Ee,xe])=>{if(!Ee)return;const Ie=re?re[xe]:null,je=Ee.split(".").map(We=>We.trim()).filter(Boolean);if(!je.length)return;const[Fe,...ot]=je;ot.length&&Z(Fe,ot,Ie??null)||ge&&(ge[Fe]=Ie??null)})},P=re=>o.value?.toString?.()===re?.toString?.(),ne=()=>{if(!f.value||typeof window>"u")return;const re=f.value.getBoundingClientRect(),ge=8,Ee=8,xe=window.innerHeight||document.documentElement.clientHeight,Ie=window.innerWidth||document.documentElement.clientWidth,je=p.value?.offsetHeight||260,Fe=Math.max(re.width,176),ot=Math.max(Ie-ge*2,120),We=Math.min(Fe,ot);let oe=re.left;oe+We+ge>Ie&&(oe=Ie-We-ge),oe=Math.max(oe,ge);const pe=xe-re.bottom-Ee-ge,_e=re.top-Ee-ge,Te=pe<Math.min(je,260)&&_e>pe,dt=Math.max(120,Math.min(320,Te?_e:pe));h.value={position:"fixed",left:`${oe}px`,top:Te?`${re.top-Ee}px`:`${re.bottom+Ee}px`,transform:Te?"translateY(-100%)":"none",width:`${We}px`,maxHeight:`${dt}px`}},U=async()=>{if(t.data){M.value=await A("");return}await z()},K=async()=>{if(o.value==null||o.value===""){c.value=null,D(null);return}const re=M.value.find(ge=>ge.id?.toString()===String(o.value));if(re){c.value=re,D(re);return}c.value=await L(o.value),D(c.value??null)},X=async()=>{a.value||(d.value=!0,await s.nextTick(),ne(),await U(),await s.nextTick(),ne())},le=()=>{d.value=!1},H=async()=>{if(d.value){le();return}await X()},$=re=>{r("value-selected",{name:t.name,value:re?.id??null,option:re})},I=re=>{c.value=re,o.value=re.id,r("change",re.id),$(re),D(re),le()},te=re=>{const ge=re.target;u.value?.contains(ge)||p.value?.contains(ge)||le()},ae=()=>{d.value&&ne()};return s.watch(()=>t.options,re=>{t.data||(M.value=re?[...re]:[],K())},{immediate:!0,deep:!0}),s.watch(o,()=>{K()}),s.watch(_,async()=>{t.data&&(await U(),c.value&&!M.value.some(re=>re.id?.toString()===c.value?.id?.toString())&&(c.value=null,o.value=null,r("change",null),$(null),D(null)))}),s.onMounted(async()=>{document.addEventListener("click",te,!0),window.addEventListener("resize",ae),window.addEventListener("scroll",ae,!0),await U(),await K()}),s.onUnmounted(()=>{document.removeEventListener("click",te,!0),window.removeEventListener("resize",ae),window.removeEventListener("scroll",ae,!0)}),(re,ge)=>(s.openBlock(),s.createElementBlock("div",{class:"relative inline-flex w-full max-w-full",ref_key:"rootRef",ref:u,onClick:ge[0]||(ge[0]=s.withModifiers(()=>{},["stop"]))},[s.createElementVNode("button",{ref_key:"triggerRef",ref:f,type:"button",disabled:a.value,"aria-expanded":d.value?"true":"false","aria-haspopup":"menu",class:s.normalizeClass(["py-1.5 px-2.5 inline-flex items-center gap-2 text-nowrap text-xs sm:text-[13px] rounded-lg focus:outline-hidden disabled:opacity-50 disabled:pointer-events-none max-w-full border",T.value?`${T.value} text-white`:"bg-secondary text-secondary-foreground hover:bg-secondary-hover focus:bg-secondary-focus border-gray-300 hover:border-gray-400"]),onClick:H},[s.createElementVNode("span",$1,s.toDisplayString(y.value),1)],10,V1),(s.openBlock(),s.createBlock(s.Teleport,{to:v.value},[d.value?(s.openBlock(),s.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:p,class:"z-[3000] w-44 transition-[opacity,margin] duration-150 bg-white text-gray-900 border border-gray-200 rounded-xl shadow-lg",style:s.normalizeStyle(h.value),role:"menu","aria-orientation":"vertical"},[s.createElementVNode("div",L1,[s.createElementVNode("span",I1,[s.createElementVNode("span",O1,s.toDisplayString(g.value),1)])]),s.createElementVNode("div",R1,[s.createElementVNode("div",F1,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(s.unref(M),Ee=>(s.openBlock(),s.createElementBlock("label",{key:Ee.id,class:"py-1.5 px-3 group flex items-center gap-x-3 rounded-lg cursor-pointer text-[13px] text-gray-800 hover:bg-gray-100",onClick:s.withModifiers(xe=>I(Ee),["prevent"])},[s.createElementVNode("input",{type:"radio",class:"hidden",name:m,checked:P(Ee.id),tabindex:"-1"},null,8,z1),s.createElementVNode("span",H1,[R(Ee)?(s.openBlock(),s.createElementBlock("span",{key:0,class:"shrink-0 size-2 block mx-auto rounded-full",style:s.normalizeStyle({backgroundColor:Ee.color})},null,4)):(s.openBlock(),s.createElementBlock("span",j1))]),s.createElementVNode("span",U1,s.toDisplayString(N(Ee)),1),s.createVNode(s.unref(Y.Check),{class:s.normalizeClass(["shrink-0 size-3.5 ms-auto transition-opacity",P(Ee.id)?"opacity-100":"opacity-0"])},null,8,["class"])],8,P1))),128))]),s.unref(M).length?s.createCommentVNode("",!0):(s.openBlock(),s.createElementBlock("p",W1,"Немає варіантів"))])],4)):s.createCommentVNode("",!0)],8,["to"]))],512))}}),K1=["placeholder","disabled"],Xu=s.defineComponent({__name:"vs-input-textarea",props:s.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const e=n,{inputClass:t}=Vt(e.style),r=s.useModel(n,"modelValue"),o=s.computed(()=>!!e.disabled),i=s.computed(()=>e.placeholder??"");function l(){typeof r.value=="string"&&(r.value=r.value.trim())}return(a,c)=>s.withDirectives((s.openBlock(),s.createElementBlock("textarea",{"onUpdate:modelValue":c[0]||(c[0]=d=>r.value=d),placeholder:i.value,disabled:o.value,row:"2",onBlur:l,class:s.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] h-auto bg-white",[s.unref(t)]]),style:{border:"1px solid #CFD9E0"}},null,42,K1)),[[s.vModelText,r.value]])}}),Zu=s.defineComponent({__name:"vs-input-richtext",props:s.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{},format:{default:"html"},richtextProps:{default:()=>({})}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const e=s.defineAsyncComponent(()=>Promise.resolve().then(()=>yT)),t=n,r=s.useModel(n,"modelValue"),o=s.computed(()=>!!t.disabled),i=s.computed(()=>t.placeholder??""),l=s.computed(()=>({height:t.richtextProps.height||"300px",format:t.format,...t.richtextProps}));return(a,c)=>(s.openBlock(),s.createElementBlock("div",{class:s.normalizeClass(["!h-full overflow-hidden rounded-md border border-solid border-stone-200 disabled:opacity-50 disabled:cursor-not-allowed",a.customClass]),style:s.normalizeStyle(o.value?{pointerEvents:"none",opacity:.6}:{})},[s.createVNode(s.unref(e),s.mergeProps({modelValue:r.value,"onUpdate:modelValue":c[0]||(c[0]=d=>r.value=d),placeholder:i.value},l.value),null,16,["modelValue","placeholder"])],6))}}),q1={},G1={viewBox:"0 0 178 90",fill:"none",xmlns:"http://www.w3.org/2000/svg"};function J1(n,e){return s.openBlock(),s.createElementBlock("svg",G1,e[0]||(e[0]=[s.createStaticVNode('<rect x="27" y="50.5" width="124" height="39" rx="7.5" fill="currentColor" class="fill-white dark:fill-neutral-800"></rect><rect x="27" y="50.5" width="124" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-50 dark:stroke-neutral-700/10"></rect><rect x="34.5" y="58" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="66.5" y="61" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="66.5" y="73" width="77" height="6" rx="3" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="19.5" y="28.5" width="139" height="39" rx="7.5" fill="currentColor" class="fill-white dark:fill-neutral-800"></rect><rect x="19.5" y="28.5" width="139" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-100 dark:stroke-neutral-700/30"></rect><rect x="27" y="36" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><rect x="59" y="39" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><rect x="59" y="51" width="92" height="6" rx="3" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><g filter="url(#filter1)"><rect x="12" y="6" width="154" height="40" rx="8" fill="currentColor" class="fill-white dark:fill-neutral-800" shape-rendering="crispEdges"></rect><rect x="12.5" y="6.5" width="153" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-100 dark:stroke-neutral-700/60" shape-rendering="crispEdges"></rect><rect x="20" y="14" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect><rect x="52" y="17" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect><rect x="52" y="29" width="106" height="6" rx="3" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect></g><defs><filter id="filter1" x="0" y="0" width="178" height="64" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"></feColorMatrix><feOffset dy="6"></feOffset><feGaussianBlur stdDeviation="6"></feGaussianBlur><feComposite in2="hardAlpha" operator="out"></feComposite><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.03 0"></feColorMatrix><feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_1187_14810"></feBlend><feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_1187_14810" result="shape"></feBlend></filter></defs>',12)]))}const Y1=Ne(q1,[["render",J1]]),X1={class:"bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden flex flex-col"},Z1={key:0,class:"flex flex-col gap-2 !p-4 border-b border-gray-200 md:flex-row md:items-center md:justify-between bg-gray-50"},Q1={key:0,class:"relative flex-1 min-w-0"},ev={class:"flex md:flex-nowrap flex-wrap items-center md:justify-end justify-start gap-2 shrink-0"},tv={class:"w-full overflow-x-auto"},nv={class:"w-full min-w-[640px] table-auto divide-y divide-gray-200"},rv={class:"bg-gray-50"},ov={class:"border-b border-gray-200"},sv={class:"px-4 py-3 text-left text-xs font-semibold text-gray-900 w-12 text-center"},iv=["onClick"],lv={key:0,class:"text-gray-400"},av={key:0,colspan:"100%",class:"text-center"},cv={class:"w-full"},dv={class:"p-5 min-h-[200px] flex flex-col justify-center items-center text-center"},uv=["data-row-index","onDragstart","onDragover","onDrop"],fv=["onPointerdown"],pv={class:"flex items-center justify-center"},hv=["innerHTML"],mv={key:0,class:"flex items-center gap-3 text-sm text-gray-700"},gv={key:0},yv=["src"],bv={key:1,class:"rounded-md max-w-[45px] w-[45px] max-h-[45px] h-[45px] bg-gray-200 flex items-center justify-center"},kv={key:1,class:"flex items-center justify-center"},wv=["innerHTML"],xv={key:3,class:"text-sm font-medium text-gray-900"},vv={class:"px-4 py-3 text-right whitespace-nowrap"},Cv={class:"flex items-center justify-end gap-2"},Sv=["onClick"],Ev=["onClick"],Mv={class:"vs-form__head mr-5 mt-3 flex items-center justify-end sticky top-0 left-0 z-[60] bg-white"},Qu=Ne(s.defineComponent({__name:"vs-input-datatable",props:s.mergeModels({actions:{},colModel:{},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const e=n,t=s.useSlots(),r=s.inject("values",null),o=s.inject("form-root-values",null),i=W=>e.actions===void 0?!0:e.actions.includes(W),l=["search","import","export","add"],a=s.computed(()=>l.some(W=>i(W))),c=s.useModel(n,"modelValue"),d=s.ref({}),u=s.ref(""),f=s.ref(null),p=s.ref("asc"),h=s.computed(()=>{const W=c.value??[],Q=u.value?W.filter(C=>m.value?.some(V=>{const j=V.key||V.name;if(!j)return!1;const ie=C[j];return ie?Array.isArray(ie)?ie.join(", ").toLowerCase().includes(u.value.toLowerCase()):String(ie).toLowerCase().includes(u.value.toLowerCase()):!1})):W;if(!f.value)return Q;const de=f.value,O=[...Q].sort((C,V)=>{const j=Fe(C?.[de]),ie=Fe(V?.[de]);return typeof j=="number"&&typeof ie=="number"?j-ie:String(j).localeCompare(String(ie))});return p.value==="asc"?O:O.reverse()}),m=s.computed(()=>(e.colModel??[]).filter(W=>!W.tableHidden)),g=s.ref(null),y=s.ref(null),b=s.ref(null);function w(W){return W.pointerType==="touch"||W.pointerType==="pen"}function v(W,Q){const O=document.elementFromPoint(W,Q)?.closest?.("[data-row-index]")??null;if(!O)return null;const C=O.getAttribute("data-row-index");if(C==null)return null;const V=Number.parseInt(C,10);return Number.isNaN(V)?null:V}function E(W,Q){w(W)&&(W.preventDefault(),W.currentTarget.setPointerCapture(W.pointerId),g.value=Q,y.value=Q)}function N(W){if(g.value===null||!w(W))return;W.preventDefault();const Q=v(W.clientX,W.clientY);Q!==null&&(y.value=Q)}function R(W){if(g.value===null||!w(W))return;W.preventDefault();const Q=v(W.clientX,W.clientY);A(Q??g.value);try{W.currentTarget.releasePointerCapture(W.pointerId)}catch{}}function T(W){if(w(W)){g.value=null,y.value=null;try{W.currentTarget.releasePointerCapture(W.pointerId)}catch{}}}const M=W=>{g.value=W},_=W=>{y.value=W},A=W=>{if(g.value===null||g.value===W){g.value=null,y.value=null;return}const Q=[...c.value],[de]=Q.splice(g.value,1);Q.splice(W,0,de),c.value=Q,g.value=null,y.value=null},L=()=>{b.value&&b.value.click()},z=W=>{const Q=[".jpg",".jpeg",".png",".gif",".bmp",".webp",".svg",".ico",".tiff",".tif"],de=W.toLowerCase();return Q.some(O=>de.endsWith(O))},Z=W=>{const de=W.target.files?.[0];if(!de)return;const O=new FileReader;O.onload=C=>{try{const V=C.target?.result;if(typeof V=="string"){const j=JSON.parse(V);Array.isArray(j)&&c.value.push(...j)}}catch(V){console.error("Error parsing file:",V)}},O.readAsText(de)},D=()=>{const W=JSON.stringify(c.value,null,2),Q=new Blob([W],{type:"application/json"}),de=URL.createObjectURL(Q),O=document.createElement("a");O.href=de,O.download="data.json",O.click(),URL.revokeObjectURL(de)},P=new Set(["autocomplete","select","radio","checkbox","combobox"]),ne=new Map,U=(W,Q)=>{const de=`/api/suggest/${W}`,O=de.includes("?")?"&":"?",C=Q?`&val=${Q}`:"";return`${de}${O}${C}`},K=W=>W==null||W===""?null:typeof W=="object"?W?.id!==void 0&&W.id!==null&&W.id!==""?W.id:null:W,X=W=>{const Q=new Set;return Array.isArray(c.value)&&c.value.forEach(de=>{const O=de?.[W];if(O==null||O==="")return;if(Array.isArray(O)){O.forEach(V=>{const j=K(V);j!==null&&Q.add(j)});return}const C=K(O);C!==null&&Q.add(C)}),Q},le=async()=>{if(!e.colModel?.length)return;const W=e.colModel.filter(Q=>Q.data&&P.has(Q.type?.toLowerCase()||""));W.length&&await Promise.all(W.map(async Q=>{const de=Q.key||Q.name;if(!de)return;const O=X(de),C=Array.from(O).map(ie=>String(ie)).sort(),V=C.join(",");if(!C.length||ne.get(de)===V)return;ne.set(de,V);const j=C.map(encodeURIComponent).join(",");try{const Me=await(await fetch(U(Q.data,j))).json();d.value[de]=Me?.data??Me}catch(ie){console.error("Failed to fetch column values",ie)}}))};s.watch([()=>e.colModel,()=>c.value],()=>{le()},{immediate:!0,deep:!0});const H=s.ref(""),$=s.ref(!1);let I="edit",te=0;const ae=W=>(W?.format||W?.type||"").toString().toLowerCase(),re=s.computed(()=>(e.colModel?.filter(Q=>ae(Q)!=="slot")??[]).map(Q=>{const de=Q.key||Q.name;return de?{...Q,name:de,key:de}:Q})),ge=s.ref({}),Ee=s.ref({}),xe=W=>typeof W!="string"?!1:!!t[W],Ie=(W,Q)=>Q?Q.split(".").reduce((de,O)=>de==null?de:de[O.trim()],W):W,je=(W,Q)=>typeof W!="string"?"":W.replace(/{{\s*([^}]+)\s*}}/g,(de,O)=>{const C=Ie(Q,O.trim());return C??""}),Fe=W=>{if(W==null||W==="")return"";if(typeof W=="number")return W;if(typeof W=="boolean")return W?1:0;if(typeof W=="string")return W.toLowerCase();if(Array.isArray(W))return W.map(Q=>Fe(Q)).join(", ");if(typeof W=="object"){if(W.text!==void 0)return String(W.text).toLowerCase();if(W.label!==void 0)return String(W.label).toLowerCase();if(W.id!==void 0)return String(W.id).toLowerCase()}return String(W).toLowerCase()},ot=W=>{const Q=W.key||W.name;if(Q){if(f.value===Q){p.value=p.value==="asc"?"desc":"asc";return}f.value=Q,p.value="asc"}};async function We(){H.value="Додати",$.value=!0,I="add",ge.value=dt({})}function oe(W,Q){if(!W?.length)return null;const de=typeof Q=="object"?Q?.id:Q;if(de==null||de==="")return null;const O=W.find(C=>C?.id?.toString()===de.toString());return O?O.text??O.label??null:null}function pe(W){return W==null||W===""?"-":Array.isArray(W)?W.map(Q=>typeof Q=="object"?Q?.text??Q?.label??Q?.id??"-":Q).join(", "):typeof W=="object"?W?.text??W?.label??W?.id??"-":W}function _e(W){const Q=W.key||W.name,de=Q?d.value[Q]:null;return Array.isArray(de)&&de.length?de:Array.isArray(W?.options)&&W.options.length?W.options:null}function Te(W,Q){const de=Q.key||Q.name,O=W?.[de],C=_e(Q);if(O==null||O==="")return"-";if(Array.isArray(O)){const j=O.map(ie=>oe(C,ie)).filter(Boolean);return j.length?j.join(", "):pe(O)}const V=oe(C,O);return V||pe(O)}function dt(W){const Q=r?.value?.content_id??o?.value?.id??o?.value?.content_id??r?.value?.id??null;return{...W,content_id:Q}}function Ye(W){if(!W||typeof W!="object")return W;const{content_id:Q,...de}=W;return de}async function Dt(W,Q){H.value="Редагувати",$.value=!0,I="edit",te=Q,ge.value=dt({...W})}function Pe(){const W=Ee.value.validate();if(W){we.notify({type:"warning",title:"Помилка валідації",message:Object.entries(W).map(([de,O])=>`${de}: ${O}`).join(`
2
+ `)});return}const Q=Ye(ge.value);I==="add"?Array.isArray(c.value)?c.value=[...c.value,Q]:c.value=[Q]:c.value=c.value.map((de,O)=>O===te?Q:de),$.value=!1}function qe(W){c.value=c.value.filter((Q,de)=>de!==W)}function tn(){$.value=!1}return(W,Q)=>(s.openBlock(),s.createElementBlock("div",X1,[a.value?(s.openBlock(),s.createElementBlock("div",Z1,[i("search")?(s.openBlock(),s.createElementBlock("div",Q1,[s.createVNode(s.unref(Y.Search),{class:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),s.withDirectives(s.createElementVNode("input",{type:"text","onUpdate:modelValue":Q[0]||(Q[0]=de=>u.value=de),placeholder:"Пошук",class:"w-full rounded-md border border-gray-200 bg-white pl-10 pr-3 py-2 text-sm text-gray-900 placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100"},null,512),[[s.vModelText,u.value]])])):s.createCommentVNode("",!0),s.createElementVNode("div",ev,[i("import")?(s.openBlock(),s.createElementBlock("input",{key:0,ref_key:"fileInput",ref:b,onChange:Z,class:"hidden",accept:".json",type:"file"},null,544)):s.createCommentVNode("",!0),i("import")?(s.openBlock(),s.createElementBlock("button",{key:1,type:"button",onClick:L,class:"inline-flex items-center gap-2 rounded-md border border-gray-200 bg-white px-3 py-2 text-sm font-medium text-gray-700 hover:border-gray-300 hover:bg-gray-50 transition-colors"},[s.createVNode(s.unref(Y.Upload),{class:"h-4 w-4 text-gray-700"}),Q[4]||(Q[4]=s.createTextVNode(" Імпорт ",-1))])):s.createCommentVNode("",!0),i("export")?(s.openBlock(),s.createElementBlock("button",{key:2,type:"button",onClick:D,class:"inline-flex items-center gap-2 rounded-md border border-gray-200 bg-white px-3 py-2 text-sm font-medium text-gray-700 hover:border-gray-300 hover:bg-gray-50 transition-colors"},[s.createVNode(s.unref(Y.Download),{class:"h-4 w-4 text-gray-700"}),Q[5]||(Q[5]=s.createTextVNode(" Експорт ",-1))])):s.createCommentVNode("",!0),i("add")?(s.openBlock(),s.createElementBlock("button",{key:3,onClick:We,type:"button",class:"inline-flex items-center gap-2 rounded-md bg-blue-500 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-blue-600 transition-colors"},[s.createVNode(s.unref(Y.Plus),{class:"h-4 w-4 text-white"}),Q[6]||(Q[6]=s.createTextVNode(" Додати ",-1))])):s.createCommentVNode("",!0)])])):s.createCommentVNode("",!0),s.createElementVNode("div",tv,[s.createElementVNode("table",nv,[s.createElementVNode("thead",rv,[s.createElementVNode("tr",ov,[s.createElementVNode("th",sv,[s.createVNode(s.unref(Y.GripVertical),{class:"mx-auto h-4 w-4 text-gray-400"})]),(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(m.value,de=>(s.openBlock(),s.createElementBlock("th",{key:de.key,class:"px-4 py-3 text-left text-xs font-semibold text-gray-900"},[s.createElementVNode("button",{type:"button",onClick:O=>ot(de),class:"flex items-center gap-1 text-xs font-semibold text-gray-700 hover:text-gray-900 transition-colors"},[s.createElementVNode("span",null,s.toDisplayString(de.ua||de.label),1),f.value===(de.key||de.name)?(s.openBlock(),s.createElementBlock("span",lv,s.toDisplayString(p.value==="asc"?"▲":"▼"),1)):s.createCommentVNode("",!0)],8,iv)]))),128)),Q[7]||(Q[7]=s.createElementVNode("th",{class:"px-4 py-3 text-left text-xs font-semibold text-gray-900 text-center w-[1%] whitespace-nowrap"}," Дії ",-1))])]),s.createElementVNode("tbody",{class:s.normalizeClass(["divide-y divide-gray-200",{"[&_tr:last-child]:border-0":!y.value}])},[h.value.length===0?(s.openBlock(),s.createElementBlock("td",av,[s.createElementVNode("div",cv,[s.createElementVNode("div",dv,[s.createVNode(Y1,{class:"w-48 mx-auto"}),Q[8]||(Q[8]=s.createElementVNode("div",{class:"max-w-sm mx-auto mt-6"},[s.createElementVNode("p",{class:"font-medium text-gray-800 dark:text-neutral-200"},"Нічого не знайдено"),s.createElementVNode("p",{class:"mt-2 text-sm text-gray-500 dark:text-neutral-500"})],-1))])])])):s.createCommentVNode("",!0),(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(h.value,(de,O)=>(s.openBlock(),s.createElementBlock("tr",{key:de.id,"data-row-index":O,class:s.normalizeClass(["border-b transition-colors hover:bg-gray-50 cursor-move text-sm text-gray-700",{"opacity-50":g.value===O,"border-t-2 border-b-2 border-blue-500 bg-blue-50 dark:bg-blue-900/20":y.value===O}]),draggable:"true",onDragstart:C=>M(O),onDragover:s.withModifiers(C=>_(O),["prevent"]),onDrop:C=>A(O)},[s.createElementVNode("td",{class:"px-4 py-3 text-center align-middle touch-none select-none",onPointerdown:C=>E(C,O),onPointermove:N,onPointerup:R,onPointercancel:T},[s.createElementVNode("div",pv,[s.createVNode(s.unref(Y.GripVertical),{class:"mx-auto h-4 w-4 text-slate-400 dark:text-slate-500"})])],40,fv),(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(m.value,C=>(s.openBlock(),s.createElementBlock("td",{key:C.key,class:"px-4 py-3 align-middle"},[ae(C)==="slot"?(s.openBlock(),s.createElementBlock(s.Fragment,{key:0},[xe(C.slot)?s.renderSlot(W.$slots,C.slot,{key:0,row:de,value:de[C.key],column:C},void 0,!0):(s.openBlock(),s.createElementBlock("div",{key:1,class:"text-sm text-gray-900",innerHTML:je(C.slot,de)},null,8,hv))],64)):(s.openBlock(),s.createElementBlock(s.Fragment,{key:1},[ae(C)==="file"?(s.openBlock(),s.createElementBlock("div",mv,[z(Te(de,C))?(s.openBlock(),s.createElementBlock("div",gv,[s.createElementVNode("img",{src:`/file/resize?filepath=${Te(de,C)}&format=webp`,alt:"alt",width:"45",class:"rounded-md max-w-[45px] h-[45px] object-cover"},null,8,yv)])):(s.openBlock(),s.createElementBlock("div",bv,[s.createVNode(s.unref(Y.FileText),{class:"h-4 w-4 min-w-4"})]))])):ae(C)==="color"?(s.openBlock(),s.createElementBlock("div",kv,[s.createElementVNode("span",{class:"inline-flex h-6 w-6 rounded border border-gray-200",style:s.normalizeStyle({backgroundColor:Te(de,C)||"#ffffff"})},null,4)])):ae(C)==="tiptap-editor"?(s.openBlock(),s.createElementBlock("div",{key:2,class:"text-sm font-medium text-gray-900 datatable-tiptap-editor line-clamp-4",innerHTML:Te(de,C)},null,8,wv)):(s.openBlock(),s.createElementBlock("div",xv,s.toDisplayString(Te(de,C)),1))],64))]))),128)),s.createElementVNode("td",vv,[s.createElementVNode("div",Cv,[s.createElementVNode("button",{onClick:C=>Dt(de,O),class:"p-1.5 text-gray-600 hover:text-blue-600 hover:bg-blue-50 rounded transition-colors"},[s.createVNode(s.unref(Y.Pencil),{class:"h-4 w-4"})],8,Sv),s.createElementVNode("button",{onClick:C=>qe(O),class:"p-1.5 text-gray-600 hover:text-red-600 hover:bg-red-50 rounded transition-colors"},[s.createVNode(s.unref(Y.Trash2),{class:"h-4 w-4"})],8,Ev)])])],42,uv))),128))],2)])]),s.createVNode(s.unref(we.VsModal),{visible:$.value,title:H.value,size:"lg",onClose:tn,teleport:"#modal"},{default:s.withCtx(()=>[s.createVNode(zt,{schema:re.value,"allow-id-field":"",values:ge.value,"onUpdate:values":Q[1]||(Q[1]=de=>ge.value=de),form:Ee.value,"onUpdate:form":Q[2]||(Q[2]=de=>Ee.value=de)},null,8,["schema","values","form"]),s.createElementVNode("div",Mv,[s.createElementVNode("button",{type:"button",onClick:Q[3]||(Q[3]=de=>$.value=!1),class:"vs-button inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border !border-gray-200 hover:text-white bg-white text-red-500 hover:border-red-500 hover:bg-red-500 focus:ring-red-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1 mr-2"}," Скасувати "),s.createElementVNode("button",{onClick:Pe,type:"button",class:"vs-button inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border-1 border-transparent text-white bg-blue-500 hover:bg-blue-600 focus:ring-blue-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1"}," Зберегти ")])]),_:1},8,["visible","title"])]))}}),[["__scopeId","data-v-ef50558b"]]),Av={},_v={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none","stroke-width":"2",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-line"};function Tv(n,e){return s.openBlock(),s.createElementBlock("svg",_v,e[0]||(e[0]=[s.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),s.createElementVNode("path",{d:"M6 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},null,-1),s.createElementVNode("path",{d:"M18 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},null,-1),s.createElementVNode("path",{d:"M7.5 16.5l9 -9"},null,-1)]))}const Bv=Ne(Av,[["render",Tv]]),Nv={},Dv={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-polygon"};function Vv(n,e){return s.openBlock(),s.createElementBlock("svg",Dv,e[0]||(e[0]=[s.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"></path><path d="M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"></path><path d="M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"></path><path d="M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"></path><path d="M6.5 9.5l3.5 -3"></path><path d="M14 5.5l3 1.5"></path><path d="M18.5 10l-2.5 7"></path><path d="M13.5 17.5l-7 -5"></path>',9)]))}const $v=Ne(Nv,[["render",Vv]]),Lv={},Iv={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-topology-ring-3"};function Ov(n,e){return s.openBlock(),s.createElementBlock("svg",Iv,e[0]||(e[0]=[s.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M8 18a2 2 0 1 0 -4 0a2 2 0 0 0 4 0z"></path><path d="M20 18a2 2 0 1 0 -4 0a2 2 0 0 0 4 0z"></path><path d="M20 6a2 2 0 1 0 -4 0a2 2 0 0 0 4 0z"></path><path d="M8 6a2 2 0 1 0 -4 0a2 2 0 0 0 4 0z"></path><path d="M6 8v8"></path><path d="M18 16v-8"></path><path d="M8 6h8"></path><path d="M16 18h-8"></path>',9)]))}const Rv=Ne(Lv,[["render",Ov]]);function Fv(n,e,t){const r=Math.max(0,Math.min(22,Math.floor(t))),o=2**r,i=Math.floor((n+180)/360*o),l=e*Math.PI/180,a=Math.floor((1-Math.log(Math.tan(l)+1/Math.cos(l))/Math.PI)/2*o);return{z:r,x:i,y:a}}function Pv(n,e){if(typeof n!="string"||!n.trim()||!/\{z\}/i.test(n))return;const t={"{z}":e.z,"{x}":e.x,"{y}":e.y,"{-y}":2**e.z-e.y-1,"{s}":"a"};let r=n;return Object.entries(t).forEach(([o,i])=>{r=r.replace(new RegExp(o.replace(/[{}-]/g,"\\$&"),"gi"),String(i))}),r}const ef=/\/(\d+)\/(\d+)\/(\d+)(\.(?:png|jpe?g|webp))(?:\?.*)?$/i;function tf(n,e){if(typeof n!="string"||!n.trim()||!ef.test(n))return;const t=n.replace(ef,`/${e.z}/${e.x}/${e.y}$4`);return t!==n?t:void 0}function zv(n,e){if(n?.url){const t=Pv(n.url,e);if(t)return t;const r=tf(n.url,e);if(r)return r}if(n?.preview){const t=tf(n.preview,e);return t||n.preview}}const Hv=["title","aria-expanded"],jv=["src"],Uv={class:"map-layers__header"},Wv={class:"map-layers__body"},Kv={key:0,class:"map-layers__section"},qv={class:"map-layers__grid map-layers__grid--4"},Gv=["disabled","title","onClick"],Jv={class:"map-layers__thumb"},Yv=["src"],Xv={class:"map-layers__option-label"},Zv={key:1,class:"map-layers__section"},Qv={class:"map-layers__grid map-layers__grid--4"},eC=["title","onClick"],tC={class:"map-layers__thumb"},nC=["src"],rC={class:"map-layers__option-label"},oC={key:2,class:"map-layers__section map-layers__section--vector"},sC={class:"map-layers__vector-list"},iC=["checked","disabled","onChange"],li=.8,lC=Ne(s.defineComponent({__name:"map-layers",props:{basemaps:{},activeBaseKey:{},tileOverlays:{},activeTileOverlayKeys:{},vectorOverlays:{},previewTile:{},disabled:{type:Boolean},compact:{type:Boolean}},emits:["onLayerChange","onOverlayToggle","onVectorOverlayToggle"],setup(n,{emit:e}){const t=n,r=e,o=10*li,i=400*li,l=400*li,a=320*li,c=s.ref(null),d=s.ref(null),u=s.ref(null),f=s.ref(!1),p=s.ref({}),h=s.computed(()=>Object.keys(t.basemaps||{}).length>0),m=s.computed(()=>Object.keys(t.tileOverlays||{}).length>0),g=s.computed(()=>t.vectorOverlays??[]),y=s.computed(()=>g.value.length>0),b=s.computed(()=>h.value||m.value||y.value),w=s.computed(()=>t.basemaps?.[t.activeBaseKey]?.name||t.activeBaseKey||"Шари"),v=s.computed(()=>N(t.basemaps)),E=s.computed(()=>N(t.tileOverlays||{}));function N(K){const X=t.previewTile;return X?Object.fromEntries(Object.entries(K).map(([le,H])=>[String(le),zv(H,X)??H.preview??""])):{}}function R(K){return v.value[K]||t.basemaps?.[K]?.preview||""}function T(K){return E.value[K]||t.tileOverlays?.[K]?.preview||""}const M=s.computed(()=>R(t.activeBaseKey));function _(K){return Array.isArray(t.activeTileOverlayKeys)&&t.activeTileOverlayKeys.includes(K)}function A(){const K=d.value;if(!K)return;const X=K.getBoundingClientRect(),le=Math.min(i,window.innerWidth-16);let H=X.left;H+le>window.innerWidth-8&&(H=window.innerWidth-le-8),H=Math.max(8,H);const $=X.top-o-8,I=t.compact?a:l,te=Math.min(I,Math.max(96,$));p.value={position:"fixed",left:`${H}px`,bottom:`${window.innerHeight-X.top+o}px`,width:`${le}px`,maxHeight:`${te}px`,zIndex:"10050"}}async function L(){f.value=!f.value,f.value&&(await s.nextTick(),A())}function z(){f.value=!1}function Z(K){K!==t.activeBaseKey&&r("onLayerChange",K)}function D(K){t.disabled||r("onOverlayToggle",K)}function P(K){t.disabled||r("onVectorOverlayToggle",K)}function ne(K){if(!f.value)return;const X=K.target;c.value?.contains(X)||u.value?.contains(X)||z()}function U(K){K.key==="Escape"&&z()}return s.watch(f,async K=>{K&&(await s.nextTick(),A())}),s.onMounted(()=>{document.addEventListener("click",ne),document.addEventListener("keydown",U),window.addEventListener("resize",A),window.addEventListener("scroll",A,!0)}),s.onBeforeUnmount(()=>{document.removeEventListener("click",ne),document.removeEventListener("keydown",U),window.removeEventListener("resize",A),window.removeEventListener("scroll",A,!0)}),(K,X)=>b.value?(s.openBlock(),s.createElementBlock("div",{key:0,ref_key:"rootRef",ref:c,class:s.normalizeClass(["map-layers relative",{"map-layers--compact":K.compact}])},[s.createElementVNode("button",{ref_key:"triggerRef",ref:d,type:"button",class:"map-layers__trigger",title:w.value,"aria-haspopup":"dialog","aria-expanded":f.value,onClick:s.withModifiers(L,["stop"])},[M.value?(s.openBlock(),s.createElementBlock("img",{key:0,src:M.value,alt:"",class:"map-layers__trigger-img"},null,8,jv)):s.createCommentVNode("",!0)],8,Hv),(s.openBlock(),s.createBlock(s.Teleport,{to:"body"},[s.createVNode(s.Transition,{name:"map-layers-panel"},{default:s.withCtx(()=>[f.value?(s.openBlock(),s.createElementBlock("div",{key:0,ref_key:"panelRef",ref:u,class:"map-layers__panel",style:s.normalizeStyle(p.value),role:"dialog","aria-label":"Шари карти"},[s.createElementVNode("header",Uv,[X[0]||(X[0]=s.createElementVNode("h3",{class:"map-layers__title"},"Шари карти",-1)),s.createElementVNode("button",{type:"button",class:"map-layers__close","aria-label":"Закрити",onClick:z},[s.createVNode(s.unref(Y.X),{class:"map-layers__close-icon"})])]),s.createElementVNode("div",Wv,[m.value?(s.openBlock(),s.createElementBlock("section",Kv,[X[1]||(X[1]=s.createElementVNode("h4",{class:"map-layers__section-title"},"Додаткові шари",-1)),s.createElementVNode("div",qv,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(K.tileOverlays,(le,H)=>(s.openBlock(),s.createElementBlock("button",{key:`tile-${H}`,type:"button",class:s.normalizeClass(["map-layers__option",{"map-layers__option--active":_(String(H))}]),disabled:K.disabled,title:le.name||String(H),onClick:$=>D(String(H))},[s.createElementVNode("span",Jv,[s.createElementVNode("img",{src:T(String(H)),alt:""},null,8,Yv)]),s.createElementVNode("span",Xv,s.toDisplayString(le.name||H),1)],10,Gv))),128))])])):s.createCommentVNode("",!0),h.value?(s.openBlock(),s.createElementBlock("section",Zv,[X[2]||(X[2]=s.createElementVNode("h4",{class:"map-layers__section-title"},"Базові шари",-1)),s.createElementVNode("div",Qv,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(K.basemaps,(le,H)=>(s.openBlock(),s.createElementBlock("button",{key:`base-${H}`,type:"button",class:s.normalizeClass(["map-layers__option",{"map-layers__option--active":K.activeBaseKey===String(H)}]),title:le.name||String(H),onClick:$=>Z(String(H))},[s.createElementVNode("span",tC,[s.createElementVNode("img",{src:R(String(H)),alt:""},null,8,nC)]),s.createElementVNode("span",rC,s.toDisplayString(le.name||H),1)],10,eC))),128))])])):s.createCommentVNode("",!0),y.value?(s.openBlock(),s.createElementBlock("section",oC,[X[3]||(X[3]=s.createElementVNode("h4",{class:"map-layers__section-title"},"Дані",-1)),s.createElementVNode("div",sC,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(g.value,le=>(s.openBlock(),s.createElementBlock("label",{key:le.id,class:"map-layers__vector-item"},[s.createElementVNode("input",{type:"checkbox",class:"map-layers__checkbox",checked:le.visible,disabled:K.disabled,onChange:H=>P(le.id)},null,40,iC),s.createElementVNode("span",null,s.toDisplayString(le.label),1)]))),128))])])):s.createCommentVNode("",!0)])],4)):s.createCommentVNode("",!0)]),_:1})]))],2)):s.createCommentVNode("",!0)}}),[["__scopeId","data-v-c1206d48"]]),Mr=1e-10,ai=/([+-]?\d{1,3})\s*[°º˚]\s*(\d{1,2})\s*['’′`]\s*(\d{1,2}(?:\.\d+)?)\s*["”″]\s*([NSEW])/gi,aC=/^[+-]?\d+(?:\.\d+)?$/;function cC(n,e,t){const r=n.split(/\r?\n/).map(d=>d.trim()).filter(Boolean);if(r.length<3)return{ok:!1,errors:[{line:0,message:"Має бути щонайменше 3 рядки координат."}]};if(r.length>100)return{ok:!1,errors:[{line:0,message:"Допускається не більше 100 рядків координат."}]};const o=[],i=[];if(r.forEach((d,u)=>{const f=u+1,p=e==="decimal"?dC(d,f,t):rf(d,f,t);if(!p.ok){o.push(...p.errors);return}const h=i[i.length-1];if(h&&sf(h,p.point)){o.push({line:f,message:"Послідовні точки не повинні дублюватися."});return}i.push(p.point)}),o.length)return{ok:!1,errors:o};if(new Set(i.map(fC)).size<3)return{ok:!1,errors:[{line:0,message:"Полігон повинен містити мінімум 3 унікальні точки."}]};const a=[...i];let c=!1;return sf(a[0],a[a.length-1])||(a.push(a[0]),c=!0),pC(a)?{ok:!1,errors:[{line:0,message:"Полігон має самоперетин."}]}:{ok:!0,ring:a,wasClosedAutomatically:c}}function dC(n,e,t){return nf(n,"decimal",t,e)}function nf(n,e,t,r=1){return e==="decimal"?uC(n,r,t):rf(n,r,t)}function uC(n,e,t){const r=[];if(/[A-Za-zА-Яа-яІіЇїЄєҐґ]/.test(n))return{ok:!1,errors:[{line:e,message:"У десятковому форматі не допускаються літери."}]};const o=n.split(/[\s,;]+/).filter(Boolean);if(o.length<2)return{ok:!1,errors:[{line:e,message:"Кожен рядок має містити дві координати."}]};if(o.length>2)return{ok:!1,errors:[{line:e,message:"У рядку дозволено лише одну пару координат."}]};if(!o.every(d=>aC.test(d)))return{ok:!1,errors:[{line:e,message:"Не вдалося розпізнати десяткові координати."}]};const i=Number(o[0]),l=Number(o[1]);if(!Number.isFinite(i)||!Number.isFinite(l))return{ok:!1,errors:[{line:e,message:"Не вдалося розпізнати десяткові координати."}]};const a=t==="lat-lon"?i:l,c=t==="lat-lon"?l:i;return(a<-90||a>90)&&r.push({line:e,message:"Широта поза діапазоном (-90..90)."}),(c<-180||c>180)&&r.push({line:e,message:"Довгота поза діапазоном (-180..180)."}),r.length?{ok:!1,errors:r}:{ok:!0,point:[c,a]}}function rf(n,e,t){ai.lastIndex=0;const r=[...n.matchAll(ai)];if(r.length<2)return{ok:!1,errors:[{line:e,message:"Не вдалося розпізнати DMS-координати."}]};if(r.length>2)return{ok:!1,errors:[{line:e,message:"У рядку дозволено лише одну пару координат."}]};if(ai.lastIndex=0,n.replace(ai," ").replace(/[\s,;]+/g,"").trim().length)return{ok:!1,errors:[{line:e,message:"У рядку виявлено зайві символи або значення."}]};const i=of(r[0],e,t==="lat-lon"?"lat":"lon"),l=of(r[1],e,t==="lat-lon"?"lon":"lat"),a=[];if(i.ok||a.push(i.error),l.ok||a.push(l.error),a.length)return{ok:!1,errors:a};const c=t==="lat-lon"?i.value:l.value;return{ok:!0,point:[t==="lat-lon"?l.value:i.value,c]}}function of(n,e,t){const r=Number(n[1]),o=Number(n[2]),i=Number(n[3]),l=String(n[4]).toUpperCase();if(!Number.isFinite(r)||!Number.isFinite(o)||!Number.isFinite(i))return{ok:!1,error:{line:e,message:"Невірні значення DMS-координат."}};if(t==="lat"&&!(l==="N"||l==="S")||t==="lon"&&!(l==="E"||l==="W"))return{ok:!1,error:{line:e,message:t==="lat"?"Для широти напрям повинен бути N або S.":"Для довготи напрям повинен бути E або W."}};if(o<0||o>59)return{ok:!1,error:{line:e,message:"Хвилини повинні бути в діапазоні 0..59."}};if(i<0||i>60)return{ok:!1,error:{line:e,message:"Секунди повинні бути в діапазоні 0..60."}};const d=Math.abs(r),u=t==="lat"?90:180;if(d>u)return{ok:!1,error:{line:e,message:t==="lat"?"Градуси широти повинні бути в діапазоні 0..90.":"Градуси довготи повинні бути в діапазоні 0..180."}};if(d===u&&(o!==0||i!==0))return{ok:!1,error:{line:e,message:t==="lat"?"Для 90° широти хвилини й секунди мають бути 0.":"Для 180° довготи хвилини й секунди мають бути 0."}};const f=d+o/60+i/3600;return{ok:!0,value:l==="S"||l==="W"?-f:f}}function fC(n){return`${n[0].toFixed(12)}:${n[1].toFixed(12)}`}function sf(n,e){return Math.abs(n[0]-e[0])<Mr&&Math.abs(n[1]-e[1])<Mr}function pC(n){if(n.length<4)return!1;for(let e=0;e<n.length-1;e+=1){const t=n[e],r=n[e+1];for(let o=e+1;o<n.length-1;o+=1){if(Math.abs(e-o)<=1||e===0&&o===n.length-2)continue;const i=n[o],l=n[o+1];if(hC(t,r,i,l))return!0}}return!1}function hC(n,e,t,r){const o=ci(n,e,t),i=ci(n,e,r),l=ci(t,r,n),a=ci(t,r,e);return!!(o!==i&&l!==a||o===0&&di(n,t,e)||i===0&&di(n,r,e)||l===0&&di(t,n,r)||a===0&&di(t,e,r))}function ci(n,e,t){const r=(e[1]-n[1])*(t[0]-e[0])-(e[0]-n[0])*(t[1]-e[1]);return Math.abs(r)<Mr?0:r>0?1:2}function di(n,e,t){return e[0]<=Math.max(n[0],t[0])+Mr&&e[0]+Mr>=Math.min(n[0],t[0])&&e[1]<=Math.max(n[1],t[1])+Mr&&e[1]+Mr>=Math.min(n[1],t[1])}const mC=["title"],gC={key:0,class:"vs-select__options absolute z-50 mt-1 w-auto min-w-full bg-white border border-gray-300 shadow-lg rounded-lg text-sm text-gray-900"},yC=["onClick"],bC=["placeholder"],kC={class:"absolute inset-y-0 right-2 flex items-center gap-1"},wC={class:"flex items-center justify-between gap-2 px-3 py-2 border-b border-gray-100"},xC={class:"text-xs font-semibold uppercase tracking-wide text-gray-500"},vC={class:"max-h-[260px] overflow-auto"},CC={key:0,class:"divide-y divide-gray-100"},SC=["onClick"],EC={key:1,class:"px-3 py-3 text-xs text-gray-500"},lf="formMapSearchAddressHistory",MC=12,AC="https://geo.rv.ua/api-user/dzk.api",_C="https://nominatim.openstreetmap.org/search",TC=Ne(s.defineComponent({__name:"map-search",props:{config:{}},emits:["goToCoordinates"],setup(n,{emit:e}){const t={mounted(O,C){if(typeof document>"u")return;let V=null;const j=8,ie=()=>{const Ze=String(C?.value??"");if(!Ze)return;V=document.createElement("div"),V.textContent=Ze,Object.assign(V.style,{position:"absolute",background:"#333",color:"#fff",padding:"4px 8px",borderRadius:"4px",fontSize:"12px",whiteSpace:"nowrap",pointerEvents:"none",zIndex:"9999"}),document.body.appendChild(V);const Ge=O.getBoundingClientRect();V.style.left=`${Ge.right+window.scrollX+j}px`,V.style.top=`${Ge.top+window.scrollY+(Ge.height-V.offsetHeight)/2}px`},Me=()=>{V?.parentNode&&V.parentNode.removeChild(V),V=null};O.addEventListener("mouseenter",ie),O.addEventListener("mouseleave",Me),Object.assign(O,{tooltipRightHandlers:{show:ie,hide:Me}})},unmounted(O){if(typeof document>"u")return;const C=O.tooltipRightHandlers;C&&(O.removeEventListener("mouseenter",C.show),O.removeEventListener("mouseleave",C.hide))}},r=n,o=e,i=s.getCurrentInstance();function l(){return typeof globalThis<"u"&&globalThis.proxy?globalThis.proxy:typeof window<"u"&&window.proxy?window.proxy:null}function a(){const C=i?.appContext.config.globalProperties?.$settings?.map?.searchViewbox;if(C)return Array.isArray(C)?C.join(","):String(C);const j=l()?.map?.searchViewbox;if(j)return Array.isArray(j)?j.join(","):String(j)}function c(){const C=i?.appContext.config.globalProperties?.$settings?.map?.addressSuggest;if(typeof C=="string"&&C.trim())return C.trim();const j=l()?.map?.addressSuggest;if(typeof j=="string"&&j.trim())return j.trim()}function d(){if(typeof r.config?.cadastreSuggest=="string"&&r.config.cadastreSuggest.trim())return r.config.cadastreSuggest.trim();const O=i?.appContext.config.globalProperties?.$settings,C=O?.map?.cadastreSuggest??O?.map?.parcelSuggest??O?.map?.parcelSearch;if(typeof C=="string"&&C.trim())return C.trim();const V=l(),j=V?.map?.cadastreSuggest??V?.map?.parcelSuggest??V?.map?.parcelSearch;if(typeof j=="string"&&j.trim())return j.trim()}const u=!!c(),f=!!a(),p=s.computed(()=>{const O=["nominatim","xy","parcel"];return u&&O.unshift("address"),f?O:O.filter(C=>C!=="nominatim")}),h=s.computed(()=>{const O=p.value,C=r.config?.tools?.filter(V=>O.includes(V));return C&&C.length?C:O}),m=s.computed(()=>r.config?.placeholder?.trim()||"Пошук…"),g=s.ref(h.value[0]);s.watch(h,O=>{O.includes(g.value)||(g.value=O[0])});const y=s.ref(""),b=s.ref(!1),w=s.ref(null),v=s.ref(null),E=s.ref(null),N=s.ref(null),R=s.ref([]),T=s.ref(null),M=s.ref(!1),_=s.ref([]),A=s.computed(()=>(g.value==="address"||g.value==="nominatim")&&M.value),L=s.computed(()=>r.config?.addressDebounceMs??1e3);let z=null;const Z=s.ref(!1),D=s.computed(()=>y.value.trim().length>0?R.value:_.value),P=s.computed(()=>y.value.trim().length?`Знайдено ${R.value.length}`:"Історія пошуку"),ne=s.computed(()=>y.value.trim().length?"Нічого не знайдено":"Історія порожня");function U(){if(typeof window>"u")return[];try{const O=window.localStorage?.getItem?.(lf);if(!O)return[];const C=JSON.parse(O);return Array.isArray(C)?C:[]}catch{return[]}}function K(O){typeof window>"u"||window.localStorage?.setItem?.(lf,JSON.stringify(O))}function X(O){const V=[O,..._.value.filter(j=>j.id!==O.id)].slice(0,10);_.value=V,K(V)}const le=s.reactive({position:"absolute",left:"0px",top:"0px",width:"100%",display:"none"});function H(){if(!N.value)return;const O=N.value.getBoundingClientRect(),C=E.value?.getBoundingClientRect(),V=C?.width??O.width,j=(C?.left??O.left)+window.scrollX,ie=O.bottom+window.scrollY+MC;le.left=`${j}px`,le.top=`${ie}px`,le.width=`${V}px`,le.display="block"}const $=()=>{A.value&&H()};function I(){z&&(clearTimeout(z),z=null)}s.watch(g,()=>{y.value="",b.value=!1,R.value=[],M.value=!1,I(),Z.value=!1}),s.watch(A,O=>{O?s.nextTick(()=>{H()}):le.display="none"}),s.watch(y,O=>{if(g.value!=="address"&&g.value!=="nominatim"){R.value=[],I();return}if(!O.trim()){R.value=[],M.value=_.value.length>0,I();return}I(),M.value=!0,z=window.setTimeout(()=>{Pe(O).catch(C=>{const V=C?.message||"Помилка пошуку адреси";we.notify({type:"error",title:"Пошук адреси",message:V})})},L.value)});function te(O){const C=[];v.value&&C.push(v.value),O instanceof HTMLElement&&C.push(O),w.value?.querySelectorAll("li")?.forEach(j=>{C.push(j)}),C.forEach(j=>{j.dispatchEvent(new MouseEvent("mouseleave",{bubbles:!0}))})}function ae(O){b.value&&te(O.target),b.value=!b.value}function re(O,C){te(C?.target),g.value=O}function ge(){y.value="",R.value=[],M.value=!1,Z.value=!1}function Ee(O){const C=O.target;if(b.value){const V=w.value;V&&!V.contains(C)&&(te(C),b.value=!1)}if(A.value){const V=T.value,j=N.value;V&&!V.contains(C)&&(!j||!j.contains(C))&&(M.value=!1)}}s.onMounted(()=>{_.value=U(),window.addEventListener("click",Ee,!0),window.addEventListener("scroll",$,!0),window.addEventListener("resize",$)}),s.onBeforeUnmount(()=>{window.removeEventListener("click",Ee,!0),window.removeEventListener("scroll",$,!0),window.removeEventListener("resize",$),I()});function xe(O){return O==="xy"?"Координати":O==="parcel"?"Кадастр":O==="nominatim"?"Адреса":"Адресний"}function Ie(O){switch(O){case"xy":return"Пошук за географічними координатами. Введіть широту і довготу через пробіл або кому (lat lng або lng lat).";case"parcel":return"Пошук земельної ділянки за кадастровим номером у форматі 0000000000:00:000:0000.";case"nominatim":return"Пошук адрес та обʼєктів через Nominatim.";case"address":return"Пошук адрес через локальний сервіс addressSuggest.";default:return""}}function je(O){const C=nf(O.trim(),"dms","lat-lon");if(C.ok){const[gt,Wt]=C.point;return{lat:Wt,lng:gt}}const V=O.replace(/[,]+/g," ").trim();if(!V)return null;const j=V.split(/\s+/).filter(Boolean);if(j.length<2)return null;const ie=j.slice(0,2).map(Number);if(!ie.every(gt=>Number.isFinite(gt)))return null;let[Me,Ze]=ie,Ge=Me,ut=Ze;const mt=gt=>Math.abs(gt)<=90,nn=gt=>Math.abs(gt)<=180;if(!mt(Ge)||!nn(ut))if(mt(ut)&&nn(Ge))Ge=Ze,ut=Me;else return null;return{lat:Ge,lng:ut}}function Fe(O){const C=O?.result||O?.data||O;return(Array.isArray(C)?C:C?[C]:[]).map((j,ie)=>{const Me=j?.geom_centroid,Ze=Array.isArray(Me?.coordinates)?Me.coordinates:null;if(!Ze||Ze.length<2)return null;const Ge=Number(Ze[0]),ut=Number(Ze[1]);return!Number.isFinite(ut)||!Number.isFinite(Ge)?null:{id:String(j?.parcel_id??j?.cad_num??ie),title:j?.cadnum||j?.cad_num||"Земельна ділянка",lat:ut,lng:Ge}}).filter(j=>!!j)}function ot(O){return(Array.isArray(O?.features)?O.features:[]).map((V,j)=>{const ie=V?.geometry?.coordinates,Me=Number(ie?.[0]),Ze=Number(ie?.[1]);if(!Number.isFinite(Ze)||!Number.isFinite(Me))return null;const Ge=V?.properties||{},ut=Ge?.geocoding?.label||Ge?.display_name||Ge?.label||"Адреса";return{id:String(Ge?.geocoding?.place_id||Ge?.place_id||j),title:ut,lat:Ze,lng:Me}}).filter(V=>!!V)}function We(O){return Number.isFinite(O.lat)&&Number.isFinite(O.lng)}function oe(O){if(O==null||typeof O=="string"&&!O.trim())return null;const C=Number(O);return Number.isFinite(C)?C:null}function pe(O){const C=oe(O.lng)??oe(O.lon)??oe(O.longitude)??oe(O.x),V=oe(O.lat)??oe(O.latitude)??oe(O.y);if(C!=null&&V!=null)return{lat:V,lng:C};const j=O?.geometry?.coordinates??O?.geom_centroid?.coordinates??O?.centroid?.coordinates??O?.geojson?.geometry?.coordinates??O?.geom?.coordinates;if(Array.isArray(j)&&j.length>=2){const ie=oe(j[0]),Me=oe(j[1]);if(ie!=null&&Me!=null)return{lat:Me,lng:ie}}return null}function _e(O){return(Array.isArray(O?.data)?O.data:[]).map((V,j)=>{const ie=pe(V),Me=String(V.text??V.title??V.label??V.name??V.address??V.display_name??V.id??"Адреса"),Ze=String(V.id??V.code??V.value??j);return ie?{id:Ze,title:Me,...ie}:{id:Ze,title:Me}}).filter(V=>!!V?.title)}function Te(O){const C=d()||AC;if(C.includes(":id"))return C.replace(":id",encodeURIComponent(O));if(C.includes(":name"))return C.replace(":name",encodeURIComponent(O));try{const V=new URL(C,window.location.origin),j=r.config?.parcelQueryParam?.trim()||"cad_num";return V.searchParams.set(j,O),V.toString()}catch{return C}}function dt(O){const C=c();if(!C)return null;if(C.includes(":name"))return C.replace(":name",encodeURIComponent(O));try{const V=new URL(C,window.location.origin);return O.trim()&&V.searchParams.set("q",O),V.toString()}catch{return C}}async function Ye(O){const C=dt(O);if(!C)return[];const V=await fetch(C);if(!V.ok)throw new Error(`HTTP ${V.status}`);const j=await V.json();return _e(j)}async function Dt(O){const C=new URL(_C);C.searchParams.set("format","geojson"),C.searchParams.set("q",O),C.searchParams.set("addressdetails","1"),C.searchParams.set("bounded","1");const V=a();V&&C.searchParams.set("viewbox",V);const j=await fetch(C.toString());if(!j.ok)throw new Error(`HTTP ${j.status}`);const ie=await j.json();return ot(ie)}async function Pe(O){if(R.value=[],I(),g.value==="address"){if(!c()){we.notify({type:"warning",title:"Пошук адреси",message:"Не налаштовано addressSuggest"});return}const j=await Ye(O);if(!j.length){we.notify({type:"warning",title:"Пошук адреси",message:"Не знайдено результатів"});return}R.value=j;return}const C=await Dt(O);if(!C.length){we.notify({type:"warning",title:"Пошук адреси",message:"Не знайдено результатів"});return}R.value=C}async function qe(O){if(We(O)){Q(O),X(O);return}we.notify({type:"warning",title:"Пошук адреси",message:"Геометрія для обраної адреси відсутня"})}function tn(){g.value!=="address"&&g.value!=="nominatim"||(M.value=!0,s.nextTick(()=>{H()}))}function W(O){const V=O.replace(/\s+/g,"").split(":");if(V.length!==4)return!1;const j=[10,2,3,4];return V.every((ie,Me)=>ie.length===j[Me]&&/^\d+$/.test(ie))}function Q(O){o("goToCoordinates",[O.lat,O.lng]),Z.value=!0}async function de(){const O=y.value.trim();if(O){if(g.value==="xy"){const C=je(O);if(!C){we.notify({type:"warning",title:"Пошук координат",message:"Використайте `lat lon` або DMS у форматі `50°27'00\"N 30°31'24\"E`."});return}Q(C);return}if(g.value==="address"||g.value==="nominatim"){try{await Pe(O)}catch(C){const V=C?.message||"Помилка пошуку адреси";we.notify({type:"error",title:"Пошук адреси",message:V})}return}try{if(!W(O)){we.notify({type:"warning",title:"Пошук кадастру",message:"Кадастровий номер має формат ХХХХХХХХХХ:ХХ:ХХХ:ХХХХ"});return}const C=await fetch(Te(O));if(!C.ok)throw new Error(`HTTP ${C.status}`);const V=await C.json(),j=Fe(V);if(!j.length)we.notify({type:"warning",title:"Пошук",message:"Не знайдено результатів"});else{const ie=j.find(We);if(!ie){we.notify({type:"warning",title:"Пошук",message:"Геометрія ділянки відсутня"});return}Q(ie)}}catch(C){const V=C?.message||"Помилка пошуку";we.notify({type:"error",title:"Пошук",message:V})}}}return(O,C)=>(s.openBlock(),s.createElementBlock("div",{ref_key:"widgetRef",ref:E,class:"map-search-widget flex flex-col gap-2 rounded-xl widget min-w-[200px]"},[s.createElementVNode("form",{class:"flex gap-2 text-gray-900",onSubmit:s.withModifiers(de,["prevent"])},[h.value.length>1?(s.openBlock(),s.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:w,class:"relative search-type w-[100px]"},[s.createElementVNode("button",{type:"button",class:"vstSelect-input transition-all text-left bg-white border border-gray-200 text-gray-900 rounded-lg focus:ring-blue-500 focus:border-blue-100 block w-full py-1.5 px-3 text-sm cursor-pointer flex items-center justify-between gap-2",onClick:ae},[s.withDirectives((s.openBlock(),s.createElementBlock("span",{ref_key:"selectedToolLabelRef",ref:v,class:"block w-full truncate",title:xe(g.value)},[s.createTextVNode(s.toDisplayString(xe(g.value)),1)],8,mC)),[[t,Ie(g.value)]]),(s.openBlock(),s.createElementBlock("svg",{class:s.normalizeClass(["w-4 h-4 text-gray-500 transition-transform",{"rotate-180":b.value}]),viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},C[3]||(C[3]=[s.createElementVNode("path",{d:"M6 9l6 6 6-6",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)]),2))]),b.value?(s.openBlock(),s.createElementBlock("div",gC,[s.createElementVNode("ul",null,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(h.value,V=>s.withDirectives((s.openBlock(),s.createElementBlock("li",{key:V,class:"px-3 py-2 cursor-pointer hover:bg-gray-100 text-gray-900",onClick:j=>re(V,j)},[s.createTextVNode(s.toDisplayString(xe(V)),1)],8,yC)),[[t,Ie(V)]])),128))])])):s.createCommentVNode("",!0)],512)):s.createCommentVNode("",!0),s.createElementVNode("div",{ref_key:"searchWrapperRef",ref:N,class:"relative flex-1 min-w-[140px]"},[g.value==="parcel"?(s.openBlock(),s.createBlock(qs,{key:0,modelValue:y.value,"onUpdate:modelValue":C[0]||(C[0]=V=>y.value=V),mask:"0000000000:00:000:0000",class:s.normalizeClass(["vs-input !h-[34px] transition-all border block w-full border-gray-200 rounded-md focus:border-blue-100 border-solid py-1.5 pl-3 text-sm",Z.value?"!pr-14":"!pr-8"])},null,8,["modelValue","class"])):s.withDirectives((s.openBlock(),s.createElementBlock("input",{key:1,"onUpdate:modelValue":C[1]||(C[1]=V=>y.value=V),placeholder:m.value,type:"text",class:s.normalizeClass(["vs-input transition-all border block w-full border-gray-200 rounded-md focus:border-blue-100 border-solid py-1.5 pl-3 text-sm",Z.value?"!pr-14":"!pr-8"]),onFocus:tn},null,42,bC)),[[s.vModelText,y.value,void 0,{trim:!0}]]),s.createElementVNode("div",kC,[Z.value?(s.openBlock(),s.createElementBlock("button",{key:0,type:"button",class:"flex items-center text-gray-400 hover:text-gray-600","aria-label":"Очистити",onClick:ge},C[4]||(C[4]=[s.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[s.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})],-1)]))):s.createCommentVNode("",!0),C[5]||(C[5]=s.createElementVNode("button",{type:"submit",class:"flex items-center text-gray-400 hover:text-gray-600","aria-label":"Пошук"},[s.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[s.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m21 21-4.35-4.35m0 0A7.5 7.5 0 1 0 5 5a7.5 7.5 0 0 0 11.65 11.65Z"})])],-1))]),A.value?(s.openBlock(),s.createBlock(s.Teleport,{key:2,to:"body"},[s.createElementVNode("div",{ref_key:"addressResultsRef",ref:T,class:"vs-select__options mt-1 bg-white border border-gray-300 rounded-lg shadow-lg text-sm text-gray-900 z-50",style:s.normalizeStyle(le)},[s.createElementVNode("div",wC,[s.createElementVNode("span",xC,s.toDisplayString(P.value),1),s.createElementVNode("button",{type:"button",class:"text-gray-400 hover:text-gray-600","aria-label":"Закрити",onClick:C[2]||(C[2]=V=>M.value=!1)}," ✕ ")]),s.createElementVNode("div",vC,[D.value.length?(s.openBlock(),s.createElementBlock("ul",CC,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(D.value,V=>(s.openBlock(),s.createElementBlock("li",{key:V.id,class:"px-3 py-2 cursor-pointer hover:bg-gray-50",onClick:j=>qe(V)},s.toDisplayString(V.title),9,SC))),128))])):(s.openBlock(),s.createElementBlock("div",EC,s.toDisplayString(ne.value),1))])],4)])):s.createCommentVNode("",!0)],512)],32)],512))}}),[["__scopeId","data-v-4d528cf7"]]),BC={class:"pt-1 border-t border-gray-100"},NC={class:"space-y-1"},DC=s.defineComponent({__name:"AddCoordinates",emits:["submit","cancel"],setup(n,{emit:e}){const t=e,r=s.ref(null),o=s.ref(null),i=(c,d,u)=>Math.min(Math.max(c,d),u),l=()=>{if(r.value===null||o.value===null||!Number.isFinite(r.value)||!Number.isFinite(o.value))return;const c=i(r.value,-90,90),d=i(o.value,-180,180);t("submit",{lat:c,lng:d}),r.value=null,o.value=null},a=()=>{r.value=null,o.value=null,t("cancel")};return(c,d)=>(s.openBlock(),s.createElementBlock("div",BC,[d[2]||(d[2]=s.createElementVNode("p",{class:"text-xs text-gray-600 mb-1"},"Додати точку за координатами:",-1)),s.createElementVNode("div",NC,[s.withDirectives(s.createElementVNode("input",{"onUpdate:modelValue":d[0]||(d[0]=u=>r.value=u),type:"number",step:"0.0001",class:"w-full px-2 py-1 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Широта (50.4501)"},null,512),[[s.vModelText,r.value,void 0,{number:!0}]]),s.withDirectives(s.createElementVNode("input",{"onUpdate:modelValue":d[1]||(d[1]=u=>o.value=u),type:"number",step:"0.0001",class:"w-full px-2 py-1 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Довгота (30.5234)"},null,512),[[s.vModelText,o.value,void 0,{number:!0}]]),s.createElementVNode("div",{class:"flex gap-1.5"},[s.createElementVNode("button",{class:"flex-1 px-2 py-1 bg-blue-500 hover:bg-blue-600 text-white text-xs font-medium rounded transition-colors",type:"button",onClick:l}," Додати "),s.createElementVNode("button",{class:"px-2 py-1 bg-gray-200 hover:bg-gray-300 text-gray-700 text-xs font-medium rounded transition-colors",type:"button",onClick:a}," Скасувати ")])])]))}}),VC=s.defineComponent({__name:"BtnAdd",emits:["click"],setup(n){return(e,t)=>(s.openBlock(),s.createElementBlock("button",{class:"flex-1 px-2 py-1.5 bg-blue-500 hover:bg-blue-600 text-white text-xs font-medium rounded transition-colors duration-150 flex items-center justify-center gap-1",onClick:t[0]||(t[0]=r=>e.$emit("click"))},[s.createVNode(s.unref(Y.Plus),{size:12,"stroke-width":2}),t[1]||(t[1]=s.createTextVNode(" Додати ",-1))]))}}),$C=s.defineComponent({__name:"BtnClear",emits:["click"],setup(n){return(e,t)=>(s.openBlock(),s.createElementBlock("button",{class:"w-full px-2 py-1.5 bg-rose-500 hover:bg-rose-600 text-white text-xs font-medium rounded transition-colors duration-150 flex items-center justify-center gap-1",onClick:t[0]||(t[0]=r=>e.$emit("click"))},[s.createVNode(s.unref(Y.Trash2),{size:12,"stroke-width":2}),t[1]||(t[1]=s.createTextVNode(" Очистити ",-1))]))}}),LC=s.defineComponent({__name:"BtnComplete",emits:["click"],setup(n){return(e,t)=>(s.openBlock(),s.createElementBlock("button",{class:"flex-1 px-2 py-1.5 bg-emerald-500 hover:bg-emerald-600 text-white text-xs font-medium rounded transition-colors duration-150 flex items-center justify-center gap-1",onClick:t[0]||(t[0]=r=>e.$emit("click"))},[s.createVNode(s.unref(Y.Circle),{size:12,"stroke-width":2}),t[1]||(t[1]=s.createTextVNode("Замкнути ",-1))]))}}),IC=new Intl.NumberFormat("uk-UA",{minimumFractionDigits:2,maximumFractionDigits:2});function Ar(n){return IC.format(n)}function af(n){return n>=1e3?`${Ar(n/1e3)} км`:`${Ar(n)} м`}const OC={class:"flex items-center gap-1.5 text-xs bg-gray-50 rounded p-1.5"},RC={key:0,class:"flex-1 flex gap-1"},FC={key:1,class:"flex-1 font-mono text-gray-700"},PC=s.defineComponent({__name:"DotListItem",props:{id:{},index:{},coords:{}},emits:["update","delete"],setup(n,{emit:e}){const t=n,r=e,o=s.computed(()=>`${t.coords.lat.toFixed(4)}°, ${t.coords.lng.toFixed(4)}°`),i=s.ref(!1),l=s.ref(t.coords.lat),a=s.ref(t.coords.lng);s.watch(()=>t.coords,p=>{l.value=p.lat,a.value=p.lng},{deep:!0,immediate:!0});const c=(p,h,m)=>Math.min(Math.max(p,h),m),d=()=>{i.value=!0},u=()=>{if(!Number.isFinite(l.value)||!Number.isFinite(a.value))return;const p=c(l.value,-90,90),h=c(a.value,-180,180);r("update",{id:t.id,coords:{lat:p,lng:h}}),i.value=!1},f=()=>{r("delete",t.id)};return(p,h)=>(s.openBlock(),s.createElementBlock("div",OC,[s.createVNode(s.unref(Y.MapPin),{size:12,"stroke-width":2,class:"text-gray-400 flex-shrink-0"}),i.value?(s.openBlock(),s.createElementBlock("div",RC,[s.withDirectives(s.createElementVNode("input",{"onUpdate:modelValue":h[0]||(h[0]=m=>l.value=m),type:"number",step:"0.0001",min:"-90",max:"90",class:"flex-1 px-1.5 py-0.5 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Широта"},null,512),[[s.vModelText,l.value,void 0,{number:!0}]]),s.withDirectives(s.createElementVNode("input",{"onUpdate:modelValue":h[1]||(h[1]=m=>a.value=m),type:"number",step:"0.0001",min:"-180",max:"180",class:"flex-1 px-1.5 py-0.5 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Довгота"},null,512),[[s.vModelText,a.value,void 0,{number:!0}]]),s.createElementVNode("button",{class:"px-1.5 py-0.5 bg-emerald-500 text-white rounded hover:bg-emerald-600 text-xs",type:"button",onClick:u}," ✓ ")])):(s.openBlock(),s.createElementBlock("span",FC,s.toDisplayString(o.value),1)),i.value?s.createCommentVNode("",!0):(s.openBlock(),s.createElementBlock("button",{key:2,class:"text-blue-500 hover:text-blue-600 px-0.5",type:"button",onClick:d}," ✎ ")),s.createElementVNode("button",{class:"text-rose-500 hover:text-rose-600 px-0.5",type:"button",onClick:f}," ✕ ")]))}}),zC={class:"ruler-control px-3 py-2.5 space-y-2"},HC={type:"button",class:"ruler-row w-full flex items-center gap-2 cursor-pointer group text-left"},jC={class:s.normalizeClass(["flex items-center justify-center w-5 h-5 rounded-full shrink-0 transition-colors pointer-events-none"]),title:"Сумарна довжина всіх відрізків","aria-hidden":"true"},UC={class:"text-sm font-semibold text-slate-700"},WC={class:"ruler-row"},KC={type:"button",class:"w-full flex items-center gap-2 cursor-pointer group text-left"},qC={class:s.normalizeClass(["flex items-center justify-center w-5 h-5 rounded-full shrink-0 transition-colors pointer-events-none"]),title:"Площа замкнутого контуру","aria-hidden":"true"},GC={class:"inline-flex rounded-md overflow-hidden border border-gray-200 bg-gray-100"},JC=["onClick"],YC={class:"flex items-center gap-2 mt-0.5 pl-7"},XC={key:0,class:"text-base font-semibold text-green-600"},ZC={key:1,class:"text-xs text-gray-400"},QC={class:"ruler-row flex items-center gap-2 cursor-pointer"},eS={class:s.normalizeClass(["flex items-center justify-center w-5 h-5 rounded-full shrink-0 transition-colors pointer-events-none"]),title:"Список точок","aria-hidden":"true"},tS={class:"text-xs font-medium text-gray-600 flex-1"},nS={key:0,class:"pt-1.5 border-t border-gray-100 max-h-32 overflow-y-auto space-y-1"},rS=s.defineComponent({__name:"ControlPanel",props:{points:{},isShapeClosed:{type:Boolean}},emits:["update-point","delete-point"],setup(n){const e=n,t=s.ref(!1),r=s.ref("km2"),o=[{id:"km2",label:"км²"},{id:"ha",label:"га"},{id:"m2",label:"м²"}],i=()=>{t.value=!t.value},l=(m,g)=>{const y=_=>_*Math.PI/180,b=y(g.lat-m.lat),w=y(g.lng-m.lng),v=y(m.lat),E=y(g.lat),N=Math.sin(b/2),R=Math.sin(w/2);return 6371e3*(2*Math.asin(Math.sqrt(N*N+Math.cos(v)*Math.cos(E)*R*R)))},a=s.computed(()=>{if(e.points.length<2)return 0;let m=0;for(let g=1;g<e.points.length;g+=1)m+=l(e.points[g-1].coords,e.points[g].coords);return e.isShapeClosed&&e.points.length>=2&&(m+=l(e.points[e.points.length-1].coords,e.points[0].coords)),m}),c=s.computed(()=>a.value>=1e3?`${Ar(a.value/1e3)} км`:`${Ar(a.value)} м`);function d(m){if(m.length<3)return 0;const g=m[0].lat,y=m[0].lng,b=(v,E)=>{const N=(v-g)*110574;return{x:(E-y)*111320*Math.cos(g*Math.PI/180),y:N}};let w=0;for(let v=0;v<m.length;v++){const E=(v+1)%m.length,N=b(m[v].lat,m[v].lng),R=b(m[E].lat,m[E].lng);w+=N.x*R.y-N.y*R.x}return Math.abs(w)*.5}const u=s.computed(()=>{if(!e.isShapeClosed||e.points.length<3)return 0;const m=e.points.map(g=>g.coords);return d(m)}),f=s.computed(()=>u.value>0),p=s.computed(()=>{const m=u.value;if(m===0)return"—";if(r.value==="km2"){const y=m/1e6;return`${Ar(y)} км²`}if(r.value==="ha"){const y=m/1e4;return`${Ar(y)} га`}const g=m>=1?Math.round(m):m;return`${Ar(g)} м²`}),h=s.computed(()=>{const m=e.points.length;return m===1?"1 точка":m>=2&&m<=4?`${m} точки`:`${m} точок`});return s.watch(()=>e.points.length,()=>{e.points.length===0&&(t.value=!1)}),(m,g)=>(s.openBlock(),s.createElementBlock("div",zC,[s.createElementVNode("button",HC,[s.createElementVNode("span",jC,[s.createVNode(s.unref(Y.Info),{size:12,"stroke-width":2.5})]),g[1]||(g[1]=s.createElementVNode("span",{class:"text-xs font-medium text-gray-600 flex-1"},"Загальна відстань",-1)),s.createElementVNode("span",UC,s.toDisplayString(c.value),1)]),s.createElementVNode("div",WC,[s.createElementVNode("button",KC,[s.createElementVNode("span",qC,[s.createVNode(s.unref(Y.Info),{size:12,"stroke-width":2.5})]),g[2]||(g[2]=s.createElementVNode("span",{class:"text-xs font-medium text-gray-600 flex-1"},"Площа",-1)),s.createElementVNode("div",GC,[(s.openBlock(),s.createElementBlock(s.Fragment,null,s.renderList(o,(y,b)=>s.createElementVNode("button",{key:y.id,type:"button",class:s.normalizeClass(["px-2.5 py-1 text-xs font-medium transition-colors border-r border-gray-200 last:border-r-0",b===0&&"rounded-l-md",b===o.length-1&&"rounded-r-md",r.value===y.id?"bg-white text-green-600 font-semibold shadow-sm":"text-gray-600 hover:bg-gray-50"]),onClick:s.withModifiers(w=>r.value=y.id,["stop"])},s.toDisplayString(y.label),11,JC)),64))])]),s.createElementVNode("div",YC,[f.value?(s.openBlock(),s.createElementBlock("span",XC,s.toDisplayString(p.value),1)):(s.openBlock(),s.createElementBlock("span",ZC,"—"))])]),s.createElementVNode("div",QC,[s.createElementVNode("span",eS,[s.createVNode(s.unref(Y.Info),{size:12,"stroke-width":2.5})]),s.createElementVNode("span",tS,s.toDisplayString(h.value),1),s.createElementVNode("button",{type:"button",class:"text-xs text-blue-500 hover:text-blue-600 font-medium transition-colors",onClick:s.withModifiers(i,["stop"])}," Координати ")]),t.value?(s.openBlock(),s.createElementBlock("div",nS,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(m.points,(y,b)=>(s.openBlock(),s.createBlock(PC,{key:y.id,id:y.id,index:b+1,coords:y.coords,onUpdate:g[0]||(g[0]=w=>m.$emit("update-point",w)),onDelete:w=>m.$emit("delete-point",y.id)},null,8,["id","index","coords","onDelete"]))),128))])):s.createCommentVNode("",!0)]))}}),oS={class:"px-3 py-3 bg-blue-50/50 border-b border-blue-100"},sS={class:"flex items-start gap-2"},iS=s.defineComponent({__name:"InfoHint",setup(n){return(e,t)=>(s.openBlock(),s.createElementBlock("div",oS,[s.createElementVNode("div",sS,[s.createVNode(s.unref(Y.Info),{size:16,"stroke-width":2,class:"text-blue-600 flex-shrink-0 mt-0.5"}),t[0]||(t[0]=s.createElementVNode("div",{class:"space-y-1"},[s.createElementVNode("p",{class:"text-xs font-medium text-blue-900"}," Натискайте на карту, щоб додати точки вимірювання "),s.createElementVNode("p",{class:"text-[10px] text-blue-700"},' Або скористайтесь кнопкою "Додати" внизу для введення координат вручну ')],-1))])]))}}),lS={class:"space-y-1.5"},aS={class:"space-y-1 max-h-40 overflow-y-auto"},cS={class:"text-gray-700"},dS={class:"font-semibold text-slate-800"},uS=s.defineComponent({__name:"ToPointList",props:{points:{},isShapeClosed:{type:Boolean}},setup(n){const e=n;function t(i,l){const a=h=>h*Math.PI/180,c=a(l.lat-i.lat),d=a(l.lng-i.lng),u=a(i.lat),f=a(l.lat);return 6371e3*(2*Math.asin(Math.sqrt(Math.sin(c/2)**2+Math.cos(u)*Math.cos(f)*Math.sin(d/2)**2)))}function r(i){return af(i)}const o=s.computed(()=>{const i=[],l=e.points;if(l.length<2)return i;for(let a=0;a<l.length;a++){const c=a===l.length-1&&e.isShapeClosed?0:a+1;if(c>=l.length)break;const d=t(l[a].coords,l[c].coords);i.push({from:a+1,to:c+1,label:r(d)})}return i});return(i,l)=>(s.openBlock(),s.createElementBlock("div",lS,[l[0]||(l[0]=s.createElementVNode("p",{class:"text-xs font-medium text-gray-600 mb-1.5"},"Відстань між точками:",-1)),s.createElementVNode("div",aS,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(o.value,(a,c)=>(s.openBlock(),s.createElementBlock("div",{key:c,class:"flex items-center justify-between text-xs py-1 px-2 rounded bg-gray-50"},[s.createElementVNode("span",cS,"Точка "+s.toDisplayString(a.from)+" → Точка "+s.toDisplayString(a.to),1),s.createElementVNode("span",dS,s.toDisplayString(a.label),1)]))),128))])]))}}),fS={class:"ruler-panel-wrap absolute bottom-12 right-4 z-[1001] animate-slide-up"},pS={class:"bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden w-72"},hS={class:"bg-gradient-to-r from-blue-400 to-blue-500 px-3 py-2 flex items-center justify-between"},mS={class:"flex items-center gap-2"},gS={class:"w-6 h-6 bg-white/20 rounded-lg flex items-center justify-center"},yS={class:"flex border-b border-gray-200"},bS={key:1,class:"px-3 py-2.5"},kS={key:1,class:"text-xs text-gray-500"},wS={class:"px-2.5 py-1.5 bg-gray-50 border-t border-gray-200 space-y-1.5"},xS={class:"flex gap-1.5"},vS=s.defineComponent({name:"RulerPanel",__name:"RulerPanel",emits:["close","tab-change","points-change","add-request","complete","shape-closed-change"],setup(n,{expose:e,emit:t}){const r=t,o=s.ref([]),i=s.computed(()=>o.value.length>0),l=s.ref(!1),a=s.ref(!1),c=s.ref("general");function d(A){c.value=A,r("tab-change",A)}s.onMounted(()=>{r("tab-change",c.value)});const u=s.computed(()=>o.value.length>=3&&!a.value);let f=1;const p=()=>o.value.map(A=>({id:A.id,coords:{...A.coords}})),h=()=>{o.value.length<3&&a.value&&(a.value=!1,r("shape-closed-change",!1)),r("points-change",p())},m=()=>{const A=f;return f+=1,A},g=A=>{o.value=[...o.value,{id:m(),coords:{lat:A.lat,lng:A.lng}}],h()},y=({id:A,coords:L})=>{const z=o.value.findIndex(D=>D.id===A);if(z===-1)return;const Z=[...o.value];Z[z]={id:A,coords:{...L}},o.value=Z,h()},b=A=>{o.value=o.value.filter(L=>L.id!==A),h()},w=()=>{o.value=[],a.value&&(a.value=!1,r("shape-closed-change",!1)),h()},v=A=>{y(A)},E=A=>{b(A)},N=()=>{l.value=!0,r("add-request")},R=A=>{g(A),l.value=!1},T=()=>{l.value=!1},M=()=>{u.value&&(a.value=!0,r("complete"),r("shape-closed-change",!0))},_=()=>{w(),l.value=!1,r("close")};return e({addPoint:g,clearPoints:w}),(A,L)=>(s.openBlock(),s.createElementBlock("div",fS,[s.createElementVNode("div",pS,[s.createElementVNode("div",hS,[s.createElementVNode("div",mS,[s.createElementVNode("div",gS,[s.createVNode(s.unref(Y.Ruler),{size:14,"stroke-width":2,class:"text-white"})]),L[2]||(L[2]=s.createElementVNode("h3",{class:"text-white font-semibold text-xs"},"Вимірювання",-1))]),s.createElementVNode("button",{class:"w-5 h-5 flex items-center justify-center rounded hover:bg-white/20 transition-colors","aria-label":"Закрити",onClick:_},[s.createVNode(s.unref(Y.X),{size:14,"stroke-width":2,class:"text-white"})])]),s.createElementVNode("div",yS,[s.createElementVNode("button",{type:"button",class:s.normalizeClass(["flex-1 px-3 py-2 text-xs font-medium transition-colors",c.value==="general"?"text-blue-600 border-b-2 border-blue-500 bg-blue-50/50":"text-gray-500 hover:text-gray-700"]),onClick:L[0]||(L[0]=z=>d("general"))}," Загальна ",2),s.createElementVNode("button",{type:"button",class:s.normalizeClass(["flex-1 px-3 py-2 text-xs font-medium transition-colors",c.value==="topoint"?"text-blue-600 border-b-2 border-blue-500 bg-blue-50/50":"text-gray-500 hover:text-gray-700"]),onClick:L[1]||(L[1]=z=>d("topoint"))}," До точки ",2)]),c.value==="general"?(s.openBlock(),s.createElementBlock(s.Fragment,{key:0},[i.value?(s.openBlock(),s.createBlock(rS,{key:1,points:o.value,"is-shape-closed":a.value,onUpdatePoint:v,onDeletePoint:E},null,8,["points","is-shape-closed"])):(s.openBlock(),s.createBlock(iS,{key:0}))],64)):(s.openBlock(),s.createElementBlock("div",bS,[i.value?(s.openBlock(),s.createBlock(uS,{key:0,points:o.value,"is-shape-closed":a.value},null,8,["points","is-shape-closed"])):(s.openBlock(),s.createElementBlock("p",kS,"Додайте точки на карті, щоб бачити відстані між ними."))])),s.createElementVNode("div",wS,[s.createElementVNode("div",xS,[l.value?s.createCommentVNode("",!0):(s.openBlock(),s.createBlock(VC,{key:0,onClick:N})),u.value?(s.openBlock(),s.createBlock(LC,{key:1,onClick:M})):s.createCommentVNode("",!0)]),l.value?(s.openBlock(),s.createBlock(DC,{key:0,onSubmit:R,onCancel:T})):s.createCommentVNode("",!0),i.value?(s.openBlock(),s.createBlock($C,{key:1,onClick:w})):s.createCommentVNode("",!0)])])]))}}),Pt="ruler-points",Vn="ruler-line",$n="ruler-polygon",Ln="ruler-segments",CS=s.defineComponent({__name:"RulerLayer",props:{map:{},points:{},isShapeClosed:{type:Boolean},labelMode:{}},setup(n){function e(m,g){const y=R=>R*Math.PI/180,b=y(g.lat-m.lat),w=y(g.lng-m.lng),v=y(m.lat),E=y(g.lat);return 6371e3*(2*Math.asin(Math.sqrt(Math.sin(b/2)**2+Math.cos(v)*Math.cos(E)*Math.sin(w/2)**2)))}function t(m){return af(m)}const r=n;function o(){return{type:"FeatureCollection",features:[]}}function i(m,g,y){const b=y??"general",w=[];let v=0;w.push(0);for(let E=1;E<m.length;E++)v+=e(m[E-1].coords,m[E].coords),w.push(v);return g&&m.length>=2&&(v+=e(m[m.length-1].coords,m[0].coords)),{type:"FeatureCollection",features:m.map((E,N)=>{const R=b==="general"?N===0?"0":t(w[N]):N===0?"0":t(e(m[N-1].coords,m[N].coords));return{type:"Feature",geometry:{type:"Point",coordinates:[E.coords.lng,E.coords.lat]},properties:{id:E.id,index:N+1,label:R}}})}}function l(m,g){if(m.length<2)return o();const y=[];for(let b=0;b<m.length;b++){const w=b===m.length-1&&g?0:b+1;if(w>=m.length)break;const v=m[b].coords,E=m[w].coords,N=e(v,E);y.push({type:"Feature",geometry:{type:"LineString",coordinates:[[v.lng,v.lat],[E.lng,E.lat]]},properties:{distance:t(N)}})}return{type:"FeatureCollection",features:y}}function a(m,g){if(m.length<2)return o();const y=m.map(b=>[b.coords.lng,b.coords.lat]);return g&&y.push(y[0]),{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"LineString",coordinates:y},properties:{}}]}}function c(m){if(m.length<3)return o();const g=m.map(y=>[y.coords.lng,y.coords.lat]);return g.push(g[0]),{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Polygon",coordinates:[g]},properties:{}}]}}let d=!1;function u(m){m.getSource(Pt)||(m.addSource(Pt,{type:"geojson",data:o()}),m.addLayer({id:`${Pt}-circle`,type:"circle",source:Pt,paint:{"circle-radius":5,"circle-color":"#1e293b","circle-stroke-width":2,"circle-stroke-color":"#ffffff"}}),m.addLayer({id:`${Pt}-labels`,type:"symbol",source:Pt,layout:{"text-field":["get","label"],"text-size":14,"text-offset":[0,1.3]},paint:{"text-color":"#0f172a","text-halo-color":"#ffffff","text-halo-width":1}})),m.getSource(Ln)||(m.addSource(Ln,{type:"geojson",data:o()}),m.addLayer({id:`${Ln}-labels`,type:"symbol",source:Ln,layout:{"text-field":["get","distance"],"text-size":13,"symbol-placement":"line-center","text-rotation-alignment":"map","text-pitch-alignment":"map"},paint:{"text-color":"#1e293b","text-halo-color":"#ffffff","text-halo-width":1.5}})),m.getSource(Vn)||(m.addSource(Vn,{type:"geojson",data:o()}),m.addLayer({id:`${Vn}-layer`,type:"line",source:Vn,paint:{"line-color":"#3b82f6","line-width":2}})),m.getSource($n)||(m.addSource($n,{type:"geojson",data:o()}),m.addLayer({id:`${$n}-layer`,type:"fill",source:$n,paint:{"fill-color":"#93c5fd","fill-opacity":.25}})),d=!0}function f(m){if(m){try{m.getLayer(`${$n}-layer`)&&m.removeLayer(`${$n}-layer`),m.getSource($n)&&m.removeSource($n),m.getLayer(`${Vn}-layer`)&&m.removeLayer(`${Vn}-layer`),m.getSource(Vn)&&m.removeSource(Vn),m.getLayer(`${Ln}-labels`)&&m.removeLayer(`${Ln}-labels`),m.getSource(Ln)&&m.removeSource(Ln),m.getLayer(`${Pt}-labels`)&&m.removeLayer(`${Pt}-labels`),m.getLayer(`${Pt}-circle`)&&m.removeLayer(`${Pt}-circle`),m.getSource(Pt)&&m.removeSource(Pt)}catch{}d=!1}}function p(m){if(!m)return;const g=m.getSource(Pt),y=m.getSource(Vn),b=m.getSource($n),w=m.getSource(Ln),v=r.points,E=r.labelMode??"general";g&&g.setData(i(v,r.isShapeClosed,E)),y&&y.setData(a(v,r.isShapeClosed)),b&&b.setData(c(v)),w&&w.setData(E==="topoint"?l(v,r.isShapeClosed):o())}function h(){const m=r.map;m&&(d||u(m),p(m))}return s.watch(()=>[r.points,r.isShapeClosed,r.labelMode],()=>h(),{deep:!0,immediate:!0}),s.watch(()=>r.map,()=>h(),{immediate:!0}),s.onBeforeUnmount(()=>{f(r.map)}),(m,g)=>null}});function SS(n={}){const e=s.ref(!1),t=s.ref([]),r=s.ref(!1),o=s.ref("general"),i=s.ref(null);function l(){e.value?a():(e.value=!0,n.onActivate?.())}function a(){e.value=!1,t.value=[],r.value=!1,i.value?.clearPoints(),n.onDeactivate?.()}function c(h){t.value=h}function d(h){o.value=h}function u(h){r.value=h}function f(h){e.value&&i.value?.addPoint({lat:h.lat,lng:h.lng})}const p=s.computed(()=>t.value.length>0);return{isRulerActive:e,rulerPoints:t,rulerShapeClosed:r,rulerActiveTab:o,rulerPanelRef:i,hasRulerPoints:p,toggleRuler:l,closeRuler:a,onRulerPointsChange:c,onRulerTabChange:d,onRulerShapeClosedChange:u,handleRulerMapClick:f}}const Da="vs-safe-raster",Io=new ArrayBuffer(0);let Va=!1;function ES(n){const e=`${Da}://`;return typeof n!="string"||!n.startsWith(e)?n:n.slice(e.length)}function MS(n){if(!n||n.byteLength<4)return!1;const e=new Uint8Array(n);return e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71||e[0]===255&&e[1]===216&&e[2]===255||e[0]===82&&e[1]===73&&e[2]===70&&e[3]===70&&n.byteLength>=12&&String.fromCharCode(e[8],e[9],e[10],e[11])==="WEBP"}async function AS(n,e){try{const t=await fetch(n,{signal:e});if(!t.ok||t.status===204)return Io;const r=await t.arrayBuffer();return!r.byteLength||!MS(r)?Io:r}catch{return Io}}function _S(n){Va||!n?.addProtocol||(Va=!0,n.addProtocol(Da,(e,t)=>{const r=ES(String(e?.url??""));if(!r)return t(null,{data:Io}),{cancel:()=>{}};const o=new AbortController;return AS(r,o.signal).then(i=>t(null,{data:i})).catch(()=>t(null,{data:Io})),{cancel:()=>o.abort()}}))}function TS(n){const e=typeof n=="string"?n.trim():"";if(!e)return e;const t=`${Da}://`;return e.startsWith(t)?e:`${t}${e}`}function BS(n,e){const t=typeof n=="string"?n.trim():"";return t?e&&Va?[TS(t)]:[t]:[]}function $a(n,e,t){const r={type:"raster",tiles:BS(n,!!t?.safe),tileSize:typeof e?.tileSize=="number"?e.tileSize:256};return typeof e?.minzoom=="number"&&(r.minzoom=e.minzoom),typeof e?.maxzoom=="number"&&(r.maxzoom=e.maxzoom),Array.isArray(e?.bounds)&&e.bounds.length===4&&(r.bounds=e.bounds),r}function NS(n){const e=String(n??"").toLowerCase();return e.includes("could not be decoded")||e.includes("source image could not be decoded")||e.includes("unsupported image type")}const DS={class:"vs-map-body"},VS={key:0,class:"absolute top-2 left-2 z-[1000] w-[calc(100%-16px)] sm:w-[320px]"},$S={key:1,class:"form-geom__panel flex items-center gap-1 mt-1"},LS={class:"flex items-center gap-1"},IS=["disabled"],OS={key:0,class:"absolute z-[1600] left-0 top-full mt-1 w-full min-w-[140px] bg-white border border-gray-200 shadow-lg rounded-lg text-sm overflow-hidden"},RS=["disabled"],FS={key:0,class:"mb-3 flex items-center gap-2 rounded-md border border-blue-100 bg-blue-50 px-3 py-2 text-sm text-blue-700"},PS={class:"mt-4 flex justify-end gap-2"},zS=["disabled"],HS=["disabled"],jS={class:"mt-4 flex justify-end gap-2"},US=["disabled"],WS={class:"vs-map-controls vs-map-controls--tr"},KS={class:"vs-map-toolbar"},qS=["disabled"],GS=["disabled"],JS=["disabled"],YS=["disabled"],XS={key:1,class:"vs-map-toolbar__divider"},ZS=["title"],QS={class:"bg-white/95 border border-gray-200 rounded-md shadow-xl px-3 py-2 max-w-[240px] text-[11px] sm:text-xs text-gray-900"},eE={class:"space-y-0.5"},tE={class:"text-gray-500"},nE={class:"text-gray-900 text-right break-all"},rE={class:"absolute left-2 bottom-2 z-[1000]"},oE={key:0,class:"vs-map-status"},sE={class:"form-geom__feature vs-map-status__inner"},iE={class:"vs-map-status__type"},lE={class:"vs-map-status__values"},aE=["onClick","disabled"],cE={key:1,class:"vs-map-status__chip"},dE={key:2,class:"vs-map-status__sep"},uE={key:1,class:"vs-map-status__chip"},fE={class:"vs-map-status__meta"},pE={class:"vs-map-status__coords"},hE={key:0,class:"vs-map-status__value"},mE={key:1,class:"vs-map-status__value"},gE={key:0,class:"vs-map-status__area"},yE={class:"vs-map-status__value"},bE={class:"vs-map-status__actions"},kE=["disabled"],wE=["disabled"],xE=11,vE=15,CE=.7,SE="vs-tile-ov-src-",EE="vs-tile-ov-raster-",ui="__vs_form_maplibre_loader__",ME="https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf",fi="vs-global-bounds-src",oo="vs-global-bounds-line",cf="rasterLayer",df=Ne(s.defineComponent({__name:"vs-input-map",props:{tools:{},multi:{type:Boolean,default:!1},multiple:{type:Boolean,default:!1},handleZoom:{type:Boolean,default:!0},ctrlZoom:{type:Boolean,default:!0},geomType:{default:()=>[]},prefix:{default:""},katottg:{default:""},layers:{default:()=>[]},bounds:{},api:{},center:{default:void 0},zoom:{default:void 0},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},emits:["update:modelValue","valueSelected"],setup(n,{emit:e}){const t=n,r=e,o=s.useAttrs(),i=s.inject("values",s.ref({})),l=typeof document<"u"&&document.querySelector("#modal")?"#modal":"body",a=s.computed(()=>{const k=o?.multiple,x=o?.multi,S=B=>B===""||B===!0||B==="true"||B===1||B==="1";return!!t.multi||!!t.multiple||S(x)||S(k)}),c=s.computed(()=>!!t.disabled),d=s.ref(!1),u=s.ref(null),f=s.ref(0),p=s.ref(""),h=s.ref(null),m=s.ref([]),g=s.ref(null),y=s.ref(null),b=SS({onActivate(){if(ye)try{ye.changeMode("simple_select",{featureIds:[]})}catch{}p.value=""},onDeactivate(){}});function w(){b.toggleRuler()}const v=s.getCurrentInstance(),E=v?.appContext?.config?.globalProperties?.$settings??{},N=E?.map??{},R=s.computed(()=>{const k=N.layerPresets;return Array.isArray(k)?k:[]}),T=v?.vnode?.props??{};function M(k){return Object.prototype.hasOwnProperty.call(T,k)||Object.prototype.hasOwnProperty.call(T,k.replace(/[A-Z]/g,x=>`-${x.toLowerCase()}`))}const _=Array.isArray(N.center)&&N.center.length===2?N.center:Array.isArray(E.center)&&E.center.length===2?E.center:[30,50],A=typeof N.zoom=="number"?N.zoom:typeof E.zoom=="number"?E.zoom:typeof E.defaultZoom=="number"?E.defaultZoom:10;function L(k){if(k!=null){if(Array.isArray(k)&&k.length>=2){const x=Number(k[0]),S=Number(k[1]);return!Number.isFinite(x)||!Number.isFinite(S)?void 0:[x,S]}if(typeof k=="object"){const x=k,S=x.geom;if(x.type==="Point"&&Array.isArray(x.coordinates)){const J=x.coordinates,ue=Number(J[0]),he=Number(J[1]);if(Number.isFinite(ue)&&Number.isFinite(he))return[ue,he]}if(S?.type==="Point"&&Array.isArray(S.coordinates)){const J=S.coordinates,ue=Number(J[0]),he=Number(J[1]);if(Number.isFinite(ue)&&Number.isFinite(he))return[ue,he]}const B=Number(x.lat),F=Number(x.lng??x.lon);if(Number.isFinite(B)&&Number.isFinite(F))return[F,B]}}}const z=s.computed(()=>{const k=L(t.center);if(k)return k;if(!M("center"))return L(N.center)??L(E.center)}),Z=s.computed(()=>M("zoom")?t.zoom:N.zoom??t.zoom),D=s.computed(()=>M("katottg")?String(t.katottg??""):String(N.katottg??t.katottg??"")),P=s.computed(()=>M("layers")?t.layers??[]:N.layers??t.layers??[]),ne=s.computed(()=>M("bounds")?t.bounds:N.bounds??t.bounds),U=s.ref(Array.isArray(z.value)&&z.value.length===2?[...z.value]:_),K=s.ref(typeof Z.value=="number"?Z.value:A),X=s.ref(null);let le=null;function H(k){const x=typeof k=="number"&&Number.isFinite(k)?k:K.value;return Math.min(vE,Math.max(xE,Math.round(x)))}function $(k,x,S){if(!Number.isFinite(k)||!Number.isFinite(x))return;const B=Fv(k,x,H(S)),F=X.value;F&&F.z===B.z&&F.x===B.x&&F.y===B.y||(X.value=B)}function I(){if(G){const k=G.getCenter?.(),x=G.getZoom?.();if(k&&Number.isFinite(x)){$(k.lng,k.lat,x);return}}Array.isArray(U.value)&&U.value.length===2&&$(U.value[0],U.value[1])}function te(){le&&clearTimeout(le),le=setTimeout(()=>{le=null,I()},120)}$(U.value[0],U.value[1]);const ae=s.ref(t.modelValue),re=s.ref(null),ge=s.ref([]),Ee=s.ref(!1),xe=s.ref(!1),Ie=s.ref(!1),je=s.ref(!1),Fe=s.ref(!1);s.provide("map-file-import-uploading",Fe);const ot=s.computed(()=>Fe.value?"Завантаження файлу на сервер...":je.value?"Конвертація геометрії...":""),We=s.ref([]),oe=s.ref({srid:"",encoding:"UTF-8",file:""}),pe=s.computed(()=>{const k=i.value??{},x=k.id??o.id??"1",S=o.form??k.form??"form",B=o.table??k.table??"table",F=t.name??o.field??"geom";return`/file/upload/temp?${new URLSearchParams({id:String(x),form:String(S),table:String(B),field:String(F)}).toString()}`}),_e=s.computed(()=>({srid:{type:"Autocomplete",label:"Система координат",info:"Оберіть одну із систем координат в якій знаходяться ваші геодані",data:"gis.srid_from_setting",placeholder:"Обрати",rules:["required"]},encoding:{type:"Select",label:"Кодування файлу",info:"Вкажіть кодування в якому зберігається інформація в ваших файлах. Зазвичай це UTF-8",options:[{id:"UTF-8",text:"UTF-8"},{id:"CP1251",text:"CP1251"},{id:"LATIN-1",text:"LATIN-1"}],default:"UTF-8",rules:["required"]},file:{type:"File",label:"Файл",info:"Завантажте файл із геоданими у форматі GeoJson або Zip (Shapefiles)",format:".geojson,.zip",api:pe.value,rules:["required"]}})),Te=s.ref({coordinates:"",format:"decimal",order:"lat-lon"}),dt={coordinates:{type:"Textarea",label:"Координати вершин полігону (3-100 точок)",placeholder:`50.4501, 30.5234
3
3
  50.4510, 30.5242
4
- 50.4494, 30.5260`},format:{type:"Radio",label:"Формат координат",options:[{id:"decimal",text:"Десяткові (Decimal)"},{id:"dms",text:"Градуси-хвилини-секунди (DMS)"}]},order:{type:"Radio",label:"Порядок координат",options:[{id:"lat-lon",text:"lat, lon"},{id:"lon-lat",text:"lon, lat"}]}};let Te=!1,Je=!1;const Ae=e.reactive({}),Fe=e.ref([]),ut=e.computed(()=>Fe.value.map(u=>Ae[u]).filter(Boolean)),z=e.ref(null),J=e.computed(()=>z.value?.entries??[]),ie=e.computed(()=>{if(z.value)return{left:`${z.value.point.x+12}px`,top:`${z.value.point.y+12}px`}}),F=e.computed(()=>{if(Array.isArray(n.tools)&&n.tools.length)return n.tools;const u=a?.tools;return Array.isArray(u)?u.map(y=>String(y)):typeof u=="string"?u.split(",").map(y=>y.trim()).filter(Boolean):[]}),w=e.computed(()=>{const u={search:!1,import:!1,export:!1,point:!1,line:!1,polygon:!1,rectangle:!1,ruler:!1};if(!F.value.length)return{...u,import:!0,export:!0,point:!0,line:!0,polygon:!0,rectangle:!0};const y=new Set(F.value.map(x=>x.toLowerCase()));return{search:y.has("search"),import:y.has("import"),export:y.has("export"),point:y.has("point"),line:y.has("line"),polygon:y.has("polygon"),rectangle:y.has("rectangle"),ruler:y.has("ruler")}});function S(u){const y=typeof u=="string"?u.trim():"";if(!y)return"";if(/^https?:\/\//i.test(y))return y;const x=window?.location?.origin??"",B=y.replace(/^\/+/,"");return B?x?`${x}/${B}`:`/${B}`:x}function P(){const u=Array.isArray(q.basemaps)&&q.basemaps.length?q.basemaps:$.basemaps;if(Array.isArray(u)&&u.length){const x=u.map((B,L)=>{const Y=String(B?.key??B?.id??B?.name??`b${L}`),ce=S(String(B?.url??""));if(!ce)return null;const ue=typeof B?.preview=="string"&&B.preview?S(B.preview):"";return[Y,{...B,url:ce,preview:ue}]}).filter(B=>Array.isArray(B)&&B.length===2).reduce((B,[L,Y])=>(B[L]=Y,B),{});if(Object.keys(x).length)return x}return{voyager:{name:"Оглядова карта",url:"https://data.gki.com.ua/api-user/rtile/voyager/ua/{z}/{x}/{y}.png",preview:"https://data.gki.com.ua/api-user/rtile/voyager/ua/13/4790/2762.png"},orto10:{name:"Ортофото 1:10K",url:"https://data.gki.com.ua/api-user/rtile/orto10/ua/{z}/{x}/{y}.png",preview:"https://data.gki.com.ua/api-user/rtile/orto10/ua/13/4790/2762.png"},osmb:{name:"Open Street Maps",url:"https://tile.openstreetmap.org.ua/styles/osm-bright/{z}/{x}/{y}.png",preview:"https://tile.openstreetmap.org.ua/styles/osm-bright/13/4790/2762.png"}}}const le=P(),we=Object.keys(le),Le=e.ref(we.length?we[0]:"");function De(){const u=Array.isArray(q.overlays)&&q.overlays.length?q.overlays:$.overlays;return!Array.isArray(u)||!u.length?{}:u.map((x,B)=>{const Y=(typeof x?.name=="string"?x.name.trim():"")||`o${B}`,ce=S(String(x?.url??""));if(!ce)return null;const ue=typeof x?.preview=="string"&&x.preview?S(x.preview):"";return[Y,{...x,name:Y,url:ce,preview:ue}]}).filter(x=>Array.isArray(x)&&x.length===2).reduce((x,[B,L])=>(x[B]=L,x),{})}const je=De(),He=e.ref(Object.keys(je).filter(u=>!!je[u]?.visible)),pt=e.computed(()=>w.value.point||w.value.line||w.value.polygon||w.value.rectangle),qe=e.computed(()=>ut.value.filter(u=>u.config?.overlay!==!1).map(u=>({id:u.id,label:String(u.config.title||u.config.name||u.id),visible:u.visible})));function it(u){return`${yf}${u}`}function Pt(u){return`${bf}${u}`}async function to(){if(typeof window>"u")return null;const u=window;if(u[Un])return u[Un];const y=Y=>{if(Array.from(document.styleSheets).some(Ee=>Ee?.href?.includes(Y)))return;const ue=document.createElement("link");ue.rel="stylesheet",ue.href=Y,document.head.appendChild(ue)},x=async()=>{const Y=new Function("u","return import(u)"),ce=await Y("https://esm.sh/maplibre-gl@3.6.2"),ue=ce?.default??ce;if(!ue)throw new Error("maplibre esm fallback failed");window.maplibregl=ue,window.mapboxgl=ue;const Ee=await Y("https://esm.sh/@mapbox/mapbox-gl-draw@1.5.0"),Ie=Ee?.default??Ee;if(!Ie)throw new Error("mapbox draw esm fallback failed");window.MapboxDraw=Ie},L=(async()=>{y("https://unpkg.com/maplibre-gl@3.6.2/dist/maplibre-gl.css"),y("https://unpkg.com/@mapbox/mapbox-gl-draw@1.5.0/dist/mapbox-gl-draw.css"),(!window.maplibregl||!window.MapboxDraw)&&await x();const Y=window.maplibregl,ce=window.MapboxDraw;if(!Y)throw new Error("maplibregl not available after load");if(!ce)throw new Error("MapboxDraw not available after load");return wm(Y),{maplibregl:Y,MapboxDraw:ce}})().catch(Y=>{throw delete u[Un],Y});return u[Un]=L,L}function Qt(u){return{version:8,glyphs:kf,sources:{rasterSource:Ao(u,void 0,{safe:!1})},layers:[{id:"rasterLayer",type:"raster",source:"rasterSource"}]}}let $t=null,Rt=null,K=null,fe=null,tt=[],At=null,wt=null,We=null,en=!1,Gt=!1,W=!1,re=null;function pe(){return{onSetup(){const u=this.newFeature({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[0,0],[0,0],[0,0],[0,0],[0,0]]]}});return this.addFeature(u),this.clearSelectedFeatures(),this.updateUIClasses({mouse:"add"}),this.setActionableState({trash:!0}),{rectangle:u,startPoint:null,hasCoordinates:!1}},onMouseMove(u,y){if(!u.startPoint)return;const[x,B]=u.startPoint,L=y.lngLat.lng,Y=y.lngLat.lat;u.rectangle.setCoordinates([[[x,B],[L,B],[L,Y],[x,Y],[x,B]]])},onClick(u,y){if(!u.startPoint){u.startPoint=[y.lngLat.lng,y.lngLat.lat],u.hasCoordinates=!0,u.rectangle.setCoordinates([[[y.lngLat.lng,y.lngLat.lat],[y.lngLat.lng,y.lngLat.lat],[y.lngLat.lng,y.lngLat.lat],[y.lngLat.lng,y.lngLat.lat],[y.lngLat.lng,y.lngLat.lat]]]);return}const[x,B]=u.startPoint,L=y.lngLat.lng,Y=y.lngLat.lat;return Math.abs(x-L)>0&&Math.abs(B-Y)>0?(u.rectangle.setCoordinates([[[x,B],[L,B],[L,Y],[x,Y],[x,B]]]),this.map.fire("draw.create",{features:[u.rectangle.toGeoJSON()]}),this.changeMode("simple_select",{featureIds:[u.rectangle.id]})):(this.deleteFeature([u.rectangle.id],{silent:!0}),u.hasCoordinates=!1,this.changeMode("simple_select"))},onStop(){},onTrash(u){this.deleteFeature([u.rectangle.id],{silent:!0}),this.changeMode("simple_select")},toDisplayFeatures(u,y,x){const B=y.properties.id===u.rectangle.id;B&&!u.hasCoordinates||(y.properties.active=B?"true":"false",x(y))}}}const Ve=[{id:"gl-draw-polygon-fill-inactive",type:"fill",filter:["all",["==","$type","Polygon"],["!=","active","true"]],paint:{"fill-color":"#3b82f6","fill-outline-color":"#3b82f6","fill-opacity":.1}},{id:"gl-draw-polygon-fill-active",type:"fill",filter:["all",["==","$type","Polygon"],["==","active","true"]],paint:{"fill-color":"#2563eb","fill-outline-color":"#2563eb","fill-opacity":.2}},{id:"gl-draw-polygon-stroke-inactive",type:"line",filter:["all",["==","$type","Polygon"],["!=","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3b82f6","line-width":2}},{id:"gl-draw-polygon-stroke-active",type:"line",filter:["all",["==","$type","Polygon"],["==","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#2563eb","line-width":2}},{id:"gl-draw-lines-inactive",type:"line",filter:["all",["==","$type","LineString"],["!=","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3b82f6","line-width":2}},{id:"gl-draw-lines-active",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#2563eb","line-width":2}},{id:"gl-draw-point-inactive",type:"circle",filter:["all",["==","$type","Point"],["!=","meta","midpoint"],["!=","active","true"]],paint:{"circle-radius":5,"circle-color":"#3b82f6"}},{id:"gl-draw-point-active",type:"circle",filter:["all",["==","$type","Point"],["!=","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":6,"circle-color":"#2563eb"}},{id:"gl-draw-polygon-and-line-vertex-halo-active",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"]],paint:{"circle-radius":7,"circle-color":"#fff"}},{id:"gl-draw-polygon-and-line-vertex-active",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"]],paint:{"circle-radius":5,"circle-color":"#2563eb"}},{id:"gl-draw-polygon-midpoint",type:"circle",filter:["all",["==","meta","midpoint"],["==","$type","Point"]],paint:{"circle-radius":4,"circle-color":"#1d4ed8"}}];function Pe(){const u=Le.value;return!u||!le[u]?.url?"":le[u].url}function Xe(u,y){return u?.id?String(u.id):u?.url?`${u.url}-${y}`:`layer-${y}`}function Re(u){const y=String(u?.url??"").trim();if(!y)return"";if(/^https?:\/\//i.test(y))return y;const x=window.location?.origin??"",B=y.replace(/^\/+/,"");return`${x}/${B}`}function Ze(u){u&&z.value?.layerId!==u||(z.value=null)}function xt(u,y={}){if(u.popup===!1)return[];const x=Number(y?.point_count);if(Number.isFinite(x)&&x>1)return[{key:"Об'єктів у кластері",value:String(x)}];const B=Re(u),L=_n(u,B,G.value);return Array.isArray(u.popup)?u.popup.length?u.popup.map(Y=>{const ce=Y?.field||Y?.name;if(!ce)return null;const ue=y[ce];if(ue==null||ue==="")return null;const Ee=L?.formatPopupValue?L.formatPopupValue(ce,ue):String(ue);return{key:Y.label||ce,value:Ee}}).filter(Boolean):[]:Object.entries(y).slice(0,5).map(([Y,ce])=>({key:Y,value:ce==null?"—":String(ce)}))}function mt(u){if(!Array.isArray(u))return[];const y=B=>Array.isArray(B)&&B.length>=2&&Number.isFinite(Number(B[0]))&&Number.isFinite(Number(B[1])),x=B=>{if(!B.length)return B;const L=B[0],Y=B[B.length-1];return!Y||L[0]!==Y[0]||L[1]!==Y[1]?[...B,L]:B};if(u.length&&y(u[0])){const B=u.map(L=>[Number(L[0]),Number(L[1])]).filter(y);return B.length?[x(B)]:[]}return u.length&&Array.isArray(u[0])&&y(u[0][0])?u.map(L=>Array.isArray(L)?L.map(Y=>[Number(Y[0]),Number(Y[1])]):[]).filter(L=>L.length).map(x):u.length&&Array.isArray(u[0])&&Array.isArray(u[0][0])&&y(u[0][0][0])?u.flatMap(L=>Array.isArray(L)?L:[]).map(L=>Array.isArray(L)?L.map(Y=>[Number(Y[0]),Number(Y[1])]):[]).filter(L=>L.length).map(x):[]}function vt(u){const y=u.style??{},x=y.color??"#3b82f6";if(!y.colorAttr||!y.colorSet)return x;const B=Object.keys(y.colorSet);if(!B.length)return x;const L=["match",["to-string",["get",y.colorAttr]]];return B.forEach(Y=>{L.push(String(Y),y.colorSet?.[Y]??x)}),L.push(x),L}function ft(u){if(!K)return;const y=K.getStyle()?.layers;Array.isArray(y)&&[...y].reverse().forEach(x=>{x.source===u&&K.getLayer(x.id)&&K.removeLayer(x.id)})}function zt(u){if(!K)return;u.handlers.forEach(B=>{try{K.off(B.type,B.layerId,B.handler)}catch{}}),u.handlers=[],[...u.layerIds,...u.boundsIds].forEach(B=>{K.getLayer(B)&&K.removeLayer(B)}),ft(u.sourceId),K.getSource(u.sourceId)&&K.removeSource(u.sourceId);const y=`vs-ov-bounds-src-${u.id}`,x=`vs-ov-bounds-line-${u.id}`;K.getLayer(x)&&K.removeLayer(x),K.getSource(y)&&K.removeSource(y),Ze(u.id)}function mb(u,y){if(!K)return[];const x=`vs-ov-bounds-src-${y}`,B=`vs-ov-bounds-line-${y}`,L=u.bounds??oe.value??me.value,Y=mt(L);if(!Y.length)return[];const ce={type:"FeatureCollection",features:Y.map(ue=>({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:ue}}))};return K.getLayer(B)&&K.removeLayer(B),K.getSource(x)&&K.removeSource(x),K.addSource(x,{type:"geojson",data:ce}),K.addLayer({id:B,type:"line",source:x,paint:{"line-color":u.style?.stroke??u.style?.color??"#2563eb","line-width":u.style?.width??2,"line-opacity":u.style?.opacity??.8,"line-dasharray":[2,2]}}),[B]}function Ho(){return W||p.value==="marker"||p.value==="polyline"||p.value==="polygon"||p.value==="rectangle"}function fb(u,y){if(!K)return;u.handlers.forEach(B=>{try{K.off(B.type,B.layerId,B.handler)}catch{}});const x=[];y.forEach(B=>{const L=ce=>{if(Ho())return;if(!ce?.features?.length){Ze(u.id);return}const ue=ce.features[0]?.properties??{},Ee=xt(u.config,ue);if(!Ee.length){Ze(u.id);return}z.value={layerId:u.id,entries:Ee,point:{x:ce.point.x,y:ce.point.y}}},Y=()=>Ze(u.id);K.on("mousemove",B,L),K.on("mouseleave",B,Y),x.push({layerId:B,type:"mousemove",handler:L},{layerId:B,type:"mouseleave",handler:Y})}),u.handlers=x}function qo(u,y){if(!K)return;u.layerIds=y,u.boundsIds=mb(u.config,u.id),fb(u,y);const x=u.visible?"visible":"none";[...u.layerIds,...u.boundsIds].forEach(B=>{K.getLayer(B)&&K.setLayoutProperty(B,"visibility",x)}),_t()}function tn(u){if(!K)return;zt(u),u.renderToken=(u.renderToken??0)+1;const y=u.renderToken,x=u.config,B=Re(x);if(!B)return;const L=[],Y=/\.v(?:m)?t(?:\?|$|\/)/i.test(B)||/\.pbf(?:\?|$)/i.test(B)||/\/vtile(?:\/|\?|$)/i.test(B)||String(x?.service??"").toLowerCase()==="vector"||String(x?.format??"").toLowerCase()==="mvt",ce=_n(x,B,G.value);if(Y&&ce){const ue=x.sourceLayer||x.layer||x.service_layer||x.dataset?.layer||x.id;K.addSource(u.sourceId,{type:"vector",tiles:[B],minzoom:typeof x.minzoom=="number"?x.minzoom:0,maxzoom:typeof x.maxzoom=="number"?x.maxzoom:22}),(async()=>{try{if(!K||!K.getSource(u.sourceId)||u.renderToken!==y)return;const Ee=await ce.render({map:K,overlayId:u.id,sourceId:u.sourceId,sourceLayer:ue,url:B,config:x});if(!K||!K.getSource(u.sourceId)||u.renderToken!==y){Ee.forEach(Ie=>{K.getLayer(Ie)&&K.removeLayer(Ie)});return}qo(u,Ee)}catch(Ee){u.renderToken===y&&console.error(`Failed to render map layer preset "${ce.id}"`,Ee)}})();return}if(Y){const ue=x.sourceLayer||x.layer||x.service_layer||x.dataset?.layer||x.id;K.addSource(u.sourceId,{type:"vector",tiles:[B],minzoom:typeof x.minzoom=="number"?x.minzoom:0,maxzoom:typeof x.maxzoom=="number"?x.maxzoom:22});const Ee=Array.isArray(x.style?.types)?x.style.types.map(Ft=>String(Ft).toLowerCase()):[String(x.style?.type??"polygon").toLowerCase()],Ie=vt(x),Mt=x.style?.opacity??.5,tr=Ft=>{if(Ft==="point"){const vn=`vs-ov-point-${u.id}`;K.addLayer({id:vn,type:"circle",source:u.sourceId,"source-layer":ue,paint:{"circle-color":Ie,"circle-radius":x.style?.radius??5,"circle-opacity":Mt}}),L.push(vn);return}if(Ft==="polyline"||Ft==="line"){const vn=`vs-ov-line-${u.id}`;K.addLayer({id:vn,type:"line",source:u.sourceId,"source-layer":ue,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":Ie,"line-width":x.style?.width??2,"line-opacity":Mt}}),L.push(vn);return}const Xl=`vs-ov-fill-${u.id}`,Zl=`vs-ov-border-${u.id}`;K.addLayer({id:Xl,type:"fill",source:u.sourceId,"source-layer":ue,paint:{"fill-color":Ie,"fill-opacity":Mt}}),K.addLayer({id:Zl,type:"line",source:u.sourceId,"source-layer":ue,paint:{"line-color":x.style?.stroke??x.style?.color??"#2563eb","line-width":x.style?.width??1,"line-opacity":Mt}}),L.push(Xl,Zl)};[...new Set(Ee)].forEach(Ft=>tr(Ft)),qo(u,L);return}else{K.addSource(u.sourceId,Ao(B,x,{safe:!1}));const ue=`vs-ov-raster-${u.id}`;K.addLayer({id:ue,type:"raster",source:u.sourceId,paint:{"raster-opacity":x.style?.opacity??1}}),L.push(ue)}qo(u,L)}function wn(){if(!K)return;const y={type:"FeatureCollection",features:mt(oe.value??me.value).map(x=>({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:x}}))};K.getSource(Hn)?K.getSource(Hn).setData(y):K.addSource(Hn,{type:"geojson",data:y}),K.getLayer(Zt)||K.addLayer({id:Zt,type:"line",source:Hn,paint:{"line-color":"#2563eb","line-width":2,"line-opacity":.8,"line-dasharray":[2,2]}})}function hb(u){if(!K||i.value)return;const y=Ae[u];if(!y)return;y.visible=!y.visible;const x=y.visible?"visible":"none";[...y.layerIds,...y.boundsIds].forEach(B=>{K.getLayer(B)&&K.setLayoutProperty(B,"visibility",x)}),_t(),y.visible||Ze(u)}function Tl(u){if(!K)return;const y=je[u];if(!y?.url)return;const x=it(u),B=Pt(u);K.getLayer(B)&&K.removeLayer(B),K.getSource(x)&&K.removeSource(x),K.addSource(x,Ao(y.url,y,{safe:!0}));const L=y?.opacity??y?.style?.opacity,Y=typeof L=="number"?L:gf;K.addLayer({id:B,type:"raster",source:x,paint:{"raster-opacity":Y}})}function gb(u){if(!K)return;const y=it(u),x=Pt(u);K.getLayer(x)&&K.removeLayer(x),K.getSource(y)&&K.removeSource(y)}function Ll(){K&&He.value.forEach(u=>Tl(u))}function yb(u){if(!K||i.value||!je[u])return;He.value.includes(u)?(He.value=He.value.filter(x=>x!==u),gb(u)):(He.value=[...He.value,u],Tl(u)),_t()}function _t(){if(!K)return;const u=He.value.map(Ee=>Pt(Ee)).filter(Ee=>K.getLayer(Ee)),y=[],x=[],B=[],L=[];Fe.value.forEach(Ee=>{const Ie=Ae[Ee];if(!Ie)return;const Mt=String(Ie.config?.url??""),tr=/\.v(?:m)?t(?:\?|$|\/)/i.test(Mt)||/\/vtile(?:\/|\?|$)/i.test(Mt)||nr(Ie.config,Mt,G.value),Ft=/\.png(?:\?|$)/i.test(Mt);tr?B.push(...Ie.layerIds):Ft?y.push(...Ie.layerIds):x.push(...Ie.layerIds),L.push(...Ie.boundsIds)});const Y=[...u,...y,...x,...B,...L];Y.forEach(Ee=>{K.getLayer(Ee)&&K.moveLayer(Ee)}),K.getLayer(Zt)&&K.moveLayer(Zt);const ue=(K.getStyle?.()?.layers??[]).map(Ee=>String(Ee?.id??"")).filter(Ee=>Ee.startsWith("gl-draw-"));if(ue.forEach(Ee=>{K.getLayer(Ee)&&K.moveLayer(Ee)}),K.getLayer(zr)){const Ee=Y.find(Ie=>K.getLayer(Ie))??(K.getLayer(Zt)?Zt:null)??ue.find(Ie=>K.getLayer(Ie));Ee&&K.moveLayer(zr,Ee)}}function bb(u){if(!le[u]||(Le.value=u,!K))return;const y=Pe();if(!y)return;const x=K.getSource("rasterSource");if(x&&typeof x.setTiles=="function"){x.setTiles([y]),_t();return}const B=K.getCenter?.(),L=K.getZoom?.(),Y=fe?.getAll?.();K.setStyle(Qt(y)),K.once("style.load",()=>{if(K&&(B&&Number.isFinite(L)&&K.jumpTo({center:[B.lng,B.lat],zoom:L}),wn(),Ll(),Fe.value.forEach(ce=>{const ue=Ae[ce];ue&&tn(ue)}),_t(),Y?.features?.length&&fe))try{Y.features.forEach(ce=>fe.add(ce)),g.value=Y.features.length}catch{g.value=0}})}function Wo(u){return{type:"Feature",properties:{},geometry:u}}function Ct(u){if(!u)return null;try{return JSON.parse(JSON.stringify(u))}catch{return null}}function Ko(u){if(!u)return null;const y=Ct(u.geometry);return y?{...u.id!==void 0?{id:u.id}:{},type:"Feature",properties:{...u.properties??{}},geometry:y}:null}function no(u){if(!u)return[];const y=(L,Y)=>{if(!L?.type)return[];const ce={...Y??{}};return L.type==="MultiPoint"&&Array.isArray(L.coordinates)?L.coordinates.map(ue=>Wo({type:"Point",coordinates:ue})).map(ue=>({...ue,properties:ce})):L.type==="MultiLineString"&&Array.isArray(L.coordinates)?L.coordinates.map(ue=>Wo({type:"LineString",coordinates:ue})).map(ue=>({...ue,properties:ce})):L.type==="MultiPolygon"&&Array.isArray(L.coordinates)?L.coordinates.map(ue=>Wo({type:"Polygon",coordinates:ue})).map(ue=>({...ue,properties:ce})):L.type==="GeometryCollection"&&Array.isArray(L.geometries)?L.geometries.flatMap(ue=>y(ue,ce)):[{type:"Feature",properties:ce,geometry:Ct(L)}]},x=L=>{if(!L)return null;if(L.type==="Feature"){const Y=Ko(L);return Y?y(Y.geometry,Y.properties):null}return L.geom?.type&&Array.isArray(L.geom.coordinates)?y({type:L.geom.type,coordinates:L.geom.coordinates},L.properties??{}):L.type==="GeometryCollection"&&Array.isArray(L.geometries)?y(L,L.properties??{}):typeof L.type=="string"&&Array.isArray(L.coordinates)?y(Ct(L),L.properties??{}):null};if(u.type==="FeatureCollection")return(u.features??[]).flatMap(x).filter(Boolean);if(Array.isArray(u))return u.flatMap(L=>L?.type==="FeatureCollection"?no(L):[x(L)]).flat().filter(Boolean);const B=x(u);return B?Array.isArray(B)?B:[B]:[]}function Il(u){if(!u.length)return null;if(!c.value)return Ct(u[0]?.geometry??null);const y=u.map(Y=>Ct(Y?.geometry)).filter(Boolean);return y.every(Y=>Y?.type==="Point")?{type:"MultiPoint",coordinates:y.map(Y=>Y.coordinates)}:y.every(Y=>Y?.type==="LineString")?{type:"MultiLineString",coordinates:y.map(Y=>Y.coordinates)}:y.every(Y=>Y?.type==="Polygon")?{type:"MultiPolygon",coordinates:y.map(Y=>Y.coordinates)}:{type:"GeometryCollection",geometries:y}}function Ol(u){if(!u)return"__null__";try{return JSON.stringify(u)}catch{return"__invalid__"}}function kb(u,y){if(!Array.isArray(u)||!Array.isArray(y)||u.length<2||y.length<2)return!1;const x=1e-12;return Math.abs(Number(u[0])-Number(y[0]))<x&&Math.abs(Number(u[1])-Number(y[1]))<x}function Pl(u,y){if(!Array.isArray(u)||u.length<4)return null;const B=kb(u[0],u[u.length-1])?u.slice(0,-1):u.slice();return!Number.isInteger(y)||y<0||y>=B.length||B.length<=3||(B.splice(y,1),B.length<3)?null:[...B,[...B[0]]]}function Rl(u,y){if(!Array.isArray(u)||u.length<2||!Number.isInteger(y)||y<0||y>=u.length||u.length<=2)return null;const x=u.slice();return x.splice(y,1),x.length<2?null:x}function wb(u,y){const x=Ct(u);if(!x||!Array.isArray(y))return null;if(x.type==="LineString"){const[B]=y,L=Rl(x.coordinates,B);return L?(x.coordinates=L,x):null}if(x.type==="MultiLineString"){const[B,L]=y,Y=x.coordinates?.[B],ce=Rl(Y,L);return ce?(x.coordinates[B]=ce,x):null}if(x.type==="Polygon"){const[B,L]=y,Y=x.coordinates?.[B],ce=Pl(Y,L);return ce?(x.coordinates[B]=ce,x):null}if(x.type==="MultiPolygon"){const[B,L,Y]=y,ce=x.coordinates?.[B]?.[L],ue=Pl(ce,Y);return ue?(x.coordinates[B][L]=ue,x):null}return null}function xb(u){return u?u.split(".").map(y=>Number(y)).filter(y=>Number.isInteger(y)&&y>=0):[]}function zl(u){return!fe||!u?null:typeof fe.get=="function"?fe.get(u)??null:fe.getAll?.()?.features?.find(x=>String(x?.id??"")===u)??null}function jl(u){const y=u?.properties?.id??u?.id;return y==null||y===""?null:String(y)}function vb(u){if(!K||!u)return null;const y=[[u.x-8,u.y-8],[u.x+8,u.y+8]],B=K.queryRenderedFeatures(y).find(L=>{const Y=String(L?.properties?.meta??"");return Y&&Y!=="feature"?!1:!!jl(L)});return jl(B)}function _b(u,y){if(!fe||!u||!y.length)return;const x=zl(u);if(!x?.geometry)return;const B=wb(x.geometry,y);if(!B)return;const L={...x,id:x.id??u,geometry:B};Je=!0,Te=!0;try{fe.delete(u),fe.add(L)}finally{Te=!1,Je=!1}jt(),Nt()}function Cb(u){if(!K||!fe||i.value||_.isRulerActive.value||p.value!=="edit")return;const y=u?.point;if(!y)return;const x=[[y.x-8,y.y-8],[y.x+8,y.y+8]],L=K.queryRenderedFeatures(x).find(ce=>ce?.properties?.meta==="vertex"&&ce?.properties?.parent&&ce?.properties?.coord_path);if(!L)return;u?.originalEvent?.preventDefault?.(),u?.originalEvent?.stopPropagation?.();const Y=xb(String(L.properties.coord_path));Y.length&&_b(String(L.properties.parent),Y)}function Eb(u){const y=ql(u);if(!y)return null;const[[x,B],[L,Y]]=y;return{lat:(B+Y)/2,lng:(x+L)/2}}function Ul(u){if(!Array.isArray(u)||u.length<3)return 0;const y=(B,L)=>{const Y=B*2003750834e-2/180,ce=Math.log(Math.tan((90+L)*Math.PI/360))/(Math.PI/180);return[Y,ce*2003750834e-2/180]};let x=0;for(let B=0;B<u.length-1;B+=1){const[L,Y]=y(Number(u[B][0]),Number(u[B][1])),[ce,ue]=y(Number(u[B+1][0]),Number(u[B+1][1]));x+=L*ue-ce*Y}return Math.abs(x/2)/1e6}function Bb(u){if(!u?.type||!u?.coordinates)return null;if(u.type==="Polygon"){const y=u.coordinates?.[0];return Array.isArray(y)?Ul(y):null}return u.type==="MultiPolygon"?u.coordinates.reduce((y,x)=>{const B=x?.[0];return Array.isArray(B)?y+Ul(B):y},0):null}function Go(u){if(!u){f.value=null;return}const y=Eb(u);if(!y){f.value=null;return}f.value={type:String(u.type??"Feature"),center:y,areaKm2:Bb(u)}}function Yo(u){if(!u){const B=tt[tt.length-1],L=Ct(B?.geometry??null);At=L,Go(L);return}const y=tt.find(B=>String(B?.id??"")===String(u))??null,x=Ct(y?.geometry??null);At=x,Go(x)}function Xo(u){m.value=(u??[]).map((y,x)=>{const B=String(y?.id??`feature-${x+1}`),L=Zo(String(y?.geometry?.type??"Feature"));return{id:B,label:`${L} ${x+1}`}})}function Zo(u){switch(String(u)){case"Point":return"Точка";case"MultiPoint":return"Мультиточка";case"LineString":return"Лінія";case"MultiLineString":return"Мультилінія";case"Polygon":return"Полігон";case"MultiPolygon":return"Мультиполігон";case"GeometryCollection":return"Колекція геометрій";default:return String(u||"Невідомо")}}function Hl(u,y){if(!Array.isArray(u)||!Array.isArray(y)||u.length!==2||y.length!==2)return!1;const x=1e-9;return Math.abs(Number(u[0])-Number(y[0]))<x&&Math.abs(Number(u[1])-Number(y[1]))<x}function ql(u){if(!u)return null;let y=1/0,x=1/0,B=-1/0,L=-1/0;const Y=ce=>{if(Array.isArray(ce)){if(ce.length>=2&&Number.isFinite(ce[0])&&Number.isFinite(ce[1])){const ue=Number(ce[0]),Ee=Number(ce[1]);y=Math.min(y,ue),x=Math.min(x,Ee),B=Math.max(B,ue),L=Math.max(L,Ee);return}ce.forEach(Y)}};return Y(u.coordinates),!Number.isFinite(y)||!Number.isFinite(x)?null:[[y,x],[B,L]]}function Wl(u){if(!K||!u)return;const y=ql(u);if(!y)return;const[[x,B],[L,Y]]=y;if(x===L&&B===Y){K.easeTo({center:[x,B],zoom:Math.max(H.value,14)}),Q();return}K.fitBounds(y,{padding:30,duration:250,maxZoom:18}),Q()}function Jo(){if(!fe){g.value=0;return}const u=fe.getAll();g.value=u?.features?.length??0}function xn(){if(!fe)return null;const y=fe.getAll?.()?.features??[],x=Y=>!!Y&&y.some(ce=>String(ce?.id??"")===String(Y??"")),B=fe.getSelectedIds?.();if(Array.isArray(B)&&B.length>0){const Y=B[0];return Y!=null?String(Y):null}if(x(We))return String(We);if(!y.length)return null;const L=c.value?y[y.length-1]:y[0];return L?.id!==void 0&&L?.id!==null?String(L.id):null}function jt(){if(!fe)return;const u=fe.getAll();if(g.value=u?.features?.length??0,!u?.features?.length){tt=[],m.value=[],At=null,We=null,f.value=null,Te||(wt="__null__",r("update:modelValue",null));return}const y=(u.features??[]).map(Ko).filter(Boolean);if(tt=y,Xo(y),We=xn(),Yo(We),!Te){const x=Il(y);wt=Ol(x),r("update:modelValue",x)}}function oo(){if(!fe)return;(fe.getAll()?.features||[]).forEach(y=>fe.delete(y.id)),m.value=[],Jo()}function ro(u){if(!fe)return;const y=no(u),x=c.value?y:y.slice(0,1);Te=!0,oo(),x.forEach(Y=>{try{fe.add(Y)}catch{}}),Te=!1,tt=(fe.getAll?.()?.features??x).map(Ko).filter(Boolean),Xo(tt),We=null;const L=Ct(tt[tt.length-1]?.geometry??null);At=Ct(L),Jo(),Go(L),L&&(Wl(L),i.value||Nt())}function Vb(){fe&&(Te=!0,oo(),tt.forEach(u=>{try{fe.add(u)}catch{}}),Te=!1,Xo(tt),Jo(),Yo(We))}function nn(){if(fe){try{fe.changeMode("simple_select",{featureIds:[]})}catch{}p.value=""}}function lo(u){if(i.value||!fe)return;_.isRulerActive.value&&_.closeRuler(),W=!0,nn(),p.value=u;const y=u==="marker"?"draw_point":u==="polyline"?"draw_line_string":u==="rectangle"?"draw_rectangle":"draw_polygon";c.value||(Te=!0,oo(),Te=!1);try{fe.changeMode(y)}catch{p.value=""}finally{requestAnimationFrame(()=>{W=!1})}}function Nt(u){if(i.value||!fe||!fe.getAll()?.features?.length)return;const x=u||xn();if(x)try{fe.changeMode("direct_select",{featureId:x}),We=x,Yo(We),p.value="edit"}catch{p.value=""}}function Sb(u){i.value||!fe||!u||Nt(u)}function $b(){if(!(i.value||!fe)){if(c.value){const u=xn();if(u)try{en=!0,fe.delete(u),en=!1,jt();const y=xn();y?Nt(y):nn();return}catch{en=!1}}nn(),oo(),tt=[],m.value=[],We=null,wt="__null__",f.value=null,r("update:modelValue",null)}}function Ab(){i.value||!At||Wl(At)}function Nb(u){if(!K||!$t)return;const y=[u[1],u[0]];re||(re=new $t.Marker({color:"#2563eb"})),re.setLngLat(y).addTo(K),K.easeTo({center:y,zoom:13,duration:250})}function Mb(){i.value||(ke.value=!ke.value)}function Kl(u){if(!ke.value)return;const y=ee.value;y&&!y.contains(u.target)&&(ke.value=!1)}function Fb(){Db()}function Db(){i.value||(ke.value=!1,ne.value={srid:"",encoding:"UTF-8",file:""},Se.value=!0)}function Tb(){Se.value=!1,Ne.value=!1,$e.value=!1}function Lb(u){return u?typeof u=="string"?u:typeof u=="object"&&u&&"file_path"in u?String(u.file_path??""):"":""}function Ib(u){const B=((Array.isArray(u)?u[0]:u)?.features??[]).map(L=>Array.isArray(L)?L[0]:L).filter(Boolean).map(L=>L?.type==="Feature"?L:{type:"Feature",properties:{},geometry:L});return B.length?{type:"FeatureCollection",features:B}:null}async function Ob(){if(i.value||!fe||Ne.value)return;const u=Lb(ne.value.file);if(!u){he.notify({type:"warning",title:"Імпорт геометрії",message:"Оберіть файл для імпорту."});return}Ne.value=!0;try{const y=await fetch("/api/gis-convert",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({srid:ne.value.srid,encoding:ne.value.encoding||"UTF-8",filepath:u,limit:!0})}),x=await y.json().catch(()=>null);if(!y.ok)throw new Error(x?.message||x?.error||`Код помилки: ${y.status}`);const B=Ib(x);if(!B){he.notify({type:"warning",title:"Імпорт геометрії",message:"Файл не містить коректні геодані."});return}ro(B),jt(),Se.value=!1,he.notify({type:"success",title:"Успіх",message:"Геометрію успішно імпортовано."})}catch(y){he.notify({type:"error",title:"Помилка",message:y?.message||"Помилка імпорту файла геометрії"})}finally{Ne.value=!1}}function Pb(){i.value||(Me.value=[],ke.value=!1,ge.value=!0)}function Rb(){ge.value=!1,Me.value=[]}function zb(){if(i.value||!fe)return;const u=tp(ve.value.coordinates??"",ve.value.format||"decimal",ve.value.order||"lat-lon");if(!u.ok){Me.value=u.errors,jb(u.errors);return}Me.value=[],ro({type:"Polygon",coordinates:[u.ring]}),jt(),ge.value=!1,u.wasClosedAutomatically&&he.notify({type:"info",title:"Імпорт координат",message:"Полігон був автоматично замкнений (перша і остання точки різнилися)."})}function jb(u){if(!u.length)return;const y=5;u.slice(0,y).forEach(x=>{const B=x.line>0?`Рядок ${x.line}`:"Загальна помилка";he.notify({type:"warning",title:"Імпорт координат",message:`${B} — ${x.message}`})}),u.length>y&&he.notify({type:"warning",title:"Імпорт координат",message:`Ще помилок: ${u.length-y}`})}function Ub(){if(i.value||!fe)return;const u=fe.getAll(),y=new Blob([JSON.stringify(u,null,2)],{type:"application/json"}),x=URL.createObjectURL(y),B=document.createElement("a");B.href=x,B.download="data.geojson",B.click(),URL.revokeObjectURL(x)}e.onMounted(async()=>{if(window.addEventListener("click",Kl,!0),!h.value)return;const u=await to();$t=u.maplibregl,Rt=u.MapboxDraw;const y=Pe();y&&(K=new $t.Map({container:h.value,style:Qt(y),center:[R.value[0],R.value[1]],zoom:H.value,attributionControl:!1}),k.value=K,K.addControl(new $t.NavigationControl({showCompass:!0}),"bottom-right"),K.on("error",x=>{const B=x?.error?.message??x?.message??"";_m(B)}),K.on("load",()=>{if(!(!Rt||!K)){if(fe=new Rt({displayControlsDefault:!1,modes:{...Rt.modes,draw_rectangle:pe()},controls:{point:!1,line_string:!1,polygon:!1,trash:!1},styles:Ve}),K.addControl(fe),K.on("click",x=>{if(_.isRulerActive.value){const L=x?.lngLat;if(!L)return;b.value?.addPoint?.({lat:L.lat,lng:L.lng});return}if(!fe||i.value||p.value!=="edit")return;const B=vb(x?.point);!B||B===We||requestAnimationFrame(()=>{!fe||i.value||Nt(B)})}),K.on("draw.create",()=>{if(fe&&!_.isRulerActive.value){if(!c.value){const x=fe.getAll();if(x.features.length>1){const B=x.features[x.features.length-1];Te=!0,x.features.slice(0,-1).forEach(L=>fe.delete(L.id)),Te=!1,B&&(Te=!0,fe.add(B),Te=!1)}}jt(),Nt()}}),K.on("draw.update",x=>{if(Gt||_.isRulerActive.value||Ho())return;const B=Array.isArray(x?.features)?x.features:[],L=x?.action==="move"&&B.length>0&&B.every(Y=>Y?.geometry?.type==="Point");if(x?.action==="move"){if(L){jt();return}if(Gt=!0,Vb(),Gt=!1,p.value==="edit"){const Y=xn(),ce=Y?zl(Y):fe?.getAll?.()?.features?.[0];if(ce?.id)try{fe.changeMode("direct_select",{featureId:ce.id}),We=String(ce.id)}catch{p.value=""}}return}jt()}),K.on("draw.delete",()=>{Je||en||_.isRulerActive.value||p.value==="marker"||p.value==="polyline"||p.value==="polygon"||p.value==="rectangle"||(jt(),fe?.getAll?.()?.features?.length||(We=null),p.value="",nn())}),K.on("draw.selectionchange",x=>{if(!fe||Gt||_.isRulerActive.value||p.value==="marker"||p.value==="polyline"||p.value==="polygon"||p.value==="rectangle")return;const B=x?.features?.[0]?.id!==void 0&&x?.features?.[0]?.id!==null?String(x.features[0].id):null;if(!i.value&&B){if(p.value==="edit"&&We===B)return;requestAnimationFrame(()=>{!fe||i.value||Nt(B)});return}const L=fe.getSelectedIds?.(),Y=Array.isArray(L)&&L.length>0?String(L[0]):null;if(!i.value&&Y){if(p.value==="edit"&&We===Y)return;requestAnimationFrame(()=>{!fe||i.value||Nt(Y)});return}try{fe.changeMode("simple_select",{featureIds:[]})}catch{}}),se.value!==void 0){const x=se.value;se.value=void 0,requestAnimationFrame(()=>{fe&&ro(x)})}wn(),Ll(),Fe.value.forEach(x=>{const B=Ae[x];B&&tn(B)}),_t(),M()}}),K.on("contextmenu",Cb),K.on("moveend",Q),K.on("zoomend",()=>{K&&(H.value=K.getZoom())}))}),e.onUnmounted(()=>{typeof document<"u"&&(document.body.style.overflow=""),typeof window<"u"&&window.removeEventListener("keydown",er),ae&&(clearTimeout(ae),ae=null),_.isRulerActive.value&&_.closeRuler(),window.removeEventListener("click",Kl,!0),Object.values(Ae).forEach(u=>{K&&zt(u)}),Ze(),re?.remove&&re.remove(),re=null,K?.remove&&K.remove(),K=null,fe=null,k.value=null}),e.watch(()=>n.modelValue,u=>{if(!fe){se.value=u;return}if(Ho())return;const y=Il((c.value?no(u):no(u).slice(0,1))||[]),x=Ol(y);if(wt&&x===wt){wt=null;return}wt=null,ro(u)},{deep:!0}),e.watch(()=>U.value,u=>{const y=Array.isArray(u)?u:[],x=[],B=new Set;y.forEach((L,Y)=>{if(!L)return;const ce=Xe(L,Y);x.push(ce),B.add(ce);const ue={...L,id:ce},Ee=Ae[ce],Ie=Ee?.visible??!!ue.visible;Ee&&K&&zt(Ee),Ae[ce]={id:ce,config:ue,visible:Ie,sourceId:`vs-ov-src-${ce}`,layerIds:[],boundsIds:[],handlers:[],renderToken:Ee?.renderToken??0}}),Object.keys(Ae).forEach(L=>{if(B.has(L))return;const Y=Ae[L];Y&&K&&zt(Y),delete Ae[L]}),Fe.value=x,K&&(Fe.value.forEach(L=>{const Y=Ae[L];Y&&tn(Y)}),_t())},{immediate:!0,deep:!0}),e.watch(()=>oe.value,()=>{K&&(wn(),Fe.value.forEach(u=>{const y=Ae[u];y&&tn(y)}),_t())},{deep:!0}),e.watch(()=>D.value,async u=>{if(me.value=[],!u){K&&(wn(),Fe.value.forEach(y=>{const x=Ae[y];x&&tn(x)}),_t());return}try{const y=await fetch(`https://data.gki.com.ua/api-user/atu/${u}`);if(!y?.ok)return;const B=(await y.json())?.geometry?.coordinates;Array.isArray(B)&&B.length&&(me.value=B)}catch(y){console.error("Failed to fetch KATOTTG bounds",y)}finally{if(!K)return;wn(),Fe.value.forEach(y=>{const x=Ae[y];x&&tn(x)}),_t()}},{immediate:!0}),e.watch(()=>j.value,u=>{if(!Array.isArray(u)||u.length!==2)return;const y=[Number(u[0]),Number(u[1])];if(Hl(R.value,y)||(R.value=[...y],!K))return;const x=K.getCenter?.();x&&Hl([x.lng,x.lat],R.value)||K.easeTo({center:[R.value[0],R.value[1]]})},{deep:!0}),e.watch(()=>te.value,u=>{typeof u=="number"&&(H.value=u,K&&K.setZoom(u))}),e.watch(()=>f.value?.center,u=>{u&&A(u.lng,u.lat,K?.getZoom?.())},{deep:!0}),e.watch(i,u=>{u&&nn()}),e.watch(g,u=>{if(u>0){i.value||Nt();return}W||nn()});const Gl=e.computed(()=>m.value.length>0||!!f.value),Qo=e.computed(()=>{const u=m.value,y=u.length>1;return u.length?u.map(x=>({id:x.id,label:y?x.label:f.value?.type?Zo(f.value.type):x.label,interactive:y})):f.value?.type?[{id:"__feature",label:Zo(f.value.type),interactive:!1}]:[]});function Yl(){setTimeout(()=>{K?.resize&&K.resize()},50)}function er(u){u.key==="Escape"&&d.value&&(d.value=!1)}return e.watch(d,u=>{typeof document<"u"&&(document.body.style.overflow=u?"hidden":""),typeof window<"u"&&(u?window.addEventListener("keydown",er):window.removeEventListener("keydown",er)),Yl()}),e.watch(Gl,Yl),(u,y)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body",disabled:!d.value},[e.createElementVNode("div",{class:e.normalizeClass(["vs-map-wrapper w-full",{fullscreen:d.value}])},[e.createElementVNode("div",Cm,[e.createElementVNode("div",{ref_key:"mapContainer",ref:h,class:"vs-map-canvas"},null,512),w.value.search||w.value.import||w.value.export?(e.openBlock(),e.createElementBlock("div",Em,[w.value.search?(e.openBlock(),e.createBlock(xp,{key:0,onGoToCoordinates:Nb})):e.createCommentVNode("",!0),w.value.import||w.value.export?(e.openBlock(),e.createElementBlock("div",Bm,[e.createElementVNode("div",Vm,[w.value.import?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"importMenuRef",ref:ee,class:"relative"},[e.createElementVNode("button",{type:"button",class:"vs-map-action-btn",onClick:Mb,disabled:i.value},[y[10]||(y[10]=e.createTextVNode(" Імпорт ",-1)),e.createVNode(e.unref(X.ChevronDown),{class:e.normalizeClass(["h-3.5 w-3.5 shrink-0 transition-transform",{"rotate-180":ke.value}])},null,8,["class"])],8,Sm),ke.value?(e.openBlock(),e.createElementBlock("div",$m,[w.value.import?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"block w-full text-left px-3 py-2 hover:bg-gray-100 text-gray-900",onClick:Fb}," З файлу ")):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"block w-full text-left px-3 py-2 hover:bg-gray-100 text-gray-900",onClick:Pb}," З координат ")])):e.createCommentVNode("",!0)],512)):e.createCommentVNode("",!0),w.value.export?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"vs-map-action-btn",onClick:Ub,disabled:i.value||g.value===0}," Експорт ",8,Am)):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createVNode(e.unref(he.VsModal),{visible:Se.value,"onUpdate:visible":y[1]||(y[1]=x=>Se.value=x),title:"Імпорт геометрії",size:"lg",teleport:e.unref(s)},{default:e.withCtx(()=>[$e.value||Ne.value?(e.openBlock(),e.createElementBlock("div",Nm,[e.createVNode(e.unref(X.LoaderCircle),{class:"h-4 w-4 shrink-0 animate-spin"}),e.createElementVNode("span",null,e.toDisplayString(Oe.value),1)])):e.createCommentVNode("",!0),e.createVNode(ot,{schema:xe.value,values:ne.value,"onUpdate:values":y[0]||(y[0]=x=>ne.value=x)},null,8,["schema","values"]),e.createElementVNode("div",Mm,[e.createElementVNode("button",{type:"button",class:"px-3 py-2 rounded-md border border-gray-300 text-gray-700 text-sm hover:bg-gray-100",onClick:Tb,disabled:$e.value||Ne.value}," Скасувати ",8,Fm),e.createElementVNode("button",{type:"button",class:"px-3 py-2 rounded-md bg-blue-600 text-white text-sm hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-2",onClick:Ob,disabled:i.value||$e.value||Ne.value||!ne.value.file},[Ne.value?(e.openBlock(),e.createBlock(e.unref(X.LoaderCircle),{key:0,class:"h-4 w-4 animate-spin"})):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(Ne.value?"Обробка...":"Додати"),1)],8,Dm)])]),_:1},8,["visible","teleport"]),e.createVNode(e.unref(he.VsModal),{visible:ge.value,"onUpdate:visible":y[3]||(y[3]=x=>ge.value=x),title:"Імпорт координат полігону",size:"lg",teleport:e.unref(s)},{default:e.withCtx(()=>[e.createVNode(ot,{schema:ze,values:ve.value,"onUpdate:values":y[2]||(y[2]=x=>ve.value=x)},null,8,["values"]),e.createElementVNode("div",Tm,[e.createElementVNode("button",{type:"button",class:"px-3 py-2 rounded-md border border-gray-300 text-gray-700 text-sm hover:bg-gray-100",onClick:Rb}," Скасувати "),e.createElementVNode("button",{type:"button",class:"px-3 py-2 rounded-md bg-blue-600 text-white text-sm hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",onClick:zb,disabled:i.value}," Побудувати ",8,Lm)])]),_:1},8,["visible","teleport"]),e.createElementVNode("div",Im,[e.createElementVNode("div",Om,[pt.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[w.value.point?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["vs-btn",{"vs-active":p.value==="marker"}]),title:"Точка",onClick:y[4]||(y[4]=x=>lo("marker")),disabled:i.value},[e.createVNode(e.unref(X.MapPin),{class:"vs-btn-icon"})],10,Pm)):e.createCommentVNode("",!0),w.value.line?(e.openBlock(),e.createElementBlock("button",{key:1,class:e.normalizeClass(["vs-btn",{"vs-active":p.value==="polyline"}]),title:"Лінія",onClick:y[5]||(y[5]=x=>lo("polyline")),disabled:i.value},[e.createVNode(vu,{class:"vs-btn-icon"})],10,Rm)):e.createCommentVNode("",!0),w.value.polygon?(e.openBlock(),e.createElementBlock("button",{key:2,class:e.normalizeClass(["vs-btn",{"vs-active":p.value==="polygon"}]),title:"Полігон",onClick:y[6]||(y[6]=x=>lo("polygon")),disabled:i.value},[e.createVNode(Bu,{class:"vs-btn-icon"})],10,zm)):e.createCommentVNode("",!0),w.value.rectangle?(e.openBlock(),e.createElementBlock("button",{key:3,class:e.normalizeClass(["vs-btn",{"vs-active":p.value==="rectangle"}]),title:"Прямокутник",onClick:y[7]||(y[7]=x=>lo("rectangle")),disabled:i.value},[e.createVNode(Au,{class:"vs-btn-icon"})],10,jm)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),pt.value?(e.openBlock(),e.createElementBlock("div",Um)):e.createCommentVNode("",!0),w.value.ruler?(e.openBlock(),e.createElementBlock("button",{key:2,class:e.normalizeClass(["vs-btn",{"vs-active":e.unref(_).isRulerActive.value}]),title:"Лінійка",onClick:C},[e.createVNode(e.unref(X.Ruler),{class:"vs-btn-icon"})],2)):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"vs-btn",onClick:y[8]||(y[8]=x=>d.value=!d.value),title:d.value?"Згорнути":"На весь екран"},[d.value?(e.openBlock(),e.createBlock(e.unref(X.Minimize),{key:0,class:"vs-btn-icon"})):(e.openBlock(),e.createBlock(e.unref(X.Maximize),{key:1,class:"vs-btn-icon"}))],8,Hm)])]),w.value.ruler&&e.unref(_).isRulerActive.value?(e.openBlock(),e.createBlock(fm,{key:1,ref_key:"rulerPanelRefEl",ref:b,onClose:y[9]||(y[9]=x=>e.unref(_).closeRuler()),onTabChange:e.unref(_).onRulerTabChange,onPointsChange:e.unref(_).onRulerPointsChange,onShapeClosedChange:e.unref(_).onRulerShapeClosedChange},null,8,["onTabChange","onPointsChange","onShapeClosedChange"])):e.createCommentVNode("",!0),w.value.ruler&&e.unref(_).isRulerActive.value&&e.unref(_).hasRulerPoints.value?(e.openBlock(),e.createBlock(hm,{key:2,map:k.value,points:e.unref(_).rulerPoints.value,"is-shape-closed":e.unref(_).rulerShapeClosed.value,"label-mode":e.unref(_).rulerActiveTab.value},null,8,["map","points","is-shape-closed","label-mode"])):e.createCommentVNode("",!0),J.value.length?(e.openBlock(),e.createElementBlock("div",{key:3,class:"absolute z-[1500] pointer-events-none",style:e.normalizeStyle(ie.value)},[e.createElementVNode("div",qm,[e.createElementVNode("dl",Wm,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(J.value,x=>(e.openBlock(),e.createElementBlock("div",{key:`${x.key}-${x.value}`,class:"flex justify-between gap-2"},[e.createElementVNode("dt",Km,e.toDisplayString(x.key),1),e.createElementVNode("dd",Gm,e.toDisplayString(x.value),1)]))),128))])])],4)):e.createCommentVNode("",!0),e.createElementVNode("div",Ym,[e.createVNode(Qu,{compact:"",basemaps:e.unref(le),"active-base-key":Le.value,"tile-overlays":e.unref(je),"active-tile-overlay-keys":He.value,"vector-overlays":qe.value,"preview-tile":Z.value,disabled:i.value,onOnLayerChange:bb,onOnOverlayToggle:yb,onOnVectorOverlayToggle:hb},null,8,["basemaps","active-base-key","tile-overlays","active-tile-overlay-keys","vector-overlays","preview-tile","disabled"])])]),Gl.value?(e.openBlock(),e.createElementBlock("div",Xm,[e.createElementVNode("div",Zm,[e.createElementVNode("div",Jm,[y[11]||(y[11]=e.createElementVNode("span",{class:"vs-map-status__label"},"Тип:",-1)),e.createElementVNode("div",Qm,[Qo.value.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(Qo.value,(x,B)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:x.id},[x.interactive?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["vs-map-status__chip",{"vs-map-status__chip--active":x.id===e.unref(We)}]),onClick:L=>Sb(x.id),disabled:i.value},e.toDisplayString(x.label),11,ef)):(e.openBlock(),e.createElementBlock("span",tf,e.toDisplayString(x.label),1)),B<Qo.value.length-1?(e.openBlock(),e.createElementBlock("span",nf,", ")):e.createCommentVNode("",!0)],64))),128)):(e.openBlock(),e.createElementBlock("span",of,"—"))])]),e.createElementVNode("div",rf,[e.createElementVNode("span",lf,[y[12]||(y[12]=e.createElementVNode("span",{class:"vs-map-status__label"},"Центр:",-1)),f.value?(e.openBlock(),e.createElementBlock("span",af,e.toDisplayString(f.value.center.lng.toFixed(5))+", "+e.toDisplayString(f.value.center.lat.toFixed(5)),1)):(e.openBlock(),e.createElementBlock("span",sf,"—"))]),f.value&&f.value.areaKm2!==null?(e.openBlock(),e.createElementBlock("span",cf,[y[13]||(y[13]=e.createElementVNode("span",{class:"vs-map-status__label"},"Площа:",-1)),e.createElementVNode("span",df,e.toDisplayString(f.value.areaKm2.toFixed(1))+" km²",1)])):e.createCommentVNode("",!0),e.createElementVNode("div",uf,[e.createElementVNode("button",{type:"button",class:"vs-status-btn vs-status-btn--zoom",title:"Масштаб до об'єкта",onClick:Ab,disabled:i.value},[e.createVNode(e.unref(X.ZoomIn),{class:"vs-status-btn__icon"})],8,pf),e.createElementVNode("button",{type:"button",class:"vs-status-btn vs-status-btn--delete",title:"Видалити об'єкт",onClick:$b,disabled:i.value},[e.createVNode(e.unref(X.Trash2),{class:"vs-status-btn__icon"})],8,mf)])])])])):e.createCommentVNode("",!0)],2)],8,["disabled"]))}}),[["__scopeId","data-v-780ba2d7"]]),wf=["data-focus"],xf={class:"flex items-center"},vf={class:"overflow-hidden text-ellipsis whitespace-nowrap rounded-sm text-[#333] text-[85%] px-0.5 py-[3px] pl-1.5 box-border"},_f=["onClick","aria-label"],Cf={key:0,class:"absolute text-gray-500 truncate pl-2"},Ef={class:"flex-1 min-w-[2px]"},Bf=["placeholder"],Vf={class:"flex items-center shrink-0"},Sf=["disabled"],Ur=e.defineComponent({__name:"vs-input-tag",props:e.mergeModels({unique:{type:Boolean,default:!0},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:"Введіть тег"},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:e.mergeModels(["update:modelValue"],["update:modelValue"]),setup(o,{emit:t}){const n=o,r=t;Qe(n.style);const a=e.ref(null),l=e.ref(null),s=e.ref(null),c=e.ref(!1),i=e.ref(""),d=e.useModel(o,"modelValue"),h=e.computed(()=>n.placeholder||"Add tag…"),g=e.computed(()=>d.value?.length===0&&i.value===""),p=e.computed(()=>!n.disabled&&d.value?.length>0),f=e.computed(()=>n.disabled),m=async()=>{f.value||await e.nextTick(()=>s.value?.focus())},k=G=>{const I=G.trim();I!==""&&(!d.value||!Array.isArray(d.value)?d.value=[I]:n.unique?d.value.includes(I)||(d.value=[...d.value,I]):d.value=[...d.value,I],i.value="")},b=()=>{const G=i.value;G.trim()!==""&&k(G),i.value=""},_=G=>{const I=d.value.slice();I.splice(G,1),r("update:modelValue",I)},C=()=>{r("update:modelValue",[])},N=()=>{f.value||(c.value=!0)},$=()=>{c.value=!1,!f.value&&b()},q=G=>{const{key:I}=G;I==="Enter"?(G.preventDefault(),b()):I==="Backspace"&&i.value===""&&d.value.length>0&&_(d.value.length-1)};return(G,I)=>(e.openBlock(),e.createElementBlock("div",{class:"flex gap-1 w-full",ref_key:"root",ref:a,onClick:I[1]||(I[1]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",{class:e.normalizeClass(["relative w-full font-sans",n.customClass]),role:"group","aria-label":"Tag input"},[e.createElementVNode("div",{class:e.normalizeClass(["flex min-h-[38px] items-center justify-between rounded border transition-colors bg-white","border-gray-300 hover:border-gray-400",c.value?"border-blue-500 ring-1 ring-blue-500":"",f.value?"bg-gray-100 text-gray-400 cursor-not-allowed hover:border-gray-300":""]),"data-focus":c.value?"true":"false",onClick:m},[e.createElementVNode("div",{class:"flex flex-1 flex-wrap items-center gap-1 py-0.5 pl-2 pr-0 overflow-hidden",ref_key:"chipsRef",ref:l},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,(E,V)=>(e.openBlock(),e.createElementBlock("div",{key:V,class:"flex min-w-0 bg-[#e6e6e6] rounded-sm m-0.5 box-border"},[e.createElementVNode("div",xf,[e.createElementVNode("div",vf,e.toDisplayString(E),1)]),e.createElementVNode("div",{role:"button",class:"flex items-center rounded-sm px-1 box-border hover:bg-[#ffbdad] hover:text-[#de350b]",onClick:e.withModifiers(v=>_(V),["stop"]),"aria-label":`Remove ${E}`},[e.createVNode(e.unref(X.X),{"aria-hidden":"true",focusable:"false",class:"inline-block h-4 w-4"})],8,_f)]))),128)),g.value?(e.openBlock(),e.createElementBlock("div",Cf,e.toDisplayString(h.value),1)):e.createCommentVNode("",!0),e.createElementVNode("div",Ef,[f.value?e.createCommentVNode("",!0):e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,ref_key:"inputRef",ref:s,class:"pl-2 w-full bg-transparent outline-none border-0 m-0 p-0 text-gray-900",autocapitalize:"none",autocomplete:"off",autocorrect:"off",spellcheck:"false",type:"text",tabindex:"0","aria-label":"Add tag","onUpdate:modelValue":I[0]||(I[0]=E=>i.value=E),onFocus:N,onBlur:$,onKeydown:q,placeholder:d.value&&d.value.length?"":void 0},null,40,Bf)),[[e.vModelText,i.value]])])],512),e.createElementVNode("div",Vf,[p.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"px-2 text-gray-400 hover:text-gray-500 transition-colors disabled:opacity-50","aria-label":"Clear all tags",disabled:f.value,onClick:e.withModifiers(C,["stop"])},[e.createVNode(e.unref(X.X),{class:"h-4 w-4"})],8,Sf)):e.createCommentVNode("",!0)])],10,wf)],2)],512))}}),$f={class:"relative flex gap-1 bg-white w-full"},Af=["disabled","placeholder"],Hr=Ce(e.defineComponent({__name:"vs-input-slug",props:e.mergeModels({disabled:{type:Boolean},placeholder:{},parent:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=e.inject("values"),n=o,r=e.useModel(o,"modelValue");function a(s){const c={а:"a",б:"b",в:"v",г:"g",д:"d",е:"e",ё:"e",ж:"zh",з:"z",и:"i",й:"y",к:"k",л:"l",м:"m",н:"n",о:"o",п:"p",р:"r",с:"s",т:"t",у:"u",ф:"f",х:"kh",ц:"ts",ч:"ch",ш:"sh",щ:"shch",ы:"y",э:"e",ю:"yu",я:"ya",ь:"",ъ:"",є:"ye",і:"i",ї:"yi",ґ:"g"};return s.toLowerCase().split("").map(i=>c[i]||i).join("").replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}const l=()=>{const s=t?.value?.[n.parent||""]?.toString(),c=a(s);r.value=c.toString()};return(s,c)=>(e.openBlock(),e.createElementBlock("div",$f,[e.withDirectives(e.createElementVNode("input",{ref:"vsText",disabled:s.disabled,placeholder:s.placeholder,"onUpdate:modelValue":c[0]||(c[0]=i=>r.value=i),class:"block w-full px-3 py-2 text-sm border border-solid rounded-lg placeholder:text-nowrap border-stone-200 text-stone-800 placeholder:text-stone-400 focus:outline focus:z-10 focus:border-blue-500 focus:ring-blue-500 focus:outline-blue-500"},null,8,Af),[[e.vModelText,r.value]]),e.createElementVNode("button",{class:"px-2 bg-gray-100 border rounded-lg hover:bg-gray-200",onClick:l}," Gen ")]))}}),[["__scopeId","data-v-b0eba370"]]),Nf={class:"relative flex gap-1 bg-white w-full"},Mf=["disabled","placeholder"],Ff=["disabled"],Df={key:0},Tf={key:1},qr=Ce(e.defineComponent({__name:"vs-input-codegen",props:e.mergeModels({table:{},code:{},init:{type:Boolean},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.ref(!1),a=e.computed(()=>t.init!==!1),l=e.computed(()=>!!t.table&&!!t.code),s=()=>{if(!l.value)return"";const d=encodeURIComponent(String(t.table)),h=encodeURIComponent(String(t.code));return`/api/code-gen/${d}/${h}`},c=async()=>{if(!l.value||r.value)return;const d=s();if(d){r.value=!0;try{const g=await(await fetch(d)).text();n.value=g}finally{r.value=!1}}},i=()=>{a.value&&(n.value||c())};return e.onMounted(()=>{i()}),e.watch(()=>[t.table,t.code,t.init],()=>{i()}),(d,h)=>(e.openBlock(),e.createElementBlock("div",Nf,[e.withDirectives(e.createElementVNode("input",{disabled:d.disabled,placeholder:d.placeholder,"onUpdate:modelValue":h[0]||(h[0]=g=>n.value=g),class:"block w-full px-3 py-2 text-sm border border-solid rounded-lg placeholder:text-nowrap border-stone-200 text-stone-800 placeholder:text-stone-400 focus:outline focus:z-10 focus:border-blue-500 focus:ring-blue-500 focus:outline-blue-500"},null,8,Mf),[[e.vModelText,n.value]]),e.createElementVNode("button",{class:"px-2 bg-gray-100 border rounded-lg hover:bg-gray-200 disabled:opacity-50 disabled:cursor-not-allowed",disabled:r.value||d.disabled||!l.value,onClick:c},[r.value?(e.openBlock(),e.createElementBlock("span",Tf,"...")):(e.openBlock(),e.createElementBlock("span",Df,"Gen"))],8,Ff)]))}}),[["__scopeId","data-v-6ee5237d"]]),Lf={class:"w-full"},If={ref:"sortableContainer",class:"flex flex-col gap-1"},Of=["onDragstart","onDrop"],Pf={class:"cursor-move",type:"button"},Rf={class:"w-1/3"},zf={class:"w-2/3"},jf=["onClick"],Uf={key:0,class:"text-[14px] text-gray-700"},Hf={class:"mt-2 w-full flex items-center"},qf=["disabled"],Wr=Ce(e.defineComponent({__name:"vs-input-key-value",props:{parent:{},ignore:{},addButtonText:{},modelValue:{}},emits:["update:modelValue"],setup(o,{emit:t}){const n=b=>`${b}-${Math.random().toString(36).substring(2,15)}`,r=e.inject("values"),a=o,l=t,s=a.addButtonText??"Додати",c=a.ignore??[],i=e.ref([]),d=e.ref(null);(()=>{const b=a.parent&&r?.value?.[a.parent]||a.modelValue||{};i.value=Object.entries(b).filter(([_])=>!c.includes(_)).map(([_,C])=>({id:n("key-value-"),key:_,value:C}))})();function g(b){d.value=b}function p(b){if(d.value===null||d.value===b)return;const _=i.value.splice(d.value,1)[0];i.value.splice(b,0,_),d.value=null}const f=e.computed(()=>i.value.some(b=>b.key&&!b.value||!b.key&&b.value)),m=()=>{i.value.push({id:n("key-value-"),key:"",value:""})},k=b=>{i.value=i.value.filter(_=>_.id!==b)};return e.watch(i,b=>{const _={};b.forEach(N=>{N.key&&N.value!==void 0&&(_[N.key]=N.value)});const C={};c.length&&c.forEach(N=>{C[N]=a.parent?r?.value?.[a.parent]?.[N]:void 0}),r?.value&&a.parent&&(r.value[a.parent]={...C,..._}),l("update:modelValue",_)},{deep:!0}),(b,_)=>(e.openBlock(),e.createElementBlock("div",Lf,[e.createElementVNode("div",If,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(C,N)=>(e.openBlock(),e.createElementBlock("div",{key:C.id,class:e.normalizeClass(["flex items-center gap-2 w-full",{"opacity-50":d.value===N}]),draggable:"true",onDragstart:$=>g(N),onDragover:_[0]||(_[0]=e.withModifiers(()=>{},["prevent"])),onDrop:$=>p(N)},[e.createElementVNode("button",Pf,[e.createVNode(e.unref(X.GripVertical),{class:"h-4 w-4"})]),e.createElementVNode("div",Rf,[e.createVNode(Yt,{modelValue:C.key,"onUpdate:modelValue":$=>C.key=$,placeholder:"Ключ"},null,8,["modelValue","onUpdate:modelValue"])]),e.createElementVNode("div",zf,[e.createVNode(Yt,{modelValue:C.value,"onUpdate:modelValue":$=>C.value=$,placeholder:"Значення"},null,8,["modelValue","onUpdate:modelValue"])]),e.createElementVNode("button",{onClick:$=>k(C.id),class:"shrink-0 w-[30px] text-gray-600 h-[30px] rounded-full flex items-center justify-center bg-gray-100 hover:bg-gray-200"},[e.createVNode(e.unref(X.X),{class:"h-4 w-4"})],8,jf)],42,Of))),128))],512),i.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",Uf," Дані для відображення відсутні ")),e.createElementVNode("div",Hf,[e.createElementVNode("button",{type:"button",onClick:m,disabled:f.value,class:"py-1.5 px-2 flex items-center gap-x-1 text-xs font-medium rounded-full border border-dashed border-gray-200 bg-white text-gray-800 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"},[e.createVNode(e.unref(X.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(e.unref(s)),1)],8,qf)])]))}}),[["__scopeId","data-v-d8c3f9d6"]]),Wf={class:"w-full"},Kf={ref:"sortableContainer",class:"flex flex-col gap-1"},Gf=["onDragstart","onDrop"],Yf=["disabled"],Xf={class:"flex-1"},Zf=["onClick","disabled"],Jf={key:0,class:"text-[14px] text-gray-700"},Qf={class:"mt-2 w-full flex items-center"},eh=["disabled"],Kr=Ce(e.defineComponent({__name:"vs-input-text-array",props:e.mergeModels({addButtonText:{default:"Додати"},inputType:{default:"text"},placeholder:{default:"Значення"},mask:{default:""},disabled:{type:Boolean,default:!1}},{modelValue:{default:[]},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.ref([]),a=e.ref(null),l=e.computed(()=>!!t.disabled),s=e.computed(()=>t.placeholder??""),c=e.computed(()=>t.addButtonText??"Додати");let i=!1;const d=b=>`${b}-${Math.random().toString(36).substring(2,15)}`,h=b=>{const _=b??n.value??[];r.value=_.map((C,N)=>({id:r.value[N]?.id??d("text-array"),value:C??""}))};h(),e.watch(()=>n.value,b=>{if(i){i=!1;return}h(b||[])},{deep:!0}),e.watch(r,b=>{i=!0,n.value=b.map(_=>_.value).filter(_=>_!=null&&_!=="")},{deep:!0});const g=e.computed(()=>l.value||r.value.some(b=>!b.value));function p(){g.value||(r.value=[...r.value,{id:d("text-array"),value:""}])}function f(b){l.value||(r.value=r.value.filter(_=>_.id!==b))}function m(b){l.value||(a.value=b)}function k(b){if(l.value||a.value===null||a.value===b)return;const _=[...r.value],[C]=_.splice(a.value,1);_.splice(b,0,C),r.value=_,a.value=null}return(b,_)=>(e.openBlock(),e.createElementBlock("div",Wf,[e.createElementVNode("div",Kf,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(C,N)=>(e.openBlock(),e.createElementBlock("div",{key:C.id,class:e.normalizeClass(["flex items-center gap-2 w-full",{"opacity-50":a.value===N}]),draggable:"true",onDragstart:$=>m(N),onDragover:_[0]||(_[0]=e.withModifiers(()=>{},["prevent"])),onDrop:$=>k(N)},[e.createElementVNode("button",{class:"cursor-move",type:"button",disabled:l.value},[e.createVNode(e.unref(X.GripVertical),{class:"h-4 w-4"})],8,Yf),e.createElementVNode("div",Xf,[b.inputType==="text"?(e.openBlock(),e.createBlock(Yt,{key:0,modelValue:C.value,"onUpdate:modelValue":$=>C.value=$,disabled:l.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):e.createCommentVNode("",!0),b.inputType==="tel"?(e.openBlock(),e.createBlock(mo,{key:1,modelValue:C.value,"onUpdate:modelValue":$=>C.value=$,disabled:l.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):e.createCommentVNode("",!0),b.inputType==="email"?(e.openBlock(),e.createBlock(po,{key:2,modelValue:C.value,"onUpdate:modelValue":$=>C.value=$,disabled:l.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):e.createCommentVNode("",!0),b.inputType==="mask"?(e.openBlock(),e.createBlock(En,{key:3,modelValue:C.value,"onUpdate:modelValue":$=>C.value=$,mask:b.mask,disabled:l.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","mask","disabled","placeholder"])):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",onClick:$=>f(C.id),disabled:l.value,class:"shrink-0 w-[30px] text-gray-600 h-[30px] rounded-full flex items-center justify-center bg-gray-100 hover:bg-gray-200 disabled:opacity-50"},[e.createVNode(e.unref(X.X),{class:"h-4 w-4"})],8,Zf)],42,Gf))),128))],512),r.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",Jf," Дані для відображення відсутні ")),e.createElementVNode("div",Qf,[e.createElementVNode("button",{type:"button",onClick:p,disabled:g.value,class:"py-1.5 px-2 flex items-center gap-x-1 text-xs font-medium rounded-full border border-dashed border-gray-200 bg-white text-gray-800 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"},[e.createVNode(e.unref(X.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(c.value),1)],8,eh)])]))}}),[["__scopeId","data-v-2c229b1f"]]),th={class:"flex items-center gap-2 w-full"},nh=["disabled"],oh=["disabled"],Gr=e.defineComponent({__name:"vs-input-color",props:{style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o,{inputClass:r}=Qe(n.style),a=t,l=e.computed({get:()=>n.modelValue||"#000000",set:c=>a("update:modelValue",c)}),s=e.computed(()=>!!n.disabled);return(c,i)=>(e.openBlock(),e.createElementBlock("div",th,[e.withDirectives(e.createElementVNode("input",{type:"color","onUpdate:modelValue":i[0]||(i[0]=d=>l.value=d),disabled:s.value,ref:"color",class:e.normalizeClass(["py-1.5 px-1 block w-full bg-white cursor-pointer max-w-[50px]",[c.modelValue?"":"text-opacity-50",e.unref(r)].join(" ")]),style:{border:"1px solid #CFD9E0"}},null,10,nh),[[e.vModelText,l.value]]),e.withDirectives(e.createElementVNode("input",{class:"text-sm text-gray-600 border border-solid border-stone-200 rounded-md p-2","onUpdate:modelValue":i[1]||(i[1]=d=>l.value=d),disabled:s.value},null,8,oh),[[e.vModelText,l.value]])]))}}),rh={class:"flex items-center gap-2 w-full"},lh=["min","max","step","disabled"],ah=["value","min","max","step","disabled"],Yr=e.defineComponent({__name:"vs-input-range",props:{style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{},min:{default:0},max:{default:100},step:{default:1}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o,{inputClass:r}=Qe(n.style),a=t,l=h=>{const g=Number(h),p=Number(n.min),f=Number(n.max);return Number.isNaN(g)?p:Math.min(f,Math.max(p,g))},s=e.computed({get:()=>l(n.modelValue??n.min),set:h=>a("update:modelValue",l(h))}),c=h=>{const g=h.target,p=l(g.value);g.value=String(p),a("update:modelValue",p)},i=h=>{Number(n.min)>=0&&h.key==="-"&&h.preventDefault()},d=e.computed(()=>!!n.disabled);return(h,g)=>(e.openBlock(),e.createElementBlock("div",rh,[e.withDirectives(e.createElementVNode("input",{type:"range","onUpdate:modelValue":g[0]||(g[0]=p=>s.value=p),min:h.min,max:h.max,step:h.step,disabled:d.value,ref:"range",class:e.normalizeClass(["w-full cursor-pointer accent-blue-500",[h.modelValue?"":"text-opacity-50",e.unref(r)].join(" ")])},null,10,lh),[[e.vModelText,s.value]]),e.createElementVNode("input",{class:"text-sm text-gray-600 border border-solid border-stone-200 rounded-md p-2 max-w-[100px]",type:"number",value:s.value,min:h.min,max:h.max,step:h.step,onInput:c,onKeydown:i,disabled:d.value},null,40,ah)]))}}),sh=["placeholder","disabled","name"],ih=["type","value","onInput","placeholder","disabled"],ch=["onClick"],Xr=e.defineComponent({__name:"vs-input-array",props:e.mergeModels({count:{default:1},limit:{default:1},mask:{default:""},unmask:{type:Boolean,default:!1},inputType:{default:"text"},isAdded:{type:Boolean,default:!1},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.ref(t.count),r=e.computed(()=>t.limit),{inputClass:a}=Qe(t.style),l=e.useModel(o,"modelValue"),s=e.computed(()=>!!t.disabled),c=e.computed(()=>t.placeholder??"");e.watchEffect(()=>{const k=l.value?.length??0;k<n.value&&(l.value=[...l.value??[],...Array(n.value-k)])});const i=e.ref({}),d=e.ref({});function h(k,b){k&&(i.value[b]=k)}async function g(k,b){if(!k||t.inputType!=="mask")return;const{default:_}=await Promise.resolve().then(()=>Qn);d.value[b]&&d.value[b].destroy(),d.value[b]=_(k,{mask:t.mask||"",definitions:{9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},lazy:!1}),d.value[b].on("accept",()=>{const C=[...l.value||[]];C[b]=t.unmask?d.value[b].unmaskedValue:d.value[b].value,l.value=C}),d.value[b].on("complete",()=>{const C=[...l.value||[]];C[b]=t.unmask?d.value[b].unmaskedValue:d.value[b].value,l.value=C}),l.value?.[b]&&(d.value[b].value=l.value[b])}function p(k,b){if(s.value)return;const _=k.target.value??null,C=[...l.value];C[b]=t.inputType==="text"?_:Number(_),l.value=C}function f(){n.value+=1;const k=t.inputType==="text"||t.inputType==="mask"?null:0;l.value=[...l.value,k],t.inputType==="mask"&&setTimeout(()=>{const b=n.value-1;i.value[b]&&g(i.value[b],b)},0)}function m(k){if(n.value>1){d.value[k]&&(d.value[k].destroy(),delete d.value[k]),n.value-=1,l.value=l.value.filter((_,C)=>C!==k);const b={};Object.keys(d.value).forEach(_=>{const C=parseInt(_,10);C>k?b[C-1]=d.value[C]:C<k&&(b[C]=d.value[C])}),d.value=b}}return e.onMounted(()=>{if(t.inputType==="mask")for(let k=0;k<n.value;k+=1)i.value[k]&&g(i.value[k],k)}),e.onBeforeUnmount(()=>{Object.values(d.value).forEach(k=>{k&&k.destroy()})}),e.watch(()=>t.mask,k=>{t.inputType==="mask"&&Object.values(d.value).forEach(b=>{b&&b.updateOptions({mask:k,definitions:{9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/}})})}),e.watch(l,k=>{t.inputType==="mask"&&k&&k.forEach((b,_)=>{d.value[_]&&d.value[_].value!==b&&(d.value[_].value=b||"")})},{deep:!0}),(k,b)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["grid gap-2",`grid-cols-${r.value}`])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,_=>(e.openBlock(),e.createElementBlock("div",{key:_,class:"flex items-center gap-2 w-full"},[k.inputType==="mask"?(e.openBlock(),e.createElementBlock("input",{key:0,type:"text",ref_for:!0,ref:C=>h(C,_-1),placeholder:k.placeholder,disabled:k.disabled,name:`${k.name}[${_-1}]`,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(a),{"!border-red-600":k.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,sh)):(e.openBlock(),e.createElementBlock("input",{key:1,type:k.inputType,value:l.value?.[_-1],onInput:C=>p(C,_-1),placeholder:c.value,disabled:s.value,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(a),{"!border-red-600":k.error}]]),style:{border:"1px solid #CFD9E0"}},null,42,ih)),!k.disabled&&_===n.value&&k.isAdded?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",onClick:e.withModifiers(f,["stop"]),class:"cursor-pointer shrink-0 w-[38px] text-green-600 h-[38px] rounded-md flex items-center justify-center border border-stone-200 hover:bg-stone-100"},[e.createVNode(e.unref(X.Plus),{class:"h-4 w-4"})])):e.createCommentVNode("",!0),!k.disabled&&n.value>1&&k.isAdded?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",onClick:e.withModifiers(C=>m(_-1),["stop"]),class:"cursor-pointer shrink-0 w-[38px] text-red-600 h-[38px] rounded-md flex items-center justify-center border border-stone-200 hover:bg-stone-100"},[e.createVNode(e.unref(X.X),{class:"h-4 w-4"})],8,ch)):e.createCommentVNode("",!0)]))),128))],2))}}),dh={class:"flex gap-1 w-full"},uh=["aria-expanded","data-focus"],ph=["placeholder","disabled","readonly"],mh={class:"max-h-full"},fh=["onClick","disabled"],hh={key:0,class:"px-3 py-2 text-sm text-stone-500"},gh=["disabled"],yh={class:"flex flex-col gap-1"},bh=["onDragstart","onDrop"],kh=["disabled"],wh=["title"],xh=["disabled","onClick","aria-label"],vh={key:0,class:"text-xs text-stone-500"},qn=Ce(e.defineComponent({__name:"vs-input-array-select",props:e.mergeModels({options:{default:()=>[]},data:{default:""},api:{default:""},prefix:{default:"api"},host:{default:""},parent:{},search:{type:Boolean,default:!0},maxHeight:{default:280},start:{default:0},slot:{},disabled:{type:Boolean,default:!1},add:{},style:{},customClass:{},modelValue:{},error:{},name:{},placeholder:{default:"Оберіть значення"},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:e.mergeModels(["change","update:modelValue","value-selected"],["update:modelValue"]),setup(o,{emit:t}){const n=o,r=t,a=e.useModel(o,"modelValue"),l=e.ref([]),s=e.ref(n.options??[]),c=e.ref({}),i=e.ref({}),d=e.ref({keyword:"",parent:null}),h=e.ref(""),g=e.ref(!1),p=e.ref(null),f=e.ref(null),m=e.ref(null),k=e.ref(null),b=e.ref(null),_=e.ref({});let C=!1,N=!1;const $=e.inject("values"),q=e.computed(()=>!!n.disabled),G=e.computed(()=>n.placeholder??"Оберіть значення"),I=e.computed(()=>n.search!==!1),E=e.computed(()=>{const w=n.parent??n.parentValue;return w?String(w):""}),V=e.computed(()=>E.value?$?.value?.[E.value]??null:null),v=w=>w==null?"__null__":String(w),T=w=>{if(!w)return"";const S=w.label??w.text??w.name??w.ua??w.en;return S?String(S):w.id!==void 0&&w.id!==null?String(w.id):""},j=w=>{const S=v(w);return i.value[S]||(i.value[S]=`array-select-${S}-${Math.random().toString(36).slice(2,8)}`),i.value[S]},te=e.computed(()=>new Set(l.value.map(w=>v(w.id)))),D=e.computed(()=>{const w=te.value;let S=[...s.value];if(!n.data&&h.value.trim()){const P=h.value.toLowerCase();S=S.filter(le=>T(le).toLowerCase().includes(P))}return S.filter(P=>!w.has(v(P.id)))}),U=()=>{if(!n.data)return"";const w=n.prefix??"api",S=n.api??`/${w}/suggest/${n.data}`;return`${n.host??""}${S}`},oe=()=>{l.value.length&&(C=!0,l.value=l.value.map(w=>({...w,text:c.value[v(w.id)]??w.text})))},R=w=>{const S=v(w.id),P=T(w);P&&(c.value[S]=P)},H=w=>{s.value=w?[...w]:[],w?.forEach(R),oe()},Z=w=>{if(!w.length)return;const S=new Map(s.value.map(P=>[v(P.id),P]));w.forEach(P=>{const le=v(P.id);S.set(le,P),R(P)}),s.value=Array.from(S.values()),oe()},ae=async(w="")=>{if(!n.data)return[];const S=U();if(!S)return[];const P=new URLSearchParams;P.set("json","1"),w&&P.set("key",w),n.start===1&&P.set("start","1"),V.value!==null&&V.value!==void 0&&V.value!==""&&P.set("parent",String(V.value));try{return(await(await fetch(`${S}?${P.toString()}`)).json())?.data??[]}catch{return[]}},O=async w=>{if(!n.data||!w.length)return[];const S=U();if(!S)return[];const P=Array.from(new Set(w.map(we=>v(we)))),le=new URLSearchParams;le.set("json","1"),le.set("val",P.join(",")),n.start===1&&le.set("start","1"),V.value!==null&&V.value!==void 0&&V.value!==""&&le.set("parent",String(V.value));try{const De=(await(await fetch(`${S}?${le.toString()}`)).json())?.data??[];return Z(De),De}catch{return[]}},A=async w=>{if(w==null||w==="")return null;const S=v(w),P=s.value.find(we=>v(we.id)===S);if(P)return P;const[le]=await O([w]);return le??null},M=async(w="",{force:S=!1}={})=>{if(!n.data)return;const P=V.value??null;if(!S&&d.value.keyword===w&&d.value.parent===P&&s.value.length>0)return;d.value={keyword:w,parent:P};const we=await ae(w);H(we)},se=((w,S=200)=>{let P;return(...le)=>{P&&clearTimeout(P),P=setTimeout(()=>w(...le),S)}})(async w=>{n.data&&await M(w,{force:!0})},250),ee=e.ref(null),me=()=>{if(!m.value)return;const w=m.value.getBoundingClientRect(),S=window.innerHeight??document.documentElement.clientHeight,P=window.innerWidth??document.documentElement.clientWidth,le=8,we=8,Le=n.maxHeight??280,De=S-w.bottom-we-le,je=w.top-we-le,He=De>=je,pt=Math.max(P-le*2,0);let{width:qe}=w;pt>0&&qe>pt&&(qe=pt);let{left:it}=w;it+qe+le>P&&(it=P-qe-le),it=Math.max(it,le);const Pt=Math.min(Le,Math.max(He?De:je,50));_.value={position:"fixed",left:`${it}px`,width:`${qe}px`,maxHeight:`${Pt}px`,transform:He?"none":"translateY(-100%)",top:He?`${w.bottom+we}px`:`${w.top-we}px`}},ke=async(w="click")=>{q.value||g.value||(ee.value=w,await M(h.value.trim()),g.value=!0,await e.nextTick(),me(),b.value?.focus())},ge=()=>{g.value=!1,ee.value=null,e.nextTick(()=>{b.value?.blur()})},Se=async w=>{if(w.stopPropagation(),!q.value){if(g.value){if(ee.value==="focus"){ee.value=null;return}ge();return}await ke("click")}},Ne=w=>{w.key==="Escape"&&ge()},$e=w=>{if(!g.value)return;const S=w.target;k.value?.contains(S)||ge()},Oe=w=>{const S=w.target;f.value?.contains(S)||k.value?.contains(S)||ge()},Me=w=>{if(w.key==="Escape"){w.preventDefault(),ge();return}if(w.key==="Enter"){w.preventDefault();const S=D.value[0];S&&ne(S)}},ne=w=>{if(!w)return;const S=v(w.id);if(te.value.has(S))return;R(w);const P={id:w.id,text:T(w)||String(w.id??""),key:j(w.id)};l.value=[...l.value,P],de(w),h.value="",e.nextTick(()=>{b.value?.focus()})},de=w=>{const S=l.value.map(P=>P.id);r("value-selected",{name:n.name,value:S,option:w})},xe=w=>{if(q.value)return;const S=l.value.filter(P=>v(P.id)!==v(w));l.value=S},{isOpenAdd:ve,addData:ze,addSchema:Te,addForm:Je,addTitle:Ae,addOption:Fe,onAddValue:ut}=Sr({props:n,fetchOptionByValue:A,optionsList:s,selectedOption:e.ref(null),modelValue:a,onCreated:async(w,S)=>{const P=w??await A(S),le=P?.id??S;te.value.has(v(le))||(P&&R(P),l.value=[...l.value,{id:le,text:P?T(P):String(le),key:j(le)}],de(P??null))}}),z=w=>{q.value||(p.value=w)},J=w=>{if(q.value||p.value===null||p.value===w)return;const S=[...l.value],[P]=S.splice(p.value,1);S.splice(w,0,P),p.value=null,l.value=S},ie=async()=>{const S=(Array.isArray(a.value)?[...a.value]:[]).filter(le=>le!=null);if(n.data&&S.length){const le=S.filter(we=>!c.value[v(we)]);le.length&&await O(le)}const P=S.map(le=>({id:le,text:c.value[v(le)]??String(le),key:j(le)}));C=!0,l.value=P};e.watch(l,w=>{if(C){C=!1;return}const S=w.map(P=>P.id);N=!0,a.value=S,r("change",S)},{deep:!0}),e.watch(a,()=>{if(N){N=!1;return}ie()},{deep:!0}),e.watch(h,w=>{!n.data||!g.value||se(w.trim())}),e.watch(q,w=>{w&&ge()}),e.watch(()=>n.options,async w=>{n.data||(H(w??[]),await ie())},{immediate:!0,deep:!0}),e.watch(()=>n.data,async w=>{w&&(await M(h.value.trim()),await ie())},{immediate:!0});const F=e.ref(!1);return e.watch(V,async()=>{if(n.data){if(!F.value){F.value=!0;return}l.value=[],await M(h.value.trim()),await ie()}}),e.onMounted(async()=>{document.addEventListener("click",Oe,!0),window.addEventListener("keydown",Ne),window.addEventListener("scroll",$e,!0),await ie()}),e.onUnmounted(()=>{document.removeEventListener("click",Oe,!0),window.removeEventListener("keydown",Ne),window.removeEventListener("scroll",$e,!0)}),(w,S)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(he.VsModal),{visible:e.unref(ve),"onUpdate:visible":S[1]||(S[1]=P=>e.isRef(ve)?ve.value=P:null),class:"z-[1000]",title:e.unref(Ae),buttonText:"Додати",onDone:e.unref(Fe)},{default:e.withCtx(()=>[e.createVNode(ot,{schema:e.unref(Te),modelValue:e.unref(ze),"onUpdate:modelValue":S[0]||(S[0]=P=>e.isRef(ze)?ze.value=P:null),ref_key:"addForm",ref:Je},null,8,["schema","modelValue"])]),_:1},8,["visible","title","onDone"]),e.createElementVNode("div",{class:"flex flex-col gap-2 w-full",ref_key:"rootRef",ref:f},[e.createElementVNode("div",dh,[e.createElementVNode("div",{class:"relative flex-1",onClick:S[4]||(S[4]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",{ref_key:"triggerRef",ref:m,class:e.normalizeClass(["flex min-h-[38px] items-center justify-between rounded border transition-colors bg-white px-3","border-gray-300 hover:border-[#b3d4ff]",g.value?"border-[#2684ff] ring-1 ring-[#2684ff] shadow-[0_0_0_1px_rgba(38,132,255,0.5)]":"",q.value?"bg-gray-100 text-gray-400 cursor-not-allowed hover:border-gray-300":""]),role:"combobox","aria-expanded":g.value,"aria-haspopup":"listbox","data-focus":g.value?"true":"false",onClick:Se},[e.withDirectives(e.createElementVNode("input",{ref_key:"inputRef",ref:b,"onUpdate:modelValue":S[2]||(S[2]=P=>h.value=P),placeholder:G.value,disabled:q.value,readonly:!I.value,onFocus:S[3]||(S[3]=()=>ke("focus")),onKeydown:Me,class:"flex-1 bg-transparent border-0 outline-none px-0 py-1 text-sm text-stone-900 placeholder:text-stone-400"},null,40,ph),[[e.vModelText,h.value]]),e.createElementVNode("span",{class:e.normalizeClass(["text-stone-400 transition-transform duration-150",g.value?"rotate-180":""]),"aria-hidden":"true"},[e.createVNode(e.unref(X.ChevronDown),{class:"h-4 w-4"})],2)],10,uh),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[g.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:k,class:"fixed z-[3000] rounded-md border border-stone-200 bg-white shadow-lg overflow-auto",style:e.normalizeStyle(_.value)},[e.createElementVNode("div",mh,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(D.value,P=>(e.openBlock(),e.createElementBlock("button",{key:v(P.id),type:"button",class:"w-full px-3 py-2 text-left text-sm text-stone-900 hover:bg-stone-100 disabled:opacity-50",onClick:e.withModifiers(le=>ne(P),["stop"]),disabled:q.value},e.toDisplayString(T(P)),9,fh))),128)),D.value.length===0?(e.openBlock(),e.createElementBlock("p",hh," Немає варіантів ")):e.createCommentVNode("",!0)])],4)):e.createCommentVNode("",!0)]),_:1})]))]),n.add?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:S[5]||(S[5]=(...P)=>e.unref(ut)&&e.unref(ut)(...P)),class:"bg-white hover:bg-gray-100 text-sm text-gray-900 py-[10px] px-3 border border-stone-200 rounded-md h-[38px] flex items-center gap-2",disabled:q.value,type:"button"},[e.createVNode(e.unref(X.Plus),{class:"h-4 w-4"}),S[8]||(S[8]=e.createElementVNode("span",null,"Додати",-1))],8,gh)):e.createCommentVNode("",!0)]),e.createElementVNode("div",yh,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,(P,le)=>(e.openBlock(),e.createElementBlock("div",{key:P.key,class:e.normalizeClass(["flex items-center gap-2 rounded-md border border-stone-200 bg-white px-2 py-2",{"opacity-60":p.value===le}]),draggable:"true",onDragstart:we=>z(le),onDragover:S[6]||(S[6]=e.withModifiers(()=>{},["prevent"])),onDrop:we=>J(le),onDragend:S[7]||(S[7]=we=>p.value=null)},[e.createElementVNode("button",{type:"button",class:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-stone-500 hover:text-stone-900",disabled:q.value,"aria-label":"Перетягнути"},[e.createVNode(e.unref(X.GripVertical),{class:"h-4 w-4"})],8,kh),e.createElementVNode("div",{class:"flex-1 text-sm text-stone-900",title:P.text},e.toDisplayString(P.text),9,wh),e.createElementVNode("button",{type:"button",class:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-stone-400 hover:text-stone-900",disabled:q.value,onClick:e.withModifiers(we=>xe(P.id),["stop"]),"aria-label":`Видалити ${P.text}`},[e.createVNode(e.unref(X.X),{class:"h-4 w-4"})],8,xh)],42,bh))),128)),l.value.length===0?(e.openBlock(),e.createElementBlock("p",vh,"Немає вибраних значень")):e.createCommentVNode("",!0)])],512)],64))}}),[["__scopeId","data-v-da4b4da7"]]),_h={class:"flex items-center gap-2 w-full"},Ch={class:"relative flex-1"},Eh=["placeholder","disabled","onKeydown"],Bh=["disabled"],Vh={key:0,class:"fixed inset-0 z-[1000] flex items-center justify-center bg-black/50"},Sh={class:"bg-white text-gray-900 rounded-lg shadow-lg w-[480px] max-h-[80vh] overflow-y-auto"},$h={class:"p-3 border-b font-semibold text-gray-900 flex justify-between items-center"},Ah=["onClick"],Nh={key:0,class:"p-4 text-sm text-gray-500"},Zr=e.defineComponent({__name:"vs-input-address",props:e.mergeModels({api:{default:""},geom:{default:""},includes:{default:()=>[]},bbox:{},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:e.mergeModels(["update:modelValue","update:geom"],["update:modelValue"]),setup(o,{emit:t}){const n=/{{\s*([^}]+?)\s*}}/g,r=o,a=t,{inputClass:l}=Qe(r.style),s=e.useModel(o,"modelValue"),c=e.computed({get:()=>s.value,set:I=>{s.value=I}}),i=e.ref(!1),d=e.ref([]),h=e.ref(!1),g=e.ref(null);e.watch(h,I=>{typeof document>"u"||(I?(g.value=document.body.style.overflow,document.body.style.overflow="hidden"):g.value!=null?(document.body.style.overflow=g.value,g.value=null):document.body.style.removeProperty("overflow"))}),e.onBeforeUnmount(()=>{typeof document>"u"||(g.value!=null?document.body.style.overflow=g.value:document.body.style.removeProperty("overflow"))});const p=e.computed(()=>r.placeholder??""),f=e.computed(()=>!!r.disabled),m=I=>{if(!I)return null;if(Array.isArray(I))return I;if(typeof I=="string"){const E=I.split(",").map(V=>V.trim()).filter(Boolean);return E.length!==4?null:E.map(Number)}return null},k=e.computed(()=>{const I=m(r.bbox);if(!I||I.length!==4)return null;const E=I.map(Number);return E.some(V=>Number.isNaN(V))?null:E}),b=e.computed(()=>{const I=k.value;if(!I)return"";const[E,V,v,T]=I;return`${E},${Math.max(V,T)},${v},${Math.min(V,T)}`});e.computed(()=>b.value?"1":"0");const _=e.inject("values");function C(){!f.value&&c.value.trim()&&N()}async function N(){const I=(c.value||"").trim();if(!I)return;let E=I;if(r.includes?.length&&_?.value){const v=r.includes.map(T=>_.value?.[T]).filter(Boolean);v.length&&(E=`${v.join(", ")}, ${I}`)}const V=G(E);if(V){i.value=!0;try{const T=await(await fetch(V)).json();d.value=Array.isArray(T)?T:[],h.value=!0}catch(v){console.error("Address search error:",v)}finally{i.value=!1}}}function $(){h.value=!h.value}function q(I){if(!I)return;h.value=!1;const E=parseFloat(I.lat),v={type:"Point",coordinates:[parseFloat(I.lon),E]};r.geom&&_?.value&&(_.value[r.geom]=v),a("update:geom",v)}function G(I){if(!r.api)return"";const E={value:encodeURIComponent(I),bbox:k.value?k.value.join(","):""};return r.api.replace(n,(V,v)=>E[v.trim()]??"")}return(I,E)=>(e.openBlock(),e.createElementBlock("div",_h,[e.createElementVNode("div",Ch,[e.withDirectives(e.createElementVNode("input",{type:"text","onUpdate:modelValue":E[0]||(E[0]=V=>c.value=V),placeholder:p.value,disabled:f.value,class:e.normalizeClass(["py-1.5 px-3 block w-full bg-white border rounded-md placeholder:text-gray-400 focus:ring-2 focus:ring-blue-500",[e.unref(l),{"!border-red-600":r.error}]]),style:{border:"1px solid #CFD9E0"},onKeydown:e.withKeys(e.withModifiers(C,["prevent"]),["enter"])},null,42,Eh),[[e.vModelText,c.value]]),d.value.length?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-blue-600",onClick:$,title:"Show search results"},[e.createVNode(e.unref(X.Info),{class:"h-4 w-4"})])):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",onClick:N,class:"flex items-center justify-center px-2 py-2 border rounded-md bg-white hover:bg-gray-50 text-gray-600 hover:text-blue-600 disabled:opacity-50 h-[38px]",disabled:i.value||!c.value?.trim()},[i.value?(e.openBlock(),e.createBlock(e.unref(X.LoaderCircle),{key:1,class:"h-5 w-5 animate-spin text-gray-400"})):(e.openBlock(),e.createBlock(e.unref(X.Search),{key:0,class:"h-4 w-4"}))],8,Bh),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[h.value?(e.openBlock(),e.createElementBlock("div",Vh,[e.createElementVNode("div",Sh,[e.createElementVNode("div",$h,[E[2]||(E[2]=e.createElementVNode("span",null,"Результати пошуку",-1)),e.createElementVNode("button",{class:"text-gray-500 hover:text-blue-600",onClick:E[1]||(E[1]=V=>h.value=!1),title:"Close"},[e.createVNode(e.unref(X.X),{class:"h-4 w-4"})])]),e.createElementVNode("ul",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,(V,v)=>(e.openBlock(),e.createElementBlock("li",{key:v,onClick:T=>q(V),class:"px-3 py-2 cursor-pointer hover:bg-gray-100 border-b text-sm"},e.toDisplayString(V.display_name),9,Ah))),128))]),d.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Nh," Не знайдено результатів "))])])):e.createCommentVNode("",!0)]))]))}}),Mh={class:"vs-datalist space-y-3"},Fh={class:"space-y-3"},Dh=["onClick","disabled"],Th={key:0,class:"rounded-lg border border-dashed border-gray-200 p-4 text-sm text-gray-500"},Lh=["disabled"],Ih=Ce(e.defineComponent({__name:"vs-input-datalist",props:e.mergeModels({schema:{default:()=>[]},minItems:{default:0},maxItems:{default:void 0},addButtonText:{default:"Додати позицію"},emptyLabel:{default:"Немає рядків"},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.computed(()=>Array.isArray(n.value)?n.value:[]),a=e.ref([]),l=e.computed(()=>t.schema?.map(b=>({...b,disabled:t.disabled||b.disabled}))??[]),s=e.computed(()=>l.value.map(b=>k(b))),c=e.computed(()=>l.value.reduce((_,C)=>{const N=Number(C?.col??12);return _+(Number.isFinite(N)&&N>0?N:12)},0)>12),i=e.computed(()=>t.disabled?!1:t.maxItems?r.value.length<t.maxItems:!0),d=e.computed(()=>t.disabled||r.value.length<=(t.minItems||0));e.watch(()=>r.value.length,()=>{h(),g()},{immediate:!0}),e.watch(()=>t.schema,g,{immediate:!0,deep:!0});function h(){const b=r.value.length;a.value.length<b?a.value=[...a.value,...Array.from({length:b-a.value.length},()=>Vo())]:a.value.length>b&&a.value.splice(b)}function g(){if(!t.minItems||r.value.length>=t.minItems)return;const b=t.minItems-r.value.length,_=Array.from({length:b},p);n.value=[...r.value,..._]}function p(){const b={};return l.value.forEach(_=>{b[_.name]=_?.default??null}),b}function f(){i.value&&(n.value=[...r.value,p()],h())}function m(b){d.value||(n.value=r.value.filter((_,C)=>C!==b),h(),g())}function k(b){return{...b}}return(b,_)=>(e.openBlock(),e.createElementBlock("div",Mh,[e.createElementVNode("div",Fh,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(C,N)=>(e.openBlock(),e.createElementBlock("div",{key:a.value[N],class:e.normalizeClass(["flex items-center gap-3 rounded-lg transition-colors",{"border border-gray-300 p-2":c.value}])},[e.createVNode(ot,{schema:s.value,layout:"inline",navigation:!1,values:r.value[N],"onUpdate:values":$=>r.value[N]=$,"form-id":a.value[N]},null,8,["schema","values","onUpdate:values","form-id"]),e.createElementVNode("button",{type:"button",class:"h-[38px] w-[38px] flex items-center justify-center text-gray-400 hover:text-gray-600 hover:bg-gray-50 rounded-lg transition-all disabled:opacity-40",onClick:$=>m(N),disabled:d.value},[e.createVNode(e.unref(X.Trash2),{class:"h-4 w-4"})],8,Dh)],2))),128)),r.value.length===0?(e.openBlock(),e.createElementBlock("div",Th,e.toDisplayString(t.emptyLabel),1)):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",class:"flex items-center gap-2 text-gray-600 hover:text-gray-900 font-medium transition-colors text-sm",onClick:f,disabled:!i.value},[e.createVNode(e.unref(X.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(t.addButtonText),1)],8,Lh)]))}}),[["__scopeId","data-v-d0065868"]]),Oh={class:"vs-dataform space-y-4"},Ph=["draggable","onDragstart","onDragover","onDragenter","onDrop"],Rh={class:"flex items-center gap-2"},zh=["onClick"],jh={class:"text-sm font-medium text-gray-700"},Uh={class:"flex items-center gap-2"},Hh=["title","onClick","disabled"],qh=["title","onClick","disabled"],Wh={key:0,class:"rounded-lg border border-dashed border-gray-200 p-4 text-sm text-gray-500"},Kh=["disabled"],Gh=Ce(e.defineComponent({__name:"vs-input-dataform",props:e.mergeModels({schema:{default:()=>[]},minGroups:{default:0},maxGroups:{default:void 0},addButtonText:{default:"Додати групу фільтрів"},groupLabel:{default:void 0},duplicateTitle:{default:"Дублювати групу"},removeTitle:{default:"Видалити групу"},emptyLabel:{},view:{default:"default"},collapsible:{type:Boolean,default:!1},draggable:{type:Boolean,default:!0},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.ref([]),a=e.ref([]),l=e.ref(0),s=e.ref(null),c=e.ref(null),i=e.ref(null),d=e.computed(()=>t.groupLabel??"Group"),h=e.computed(()=>t.emptyLabel??"Ще немає груп"),g=e.computed(()=>t.schema?.map(M=>({...M,disabled:t.disabled||M.disabled}))??[]),p=e.computed(()=>g.value.map(M=>V(M))),f=e.computed(()=>t.view==="accordion"),m=e.computed(()=>!!(t.collapsible||f.value)),k=e.computed(()=>t.draggable!==!1),b=e.computed(()=>t.disabled?!1:t.maxGroups?n.value.length<t.maxGroups:!0),_=e.computed(()=>t.disabled||n.value.length<=(t.minGroups||0));e.watch(()=>n.value.length,()=>{C(),N(),$()},{immediate:!0}),e.watch(()=>t.schema,$,{immediate:!0,deep:!0}),e.watch(()=>t.view,()=>{N()},{immediate:!0});function C(){const M=n.value.length;r.value.length<M?r.value=[...r.value,...Array.from({length:M-r.value.length},()=>Vo())]:r.value.length>M&&r.value.splice(M)}function N(){const M=n.value.length;f.value?M===0?l.value=-1:l.value>=M?l.value=M-1:l.value<0&&(l.value=0):a.value.length<M?a.value=[...a.value,...Array.from({length:M-a.value.length},()=>!1)]:a.value.length>M&&a.value.splice(M)}function $(){if(!t.minGroups||n.value.length>=t.minGroups)return;const M=t.minGroups-n.value.length,Q=Array.from({length:M},q);n.value=[...n.value,...Q],N()}function q(){const M={};return g.value.forEach(Q=>{M[Q.name]=Q?.default??null}),M}function G(){b.value&&(n.value=[...n.value,q()],C(),N())}function I(M){_.value||(n.value=n.value.filter((Q,se)=>se!==M),C(),f.value?l.value>=n.value.length&&(l.value=n.value.length-1):a.value.splice(M,1),$())}function E(M){if(t.disabled)return;const Q=JSON.parse(JSON.stringify(n.value[M]??{}));n.value=[...n.value.slice(0,M+1),Q,...n.value.slice(M+1)],C(),f.value?l.value>M&&(l.value+=1):a.value.splice(M+1,0,a.value[M]??!1)}function V(M){return{...M}}function v(M){return f.value?l.value===-1&&M===0?!1:l.value!==M:!!a.value[M]}function T(M){if(m.value){if(f.value){l.value=M;return}a.value[M]=!a.value[M]}}function j(M,Q){if(!k.value||t.disabled){Q.preventDefault();return}s.value=M,c.value=M,i.value={groups:JSON.parse(JSON.stringify(n.value)),keys:[...r.value],states:[...a.value]},Q.dataTransfer?.setData("text/plain",String(M)),Q.dataTransfer?.setDragImage?.(Q.currentTarget,0,0)}function te(M,Q){!k.value||t.disabled||s.value!==null&&Z(M,Q)}function D(M,Q){Z(M,Q)}function U(M){!k.value||t.disabled||A()}function oe(){i.value&&H(),s.value=null,c.value=null,i.value=null}function R(M,Q){const se=[...n.value],[ee]=se.splice(M,1);se.splice(Q,0,ee),n.value=se;const me=[...r.value],[ke]=me.splice(M,1);if(me.splice(Q,0,ke),r.value=me,f.value)l.value===M&&(l.value=Q);else{const ge=[...a.value],[Se]=ge.splice(M,1);ge.splice(Q,0,Se),a.value=ge}}function H(){i.value&&(n.value=i.value.groups,r.value=i.value.keys,a.value=i.value.states,i.value=null,c.value=null)}function Z(M,Q){if(s.value===null)return;const se=ae(M,Q);c.value=se,O(se)}function ae(M,Q){if(!Q?.currentTarget)return M;const se=Q.currentTarget.getBoundingClientRect(),me=Q.clientY-se.top>se.height/2?M+1:M;return Math.max(0,Math.min(me,n.value.length))}function O(M){const Q=s.value;if(Q===null)return;let se=M;if(se>n.value.length&&(se=n.value.length),se===Q||se===Q+1)return;const ee=se>Q?se-1:se;R(Q,ee),s.value=ee,c.value=se>Q?ee+1:ee}function A(){i.value=null,s.value=null,c.value=null}return(M,Q)=>(e.openBlock(),e.createElementBlock("div",Oh,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,(se,ee)=>(e.openBlock(),e.createElementBlock("div",{key:r.value[ee],class:e.normalizeClass(["relative border border-gray-200 rounded-lg bg-white transition vs-dataform__group",[t.view==="accordion"?"overflow-hidden":v(ee)?"pt-6 px-6":"p-6"]]),draggable:k.value&&!t.disabled,onDragstart:me=>j(ee,me),onDragend:oe,onDragover:e.withModifiers(me=>te(ee,me),["prevent"]),onDragenter:e.withModifiers(me=>D(ee,me),["prevent"]),onDrop:e.withModifiers(me=>U(),["prevent"])},[e.createElementVNode("div",{class:e.normalizeClass(["flex items-center justify-between gap-2 border-b border-gray-100 px-4 py-3",[t.view!=="accordion"?"-mx-6 -mt-6 px-6":"",t.view!=="accordion"&&!v(ee)?"rounded-t-lg":"rounded-lg"]])},[e.createElementVNode("div",Rh,[k.value?(e.openBlock(),e.createBlock(e.unref(X.GripVertical),{key:0,class:"h-4 w-4 text-gray-400","aria-hidden":"true"})):e.createCommentVNode("",!0),m.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"rounded-full p-1 text-gray-500 transition hover:bg-gray-100",onClick:me=>T(ee)},[e.createVNode(e.unref(X.ChevronDown),{class:e.normalizeClass(["h-4 w-4 transition",v(ee)?"-rotate-90":"rotate-0"])},null,8,["class"])],8,zh)):e.createCommentVNode("",!0),e.createElementVNode("div",jh,e.toDisplayString(`${d.value} (${ee+1})`),1)]),e.createElementVNode("div",Uh,[e.createElementVNode("button",{type:"button",class:"p-2 text-gray-400 hover:text-gray-600 hover:bg-gray-50 rounded-lg transition-all disabled:opacity-40",title:t.duplicateTitle,onClick:me=>E(ee),disabled:t.disabled,draggable:"false"},[e.createVNode(e.unref(X.Copy),{class:"h-4 w-4"})],8,Hh),e.createElementVNode("button",{type:"button",class:"p-2 text-gray-400 hover:text-gray-600 hover:bg-gray-50 rounded-lg transition-all disabled:opacity-40",title:t.removeTitle,onClick:me=>I(ee),disabled:_.value,draggable:"false"},[e.createVNode(e.unref(X.Trash2),{class:"h-4 w-4"})],8,qh)])],2),e.withDirectives(e.createElementVNode("div",{class:e.normalizeClass(t.view==="accordion"?"p-6":"pt-6")},[e.createVNode(ot,{class:"vs-dataform__form",schema:p.value,layout:"inline",navigation:!1,values:n.value[ee],"onUpdate:values":me=>n.value[ee]=me,"form-id":r.value[ee],disabled:t.disabled},null,8,["schema","values","onUpdate:values","form-id","disabled"])],2),[[e.vShow,!v(ee)]])],42,Ph))),128)),n.value.length===0?(e.openBlock(),e.createElementBlock("div",Wh,e.toDisplayString(h.value),1)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"flex items-center gap-2 text-gray-600 hover:text-gray-900 font-medium transition-colors text-sm",onClick:G,disabled:!b.value},[e.createVNode(e.unref(X.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(t.addButtonText),1)],8,Kh)]))}}),[["__scopeId","data-v-cfbcfed8"]]),Wn="__vs_form_monaco_loader__",Wt="__vs_form_monaco_script_loader__",Kn="__vs_form_monaco_editor_loader__",No=e.defineComponent({__name:"vs-input-monaco",props:e.mergeModels({syntax:{default:"xml"},theme:{default:"vs-light"},height:{default:280},minimap:{type:Boolean,default:!1},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o,{expose:t}){const n=o,r=e.useModel(o,"modelValue"),a=e.ref(null),l=e.computed(()=>typeof n.height=="number"?`${n.height}px`:n.height||"280px");let s=null,c=null,i=!1;const d=()=>{if(c)return Promise.resolve(c);if(typeof window>"u")return Promise.resolve(null);const m=window;if(m.monaco?.editor?.create)return c=m.monaco,Promise.resolve(c);if(m[Wn])return m[Wn];const b=(async()=>{const _=$=>{if(Array.from(document.styleSheets||[]).some(I=>I?.href?.includes($)))return;const G=document.createElement("link");G.rel="stylesheet",G.href=$,document.head.appendChild(G)},C=$=>{if(m[Wt]?.[$])return m[Wt][$];m[Wt]||={};const q=Array.from(document.scripts).find(G=>G.src===$);return q?(m[Wt][$]=new Promise((G,I)=>{const E=q.readyState;if(q.dataset.loaded==="true"||E==="loaded"||E==="complete"){G();return}q.addEventListener("load",()=>{q.dataset.loaded="true",G()},{once:!0}),q.addEventListener("error",V=>I(V),{once:!0})}),m[Wt][$]):(m[Wt][$]=new Promise((G,I)=>{const E=document.createElement("script");E.src=$,E.async=!0,E.onload=()=>{E.dataset.loaded="true",G()},E.onerror=V=>I(V),document.body.appendChild(E)}),m[Wt][$])},N="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.52.0/min/vs";return _(`${N}/editor/editor.main.min.css`),await C(`${N}/loader.min.js`),m[Kn]||(m[Kn]=new Promise(($,q)=>{window.require.config({paths:{vs:N}}),window.require(["vs/editor/editor.main"],()=>{c=window.monaco,m.monaco=c,$(c)},G=>q(G))}).catch($=>{throw delete m[Kn],$})),m[Kn]})().catch(_=>{throw delete m[Wn],_});return m[Wn]=b,b},h=()=>{!a.value||!c||(s&&(s.dispose(),s=null),s=c.editor.create(a.value,{value:r.value||"",language:n.syntax,theme:n.theme,automaticLayout:!0,minimap:{enabled:!!n.minimap},readOnly:!!n.disabled}),s.onDidChangeModelContent(()=>{i||(r.value=s.getValue())}))},g=()=>{s?.focus()},p=()=>s,f=()=>c;return e.watch(()=>r.value,m=>{if(!s)return;const k=s.getValue();m!==k&&(i=!0,s.setValue(m||""),i=!1)}),e.watch(()=>n.syntax,m=>{!s||!c||c.editor.setModelLanguage(s.getModel(),m||"xml")}),e.watch(()=>n.theme,m=>{c&&c.editor.setTheme(m||"vs-light")}),e.watch(()=>n.disabled,m=>{s&&s.updateOptions({readOnly:!!m})}),e.watch(()=>n.minimap,m=>{s&&s.updateOptions({minimap:{enabled:!!m}})}),e.onMounted(async()=>{try{const m=await d();if(!m||!m.editor)return;c=m,h()}catch(m){console.error("Failed to load Monaco editor",m)}}),e.onBeforeUnmount(()=>{s&&(s.dispose(),s=null)}),t({focus:g,getEditor:p,getMonaco:f}),(m,k)=>(e.openBlock(),e.createElementBlock("div",{class:"w-full",style:e.normalizeStyle({height:l.value})},[e.createElementVNode("div",{ref_key:"editorContainer",ref:a,class:"w-full h-full overflow-hidden border border-[#CFD9E0] rounded"},null,512)],4))}}),Jr={VsInputText:Yt,VsInputRadio:fo,VsInputInlineSelect:On,"vs-input-text":Yt,"vs-input-password":xa,"vs-input-textarea":Ar,"vs-input-richtext":Nr,"vs-input-mask":En,"vs-input-number":rr,"vs-input-radio":fo,"vs-input-select":Bo,"vs-input-inline-select":On,"inline-select":On,"vs-input-switcher":co,"vs-input-static":uo,"vs-input-container":Vr,"vs-input-date":hr,"vs-input-checkbox":sr,"vs-input-file":xr,"vs-input-file2":Tn,file2:Tn,File2:Tn,"vs-input-file64":Ln,file64:Ln,File64:Ln,"vs-input-html":uo,"vs-input-email":po,"vs-input-tel":mo,"vs-input-datatable":Mr,"vs-input-map":jr,"vs-input-file-list":Er,"vs-input-tags":Ur,"vs-input-slug":Hr,"vs-input-codegen":qr,"vs-input-key-value":Wr,"vs-input-text[]":Kr,"vs-input-range":Yr,"vs-input-color":Gr,"vs-input-native-select":Bo,VsInputArraySelect:qn,"vs-input-array":Xr,"vs-input-array-select":qn,"array-select":qn,"vs-input-address":Zr,"vs-input-datalist":Ih,"vs-input-dataform":Gh,"vs-input-monaco":No},Yh=e.defineComponent({__name:"behavior",props:{api:{},set:{},button:{},error:{},value:{}},setup(o){const t=o,n=e.inject("values");function r(l,s){const c=s?.result||s?.message||s?.error||s?.detail;return l.status===400&&typeof c=="string"&&c.trim().toLowerCase()==="not found"?"Дані не знайдено.":l.status===500?"Помилка на сервері.":typeof c=="string"&&c.trim()?c:"При спробі завантажити дані виникла помилка."}async function a(){try{if(!t.api)return;const l=t.api.replace("{{value}}",t.value),s=await fetch(l);if(!s.ok){let i=null;try{i=await s.json()}catch{try{i=await s.text()}catch{i=null}}he.notify({type:"warning",title:"Validation",message:r(s,i)});return}const c=await s.json();if(!t.set||!n)return;for(const[i,d]of Object.entries(t.set))n.value[i]=c.result[d]}catch(l){console.error(t.error,l)}}return(l,s)=>(e.openBlock(),e.createElementBlock("button",{onClick:a,class:"vs-button relative inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border !border-gray-200 hover:text-white bg-white text-blue-500 hover:border-blue-500 hover:bg-blue-500 focus:ring-blue-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1 ml-0 md:ml-2 mt-2 md:mt-0 py-[8px] md:w-2/4 whitespace-nowrap w-full"},e.toDisplayString(l.button),1))}}),Xh={class:"flex flex-col gap-1 w-full"},Zh={class:"w-full"},Jh=["disabled"],Qh=["innerHTML"],eg=2e3,tg=10,Qr=e.defineComponent({__name:"vs-compact-form-layout",props:e.mergeModels({item:{default:{}},layout:{default:"default"},style:{default:{}},type:{default:""},error:{type:[String,Boolean]},columns:{default:()=>({container:12,label:3})}},{modelValue:{default:null},modelModifiers:{}}),emits:e.mergeModels(["value-selected"],["update:modelValue"]),setup(o,{emit:t}){const n=o,r=e.useModel(o,"modelValue"),a=t,l=e.computed(()=>ka[`${n.layout}`]),s=["label","placeholder","info","description","text","html"],c=e.ref(j()),i=e.computed(()=>V(n.item,c.value)),d=e.computed(()=>{const D={...i.value??{}},U=n.item?.name;return U&&g?.value?.[U]&&Object.assign(D,g.value[U]),D.__locale=c.value,D}),h=e.computed(()=>Jr?.[`vs-input-${n.item.type}`]),g=e.inject("field-props"),p=e.computed(()=>{const D=e.unref(h);if(!D)return new Set;const U=D.props??D.__vccOpts?.props;if(!U)return new Set;const oe=Array.isArray(U)?U:Object.keys(U);return new Set(oe)}),m=[...["min","max","step"],"api","set","mask","layers"],k=new Set(["name","type","label","ua","col","rules","validators","conditions","schema","hidden","behavior","default","columns","layout","multiple","data","info","description","text","html","view","groupLabel","emptyLabel","minGroups","maxGroups","collapsible","draggable","props","__locale","slot","slots","component"]);function b(D){const U={};Object.entries(D).forEach(([R,H])=>{k.has(R)||R.includes(":")||H!==void 0&&(U[R]=H)});const oe=D.props;return oe&&typeof oe=="object"&&!Array.isArray(oe)&&Object.entries(oe).forEach(([R,H])=>{H!==void 0&&(U[R]=H)}),U}const _=e.computed(()=>{const D={...i.value??{}},U=n.item?.name;U&&g?.value?.[U]&&Object.assign(D,g.value[U]);const oe=p.value;let R;return oe.size?R=Object.fromEntries(Object.entries(D).filter(([H])=>oe.has(H))):R={...D},Object.assign(R,b(D)),m.forEach(H=>{const Z=D[H];Z!=null&&(R[H]=Z)}),R}),C=D=>{const U=typeof D=="object"&&D!==null?D:{value:D};a("value-selected",{...U,name:U.name??n.item?.name})},N=/{{\s*([^}]+?)\s*}}/g,$=e.inject("values"),q=e.ref(!1),G=e.computed(()=>{const D=n.item?.api,U=n.item?.type?.toLowerCase();return typeof D=="string"&&D.trim().length>0&&(U==="text"||U==="mask")});function I(D,U){if(!(D==null||!U))return U.split(".").reduce((oe,R)=>oe?.[R.trim()],D)}async function E(){const D=String(r.value??"").trim();if(!D)return;const U=(n.item?.api??"").trim();if(!U)return;const oe=U.replace(N,(R,H)=>H.trim()==="value"?encodeURIComponent(D):"");q.value=!0;try{let R=await fetch(oe),H=0;for(;R.status===202&&H<tg;)H+=1,await new Promise(M=>{setTimeout(M,eg)}),R=await fetch(oe);if(R.status===202){he.notify({type:"warning",title:"Validation",message:"Сервер ще обробляє запит. Спробуйте пізніше."});return}if(!R.ok){he.notify({type:"warning",title:"Validation",message:"При спробі завантажити дані виникла помилка."});return}const Z=await R.json(),ae=Z?.result!==void 0?Z.result:Z,O=n.item?.set;if(!O||!$?.value)return;const A=n.item?.name;Object.entries(O).forEach(([M,Q])=>{if(!M)return;let se=Q;A&&se.startsWith(`${A}.`)&&(se=se.slice(A.length+1));const ee=I(ae,se);$.value[M]=ee??null})}catch(R){console.error("API lookup error:",R),he.notify({type:"warning",title:"Validation",message:"При спробі завантажити дані виникла помилка."})}finally{q.value=!1}}e.onMounted(()=>{c.value=j(),window.addEventListener("storage",te)}),e.onUnmounted(()=>{window.removeEventListener("storage",te)});function V(D,U){if(!D)return{};const oe={...D};return s.forEach(R=>{const H=T(D,R,U);H!=null&&(oe[R]=H)}),Array.isArray(D.options)&&(oe.options=D.options.map(R=>v(R,U))),oe}function v(D,U){if(!D)return D;const oe={...D},R=T(D,"label",U),H=T(D,"text",U);return R!=null&&(oe.label=R),H!=null?oe.text=H:R!=null&&(oe.text=R),oe}function T(D,U,oe){const R=`${U}:${oe}`;if(D?.[R]!=null)return D[R];if(U==="label"&&D?.[oe]!=null)return D[oe];if(D?.[U]!=null)return D[U];if(U==="label"){if(D?.ua!=null)return D.ua;if(D?.en!=null)return D.en}if(U==="text"||U==="html"){if(D?.ua!=null)return D.ua;if(D?.en!=null)return D.en}return null}function j(){return typeof window>"u"?"uk":localStorage.getItem("locale")||"uk"}function te(){c.value=j()}return(D,U)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(l.value),{ua:d.value.ua,error:n.error||"",item:d.value,columns:n.columns,label:d.value.label},{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(["flex w-full",`${n.item.type}-component`])},[e.createElementVNode("div",Xh,[e.createElementVNode("div",{class:e.normalizeClass(["flex items-center gap-2 w-full",{"flex-1":G.value}])},[e.createElementVNode("div",Zh,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(h.value),e.mergeProps(_.value,{modelValue:r.value,"onUpdate:modelValue":U[0]||(U[0]=oe=>r.value=oe),onValueSelected:C}),null,16,["modelValue"]))]),G.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"flex items-center justify-center px-2 py-2 border rounded-md bg-white hover:bg-gray-50 text-gray-600 hover:text-blue-600 disabled:opacity-50 h-[38px] shrink-0",disabled:q.value||!r.value?.toString().trim(),onClick:E},[q.value?(e.openBlock(),e.createBlock(e.unref(X.LoaderCircle),{key:1,class:"h-5 w-5 animate-spin text-gray-400"})):(e.openBlock(),e.createBlock(e.unref(X.Search),{key:0,class:"h-4 w-4"}))],8,Jh)):e.createCommentVNode("",!0)],2),d.value.description&&n.layout!=="settings"?(e.openBlock(),e.createElementBlock("p",{key:0,class:"text-sm text-gray-500",innerHTML:d.value.description},null,8,Qh)):e.createCommentVNode("",!0)]),d.value.behavior?.api&&d.value.behavior?.button?(e.openBlock(),e.createBlock(Yh,e.mergeProps({key:0},d.value.behavior,{value:r.value}),null,16,["value"])):e.createCommentVNode("",!0)],2)]),_:1},8,["ua","error","item","columns","label"]))}}),ng={class:"text-sm text-gray-800 mb-[4px] font-medium dark:text-neutral-300"},og={class:"vs-compact-form-navigation__rail mt-[6px]"},rg=["onClick"],lg=Ce(e.defineComponent({__name:"vs-compact-form-navigation",props:{target:{},scrollContainer:{},title:{default:"Навігація"},enabled:{type:Boolean,default:!0},width:{default:400}},setup(o,{expose:t}){const n=o,r=e.ref([]),a=e.ref(""),l=e.ref(""),s=e.computed(()=>!!n.enabled),c=e.computed(()=>["vs-compact-form-navigation flex flex-col pl-[6px] pt-[8px] pr-[8px]","sticky top-0 self-start shrink-0","max-h-full min-h-0 overflow-y-auto"]),i=e.computed(()=>{const T=n.width;if(T==null)return{};const j=typeof T=="number"?`${T}px`:`${T}`;return{width:j,minWidth:j}});let d=null,h=0,g=0,p=null,f=null,m=null;const k=()=>V(),b=()=>C();e.watch(()=>n.target,async T=>{if(G(),!T){p=null,r.value=[],a.value="";return}p=T,s.value&&(await e.nextTick(),q(T),C())},{immediate:!0}),e.watch(()=>n.scrollContainer,T=>{if(!s.value){f=T??null;return}_(T??null),e.nextTick(()=>C())},{immediate:!0}),e.onMounted(()=>{n.scrollContainer||_(null),C()}),e.onBeforeUnmount(()=>{G(),_(null,!0),p=null,typeof window<"u"&&(h&&window.cancelAnimationFrame(h),g&&window.cancelAnimationFrame(g))});function _(T,j=!1){if(m&&(m(),m=null),j){f=null;return}if(f=T??null,typeof window>"u")return;const te=T??window,D=window;te.addEventListener("scroll",k,{passive:!0}),D.addEventListener("resize",b),m=()=>{te.removeEventListener("scroll",k),D.removeEventListener("resize",b)}}function C(){if(!s.value||!p)return;h&&typeof window<"u"&&window.cancelAnimationFrame(h);const T=()=>{N(),h=0};typeof window>"u"?T():h=window.requestAnimationFrame(T)}function N(){if(!s.value||!p)return;const T=Array.from(p.querySelectorAll("h1, h2")),j=new Set,te=[];T.forEach((D,U)=>{const oe=D.textContent?.trim()??"";if(!oe)return;let R=(D.getAttribute("id")??"").trim();R||(R=$(oe)||`heading-${U+1}`);let H=R,Z=1;for(;j.has(H);)H=`${R}-${Z+=1}`;D.id!==H&&Object.assign(D,{id:H}),j.add(H),te.push({id:H,text:oe,level:D.tagName.toLowerCase()==="h1"?1:2})}),r.value=te,te.length||(a.value=""),E()}function $(T){return T.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-")}function q(T){!T||!s.value||typeof MutationObserver>"u"||(G(),d=new MutationObserver(()=>C()),d.observe(T,{childList:!0,subtree:!0}))}function G(){d&&(d.disconnect(),d=null)}function I(T){const j=f;if(!j)return typeof window>"u"?T.offsetTop:T.getBoundingClientRect().top+window.scrollY;const te=T.getBoundingClientRect(),D=j.getBoundingClientRect();return te.top-D.top+j.scrollTop}function E(){if(!s.value||!r.value.length)return;const T=f,j=(T?T.scrollTop:null)||(typeof window<"u"?window.scrollY:0),te=(T?T.clientHeight:null)||(typeof window<"u"?window.innerHeight:0),D=j+te;let U=null;for(let R=0;R<r.value.length;R+=1){const H=r.value[R],Z=document.getElementById(H.id);if(Z){const ae=I(Z);ae+Z.offsetHeight>j&&ae<D&&(U=H.id)}}!U&&l.value&&(U=l.value),U&&(l.value=U);const oe=T?T.scrollHeight-T.clientHeight:document.documentElement.scrollHeight-window.innerHeight;j+5>=oe&&(U=r.value[r.value.length-1].id),U&&(a.value=U)}function V(){s.value&&(g&&window.cancelAnimationFrame(g),g=window.requestAnimationFrame(()=>{E(),g=0}))}function v(T){if(!s.value)return;const j=document.getElementById(T);if(!j)return;const te=f,D=Math.max(0,I(j));te?te.scrollTo({top:D,behavior:"smooth"}):typeof window<"u"&&window.scrollTo({top:D,behavior:"smooth"})}return t({refresh:C}),(T,j)=>s.value&&r.value.length?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(c.value),style:e.normalizeStyle(i.value)},[e.createElementVNode("h2",ng,e.toDisplayString(T.title),1),e.createElementVNode("div",og,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,te=>(e.openBlock(),e.createElementBlock("div",{key:te.id,class:e.normalizeClass(["vs-compact-form-navigation__item relative",te.level===2?"vs-compact-form-navigation__item--nested":"",te.id===a.value?"vs-compact-form-navigation__item--active":""])},[e.createElementVNode("button",{type:"button",onClick:D=>v(te.id),class:e.normalizeClass(["vs-compact-form-navigation__button flex gap-x-3 py-[6px] pr-3 text-sm duration-200 hover:text-gray-800",te.level===2?"pl-[15px]":"pl-[18px]",te.id===a.value?"text-gray-800":"text-gray-500"])},[e.createElementVNode("span",null,e.toDisplayString(te.text),1)],10,rg)],2))),128))])],6)):e.createCommentVNode("",!0)}}),[["__scopeId","data-v-1584a562"]]),dt={required:"Це поле є обов’язковим",email:"Неправильний email",tel:"Неправильний телефон",minlength:o=>`Мінімальна довжина — ${o} символів`,maxlength:o=>`Максимальна довжина — ${o} символів`,min:o=>`Значення має бути не менше ${o}`,max:o=>`Значення має бути не більше ${o}`},ag=new Set(["select","inline-select","array-select"]),sg=(o,t)=>typeof o=="string"?o.trim()?!1:dt.required:Array.isArray(o)?o.map(r=>typeof r=="string"?r.trim():r).filter(r=>r!=null&&r!=="").length?!1:dt.required:typeof o=="number"?Number?.isNaN(o)?dt?.required:!1:typeof o=="boolean"?t&&ag.has(t)||o?!1:dt.required:o?!1:dt.required,ig=o=>{const t=/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/;return o?t.test(o)?!1:dt.email:!1},cg=(o,t)=>{if(!o)return!1;const n=String(o).trim();if(!/^\+[1-9]\d{1,14}$/.test(n))return dt.tel;const l=(typeof t?.digits=="number"&&Number.isFinite(t.digits)&&t.digits>0?t.digits:Tt(Et))||Tt(Et);return n.length-1!==l?dt.tel:!1},el=o=>o==null?0:typeof o=="string"?o.trim().length:Array.isArray(o)?o.length:typeof o=="number"?o.toString().length:String(o).length,dg=(o,t)=>{if(o==null)return!1;const n=Number(t?.value??t?.length);return Number.isFinite(n)&&el(o)<n?t?.message||dt.minlength(n):!1},ug=(o,t)=>{if(o==null||o==="")return!1;const n=Number(t?.value??t?.length);return Number.isFinite(n)&&el(o)>n?t?.message||dt.maxlength(n):!1},Gn=o=>{if(typeof o=="number")return o;if(typeof o=="string"){const t=o.trim().replace(",",".");return t?Number(t):Number.NaN}return Number(o)},pg=(o,t)=>{if(o==null||o==="")return!1;const n=Number(t?.value);if(!Number.isFinite(n))return!1;const r=Gn(o);return Number.isFinite(r)&&r<n?t?.message||dt.min(n):!1},mg=(o,t)=>{if(o==null||o==="")return!1;const n=Number(t?.value);if(!Number.isFinite(n))return!1;const r=Gn(o);return Number.isFinite(r)&&r>n?t?.message||dt.max(n):!1},fg=(o,t,n)=>{if(o==null||o==="")return!1;const r=t?.field;if(!r||!n)return!1;const a=n[r];if(a==null||a==="")return!1;const l=Gn(o),s=Gn(a);return!Number.isFinite(l)||!Number.isFinite(s)?!1:l>s?t?.message||`Значення має бути не більше ${s}`:!1},hg=(o,t)=>{const n=t.pattern??t.regexp,r=typeof n=="string"?new RegExp(n):n;if(Array.isArray(o)){const a=o.filter(Boolean);return a.length===0||a.every(l=>r.test(l))?!1:t.message}return!r.test(o)&&o?t.message:!1},gg=(o,t)=>!1,yg=(o,t,n,r)=>{switch(typeof t=="string"?t:t.type){case"required":return sg(o,r);case"email":return ig(o);case"tel":return cg(o,typeof t=="object"?t:void 0);case"regexp":return hg(o,t);case"minlength":return dg(o,t);case"maxlength":return ug(o,t);case"min":return pg(o,t);case"max":return mg(o,t);case"maxField":return fg(o,t,n);case"custom":return gg();default:return!1}},bg={autocomplete:"select",combobox:"select",datepicker:"date",markedtext:"mask",html:"static",geom:"map",filelist:"file-list",file:"file",file64:"file64",dropzone:"file",inlineselect:"inline-select"};function tl(o){const t=o?.toLowerCase();return bg[t]||t}function Mo(o,t=!1){if(Array.isArray(o)){const r=[];return o.forEach(a=>{const l={...a};if(l.name=(a.name||a.id||a.key||"").toString(),l.type=tl(a.type),l.label=a.label||a.ua,l.rules=a.rules||a.validators,l.type==="email"&&!l.rules&&(l.rules=["email"]),l.type==="tel"&&!l.rules){const s=l.mask||Et,c=Tt(s)||Tt(Et);l.rules=[{type:"tel",digits:c}]}a.data&&(l.api=`/api/suggest/${a.data}`),l.disabled=l.disabled??t,Array.isArray(l.schema)&&(l.schema=Mo(l.schema,l.disabled)),r.push(l)}),r}const n=[];return Object.entries(o).forEach(r=>{const a={name:r[0],...r[1],type:tl(r[1].type),label:r[1].label||r[1].ua,rules:r[1].rules||r[1].validators,disabled:r[1].disabled??t};if(a.type==="email"&&!a.rules&&(a.rules=["email"]),a.type==="tel"&&!a.rules){const l=a.mask||Et,s=Tt(l)||Tt(Et);a.rules=[{type:"tel",digits:s}]}r[1].type?.includes("list")&&(a.multiple=!0),!a.api&&r[1].data&&(a.api=`/api/suggest/${r[1].data}`),Array.isArray(a.schema)&&(a.schema=Mo(a.schema,a.disabled)),n.push(a)}),n}function kg(o,t,n=!1){const r=e.computed(()=>Mo((Array.isArray(t),t),typeof n=="boolean"?n:n.value)),a=e.ref({});function l(p){return Br(o?.value,p?.conditions)}const s=new Set(["maxField"]);function c(p){return typeof p.maxField=="string"&&p.maxField?!0:(p.rules||[]).some(f=>{const m=typeof f=="string"?f:f.type;return m?s.has(m):!1})}function i(p){const f=[],m=Number(p?.minlength),k=Number(p?.maxlength),b=Number(p?.min),_=Number(p?.max);!Number.isNaN(m)&&Number.isFinite(m)&&f.push({type:"minlength",value:m}),!Number.isNaN(k)&&Number.isFinite(k)&&f.push({type:"maxlength",value:k}),!Number.isNaN(b)&&Number.isFinite(b)&&f.push({type:"min",value:b}),!Number.isNaN(_)&&Number.isFinite(_)&&f.push({type:"max",value:_}),typeof p?.maxField=="string"&&p.maxField&&f.push({type:"maxField",field:p.maxField,message:p.maxFieldMessage});const C=[...f,...p.rules||[]];if(!C.length)return;if(!l(p)){delete a.value[p.name];return}let N=!1,$=null;C.forEach(q=>{const G=yg(o.value[p.name],q,o.value,p.type);G&&(N=!0,!$&&typeof G=="string"&&($=G))}),N&&$?a.value[p.name]=$:delete a.value[p.name]}const d=(p=r.value,f=!0)=>(p.forEach(m=>{i(m),m.schema&&d(m.schema,!1)}),f&&Object.values(a.value).some(Boolean)?a.value:null);e.watch(o,()=>{const p=[],f=m=>{m.forEach(k=>{c(k)&&p.push(k),k.schema&&f(k.schema)})};f(r.value),p.forEach(i)},{deep:!0});const h=e.computed(()=>r.value?.filter(p=>p.hidden!==!0&&l(p)));return{errors:a,validate:d,reset:()=>{o.value={},a.value={}},visibleSchema:h}}const wg={class:"flex w-full h-full min-h-0 gap-6"},xg={key:0,"data-orientation":"horizontal",role:"none",class:"mt-1 shrink-0 h-[1px] w-full bg-slate-100 dark:bg-slate-600"},ot=e.defineComponent({__name:"vs-compact-form",props:e.mergeModels({schema:{default:()=>[]},style:{default:()=>({})},modelValue:{},layout:{default:()=>"default"},formId:{default:()=>""},allowIdField:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},navigation:{type:Boolean,default:!1},navWidth:{default:400},columns:{}},{form:{default:()=>({})},formModifiers:{},modelValue:{default:()=>({})},modelModifiers:{},values:{default:void 0},valuesModifiers:{}}),emits:e.mergeModels(["handle-submit","update:modelValue","value-selected"],["update:form","update:modelValue","update:values"]),setup(o,{expose:t,emit:n}){const r=n,a=o,l=e.computed(()=>!!a.formId||a.allowIdField),s=e.useModel(o,"form"),c=e.useModel(o,"modelValue"),i=e.useModel(o,"values"),d=e.computed({get:()=>i.value??c.value,set:R=>{c.value=R,i.value=R}}),{errors:h,validate:g,reset:p,visibleSchema:f}=kg(d,a.schema,e.toRef(a,"disabled")),m=e.ref(null),k=e.ref(null),b=e.ref({}),_=e.computed(()=>a.navigation),C=e.computed(()=>a.navWidth),N=e.computed(()=>a.style?.columns),$=Object.freeze({container:12,label:3}),q=e.computed(()=>a.columns??N.value??$),G=e.computed(()=>a.columns!=null||N.value!=null),I=e.computed(()=>G.value?"horizontal":a.layout),E=R=>R?.columns?"horizontal":I.value,V=R=>R?.columns??q.value,v=e.computed(()=>{const R={},H=Z=>{if(!Z)return;(Array.isArray(Z)?Z.map((O,A)=>({key:String(A),entry:O})):typeof Z=="object"?Object.entries(Z).map(([O,A])=>({key:O,entry:A})):[]).forEach(({key:O,entry:A})=>{if(!A||typeof A!="object")return;const M=A.name?String(A.name):O;M&&(R[M]={...A,name:M}),Array.isArray(A.schema)&&H(A.schema)})};return H(a.schema),R}),T=()=>{!l.value&&d.value&&delete d.value.id,r("update:modelValue",d.value),g(),r("handle-submit",d.value)},j=R=>{r("value-selected",R)};t({validate:g,reset:p,errors:h}),e.onMounted(()=>{s.value={value:d.value,errors:h.value,reset:p,validate:g,formId:a.formId}});function te(R,H){if(R===H)return!0;if(typeof R!="object"||typeof H!="object"||!R||!H)return!1;const Z=Object.keys(R),ae=Object.keys(H);return Z.length!==ae.length?!1:Z.every(O=>R[O]===H[O])}function D(R){return Array.isArray(R)?[...R]:R&&typeof R=="object"?{...R}:R}function U(R){Array.isArray(R)&&R.forEach(H=>{if(!H)return;const Z=H.name,ae=H.default!==void 0;Z&&ae&&d.value[Z]===void 0&&(d.value[Z]=D(H.default)),Array.isArray(H.schema)&&U(H.schema)})}return e.watch(f,R=>{U(R)},{immediate:!0,deep:!0}),e.provide("form",s),e.provide("values",d),e.inject("form-root-values",null)||e.provide("form-root-values",d),e.provide("field-props",b),e.provide("schema-by-name",v),(R,H)=>(e.openBlock(),e.createElementBlock("div",wg,[e.createElementVNode("div",{class:"flex-1 min-h-0 overflow-y-auto overflow-x-visible",ref_key:"formScrollContainer",ref:k},[e.createElementVNode("form",{ref_key:"formRef",ref:m,onSubmit:e.withModifiers(T,["prevent"]),class:e.normalizeClass(["grid grid-cols-12 p-1",I.value==="default"?"gap-6":"gap-4"])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(f),(Z,ae)=>(e.openBlock(),e.createElementBlock("div",{key:Z.name,class:e.normalizeClass(E(Z)==="horizontal"?"col-span-12":`col-span-12 md:col-span-${Z.col||12}`)},[e.createVNode(Qr,{style:e.normalizeStyle(R.style),item:Z,layout:E(Z),columns:V(Z),"model-value":d.value[Z.name],"onUpdate:modelValue":O=>{if(Z.name==="id"&&!l.value)return;const A=d.value[Z.name];te(A,O)||(d.value[Z.name]=O)},error:e.unref(h)[Z.name],onValueSelected:j},null,8,["style","item","layout","columns","model-value","onUpdate:modelValue","error"]),E(Z)==="settings"&&ae+1!==e.unref(f).length?(e.openBlock(),e.createElementBlock("div",xg)):e.createCommentVNode("",!0)],2))),128))],34)],512),e.createVNode(lg,{target:m.value,"scroll-container":k.value,enabled:_.value,width:C.value},null,8,["target","scroll-container","enabled","width"])]))}}),vg={class:"relative"},_g={class:"w-full h-full fixed top-0 start-0 bg-black bg-opacity-50"},Cg={class:"m-[10px] fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 min-h-0 h-fit max-h-[80vh] overflow-hidden opacity-1 flex flex-col bg-white dark:bg-[#1A1A1A] border dark:border-[#454545] pointer-events-auto shadow-[0_10px_40px_10px_rgba(0,0,0,0.08)] rounded-xl lg:w-7/12 w-11/12"},Eg={class:"py-2.5 px-4 flex justify-between items-center border-0 border-b border-solid border-gray-200 dark:border-b-[#454545]"},Bg={class:"font-medium text-gray-800 dark:text-[#ffffff]"},Vg={class:"p-4 mim-h-0 h-full overflow-auto"},nl=e.defineComponent({__name:"modal-edit",props:{schema:{},defaultValue:{},mode:{},token:{},form:{},api:{},method:{}},emits:["close","save","edit"],setup(o,{emit:t}){const n=o,r=t,a=e.ref(n.schema),l=e.ref(n.defaultValue?JSON.parse(JSON.stringify(n.defaultValue)):{}),s=e.ref({}),c=e.ref(n.token||""),i=e.ref(n.token||""),d=e.ref(n.mode),h=()=>{const b=n.method?.trim().toUpperCase();return b==="GET"||b==="POST"||b==="PUT"?b:d.value==="add"?"POST":"PUT"},g=()=>{he.notify({type:"success",title:"Успішно",message:`Дані успішно ${d.value==="add"?"збережено":"оновлено"}`})},p=b=>{const _={};b.id!==void 0&&b.id!==null&&(_.id=b.id,i.value=b.id.toString()),b.obj&&typeof b.obj=="object"&&Object.assign(_,b.obj),Object.keys(_).length&&(l.value={...l.value,..._})},f=async b=>{if(console.log(b),b.ok){await b.json().catch(()=>({})),g(),r("save",l.value);return}const _=await b.json().catch(()=>({})),C=_.message||_.error;if(b.status===400){he.notify({type:"warning",title:"Помилка валідації",message:C||"Некоректні дані (400)"});return}if(b.status===403){he.notify({type:"warning",title:"Доступ заборонено",message:C||"Доступ заборонено (403)"});return}if(b.status===500){he.notify({type:"error",title:"Серверна помилка",message:C||"Виникла помилка на сервері (500)"});return}he.notify({type:"error",title:"Помилка",message:C||`Статус: ${b.status}`})};async function m(){const b=s.value.validate();if(b){he.notify({type:"warning",title:"Помилка валідації",message:Object.entries(b).map(([C,N])=>`${C}: ${N}`).join(`
5
- `)});return}d.value==="add"&&l.value&&delete l.value.id;const _=n.api?.trim();if(_){const C=h();try{const N=await fetch(_,{method:C,headers:C==="GET"?void 0:{"Content-Type":"application/json"},body:C==="GET"?void 0:JSON.stringify(l.value)});await f(N)}catch(N){he.notify({type:"error",title:"Помилка з’єднання",message:N.message||"Не вдалося виконати запит"})}return}if(c.value)try{const C=await fetch(`/api/table/${c.value}`,{method:d.value==="add"?"POST":"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(l.value)});await f(C)}catch(C){he.notify({type:"error",title:"Помилка з’єднання",message:C.message||"Не вдалося виконати запит"})}else r("edit",l.value),k()}function k(){r("close")}return e.onMounted(async()=>{try{if(n.form&&!n.schema){const b=await fetch(`/api/template/form/${n.form}`);if(!b.ok){he.notify({type:b.status>=400&&b.status<500?"warning":"error",title:"Error",message:`Error code: ${b.status}`});return}const _=await b.json();a.value=_.schema,_.id&&(i.value=_.id),_.token&&(c.value=_.token,i.value||(i.value=_.token))}else if(n.token&&!n.defaultValue){c.value=n.token;const b=await fetch(`/api/form/${c.value}`);if(!b.ok){he.notify({type:b.status>=400&&b.status<500?"warning":"error",title:"Error",message:`Error code: ${b.status}`});return}const _=await b.json();a.value=_.schema,_.data?l.value=_.data:d.value="add",p({id:_.id,obj:_.obj})}}catch(b){he.notify({type:"error",title:"Error",message:b.message||"Unexpected error"}),console.error(b)}}),(b,_)=>(e.openBlock(),e.createElementBlock("div",vg,[e.createElementVNode("div",_g,[e.createElementVNode("div",Cg,[e.createElementVNode("div",Eg,[e.createElementVNode("h3",Bg,e.toDisplayString(d.value==="add"?"Додати":"Змінити"),1),e.createElementVNode("button",{onClick:k,type:"button",class:"size-8 inline-flex justify-center items-center gap-x-2 rounded-full border border-transparent bg-gray-100 text-gray-800 hover:bg-gray-200 focus:outline-none focus:bg-gray-200 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-700 dark:hover:bg-neutral-600 dark:text-neutral-400 dark:focus:bg-neutral-600"},[_[2]||(_[2]=e.createElementVNode("span",{class:"sr-only"},"Close",-1)),e.createVNode(e.unref(X.X),{class:"h-4 w-4 flex-shrink-0"})])]),e.createElementVNode("div",Vg,[a.value?(e.openBlock(),e.createBlock(ot,{key:0,schema:a.value,values:l.value,"onUpdate:values":_[0]||(_[0]=C=>l.value=C),form:s.value,"onUpdate:form":_[1]||(_[1]=C=>s.value=C),formId:i.value},null,8,["schema","values","form","formId"])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:"vs-form__head mr-5 mb-5 mt-3 flex items-center justify-end sticky top-0 left-0 z-[60] bg-white"},[e.createElementVNode("button",{type:"button",onClick:k,class:"vs-button inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border !border-gray-200 hover:text-white bg-white text-red-500 hover:border-red-500 hover:bg-red-500 focus:ring-red-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1 mr-2"}," Скасувати "),e.createElementVNode("button",{onClick:m,type:"button",class:"vs-button inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border-1 border-transparent text-white bg-blue-500 hover:bg-blue-600 focus:ring-blue-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1"}," Зберегти ")])])])]))}}),ol=ao.form.richtext,rl=so.form.richtext,Fo={en:{form:{richtext:ol}},uk:{form:{richtext:rl}}},ll=(o={mode:"edit",schema:null})=>new Promise(t=>{const{close:n}=he.modal({title:o.mode==="add"?"Додати":"Редагувати",template:"",visible:!0,size:"medium",closeClickBack:!0,content:nl,contentProps:{...o,onClose:()=>{t(null),n()},onSave:r=>{t(r),n()}}})});ot.install=function(t){t.component("VForm",ot),Object.assign(t.config.globalProperties,{$form:ll}),t.provide("form",ll),window.v3plugin||(window.v3plugin={})};function Lt(o){return typeof o=="string"||o instanceof String}function al(o){var t;return typeof o=="object"&&o!=null&&(o==null||(t=o.constructor)==null?void 0:t.name)==="Object"}function sl(o,t){return Array.isArray(t)?sl(o,(n,r)=>t.includes(r)):Object.entries(o).reduce((n,r)=>{let[a,l]=r;return t(l,a)&&(n[a]=l),n},{})}const ye={NONE:"NONE",LEFT:"LEFT",FORCE_LEFT:"FORCE_LEFT",RIGHT:"RIGHT",FORCE_RIGHT:"FORCE_RIGHT"};function il(o){switch(o){case ye.LEFT:return ye.FORCE_LEFT;case ye.RIGHT:return ye.FORCE_RIGHT;default:return o}}function Do(o){return o.replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1")}function Yn(o,t){if(t===o)return!0;const n=Array.isArray(t),r=Array.isArray(o);let a;if(n&&r){if(t.length!=o.length)return!1;for(a=0;a<t.length;a++)if(!Yn(t[a],o[a]))return!1;return!0}if(n!=r)return!1;if(t&&o&&typeof t=="object"&&typeof o=="object"){const l=t instanceof Date,s=o instanceof Date;if(l&&s)return t.getTime()==o.getTime();if(l!=s)return!1;const c=t instanceof RegExp,i=o instanceof RegExp;if(c&&i)return t.toString()==o.toString();if(c!=i)return!1;const d=Object.keys(t);for(a=0;a<d.length;a++)if(!Object.prototype.hasOwnProperty.call(o,d[a]))return!1;for(a=0;a<d.length;a++)if(!Yn(o[d[a]],t[d[a]]))return!1;return!0}else if(t&&o&&typeof t=="function"&&typeof o=="function")return t.toString()===o.toString();return!1}class Sg{constructor(t){for(Object.assign(this,t);this.value.slice(0,this.startChangePos)!==this.oldValue.slice(0,this.startChangePos);)--this.oldSelection.start;if(this.insertedCount)for(;this.value.slice(this.cursorPos)!==this.oldValue.slice(this.oldSelection.end);)this.value.length-this.cursorPos<this.oldValue.length-this.oldSelection.end?++this.oldSelection.end:++this.cursorPos}get startChangePos(){return Math.min(this.cursorPos,this.oldSelection.start)}get insertedCount(){return this.cursorPos-this.startChangePos}get inserted(){return this.value.substr(this.startChangePos,this.insertedCount)}get removedCount(){return Math.max(this.oldSelection.end-this.startChangePos||this.oldValue.length-this.value.length,0)}get removed(){return this.oldValue.substr(this.startChangePos,this.removedCount)}get head(){return this.value.substring(0,this.startChangePos)}get tail(){return this.value.substring(this.startChangePos+this.insertedCount)}get removeDirection(){return!this.removedCount||this.insertedCount?ye.NONE:(this.oldSelection.end===this.cursorPos||this.oldSelection.start===this.cursorPos)&&this.oldSelection.end===this.oldSelection.start?ye.RIGHT:ye.LEFT}}function _e(o,t){return new _e.InputMask(o,t)}function cl(o){if(o==null)throw new Error("mask property should be defined");return o instanceof RegExp?_e.MaskedRegExp:Lt(o)?_e.MaskedPattern:o===Date?_e.MaskedDate:o===Number?_e.MaskedNumber:Array.isArray(o)||o===Array?_e.MaskedDynamic:_e.Masked&&o.prototype instanceof _e.Masked?o:_e.Masked&&o instanceof _e.Masked?o.constructor:o instanceof Function?_e.MaskedFunction:(console.warn("Mask not found for mask",o),_e.Masked)}function Jt(o){if(!o)throw new Error("Options in not defined");if(_e.Masked){if(o.prototype instanceof _e.Masked)return{mask:o};const{mask:t=void 0,...n}=o instanceof _e.Masked?{mask:o}:al(o)&&o.mask instanceof _e.Masked?o:{};if(t){const r=t.mask;return{...sl(t,(a,l)=>!l.startsWith("_")),mask:t.constructor,_mask:r,...n}}}return al(o)?{...o}:{mask:o}}function yt(o){if(_e.Masked&&o instanceof _e.Masked)return o;const t=Jt(o),n=cl(t.mask);if(!n)throw new Error("Masked class is not found for provided mask "+t.mask+", appropriate module needs to be imported manually before creating mask.");return t.mask===n&&delete t.mask,t._mask&&(t.mask=t._mask,delete t._mask),new n(t)}_e.createMask=yt;class Xn{get selectionStart(){let t;try{t=this._unsafeSelectionStart}catch{}return t??this.value.length}get selectionEnd(){let t;try{t=this._unsafeSelectionEnd}catch{}return t??this.value.length}select(t,n){if(!(t==null||n==null||t===this.selectionStart&&n===this.selectionEnd))try{this._unsafeSelect(t,n)}catch{}}get isActive(){return!1}}_e.MaskElement=Xn;const dl=90,$g=89;class un extends Xn{constructor(t){super(),this.input=t,this._onKeydown=this._onKeydown.bind(this),this._onInput=this._onInput.bind(this),this._onBeforeinput=this._onBeforeinput.bind(this),this._onCompositionEnd=this._onCompositionEnd.bind(this)}get rootElement(){var t,n,r;return(t=(n=(r=this.input).getRootNode)==null?void 0:n.call(r))!=null?t:document}get isActive(){return this.input===this.rootElement.activeElement}bindEvents(t){this.input.addEventListener("keydown",this._onKeydown),this.input.addEventListener("input",this._onInput),this.input.addEventListener("beforeinput",this._onBeforeinput),this.input.addEventListener("compositionend",this._onCompositionEnd),this.input.addEventListener("drop",t.drop),this.input.addEventListener("click",t.click),this.input.addEventListener("focus",t.focus),this.input.addEventListener("blur",t.commit),this._handlers=t}_onKeydown(t){if(this._handlers.redo&&(t.keyCode===dl&&t.shiftKey&&(t.metaKey||t.ctrlKey)||t.keyCode===$g&&t.ctrlKey))return t.preventDefault(),this._handlers.redo(t);if(this._handlers.undo&&t.keyCode===dl&&(t.metaKey||t.ctrlKey))return t.preventDefault(),this._handlers.undo(t);t.isComposing||this._handlers.selectionChange(t)}_onBeforeinput(t){if(t.inputType==="historyUndo"&&this._handlers.undo)return t.preventDefault(),this._handlers.undo(t);if(t.inputType==="historyRedo"&&this._handlers.redo)return t.preventDefault(),this._handlers.redo(t)}_onCompositionEnd(t){this._handlers.input(t)}_onInput(t){t.isComposing||this._handlers.input(t)}unbindEvents(){this.input.removeEventListener("keydown",this._onKeydown),this.input.removeEventListener("input",this._onInput),this.input.removeEventListener("beforeinput",this._onBeforeinput),this.input.removeEventListener("compositionend",this._onCompositionEnd),this.input.removeEventListener("drop",this._handlers.drop),this.input.removeEventListener("click",this._handlers.click),this.input.removeEventListener("focus",this._handlers.focus),this.input.removeEventListener("blur",this._handlers.commit),this._handlers={}}}_e.HTMLMaskElement=un;class ul extends un{constructor(t){super(t),this.input=t}get _unsafeSelectionStart(){return this.input.selectionStart!=null?this.input.selectionStart:this.value.length}get _unsafeSelectionEnd(){return this.input.selectionEnd}_unsafeSelect(t,n){this.input.setSelectionRange(t,n)}get value(){return this.input.value}set value(t){this.input.value=t}}_e.HTMLMaskElement=un;class To extends un{get _unsafeSelectionStart(){const t=this.rootElement,n=t.getSelection&&t.getSelection(),r=n&&n.anchorOffset,a=n&&n.focusOffset;return a==null||r==null||r<a?r:a}get _unsafeSelectionEnd(){const t=this.rootElement,n=t.getSelection&&t.getSelection(),r=n&&n.anchorOffset,a=n&&n.focusOffset;return a==null||r==null||r>a?r:a}_unsafeSelect(t,n){if(!this.rootElement.createRange)return;const r=this.rootElement.createRange();r.setStart(this.input.firstChild||this.input,t),r.setEnd(this.input.lastChild||this.input,n);const a=this.rootElement,l=a.getSelection&&a.getSelection();l&&(l.removeAllRanges(),l.addRange(r))}get value(){return this.input.textContent||""}set value(t){this.input.textContent=t}}_e.HTMLContenteditableMaskElement=To;class Zn{constructor(){this.states=[],this.currentIndex=0}get currentState(){return this.states[this.currentIndex]}get isEmpty(){return this.states.length===0}push(t){this.currentIndex<this.states.length-1&&(this.states.length=this.currentIndex+1),this.states.push(t),this.states.length>Zn.MAX_LENGTH&&this.states.shift(),this.currentIndex=this.states.length-1}go(t){return this.currentIndex=Math.min(Math.max(this.currentIndex+t,0),this.states.length-1),this.currentState}undo(){return this.go(-1)}redo(){return this.go(1)}clear(){this.states.length=0,this.currentIndex=0}}Zn.MAX_LENGTH=100;class pl{constructor(t,n){this.el=t instanceof Xn?t:t.isContentEditable&&t.tagName!=="INPUT"&&t.tagName!=="TEXTAREA"?new To(t):new ul(t),this.masked=yt(n),this._listeners={},this._value="",this._unmaskedValue="",this._rawInputValue="",this.history=new Zn,this._saveSelection=this._saveSelection.bind(this),this._onInput=this._onInput.bind(this),this._onChange=this._onChange.bind(this),this._onDrop=this._onDrop.bind(this),this._onFocus=this._onFocus.bind(this),this._onClick=this._onClick.bind(this),this._onUndo=this._onUndo.bind(this),this._onRedo=this._onRedo.bind(this),this.alignCursor=this.alignCursor.bind(this),this.alignCursorFriendly=this.alignCursorFriendly.bind(this),this._bindEvents(),this.updateValue(),this._onChange()}maskEquals(t){var n;return t==null||((n=this.masked)==null?void 0:n.maskEquals(t))}get mask(){return this.masked.mask}set mask(t){if(this.maskEquals(t))return;if(!(t instanceof _e.Masked)&&this.masked.constructor===cl(t)){this.masked.updateOptions({mask:t});return}const n=t instanceof _e.Masked?t:yt({mask:t});n.unmaskedValue=this.masked.unmaskedValue,this.masked=n}get value(){return this._value}set value(t){this.value!==t&&(this.masked.value=t,this.updateControl("auto"))}get unmaskedValue(){return this._unmaskedValue}set unmaskedValue(t){this.unmaskedValue!==t&&(this.masked.unmaskedValue=t,this.updateControl("auto"))}get rawInputValue(){return this._rawInputValue}set rawInputValue(t){this.rawInputValue!==t&&(this.masked.rawInputValue=t,this.updateControl(),this.alignCursor())}get typedValue(){return this.masked.typedValue}set typedValue(t){this.masked.typedValueEquals(t)||(this.masked.typedValue=t,this.updateControl("auto"))}get displayValue(){return this.masked.displayValue}_bindEvents(){this.el.bindEvents({selectionChange:this._saveSelection,input:this._onInput,drop:this._onDrop,click:this._onClick,focus:this._onFocus,commit:this._onChange,undo:this._onUndo,redo:this._onRedo})}_unbindEvents(){this.el&&this.el.unbindEvents()}_fireEvent(t,n){const r=this._listeners[t];r&&r.forEach(a=>a(n))}get selectionStart(){return this._cursorChanging?this._changingCursorPos:this.el.selectionStart}get cursorPos(){return this._cursorChanging?this._changingCursorPos:this.el.selectionEnd}set cursorPos(t){!this.el||!this.el.isActive||(this.el.select(t,t),this._saveSelection())}_saveSelection(){this.displayValue!==this.el.value&&console.warn("Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly."),this._selection={start:this.selectionStart,end:this.cursorPos}}updateValue(){this.masked.value=this.el.value,this._value=this.masked.value,this._unmaskedValue=this.masked.unmaskedValue,this._rawInputValue=this.masked.rawInputValue}updateControl(t){const n=this.masked.unmaskedValue,r=this.masked.value,a=this.masked.rawInputValue,l=this.displayValue,s=this.unmaskedValue!==n||this.value!==r||this._rawInputValue!==a;this._unmaskedValue=n,this._value=r,this._rawInputValue=a,this.el.value!==l&&(this.el.value=l),t==="auto"?this.alignCursor():t!=null&&(this.cursorPos=t),s&&this._fireChangeEvents(),!this._historyChanging&&(s||this.history.isEmpty)&&this.history.push({unmaskedValue:n,selection:{start:this.selectionStart,end:this.cursorPos}})}updateOptions(t){const{mask:n,...r}=t,a=!this.maskEquals(n),l=this.masked.optionsIsChanged(r);a&&(this.mask=n),l&&this.masked.updateOptions(r),(a||l)&&this.updateControl()}updateCursor(t){t!=null&&(this.cursorPos=t,this._delayUpdateCursor(t))}_delayUpdateCursor(t){this._abortUpdateCursor(),this._changingCursorPos=t,this._cursorChanging=setTimeout(()=>{this.el&&(this.cursorPos=this._changingCursorPos,this._abortUpdateCursor())},10)}_fireChangeEvents(){this._fireEvent("accept",this._inputEvent),this.masked.isComplete&&this._fireEvent("complete",this._inputEvent)}_abortUpdateCursor(){this._cursorChanging&&(clearTimeout(this._cursorChanging),delete this._cursorChanging)}alignCursor(){this.cursorPos=this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos,ye.LEFT))}alignCursorFriendly(){this.selectionStart===this.cursorPos&&this.alignCursor()}on(t,n){return this._listeners[t]||(this._listeners[t]=[]),this._listeners[t].push(n),this}off(t,n){if(!this._listeners[t])return this;if(!n)return delete this._listeners[t],this;const r=this._listeners[t].indexOf(n);return r>=0&&this._listeners[t].splice(r,1),this}_onInput(t){this._inputEvent=t,this._abortUpdateCursor();const n=new Sg({value:this.el.value,cursorPos:this.cursorPos,oldValue:this.displayValue,oldSelection:this._selection}),r=this.masked.rawInputValue,a=this.masked.splice(n.startChangePos,n.removed.length,n.inserted,n.removeDirection,{input:!0,raw:!0}).offset,l=r===this.masked.rawInputValue?n.removeDirection:ye.NONE;let s=this.masked.nearestInputPos(n.startChangePos+a,l);l!==ye.NONE&&(s=this.masked.nearestInputPos(s,ye.NONE)),this.updateControl(s),delete this._inputEvent}_onChange(){this.displayValue!==this.el.value&&this.updateValue(),this.masked.doCommit(),this.updateControl(),this._saveSelection()}_onDrop(t){t.preventDefault(),t.stopPropagation()}_onFocus(t){this.alignCursorFriendly()}_onClick(t){this.alignCursorFriendly()}_onUndo(){this._applyHistoryState(this.history.undo())}_onRedo(){this._applyHistoryState(this.history.redo())}_applyHistoryState(t){t&&(this._historyChanging=!0,this.unmaskedValue=t.unmaskedValue,this.el.select(t.selection.start,t.selection.end),this._saveSelection(),this._historyChanging=!1)}destroy(){this._unbindEvents(),this._listeners.length=0,delete this.el}}_e.InputMask=pl;class Be{static normalize(t){return Array.isArray(t)?t:[t,new Be]}constructor(t){Object.assign(this,{inserted:"",rawInserted:"",tailShift:0,skip:!1},t)}aggregate(t){return this.inserted+=t.inserted,this.rawInserted+=t.rawInserted,this.tailShift+=t.tailShift,this.skip=this.skip||t.skip,this}get offset(){return this.tailShift+this.inserted.length}get consumed(){return!!this.rawInserted||this.skip}equals(t){return this.inserted===t.inserted&&this.tailShift===t.tailShift&&this.rawInserted===t.rawInserted&&this.skip===t.skip}}_e.ChangeDetails=Be;class bt{constructor(t,n,r){t===void 0&&(t=""),n===void 0&&(n=0),this.value=t,this.from=n,this.stop=r}toString(){return this.value}extend(t){this.value+=String(t)}appendTo(t){return t.append(this.toString(),{tail:!0}).aggregate(t._appendPlaceholder())}get state(){return{value:this.value,from:this.from,stop:this.stop}}set state(t){Object.assign(this,t)}unshift(t){if(!this.value.length||t!=null&&this.from>=t)return"";const n=this.value[0];return this.value=this.value.slice(1),n}shift(){if(!this.value.length)return"";const t=this.value[this.value.length-1];return this.value=this.value.slice(0,-1),t}}class Ge{constructor(t){this._value="",this._update({...Ge.DEFAULTS,...t}),this._initialized=!0}updateOptions(t){this.optionsIsChanged(t)&&this.withValueRefresh(this._update.bind(this,t))}_update(t){Object.assign(this,t)}get state(){return{_value:this.value,_rawInputValue:this.rawInputValue}}set state(t){this._value=t._value}reset(){this._value=""}get value(){return this._value}set value(t){this.resolve(t,{input:!0})}resolve(t,n){n===void 0&&(n={input:!0}),this.reset(),this.append(t,n,""),this.doCommit()}get unmaskedValue(){return this.value}set unmaskedValue(t){this.resolve(t,{})}get typedValue(){return this.parse?this.parse(this.value,this):this.unmaskedValue}set typedValue(t){this.format?this.value=this.format(t,this):this.unmaskedValue=String(t)}get rawInputValue(){return this.extractInput(0,this.displayValue.length,{raw:!0})}set rawInputValue(t){this.resolve(t,{raw:!0})}get displayValue(){return this.value}get isComplete(){return!0}get isFilled(){return this.isComplete}nearestInputPos(t,n){return t}totalInputPositions(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),Math.min(this.displayValue.length,n-t)}extractInput(t,n,r){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),this.displayValue.slice(t,n)}extractTail(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),new bt(this.extractInput(t,n),t)}appendTail(t){return Lt(t)&&(t=new bt(String(t))),t.appendTo(this)}_appendCharRaw(t,n){return t?(this._value+=t,new Be({inserted:t,rawInserted:t})):new Be}_appendChar(t,n,r){n===void 0&&(n={});const a=this.state;let l;if([t,l]=this.doPrepareChar(t,n),t&&(l=l.aggregate(this._appendCharRaw(t,n)),!l.rawInserted&&this.autofix==="pad")){const s=this.state;this.state=a;let c=this.pad(n);const i=this._appendCharRaw(t,n);c=c.aggregate(i),i.rawInserted||c.equals(l)?l=c:this.state=s}if(l.inserted){let s,c=this.doValidate(n)!==!1;if(c&&r!=null){const i=this.state;if(this.overwrite===!0){s=r.state;for(let h=0;h<l.rawInserted.length;++h)r.unshift(this.displayValue.length-l.tailShift)}let d=this.appendTail(r);if(c=d.rawInserted.length===r.toString().length,!(c&&d.inserted)&&this.overwrite==="shift"){this.state=i,s=r.state;for(let h=0;h<l.rawInserted.length;++h)r.shift();d=this.appendTail(r),c=d.rawInserted.length===r.toString().length}c&&d.inserted&&(this.state=i)}c||(l=new Be,this.state=a,r&&s&&(r.state=s))}return l}_appendPlaceholder(){return new Be}_appendEager(){return new Be}append(t,n,r){if(!Lt(t))throw new Error("value should be string");const a=Lt(r)?new bt(String(r)):r;n!=null&&n.tail&&(n._beforeTailState=this.state);let l;[t,l]=this.doPrepare(t,n);for(let s=0;s<t.length;++s){const c=this._appendChar(t[s],n,a);if(!c.rawInserted&&!this.doSkipInvalid(t[s],n,a))break;l.aggregate(c)}return(this.eager===!0||this.eager==="append")&&n!=null&&n.input&&t&&l.aggregate(this._appendEager()),a!=null&&(l.tailShift+=this.appendTail(a).tailShift),l}remove(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),this._value=this.displayValue.slice(0,t)+this.displayValue.slice(n),new Be}withValueRefresh(t){if(this._refreshing||!this._initialized)return t();this._refreshing=!0;const n=this.rawInputValue,r=this.value,a=t();return this.rawInputValue=n,this.value&&this.value!==r&&r.indexOf(this.value)===0&&(this.append(r.slice(this.displayValue.length),{},""),this.doCommit()),delete this._refreshing,a}runIsolated(t){if(this._isolated||!this._initialized)return t(this);this._isolated=!0;const n=this.state,r=t(this);return this.state=n,delete this._isolated,r}doSkipInvalid(t,n,r){return!!this.skipInvalid}doPrepare(t,n){return n===void 0&&(n={}),Be.normalize(this.prepare?this.prepare(t,this,n):t)}doPrepareChar(t,n){return n===void 0&&(n={}),Be.normalize(this.prepareChar?this.prepareChar(t,this,n):t)}doValidate(t){return(!this.validate||this.validate(this.value,this,t))&&(!this.parent||this.parent.doValidate(t))}doCommit(){this.commit&&this.commit(this.value,this)}splice(t,n,r,a,l){r===void 0&&(r=""),a===void 0&&(a=ye.NONE),l===void 0&&(l={input:!0});const s=t+n,c=this.extractTail(s),i=this.eager===!0||this.eager==="remove";let d;i&&(a=il(a),d=this.extractInput(0,s,{raw:!0}));let h=t;const g=new Be;if(a!==ye.NONE&&(h=this.nearestInputPos(t,n>1&&t!==0&&!i?ye.NONE:a),g.tailShift=h-t),g.aggregate(this.remove(h)),i&&a!==ye.NONE&&d===this.rawInputValue)if(a===ye.FORCE_LEFT){let p;for(;d===this.rawInputValue&&(p=this.displayValue.length);)g.aggregate(new Be({tailShift:-1})).aggregate(this.remove(p-1))}else a===ye.FORCE_RIGHT&&c.unshift();return g.aggregate(this.append(r,l,c))}maskEquals(t){return this.mask===t}optionsIsChanged(t){return!Yn(this,t)}typedValueEquals(t){const n=this.typedValue;return t===n||Ge.EMPTY_VALUES.includes(t)&&Ge.EMPTY_VALUES.includes(n)||(this.format?this.format(t,this)===this.format(this.typedValue,this):!1)}pad(t){return new Be}}Ge.DEFAULTS={skipInvalid:!0},Ge.EMPTY_VALUES=[void 0,null,""],_e.Masked=Ge;class It{constructor(t,n){t===void 0&&(t=[]),n===void 0&&(n=0),this.chunks=t,this.from=n}toString(){return this.chunks.map(String).join("")}extend(t){if(!String(t))return;t=Lt(t)?new bt(String(t)):t;const n=this.chunks[this.chunks.length-1],r=n&&(n.stop===t.stop||t.stop==null)&&t.from===n.from+n.toString().length;if(t instanceof bt)r?n.extend(t.toString()):this.chunks.push(t);else if(t instanceof It){if(t.stop==null){let a;for(;t.chunks.length&&t.chunks[0].stop==null;)a=t.chunks.shift(),a.from+=t.from,this.extend(a)}t.toString()&&(t.stop=t.blockIndex,this.chunks.push(t))}}appendTo(t){if(!(t instanceof _e.MaskedPattern))return new bt(this.toString()).appendTo(t);const n=new Be;for(let r=0;r<this.chunks.length;++r){const a=this.chunks[r],l=t._mapPosToBlock(t.displayValue.length),s=a.stop;let c;if(s!=null&&(!l||l.index<=s)&&((a instanceof It||t._stops.indexOf(s)>=0)&&n.aggregate(t._appendPlaceholder(s)),c=a instanceof It&&t._blocks[s]),c){const i=c.appendTail(a);n.aggregate(i);const d=a.toString().slice(i.rawInserted.length);d&&n.aggregate(t.append(d,{tail:!0}))}else n.aggregate(t.append(a.toString(),{tail:!0}))}return n}get state(){return{chunks:this.chunks.map(t=>t.state),from:this.from,stop:this.stop,blockIndex:this.blockIndex}}set state(t){const{chunks:n,...r}=t;Object.assign(this,r),this.chunks=n.map(a=>{const l="chunks"in a?new It:new bt;return l.state=a,l})}unshift(t){if(!this.chunks.length||t!=null&&this.from>=t)return"";const n=t!=null?t-this.from:t;let r=0;for(;r<this.chunks.length;){const a=this.chunks[r],l=a.unshift(n);if(a.toString()){if(!l)break;++r}else this.chunks.splice(r,1);if(l)return l}return""}shift(){if(!this.chunks.length)return"";let t=this.chunks.length-1;for(;0<=t;){const n=this.chunks[t],r=n.shift();if(n.toString()){if(!r)break;--t}else this.chunks.splice(t,1);if(r)return r}return""}}class Ag{constructor(t,n){this.masked=t,this._log=[];const{offset:r,index:a}=t._mapPosToBlock(n)||(n<0?{index:0,offset:0}:{index:this.masked._blocks.length,offset:0});this.offset=r,this.index=a,this.ok=!1}get block(){return this.masked._blocks[this.index]}get pos(){return this.masked._blockStartPos(this.index)+this.offset}get state(){return{index:this.index,offset:this.offset,ok:this.ok}}set state(t){Object.assign(this,t)}pushState(){this._log.push(this.state)}popState(){const t=this._log.pop();return t&&(this.state=t),t}bindBlock(){this.block||(this.index<0&&(this.index=0,this.offset=0),this.index>=this.masked._blocks.length&&(this.index=this.masked._blocks.length-1,this.offset=this.block.displayValue.length))}_pushLeft(t){for(this.pushState(),this.bindBlock();0<=this.index;--this.index,this.offset=((n=this.block)==null?void 0:n.displayValue.length)||0){var n;if(t())return this.ok=!0}return this.ok=!1}_pushRight(t){for(this.pushState(),this.bindBlock();this.index<this.masked._blocks.length;++this.index,this.offset=0)if(t())return this.ok=!0;return this.ok=!1}pushLeftBeforeFilled(){return this._pushLeft(()=>{if(!(this.block.isFixed||!this.block.value)&&(this.offset=this.block.nearestInputPos(this.offset,ye.FORCE_LEFT),this.offset!==0))return!0})}pushLeftBeforeInput(){return this._pushLeft(()=>{if(!this.block.isFixed)return this.offset=this.block.nearestInputPos(this.offset,ye.LEFT),!0})}pushLeftBeforeRequired(){return this._pushLeft(()=>{if(!(this.block.isFixed||this.block.isOptional&&!this.block.value))return this.offset=this.block.nearestInputPos(this.offset,ye.LEFT),!0})}pushRightBeforeFilled(){return this._pushRight(()=>{if(!(this.block.isFixed||!this.block.value)&&(this.offset=this.block.nearestInputPos(this.offset,ye.FORCE_RIGHT),this.offset!==this.block.value.length))return!0})}pushRightBeforeInput(){return this._pushRight(()=>{if(!this.block.isFixed)return this.offset=this.block.nearestInputPos(this.offset,ye.NONE),!0})}pushRightBeforeRequired(){return this._pushRight(()=>{if(!(this.block.isFixed||this.block.isOptional&&!this.block.value))return this.offset=this.block.nearestInputPos(this.offset,ye.NONE),!0})}}class Lo{constructor(t){Object.assign(this,t),this._value="",this.isFixed=!0}get value(){return this._value}get unmaskedValue(){return this.isUnmasking?this.value:""}get rawInputValue(){return this._isRawInput?this.value:""}get displayValue(){return this.value}reset(){this._isRawInput=!1,this._value=""}remove(t,n){return t===void 0&&(t=0),n===void 0&&(n=this._value.length),this._value=this._value.slice(0,t)+this._value.slice(n),this._value||(this._isRawInput=!1),new Be}nearestInputPos(t,n){n===void 0&&(n=ye.NONE);const r=0,a=this._value.length;switch(n){case ye.LEFT:case ye.FORCE_LEFT:return r;case ye.NONE:case ye.RIGHT:case ye.FORCE_RIGHT:default:return a}}totalInputPositions(t,n){return t===void 0&&(t=0),n===void 0&&(n=this._value.length),this._isRawInput?n-t:0}extractInput(t,n,r){return t===void 0&&(t=0),n===void 0&&(n=this._value.length),r===void 0&&(r={}),r.raw&&this._isRawInput&&this._value.slice(t,n)||""}get isComplete(){return!0}get isFilled(){return!!this._value}_appendChar(t,n){if(n===void 0&&(n={}),this.isFilled)return new Be;const r=this.eager===!0||this.eager==="append",l=this.char===t&&(this.isUnmasking||n.input||n.raw)&&(!n.raw||!r)&&!n.tail,s=new Be({inserted:this.char,rawInserted:l?this.char:""});return this._value=this.char,this._isRawInput=l&&(n.raw||n.input),s}_appendEager(){return this._appendChar(this.char,{tail:!0})}_appendPlaceholder(){const t=new Be;return this.isFilled||(this._value=t.inserted=this.char),t}extractTail(){return new bt("")}appendTail(t){return Lt(t)&&(t=new bt(String(t))),t.appendTo(this)}append(t,n,r){const a=this._appendChar(t[0],n);return r!=null&&(a.tailShift+=this.appendTail(r).tailShift),a}doCommit(){}get state(){return{_value:this._value,_rawInputValue:this.rawInputValue}}set state(t){this._value=t._value,this._isRawInput=!!t._rawInputValue}pad(t){return this._appendPlaceholder()}}class pn{constructor(t){const{parent:n,isOptional:r,placeholderChar:a,displayChar:l,lazy:s,eager:c,...i}=t;this.masked=yt(i),Object.assign(this,{parent:n,isOptional:r,placeholderChar:a,displayChar:l,lazy:s,eager:c})}reset(){this.isFilled=!1,this.masked.reset()}remove(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.value.length),t===0&&n>=1?(this.isFilled=!1,this.masked.remove(t,n)):new Be}get value(){return this.masked.value||(this.isFilled&&!this.isOptional?this.placeholderChar:"")}get unmaskedValue(){return this.masked.unmaskedValue}get rawInputValue(){return this.masked.rawInputValue}get displayValue(){return this.masked.value&&this.displayChar||this.value}get isComplete(){return!!this.masked.value||this.isOptional}_appendChar(t,n){if(n===void 0&&(n={}),this.isFilled)return new Be;const r=this.masked.state;let a=this.masked._appendChar(t,this.currentMaskFlags(n));return a.inserted&&this.doValidate(n)===!1&&(a=new Be,this.masked.state=r),!a.inserted&&!this.isOptional&&!this.lazy&&!n.input&&(a.inserted=this.placeholderChar),a.skip=!a.inserted&&!this.isOptional,this.isFilled=!!a.inserted,a}append(t,n,r){return this.masked.append(t,this.currentMaskFlags(n),r)}_appendPlaceholder(){return this.isFilled||this.isOptional?new Be:(this.isFilled=!0,new Be({inserted:this.placeholderChar}))}_appendEager(){return new Be}extractTail(t,n){return this.masked.extractTail(t,n)}appendTail(t){return this.masked.appendTail(t)}extractInput(t,n,r){return t===void 0&&(t=0),n===void 0&&(n=this.value.length),this.masked.extractInput(t,n,r)}nearestInputPos(t,n){n===void 0&&(n=ye.NONE);const r=0,a=this.value.length,l=Math.min(Math.max(t,r),a);switch(n){case ye.LEFT:case ye.FORCE_LEFT:return this.isComplete?l:r;case ye.RIGHT:case ye.FORCE_RIGHT:return this.isComplete?l:a;case ye.NONE:default:return l}}totalInputPositions(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.value.length),this.value.slice(t,n).length}doValidate(t){return this.masked.doValidate(this.currentMaskFlags(t))&&(!this.parent||this.parent.doValidate(this.currentMaskFlags(t)))}doCommit(){this.masked.doCommit()}get state(){return{_value:this.value,_rawInputValue:this.rawInputValue,masked:this.masked.state,isFilled:this.isFilled}}set state(t){this.masked.state=t.masked,this.isFilled=t.isFilled}currentMaskFlags(t){var n;return{...t,_beforeTailState:(t==null||(n=t._beforeTailState)==null?void 0:n.masked)||t?._beforeTailState}}pad(t){return new Be}}pn.DEFAULT_DEFINITIONS={0:/\d/,a:/[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,"*":/./};class ml extends Ge{updateOptions(t){super.updateOptions(t)}_update(t){const n=t.mask;n&&(t.validate=r=>r.search(n)>=0),super._update(t)}}_e.MaskedRegExp=ml;class Ye extends Ge{constructor(t){super({...Ye.DEFAULTS,...t,definitions:Object.assign({},pn.DEFAULT_DEFINITIONS,t?.definitions)})}updateOptions(t){super.updateOptions(t)}_update(t){t.definitions=Object.assign({},this.definitions,t.definitions),super._update(t),this._rebuildMask()}_rebuildMask(){const t=this.definitions;this._blocks=[],this.exposeBlock=void 0,this._stops=[],this._maskedBlocks={};const n=this.mask;if(!n||!t)return;let r=!1,a=!1;for(let l=0;l<n.length;++l){if(this.blocks){const d=n.slice(l),h=Object.keys(this.blocks).filter(p=>d.indexOf(p)===0);h.sort((p,f)=>f.length-p.length);const g=h[0];if(g){const{expose:p,repeat:f,...m}=Jt(this.blocks[g]),k={lazy:this.lazy,eager:this.eager,placeholderChar:this.placeholderChar,displayChar:this.displayChar,overwrite:this.overwrite,autofix:this.autofix,...m,repeat:f,parent:this},b=f!=null?new _e.RepeatBlock(k):yt(k);b&&(this._blocks.push(b),p&&(this.exposeBlock=b),this._maskedBlocks[g]||(this._maskedBlocks[g]=[]),this._maskedBlocks[g].push(this._blocks.length-1)),l+=g.length-1;continue}}let s=n[l],c=s in t;if(s===Ye.STOP_CHAR){this._stops.push(this._blocks.length);continue}if(s==="{"||s==="}"){r=!r;continue}if(s==="["||s==="]"){a=!a;continue}if(s===Ye.ESCAPE_CHAR){if(++l,s=n[l],!s)break;c=!1}const i=c?new pn({isOptional:a,lazy:this.lazy,eager:this.eager,placeholderChar:this.placeholderChar,displayChar:this.displayChar,...Jt(t[s]),parent:this}):new Lo({char:s,eager:this.eager,isUnmasking:r});this._blocks.push(i)}}get state(){return{...super.state,_blocks:this._blocks.map(t=>t.state)}}set state(t){if(!t){this.reset();return}const{_blocks:n,...r}=t;this._blocks.forEach((a,l)=>a.state=n[l]),super.state=r}reset(){super.reset(),this._blocks.forEach(t=>t.reset())}get isComplete(){return this.exposeBlock?this.exposeBlock.isComplete:this._blocks.every(t=>t.isComplete)}get isFilled(){return this._blocks.every(t=>t.isFilled)}get isFixed(){return this._blocks.every(t=>t.isFixed)}get isOptional(){return this._blocks.every(t=>t.isOptional)}doCommit(){this._blocks.forEach(t=>t.doCommit()),super.doCommit()}get unmaskedValue(){return this.exposeBlock?this.exposeBlock.unmaskedValue:this._blocks.reduce((t,n)=>t+=n.unmaskedValue,"")}set unmaskedValue(t){if(this.exposeBlock){const n=this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock))+this.exposeBlock.displayValue.length);this.exposeBlock.unmaskedValue=t,this.appendTail(n),this.doCommit()}else super.unmaskedValue=t}get value(){return this.exposeBlock?this.exposeBlock.value:this._blocks.reduce((t,n)=>t+=n.value,"")}set value(t){if(this.exposeBlock){const n=this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock))+this.exposeBlock.displayValue.length);this.exposeBlock.value=t,this.appendTail(n),this.doCommit()}else super.value=t}get typedValue(){return this.exposeBlock?this.exposeBlock.typedValue:super.typedValue}set typedValue(t){if(this.exposeBlock){const n=this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock))+this.exposeBlock.displayValue.length);this.exposeBlock.typedValue=t,this.appendTail(n),this.doCommit()}else super.typedValue=t}get displayValue(){return this._blocks.reduce((t,n)=>t+=n.displayValue,"")}appendTail(t){return super.appendTail(t).aggregate(this._appendPlaceholder())}_appendEager(){var t;const n=new Be;let r=(t=this._mapPosToBlock(this.displayValue.length))==null?void 0:t.index;if(r==null)return n;this._blocks[r].isFilled&&++r;for(let a=r;a<this._blocks.length;++a){const l=this._blocks[a]._appendEager();if(!l.inserted)break;n.aggregate(l)}return n}_appendCharRaw(t,n){n===void 0&&(n={});const r=this._mapPosToBlock(this.displayValue.length),a=new Be;if(!r)return a;for(let s=r.index,c;c=this._blocks[s];++s){var l;const i=c._appendChar(t,{...n,_beforeTailState:(l=n._beforeTailState)==null||(l=l._blocks)==null?void 0:l[s]});if(a.aggregate(i),i.consumed)break}return a}extractTail(t,n){t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length);const r=new It;return t===n||this._forEachBlocksInRange(t,n,(a,l,s,c)=>{const i=a.extractTail(s,c);i.stop=this._findStopBefore(l),i.from=this._blockStartPos(l),i instanceof It&&(i.blockIndex=l),r.extend(i)}),r}extractInput(t,n,r){if(t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),r===void 0&&(r={}),t===n)return"";let a="";return this._forEachBlocksInRange(t,n,(l,s,c,i)=>{a+=l.extractInput(c,i,r)}),a}_findStopBefore(t){let n;for(let r=0;r<this._stops.length;++r){const a=this._stops[r];if(a<=t)n=a;else break}return n}_appendPlaceholder(t){const n=new Be;if(this.lazy&&t==null)return n;const r=this._mapPosToBlock(this.displayValue.length);if(!r)return n;const a=r.index,l=t??this._blocks.length;return this._blocks.slice(a,l).forEach(s=>{if(!s.lazy||t!=null){var c;n.aggregate(s._appendPlaceholder((c=s._blocks)==null?void 0:c.length))}}),n}_mapPosToBlock(t){let n="";for(let r=0;r<this._blocks.length;++r){const a=this._blocks[r],l=n.length;if(n+=a.displayValue,t<=n.length)return{index:r,offset:t-l}}}_blockStartPos(t){return this._blocks.slice(0,t).reduce((n,r)=>n+=r.displayValue.length,0)}_forEachBlocksInRange(t,n,r){n===void 0&&(n=this.displayValue.length);const a=this._mapPosToBlock(t);if(a){const l=this._mapPosToBlock(n),s=l&&a.index===l.index,c=a.offset,i=l&&s?l.offset:this._blocks[a.index].displayValue.length;if(r(this._blocks[a.index],a.index,c,i),l&&!s){for(let d=a.index+1;d<l.index;++d)r(this._blocks[d],d,0,this._blocks[d].displayValue.length);r(this._blocks[l.index],l.index,0,l.offset)}}}remove(t,n){t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length);const r=super.remove(t,n);return this._forEachBlocksInRange(t,n,(a,l,s,c)=>{r.aggregate(a.remove(s,c))}),r}nearestInputPos(t,n){if(n===void 0&&(n=ye.NONE),!this._blocks.length)return 0;const r=new Ag(this,t);if(n===ye.NONE)return r.pushRightBeforeInput()||(r.popState(),r.pushLeftBeforeInput())?r.pos:this.displayValue.length;if(n===ye.LEFT||n===ye.FORCE_LEFT){if(n===ye.LEFT){if(r.pushRightBeforeFilled(),r.ok&&r.pos===t)return t;r.popState()}if(r.pushLeftBeforeInput(),r.pushLeftBeforeRequired(),r.pushLeftBeforeFilled(),n===ye.LEFT){if(r.pushRightBeforeInput(),r.pushRightBeforeRequired(),r.ok&&r.pos<=t||(r.popState(),r.ok&&r.pos<=t))return r.pos;r.popState()}return r.ok?r.pos:n===ye.FORCE_LEFT?0:(r.popState(),r.ok||(r.popState(),r.ok)?r.pos:0)}return n===ye.RIGHT||n===ye.FORCE_RIGHT?(r.pushRightBeforeInput(),r.pushRightBeforeRequired(),r.pushRightBeforeFilled()?r.pos:n===ye.FORCE_RIGHT?this.displayValue.length:(r.popState(),r.ok||(r.popState(),r.ok)?r.pos:this.nearestInputPos(t,ye.LEFT))):t}totalInputPositions(t,n){t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length);let r=0;return this._forEachBlocksInRange(t,n,(a,l,s,c)=>{r+=a.totalInputPositions(s,c)}),r}maskedBlock(t){return this.maskedBlocks(t)[0]}maskedBlocks(t){const n=this._maskedBlocks[t];return n?n.map(r=>this._blocks[r]):[]}pad(t){const n=new Be;return this._forEachBlocksInRange(0,this.displayValue.length,r=>n.aggregate(r.pad(t))),n}}Ye.DEFAULTS={...Ge.DEFAULTS,lazy:!0,placeholderChar:"_"},Ye.STOP_CHAR="`",Ye.ESCAPE_CHAR="\\",Ye.InputDefinition=pn,Ye.FixedDefinition=Lo,_e.MaskedPattern=Ye;class mn extends Ye{get _matchFrom(){return this.maxLength-String(this.from).length}constructor(t){super(t)}updateOptions(t){super.updateOptions(t)}_update(t){const{to:n=this.to||0,from:r=this.from||0,maxLength:a=this.maxLength||0,autofix:l=this.autofix,...s}=t;this.to=n,this.from=r,this.maxLength=Math.max(String(n).length,a),this.autofix=l;const c=String(this.from).padStart(this.maxLength,"0"),i=String(this.to).padStart(this.maxLength,"0");let d=0;for(;d<i.length&&i[d]===c[d];)++d;s.mask=i.slice(0,d).replace(/0/g,"\\0")+"0".repeat(this.maxLength-d),super._update(s)}get isComplete(){return super.isComplete&&!!this.value}boundaries(t){let n="",r="";const[,a,l]=t.match(/^(\D*)(\d*)(\D*)/)||[];return l&&(n="0".repeat(a.length)+l,r="9".repeat(a.length)+l),n=n.padEnd(this.maxLength,"0"),r=r.padEnd(this.maxLength,"9"),[n,r]}doPrepareChar(t,n){n===void 0&&(n={});let r;return[t,r]=super.doPrepareChar(t.replace(/\D/g,""),n),t||(r.skip=!this.isComplete),[t,r]}_appendCharRaw(t,n){if(n===void 0&&(n={}),!this.autofix||this.value.length+1>this.maxLength)return super._appendCharRaw(t,n);const r=String(this.from).padStart(this.maxLength,"0"),a=String(this.to).padStart(this.maxLength,"0"),[l,s]=this.boundaries(this.value+t);return Number(s)<this.from?super._appendCharRaw(r[this.value.length],n):Number(l)>this.to?!n.tail&&this.autofix==="pad"&&this.value.length+1<this.maxLength?super._appendCharRaw(r[this.value.length],n).aggregate(this._appendCharRaw(t,n)):super._appendCharRaw(a[this.value.length],n):super._appendCharRaw(t,n)}doValidate(t){const n=this.value;if(n.search(/[^0]/)===-1&&n.length<=this._matchFrom)return!0;const[a,l]=this.boundaries(n);return this.from<=Number(l)&&Number(a)<=this.to&&super.doValidate(t)}pad(t){const n=new Be;if(this.value.length===this.maxLength)return n;const r=this.value,a=this.maxLength-this.value.length;if(a){this.reset();for(let l=0;l<a;++l)n.aggregate(super._appendCharRaw("0",t));r.split("").forEach(l=>this._appendCharRaw(l))}return n}}_e.MaskedRange=mn;const Ng="d{.}`m{.}`Y";class kt extends Ye{static extractPatternOptions(t){const{mask:n,pattern:r,...a}=t;return{...a,mask:Lt(n)?n:r}}constructor(t){super(kt.extractPatternOptions({...kt.DEFAULTS,...t}))}updateOptions(t){super.updateOptions(t)}_update(t){const{mask:n,pattern:r,blocks:a,...l}={...kt.DEFAULTS,...t},s=Object.assign({},kt.GET_DEFAULT_BLOCKS());t.min&&(s.Y.from=t.min.getFullYear()),t.max&&(s.Y.to=t.max.getFullYear()),t.min&&t.max&&s.Y.from===s.Y.to&&(s.m.from=t.min.getMonth()+1,s.m.to=t.max.getMonth()+1,s.m.from===s.m.to&&(s.d.from=t.min.getDate(),s.d.to=t.max.getDate())),Object.assign(s,this.blocks,a),super._update({...l,mask:Lt(n)?n:r,blocks:s})}doValidate(t){const n=this.date;return super.doValidate(t)&&(!this.isComplete||this.isDateExist(this.value)&&n!=null&&(this.min==null||this.min<=n)&&(this.max==null||n<=this.max))}isDateExist(t){return this.format(this.parse(t,this),this).indexOf(t)>=0}get date(){return this.typedValue}set date(t){this.typedValue=t}get typedValue(){return this.isComplete?super.typedValue:null}set typedValue(t){super.typedValue=t}maskEquals(t){return t===Date||super.maskEquals(t)}optionsIsChanged(t){return super.optionsIsChanged(kt.extractPatternOptions(t))}}kt.GET_DEFAULT_BLOCKS=()=>({d:{mask:mn,from:1,to:31,maxLength:2},m:{mask:mn,from:1,to:12,maxLength:2},Y:{mask:mn,from:1900,to:9999}}),kt.DEFAULTS={...Ye.DEFAULTS,mask:Date,pattern:Ng,format:(o,t)=>{if(!o)return"";const n=String(o.getDate()).padStart(2,"0"),r=String(o.getMonth()+1).padStart(2,"0"),a=o.getFullYear();return[n,r,a].join(".")},parse:(o,t)=>{const[n,r,a]=o.split(".").map(Number);return new Date(a,r-1,n)}},_e.MaskedDate=kt;class fn extends Ge{constructor(t){super({...fn.DEFAULTS,...t}),this.currentMask=void 0}updateOptions(t){super.updateOptions(t)}_update(t){super._update(t),"mask"in t&&(this.exposeMask=void 0,this.compiledMasks=Array.isArray(t.mask)?t.mask.map(n=>{const{expose:r,...a}=Jt(n),l=yt({overwrite:this._overwrite,eager:this._eager,skipInvalid:this._skipInvalid,...a});return r&&(this.exposeMask=l),l}):[])}_appendCharRaw(t,n){n===void 0&&(n={});const r=this._applyDispatch(t,n);return this.currentMask&&r.aggregate(this.currentMask._appendChar(t,this.currentMaskFlags(n))),r}_applyDispatch(t,n,r){t===void 0&&(t=""),n===void 0&&(n={}),r===void 0&&(r="");const a=n.tail&&n._beforeTailState!=null?n._beforeTailState._value:this.value,l=this.rawInputValue,s=n.tail&&n._beforeTailState!=null?n._beforeTailState._rawInputValue:l,c=l.slice(s.length),i=this.currentMask,d=new Be,h=i?.state;return this.currentMask=this.doDispatch(t,{...n},r),this.currentMask&&(this.currentMask!==i?(this.currentMask.reset(),s&&(this.currentMask.append(s,{raw:!0}),d.tailShift=this.currentMask.value.length-a.length),c&&(d.tailShift+=this.currentMask.append(c,{raw:!0,tail:!0}).tailShift)):h&&(this.currentMask.state=h)),d}_appendPlaceholder(){const t=this._applyDispatch();return this.currentMask&&t.aggregate(this.currentMask._appendPlaceholder()),t}_appendEager(){const t=this._applyDispatch();return this.currentMask&&t.aggregate(this.currentMask._appendEager()),t}appendTail(t){const n=new Be;return t&&n.aggregate(this._applyDispatch("",{},t)),n.aggregate(this.currentMask?this.currentMask.appendTail(t):super.appendTail(t))}currentMaskFlags(t){var n,r;return{...t,_beforeTailState:((n=t._beforeTailState)==null?void 0:n.currentMaskRef)===this.currentMask&&((r=t._beforeTailState)==null?void 0:r.currentMask)||t._beforeTailState}}doDispatch(t,n,r){return n===void 0&&(n={}),r===void 0&&(r=""),this.dispatch(t,this,n,r)}doValidate(t){return super.doValidate(t)&&(!this.currentMask||this.currentMask.doValidate(this.currentMaskFlags(t)))}doPrepare(t,n){n===void 0&&(n={});let[r,a]=super.doPrepare(t,n);if(this.currentMask){let l;[r,l]=super.doPrepare(r,this.currentMaskFlags(n)),a=a.aggregate(l)}return[r,a]}doPrepareChar(t,n){n===void 0&&(n={});let[r,a]=super.doPrepareChar(t,n);if(this.currentMask){let l;[r,l]=super.doPrepareChar(r,this.currentMaskFlags(n)),a=a.aggregate(l)}return[r,a]}reset(){var t;(t=this.currentMask)==null||t.reset(),this.compiledMasks.forEach(n=>n.reset())}get value(){return this.exposeMask?this.exposeMask.value:this.currentMask?this.currentMask.value:""}set value(t){this.exposeMask?(this.exposeMask.value=t,this.currentMask=this.exposeMask,this._applyDispatch()):super.value=t}get unmaskedValue(){return this.exposeMask?this.exposeMask.unmaskedValue:this.currentMask?this.currentMask.unmaskedValue:""}set unmaskedValue(t){this.exposeMask?(this.exposeMask.unmaskedValue=t,this.currentMask=this.exposeMask,this._applyDispatch()):super.unmaskedValue=t}get typedValue(){return this.exposeMask?this.exposeMask.typedValue:this.currentMask?this.currentMask.typedValue:""}set typedValue(t){if(this.exposeMask){this.exposeMask.typedValue=t,this.currentMask=this.exposeMask,this._applyDispatch();return}let n=String(t);this.currentMask&&(this.currentMask.typedValue=t,n=this.currentMask.unmaskedValue),this.unmaskedValue=n}get displayValue(){return this.currentMask?this.currentMask.displayValue:""}get isComplete(){var t;return!!((t=this.currentMask)!=null&&t.isComplete)}get isFilled(){var t;return!!((t=this.currentMask)!=null&&t.isFilled)}remove(t,n){const r=new Be;return this.currentMask&&r.aggregate(this.currentMask.remove(t,n)).aggregate(this._applyDispatch()),r}get state(){var t;return{...super.state,_rawInputValue:this.rawInputValue,compiledMasks:this.compiledMasks.map(n=>n.state),currentMaskRef:this.currentMask,currentMask:(t=this.currentMask)==null?void 0:t.state}}set state(t){const{compiledMasks:n,currentMaskRef:r,currentMask:a,...l}=t;n&&this.compiledMasks.forEach((s,c)=>s.state=n[c]),r!=null&&(this.currentMask=r,this.currentMask.state=a),super.state=l}extractInput(t,n,r){return this.currentMask?this.currentMask.extractInput(t,n,r):""}extractTail(t,n){return this.currentMask?this.currentMask.extractTail(t,n):super.extractTail(t,n)}doCommit(){this.currentMask&&this.currentMask.doCommit(),super.doCommit()}nearestInputPos(t,n){return this.currentMask?this.currentMask.nearestInputPos(t,n):super.nearestInputPos(t,n)}get overwrite(){return this.currentMask?this.currentMask.overwrite:this._overwrite}set overwrite(t){this._overwrite=t}get eager(){return this.currentMask?this.currentMask.eager:this._eager}set eager(t){this._eager=t}get skipInvalid(){return this.currentMask?this.currentMask.skipInvalid:this._skipInvalid}set skipInvalid(t){this._skipInvalid=t}get autofix(){return this.currentMask?this.currentMask.autofix:this._autofix}set autofix(t){this._autofix=t}maskEquals(t){return Array.isArray(t)?this.compiledMasks.every((n,r)=>{if(!t[r])return;const{mask:a,...l}=t[r];return Yn(n,l)&&n.maskEquals(a)}):super.maskEquals(t)}typedValueEquals(t){var n;return!!((n=this.currentMask)!=null&&n.typedValueEquals(t))}}fn.DEFAULTS={...Ge.DEFAULTS,dispatch:(o,t,n,r)=>{if(!t.compiledMasks.length)return;const a=t.rawInputValue,l=t.compiledMasks.map((s,c)=>{const i=t.currentMask===s,d=i?s.displayValue.length:s.nearestInputPos(s.displayValue.length,ye.FORCE_LEFT);return s.rawInputValue!==a?(s.reset(),s.append(a,{raw:!0})):i||s.remove(d),s.append(o,t.currentMaskFlags(n)),s.appendTail(r),{index:c,weight:s.rawInputValue.length,totalInputPositions:s.totalInputPositions(0,Math.max(d,s.nearestInputPos(s.displayValue.length,ye.FORCE_LEFT)))}});return l.sort((s,c)=>c.weight-s.weight||c.totalInputPositions-s.totalInputPositions),t.compiledMasks[l[0].index]}},_e.MaskedDynamic=fn;class hn extends Ye{constructor(t){super({...hn.DEFAULTS,...t})}updateOptions(t){super.updateOptions(t)}_update(t){const{enum:n,...r}=t;if(n){const a=n.map(c=>c.length),l=Math.min(...a),s=Math.max(...a)-l;r.mask="*".repeat(l),s&&(r.mask+="["+"*".repeat(s)+"]"),this.enum=n}super._update(r)}_appendCharRaw(t,n){n===void 0&&(n={});const r=Math.min(this.nearestInputPos(0,ye.FORCE_RIGHT),this.value.length),a=this.enum.filter(l=>this.matchValue(l,this.unmaskedValue+t,r));if(a.length){a.length===1&&this._forEachBlocksInRange(0,this.value.length,(s,c)=>{const i=a[0][c];c>=this.value.length||i===s.value||(s.reset(),s._appendChar(i,n))});const l=super._appendCharRaw(a[0][this.value.length],n);return a.length===1&&a[0].slice(this.unmaskedValue.length).split("").forEach(s=>l.aggregate(super._appendCharRaw(s))),l}return new Be({skip:!this.isComplete})}extractTail(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),new bt("",t)}remove(t,n){if(t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),t===n)return new Be;const r=Math.min(super.nearestInputPos(0,ye.FORCE_RIGHT),this.value.length);let a;for(a=t;a>=0&&!(this.enum.filter(c=>this.matchValue(c,this.value.slice(r,a),r)).length>1);--a);const l=super.remove(a,n);return l.tailShift+=a-t,l}get isComplete(){return this.enum.indexOf(this.value)>=0}}hn.DEFAULTS={...Ye.DEFAULTS,matchValue:(o,t,n)=>o.indexOf(t,n)===n},_e.MaskedEnum=hn;class fl extends Ge{updateOptions(t){super.updateOptions(t)}_update(t){super._update({...t,validate:t.mask})}}_e.MaskedFunction=fl;var hl;class et extends Ge{constructor(t){super({...et.DEFAULTS,...t})}updateOptions(t){super.updateOptions(t)}_update(t){super._update(t),this._updateRegExps()}_updateRegExps(){const t="^"+(this.allowNegative?"[+|\\-]?":""),n="\\d*",r=(this.scale?"("+Do(this.radix)+"\\d{0,"+this.scale+"})?":"")+"$";this._numberRegExp=new RegExp(t+n+r),this._mapToRadixRegExp=new RegExp("["+this.mapToRadix.map(Do).join("")+"]","g"),this._thousandsSeparatorRegExp=new RegExp(Do(this.thousandsSeparator),"g")}_removeThousandsSeparators(t){return t.replace(this._thousandsSeparatorRegExp,"")}_insertThousandsSeparators(t){const n=t.split(this.radix);return n[0]=n[0].replace(/\B(?=(\d{3})+(?!\d))/g,this.thousandsSeparator),n.join(this.radix)}doPrepareChar(t,n){n===void 0&&(n={});const[r,a]=super.doPrepareChar(this._removeThousandsSeparators(this.scale&&this.mapToRadix.length&&(n.input&&n.raw||!n.input&&!n.raw)?t.replace(this._mapToRadixRegExp,this.radix):t),n);return t&&!r&&(a.skip=!0),r&&!this.allowPositive&&!this.value&&r!=="-"&&a.aggregate(this._appendChar("-")),[r,a]}_separatorsCount(t,n){n===void 0&&(n=!1);let r=0;for(let a=0;a<t;++a)this._value.indexOf(this.thousandsSeparator,a)===a&&(++r,n&&(t+=this.thousandsSeparator.length));return r}_separatorsCountFromSlice(t){return t===void 0&&(t=this._value),this._separatorsCount(this._removeThousandsSeparators(t).length,!0)}extractInput(t,n,r){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),[t,n]=this._adjustRangeWithSeparators(t,n),this._removeThousandsSeparators(super.extractInput(t,n,r))}_appendCharRaw(t,n){n===void 0&&(n={});const r=n.tail&&n._beforeTailState?n._beforeTailState._value:this._value,a=this._separatorsCountFromSlice(r);this._value=this._removeThousandsSeparators(this.value);const l=this._value;this._value+=t;const s=this.number;let c=!isNaN(s),i=!1;if(c){let p;this.min!=null&&this.min<0&&this.number<this.min&&(p=this.min),this.max!=null&&this.max>0&&this.number>this.max&&(p=this.max),p!=null&&(this.autofix?(this._value=this.format(p,this).replace(et.UNMASKED_RADIX,this.radix),i||(i=l===this._value&&!n.tail)):c=!1),c&&(c=!!this._value.match(this._numberRegExp))}let d;c?d=new Be({inserted:this._value.slice(l.length),rawInserted:i?"":t,skip:i}):(this._value=l,d=new Be),this._value=this._insertThousandsSeparators(this._value);const h=n.tail&&n._beforeTailState?n._beforeTailState._value:this._value,g=this._separatorsCountFromSlice(h);return d.tailShift+=(g-a)*this.thousandsSeparator.length,d}_findSeparatorAround(t){if(this.thousandsSeparator){const n=t-this.thousandsSeparator.length+1,r=this.value.indexOf(this.thousandsSeparator,n);if(r<=t)return r}return-1}_adjustRangeWithSeparators(t,n){const r=this._findSeparatorAround(t);r>=0&&(t=r);const a=this._findSeparatorAround(n);return a>=0&&(n=a+this.thousandsSeparator.length),[t,n]}remove(t,n){t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),[t,n]=this._adjustRangeWithSeparators(t,n);const r=this.value.slice(0,t),a=this.value.slice(n),l=this._separatorsCount(r.length);this._value=this._insertThousandsSeparators(this._removeThousandsSeparators(r+a));const s=this._separatorsCountFromSlice(r);return new Be({tailShift:(s-l)*this.thousandsSeparator.length})}nearestInputPos(t,n){if(!this.thousandsSeparator)return t;switch(n){case ye.NONE:case ye.LEFT:case ye.FORCE_LEFT:{const r=this._findSeparatorAround(t-1);if(r>=0){const a=r+this.thousandsSeparator.length;if(t<a||this.value.length<=a||n===ye.FORCE_LEFT)return r}break}case ye.RIGHT:case ye.FORCE_RIGHT:{const r=this._findSeparatorAround(t);if(r>=0)return r+this.thousandsSeparator.length}}return t}doCommit(){if(this.value){const t=this.number;let n=t;this.min!=null&&(n=Math.max(n,this.min)),this.max!=null&&(n=Math.min(n,this.max)),n!==t&&(this.unmaskedValue=this.format(n,this));let r=this.value;this.normalizeZeros&&(r=this._normalizeZeros(r)),this.padFractionalZeros&&this.scale>0&&(r=this._padFractionalZeros(r)),this._value=r}super.doCommit()}_normalizeZeros(t){const n=this._removeThousandsSeparators(t).split(this.radix);return n[0]=n[0].replace(/^(\D*)(0*)(\d*)/,(r,a,l,s)=>a+s),t.length&&!/\d$/.test(n[0])&&(n[0]=n[0]+"0"),n.length>1&&(n[1]=n[1].replace(/0*$/,""),n[1].length||(n.length=1)),this._insertThousandsSeparators(n.join(this.radix))}_padFractionalZeros(t){if(!t)return t;const n=t.split(this.radix);return n.length<2&&n.push(""),n[1]=n[1].padEnd(this.scale,"0"),n.join(this.radix)}doSkipInvalid(t,n,r){n===void 0&&(n={});const a=this.scale===0&&t!==this.thousandsSeparator&&(t===this.radix||t===et.UNMASKED_RADIX||this.mapToRadix.includes(t));return super.doSkipInvalid(t,n,r)&&!a}get unmaskedValue(){return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix,et.UNMASKED_RADIX)}set unmaskedValue(t){super.unmaskedValue=t}get typedValue(){return this.parse(this.unmaskedValue,this)}set typedValue(t){this.rawInputValue=this.format(t,this).replace(et.UNMASKED_RADIX,this.radix)}get number(){return this.typedValue}set number(t){this.typedValue=t}get allowNegative(){return this.min!=null&&this.min<0||this.max!=null&&this.max<0}get allowPositive(){return this.min!=null&&this.min>0||this.max!=null&&this.max>0}typedValueEquals(t){return(super.typedValueEquals(t)||et.EMPTY_VALUES.includes(t)&&et.EMPTY_VALUES.includes(this.typedValue))&&!(t===0&&this.value==="")}}hl=et,et.UNMASKED_RADIX=".",et.EMPTY_VALUES=[...Ge.EMPTY_VALUES,0],et.DEFAULTS={...Ge.DEFAULTS,mask:Number,radix:",",thousandsSeparator:"",mapToRadix:[hl.UNMASKED_RADIX],min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,scale:2,normalizeZeros:!0,padFractionalZeros:!1,parse:Number,format:o=>o.toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:20})},_e.MaskedNumber=et;const Jn={MASKED:"value",UNMASKED:"unmaskedValue",TYPED:"typedValue"};function Io(o,t,n){t===void 0&&(t=Jn.MASKED),n===void 0&&(n=Jn.MASKED);const r=yt(o);return a=>r.runIsolated(l=>(l[t]=a,l[n]))}function gl(o,t,n,r){return Io(t,n,r)(o)}_e.PIPE_TYPE=Jn,_e.createPipe=Io,_e.pipe=gl;class yl extends Ye{get repeatFrom(){var t;return(t=Array.isArray(this.repeat)?this.repeat[0]:this.repeat===1/0?0:this.repeat)!=null?t:0}get repeatTo(){var t;return(t=Array.isArray(this.repeat)?this.repeat[1]:this.repeat)!=null?t:1/0}constructor(t){super(t)}updateOptions(t){super.updateOptions(t)}_update(t){var n,r,a;const{repeat:l,...s}=Jt(t);this._blockOpts=Object.assign({},this._blockOpts,s);const c=yt(this._blockOpts);this.repeat=(n=(r=l??c.repeat)!=null?r:this.repeat)!=null?n:1/0,super._update({mask:"m".repeat(Math.max(this.repeatTo===1/0&&((a=this._blocks)==null?void 0:a.length)||0,this.repeatFrom)),blocks:{m:c},eager:c.eager,overwrite:c.overwrite,skipInvalid:c.skipInvalid,lazy:c.lazy,placeholderChar:c.placeholderChar,displayChar:c.displayChar})}_allocateBlock(t){if(t<this._blocks.length)return this._blocks[t];if(this.repeatTo===1/0||this._blocks.length<this.repeatTo)return this._blocks.push(yt(this._blockOpts)),this.mask+="m",this._blocks[this._blocks.length-1]}_appendCharRaw(t,n){n===void 0&&(n={});const r=new Be;for(let i=(a=(l=this._mapPosToBlock(this.displayValue.length))==null?void 0:l.index)!=null?a:Math.max(this._blocks.length-1,0),d,h;d=(s=this._blocks[i])!=null?s:h=!h&&this._allocateBlock(i);++i){var a,l,s,c;const g=d._appendChar(t,{...n,_beforeTailState:(c=n._beforeTailState)==null||(c=c._blocks)==null?void 0:c[i]});if(g.skip&&h){this._blocks.pop(),this.mask=this.mask.slice(1);break}if(r.aggregate(g),g.consumed)break}return r}_trimEmptyTail(t,n){var r,a;t===void 0&&(t=0);const l=Math.max(((r=this._mapPosToBlock(t))==null?void 0:r.index)||0,this.repeatFrom,0);let s;n!=null&&(s=(a=this._mapPosToBlock(n))==null?void 0:a.index),s==null&&(s=this._blocks.length-1);let c=0;for(let i=s;l<=i&&!this._blocks[i].unmaskedValue;--i,++c);c&&(this._blocks.splice(s-c+1,c),this.mask=this.mask.slice(c))}reset(){super.reset(),this._trimEmptyTail()}remove(t,n){t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length);const r=super.remove(t,n);return this._trimEmptyTail(t,n),r}totalInputPositions(t,n){return t===void 0&&(t=0),n==null&&this.repeatTo===1/0?1/0:super.totalInputPositions(t,n)}get state(){return super.state}set state(t){this._blocks.length=t._blocks.length,this.mask=this.mask.slice(0,this._blocks.length),super.state=t}}_e.RepeatBlock=yl;try{globalThis.IMask=_e}catch{}const Qn=Object.freeze(Object.defineProperty({__proto__:null,ChangeDetails:Be,ChunksTailDetails:It,DIRECTION:ye,HTMLContenteditableMaskElement:To,HTMLInputMaskElement:ul,HTMLMaskElement:un,InputMask:pl,MaskElement:Xn,Masked:Ge,MaskedDate:kt,MaskedDynamic:fn,MaskedEnum:hn,MaskedFunction:fl,MaskedNumber:et,MaskedPattern:Ye,MaskedRange:mn,MaskedRegExp:ml,PIPE_TYPE:Jn,PatternFixedDefinition:Lo,PatternInputDefinition:pn,RepeatBlock:yl,createMask:yt,createPipe:Io,default:_e,forceDirection:il,normalizeOpts:Jt,pipe:gl},Symbol.toStringTag,{value:"Module"}));function Mg(){const o=e.ref(!1);return{isFullscreen:o,toggleFullscreen:()=>{o.value=!o.value}}}const Fg="https://esm.sh",rt="3.7.2",bl="3.7.2",Dg=`?deps=@tiptap/core@${rt},@tiptap/pm@${bl}`,lt=o=>`${Fg}/${o}${Dg}`,at={core:lt(`@tiptap/core@${rt}`),starterKit:lt(`@tiptap/starter-kit@${rt}`),textStyle:lt(`@tiptap/extension-text-style@${rt}`),table:lt(`@tiptap/extension-table@${rt}`),highlight:lt(`@tiptap/extension-highlight@${rt}`),subscript:lt(`@tiptap/extension-subscript@${rt}`),superscript:lt(`@tiptap/extension-superscript@${rt}`),link:lt(`@tiptap/extension-link@${rt}`),image:lt(`@tiptap/extension-image@${rt}`),textAlign:lt(`@tiptap/extension-text-align@${rt}`),heading:lt(`@tiptap/extension-heading@${rt}`),paragraph:lt(`@tiptap/extension-paragraph@${rt}`),pmModel:lt(`@tiptap/pm@${bl}/model`)},gn="__vs_form_tiptap_loader__",st=o=>import(o),Ue=(o,t)=>o?.[t]||o?.default?.[t]||o?.default?.default?.[t]||o?.default||o,Tg=o=>o&&o.split(";").map(n=>n.trim()).filter(n=>n&&!/^text-align\s*:/i.test(n)).join("; ")||null,Lg=o=>o.style?{style:String(o.style).replace(/;\s*$/,"")}:{},kl=({stripTextAlign:o=!1}={})=>({default:null,parseHTML:t=>{const n=t.getAttribute("style");return o?Tg(n):n||null},renderHTML:t=>Lg(t)}),Ig=o=>o.extend({addAttributes(){return{...this.parent?.(),style:kl({stripTextAlign:!0})}}}),Og=o=>o.extend({addAttributes(){return{...this.parent?.(),style:kl()}}}),Pg=o=>o.extend({addOptions(){return{...this.parent?.(),levels:[1,2,3,4,5,6]}}}),Rg=(o,t,n,r,a)=>{const l=t.extend({addAttributes(){return{...this.parent?.(),border:{default:null,parseHTML:s=>s.getAttribute("border"),renderHTML:s=>s.border?{border:s.border}:{}},cellpadding:{default:null,parseHTML:s=>s.getAttribute("cellpadding"),renderHTML:s=>s.cellpadding?{cellpadding:s.cellpadding}:{}},cellspacing:{default:null,parseHTML:s=>s.getAttribute("cellspacing"),renderHTML:s=>s.cellspacing?{cellspacing:s.cellspacing}:{}},style:{default:null,parseHTML:s=>s.getAttribute("style"),renderHTML:s=>s.style?{style:s.style}:{}},width:{default:null,parseHTML:s=>s.getAttribute("width"),renderHTML:s=>s.width?{width:s.width}:{}}}},parseHTML(){return[{tag:"div.tableWrapper table",priority:100},{tag:"table"}]}});return o.extend({addExtensions(){return[l.configure({resizable:!0}),n,r,a]}})},zg=o=>o.extend({addAttributes(){return{...this.parent?.(),fontFamily:{default:null,parseHTML:t=>t.style.fontFamily?.replace(/['"]/g,""),renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}},fontSize:{default:null,parseHTML:t=>t.style.fontSize?.replace(/['"]/g,""),renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}},color:{default:null,parseHTML:t=>t.style.color?.replace(/['"]/g,""),renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}},backgroundColor:{default:null,parseHTML:t=>t.style.backgroundColor?.replace(/['"]/g,""),renderHTML:t=>!t.backgroundColor||t.backgroundColor==="transparent"?{}:{style:`background-color: ${t.backgroundColor}`}}}},addCommands(){return{setFontFamily:t=>({chain:n})=>n().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run(),setFontSize:t=>({chain:n})=>n().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run(),setColor:t=>({chain:n})=>n().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run(),setBackgroundColor:t=>({chain:n})=>n().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),jg=o=>o.create({name:"iframe",group:"block",inline:!1,atom:!0,selectable:!0,addAttributes(){return{src:{default:null},width:{default:"100%"},height:{default:"280"},frameborder:{default:"0"},allow:{default:null},allowfullscreen:{default:null},referrerpolicy:{default:null},loading:{default:null},class:{default:null},title:{default:null},style:{default:null}}},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:t}){return["iframe",t]}});async function Ug(){if(typeof window>"u")return null;const o=window;return o[gn]||(o[gn]=Promise.all([st(at.core),st(at.starterKit),st(at.textStyle),st(at.table),st(at.highlight),st(at.subscript),st(at.superscript),st(at.link),st(at.image),st(at.textAlign),st(at.heading),st(at.paragraph),st(at.pmModel)]).then(([t,n,r,a,l,s,c,i,d,h,g,p,f])=>{const m=Ue(t,"Editor"),k=Ue(t,"Node"),b=Ue(n,"StarterKit"),_=Ue(r,"TextStyle"),C=Ue(a,"TableKit"),N=Ue(a,"Table"),$=Ue(a,"TableRow"),q=Ue(a,"TableCell"),G=Ue(a,"TableHeader"),I=Ue(l,"Highlight"),E=Ue(s,"Subscript"),V=Ue(c,"Superscript"),v=Ue(i,"Link"),T=Ue(d,"Image"),j=Ue(h,"TextAlign"),te=Ue(g,"Heading"),D=Ue(p,"Paragraph"),U=Ue(f,"DOMParser");if(!m||!k||!b||!_||!C||!N||!$||!q||!G||!I||!E||!V||!v||!T||!j||!te||!D||!U)throw new Error("Failed to resolve one or more Tiptap modules");return{Editor:m,ProseMirrorDOMParser:U,StarterKit:b,ExtendedTextStyle:zg(_),Highlight:I,Subscript:E,Superscript:V,CustomLink:Og(v),Image:T,TextAlign:j,CustomHeading:Pg(te),CustomParagraph:Ig(D),CustomTableKit:Rg(C,N,$,q,G),Iframe:jg(k)}}).catch(t=>{throw delete o[gn],t})),o[gn]}const Ot=o=>o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),yn=o=>{let t=Ot(o||"");return t=t.replace(/!\[([^\]]*)]\(([^)\s]+)(?:\s+"([^"]+)")?\)/g,(n,r,a,l)=>{const s=l?` title="${Ot(l)}"`:"";return`<img src="${Ot(a)}" alt="${Ot(r)}"${s}>`}),t=t.replace(/\[([^\]]+)]\(([^)\s]+)(?:\s+"([^"]+)")?\)/g,(n,r,a,l)=>{const s=l?` title="${Ot(l)}"`:"";return`<a href="${Ot(a)}"${s} target="_blank" rel="noopener noreferrer">${r}</a>`}),t=t.replace(/`([^`]+)`/g,"<code>$1</code>"),t=t.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),t=t.replace(/__([^_]+)__/g,"<strong>$1</strong>"),t=t.replace(/~~([^~]+)~~/g,"<del>$1</del>"),t=t.replace(/\*([^*\n]+)\*/g,"<em>$1</em>"),t=t.replace(/_([^_\n]+)_/g,"<em>$1</em>"),t},bn=o=>/^\s*\d+\.\s+/.test(o),Oo=o=>/^\s*[-*+]\s+/.test(o),wl=o=>/^\s*[-*+]\s+\[[ xX]\]\s+/.test(o),Po=o=>/^\s*>\s?/.test(o),Ro=o=>/^\s*\|?(?:\s*:?-{3,}:?\s*\|)+\s*:?-{3,}:?\s*\|?\s*$/.test(o),xl=o=>o.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(t=>yn(t.trim())),Hg=(o,t)=>{const n=o[t],r=o[t+1];if(!n||!r||!n.includes("|")||!Ro(r))return null;const a=xl(n),l=[];let s=t+2;for(;s<o.length&&o[s].includes("|")&&o[s].trim()!=="";){const d=xl(o[s]);l.push(`<tr>${d.map(h=>`<td>${h}</td>`).join("")}</tr>`),s+=1}const c=`<thead><tr>${a.map(d=>`<th>${d}</th>`).join("")}</tr></thead>`,i=l.length?`<tbody>${l.join("")}</tbody>`:"";return{html:`<table>${c}${i}</table>`,nextIndex:s}},qg=(o,t)=>{const n=bn(o[t]),r=n?"ol":"ul",a=[];let l=t;for(;l<o.length;){const s=o[l];if(s.trim()===""||!(n?bn(s):(Oo(s)||wl(s))&&!bn(s)))break;const i=s.match(/^\s*[-*+]\s+\[([ xX])\]\s+(.*)$/);if(i){const d=i[1].toLowerCase()==="x";a.push(`<li><input type="checkbox" disabled${d?" checked":""}> ${yn(i[2])}</li>`)}else{const d=s.replace(/^\s*(?:[-*+]|\d+\.)\s+/,"");a.push(`<li>${yn(d)}</li>`)}l+=1}return{html:`<${r}>${a.join("")}</${r}>`,nextIndex:l}},Wg=(o,t)=>{const r=o[t].replace(/^```/,"").trim(),a=[];let l=t+1;for(;l<o.length&&!o[l].startsWith("```");)a.push(o[l]),l+=1;return{html:`<pre><code${r?` class="language-${Ot(r)}"`:""}>${Ot(a.join(`
6
- `))}</code></pre>`,nextIndex:l<o.length?l+1:l}},Kg=(o,t)=>{const n=[];let r=t;for(;r<o.length;){const a=o[r];if(a.trim()===""||a.startsWith("```")||/^#{1,6}\s+/.test(a)||/^---+$/.test(a.trim())||/^\*\*\*+$/.test(a.trim())||Po(a)||bn(a)||Oo(a)||r+1<o.length&&a.includes("|")&&Ro(o[r+1]))break;n.push(a.trim()),r+=1}return{html:`<p>${yn(n.join(" "))}</p>`,nextIndex:r}},vl=o=>{const n=(o||"").replace(/\r\n/g,`
4
+ 50.4494, 30.5260`},format:{type:"Radio",label:"Формат координат",options:[{id:"decimal",text:"Десяткові (Decimal)"},{id:"dms",text:"Градуси-хвилини-секунди (DMS)"}]},order:{type:"Radio",label:"Порядок координат",options:[{id:"lat-lon",text:"lat, lon"},{id:"lon-lat",text:"lon, lat"}]}};let Ye=!1,Dt=!1;const Pe=s.reactive({}),qe=s.ref([]),tn=s.computed(()=>qe.value.map(k=>Pe[k]).filter(Boolean)),W=s.ref(null),Q=s.computed(()=>W.value?.entries??[]),de=s.computed(()=>{if(W.value)return{left:`${W.value.point.x+12}px`,top:`${W.value.point.y+12}px`}}),O=s.computed(()=>{if(Array.isArray(t.tools)&&t.tools.length)return t.tools;const k=o?.tools;return Array.isArray(k)?k.map(x=>String(x)):typeof k=="string"?k.split(",").map(x=>x.trim()).filter(Boolean):[]}),C=s.computed(()=>{const k={search:!1,import:!1,export:!1,point:!1,line:!1,polygon:!1,rectangle:!1,ruler:!1};if(!O.value.length)return{...k,import:!0,export:!0,point:!0,line:!0,polygon:!0,rectangle:!0};const x=new Set(O.value.map(S=>S.toLowerCase()));return{search:x.has("search"),import:x.has("import"),export:x.has("export"),point:x.has("point"),line:x.has("line"),polygon:x.has("polygon"),rectangle:x.has("rectangle"),ruler:x.has("ruler")}});function V(k){const x=typeof k=="string"?k.trim():"";if(!x)return"";if(/^https?:\/\//i.test(x))return x;const S=window?.location?.origin??"",B=x.replace(/^\/+/,"");return B?S?`${S}/${B}`:`/${B}`:S}function j(){const k=Array.isArray(N.basemaps)&&N.basemaps.length?N.basemaps:E.basemaps;if(Array.isArray(k)&&k.length){const S=k.map((B,F)=>{const J=String(B?.key??B?.id??B?.name??`b${F}`),ue=V(String(B?.url??""));if(!ue)return null;const he=typeof B?.preview=="string"&&B.preview?V(B.preview):"";return[J,{...B,url:ue,preview:he}]}).filter(B=>Array.isArray(B)&&B.length===2).reduce((B,[F,J])=>(B[F]=J,B),{});if(Object.keys(S).length)return S}return{voyager:{name:"Оглядова карта",url:"https://data.gki.com.ua/api-user/rtile/voyager/ua/{z}/{x}/{y}.png",preview:"https://data.gki.com.ua/api-user/rtile/voyager/ua/13/4790/2762.png"},orto10:{name:"Ортофото 1:10K",url:"https://data.gki.com.ua/api-user/rtile/orto10/ua/{z}/{x}/{y}.png",preview:"https://data.gki.com.ua/api-user/rtile/orto10/ua/13/4790/2762.png"},osmb:{name:"Open Street Maps",url:"https://tile.openstreetmap.org.ua/styles/osm-bright/{z}/{x}/{y}.png",preview:"https://tile.openstreetmap.org.ua/styles/osm-bright/13/4790/2762.png"}}}const ie=j(),Me=Object.keys(ie),Ze=s.ref(Me.length?Me[0]:"");function Ge(){const k=Array.isArray(N.overlays)&&N.overlays.length?N.overlays:E.overlays;return!Array.isArray(k)||!k.length?{}:k.map((S,B)=>{const J=(typeof S?.name=="string"?S.name.trim():"")||`o${B}`,ue=V(String(S?.url??""));if(!ue)return null;const he=typeof S?.preview=="string"&&S.preview?V(S.preview):"";return[J,{...S,name:J,url:ue,preview:he}]}).filter(S=>Array.isArray(S)&&S.length===2).reduce((S,[B,F])=>(S[B]=F,S),{})}const ut=Ge(),mt=s.ref(Object.keys(ut).filter(k=>!!ut[k]?.visible)),nn=s.computed(()=>C.value.point||C.value.line||C.value.polygon||C.value.rectangle),gt=s.computed(()=>tn.value.filter(k=>k.config?.overlay!==!1).map(k=>({id:k.id,label:String(k.config.title||k.config.name||k.id),visible:k.visible})));function Wt(k){return`${SE}${k}`}function xr(k){return`${EE}${k}`}async function sa(){if(typeof window>"u")return null;const k=window;if(k[ui])return k[ui];const x=J=>{if(Array.from(document.styleSheets).some(De=>De?.href?.includes(J)))return;const he=document.createElement("link");he.rel="stylesheet",he.href=J,document.head.appendChild(he)},S=async()=>{const J=new Function("u","return import(u)"),ue=await J("https://esm.sh/maplibre-gl@3.6.2"),he=ue?.default??ue;if(!he)throw new Error("maplibre esm fallback failed");window.maplibregl=he,window.mapboxgl=he;const De=await J("https://esm.sh/@mapbox/mapbox-gl-draw@1.5.0"),et=De?.default??De;if(!et)throw new Error("mapbox draw esm fallback failed");window.MapboxDraw=et},F=(async()=>{x("https://unpkg.com/maplibre-gl@3.6.2/dist/maplibre-gl.css"),x("https://unpkg.com/@mapbox/mapbox-gl-draw@1.5.0/dist/mapbox-gl-draw.css"),(!window.maplibregl||!window.MapboxDraw)&&await S();const J=window.maplibregl,ue=window.MapboxDraw;if(!J)throw new Error("maplibregl not available after load");if(!ue)throw new Error("MapboxDraw not available after load");return _S(J),{maplibregl:J,MapboxDraw:ue}})().catch(J=>{throw delete k[ui],J});return k[ui]=F,F}function Mo(k){return{version:8,glyphs:ME,sources:{rasterSource:$a(k,void 0,{safe:!1})},layers:[{id:"rasterLayer",type:"raster",source:"rasterSource"}]}}let Kn=null,vr=null,G=null,ye=null,Ft=[],qn=null,Mn=null,yt=null,Ao=!1,to=!1,q=!1,se=null;function me(){return{onSetup(){const k=this.newFeature({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[0,0],[0,0],[0,0],[0,0],[0,0]]]}});return this.addFeature(k),this.clearSelectedFeatures(),this.updateUIClasses({mouse:"add"}),this.setActionableState({trash:!0}),{rectangle:k,startPoint:null,hasCoordinates:!1}},onMouseMove(k,x){if(!k.startPoint)return;const[S,B]=k.startPoint,F=x.lngLat.lng,J=x.lngLat.lat;k.rectangle.setCoordinates([[[S,B],[F,B],[F,J],[S,J],[S,B]]])},onClick(k,x){if(!k.startPoint){k.startPoint=[x.lngLat.lng,x.lngLat.lat],k.hasCoordinates=!0,k.rectangle.setCoordinates([[[x.lngLat.lng,x.lngLat.lat],[x.lngLat.lng,x.lngLat.lat],[x.lngLat.lng,x.lngLat.lat],[x.lngLat.lng,x.lngLat.lat],[x.lngLat.lng,x.lngLat.lat]]]);return}const[S,B]=k.startPoint,F=x.lngLat.lng,J=x.lngLat.lat;return Math.abs(S-F)>0&&Math.abs(B-J)>0?(k.rectangle.setCoordinates([[[S,B],[F,B],[F,J],[S,J],[S,B]]]),this.map.fire("draw.create",{features:[k.rectangle.toGeoJSON()]}),this.changeMode("simple_select",{featureIds:[k.rectangle.id]})):(this.deleteFeature([k.rectangle.id],{silent:!0}),k.hasCoordinates=!1,this.changeMode("simple_select"))},onStop(){},onTrash(k){this.deleteFeature([k.rectangle.id],{silent:!0}),this.changeMode("simple_select")},toDisplayFeatures(k,x,S){const B=x.properties.id===k.rectangle.id;B&&!k.hasCoordinates||(x.properties.active=B?"true":"false",S(x))}}}const Le=[{id:"gl-draw-polygon-fill-inactive",type:"fill",filter:["all",["==","$type","Polygon"],["!=","active","true"]],paint:{"fill-color":"#3b82f6","fill-outline-color":"#3b82f6","fill-opacity":.1}},{id:"gl-draw-polygon-fill-active",type:"fill",filter:["all",["==","$type","Polygon"],["==","active","true"]],paint:{"fill-color":"#2563eb","fill-outline-color":"#2563eb","fill-opacity":.2}},{id:"gl-draw-polygon-stroke-inactive",type:"line",filter:["all",["==","$type","Polygon"],["!=","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3b82f6","line-width":2}},{id:"gl-draw-polygon-stroke-active",type:"line",filter:["all",["==","$type","Polygon"],["==","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#2563eb","line-width":2}},{id:"gl-draw-lines-inactive",type:"line",filter:["all",["==","$type","LineString"],["!=","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3b82f6","line-width":2}},{id:"gl-draw-lines-active",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#2563eb","line-width":2}},{id:"gl-draw-point-inactive",type:"circle",filter:["all",["==","$type","Point"],["!=","meta","midpoint"],["!=","active","true"]],paint:{"circle-radius":5,"circle-color":"#3b82f6"}},{id:"gl-draw-point-active",type:"circle",filter:["all",["==","$type","Point"],["!=","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":6,"circle-color":"#2563eb"}},{id:"gl-draw-polygon-and-line-vertex-halo-active",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"]],paint:{"circle-radius":7,"circle-color":"#fff"}},{id:"gl-draw-polygon-and-line-vertex-active",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"]],paint:{"circle-radius":5,"circle-color":"#2563eb"}},{id:"gl-draw-polygon-midpoint",type:"circle",filter:["all",["==","meta","midpoint"],["==","$type","Point"]],paint:{"circle-radius":4,"circle-color":"#1d4ed8"}}];function st(){const k=Ze.value;return!k||!ie[k]?.url?"":ie[k].url}function Et(k,x){return k?.id?String(k.id):k?.url?`${k.url}-${x}`:`layer-${x}`}function it(k){const x=String(k?.url??"").trim();if(!x)return"";if(/^https?:\/\//i.test(x))return x;const S=window.location?.origin??"",B=x.replace(/^\/+/,"");return`${S}/${B}`}function Mt(k){k&&W.value?.layerId!==k||(W.value=null)}function An(k,x={}){if(k.popup===!1)return[];const S=Number(x?.point_count);if(Number.isFinite(S)&&S>1)return[{key:"Об'єктів у кластері",value:String(S)}];const B=it(k),F=Us(k,B,R.value);return Array.isArray(k.popup)?k.popup.length?k.popup.map(J=>{const ue=J?.field||J?.name;if(!ue)return null;const he=x[ue];if(he==null||he==="")return null;const De=F?.formatPopupValue?F.formatPopupValue(ue,he):String(he);return{key:J.label||ue,value:De}}).filter(Boolean):[]:Object.entries(x).slice(0,5).map(([J,ue])=>({key:J,value:ue==null?"—":String(ue)}))}function rn(k){if(!Array.isArray(k))return[];const x=B=>Array.isArray(B)&&B.length>=2&&Number.isFinite(Number(B[0]))&&Number.isFinite(Number(B[1])),S=B=>{if(!B.length)return B;const F=B[0],J=B[B.length-1];return!J||F[0]!==J[0]||F[1]!==J[1]?[...B,F]:B};if(k.length&&x(k[0])){const B=k.map(F=>[Number(F[0]),Number(F[1])]).filter(x);return B.length?[S(B)]:[]}return k.length&&Array.isArray(k[0])&&x(k[0][0])?k.map(F=>Array.isArray(F)?F.map(J=>[Number(J[0]),Number(J[1])]):[]).filter(F=>F.length).map(S):k.length&&Array.isArray(k[0])&&Array.isArray(k[0][0])&&x(k[0][0][0])?k.flatMap(F=>Array.isArray(F)?F:[]).map(F=>Array.isArray(F)?F.map(J=>[Number(J[0]),Number(J[1])]):[]).filter(F=>F.length).map(S):[]}function _n(k){const x=k.style??{},S=x.color??"#3b82f6";if(!x.colorAttr||!x.colorSet)return S;const B=Object.keys(x.colorSet);if(!B.length)return S;const F=["match",["to-string",["get",x.colorAttr]]];return B.forEach(J=>{F.push(String(J),x.colorSet?.[J]??S)}),F.push(S),F}function on(k){if(!G)return;const x=G.getStyle()?.layers;Array.isArray(x)&&[...x].reverse().forEach(S=>{S.source===k&&G.getLayer(S.id)&&G.removeLayer(S.id)})}function Cr(k){if(!G)return;k.handlers.forEach(B=>{try{G.off(B.type,B.layerId,B.handler)}catch{}}),k.handlers=[],[...k.layerIds,...k.boundsIds].forEach(B=>{G.getLayer(B)&&G.removeLayer(B)}),on(k.sourceId),G.getSource(k.sourceId)&&G.removeSource(k.sourceId);const x=`vs-ov-bounds-src-${k.id}`,S=`vs-ov-bounds-line-${k.id}`;G.getLayer(S)&&G.removeLayer(S),G.getSource(x)&&G.removeSource(x),Mt(k.id)}function NR(k,x){if(!G)return[];const S=`vs-ov-bounds-src-${x}`,B=`vs-ov-bounds-line-${x}`,F=k.bounds??ne.value??ge.value,J=rn(F);if(!J.length)return[];const ue={type:"FeatureCollection",features:J.map(he=>({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:he}}))};return G.getLayer(B)&&G.removeLayer(B),G.getSource(S)&&G.removeSource(S),G.addSource(S,{type:"geojson",data:ue}),G.addLayer({id:B,type:"line",source:S,paint:{"line-color":k.style?.stroke??k.style?.color??"#2563eb","line-width":k.style?.width??2,"line-opacity":k.style?.opacity??.8,"line-dasharray":[2,2]}}),[B]}function au(){return q||p.value==="marker"||p.value==="polyline"||p.value==="polygon"||p.value==="rectangle"}function DR(k,x){if(!G)return;k.handlers.forEach(B=>{try{G.off(B.type,B.layerId,B.handler)}catch{}});const S=[];x.forEach(B=>{const F=ue=>{if(au())return;if(!ue?.features?.length){Mt(k.id);return}const he=ue.features[0]?.properties??{},De=An(k.config,he);if(!De.length){Mt(k.id);return}W.value={layerId:k.id,entries:De,point:{x:ue.point.x,y:ue.point.y}}},J=()=>Mt(k.id);G.on("mousemove",B,F),G.on("mouseleave",B,J),S.push({layerId:B,type:"mousemove",handler:F},{layerId:B,type:"mouseleave",handler:J})}),k.handlers=S}function cu(k,x){if(!G)return;k.layerIds=x,k.boundsIds=NR(k.config,k.id),DR(k,x);const S=k.visible?"visible":"none";[...k.layerIds,...k.boundsIds].forEach(B=>{G.getLayer(B)&&G.setLayoutProperty(B,"visibility",S)}),Tn()}function _o(k){if(!G)return;Cr(k),k.renderToken=(k.renderToken??0)+1;const x=k.renderToken,S=k.config,B=it(S);if(!B)return;const F=[],J=/\.v(?:m)?t(?:\?|$|\/)/i.test(B)||/\.pbf(?:\?|$)/i.test(B)||/\/vtile(?:\/|\?|$)/i.test(B)||String(S?.service??"").toLowerCase()==="vector"||String(S?.format??"").toLowerCase()==="mvt",ue=Us(S,B,R.value);if(J&&ue){const he=S.sourceLayer||S.layer||S.service_layer||S.dataset?.layer||S.id;G.addSource(k.sourceId,{type:"vector",tiles:[B],minzoom:typeof S.minzoom=="number"?S.minzoom:0,maxzoom:typeof S.maxzoom=="number"?S.maxzoom:22}),(async()=>{try{if(!G||!G.getSource(k.sourceId)||k.renderToken!==x)return;const De=await ue.render({map:G,overlayId:k.id,sourceId:k.sourceId,sourceLayer:he,url:B,config:S});if(!G||!G.getSource(k.sourceId)||k.renderToken!==x){De.forEach(et=>{G.getLayer(et)&&G.removeLayer(et)});return}cu(k,De)}catch(De){k.renderToken===x&&console.error(`Failed to render map layer preset "${ue.id}"`,De)}})();return}if(J){const he=S.sourceLayer||S.layer||S.service_layer||S.dataset?.layer||S.id;G.addSource(k.sourceId,{type:"vector",tiles:[B],minzoom:typeof S.minzoom=="number"?S.minzoom:0,maxzoom:typeof S.maxzoom=="number"?S.maxzoom:22});const De=Array.isArray(S.style?.types)?S.style.types.map(Yn=>String(Yn).toLowerCase()):[String(S.style?.type??"polygon").toLowerCase()],et=_n(S),Jn=S.style?.opacity??.5,ku=Yn=>{if(Yn==="point"){const zs=`vs-ov-point-${k.id}`;G.addLayer({id:zs,type:"circle",source:k.sourceId,"source-layer":he,paint:{"circle-color":et,"circle-radius":S.style?.radius??5,"circle-opacity":Jn}}),F.push(zs);return}if(Yn==="polyline"||Yn==="line"){const zs=`vs-ov-line-${k.id}`;G.addLayer({id:zs,type:"line",source:k.sourceId,"source-layer":he,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":et,"line-width":S.style?.width??2,"line-opacity":Jn}}),F.push(zs);return}const Z0=`vs-ov-fill-${k.id}`,Q0=`vs-ov-border-${k.id}`;G.addLayer({id:Z0,type:"fill",source:k.sourceId,"source-layer":he,paint:{"fill-color":et,"fill-opacity":Jn}}),G.addLayer({id:Q0,type:"line",source:k.sourceId,"source-layer":he,paint:{"line-color":S.style?.stroke??S.style?.color??"#2563eb","line-width":S.style?.width??1,"line-opacity":Jn}}),F.push(Z0,Q0)};[...new Set(De)].forEach(Yn=>ku(Yn)),cu(k,F);return}else{G.addSource(k.sourceId,$a(B,S,{safe:!1}));const he=`vs-ov-raster-${k.id}`;G.addLayer({id:he,type:"raster",source:k.sourceId,paint:{"raster-opacity":S.style?.opacity??1}}),F.push(he)}cu(k,F)}function Fs(){if(!G)return;const x={type:"FeatureCollection",features:rn(ne.value??ge.value).map(S=>({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:S}}))};G.getSource(fi)?G.getSource(fi).setData(x):G.addSource(fi,{type:"geojson",data:x}),G.getLayer(oo)||G.addLayer({id:oo,type:"line",source:fi,paint:{"line-color":"#2563eb","line-width":2,"line-opacity":.8,"line-dasharray":[2,2]}})}function VR(k){if(!G||c.value)return;const x=Pe[k];if(!x)return;x.visible=!x.visible;const S=x.visible?"visible":"none";[...x.layerIds,...x.boundsIds].forEach(B=>{G.getLayer(B)&&G.setLayoutProperty(B,"visibility",S)}),Tn(),x.visible||Mt(k)}function O0(k){if(!G)return;const x=ut[k];if(!x?.url)return;const S=Wt(k),B=xr(k);G.getLayer(B)&&G.removeLayer(B),G.getSource(S)&&G.removeSource(S),G.addSource(S,$a(x.url,x,{safe:!0}));const F=x?.opacity??x?.style?.opacity,J=typeof F=="number"?F:CE;G.addLayer({id:B,type:"raster",source:S,paint:{"raster-opacity":J}})}function $R(k){if(!G)return;const x=Wt(k),S=xr(k);G.getLayer(S)&&G.removeLayer(S),G.getSource(x)&&G.removeSource(x)}function R0(){G&&mt.value.forEach(k=>O0(k))}function LR(k){if(!G||c.value||!ut[k])return;mt.value.includes(k)?(mt.value=mt.value.filter(S=>S!==k),$R(k)):(mt.value=[...mt.value,k],O0(k)),Tn()}function Tn(){if(!G)return;const k=mt.value.map(De=>xr(De)).filter(De=>G.getLayer(De)),x=[],S=[],B=[],F=[];qe.value.forEach(De=>{const et=Pe[De];if(!et)return;const Jn=String(et.config?.url??""),ku=/\.v(?:m)?t(?:\?|$|\/)/i.test(Jn)||/\/vtile(?:\/|\?|$)/i.test(Jn)||Cu(et.config,Jn,R.value),Yn=/\.png(?:\?|$)/i.test(Jn);ku?B.push(...et.layerIds):Yn?x.push(...et.layerIds):S.push(...et.layerIds),F.push(...et.boundsIds)});const J=[...k,...x,...S,...B,...F];J.forEach(De=>{G.getLayer(De)&&G.moveLayer(De)}),G.getLayer(oo)&&G.moveLayer(oo);const he=(G.getStyle?.()?.layers??[]).map(De=>String(De?.id??"")).filter(De=>De.startsWith("gl-draw-"));if(he.forEach(De=>{G.getLayer(De)&&G.moveLayer(De)}),G.getLayer(cf)){const De=J.find(et=>G.getLayer(et))??(G.getLayer(oo)?oo:null)??he.find(et=>G.getLayer(et));De&&G.moveLayer(cf,De)}}function IR(k){if(!ie[k]||(Ze.value=k,!G))return;const x=st();if(!x)return;const S=G.getSource("rasterSource");if(S&&typeof S.setTiles=="function"){S.setTiles([x]),Tn();return}const B=G.getCenter?.(),F=G.getZoom?.(),J=ye?.getAll?.();G.setStyle(Mo(x)),G.once("style.load",()=>{if(G&&(B&&Number.isFinite(F)&&G.jumpTo({center:[B.lng,B.lat],zoom:F}),Fs(),R0(),qe.value.forEach(ue=>{const he=Pe[ue];he&&_o(he)}),Tn(),J?.features?.length&&ye))try{J.features.forEach(ue=>ye.add(ue)),f.value=J.features.length}catch{f.value=0}})}function du(k){return{type:"Feature",properties:{},geometry:k}}function Bn(k){if(!k)return null;try{return JSON.parse(JSON.stringify(k))}catch{return null}}function uu(k){if(!k)return null;const x=Bn(k.geometry);return x?{...k.id!==void 0?{id:k.id}:{},type:"Feature",properties:{...k.properties??{}},geometry:x}:null}function ia(k){if(!k)return[];const x=(F,J)=>{if(!F?.type)return[];const ue={...J??{}};return F.type==="MultiPoint"&&Array.isArray(F.coordinates)?F.coordinates.map(he=>du({type:"Point",coordinates:he})).map(he=>({...he,properties:ue})):F.type==="MultiLineString"&&Array.isArray(F.coordinates)?F.coordinates.map(he=>du({type:"LineString",coordinates:he})).map(he=>({...he,properties:ue})):F.type==="MultiPolygon"&&Array.isArray(F.coordinates)?F.coordinates.map(he=>du({type:"Polygon",coordinates:he})).map(he=>({...he,properties:ue})):F.type==="GeometryCollection"&&Array.isArray(F.geometries)?F.geometries.flatMap(he=>x(he,ue)):[{type:"Feature",properties:ue,geometry:Bn(F)}]},S=F=>{if(!F)return null;if(F.type==="Feature"){const J=uu(F);return J?x(J.geometry,J.properties):null}return F.geom?.type&&Array.isArray(F.geom.coordinates)?x({type:F.geom.type,coordinates:F.geom.coordinates},F.properties??{}):F.type==="GeometryCollection"&&Array.isArray(F.geometries)?x(F,F.properties??{}):typeof F.type=="string"&&Array.isArray(F.coordinates)?x(Bn(F),F.properties??{}):null};if(k.type==="FeatureCollection")return(k.features??[]).flatMap(S).filter(Boolean);if(Array.isArray(k))return k.flatMap(F=>F?.type==="FeatureCollection"?ia(F):[S(F)]).flat().filter(Boolean);const B=S(k);return B?Array.isArray(B)?B:[B]:[]}function F0(k){if(!k.length)return null;if(!a.value)return Bn(k[0]?.geometry??null);const x=k.map(J=>Bn(J?.geometry)).filter(Boolean);return x.every(J=>J?.type==="Point")?{type:"MultiPoint",coordinates:x.map(J=>J.coordinates)}:x.every(J=>J?.type==="LineString")?{type:"MultiLineString",coordinates:x.map(J=>J.coordinates)}:x.every(J=>J?.type==="Polygon")?{type:"MultiPolygon",coordinates:x.map(J=>J.coordinates)}:{type:"GeometryCollection",geometries:x}}function P0(k){if(!k)return"__null__";try{return JSON.stringify(k)}catch{return"__invalid__"}}function OR(k,x){if(!Array.isArray(k)||!Array.isArray(x)||k.length<2||x.length<2)return!1;const S=1e-12;return Math.abs(Number(k[0])-Number(x[0]))<S&&Math.abs(Number(k[1])-Number(x[1]))<S}function z0(k,x){if(!Array.isArray(k)||k.length<4)return null;const B=OR(k[0],k[k.length-1])?k.slice(0,-1):k.slice();return!Number.isInteger(x)||x<0||x>=B.length||B.length<=3||(B.splice(x,1),B.length<3)?null:[...B,[...B[0]]]}function H0(k,x){if(!Array.isArray(k)||k.length<2||!Number.isInteger(x)||x<0||x>=k.length||k.length<=2)return null;const S=k.slice();return S.splice(x,1),S.length<2?null:S}function RR(k,x){const S=Bn(k);if(!S||!Array.isArray(x))return null;if(S.type==="LineString"){const[B]=x,F=H0(S.coordinates,B);return F?(S.coordinates=F,S):null}if(S.type==="MultiLineString"){const[B,F]=x,J=S.coordinates?.[B],ue=H0(J,F);return ue?(S.coordinates[B]=ue,S):null}if(S.type==="Polygon"){const[B,F]=x,J=S.coordinates?.[B],ue=z0(J,F);return ue?(S.coordinates[B]=ue,S):null}if(S.type==="MultiPolygon"){const[B,F,J]=x,ue=S.coordinates?.[B]?.[F],he=z0(ue,J);return he?(S.coordinates[B][F]=he,S):null}return null}function FR(k){return k?k.split(".").map(x=>Number(x)).filter(x=>Number.isInteger(x)&&x>=0):[]}function j0(k){return!ye||!k?null:typeof ye.get=="function"?ye.get(k)??null:ye.getAll?.()?.features?.find(S=>String(S?.id??"")===k)??null}function U0(k){const x=k?.properties?.id??k?.id;return x==null||x===""?null:String(x)}function PR(k){if(!G||!k)return null;const x=[[k.x-8,k.y-8],[k.x+8,k.y+8]],B=G.queryRenderedFeatures(x).find(F=>{const J=String(F?.properties?.meta??"");return J&&J!=="feature"?!1:!!U0(F)});return U0(B)}function zR(k,x){if(!ye||!k||!x.length)return;const S=j0(k);if(!S?.geometry)return;const B=RR(S.geometry,x);if(!B)return;const F={...S,id:S.id??k,geometry:B};Dt=!0,Ye=!0;try{ye.delete(k),ye.add(F)}finally{Ye=!1,Dt=!1}Sr(),Gn()}function HR(k){if(!G||!ye||c.value||b.isRulerActive.value||p.value!=="edit")return;const x=k?.point;if(!x)return;const S=[[x.x-8,x.y-8],[x.x+8,x.y+8]],F=G.queryRenderedFeatures(S).find(ue=>ue?.properties?.meta==="vertex"&&ue?.properties?.parent&&ue?.properties?.coord_path);if(!F)return;k?.originalEvent?.preventDefault?.(),k?.originalEvent?.stopPropagation?.();const J=FR(String(F.properties.coord_path));J.length&&zR(String(F.properties.parent),J)}function jR(k){const x=q0(k);if(!x)return null;const[[S,B],[F,J]]=x;return{lat:(B+J)/2,lng:(S+F)/2}}function W0(k){if(!Array.isArray(k)||k.length<3)return 0;const x=(B,F)=>{const J=B*2003750834e-2/180,ue=Math.log(Math.tan((90+F)*Math.PI/360))/(Math.PI/180);return[J,ue*2003750834e-2/180]};let S=0;for(let B=0;B<k.length-1;B+=1){const[F,J]=x(Number(k[B][0]),Number(k[B][1])),[ue,he]=x(Number(k[B+1][0]),Number(k[B+1][1]));S+=F*he-ue*J}return Math.abs(S/2)/1e6}function UR(k){if(!k?.type||!k?.coordinates)return null;if(k.type==="Polygon"){const x=k.coordinates?.[0];return Array.isArray(x)?W0(x):null}return k.type==="MultiPolygon"?k.coordinates.reduce((x,S)=>{const B=S?.[0];return Array.isArray(B)?x+W0(B):x},0):null}function fu(k){if(!k){h.value=null;return}const x=jR(k);if(!x){h.value=null;return}h.value={type:String(k.type??"Feature"),center:x,areaKm2:UR(k)}}function pu(k){if(!k){const B=Ft[Ft.length-1],F=Bn(B?.geometry??null);qn=F,fu(F);return}const x=Ft.find(B=>String(B?.id??"")===String(k))??null,S=Bn(x?.geometry??null);qn=S,fu(S)}function hu(k){m.value=(k??[]).map((x,S)=>{const B=String(x?.id??`feature-${S+1}`),F=mu(String(x?.geometry?.type??"Feature"));return{id:B,label:`${F} ${S+1}`}})}function mu(k){switch(String(k)){case"Point":return"Точка";case"MultiPoint":return"Мультиточка";case"LineString":return"Лінія";case"MultiLineString":return"Мультилінія";case"Polygon":return"Полігон";case"MultiPolygon":return"Мультиполігон";case"GeometryCollection":return"Колекція геометрій";default:return String(k||"Невідомо")}}function K0(k,x){if(!Array.isArray(k)||!Array.isArray(x)||k.length!==2||x.length!==2)return!1;const S=1e-9;return Math.abs(Number(k[0])-Number(x[0]))<S&&Math.abs(Number(k[1])-Number(x[1]))<S}function q0(k){if(!k)return null;let x=1/0,S=1/0,B=-1/0,F=-1/0;const J=ue=>{if(Array.isArray(ue)){if(ue.length>=2&&Number.isFinite(ue[0])&&Number.isFinite(ue[1])){const he=Number(ue[0]),De=Number(ue[1]);x=Math.min(x,he),S=Math.min(S,De),B=Math.max(B,he),F=Math.max(F,De);return}ue.forEach(J)}};return J(k.coordinates),!Number.isFinite(x)||!Number.isFinite(S)?null:[[x,S],[B,F]]}function G0(k){if(!G||!k)return;const x=q0(k);if(!x)return;const[[S,B],[F,J]]=x;if(S===F&&B===J){G.easeTo({center:[S,B],zoom:Math.max(K.value,14)}),te();return}G.fitBounds(x,{padding:30,duration:250,maxZoom:18}),te()}function gu(){if(!ye){f.value=0;return}const k=ye.getAll();f.value=k?.features?.length??0}function Ps(){if(!ye)return null;const x=ye.getAll?.()?.features??[],S=J=>!!J&&x.some(ue=>String(ue?.id??"")===String(J??"")),B=ye.getSelectedIds?.();if(Array.isArray(B)&&B.length>0){const J=B[0];return J!=null?String(J):null}if(S(yt))return String(yt);if(!x.length)return null;const F=a.value?x[x.length-1]:x[0];return F?.id!==void 0&&F?.id!==null?String(F.id):null}function Sr(){if(!ye)return;const k=ye.getAll();if(f.value=k?.features?.length??0,!k?.features?.length){Ft=[],m.value=[],qn=null,yt=null,h.value=null,Ye||(Mn="__null__",r("update:modelValue",null));return}const x=(k.features??[]).map(uu).filter(Boolean);if(Ft=x,hu(x),yt=Ps(),pu(yt),!Ye){const S=F0(x);Mn=P0(S),r("update:modelValue",S)}}function la(){if(!ye)return;(ye.getAll()?.features||[]).forEach(x=>ye.delete(x.id)),m.value=[],gu()}function aa(k){if(!ye)return;const x=ia(k),S=a.value?x:x.slice(0,1);Ye=!0,la(),S.forEach(J=>{try{ye.add(J)}catch{}}),Ye=!1,Ft=(ye.getAll?.()?.features??S).map(uu).filter(Boolean),hu(Ft),yt=null;const F=Bn(Ft[Ft.length-1]?.geometry??null);qn=Bn(F),gu(),fu(F),F&&(G0(F),c.value||Gn())}function WR(){ye&&(Ye=!0,la(),Ft.forEach(k=>{try{ye.add(k)}catch{}}),Ye=!1,hu(Ft),gu(),pu(yt))}function To(){if(ye){try{ye.changeMode("simple_select",{featureIds:[]})}catch{}p.value=""}}function ca(k){if(c.value||!ye)return;b.isRulerActive.value&&b.closeRuler(),q=!0,To(),p.value=k;const x=k==="marker"?"draw_point":k==="polyline"?"draw_line_string":k==="rectangle"?"draw_rectangle":"draw_polygon";a.value||(Ye=!0,la(),Ye=!1);try{ye.changeMode(x)}catch{p.value=""}finally{requestAnimationFrame(()=>{q=!1})}}function Gn(k){if(c.value||!ye||!ye.getAll()?.features?.length)return;const S=k||Ps();if(S)try{ye.changeMode("direct_select",{featureId:S}),yt=S,pu(yt),p.value="edit"}catch{p.value=""}}function KR(k){c.value||!ye||!k||Gn(k)}function qR(){if(!(c.value||!ye)){if(a.value){const k=Ps();if(k)try{Ao=!0,ye.delete(k),Ao=!1,Sr();const x=Ps();x?Gn(x):To();return}catch{Ao=!1}}To(),la(),Ft=[],m.value=[],yt=null,Mn="__null__",h.value=null,r("update:modelValue",null)}}function GR(){c.value||!qn||G0(qn)}function JR(k){if(!G||!Kn)return;const x=[k[1],k[0]];se||(se=new Kn.Marker({color:"#2563eb"})),se.setLngLat(x).addTo(G),G.easeTo({center:x,zoom:13,duration:250})}function YR(){c.value||(Ee.value=!Ee.value)}function J0(k){if(!Ee.value)return;const x=re.value;x&&!x.contains(k.target)&&(Ee.value=!1)}function XR(){ZR()}function ZR(){c.value||(Ee.value=!1,oe.value={srid:"",encoding:"UTF-8",file:""},Ie.value=!0)}function QR(){Ie.value=!1,je.value=!1,Fe.value=!1}function eF(k){return k?typeof k=="string"?k:typeof k=="object"&&k&&"file_path"in k?String(k.file_path??""):"":""}function tF(k){const B=((Array.isArray(k)?k[0]:k)?.features??[]).map(F=>Array.isArray(F)?F[0]:F).filter(Boolean).map(F=>F?.type==="Feature"?F:{type:"Feature",properties:{},geometry:F});return B.length?{type:"FeatureCollection",features:B}:null}async function nF(){if(c.value||!ye||je.value)return;const k=eF(oe.value.file);if(!k){we.notify({type:"warning",title:"Імпорт геометрії",message:"Оберіть файл для імпорту."});return}je.value=!0;try{const x=await fetch("/api/gis-convert",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({srid:oe.value.srid,encoding:oe.value.encoding||"UTF-8",filepath:k,limit:!0})}),S=await x.json().catch(()=>null);if(!x.ok)throw new Error(S?.message||S?.error||`Код помилки: ${x.status}`);const B=tF(S);if(!B){we.notify({type:"warning",title:"Імпорт геометрії",message:"Файл не містить коректні геодані."});return}aa(B),Sr(),Ie.value=!1,we.notify({type:"success",title:"Успіх",message:"Геометрію успішно імпортовано."})}catch(x){we.notify({type:"error",title:"Помилка",message:x?.message||"Помилка імпорту файла геометрії"})}finally{je.value=!1}}function rF(){c.value||(We.value=[],Ee.value=!1,xe.value=!0)}function oF(){xe.value=!1,We.value=[]}function sF(){if(c.value||!ye)return;const k=cC(Te.value.coordinates??"",Te.value.format||"decimal",Te.value.order||"lat-lon");if(!k.ok){We.value=k.errors,iF(k.errors);return}We.value=[],aa({type:"Polygon",coordinates:[k.ring]}),Sr(),xe.value=!1,k.wasClosedAutomatically&&we.notify({type:"info",title:"Імпорт координат",message:"Полігон був автоматично замкнений (перша і остання точки різнилися)."})}function iF(k){if(!k.length)return;const x=5;k.slice(0,x).forEach(S=>{const B=S.line>0?`Рядок ${S.line}`:"Загальна помилка";we.notify({type:"warning",title:"Імпорт координат",message:`${B} — ${S.message}`})}),k.length>x&&we.notify({type:"warning",title:"Імпорт координат",message:`Ще помилок: ${k.length-x}`})}function lF(){if(c.value||!ye)return;const k=ye.getAll(),x=new Blob([JSON.stringify(k,null,2)],{type:"application/json"}),S=URL.createObjectURL(x),B=document.createElement("a");B.href=S,B.download="data.geojson",B.click(),URL.revokeObjectURL(S)}s.onMounted(async()=>{if(window.addEventListener("click",J0,!0),!u.value)return;const k=await sa();Kn=k.maplibregl,vr=k.MapboxDraw;const x=st();x&&(G=new Kn.Map({container:u.value,style:Mo(x),center:[U.value[0],U.value[1]],zoom:K.value,attributionControl:!1}),g.value=G,G.addControl(new Kn.NavigationControl({showCompass:!0}),"bottom-right"),G.on("error",S=>{const B=S?.error?.message??S?.message??"";NS(B)}),G.on("load",()=>{if(!(!vr||!G)){if(ye=new vr({displayControlsDefault:!1,modes:{...vr.modes,draw_rectangle:me()},controls:{point:!1,line_string:!1,polygon:!1,trash:!1},styles:Le}),G.addControl(ye),G.on("click",S=>{if(b.isRulerActive.value){const F=S?.lngLat;if(!F)return;y.value?.addPoint?.({lat:F.lat,lng:F.lng});return}if(!ye||c.value||p.value!=="edit")return;const B=PR(S?.point);!B||B===yt||requestAnimationFrame(()=>{!ye||c.value||Gn(B)})}),G.on("draw.create",()=>{if(ye&&!b.isRulerActive.value){if(!a.value){const S=ye.getAll();if(S.features.length>1){const B=S.features[S.features.length-1];Ye=!0,S.features.slice(0,-1).forEach(F=>ye.delete(F.id)),Ye=!1,B&&(Ye=!0,ye.add(B),Ye=!1)}}Sr(),Gn()}}),G.on("draw.update",S=>{if(to||b.isRulerActive.value||au())return;const B=Array.isArray(S?.features)?S.features:[],F=S?.action==="move"&&B.length>0&&B.every(J=>J?.geometry?.type==="Point");if(S?.action==="move"){if(F){Sr();return}if(to=!0,WR(),to=!1,p.value==="edit"){const J=Ps(),ue=J?j0(J):ye?.getAll?.()?.features?.[0];if(ue?.id)try{ye.changeMode("direct_select",{featureId:ue.id}),yt=String(ue.id)}catch{p.value=""}}return}Sr()}),G.on("draw.delete",()=>{Dt||Ao||b.isRulerActive.value||p.value==="marker"||p.value==="polyline"||p.value==="polygon"||p.value==="rectangle"||(Sr(),ye?.getAll?.()?.features?.length||(yt=null),p.value="",To())}),G.on("draw.selectionchange",S=>{if(!ye||to||b.isRulerActive.value||p.value==="marker"||p.value==="polyline"||p.value==="polygon"||p.value==="rectangle")return;const B=S?.features?.[0]?.id!==void 0&&S?.features?.[0]?.id!==null?String(S.features[0].id):null;if(!c.value&&B){if(p.value==="edit"&&yt===B)return;requestAnimationFrame(()=>{!ye||c.value||Gn(B)});return}const F=ye.getSelectedIds?.(),J=Array.isArray(F)&&F.length>0?String(F[0]):null;if(!c.value&&J){if(p.value==="edit"&&yt===J)return;requestAnimationFrame(()=>{!ye||c.value||Gn(J)});return}try{ye.changeMode("simple_select",{featureIds:[]})}catch{}}),ae.value!==void 0){const S=ae.value;ae.value=void 0,requestAnimationFrame(()=>{ye&&aa(S)})}Fs(),R0(),qe.value.forEach(S=>{const B=Pe[S];B&&_o(B)}),Tn(),I()}}),G.on("contextmenu",HR),G.on("moveend",te),G.on("zoomend",()=>{G&&(K.value=G.getZoom())}))}),s.onUnmounted(()=>{typeof document<"u"&&(document.body.style.overflow=""),typeof window<"u"&&window.removeEventListener("keydown",bu),le&&(clearTimeout(le),le=null),b.isRulerActive.value&&b.closeRuler(),window.removeEventListener("click",J0,!0),Object.values(Pe).forEach(k=>{G&&Cr(k)}),Mt(),se?.remove&&se.remove(),se=null,G?.remove&&G.remove(),G=null,ye=null,g.value=null}),s.watch(()=>t.modelValue,k=>{if(!ye){ae.value=k;return}if(au())return;const x=F0((a.value?ia(k):ia(k).slice(0,1))||[]),S=P0(x);if(Mn&&S===Mn){Mn=null;return}Mn=null,aa(k)},{deep:!0}),s.watch(()=>P.value,k=>{const x=Array.isArray(k)?k:[],S=[],B=new Set;x.forEach((F,J)=>{if(!F)return;const ue=Et(F,J);S.push(ue),B.add(ue);const he={...F,id:ue},De=Pe[ue],et=De?.visible??!!he.visible;De&&G&&Cr(De),Pe[ue]={id:ue,config:he,visible:et,sourceId:`vs-ov-src-${ue}`,layerIds:[],boundsIds:[],handlers:[],renderToken:De?.renderToken??0}}),Object.keys(Pe).forEach(F=>{if(B.has(F))return;const J=Pe[F];J&&G&&Cr(J),delete Pe[F]}),qe.value=S,G&&(qe.value.forEach(F=>{const J=Pe[F];J&&_o(J)}),Tn())},{immediate:!0,deep:!0}),s.watch(()=>ne.value,()=>{G&&(Fs(),qe.value.forEach(k=>{const x=Pe[k];x&&_o(x)}),Tn())},{deep:!0}),s.watch(()=>D.value,async k=>{if(ge.value=[],!k){G&&(Fs(),qe.value.forEach(x=>{const S=Pe[x];S&&_o(S)}),Tn());return}try{const x=await fetch(`https://data.gki.com.ua/api-user/atu/${k}`);if(!x?.ok)return;const B=(await x.json())?.geometry?.coordinates;Array.isArray(B)&&B.length&&(ge.value=B)}catch(x){console.error("Failed to fetch KATOTTG bounds",x)}finally{if(!G)return;Fs(),qe.value.forEach(x=>{const S=Pe[x];S&&_o(S)}),Tn()}},{immediate:!0}),s.watch(()=>z.value,k=>{if(!Array.isArray(k)||k.length!==2)return;const x=[Number(k[0]),Number(k[1])];if(K0(U.value,x)||(U.value=[...x],!G))return;const S=G.getCenter?.();S&&K0([S.lng,S.lat],U.value)||G.easeTo({center:[U.value[0],U.value[1]]})},{deep:!0}),s.watch(()=>Z.value,k=>{typeof k=="number"&&(K.value=k,G&&G.setZoom(k))}),s.watch(()=>h.value?.center,k=>{k&&$(k.lng,k.lat,G?.getZoom?.())},{deep:!0}),s.watch(c,k=>{k&&To()}),s.watch(f,k=>{if(k>0){c.value||Gn();return}q||To()});const Y0=s.computed(()=>m.value.length>0||!!h.value),yu=s.computed(()=>{const k=m.value,x=k.length>1;return k.length?k.map(S=>({id:S.id,label:x?S.label:h.value?.type?mu(h.value.type):S.label,interactive:x})):h.value?.type?[{id:"__feature",label:mu(h.value.type),interactive:!1}]:[]});function X0(){setTimeout(()=>{G?.resize&&G.resize()},50)}function bu(k){k.key==="Escape"&&d.value&&(d.value=!1)}return s.watch(d,k=>{typeof document<"u"&&(document.body.style.overflow=k?"hidden":""),typeof window<"u"&&(k?window.addEventListener("keydown",bu):window.removeEventListener("keydown",bu)),X0()}),s.watch(Y0,X0),(k,x)=>(s.openBlock(),s.createBlock(s.Teleport,{to:"body",disabled:!d.value},[s.createElementVNode("div",{class:s.normalizeClass(["vs-map-wrapper w-full",{fullscreen:d.value}])},[s.createElementVNode("div",DS,[s.createElementVNode("div",{ref_key:"mapContainer",ref:u,class:"vs-map-canvas"},null,512),C.value.search||C.value.import||C.value.export?(s.openBlock(),s.createElementBlock("div",VS,[C.value.search?(s.openBlock(),s.createBlock(TC,{key:0,onGoToCoordinates:JR})):s.createCommentVNode("",!0),C.value.import||C.value.export?(s.openBlock(),s.createElementBlock("div",$S,[s.createElementVNode("div",LS,[C.value.import?(s.openBlock(),s.createElementBlock("div",{key:0,ref_key:"importMenuRef",ref:re,class:"relative"},[s.createElementVNode("button",{type:"button",class:"vs-map-action-btn",onClick:YR,disabled:c.value},[x[10]||(x[10]=s.createTextVNode(" Імпорт ",-1)),s.createVNode(s.unref(Y.ChevronDown),{class:s.normalizeClass(["h-3.5 w-3.5 shrink-0 transition-transform",{"rotate-180":Ee.value}])},null,8,["class"])],8,IS),Ee.value?(s.openBlock(),s.createElementBlock("div",OS,[C.value.import?(s.openBlock(),s.createElementBlock("button",{key:0,type:"button",class:"block w-full text-left px-3 py-2 hover:bg-gray-100 text-gray-900",onClick:XR}," З файлу ")):s.createCommentVNode("",!0),s.createElementVNode("button",{type:"button",class:"block w-full text-left px-3 py-2 hover:bg-gray-100 text-gray-900",onClick:rF}," З координат ")])):s.createCommentVNode("",!0)],512)):s.createCommentVNode("",!0),C.value.export?(s.openBlock(),s.createElementBlock("button",{key:1,type:"button",class:"vs-map-action-btn",onClick:lF,disabled:c.value||f.value===0}," Експорт ",8,RS)):s.createCommentVNode("",!0)])])):s.createCommentVNode("",!0)])):s.createCommentVNode("",!0),s.createVNode(s.unref(we.VsModal),{visible:Ie.value,"onUpdate:visible":x[1]||(x[1]=S=>Ie.value=S),title:"Імпорт геометрії",size:"lg",teleport:s.unref(l)},{default:s.withCtx(()=>[Fe.value||je.value?(s.openBlock(),s.createElementBlock("div",FS,[s.createVNode(s.unref(Y.LoaderCircle),{class:"h-4 w-4 shrink-0 animate-spin"}),s.createElementVNode("span",null,s.toDisplayString(ot.value),1)])):s.createCommentVNode("",!0),s.createVNode(zt,{schema:_e.value,values:oe.value,"onUpdate:values":x[0]||(x[0]=S=>oe.value=S)},null,8,["schema","values"]),s.createElementVNode("div",PS,[s.createElementVNode("button",{type:"button",class:"px-3 py-2 rounded-md border border-gray-300 text-gray-700 text-sm hover:bg-gray-100",onClick:QR,disabled:Fe.value||je.value}," Скасувати ",8,zS),s.createElementVNode("button",{type:"button",class:"px-3 py-2 rounded-md bg-blue-600 text-white text-sm hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-2",onClick:nF,disabled:c.value||Fe.value||je.value||!oe.value.file},[je.value?(s.openBlock(),s.createBlock(s.unref(Y.LoaderCircle),{key:0,class:"h-4 w-4 animate-spin"})):s.createCommentVNode("",!0),s.createTextVNode(" "+s.toDisplayString(je.value?"Обробка...":"Додати"),1)],8,HS)])]),_:1},8,["visible","teleport"]),s.createVNode(s.unref(we.VsModal),{visible:xe.value,"onUpdate:visible":x[3]||(x[3]=S=>xe.value=S),title:"Імпорт координат полігону",size:"lg",teleport:s.unref(l)},{default:s.withCtx(()=>[s.createVNode(zt,{schema:dt,values:Te.value,"onUpdate:values":x[2]||(x[2]=S=>Te.value=S)},null,8,["values"]),s.createElementVNode("div",jS,[s.createElementVNode("button",{type:"button",class:"px-3 py-2 rounded-md border border-gray-300 text-gray-700 text-sm hover:bg-gray-100",onClick:oF}," Скасувати "),s.createElementVNode("button",{type:"button",class:"px-3 py-2 rounded-md bg-blue-600 text-white text-sm hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",onClick:sF,disabled:c.value}," Побудувати ",8,US)])]),_:1},8,["visible","teleport"]),s.createElementVNode("div",WS,[s.createElementVNode("div",KS,[nn.value?(s.openBlock(),s.createElementBlock(s.Fragment,{key:0},[C.value.point?(s.openBlock(),s.createElementBlock("button",{key:0,class:s.normalizeClass(["vs-btn",{"vs-active":p.value==="marker"}]),title:"Точка",onClick:x[4]||(x[4]=S=>ca("marker")),disabled:c.value},[s.createVNode(s.unref(Y.MapPin),{class:"vs-btn-icon"})],10,qS)):s.createCommentVNode("",!0),C.value.line?(s.openBlock(),s.createElementBlock("button",{key:1,class:s.normalizeClass(["vs-btn",{"vs-active":p.value==="polyline"}]),title:"Лінія",onClick:x[5]||(x[5]=S=>ca("polyline")),disabled:c.value},[s.createVNode(Bv,{class:"vs-btn-icon"})],10,GS)):s.createCommentVNode("",!0),C.value.polygon?(s.openBlock(),s.createElementBlock("button",{key:2,class:s.normalizeClass(["vs-btn",{"vs-active":p.value==="polygon"}]),title:"Полігон",onClick:x[6]||(x[6]=S=>ca("polygon")),disabled:c.value},[s.createVNode($v,{class:"vs-btn-icon"})],10,JS)):s.createCommentVNode("",!0),C.value.rectangle?(s.openBlock(),s.createElementBlock("button",{key:3,class:s.normalizeClass(["vs-btn",{"vs-active":p.value==="rectangle"}]),title:"Прямокутник",onClick:x[7]||(x[7]=S=>ca("rectangle")),disabled:c.value},[s.createVNode(Rv,{class:"vs-btn-icon"})],10,YS)):s.createCommentVNode("",!0)],64)):s.createCommentVNode("",!0),nn.value?(s.openBlock(),s.createElementBlock("div",XS)):s.createCommentVNode("",!0),C.value.ruler?(s.openBlock(),s.createElementBlock("button",{key:2,class:s.normalizeClass(["vs-btn",{"vs-active":s.unref(b).isRulerActive.value}]),title:"Лінійка",onClick:w},[s.createVNode(s.unref(Y.Ruler),{class:"vs-btn-icon"})],2)):s.createCommentVNode("",!0),s.createElementVNode("button",{class:"vs-btn",onClick:x[8]||(x[8]=S=>d.value=!d.value),title:d.value?"Згорнути":"На весь екран"},[d.value?(s.openBlock(),s.createBlock(s.unref(Y.Minimize),{key:0,class:"vs-btn-icon"})):(s.openBlock(),s.createBlock(s.unref(Y.Maximize),{key:1,class:"vs-btn-icon"}))],8,ZS)])]),C.value.ruler&&s.unref(b).isRulerActive.value?(s.openBlock(),s.createBlock(vS,{key:1,ref_key:"rulerPanelRefEl",ref:y,onClose:x[9]||(x[9]=S=>s.unref(b).closeRuler()),onTabChange:s.unref(b).onRulerTabChange,onPointsChange:s.unref(b).onRulerPointsChange,onShapeClosedChange:s.unref(b).onRulerShapeClosedChange},null,8,["onTabChange","onPointsChange","onShapeClosedChange"])):s.createCommentVNode("",!0),C.value.ruler&&s.unref(b).isRulerActive.value&&s.unref(b).hasRulerPoints.value?(s.openBlock(),s.createBlock(CS,{key:2,map:g.value,points:s.unref(b).rulerPoints.value,"is-shape-closed":s.unref(b).rulerShapeClosed.value,"label-mode":s.unref(b).rulerActiveTab.value},null,8,["map","points","is-shape-closed","label-mode"])):s.createCommentVNode("",!0),Q.value.length?(s.openBlock(),s.createElementBlock("div",{key:3,class:"absolute z-[1500] pointer-events-none",style:s.normalizeStyle(de.value)},[s.createElementVNode("div",QS,[s.createElementVNode("dl",eE,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(Q.value,S=>(s.openBlock(),s.createElementBlock("div",{key:`${S.key}-${S.value}`,class:"flex justify-between gap-2"},[s.createElementVNode("dt",tE,s.toDisplayString(S.key),1),s.createElementVNode("dd",nE,s.toDisplayString(S.value),1)]))),128))])])],4)):s.createCommentVNode("",!0),s.createElementVNode("div",rE,[s.createVNode(lC,{compact:"",basemaps:s.unref(ie),"active-base-key":Ze.value,"tile-overlays":s.unref(ut),"active-tile-overlay-keys":mt.value,"vector-overlays":gt.value,"preview-tile":X.value,disabled:c.value,onOnLayerChange:IR,onOnOverlayToggle:LR,onOnVectorOverlayToggle:VR},null,8,["basemaps","active-base-key","tile-overlays","active-tile-overlay-keys","vector-overlays","preview-tile","disabled"])])]),Y0.value?(s.openBlock(),s.createElementBlock("div",oE,[s.createElementVNode("div",sE,[s.createElementVNode("div",iE,[x[11]||(x[11]=s.createElementVNode("span",{class:"vs-map-status__label"},"Тип:",-1)),s.createElementVNode("div",lE,[yu.value.length?(s.openBlock(!0),s.createElementBlock(s.Fragment,{key:0},s.renderList(yu.value,(S,B)=>(s.openBlock(),s.createElementBlock(s.Fragment,{key:S.id},[S.interactive?(s.openBlock(),s.createElementBlock("button",{key:0,type:"button",class:s.normalizeClass(["vs-map-status__chip",{"vs-map-status__chip--active":S.id===s.unref(yt)}]),onClick:F=>KR(S.id),disabled:c.value},s.toDisplayString(S.label),11,aE)):(s.openBlock(),s.createElementBlock("span",cE,s.toDisplayString(S.label),1)),B<yu.value.length-1?(s.openBlock(),s.createElementBlock("span",dE,", ")):s.createCommentVNode("",!0)],64))),128)):(s.openBlock(),s.createElementBlock("span",uE,"—"))])]),s.createElementVNode("div",fE,[s.createElementVNode("span",pE,[x[12]||(x[12]=s.createElementVNode("span",{class:"vs-map-status__label"},"Центр:",-1)),h.value?(s.openBlock(),s.createElementBlock("span",hE,s.toDisplayString(h.value.center.lng.toFixed(5))+", "+s.toDisplayString(h.value.center.lat.toFixed(5)),1)):(s.openBlock(),s.createElementBlock("span",mE,"—"))]),h.value&&h.value.areaKm2!==null?(s.openBlock(),s.createElementBlock("span",gE,[x[13]||(x[13]=s.createElementVNode("span",{class:"vs-map-status__label"},"Площа:",-1)),s.createElementVNode("span",yE,s.toDisplayString(h.value.areaKm2.toFixed(1))+" km²",1)])):s.createCommentVNode("",!0),s.createElementVNode("div",bE,[s.createElementVNode("button",{type:"button",class:"vs-status-btn vs-status-btn--zoom",title:"Масштаб до об'єкта",onClick:GR,disabled:c.value},[s.createVNode(s.unref(Y.ZoomIn),{class:"vs-status-btn__icon"})],8,kE),s.createElementVNode("button",{type:"button",class:"vs-status-btn vs-status-btn--delete",title:"Видалити об'єкт",onClick:qR,disabled:c.value},[s.createVNode(s.unref(Y.Trash2),{class:"vs-status-btn__icon"})],8,wE)])])])])):s.createCommentVNode("",!0)],2)],8,["disabled"]))}}),[["__scopeId","data-v-780ba2d7"]]),AE=["data-focus"],_E={class:"flex items-center"},TE={class:"overflow-hidden text-ellipsis whitespace-nowrap rounded-sm text-[#333] text-[85%] px-0.5 py-[3px] pl-1.5 box-border"},BE=["onClick","aria-label"],NE={key:0,class:"absolute text-gray-500 truncate pl-2"},DE={class:"flex-1 min-w-[2px]"},VE=["placeholder"],$E={class:"flex items-center shrink-0"},LE=["disabled"],uf=s.defineComponent({__name:"vs-input-tag",props:s.mergeModels({unique:{type:Boolean,default:!0},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:"Введіть тег"},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:s.mergeModels(["update:modelValue"],["update:modelValue"]),setup(n,{emit:e}){const t=n,r=e;Vt(t.style);const o=s.ref(null),i=s.ref(null),l=s.ref(null),a=s.ref(!1),c=s.ref(""),d=s.useModel(n,"modelValue"),u=s.computed(()=>t.placeholder||"Add tag…"),f=s.computed(()=>d.value?.length===0&&c.value===""),p=s.computed(()=>!t.disabled&&d.value?.length>0),h=s.computed(()=>t.disabled),m=async()=>{h.value||await s.nextTick(()=>l.value?.focus())},g=R=>{const T=R.trim();T!==""&&(!d.value||!Array.isArray(d.value)?d.value=[T]:t.unique?d.value.includes(T)||(d.value=[...d.value,T]):d.value=[...d.value,T],c.value="")},y=()=>{const R=c.value;R.trim()!==""&&g(R),c.value=""},b=R=>{const T=d.value.slice();T.splice(R,1),r("update:modelValue",T)},w=()=>{r("update:modelValue",[])},v=()=>{h.value||(a.value=!0)},E=()=>{a.value=!1,!h.value&&y()},N=R=>{const{key:T}=R;T==="Enter"?(R.preventDefault(),y()):T==="Backspace"&&c.value===""&&d.value.length>0&&b(d.value.length-1)};return(R,T)=>(s.openBlock(),s.createElementBlock("div",{class:"flex gap-1 w-full",ref_key:"root",ref:o,onClick:T[1]||(T[1]=s.withModifiers(()=>{},["stop"]))},[s.createElementVNode("div",{class:s.normalizeClass(["relative w-full font-sans",t.customClass]),role:"group","aria-label":"Tag input"},[s.createElementVNode("div",{class:s.normalizeClass(["flex min-h-[38px] items-center justify-between rounded border transition-colors bg-white","border-gray-300 hover:border-gray-400",a.value?"border-blue-500 ring-1 ring-blue-500":"",h.value?"bg-gray-100 text-gray-400 cursor-not-allowed hover:border-gray-300":""]),"data-focus":a.value?"true":"false",onClick:m},[s.createElementVNode("div",{class:"flex flex-1 flex-wrap items-center gap-1 py-0.5 pl-2 pr-0 overflow-hidden",ref_key:"chipsRef",ref:i},[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(d.value,(M,_)=>(s.openBlock(),s.createElementBlock("div",{key:_,class:"flex min-w-0 bg-[#e6e6e6] rounded-sm m-0.5 box-border"},[s.createElementVNode("div",_E,[s.createElementVNode("div",TE,s.toDisplayString(M),1)]),s.createElementVNode("div",{role:"button",class:"flex items-center rounded-sm px-1 box-border hover:bg-[#ffbdad] hover:text-[#de350b]",onClick:s.withModifiers(A=>b(_),["stop"]),"aria-label":`Remove ${M}`},[s.createVNode(s.unref(Y.X),{"aria-hidden":"true",focusable:"false",class:"inline-block h-4 w-4"})],8,BE)]))),128)),f.value?(s.openBlock(),s.createElementBlock("div",NE,s.toDisplayString(u.value),1)):s.createCommentVNode("",!0),s.createElementVNode("div",DE,[h.value?s.createCommentVNode("",!0):s.withDirectives((s.openBlock(),s.createElementBlock("input",{key:0,ref_key:"inputRef",ref:l,class:"pl-2 w-full bg-transparent outline-none border-0 m-0 p-0 text-gray-900",autocapitalize:"none",autocomplete:"off",autocorrect:"off",spellcheck:"false",type:"text",tabindex:"0","aria-label":"Add tag","onUpdate:modelValue":T[0]||(T[0]=M=>c.value=M),onFocus:v,onBlur:E,onKeydown:N,placeholder:d.value&&d.value.length?"":void 0},null,40,VE)),[[s.vModelText,c.value]])])],512),s.createElementVNode("div",$E,[p.value?(s.openBlock(),s.createElementBlock("button",{key:0,type:"button",class:"px-2 text-gray-400 hover:text-gray-500 transition-colors disabled:opacity-50","aria-label":"Clear all tags",disabled:h.value,onClick:s.withModifiers(w,["stop"])},[s.createVNode(s.unref(Y.X),{class:"h-4 w-4"})],8,LE)):s.createCommentVNode("",!0)])],10,AE)],2)],512))}}),IE={class:"relative flex gap-1 bg-white w-full"},OE=["disabled","placeholder"],ff=Ne(s.defineComponent({__name:"vs-input-slug",props:s.mergeModels({disabled:{type:Boolean},placeholder:{},parent:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const e=s.inject("values"),t=n,r=s.useModel(n,"modelValue");function o(l){const a={а:"a",б:"b",в:"v",г:"g",д:"d",е:"e",ё:"e",ж:"zh",з:"z",и:"i",й:"y",к:"k",л:"l",м:"m",н:"n",о:"o",п:"p",р:"r",с:"s",т:"t",у:"u",ф:"f",х:"kh",ц:"ts",ч:"ch",ш:"sh",щ:"shch",ы:"y",э:"e",ю:"yu",я:"ya",ь:"",ъ:"",є:"ye",і:"i",ї:"yi",ґ:"g"};return l.toLowerCase().split("").map(c=>a[c]||c).join("").replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}const i=()=>{const l=e?.value?.[t.parent||""]?.toString(),a=o(l);r.value=a.toString()};return(l,a)=>(s.openBlock(),s.createElementBlock("div",IE,[s.withDirectives(s.createElementVNode("input",{ref:"vsText",disabled:l.disabled,placeholder:l.placeholder,"onUpdate:modelValue":a[0]||(a[0]=c=>r.value=c),class:"block w-full px-3 py-2 text-sm border border-solid rounded-lg placeholder:text-nowrap border-stone-200 text-stone-800 placeholder:text-stone-400 focus:outline focus:z-10 focus:border-blue-500 focus:ring-blue-500 focus:outline-blue-500"},null,8,OE),[[s.vModelText,r.value]]),s.createElementVNode("button",{class:"px-2 bg-gray-100 border rounded-lg hover:bg-gray-200",onClick:i}," Gen ")]))}}),[["__scopeId","data-v-b0eba370"]]),RE={class:"relative flex gap-1 bg-white w-full"},FE=["disabled","placeholder"],PE=["disabled"],zE={key:0},HE={key:1},pf=Ne(s.defineComponent({__name:"vs-input-codegen",props:s.mergeModels({table:{},code:{},init:{type:Boolean},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const e=n,t=s.useModel(n,"modelValue"),r=s.ref(!1),o=s.computed(()=>e.init!==!1),i=s.computed(()=>!!e.table&&!!e.code),l=()=>{if(!i.value)return"";const d=encodeURIComponent(String(e.table)),u=encodeURIComponent(String(e.code));return`/api/code-gen/${d}/${u}`},a=async()=>{if(!i.value||r.value)return;const d=l();if(d){r.value=!0;try{const f=await(await fetch(d)).text();t.value=f}finally{r.value=!1}}},c=()=>{o.value&&(t.value||a())};return s.onMounted(()=>{c()}),s.watch(()=>[e.table,e.code,e.init],()=>{c()}),(d,u)=>(s.openBlock(),s.createElementBlock("div",RE,[s.withDirectives(s.createElementVNode("input",{disabled:d.disabled,placeholder:d.placeholder,"onUpdate:modelValue":u[0]||(u[0]=f=>t.value=f),class:"block w-full px-3 py-2 text-sm border border-solid rounded-lg placeholder:text-nowrap border-stone-200 text-stone-800 placeholder:text-stone-400 focus:outline focus:z-10 focus:border-blue-500 focus:ring-blue-500 focus:outline-blue-500"},null,8,FE),[[s.vModelText,t.value]]),s.createElementVNode("button",{class:"px-2 bg-gray-100 border rounded-lg hover:bg-gray-200 disabled:opacity-50 disabled:cursor-not-allowed",disabled:r.value||d.disabled||!i.value,onClick:a},[r.value?(s.openBlock(),s.createElementBlock("span",HE,"...")):(s.openBlock(),s.createElementBlock("span",zE,"Gen"))],8,PE)]))}}),[["__scopeId","data-v-6ee5237d"]]),jE={class:"w-full"},UE={ref:"sortableContainer",class:"flex flex-col gap-1"},WE=["onDragstart","onDrop"],KE={class:"cursor-move",type:"button"},qE={class:"w-1/3"},GE={class:"w-2/3"},JE=["onClick"],YE={key:0,class:"text-[14px] text-gray-700"},XE={class:"mt-2 w-full flex items-center"},ZE=["disabled"],hf=Ne(s.defineComponent({__name:"vs-input-key-value",props:{parent:{},ignore:{},addButtonText:{},modelValue:{}},emits:["update:modelValue"],setup(n,{emit:e}){const t=y=>`${y}-${Math.random().toString(36).substring(2,15)}`,r=s.inject("values"),o=n,i=e,l=o.addButtonText??"Додати",a=o.ignore??[],c=s.ref([]),d=s.ref(null);(()=>{const y=o.parent&&r?.value?.[o.parent]||o.modelValue||{};c.value=Object.entries(y).filter(([b])=>!a.includes(b)).map(([b,w])=>({id:t("key-value-"),key:b,value:w}))})();function f(y){d.value=y}function p(y){if(d.value===null||d.value===y)return;const b=c.value.splice(d.value,1)[0];c.value.splice(y,0,b),d.value=null}const h=s.computed(()=>c.value.some(y=>y.key&&!y.value||!y.key&&y.value)),m=()=>{c.value.push({id:t("key-value-"),key:"",value:""})},g=y=>{c.value=c.value.filter(b=>b.id!==y)};return s.watch(c,y=>{const b={};y.forEach(v=>{v.key&&v.value!==void 0&&(b[v.key]=v.value)});const w={};a.length&&a.forEach(v=>{w[v]=o.parent?r?.value?.[o.parent]?.[v]:void 0}),r?.value&&o.parent&&(r.value[o.parent]={...w,...b}),i("update:modelValue",b)},{deep:!0}),(y,b)=>(s.openBlock(),s.createElementBlock("div",jE,[s.createElementVNode("div",UE,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(c.value,(w,v)=>(s.openBlock(),s.createElementBlock("div",{key:w.id,class:s.normalizeClass(["flex items-center gap-2 w-full",{"opacity-50":d.value===v}]),draggable:"true",onDragstart:E=>f(v),onDragover:b[0]||(b[0]=s.withModifiers(()=>{},["prevent"])),onDrop:E=>p(v)},[s.createElementVNode("button",KE,[s.createVNode(s.unref(Y.GripVertical),{class:"h-4 w-4"})]),s.createElementVNode("div",qE,[s.createVNode(no,{modelValue:w.key,"onUpdate:modelValue":E=>w.key=E,placeholder:"Ключ"},null,8,["modelValue","onUpdate:modelValue"])]),s.createElementVNode("div",GE,[s.createVNode(no,{modelValue:w.value,"onUpdate:modelValue":E=>w.value=E,placeholder:"Значення"},null,8,["modelValue","onUpdate:modelValue"])]),s.createElementVNode("button",{onClick:E=>g(w.id),class:"shrink-0 w-[30px] text-gray-600 h-[30px] rounded-full flex items-center justify-center bg-gray-100 hover:bg-gray-200"},[s.createVNode(s.unref(Y.X),{class:"h-4 w-4"})],8,JE)],42,WE))),128))],512),c.value.length?s.createCommentVNode("",!0):(s.openBlock(),s.createElementBlock("span",YE," Дані для відображення відсутні ")),s.createElementVNode("div",XE,[s.createElementVNode("button",{type:"button",onClick:m,disabled:h.value,class:"py-1.5 px-2 flex items-center gap-x-1 text-xs font-medium rounded-full border border-dashed border-gray-200 bg-white text-gray-800 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"},[s.createVNode(s.unref(Y.Plus),{class:"h-4 w-4"}),s.createTextVNode(" "+s.toDisplayString(s.unref(l)),1)],8,ZE)])]))}}),[["__scopeId","data-v-d8c3f9d6"]]),QE={class:"w-full"},eM={ref:"sortableContainer",class:"flex flex-col gap-1"},tM=["onDragstart","onDrop"],nM=["disabled"],rM={class:"flex-1"},oM=["onClick","disabled"],sM={key:0,class:"text-[14px] text-gray-700"},iM={class:"mt-2 w-full flex items-center"},lM=["disabled"],mf=Ne(s.defineComponent({__name:"vs-input-text-array",props:s.mergeModels({addButtonText:{default:"Додати"},inputType:{default:"text"},placeholder:{default:"Значення"},mask:{default:""},disabled:{type:Boolean,default:!1}},{modelValue:{default:[]},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const e=n,t=s.useModel(n,"modelValue"),r=s.ref([]),o=s.ref(null),i=s.computed(()=>!!e.disabled),l=s.computed(()=>e.placeholder??""),a=s.computed(()=>e.addButtonText??"Додати");let c=!1;const d=y=>`${y}-${Math.random().toString(36).substring(2,15)}`,u=y=>{const b=y??t.value??[];r.value=b.map((w,v)=>({id:r.value[v]?.id??d("text-array"),value:w??""}))};u(),s.watch(()=>t.value,y=>{if(c){c=!1;return}u(y||[])},{deep:!0}),s.watch(r,y=>{c=!0,t.value=y.map(b=>b.value).filter(b=>b!=null&&b!=="")},{deep:!0});const f=s.computed(()=>i.value||r.value.some(y=>!y.value));function p(){f.value||(r.value=[...r.value,{id:d("text-array"),value:""}])}function h(y){i.value||(r.value=r.value.filter(b=>b.id!==y))}function m(y){i.value||(o.value=y)}function g(y){if(i.value||o.value===null||o.value===y)return;const b=[...r.value],[w]=b.splice(o.value,1);b.splice(y,0,w),r.value=b,o.value=null}return(y,b)=>(s.openBlock(),s.createElementBlock("div",QE,[s.createElementVNode("div",eM,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(r.value,(w,v)=>(s.openBlock(),s.createElementBlock("div",{key:w.id,class:s.normalizeClass(["flex items-center gap-2 w-full",{"opacity-50":o.value===v}]),draggable:"true",onDragstart:E=>m(v),onDragover:b[0]||(b[0]=s.withModifiers(()=>{},["prevent"])),onDrop:E=>g(v)},[s.createElementVNode("button",{class:"cursor-move",type:"button",disabled:i.value},[s.createVNode(s.unref(Y.GripVertical),{class:"h-4 w-4"})],8,nM),s.createElementVNode("div",rM,[y.inputType==="text"?(s.openBlock(),s.createBlock(no,{key:0,modelValue:w.value,"onUpdate:modelValue":E=>w.value=E,disabled:i.value,placeholder:l.value},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):s.createCommentVNode("",!0),y.inputType==="tel"?(s.openBlock(),s.createBlock(ya,{key:1,modelValue:w.value,"onUpdate:modelValue":E=>w.value=E,disabled:i.value,placeholder:l.value},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):s.createCommentVNode("",!0),y.inputType==="email"?(s.openBlock(),s.createBlock(ga,{key:2,modelValue:w.value,"onUpdate:modelValue":E=>w.value=E,disabled:i.value,placeholder:l.value},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):s.createCommentVNode("",!0),y.inputType==="mask"?(s.openBlock(),s.createBlock(qs,{key:3,modelValue:w.value,"onUpdate:modelValue":E=>w.value=E,mask:y.mask,disabled:i.value,placeholder:l.value},null,8,["modelValue","onUpdate:modelValue","mask","disabled","placeholder"])):s.createCommentVNode("",!0)]),s.createElementVNode("button",{type:"button",onClick:E=>h(w.id),disabled:i.value,class:"shrink-0 w-[30px] text-gray-600 h-[30px] rounded-full flex items-center justify-center bg-gray-100 hover:bg-gray-200 disabled:opacity-50"},[s.createVNode(s.unref(Y.X),{class:"h-4 w-4"})],8,oM)],42,tM))),128))],512),r.value.length?s.createCommentVNode("",!0):(s.openBlock(),s.createElementBlock("span",sM," Дані для відображення відсутні ")),s.createElementVNode("div",iM,[s.createElementVNode("button",{type:"button",onClick:p,disabled:f.value,class:"py-1.5 px-2 flex items-center gap-x-1 text-xs font-medium rounded-full border border-dashed border-gray-200 bg-white text-gray-800 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"},[s.createVNode(s.unref(Y.Plus),{class:"h-4 w-4"}),s.createTextVNode(" "+s.toDisplayString(a.value),1)],8,lM)])]))}}),[["__scopeId","data-v-2c229b1f"]]),aM={class:"flex items-center gap-2 w-full"},cM=["disabled"],dM=["disabled"],gf=s.defineComponent({__name:"vs-input-color",props:{style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{}},emits:["update:modelValue"],setup(n,{emit:e}){const t=n,{inputClass:r}=Vt(t.style),o=e,i=s.computed({get:()=>t.modelValue||"#000000",set:a=>o("update:modelValue",a)}),l=s.computed(()=>!!t.disabled);return(a,c)=>(s.openBlock(),s.createElementBlock("div",aM,[s.withDirectives(s.createElementVNode("input",{type:"color","onUpdate:modelValue":c[0]||(c[0]=d=>i.value=d),disabled:l.value,ref:"color",class:s.normalizeClass(["py-1.5 px-1 block w-full bg-white cursor-pointer max-w-[50px]",[a.modelValue?"":"text-opacity-50",s.unref(r)].join(" ")]),style:{border:"1px solid #CFD9E0"}},null,10,cM),[[s.vModelText,i.value]]),s.withDirectives(s.createElementVNode("input",{class:"text-sm text-gray-600 border border-solid border-stone-200 rounded-md p-2","onUpdate:modelValue":c[1]||(c[1]=d=>i.value=d),disabled:l.value},null,8,dM),[[s.vModelText,i.value]])]))}}),uM={class:"flex items-center gap-2 w-full"},fM=["min","max","step","disabled"],pM=["value","min","max","step","disabled"],yf=s.defineComponent({__name:"vs-input-range",props:{style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{},min:{default:0},max:{default:100},step:{default:1}},emits:["update:modelValue"],setup(n,{emit:e}){const t=n,{inputClass:r}=Vt(t.style),o=e,i=u=>{const f=Number(u),p=Number(t.min),h=Number(t.max);return Number.isNaN(f)?p:Math.min(h,Math.max(p,f))},l=s.computed({get:()=>i(t.modelValue??t.min),set:u=>o("update:modelValue",i(u))}),a=u=>{const f=u.target,p=i(f.value);f.value=String(p),o("update:modelValue",p)},c=u=>{Number(t.min)>=0&&u.key==="-"&&u.preventDefault()},d=s.computed(()=>!!t.disabled);return(u,f)=>(s.openBlock(),s.createElementBlock("div",uM,[s.withDirectives(s.createElementVNode("input",{type:"range","onUpdate:modelValue":f[0]||(f[0]=p=>l.value=p),min:u.min,max:u.max,step:u.step,disabled:d.value,ref:"range",class:s.normalizeClass(["w-full cursor-pointer accent-blue-500",[u.modelValue?"":"text-opacity-50",s.unref(r)].join(" ")])},null,10,fM),[[s.vModelText,l.value]]),s.createElementVNode("input",{class:"text-sm text-gray-600 border border-solid border-stone-200 rounded-md p-2 max-w-[100px]",type:"number",value:l.value,min:u.min,max:u.max,step:u.step,onInput:a,onKeydown:c,disabled:d.value},null,40,pM)]))}}),hM=["placeholder","disabled","name"],mM=["type","value","onInput","placeholder","disabled"],gM=["onClick"],bf=s.defineComponent({__name:"vs-input-array",props:s.mergeModels({count:{default:1},limit:{default:1},mask:{default:""},unmask:{type:Boolean,default:!1},inputType:{default:"text"},isAdded:{type:Boolean,default:!1},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const e=n,t=s.ref(e.count),r=s.computed(()=>e.limit),{inputClass:o}=Vt(e.style),i=s.useModel(n,"modelValue"),l=s.computed(()=>!!e.disabled),a=s.computed(()=>e.placeholder??"");s.watchEffect(()=>{const g=i.value?.length??0;g<t.value&&(i.value=[...i.value??[],...Array(t.value-g)])});const c=s.ref({}),d=s.ref({});function u(g,y){g&&(c.value[y]=g)}async function f(g,y){if(!g||e.inputType!=="mask")return;const{default:b}=await Promise.resolve().then(()=>xi);d.value[y]&&d.value[y].destroy(),d.value[y]=b(g,{mask:e.mask||"",definitions:{9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},lazy:!1}),d.value[y].on("accept",()=>{const w=[...i.value||[]];w[y]=e.unmask?d.value[y].unmaskedValue:d.value[y].value,i.value=w}),d.value[y].on("complete",()=>{const w=[...i.value||[]];w[y]=e.unmask?d.value[y].unmaskedValue:d.value[y].value,i.value=w}),i.value?.[y]&&(d.value[y].value=i.value[y])}function p(g,y){if(l.value)return;const b=g.target.value??null,w=[...i.value];w[y]=e.inputType==="text"?b:Number(b),i.value=w}function h(){t.value+=1;const g=e.inputType==="text"||e.inputType==="mask"?null:0;i.value=[...i.value,g],e.inputType==="mask"&&setTimeout(()=>{const y=t.value-1;c.value[y]&&f(c.value[y],y)},0)}function m(g){if(t.value>1){d.value[g]&&(d.value[g].destroy(),delete d.value[g]),t.value-=1,i.value=i.value.filter((b,w)=>w!==g);const y={};Object.keys(d.value).forEach(b=>{const w=parseInt(b,10);w>g?y[w-1]=d.value[w]:w<g&&(y[w]=d.value[w])}),d.value=y}}return s.onMounted(()=>{if(e.inputType==="mask")for(let g=0;g<t.value;g+=1)c.value[g]&&f(c.value[g],g)}),s.onBeforeUnmount(()=>{Object.values(d.value).forEach(g=>{g&&g.destroy()})}),s.watch(()=>e.mask,g=>{e.inputType==="mask"&&Object.values(d.value).forEach(y=>{y&&y.updateOptions({mask:g,definitions:{9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/}})})}),s.watch(i,g=>{e.inputType==="mask"&&g&&g.forEach((y,b)=>{d.value[b]&&d.value[b].value!==y&&(d.value[b].value=y||"")})},{deep:!0}),(g,y)=>(s.openBlock(),s.createElementBlock("div",{class:s.normalizeClass(["grid gap-2",`grid-cols-${r.value}`])},[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(t.value,b=>(s.openBlock(),s.createElementBlock("div",{key:b,class:"flex items-center gap-2 w-full"},[g.inputType==="mask"?(s.openBlock(),s.createElementBlock("input",{key:0,type:"text",ref_for:!0,ref:w=>u(w,b-1),placeholder:g.placeholder,disabled:g.disabled,name:`${g.name}[${b-1}]`,class:s.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[s.unref(o),{"!border-red-600":g.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,hM)):(s.openBlock(),s.createElementBlock("input",{key:1,type:g.inputType,value:i.value?.[b-1],onInput:w=>p(w,b-1),placeholder:a.value,disabled:l.value,class:s.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[s.unref(o),{"!border-red-600":g.error}]]),style:{border:"1px solid #CFD9E0"}},null,42,mM)),!g.disabled&&b===t.value&&g.isAdded?(s.openBlock(),s.createElementBlock("button",{key:2,type:"button",onClick:s.withModifiers(h,["stop"]),class:"cursor-pointer shrink-0 w-[38px] text-green-600 h-[38px] rounded-md flex items-center justify-center border border-stone-200 hover:bg-stone-100"},[s.createVNode(s.unref(Y.Plus),{class:"h-4 w-4"})])):s.createCommentVNode("",!0),!g.disabled&&t.value>1&&g.isAdded?(s.openBlock(),s.createElementBlock("button",{key:3,type:"button",onClick:s.withModifiers(w=>m(b-1),["stop"]),class:"cursor-pointer shrink-0 w-[38px] text-red-600 h-[38px] rounded-md flex items-center justify-center border border-stone-200 hover:bg-stone-100"},[s.createVNode(s.unref(Y.X),{class:"h-4 w-4"})],8,gM)):s.createCommentVNode("",!0)]))),128))],2))}}),yM={class:"flex gap-1 w-full"},bM=["aria-expanded","data-focus"],kM=["placeholder","disabled","readonly"],wM={class:"max-h-full"},xM=["onClick","disabled"],vM={key:0,class:"px-3 py-2 text-sm text-stone-500"},CM=["disabled"],SM={class:"flex flex-col gap-1"},EM=["onDragstart","onDrop"],MM=["disabled"],AM=["title"],_M=["disabled","onClick","aria-label"],TM={key:0,class:"text-xs text-stone-500"},pi=Ne(s.defineComponent({__name:"vs-input-array-select",props:s.mergeModels({options:{default:()=>[]},data:{default:""},api:{default:""},prefix:{default:"api"},host:{default:""},parent:{},search:{type:Boolean,default:!0},maxHeight:{default:280},start:{default:0},slot:{},disabled:{type:Boolean,default:!1},add:{},style:{},customClass:{},modelValue:{},error:{},name:{},placeholder:{default:"Оберіть значення"},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:s.mergeModels(["change","update:modelValue","value-selected"],["update:modelValue"]),setup(n,{emit:e}){const t=n,r=e,o=s.useModel(n,"modelValue"),i=s.ref([]),l=s.ref(t.options??[]),a=s.ref({}),c=s.ref({}),d=s.ref({keyword:"",parent:null}),u=s.ref(""),f=s.ref(!1),p=s.ref(null),h=s.ref(null),m=s.ref(null),g=s.ref(null),y=s.ref(null),b=s.ref({});let w=!1,v=!1;const E=s.inject("values"),N=s.computed(()=>!!t.disabled),R=s.computed(()=>t.placeholder??"Оберіть значення"),T=s.computed(()=>t.search!==!1),M=s.computed(()=>{const C=t.parent??t.parentValue;return C?String(C):""}),_=s.computed(()=>M.value?E?.value?.[M.value]??null:null),A=C=>C==null?"__null__":String(C),L=C=>{if(!C)return"";const V=C.label??C.text??C.name??C.ua??C.en;return V?String(V):C.id!==void 0&&C.id!==null?String(C.id):""},z=C=>{const V=A(C);return c.value[V]||(c.value[V]=`array-select-${V}-${Math.random().toString(36).slice(2,8)}`),c.value[V]},Z=s.computed(()=>new Set(i.value.map(C=>A(C.id)))),D=s.computed(()=>{const C=Z.value;let V=[...l.value];if(!t.data&&u.value.trim()){const j=u.value.toLowerCase();V=V.filter(ie=>L(ie).toLowerCase().includes(j))}return V.filter(j=>!C.has(A(j.id)))}),P=()=>{if(!t.data)return"";const C=t.prefix??"api",V=t.api??`/${C}/suggest/${t.data}`;return`${t.host??""}${V}`},ne=()=>{i.value.length&&(w=!0,i.value=i.value.map(C=>({...C,text:a.value[A(C.id)]??C.text})))},U=C=>{const V=A(C.id),j=L(C);j&&(a.value[V]=j)},K=C=>{l.value=C?[...C]:[],C?.forEach(U),ne()},X=C=>{if(!C.length)return;const V=new Map(l.value.map(j=>[A(j.id),j]));C.forEach(j=>{const ie=A(j.id);V.set(ie,j),U(j)}),l.value=Array.from(V.values()),ne()},le=async(C="")=>{if(!t.data)return[];const V=P();if(!V)return[];const j=new URLSearchParams;j.set("json","1"),C&&j.set("key",C),t.start===1&&j.set("start","1"),_.value!==null&&_.value!==void 0&&_.value!==""&&j.set("parent",String(_.value));try{return(await(await fetch(`${V}?${j.toString()}`)).json())?.data??[]}catch{return[]}},H=async C=>{if(!t.data||!C.length)return[];const V=P();if(!V)return[];const j=Array.from(new Set(C.map(Me=>A(Me)))),ie=new URLSearchParams;ie.set("json","1"),ie.set("val",j.join(",")),t.start===1&&ie.set("start","1"),_.value!==null&&_.value!==void 0&&_.value!==""&&ie.set("parent",String(_.value));try{const Ge=(await(await fetch(`${V}?${ie.toString()}`)).json())?.data??[];return X(Ge),Ge}catch{return[]}},$=async C=>{if(C==null||C==="")return null;const V=A(C),j=l.value.find(Me=>A(Me.id)===V);if(j)return j;const[ie]=await H([C]);return ie??null},I=async(C="",{force:V=!1}={})=>{if(!t.data)return;const j=_.value??null;if(!V&&d.value.keyword===C&&d.value.parent===j&&l.value.length>0)return;d.value={keyword:C,parent:j};const Me=await le(C);K(Me)},ae=((C,V=200)=>{let j;return(...ie)=>{j&&clearTimeout(j),j=setTimeout(()=>C(...ie),V)}})(async C=>{t.data&&await I(C,{force:!0})},250),re=s.ref(null),ge=()=>{if(!m.value)return;const C=m.value.getBoundingClientRect(),V=window.innerHeight??document.documentElement.clientHeight,j=window.innerWidth??document.documentElement.clientWidth,ie=8,Me=8,Ze=t.maxHeight??280,Ge=V-C.bottom-Me-ie,ut=C.top-Me-ie,mt=Ge>=ut,nn=Math.max(j-ie*2,0);let{width:gt}=C;nn>0&&gt>nn&&(gt=nn);let{left:Wt}=C;Wt+gt+ie>j&&(Wt=j-gt-ie),Wt=Math.max(Wt,ie);const xr=Math.min(Ze,Math.max(mt?Ge:ut,50));b.value={position:"fixed",left:`${Wt}px`,width:`${gt}px`,maxHeight:`${xr}px`,transform:mt?"none":"translateY(-100%)",top:mt?`${C.bottom+Me}px`:`${C.top-Me}px`}},Ee=async(C="click")=>{N.value||f.value||(re.value=C,await I(u.value.trim()),f.value=!0,await s.nextTick(),ge(),y.value?.focus())},xe=()=>{f.value=!1,re.value=null,s.nextTick(()=>{y.value?.blur()})},Ie=async C=>{if(C.stopPropagation(),!N.value){if(f.value){if(re.value==="focus"){re.value=null;return}xe();return}await Ee("click")}},je=C=>{C.key==="Escape"&&xe()},Fe=C=>{if(!f.value)return;const V=C.target;g.value?.contains(V)||xe()},ot=C=>{const V=C.target;h.value?.contains(V)||g.value?.contains(V)||xe()},We=C=>{if(C.key==="Escape"){C.preventDefault(),xe();return}if(C.key==="Enter"){C.preventDefault();const V=D.value[0];V&&oe(V)}},oe=C=>{if(!C)return;const V=A(C.id);if(Z.value.has(V))return;U(C);const j={id:C.id,text:L(C)||String(C.id??""),key:z(C.id)};i.value=[...i.value,j],pe(C),u.value="",s.nextTick(()=>{y.value?.focus()})},pe=C=>{const V=i.value.map(j=>j.id);r("value-selected",{name:t.name,value:V,option:C})},_e=C=>{if(N.value)return;const V=i.value.filter(j=>A(j.id)!==A(C));i.value=V},{isOpenAdd:Te,addData:dt,addSchema:Ye,addForm:Dt,addTitle:Pe,addOption:qe,onAddValue:tn}=Ju({props:t,fetchOptionByValue:$,optionsList:l,selectedOption:s.ref(null),modelValue:o,onCreated:async(C,V)=>{const j=C??await $(V),ie=j?.id??V;Z.value.has(A(ie))||(j&&U(j),i.value=[...i.value,{id:ie,text:j?L(j):String(ie),key:z(ie)}],pe(j??null))}}),W=C=>{N.value||(p.value=C)},Q=C=>{if(N.value||p.value===null||p.value===C)return;const V=[...i.value],[j]=V.splice(p.value,1);V.splice(C,0,j),p.value=null,i.value=V},de=async()=>{const V=(Array.isArray(o.value)?[...o.value]:[]).filter(ie=>ie!=null);if(t.data&&V.length){const ie=V.filter(Me=>!a.value[A(Me)]);ie.length&&await H(ie)}const j=V.map(ie=>({id:ie,text:a.value[A(ie)]??String(ie),key:z(ie)}));w=!0,i.value=j};s.watch(i,C=>{if(w){w=!1;return}const V=C.map(j=>j.id);v=!0,o.value=V,r("change",V)},{deep:!0}),s.watch(o,()=>{if(v){v=!1;return}de()},{deep:!0}),s.watch(u,C=>{!t.data||!f.value||ae(C.trim())}),s.watch(N,C=>{C&&xe()}),s.watch(()=>t.options,async C=>{t.data||(K(C??[]),await de())},{immediate:!0,deep:!0}),s.watch(()=>t.data,async C=>{C&&(await I(u.value.trim()),await de())},{immediate:!0});const O=s.ref(!1);return s.watch(_,async()=>{if(t.data){if(!O.value){O.value=!0;return}i.value=[],await I(u.value.trim()),await de()}}),s.onMounted(async()=>{document.addEventListener("click",ot,!0),window.addEventListener("keydown",je),window.addEventListener("scroll",Fe,!0),await de()}),s.onUnmounted(()=>{document.removeEventListener("click",ot,!0),window.removeEventListener("keydown",je),window.removeEventListener("scroll",Fe,!0)}),(C,V)=>(s.openBlock(),s.createElementBlock(s.Fragment,null,[s.createVNode(s.unref(we.VsModal),{visible:s.unref(Te),"onUpdate:visible":V[1]||(V[1]=j=>s.isRef(Te)?Te.value=j:null),class:"z-[1000]",title:s.unref(Pe),buttonText:"Додати",onDone:s.unref(qe)},{default:s.withCtx(()=>[s.createVNode(zt,{schema:s.unref(Ye),modelValue:s.unref(dt),"onUpdate:modelValue":V[0]||(V[0]=j=>s.isRef(dt)?dt.value=j:null),ref_key:"addForm",ref:Dt},null,8,["schema","modelValue"])]),_:1},8,["visible","title","onDone"]),s.createElementVNode("div",{class:"flex flex-col gap-2 w-full",ref_key:"rootRef",ref:h},[s.createElementVNode("div",yM,[s.createElementVNode("div",{class:"relative flex-1",onClick:V[4]||(V[4]=s.withModifiers(()=>{},["stop"]))},[s.createElementVNode("div",{ref_key:"triggerRef",ref:m,class:s.normalizeClass(["flex min-h-[38px] items-center justify-between rounded border transition-colors bg-white px-3","border-gray-300 hover:border-[#b3d4ff]",f.value?"border-[#2684ff] ring-1 ring-[#2684ff] shadow-[0_0_0_1px_rgba(38,132,255,0.5)]":"",N.value?"bg-gray-100 text-gray-400 cursor-not-allowed hover:border-gray-300":""]),role:"combobox","aria-expanded":f.value,"aria-haspopup":"listbox","data-focus":f.value?"true":"false",onClick:Ie},[s.withDirectives(s.createElementVNode("input",{ref_key:"inputRef",ref:y,"onUpdate:modelValue":V[2]||(V[2]=j=>u.value=j),placeholder:R.value,disabled:N.value,readonly:!T.value,onFocus:V[3]||(V[3]=()=>Ee("focus")),onKeydown:We,class:"flex-1 bg-transparent border-0 outline-none px-0 py-1 text-sm text-stone-900 placeholder:text-stone-400"},null,40,kM),[[s.vModelText,u.value]]),s.createElementVNode("span",{class:s.normalizeClass(["text-stone-400 transition-transform duration-150",f.value?"rotate-180":""]),"aria-hidden":"true"},[s.createVNode(s.unref(Y.ChevronDown),{class:"h-4 w-4"})],2)],10,bM),(s.openBlock(),s.createBlock(s.Teleport,{to:"body"},[s.createVNode(s.Transition,{name:"fade"},{default:s.withCtx(()=>[f.value?(s.openBlock(),s.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:g,class:"fixed z-[3000] rounded-md border border-stone-200 bg-white shadow-lg overflow-auto",style:s.normalizeStyle(b.value)},[s.createElementVNode("div",wM,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(D.value,j=>(s.openBlock(),s.createElementBlock("button",{key:A(j.id),type:"button",class:"w-full px-3 py-2 text-left text-sm text-stone-900 hover:bg-stone-100 disabled:opacity-50",onClick:s.withModifiers(ie=>oe(j),["stop"]),disabled:N.value},s.toDisplayString(L(j)),9,xM))),128)),D.value.length===0?(s.openBlock(),s.createElementBlock("p",vM," Немає варіантів ")):s.createCommentVNode("",!0)])],4)):s.createCommentVNode("",!0)]),_:1})]))]),t.add?(s.openBlock(),s.createElementBlock("button",{key:0,onClick:V[5]||(V[5]=(...j)=>s.unref(tn)&&s.unref(tn)(...j)),class:"bg-white hover:bg-gray-100 text-sm text-gray-900 py-[10px] px-3 border border-stone-200 rounded-md h-[38px] flex items-center gap-2",disabled:N.value,type:"button"},[s.createVNode(s.unref(Y.Plus),{class:"h-4 w-4"}),V[8]||(V[8]=s.createElementVNode("span",null,"Додати",-1))],8,CM)):s.createCommentVNode("",!0)]),s.createElementVNode("div",SM,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(i.value,(j,ie)=>(s.openBlock(),s.createElementBlock("div",{key:j.key,class:s.normalizeClass(["flex items-center gap-2 rounded-md border border-stone-200 bg-white px-2 py-2",{"opacity-60":p.value===ie}]),draggable:"true",onDragstart:Me=>W(ie),onDragover:V[6]||(V[6]=s.withModifiers(()=>{},["prevent"])),onDrop:Me=>Q(ie),onDragend:V[7]||(V[7]=Me=>p.value=null)},[s.createElementVNode("button",{type:"button",class:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-stone-500 hover:text-stone-900",disabled:N.value,"aria-label":"Перетягнути"},[s.createVNode(s.unref(Y.GripVertical),{class:"h-4 w-4"})],8,MM),s.createElementVNode("div",{class:"flex-1 text-sm text-stone-900",title:j.text},s.toDisplayString(j.text),9,AM),s.createElementVNode("button",{type:"button",class:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-stone-400 hover:text-stone-900",disabled:N.value,onClick:s.withModifiers(Me=>_e(j.id),["stop"]),"aria-label":`Видалити ${j.text}`},[s.createVNode(s.unref(Y.X),{class:"h-4 w-4"})],8,_M)],42,EM))),128)),i.value.length===0?(s.openBlock(),s.createElementBlock("p",TM,"Немає вибраних значень")):s.createCommentVNode("",!0)])],512)],64))}}),[["__scopeId","data-v-da4b4da7"]]),BM={class:"flex items-center gap-2 w-full"},NM={class:"relative flex-1"},DM=["placeholder","disabled","onKeydown"],VM=["disabled"],$M={key:0,class:"fixed inset-0 z-[1000] flex items-center justify-center bg-black/50"},LM={class:"bg-white text-gray-900 rounded-lg shadow-lg w-[480px] max-h-[80vh] overflow-y-auto"},IM={class:"p-3 border-b font-semibold text-gray-900 flex justify-between items-center"},OM=["onClick"],RM={key:0,class:"p-4 text-sm text-gray-500"},kf=s.defineComponent({__name:"vs-input-address",props:s.mergeModels({api:{default:""},geom:{default:""},includes:{default:()=>[]},bbox:{},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:s.mergeModels(["update:modelValue","update:geom"],["update:modelValue"]),setup(n,{emit:e}){const t=/{{\s*([^}]+?)\s*}}/g,r=n,o=e,{inputClass:i}=Vt(r.style),l=s.useModel(n,"modelValue"),a=s.computed({get:()=>l.value,set:T=>{l.value=T}}),c=s.ref(!1),d=s.ref([]),u=s.ref(!1),f=s.ref(null);s.watch(u,T=>{typeof document>"u"||(T?(f.value=document.body.style.overflow,document.body.style.overflow="hidden"):f.value!=null?(document.body.style.overflow=f.value,f.value=null):document.body.style.removeProperty("overflow"))}),s.onBeforeUnmount(()=>{typeof document>"u"||(f.value!=null?document.body.style.overflow=f.value:document.body.style.removeProperty("overflow"))});const p=s.computed(()=>r.placeholder??""),h=s.computed(()=>!!r.disabled),m=T=>{if(!T)return null;if(Array.isArray(T))return T;if(typeof T=="string"){const M=T.split(",").map(_=>_.trim()).filter(Boolean);return M.length!==4?null:M.map(Number)}return null},g=s.computed(()=>{const T=m(r.bbox);if(!T||T.length!==4)return null;const M=T.map(Number);return M.some(_=>Number.isNaN(_))?null:M}),y=s.computed(()=>{const T=g.value;if(!T)return"";const[M,_,A,L]=T;return`${M},${Math.max(_,L)},${A},${Math.min(_,L)}`});s.computed(()=>y.value?"1":"0");const b=s.inject("values");function w(){!h.value&&a.value.trim()&&v()}async function v(){const T=(a.value||"").trim();if(!T)return;let M=T;if(r.includes?.length&&b?.value){const A=r.includes.map(L=>b.value?.[L]).filter(Boolean);A.length&&(M=`${A.join(", ")}, ${T}`)}const _=R(M);if(_){c.value=!0;try{const L=await(await fetch(_)).json();d.value=Array.isArray(L)?L:[],u.value=!0}catch(A){console.error("Address search error:",A)}finally{c.value=!1}}}function E(){u.value=!u.value}function N(T){if(!T)return;u.value=!1;const M=parseFloat(T.lat),A={type:"Point",coordinates:[parseFloat(T.lon),M]};r.geom&&b?.value&&(b.value[r.geom]=A),o("update:geom",A)}function R(T){if(!r.api)return"";const M={value:encodeURIComponent(T),bbox:g.value?g.value.join(","):""};return r.api.replace(t,(_,A)=>M[A.trim()]??"")}return(T,M)=>(s.openBlock(),s.createElementBlock("div",BM,[s.createElementVNode("div",NM,[s.withDirectives(s.createElementVNode("input",{type:"text","onUpdate:modelValue":M[0]||(M[0]=_=>a.value=_),placeholder:p.value,disabled:h.value,class:s.normalizeClass(["py-1.5 px-3 block w-full bg-white border rounded-md placeholder:text-gray-400 focus:ring-2 focus:ring-blue-500",[s.unref(i),{"!border-red-600":r.error}]]),style:{border:"1px solid #CFD9E0"},onKeydown:s.withKeys(s.withModifiers(w,["prevent"]),["enter"])},null,42,DM),[[s.vModelText,a.value]]),d.value.length?(s.openBlock(),s.createElementBlock("button",{key:0,type:"button",class:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-blue-600",onClick:E,title:"Show search results"},[s.createVNode(s.unref(Y.Info),{class:"h-4 w-4"})])):s.createCommentVNode("",!0)]),s.createElementVNode("button",{type:"button",onClick:v,class:"flex items-center justify-center px-2 py-2 border rounded-md bg-white hover:bg-gray-50 text-gray-600 hover:text-blue-600 disabled:opacity-50 h-[38px]",disabled:c.value||!a.value?.trim()},[c.value?(s.openBlock(),s.createBlock(s.unref(Y.LoaderCircle),{key:1,class:"h-5 w-5 animate-spin text-gray-400"})):(s.openBlock(),s.createBlock(s.unref(Y.Search),{key:0,class:"h-4 w-4"}))],8,VM),(s.openBlock(),s.createBlock(s.Teleport,{to:"body"},[u.value?(s.openBlock(),s.createElementBlock("div",$M,[s.createElementVNode("div",LM,[s.createElementVNode("div",IM,[M[2]||(M[2]=s.createElementVNode("span",null,"Результати пошуку",-1)),s.createElementVNode("button",{class:"text-gray-500 hover:text-blue-600",onClick:M[1]||(M[1]=_=>u.value=!1),title:"Close"},[s.createVNode(s.unref(Y.X),{class:"h-4 w-4"})])]),s.createElementVNode("ul",null,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(d.value,(_,A)=>(s.openBlock(),s.createElementBlock("li",{key:A,onClick:L=>N(_),class:"px-3 py-2 cursor-pointer hover:bg-gray-100 border-b text-sm"},s.toDisplayString(_.display_name),9,OM))),128))]),d.value.length?s.createCommentVNode("",!0):(s.openBlock(),s.createElementBlock("div",RM," Не знайдено результатів "))])])):s.createCommentVNode("",!0)]))]))}}),FM={class:"vs-datalist space-y-3"},PM={class:"space-y-3"},zM=["onClick","disabled"],HM={key:0,class:"rounded-lg border border-dashed border-gray-200 p-4 text-sm text-gray-500"},jM=["disabled"],UM=Ne(s.defineComponent({__name:"vs-input-datalist",props:s.mergeModels({schema:{default:()=>[]},minItems:{default:0},maxItems:{default:void 0},addButtonText:{default:"Додати позицію"},emptyLabel:{default:"Немає рядків"},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const e=n,t=s.useModel(n,"modelValue"),r=s.computed(()=>Array.isArray(t.value)?t.value:[]),o=s.ref([]),i=s.computed(()=>e.schema?.map(y=>({...y,disabled:e.disabled||y.disabled}))??[]),l=s.computed(()=>i.value.map(y=>g(y))),a=s.computed(()=>i.value.reduce((b,w)=>{const v=Number(w?.col??12);return b+(Number.isFinite(v)&&v>0?v:12)},0)>12),c=s.computed(()=>e.disabled?!1:e.maxItems?r.value.length<e.maxItems:!0),d=s.computed(()=>e.disabled||r.value.length<=(e.minItems||0));s.watch(()=>r.value.length,()=>{u(),f()},{immediate:!0}),s.watch(()=>e.schema,f,{immediate:!0,deep:!0});function u(){const y=r.value.length;o.value.length<y?o.value=[...o.value,...Array.from({length:y-o.value.length},()=>Na())]:o.value.length>y&&o.value.splice(y)}function f(){if(!e.minItems||r.value.length>=e.minItems)return;const y=e.minItems-r.value.length,b=Array.from({length:y},p);t.value=[...r.value,...b]}function p(){const y={};return i.value.forEach(b=>{y[b.name]=b?.default??null}),y}function h(){c.value&&(t.value=[...r.value,p()],u())}function m(y){d.value||(t.value=r.value.filter((b,w)=>w!==y),u(),f())}function g(y){return{...y}}return(y,b)=>(s.openBlock(),s.createElementBlock("div",FM,[s.createElementVNode("div",PM,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(r.value,(w,v)=>(s.openBlock(),s.createElementBlock("div",{key:o.value[v],class:s.normalizeClass(["flex items-center gap-3 rounded-lg transition-colors",{"border border-gray-300 p-2":a.value}])},[s.createVNode(zt,{schema:l.value,layout:"inline",navigation:!1,values:r.value[v],"onUpdate:values":E=>r.value[v]=E,"form-id":o.value[v]},null,8,["schema","values","onUpdate:values","form-id"]),s.createElementVNode("button",{type:"button",class:"h-[38px] w-[38px] flex items-center justify-center text-gray-400 hover:text-gray-600 hover:bg-gray-50 rounded-lg transition-all disabled:opacity-40",onClick:E=>m(v),disabled:d.value},[s.createVNode(s.unref(Y.Trash2),{class:"h-4 w-4"})],8,zM)],2))),128)),r.value.length===0?(s.openBlock(),s.createElementBlock("div",HM,s.toDisplayString(e.emptyLabel),1)):s.createCommentVNode("",!0)]),s.createElementVNode("button",{type:"button",class:"flex items-center gap-2 text-gray-600 hover:text-gray-900 font-medium transition-colors text-sm",onClick:h,disabled:!c.value},[s.createVNode(s.unref(Y.Plus),{class:"h-4 w-4"}),s.createTextVNode(" "+s.toDisplayString(e.addButtonText),1)],8,jM)]))}}),[["__scopeId","data-v-d0065868"]]),WM={class:"vs-dataform space-y-4"},KM=["draggable","onDragstart","onDragover","onDragenter","onDrop"],qM={class:"flex items-center gap-2"},GM=["onClick"],JM={class:"text-sm font-medium text-gray-700"},YM={class:"flex items-center gap-2"},XM=["title","onClick","disabled"],ZM=["title","onClick","disabled"],QM={key:0,class:"rounded-lg border border-dashed border-gray-200 p-4 text-sm text-gray-500"},e2=["disabled"],t2=Ne(s.defineComponent({__name:"vs-input-dataform",props:s.mergeModels({schema:{default:()=>[]},minGroups:{default:0},maxGroups:{default:void 0},addButtonText:{default:"Додати групу фільтрів"},groupLabel:{default:void 0},duplicateTitle:{default:"Дублювати групу"},removeTitle:{default:"Видалити групу"},emptyLabel:{},view:{default:"default"},collapsible:{type:Boolean,default:!1},draggable:{type:Boolean,default:!0},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const e=n,t=s.useModel(n,"modelValue"),r=s.ref([]),o=s.ref([]),i=s.ref(0),l=s.ref(null),a=s.ref(null),c=s.ref(null),d=s.computed(()=>e.groupLabel??"Group"),u=s.computed(()=>e.emptyLabel??"Ще немає груп"),f=s.computed(()=>e.schema?.map(I=>({...I,disabled:e.disabled||I.disabled}))??[]),p=s.computed(()=>f.value.map(I=>_(I))),h=s.computed(()=>e.view==="accordion"),m=s.computed(()=>!!(e.collapsible||h.value)),g=s.computed(()=>e.draggable!==!1),y=s.computed(()=>e.disabled?!1:e.maxGroups?t.value.length<e.maxGroups:!0),b=s.computed(()=>e.disabled||t.value.length<=(e.minGroups||0));s.watch(()=>t.value.length,()=>{w(),v(),E()},{immediate:!0}),s.watch(()=>e.schema,E,{immediate:!0,deep:!0}),s.watch(()=>e.view,()=>{v()},{immediate:!0});function w(){const I=t.value.length;r.value.length<I?r.value=[...r.value,...Array.from({length:I-r.value.length},()=>Na())]:r.value.length>I&&r.value.splice(I)}function v(){const I=t.value.length;h.value?I===0?i.value=-1:i.value>=I?i.value=I-1:i.value<0&&(i.value=0):o.value.length<I?o.value=[...o.value,...Array.from({length:I-o.value.length},()=>!1)]:o.value.length>I&&o.value.splice(I)}function E(){if(!e.minGroups||t.value.length>=e.minGroups)return;const I=e.minGroups-t.value.length,te=Array.from({length:I},N);t.value=[...t.value,...te],v()}function N(){const I={};return f.value.forEach(te=>{I[te.name]=te?.default??null}),I}function R(){y.value&&(t.value=[...t.value,N()],w(),v())}function T(I){b.value||(t.value=t.value.filter((te,ae)=>ae!==I),w(),h.value?i.value>=t.value.length&&(i.value=t.value.length-1):o.value.splice(I,1),E())}function M(I){if(e.disabled)return;const te=JSON.parse(JSON.stringify(t.value[I]??{}));t.value=[...t.value.slice(0,I+1),te,...t.value.slice(I+1)],w(),h.value?i.value>I&&(i.value+=1):o.value.splice(I+1,0,o.value[I]??!1)}function _(I){return{...I}}function A(I){return h.value?i.value===-1&&I===0?!1:i.value!==I:!!o.value[I]}function L(I){if(m.value){if(h.value){i.value=I;return}o.value[I]=!o.value[I]}}function z(I,te){if(!g.value||e.disabled){te.preventDefault();return}l.value=I,a.value=I,c.value={groups:JSON.parse(JSON.stringify(t.value)),keys:[...r.value],states:[...o.value]},te.dataTransfer?.setData("text/plain",String(I)),te.dataTransfer?.setDragImage?.(te.currentTarget,0,0)}function Z(I,te){!g.value||e.disabled||l.value!==null&&X(I,te)}function D(I,te){X(I,te)}function P(I){!g.value||e.disabled||$()}function ne(){c.value&&K(),l.value=null,a.value=null,c.value=null}function U(I,te){const ae=[...t.value],[re]=ae.splice(I,1);ae.splice(te,0,re),t.value=ae;const ge=[...r.value],[Ee]=ge.splice(I,1);if(ge.splice(te,0,Ee),r.value=ge,h.value)i.value===I&&(i.value=te);else{const xe=[...o.value],[Ie]=xe.splice(I,1);xe.splice(te,0,Ie),o.value=xe}}function K(){c.value&&(t.value=c.value.groups,r.value=c.value.keys,o.value=c.value.states,c.value=null,a.value=null)}function X(I,te){if(l.value===null)return;const ae=le(I,te);a.value=ae,H(ae)}function le(I,te){if(!te?.currentTarget)return I;const ae=te.currentTarget.getBoundingClientRect(),ge=te.clientY-ae.top>ae.height/2?I+1:I;return Math.max(0,Math.min(ge,t.value.length))}function H(I){const te=l.value;if(te===null)return;let ae=I;if(ae>t.value.length&&(ae=t.value.length),ae===te||ae===te+1)return;const re=ae>te?ae-1:ae;U(te,re),l.value=re,a.value=ae>te?re+1:re}function $(){c.value=null,l.value=null,a.value=null}return(I,te)=>(s.openBlock(),s.createElementBlock("div",WM,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(t.value,(ae,re)=>(s.openBlock(),s.createElementBlock("div",{key:r.value[re],class:s.normalizeClass(["relative border border-gray-200 rounded-lg bg-white transition vs-dataform__group",[e.view==="accordion"?"overflow-hidden":A(re)?"pt-6 px-6":"p-6"]]),draggable:g.value&&!e.disabled,onDragstart:ge=>z(re,ge),onDragend:ne,onDragover:s.withModifiers(ge=>Z(re,ge),["prevent"]),onDragenter:s.withModifiers(ge=>D(re,ge),["prevent"]),onDrop:s.withModifiers(ge=>P(),["prevent"])},[s.createElementVNode("div",{class:s.normalizeClass(["flex items-center justify-between gap-2 border-b border-gray-100 px-4 py-3",[e.view!=="accordion"?"-mx-6 -mt-6 px-6":"",e.view!=="accordion"&&!A(re)?"rounded-t-lg":"rounded-lg"]])},[s.createElementVNode("div",qM,[g.value?(s.openBlock(),s.createBlock(s.unref(Y.GripVertical),{key:0,class:"h-4 w-4 text-gray-400","aria-hidden":"true"})):s.createCommentVNode("",!0),m.value?(s.openBlock(),s.createElementBlock("button",{key:1,type:"button",class:"rounded-full p-1 text-gray-500 transition hover:bg-gray-100",onClick:ge=>L(re)},[s.createVNode(s.unref(Y.ChevronDown),{class:s.normalizeClass(["h-4 w-4 transition",A(re)?"-rotate-90":"rotate-0"])},null,8,["class"])],8,GM)):s.createCommentVNode("",!0),s.createElementVNode("div",JM,s.toDisplayString(`${d.value} (${re+1})`),1)]),s.createElementVNode("div",YM,[s.createElementVNode("button",{type:"button",class:"p-2 text-gray-400 hover:text-gray-600 hover:bg-gray-50 rounded-lg transition-all disabled:opacity-40",title:e.duplicateTitle,onClick:ge=>M(re),disabled:e.disabled,draggable:"false"},[s.createVNode(s.unref(Y.Copy),{class:"h-4 w-4"})],8,XM),s.createElementVNode("button",{type:"button",class:"p-2 text-gray-400 hover:text-gray-600 hover:bg-gray-50 rounded-lg transition-all disabled:opacity-40",title:e.removeTitle,onClick:ge=>T(re),disabled:b.value,draggable:"false"},[s.createVNode(s.unref(Y.Trash2),{class:"h-4 w-4"})],8,ZM)])],2),s.withDirectives(s.createElementVNode("div",{class:s.normalizeClass(e.view==="accordion"?"p-6":"pt-6")},[s.createVNode(zt,{class:"vs-dataform__form",schema:p.value,layout:"inline",navigation:!1,values:t.value[re],"onUpdate:values":ge=>t.value[re]=ge,"form-id":r.value[re],disabled:e.disabled},null,8,["schema","values","onUpdate:values","form-id","disabled"])],2),[[s.vShow,!A(re)]])],42,KM))),128)),t.value.length===0?(s.openBlock(),s.createElementBlock("div",QM,s.toDisplayString(u.value),1)):s.createCommentVNode("",!0),s.createElementVNode("button",{type:"button",class:"flex items-center gap-2 text-gray-600 hover:text-gray-900 font-medium transition-colors text-sm",onClick:R,disabled:!y.value},[s.createVNode(s.unref(Y.Plus),{class:"h-4 w-4"}),s.createTextVNode(" "+s.toDisplayString(e.addButtonText),1)],8,e2)]))}}),[["__scopeId","data-v-cfbcfed8"]]),hi="__vs_form_monaco_loader__",_r="__vs_form_monaco_script_loader__",mi="__vs_form_monaco_editor_loader__",La=s.defineComponent({__name:"vs-input-monaco",props:s.mergeModels({syntax:{default:"xml"},theme:{default:"vs-light"},height:{default:280},minimap:{type:Boolean,default:!1},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(n,{expose:e}){const t=n,r=s.useModel(n,"modelValue"),o=s.ref(null),i=s.computed(()=>typeof t.height=="number"?`${t.height}px`:t.height||"280px");let l=null,a=null,c=!1;const d=()=>{if(a)return Promise.resolve(a);if(typeof window>"u")return Promise.resolve(null);const m=window;if(m.monaco?.editor?.create)return a=m.monaco,Promise.resolve(a);if(m[hi])return m[hi];const y=(async()=>{const b=E=>{if(Array.from(document.styleSheets||[]).some(T=>T?.href?.includes(E)))return;const R=document.createElement("link");R.rel="stylesheet",R.href=E,document.head.appendChild(R)},w=E=>{if(m[_r]?.[E])return m[_r][E];m[_r]||={};const N=Array.from(document.scripts).find(R=>R.src===E);return N?(m[_r][E]=new Promise((R,T)=>{const M=N.readyState;if(N.dataset.loaded==="true"||M==="loaded"||M==="complete"){R();return}N.addEventListener("load",()=>{N.dataset.loaded="true",R()},{once:!0}),N.addEventListener("error",_=>T(_),{once:!0})}),m[_r][E]):(m[_r][E]=new Promise((R,T)=>{const M=document.createElement("script");M.src=E,M.async=!0,M.onload=()=>{M.dataset.loaded="true",R()},M.onerror=_=>T(_),document.body.appendChild(M)}),m[_r][E])},v="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.52.0/min/vs";return b(`${v}/editor/editor.main.min.css`),await w(`${v}/loader.min.js`),m[mi]||(m[mi]=new Promise((E,N)=>{window.require.config({paths:{vs:v}}),window.require(["vs/editor/editor.main"],()=>{a=window.monaco,m.monaco=a,E(a)},R=>N(R))}).catch(E=>{throw delete m[mi],E})),m[mi]})().catch(b=>{throw delete m[hi],b});return m[hi]=y,y},u=()=>{!o.value||!a||(l&&(l.dispose(),l=null),l=a.editor.create(o.value,{value:r.value||"",language:t.syntax,theme:t.theme,automaticLayout:!0,minimap:{enabled:!!t.minimap},readOnly:!!t.disabled}),l.onDidChangeModelContent(()=>{c||(r.value=l.getValue())}))},f=()=>{l?.focus()},p=()=>l,h=()=>a;return s.watch(()=>r.value,m=>{if(!l)return;const g=l.getValue();m!==g&&(c=!0,l.setValue(m||""),c=!1)}),s.watch(()=>t.syntax,m=>{!l||!a||a.editor.setModelLanguage(l.getModel(),m||"xml")}),s.watch(()=>t.theme,m=>{a&&a.editor.setTheme(m||"vs-light")}),s.watch(()=>t.disabled,m=>{l&&l.updateOptions({readOnly:!!m})}),s.watch(()=>t.minimap,m=>{l&&l.updateOptions({minimap:{enabled:!!m}})}),s.onMounted(async()=>{try{const m=await d();if(!m||!m.editor)return;a=m,u()}catch(m){console.error("Failed to load Monaco editor",m)}}),s.onBeforeUnmount(()=>{l&&(l.dispose(),l=null)}),e({focus:f,getEditor:p,getMonaco:h}),(m,g)=>(s.openBlock(),s.createElementBlock("div",{class:"w-full",style:s.normalizeStyle({height:i.value})},[s.createElementVNode("div",{ref_key:"editorContainer",ref:o,class:"w-full h-full overflow-hidden border border-[#CFD9E0] rounded"},null,512)],4))}}),wf={VsInputText:no,VsInputRadio:ba,VsInputInlineSelect:ii,"vs-input-text":no,"vs-input-password":Tb,"vs-input-textarea":Xu,"vs-input-richtext":Zu,"vs-input-mask":qs,"vs-input-number":Eu,"vs-input-radio":ba,"vs-input-select":Ba,"vs-input-inline-select":ii,"inline-select":ii,"vs-input-switcher":ha,"vs-input-static":ma,"vs-input-container":Gu,"vs-input-date":Iu,"vs-input-checkbox":_u,"vs-input-file":Hu,"vs-input-file2":ri,file2:ri,File2:ri,"vs-input-file64":oi,file64:oi,File64:oi,"vs-input-html":ma,"vs-input-email":ga,"vs-input-tel":ya,"vs-input-datatable":Qu,"vs-input-map":df,"vs-input-file-list":Ku,"vs-input-tags":uf,"vs-input-slug":ff,"vs-input-codegen":pf,"vs-input-key-value":hf,"vs-input-text[]":mf,"vs-input-range":yf,"vs-input-color":gf,"vs-input-native-select":Ba,VsInputArraySelect:pi,"vs-input-array":bf,"vs-input-array-select":pi,"array-select":pi,"vs-input-address":kf,"vs-input-datalist":UM,"vs-input-dataform":t2,"vs-input-monaco":La},n2=s.defineComponent({__name:"behavior",props:{api:{},set:{},button:{},error:{},value:{}},setup(n){const e=n,t=s.inject("values");function r(i,l){const a=l?.result||l?.message||l?.error||l?.detail;return i.status===400&&typeof a=="string"&&a.trim().toLowerCase()==="not found"?"Дані не знайдено.":i.status===500?"Помилка на сервері.":typeof a=="string"&&a.trim()?a:"При спробі завантажити дані виникла помилка."}async function o(){try{if(!e.api)return;const i=e.api.replace("{{value}}",e.value),l=await fetch(i);if(!l.ok){let c=null;try{c=await l.json()}catch{try{c=await l.text()}catch{c=null}}we.notify({type:"warning",title:"Validation",message:r(l,c)});return}const a=await l.json();if(!e.set||!t)return;for(const[c,d]of Object.entries(e.set))t.value[c]=a.result[d]}catch(i){console.error(e.error,i)}}return(i,l)=>(s.openBlock(),s.createElementBlock("button",{onClick:o,class:"vs-button relative inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border !border-gray-200 hover:text-white bg-white text-blue-500 hover:border-blue-500 hover:bg-blue-500 focus:ring-blue-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1 ml-0 md:ml-2 mt-2 md:mt-0 py-[8px] md:w-2/4 whitespace-nowrap w-full"},s.toDisplayString(i.button),1))}}),r2={class:"flex flex-col gap-1 w-full"},o2={class:"w-full"},s2=["disabled"],i2=["innerHTML"],l2=2e3,a2=10,xf=s.defineComponent({__name:"vs-compact-form-layout",props:s.mergeModels({item:{default:{}},layout:{default:"default"},style:{default:{}},type:{default:""},error:{type:[String,Boolean]},columns:{default:()=>({container:12,label:3})}},{modelValue:{default:null},modelModifiers:{}}),emits:s.mergeModels(["value-selected"],["update:modelValue"]),setup(n,{emit:e}){const t=n,r=s.useModel(n,"modelValue"),o=e,i=s.computed(()=>Ab[`${t.layout}`]),l=["label","placeholder","info","description","text","html"],a=s.ref(z()),c=s.computed(()=>_(t.item,a.value)),d=s.computed(()=>{const D={...c.value??{}},P=t.item?.name;return P&&f?.value?.[P]&&Object.assign(D,f.value[P]),D.__locale=a.value,D}),u=s.computed(()=>wf?.[`vs-input-${t.item.type}`]),f=s.inject("field-props"),p=s.computed(()=>{const D=s.unref(u);if(!D)return new Set;const P=D.props??D.__vccOpts?.props;if(!P)return new Set;const ne=Array.isArray(P)?P:Object.keys(P);return new Set(ne)}),m=[...["min","max","step"],"api","set","mask","layers"],g=new Set(["name","type","label","ua","col","rules","validators","conditions","schema","hidden","behavior","default","columns","layout","multiple","data","info","description","text","html","view","groupLabel","emptyLabel","minGroups","maxGroups","collapsible","draggable","props","__locale","slot","slots","component"]);function y(D){const P={};Object.entries(D).forEach(([U,K])=>{g.has(U)||U.includes(":")||K!==void 0&&(P[U]=K)});const ne=D.props;return ne&&typeof ne=="object"&&!Array.isArray(ne)&&Object.entries(ne).forEach(([U,K])=>{K!==void 0&&(P[U]=K)}),P}const b=s.computed(()=>{const D={...c.value??{}},P=t.item?.name;P&&f?.value?.[P]&&Object.assign(D,f.value[P]);const ne=p.value;let U;return ne.size?U=Object.fromEntries(Object.entries(D).filter(([K])=>ne.has(K))):U={...D},Object.assign(U,y(D)),m.forEach(K=>{const X=D[K];X!=null&&(U[K]=X)}),U}),w=D=>{const P=typeof D=="object"&&D!==null?D:{value:D};o("value-selected",{...P,name:P.name??t.item?.name})},v=/{{\s*([^}]+?)\s*}}/g,E=s.inject("values"),N=s.ref(!1),R=s.computed(()=>{const D=t.item?.api,P=t.item?.type?.toLowerCase();return typeof D=="string"&&D.trim().length>0&&(P==="text"||P==="mask")});function T(D,P){if(!(D==null||!P))return P.split(".").reduce((ne,U)=>ne?.[U.trim()],D)}async function M(){const D=String(r.value??"").trim();if(!D)return;const P=(t.item?.api??"").trim();if(!P)return;const ne=P.replace(v,(U,K)=>K.trim()==="value"?encodeURIComponent(D):"");N.value=!0;try{let U=await fetch(ne),K=0;for(;U.status===202&&K<a2;)K+=1,await new Promise(I=>{setTimeout(I,l2)}),U=await fetch(ne);if(U.status===202){we.notify({type:"warning",title:"Validation",message:"Сервер ще обробляє запит. Спробуйте пізніше."});return}if(!U.ok){we.notify({type:"warning",title:"Validation",message:"При спробі завантажити дані виникла помилка."});return}const X=await U.json(),le=X?.result!==void 0?X.result:X,H=t.item?.set;if(!H||!E?.value)return;const $=t.item?.name;Object.entries(H).forEach(([I,te])=>{if(!I)return;let ae=te;$&&ae.startsWith(`${$}.`)&&(ae=ae.slice($.length+1));const re=T(le,ae);E.value[I]=re??null})}catch(U){console.error("API lookup error:",U),we.notify({type:"warning",title:"Validation",message:"При спробі завантажити дані виникла помилка."})}finally{N.value=!1}}s.onMounted(()=>{a.value=z(),window.addEventListener("storage",Z)}),s.onUnmounted(()=>{window.removeEventListener("storage",Z)});function _(D,P){if(!D)return{};const ne={...D};return l.forEach(U=>{const K=L(D,U,P);K!=null&&(ne[U]=K)}),Array.isArray(D.options)&&(ne.options=D.options.map(U=>A(U,P))),ne}function A(D,P){if(!D)return D;const ne={...D},U=L(D,"label",P),K=L(D,"text",P);return U!=null&&(ne.label=U),K!=null?ne.text=K:U!=null&&(ne.text=U),ne}function L(D,P,ne){const U=`${P}:${ne}`;if(D?.[U]!=null)return D[U];if(P==="label"&&D?.[ne]!=null)return D[ne];if(D?.[P]!=null)return D[P];if(P==="label"){if(D?.ua!=null)return D.ua;if(D?.en!=null)return D.en}if(P==="text"||P==="html"){if(D?.ua!=null)return D.ua;if(D?.en!=null)return D.en}return null}function z(){return typeof window>"u"?"uk":localStorage.getItem("locale")||"uk"}function Z(){a.value=z()}return(D,P)=>(s.openBlock(),s.createBlock(s.resolveDynamicComponent(i.value),{ua:d.value.ua,error:t.error||"",item:d.value,columns:t.columns,label:d.value.label},{default:s.withCtx(()=>[s.createElementVNode("div",{class:s.normalizeClass(["flex w-full",`${t.item.type}-component`])},[s.createElementVNode("div",r2,[s.createElementVNode("div",{class:s.normalizeClass(["flex items-center gap-2 w-full",{"flex-1":R.value}])},[s.createElementVNode("div",o2,[(s.openBlock(),s.createBlock(s.resolveDynamicComponent(u.value),s.mergeProps(b.value,{modelValue:r.value,"onUpdate:modelValue":P[0]||(P[0]=ne=>r.value=ne),onValueSelected:w}),null,16,["modelValue"]))]),R.value?(s.openBlock(),s.createElementBlock("button",{key:0,type:"button",class:"flex items-center justify-center px-2 py-2 border rounded-md bg-white hover:bg-gray-50 text-gray-600 hover:text-blue-600 disabled:opacity-50 h-[38px] shrink-0",disabled:N.value||!r.value?.toString().trim(),onClick:M},[N.value?(s.openBlock(),s.createBlock(s.unref(Y.LoaderCircle),{key:1,class:"h-5 w-5 animate-spin text-gray-400"})):(s.openBlock(),s.createBlock(s.unref(Y.Search),{key:0,class:"h-4 w-4"}))],8,s2)):s.createCommentVNode("",!0)],2),d.value.description&&t.layout!=="settings"?(s.openBlock(),s.createElementBlock("p",{key:0,class:"text-sm text-gray-500",innerHTML:d.value.description},null,8,i2)):s.createCommentVNode("",!0)]),d.value.behavior?.api&&d.value.behavior?.button?(s.openBlock(),s.createBlock(n2,s.mergeProps({key:0},d.value.behavior,{value:r.value}),null,16,["value"])):s.createCommentVNode("",!0)],2)]),_:1},8,["ua","error","item","columns","label"]))}}),c2={class:"text-sm text-gray-800 mb-[4px] font-medium dark:text-neutral-300"},d2={class:"vs-compact-form-navigation__rail mt-[6px]"},u2=["onClick"],f2=Ne(s.defineComponent({__name:"vs-compact-form-navigation",props:{target:{},scrollContainer:{},title:{default:"Навігація"},enabled:{type:Boolean,default:!0},width:{default:400}},setup(n,{expose:e}){const t=n,r=s.ref([]),o=s.ref(""),i=s.ref(""),l=s.computed(()=>!!t.enabled),a=s.computed(()=>["vs-compact-form-navigation flex flex-col pl-[6px] pt-[8px] pr-[8px]","sticky top-0 self-start shrink-0","max-h-full min-h-0 overflow-y-auto"]),c=s.computed(()=>{const L=t.width;if(L==null)return{};const z=typeof L=="number"?`${L}px`:`${L}`;return{width:z,minWidth:z}});let d=null,u=0,f=0,p=null,h=null,m=null;const g=()=>_(),y=()=>w();s.watch(()=>t.target,async L=>{if(R(),!L){p=null,r.value=[],o.value="";return}p=L,l.value&&(await s.nextTick(),N(L),w())},{immediate:!0}),s.watch(()=>t.scrollContainer,L=>{if(!l.value){h=L??null;return}b(L??null),s.nextTick(()=>w())},{immediate:!0}),s.onMounted(()=>{t.scrollContainer||b(null),w()}),s.onBeforeUnmount(()=>{R(),b(null,!0),p=null,typeof window<"u"&&(u&&window.cancelAnimationFrame(u),f&&window.cancelAnimationFrame(f))});function b(L,z=!1){if(m&&(m(),m=null),z){h=null;return}if(h=L??null,typeof window>"u")return;const Z=L??window,D=window;Z.addEventListener("scroll",g,{passive:!0}),D.addEventListener("resize",y),m=()=>{Z.removeEventListener("scroll",g),D.removeEventListener("resize",y)}}function w(){if(!l.value||!p)return;u&&typeof window<"u"&&window.cancelAnimationFrame(u);const L=()=>{v(),u=0};typeof window>"u"?L():u=window.requestAnimationFrame(L)}function v(){if(!l.value||!p)return;const L=Array.from(p.querySelectorAll("h1, h2")),z=new Set,Z=[];L.forEach((D,P)=>{const ne=D.textContent?.trim()??"";if(!ne)return;let U=(D.getAttribute("id")??"").trim();U||(U=E(ne)||`heading-${P+1}`);let K=U,X=1;for(;z.has(K);)K=`${U}-${X+=1}`;D.id!==K&&Object.assign(D,{id:K}),z.add(K),Z.push({id:K,text:ne,level:D.tagName.toLowerCase()==="h1"?1:2})}),r.value=Z,Z.length||(o.value=""),M()}function E(L){return L.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-")}function N(L){!L||!l.value||typeof MutationObserver>"u"||(R(),d=new MutationObserver(()=>w()),d.observe(L,{childList:!0,subtree:!0}))}function R(){d&&(d.disconnect(),d=null)}function T(L){const z=h;if(!z)return typeof window>"u"?L.offsetTop:L.getBoundingClientRect().top+window.scrollY;const Z=L.getBoundingClientRect(),D=z.getBoundingClientRect();return Z.top-D.top+z.scrollTop}function M(){if(!l.value||!r.value.length)return;const L=h,z=(L?L.scrollTop:null)||(typeof window<"u"?window.scrollY:0),Z=(L?L.clientHeight:null)||(typeof window<"u"?window.innerHeight:0),D=z+Z;let P=null;for(let U=0;U<r.value.length;U+=1){const K=r.value[U],X=document.getElementById(K.id);if(X){const le=T(X);le+X.offsetHeight>z&&le<D&&(P=K.id)}}!P&&i.value&&(P=i.value),P&&(i.value=P);const ne=L?L.scrollHeight-L.clientHeight:document.documentElement.scrollHeight-window.innerHeight;z+5>=ne&&(P=r.value[r.value.length-1].id),P&&(o.value=P)}function _(){l.value&&(f&&window.cancelAnimationFrame(f),f=window.requestAnimationFrame(()=>{M(),f=0}))}function A(L){if(!l.value)return;const z=document.getElementById(L);if(!z)return;const Z=h,D=Math.max(0,T(z));Z?Z.scrollTo({top:D,behavior:"smooth"}):typeof window<"u"&&window.scrollTo({top:D,behavior:"smooth"})}return e({refresh:w}),(L,z)=>l.value&&r.value.length?(s.openBlock(),s.createElementBlock("div",{key:0,class:s.normalizeClass(a.value),style:s.normalizeStyle(c.value)},[s.createElementVNode("h2",c2,s.toDisplayString(L.title),1),s.createElementVNode("div",d2,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(r.value,Z=>(s.openBlock(),s.createElementBlock("div",{key:Z.id,class:s.normalizeClass(["vs-compact-form-navigation__item relative",Z.level===2?"vs-compact-form-navigation__item--nested":"",Z.id===o.value?"vs-compact-form-navigation__item--active":""])},[s.createElementVNode("button",{type:"button",onClick:D=>A(Z.id),class:s.normalizeClass(["vs-compact-form-navigation__button flex gap-x-3 py-[6px] pr-3 text-sm duration-200 hover:text-gray-800",Z.level===2?"pl-[15px]":"pl-[18px]",Z.id===o.value?"text-gray-800":"text-gray-500"])},[s.createElementVNode("span",null,s.toDisplayString(Z.text),1)],10,u2)],2))),128))])],6)):s.createCommentVNode("",!0)}}),[["__scopeId","data-v-1584a562"]]),qt={required:"Це поле є обов’язковим",email:"Неправильний email",tel:"Неправильний телефон",minlength:n=>`Мінімальна довжина — ${n} символів`,maxlength:n=>`Максимальна довжина — ${n} символів`,min:n=>`Значення має бути не менше ${n}`,max:n=>`Значення має бути не більше ${n}`},p2=new Set(["select","inline-select","array-select"]),h2=(n,e)=>typeof n=="string"?n.trim()?!1:qt.required:Array.isArray(n)?n.map(r=>typeof r=="string"?r.trim():r).filter(r=>r!=null&&r!=="").length?!1:qt.required:typeof n=="number"?Number?.isNaN(n)?qt?.required:!1:typeof n=="boolean"?e&&p2.has(e)||n?!1:qt.required:n?!1:qt.required,m2=n=>{const e=/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/;return n?e.test(n)?!1:qt.email:!1},g2=(n,e)=>{if(!n)return!1;const t=String(n).trim();if(!/^\+[1-9]\d{1,14}$/.test(t))return qt.tel;const i=(typeof e?.digits=="number"&&Number.isFinite(e.digits)&&e.digits>0?e.digits:Qn(Dn))||Qn(Dn);return t.length-1!==i?qt.tel:!1},vf=n=>n==null?0:typeof n=="string"?n.trim().length:Array.isArray(n)?n.length:typeof n=="number"?n.toString().length:String(n).length,y2=(n,e)=>{if(n==null)return!1;const t=Number(e?.value??e?.length);return Number.isFinite(t)&&vf(n)<t?e?.message||qt.minlength(t):!1},b2=(n,e)=>{if(n==null||n==="")return!1;const t=Number(e?.value??e?.length);return Number.isFinite(t)&&vf(n)>t?e?.message||qt.maxlength(t):!1},gi=n=>{if(typeof n=="number")return n;if(typeof n=="string"){const e=n.trim().replace(",",".");return e?Number(e):Number.NaN}return Number(n)},k2=(n,e)=>{if(n==null||n==="")return!1;const t=Number(e?.value);if(!Number.isFinite(t))return!1;const r=gi(n);return Number.isFinite(r)&&r<t?e?.message||qt.min(t):!1},w2=(n,e)=>{if(n==null||n==="")return!1;const t=Number(e?.value);if(!Number.isFinite(t))return!1;const r=gi(n);return Number.isFinite(r)&&r>t?e?.message||qt.max(t):!1},x2=(n,e,t)=>{if(n==null||n==="")return!1;const r=e?.field;if(!r||!t)return!1;const o=t[r];if(o==null||o==="")return!1;const i=gi(n),l=gi(o);return!Number.isFinite(i)||!Number.isFinite(l)?!1:i>l?e?.message||`Значення має бути не більше ${l}`:!1},v2=(n,e)=>{const t=e.pattern??e.regexp,r=typeof t=="string"?new RegExp(t):t;if(Array.isArray(n)){const o=n.filter(Boolean);return o.length===0||o.every(i=>r.test(i))?!1:e.message}return!r.test(n)&&n?e.message:!1},C2=(n,e)=>!1,S2=(n,e,t,r)=>{switch(typeof e=="string"?e:e.type){case"required":return h2(n,r);case"email":return m2(n);case"tel":return g2(n,typeof e=="object"?e:void 0);case"regexp":return v2(n,e);case"minlength":return y2(n,e);case"maxlength":return b2(n,e);case"min":return k2(n,e);case"max":return w2(n,e);case"maxField":return x2(n,e,t);case"custom":return C2();default:return!1}},E2={autocomplete:"select",combobox:"select",datepicker:"date",markedtext:"mask",html:"static",geom:"map",filelist:"file-list",file:"file",file64:"file64",dropzone:"file",inlineselect:"inline-select"};function Cf(n){const e=n?.toLowerCase();return E2[e]||e}function Ia(n,e=!1){if(Array.isArray(n)){const r=[];return n.forEach(o=>{const i={...o};if(i.name=(o.name||o.id||o.key||"").toString(),i.type=Cf(o.type),i.label=o.label||o.ua,i.rules=o.rules||o.validators,i.type==="email"&&!i.rules&&(i.rules=["email"]),i.type==="tel"&&!i.rules){const l=i.mask||Dn,a=Qn(l)||Qn(Dn);i.rules=[{type:"tel",digits:a}]}o.data&&(i.api=`/api/suggest/${o.data}`),i.disabled=i.disabled??e,Array.isArray(i.schema)&&(i.schema=Ia(i.schema,i.disabled)),r.push(i)}),r}const t=[];return Object.entries(n).forEach(r=>{const o={name:r[0],...r[1],type:Cf(r[1].type),label:r[1].label||r[1].ua,rules:r[1].rules||r[1].validators,disabled:r[1].disabled??e};if(o.type==="email"&&!o.rules&&(o.rules=["email"]),o.type==="tel"&&!o.rules){const i=o.mask||Dn,l=Qn(i)||Qn(Dn);o.rules=[{type:"tel",digits:l}]}r[1].type?.includes("list")&&(o.multiple=!0),!o.api&&r[1].data&&(o.api=`/api/suggest/${r[1].data}`),Array.isArray(o.schema)&&(o.schema=Ia(o.schema,o.disabled)),t.push(o)}),t}function M2(n,e,t=!1){const r=s.computed(()=>Ia((Array.isArray(e),e),typeof t=="boolean"?t:t.value)),o=s.ref({});function i(p){return qu(n?.value,p?.conditions)}const l=new Set(["maxField"]);function a(p){return typeof p.maxField=="string"&&p.maxField?!0:(p.rules||[]).some(h=>{const m=typeof h=="string"?h:h.type;return m?l.has(m):!1})}function c(p){const h=[],m=Number(p?.minlength),g=Number(p?.maxlength),y=Number(p?.min),b=Number(p?.max);!Number.isNaN(m)&&Number.isFinite(m)&&h.push({type:"minlength",value:m}),!Number.isNaN(g)&&Number.isFinite(g)&&h.push({type:"maxlength",value:g}),!Number.isNaN(y)&&Number.isFinite(y)&&h.push({type:"min",value:y}),!Number.isNaN(b)&&Number.isFinite(b)&&h.push({type:"max",value:b}),typeof p?.maxField=="string"&&p.maxField&&h.push({type:"maxField",field:p.maxField,message:p.maxFieldMessage});const w=[...h,...p.rules||[]];if(!w.length)return;if(!i(p)){delete o.value[p.name];return}let v=!1,E=null;w.forEach(N=>{const R=S2(n.value[p.name],N,n.value,p.type);R&&(v=!0,!E&&typeof R=="string"&&(E=R))}),v&&E?o.value[p.name]=E:delete o.value[p.name]}const d=(p=r.value,h=!0)=>(p.forEach(m=>{c(m),m.schema&&d(m.schema,!1)}),h&&Object.values(o.value).some(Boolean)?o.value:null);s.watch(n,()=>{const p=[],h=m=>{m.forEach(g=>{a(g)&&p.push(g),g.schema&&h(g.schema)})};h(r.value),p.forEach(c)},{deep:!0});const u=s.computed(()=>r.value?.filter(p=>p.hidden!==!0&&i(p)));return{errors:o,validate:d,reset:()=>{n.value={},o.value={}},visibleSchema:u}}const A2={class:"flex w-full h-full min-h-0 gap-6"},_2={key:0,"data-orientation":"horizontal",role:"none",class:"mt-1 shrink-0 h-[1px] w-full bg-slate-100 dark:bg-slate-600"},zt=s.defineComponent({__name:"vs-compact-form",props:s.mergeModels({schema:{default:()=>[]},style:{default:()=>({})},modelValue:{},layout:{default:()=>"default"},formId:{default:()=>""},allowIdField:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},navigation:{type:Boolean,default:!1},navWidth:{default:400},columns:{}},{form:{default:()=>({})},formModifiers:{},modelValue:{default:()=>({})},modelModifiers:{},values:{default:void 0},valuesModifiers:{}}),emits:s.mergeModels(["handle-submit","update:modelValue","value-selected"],["update:form","update:modelValue","update:values"]),setup(n,{expose:e,emit:t}){const r=t,o=n,i=s.computed(()=>!!o.formId||o.allowIdField),l=s.useModel(n,"form"),a=s.useModel(n,"modelValue"),c=s.useModel(n,"values"),d=s.computed({get:()=>c.value??a.value,set:U=>{a.value=U,c.value=U}}),{errors:u,validate:f,reset:p,visibleSchema:h}=M2(d,o.schema,s.toRef(o,"disabled")),m=s.ref(null),g=s.ref(null),y=s.ref({}),b=s.computed(()=>o.navigation),w=s.computed(()=>o.navWidth),v=s.computed(()=>o.style?.columns),E=Object.freeze({container:12,label:3}),N=s.computed(()=>o.columns??v.value??E),R=s.computed(()=>o.columns!=null||v.value!=null),T=s.computed(()=>R.value?"horizontal":o.layout),M=U=>U?.columns?"horizontal":T.value,_=U=>U?.columns??N.value,A=s.computed(()=>{const U={},K=X=>{if(!X)return;(Array.isArray(X)?X.map((H,$)=>({key:String($),entry:H})):typeof X=="object"?Object.entries(X).map(([H,$])=>({key:H,entry:$})):[]).forEach(({key:H,entry:$})=>{if(!$||typeof $!="object")return;const I=$.name?String($.name):H;I&&(U[I]={...$,name:I}),Array.isArray($.schema)&&K($.schema)})};return K(o.schema),U}),L=()=>{!i.value&&d.value&&delete d.value.id,r("update:modelValue",d.value),f(),r("handle-submit",d.value)},z=U=>{r("value-selected",U)};e({validate:f,reset:p,errors:u}),s.onMounted(()=>{l.value={value:d.value,errors:u.value,reset:p,validate:f,formId:o.formId}});function Z(U,K){if(U===K)return!0;if(typeof U!="object"||typeof K!="object"||!U||!K)return!1;const X=Object.keys(U),le=Object.keys(K);return X.length!==le.length?!1:X.every(H=>U[H]===K[H])}function D(U){return Array.isArray(U)?[...U]:U&&typeof U=="object"?{...U}:U}function P(U){Array.isArray(U)&&U.forEach(K=>{if(!K)return;const X=K.name,le=K.default!==void 0;X&&le&&d.value[X]===void 0&&(d.value[X]=D(K.default)),Array.isArray(K.schema)&&P(K.schema)})}return s.watch(h,U=>{P(U)},{immediate:!0,deep:!0}),s.provide("form",l),s.provide("values",d),s.inject("form-root-values",null)||s.provide("form-root-values",d),s.provide("field-props",y),s.provide("schema-by-name",A),(U,K)=>(s.openBlock(),s.createElementBlock("div",A2,[s.createElementVNode("div",{class:"flex-1 min-h-0 overflow-y-auto overflow-x-visible",ref_key:"formScrollContainer",ref:g},[s.createElementVNode("form",{ref_key:"formRef",ref:m,onSubmit:s.withModifiers(L,["prevent"]),class:s.normalizeClass(["grid grid-cols-12 p-1",T.value==="default"?"gap-6":"gap-4"])},[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(s.unref(h),(X,le)=>(s.openBlock(),s.createElementBlock("div",{key:X.name,class:s.normalizeClass(M(X)==="horizontal"?"col-span-12":`col-span-12 md:col-span-${X.col||12}`)},[s.createVNode(xf,{style:s.normalizeStyle(U.style),item:X,layout:M(X),columns:_(X),"model-value":d.value[X.name],"onUpdate:modelValue":H=>{if(X.name==="id"&&!i.value)return;const $=d.value[X.name];Z($,H)||(d.value[X.name]=H)},error:s.unref(u)[X.name],onValueSelected:z},null,8,["style","item","layout","columns","model-value","onUpdate:modelValue","error"]),M(X)==="settings"&&le+1!==s.unref(h).length?(s.openBlock(),s.createElementBlock("div",_2)):s.createCommentVNode("",!0)],2))),128))],34)],512),s.createVNode(f2,{target:m.value,"scroll-container":g.value,enabled:b.value,width:w.value},null,8,["target","scroll-container","enabled","width"])]))}}),T2={class:"relative"},B2={class:"w-full h-full fixed top-0 start-0 bg-black bg-opacity-50"},N2={class:"m-[10px] fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 min-h-0 h-fit max-h-[80vh] overflow-hidden opacity-1 flex flex-col bg-white dark:bg-[#1A1A1A] border dark:border-[#454545] pointer-events-auto shadow-[0_10px_40px_10px_rgba(0,0,0,0.08)] rounded-xl lg:w-7/12 w-11/12"},D2={class:"py-2.5 px-4 flex justify-between items-center border-0 border-b border-solid border-gray-200 dark:border-b-[#454545]"},V2={class:"font-medium text-gray-800 dark:text-[#ffffff]"},$2={class:"p-4 mim-h-0 h-full overflow-auto"},Sf=s.defineComponent({__name:"modal-edit",props:{schema:{},defaultValue:{},mode:{},token:{},form:{},api:{},method:{}},emits:["close","save","edit"],setup(n,{emit:e}){const t=n,r=e,o=s.ref(t.schema),i=s.ref(t.defaultValue?JSON.parse(JSON.stringify(t.defaultValue)):{}),l=s.ref({}),a=s.ref(t.token||""),c=s.ref(t.token||""),d=s.ref(t.mode),u=()=>{const y=t.method?.trim().toUpperCase();return y==="GET"||y==="POST"||y==="PUT"?y:d.value==="add"?"POST":"PUT"},f=()=>{we.notify({type:"success",title:"Успішно",message:`Дані успішно ${d.value==="add"?"збережено":"оновлено"}`})},p=y=>{const b={};y.id!==void 0&&y.id!==null&&(b.id=y.id,c.value=y.id.toString()),y.obj&&typeof y.obj=="object"&&Object.assign(b,y.obj),Object.keys(b).length&&(i.value={...i.value,...b})},h=async y=>{if(console.log(y),y.ok){await y.json().catch(()=>({})),f(),r("save",i.value);return}const b=await y.json().catch(()=>({})),w=b.message||b.error;if(y.status===400){we.notify({type:"warning",title:"Помилка валідації",message:w||"Некоректні дані (400)"});return}if(y.status===403){we.notify({type:"warning",title:"Доступ заборонено",message:w||"Доступ заборонено (403)"});return}if(y.status===500){we.notify({type:"error",title:"Серверна помилка",message:w||"Виникла помилка на сервері (500)"});return}we.notify({type:"error",title:"Помилка",message:w||`Статус: ${y.status}`})};async function m(){const y=l.value.validate();if(y){we.notify({type:"warning",title:"Помилка валідації",message:Object.entries(y).map(([w,v])=>`${w}: ${v}`).join(`
5
+ `)});return}d.value==="add"&&i.value&&delete i.value.id;const b=t.api?.trim();if(b){const w=u();try{const v=await fetch(b,{method:w,headers:w==="GET"?void 0:{"Content-Type":"application/json"},body:w==="GET"?void 0:JSON.stringify(i.value)});await h(v)}catch(v){we.notify({type:"error",title:"Помилка з’єднання",message:v.message||"Не вдалося виконати запит"})}return}if(a.value)try{const w=await fetch(`/api/table/${a.value}`,{method:d.value==="add"?"POST":"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i.value)});await h(w)}catch(w){we.notify({type:"error",title:"Помилка з’єднання",message:w.message||"Не вдалося виконати запит"})}else r("edit",i.value),g()}function g(){r("close")}return s.onMounted(async()=>{try{if(t.form&&!t.schema){const y=await fetch(`/api/template/form/${t.form}`);if(!y.ok){we.notify({type:y.status>=400&&y.status<500?"warning":"error",title:"Error",message:`Error code: ${y.status}`});return}const b=await y.json();o.value=b.schema,b.id&&(c.value=b.id),b.token&&(a.value=b.token,c.value||(c.value=b.token))}else if(t.token&&!t.defaultValue){a.value=t.token;const y=await fetch(`/api/form/${a.value}`);if(!y.ok){we.notify({type:y.status>=400&&y.status<500?"warning":"error",title:"Error",message:`Error code: ${y.status}`});return}const b=await y.json();o.value=b.schema,b.data?i.value=b.data:d.value="add",p({id:b.id,obj:b.obj})}}catch(y){we.notify({type:"error",title:"Error",message:y.message||"Unexpected error"}),console.error(y)}}),(y,b)=>(s.openBlock(),s.createElementBlock("div",T2,[s.createElementVNode("div",B2,[s.createElementVNode("div",N2,[s.createElementVNode("div",D2,[s.createElementVNode("h3",V2,s.toDisplayString(d.value==="add"?"Додати":"Змінити"),1),s.createElementVNode("button",{onClick:g,type:"button",class:"size-8 inline-flex justify-center items-center gap-x-2 rounded-full border border-transparent bg-gray-100 text-gray-800 hover:bg-gray-200 focus:outline-none focus:bg-gray-200 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-700 dark:hover:bg-neutral-600 dark:text-neutral-400 dark:focus:bg-neutral-600"},[b[2]||(b[2]=s.createElementVNode("span",{class:"sr-only"},"Close",-1)),s.createVNode(s.unref(Y.X),{class:"h-4 w-4 flex-shrink-0"})])]),s.createElementVNode("div",$2,[o.value?(s.openBlock(),s.createBlock(zt,{key:0,schema:o.value,values:i.value,"onUpdate:values":b[0]||(b[0]=w=>i.value=w),form:l.value,"onUpdate:form":b[1]||(b[1]=w=>l.value=w),formId:c.value},null,8,["schema","values","form","formId"])):s.createCommentVNode("",!0)]),s.createElementVNode("div",{class:"vs-form__head mr-5 mb-5 mt-3 flex items-center justify-end sticky top-0 left-0 z-[60] bg-white"},[s.createElementVNode("button",{type:"button",onClick:g,class:"vs-button inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border !border-gray-200 hover:text-white bg-white text-red-500 hover:border-red-500 hover:bg-red-500 focus:ring-red-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1 mr-2"}," Скасувати "),s.createElementVNode("button",{onClick:m,type:"button",class:"vs-button inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border-1 border-transparent text-white bg-blue-500 hover:bg-blue-600 focus:ring-blue-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1"}," Зберегти ")])])])]))}}),Ef=ua.form.richtext,Mf=fa.form.richtext,Oa={en:{form:{richtext:Ef}},uk:{form:{richtext:Mf}}},Af=(n={mode:"edit",schema:null})=>new Promise(e=>{const{close:t}=we.modal({title:n.mode==="add"?"Додати":"Редагувати",template:"",visible:!0,size:"medium",closeClickBack:!0,content:Sf,contentProps:{...n,onClose:()=>{e(null),t()},onSave:r=>{e(r),t()}}})});zt.install=function(e){e.component("VForm",zt),Object.assign(e.config.globalProperties,{$form:Af}),e.provide("form",Af),window.v3plugin||(window.v3plugin={})};function er(n){return typeof n=="string"||n instanceof String}function _f(n){var e;return typeof n=="object"&&n!=null&&(n==null||(e=n.constructor)==null?void 0:e.name)==="Object"}function Tf(n,e){return Array.isArray(e)?Tf(n,(t,r)=>e.includes(r)):Object.entries(n).reduce((t,r)=>{let[o,i]=r;return e(i,o)&&(t[o]=i),t},{})}const ve={NONE:"NONE",LEFT:"LEFT",FORCE_LEFT:"FORCE_LEFT",RIGHT:"RIGHT",FORCE_RIGHT:"FORCE_RIGHT"};function Bf(n){switch(n){case ve.LEFT:return ve.FORCE_LEFT;case ve.RIGHT:return ve.FORCE_RIGHT;default:return n}}function Ra(n){return n.replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1")}function yi(n,e){if(e===n)return!0;const t=Array.isArray(e),r=Array.isArray(n);let o;if(t&&r){if(e.length!=n.length)return!1;for(o=0;o<e.length;o++)if(!yi(e[o],n[o]))return!1;return!0}if(t!=r)return!1;if(e&&n&&typeof e=="object"&&typeof n=="object"){const i=e instanceof Date,l=n instanceof Date;if(i&&l)return e.getTime()==n.getTime();if(i!=l)return!1;const a=e instanceof RegExp,c=n instanceof RegExp;if(a&&c)return e.toString()==n.toString();if(a!=c)return!1;const d=Object.keys(e);for(o=0;o<d.length;o++)if(!Object.prototype.hasOwnProperty.call(n,d[o]))return!1;for(o=0;o<d.length;o++)if(!yi(n[d[o]],e[d[o]]))return!1;return!0}else if(e&&n&&typeof e=="function"&&typeof n=="function")return e.toString()===n.toString();return!1}class L2{constructor(e){for(Object.assign(this,e);this.value.slice(0,this.startChangePos)!==this.oldValue.slice(0,this.startChangePos);)--this.oldSelection.start;if(this.insertedCount)for(;this.value.slice(this.cursorPos)!==this.oldValue.slice(this.oldSelection.end);)this.value.length-this.cursorPos<this.oldValue.length-this.oldSelection.end?++this.oldSelection.end:++this.cursorPos}get startChangePos(){return Math.min(this.cursorPos,this.oldSelection.start)}get insertedCount(){return this.cursorPos-this.startChangePos}get inserted(){return this.value.substr(this.startChangePos,this.insertedCount)}get removedCount(){return Math.max(this.oldSelection.end-this.startChangePos||this.oldValue.length-this.value.length,0)}get removed(){return this.oldValue.substr(this.startChangePos,this.removedCount)}get head(){return this.value.substring(0,this.startChangePos)}get tail(){return this.value.substring(this.startChangePos+this.insertedCount)}get removeDirection(){return!this.removedCount||this.insertedCount?ve.NONE:(this.oldSelection.end===this.cursorPos||this.oldSelection.start===this.cursorPos)&&this.oldSelection.end===this.oldSelection.start?ve.RIGHT:ve.LEFT}}function Be(n,e){return new Be.InputMask(n,e)}function Nf(n){if(n==null)throw new Error("mask property should be defined");return n instanceof RegExp?Be.MaskedRegExp:er(n)?Be.MaskedPattern:n===Date?Be.MaskedDate:n===Number?Be.MaskedNumber:Array.isArray(n)||n===Array?Be.MaskedDynamic:Be.Masked&&n.prototype instanceof Be.Masked?n:Be.Masked&&n instanceof Be.Masked?n.constructor:n instanceof Function?Be.MaskedFunction:(console.warn("Mask not found for mask",n),Be.Masked)}function so(n){if(!n)throw new Error("Options in not defined");if(Be.Masked){if(n.prototype instanceof Be.Masked)return{mask:n};const{mask:e=void 0,...t}=n instanceof Be.Masked?{mask:n}:_f(n)&&n.mask instanceof Be.Masked?n:{};if(e){const r=e.mask;return{...Tf(e,(o,i)=>!i.startsWith("_")),mask:e.constructor,_mask:r,...t}}}return _f(n)?{...n}:{mask:n}}function fn(n){if(Be.Masked&&n instanceof Be.Masked)return n;const e=so(n),t=Nf(e.mask);if(!t)throw new Error("Masked class is not found for provided mask "+e.mask+", appropriate module needs to be imported manually before creating mask.");return e.mask===t&&delete e.mask,e._mask&&(e.mask=e._mask,delete e._mask),new t(e)}Be.createMask=fn;class bi{get selectionStart(){let e;try{e=this._unsafeSelectionStart}catch{}return e??this.value.length}get selectionEnd(){let e;try{e=this._unsafeSelectionEnd}catch{}return e??this.value.length}select(e,t){if(!(e==null||t==null||e===this.selectionStart&&t===this.selectionEnd))try{this._unsafeSelect(e,t)}catch{}}get isActive(){return!1}}Be.MaskElement=bi;const Df=90,I2=89;class Oo extends bi{constructor(e){super(),this.input=e,this._onKeydown=this._onKeydown.bind(this),this._onInput=this._onInput.bind(this),this._onBeforeinput=this._onBeforeinput.bind(this),this._onCompositionEnd=this._onCompositionEnd.bind(this)}get rootElement(){var e,t,r;return(e=(t=(r=this.input).getRootNode)==null?void 0:t.call(r))!=null?e:document}get isActive(){return this.input===this.rootElement.activeElement}bindEvents(e){this.input.addEventListener("keydown",this._onKeydown),this.input.addEventListener("input",this._onInput),this.input.addEventListener("beforeinput",this._onBeforeinput),this.input.addEventListener("compositionend",this._onCompositionEnd),this.input.addEventListener("drop",e.drop),this.input.addEventListener("click",e.click),this.input.addEventListener("focus",e.focus),this.input.addEventListener("blur",e.commit),this._handlers=e}_onKeydown(e){if(this._handlers.redo&&(e.keyCode===Df&&e.shiftKey&&(e.metaKey||e.ctrlKey)||e.keyCode===I2&&e.ctrlKey))return e.preventDefault(),this._handlers.redo(e);if(this._handlers.undo&&e.keyCode===Df&&(e.metaKey||e.ctrlKey))return e.preventDefault(),this._handlers.undo(e);e.isComposing||this._handlers.selectionChange(e)}_onBeforeinput(e){if(e.inputType==="historyUndo"&&this._handlers.undo)return e.preventDefault(),this._handlers.undo(e);if(e.inputType==="historyRedo"&&this._handlers.redo)return e.preventDefault(),this._handlers.redo(e)}_onCompositionEnd(e){this._handlers.input(e)}_onInput(e){e.isComposing||this._handlers.input(e)}unbindEvents(){this.input.removeEventListener("keydown",this._onKeydown),this.input.removeEventListener("input",this._onInput),this.input.removeEventListener("beforeinput",this._onBeforeinput),this.input.removeEventListener("compositionend",this._onCompositionEnd),this.input.removeEventListener("drop",this._handlers.drop),this.input.removeEventListener("click",this._handlers.click),this.input.removeEventListener("focus",this._handlers.focus),this.input.removeEventListener("blur",this._handlers.commit),this._handlers={}}}Be.HTMLMaskElement=Oo;class Vf extends Oo{constructor(e){super(e),this.input=e}get _unsafeSelectionStart(){return this.input.selectionStart!=null?this.input.selectionStart:this.value.length}get _unsafeSelectionEnd(){return this.input.selectionEnd}_unsafeSelect(e,t){this.input.setSelectionRange(e,t)}get value(){return this.input.value}set value(e){this.input.value=e}}Be.HTMLMaskElement=Oo;class Fa extends Oo{get _unsafeSelectionStart(){const e=this.rootElement,t=e.getSelection&&e.getSelection(),r=t&&t.anchorOffset,o=t&&t.focusOffset;return o==null||r==null||r<o?r:o}get _unsafeSelectionEnd(){const e=this.rootElement,t=e.getSelection&&e.getSelection(),r=t&&t.anchorOffset,o=t&&t.focusOffset;return o==null||r==null||r>o?r:o}_unsafeSelect(e,t){if(!this.rootElement.createRange)return;const r=this.rootElement.createRange();r.setStart(this.input.firstChild||this.input,e),r.setEnd(this.input.lastChild||this.input,t);const o=this.rootElement,i=o.getSelection&&o.getSelection();i&&(i.removeAllRanges(),i.addRange(r))}get value(){return this.input.textContent||""}set value(e){this.input.textContent=e}}Be.HTMLContenteditableMaskElement=Fa;class ki{constructor(){this.states=[],this.currentIndex=0}get currentState(){return this.states[this.currentIndex]}get isEmpty(){return this.states.length===0}push(e){this.currentIndex<this.states.length-1&&(this.states.length=this.currentIndex+1),this.states.push(e),this.states.length>ki.MAX_LENGTH&&this.states.shift(),this.currentIndex=this.states.length-1}go(e){return this.currentIndex=Math.min(Math.max(this.currentIndex+e,0),this.states.length-1),this.currentState}undo(){return this.go(-1)}redo(){return this.go(1)}clear(){this.states.length=0,this.currentIndex=0}}ki.MAX_LENGTH=100;class $f{constructor(e,t){this.el=e instanceof bi?e:e.isContentEditable&&e.tagName!=="INPUT"&&e.tagName!=="TEXTAREA"?new Fa(e):new Vf(e),this.masked=fn(t),this._listeners={},this._value="",this._unmaskedValue="",this._rawInputValue="",this.history=new ki,this._saveSelection=this._saveSelection.bind(this),this._onInput=this._onInput.bind(this),this._onChange=this._onChange.bind(this),this._onDrop=this._onDrop.bind(this),this._onFocus=this._onFocus.bind(this),this._onClick=this._onClick.bind(this),this._onUndo=this._onUndo.bind(this),this._onRedo=this._onRedo.bind(this),this.alignCursor=this.alignCursor.bind(this),this.alignCursorFriendly=this.alignCursorFriendly.bind(this),this._bindEvents(),this.updateValue(),this._onChange()}maskEquals(e){var t;return e==null||((t=this.masked)==null?void 0:t.maskEquals(e))}get mask(){return this.masked.mask}set mask(e){if(this.maskEquals(e))return;if(!(e instanceof Be.Masked)&&this.masked.constructor===Nf(e)){this.masked.updateOptions({mask:e});return}const t=e instanceof Be.Masked?e:fn({mask:e});t.unmaskedValue=this.masked.unmaskedValue,this.masked=t}get value(){return this._value}set value(e){this.value!==e&&(this.masked.value=e,this.updateControl("auto"))}get unmaskedValue(){return this._unmaskedValue}set unmaskedValue(e){this.unmaskedValue!==e&&(this.masked.unmaskedValue=e,this.updateControl("auto"))}get rawInputValue(){return this._rawInputValue}set rawInputValue(e){this.rawInputValue!==e&&(this.masked.rawInputValue=e,this.updateControl(),this.alignCursor())}get typedValue(){return this.masked.typedValue}set typedValue(e){this.masked.typedValueEquals(e)||(this.masked.typedValue=e,this.updateControl("auto"))}get displayValue(){return this.masked.displayValue}_bindEvents(){this.el.bindEvents({selectionChange:this._saveSelection,input:this._onInput,drop:this._onDrop,click:this._onClick,focus:this._onFocus,commit:this._onChange,undo:this._onUndo,redo:this._onRedo})}_unbindEvents(){this.el&&this.el.unbindEvents()}_fireEvent(e,t){const r=this._listeners[e];r&&r.forEach(o=>o(t))}get selectionStart(){return this._cursorChanging?this._changingCursorPos:this.el.selectionStart}get cursorPos(){return this._cursorChanging?this._changingCursorPos:this.el.selectionEnd}set cursorPos(e){!this.el||!this.el.isActive||(this.el.select(e,e),this._saveSelection())}_saveSelection(){this.displayValue!==this.el.value&&console.warn("Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly."),this._selection={start:this.selectionStart,end:this.cursorPos}}updateValue(){this.masked.value=this.el.value,this._value=this.masked.value,this._unmaskedValue=this.masked.unmaskedValue,this._rawInputValue=this.masked.rawInputValue}updateControl(e){const t=this.masked.unmaskedValue,r=this.masked.value,o=this.masked.rawInputValue,i=this.displayValue,l=this.unmaskedValue!==t||this.value!==r||this._rawInputValue!==o;this._unmaskedValue=t,this._value=r,this._rawInputValue=o,this.el.value!==i&&(this.el.value=i),e==="auto"?this.alignCursor():e!=null&&(this.cursorPos=e),l&&this._fireChangeEvents(),!this._historyChanging&&(l||this.history.isEmpty)&&this.history.push({unmaskedValue:t,selection:{start:this.selectionStart,end:this.cursorPos}})}updateOptions(e){const{mask:t,...r}=e,o=!this.maskEquals(t),i=this.masked.optionsIsChanged(r);o&&(this.mask=t),i&&this.masked.updateOptions(r),(o||i)&&this.updateControl()}updateCursor(e){e!=null&&(this.cursorPos=e,this._delayUpdateCursor(e))}_delayUpdateCursor(e){this._abortUpdateCursor(),this._changingCursorPos=e,this._cursorChanging=setTimeout(()=>{this.el&&(this.cursorPos=this._changingCursorPos,this._abortUpdateCursor())},10)}_fireChangeEvents(){this._fireEvent("accept",this._inputEvent),this.masked.isComplete&&this._fireEvent("complete",this._inputEvent)}_abortUpdateCursor(){this._cursorChanging&&(clearTimeout(this._cursorChanging),delete this._cursorChanging)}alignCursor(){this.cursorPos=this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos,ve.LEFT))}alignCursorFriendly(){this.selectionStart===this.cursorPos&&this.alignCursor()}on(e,t){return this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t),this}off(e,t){if(!this._listeners[e])return this;if(!t)return delete this._listeners[e],this;const r=this._listeners[e].indexOf(t);return r>=0&&this._listeners[e].splice(r,1),this}_onInput(e){this._inputEvent=e,this._abortUpdateCursor();const t=new L2({value:this.el.value,cursorPos:this.cursorPos,oldValue:this.displayValue,oldSelection:this._selection}),r=this.masked.rawInputValue,o=this.masked.splice(t.startChangePos,t.removed.length,t.inserted,t.removeDirection,{input:!0,raw:!0}).offset,i=r===this.masked.rawInputValue?t.removeDirection:ve.NONE;let l=this.masked.nearestInputPos(t.startChangePos+o,i);i!==ve.NONE&&(l=this.masked.nearestInputPos(l,ve.NONE)),this.updateControl(l),delete this._inputEvent}_onChange(){this.displayValue!==this.el.value&&this.updateValue(),this.masked.doCommit(),this.updateControl(),this._saveSelection()}_onDrop(e){e.preventDefault(),e.stopPropagation()}_onFocus(e){this.alignCursorFriendly()}_onClick(e){this.alignCursorFriendly()}_onUndo(){this._applyHistoryState(this.history.undo())}_onRedo(){this._applyHistoryState(this.history.redo())}_applyHistoryState(e){e&&(this._historyChanging=!0,this.unmaskedValue=e.unmaskedValue,this.el.select(e.selection.start,e.selection.end),this._saveSelection(),this._historyChanging=!1)}destroy(){this._unbindEvents(),this._listeners.length=0,delete this.el}}Be.InputMask=$f;class Ve{static normalize(e){return Array.isArray(e)?e:[e,new Ve]}constructor(e){Object.assign(this,{inserted:"",rawInserted:"",tailShift:0,skip:!1},e)}aggregate(e){return this.inserted+=e.inserted,this.rawInserted+=e.rawInserted,this.tailShift+=e.tailShift,this.skip=this.skip||e.skip,this}get offset(){return this.tailShift+this.inserted.length}get consumed(){return!!this.rawInserted||this.skip}equals(e){return this.inserted===e.inserted&&this.tailShift===e.tailShift&&this.rawInserted===e.rawInserted&&this.skip===e.skip}}Be.ChangeDetails=Ve;class pn{constructor(e,t,r){e===void 0&&(e=""),t===void 0&&(t=0),this.value=e,this.from=t,this.stop=r}toString(){return this.value}extend(e){this.value+=String(e)}appendTo(e){return e.append(this.toString(),{tail:!0}).aggregate(e._appendPlaceholder())}get state(){return{value:this.value,from:this.from,stop:this.stop}}set state(e){Object.assign(this,e)}unshift(e){if(!this.value.length||e!=null&&this.from>=e)return"";const t=this.value[0];return this.value=this.value.slice(1),t}shift(){if(!this.value.length)return"";const e=this.value[this.value.length-1];return this.value=this.value.slice(0,-1),e}}class kt{constructor(e){this._value="",this._update({...kt.DEFAULTS,...e}),this._initialized=!0}updateOptions(e){this.optionsIsChanged(e)&&this.withValueRefresh(this._update.bind(this,e))}_update(e){Object.assign(this,e)}get state(){return{_value:this.value,_rawInputValue:this.rawInputValue}}set state(e){this._value=e._value}reset(){this._value=""}get value(){return this._value}set value(e){this.resolve(e,{input:!0})}resolve(e,t){t===void 0&&(t={input:!0}),this.reset(),this.append(e,t,""),this.doCommit()}get unmaskedValue(){return this.value}set unmaskedValue(e){this.resolve(e,{})}get typedValue(){return this.parse?this.parse(this.value,this):this.unmaskedValue}set typedValue(e){this.format?this.value=this.format(e,this):this.unmaskedValue=String(e)}get rawInputValue(){return this.extractInput(0,this.displayValue.length,{raw:!0})}set rawInputValue(e){this.resolve(e,{raw:!0})}get displayValue(){return this.value}get isComplete(){return!0}get isFilled(){return this.isComplete}nearestInputPos(e,t){return e}totalInputPositions(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.displayValue.length),Math.min(this.displayValue.length,t-e)}extractInput(e,t,r){return e===void 0&&(e=0),t===void 0&&(t=this.displayValue.length),this.displayValue.slice(e,t)}extractTail(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.displayValue.length),new pn(this.extractInput(e,t),e)}appendTail(e){return er(e)&&(e=new pn(String(e))),e.appendTo(this)}_appendCharRaw(e,t){return e?(this._value+=e,new Ve({inserted:e,rawInserted:e})):new Ve}_appendChar(e,t,r){t===void 0&&(t={});const o=this.state;let i;if([e,i]=this.doPrepareChar(e,t),e&&(i=i.aggregate(this._appendCharRaw(e,t)),!i.rawInserted&&this.autofix==="pad")){const l=this.state;this.state=o;let a=this.pad(t);const c=this._appendCharRaw(e,t);a=a.aggregate(c),c.rawInserted||a.equals(i)?i=a:this.state=l}if(i.inserted){let l,a=this.doValidate(t)!==!1;if(a&&r!=null){const c=this.state;if(this.overwrite===!0){l=r.state;for(let u=0;u<i.rawInserted.length;++u)r.unshift(this.displayValue.length-i.tailShift)}let d=this.appendTail(r);if(a=d.rawInserted.length===r.toString().length,!(a&&d.inserted)&&this.overwrite==="shift"){this.state=c,l=r.state;for(let u=0;u<i.rawInserted.length;++u)r.shift();d=this.appendTail(r),a=d.rawInserted.length===r.toString().length}a&&d.inserted&&(this.state=c)}a||(i=new Ve,this.state=o,r&&l&&(r.state=l))}return i}_appendPlaceholder(){return new Ve}_appendEager(){return new Ve}append(e,t,r){if(!er(e))throw new Error("value should be string");const o=er(r)?new pn(String(r)):r;t!=null&&t.tail&&(t._beforeTailState=this.state);let i;[e,i]=this.doPrepare(e,t);for(let l=0;l<e.length;++l){const a=this._appendChar(e[l],t,o);if(!a.rawInserted&&!this.doSkipInvalid(e[l],t,o))break;i.aggregate(a)}return(this.eager===!0||this.eager==="append")&&t!=null&&t.input&&e&&i.aggregate(this._appendEager()),o!=null&&(i.tailShift+=this.appendTail(o).tailShift),i}remove(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.displayValue.length),this._value=this.displayValue.slice(0,e)+this.displayValue.slice(t),new Ve}withValueRefresh(e){if(this._refreshing||!this._initialized)return e();this._refreshing=!0;const t=this.rawInputValue,r=this.value,o=e();return this.rawInputValue=t,this.value&&this.value!==r&&r.indexOf(this.value)===0&&(this.append(r.slice(this.displayValue.length),{},""),this.doCommit()),delete this._refreshing,o}runIsolated(e){if(this._isolated||!this._initialized)return e(this);this._isolated=!0;const t=this.state,r=e(this);return this.state=t,delete this._isolated,r}doSkipInvalid(e,t,r){return!!this.skipInvalid}doPrepare(e,t){return t===void 0&&(t={}),Ve.normalize(this.prepare?this.prepare(e,this,t):e)}doPrepareChar(e,t){return t===void 0&&(t={}),Ve.normalize(this.prepareChar?this.prepareChar(e,this,t):e)}doValidate(e){return(!this.validate||this.validate(this.value,this,e))&&(!this.parent||this.parent.doValidate(e))}doCommit(){this.commit&&this.commit(this.value,this)}splice(e,t,r,o,i){r===void 0&&(r=""),o===void 0&&(o=ve.NONE),i===void 0&&(i={input:!0});const l=e+t,a=this.extractTail(l),c=this.eager===!0||this.eager==="remove";let d;c&&(o=Bf(o),d=this.extractInput(0,l,{raw:!0}));let u=e;const f=new Ve;if(o!==ve.NONE&&(u=this.nearestInputPos(e,t>1&&e!==0&&!c?ve.NONE:o),f.tailShift=u-e),f.aggregate(this.remove(u)),c&&o!==ve.NONE&&d===this.rawInputValue)if(o===ve.FORCE_LEFT){let p;for(;d===this.rawInputValue&&(p=this.displayValue.length);)f.aggregate(new Ve({tailShift:-1})).aggregate(this.remove(p-1))}else o===ve.FORCE_RIGHT&&a.unshift();return f.aggregate(this.append(r,i,a))}maskEquals(e){return this.mask===e}optionsIsChanged(e){return!yi(this,e)}typedValueEquals(e){const t=this.typedValue;return e===t||kt.EMPTY_VALUES.includes(e)&&kt.EMPTY_VALUES.includes(t)||(this.format?this.format(e,this)===this.format(this.typedValue,this):!1)}pad(e){return new Ve}}kt.DEFAULTS={skipInvalid:!0},kt.EMPTY_VALUES=[void 0,null,""],Be.Masked=kt;class tr{constructor(e,t){e===void 0&&(e=[]),t===void 0&&(t=0),this.chunks=e,this.from=t}toString(){return this.chunks.map(String).join("")}extend(e){if(!String(e))return;e=er(e)?new pn(String(e)):e;const t=this.chunks[this.chunks.length-1],r=t&&(t.stop===e.stop||e.stop==null)&&e.from===t.from+t.toString().length;if(e instanceof pn)r?t.extend(e.toString()):this.chunks.push(e);else if(e instanceof tr){if(e.stop==null){let o;for(;e.chunks.length&&e.chunks[0].stop==null;)o=e.chunks.shift(),o.from+=e.from,this.extend(o)}e.toString()&&(e.stop=e.blockIndex,this.chunks.push(e))}}appendTo(e){if(!(e instanceof Be.MaskedPattern))return new pn(this.toString()).appendTo(e);const t=new Ve;for(let r=0;r<this.chunks.length;++r){const o=this.chunks[r],i=e._mapPosToBlock(e.displayValue.length),l=o.stop;let a;if(l!=null&&(!i||i.index<=l)&&((o instanceof tr||e._stops.indexOf(l)>=0)&&t.aggregate(e._appendPlaceholder(l)),a=o instanceof tr&&e._blocks[l]),a){const c=a.appendTail(o);t.aggregate(c);const d=o.toString().slice(c.rawInserted.length);d&&t.aggregate(e.append(d,{tail:!0}))}else t.aggregate(e.append(o.toString(),{tail:!0}))}return t}get state(){return{chunks:this.chunks.map(e=>e.state),from:this.from,stop:this.stop,blockIndex:this.blockIndex}}set state(e){const{chunks:t,...r}=e;Object.assign(this,r),this.chunks=t.map(o=>{const i="chunks"in o?new tr:new pn;return i.state=o,i})}unshift(e){if(!this.chunks.length||e!=null&&this.from>=e)return"";const t=e!=null?e-this.from:e;let r=0;for(;r<this.chunks.length;){const o=this.chunks[r],i=o.unshift(t);if(o.toString()){if(!i)break;++r}else this.chunks.splice(r,1);if(i)return i}return""}shift(){if(!this.chunks.length)return"";let e=this.chunks.length-1;for(;0<=e;){const t=this.chunks[e],r=t.shift();if(t.toString()){if(!r)break;--e}else this.chunks.splice(e,1);if(r)return r}return""}}class O2{constructor(e,t){this.masked=e,this._log=[];const{offset:r,index:o}=e._mapPosToBlock(t)||(t<0?{index:0,offset:0}:{index:this.masked._blocks.length,offset:0});this.offset=r,this.index=o,this.ok=!1}get block(){return this.masked._blocks[this.index]}get pos(){return this.masked._blockStartPos(this.index)+this.offset}get state(){return{index:this.index,offset:this.offset,ok:this.ok}}set state(e){Object.assign(this,e)}pushState(){this._log.push(this.state)}popState(){const e=this._log.pop();return e&&(this.state=e),e}bindBlock(){this.block||(this.index<0&&(this.index=0,this.offset=0),this.index>=this.masked._blocks.length&&(this.index=this.masked._blocks.length-1,this.offset=this.block.displayValue.length))}_pushLeft(e){for(this.pushState(),this.bindBlock();0<=this.index;--this.index,this.offset=((t=this.block)==null?void 0:t.displayValue.length)||0){var t;if(e())return this.ok=!0}return this.ok=!1}_pushRight(e){for(this.pushState(),this.bindBlock();this.index<this.masked._blocks.length;++this.index,this.offset=0)if(e())return this.ok=!0;return this.ok=!1}pushLeftBeforeFilled(){return this._pushLeft(()=>{if(!(this.block.isFixed||!this.block.value)&&(this.offset=this.block.nearestInputPos(this.offset,ve.FORCE_LEFT),this.offset!==0))return!0})}pushLeftBeforeInput(){return this._pushLeft(()=>{if(!this.block.isFixed)return this.offset=this.block.nearestInputPos(this.offset,ve.LEFT),!0})}pushLeftBeforeRequired(){return this._pushLeft(()=>{if(!(this.block.isFixed||this.block.isOptional&&!this.block.value))return this.offset=this.block.nearestInputPos(this.offset,ve.LEFT),!0})}pushRightBeforeFilled(){return this._pushRight(()=>{if(!(this.block.isFixed||!this.block.value)&&(this.offset=this.block.nearestInputPos(this.offset,ve.FORCE_RIGHT),this.offset!==this.block.value.length))return!0})}pushRightBeforeInput(){return this._pushRight(()=>{if(!this.block.isFixed)return this.offset=this.block.nearestInputPos(this.offset,ve.NONE),!0})}pushRightBeforeRequired(){return this._pushRight(()=>{if(!(this.block.isFixed||this.block.isOptional&&!this.block.value))return this.offset=this.block.nearestInputPos(this.offset,ve.NONE),!0})}}class Pa{constructor(e){Object.assign(this,e),this._value="",this.isFixed=!0}get value(){return this._value}get unmaskedValue(){return this.isUnmasking?this.value:""}get rawInputValue(){return this._isRawInput?this.value:""}get displayValue(){return this.value}reset(){this._isRawInput=!1,this._value=""}remove(e,t){return e===void 0&&(e=0),t===void 0&&(t=this._value.length),this._value=this._value.slice(0,e)+this._value.slice(t),this._value||(this._isRawInput=!1),new Ve}nearestInputPos(e,t){t===void 0&&(t=ve.NONE);const r=0,o=this._value.length;switch(t){case ve.LEFT:case ve.FORCE_LEFT:return r;case ve.NONE:case ve.RIGHT:case ve.FORCE_RIGHT:default:return o}}totalInputPositions(e,t){return e===void 0&&(e=0),t===void 0&&(t=this._value.length),this._isRawInput?t-e:0}extractInput(e,t,r){return e===void 0&&(e=0),t===void 0&&(t=this._value.length),r===void 0&&(r={}),r.raw&&this._isRawInput&&this._value.slice(e,t)||""}get isComplete(){return!0}get isFilled(){return!!this._value}_appendChar(e,t){if(t===void 0&&(t={}),this.isFilled)return new Ve;const r=this.eager===!0||this.eager==="append",i=this.char===e&&(this.isUnmasking||t.input||t.raw)&&(!t.raw||!r)&&!t.tail,l=new Ve({inserted:this.char,rawInserted:i?this.char:""});return this._value=this.char,this._isRawInput=i&&(t.raw||t.input),l}_appendEager(){return this._appendChar(this.char,{tail:!0})}_appendPlaceholder(){const e=new Ve;return this.isFilled||(this._value=e.inserted=this.char),e}extractTail(){return new pn("")}appendTail(e){return er(e)&&(e=new pn(String(e))),e.appendTo(this)}append(e,t,r){const o=this._appendChar(e[0],t);return r!=null&&(o.tailShift+=this.appendTail(r).tailShift),o}doCommit(){}get state(){return{_value:this._value,_rawInputValue:this.rawInputValue}}set state(e){this._value=e._value,this._isRawInput=!!e._rawInputValue}pad(e){return this._appendPlaceholder()}}class Ro{constructor(e){const{parent:t,isOptional:r,placeholderChar:o,displayChar:i,lazy:l,eager:a,...c}=e;this.masked=fn(c),Object.assign(this,{parent:t,isOptional:r,placeholderChar:o,displayChar:i,lazy:l,eager:a})}reset(){this.isFilled=!1,this.masked.reset()}remove(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.value.length),e===0&&t>=1?(this.isFilled=!1,this.masked.remove(e,t)):new Ve}get value(){return this.masked.value||(this.isFilled&&!this.isOptional?this.placeholderChar:"")}get unmaskedValue(){return this.masked.unmaskedValue}get rawInputValue(){return this.masked.rawInputValue}get displayValue(){return this.masked.value&&this.displayChar||this.value}get isComplete(){return!!this.masked.value||this.isOptional}_appendChar(e,t){if(t===void 0&&(t={}),this.isFilled)return new Ve;const r=this.masked.state;let o=this.masked._appendChar(e,this.currentMaskFlags(t));return o.inserted&&this.doValidate(t)===!1&&(o=new Ve,this.masked.state=r),!o.inserted&&!this.isOptional&&!this.lazy&&!t.input&&(o.inserted=this.placeholderChar),o.skip=!o.inserted&&!this.isOptional,this.isFilled=!!o.inserted,o}append(e,t,r){return this.masked.append(e,this.currentMaskFlags(t),r)}_appendPlaceholder(){return this.isFilled||this.isOptional?new Ve:(this.isFilled=!0,new Ve({inserted:this.placeholderChar}))}_appendEager(){return new Ve}extractTail(e,t){return this.masked.extractTail(e,t)}appendTail(e){return this.masked.appendTail(e)}extractInput(e,t,r){return e===void 0&&(e=0),t===void 0&&(t=this.value.length),this.masked.extractInput(e,t,r)}nearestInputPos(e,t){t===void 0&&(t=ve.NONE);const r=0,o=this.value.length,i=Math.min(Math.max(e,r),o);switch(t){case ve.LEFT:case ve.FORCE_LEFT:return this.isComplete?i:r;case ve.RIGHT:case ve.FORCE_RIGHT:return this.isComplete?i:o;case ve.NONE:default:return i}}totalInputPositions(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.value.length),this.value.slice(e,t).length}doValidate(e){return this.masked.doValidate(this.currentMaskFlags(e))&&(!this.parent||this.parent.doValidate(this.currentMaskFlags(e)))}doCommit(){this.masked.doCommit()}get state(){return{_value:this.value,_rawInputValue:this.rawInputValue,masked:this.masked.state,isFilled:this.isFilled}}set state(e){this.masked.state=e.masked,this.isFilled=e.isFilled}currentMaskFlags(e){var t;return{...e,_beforeTailState:(e==null||(t=e._beforeTailState)==null?void 0:t.masked)||e?._beforeTailState}}pad(e){return new Ve}}Ro.DEFAULT_DEFINITIONS={0:/\d/,a:/[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,"*":/./};class Lf extends kt{updateOptions(e){super.updateOptions(e)}_update(e){const t=e.mask;t&&(e.validate=r=>r.search(t)>=0),super._update(e)}}Be.MaskedRegExp=Lf;class wt extends kt{constructor(e){super({...wt.DEFAULTS,...e,definitions:Object.assign({},Ro.DEFAULT_DEFINITIONS,e?.definitions)})}updateOptions(e){super.updateOptions(e)}_update(e){e.definitions=Object.assign({},this.definitions,e.definitions),super._update(e),this._rebuildMask()}_rebuildMask(){const e=this.definitions;this._blocks=[],this.exposeBlock=void 0,this._stops=[],this._maskedBlocks={};const t=this.mask;if(!t||!e)return;let r=!1,o=!1;for(let i=0;i<t.length;++i){if(this.blocks){const d=t.slice(i),u=Object.keys(this.blocks).filter(p=>d.indexOf(p)===0);u.sort((p,h)=>h.length-p.length);const f=u[0];if(f){const{expose:p,repeat:h,...m}=so(this.blocks[f]),g={lazy:this.lazy,eager:this.eager,placeholderChar:this.placeholderChar,displayChar:this.displayChar,overwrite:this.overwrite,autofix:this.autofix,...m,repeat:h,parent:this},y=h!=null?new Be.RepeatBlock(g):fn(g);y&&(this._blocks.push(y),p&&(this.exposeBlock=y),this._maskedBlocks[f]||(this._maskedBlocks[f]=[]),this._maskedBlocks[f].push(this._blocks.length-1)),i+=f.length-1;continue}}let l=t[i],a=l in e;if(l===wt.STOP_CHAR){this._stops.push(this._blocks.length);continue}if(l==="{"||l==="}"){r=!r;continue}if(l==="["||l==="]"){o=!o;continue}if(l===wt.ESCAPE_CHAR){if(++i,l=t[i],!l)break;a=!1}const c=a?new Ro({isOptional:o,lazy:this.lazy,eager:this.eager,placeholderChar:this.placeholderChar,displayChar:this.displayChar,...so(e[l]),parent:this}):new Pa({char:l,eager:this.eager,isUnmasking:r});this._blocks.push(c)}}get state(){return{...super.state,_blocks:this._blocks.map(e=>e.state)}}set state(e){if(!e){this.reset();return}const{_blocks:t,...r}=e;this._blocks.forEach((o,i)=>o.state=t[i]),super.state=r}reset(){super.reset(),this._blocks.forEach(e=>e.reset())}get isComplete(){return this.exposeBlock?this.exposeBlock.isComplete:this._blocks.every(e=>e.isComplete)}get isFilled(){return this._blocks.every(e=>e.isFilled)}get isFixed(){return this._blocks.every(e=>e.isFixed)}get isOptional(){return this._blocks.every(e=>e.isOptional)}doCommit(){this._blocks.forEach(e=>e.doCommit()),super.doCommit()}get unmaskedValue(){return this.exposeBlock?this.exposeBlock.unmaskedValue:this._blocks.reduce((e,t)=>e+=t.unmaskedValue,"")}set unmaskedValue(e){if(this.exposeBlock){const t=this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock))+this.exposeBlock.displayValue.length);this.exposeBlock.unmaskedValue=e,this.appendTail(t),this.doCommit()}else super.unmaskedValue=e}get value(){return this.exposeBlock?this.exposeBlock.value:this._blocks.reduce((e,t)=>e+=t.value,"")}set value(e){if(this.exposeBlock){const t=this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock))+this.exposeBlock.displayValue.length);this.exposeBlock.value=e,this.appendTail(t),this.doCommit()}else super.value=e}get typedValue(){return this.exposeBlock?this.exposeBlock.typedValue:super.typedValue}set typedValue(e){if(this.exposeBlock){const t=this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock))+this.exposeBlock.displayValue.length);this.exposeBlock.typedValue=e,this.appendTail(t),this.doCommit()}else super.typedValue=e}get displayValue(){return this._blocks.reduce((e,t)=>e+=t.displayValue,"")}appendTail(e){return super.appendTail(e).aggregate(this._appendPlaceholder())}_appendEager(){var e;const t=new Ve;let r=(e=this._mapPosToBlock(this.displayValue.length))==null?void 0:e.index;if(r==null)return t;this._blocks[r].isFilled&&++r;for(let o=r;o<this._blocks.length;++o){const i=this._blocks[o]._appendEager();if(!i.inserted)break;t.aggregate(i)}return t}_appendCharRaw(e,t){t===void 0&&(t={});const r=this._mapPosToBlock(this.displayValue.length),o=new Ve;if(!r)return o;for(let l=r.index,a;a=this._blocks[l];++l){var i;const c=a._appendChar(e,{...t,_beforeTailState:(i=t._beforeTailState)==null||(i=i._blocks)==null?void 0:i[l]});if(o.aggregate(c),c.consumed)break}return o}extractTail(e,t){e===void 0&&(e=0),t===void 0&&(t=this.displayValue.length);const r=new tr;return e===t||this._forEachBlocksInRange(e,t,(o,i,l,a)=>{const c=o.extractTail(l,a);c.stop=this._findStopBefore(i),c.from=this._blockStartPos(i),c instanceof tr&&(c.blockIndex=i),r.extend(c)}),r}extractInput(e,t,r){if(e===void 0&&(e=0),t===void 0&&(t=this.displayValue.length),r===void 0&&(r={}),e===t)return"";let o="";return this._forEachBlocksInRange(e,t,(i,l,a,c)=>{o+=i.extractInput(a,c,r)}),o}_findStopBefore(e){let t;for(let r=0;r<this._stops.length;++r){const o=this._stops[r];if(o<=e)t=o;else break}return t}_appendPlaceholder(e){const t=new Ve;if(this.lazy&&e==null)return t;const r=this._mapPosToBlock(this.displayValue.length);if(!r)return t;const o=r.index,i=e??this._blocks.length;return this._blocks.slice(o,i).forEach(l=>{if(!l.lazy||e!=null){var a;t.aggregate(l._appendPlaceholder((a=l._blocks)==null?void 0:a.length))}}),t}_mapPosToBlock(e){let t="";for(let r=0;r<this._blocks.length;++r){const o=this._blocks[r],i=t.length;if(t+=o.displayValue,e<=t.length)return{index:r,offset:e-i}}}_blockStartPos(e){return this._blocks.slice(0,e).reduce((t,r)=>t+=r.displayValue.length,0)}_forEachBlocksInRange(e,t,r){t===void 0&&(t=this.displayValue.length);const o=this._mapPosToBlock(e);if(o){const i=this._mapPosToBlock(t),l=i&&o.index===i.index,a=o.offset,c=i&&l?i.offset:this._blocks[o.index].displayValue.length;if(r(this._blocks[o.index],o.index,a,c),i&&!l){for(let d=o.index+1;d<i.index;++d)r(this._blocks[d],d,0,this._blocks[d].displayValue.length);r(this._blocks[i.index],i.index,0,i.offset)}}}remove(e,t){e===void 0&&(e=0),t===void 0&&(t=this.displayValue.length);const r=super.remove(e,t);return this._forEachBlocksInRange(e,t,(o,i,l,a)=>{r.aggregate(o.remove(l,a))}),r}nearestInputPos(e,t){if(t===void 0&&(t=ve.NONE),!this._blocks.length)return 0;const r=new O2(this,e);if(t===ve.NONE)return r.pushRightBeforeInput()||(r.popState(),r.pushLeftBeforeInput())?r.pos:this.displayValue.length;if(t===ve.LEFT||t===ve.FORCE_LEFT){if(t===ve.LEFT){if(r.pushRightBeforeFilled(),r.ok&&r.pos===e)return e;r.popState()}if(r.pushLeftBeforeInput(),r.pushLeftBeforeRequired(),r.pushLeftBeforeFilled(),t===ve.LEFT){if(r.pushRightBeforeInput(),r.pushRightBeforeRequired(),r.ok&&r.pos<=e||(r.popState(),r.ok&&r.pos<=e))return r.pos;r.popState()}return r.ok?r.pos:t===ve.FORCE_LEFT?0:(r.popState(),r.ok||(r.popState(),r.ok)?r.pos:0)}return t===ve.RIGHT||t===ve.FORCE_RIGHT?(r.pushRightBeforeInput(),r.pushRightBeforeRequired(),r.pushRightBeforeFilled()?r.pos:t===ve.FORCE_RIGHT?this.displayValue.length:(r.popState(),r.ok||(r.popState(),r.ok)?r.pos:this.nearestInputPos(e,ve.LEFT))):e}totalInputPositions(e,t){e===void 0&&(e=0),t===void 0&&(t=this.displayValue.length);let r=0;return this._forEachBlocksInRange(e,t,(o,i,l,a)=>{r+=o.totalInputPositions(l,a)}),r}maskedBlock(e){return this.maskedBlocks(e)[0]}maskedBlocks(e){const t=this._maskedBlocks[e];return t?t.map(r=>this._blocks[r]):[]}pad(e){const t=new Ve;return this._forEachBlocksInRange(0,this.displayValue.length,r=>t.aggregate(r.pad(e))),t}}wt.DEFAULTS={...kt.DEFAULTS,lazy:!0,placeholderChar:"_"},wt.STOP_CHAR="`",wt.ESCAPE_CHAR="\\",wt.InputDefinition=Ro,wt.FixedDefinition=Pa,Be.MaskedPattern=wt;class Fo extends wt{get _matchFrom(){return this.maxLength-String(this.from).length}constructor(e){super(e)}updateOptions(e){super.updateOptions(e)}_update(e){const{to:t=this.to||0,from:r=this.from||0,maxLength:o=this.maxLength||0,autofix:i=this.autofix,...l}=e;this.to=t,this.from=r,this.maxLength=Math.max(String(t).length,o),this.autofix=i;const a=String(this.from).padStart(this.maxLength,"0"),c=String(this.to).padStart(this.maxLength,"0");let d=0;for(;d<c.length&&c[d]===a[d];)++d;l.mask=c.slice(0,d).replace(/0/g,"\\0")+"0".repeat(this.maxLength-d),super._update(l)}get isComplete(){return super.isComplete&&!!this.value}boundaries(e){let t="",r="";const[,o,i]=e.match(/^(\D*)(\d*)(\D*)/)||[];return i&&(t="0".repeat(o.length)+i,r="9".repeat(o.length)+i),t=t.padEnd(this.maxLength,"0"),r=r.padEnd(this.maxLength,"9"),[t,r]}doPrepareChar(e,t){t===void 0&&(t={});let r;return[e,r]=super.doPrepareChar(e.replace(/\D/g,""),t),e||(r.skip=!this.isComplete),[e,r]}_appendCharRaw(e,t){if(t===void 0&&(t={}),!this.autofix||this.value.length+1>this.maxLength)return super._appendCharRaw(e,t);const r=String(this.from).padStart(this.maxLength,"0"),o=String(this.to).padStart(this.maxLength,"0"),[i,l]=this.boundaries(this.value+e);return Number(l)<this.from?super._appendCharRaw(r[this.value.length],t):Number(i)>this.to?!t.tail&&this.autofix==="pad"&&this.value.length+1<this.maxLength?super._appendCharRaw(r[this.value.length],t).aggregate(this._appendCharRaw(e,t)):super._appendCharRaw(o[this.value.length],t):super._appendCharRaw(e,t)}doValidate(e){const t=this.value;if(t.search(/[^0]/)===-1&&t.length<=this._matchFrom)return!0;const[o,i]=this.boundaries(t);return this.from<=Number(i)&&Number(o)<=this.to&&super.doValidate(e)}pad(e){const t=new Ve;if(this.value.length===this.maxLength)return t;const r=this.value,o=this.maxLength-this.value.length;if(o){this.reset();for(let i=0;i<o;++i)t.aggregate(super._appendCharRaw("0",e));r.split("").forEach(i=>this._appendCharRaw(i))}return t}}Be.MaskedRange=Fo;const R2="d{.}`m{.}`Y";class hn extends wt{static extractPatternOptions(e){const{mask:t,pattern:r,...o}=e;return{...o,mask:er(t)?t:r}}constructor(e){super(hn.extractPatternOptions({...hn.DEFAULTS,...e}))}updateOptions(e){super.updateOptions(e)}_update(e){const{mask:t,pattern:r,blocks:o,...i}={...hn.DEFAULTS,...e},l=Object.assign({},hn.GET_DEFAULT_BLOCKS());e.min&&(l.Y.from=e.min.getFullYear()),e.max&&(l.Y.to=e.max.getFullYear()),e.min&&e.max&&l.Y.from===l.Y.to&&(l.m.from=e.min.getMonth()+1,l.m.to=e.max.getMonth()+1,l.m.from===l.m.to&&(l.d.from=e.min.getDate(),l.d.to=e.max.getDate())),Object.assign(l,this.blocks,o),super._update({...i,mask:er(t)?t:r,blocks:l})}doValidate(e){const t=this.date;return super.doValidate(e)&&(!this.isComplete||this.isDateExist(this.value)&&t!=null&&(this.min==null||this.min<=t)&&(this.max==null||t<=this.max))}isDateExist(e){return this.format(this.parse(e,this),this).indexOf(e)>=0}get date(){return this.typedValue}set date(e){this.typedValue=e}get typedValue(){return this.isComplete?super.typedValue:null}set typedValue(e){super.typedValue=e}maskEquals(e){return e===Date||super.maskEquals(e)}optionsIsChanged(e){return super.optionsIsChanged(hn.extractPatternOptions(e))}}hn.GET_DEFAULT_BLOCKS=()=>({d:{mask:Fo,from:1,to:31,maxLength:2},m:{mask:Fo,from:1,to:12,maxLength:2},Y:{mask:Fo,from:1900,to:9999}}),hn.DEFAULTS={...wt.DEFAULTS,mask:Date,pattern:R2,format:(n,e)=>{if(!n)return"";const t=String(n.getDate()).padStart(2,"0"),r=String(n.getMonth()+1).padStart(2,"0"),o=n.getFullYear();return[t,r,o].join(".")},parse:(n,e)=>{const[t,r,o]=n.split(".").map(Number);return new Date(o,r-1,t)}},Be.MaskedDate=hn;class Po extends kt{constructor(e){super({...Po.DEFAULTS,...e}),this.currentMask=void 0}updateOptions(e){super.updateOptions(e)}_update(e){super._update(e),"mask"in e&&(this.exposeMask=void 0,this.compiledMasks=Array.isArray(e.mask)?e.mask.map(t=>{const{expose:r,...o}=so(t),i=fn({overwrite:this._overwrite,eager:this._eager,skipInvalid:this._skipInvalid,...o});return r&&(this.exposeMask=i),i}):[])}_appendCharRaw(e,t){t===void 0&&(t={});const r=this._applyDispatch(e,t);return this.currentMask&&r.aggregate(this.currentMask._appendChar(e,this.currentMaskFlags(t))),r}_applyDispatch(e,t,r){e===void 0&&(e=""),t===void 0&&(t={}),r===void 0&&(r="");const o=t.tail&&t._beforeTailState!=null?t._beforeTailState._value:this.value,i=this.rawInputValue,l=t.tail&&t._beforeTailState!=null?t._beforeTailState._rawInputValue:i,a=i.slice(l.length),c=this.currentMask,d=new Ve,u=c?.state;return this.currentMask=this.doDispatch(e,{...t},r),this.currentMask&&(this.currentMask!==c?(this.currentMask.reset(),l&&(this.currentMask.append(l,{raw:!0}),d.tailShift=this.currentMask.value.length-o.length),a&&(d.tailShift+=this.currentMask.append(a,{raw:!0,tail:!0}).tailShift)):u&&(this.currentMask.state=u)),d}_appendPlaceholder(){const e=this._applyDispatch();return this.currentMask&&e.aggregate(this.currentMask._appendPlaceholder()),e}_appendEager(){const e=this._applyDispatch();return this.currentMask&&e.aggregate(this.currentMask._appendEager()),e}appendTail(e){const t=new Ve;return e&&t.aggregate(this._applyDispatch("",{},e)),t.aggregate(this.currentMask?this.currentMask.appendTail(e):super.appendTail(e))}currentMaskFlags(e){var t,r;return{...e,_beforeTailState:((t=e._beforeTailState)==null?void 0:t.currentMaskRef)===this.currentMask&&((r=e._beforeTailState)==null?void 0:r.currentMask)||e._beforeTailState}}doDispatch(e,t,r){return t===void 0&&(t={}),r===void 0&&(r=""),this.dispatch(e,this,t,r)}doValidate(e){return super.doValidate(e)&&(!this.currentMask||this.currentMask.doValidate(this.currentMaskFlags(e)))}doPrepare(e,t){t===void 0&&(t={});let[r,o]=super.doPrepare(e,t);if(this.currentMask){let i;[r,i]=super.doPrepare(r,this.currentMaskFlags(t)),o=o.aggregate(i)}return[r,o]}doPrepareChar(e,t){t===void 0&&(t={});let[r,o]=super.doPrepareChar(e,t);if(this.currentMask){let i;[r,i]=super.doPrepareChar(r,this.currentMaskFlags(t)),o=o.aggregate(i)}return[r,o]}reset(){var e;(e=this.currentMask)==null||e.reset(),this.compiledMasks.forEach(t=>t.reset())}get value(){return this.exposeMask?this.exposeMask.value:this.currentMask?this.currentMask.value:""}set value(e){this.exposeMask?(this.exposeMask.value=e,this.currentMask=this.exposeMask,this._applyDispatch()):super.value=e}get unmaskedValue(){return this.exposeMask?this.exposeMask.unmaskedValue:this.currentMask?this.currentMask.unmaskedValue:""}set unmaskedValue(e){this.exposeMask?(this.exposeMask.unmaskedValue=e,this.currentMask=this.exposeMask,this._applyDispatch()):super.unmaskedValue=e}get typedValue(){return this.exposeMask?this.exposeMask.typedValue:this.currentMask?this.currentMask.typedValue:""}set typedValue(e){if(this.exposeMask){this.exposeMask.typedValue=e,this.currentMask=this.exposeMask,this._applyDispatch();return}let t=String(e);this.currentMask&&(this.currentMask.typedValue=e,t=this.currentMask.unmaskedValue),this.unmaskedValue=t}get displayValue(){return this.currentMask?this.currentMask.displayValue:""}get isComplete(){var e;return!!((e=this.currentMask)!=null&&e.isComplete)}get isFilled(){var e;return!!((e=this.currentMask)!=null&&e.isFilled)}remove(e,t){const r=new Ve;return this.currentMask&&r.aggregate(this.currentMask.remove(e,t)).aggregate(this._applyDispatch()),r}get state(){var e;return{...super.state,_rawInputValue:this.rawInputValue,compiledMasks:this.compiledMasks.map(t=>t.state),currentMaskRef:this.currentMask,currentMask:(e=this.currentMask)==null?void 0:e.state}}set state(e){const{compiledMasks:t,currentMaskRef:r,currentMask:o,...i}=e;t&&this.compiledMasks.forEach((l,a)=>l.state=t[a]),r!=null&&(this.currentMask=r,this.currentMask.state=o),super.state=i}extractInput(e,t,r){return this.currentMask?this.currentMask.extractInput(e,t,r):""}extractTail(e,t){return this.currentMask?this.currentMask.extractTail(e,t):super.extractTail(e,t)}doCommit(){this.currentMask&&this.currentMask.doCommit(),super.doCommit()}nearestInputPos(e,t){return this.currentMask?this.currentMask.nearestInputPos(e,t):super.nearestInputPos(e,t)}get overwrite(){return this.currentMask?this.currentMask.overwrite:this._overwrite}set overwrite(e){this._overwrite=e}get eager(){return this.currentMask?this.currentMask.eager:this._eager}set eager(e){this._eager=e}get skipInvalid(){return this.currentMask?this.currentMask.skipInvalid:this._skipInvalid}set skipInvalid(e){this._skipInvalid=e}get autofix(){return this.currentMask?this.currentMask.autofix:this._autofix}set autofix(e){this._autofix=e}maskEquals(e){return Array.isArray(e)?this.compiledMasks.every((t,r)=>{if(!e[r])return;const{mask:o,...i}=e[r];return yi(t,i)&&t.maskEquals(o)}):super.maskEquals(e)}typedValueEquals(e){var t;return!!((t=this.currentMask)!=null&&t.typedValueEquals(e))}}Po.DEFAULTS={...kt.DEFAULTS,dispatch:(n,e,t,r)=>{if(!e.compiledMasks.length)return;const o=e.rawInputValue,i=e.compiledMasks.map((l,a)=>{const c=e.currentMask===l,d=c?l.displayValue.length:l.nearestInputPos(l.displayValue.length,ve.FORCE_LEFT);return l.rawInputValue!==o?(l.reset(),l.append(o,{raw:!0})):c||l.remove(d),l.append(n,e.currentMaskFlags(t)),l.appendTail(r),{index:a,weight:l.rawInputValue.length,totalInputPositions:l.totalInputPositions(0,Math.max(d,l.nearestInputPos(l.displayValue.length,ve.FORCE_LEFT)))}});return i.sort((l,a)=>a.weight-l.weight||a.totalInputPositions-l.totalInputPositions),e.compiledMasks[i[0].index]}},Be.MaskedDynamic=Po;class zo extends wt{constructor(e){super({...zo.DEFAULTS,...e})}updateOptions(e){super.updateOptions(e)}_update(e){const{enum:t,...r}=e;if(t){const o=t.map(a=>a.length),i=Math.min(...o),l=Math.max(...o)-i;r.mask="*".repeat(i),l&&(r.mask+="["+"*".repeat(l)+"]"),this.enum=t}super._update(r)}_appendCharRaw(e,t){t===void 0&&(t={});const r=Math.min(this.nearestInputPos(0,ve.FORCE_RIGHT),this.value.length),o=this.enum.filter(i=>this.matchValue(i,this.unmaskedValue+e,r));if(o.length){o.length===1&&this._forEachBlocksInRange(0,this.value.length,(l,a)=>{const c=o[0][a];a>=this.value.length||c===l.value||(l.reset(),l._appendChar(c,t))});const i=super._appendCharRaw(o[0][this.value.length],t);return o.length===1&&o[0].slice(this.unmaskedValue.length).split("").forEach(l=>i.aggregate(super._appendCharRaw(l))),i}return new Ve({skip:!this.isComplete})}extractTail(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.displayValue.length),new pn("",e)}remove(e,t){if(e===void 0&&(e=0),t===void 0&&(t=this.displayValue.length),e===t)return new Ve;const r=Math.min(super.nearestInputPos(0,ve.FORCE_RIGHT),this.value.length);let o;for(o=e;o>=0&&!(this.enum.filter(a=>this.matchValue(a,this.value.slice(r,o),r)).length>1);--o);const i=super.remove(o,t);return i.tailShift+=o-e,i}get isComplete(){return this.enum.indexOf(this.value)>=0}}zo.DEFAULTS={...wt.DEFAULTS,matchValue:(n,e,t)=>n.indexOf(e,t)===t},Be.MaskedEnum=zo;class If extends kt{updateOptions(e){super.updateOptions(e)}_update(e){super._update({...e,validate:e.mask})}}Be.MaskedFunction=If;var Of;class It extends kt{constructor(e){super({...It.DEFAULTS,...e})}updateOptions(e){super.updateOptions(e)}_update(e){super._update(e),this._updateRegExps()}_updateRegExps(){const e="^"+(this.allowNegative?"[+|\\-]?":""),t="\\d*",r=(this.scale?"("+Ra(this.radix)+"\\d{0,"+this.scale+"})?":"")+"$";this._numberRegExp=new RegExp(e+t+r),this._mapToRadixRegExp=new RegExp("["+this.mapToRadix.map(Ra).join("")+"]","g"),this._thousandsSeparatorRegExp=new RegExp(Ra(this.thousandsSeparator),"g")}_removeThousandsSeparators(e){return e.replace(this._thousandsSeparatorRegExp,"")}_insertThousandsSeparators(e){const t=e.split(this.radix);return t[0]=t[0].replace(/\B(?=(\d{3})+(?!\d))/g,this.thousandsSeparator),t.join(this.radix)}doPrepareChar(e,t){t===void 0&&(t={});const[r,o]=super.doPrepareChar(this._removeThousandsSeparators(this.scale&&this.mapToRadix.length&&(t.input&&t.raw||!t.input&&!t.raw)?e.replace(this._mapToRadixRegExp,this.radix):e),t);return e&&!r&&(o.skip=!0),r&&!this.allowPositive&&!this.value&&r!=="-"&&o.aggregate(this._appendChar("-")),[r,o]}_separatorsCount(e,t){t===void 0&&(t=!1);let r=0;for(let o=0;o<e;++o)this._value.indexOf(this.thousandsSeparator,o)===o&&(++r,t&&(e+=this.thousandsSeparator.length));return r}_separatorsCountFromSlice(e){return e===void 0&&(e=this._value),this._separatorsCount(this._removeThousandsSeparators(e).length,!0)}extractInput(e,t,r){return e===void 0&&(e=0),t===void 0&&(t=this.displayValue.length),[e,t]=this._adjustRangeWithSeparators(e,t),this._removeThousandsSeparators(super.extractInput(e,t,r))}_appendCharRaw(e,t){t===void 0&&(t={});const r=t.tail&&t._beforeTailState?t._beforeTailState._value:this._value,o=this._separatorsCountFromSlice(r);this._value=this._removeThousandsSeparators(this.value);const i=this._value;this._value+=e;const l=this.number;let a=!isNaN(l),c=!1;if(a){let p;this.min!=null&&this.min<0&&this.number<this.min&&(p=this.min),this.max!=null&&this.max>0&&this.number>this.max&&(p=this.max),p!=null&&(this.autofix?(this._value=this.format(p,this).replace(It.UNMASKED_RADIX,this.radix),c||(c=i===this._value&&!t.tail)):a=!1),a&&(a=!!this._value.match(this._numberRegExp))}let d;a?d=new Ve({inserted:this._value.slice(i.length),rawInserted:c?"":e,skip:c}):(this._value=i,d=new Ve),this._value=this._insertThousandsSeparators(this._value);const u=t.tail&&t._beforeTailState?t._beforeTailState._value:this._value,f=this._separatorsCountFromSlice(u);return d.tailShift+=(f-o)*this.thousandsSeparator.length,d}_findSeparatorAround(e){if(this.thousandsSeparator){const t=e-this.thousandsSeparator.length+1,r=this.value.indexOf(this.thousandsSeparator,t);if(r<=e)return r}return-1}_adjustRangeWithSeparators(e,t){const r=this._findSeparatorAround(e);r>=0&&(e=r);const o=this._findSeparatorAround(t);return o>=0&&(t=o+this.thousandsSeparator.length),[e,t]}remove(e,t){e===void 0&&(e=0),t===void 0&&(t=this.displayValue.length),[e,t]=this._adjustRangeWithSeparators(e,t);const r=this.value.slice(0,e),o=this.value.slice(t),i=this._separatorsCount(r.length);this._value=this._insertThousandsSeparators(this._removeThousandsSeparators(r+o));const l=this._separatorsCountFromSlice(r);return new Ve({tailShift:(l-i)*this.thousandsSeparator.length})}nearestInputPos(e,t){if(!this.thousandsSeparator)return e;switch(t){case ve.NONE:case ve.LEFT:case ve.FORCE_LEFT:{const r=this._findSeparatorAround(e-1);if(r>=0){const o=r+this.thousandsSeparator.length;if(e<o||this.value.length<=o||t===ve.FORCE_LEFT)return r}break}case ve.RIGHT:case ve.FORCE_RIGHT:{const r=this._findSeparatorAround(e);if(r>=0)return r+this.thousandsSeparator.length}}return e}doCommit(){if(this.value){const e=this.number;let t=e;this.min!=null&&(t=Math.max(t,this.min)),this.max!=null&&(t=Math.min(t,this.max)),t!==e&&(this.unmaskedValue=this.format(t,this));let r=this.value;this.normalizeZeros&&(r=this._normalizeZeros(r)),this.padFractionalZeros&&this.scale>0&&(r=this._padFractionalZeros(r)),this._value=r}super.doCommit()}_normalizeZeros(e){const t=this._removeThousandsSeparators(e).split(this.radix);return t[0]=t[0].replace(/^(\D*)(0*)(\d*)/,(r,o,i,l)=>o+l),e.length&&!/\d$/.test(t[0])&&(t[0]=t[0]+"0"),t.length>1&&(t[1]=t[1].replace(/0*$/,""),t[1].length||(t.length=1)),this._insertThousandsSeparators(t.join(this.radix))}_padFractionalZeros(e){if(!e)return e;const t=e.split(this.radix);return t.length<2&&t.push(""),t[1]=t[1].padEnd(this.scale,"0"),t.join(this.radix)}doSkipInvalid(e,t,r){t===void 0&&(t={});const o=this.scale===0&&e!==this.thousandsSeparator&&(e===this.radix||e===It.UNMASKED_RADIX||this.mapToRadix.includes(e));return super.doSkipInvalid(e,t,r)&&!o}get unmaskedValue(){return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix,It.UNMASKED_RADIX)}set unmaskedValue(e){super.unmaskedValue=e}get typedValue(){return this.parse(this.unmaskedValue,this)}set typedValue(e){this.rawInputValue=this.format(e,this).replace(It.UNMASKED_RADIX,this.radix)}get number(){return this.typedValue}set number(e){this.typedValue=e}get allowNegative(){return this.min!=null&&this.min<0||this.max!=null&&this.max<0}get allowPositive(){return this.min!=null&&this.min>0||this.max!=null&&this.max>0}typedValueEquals(e){return(super.typedValueEquals(e)||It.EMPTY_VALUES.includes(e)&&It.EMPTY_VALUES.includes(this.typedValue))&&!(e===0&&this.value==="")}}Of=It,It.UNMASKED_RADIX=".",It.EMPTY_VALUES=[...kt.EMPTY_VALUES,0],It.DEFAULTS={...kt.DEFAULTS,mask:Number,radix:",",thousandsSeparator:"",mapToRadix:[Of.UNMASKED_RADIX],min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,scale:2,normalizeZeros:!0,padFractionalZeros:!1,parse:Number,format:n=>n.toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:20})},Be.MaskedNumber=It;const wi={MASKED:"value",UNMASKED:"unmaskedValue",TYPED:"typedValue"};function za(n,e,t){e===void 0&&(e=wi.MASKED),t===void 0&&(t=wi.MASKED);const r=fn(n);return o=>r.runIsolated(i=>(i[e]=o,i[t]))}function Rf(n,e,t,r){return za(e,t,r)(n)}Be.PIPE_TYPE=wi,Be.createPipe=za,Be.pipe=Rf;class Ff extends wt{get repeatFrom(){var e;return(e=Array.isArray(this.repeat)?this.repeat[0]:this.repeat===1/0?0:this.repeat)!=null?e:0}get repeatTo(){var e;return(e=Array.isArray(this.repeat)?this.repeat[1]:this.repeat)!=null?e:1/0}constructor(e){super(e)}updateOptions(e){super.updateOptions(e)}_update(e){var t,r,o;const{repeat:i,...l}=so(e);this._blockOpts=Object.assign({},this._blockOpts,l);const a=fn(this._blockOpts);this.repeat=(t=(r=i??a.repeat)!=null?r:this.repeat)!=null?t:1/0,super._update({mask:"m".repeat(Math.max(this.repeatTo===1/0&&((o=this._blocks)==null?void 0:o.length)||0,this.repeatFrom)),blocks:{m:a},eager:a.eager,overwrite:a.overwrite,skipInvalid:a.skipInvalid,lazy:a.lazy,placeholderChar:a.placeholderChar,displayChar:a.displayChar})}_allocateBlock(e){if(e<this._blocks.length)return this._blocks[e];if(this.repeatTo===1/0||this._blocks.length<this.repeatTo)return this._blocks.push(fn(this._blockOpts)),this.mask+="m",this._blocks[this._blocks.length-1]}_appendCharRaw(e,t){t===void 0&&(t={});const r=new Ve;for(let c=(o=(i=this._mapPosToBlock(this.displayValue.length))==null?void 0:i.index)!=null?o:Math.max(this._blocks.length-1,0),d,u;d=(l=this._blocks[c])!=null?l:u=!u&&this._allocateBlock(c);++c){var o,i,l,a;const f=d._appendChar(e,{...t,_beforeTailState:(a=t._beforeTailState)==null||(a=a._blocks)==null?void 0:a[c]});if(f.skip&&u){this._blocks.pop(),this.mask=this.mask.slice(1);break}if(r.aggregate(f),f.consumed)break}return r}_trimEmptyTail(e,t){var r,o;e===void 0&&(e=0);const i=Math.max(((r=this._mapPosToBlock(e))==null?void 0:r.index)||0,this.repeatFrom,0);let l;t!=null&&(l=(o=this._mapPosToBlock(t))==null?void 0:o.index),l==null&&(l=this._blocks.length-1);let a=0;for(let c=l;i<=c&&!this._blocks[c].unmaskedValue;--c,++a);a&&(this._blocks.splice(l-a+1,a),this.mask=this.mask.slice(a))}reset(){super.reset(),this._trimEmptyTail()}remove(e,t){e===void 0&&(e=0),t===void 0&&(t=this.displayValue.length);const r=super.remove(e,t);return this._trimEmptyTail(e,t),r}totalInputPositions(e,t){return e===void 0&&(e=0),t==null&&this.repeatTo===1/0?1/0:super.totalInputPositions(e,t)}get state(){return super.state}set state(e){this._blocks.length=e._blocks.length,this.mask=this.mask.slice(0,this._blocks.length),super.state=e}}Be.RepeatBlock=Ff;try{globalThis.IMask=Be}catch{}const xi=Object.freeze(Object.defineProperty({__proto__:null,ChangeDetails:Ve,ChunksTailDetails:tr,DIRECTION:ve,HTMLContenteditableMaskElement:Fa,HTMLInputMaskElement:Vf,HTMLMaskElement:Oo,InputMask:$f,MaskElement:bi,Masked:kt,MaskedDate:hn,MaskedDynamic:Po,MaskedEnum:zo,MaskedFunction:If,MaskedNumber:It,MaskedPattern:wt,MaskedRange:Fo,MaskedRegExp:Lf,PIPE_TYPE:wi,PatternFixedDefinition:Pa,PatternInputDefinition:Ro,RepeatBlock:Ff,createMask:fn,createPipe:za,default:Be,forceDirection:Bf,normalizeOpts:so,pipe:Rf},Symbol.toStringTag,{value:"Module"}));function F2(){const n=s.ref(!1);return{isFullscreen:n,toggleFullscreen:()=>{n.value=!n.value}}}const Ho="__vs_form_tiptap_loader__",P2=n=>n&&n.split(";").map(t=>t.trim()).filter(t=>t&&!/^text-align\s*:/i.test(t)).join("; ")||null,z2=n=>n.style?{style:String(n.style).replace(/;\s*$/,"")}:{},Pf=({stripTextAlign:n=!1}={})=>({default:null,parseHTML:e=>{const t=e.getAttribute("style");return n?P2(t):t||null},renderHTML:e=>z2(e)}),H2=n=>n.extend({addAttributes(){return{...this.parent?.(),style:Pf({stripTextAlign:!0})}}}),j2=n=>n.extend({addAttributes(){return{...this.parent?.(),style:Pf()}}}),U2=n=>n.extend({addOptions(){return{...this.parent?.(),levels:[1,2,3,4,5,6]}}}),W2=(n,e,t,r,o)=>{const i=e.extend({addAttributes(){return{...this.parent?.(),border:{default:null,parseHTML:l=>l.getAttribute("border"),renderHTML:l=>l.border?{border:l.border}:{}},cellpadding:{default:null,parseHTML:l=>l.getAttribute("cellpadding"),renderHTML:l=>l.cellpadding?{cellpadding:l.cellpadding}:{}},cellspacing:{default:null,parseHTML:l=>l.getAttribute("cellspacing"),renderHTML:l=>l.cellspacing?{cellspacing:l.cellspacing}:{}},style:{default:null,parseHTML:l=>l.getAttribute("style"),renderHTML:l=>l.style?{style:l.style}:{}},width:{default:null,parseHTML:l=>l.getAttribute("width"),renderHTML:l=>l.width?{width:l.width}:{}}}},parseHTML(){return[{tag:"div.tableWrapper table",priority:100},{tag:"table"}]}});return n.extend({addExtensions(){return[i.configure({resizable:!0}),t,r,o]}})},K2=n=>n.extend({addAttributes(){return{...this.parent?.(),fontFamily:{default:null,parseHTML:e=>e.style.fontFamily?.replace(/['"]/g,""),renderHTML:e=>e.fontFamily?{style:`font-family: ${e.fontFamily}`}:{}},fontSize:{default:null,parseHTML:e=>e.style.fontSize?.replace(/['"]/g,""),renderHTML:e=>e.fontSize?{style:`font-size: ${e.fontSize}`}:{}},color:{default:null,parseHTML:e=>e.style.color?.replace(/['"]/g,""),renderHTML:e=>e.color?{style:`color: ${e.color}`}:{}},backgroundColor:{default:null,parseHTML:e=>e.style.backgroundColor?.replace(/['"]/g,""),renderHTML:e=>!e.backgroundColor||e.backgroundColor==="transparent"?{}:{style:`background-color: ${e.backgroundColor}`}}}},addCommands(){return{setFontFamily:e=>({chain:t})=>t().setMark("textStyle",{fontFamily:e}).run(),unsetFontFamily:()=>({chain:e})=>e().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run(),setFontSize:e=>({chain:t})=>t().setMark("textStyle",{fontSize:e}).run(),unsetFontSize:()=>({chain:e})=>e().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run(),setColor:e=>({chain:t})=>t().setMark("textStyle",{color:e}).run(),unsetColor:()=>({chain:e})=>e().setMark("textStyle",{color:null}).removeEmptyTextStyle().run(),setBackgroundColor:e=>({chain:t})=>t().setMark("textStyle",{backgroundColor:e}).run(),unsetBackgroundColor:()=>({chain:e})=>e().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),q2=n=>n.create({name:"iframe",group:"block",inline:!1,atom:!0,selectable:!0,addAttributes(){return{src:{default:null},width:{default:"100%"},height:{default:"280"},frameborder:{default:"0"},allow:{default:null},allowfullscreen:{default:null},referrerpolicy:{default:null},loading:{default:null},class:{default:null},title:{default:null},style:{default:null}}},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:e}){return["iframe",e]}});async function G2(){if(typeof window>"u")return null;const n=window;return n[Ho]||(n[Ho]=Promise.all([Promise.resolve().then(()=>$$),Promise.resolve().then(()=>cO),Promise.resolve().then(()=>pO),Promise.resolve().then(()=>wR),Promise.resolve().then(()=>vR),Promise.resolve().then(()=>SR),Promise.resolve().then(()=>MR),Promise.resolve().then(()=>RL),Promise.resolve().then(()=>_R),Promise.resolve().then(()=>BR),Promise.resolve().then(()=>Z$),Promise.resolve().then(()=>xI),Promise.resolve().then(()=>EB)]).then(([{Editor:e,Node:t},{StarterKit:r},{TextStyle:o},{TableKit:i,Table:l,TableRow:a,TableCell:c,TableHeader:d},{Highlight:u},{Subscript:f},{Superscript:p},{Link:h},{Image:m},{TextAlign:g},{Heading:y},{Paragraph:b},{DOMParser:w}])=>{if(!e||!t||!r||!o||!i||!l||!a||!c||!d||!u||!f||!p||!h||!m||!g||!y||!b||!w)throw new Error("Failed to resolve one or more Tiptap modules");return{Editor:e,ProseMirrorDOMParser:w,StarterKit:r,ExtendedTextStyle:K2(o),Highlight:u,Subscript:f,Superscript:p,CustomLink:j2(h),Image:m,TextAlign:g,CustomHeading:U2(y),CustomParagraph:H2(b),CustomTableKit:W2(i,l,a,c,d),Iframe:q2(t)}}).catch(e=>{throw delete n[Ho],e})),n[Ho]}const nr=n=>n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),jo=n=>{let e=nr(n||"");return e=e.replace(/!\[([^\]]*)]\(([^)\s]+)(?:\s+"([^"]+)")?\)/g,(t,r,o,i)=>{const l=i?` title="${nr(i)}"`:"";return`<img src="${nr(o)}" alt="${nr(r)}"${l}>`}),e=e.replace(/\[([^\]]+)]\(([^)\s]+)(?:\s+"([^"]+)")?\)/g,(t,r,o,i)=>{const l=i?` title="${nr(i)}"`:"";return`<a href="${nr(o)}"${l} target="_blank" rel="noopener noreferrer">${r}</a>`}),e=e.replace(/`([^`]+)`/g,"<code>$1</code>"),e=e.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),e=e.replace(/__([^_]+)__/g,"<strong>$1</strong>"),e=e.replace(/~~([^~]+)~~/g,"<del>$1</del>"),e=e.replace(/\*([^*\n]+)\*/g,"<em>$1</em>"),e=e.replace(/_([^_\n]+)_/g,"<em>$1</em>"),e},Uo=n=>/^\s*\d+\.\s+/.test(n),Ha=n=>/^\s*[-*+]\s+/.test(n),zf=n=>/^\s*[-*+]\s+\[[ xX]\]\s+/.test(n),ja=n=>/^\s*>\s?/.test(n),Ua=n=>/^\s*\|?(?:\s*:?-{3,}:?\s*\|)+\s*:?-{3,}:?\s*\|?\s*$/.test(n),Hf=n=>n.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(e=>jo(e.trim())),J2=(n,e)=>{const t=n[e],r=n[e+1];if(!t||!r||!t.includes("|")||!Ua(r))return null;const o=Hf(t),i=[];let l=e+2;for(;l<n.length&&n[l].includes("|")&&n[l].trim()!=="";){const d=Hf(n[l]);i.push(`<tr>${d.map(u=>`<td>${u}</td>`).join("")}</tr>`),l+=1}const a=`<thead><tr>${o.map(d=>`<th>${d}</th>`).join("")}</tr></thead>`,c=i.length?`<tbody>${i.join("")}</tbody>`:"";return{html:`<table>${a}${c}</table>`,nextIndex:l}},Y2=(n,e)=>{const t=Uo(n[e]),r=t?"ol":"ul",o=[];let i=e;for(;i<n.length;){const l=n[i];if(l.trim()===""||!(t?Uo(l):(Ha(l)||zf(l))&&!Uo(l)))break;const c=l.match(/^\s*[-*+]\s+\[([ xX])\]\s+(.*)$/);if(c){const d=c[1].toLowerCase()==="x";o.push(`<li><input type="checkbox" disabled${d?" checked":""}> ${jo(c[2])}</li>`)}else{const d=l.replace(/^\s*(?:[-*+]|\d+\.)\s+/,"");o.push(`<li>${jo(d)}</li>`)}i+=1}return{html:`<${r}>${o.join("")}</${r}>`,nextIndex:i}},X2=(n,e)=>{const r=n[e].replace(/^```/,"").trim(),o=[];let i=e+1;for(;i<n.length&&!n[i].startsWith("```");)o.push(n[i]),i+=1;return{html:`<pre><code${r?` class="language-${nr(r)}"`:""}>${nr(o.join(`
6
+ `))}</code></pre>`,nextIndex:i<n.length?i+1:i}},Z2=(n,e)=>{const t=[];let r=e;for(;r<n.length;){const o=n[r];if(o.trim()===""||o.startsWith("```")||/^#{1,6}\s+/.test(o)||/^---+$/.test(o.trim())||/^\*\*\*+$/.test(o.trim())||ja(o)||Uo(o)||Ha(o)||r+1<n.length&&o.includes("|")&&Ua(n[r+1]))break;t.push(o.trim()),r+=1}return{html:`<p>${jo(t.join(" "))}</p>`,nextIndex:r}},jf=n=>{const t=(n||"").replace(/\r\n/g,`
7
7
  `).split(`
8
- `),r=[];let a=0;for(;a<n.length;){const l=n[a],s=l.trim();if(!s){a+=1;continue}if(l.startsWith("```")){const d=Wg(n,a);r.push(d.html),a=d.nextIndex;continue}const c=l.match(/^(#{1,6})\s+(.*)$/);if(c){const d=c[1].length;r.push(`<h${d}>${yn(c[2])}</h${d}>`),a+=1;continue}if(/^---+$/.test(s)||/^\*\*\*+$/.test(s)){r.push("<hr>"),a+=1;continue}if(l.includes("|")&&a+1<n.length&&Ro(n[a+1])){const d=Hg(n,a);if(d){r.push(d.html),a=d.nextIndex;continue}}if(Po(l)){const d=[];for(;a<n.length&&Po(n[a]);)d.push(n[a].replace(/^\s*>\s?/,"")),a+=1;r.push(`<blockquote>${vl(d.join(`
9
- `))}</blockquote>`);continue}if(bn(l)||Oo(l)||wl(l)){const d=qg(n,a);r.push(d.html),a=d.nextIndex;continue}const i=Kg(n,a);r.push(i.html),a=i.nextIndex}return r.join("")},zo=o=>(o.textContent||"").replace(/\u00a0/g," "),_l=o=>Array.from(o.childNodes).map(t=>jo(t)).join(""),Gg=o=>{const t=Array.from(o.querySelectorAll("tr"));if(!t.length)return"";const n=c=>`| ${Array.from(c.children).map(d=>_l(d).trim()).join(" | ")} |`,r=t[0],a=r?Array.from(r.children).length:0,l=`| ${Array(Math.max(a,1)).fill("---").join(" | ")} |`,s=t.slice(1).map(c=>n(c));return[n(r),l,...s].join(`
10
- `)},Cl=(o,t=!1)=>Array.from(o.children).filter(n=>n.nodeType===Node.ELEMENT_NODE).map((n,r)=>{const a=n,l=a.querySelector('input[type="checkbox"]'),s=Array.from(a.childNodes).filter(c=>!(c instanceof HTMLInputElement)).map(c=>jo(c)).join("").trim();return l?`- [${l.checked?"x":" "}] ${s}`:t?`${r+1}. ${s}`:`- ${s}`}).join(`
11
- `);function jo(o){if(o.nodeType===Node.TEXT_NODE)return zo(o);if(o.nodeType!==Node.ELEMENT_NODE)return"";const t=o,n=t.tagName.toLowerCase(),r=_l(t);switch(n){case"br":return`
8
+ `),r=[];let o=0;for(;o<t.length;){const i=t[o],l=i.trim();if(!l){o+=1;continue}if(i.startsWith("```")){const d=X2(t,o);r.push(d.html),o=d.nextIndex;continue}const a=i.match(/^(#{1,6})\s+(.*)$/);if(a){const d=a[1].length;r.push(`<h${d}>${jo(a[2])}</h${d}>`),o+=1;continue}if(/^---+$/.test(l)||/^\*\*\*+$/.test(l)){r.push("<hr>"),o+=1;continue}if(i.includes("|")&&o+1<t.length&&Ua(t[o+1])){const d=J2(t,o);if(d){r.push(d.html),o=d.nextIndex;continue}}if(ja(i)){const d=[];for(;o<t.length&&ja(t[o]);)d.push(t[o].replace(/^\s*>\s?/,"")),o+=1;r.push(`<blockquote>${jf(d.join(`
9
+ `))}</blockquote>`);continue}if(Uo(i)||Ha(i)||zf(i)){const d=Y2(t,o);r.push(d.html),o=d.nextIndex;continue}const c=Z2(t,o);r.push(c.html),o=c.nextIndex}return r.join("")},Wa=n=>(n.textContent||"").replace(/\u00a0/g," "),Uf=n=>Array.from(n.childNodes).map(e=>Ka(e)).join(""),Q2=n=>{const e=Array.from(n.querySelectorAll("tr"));if(!e.length)return"";const t=a=>`| ${Array.from(a.children).map(d=>Uf(d).trim()).join(" | ")} |`,r=e[0],o=r?Array.from(r.children).length:0,i=`| ${Array(Math.max(o,1)).fill("---").join(" | ")} |`,l=e.slice(1).map(a=>t(a));return[t(r),i,...l].join(`
10
+ `)},Wf=(n,e=!1)=>Array.from(n.children).filter(t=>t.nodeType===Node.ELEMENT_NODE).map((t,r)=>{const o=t,i=o.querySelector('input[type="checkbox"]'),l=Array.from(o.childNodes).filter(a=>!(a instanceof HTMLInputElement)).map(a=>Ka(a)).join("").trim();return i?`- [${i.checked?"x":" "}] ${l}`:e?`${r+1}. ${l}`:`- ${l}`}).join(`
11
+ `);function Ka(n){if(n.nodeType===Node.TEXT_NODE)return Wa(n);if(n.nodeType!==Node.ELEMENT_NODE)return"";const e=n,t=e.tagName.toLowerCase(),r=Uf(e);switch(t){case"br":return`
12
12
  `;case"p":return`${r.trim()}
13
13
 
14
- `;case"strong":case"b":return`**${r}**`;case"em":case"i":return`*${r}*`;case"del":case"s":return`~~${r}~~`;case"code":return t.parentElement?.tagName.toLowerCase()==="pre"?r:`\`${r}\``;case"pre":{const a=t.querySelector("code"),c=(a?.className||"").match(/language-([a-z0-9_-]+)/i)?.[1]||"",i=zo(a||t);return`\`\`\`${c}
15
- ${i}
14
+ `;case"strong":case"b":return`**${r}**`;case"em":case"i":return`*${r}*`;case"del":case"s":return`~~${r}~~`;case"code":return e.parentElement?.tagName.toLowerCase()==="pre"?r:`\`${r}\``;case"pre":{const o=e.querySelector("code"),a=(o?.className||"").match(/language-([a-z0-9_-]+)/i)?.[1]||"",c=Wa(o||e);return`\`\`\`${a}
15
+ ${c}
16
16
  \`\`\`
17
17
 
18
18
  `}case"blockquote":return`${r.trim().split(`
19
- `).map(a=>`> ${a}`).join(`
19
+ `).map(o=>`> ${o}`).join(`
20
20
  `)}
21
21
 
22
- `;case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":{const a=Number(n[1]);return`${"#".repeat(a)} ${r.trim()}
22
+ `;case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":{const o=Number(t[1]);return`${"#".repeat(o)} ${r.trim()}
23
23
 
24
- `}case"ul":return`${Cl(t,!1)}
24
+ `}case"ul":return`${Wf(e,!1)}
25
25
 
26
- `;case"ol":return`${Cl(t,!0)}
26
+ `;case"ol":return`${Wf(e,!0)}
27
27
 
28
- `;case"a":{const a=t.getAttribute("href")||"";return`[${r||a}](${a})`}case"img":{const a=t.getAttribute("alt")||"",l=t.getAttribute("src")||"";return l?`![${a}](${l})`:""}case"hr":return`---
28
+ `;case"a":{const o=e.getAttribute("href")||"";return`[${r||o}](${o})`}case"img":{const o=e.getAttribute("alt")||"",i=e.getAttribute("src")||"";return i?`![${o}](${i})`:""}case"hr":return`---
29
29
 
30
- `;case"table":return`${Gg(t)}
30
+ `;case"table":return`${Q2(e)}
31
31
 
32
- `;default:return r}}const El=o=>{if(!o)return"";if(typeof window>"u"||typeof DOMParser>"u")return o;const n=new DOMParser().parseFromString(o,"text/html");return Array.from(n.body.childNodes).map(r=>jo(r)).join("").replace(/\n{3,}/g,`
32
+ `;default:return r}}const Kf=n=>{if(!n)return"";if(typeof window>"u"||typeof DOMParser>"u")return n;const t=new DOMParser().parseFromString(n,"text/html");return Array.from(t.body.childNodes).map(r=>Ka(r)).join("").replace(/\n{3,}/g,`
33
33
 
34
- `).trim()},Yg=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Xg=o=>{if(!o)return"";if(typeof window>"u"||typeof DOMParser>"u")return o;const n=new DOMParser().parseFromString(o,"text/html"),r=" ",a=(l,s)=>{if(l.nodeType===Node.TEXT_NODE){const f=(l.textContent||"").replace(/\s+/g," ").trim();return f?[`${r.repeat(s)}${f}`]:[]}if(l.nodeType!==Node.ELEMENT_NODE)return[];const c=l,i=c.tagName.toLowerCase(),d=Array.from(c.attributes).map(f=>`${f.name}="${f.value}"`).join(" "),h=d?`<${i} ${d}>`:`<${i}>`,g=`</${i}>`;if(Yg.has(i))return[`${r.repeat(s)}${h}`];const p=Array.from(c.childNodes).flatMap(f=>a(f,s+1));if(!p.length)return[`${r.repeat(s)}${h}${g}`];if(c.childNodes.length===1&&c.firstChild?.nodeType===Node.TEXT_NODE&&p.length===1){const f=p[0].trim();return[`${r.repeat(s)}${h}${f}${g}`]}return[`${r.repeat(s)}${h}`,...p,`${r.repeat(s)}${g}`]};return Array.from(n.body.childNodes).flatMap(l=>a(l,0)).join(`
35
- `)},Zg=o=>o.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),eo=o=>{if(!o)return"";if(typeof window>"u"||typeof DOMParser>"u")return o.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");const n=new DOMParser().parseFromString(o,"text/html");return n.querySelectorAll("script").forEach(r=>r.remove()),n.body.innerHTML},Bl=o=>{if(!o)return{wrapper:null,bodyHtml:""};if(typeof window>"u"||typeof DOMParser>"u")return{wrapper:null,bodyHtml:o};const n=new DOMParser().parseFromString(o,"text/html"),{body:r}=n;if(r.childElementCount!==1)return{wrapper:null,bodyHtml:o};const a=r.firstElementChild;return!a||a.tagName.toLowerCase()!=="div"?{wrapper:null,bodyHtml:o}:{wrapper:{tag:a.tagName.toLowerCase(),attributes:Array.from(a.attributes).map(l=>({name:l.name,value:l.value}))},bodyHtml:a.innerHTML}},Vl=(o,t)=>{if(!t)return o||"";const n=(t.attributes||[]).map(({name:a,value:l})=>`${a}="${Zg(l)}"`).join(" ");return`${n?`<${t.tag} ${n}>`:`<${t.tag}>`}${o||""}</${t.tag}>`},Sl=async(o,t)=>t!=="md"?o||"":vl(o||""),$l=async(o,t)=>t!=="md"?Xg(o||""):El(o||""),Jg=async(o,t)=>t!=="md"?o||"":El(o||""),Qg=async o=>{try{const t=new FormData;return t.append("unique","true"),t.append("file",o),(await(await fetch("/file/upload/uploads?id=&form=&table=",{method:"POST",body:t})).json())?.result}catch(t){console.error(t)}},ey=async(o,t,n)=>{const r=t.clipboardData?.items;if(r){const a=t.clipboardData?.getData("text/html"),l=t.clipboardData?.getData("text/plain");if(a){const{state:s,dispatch:c}=o,{tr:i}=s,d=n.fromSchema(o.state.schema),h=new DOMParser().parseFromString(a,"text/html").body,g=d.parse(h),p=i.replaceSelectionWith(g);return c(p),t.preventDefault(),!0}if(l){const{state:s,dispatch:c}=o,{tr:i}=s,d=i.insertText(l,s.selection.from,s.selection.to);return c(d),t.preventDefault(),!0}for(let s=0;s<r.length;s++){const c=r[s];if(c.type.startsWith("image/")){const i=c.getAsFile();if(i){const d=await Qg(i),{schema:h}=o.state,g=h.nodes.image.create({src:d?.file_path}),p=o.state.tr.replaceSelectionWith(g);return o.dispatch(p),t.preventDefault(),!0}}}}return!1},ty=o=>String(o).trim().toLowerCase().split("-")[0],ny=()=>typeof window>"u"?"uk":ty(localStorage.getItem("language")||localStorage.getItem("locale")||navigator.language||"uk"),oy=(o,t)=>{const n=t.replace(/^form\.richtext\./,"");return Fo?.[o]?.form?.richtext?.[n]||Fo?.uk?.form?.richtext?.[n]||t},Al=o=>o.startsWith("form.richtext.")?o:`form.richtext.${o}`;function Uo(){const t=e.getCurrentInstance()?.appContext?.config?.globalProperties,n=t?.$i18n;return{t:a=>{const l=t?.$t,s=t?.$te,c=typeof n?.te=="function"?n.te.bind(n):null;if(typeof l=="function"){const i=Al(a);if((typeof s=="function"?s(i):typeof c=="function"?c(i):null)!==!1){const h=l(i);if(h&&h!==i)return h}}return oy(ny(),Al(a))}}}const ry={components:{Quote:X.Quote},props:{editor:Object},methods:{toggleBlockquote(){this.editor&&this.editor.chain().toggleBlockquote().run()}}};function ly(o,t,n,r,a,l){const s=e.resolveComponent("Quote");return e.openBlock(),e.createElementBlock("button",{title:"Blockquote",onClick:t[0]||(t[0]=(...c)=>l.toggleBlockquote&&l.toggleBlockquote(...c)),class:e.normalizeClass(["text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100 focus:outline-none",{"bg-gray-100 text-gray-900":n.editor?.isActive("blockquote")}])},[e.createVNode(s,{class:"h-4 w-4"})],2)}const ay=Ce(ry,[["render",ly]]),sy={components:{List:X.List},props:{editor:Object},methods:{toggleBulletList(){this.editor&&this.editor.chain().focus().toggleBulletList().run()}}};function iy(o,t,n,r,a,l){const s=e.resolveComponent("List");return e.openBlock(),e.createElementBlock("button",{title:"Bullet List",onClick:t[0]||(t[0]=(...c)=>l.toggleBulletList&&l.toggleBulletList(...c)),class:e.normalizeClass(["text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":n.editor?.isActive("bulletList")}])},[e.createVNode(s,{class:"h-4 w-4"})],2)}const cy=Ce(sy,[["render",iy]]),dy={components:{ListOrdered:X.ListOrdered},props:{editor:Object},methods:{toggleOrderedList(){this.editor&&this.editor.chain().focus().toggleOrderedList().run()}}};function uy(o,t,n,r,a,l){const s=e.resolveComponent("ListOrdered");return e.openBlock(),e.createElementBlock("button",{title:"Ordered List",onClick:t[0]||(t[0]=(...c)=>l.toggleOrderedList&&l.toggleOrderedList(...c)),class:e.normalizeClass(["text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":n.editor?.isActive("orderedList")}])},[e.createVNode(s,{class:"h-4 w-4"})],2)}const py=Ce(dy,[["render",uy]]),my={components:{CodeXml:X.CodeXml},props:{editor:Object},methods:{toggleCodeBlock(){this.editor&&this.editor.chain().focus().toggleCodeBlock().run()}}};function fy(o,t,n,r,a,l){const s=e.resolveComponent("CodeXml");return e.openBlock(),e.createElementBlock("button",{title:"Code Block",onClick:t[0]||(t[0]=(...c)=>l.toggleCodeBlock&&l.toggleCodeBlock(...c)),class:e.normalizeClass(["text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":n.editor?.isActive("codeBlock")}])},[e.createVNode(s,{class:"h-4 w-4"})],2)}const hy=Ce(my,[["render",fy]]),gy={components:{Bold:X.Bold},props:{editor:Object},methods:{toggleBold(){this.editor&&this.editor.commands.toggleBold()}}};function yy(o,t,n,r,a,l){const s=e.resolveComponent("Bold");return e.openBlock(),e.createElementBlock("button",{title:"Bold Text",onClick:t[0]||(t[0]=(...c)=>l.toggleBold&&l.toggleBold(...c)),class:e.normalizeClass(["h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":n.editor?.isActive("bold")}])},[e.createVNode(s,{class:"h-4 w-4"}),t[1]||(t[1]=e.createElementVNode("span",{class:"sr-only"},"Bold",-1))],2)}const by=Ce(gy,[["render",yy]]),ky={components:{Italic:X.Italic},props:{editor:Object},methods:{toggleItalic(){this.editor&&this.editor.chain().toggleItalic().run()}}};function wy(o,t,n,r,a,l){const s=e.resolveComponent("Italic");return e.openBlock(),e.createElementBlock("button",{title:"Italic Text",onClick:t[0]||(t[0]=(...c)=>l.toggleItalic&&l.toggleItalic(...c)),class:e.normalizeClass(["h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":n.editor?.isActive("italic")}])},[e.createVNode(s,{class:"h-4 w-4"}),t[1]||(t[1]=e.createElementVNode("span",{class:"sr-only"},"Italic",-1))],2)}const xy=Ce(ky,[["render",wy]]),vy={__name:"vs-editor-underline",props:{editor:Object},setup(o){const t=o,n=()=>{t.editor&&t.editor.chain().focus().toggleUnderline().run()};return(r,a)=>(e.openBlock(),e.createElementBlock("button",{title:"Underline",onClick:n,class:e.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100",[o.editor?.isActive("underline")?"bg-gray-100 text-gray-900":"text-gray-500"]])},[e.createVNode(e.unref(X.Underline),{class:"h-4 w-4"})],2))}},_y={__name:"vs-editor-strike",props:{editor:Object},setup(o){const t=o,n=()=>{t.editor&&t.editor.chain().focus().toggleStrike().run()};return(r,a)=>(e.openBlock(),e.createElementBlock("button",{title:"Strikethrough",onClick:n,class:e.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100",[o.editor?.isActive("strike")?"bg-gray-100 text-gray-900":"text-gray-500"]])},[e.createVNode(e.unref(X.Strikethrough),{class:"h-4 w-4"})],2))}},Cy={components:{X:X.X},props:{visible:{type:Boolean,default:()=>!1},modelValue:{type:Boolean,default:()=>!1},title:{type:String,default:()=>""},size:{type:String,default:()=>""},closeClickBack:{type:Boolean,default:()=>!1}},emits:["update:visible","update:modelValue","onClose","confirm","cancel"],inheritAttrs:!1,name:"vs-dialog",mounted(){window.addEventListener("keydown",this.checkKey)},unmounted(){window.removeEventListener("keydown",this.checkKey)},computed:{hasSlot(){return!!this.$slots?.footer},checkSize(){return this.size==="small"?"md:w-5/12 w-9/12":this.size==="medium"?"md:w-6/12 w-9/12":"lg:w-7/12 w-11/12"}},methods:{checkKey({key:o}){o==="Escape"&&this.handleClose()},handleClose(){this.$emit("update:visible",!1),this.$emit("update:modelValue",!1),this.$emit("onClose")},handleConfirm(){this.$emit("confirm"),this.handleClose()},handleCancel(){this.$emit("cancel"),this.handleClose()},closeByClickBack(o,t){t&&o.target.classList.contains("vs-dialog-overlay")&&this.handleClose()}}},Ey={key:0,class:"vsTailwind ui-dialog__wrapper"},By={class:"py-2.5 px-4 flex justify-between items-center border-0 border-b border-solid border-gray-200 dark:border-b-[#454545]"},Vy={class:"font-medium text-gray-800 dark:text-[#ffffff]"},Sy={class:"ui-dialog__content p-4"},$y={key:0,class:"flex justify-end gap-x-2"};function Ay(o,t,n,r,a,l){const s=e.resolveComponent("X");return e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[n.visible||n.modelValue?(e.openBlock(),e.createElementBlock("div",Ey,[e.createElementVNode("div",{onMousedown:t[1]||(t[1]=c=>l.closeByClickBack(c,n.closeClickBack)),class:"vs-dialog-overlay vs-dialog w-full h-full fixed top-0 start-0 z-[100001] bg-black bg-opacity-50"},[e.createVNode(e.Transition,{name:"content",appear:""},{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(["ui-dialog__modal opacity-1 flex flex-col bg-white dark:bg-[#1A1A1A] border dark:border-[#454545] pointer-events-auto shadow-[0_10px_40px_10px_rgba(0,0,0,0.08)] rounded-xl",[l.checkSize]])},[e.createElementVNode("div",By,[e.createElementVNode("h3",Vy,e.toDisplayString(n.title),1),e.createElementVNode("button",{type:"button",class:"size-8 inline-flex justify-center items-center gap-x-2 rounded-full border border-transparent bg-gray-100 text-gray-800 hover:bg-gray-200 focus:outline-none focus:bg-gray-200 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-700 dark:hover:bg-neutral-600 dark:text-neutral-400 dark:focus:bg-neutral-600",onClick:t[0]||(t[0]=(...c)=>l.handleClose&&l.handleClose(...c))},[t[2]||(t[2]=e.createElementVNode("span",{class:"sr-only"},"Close",-1)),e.createVNode(s,{class:"h-4 w-4 flex-shrink-0"})])]),e.createElementVNode("div",Sy,[e.renderSlot(o.$slots,"default",{},void 0,!0)]),l.hasSlot?(e.openBlock(),e.createElementBlock("div",$y,[e.renderSlot(o.$slots,"footer",{handleClose:l.handleClose,handleConfirm:l.handleConfirm,handleCancel:l.handleCancel},void 0,!0)])):e.createCommentVNode("",!0)],2)]),_:3})],32)])):e.createCommentVNode("",!0)])}const Nl=Ce(Cy,[["render",Ay],["__scopeId","data-v-56ad9010"]]),Ny=e.defineComponent({components:{IconClose:X.X,IconSearch:X.Search,IconEmail:X.Mail},inheritAttrs:!1,props:{icon:{type:String,default:()=>""},disabled:{type:Boolean,default:()=>!1},clearable:{type:Boolean,default:()=>!1},modelValue:{type:String,default:()=>""},placeholder:{type:String,default:()=>""},iconPosition:{type:String,default:()=>"right"},type:{type:String,default:()=>"text"},style:{type:Object,default:()=>null},size:{type:String,default:()=>"md"},attrs:{type:Object,default:()=>{}}},emits:["onInput","update:modelValue","blur","focus"],computed:{checkSize(){return(this.style?.size||this.size)==="xs"?"h-[32px] text-sm":(this.style?.size||this.size)==="md"?"h-[38px] text-sm":(this.style?.size||this.size)==="lg"?"h-[46px] text-[20px]":"h-[38px] text-sm"},value:{get(){return this.modelValue},set(o){this.$emit("update:modelValue",o.trim())}},clearIconStyle(){return[{"right-8":this.icon&&this.iconPosition==="right","right-3":!this.icon||this.iconPosition!=="right","pointer-events-none":this.disabled}]},iconStylePosition(){return[{"left-3":this.icon&&this.iconPosition==="left","right-3":this.icon&&this.iconPosition==="right"}]},inputStyle(){return[{"!pr-8":this.clearable&&!this.icon,"!pr-7":this.clearable,"!pr-16":this.clearable&&this.icon&&this.iconPosition==="right","!pl-8":this.icon&&this.iconPosition==="left","!pr-[50px]":this.clearable&&this.value&&this.icon&&this.iconPosition==="right","!cursor-not-allowed bg-slate-100":this.disabled,"bg-white":!this.disabled}]}},methods:{handleInput(){this.$emit("onInput",this.modelValue)},handleBlur(){this.$emit("blur")},handleFocus(){this.$emit("focus")},clearInput(){this.$emit("update:modelValue",""),this.$emit("onInput","")},async inputFocus(){await this.$refs.vsText?.focus()}}}),My={class:"vs-form-text relative bg-white rounded-lg"},Fy={key:2,class:"absolute bottom-2/4 translate-y-2/4 left-[10px] cursor-pointer"},Dy=["disabled","type","placeholder"];function Ty(o,t,n,r,a,l){const s=e.resolveComponent("IconClose"),c=e.resolveComponent("IconSearch"),i=e.resolveComponent("IconEmail");return e.openBlock(),e.createElementBlock("div",My,[o.clearable&&o.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"absolute bottom-2/4 translate-y-2/4 right-3 cursor-pointer",onClick:t[0]||(t[0]=(...d)=>o.clearInput&&o.clearInput(...d))},[e.createVNode(s,{class:"h-4 w-4 stroke-gray-500 transition-all hover:stroke-red-500"})])):e.createCommentVNode("",!0),o.icon&&o.icon==="search"?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["absolute bottom-2/4 translate-y-2/4 cursor-pointer",o.iconStylePosition])},[e.createVNode(c,{class:"h-4 w-4 stroke-gray-500 transition-all"})],2)):o.icon&&o.icon==="email"?(e.openBlock(),e.createElementBlock("div",Fy,[e.createVNode(i,{class:"h-4 w-4 stroke-gray-500 transition-all"})])):(e.openBlock(),e.createElementBlock("i",{key:3,class:e.normalizeClass(["absolute bottom-2/4 translate-y-2/4 text-gray-500 cursor-pointer",["ti "+o.icon,o.iconStylePosition]])},null,2)),o.clearable&&o.value?(e.openBlock(),e.createElementBlock("div",{key:4,class:"absolute bottom-2/4 translate-y-2/4 right-3 cursor-pointer",onClick:t[1]||(t[1]=(...d)=>o.clearInput&&o.clearInput(...d))},[e.createVNode(s,{class:"h-4 w-4 stroke-gray-500 transition-all hover:stroke-red-500"})])):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("input",e.mergeProps({ref:"vsText",disabled:o.disabled,type:o.type,onInput:t[2]||(t[2]=(...d)=>o.handleInput&&o.handleInput(...d)),placeholder:o.placeholder,"onUpdate:modelValue":t[3]||(t[3]=d=>o.value=d)},o.style?.attrs||o.attrs||{},{onFocus:t[4]||(t[4]=(...d)=>o.handleFocus&&o.handleFocus(...d)),onBlur:t[5]||(t[5]=(...d)=>o.handleBlur&&o.handleBlur(...d)),class:[[o.inputStyle,o.checkSize],"py-2 px-3 block w-full border border-solid placeholder:text-nowrap border-stone-200 rounded-lg text-sm text-stone-800 placeholder:text-stone-400 focus:outline focus:z-10 focus:border-blue-500 focus:ring-blue-500 focus:outline-blue-500"]}),null,16,Dy),[[e.vModelDynamic,o.value]])])}const Ml=Ce(Ny,[["render",Ty],["__scopeId","data-v-eb21a54f"]]),Ly=["title"],Iy={class:"flex flex-col gap-3 p-[20px]"},Oy={class:"relative flex items-center gap-2"},Py={class:"flex-1"},Ry={key:0,class:"flex items-center gap-2 flex-shrink-0"},zy=["title"],jy=["title"],Uy={class:"flex items-center gap-2"},Hy={for:"openInNewTab",class:"text-sm text-gray-700 cursor-pointer"},qy={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},Wy=Object.assign({inheritAttrs:!1},{__name:"vs-editor-link",props:{editor:Object},setup(o){const{t}=Uo(),n=o,r=e.ref(!1),a=e.ref(""),l=e.ref(!1),s=e.ref(!1),c=()=>{if(!n.editor)return;n.editor.chain().focus().extendMarkRange("link").run();const p=n.editor.getAttributes("link");p.href?(l.value=!0,a.value=p.href,s.value=p.target==="_blank"):(l.value=!1,a.value="",s.value=!1),r.value=!0},i=()=>{r.value=!1,a.value="",l.value=!1,s.value=!1},d=()=>{if(!n.editor||!a.value.trim())return;let p=a.value.trim();p.match(/^https?:\/\//i)||(p="https://"+p),n.editor.chain().focus().setLink({href:p,target:s.value?"_blank":null}).run(),i()},h=()=>{n.editor&&(n.editor.chain().focus().unsetLink().run(),i())},g=()=>{if(!a.value)return;let p=a.value.trim();p.match(/^https?:\/\//i)||(p="https://"+p),window.open(p,"_blank","noopener,noreferrer")};return(p,f)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("button",{title:e.unref(t)("form.richtext.link")||"Посилання",onClick:c,class:e.normalizeClass(["text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100 focus:outline-none",{"bg-gray-100 text-gray-900":o.editor?.isActive("link")}])},[e.createVNode(e.unref(X.Link2),{class:"h-4 w-4"})],10,Ly),e.createVNode(Nl,{title:l.value?e.unref(t)("form.richtext.editLink")||"Редагувати посилання":e.unref(t)("form.richtext.linkTitle")||"Додати посилання",visible:r.value,"onUpdate:visible":f[2]||(f[2]=m=>r.value=m),size:"small"},{footer:e.withCtx(()=>[e.createElementVNode("div",qy,[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:i,class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-black border-gray-200 rounded-lg !border-gray-200 hover:bg-gray-100 duration-300"},e.toDisplayString(e.unref(t)("form.richtext.cancel")||"Скасувати"),1),e.createElementVNode("button",{onClick:d,class:"py-2 px-3 inline-flex items-center gap-x-2 text-[14px] font-[400] whitespace-nowrap text-white bg-blue-500 rounded-lg !border-gray-200 hover:bg-blue-700 duration-300"},e.toDisplayString(l.value?e.unref(t)("form.richtext.update")||"Оновити":e.unref(t)("form.richtext.create")||"Створити"),1)])]),default:e.withCtx(()=>[e.createElementVNode("div",Iy,[e.createElementVNode("div",Oy,[e.createElementVNode("div",Py,[e.createVNode(Ml,{modelValue:a.value,"onUpdate:modelValue":f[0]||(f[0]=m=>a.value=m),placeholder:e.unref(t)("form.richtext.linkUrl")||"Введіть URL",class:"w-full"},null,8,["modelValue","placeholder"])]),l.value?(e.openBlock(),e.createElementBlock("div",Ry,[e.createElementVNode("button",{onClick:g,class:"text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100 focus:outline-none transition-colors",title:e.unref(t)("form.richtext.openLink")||"Відкрити посилання"},[e.createVNode(e.unref(X.ExternalLink),{class:"h-4 w-4"})],8,zy),e.createElementVNode("button",{onClick:h,class:"text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-red-600 hover:bg-red-50 focus:outline-none transition-colors",title:e.unref(t)("form.richtext.removeLink")||"Видалити посилання"},[e.createVNode(e.unref(X.Trash2),{class:"h-4 w-4"})],8,jy)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",Uy,[e.withDirectives(e.createElementVNode("input",{type:"checkbox",id:"openInNewTab","onUpdate:modelValue":f[1]||(f[1]=m=>s.value=m),class:"w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500"},null,512),[[e.vModelCheckbox,s.value]]),e.createElementVNode("label",Hy,e.toDisplayString(e.unref(t)("form.richtext.openInNewTab")||"Відкривати в новій вкладці"),1)])])]),_:1},8,["title","visible"])],64))}}),kn=async(o,t,n,r=10)=>{if(!t||!n)return;await e.nextTick();const a=await n?.getBoundingClientRect(),l=await t?.getBoundingClientRect();if(!l||!a)return;const s=await parseInt(t?.getBoundingClientRect()?.height),c=await parseInt(t?.getBoundingClientRect()?.width),i=await parseInt(n?.getBoundingClientRect()?.height),d=await parseInt(n?.getBoundingClientRect()?.width),h=await window.innerHeight,g=await window.innerWidth;let p=0,f=0;const m=l.bottom+r+i;switch(o){case"top":l.top-a.height-r<0?p=l.top-a.height+r+i+s:p=l.top-a.height-r,g>d+l.right+30?f=l.left-a.width/2+l.width/2:f=g-30-d;break;case"bottom":h>m?p=l.bottom+r:p=l.bottom-r-i-s,f=l.left-a.width/2+l.width/2;break;case"left":p=l.top-a.height/2+l.height/2,l.left-a.width-r>0?f=l.left-a.width-r:f=10;break;case"right":p=l.top-a.height/2+l.height/2,g-c>d?f=l.right+r:f=g-30-d;break;case"top-right":l.top-a.height-r<0?p=l.top-a.height+r+i+s:p=l.top-a.height-r,g-c>d?f=l.right+r:f=g-30-d;break;case"top-left":l.top-a.height-r<0?p=l.top-a.height+r+i+s:p=l.top-a.height-r,l.left-a.width-r>0?f=l.left-a.width-r:f=10;break;case"top-start":l.top-a.height-r<0?p=l.top-a.height+r+i+s:p=l.top-a.height-r,l.left>0?f=l.left:f=10;break;case"bottom-right":h>m?p=l.bottom+r:p=l.bottom-r-i-s,g-c>d?f=l.left:f=g-30-d;break;case"bottom-left":h>m?p=l.bottom+r:p=l.bottom-r-i-s,l.left>0?f=l.right-d:f=10;break;case"bottom-start":h>m?p=l.bottom+r:p=l.bottom-r-i-s,l.left>0?f=l.left:f=10;break}p+i>h?p=h-i-r:p<0&&(p=r),f+d>g?f=g-d-r:f<0&&(f=r),n instanceof HTMLElement&&(n.style.top=`${p}px`,n.style.left=`${f}px`,n.style.position="fixed")},Ky={class:"text-center"},Gy={class:"py-2 px-4 w-full text-sm text-stone-800 bg-white shadow-[0_10px_40px_10px_rgba(0,0,0,0.08)] rounded-lg focus:outline-none focus:bg-stone-100 dark:bg-neutral-900 dark:text-neutral-200 dark:focus:bg-neutral-800 after:h-4 after:absolute after:-bottom-4 after:start-0 after:w-full before:h-4 before:absolute before:-top-4 before:start-0 before:w-full"},Kt=Object.assign({inheritAttrs:!1},{__name:"vs-popover",props:{isOpen:{type:Boolean,default:()=>!1},placement:{type:String,default:"top"},gap:{type:Number,default:8},width:{type:[String,Number],default:""},disabled:{type:Boolean,default:!1},trigger:{type:String,default:"click"},teleport:{type:String,default:"body"}},emits:["isvisible"],setup(o,{expose:t,emit:n}){const r=o,a=n,l=e.ref(!1),s=e.ref([]),c=e.ref(null),i=e.ref(null),d=e.ref(null);e.watch(l,N=>{N?(h(),window.addEventListener("resize",()=>kn(r.placement,i.value,d.value)),kn(r.placement,i.value,d.value)):window.removeEventListener("resize",()=>kn(r.placement,i.value,d.value)),a("isvisible",N)}),e.onMounted(()=>{window.addEventListener("click",b),window.addEventListener("popstate",_),window.addEventListener("scroll",C,!0),h()}),e.onBeforeUnmount(()=>{window.removeEventListener("click",b),window.removeEventListener("popstate",_),g()});const h=()=>{let N=c.value;for(;N&&N!==document.body;)(N.scrollHeight>N.clientHeight||N.scrollWidth>N.clientWidth)&&(N.addEventListener("scroll",k),s.value.push(N)),N=N.parentElement;document.body&&(document.body.addEventListener("scroll",k),s.value.push(document.body))},g=()=>{s.value.forEach(N=>{N.removeEventListener("scroll",k)}),s.value=[]},p=()=>{l.value=!0,kn(r.placement,i.value,d.value)},f=()=>{l.value=!1},m=async()=>{await kn(r.placement,i.value,d.value),l.value=!l.value},k=()=>{l.value=!1},b=N=>{if(!N){l.value=!1;return}i.value?.contains(N.target)||d.value?.contains(N.target)||(l.value=!1)},_=()=>{l.value&&(l.value=!1)},C=N=>{l.value&&d.value&&!d.value.contains(N.target)&&(l.value=!1)};return t({togglePopover:m}),(N,$)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"popover",ref:c,class:"vs-popover inline-block"},[e.createElementVNode("div",Ky,[o.trigger==="click"?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"popoverRef",ref:i,onClick:m,class:e.normalizeClass({"pointer-events-none":o.disabled})},[e.renderSlot(N.$slots,"reference",{},()=>[$[0]||($[0]=e.createElementVNode("button",null,"Click me!",-1))])],2)):e.createCommentVNode("",!0),o.trigger==="hover"?(e.openBlock(),e.createElementBlock("div",{key:1,ref_key:"popoverRef",ref:i,onMouseover:p,onMouseleave:f,class:e.normalizeClass({"pointer-events-none":o.disabled})},[e.renderSlot(N.$slots,"reference",{},()=>[$[1]||($[1]=e.createElementVNode("button",null,"Click me!",-1))])],34)):e.createCommentVNode("",!0),(e.openBlock(),e.createBlock(e.Teleport,{to:o.teleport},[e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",{class:e.normalizeClass(["vsTailwind vs-popover__content",o.placement]),ref_key:"contentPop",ref:d,style:e.normalizeStyle({width:o.width?o.width+"px":"fit-content",zIndex:100001})},[e.createElementVNode("div",Gy,[e.renderSlot(N.$slots,"default",{},()=>[$[2]||($[2]=e.createElementVNode("span",null,"Popover content",-1))])])],6),[[e.vShow,l.value]])]),_:3})],8,["to"]))])],512))}}),Yy={class:"flex flex-col gap-[2px] p-[2px]"},Xy=["onClick"],Zy={__name:"vs-editor-table",props:{editor:Object},setup(o){const{t}=Uo(),n=o,r=e.ref(!1),a=e.ref("popover"),l=()=>{n.editor&&(n.editor.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),a.value.togglePopover())},s=()=>{n.editor&&(n.editor.chain().focus().addColumnAfter().run(),a.value.togglePopover())},c=()=>{n.editor&&(n.editor.chain().focus().addRowAfter().run(),a.value.togglePopover())},i=()=>{n.editor&&(n.editor.chain().focus().deleteColumn().run(),a.value.togglePopover())},d=()=>{n.editor&&(n.editor.chain().focus().deleteRow().run(),a.value.togglePopover())},h=()=>{n.editor&&(n.editor.chain().focus().deleteTable().run(),a.value.togglePopover())},g=()=>{n.editor&&(n.editor.chain().focus().mergeCells().run(),a.value.togglePopover())},p=()=>{n.editor&&(n.editor.chain().focus().splitCell().run(),a.value.togglePopover())},f=e.computed(()=>[{text:t("form.richtext.createTable"),function:l},{text:t("form.richtext.addColumn"),function:s},{text:t("form.richtext.addRow"),function:c},{text:t("form.richtext.deleteColumn"),function:i},{text:t("form.richtext.deleteRow"),function:d},{text:t("form.richtext.deleteTable"),function:h},{text:t("form.richtext.mergeCells"),function:g},{text:t("form.richtext.splitCells"),function:p}]);return(m,k)=>(e.openBlock(),e.createBlock(Kt,{ref_key:"popover",ref:a,placement:"bottom",onIsvisible:k[0]||(k[0]=b=>r.value=b)},{reference:e.withCtx(()=>[e.createElementVNode("button",{title:"Table",class:e.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center text-gray-500 rounded-full hover:text-gray-900 hover:bg-gray-100",[r.value?"bg-gray-100 text-gray-900":"text-gray-500"]])},[e.createVNode(e.unref(X.Table2),{class:"h-4 w-4"})],2)]),default:e.withCtx(()=>[e.createElementVNode("div",Yy,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,(b,_)=>(e.openBlock(),e.createElementBlock("button",{key:_,onClick:b?.function,class:"px-2 py-1 text-gray-500 text-start hover:text-gray-900 hover:bg-gray-100 rounded"},e.toDisplayString(b.text),9,Xy))),128))])]),_:1},512))}},Jy={class:"flex gap-[4px] p-1"},Qy=["title","onClick"],e0={__name:"vs-editor-align",props:{editor:Object},setup(o){const t=o,n={left:X.AlignLeft,center:X.AlignCenter,right:X.AlignRight,justify:X.AlignJustify},r=e.ref(!1),a=e.ref("popover"),l=e.ref("left"),s=e.computed(()=>t.editor?t.editor.isActive("paragraph",{textAlign:"left"})||t.editor.isActive("heading",{textAlign:"left"}):!1),c=e.computed(()=>t.editor?t.editor.isActive("paragraph",{textAlign:"right"})||t.editor.isActive("heading",{textAlign:"right"}):!1),i=e.computed(()=>t.editor?t.editor.isActive("paragraph",{textAlign:"center"})||t.editor.isActive("heading",{textAlign:"center"}):!1),d=e.computed(()=>t.editor?t.editor.isActive("paragraph",{textAlign:"justify"})||t.editor.isActive("heading",{textAlign:"justify"}):!1),h=e.computed(()=>s.value||c.value||i.value||d.value),g=()=>{c.value?l.value="right":i.value?l.value="center":d.value?l.value="justify":l.value="left"};e.watch([s,c,i,d],()=>{g()},{immediate:!0}),e.onMounted(()=>{t.editor&&(t.editor.on("selectionUpdate",g),t.editor.on("update",g))}),e.onUnmounted(()=>{t.editor&&(t.editor.off("selectionUpdate",g),t.editor.off("update",g))});const p=m=>{t.editor&&(t.editor.chain().focus().setTextAlign(m).run(),l.value=m)},f=e.ref([{id:"left",isActive:s},{id:"center",isActive:i},{id:"right",isActive:c},{id:"justify",isActive:d}]);return(m,k)=>(e.openBlock(),e.createBlock(Kt,{ref_key:"popover",ref:a,placement:"bottom",onIsvisible:k[0]||(k[0]=b=>r.value=b)},{reference:e.withCtx(()=>[e.createElementVNode("button",{title:"Text Align",class:e.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center text-gray-500 rounded-full hover:text-gray-900 hover:bg-gray-100",[h.value?"bg-gray-100 text-gray-900":"text-gray-500"]])},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n[l.value]),{height:"16",width:"16"}))],2)]),default:e.withCtx(()=>[e.createElementVNode("div",Jy,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,b=>(e.openBlock(),e.createElementBlock("button",{title:"Text align "+b?.id,class:e.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center text-gray-500 rounded hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":b?.isActive}]),key:b?.id,onClick:_=>p(b?.id)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n[b?.id]),{height:"16",width:"16"}))],10,Qy))),128))])]),_:1},512))}},t0={components:{VsText:Ml},inheritAttrs:!1,events:["update:modelValue"],props:{modelValue:{type:String},disabled:{type:Boolean,default:()=>!1},clearable:{type:Boolean,default:()=>!1},isTextInputShown:{type:Boolean,default:()=>!0}},computed:{value:{get(){return this.modelValue??""},set(o){this.$emit("update:modelValue",o)}}}},n0={class:"flex items-center w-full max-w-[182px]"},o0=["disabled"];function r0(o,t,n,r,a,l){const s=e.resolveComponent("vs-text");return e.openBlock(),e.createElementBlock("div",n0,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":t[0]||(t[0]=c=>l.value=c),type:"color",class:e.normalizeClass(["w-[38px] h-[38px] min-h-[38px] min-w-[38px] py-[2px] px-[3px] -ml-1 dark:bg-neutral-800 border dark:border-neutral-700 border-stone-200 rounded-lg",n.disabled?"cursor-not-allowed":"cursor-pointer"]),disabled:n.disabled},null,10,o0),[[e.vModelText,l.value]]),n.isTextInputShown?(e.openBlock(),e.createBlock(s,{key:0,modelValue:l.value,"onUpdate:modelValue":t[1]||(t[1]=c=>l.value=c),class:"ml-2 w-full",disabled:n.disabled,clearable:n.clearable},null,8,["modelValue","disabled","clearable"])):e.createCommentVNode("",!0)])}const Fl=Ce(t0,[["render",r0]]),l0={class:"flex gap-[4px] mb-[8px]"},a0={class:"grid grid-rows-3 grid-cols-7"},s0={class:"w-full h-full rounded border border-gray-300 overflow-hidden"},i0=["onClick","title"],c0={__name:"vs-editor-color",props:{editor:Object},setup(o){const t=o,n=e.ref(null),r=e.ref("#000000"),a=e.computed(()=>t.editor&&t.editor.getAttributes("textStyle").color||"#000000"),l=e.computed(()=>a.value!=="#000000"),s=()=>{t.editor&&(r.value=a.value)};e.onMounted(()=>{t.editor&&(t.editor.on("selectionUpdate",s),t.editor.on("update",s),s())}),e.onUnmounted(()=>{t.editor&&(t.editor.off("selectionUpdate",s),t.editor.off("update",s))});const c=e.ref(["#172B4D","#0747A6","#008DA6","#006644","#FF991F","#BF2600","#403294","#97A0AF","#4C9AFF","#00B8D9","#36B37E","#FFC400","#FF5630","#6554C0","#FFFFFF","#B3D4FF","#B3F5FF","#ABF5D1","#FFF0B3","#FFBDAD","#EAE6FF"]),i=g=>{t.editor&&(t.editor.chain().focus().setColor(g).run(),r.value=g,n.value&&n.value.togglePopover())},d=()=>{i(r.value)},h=g=>({"#172B4D":"Default","#0747A6":"Bright blue","#008DA6":"Bright blue-green","#006644":"Bright green","#FF991F":"Bright orange","#BF2600":"Bright red","#403294":"Bright purple","#97A0AF":"Gray","#4C9AFF":"Blue","#00B8D9":"Blue-green","#36B37E":"Green","#FFC400":"Yellow","#FF5630":"Red","#6554C0":"Purple","#FFFFFF":"White","#B3D4FF":"Bright blue","#B3F5FF":"Bright blue-green","#ABF5D1":"Bright green","#FFF0B3":"Bright yellow","#FFBDAD":"Bright red","#EAE6FF":"Bright purple"})[g]||g;return(g,p)=>(e.openBlock(),e.createBlock(Kt,{ref_key:"popover",ref:n,placement:"bottom"},{reference:e.withCtx(()=>[e.createElementVNode("button",{title:"Text Color",class:e.normalizeClass(["flex flex-col h-[30px] min-w-[30px] px-1 rounded-full hover:bg-gray-100 justify-center items-center relative flex",{"bg-gray-100":l.value}])},[p[1]||(p[1]=e.createElementVNode("span",{class:"leading-none"},"A",-1)),e.createElementVNode("span",{class:"block h-1 w-5",style:e.normalizeStyle({backgroundColor:r.value})},null,4)],2)]),default:e.withCtx(()=>[e.createElementVNode("div",null,[e.createElementVNode("div",l0,[e.createVNode(Fl,{modelValue:r.value,"onUpdate:modelValue":p[0]||(p[0]=f=>r.value=f)},null,8,["modelValue"]),e.createElementVNode("button",{onClick:d,class:"h-[38px] w-[38px] bg-blue-500 shrink-0 border rounded-md flex items-center justify-center hover:bg-blue-700 duration-300"},[e.createVNode(e.unref(X.Check),{class:"h-4 w-4 text-white"})])]),e.createElementVNode("div",a0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,f=>(e.openBlock(),e.createElementBlock("div",{key:f,class:"h-8 w-8 p-0.5 rounded border border-transparent hover:border-gray-200 transition-transform cursor-pointer"},[e.createElementVNode("div",s0,[e.createElementVNode("button",{class:"flex items-center justify-center w-full h-full",style:e.normalizeStyle({backgroundColor:f}),onClick:m=>i(f),title:h(f)},[r.value===f?(e.openBlock(),e.createBlock(e.unref(X.Check),{key:0,class:"h-4 w-4 text-gray-500"})):e.createCommentVNode("",!0)],12,i0)])]))),128))])])]),_:1},512))}},d0={class:"flex gap-[4px] mb-[8px]"},u0={class:"grid grid-rows-3 grid-cols-7"},p0={class:"w-full h-full rounded border border-gray-300 overflow-hidden"},m0=["onClick","title"],f0=["onClick","title"],h0={__name:"vs-editor-background-color",props:{editor:Object},setup(o){const t=o,n=e.ref(null),r=e.ref("transparent"),a=e.computed(()=>t.editor&&t.editor.getAttributes("textStyle").backgroundColor||"transparent"),l=e.computed(()=>a.value!=="transparent"&&a.value!==""),s=()=>{t.editor&&(r.value=a.value)};e.onMounted(()=>{t.editor&&(t.editor.on("selectionUpdate",s),t.editor.on("update",s),s())}),e.onUnmounted(()=>{t.editor&&(t.editor.off("selectionUpdate",s),t.editor.off("update",s))});const c=e.ref(["#172B4D","#0747A6","#008DA6","#006644","#FF991F","#BF2600","#403294","#97A0AF","#4C9AFF","#00B8D9","#36B37E","#FFC400","#FF5630","#6554C0","#FFFFFF","#B3D4FF","#B3F5FF","#ABF5D1","#FFF0B3","#FFBDAD","#EAE6FF"]),i=g=>{t.editor&&(t.editor.chain().focus().setBackgroundColor(g).run(),r.value=g,n.value&&n.value.togglePopover())},d=()=>{i(r.value)},h=g=>({"#172B4D":"Default","#0747A6":"Bright blue","#008DA6":"Bright blue-green","#006644":"Bright green","#FF991F":"Bright orange","#BF2600":"Bright red","#403294":"Bright purple","#97A0AF":"Gray","#4C9AFF":"Blue","#00B8D9":"Blue-green","#36B37E":"Green","#FFC400":"Yellow","#FF5630":"Red","#6554C0":"Purple",transparent:"Transparent","#B3D4FF":"Bright blue","#B3F5FF":"Bright blue-green","#ABF5D1":"Bright green","#FFF0B3":"Bright yellow","#FFBDAD":"Bright red","#EAE6FF":"Bright purple"})[g]||g;return(g,p)=>(e.openBlock(),e.createBlock(Kt,{ref_key:"popover",ref:n,placement:"bottom"},{reference:e.withCtx(()=>[e.createElementVNode("button",{title:"Background Color",class:e.normalizeClass(["flex flex-col h-[30px] px-1 rounded-full hover:bg-gray-100 justify-center items-center relative flex",{"bg-gray-100":l.value}])},[e.createVNode(e.unref(X.PaintBucket),{class:"h-4 w-4"}),e.createElementVNode("span",{class:"block h-1 w-5",style:e.normalizeStyle({backgroundColor:r.value})},null,4)],2)]),default:e.withCtx(()=>[e.createElementVNode("div",null,[e.createElementVNode("div",d0,[e.createVNode(Fl,{modelValue:r.value,"onUpdate:modelValue":p[0]||(p[0]=f=>r.value=f)},null,8,["modelValue"]),e.createElementVNode("button",{onClick:d,class:"h-[38px] w-[38px] bg-blue-500 shrink-0 border rounded-md flex items-center justify-center hover:bg-blue-700 duration-300"},[e.createVNode(e.unref(X.Check),{class:"h-4 w-4 text-white"})])]),e.createElementVNode("div",u0,[e.createElementVNode("button",{onClick:p[1]||(p[1]=f=>i("transparent")),class:"col-span-7 flex items-center justify-center gap-2 bg-gray-100 rounded-md py-1 mb-2 hover:bg-gray-200"},[e.createVNode(e.unref(X.Eraser),{class:"h-4 w-4"}),p[2]||(p[2]=e.createElementVNode("p",null,"no color",-1))]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,f=>(e.openBlock(),e.createElementBlock("div",{key:f,class:"h-8 w-8 p-0.5 rounded border border-transparent hover:border-gray-200 transition-transform cursor-pointer"},[e.createElementVNode("div",p0,[f!=="transparent"?(e.openBlock(),e.createElementBlock("button",{key:0,class:"flex items-center justify-center w-full h-full",style:e.normalizeStyle({backgroundColor:f}),onClick:m=>i(f),title:h(f)},[r.value===f?(e.openBlock(),e.createBlock(e.unref(X.Check),{key:0,class:"h-4 w-4 text-gray-500"})):e.createCommentVNode("",!0)],12,m0)):e.createCommentVNode("",!0),f==="transparent"?(e.openBlock(),e.createElementBlock("button",{key:1,class:"flex items-center justify-center w-full h-full",onClick:m=>i(f),title:h(f)},[r.value===f?(e.openBlock(),e.createBlock(e.unref(X.Check),{key:0,class:"h-4 w-4 text-gray-500"})):e.createCommentVNode("",!0)],8,f0)):e.createCommentVNode("",!0)])]))),128))])])]),_:1},512))}},g0={__name:"vs-editor-highlight",props:{editor:Object},setup(o){const t=o,n=e.computed(()=>t.editor?.isActive("highlight")),r=()=>{t.editor&&t.editor.chain().focus().toggleHighlight().run()};return(a,l)=>(e.openBlock(),e.createElementBlock("button",{title:"Highlight",onClick:r,class:e.normalizeClass(["flex flex-col h-[30px] px-1 rounded-full hover:bg-gray-100 justify-center items-center relative flex",{"bg-gray-200":n.value}])},[e.createVNode(e.unref(X.Highlighter),{class:"h-4 w-4"})],2))}},y0={class:"truncate"},b0={class:"w-[200px]"},k0={class:"max-h-[200px] overflow-y-auto"},w0=["onClick"],x0={__name:"vs-editor-font-family",props:{editor:Object},setup(o){const t=o,n=e.ref("popover"),r=e.ref(!1),a=e.ref([{label:"Arial",value:"Arial, sans-serif"},{label:"Helvetica",value:"Helvetica, sans-serif"},{label:"Times New Roman",value:"Times New Roman, serif"},{label:"Georgia",value:"Georgia, serif"},{label:"Verdana",value:"Verdana, sans-serif"},{label:"Courier New",value:"Courier New, monospace"},{label:"Comic Sans MS",value:"Comic Sans MS, cursive"},{label:"Impact",value:"Impact, sans-serif"},{label:"Trebuchet MS",value:"Trebuchet MS, sans-serif"},{label:"Palatino",value:"Palatino, serif"}]),l=e.computed(()=>{if(!t.editor)return"Arial, sans-serif";for(const d of a.value)if(t.editor.isActive("textStyle",{fontFamily:d.value}))return d.value;return"Arial, sans-serif"}),s=e.computed(()=>a.value.find(h=>h.value===l.value)?.label||"Arial"),c=d=>t.editor?t.editor.isActive("textStyle",{fontFamily:d}):!1,i=d=>{t.editor&&(t.editor.chain().focus().setFontFamily(d).run(),n.value&&n.value.togglePopover())};return(d,h)=>(e.openBlock(),e.createBlock(Kt,{ref_key:"popover",ref:n,placement:"bottom",onIsvisible:h[0]||(h[0]=g=>r.value=g)},{reference:e.withCtx(()=>[e.createElementVNode("button",{title:"Font Family",class:e.normalizeClass(["h-[30px] px-2 rounded-full hover:bg-gray-100 justify-center items-center flex text-sm",[r.value?"bg-gray-100 text-gray-900":"text-gray-700"]]),style:e.normalizeStyle({fontFamily:l.value})},[e.createElementVNode("span",y0,e.toDisplayString(s.value),1),e.createVNode(e.unref(X.ChevronDown),{class:"ml-1 h-3 w-3 text-gray-400"})],6)]),default:e.withCtx(()=>[e.createElementVNode("div",b0,[e.createElementVNode("ul",k0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,g=>(e.openBlock(),e.createElementBlock("li",{key:g.value,class:e.normalizeClass(["px-3 py-2 hover:bg-gray-100 cursor-pointer text-sm",{"bg-gray-100":c(g.value)}]),style:e.normalizeStyle({fontFamily:g.value}),onClick:p=>i(g.value)},e.toDisplayString(g.label),15,w0))),128))])])]),_:1},512))}},v0={class:"w-[120px]"},_0={class:"max-h-[200px] overflow-y-auto"},C0=["onClick"],E0={__name:"vs-editor-font-size",props:{editor:Object},setup(o){const t=o,n=e.ref("popover"),r=e.ref("14px"),a=e.computed(()=>t.editor&&t.editor.getAttributes("textStyle").fontSize||"14px"),l=e.computed(()=>a.value!=="14px"),s=()=>{t.editor&&(r.value=a.value)};e.onMounted(()=>{t.editor&&(t.editor.on("selectionUpdate",s),t.editor.on("update",s),s())}),e.onUnmounted(()=>{t.editor&&(t.editor.off("selectionUpdate",s),t.editor.off("update",s))});const c=e.ref([{label:"8px",value:"8px"},{label:"9px",value:"9px"},{label:"10px",value:"10px"},{label:"11px",value:"11px"},{label:"12px",value:"12px"},{label:"14px",value:"14px"},{label:"16px",value:"16px"},{label:"18px",value:"18px"},{label:"20px",value:"20px"},{label:"24px",value:"24px"},{label:"28px",value:"28px"},{label:"32px",value:"32px"},{label:"36px",value:"36px"},{label:"48px",value:"48px"},{label:"72px",value:"72px"}]),i=d=>{t.editor&&(t.editor.chain().focus().setFontSize(d).run(),r.value=d,n.value&&n.value.togglePopover())};return(d,h)=>(e.openBlock(),e.createBlock(Kt,{ref_key:"popover",ref:n,placement:"bottom"},{reference:e.withCtx(()=>[e.createElementVNode("button",{title:"Font Size",class:e.normalizeClass(["h-[30px] px-2 min-w-[30px] rounded-full hover:bg-gray-100 justify-center items-center flex text-sm text-gray-700 space-x-1",{"bg-gray-100 text-gray-900":l.value}])},[e.createVNode(e.unref(X.ALargeSmall),{class:"h-4 w-4"}),e.createVNode(e.unref(X.ChevronDown),{class:"h-3 w-3 text-gray-400"})],2)]),default:e.withCtx(()=>[e.createElementVNode("div",v0,[e.createElementVNode("ul",_0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,g=>(e.openBlock(),e.createElementBlock("li",{key:g.value,class:"px-3 py-2 hover:bg-gray-100 cursor-pointer",onClick:p=>i(g.value)},e.toDisplayString(g.label),9,C0))),128))])])]),_:1},512))}},B0={components:{Superscript:X.Superscript},props:{editor:Object},methods:{toggleSuperscript(){this.editor&&this.editor.commands.toggleSuperscript()}}};function V0(o,t,n,r,a,l){const s=e.resolveComponent("Superscript");return e.openBlock(),e.createElementBlock("button",{title:"Superscript",onClick:t[0]||(t[0]=(...c)=>l.toggleSuperscript&&l.toggleSuperscript(...c)),class:e.normalizeClass(["h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":n.editor?.isActive("superscript")}])},[e.createVNode(s,{class:"h-4 w-4"}),t[1]||(t[1]=e.createElementVNode("span",{class:"sr-only"},"Superscript",-1))],2)}const S0=Ce(B0,[["render",V0]]),$0={components:{Subscript:X.Subscript},props:{editor:Object},methods:{toggleSubscript(){this.editor&&this.editor.commands.toggleSubscript()}}};function A0(o,t,n,r,a,l){const s=e.resolveComponent("Subscript");return e.openBlock(),e.createElementBlock("button",{title:"Subscript",onClick:t[0]||(t[0]=(...c)=>l.toggleSubscript&&l.toggleSubscript(...c)),class:e.normalizeClass(["h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":n.editor?.isActive("subscript")}])},[e.createVNode(s,{class:"h-4 w-4"}),t[1]||(t[1]=e.createElementVNode("span",{class:"sr-only"},"Subscript",-1))],2)}const N0=Ce($0,[["render",A0]]),M0={title:"Heading",class:"h-[30px] px-2 rounded-full hover:bg-gray-100 justify-center items-center flex text-sm text-gray-700"},F0={class:"truncate"},D0={class:"max-h-[200px] overflow-y-auto"},T0=["onClick"],L0=Ce({__name:"vs-editor-heading",props:{editor:Object},setup(o){const t=o,n=e.ref("popover"),r=e.ref([{label:"Heading 1",value:1},{label:"Heading 2",value:2},{label:"Heading 3",value:3},{label:"Heading 4",value:4},{label:"Heading 5",value:5},{label:"Heading 6",value:6}]),a=e.computed(()=>{if(!t.editor)return"Paragraph";for(let i=1;i<=6;i++)if(t.editor.isActive("heading",{level:i}))return`H ${i}`;return"P"}),l=i=>({1:"font-weight:700; font-size:30px;",2:"font-weight:700; font-size:26px;",3:"font-weight:700; font-size:22px;",4:"font-weight:700; font-size:18px;",5:"font-weight:500; font-size:16px;",6:"font-weight:400; font-size:14px;"})[i]||"",s=i=>{t.editor&&(t.editor.chain().focus().setHeading({level:i}).run(),n.value&&n.value.togglePopover())},c=()=>{t.editor&&(t.editor.chain().focus().setParagraph().run(),n.value&&n.value.togglePopover())};return(i,d)=>(e.openBlock(),e.createBlock(Kt,{ref_key:"popover",ref:n,placement:"bottom"},{reference:e.withCtx(()=>[e.createElementVNode("button",M0,[e.createElementVNode("span",F0,e.toDisplayString(a.value),1),e.createVNode(e.unref(X.ChevronDown),{class:"ml-1 h-3 w-3 text-gray-400"})])]),default:e.withCtx(()=>[e.createElementVNode("div",null,[e.createElementVNode("ul",D0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,h=>(e.openBlock(),e.createElementBlock("li",{key:h.value,class:e.normalizeClass(["px-3 py-2 hover:bg-gray-100 cursor-pointer text-sm",`heading-level-${h.value}`]),style:e.normalizeStyle(l(h.value)),onClick:g=>s(h.value)},e.toDisplayString(h.label),15,T0))),128)),e.createElementVNode("li",{class:"px-3 py-2 hover:bg-gray-100 cursor-pointer text-sm border-t border-gray-200 mt-1 pt-2",onClick:c}," Paragraph ")])])]),_:1},512))}},[["__scopeId","data-v-96f02f2a"]]),I0={components:{RemoveFormatting:X.RemoveFormatting},props:{editor:Object},methods:{clearFormatting(){this.editor&&this.editor.commands.unsetAllMarks()}}};function O0(o,t,n,r,a,l){const s=e.resolveComponent("RemoveFormatting");return e.openBlock(),e.createElementBlock("button",{title:"Clear Formatting",onClick:t[0]||(t[0]=(...c)=>l.clearFormatting&&l.clearFormatting(...c)),class:"h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100"},[e.createVNode(s,{class:"h-4 w-4"}),t[1]||(t[1]=e.createElementVNode("span",{class:"sr-only"},"Clear Formatting",-1))])}const P0=Ce(I0,[["render",O0]]),R0={class:"relative"},z0={key:0,class:"mt-4"},j0=["src","alt","title"],U0={key:0,class:"text-sm text-red-500"},H0={key:1,class:"mt-4"},q0={class:"text-sm text-gray-600 mb-2"},W0={class:"flex flex-wrap gap-2"},K0=["src","alt","onError"],G0=["onClick"],Y0={class:"flex justify-end gap-x-2 p-[20px]"},X0=Object.assign({inheritAttrs:!1},{__name:"vs-editor-image",props:{editor:{type:Object,required:!0}},setup(o){const t=o,n=e.ref(!1),r=e.ref(!1),a=e.ref({}),l=e.ref(!1),s=e.ref([]),c=e.ref(null),i=e.ref({src:"",file:[],alt:"",title:"",width:"",height:"",link:"",openInNewTab:!1}),d=e.computed(()=>{if(Array.isArray(i.value.file)){const E=i.value.file.filter(T=>T instanceof File),V=i.value.file.filter(T=>typeof T=="string"&&T.trim()!=="");return E.length+V.length>1}return i.value.file instanceof FileList?i.value.file.length>1:!1}),h=e.computed(()=>Array.isArray(i.value.file)?i.value.file.filter(E=>E instanceof File).length===1:i.value.file instanceof FileList?i.value.file.length===1:i.value.file instanceof File),g=e.computed(()=>{if(d.value)return"";if(i.value.src)return i.value.src;if(h.value){let E=null;if(Array.isArray(i.value.file)||i.value.file instanceof FileList?E=i.value.file[0]:i.value.file instanceof File&&(E=i.value.file),E instanceof File){const V=s.value.find(v=>v.file===E);return V?V.preview:""}else if(typeof E=="string")return E}return""}),p=e.computed(()=>[{name:"src",label:"URL зображення",type:"text",required:!1,placeholder:"https://example.com/image.png"},{name:"file",label:"Файл (можна вибрати кілька)",type:"file",multiple:!0,required:!1,placeholder:"Шлях до файлу зображення",accept:"image/*"},{name:"width",label:"Ширина",type:"number",required:!1,placeholder:"Ширина зображення",clearable:!0,min:0},{name:"height",label:"Висота",type:"number",required:!1,placeholder:"Висота зображення",clearable:!0,min:0},{name:"alt",label:"Альтернативний текст",type:"text",required:!1,placeholder:"Опис зображення"},{name:"title",label:"Заголовок (необов'язково)",type:"text",required:!1,placeholder:"Заголовок зображення"},{name:"link",label:"Посилання",type:"text",required:!1,placeholder:"https://example.com"},{name:"openInNewTab",label:"Відкривати у новій вкладці?",type:"switcher",required:!1}]),f=()=>{if(!t.editor)return;if(t.editor.isActive("image")){const{state:V}=t.editor,{selection:v}=V,{$from:T}=v;let j=null,te=null;if(T.parent.type.name==="image")j=T.before(T.depth),te=T.parent;else for(let ae=T.depth;ae>0;ae--){const O=T.node(ae),A=T.before(ae);O.type.name==="paragraph"&&O.forEach((M,Q)=>{if(M.type.name==="image"){const se=A+Q+1;(j===null||Math.abs(se-v.$from.pos)<Math.abs(j-v.$from.pos))&&(j=se,te=M)}})}if(j!==null&&te){try{t.editor.chain().focus().setNodeSelection(j).run()}catch{t.editor.chain().focus().setTextSelection(j).run()}c.value=j}else{t.editor.chain().focus().selectParentNode().run();const{state:ae}=t.editor;c.value=ae.selection.$from.pos}const D=te?te.attrs:t.editor.getAttributes("image");l.value=!0;let U="",oe=!1;const R=t.editor.getAttributes("link");R&&R.href&&(U=R.href,oe=R.target==="_blank");const H=D.src||"",Z=H?[H]:[];i.value={src:H,file:Z,alt:D.alt||"",title:D.title||"",width:D.width||"",height:D.height||"",link:U,openInNewTab:oe}}else l.value=!1,i.value={src:"",file:[],alt:"",title:"",width:"",height:"",link:"",openInNewTab:!1};r.value=!1,n.value=!0},m=()=>{n.value=!1,r.value=!1,l.value=!1,s.value=[],c.value=null,i.value={src:"",file:[],alt:"",title:"",width:"",height:"",link:"",openInNewTab:!1}},k=async E=>{if(!E||E.length===0)return;const V=[];for(const v of E)if(v&&v.type&&v.type.startsWith("image/")&&!s.value.some(j=>j.file===v)){const j=new Promise((te,D)=>{const U=new FileReader;U.onload=oe=>{s.value.push({file:v,preview:oe.target.result,error:!1}),te()},U.onerror=D,U.readAsDataURL(v)});V.push(j)}await Promise.all(V)},b=E=>{s.value.splice(E,1),Array.isArray(i.value.file)&&i.value.file.splice(E,1)},_=()=>{const E=i.value.width!==null&&i.value.width!==void 0&&i.value.width!==""&&String(i.value.width).trim()!==""?String(i.value.width).trim():"",V=i.value.height!==null&&i.value.height!==void 0&&i.value.height!==""&&String(i.value.height).trim()!==""?String(i.value.height).trim():"",v={};return E&&V?(v.width=E,v.height=V,v.style=`width: ${E}px; height: ${V}px; object-fit: fill;`):E?(v.width=E,v.height=void 0):V?(v.height=V,v.width=void 0):(v.width=void 0,v.height=void 0),v},C=(E,V=null,v=50)=>{const T=()=>{const{view:D}=E;if(!D||!D.dom)return;D.dom.querySelectorAll("img.editor-image[width][height]").forEach(R=>{if(R instanceof HTMLImageElement){const H=R.getAttribute("width"),Z=R.getAttribute("height");H&&Z&&H!=="auto"&&Z!=="auto"&&H!==""&&Z!==""&&!isNaN(Number(H))&&!isNaN(Number(Z))&&(R.style.cssText=`
36
- width: ${H}px !important;
37
- height: ${Z}px !important;
34
+ `).trim()},eA=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),tA=n=>{if(!n)return"";if(typeof window>"u"||typeof DOMParser>"u")return n;const t=new DOMParser().parseFromString(n,"text/html"),r=" ",o=(i,l)=>{if(i.nodeType===Node.TEXT_NODE){const h=(i.textContent||"").replace(/\s+/g," ").trim();return h?[`${r.repeat(l)}${h}`]:[]}if(i.nodeType!==Node.ELEMENT_NODE)return[];const a=i,c=a.tagName.toLowerCase(),d=Array.from(a.attributes).map(h=>`${h.name}="${h.value}"`).join(" "),u=d?`<${c} ${d}>`:`<${c}>`,f=`</${c}>`;if(eA.has(c))return[`${r.repeat(l)}${u}`];const p=Array.from(a.childNodes).flatMap(h=>o(h,l+1));if(!p.length)return[`${r.repeat(l)}${u}${f}`];if(a.childNodes.length===1&&a.firstChild?.nodeType===Node.TEXT_NODE&&p.length===1){const h=p[0].trim();return[`${r.repeat(l)}${u}${h}${f}`]}return[`${r.repeat(l)}${u}`,...p,`${r.repeat(l)}${f}`]};return Array.from(t.body.childNodes).flatMap(i=>o(i,0)).join(`
35
+ `)},nA=n=>n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),vi=n=>{if(!n)return"";if(typeof window>"u"||typeof DOMParser>"u")return n.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");const t=new DOMParser().parseFromString(n,"text/html");return t.querySelectorAll("script").forEach(r=>r.remove()),t.body.innerHTML},qf=n=>{if(!n)return{wrapper:null,bodyHtml:""};if(typeof window>"u"||typeof DOMParser>"u")return{wrapper:null,bodyHtml:n};const t=new DOMParser().parseFromString(n,"text/html"),{body:r}=t;if(r.childElementCount!==1)return{wrapper:null,bodyHtml:n};const o=r.firstElementChild;return!o||o.tagName.toLowerCase()!=="div"?{wrapper:null,bodyHtml:n}:{wrapper:{tag:o.tagName.toLowerCase(),attributes:Array.from(o.attributes).map(i=>({name:i.name,value:i.value}))},bodyHtml:o.innerHTML}},Gf=(n,e)=>{if(!e)return n||"";const t=(e.attributes||[]).map(({name:o,value:i})=>`${o}="${nA(i)}"`).join(" ");return`${t?`<${e.tag} ${t}>`:`<${e.tag}>`}${n||""}</${e.tag}>`},Jf=async(n,e)=>e!=="md"?n||"":jf(n||""),Yf=async(n,e)=>e!=="md"?tA(n||""):Kf(n||""),rA=async(n,e)=>e!=="md"?n||"":Kf(n||""),oA=async n=>{try{const e=new FormData;return e.append("unique","true"),e.append("file",n),(await(await fetch("/file/upload/uploads?id=&form=&table=",{method:"POST",body:e})).json())?.result}catch(e){console.error(e)}},sA=async(n,e,t)=>{const r=e.clipboardData?.items;if(r){const o=e.clipboardData?.getData("text/html"),i=e.clipboardData?.getData("text/plain");if(o){const{state:l,dispatch:a}=n,{tr:c}=l,d=t.fromSchema(n.state.schema),u=new DOMParser().parseFromString(o,"text/html").body,f=d.parse(u),p=c.replaceSelectionWith(f);return a(p),e.preventDefault(),!0}if(i){const{state:l,dispatch:a}=n,{tr:c}=l,d=c.insertText(i,l.selection.from,l.selection.to);return a(d),e.preventDefault(),!0}for(let l=0;l<r.length;l++){const a=r[l];if(a.type.startsWith("image/")){const c=a.getAsFile();if(c){const d=await oA(c),{schema:u}=n.state,f=u.nodes.image.create({src:d?.file_path}),p=n.state.tr.replaceSelectionWith(f);return n.dispatch(p),e.preventDefault(),!0}}}}return!1},iA=n=>String(n).trim().toLowerCase().split("-")[0],lA=()=>typeof window>"u"?"uk":iA(localStorage.getItem("language")||localStorage.getItem("locale")||navigator.language||"uk"),aA=(n,e)=>{const t=e.replace(/^form\.richtext\./,"");return Oa?.[n]?.form?.richtext?.[t]||Oa?.uk?.form?.richtext?.[t]||e},Xf=n=>n.startsWith("form.richtext.")?n:`form.richtext.${n}`;function qa(){const e=s.getCurrentInstance()?.appContext?.config?.globalProperties,t=e?.$i18n;return{t:o=>{const i=e?.$t,l=e?.$te,a=typeof t?.te=="function"?t.te.bind(t):null;if(typeof i=="function"){const c=Xf(o);if((typeof l=="function"?l(c):typeof a=="function"?a(c):null)!==!1){const u=i(c);if(u&&u!==c)return u}}return aA(lA(),Xf(o))}}}const cA={components:{Quote:Y.Quote},props:{editor:Object},methods:{toggleBlockquote(){this.editor&&this.editor.chain().toggleBlockquote().run()}}};function dA(n,e,t,r,o,i){const l=s.resolveComponent("Quote");return s.openBlock(),s.createElementBlock("button",{title:"Blockquote",onClick:e[0]||(e[0]=(...a)=>i.toggleBlockquote&&i.toggleBlockquote(...a)),class:s.normalizeClass(["text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100 focus:outline-none",{"bg-gray-100 text-gray-900":t.editor?.isActive("blockquote")}])},[s.createVNode(l,{class:"h-4 w-4"})],2)}const uA=Ne(cA,[["render",dA]]),fA={components:{List:Y.List},props:{editor:Object},methods:{toggleBulletList(){this.editor&&this.editor.chain().focus().toggleBulletList().run()}}};function pA(n,e,t,r,o,i){const l=s.resolveComponent("List");return s.openBlock(),s.createElementBlock("button",{title:"Bullet List",onClick:e[0]||(e[0]=(...a)=>i.toggleBulletList&&i.toggleBulletList(...a)),class:s.normalizeClass(["text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":t.editor?.isActive("bulletList")}])},[s.createVNode(l,{class:"h-4 w-4"})],2)}const hA=Ne(fA,[["render",pA]]),mA={components:{ListOrdered:Y.ListOrdered},props:{editor:Object},methods:{toggleOrderedList(){this.editor&&this.editor.chain().focus().toggleOrderedList().run()}}};function gA(n,e,t,r,o,i){const l=s.resolveComponent("ListOrdered");return s.openBlock(),s.createElementBlock("button",{title:"Ordered List",onClick:e[0]||(e[0]=(...a)=>i.toggleOrderedList&&i.toggleOrderedList(...a)),class:s.normalizeClass(["text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":t.editor?.isActive("orderedList")}])},[s.createVNode(l,{class:"h-4 w-4"})],2)}const yA=Ne(mA,[["render",gA]]),bA={components:{CodeXml:Y.CodeXml},props:{editor:Object},methods:{toggleCodeBlock(){this.editor&&this.editor.chain().focus().toggleCodeBlock().run()}}};function kA(n,e,t,r,o,i){const l=s.resolveComponent("CodeXml");return s.openBlock(),s.createElementBlock("button",{title:"Code Block",onClick:e[0]||(e[0]=(...a)=>i.toggleCodeBlock&&i.toggleCodeBlock(...a)),class:s.normalizeClass(["text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":t.editor?.isActive("codeBlock")}])},[s.createVNode(l,{class:"h-4 w-4"})],2)}const wA=Ne(bA,[["render",kA]]),xA={components:{Bold:Y.Bold},props:{editor:Object},methods:{toggleBold(){this.editor&&this.editor.commands.toggleBold()}}};function vA(n,e,t,r,o,i){const l=s.resolveComponent("Bold");return s.openBlock(),s.createElementBlock("button",{title:"Bold Text",onClick:e[0]||(e[0]=(...a)=>i.toggleBold&&i.toggleBold(...a)),class:s.normalizeClass(["h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":t.editor?.isActive("bold")}])},[s.createVNode(l,{class:"h-4 w-4"}),e[1]||(e[1]=s.createElementVNode("span",{class:"sr-only"},"Bold",-1))],2)}const CA=Ne(xA,[["render",vA]]),SA={components:{Italic:Y.Italic},props:{editor:Object},methods:{toggleItalic(){this.editor&&this.editor.chain().toggleItalic().run()}}};function EA(n,e,t,r,o,i){const l=s.resolveComponent("Italic");return s.openBlock(),s.createElementBlock("button",{title:"Italic Text",onClick:e[0]||(e[0]=(...a)=>i.toggleItalic&&i.toggleItalic(...a)),class:s.normalizeClass(["h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":t.editor?.isActive("italic")}])},[s.createVNode(l,{class:"h-4 w-4"}),e[1]||(e[1]=s.createElementVNode("span",{class:"sr-only"},"Italic",-1))],2)}const MA=Ne(SA,[["render",EA]]),AA={__name:"vs-editor-underline",props:{editor:Object},setup(n){const e=n,t=()=>{e.editor&&e.editor.chain().focus().toggleUnderline().run()};return(r,o)=>(s.openBlock(),s.createElementBlock("button",{title:"Underline",onClick:t,class:s.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100",[n.editor?.isActive("underline")?"bg-gray-100 text-gray-900":"text-gray-500"]])},[s.createVNode(s.unref(Y.Underline),{class:"h-4 w-4"})],2))}},_A={__name:"vs-editor-strike",props:{editor:Object},setup(n){const e=n,t=()=>{e.editor&&e.editor.chain().focus().toggleStrike().run()};return(r,o)=>(s.openBlock(),s.createElementBlock("button",{title:"Strikethrough",onClick:t,class:s.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100",[n.editor?.isActive("strike")?"bg-gray-100 text-gray-900":"text-gray-500"]])},[s.createVNode(s.unref(Y.Strikethrough),{class:"h-4 w-4"})],2))}},TA={components:{X:Y.X},props:{visible:{type:Boolean,default:()=>!1},modelValue:{type:Boolean,default:()=>!1},title:{type:String,default:()=>""},size:{type:String,default:()=>""},closeClickBack:{type:Boolean,default:()=>!1}},emits:["update:visible","update:modelValue","onClose","confirm","cancel"],inheritAttrs:!1,name:"vs-dialog",mounted(){window.addEventListener("keydown",this.checkKey)},unmounted(){window.removeEventListener("keydown",this.checkKey)},computed:{hasSlot(){return!!this.$slots?.footer},checkSize(){return this.size==="small"?"md:w-5/12 w-9/12":this.size==="medium"?"md:w-6/12 w-9/12":"lg:w-7/12 w-11/12"}},methods:{checkKey({key:n}){n==="Escape"&&this.handleClose()},handleClose(){this.$emit("update:visible",!1),this.$emit("update:modelValue",!1),this.$emit("onClose")},handleConfirm(){this.$emit("confirm"),this.handleClose()},handleCancel(){this.$emit("cancel"),this.handleClose()},closeByClickBack(n,e){e&&n.target.classList.contains("vs-dialog-overlay")&&this.handleClose()}}},BA={key:0,class:"vsTailwind ui-dialog__wrapper"},NA={class:"py-2.5 px-4 flex justify-between items-center border-0 border-b border-solid border-gray-200 dark:border-b-[#454545]"},DA={class:"font-medium text-gray-800 dark:text-[#ffffff]"},VA={class:"ui-dialog__content p-4"},$A={key:0,class:"flex justify-end gap-x-2"};function LA(n,e,t,r,o,i){const l=s.resolveComponent("X");return s.openBlock(),s.createBlock(s.Teleport,{to:"body"},[t.visible||t.modelValue?(s.openBlock(),s.createElementBlock("div",BA,[s.createElementVNode("div",{onMousedown:e[1]||(e[1]=a=>i.closeByClickBack(a,t.closeClickBack)),class:"vs-dialog-overlay vs-dialog w-full h-full fixed top-0 start-0 z-[100001] bg-black bg-opacity-50"},[s.createVNode(s.Transition,{name:"content",appear:""},{default:s.withCtx(()=>[s.createElementVNode("div",{class:s.normalizeClass(["ui-dialog__modal opacity-1 flex flex-col bg-white dark:bg-[#1A1A1A] border dark:border-[#454545] pointer-events-auto shadow-[0_10px_40px_10px_rgba(0,0,0,0.08)] rounded-xl",[i.checkSize]])},[s.createElementVNode("div",NA,[s.createElementVNode("h3",DA,s.toDisplayString(t.title),1),s.createElementVNode("button",{type:"button",class:"size-8 inline-flex justify-center items-center gap-x-2 rounded-full border border-transparent bg-gray-100 text-gray-800 hover:bg-gray-200 focus:outline-none focus:bg-gray-200 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-700 dark:hover:bg-neutral-600 dark:text-neutral-400 dark:focus:bg-neutral-600",onClick:e[0]||(e[0]=(...a)=>i.handleClose&&i.handleClose(...a))},[e[2]||(e[2]=s.createElementVNode("span",{class:"sr-only"},"Close",-1)),s.createVNode(l,{class:"h-4 w-4 flex-shrink-0"})])]),s.createElementVNode("div",VA,[s.renderSlot(n.$slots,"default",{},void 0,!0)]),i.hasSlot?(s.openBlock(),s.createElementBlock("div",$A,[s.renderSlot(n.$slots,"footer",{handleClose:i.handleClose,handleConfirm:i.handleConfirm,handleCancel:i.handleCancel},void 0,!0)])):s.createCommentVNode("",!0)],2)]),_:3})],32)])):s.createCommentVNode("",!0)])}const Zf=Ne(TA,[["render",LA],["__scopeId","data-v-56ad9010"]]),IA=s.defineComponent({components:{IconClose:Y.X,IconSearch:Y.Search,IconEmail:Y.Mail},inheritAttrs:!1,props:{icon:{type:String,default:()=>""},disabled:{type:Boolean,default:()=>!1},clearable:{type:Boolean,default:()=>!1},modelValue:{type:String,default:()=>""},placeholder:{type:String,default:()=>""},iconPosition:{type:String,default:()=>"right"},type:{type:String,default:()=>"text"},style:{type:Object,default:()=>null},size:{type:String,default:()=>"md"},attrs:{type:Object,default:()=>{}}},emits:["onInput","update:modelValue","blur","focus"],computed:{checkSize(){return(this.style?.size||this.size)==="xs"?"h-[32px] text-sm":(this.style?.size||this.size)==="md"?"h-[38px] text-sm":(this.style?.size||this.size)==="lg"?"h-[46px] text-[20px]":"h-[38px] text-sm"},value:{get(){return this.modelValue},set(n){this.$emit("update:modelValue",n.trim())}},clearIconStyle(){return[{"right-8":this.icon&&this.iconPosition==="right","right-3":!this.icon||this.iconPosition!=="right","pointer-events-none":this.disabled}]},iconStylePosition(){return[{"left-3":this.icon&&this.iconPosition==="left","right-3":this.icon&&this.iconPosition==="right"}]},inputStyle(){return[{"!pr-8":this.clearable&&!this.icon,"!pr-7":this.clearable,"!pr-16":this.clearable&&this.icon&&this.iconPosition==="right","!pl-8":this.icon&&this.iconPosition==="left","!pr-[50px]":this.clearable&&this.value&&this.icon&&this.iconPosition==="right","!cursor-not-allowed bg-slate-100":this.disabled,"bg-white":!this.disabled}]}},methods:{handleInput(){this.$emit("onInput",this.modelValue)},handleBlur(){this.$emit("blur")},handleFocus(){this.$emit("focus")},clearInput(){this.$emit("update:modelValue",""),this.$emit("onInput","")},async inputFocus(){await this.$refs.vsText?.focus()}}}),OA={class:"vs-form-text relative bg-white rounded-lg"},RA={key:2,class:"absolute bottom-2/4 translate-y-2/4 left-[10px] cursor-pointer"},FA=["disabled","type","placeholder"];function PA(n,e,t,r,o,i){const l=s.resolveComponent("IconClose"),a=s.resolveComponent("IconSearch"),c=s.resolveComponent("IconEmail");return s.openBlock(),s.createElementBlock("div",OA,[n.clearable&&n.value?(s.openBlock(),s.createElementBlock("div",{key:0,class:"absolute bottom-2/4 translate-y-2/4 right-3 cursor-pointer",onClick:e[0]||(e[0]=(...d)=>n.clearInput&&n.clearInput(...d))},[s.createVNode(l,{class:"h-4 w-4 stroke-gray-500 transition-all hover:stroke-red-500"})])):s.createCommentVNode("",!0),n.icon&&n.icon==="search"?(s.openBlock(),s.createElementBlock("div",{key:1,class:s.normalizeClass(["absolute bottom-2/4 translate-y-2/4 cursor-pointer",n.iconStylePosition])},[s.createVNode(a,{class:"h-4 w-4 stroke-gray-500 transition-all"})],2)):n.icon&&n.icon==="email"?(s.openBlock(),s.createElementBlock("div",RA,[s.createVNode(c,{class:"h-4 w-4 stroke-gray-500 transition-all"})])):(s.openBlock(),s.createElementBlock("i",{key:3,class:s.normalizeClass(["absolute bottom-2/4 translate-y-2/4 text-gray-500 cursor-pointer",["ti "+n.icon,n.iconStylePosition]])},null,2)),n.clearable&&n.value?(s.openBlock(),s.createElementBlock("div",{key:4,class:"absolute bottom-2/4 translate-y-2/4 right-3 cursor-pointer",onClick:e[1]||(e[1]=(...d)=>n.clearInput&&n.clearInput(...d))},[s.createVNode(l,{class:"h-4 w-4 stroke-gray-500 transition-all hover:stroke-red-500"})])):s.createCommentVNode("",!0),s.withDirectives(s.createElementVNode("input",s.mergeProps({ref:"vsText",disabled:n.disabled,type:n.type,onInput:e[2]||(e[2]=(...d)=>n.handleInput&&n.handleInput(...d)),placeholder:n.placeholder,"onUpdate:modelValue":e[3]||(e[3]=d=>n.value=d)},n.style?.attrs||n.attrs||{},{onFocus:e[4]||(e[4]=(...d)=>n.handleFocus&&n.handleFocus(...d)),onBlur:e[5]||(e[5]=(...d)=>n.handleBlur&&n.handleBlur(...d)),class:[[n.inputStyle,n.checkSize],"py-2 px-3 block w-full border border-solid placeholder:text-nowrap border-stone-200 rounded-lg text-sm text-stone-800 placeholder:text-stone-400 focus:outline focus:z-10 focus:border-blue-500 focus:ring-blue-500 focus:outline-blue-500"]}),null,16,FA),[[s.vModelDynamic,n.value]])])}const Qf=Ne(IA,[["render",PA],["__scopeId","data-v-eb21a54f"]]),zA=["title"],HA={class:"flex flex-col gap-3 p-[20px]"},jA={class:"relative flex items-center gap-2"},UA={class:"flex-1"},WA={key:0,class:"flex items-center gap-2 flex-shrink-0"},KA=["title"],qA=["title"],GA={class:"flex items-center gap-2"},JA={for:"openInNewTab",class:"text-sm text-gray-700 cursor-pointer"},YA={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},XA=Object.assign({inheritAttrs:!1},{__name:"vs-editor-link",props:{editor:Object},setup(n){const{t:e}=qa(),t=n,r=s.ref(!1),o=s.ref(""),i=s.ref(!1),l=s.ref(!1),a=()=>{if(!t.editor)return;t.editor.chain().focus().extendMarkRange("link").run();const p=t.editor.getAttributes("link");p.href?(i.value=!0,o.value=p.href,l.value=p.target==="_blank"):(i.value=!1,o.value="",l.value=!1),r.value=!0},c=()=>{r.value=!1,o.value="",i.value=!1,l.value=!1},d=()=>{if(!t.editor||!o.value.trim())return;let p=o.value.trim();p.match(/^https?:\/\//i)||(p="https://"+p),t.editor.chain().focus().setLink({href:p,target:l.value?"_blank":null}).run(),c()},u=()=>{t.editor&&(t.editor.chain().focus().unsetLink().run(),c())},f=()=>{if(!o.value)return;let p=o.value.trim();p.match(/^https?:\/\//i)||(p="https://"+p),window.open(p,"_blank","noopener,noreferrer")};return(p,h)=>(s.openBlock(),s.createElementBlock(s.Fragment,null,[s.createElementVNode("button",{title:s.unref(e)("form.richtext.link")||"Посилання",onClick:a,class:s.normalizeClass(["text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100 focus:outline-none",{"bg-gray-100 text-gray-900":n.editor?.isActive("link")}])},[s.createVNode(s.unref(Y.Link2),{class:"h-4 w-4"})],10,zA),s.createVNode(Zf,{title:i.value?s.unref(e)("form.richtext.editLink")||"Редагувати посилання":s.unref(e)("form.richtext.linkTitle")||"Додати посилання",visible:r.value,"onUpdate:visible":h[2]||(h[2]=m=>r.value=m),size:"small"},{footer:s.withCtx(()=>[s.createElementVNode("div",YA,[s.createElementVNode("button",{style:{border:"1px solid #000"},onClick:c,class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-black border-gray-200 rounded-lg !border-gray-200 hover:bg-gray-100 duration-300"},s.toDisplayString(s.unref(e)("form.richtext.cancel")||"Скасувати"),1),s.createElementVNode("button",{onClick:d,class:"py-2 px-3 inline-flex items-center gap-x-2 text-[14px] font-[400] whitespace-nowrap text-white bg-blue-500 rounded-lg !border-gray-200 hover:bg-blue-700 duration-300"},s.toDisplayString(i.value?s.unref(e)("form.richtext.update")||"Оновити":s.unref(e)("form.richtext.create")||"Створити"),1)])]),default:s.withCtx(()=>[s.createElementVNode("div",HA,[s.createElementVNode("div",jA,[s.createElementVNode("div",UA,[s.createVNode(Qf,{modelValue:o.value,"onUpdate:modelValue":h[0]||(h[0]=m=>o.value=m),placeholder:s.unref(e)("form.richtext.linkUrl")||"Введіть URL",class:"w-full"},null,8,["modelValue","placeholder"])]),i.value?(s.openBlock(),s.createElementBlock("div",WA,[s.createElementVNode("button",{onClick:f,class:"text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100 focus:outline-none transition-colors",title:s.unref(e)("form.richtext.openLink")||"Відкрити посилання"},[s.createVNode(s.unref(Y.ExternalLink),{class:"h-4 w-4"})],8,KA),s.createElementVNode("button",{onClick:u,class:"text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-red-600 hover:bg-red-50 focus:outline-none transition-colors",title:s.unref(e)("form.richtext.removeLink")||"Видалити посилання"},[s.createVNode(s.unref(Y.Trash2),{class:"h-4 w-4"})],8,qA)])):s.createCommentVNode("",!0)]),s.createElementVNode("div",GA,[s.withDirectives(s.createElementVNode("input",{type:"checkbox",id:"openInNewTab","onUpdate:modelValue":h[1]||(h[1]=m=>l.value=m),class:"w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500"},null,512),[[s.vModelCheckbox,l.value]]),s.createElementVNode("label",JA,s.toDisplayString(s.unref(e)("form.richtext.openInNewTab")||"Відкривати в новій вкладці"),1)])])]),_:1},8,["title","visible"])],64))}}),Wo=async(n,e,t,r=10)=>{if(!e||!t)return;await s.nextTick();const o=await t?.getBoundingClientRect(),i=await e?.getBoundingClientRect();if(!i||!o)return;const l=await parseInt(e?.getBoundingClientRect()?.height),a=await parseInt(e?.getBoundingClientRect()?.width),c=await parseInt(t?.getBoundingClientRect()?.height),d=await parseInt(t?.getBoundingClientRect()?.width),u=await window.innerHeight,f=await window.innerWidth;let p=0,h=0;const m=i.bottom+r+c;switch(n){case"top":i.top-o.height-r<0?p=i.top-o.height+r+c+l:p=i.top-o.height-r,f>d+i.right+30?h=i.left-o.width/2+i.width/2:h=f-30-d;break;case"bottom":u>m?p=i.bottom+r:p=i.bottom-r-c-l,h=i.left-o.width/2+i.width/2;break;case"left":p=i.top-o.height/2+i.height/2,i.left-o.width-r>0?h=i.left-o.width-r:h=10;break;case"right":p=i.top-o.height/2+i.height/2,f-a>d?h=i.right+r:h=f-30-d;break;case"top-right":i.top-o.height-r<0?p=i.top-o.height+r+c+l:p=i.top-o.height-r,f-a>d?h=i.right+r:h=f-30-d;break;case"top-left":i.top-o.height-r<0?p=i.top-o.height+r+c+l:p=i.top-o.height-r,i.left-o.width-r>0?h=i.left-o.width-r:h=10;break;case"top-start":i.top-o.height-r<0?p=i.top-o.height+r+c+l:p=i.top-o.height-r,i.left>0?h=i.left:h=10;break;case"bottom-right":u>m?p=i.bottom+r:p=i.bottom-r-c-l,f-a>d?h=i.left:h=f-30-d;break;case"bottom-left":u>m?p=i.bottom+r:p=i.bottom-r-c-l,i.left>0?h=i.right-d:h=10;break;case"bottom-start":u>m?p=i.bottom+r:p=i.bottom-r-c-l,i.left>0?h=i.left:h=10;break}p+c>u?p=u-c-r:p<0&&(p=r),h+d>f?h=f-d-r:h<0&&(h=r),t instanceof HTMLElement&&(t.style.top=`${p}px`,t.style.left=`${h}px`,t.style.position="fixed")},ZA={class:"text-center"},QA={class:"py-2 px-4 w-full text-sm text-stone-800 bg-white shadow-[0_10px_40px_10px_rgba(0,0,0,0.08)] rounded-lg focus:outline-none focus:bg-stone-100 dark:bg-neutral-900 dark:text-neutral-200 dark:focus:bg-neutral-800 after:h-4 after:absolute after:-bottom-4 after:start-0 after:w-full before:h-4 before:absolute before:-top-4 before:start-0 before:w-full"},Tr=Object.assign({inheritAttrs:!1},{__name:"vs-popover",props:{isOpen:{type:Boolean,default:()=>!1},placement:{type:String,default:"top"},gap:{type:Number,default:8},width:{type:[String,Number],default:""},disabled:{type:Boolean,default:!1},trigger:{type:String,default:"click"},teleport:{type:String,default:"body"}},emits:["isvisible"],setup(n,{expose:e,emit:t}){const r=n,o=t,i=s.ref(!1),l=s.ref([]),a=s.ref(null),c=s.ref(null),d=s.ref(null);s.watch(i,v=>{v?(u(),window.addEventListener("resize",()=>Wo(r.placement,c.value,d.value)),Wo(r.placement,c.value,d.value)):window.removeEventListener("resize",()=>Wo(r.placement,c.value,d.value)),o("isvisible",v)}),s.onMounted(()=>{window.addEventListener("click",y),window.addEventListener("popstate",b),window.addEventListener("scroll",w,!0),u()}),s.onBeforeUnmount(()=>{window.removeEventListener("click",y),window.removeEventListener("popstate",b),f()});const u=()=>{let v=a.value;for(;v&&v!==document.body;)(v.scrollHeight>v.clientHeight||v.scrollWidth>v.clientWidth)&&(v.addEventListener("scroll",g),l.value.push(v)),v=v.parentElement;document.body&&(document.body.addEventListener("scroll",g),l.value.push(document.body))},f=()=>{l.value.forEach(v=>{v.removeEventListener("scroll",g)}),l.value=[]},p=()=>{i.value=!0,Wo(r.placement,c.value,d.value)},h=()=>{i.value=!1},m=async()=>{await Wo(r.placement,c.value,d.value),i.value=!i.value},g=()=>{i.value=!1},y=v=>{if(!v){i.value=!1;return}c.value?.contains(v.target)||d.value?.contains(v.target)||(i.value=!1)},b=()=>{i.value&&(i.value=!1)},w=v=>{i.value&&d.value&&!d.value.contains(v.target)&&(i.value=!1)};return e({togglePopover:m}),(v,E)=>(s.openBlock(),s.createElementBlock("div",{ref_key:"popover",ref:a,class:"vs-popover inline-block"},[s.createElementVNode("div",ZA,[n.trigger==="click"?(s.openBlock(),s.createElementBlock("div",{key:0,ref_key:"popoverRef",ref:c,onClick:m,class:s.normalizeClass({"pointer-events-none":n.disabled})},[s.renderSlot(v.$slots,"reference",{},()=>[E[0]||(E[0]=s.createElementVNode("button",null,"Click me!",-1))])],2)):s.createCommentVNode("",!0),n.trigger==="hover"?(s.openBlock(),s.createElementBlock("div",{key:1,ref_key:"popoverRef",ref:c,onMouseover:p,onMouseleave:h,class:s.normalizeClass({"pointer-events-none":n.disabled})},[s.renderSlot(v.$slots,"reference",{},()=>[E[1]||(E[1]=s.createElementVNode("button",null,"Click me!",-1))])],34)):s.createCommentVNode("",!0),(s.openBlock(),s.createBlock(s.Teleport,{to:n.teleport},[s.createVNode(s.Transition,{name:"fade"},{default:s.withCtx(()=>[s.withDirectives(s.createElementVNode("div",{class:s.normalizeClass(["vsTailwind vs-popover__content",n.placement]),ref_key:"contentPop",ref:d,style:s.normalizeStyle({width:n.width?n.width+"px":"fit-content",zIndex:100001})},[s.createElementVNode("div",QA,[s.renderSlot(v.$slots,"default",{},()=>[E[2]||(E[2]=s.createElementVNode("span",null,"Popover content",-1))])])],6),[[s.vShow,i.value]])]),_:3})],8,["to"]))])],512))}}),e_={class:"flex flex-col gap-[2px] p-[2px]"},t_=["onClick"],n_={__name:"vs-editor-table",props:{editor:Object},setup(n){const{t:e}=qa(),t=n,r=s.ref(!1),o=s.ref("popover"),i=()=>{t.editor&&(t.editor.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),o.value.togglePopover())},l=()=>{t.editor&&(t.editor.chain().focus().addColumnAfter().run(),o.value.togglePopover())},a=()=>{t.editor&&(t.editor.chain().focus().addRowAfter().run(),o.value.togglePopover())},c=()=>{t.editor&&(t.editor.chain().focus().deleteColumn().run(),o.value.togglePopover())},d=()=>{t.editor&&(t.editor.chain().focus().deleteRow().run(),o.value.togglePopover())},u=()=>{t.editor&&(t.editor.chain().focus().deleteTable().run(),o.value.togglePopover())},f=()=>{t.editor&&(t.editor.chain().focus().mergeCells().run(),o.value.togglePopover())},p=()=>{t.editor&&(t.editor.chain().focus().splitCell().run(),o.value.togglePopover())},h=s.computed(()=>[{text:e("form.richtext.createTable"),function:i},{text:e("form.richtext.addColumn"),function:l},{text:e("form.richtext.addRow"),function:a},{text:e("form.richtext.deleteColumn"),function:c},{text:e("form.richtext.deleteRow"),function:d},{text:e("form.richtext.deleteTable"),function:u},{text:e("form.richtext.mergeCells"),function:f},{text:e("form.richtext.splitCells"),function:p}]);return(m,g)=>(s.openBlock(),s.createBlock(Tr,{ref_key:"popover",ref:o,placement:"bottom",onIsvisible:g[0]||(g[0]=y=>r.value=y)},{reference:s.withCtx(()=>[s.createElementVNode("button",{title:"Table",class:s.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center text-gray-500 rounded-full hover:text-gray-900 hover:bg-gray-100",[r.value?"bg-gray-100 text-gray-900":"text-gray-500"]])},[s.createVNode(s.unref(Y.Table2),{class:"h-4 w-4"})],2)]),default:s.withCtx(()=>[s.createElementVNode("div",e_,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(h.value,(y,b)=>(s.openBlock(),s.createElementBlock("button",{key:b,onClick:y?.function,class:"px-2 py-1 text-gray-500 text-start hover:text-gray-900 hover:bg-gray-100 rounded"},s.toDisplayString(y.text),9,t_))),128))])]),_:1},512))}},r_={class:"flex gap-[4px] p-1"},o_=["title","onClick"],s_={__name:"vs-editor-align",props:{editor:Object},setup(n){const e=n,t={left:Y.AlignLeft,center:Y.AlignCenter,right:Y.AlignRight,justify:Y.AlignJustify},r=s.ref(!1),o=s.ref("popover"),i=s.ref("left"),l=s.computed(()=>e.editor?e.editor.isActive("paragraph",{textAlign:"left"})||e.editor.isActive("heading",{textAlign:"left"}):!1),a=s.computed(()=>e.editor?e.editor.isActive("paragraph",{textAlign:"right"})||e.editor.isActive("heading",{textAlign:"right"}):!1),c=s.computed(()=>e.editor?e.editor.isActive("paragraph",{textAlign:"center"})||e.editor.isActive("heading",{textAlign:"center"}):!1),d=s.computed(()=>e.editor?e.editor.isActive("paragraph",{textAlign:"justify"})||e.editor.isActive("heading",{textAlign:"justify"}):!1),u=s.computed(()=>l.value||a.value||c.value||d.value),f=()=>{a.value?i.value="right":c.value?i.value="center":d.value?i.value="justify":i.value="left"};s.watch([l,a,c,d],()=>{f()},{immediate:!0}),s.onMounted(()=>{e.editor&&(e.editor.on("selectionUpdate",f),e.editor.on("update",f))}),s.onUnmounted(()=>{e.editor&&(e.editor.off("selectionUpdate",f),e.editor.off("update",f))});const p=m=>{e.editor&&(e.editor.chain().focus().setTextAlign(m).run(),i.value=m)},h=s.ref([{id:"left",isActive:l},{id:"center",isActive:c},{id:"right",isActive:a},{id:"justify",isActive:d}]);return(m,g)=>(s.openBlock(),s.createBlock(Tr,{ref_key:"popover",ref:o,placement:"bottom",onIsvisible:g[0]||(g[0]=y=>r.value=y)},{reference:s.withCtx(()=>[s.createElementVNode("button",{title:"Text Align",class:s.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center text-gray-500 rounded-full hover:text-gray-900 hover:bg-gray-100",[u.value?"bg-gray-100 text-gray-900":"text-gray-500"]])},[(s.openBlock(),s.createBlock(s.resolveDynamicComponent(t[i.value]),{height:"16",width:"16"}))],2)]),default:s.withCtx(()=>[s.createElementVNode("div",r_,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(h.value,y=>(s.openBlock(),s.createElementBlock("button",{title:"Text align "+y?.id,class:s.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center text-gray-500 rounded hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":y?.isActive}]),key:y?.id,onClick:b=>p(y?.id)},[(s.openBlock(),s.createBlock(s.resolveDynamicComponent(t[y?.id]),{height:"16",width:"16"}))],10,o_))),128))])]),_:1},512))}},i_={components:{VsText:Qf},inheritAttrs:!1,events:["update:modelValue"],props:{modelValue:{type:String},disabled:{type:Boolean,default:()=>!1},clearable:{type:Boolean,default:()=>!1},isTextInputShown:{type:Boolean,default:()=>!0}},computed:{value:{get(){return this.modelValue??""},set(n){this.$emit("update:modelValue",n)}}}},l_={class:"flex items-center w-full max-w-[182px]"},a_=["disabled"];function c_(n,e,t,r,o,i){const l=s.resolveComponent("vs-text");return s.openBlock(),s.createElementBlock("div",l_,[s.withDirectives(s.createElementVNode("input",{"onUpdate:modelValue":e[0]||(e[0]=a=>i.value=a),type:"color",class:s.normalizeClass(["w-[38px] h-[38px] min-h-[38px] min-w-[38px] py-[2px] px-[3px] -ml-1 dark:bg-neutral-800 border dark:border-neutral-700 border-stone-200 rounded-lg",t.disabled?"cursor-not-allowed":"cursor-pointer"]),disabled:t.disabled},null,10,a_),[[s.vModelText,i.value]]),t.isTextInputShown?(s.openBlock(),s.createBlock(l,{key:0,modelValue:i.value,"onUpdate:modelValue":e[1]||(e[1]=a=>i.value=a),class:"ml-2 w-full",disabled:t.disabled,clearable:t.clearable},null,8,["modelValue","disabled","clearable"])):s.createCommentVNode("",!0)])}const ep=Ne(i_,[["render",c_]]),d_={class:"flex gap-[4px] mb-[8px]"},u_={class:"grid grid-rows-3 grid-cols-7"},f_={class:"w-full h-full rounded border border-gray-300 overflow-hidden"},p_=["onClick","title"],h_={__name:"vs-editor-color",props:{editor:Object},setup(n){const e=n,t=s.ref(null),r=s.ref("#000000"),o=s.computed(()=>e.editor&&e.editor.getAttributes("textStyle").color||"#000000"),i=s.computed(()=>o.value!=="#000000"),l=()=>{e.editor&&(r.value=o.value)};s.onMounted(()=>{e.editor&&(e.editor.on("selectionUpdate",l),e.editor.on("update",l),l())}),s.onUnmounted(()=>{e.editor&&(e.editor.off("selectionUpdate",l),e.editor.off("update",l))});const a=s.ref(["#172B4D","#0747A6","#008DA6","#006644","#FF991F","#BF2600","#403294","#97A0AF","#4C9AFF","#00B8D9","#36B37E","#FFC400","#FF5630","#6554C0","#FFFFFF","#B3D4FF","#B3F5FF","#ABF5D1","#FFF0B3","#FFBDAD","#EAE6FF"]),c=f=>{e.editor&&(e.editor.chain().focus().setColor(f).run(),r.value=f,t.value&&t.value.togglePopover())},d=()=>{c(r.value)},u=f=>({"#172B4D":"Default","#0747A6":"Bright blue","#008DA6":"Bright blue-green","#006644":"Bright green","#FF991F":"Bright orange","#BF2600":"Bright red","#403294":"Bright purple","#97A0AF":"Gray","#4C9AFF":"Blue","#00B8D9":"Blue-green","#36B37E":"Green","#FFC400":"Yellow","#FF5630":"Red","#6554C0":"Purple","#FFFFFF":"White","#B3D4FF":"Bright blue","#B3F5FF":"Bright blue-green","#ABF5D1":"Bright green","#FFF0B3":"Bright yellow","#FFBDAD":"Bright red","#EAE6FF":"Bright purple"})[f]||f;return(f,p)=>(s.openBlock(),s.createBlock(Tr,{ref_key:"popover",ref:t,placement:"bottom"},{reference:s.withCtx(()=>[s.createElementVNode("button",{title:"Text Color",class:s.normalizeClass(["flex flex-col h-[30px] min-w-[30px] px-1 rounded-full hover:bg-gray-100 justify-center items-center relative flex",{"bg-gray-100":i.value}])},[p[1]||(p[1]=s.createElementVNode("span",{class:"leading-none"},"A",-1)),s.createElementVNode("span",{class:"block h-1 w-5",style:s.normalizeStyle({backgroundColor:r.value})},null,4)],2)]),default:s.withCtx(()=>[s.createElementVNode("div",null,[s.createElementVNode("div",d_,[s.createVNode(ep,{modelValue:r.value,"onUpdate:modelValue":p[0]||(p[0]=h=>r.value=h)},null,8,["modelValue"]),s.createElementVNode("button",{onClick:d,class:"h-[38px] w-[38px] bg-blue-500 shrink-0 border rounded-md flex items-center justify-center hover:bg-blue-700 duration-300"},[s.createVNode(s.unref(Y.Check),{class:"h-4 w-4 text-white"})])]),s.createElementVNode("div",u_,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(a.value,h=>(s.openBlock(),s.createElementBlock("div",{key:h,class:"h-8 w-8 p-0.5 rounded border border-transparent hover:border-gray-200 transition-transform cursor-pointer"},[s.createElementVNode("div",f_,[s.createElementVNode("button",{class:"flex items-center justify-center w-full h-full",style:s.normalizeStyle({backgroundColor:h}),onClick:m=>c(h),title:u(h)},[r.value===h?(s.openBlock(),s.createBlock(s.unref(Y.Check),{key:0,class:"h-4 w-4 text-gray-500"})):s.createCommentVNode("",!0)],12,p_)])]))),128))])])]),_:1},512))}},m_={class:"flex gap-[4px] mb-[8px]"},g_={class:"grid grid-rows-3 grid-cols-7"},y_={class:"w-full h-full rounded border border-gray-300 overflow-hidden"},b_=["onClick","title"],k_=["onClick","title"],w_={__name:"vs-editor-background-color",props:{editor:Object},setup(n){const e=n,t=s.ref(null),r=s.ref("transparent"),o=s.computed(()=>e.editor&&e.editor.getAttributes("textStyle").backgroundColor||"transparent"),i=s.computed(()=>o.value!=="transparent"&&o.value!==""),l=()=>{e.editor&&(r.value=o.value)};s.onMounted(()=>{e.editor&&(e.editor.on("selectionUpdate",l),e.editor.on("update",l),l())}),s.onUnmounted(()=>{e.editor&&(e.editor.off("selectionUpdate",l),e.editor.off("update",l))});const a=s.ref(["#172B4D","#0747A6","#008DA6","#006644","#FF991F","#BF2600","#403294","#97A0AF","#4C9AFF","#00B8D9","#36B37E","#FFC400","#FF5630","#6554C0","#FFFFFF","#B3D4FF","#B3F5FF","#ABF5D1","#FFF0B3","#FFBDAD","#EAE6FF"]),c=f=>{e.editor&&(e.editor.chain().focus().setBackgroundColor(f).run(),r.value=f,t.value&&t.value.togglePopover())},d=()=>{c(r.value)},u=f=>({"#172B4D":"Default","#0747A6":"Bright blue","#008DA6":"Bright blue-green","#006644":"Bright green","#FF991F":"Bright orange","#BF2600":"Bright red","#403294":"Bright purple","#97A0AF":"Gray","#4C9AFF":"Blue","#00B8D9":"Blue-green","#36B37E":"Green","#FFC400":"Yellow","#FF5630":"Red","#6554C0":"Purple",transparent:"Transparent","#B3D4FF":"Bright blue","#B3F5FF":"Bright blue-green","#ABF5D1":"Bright green","#FFF0B3":"Bright yellow","#FFBDAD":"Bright red","#EAE6FF":"Bright purple"})[f]||f;return(f,p)=>(s.openBlock(),s.createBlock(Tr,{ref_key:"popover",ref:t,placement:"bottom"},{reference:s.withCtx(()=>[s.createElementVNode("button",{title:"Background Color",class:s.normalizeClass(["flex flex-col h-[30px] px-1 rounded-full hover:bg-gray-100 justify-center items-center relative flex",{"bg-gray-100":i.value}])},[s.createVNode(s.unref(Y.PaintBucket),{class:"h-4 w-4"}),s.createElementVNode("span",{class:"block h-1 w-5",style:s.normalizeStyle({backgroundColor:r.value})},null,4)],2)]),default:s.withCtx(()=>[s.createElementVNode("div",null,[s.createElementVNode("div",m_,[s.createVNode(ep,{modelValue:r.value,"onUpdate:modelValue":p[0]||(p[0]=h=>r.value=h)},null,8,["modelValue"]),s.createElementVNode("button",{onClick:d,class:"h-[38px] w-[38px] bg-blue-500 shrink-0 border rounded-md flex items-center justify-center hover:bg-blue-700 duration-300"},[s.createVNode(s.unref(Y.Check),{class:"h-4 w-4 text-white"})])]),s.createElementVNode("div",g_,[s.createElementVNode("button",{onClick:p[1]||(p[1]=h=>c("transparent")),class:"col-span-7 flex items-center justify-center gap-2 bg-gray-100 rounded-md py-1 mb-2 hover:bg-gray-200"},[s.createVNode(s.unref(Y.Eraser),{class:"h-4 w-4"}),p[2]||(p[2]=s.createElementVNode("p",null,"no color",-1))]),(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(a.value,h=>(s.openBlock(),s.createElementBlock("div",{key:h,class:"h-8 w-8 p-0.5 rounded border border-transparent hover:border-gray-200 transition-transform cursor-pointer"},[s.createElementVNode("div",y_,[h!=="transparent"?(s.openBlock(),s.createElementBlock("button",{key:0,class:"flex items-center justify-center w-full h-full",style:s.normalizeStyle({backgroundColor:h}),onClick:m=>c(h),title:u(h)},[r.value===h?(s.openBlock(),s.createBlock(s.unref(Y.Check),{key:0,class:"h-4 w-4 text-gray-500"})):s.createCommentVNode("",!0)],12,b_)):s.createCommentVNode("",!0),h==="transparent"?(s.openBlock(),s.createElementBlock("button",{key:1,class:"flex items-center justify-center w-full h-full",onClick:m=>c(h),title:u(h)},[r.value===h?(s.openBlock(),s.createBlock(s.unref(Y.Check),{key:0,class:"h-4 w-4 text-gray-500"})):s.createCommentVNode("",!0)],8,k_)):s.createCommentVNode("",!0)])]))),128))])])]),_:1},512))}},x_={__name:"vs-editor-highlight",props:{editor:Object},setup(n){const e=n,t=s.computed(()=>e.editor?.isActive("highlight")),r=()=>{e.editor&&e.editor.chain().focus().toggleHighlight().run()};return(o,i)=>(s.openBlock(),s.createElementBlock("button",{title:"Highlight",onClick:r,class:s.normalizeClass(["flex flex-col h-[30px] px-1 rounded-full hover:bg-gray-100 justify-center items-center relative flex",{"bg-gray-200":t.value}])},[s.createVNode(s.unref(Y.Highlighter),{class:"h-4 w-4"})],2))}},v_={class:"truncate"},C_={class:"w-[200px]"},S_={class:"max-h-[200px] overflow-y-auto"},E_=["onClick"],M_={__name:"vs-editor-font-family",props:{editor:Object},setup(n){const e=n,t=s.ref("popover"),r=s.ref(!1),o=s.ref([{label:"Arial",value:"Arial, sans-serif"},{label:"Helvetica",value:"Helvetica, sans-serif"},{label:"Times New Roman",value:"Times New Roman, serif"},{label:"Georgia",value:"Georgia, serif"},{label:"Verdana",value:"Verdana, sans-serif"},{label:"Courier New",value:"Courier New, monospace"},{label:"Comic Sans MS",value:"Comic Sans MS, cursive"},{label:"Impact",value:"Impact, sans-serif"},{label:"Trebuchet MS",value:"Trebuchet MS, sans-serif"},{label:"Palatino",value:"Palatino, serif"}]),i=s.computed(()=>{if(!e.editor)return"Arial, sans-serif";for(const d of o.value)if(e.editor.isActive("textStyle",{fontFamily:d.value}))return d.value;return"Arial, sans-serif"}),l=s.computed(()=>o.value.find(u=>u.value===i.value)?.label||"Arial"),a=d=>e.editor?e.editor.isActive("textStyle",{fontFamily:d}):!1,c=d=>{e.editor&&(e.editor.chain().focus().setFontFamily(d).run(),t.value&&t.value.togglePopover())};return(d,u)=>(s.openBlock(),s.createBlock(Tr,{ref_key:"popover",ref:t,placement:"bottom",onIsvisible:u[0]||(u[0]=f=>r.value=f)},{reference:s.withCtx(()=>[s.createElementVNode("button",{title:"Font Family",class:s.normalizeClass(["h-[30px] px-2 rounded-full hover:bg-gray-100 justify-center items-center flex text-sm",[r.value?"bg-gray-100 text-gray-900":"text-gray-700"]]),style:s.normalizeStyle({fontFamily:i.value})},[s.createElementVNode("span",v_,s.toDisplayString(l.value),1),s.createVNode(s.unref(Y.ChevronDown),{class:"ml-1 h-3 w-3 text-gray-400"})],6)]),default:s.withCtx(()=>[s.createElementVNode("div",C_,[s.createElementVNode("ul",S_,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(o.value,f=>(s.openBlock(),s.createElementBlock("li",{key:f.value,class:s.normalizeClass(["px-3 py-2 hover:bg-gray-100 cursor-pointer text-sm",{"bg-gray-100":a(f.value)}]),style:s.normalizeStyle({fontFamily:f.value}),onClick:p=>c(f.value)},s.toDisplayString(f.label),15,E_))),128))])])]),_:1},512))}},A_={class:"w-[120px]"},__={class:"max-h-[200px] overflow-y-auto"},T_=["onClick"],B_={__name:"vs-editor-font-size",props:{editor:Object},setup(n){const e=n,t=s.ref("popover"),r=s.ref("14px"),o=s.computed(()=>e.editor&&e.editor.getAttributes("textStyle").fontSize||"14px"),i=s.computed(()=>o.value!=="14px"),l=()=>{e.editor&&(r.value=o.value)};s.onMounted(()=>{e.editor&&(e.editor.on("selectionUpdate",l),e.editor.on("update",l),l())}),s.onUnmounted(()=>{e.editor&&(e.editor.off("selectionUpdate",l),e.editor.off("update",l))});const a=s.ref([{label:"8px",value:"8px"},{label:"9px",value:"9px"},{label:"10px",value:"10px"},{label:"11px",value:"11px"},{label:"12px",value:"12px"},{label:"14px",value:"14px"},{label:"16px",value:"16px"},{label:"18px",value:"18px"},{label:"20px",value:"20px"},{label:"24px",value:"24px"},{label:"28px",value:"28px"},{label:"32px",value:"32px"},{label:"36px",value:"36px"},{label:"48px",value:"48px"},{label:"72px",value:"72px"}]),c=d=>{e.editor&&(e.editor.chain().focus().setFontSize(d).run(),r.value=d,t.value&&t.value.togglePopover())};return(d,u)=>(s.openBlock(),s.createBlock(Tr,{ref_key:"popover",ref:t,placement:"bottom"},{reference:s.withCtx(()=>[s.createElementVNode("button",{title:"Font Size",class:s.normalizeClass(["h-[30px] px-2 min-w-[30px] rounded-full hover:bg-gray-100 justify-center items-center flex text-sm text-gray-700 space-x-1",{"bg-gray-100 text-gray-900":i.value}])},[s.createVNode(s.unref(Y.ALargeSmall),{class:"h-4 w-4"}),s.createVNode(s.unref(Y.ChevronDown),{class:"h-3 w-3 text-gray-400"})],2)]),default:s.withCtx(()=>[s.createElementVNode("div",A_,[s.createElementVNode("ul",__,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(a.value,f=>(s.openBlock(),s.createElementBlock("li",{key:f.value,class:"px-3 py-2 hover:bg-gray-100 cursor-pointer",onClick:p=>c(f.value)},s.toDisplayString(f.label),9,T_))),128))])])]),_:1},512))}},N_={components:{Superscript:Y.Superscript},props:{editor:Object},methods:{toggleSuperscript(){this.editor&&this.editor.commands.toggleSuperscript()}}};function D_(n,e,t,r,o,i){const l=s.resolveComponent("Superscript");return s.openBlock(),s.createElementBlock("button",{title:"Superscript",onClick:e[0]||(e[0]=(...a)=>i.toggleSuperscript&&i.toggleSuperscript(...a)),class:s.normalizeClass(["h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":t.editor?.isActive("superscript")}])},[s.createVNode(l,{class:"h-4 w-4"}),e[1]||(e[1]=s.createElementVNode("span",{class:"sr-only"},"Superscript",-1))],2)}const V_=Ne(N_,[["render",D_]]),$_={components:{Subscript:Y.Subscript},props:{editor:Object},methods:{toggleSubscript(){this.editor&&this.editor.commands.toggleSubscript()}}};function L_(n,e,t,r,o,i){const l=s.resolveComponent("Subscript");return s.openBlock(),s.createElementBlock("button",{title:"Subscript",onClick:e[0]||(e[0]=(...a)=>i.toggleSubscript&&i.toggleSubscript(...a)),class:s.normalizeClass(["h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":t.editor?.isActive("subscript")}])},[s.createVNode(l,{class:"h-4 w-4"}),e[1]||(e[1]=s.createElementVNode("span",{class:"sr-only"},"Subscript",-1))],2)}const I_=Ne($_,[["render",L_]]),O_={title:"Heading",class:"h-[30px] px-2 rounded-full hover:bg-gray-100 justify-center items-center flex text-sm text-gray-700"},R_={class:"truncate"},F_={class:"max-h-[200px] overflow-y-auto"},P_=["onClick"],z_=Ne({__name:"vs-editor-heading",props:{editor:Object},setup(n){const e=n,t=s.ref("popover"),r=s.ref([{label:"Heading 1",value:1},{label:"Heading 2",value:2},{label:"Heading 3",value:3},{label:"Heading 4",value:4},{label:"Heading 5",value:5},{label:"Heading 6",value:6}]),o=s.computed(()=>{if(!e.editor)return"Paragraph";for(let c=1;c<=6;c++)if(e.editor.isActive("heading",{level:c}))return`H ${c}`;return"P"}),i=c=>({1:"font-weight:700; font-size:30px;",2:"font-weight:700; font-size:26px;",3:"font-weight:700; font-size:22px;",4:"font-weight:700; font-size:18px;",5:"font-weight:500; font-size:16px;",6:"font-weight:400; font-size:14px;"})[c]||"",l=c=>{e.editor&&(e.editor.chain().focus().setHeading({level:c}).run(),t.value&&t.value.togglePopover())},a=()=>{e.editor&&(e.editor.chain().focus().setParagraph().run(),t.value&&t.value.togglePopover())};return(c,d)=>(s.openBlock(),s.createBlock(Tr,{ref_key:"popover",ref:t,placement:"bottom"},{reference:s.withCtx(()=>[s.createElementVNode("button",O_,[s.createElementVNode("span",R_,s.toDisplayString(o.value),1),s.createVNode(s.unref(Y.ChevronDown),{class:"ml-1 h-3 w-3 text-gray-400"})])]),default:s.withCtx(()=>[s.createElementVNode("div",null,[s.createElementVNode("ul",F_,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(r.value,u=>(s.openBlock(),s.createElementBlock("li",{key:u.value,class:s.normalizeClass(["px-3 py-2 hover:bg-gray-100 cursor-pointer text-sm",`heading-level-${u.value}`]),style:s.normalizeStyle(i(u.value)),onClick:f=>l(u.value)},s.toDisplayString(u.label),15,P_))),128)),s.createElementVNode("li",{class:"px-3 py-2 hover:bg-gray-100 cursor-pointer text-sm border-t border-gray-200 mt-1 pt-2",onClick:a}," Paragraph ")])])]),_:1},512))}},[["__scopeId","data-v-96f02f2a"]]),H_={components:{RemoveFormatting:Y.RemoveFormatting},props:{editor:Object},methods:{clearFormatting(){this.editor&&this.editor.commands.unsetAllMarks()}}};function j_(n,e,t,r,o,i){const l=s.resolveComponent("RemoveFormatting");return s.openBlock(),s.createElementBlock("button",{title:"Clear Formatting",onClick:e[0]||(e[0]=(...a)=>i.clearFormatting&&i.clearFormatting(...a)),class:"h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100"},[s.createVNode(l,{class:"h-4 w-4"}),e[1]||(e[1]=s.createElementVNode("span",{class:"sr-only"},"Clear Formatting",-1))])}const U_=Ne(H_,[["render",j_]]),W_={class:"relative"},K_={key:0,class:"mt-4"},q_=["src","alt","title"],G_={key:0,class:"text-sm text-red-500"},J_={key:1,class:"mt-4"},Y_={class:"text-sm text-gray-600 mb-2"},X_={class:"flex flex-wrap gap-2"},Z_=["src","alt","onError"],Q_=["onClick"],eT={class:"flex justify-end gap-x-2 p-[20px]"},tT=Object.assign({inheritAttrs:!1},{__name:"vs-editor-image",props:{editor:{type:Object,required:!0}},setup(n){const e=n,t=s.ref(!1),r=s.ref(!1),o=s.ref({}),i=s.ref(!1),l=s.ref([]),a=s.ref(null),c=s.ref({src:"",file:[],alt:"",title:"",width:"",height:"",link:"",openInNewTab:!1}),d=s.computed(()=>{if(Array.isArray(c.value.file)){const M=c.value.file.filter(L=>L instanceof File),_=c.value.file.filter(L=>typeof L=="string"&&L.trim()!=="");return M.length+_.length>1}return c.value.file instanceof FileList?c.value.file.length>1:!1}),u=s.computed(()=>Array.isArray(c.value.file)?c.value.file.filter(M=>M instanceof File).length===1:c.value.file instanceof FileList?c.value.file.length===1:c.value.file instanceof File),f=s.computed(()=>{if(d.value)return"";if(c.value.src)return c.value.src;if(u.value){let M=null;if(Array.isArray(c.value.file)||c.value.file instanceof FileList?M=c.value.file[0]:c.value.file instanceof File&&(M=c.value.file),M instanceof File){const _=l.value.find(A=>A.file===M);return _?_.preview:""}else if(typeof M=="string")return M}return""}),p=s.computed(()=>[{name:"src",label:"URL зображення",type:"text",required:!1,placeholder:"https://example.com/image.png"},{name:"file",label:"Файл (можна вибрати кілька)",type:"file",multiple:!0,required:!1,placeholder:"Шлях до файлу зображення",accept:"image/*"},{name:"width",label:"Ширина",type:"number",required:!1,placeholder:"Ширина зображення",clearable:!0,min:0},{name:"height",label:"Висота",type:"number",required:!1,placeholder:"Висота зображення",clearable:!0,min:0},{name:"alt",label:"Альтернативний текст",type:"text",required:!1,placeholder:"Опис зображення"},{name:"title",label:"Заголовок (необов'язково)",type:"text",required:!1,placeholder:"Заголовок зображення"},{name:"link",label:"Посилання",type:"text",required:!1,placeholder:"https://example.com"},{name:"openInNewTab",label:"Відкривати у новій вкладці?",type:"switcher",required:!1}]),h=()=>{if(!e.editor)return;if(e.editor.isActive("image")){const{state:_}=e.editor,{selection:A}=_,{$from:L}=A;let z=null,Z=null;if(L.parent.type.name==="image")z=L.before(L.depth),Z=L.parent;else for(let le=L.depth;le>0;le--){const H=L.node(le),$=L.before(le);H.type.name==="paragraph"&&H.forEach((I,te)=>{if(I.type.name==="image"){const ae=$+te+1;(z===null||Math.abs(ae-A.$from.pos)<Math.abs(z-A.$from.pos))&&(z=ae,Z=I)}})}if(z!==null&&Z){try{e.editor.chain().focus().setNodeSelection(z).run()}catch{e.editor.chain().focus().setTextSelection(z).run()}a.value=z}else{e.editor.chain().focus().selectParentNode().run();const{state:le}=e.editor;a.value=le.selection.$from.pos}const D=Z?Z.attrs:e.editor.getAttributes("image");i.value=!0;let P="",ne=!1;const U=e.editor.getAttributes("link");U&&U.href&&(P=U.href,ne=U.target==="_blank");const K=D.src||"",X=K?[K]:[];c.value={src:K,file:X,alt:D.alt||"",title:D.title||"",width:D.width||"",height:D.height||"",link:P,openInNewTab:ne}}else i.value=!1,c.value={src:"",file:[],alt:"",title:"",width:"",height:"",link:"",openInNewTab:!1};r.value=!1,t.value=!0},m=()=>{t.value=!1,r.value=!1,i.value=!1,l.value=[],a.value=null,c.value={src:"",file:[],alt:"",title:"",width:"",height:"",link:"",openInNewTab:!1}},g=async M=>{if(!M||M.length===0)return;const _=[];for(const A of M)if(A&&A.type&&A.type.startsWith("image/")&&!l.value.some(z=>z.file===A)){const z=new Promise((Z,D)=>{const P=new FileReader;P.onload=ne=>{l.value.push({file:A,preview:ne.target.result,error:!1}),Z()},P.onerror=D,P.readAsDataURL(A)});_.push(z)}await Promise.all(_)},y=M=>{l.value.splice(M,1),Array.isArray(c.value.file)&&c.value.file.splice(M,1)},b=()=>{const M=c.value.width!==null&&c.value.width!==void 0&&c.value.width!==""&&String(c.value.width).trim()!==""?String(c.value.width).trim():"",_=c.value.height!==null&&c.value.height!==void 0&&c.value.height!==""&&String(c.value.height).trim()!==""?String(c.value.height).trim():"",A={};return M&&_?(A.width=M,A.height=_,A.style=`width: ${M}px; height: ${_}px; object-fit: fill;`):M?(A.width=M,A.height=void 0):_?(A.height=_,A.width=void 0):(A.width=void 0,A.height=void 0),A},w=(M,_=null,A=50)=>{const L=()=>{const{view:D}=M;if(!D||!D.dom)return;D.dom.querySelectorAll("img.editor-image[width][height]").forEach(U=>{if(U instanceof HTMLImageElement){const K=U.getAttribute("width"),X=U.getAttribute("height");K&&X&&K!=="auto"&&X!=="auto"&&K!==""&&X!==""&&!isNaN(Number(K))&&!isNaN(Number(X))&&(U.style.cssText=`
36
+ width: ${K}px !important;
37
+ height: ${X}px !important;
38
38
  max-width: none !important;
39
39
  max-height: none !important;
40
40
  min-width: auto !important;
41
41
  min-height: auto !important;
42
42
  object-fit: fill !important;
43
- `.replace(/\s+/g," ").trim())}})},j=i.value.width,te=i.value.height;j&&te&&j!==""&&te!==""?[0,v,v*2,v*3,v*4].forEach(U=>{setTimeout(T,U)}):(T(),setTimeout(T,v))},N=async()=>{let E=[],V=[];if(Array.isArray(i.value.file)?(E=i.value.file.filter(D=>D instanceof File),V=i.value.file.filter(D=>typeof D=="string"&&D.trim()!=="")):i.value.file instanceof FileList?E=Array.from(i.value.file):i.value.file instanceof File?E=[i.value.file]:typeof i.value.file=="string"&&i.value.file.trim()!==""&&(V=[i.value.file]),E.length===0&&V.length===0&&a.value&&a.value.file){const D=a.value.file;Array.isArray(D)?(E=D.filter(U=>U instanceof File),V=D.filter(U=>typeof U=="string"&&U.trim()!=="")):D instanceof FileList?E=Array.from(D):D instanceof File?E=[D]:typeof D=="string"&&D.trim()!==""&&(V=[D])}if(V.length>0&&!l.value){for(const D of V)s.value.some(U=>U.url===D)||s.value.push({url:D,preview:D,error:!1});if(E.length===0&&s.value.length>0){await q();return}}const v=E.length,T=v+V.length;if(!(l.value&&v<=1)){if(v>0){const D=E.filter(U=>!s.value.some(oe=>oe.file===U));D.length>0&&await k(D)}}if(!l.value){if(T>1||d.value||s.value.length>1){if(s.value.length>0){await q();return}else if(v>0){if(await k(E),s.value.length>0){await q();return}}else if(V.length>0){await q();return}}else if(s.value.length>1){await q();return}}let j=i.value.src;if(h.value){let D=null;if(Array.isArray(i.value.file)||i.value.file instanceof FileList?D=i.value.file[0]:(i.value.file instanceof File||typeof i.value.file=="string")&&(D=i.value.file),D instanceof File)try{const U=new FileReader,oe=await new Promise((R,H)=>{U.onload=Z=>R(Z.target.result),U.onerror=H,U.readAsDataURL(D)});j=oe,l.value&&(i.value.src=oe)}catch(U){console.error("Помилка при читанні файлу:",U),he.notify({type:"error",title:"Помилка",message:"Не вдалося прочитати файл"});return}else typeof D=="string"&&D.trim()!==""&&(j=D.trim(),l.value&&D.trim()!==i.value.src&&(i.value.src=D.trim(),j=D.trim()))}else if(Array.isArray(i.value.file)&&i.value.file.length===1){const D=i.value.file[0];typeof D=="string"&&D.trim()!==""&&(j=D.trim(),(!i.value.src||i.value.src!==D.trim())&&(i.value.src=D.trim()))}else typeof i.value.file=="string"&&i.value.file.trim()!==""&&(j=i.value.file.trim(),(!i.value.src||i.value.src!==i.value.file.trim())&&(i.value.src=i.value.file.trim()));const te=j||Array.isArray(i.value.file)&&i.value.file.length>0&&(i.value.file.some(D=>D instanceof File)||i.value.file.some(D=>typeof D=="string"&&D.trim()!==""))||i.value.file instanceof FileList&&i.value.file.length>0||typeof i.value.file=="string"&&i.value.file.trim()!=="";if(!j&&!te){he.notify({type:"warning",title:"Попередження",message:"Будь ласка, введіть URL зображення або виберіть файл"});return}if(!d.value&&!te&&await a.value.validate()){he.notify({type:"warning",title:"Попередження",message:"Будь ласка, заповніть всі обов'язкові поля"});return}if(t.editor&&j)if(l.value&&c.value!==null){const{state:D}=t.editor;try{t.editor.chain().focus().setNodeSelection(c.value).run()}catch{t.editor.chain().focus().setTextSelection(c.value).run()}const U=t.editor.getAttributes("link"),oe=U&&U.href,R=_(),H={src:j,alt:i.value.alt||"",title:i.value.title||"",...R};if((!i.value.width||i.value.width==="")&&(H.width=void 0),(!i.value.height||i.value.height==="")&&(H.height=void 0),t.editor.chain().focus().updateAttributes("image",H).run(),setTimeout(()=>{const{view:Z}=t.editor;if(!Z||!Z.dom)return;Z.dom.querySelectorAll("img.editor-image").forEach(A=>{if(A instanceof HTMLImageElement){const M=A.getAttribute("src")||A.src;(M===j||M.includes(j.split("/").pop()))&&(i.value.width&&i.value.height?(A.style.setProperty("width",`${i.value.width}px`,"important"),A.style.setProperty("height",`${i.value.height}px`,"important"),A.style.setProperty("object-fit","fill","important"),A.style.setProperty("max-width","none","important"),A.style.setProperty("max-height","none","important")):(A.style.removeProperty("width"),A.style.removeProperty("height"),A.style.removeProperty("object-fit"),A.style.removeProperty("max-width"),A.style.removeProperty("max-height")))}})},20),i.value.link&&i.value.link.trim()!==""){let Z=i.value.link.trim();Z.match(/^https?:\/\//i)||(Z="https://"+Z),oe?t.editor.chain().focus().extendMarkRange("link").setLink({href:Z,target:i.value.openInNewTab?"_blank":null}).run():t.editor.chain().focus().selectParentNode().setLink({href:Z,target:i.value.openInNewTab?"_blank":null}).run()}else oe&&t.editor.chain().focus().extendMarkRange("link").unsetLink().run()}else{const{state:D}=t.editor,{selection:U}=D,{$anchor:oe}=U;let R=null;for(let Z=oe.depth;Z>0;Z--){const ae=oe.node(Z);if(ae&&ae.type.name==="paragraph"){R=ae;break}}if(R&&R.content.content.some(Z=>Z.type.name==="image")){const Z=$(R,oe.before(oe.depth));if(Z!==null){const ae=_(),O=D.schema.nodes.image.create({src:j,alt:i.value.alt||"",title:i.value.title||"",...ae});if(i.value.link&&i.value.link.trim()!==""){let A=i.value.link.trim();A.match(/^https?:\/\//i)||(A="https://"+A);const M=D.schema.marks.link.create({href:A,target:i.value.openInNewTab?"_blank":null}),Q=O.type.create(O.attrs,O.content,[M]);t.editor.chain().focus().insertContentAt(Z+1,Q).run(),C(t.editor,j)}else t.editor.chain().focus().insertContentAt(Z+1,O).run(),C(t.editor,j)}else if(i.value.link&&i.value.link.trim()!==""){const ae=_();t.editor.chain().focus().setImage({src:j,alt:i.value.alt||"",title:i.value.title||"",...ae}).run(),setTimeout(()=>{let O=i.value.link.trim();O.match(/^https?:\/\//i)||(O="https://"+O),t.editor.chain().focus().selectParentNode().setLink({href:O,target:i.value.openInNewTab?"_blank":null}).run(),C(t.editor,j,20)},10)}else{const ae=_();t.editor.chain().focus().setImage({src:j,alt:i.value.alt||"",title:i.value.title||"",...ae}).run(),C(t.editor,j)}}else if(i.value.link&&i.value.link.trim()!==""){const Z=_();t.editor.chain().focus().setImage({src:j,alt:i.value.alt||"",title:i.value.title||"",...Z}).run(),setTimeout(()=>{let ae=i.value.link.trim();ae.match(/^https?:\/\//i)||(ae="https://"+ae),t.editor.chain().focus().selectParentNode().setLink({href:ae,target:i.value.openInNewTab?"_blank":null}).run(),C(t.editor,j,20)},10)}else{const Z=_();t.editor.chain().focus().setImage({src:j,alt:i.value.alt||"",title:i.value.title||"",...Z}).run(),C(t.editor,j)}}m()},$=(E,V)=>{let v=null;return E.forEach((T,j)=>{T.type.name==="image"&&(v=V+j+1)}),v},q=async()=>{if(t.editor){if(s.value.length===0)if(Array.isArray(i.value.file)&&i.value.file.length>0){const E=i.value.file.filter(v=>typeof v=="string"&&v.trim()!==""),V=i.value.file.filter(v=>v instanceof File);for(const v of E)s.value.some(T=>T.url===v||T.preview===v)||s.value.push({url:v,preview:v,error:!1});V.length>0&&await k(V)}else d.value&&await k(i.value.file);if(s.value.length!==0)try{const E=[],V=_();for(const v of s.value){const T=v.url||v.preview||"";if(!T)continue;const j=t.editor.schema.nodes.image.create({src:T,alt:i.value.alt||"",title:i.value.title||"",...V});E.push(j)}E.length>0&&(t.editor.chain().focus().command(({tr:v,dispatch:T})=>{if(T){const{selection:j}=v,{$anchor:te}=j;let D=j.$anchor.pos,U=null,oe=null;for(let H=te.depth;H>0;H--){const Z=te.node(H);if(Z&&Z.type.name==="paragraph"){U=Z,oe=te.start(H);break}}if(U){let H=null;U.forEach((Z,ae)=>{Z.type.name==="image"&&(H=oe+ae+1)}),H!==null?D=H+1:D=oe+U.content.size}let R=D;return E.forEach(H=>{v.insert(R,H),R+=H.nodeSize}),!0}return!1}).run(),i.value.width&&i.value.height&&setTimeout(()=>{const{view:v}=t.editor;v&&v.dom&&v.dom.querySelectorAll("img.editor-image").forEach(te=>{te instanceof HTMLImageElement&&Array.from(s.value).some(U=>{const oe=U.url||U.preview||"",R=te.src||te.getAttribute("src")||"";return R===oe||R.includes(oe.split("/").pop())})&&(te.style.setProperty("width",`${i.value.width}px`,"important"),te.style.setProperty("height",`${i.value.height}px`,"important"),te.style.setProperty("object-fit","fill","important"),te.style.setProperty("max-width","none","important"),te.style.setProperty("max-height","none","important"))})},50)),m()}catch(E){console.error("Помилка при додаванні зображень:",E),he.notify({type:"error",title:"Помилка",message:"Не вдалося додати зображення"})}}},G=async()=>{await N()},I=()=>{m()};return e.watch(()=>i.value.file,async(E,V)=>{if(r.value=!1,!(l.value&&Array.isArray(E)&&E.length===1&&typeof E[0]=="string"&&!E.some(T=>T instanceof File)))if(Array.isArray(E)&&E.length>0){const v=E.filter(j=>j instanceof File),T=E.filter(j=>typeof j=="string"&&j.trim()!=="");if(v.length>0&&(l.value?l.value&&v.length===1&&T.length===0&&(s.value=[]):s.value=[],(!l.value||v.length>1||T.length>0)&&await k(v),l.value&&v.length===1&&T.length===0)){const j=new FileReader;j.onload=te=>{i.value.src=te.target.result},j.readAsDataURL(v[0])}if(T.length>0)if(l.value)l.value&&T.length===1&&v.length===0&&(i.value.src=T[0]);else{v.length===0&&(s.value=[]);for(const j of T)s.value.some(te=>te.url===j||te.preview===j)||s.value.push({url:j,preview:j,error:!1})}}else E&&typeof E=="object"&&E instanceof FileList?(l.value||(s.value=[]),await k(Array.from(E))):E&&typeof E=="object"&&!Array.isArray(E)&&E instanceof File?(l.value||(s.value=[]),await k([E])):l.value||(s.value=[])},{immediate:!1}),e.watch(()=>i.value.src,()=>{r.value=!1}),(E,V)=>(e.openBlock(),e.createElementBlock("div",R0,[e.createElementVNode("button",{onClick:f,class:e.normalizeClass(["h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100",o.editor?.isActive("image")?"bg-gray-200 text-gray-900":""]),title:"Додати зображення"},[e.createVNode(e.unref(X.Image),{class:"h-4 w-4"}),V[4]||(V[4]=e.createElementVNode("span",{class:"sr-only"},"Додати зображення",-1))],2),e.createVNode(Nl,{modelValue:n.value,"onUpdate:modelValue":V[3]||(V[3]=v=>n.value=v),title:l.value?"Редагувати зображення":"Додати зображення"},{footer:e.withCtx(()=>[e.createElementVNode("div",Y0,[e.createElementVNode("button",{onClick:I,type:"button",class:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500"}," Скасувати "),e.createElementVNode("button",{onClick:G,type:"button",class:"px-4 py-2 text-sm font-medium text-white bg-blue-600 border border-transparent rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500"},e.toDisplayString(l.value?"Оновити зображення":"Додати зображення"),1)])]),default:e.withCtx(()=>[e.createVNode(ot,{modelValue:i.value,"onUpdate:modelValue":V[0]||(V[0]=v=>i.value=v),schema:p.value,form:a.value,"onUpdate:form":V[1]||(V[1]=v=>a.value=v)},null,8,["modelValue","schema","form"]),g.value&&!d.value?(e.openBlock(),e.createElementBlock("div",z0,[V[5]||(V[5]=e.createElementVNode("p",{class:"text-sm text-gray-600 mb-2"},"Попередній перегляд:",-1)),e.withDirectives(e.createElementVNode("img",{src:g.value,alt:i.value.alt||"Попередній перегляд зображення",title:i.value.title,class:"max-w-full h-auto max-h-32 rounded border",onError:V[2]||(V[2]=v=>r.value=!0)},null,40,j0),[[e.vShow,!r.value]]),r.value?(e.openBlock(),e.createElementBlock("p",U0," Не вдалося завантажити попередній перегляд зображення ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),s.value.length>0?(e.openBlock(),e.createElementBlock("div",H0,[e.createElementVNode("p",q0,"Попередній перегляд ("+e.toDisplayString(s.value.length)+" зображень):",1),V[6]||(V[6]=e.createElementVNode("p",{class:"text-xs text-gray-500 mb-2"}," Зображення будуть розміщені в ряд, якщо вони помістяться по ширині ",-1)),e.createElementVNode("div",W0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value,(v,T)=>(e.openBlock(),e.createElementBlock("div",{key:T,class:"relative"},[e.withDirectives(e.createElementVNode("img",{src:v.preview,alt:`Попередній перегляд ${T+1}`,class:"max-w-[100px] max-h-[100px] rounded border object-contain",onError:j=>v.error=!0},null,40,K0),[[e.vShow,!v.error]]),e.createElementVNode("button",{onClick:j=>b(T),class:"absolute -top-2 -right-2 bg-red-500 text-white rounded-full w-5 h-5 flex items-center justify-center text-xs hover:bg-red-600",type:"button"}," × ",8,G0)]))),128))])])):e.createCommentVNode("",!0)]),_:1},8,["modelValue","title"])]))}}),Z0={class:"flex items-center"},J0=["disabled"],Q0=["disabled"],eb=Ce(Object.assign({inheritAttrs:!1},{__name:"vs-editor-history",props:{editor:Object},setup(o){const t=o,n=()=>{t.editor?.can().undo()&&t.editor.chain().focus().undo().run()},r=()=>{t.editor?.can().redo()&&t.editor.chain().focus().redo().run()};return(a,l)=>(e.openBlock(),e.createElementBlock("div",Z0,[e.createElementVNode("button",{onClick:n,class:e.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center rounded-l-full hover:text-gray-900 hover:bg-gray-100 border-r border-gray-200",[o.editor?.can().undo()?"text-gray-500":"text-gray-300 cursor-not-allowed"]]),disabled:!o.editor?.can().undo(),title:"Undo (Ctrl+Z)"},[e.createVNode(e.unref(X.Undo2),{class:"h-4 w-4"})],10,J0),e.createElementVNode("button",{onClick:r,class:e.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center rounded-r-full hover:text-gray-900 hover:bg-gray-100",[o.editor?.can().redo()?"text-gray-500":"text-gray-300 cursor-not-allowed"]]),disabled:!o.editor?.can().redo(),title:"Redo (Ctrl+Y)"},[e.createVNode(e.unref(X.Redo2),{class:"h-4 w-4"})],10,Q0)]))}}),[["__scopeId","data-v-6a87fc55"]]),tb={class:"relative"},nb={class:"p-6"},ob={class:"flex justify-between items-center mb-4"},rb={bold:by,italic:xy,color:c0,background_color:h0,highlight:g0,bullet_list:cy,ordered_list:py,blockquote:ay,codeblock:hy,underline:vy,strike:_y,link:Wy,table:Zy,text_align:e0,font_family:x0,font_size:E0,superscript:S0,subscript:N0,heading:L0,clear_formatting:P0,image:X0,history:eb,help:Ce(Object.assign({inheritAttrs:!1},{__name:"vs-editor-help",props:{editor:Object},setup(o){const t=e.ref(!1),n=e.ref(null),r=()=>{t.value=!t.value},a=()=>{t.value=!1};return(l,s)=>(e.openBlock(),e.createElementBlock("div",tb,[e.createElementVNode("button",{ref_key:"helpButton",ref:n,onClick:r,class:e.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100 text-gray-500",[t.value?"bg-gray-100 text-gray-900":"text-gray-500"]]),title:"Markdown Shortcuts Help"},[e.createVNode(e.unref(X.CircleHelp),{class:"h-4 w-4"})],2),t.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[100001]",onClick:a},[e.createElementVNode("div",{class:"bg-white rounded-lg shadow-xl max-w-2xl w-full mx-4 max-h-[80vh] overflow-y-auto",onClick:s[0]||(s[0]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",nb,[e.createElementVNode("div",ob,[s[1]||(s[1]=e.createElementVNode("h2",{class:"text-xl font-semibold text-gray-900"},"Common Markdown Syntax & Shortcuts",-1)),e.createElementVNode("button",{onClick:a,class:"text-gray-400 hover:text-gray-600 transition-colors"},[e.createVNode(e.unref(X.X),{class:"h-6 w-6"})])]),s[2]||(s[2]=e.createStaticVNode('<div class="space-y-6" data-v-92c21275><div data-v-92c21275><h3 class="text-lg font-medium text-gray-800 mb-3" data-v-92c21275>Markdown Syntax</h3><div class="overflow-x-auto" data-v-92c21275><table class="w-full border-collapse" data-v-92c21275><thead data-v-92c21275><tr class="bg-gray-50" data-v-92c21275><th class="border border-gray-200 px-3 py-2 text-left font-medium text-gray-700" data-v-92c21275>Element</th><th class="border border-gray-200 px-3 py-2 text-left font-medium text-gray-700" data-v-92c21275>Example</th></tr></thead><tbody class="text-sm" data-v-92c21275><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Bold</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>**bold text**</code> or <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>__bold text__</code></td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Italics</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>*italic text*</code> or <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>_italic text_</code></td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Strikethrough</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>~strikethrough text~</code></td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Headings</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275># Heading 1</code>, <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>## Heading 2</code>, etc., up to <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>###### Heading 6</code></td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Unordered Lists</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Use an asterisk (*), dash (-), or plus sign (+) followed by a space. </td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Ordered Lists</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Use a number followed by a period and a space (e.g., <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>1. First item</code>). </td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Blockquotes</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Start with a greater-than sign (&gt;) followed by a space. </td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Inline Code</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Surround with backticks (<code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>`</code>). </td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Code Blocks</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Enclose with three backticks (<code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>```</code>) before and after the code. </td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Images</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Use <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>![alt text](url)</code> syntax. </td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Links</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Use <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>[Link Text](url)</code> syntax. </td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Checklists</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Create a list item with <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>- [ ]</code> for an incomplete task or <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>- [x]</code> for a completed one. </td></tr></tbody></table></div></div><div data-v-92c21275><h3 class="text-lg font-medium text-gray-800 mb-3" data-v-92c21275>Common Editing Shortcuts</h3><div class="overflow-x-auto" data-v-92c21275><table class="w-full border-collapse" data-v-92c21275><thead data-v-92c21275><tr class="bg-gray-50" data-v-92c21275><th class="border border-gray-200 px-3 py-2 text-left font-medium text-gray-700" data-v-92c21275>Shortcut</th><th class="border border-gray-200 px-3 py-2 text-left font-medium text-gray-700" data-v-92c21275>Action</th></tr></thead><tbody class="text-sm" data-v-92c21275><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+A</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Select all text</td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+B</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Apply bold formatting</td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+C</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Copy selected text</td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+I</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Apply italic formatting</td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+K</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Open the insert link dialog</td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+S</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Save the current document</td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+V</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Paste copied text</td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+X</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Cut selected text</td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+Y</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Redo the last action</td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Alt+Shift+Backspace</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Redo the last action</td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+Z</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Undo the last action</td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Alt+Backspace</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Undo the last action</td></tr></tbody></table></div></div></div>',1))])])])):e.createCommentVNode("",!0)]))}}),[["__scopeId","data-v-92c21275"]]),horizontal_rule:{__name:"vs-editor-horizontal-rule",props:{editor:Object},setup(o){const t=o,n=()=>{t.editor&&t.editor.chain().focus().setHorizontalRule().run()};return(r,a)=>(e.openBlock(),e.createElementBlock("button",{title:"Horizontal Rule",onClick:n,class:"flex flex-col h-[30px] px-1 rounded-full hover:bg-gray-100 justify-center items-center relative flex"},[e.createVNode(e.unref(X.Minus),{class:"h-4 w-4"})]))}},fullscreen:{__name:"vs-editor-fullscreen",props:{editor:Object},emits:["toggle-fullscreen"],setup(o,{emit:t}){const n=t,r=()=>{n("toggle-fullscreen")};return(a,l)=>(e.openBlock(),e.createElementBlock("button",{title:"Fullscreen",onClick:r,class:"w-[30px] h-[30px] flex items-center justify-center text-gray-500 rounded-full hover:text-gray-900 hover:bg-gray-100"},[e.createVNode(e.unref(X.Maximize),{class:"h-4 w-4"})]))}}},Dl={basic:["history","font_family","font_size","bold","italic","underline","strike","text_align","bullet_list","ordered_list","link","image","clear_formatting","help"],default:["history","heading","font_family","font_size","bold","italic","underline","strike","superscript","subscript","color","background_color","highlight","text_align","bullet_list","ordered_list","blockquote","codeblock","table","link","image","horizontal_rule","clear_formatting","fullscreen","help"],full:["history","heading","font_family","font_size","bold","italic","underline","strike","color","background_color","highlight","text_align","bullet_list","ordered_list","blockquote","codeblock","table","link","image","horizontal_rule","superscript","subscript","clear_formatting","fullscreen","help"]},lb={class:"flex align-middle gap-x-0.5 border-b flex-wrap border-b-gray-200 px-[10px] py-[6px] border-solid border-transparent"},ab={class:"editor-body"},sb={key:0,class:"richtext-loading text-sm text-gray-500"},ib={key:1,class:"richtext-error text-sm text-red-600"},cb={class:"html-source-editor"},db={class:"flex justify-end border-t border-[#e5e7eb] bg-[#f8fafc] px-4 min-h-[38px] items-start overflow-visible"},ub={class:"inline-flex items-stretch -mt-px"},pb=Object.freeze(Object.defineProperty({__proto__:null,default:Object.assign({inheritAttrs:!1},{__name:"vs-richtext",props:e.mergeModels({modelValue:{type:String,default:()=>""},height:{type:String,default:()=>"300px"},format:{type:String,default:()=>"html"},toolbar:{type:[Array,String],default:()=>"default"}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.ref(null),a=e.ref(null),l=e.shallowRef(null),s=e.ref(!1),c=e.ref(""),i=e.ref(!1),d=e.ref(null),h=e.ref(""),g=e.ref(""),p=e.ref(null),f=e.ref(!1),m=e.ref(!1),{isFullscreen:k,toggleFullscreen:b}=Mg(),{t:_}=Uo(),C=e.computed(()=>t.format==="md"?"markdown":"html"),N=e.computed(()=>t.format==="md"?_("form.richtext.markdown"):_("form.richtext.html")),$=e.computed(()=>l.value||null),q=e.computed(()=>typeof t.toolbar=="string"?Dl[t.toolbar]||Dl.default:t.toolbar),G=e.computed(()=>q.value.map(A=>rb[A]).filter(Boolean)),I=e.computed(()=>(d.value?.attributes||[]).find(M=>M.name==="class")?.value||""),E=e.computed(()=>{const M=(d.value?.attributes||[]).find(se=>se.name==="style")?.value||"",Q={};return M.split(";").forEach(se=>{const[ee,...me]=se.split(":"),ke=ee?.trim(),ge=me.join(":").trim();!ke||!ge||ke!=="height"&&(Q[ke.replace(/-([a-z])/g,(Se,Ne)=>Ne.toUpperCase())]=ge)}),Q}),V=A=>{const M=(A||"").trim();return M?/^<p(?:\s+[^>]*)?>(?:\s|<br[^>]*>)*<\/p>$/i.test(M):!0},v=A=>V(A)?"":A||"",T=A=>{const M=A||"";p.value=M,n.value=M},j=A=>{if(!A||!A.view||!A.view.dom)return;A.view.dom.querySelectorAll("img.editor-image[width][height]").forEach(Q=>{if(Q instanceof HTMLImageElement){const se=Q.getAttribute("width"),ee=Q.getAttribute("height");se&&ee&&se!=="auto"&&ee!=="auto"&&se!==""&&ee!==""&&!isNaN(Number(se))&&!isNaN(Number(ee))&&(Q.style.cssText=`
44
- width: ${se}px !important;
45
- height: ${ee}px !important;
43
+ `.replace(/\s+/g," ").trim())}})},z=c.value.width,Z=c.value.height;z&&Z&&z!==""&&Z!==""?[0,A,A*2,A*3,A*4].forEach(P=>{setTimeout(L,P)}):(L(),setTimeout(L,A))},v=async()=>{let M=[],_=[];if(Array.isArray(c.value.file)?(M=c.value.file.filter(D=>D instanceof File),_=c.value.file.filter(D=>typeof D=="string"&&D.trim()!=="")):c.value.file instanceof FileList?M=Array.from(c.value.file):c.value.file instanceof File?M=[c.value.file]:typeof c.value.file=="string"&&c.value.file.trim()!==""&&(_=[c.value.file]),M.length===0&&_.length===0&&o.value&&o.value.file){const D=o.value.file;Array.isArray(D)?(M=D.filter(P=>P instanceof File),_=D.filter(P=>typeof P=="string"&&P.trim()!=="")):D instanceof FileList?M=Array.from(D):D instanceof File?M=[D]:typeof D=="string"&&D.trim()!==""&&(_=[D])}if(_.length>0&&!i.value){for(const D of _)l.value.some(P=>P.url===D)||l.value.push({url:D,preview:D,error:!1});if(M.length===0&&l.value.length>0){await N();return}}const A=M.length,L=A+_.length;if(!(i.value&&A<=1)){if(A>0){const D=M.filter(P=>!l.value.some(ne=>ne.file===P));D.length>0&&await g(D)}}if(!i.value){if(L>1||d.value||l.value.length>1){if(l.value.length>0){await N();return}else if(A>0){if(await g(M),l.value.length>0){await N();return}}else if(_.length>0){await N();return}}else if(l.value.length>1){await N();return}}let z=c.value.src;if(u.value){let D=null;if(Array.isArray(c.value.file)||c.value.file instanceof FileList?D=c.value.file[0]:(c.value.file instanceof File||typeof c.value.file=="string")&&(D=c.value.file),D instanceof File)try{const P=new FileReader,ne=await new Promise((U,K)=>{P.onload=X=>U(X.target.result),P.onerror=K,P.readAsDataURL(D)});z=ne,i.value&&(c.value.src=ne)}catch(P){console.error("Помилка при читанні файлу:",P),we.notify({type:"error",title:"Помилка",message:"Не вдалося прочитати файл"});return}else typeof D=="string"&&D.trim()!==""&&(z=D.trim(),i.value&&D.trim()!==c.value.src&&(c.value.src=D.trim(),z=D.trim()))}else if(Array.isArray(c.value.file)&&c.value.file.length===1){const D=c.value.file[0];typeof D=="string"&&D.trim()!==""&&(z=D.trim(),(!c.value.src||c.value.src!==D.trim())&&(c.value.src=D.trim()))}else typeof c.value.file=="string"&&c.value.file.trim()!==""&&(z=c.value.file.trim(),(!c.value.src||c.value.src!==c.value.file.trim())&&(c.value.src=c.value.file.trim()));const Z=z||Array.isArray(c.value.file)&&c.value.file.length>0&&(c.value.file.some(D=>D instanceof File)||c.value.file.some(D=>typeof D=="string"&&D.trim()!==""))||c.value.file instanceof FileList&&c.value.file.length>0||typeof c.value.file=="string"&&c.value.file.trim()!=="";if(!z&&!Z){we.notify({type:"warning",title:"Попередження",message:"Будь ласка, введіть URL зображення або виберіть файл"});return}if(!d.value&&!Z&&await o.value.validate()){we.notify({type:"warning",title:"Попередження",message:"Будь ласка, заповніть всі обов'язкові поля"});return}if(e.editor&&z)if(i.value&&a.value!==null){const{state:D}=e.editor;try{e.editor.chain().focus().setNodeSelection(a.value).run()}catch{e.editor.chain().focus().setTextSelection(a.value).run()}const P=e.editor.getAttributes("link"),ne=P&&P.href,U=b(),K={src:z,alt:c.value.alt||"",title:c.value.title||"",...U};if((!c.value.width||c.value.width==="")&&(K.width=void 0),(!c.value.height||c.value.height==="")&&(K.height=void 0),e.editor.chain().focus().updateAttributes("image",K).run(),setTimeout(()=>{const{view:X}=e.editor;if(!X||!X.dom)return;X.dom.querySelectorAll("img.editor-image").forEach($=>{if($ instanceof HTMLImageElement){const I=$.getAttribute("src")||$.src;(I===z||I.includes(z.split("/").pop()))&&(c.value.width&&c.value.height?($.style.setProperty("width",`${c.value.width}px`,"important"),$.style.setProperty("height",`${c.value.height}px`,"important"),$.style.setProperty("object-fit","fill","important"),$.style.setProperty("max-width","none","important"),$.style.setProperty("max-height","none","important")):($.style.removeProperty("width"),$.style.removeProperty("height"),$.style.removeProperty("object-fit"),$.style.removeProperty("max-width"),$.style.removeProperty("max-height")))}})},20),c.value.link&&c.value.link.trim()!==""){let X=c.value.link.trim();X.match(/^https?:\/\//i)||(X="https://"+X),ne?e.editor.chain().focus().extendMarkRange("link").setLink({href:X,target:c.value.openInNewTab?"_blank":null}).run():e.editor.chain().focus().selectParentNode().setLink({href:X,target:c.value.openInNewTab?"_blank":null}).run()}else ne&&e.editor.chain().focus().extendMarkRange("link").unsetLink().run()}else{const{state:D}=e.editor,{selection:P}=D,{$anchor:ne}=P;let U=null;for(let X=ne.depth;X>0;X--){const le=ne.node(X);if(le&&le.type.name==="paragraph"){U=le;break}}if(U&&U.content.content.some(X=>X.type.name==="image")){const X=E(U,ne.before(ne.depth));if(X!==null){const le=b(),H=D.schema.nodes.image.create({src:z,alt:c.value.alt||"",title:c.value.title||"",...le});if(c.value.link&&c.value.link.trim()!==""){let $=c.value.link.trim();$.match(/^https?:\/\//i)||($="https://"+$);const I=D.schema.marks.link.create({href:$,target:c.value.openInNewTab?"_blank":null}),te=H.type.create(H.attrs,H.content,[I]);e.editor.chain().focus().insertContentAt(X+1,te).run(),w(e.editor,z)}else e.editor.chain().focus().insertContentAt(X+1,H).run(),w(e.editor,z)}else if(c.value.link&&c.value.link.trim()!==""){const le=b();e.editor.chain().focus().setImage({src:z,alt:c.value.alt||"",title:c.value.title||"",...le}).run(),setTimeout(()=>{let H=c.value.link.trim();H.match(/^https?:\/\//i)||(H="https://"+H),e.editor.chain().focus().selectParentNode().setLink({href:H,target:c.value.openInNewTab?"_blank":null}).run(),w(e.editor,z,20)},10)}else{const le=b();e.editor.chain().focus().setImage({src:z,alt:c.value.alt||"",title:c.value.title||"",...le}).run(),w(e.editor,z)}}else if(c.value.link&&c.value.link.trim()!==""){const X=b();e.editor.chain().focus().setImage({src:z,alt:c.value.alt||"",title:c.value.title||"",...X}).run(),setTimeout(()=>{let le=c.value.link.trim();le.match(/^https?:\/\//i)||(le="https://"+le),e.editor.chain().focus().selectParentNode().setLink({href:le,target:c.value.openInNewTab?"_blank":null}).run(),w(e.editor,z,20)},10)}else{const X=b();e.editor.chain().focus().setImage({src:z,alt:c.value.alt||"",title:c.value.title||"",...X}).run(),w(e.editor,z)}}m()},E=(M,_)=>{let A=null;return M.forEach((L,z)=>{L.type.name==="image"&&(A=_+z+1)}),A},N=async()=>{if(e.editor){if(l.value.length===0)if(Array.isArray(c.value.file)&&c.value.file.length>0){const M=c.value.file.filter(A=>typeof A=="string"&&A.trim()!==""),_=c.value.file.filter(A=>A instanceof File);for(const A of M)l.value.some(L=>L.url===A||L.preview===A)||l.value.push({url:A,preview:A,error:!1});_.length>0&&await g(_)}else d.value&&await g(c.value.file);if(l.value.length!==0)try{const M=[],_=b();for(const A of l.value){const L=A.url||A.preview||"";if(!L)continue;const z=e.editor.schema.nodes.image.create({src:L,alt:c.value.alt||"",title:c.value.title||"",..._});M.push(z)}M.length>0&&(e.editor.chain().focus().command(({tr:A,dispatch:L})=>{if(L){const{selection:z}=A,{$anchor:Z}=z;let D=z.$anchor.pos,P=null,ne=null;for(let K=Z.depth;K>0;K--){const X=Z.node(K);if(X&&X.type.name==="paragraph"){P=X,ne=Z.start(K);break}}if(P){let K=null;P.forEach((X,le)=>{X.type.name==="image"&&(K=ne+le+1)}),K!==null?D=K+1:D=ne+P.content.size}let U=D;return M.forEach(K=>{A.insert(U,K),U+=K.nodeSize}),!0}return!1}).run(),c.value.width&&c.value.height&&setTimeout(()=>{const{view:A}=e.editor;A&&A.dom&&A.dom.querySelectorAll("img.editor-image").forEach(Z=>{Z instanceof HTMLImageElement&&Array.from(l.value).some(P=>{const ne=P.url||P.preview||"",U=Z.src||Z.getAttribute("src")||"";return U===ne||U.includes(ne.split("/").pop())})&&(Z.style.setProperty("width",`${c.value.width}px`,"important"),Z.style.setProperty("height",`${c.value.height}px`,"important"),Z.style.setProperty("object-fit","fill","important"),Z.style.setProperty("max-width","none","important"),Z.style.setProperty("max-height","none","important"))})},50)),m()}catch(M){console.error("Помилка при додаванні зображень:",M),we.notify({type:"error",title:"Помилка",message:"Не вдалося додати зображення"})}}},R=async()=>{await v()},T=()=>{m()};return s.watch(()=>c.value.file,async(M,_)=>{if(r.value=!1,!(i.value&&Array.isArray(M)&&M.length===1&&typeof M[0]=="string"&&!M.some(L=>L instanceof File)))if(Array.isArray(M)&&M.length>0){const A=M.filter(z=>z instanceof File),L=M.filter(z=>typeof z=="string"&&z.trim()!=="");if(A.length>0&&(i.value?i.value&&A.length===1&&L.length===0&&(l.value=[]):l.value=[],(!i.value||A.length>1||L.length>0)&&await g(A),i.value&&A.length===1&&L.length===0)){const z=new FileReader;z.onload=Z=>{c.value.src=Z.target.result},z.readAsDataURL(A[0])}if(L.length>0)if(i.value)i.value&&L.length===1&&A.length===0&&(c.value.src=L[0]);else{A.length===0&&(l.value=[]);for(const z of L)l.value.some(Z=>Z.url===z||Z.preview===z)||l.value.push({url:z,preview:z,error:!1})}}else M&&typeof M=="object"&&M instanceof FileList?(i.value||(l.value=[]),await g(Array.from(M))):M&&typeof M=="object"&&!Array.isArray(M)&&M instanceof File?(i.value||(l.value=[]),await g([M])):i.value||(l.value=[])},{immediate:!1}),s.watch(()=>c.value.src,()=>{r.value=!1}),(M,_)=>(s.openBlock(),s.createElementBlock("div",W_,[s.createElementVNode("button",{onClick:h,class:s.normalizeClass(["h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100",n.editor?.isActive("image")?"bg-gray-200 text-gray-900":""]),title:"Додати зображення"},[s.createVNode(s.unref(Y.Image),{class:"h-4 w-4"}),_[4]||(_[4]=s.createElementVNode("span",{class:"sr-only"},"Додати зображення",-1))],2),s.createVNode(Zf,{modelValue:t.value,"onUpdate:modelValue":_[3]||(_[3]=A=>t.value=A),title:i.value?"Редагувати зображення":"Додати зображення"},{footer:s.withCtx(()=>[s.createElementVNode("div",eT,[s.createElementVNode("button",{onClick:T,type:"button",class:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500"}," Скасувати "),s.createElementVNode("button",{onClick:R,type:"button",class:"px-4 py-2 text-sm font-medium text-white bg-blue-600 border border-transparent rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500"},s.toDisplayString(i.value?"Оновити зображення":"Додати зображення"),1)])]),default:s.withCtx(()=>[s.createVNode(zt,{modelValue:c.value,"onUpdate:modelValue":_[0]||(_[0]=A=>c.value=A),schema:p.value,form:o.value,"onUpdate:form":_[1]||(_[1]=A=>o.value=A)},null,8,["modelValue","schema","form"]),f.value&&!d.value?(s.openBlock(),s.createElementBlock("div",K_,[_[5]||(_[5]=s.createElementVNode("p",{class:"text-sm text-gray-600 mb-2"},"Попередній перегляд:",-1)),s.withDirectives(s.createElementVNode("img",{src:f.value,alt:c.value.alt||"Попередній перегляд зображення",title:c.value.title,class:"max-w-full h-auto max-h-32 rounded border",onError:_[2]||(_[2]=A=>r.value=!0)},null,40,q_),[[s.vShow,!r.value]]),r.value?(s.openBlock(),s.createElementBlock("p",G_," Не вдалося завантажити попередній перегляд зображення ")):s.createCommentVNode("",!0)])):s.createCommentVNode("",!0),l.value.length>0?(s.openBlock(),s.createElementBlock("div",J_,[s.createElementVNode("p",Y_,"Попередній перегляд ("+s.toDisplayString(l.value.length)+" зображень):",1),_[6]||(_[6]=s.createElementVNode("p",{class:"text-xs text-gray-500 mb-2"}," Зображення будуть розміщені в ряд, якщо вони помістяться по ширині ",-1)),s.createElementVNode("div",X_,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(l.value,(A,L)=>(s.openBlock(),s.createElementBlock("div",{key:L,class:"relative"},[s.withDirectives(s.createElementVNode("img",{src:A.preview,alt:`Попередній перегляд ${L+1}`,class:"max-w-[100px] max-h-[100px] rounded border object-contain",onError:z=>A.error=!0},null,40,Z_),[[s.vShow,!A.error]]),s.createElementVNode("button",{onClick:z=>y(L),class:"absolute -top-2 -right-2 bg-red-500 text-white rounded-full w-5 h-5 flex items-center justify-center text-xs hover:bg-red-600",type:"button"}," × ",8,Q_)]))),128))])])):s.createCommentVNode("",!0)]),_:1},8,["modelValue","title"])]))}}),nT={class:"flex items-center"},rT=["disabled"],oT=["disabled"],sT=Ne(Object.assign({inheritAttrs:!1},{__name:"vs-editor-history",props:{editor:Object},setup(n){const e=n,t=()=>{e.editor?.can().undo()&&e.editor.chain().focus().undo().run()},r=()=>{e.editor?.can().redo()&&e.editor.chain().focus().redo().run()};return(o,i)=>(s.openBlock(),s.createElementBlock("div",nT,[s.createElementVNode("button",{onClick:t,class:s.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center rounded-l-full hover:text-gray-900 hover:bg-gray-100 border-r border-gray-200",[n.editor?.can().undo()?"text-gray-500":"text-gray-300 cursor-not-allowed"]]),disabled:!n.editor?.can().undo(),title:"Undo (Ctrl+Z)"},[s.createVNode(s.unref(Y.Undo2),{class:"h-4 w-4"})],10,rT),s.createElementVNode("button",{onClick:r,class:s.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center rounded-r-full hover:text-gray-900 hover:bg-gray-100",[n.editor?.can().redo()?"text-gray-500":"text-gray-300 cursor-not-allowed"]]),disabled:!n.editor?.can().redo(),title:"Redo (Ctrl+Y)"},[s.createVNode(s.unref(Y.Redo2),{class:"h-4 w-4"})],10,oT)]))}}),[["__scopeId","data-v-6a87fc55"]]),iT={class:"relative"},lT={class:"p-6"},aT={class:"flex justify-between items-center mb-4"},cT={bold:CA,italic:MA,color:h_,background_color:w_,highlight:x_,bullet_list:hA,ordered_list:yA,blockquote:uA,codeblock:wA,underline:AA,strike:_A,link:XA,table:n_,text_align:s_,font_family:M_,font_size:B_,superscript:V_,subscript:I_,heading:z_,clear_formatting:U_,image:tT,history:sT,help:Ne(Object.assign({inheritAttrs:!1},{__name:"vs-editor-help",props:{editor:Object},setup(n){const e=s.ref(!1),t=s.ref(null),r=()=>{e.value=!e.value},o=()=>{e.value=!1};return(i,l)=>(s.openBlock(),s.createElementBlock("div",iT,[s.createElementVNode("button",{ref_key:"helpButton",ref:t,onClick:r,class:s.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100 text-gray-500",[e.value?"bg-gray-100 text-gray-900":"text-gray-500"]]),title:"Markdown Shortcuts Help"},[s.createVNode(s.unref(Y.CircleHelp),{class:"h-4 w-4"})],2),e.value?(s.openBlock(),s.createElementBlock("div",{key:0,class:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[100001]",onClick:o},[s.createElementVNode("div",{class:"bg-white rounded-lg shadow-xl max-w-2xl w-full mx-4 max-h-[80vh] overflow-y-auto",onClick:l[0]||(l[0]=s.withModifiers(()=>{},["stop"]))},[s.createElementVNode("div",lT,[s.createElementVNode("div",aT,[l[1]||(l[1]=s.createElementVNode("h2",{class:"text-xl font-semibold text-gray-900"},"Common Markdown Syntax & Shortcuts",-1)),s.createElementVNode("button",{onClick:o,class:"text-gray-400 hover:text-gray-600 transition-colors"},[s.createVNode(s.unref(Y.X),{class:"h-6 w-6"})])]),l[2]||(l[2]=s.createStaticVNode('<div class="space-y-6" data-v-92c21275><div data-v-92c21275><h3 class="text-lg font-medium text-gray-800 mb-3" data-v-92c21275>Markdown Syntax</h3><div class="overflow-x-auto" data-v-92c21275><table class="w-full border-collapse" data-v-92c21275><thead data-v-92c21275><tr class="bg-gray-50" data-v-92c21275><th class="border border-gray-200 px-3 py-2 text-left font-medium text-gray-700" data-v-92c21275>Element</th><th class="border border-gray-200 px-3 py-2 text-left font-medium text-gray-700" data-v-92c21275>Example</th></tr></thead><tbody class="text-sm" data-v-92c21275><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Bold</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>**bold text**</code> or <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>__bold text__</code></td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Italics</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>*italic text*</code> or <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>_italic text_</code></td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Strikethrough</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>~strikethrough text~</code></td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Headings</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275># Heading 1</code>, <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>## Heading 2</code>, etc., up to <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>###### Heading 6</code></td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Unordered Lists</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Use an asterisk (*), dash (-), or plus sign (+) followed by a space. </td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Ordered Lists</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Use a number followed by a period and a space (e.g., <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>1. First item</code>). </td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Blockquotes</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Start with a greater-than sign (&gt;) followed by a space. </td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Inline Code</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Surround with backticks (<code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>`</code>). </td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Code Blocks</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Enclose with three backticks (<code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>```</code>) before and after the code. </td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Images</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Use <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>![alt text](url)</code> syntax. </td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Links</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Use <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>[Link Text](url)</code> syntax. </td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Checklists</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Create a list item with <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>- [ ]</code> for an incomplete task or <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>- [x]</code> for a completed one. </td></tr></tbody></table></div></div><div data-v-92c21275><h3 class="text-lg font-medium text-gray-800 mb-3" data-v-92c21275>Common Editing Shortcuts</h3><div class="overflow-x-auto" data-v-92c21275><table class="w-full border-collapse" data-v-92c21275><thead data-v-92c21275><tr class="bg-gray-50" data-v-92c21275><th class="border border-gray-200 px-3 py-2 text-left font-medium text-gray-700" data-v-92c21275>Shortcut</th><th class="border border-gray-200 px-3 py-2 text-left font-medium text-gray-700" data-v-92c21275>Action</th></tr></thead><tbody class="text-sm" data-v-92c21275><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+A</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Select all text</td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+B</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Apply bold formatting</td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+C</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Copy selected text</td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+I</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Apply italic formatting</td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+K</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Open the insert link dialog</td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+S</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Save the current document</td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+V</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Paste copied text</td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+X</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Cut selected text</td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+Y</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Redo the last action</td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Alt+Shift+Backspace</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Redo the last action</td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+Z</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Undo the last action</td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Alt+Backspace</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Undo the last action</td></tr></tbody></table></div></div></div>',1))])])])):s.createCommentVNode("",!0)]))}}),[["__scopeId","data-v-92c21275"]]),horizontal_rule:{__name:"vs-editor-horizontal-rule",props:{editor:Object},setup(n){const e=n,t=()=>{e.editor&&e.editor.chain().focus().setHorizontalRule().run()};return(r,o)=>(s.openBlock(),s.createElementBlock("button",{title:"Horizontal Rule",onClick:t,class:"flex flex-col h-[30px] px-1 rounded-full hover:bg-gray-100 justify-center items-center relative flex"},[s.createVNode(s.unref(Y.Minus),{class:"h-4 w-4"})]))}},fullscreen:{__name:"vs-editor-fullscreen",props:{editor:Object},emits:["toggle-fullscreen"],setup(n,{emit:e}){const t=e,r=()=>{t("toggle-fullscreen")};return(o,i)=>(s.openBlock(),s.createElementBlock("button",{title:"Fullscreen",onClick:r,class:"w-[30px] h-[30px] flex items-center justify-center text-gray-500 rounded-full hover:text-gray-900 hover:bg-gray-100"},[s.createVNode(s.unref(Y.Maximize),{class:"h-4 w-4"})]))}}},tp={basic:["history","font_family","font_size","bold","italic","underline","strike","text_align","bullet_list","ordered_list","link","image","clear_formatting","help"],default:["history","heading","font_family","font_size","bold","italic","underline","strike","superscript","subscript","color","background_color","highlight","text_align","bullet_list","ordered_list","blockquote","codeblock","table","link","image","horizontal_rule","clear_formatting","fullscreen","help"],full:["history","heading","font_family","font_size","bold","italic","underline","strike","color","background_color","highlight","text_align","bullet_list","ordered_list","blockquote","codeblock","table","link","image","horizontal_rule","superscript","subscript","clear_formatting","fullscreen","help"]},dT={class:"flex align-middle gap-x-0.5 border-b flex-wrap border-b-gray-200 px-[10px] py-[6px] border-solid border-transparent"},uT={class:"editor-body"},fT={key:0,class:"richtext-loading text-sm text-gray-500"},pT={key:1,class:"richtext-error text-sm text-red-600"},hT={class:"html-source-editor"},mT={class:"flex justify-end border-t border-[#e5e7eb] bg-[#f8fafc] px-4 min-h-[38px] items-start overflow-visible"},gT={class:"inline-flex items-stretch -mt-px"},yT=Object.freeze(Object.defineProperty({__proto__:null,default:Object.assign({inheritAttrs:!1},{__name:"vs-richtext",props:s.mergeModels({modelValue:{type:String,default:()=>""},height:{type:String,default:()=>"300px"},format:{type:String,default:()=>"html"},toolbar:{type:[Array,String],default:()=>"default"}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const e=n,t=s.useModel(n,"modelValue"),r=s.ref(null),o=s.ref(null),i=s.shallowRef(null),l=s.ref(!1),a=s.ref(""),c=s.ref(!1),d=s.ref(null),u=s.ref(""),f=s.ref(""),p=s.ref(null),h=s.ref(!1),m=s.ref(!1),{isFullscreen:g,toggleFullscreen:y}=F2(),{t:b}=qa(),w=s.computed(()=>e.format==="md"?"markdown":"html"),v=s.computed(()=>e.format==="md"?b("form.richtext.markdown"):b("form.richtext.html")),E=s.computed(()=>i.value||null),N=s.computed(()=>typeof e.toolbar=="string"?tp[e.toolbar]||tp.default:e.toolbar),R=s.computed(()=>N.value.map($=>cT[$]).filter(Boolean)),T=s.computed(()=>(d.value?.attributes||[]).find(I=>I.name==="class")?.value||""),M=s.computed(()=>{const I=(d.value?.attributes||[]).find(ae=>ae.name==="style")?.value||"",te={};return I.split(";").forEach(ae=>{const[re,...ge]=ae.split(":"),Ee=re?.trim(),xe=ge.join(":").trim();!Ee||!xe||Ee!=="height"&&(te[Ee.replace(/-([a-z])/g,(Ie,je)=>je.toUpperCase())]=xe)}),te}),_=$=>{const I=($||"").trim();return I?/^<p(?:\s+[^>]*)?>(?:\s|<br[^>]*>)*<\/p>$/i.test(I):!0},A=$=>_($)?"":$||"",L=$=>{const I=$||"";p.value=I,t.value=I},z=$=>{if(!$||!$.view||!$.view.dom)return;$.view.dom.querySelectorAll("img.editor-image[width][height]").forEach(te=>{if(te instanceof HTMLImageElement){const ae=te.getAttribute("width"),re=te.getAttribute("height");ae&&re&&ae!=="auto"&&re!=="auto"&&ae!==""&&re!==""&&!isNaN(Number(ae))&&!isNaN(Number(re))&&(te.style.cssText=`
44
+ width: ${ae}px !important;
45
+ height: ${re}px !important;
46
46
  max-width: none !important;
47
47
  max-height: none !important;
48
48
  min-width: auto !important;
49
49
  min-height: auto !important;
50
50
  object-fit: fill !important;
51
- `.replace(/\s+/g," ").trim())}})},te=async(A,{force:M=!1}={})=>{if(h.value=A||"",!l.value||i.value&&!M)return;v(l.value.getHTML())!==(A||"")&&(l.value.commands.setContent(A||"",!1),e.nextTick(()=>{j(l.value)}))},D=async A=>{m.value=!0,g.value=A||"",await e.nextTick(),m.value=!1},U=async A=>t.format==="html"?eo(A||""):A||"",oe=async()=>{const A=await U(g.value);A!==(n.value||"")?T(A):p.value=A},R=async A=>{const M=A||"";if(t.format==="html"){const Q=eo(M),se=Bl(Q);d.value=se.wrapper,await te(se.bodyHtml||""),p.value=Q;return}else{d.value=null;const Q=await Sl(M,t.format);await te(Q||""),i.value&&await D(M)}p.value=M},H=async()=>{if(t.format==="html"){const M=v(l.value?.getHTML()||h.value||""),Q=Vl(M,d.value);return $l(eo(Q),"html")}const A=v(l.value?.getHTML()||h.value||"");return $l(A,t.format)},Z=async A=>{if(i.value!==A){if(A){f.value=!0,i.value=!0,await D(await H()),e.nextTick(()=>{a.value?.focus?.()});return}if(await oe(),t.format==="html"){const M=eo(g.value||""),Q=Bl(M);d.value=Q.wrapper,await te(Q.bodyHtml||"",{force:!0})}else{const M=await Sl(g.value||"",t.format);await te(M||"",{force:!0})}i.value=!1,f.value=!1,e.nextTick(()=>{l.value?.commands?.focus?.()})}},ae=()=>{i.value||l.value?.commands?.focus?.()},O=async()=>{if(!r.value)return null;s.value=!0,c.value="";try{const A=await Ug();if(!A)return null;const M=new A.Editor({element:r.value,content:h.value||"",extensions:[A.StarterKit.configure({history:{depth:100,newGroupDelay:500},code:{HTMLAttributes:{class:"editor-code"}},codeBlock:{HTMLAttributes:{class:"editor-codeblock"}},paragraph:!1,heading:!1,link:!1}),A.Superscript,A.Subscript,A.ExtendedTextStyle,A.CustomParagraph,A.CustomHeading,A.Highlight,A.Image.configure({inline:!0,allowBase64:!0,HTMLAttributes:{class:"editor-image"}}),A.TextAlign.configure({types:["heading","paragraph"]}),A.CustomLink.configure({HTMLAttributes:{class:"editor-link"},openOnClick:!1,autolink:!0}),A.CustomTableKit,A.Iframe],editorProps:{handlePaste:(Q,se)=>ey(Q,se,A.ProseMirrorDOMParser),handleKeyDown:(Q,se)=>{if(se.key==="Tab"){const ee=Q.state,{$anchor:me}=ee.selection;let ke=!1;for(let ge=me.depth;ge>0;ge--){const Se=me.node(ge);if(Se&&(Se.type.name==="bulletList"||Se.type.name==="orderedList")){ke=!0;break}}return ke?!1:(se.preventDefault(),!0)}return!1}}});return l.value=e.markRaw(M),l.value.on("update",async({editor:Q})=>{if(i.value)return;const se=v(Q.getHTML());if(h.value=se,t.format==="html"){const ee=Vl(se,d.value);ee!==n.value&&T(ee)}else{const ee=await Jg(se,t.format);ee!==n.value&&T(ee)}setTimeout(()=>{j(Q)},10)}),e.nextTick(()=>{j(l.value)}),M}catch(A){return c.value="Failed to load rich text editor dependencies.",console.error("Failed to initialize rich text editor",A),null}finally{s.value=!1}};return e.watch(()=>t.modelValue,async A=>{if(f.value)return;const M=A||"";M!==p.value&&await R(M)},{immediate:!0}),e.watch(g,async()=>{!i.value||!f.value||m.value||await oe()}),e.onMounted(async()=>{await O(),e.nextTick(()=>{l.value&&setTimeout(()=>{j(l.value)},100)})}),e.onBeforeUnmount(async()=>{i.value&&f.value&&await oe(),l.value?.destroy?.(),l.value=null}),(A,M)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["bg-white rounded-md w-full",{"fixed left-0 right-0 top-0 bottom-0 z-[100000]":e.unref(k)}])},[e.createElementVNode("div",lb,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(G.value,Q=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:Q},[l.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(Q),{key:0,editor:$.value,onToggleFullscreen:e.unref(b)},null,40,["editor","onToggleFullscreen"])):e.createCommentVNode("",!0)],64))),128))]),e.createElementVNode("div",{onClick:ae,class:"relative w-full px-4 py-2 bg-white rounded-b-lg editor-content",style:e.normalizeStyle({height:e.unref(k)?"calc(95vh - 44px)":o.height})},[e.createElementVNode("div",ab,[e.withDirectives(e.createElementVNode("div",{class:e.normalizeClass(["rich-text-scroll-wrapper",I.value]),style:e.normalizeStyle(E.value)},[e.createElementVNode("div",{ref_key:"editorElement",ref:r,class:"relative w-full"},null,512),s.value?(e.openBlock(),e.createElementBlock("div",sb,"Loading editor...")):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("div",ib,e.toDisplayString(c.value),1)):e.createCommentVNode("",!0)],6),[[e.vShow,!i.value]]),e.withDirectives(e.createElementVNode("div",cb,[e.createVNode(No,{ref_key:"htmlTextarea",ref:a,modelValue:g.value,"onUpdate:modelValue":M[0]||(M[0]=Q=>g.value=Q),height:"100%",syntax:C.value,theme:"vs-light"},null,8,["modelValue","syntax"])],512),[[e.vShow,i.value]])])],4),e.createElementVNode("div",db,[e.createElementVNode("div",ub,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["min-w-[96px] h-[30px] px-[14px] border border-[#cfd6e0] bg-[#f3f5f8] text-[8px] font-bold uppercase tracking-[0.06em] leading-none cursor-pointer transition-colors duration-200 border-b-[1px] border-b-[#cfd6e0] rounded-none rounded-bl-[8px] hover:bg-[#eef1f5] hover:text-[#667284]",i.value?"text-[#8f99aa]":"!bg-white text-[#49556a] border-[#cfd6e0] border-t-transparent relative z-[1]"]),onClick:M[1]||(M[1]=Q=>Z(!1))},e.toDisplayString(e.unref(_)("form.richtext.editor")),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["min-w-[96px] h-[30px] px-[14px] border border-[#cfd6e0] border-l-0 bg-[#f3f5f8] text-[8px] font-bold uppercase tracking-[0.06em] leading-none cursor-pointer transition-colors duration-200 border-b-[1px] border-b-[#cfd6e0] rounded-none rounded-br-[8px] hover:bg-[#eef1f5] hover:text-[#667284]",i.value?"!bg-white text-[#49556a] border-[#cfd6e0] border-t-transparent relative z-[1]":"text-[#8f99aa]"]),onClick:M[2]||(M[2]=Q=>Z(!0))},e.toDisplayString(N.value),3)])])],2))}})},Symbol.toStringTag,{value:"Module"}));be.ModalEdit=nl,be.VForm=ot,be.VsInputAddress=Zr,be.VsInputArray=Xr,be.VsInputArraySelect=qn,be.VsInputCheckbox=sr,be.VsInputCodegen=qr,be.VsInputColor=Gr,be.VsInputContainer=Vr,be.VsInputDate=hr,be.VsInputEmail=po,be.VsInputFile=xr,be.VsInputFile2=Tn,be.VsInputFile64=Ln,be.VsInputFileList=Er,be.VsInputInlineSelect=On,be.VsInputKeyValue=Wr,be.VsInputMask=En,be.VsInputMonaco=No,be.VsInputNumber=rr,be.VsInputRadio=fo,be.VsInputRange=Yr,be.VsInputRichtext=Nr,be.VsInputSelect=Bo,be.VsInputSlug=Hr,be.VsInputStatic=uo,be.VsInputSwitcher=co,be.VsInputTag=Ur,be.VsInputTel=mo,be.VsInputText=Yt,be.VsInputTextArray=Kr,be.VsInputTextarea=Ar,be.base64ToBlob=Co,be.base64ToObjectUrl=_r,be.default=ot,be.downloadBase64File=Cr,be.fileToBase64=vr,be.hasMapLayerPreset=nr,be.inputs=Jr,be.resolveMapLayerPreset=_n,be.richtextLocaleEn=ol,be.richtextLocaleUk=rl,be.richtextMessages=Fo,be.vsInputDatatable=Mr,be.vsInputMap=jr,Object.defineProperties(be,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
51
+ `.replace(/\s+/g," ").trim())}})},Z=async($,{force:I=!1}={})=>{if(u.value=$||"",!i.value||c.value&&!I)return;A(i.value.getHTML())!==($||"")&&(i.value.commands.setContent($||"",!1),s.nextTick(()=>{z(i.value)}))},D=async $=>{m.value=!0,f.value=$||"",await s.nextTick(),m.value=!1},P=async $=>e.format==="html"?vi($||""):$||"",ne=async()=>{const $=await P(f.value);$!==(t.value||"")?L($):p.value=$},U=async $=>{const I=$||"";if(e.format==="html"){const te=vi(I),ae=qf(te);d.value=ae.wrapper,await Z(ae.bodyHtml||""),p.value=te;return}else{d.value=null;const te=await Jf(I,e.format);await Z(te||""),c.value&&await D(I)}p.value=I},K=async()=>{if(e.format==="html"){const I=A(i.value?.getHTML()||u.value||""),te=Gf(I,d.value);return Yf(vi(te),"html")}const $=A(i.value?.getHTML()||u.value||"");return Yf($,e.format)},X=async $=>{if(c.value!==$){if($){h.value=!0,c.value=!0,await D(await K()),s.nextTick(()=>{o.value?.focus?.()});return}if(await ne(),e.format==="html"){const I=vi(f.value||""),te=qf(I);d.value=te.wrapper,await Z(te.bodyHtml||"",{force:!0})}else{const I=await Jf(f.value||"",e.format);await Z(I||"",{force:!0})}c.value=!1,h.value=!1,s.nextTick(()=>{i.value?.commands?.focus?.()})}},le=()=>{c.value||i.value?.commands?.focus?.()},H=async()=>{if(!r.value)return null;l.value=!0,a.value="";try{const $=await G2();if(!$)return null;const I=new $.Editor({element:r.value,content:u.value||"",extensions:[$.StarterKit.configure({history:{depth:100,newGroupDelay:500},code:{HTMLAttributes:{class:"editor-code"}},codeBlock:{HTMLAttributes:{class:"editor-codeblock"}},paragraph:!1,heading:!1,link:!1}),$.Superscript,$.Subscript,$.ExtendedTextStyle,$.CustomParagraph,$.CustomHeading,$.Highlight,$.Image.configure({inline:!0,allowBase64:!0,HTMLAttributes:{class:"editor-image"}}),$.TextAlign.configure({types:["heading","paragraph"]}),$.CustomLink.configure({HTMLAttributes:{class:"editor-link"},openOnClick:!1,autolink:!0}),$.CustomTableKit,$.Iframe],editorProps:{handlePaste:(te,ae)=>sA(te,ae,$.ProseMirrorDOMParser),handleKeyDown:(te,ae)=>{if(ae.key==="Tab"){const re=te.state,{$anchor:ge}=re.selection;let Ee=!1;for(let xe=ge.depth;xe>0;xe--){const Ie=ge.node(xe);if(Ie&&(Ie.type.name==="bulletList"||Ie.type.name==="orderedList")){Ee=!0;break}}return Ee?!1:(ae.preventDefault(),!0)}return!1}}});return i.value=s.markRaw(I),i.value.on("update",async({editor:te})=>{if(c.value)return;const ae=A(te.getHTML());if(u.value=ae,e.format==="html"){const re=Gf(ae,d.value);re!==t.value&&L(re)}else{const re=await rA(ae,e.format);re!==t.value&&L(re)}setTimeout(()=>{z(te)},10)}),s.nextTick(()=>{z(i.value)}),I}catch($){return a.value="Failed to load rich text editor dependencies.",console.error("Failed to initialize rich text editor",$),null}finally{l.value=!1}};return s.watch(()=>e.modelValue,async $=>{if(h.value)return;const I=$||"";I!==p.value&&await U(I)},{immediate:!0}),s.watch(f,async()=>{!c.value||!h.value||m.value||await ne()}),s.onMounted(async()=>{await H(),s.nextTick(()=>{i.value&&setTimeout(()=>{z(i.value)},100)})}),s.onBeforeUnmount(async()=>{c.value&&h.value&&await ne(),i.value?.destroy?.(),i.value=null}),($,I)=>(s.openBlock(),s.createElementBlock("div",{class:s.normalizeClass(["bg-white rounded-md w-full",{"fixed left-0 right-0 top-0 bottom-0 z-[100000]":s.unref(g)}])},[s.createElementVNode("div",dT,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(R.value,te=>(s.openBlock(),s.createElementBlock(s.Fragment,{key:te},[i.value?(s.openBlock(),s.createBlock(s.resolveDynamicComponent(te),{key:0,editor:E.value,onToggleFullscreen:s.unref(y)},null,40,["editor","onToggleFullscreen"])):s.createCommentVNode("",!0)],64))),128))]),s.createElementVNode("div",{onClick:le,class:"relative w-full px-4 py-2 bg-white rounded-b-lg editor-content",style:s.normalizeStyle({height:s.unref(g)?"calc(95vh - 44px)":n.height})},[s.createElementVNode("div",uT,[s.withDirectives(s.createElementVNode("div",{class:s.normalizeClass(["rich-text-scroll-wrapper",T.value]),style:s.normalizeStyle(M.value)},[s.createElementVNode("div",{ref_key:"editorElement",ref:r,class:"relative w-full"},null,512),l.value?(s.openBlock(),s.createElementBlock("div",fT,"Loading editor...")):s.createCommentVNode("",!0),a.value?(s.openBlock(),s.createElementBlock("div",pT,s.toDisplayString(a.value),1)):s.createCommentVNode("",!0)],6),[[s.vShow,!c.value]]),s.withDirectives(s.createElementVNode("div",hT,[s.createVNode(La,{ref_key:"htmlTextarea",ref:o,modelValue:f.value,"onUpdate:modelValue":I[0]||(I[0]=te=>f.value=te),height:"100%",syntax:w.value,theme:"vs-light"},null,8,["modelValue","syntax"])],512),[[s.vShow,c.value]])])],4),s.createElementVNode("div",mT,[s.createElementVNode("div",gT,[s.createElementVNode("button",{type:"button",class:s.normalizeClass(["min-w-[96px] h-[30px] px-[14px] border border-[#cfd6e0] bg-[#f3f5f8] text-[8px] font-bold uppercase tracking-[0.06em] leading-none cursor-pointer transition-colors duration-200 border-b-[1px] border-b-[#cfd6e0] rounded-none rounded-bl-[8px] hover:bg-[#eef1f5] hover:text-[#667284]",c.value?"text-[#8f99aa]":"!bg-white text-[#49556a] border-[#cfd6e0] border-t-transparent relative z-[1]"]),onClick:I[1]||(I[1]=te=>X(!1))},s.toDisplayString(s.unref(b)("form.richtext.editor")),3),s.createElementVNode("button",{type:"button",class:s.normalizeClass(["min-w-[96px] h-[30px] px-[14px] border border-[#cfd6e0] border-l-0 bg-[#f3f5f8] text-[8px] font-bold uppercase tracking-[0.06em] leading-none cursor-pointer transition-colors duration-200 border-b-[1px] border-b-[#cfd6e0] rounded-none rounded-br-[8px] hover:bg-[#eef1f5] hover:text-[#667284]",c.value?"!bg-white text-[#49556a] border-[#cfd6e0] border-t-transparent relative z-[1]":"text-[#8f99aa]"]),onClick:I[2]||(I[2]=te=>X(!0))},s.toDisplayString(v.value),3)])])],2))}})},Symbol.toStringTag,{value:"Module"}));function xt(n){this.content=n}xt.prototype={constructor:xt,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,o=r.find(n),i=r.content.slice();return o==-1?i.push(t||n,e):(i[o+1]=e,t&&(i[o]=t)),new xt(i)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new xt(t)},addToStart:function(n,e){return new xt([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new xt(t)},addBefore:function(n,e,t){var r=this.remove(e),o=r.content.slice(),i=r.find(n);return o.splice(i==-1?o.length:i,0,e,t),new xt(o)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=xt.from(n),n.size?new xt(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=xt.from(n),n.size?new xt(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=xt.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}},xt.from=function(n){if(n instanceof xt)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new xt(e)};function np(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(r),i=e.child(r);if(o==i){t+=o.nodeSize;continue}if(!o.sameMarkup(i))return t;if(o.isText&&o.text!=i.text){let l=o.text,a=i.text,c=0;for(;l[c]==a[c];c++)t++;return c&&c<l.length&&c<a.length&&sp(l.charCodeAt(c-1))&&op(l.charCodeAt(c))&&t--,t}if(o.content.size||i.content.size){let l=np(o.content,i.content,t+1);if(l!=null)return l}t+=o.nodeSize}}function rp(n,e,t,r){for(let o=n.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:t,b:r};let l=n.child(--o),a=e.child(--i),c=l.nodeSize;if(l==a){t-=c,r-=c;continue}if(!l.sameMarkup(a))return{a:t,b:r};if(l.isText&&l.text!=a.text){let d=l.text,u=a.text,f=d.length,p=u.length;for(;f>0&&p>0&&d[f-1]==u[p-1];)f--,p--,t--,r--;return f&&p&&f<d.length&&sp(d.charCodeAt(f-1))&&op(d.charCodeAt(f))&&(t++,r++),{a:t,b:r}}if(l.content.size||a.content.size){let d=rp(l.content,a.content,t-1,r-1);if(d)return d}t-=c,r-=c}}function op(n){return n>=56320&&n<57344}function sp(n){return n>=55296&&n<56320}class ee{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,o=0,i){for(let l=0,a=0;a<t;l++){let c=this.content[l],d=a+c.nodeSize;if(d>e&&r(c,o+a,i||null,l)!==!1&&c.content.size){let u=a+1;c.nodesBetween(Math.max(0,e-u),Math.min(c.content.size,t-u),r,o+u)}a=d}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,o){let i="",l=!0;return this.nodesBetween(e,t,(a,c)=>{let d=a.isText?a.text.slice(Math.max(e,c)-c,t-c):a.isLeaf?o?typeof o=="function"?o(a):o:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&d||a.isTextblock)&&r&&(l?l=!1:i+=r),i+=d},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,o=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(o[o.length-1]=t.withText(t.text+r.text),i=1);i<e.content.length;i++)o.push(e.content[i]);return new ee(o,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],o=0;if(t>e)for(let i=0,l=0;l<t;i++){let a=this.content[i],c=l+a.nodeSize;c>e&&((l<e||c>t)&&(a.isText?a=a.cut(Math.max(0,e-l),Math.min(a.text.length,t-l)):a=a.cut(Math.max(0,e-l-1),Math.min(a.content.size,t-l-1))),r.push(a),o+=a.nodeSize),l=c}return new ee(r,o)}cutByIndex(e,t){return e==t?ee.empty:e==0&&t==this.content.length?this:new ee(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let o=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return o[e]=t,new ee(o,i)}addToStart(e){return new ee([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new ee(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let o=this.content[t];e(o,r,t),r+=o.nodeSize}}findDiffStart(e,t=0){return np(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return rp(this,e,t,r)}findIndex(e){if(e==0)return Ci(0,e);if(e==this.size)return Ci(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let o=this.child(t),i=r+o.nodeSize;if(i>=e)return i==e?Ci(t+1,i):Ci(t,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return ee.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return ee.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return ee.empty;let t,r=0;for(let o=0;o<e.length;o++){let i=e[o];r+=i.nodeSize,o&&i.isText&&e[o-1].sameMarkup(i)?(t||(t=e.slice(0,o)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new ee(t||e,r)}static from(e){if(!e)return ee.empty;if(e instanceof ee)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new ee([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}ee.empty=new ee([],0);const Ga={index:0,offset:0};function Ci(n,e){return Ga.index=n,Ga.offset=e,Ga}function Si(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Si(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Si(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let Ue=class wu{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let o=0;o<e.length;o++){let i=e[o];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,o));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),r=!0),t&&t.push(i)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Si(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let o=r.create(t.attrs);return r.checkAttrs(o.attrs),o}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return wu.none;if(e instanceof wu)return[e];let t=e.slice();return t.sort((r,o)=>r.type.rank-o.type.rank),t}};Ue.none=[];class io extends Error{}class fe{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=lp(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return r&&new fe(r,this.openStart,this.openEnd)}removeBetween(e,t){return new fe(ip(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return fe.empty;let r=t.openStart||0,o=t.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new fe(ee.fromJSON(e,t.content),r,o)}static maxOpen(e,t=!0){let r=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)o++;return new fe(e,r,o)}}fe.empty=new fe(ee.empty,0,0);function ip(n,e,t){let{index:r,offset:o}=n.findIndex(e),i=n.maybeChild(r),{index:l,offset:a}=n.findIndex(t);if(o==e||i.isText){if(a!=t&&!n.child(l).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=l)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy(ip(i.content,e-o-1,t-o-1)))}function lp(n,e,t,r,o,i){let{index:l,offset:a}=n.findIndex(e),c=n.maybeChild(l);if(a==e||c.isText)return i&&r<=0&&o<=0&&!i.canReplace(l,l,t)?null:n.cut(0,e).append(t).append(n.cut(e));let d=lp(c.content,e-a-1,t,l==0?r-1:0,l==n.childCount-1?o-1:0,c);return d&&n.replaceChild(l,c.copy(d))}function bT(n,e,t){if(t.openStart>n.depth)throw new io("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new io("Inconsistent open depths");return ap(n,e,t,0)}function ap(n,e,t,r){let o=n.index(r),i=n.node(r);if(o==e.index(r)&&r<n.depth-t.openStart){let l=ap(n,e,t,r+1);return i.copy(i.content.replaceChild(o,l))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let l=n.parent,a=l.content;return Nr(l,a.cut(0,n.parentOffset).append(t.content).append(a.cut(e.parentOffset)))}else{let{start:l,end:a}=kT(t,n);return Nr(i,dp(n,l,a,e,r))}else return Nr(i,Ei(n,e,r))}function cp(n,e){if(!e.type.compatibleContent(n.type))throw new io("Cannot join "+e.type.name+" onto "+n.type.name)}function Ja(n,e,t){let r=n.node(t);return cp(r,e.node(t)),r}function Br(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Ko(n,e,t,r){let o=(e||n).node(t),i=0,l=e?e.index(t):o.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(Br(n.nodeAfter,r),i++));for(let a=i;a<l;a++)Br(o.child(a),r);e&&e.depth==t&&e.textOffset&&Br(e.nodeBefore,r)}function Nr(n,e){if(!n.type.validContent(e))throw new io("Invalid content for node "+n.type.name);return n.copy(e)}function dp(n,e,t,r,o){let i=n.depth>o&&Ja(n,e,o+1),l=r.depth>o&&Ja(t,r,o+1),a=[];return Ko(null,n,o,a),i&&l&&e.index(o)==t.index(o)?(cp(i,l),Br(Nr(i,dp(n,e,t,r,o+1)),a)):(i&&Br(Nr(i,Ei(n,e,o+1)),a),Ko(e,t,o,a),l&&Br(Nr(l,Ei(t,r,o+1)),a)),Ko(r,null,o,a),new ee(a)}function Ei(n,e,t){let r=[];if(Ko(null,n,t,r),n.depth>t){let o=Ja(n,e,t+1);Br(Nr(o,Ei(n,e,t+1)),r)}return Ko(e,null,t,r),new ee(r)}function kT(n,e){let t=e.depth-n.openStart,o=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)o=e.node(i).copy(ee.from(o));return{start:o.resolveNoCache(n.openStart+t),end:o.resolveNoCache(o.content.size-n.openEnd-t)}}class lo{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(t);return r?e.child(t).cut(r):o}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],o=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)o+=r.child(i).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return Ue.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),o=e.maybeChild(t);if(!r){let a=r;r=o,o=a}let i=r.marks;for(var l=0;l<i.length;l++)i[l].type.spec.inclusive===!1&&(!o||!i[l].isInSet(o.marks))&&(i=i[l--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,o=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!o||!r[i].isInSet(o.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new qo(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],o=0,i=t;for(let l=e;;){let{index:a,offset:c}=l.content.findIndex(i),d=i-c;if(r.push(l,a,o+c),!d||(l=l.child(a),l.isText))break;i=d-1,o+=c+1}return new lo(t,r,i)}static resolveCached(e,t){let r=up.get(e);if(r)for(let i=0;i<r.elts.length;i++){let l=r.elts[i];if(l.pos==t)return l}else up.set(e,r=new wT);let o=r.elts[r.i]=lo.resolve(e,t);return r.i=(r.i+1)%xT,o}}class wT{constructor(){this.elts=[],this.i=0}}const xT=12,up=new WeakMap;class qo{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const vT=Object.create(null);let mn=class xu{constructor(e,t,r,o=Ue.none){this.type=e,this.attrs=t,this.marks=o,this.content=r||ee.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,o=0){this.content.nodesBetween(e,t,r,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,o){return this.content.textBetween(e,t,r,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&Si(this.attrs,t||e.defaultAttrs||vT)&&Ue.sameSet(this.marks,r||Ue.none)}copy(e=null){return e==this.content?this:new xu(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new xu(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return fe.empty;let o=this.resolve(e),i=this.resolve(t),l=r?0:o.sharedDepth(t),a=o.start(l),d=o.node(l).content.cut(o.pos-a,i.pos-a);return new fe(d,o.depth-l,i.depth-l)}replace(e,t,r){return bT(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let o=this.content.child(t-1);return{node:o,index:t-1,offset:r-o.nodeSize}}resolve(e){return lo.resolveCached(this,e)}resolveNoCache(e){return lo.resolve(this,e)}rangeHasMark(e,t,r){let o=!1;return t>e&&this.nodesBetween(e,t,i=>(r.isInSet(i.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),fp(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=ee.empty,o=0,i=r.childCount){let l=this.contentMatchAt(e).matchFragment(r,o,i),a=l&&l.matchFragment(this.content,t);if(!a||!a.validEnd)return!1;for(let c=o;c<i;c++)if(!this.type.allowsMarks(r.child(c).marks))return!1;return!0}canReplaceWith(e,t,r,o){if(o&&!this.type.allowsMarks(o))return!1;let i=this.contentMatchAt(e).matchType(r),l=i&&i.matchFragment(this.content,t);return l?l.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Ue.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!Ue.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let o=ee.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,o,r);return i.type.checkAttrs(i.attrs),i}};mn.prototype.text=void 0;class Mi extends mn{constructor(e,t,r,o){if(super(e,t,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):fp(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Mi(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Mi(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function fp(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class rr{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new CT(e,t);if(r.next==null)return rr.empty;let o=pp(r);r.next&&r.err("Unexpected trailing text");let i=BT(TT(o));return NT(i,r),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let o=this;for(let i=t;o&&i<r;i++)o=o.matchType(e.child(i).type);return o}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let o=[this];function i(l,a){let c=l.matchFragment(e,r);if(c&&(!t||c.validEnd))return ee.from(a.map(d=>d.createAndFill()));for(let d=0;d<l.next.length;d++){let{type:u,next:f}=l.next[d];if(!(u.isText||u.hasRequiredAttrs())&&o.indexOf(f)==-1){o.push(f);let p=i(f,a.concat(u));if(p)return p}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),i=o.match;if(i.matchType(e)){let l=[];for(let a=o;a.type;a=a.via)l.push(a.type);return l.reverse()}for(let l=0;l<i.next.length;l++){let{type:a,next:c}=i.next[l];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!o.type||c.validEnd)&&(r.push({match:a.contentMatch,type:a,via:o}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let o=0;o<r.next.length;o++)e.indexOf(r.next[o].next)==-1&&t(r.next[o].next)}return t(this),e.map((r,o)=>{let i=o+(r.validEnd?"*":" ")+" ";for(let l=0;l<r.next.length;l++)i+=(l?", ":"")+r.next[l].type.name+"->"+e.indexOf(r.next[l].next);return i}).join(`
52
+ `)}}rr.empty=new rr(!0);class CT{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function pp(n){let e=[];do e.push(ST(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function ST(n){let e=[];do e.push(ET(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function ET(n){let e=_T(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=MT(n,e);else break;return e}function hp(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function MT(n,e){let t=hp(n),r=t;return n.eat(",")&&(n.next!="}"?r=hp(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function AT(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let o=[];for(let i in t){let l=t[i];l.isInGroup(e)&&o.push(l)}return o.length==0&&n.err("No node type or group '"+e+"' found"),o}function _T(n){if(n.eat("(")){let e=pp(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=AT(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function TT(n){let e=[[]];return o(i(n,0),t()),e;function t(){return e.push([])-1}function r(l,a,c){let d={term:c,to:a};return e[l].push(d),d}function o(l,a){l.forEach(c=>c.to=a)}function i(l,a){if(l.type=="choice")return l.exprs.reduce((c,d)=>c.concat(i(d,a)),[]);if(l.type=="seq")for(let c=0;;c++){let d=i(l.exprs[c],a);if(c==l.exprs.length-1)return d;o(d,a=t())}else if(l.type=="star"){let c=t();return r(a,c),o(i(l.expr,c),c),[r(c)]}else if(l.type=="plus"){let c=t();return o(i(l.expr,a),c),o(i(l.expr,c),c),[r(c)]}else{if(l.type=="opt")return[r(a)].concat(i(l.expr,a));if(l.type=="range"){let c=a;for(let d=0;d<l.min;d++){let u=t();o(i(l.expr,c),u),c=u}if(l.max==-1)o(i(l.expr,c),c);else for(let d=l.min;d<l.max;d++){let u=t();r(c,u),o(i(l.expr,c),u),c=u}return[r(c)]}else{if(l.type=="name")return[r(a,void 0,l.value)];throw new Error("Unknown expr type")}}}}function mp(n,e){return e-n}function gp(n,e){let t=[];return r(e),t.sort(mp);function r(o){let i=n[o];if(i.length==1&&!i[0].term)return r(i[0].to);t.push(o);for(let l=0;l<i.length;l++){let{term:a,to:c}=i[l];!a&&t.indexOf(c)==-1&&r(c)}}}function BT(n){let e=Object.create(null);return t(gp(n,0));function t(r){let o=[];r.forEach(l=>{n[l].forEach(({term:a,to:c})=>{if(!a)return;let d;for(let u=0;u<o.length;u++)o[u][0]==a&&(d=o[u][1]);gp(n,c).forEach(u=>{d||o.push([a,d=[]]),d.indexOf(u)==-1&&d.push(u)})})});let i=e[r.join(",")]=new rr(r.indexOf(n.length-1)>-1);for(let l=0;l<o.length;l++){let a=o[l][1].sort(mp);i.next.push({type:o[l][0],next:e[a.join(",")]||t(a)})}return i}}function NT(n,e){for(let t=0,r=[n];t<r.length;t++){let o=r[t],i=!o.validEnd,l=[];for(let a=0;a<o.next.length;a++){let{type:c,next:d}=o.next[a];l.push(c.name),i&&!(c.isText||c.hasRequiredAttrs())&&(i=!1),r.indexOf(d)==-1&&r.push(d)}i&&e.err("Only non-generatable nodes ("+l.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function yp(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function bp(n,e){let t=Object.create(null);for(let r in n){let o=e&&e[r];if(o===void 0){let i=n[r];if(i.hasDefault)o=i.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=o}return t}function kp(n,e,t,r){for(let o in e)if(!(o in n))throw new RangeError(`Unsupported attribute ${o} for ${t} of type ${r}`);for(let o in n)n[o].validate&&n[o].validate(e[o])}function wp(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new VT(n,r,e[r]);return t}let Ya=class eb{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=wp(e,r.attrs),this.defaultAttrs=yp(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==rr.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:bp(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new mn(this,this.computeAttrs(e),ee.from(t),Ue.setFrom(r))}createChecked(e=null,t,r){return t=ee.from(t),this.checkContent(t),new mn(this,this.computeAttrs(e),t,Ue.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=ee.from(t),t.size){let l=this.contentMatch.fillBefore(t);if(!l)return null;t=l.append(t)}let o=this.contentMatch.matchFragment(t),i=o&&o.fillBefore(ee.empty,!0);return i?new mn(this,e,t.append(i),Ue.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){kp(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:Ue.none:e}static compile(e,t){let r=Object.create(null);e.forEach((i,l)=>r[i]=new eb(i,t,l));let o=t.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function DT(n,e,t){let r=t.split("|");return o=>{let i=o===null?"null":typeof o;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${i}`)}}class VT{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?DT(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Go{constructor(e,t,r,o){this.name=e,this.rank=t,this.schema=r,this.spec=o,this.attrs=wp(e,o.attrs),this.excluded=null;let i=yp(this.attrs);this.instance=i?new Ue(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Ue(this,bp(this.attrs,e))}static compile(e,t){let r=Object.create(null),o=0;return e.forEach((i,l)=>r[i]=new Go(i,o++,t,l)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){kp(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Xa{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let o in e)t[o]=e[o];t.nodes=xt.from(e.nodes),t.marks=xt.from(e.marks||{}),this.nodes=Ya.compile(this.spec.nodes,this),this.marks=Go.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],l=i.spec.content||"",a=i.spec.marks;if(i.contentMatch=r[l]||(r[l]=rr.parse(l,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=a=="_"?null:a?xp(this,a.split(" ")):a==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],l=i.spec.excludes;i.excluded=l==null?[i]:l==""?[]:xp(this,l.split(" "))}this.nodeFromJSON=o=>mn.fromJSON(this,o),this.markFromJSON=o=>Ue.fromJSON(this,o),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Ya){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,o)}text(e,t){let r=this.nodes.text;return new Mi(r,r.defaultAttrs,e,Ue.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function xp(n,e){let t=[];for(let r=0;r<e.length;r++){let o=e[r],i=n.marks[o],l=i;if(i)t.push(i);else for(let a in n.marks){let c=n.marks[a];(o=="_"||c.spec.group&&c.spec.group.split(" ").indexOf(o)>-1)&&t.push(l=c)}if(!l)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function $T(n){return n.tag!=null}function LT(n){return n.style!=null}let Dr=class vu{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(o=>{if($T(o))this.tags.push(o);else if(LT(o)){let i=/[^=]*/.exec(o.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let i=e.nodes[o.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let r=new Ep(this,t,!1);return r.addAll(e,Ue.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Ep(this,t,!0);return r.addAll(e,Ue.none,t.from,t.to),fe.maxOpen(r.finish())}matchTag(e,t,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let i=this.tags[o];if(RT(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let l=i.getAttrs(e);if(l===!1)continue;i.attrs=l||void 0}return i}}}matchStyle(e,t,r,o){for(let i=o?this.styles.indexOf(o)+1:0;i<this.styles.length;i++){let l=this.styles[i],a=l.style;if(!(a.indexOf(e)!=0||l.context&&!r.matchesContext(l.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(l.getAttrs){let c=l.getAttrs(t);if(c===!1)continue;l.attrs=c||void 0}return l}}}static schemaRules(e){let t=[];function r(o){let i=o.priority==null?50:o.priority,l=0;for(;l<t.length;l++){let a=t[l];if((a.priority==null?50:a.priority)<i)break}t.splice(l,0,o)}for(let o in e.marks){let i=e.marks[o].spec.parseDOM;i&&i.forEach(l=>{r(l=Mp(l)),l.mark||l.ignore||l.clearMark||(l.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(l=>{r(l=Mp(l)),l.node||l.ignore||l.mark||(l.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new vu(e,vu.schemaRules(e)))}};const vp={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},IT={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Cp={ol:!0,ul:!0},Jo=1,Za=2,Yo=4;function Sp(n,e,t){return e!=null?(e?Jo:0)|(e==="full"?Za:0):n&&n.whitespace=="pre"?Jo|Za:t&~Yo}class Ai{constructor(e,t,r,o,i,l){this.type=e,this.attrs=t,this.marks=r,this.solid=o,this.options=l,this.content=[],this.activeMarks=Ue.none,this.match=i||(l&Yo?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(ee.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Jo)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let t=ee.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(ee.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!vp.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Ep{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=t.topNode,i,l=Sp(null,t.preserveWhitespace,0)|(r?Yo:0);o?i=new Ai(o.type,o.attrs,Ue.none,!0,t.topMatch||o.type.contentMatch,l):r?i=new Ai(null,null,Ue.none,!0,null,l):i=new Ai(e.schema.topNodeType,null,Ue.none,!0,null,l),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,o=this.top,i=o.options&Za?"full":this.localPreserveWS||(o.options&Jo)>0,{schema:l}=this.parser;if(i==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
53
+ `);else if(l.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(l.linebreakReplacement.create())){let a=r.split(/\r?\n|\r/);for(let c=0;c<a.length;c++)c&&this.insertNode(l.linebreakReplacement.create(),t,!0),a[c]&&this.insertNode(l.text(a[c]),t,!/\S/.test(a[c]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let a=o.content[o.content.length-1],c=e.previousSibling;(!a||c&&c.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.text))&&(r=r.slice(1))}r&&this.insertNode(l.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let o=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let l=e.nodeName.toLowerCase(),a;Cp.hasOwnProperty(l)&&this.parser.normalizeLists&&OT(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(c?c.ignore:IT.hasOwnProperty(l))this.findInside(e),this.ignoreFallback(e,t);else if(!c||c.skip||c.closeParent){c&&c.closeParent?this.open=Math.max(0,this.open-1):c&&c.skip.nodeType&&(e=c.skip);let d,u=this.needsBlock;if(vp.hasOwnProperty(l))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),d=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let f=c&&c.skip?t:this.readStyles(e,t);f&&this.addAll(e,f),d&&this.sync(i),this.needsBlock=u}else{let d=this.readStyles(e,t);d&&this.addElementByRule(e,c,d,c.consuming===!1?a:void 0)}this.localPreserveWS=o}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
54
+ `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let i=this.parser.matchedStyles[o],l=r.getPropertyValue(i);if(l)for(let a=void 0;;){let c=this.parser.matchStyle(i,l,this,a);if(!c)break;if(c.ignore)return null;if(c.clearMark?t=t.filter(d=>!c.clearMark(d)):t=t.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)a=c;else break}}return t}addElementByRule(e,t,r,o){let i,l;if(t.node)if(l=this.parser.schema.nodes[t.node],l.isLeaf)this.insertNode(l.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let c=this.enter(l,t.attrs||null,r,t.preserveWhitespace);c&&(i=!0,r=c)}else{let c=this.parser.schema.marks[t.mark];r=r.concat(c.create(t.attrs))}let a=this.top;if(l&&l.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c,r,!1));else{let c=e;typeof t.contentElement=="string"?c=e.querySelector(t.contentElement):typeof t.contentElement=="function"?c=t.contentElement(e):t.contentElement&&(c=t.contentElement),this.findAround(e,c,!0),this.addAll(c,r),this.findAround(e,c,!1)}i&&this.sync(a)&&this.open--}addAll(e,t,r,o){let i=r||0;for(let l=r?e.childNodes[r]:e.firstChild,a=o==null?null:e.childNodes[o];l!=a;l=l.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(l,t);this.findAtPoint(e,i)}findPlace(e,t,r){let o,i;for(let l=this.open,a=0;l>=0;l--){let c=this.nodes[l],d=c.findWrapping(e);if(d&&(!o||o.length>d.length+a)&&(o=d,i=c,!d.length))break;if(c.solid){if(r)break;a+=2}}if(!o)return null;this.sync(i);for(let l=0;l<o.length;l++)t=this.enterInner(o[l],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}let o=this.findPlace(e,t,r);if(o){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let l=Ue.none;for(let a of o.concat(e.marks))(i.type?i.type.allowsMarkType(a.type):Ap(a.type,e.type))&&(l=a.addToSet(l));return i.content.push(e.mark(l)),!0}return!1}enter(e,t,r,o){let i=this.findPlace(e.create(t),r,!1);return i&&(i=this.enterInner(e,t,r,!0,o)),i}enterInner(e,t,r,o=!1,i){this.closeExtra();let l=this.top;l.match=l.match&&l.match.matchType(e);let a=Sp(e,i,l.options);l.options&Yo&&l.content.length==0&&(a|=Yo);let c=Ue.none;return r=r.filter(d=>(l.type?l.type.allowsMarkType(d.type):Ap(d.type,e))?(c=d.addToSet(c),!1):!0),this.nodes.push(new Ai(e,t,c,o,null,a)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=Jo)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&t.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),l=(a,c)=>{for(;a>=0;a--){let d=t[a];if(d==""){if(a==t.length-1||a==0)continue;for(;c>=i;c--)if(l(a-1,c))return!0;return!1}else{let u=c>0||c==0&&o?this.nodes[c].type:r&&c>=i?r.node(c-i).type:null;if(!u||u.name!=d&&!u.isInGroup(d))return!1;c--}}return!0};return l(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function OT(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Cp.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function RT(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Mp(n){let e={};for(let t in n)e[t]=n[t];return e}function Ap(n,e){let t=e.schema.nodes;for(let r in t){let o=t[r];if(!o.allowsMarkType(n))continue;let i=[],l=a=>{i.push(a);for(let c=0;c<a.edgeCount;c++){let{type:d,next:u}=a.edge(c);if(d==e||i.indexOf(u)<0&&l(u))return!0}};if(l(o.contentMatch))return!0}}class or{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=_i(t).createDocumentFragment());let o=r,i=[];return e.forEach(l=>{if(i.length||l.marks.length){let a=0,c=0;for(;a<i.length&&c<l.marks.length;){let d=l.marks[c];if(!this.marks[d.type.name]){c++;continue}if(!d.eq(i[a][0])||d.type.spec.spanning===!1)break;a++,c++}for(;a<i.length;)o=i.pop()[1];for(;c<l.marks.length;){let d=l.marks[c++],u=this.serializeMark(d,l.isInline,t);u&&(i.push([d,o]),o.appendChild(u.dom),o=u.contentDOM||u.dom)}}o.appendChild(this.serializeNodeInner(l,t))}),r}serializeNodeInner(e,t){if(e.isText)return _i(t).createTextNode(e.text);let{dom:r,contentDOM:o}=Ti(_i(t),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let i=this.serializeMark(e.marks[o],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,t,r={}){let o=this.marks[e.type.name];return o&&Ti(_i(r),o(e,t),null,e.attrs)}static renderSpec(e,t,r=null,o){return typeof t=="string"?{dom:e.createTextNode(t)}:Ti(e,t,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new or(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=_p(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return _p(e.marks)}}function _p(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function _i(n){return n.document||window.document}const Tp=new WeakMap;function FT(n){let e=Tp.get(n);return e===void 0&&Tp.set(n,e=PT(n)),e}function PT(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o<r.length;o++)t(r[o]);else for(let o in r)t(r[o])}return t(n),e}function Ti(n,e,t,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let o=e[0],i;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=FT(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let l=o.indexOf(" ");l>0&&(t=o.slice(0,l),o=o.slice(l+1));let a,c=t?n.createElementNS(t,o):n.createElement(o),d=e[1],u=1;if(d&&typeof d=="object"&&d.nodeType==null&&!Array.isArray(d)){u=2;for(let f in d)if(d[f]!=null){let p=f.indexOf(" ");p>0?c.setAttributeNS(f.slice(0,p),f.slice(p+1),d[f]):f=="style"&&c.style?c.style.cssText=d[f]:c.setAttribute(f,d[f])}}for(let f=u;f<e.length;f++){let p=e[f];if(p===0){if(f<e.length-1||f>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else if(typeof p=="string")c.appendChild(n.createTextNode(p));else{let{dom:h,contentDOM:m}=Ti(n,p,t,r);if(c.appendChild(h),m){if(a)throw new RangeError("Multiple content holes");a=m}}}return{dom:c,contentDOM:a}}const Bp=65535,Np=Math.pow(2,16);function zT(n,e){return n+e*Np}function Dp(n){return n&Bp}function HT(n){return(n-(n&Bp))/Np}const Vp=1,$p=2,Bi=4,Lp=8;class Qa{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Lp)>0}get deletedBefore(){return(this.delInfo&(Vp|Bi))>0}get deletedAfter(){return(this.delInfo&($p|Bi))>0}get deletedAcross(){return(this.delInfo&Bi)>0}}class Ht{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Ht.empty)return Ht.empty}recover(e){let t=0,r=Dp(e);if(!this.inverted)for(let o=0;o<r;o++)t+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+t+HT(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let o=0,i=this.inverted?2:1,l=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let c=this.ranges[a]-(this.inverted?o:0);if(c>e)break;let d=this.ranges[a+i],u=this.ranges[a+l],f=c+d;if(e<=f){let p=d?e==c?-1:e==f?1:t:t,h=c+o+(p<0?0:u);if(r)return h;let m=e==(t<0?c:f)?null:zT(a/3,e-c),g=e==c?$p:e==f?Vp:Bi;return(t<0?e!=c:e!=f)&&(g|=Lp),new Qa(h,g,m)}o+=u-d}return r?e+o:new Qa(e+o,0,null)}touches(e,t){let r=0,o=Dp(t),i=this.inverted?2:1,l=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let c=this.ranges[a]-(this.inverted?r:0);if(c>e)break;let d=this.ranges[a+i],u=c+d;if(e<=u&&a==o*3)return!0;r+=this.ranges[a+l]-d}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,i=0;o<this.ranges.length;o+=3){let l=this.ranges[o],a=l-(this.inverted?i:0),c=l+(this.inverted?0:i),d=this.ranges[o+t],u=this.ranges[o+r];e(a,a+d,c,c+u),i+=u-d}}invert(){return new Ht(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ht.empty:new Ht(e<0?[0,-e,0]:[0,0,e])}}Ht.empty=new Ht([]);class Xo{constructor(e,t,r=0,o=e?e.length:0){this.mirror=t,this.from=r,this.to=o,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Xo(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let o=e.getMirror(t);this.appendMap(e._maps[t],o!=null&&o<t?r+o:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let o=e.getMirror(t);this.appendMap(e._maps[t].invert(),o!=null&&o>t?r-o-1:void 0)}}invert(){let e=new Xo;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let o=0;for(let i=this.from;i<this.to;i++){let l=this._maps[i],a=l.mapResult(e,t);if(a.recover!=null){let c=this.getMirror(i);if(c!=null&&c>i&&c<this.to){i=c,e=this._maps[c].recover(a.recover);continue}}o|=a.delInfo,e=a.pos}return r?e:new Qa(e,o,null)}}const ec=Object.create(null);class At{getMap(){return Ht.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=ec[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in ec)throw new RangeError("Duplicate use of step JSON ID "+e);return ec[e]=t,t.prototype.jsonID=e,t}}class ct{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new ct(e,null)}static fail(e){return new ct(null,e)}static fromReplace(e,t,r,o){try{return ct.ok(e.replace(t,r,o))}catch(i){if(i instanceof io)return ct.fail(i.message);throw i}}}function tc(n,e,t){let r=[];for(let o=0;o<n.childCount;o++){let i=n.child(o);i.content.size&&(i=i.copy(tc(i.content,e,i))),i.isInline&&(i=e(i,t,o)),r.push(i)}return ee.fromArray(r)}class sr extends At{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),i=new fe(tc(t.content,(l,a)=>!l.isAtom||!a.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),o),t.openStart,t.openEnd);return ct.fromReplace(e,this.from,this.to,i)}invert(){return new an(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new sr(t.pos,r.pos,this.mark)}merge(e){return e instanceof sr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new sr(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new sr(t.from,t.to,e.markFromJSON(t.mark))}}At.jsonID("addMark",sr);class an extends At{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new fe(tc(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return ct.fromReplace(e,this.from,this.to,r)}invert(){return new sr(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new an(t.pos,r.pos,this.mark)}merge(e){return e instanceof an&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new an(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new an(t.from,t.to,e.markFromJSON(t.mark))}}At.jsonID("removeMark",an);class ir extends At{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ct.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ct.fromReplace(e,this.pos,this.pos+1,new fe(ee.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let o=0;o<t.marks.length;o++)if(!t.marks[o].isInSet(r))return new ir(this.pos,t.marks[o]);return new ir(this.pos,this.mark)}}return new Vr(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ir(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ir(t.pos,e.markFromJSON(t.mark))}}At.jsonID("addNodeMark",ir);class Vr extends At{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ct.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return ct.fromReplace(e,this.pos,this.pos+1,new fe(ee.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new ir(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Vr(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Vr(t.pos,e.markFromJSON(t.mark))}}At.jsonID("removeNodeMark",Vr);class lt extends At{constructor(e,t,r,o=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=o}apply(e){return this.structure&&nc(e,this.from,this.to)?ct.fail("Structure replace would overwrite content"):ct.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ht([this.from,this.to-this.from,this.slice.size])}invert(e){return new lt(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),r=this.from==this.to&&lt.MAP_BIAS<0?t:e.mapResult(this.from,1);return r.deletedAcross&&t.deletedAcross?null:new lt(r.pos,Math.max(r.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof lt)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?fe.empty:new fe(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new lt(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?fe.empty:new fe(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new lt(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new lt(t.from,t.to,fe.fromJSON(e,t.slice),!!t.structure)}}lt.MAP_BIAS=1,At.jsonID("replace",lt);class pt extends At{constructor(e,t,r,o,i,l,a=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=o,this.slice=i,this.insert=l,this.structure=a}apply(e){if(this.structure&&(nc(e,this.from,this.gapFrom)||nc(e,this.gapTo,this.to)))return ct.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return ct.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?ct.fromReplace(e,this.from,this.to,r):ct.fail("Content does not fit in gap")}getMap(){return new Ht([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new pt(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||o<t.pos||i>r.pos?null:new pt(t.pos,r.pos,o,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new pt(t.from,t.to,t.gapFrom,t.gapTo,fe.fromJSON(e,t.slice),t.insert,!!t.structure)}}At.jsonID("replaceAround",pt);function nc(n,e,t){let r=n.resolve(e),o=t-e,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let l=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,o--}}return!1}function jT(n,e,t,r){let o=[],i=[],l,a;n.doc.nodesBetween(e,t,(c,d,u)=>{if(!c.isInline)return;let f=c.marks;if(!r.isInSet(f)&&u.type.allowsMarkType(r.type)){let p=Math.max(d,e),h=Math.min(d+c.nodeSize,t),m=r.addToSet(f);for(let g=0;g<f.length;g++)f[g].isInSet(m)||(l&&l.to==p&&l.mark.eq(f[g])?l.to=h:o.push(l=new an(p,h,f[g])));a&&a.to==p?a.to=h:i.push(a=new sr(p,h,r))}}),o.forEach(c=>n.step(c)),i.forEach(c=>n.step(c))}function UT(n,e,t,r){let o=[],i=0;n.doc.nodesBetween(e,t,(l,a)=>{if(!l.isInline)return;i++;let c=null;if(r instanceof Go){let d=l.marks,u;for(;u=r.isInSet(d);)(c||(c=[])).push(u),d=u.removeFromSet(d)}else r?r.isInSet(l.marks)&&(c=[r]):c=l.marks;if(c&&c.length){let d=Math.min(a+l.nodeSize,t);for(let u=0;u<c.length;u++){let f=c[u],p;for(let h=0;h<o.length;h++){let m=o[h];m.step==i-1&&f.eq(o[h].style)&&(p=m)}p?(p.to=d,p.step=i):o.push({style:f,from:Math.max(a,e),to:d,step:i})}}}),o.forEach(l=>n.step(new an(l.from,l.to,l.style)))}function rc(n,e,t,r=t.contentMatch,o=!0){let i=n.doc.nodeAt(e),l=[],a=e+1;for(let c=0;c<i.childCount;c++){let d=i.child(c),u=a+d.nodeSize,f=r.matchType(d.type);if(!f)l.push(new lt(a,u,fe.empty));else{r=f;for(let p=0;p<d.marks.length;p++)t.allowsMarkType(d.marks[p].type)||n.step(new an(a,u,d.marks[p]));if(o&&d.isText&&t.whitespace!="pre"){let p,h=/\r?\n|\r/g,m;for(;p=h.exec(d.text);)m||(m=new fe(ee.from(t.schema.text(" ",t.allowedMarks(d.marks))),0,0)),l.push(new lt(a+p.index,a+p.index+p[0].length,m))}}a=u}if(!r.validEnd){let c=r.fillBefore(ee.empty,!0);n.replace(a,a,new fe(c,0,0))}for(let c=l.length-1;c>=0;c--)n.step(l[c])}function WT(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function ao(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,o=0,i=0;;--r){let l=n.$from.node(r),a=n.$from.index(r)+o,c=n.$to.indexAfter(r)-i;if(r<n.depth&&l.canReplace(a,c,t))return r;if(r==0||l.type.spec.isolating||!WT(l,a,c))break;a&&(o=1),c<l.childCount&&(i=1)}return null}function KT(n,e,t){let{$from:r,$to:o,depth:i}=e,l=r.before(i+1),a=o.after(i+1),c=l,d=a,u=ee.empty,f=0;for(let m=i,g=!1;m>t;m--)g||r.index(m)>0?(g=!0,u=ee.from(r.node(m).copy(u)),f++):c--;let p=ee.empty,h=0;for(let m=i,g=!1;m>t;m--)g||o.after(m+1)<o.end(m)?(g=!0,p=ee.from(o.node(m).copy(p)),h++):d++;n.step(new pt(c,d,l,a,new fe(u.append(p),f,h),u.size-f,!0))}function oc(n,e,t=null,r=n){let o=qT(n,e),i=o&&GT(r,e);return i?o.map(Ip).concat({type:e,attrs:t}).concat(i.map(Ip)):null}function Ip(n){return{type:n,attrs:null}}function qT(n,e){let{parent:t,startIndex:r,endIndex:o}=n,i=t.contentMatchAt(r).findWrapping(e);if(!i)return null;let l=i.length?i[0]:e;return t.canReplaceWith(r,o,l)?i:null}function GT(n,e){let{parent:t,startIndex:r,endIndex:o}=n,i=t.child(r),l=e.contentMatch.findWrapping(i.type);if(!l)return null;let c=(l.length?l[l.length-1]:e).contentMatch;for(let d=r;c&&d<o;d++)c=c.matchType(t.child(d).type);return!c||!c.validEnd?null:l}function JT(n,e,t){let r=ee.empty;for(let l=t.length-1;l>=0;l--){if(r.size){let a=t[l].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=ee.from(t[l].type.create(t[l].attrs,r))}let o=e.start,i=e.end;n.step(new pt(o,i,o,i,new fe(r,0,0),t.length,!0))}function YT(n,e,t,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(l,a)=>{let c=typeof o=="function"?o(l):o;if(l.isTextblock&&!l.hasMarkup(r,c)&&XT(n.doc,n.mapping.slice(i).map(a),r)){let d=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",m=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!m?d=!1:!h&&m&&(d=!0)}d===!1&&Rp(n,l,a,i),rc(n,n.mapping.slice(i).map(a,1),r,void 0,d===null);let u=n.mapping.slice(i),f=u.map(a,1),p=u.map(a+l.nodeSize,1);return n.step(new pt(f,p,f+1,p-1,new fe(ee.from(r.create(c,null,l.marks)),0,0),1,!0)),d===!0&&Op(n,l,a,i),!1}})}function Op(n,e,t,r){e.forEach((o,i)=>{if(o.isText){let l,a=/\r?\n|\r/g;for(;l=a.exec(o.text);){let c=n.mapping.slice(r).map(t+1+i+l.index);n.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function Rp(n,e,t,r){e.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let l=n.mapping.slice(r).map(t+1+i);n.replaceWith(l,l+1,e.type.schema.text(`
55
+ `))}})}function XT(n,e,t){let r=n.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,t)}function ZT(n,e,t,r,o){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let l=t.create(r,null,o||i.marks);if(i.isLeaf)return n.replaceWith(e,e+i.nodeSize,l);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new pt(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new fe(ee.from(l),0,0),1,!0))}function In(n,e,t=1,r){let o=n.resolve(e),i=o.depth-t,l=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!l.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let d=o.depth-1,u=t-2;d>i;d--,u--){let f=o.node(d),p=o.index(d);if(f.type.spec.isolating)return!1;let h=f.content.cutByIndex(p,f.childCount),m=r&&r[u+1];m&&(h=h.replaceChild(0,m.type.create(m.attrs)));let g=r&&r[u]||f;if(!f.canReplace(p+1,f.childCount)||!g.type.validContent(h))return!1}let a=o.indexAfter(i),c=r&&r[0];return o.node(i).canReplaceWith(a,a,c?c.type:o.node(i+1).type)}function QT(n,e,t=1,r){let o=n.doc.resolve(e),i=ee.empty,l=ee.empty;for(let a=o.depth,c=o.depth-t,d=t-1;a>c;a--,d--){i=ee.from(o.node(a).copy(i));let u=r&&r[d];l=ee.from(u?u.type.create(u.attrs,l):o.node(a).copy(l))}n.step(new lt(e,e,new fe(i.append(l),t,t),!0))}function lr(n,e){let t=n.resolve(e),r=t.index();return Fp(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function eB(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let o=0;o<e.childCount;o++){let i=e.child(o),l=i.type==r?n.type.schema.nodes.text:i.type;if(t=t.matchType(l),!t||!n.type.allowsMarks(i.marks))return!1}return t.validEnd}function Fp(n,e){return!!(n&&e&&!n.isLeaf&&eB(n,e))}function Ni(n,e,t=-1){let r=n.resolve(e);for(let o=r.depth;;o--){let i,l,a=r.index(o);if(o==r.depth?(i=r.nodeBefore,l=r.nodeAfter):t>0?(i=r.node(o+1),a++,l=r.node(o).maybeChild(a)):(i=r.node(o).maybeChild(a-1),l=r.node(o+1)),i&&!i.isTextblock&&Fp(i,l)&&r.node(o).canReplace(a,a+1))return e;if(o==0)break;e=t<0?r.before(o):r.after(o)}}function tB(n,e,t){let r=null,{linebreakReplacement:o}=n.doc.type.schema,i=n.doc.resolve(e-t),l=i.node().type;if(o&&l.inlineContent){let u=l.whitespace=="pre",f=!!l.contentMatch.matchType(o);u&&!f?r=!1:!u&&f&&(r=!0)}let a=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);Rp(n,u.node(),u.before(),a)}l.inlineContent&&rc(n,e+t-1,l,i.node().contentMatchAt(i.index()),r==null);let c=n.mapping.slice(a),d=c.map(e-t);if(n.step(new lt(d,c.map(e+t,-1),fe.empty,!0)),r===!0){let u=n.doc.resolve(d);Op(n,u.node(),u.before(),n.steps.length)}return n}function nB(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let i=r.index(o);if(r.node(o).canReplaceWith(i,i,t))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let i=r.indexAfter(o);if(r.node(o).canReplaceWith(i,i,t))return r.after(o+1);if(i<r.node(o).childCount)return null}return null}function Pp(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let o=t.content;for(let i=0;i<t.openStart;i++)o=o.firstChild.content;for(let i=1;i<=(t.openStart==0&&t.size?2:1);i++)for(let l=r.depth;l>=0;l--){let a=l==r.depth?0:r.pos<=(r.start(l+1)+r.end(l+1))/2?-1:1,c=r.index(l)+(a>0?1:0),d=r.node(l),u=!1;if(i==1)u=d.canReplace(c,c,o);else{let f=d.contentMatchAt(c).findWrapping(o.firstChild.type);u=f&&d.canReplaceWith(c,c,f[0])}if(u)return a==0?r.pos:a<0?r.before(l+1):r.after(l+1)}return null}function Di(n,e,t=e,r=fe.empty){if(e==t&&!r.size)return null;let o=n.resolve(e),i=n.resolve(t);return zp(o,i,r)?new lt(e,t,r):new rB(o,i,r).fit()}function zp(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class rB{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=ee.empty;for(let o=0;o<=e.depth;o++){let i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=ee.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let d=this.findFittable();d?this.placeNodes(d):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let i=this.placed,l=r.depth,a=o.depth;for(;l&&a&&i.childCount==1;)i=i.firstChild.content,l--,a--;let c=new fe(i,l,a);return e>-1?new pt(r.pos,e,this.$to.pos,this.$to.end(),c,t):c.size||r.pos!=this.$to.pos?new lt(r.pos,o.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<e;r++){let i=t.firstChild;if(t.childCount>1&&(o=0),i.type.spec.isolating&&o<=r){e=r;break}t=i.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let o,i=null;r?(i=sc(this.unplaced.content,r-1).firstChild,o=i.content):o=this.unplaced.content;let l=o.firstChild;for(let a=this.depth;a>=0;a--){let{type:c,match:d}=this.frontier[a],u,f=null;if(t==1&&(l?d.matchType(l.type)||(f=d.fillBefore(ee.from(l),!1)):i&&c.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:a,parent:i,inject:f};if(t==2&&l&&(u=d.findWrapping(l.type)))return{sliceDepth:r,frontierDepth:a,parent:i,wrap:u};if(i&&d.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=sc(e,t);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new fe(e,t+1,Math.max(r,o.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=sc(e,t);if(o.childCount<=1&&t>0){let i=e.size-t<=t+o.size;this.unplaced=new fe(Zo(e,t-1,1),t-1,i?t-1:r)}else this.unplaced=new fe(Zo(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:o,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let g=0;g<i.length;g++)this.openFrontierNode(i[g]);let l=this.unplaced,a=r?r.content:l.content,c=l.openStart-e,d=0,u=[],{match:f,type:p}=this.frontier[t];if(o){for(let g=0;g<o.childCount;g++)u.push(o.child(g));f=f.matchFragment(o)}let h=a.size+e-(l.content.size-l.openEnd);for(;d<a.childCount;){let g=a.child(d),y=f.matchType(g.type);if(!y)break;d++,(d>1||c==0||g.content.size)&&(f=y,u.push(Hp(g.mark(p.allowedMarks(g.marks)),d==1?c:0,d==a.childCount?h:-1)))}let m=d==a.childCount;m||(h=-1),this.placed=Qo(this.placed,t,ee.from(u)),this.frontier[t].match=f,m&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,y=a;g<h;g++){let b=y.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),y=b.content}this.unplaced=m?e==0?fe.empty:new fe(Zo(l.content,e-1,1),e-1,h<0?l.openEnd:e-1):new fe(Zo(l.content,e,d),l.openStart,l.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!ic(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:o}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),l=ic(e,t,o,r,i);if(l){for(let a=t-1;a>=0;a--){let{match:c,type:d}=this.frontier[a],u=ic(e,a,d,c,!0);if(!u||u.childCount)continue e}return{depth:t,fit:l,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Qo(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let o=e.node(r),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,t=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Qo(this.placed,this.depth,ee.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(ee.empty,!0);t.childCount&&(this.placed=Qo(this.placed,this.frontier.length,t))}}function Zo(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Zo(n.firstChild.content,e-1,t)))}function Qo(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Qo(n.lastChild.content,e-1,t)))}function sc(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Hp(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,Hp(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(ee.empty,!0)))),n.copy(r)}function ic(n,e,t,r,o){let i=n.node(e),l=o?n.indexAfter(e):n.index(e);if(l==i.childCount&&!t.compatibleContent(i.type))return null;let a=r.fillBefore(i.content,!0,l);return a&&!oB(t,i.content,l)?a:null}function oB(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function sB(n){return n.spec.defining||n.spec.definingForContent}function iB(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let o=n.doc.resolve(e),i=n.doc.resolve(t);if(zp(o,i,r))return n.step(new lt(e,t,r));let l=Up(o,i);l[l.length-1]==0&&l.pop();let a=-(o.depth+1);l.unshift(a);for(let p=o.depth,h=o.pos-1;p>0;p--,h--){let m=o.node(p).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;l.indexOf(p)>-1?a=p:o.before(p)==h&&l.splice(1,0,-p)}let c=l.indexOf(a),d=[],u=r.openStart;for(let p=r.content,h=0;;h++){let m=p.firstChild;if(d.push(m),h==r.openStart)break;p=m.content}for(let p=u-1;p>=0;p--){let h=d[p],m=sB(h.type);if(m&&!h.sameMarkup(o.node(Math.abs(a)-1)))u=p;else if(m||!h.type.isTextblock)break}for(let p=r.openStart;p>=0;p--){let h=(p+u+1)%(r.openStart+1),m=d[h];if(m)for(let g=0;g<l.length;g++){let y=l[(g+c)%l.length],b=!0;y<0&&(b=!1,y=-y);let w=o.node(y-1),v=o.index(y-1);if(w.canReplaceWith(v,v,m.type,m.marks))return n.replace(o.before(y),b?i.after(y):t,new fe(jp(r.content,0,r.openStart,h),h,r.openEnd))}}let f=n.steps.length;for(let p=l.length-1;p>=0&&(n.replace(e,t,r),!(n.steps.length>f));p--){let h=l[p];h<0||(e=o.before(h),t=i.after(h))}}function jp(n,e,t,r,o){if(e<t){let i=n.firstChild;n=n.replaceChild(0,i.copy(jp(i.content,e+1,t,r,i)))}if(e>r){let i=o.contentMatchAt(0),l=i.fillBefore(n).append(n);n=l.append(i.matchFragment(l).fillBefore(ee.empty,!0))}return n}function lB(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let o=nB(n.doc,e,r.type);o!=null&&(e=t=o)}n.replaceRange(e,t,new fe(ee.from(r),0,0))}function aB(n,e,t){let r=n.doc.resolve(e),o=n.doc.resolve(t);if(r.parent.isTextblock&&o.parent.isTextblock&&r.start()!=o.start()&&r.parentOffset==0&&o.parentOffset==0){let l=r.sharedDepth(t),a=!1;for(let c=r.depth;c>l;c--)r.node(c).type.spec.isolating&&(a=!0);for(let c=o.depth;c>l;c--)o.node(c).type.spec.isolating&&(a=!0);if(!a){for(let c=r.depth;c>0&&e==r.start(c);c--)e=r.before(c);for(let c=o.depth;c>0&&t==o.start(c);c--)t=o.before(c);r=n.doc.resolve(e),o=n.doc.resolve(t)}}let i=Up(r,o);for(let l=0;l<i.length;l++){let a=i[l],c=l==i.length-1;if(c&&a==0||r.node(a).type.contentMatch.validEnd)return n.delete(r.start(a),o.end(a));if(a>0&&(c||r.node(a-1).canReplace(r.index(a-1),o.indexAfter(a-1))))return n.delete(r.before(a),o.after(a))}for(let l=1;l<=r.depth&&l<=o.depth;l++)if(e-r.start(l)==r.depth-l&&t>r.end(l)&&o.end(l)-t!=o.depth-l&&r.start(l-1)==o.start(l-1)&&r.node(l-1).canReplace(r.index(l-1),o.index(l-1)))return n.delete(r.before(l),t);n.delete(e,t)}function Up(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let o=r;o>=0;o--){let i=n.start(o);if(i<n.pos-(n.depth-o)||e.end(o)>e.pos+(e.depth-o)||n.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(i==e.start(o)||o==n.depth&&o==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==i-1)&&t.push(o)}return t}class co extends At{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return ct.fail("No node at attribute step's position");let r=Object.create(null);for(let i in t.attrs)r[i]=t.attrs[i];r[this.attr]=this.value;let o=t.type.create(r,null,t.marks);return ct.fromReplace(e,this.pos,this.pos+1,new fe(ee.from(o),0,t.isLeaf?0:1))}getMap(){return Ht.empty}invert(e){return new co(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new co(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new co(t.pos,t.attr,t.value)}}At.jsonID("attr",co);class es extends At{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let o in e.attrs)t[o]=e.attrs[o];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return ct.ok(r)}getMap(){return Ht.empty}invert(e){return new es(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new es(t.attr,t.value)}}At.jsonID("docAttr",es);let uo=class extends Error{};uo=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},uo.prototype=Object.create(Error.prototype),uo.prototype.constructor=uo,uo.prototype.name="TransformError";class lc{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Xo}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new uo(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let o=this.mapping.maps[r];r&&(e=o.map(e,1),t=o.map(t,-1)),o.forEach((i,l,a,c)=>{e=Math.min(e,a),t=Math.max(t,c)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=fe.empty){let o=Di(this.doc,e,t,r);return o&&this.step(o),this}replaceWith(e,t,r){return this.replace(e,t,new fe(ee.from(r),0,0))}delete(e,t){return this.replace(e,t,fe.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return iB(this,e,t,r),this}replaceRangeWith(e,t,r){return lB(this,e,t,r),this}deleteRange(e,t){return aB(this,e,t),this}lift(e,t){return KT(this,e,t),this}join(e,t=1){return tB(this,e,t),this}wrap(e,t){return JT(this,e,t),this}setBlockType(e,t=e,r,o=null){return YT(this,e,t,r,o),this}setNodeMarkup(e,t,r=null,o){return ZT(this,e,t,r,o),this}setNodeAttribute(e,t,r){return this.step(new co(e,t,r)),this}setDocAttribute(e,t){return this.step(new es(e,t)),this}addNodeMark(e,t){return this.step(new ir(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof Ue)t.isInSet(r.marks)&&this.step(new Vr(e,t));else{let o=r.marks,i,l=[];for(;i=t.isInSet(o);)l.push(new Vr(e,i)),o=i.removeFromSet(o);for(let a=l.length-1;a>=0;a--)this.step(l[a])}return this}split(e,t=1,r){return QT(this,e,t,r),this}addMark(e,t,r){return jT(this,e,t,r),this}removeMark(e,t,r){return UT(this,e,t,r),this}clearIncompatible(e,t,r){return rc(this,e,t,r),this}}const ac=Object.create(null);class Ae{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Wp(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=fe.empty){let r=t.content.lastChild,o=null;for(let a=0;a<t.openEnd;a++)o=r,r=r.lastChild;let i=e.steps.length,l=this.ranges;for(let a=0;a<l.length;a++){let{$from:c,$to:d}=l[a],u=e.mapping.slice(i);e.replaceRange(u.map(c.pos),u.map(d.pos),a?fe.empty:t),a==0&&Gp(e,i,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){let{$from:l,$to:a}=o[i],c=e.mapping.slice(r),d=c.map(l.pos),u=c.map(a.pos);i?e.deleteRange(d,u):(e.replaceRangeWith(d,u,t),Gp(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let o=e.parent.inlineContent?new be(e):fo(e.node(0),e.parent,e.pos,e.index(),t,r);if(o)return o;for(let i=e.depth-1;i>=0;i--){let l=t<0?fo(e.node(0),e.node(i),e.before(i+1),e.index(i),t,r):fo(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,r);if(l)return l}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new jt(e.node(0))}static atStart(e){return fo(e,e,0,0,1)||new jt(e)}static atEnd(e){return fo(e,e,e.content.size,e.childCount,-1)||new jt(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=ac[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in ac)throw new RangeError("Duplicate use of selection JSON ID "+e);return ac[e]=t,t.prototype.jsonID=e,t}getBookmark(){return be.between(this.$anchor,this.$head).getBookmark()}}Ae.prototype.visible=!0;class Wp{constructor(e,t){this.$from=e,this.$to=t}}let Kp=!1;function qp(n){!Kp&&!n.parent.inlineContent&&(Kp=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class be extends Ae{constructor(e,t=e){qp(e),qp(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return Ae.near(r);let o=e.resolve(t.map(this.anchor));return new be(o.parent.inlineContent?o:r,r)}replace(e,t=fe.empty){if(super.replace(e,t),t==fe.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof be&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Vi(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new be(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let o=e.resolve(t);return new this(o,r==t?o:e.resolve(r))}static between(e,t,r){let o=e.pos-t.pos;if((!r||o)&&(r=o>=0?1:-1),!t.parent.inlineContent){let i=Ae.findFrom(t,r,!0)||Ae.findFrom(t,-r,!0);if(i)t=i.$head;else return Ae.near(t,r)}return e.parent.inlineContent||(o==0?e=t:(e=(Ae.findFrom(e,-r,!0)||Ae.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=o<0&&(e=t))),new be(e,t)}}Ae.jsonID("text",be);class Vi{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Vi(e.map(this.anchor),e.map(this.head))}resolve(e){return be.between(e.resolve(this.anchor),e.resolve(this.head))}}class Ce extends Ae{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:o}=t.mapResult(this.anchor),i=e.resolve(o);return r?Ae.near(i):new Ce(i)}content(){return new fe(ee.from(this.node),0,0)}eq(e){return e instanceof Ce&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new cc(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Ce(e.resolve(t.anchor))}static create(e,t){return new Ce(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Ce.prototype.visible=!1,Ae.jsonID("node",Ce);class cc{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Vi(r,r):new cc(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&Ce.isSelectable(r)?new Ce(t):Ae.near(t)}}class jt extends Ae{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=fe.empty){if(t==fe.empty){e.delete(0,e.doc.content.size);let r=Ae.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new jt(e)}map(e){return new jt(e)}eq(e){return e instanceof jt}getBookmark(){return cB}}Ae.jsonID("all",jt);const cB={map(){return this},resolve(n){return new jt(n)}};function fo(n,e,t,r,o,i=!1){if(e.inlineContent)return be.create(n,t);for(let l=r-(o>0?0:1);o>0?l<e.childCount:l>=0;l+=o){let a=e.child(l);if(a.isAtom){if(!i&&Ce.isSelectable(a))return Ce.create(n,t-(o<0?a.nodeSize:0))}else{let c=fo(n,a,t+o,o<0?a.childCount:0,o,i);if(c)return c}t+=a.nodeSize*o}return null}function Gp(n,e,t){let r=n.steps.length-1;if(r<e)return;let o=n.steps[r];if(!(o instanceof lt||o instanceof pt))return;let i=n.mapping.maps[r],l;i.forEach((a,c,d,u)=>{l==null&&(l=u)}),n.setSelection(Ae.near(n.doc.resolve(l),t))}const Jp=1,$i=2,Yp=4;class dB extends lc{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Jp)&~$i,this.storedMarks=null,this}get selectionSet(){return(this.updated&Jp)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=$i,this}ensureMarks(e){return Ue.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&$i)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~$i,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Ue.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let o=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let i=this.storedMarks;if(!i){let l=this.doc.resolve(t);i=r==t?l.marks():l.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,o.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(Ae.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Yp,this}get scrolledIntoView(){return(this.updated&Yp)>0}}function Xp(n,e){return!e||!n?n:n.bind(e)}class ts{constructor(e,t,r){this.name=e,this.init=Xp(t.init,r),this.apply=Xp(t.apply,r)}}const uB=[new ts("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new ts("selection",{init(n,e){return n.selection||Ae.atStart(e.doc)},apply(n){return n.selection}}),new ts("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new ts("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class dc{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=uB.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new ts(r.key,r.spec.state,r))})}}class $r{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let o=this.config.plugins[r];if(o.spec.filterTransaction&&!o.spec.filterTransaction.call(o,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),o=null;for(;;){let i=!1;for(let l=0;l<this.config.plugins.length;l++){let a=this.config.plugins[l];if(a.spec.appendTransaction){let c=o?o[l].n:0,d=o?o[l].state:this,u=c<t.length&&a.spec.appendTransaction.call(a,c?t.slice(c):t,d,r);if(u&&r.filterTransaction(u,l)){if(u.setMeta("appendedTransaction",e),!o){o=[];for(let f=0;f<this.config.plugins.length;f++)o.push(f<l?{state:r,n:t.length}:{state:this,n:0})}t.push(u),r=r.applyInner(u),i=!0}o&&(o[l]={state:r,n:t.length})}}if(!i)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new $r(this.config),r=this.config.fields;for(let o=0;o<r.length;o++){let i=r[o];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new dB(this)}static create(e){let t=new dc(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new $r(t);for(let o=0;o<t.fields.length;o++)r[t.fields[o].name]=t.fields[o].init(e,r);return r}reconfigure(e){let t=new dc(this.schema,e.plugins),r=t.fields,o=new $r(t);for(let i=0;i<r.length;i++){let l=r[i].name;o[l]=this.hasOwnProperty(l)?this[l]:r[i].init(e,o)}return o}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[r],i=o.spec.state;i&&i.toJSON&&(t[r]=i.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new dc(e.schema,e.plugins),i=new $r(o);return o.fields.forEach(l=>{if(l.name=="doc")i.doc=mn.fromJSON(e.schema,t.doc);else if(l.name=="selection")i.selection=Ae.fromJSON(i.doc,t.selection);else if(l.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let a in r){let c=r[a],d=c.spec.state;if(c.key==l.name&&d&&d.fromJSON&&Object.prototype.hasOwnProperty.call(t,a)){i[l.name]=d.fromJSON.call(c,e,t[a],i);return}}i[l.name]=l.init(e,i)}}),i}}function Zp(n,e,t){for(let r in n){let o=n[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=Zp(o,e,{})),t[r]=o}return t}class Ke{constructor(e){this.spec=e,this.props={},e.props&&Zp(e.props,this,this.props),this.key=e.key?e.key.key:Qp("plugin")}getState(e){return e[this.key]}}const uc=Object.create(null);function Qp(n){return n in uc?n+"$"+ ++uc[n]:(uc[n]=0,n+"$")}class Qe{constructor(e="key"){this.key=Qp(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const eh=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function th(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const nh=(n,e,t)=>{let r=th(n,t);if(!r)return!1;let o=fc(r);if(!o){let l=r.blockRange(),a=l&&ao(l);return a==null?!1:(e&&e(n.tr.lift(l,a).scrollIntoView()),!0)}let i=o.nodeBefore;if(uh(n,o,e,-1))return!0;if(r.parent.content.size==0&&(po(i,"end")||Ce.isSelectable(i)))for(let l=r.depth;;l--){let a=Di(n.doc,r.before(l),r.after(l),fe.empty);if(a&&a.slice.size<a.to-a.from){if(e){let c=n.tr.step(a);c.setSelection(po(i,"end")?Ae.findFrom(c.doc.resolve(c.mapping.map(o.pos,-1)),-1):Ce.create(c.doc,o.pos-i.nodeSize)),e(c.scrollIntoView())}return!0}if(l==1||r.node(l-1).childCount>1)break}return i.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1},fB=(n,e,t)=>{let r=th(n,t);if(!r)return!1;let o=fc(r);return o?rh(n,o,e):!1},pB=(n,e,t)=>{let r=sh(n,t);if(!r)return!1;let o=pc(r);return o?rh(n,o,e):!1};function rh(n,e,t){let r=e.nodeBefore,o=r,i=e.pos-1;for(;!o.isTextblock;i--){if(o.type.spec.isolating)return!1;let u=o.lastChild;if(!u)return!1;o=u}let l=e.nodeAfter,a=l,c=e.pos+1;for(;!a.isTextblock;c++){if(a.type.spec.isolating)return!1;let u=a.firstChild;if(!u)return!1;a=u}let d=Di(n.doc,i,c,fe.empty);if(!d||d.from!=i||d instanceof lt&&d.slice.size>=c-i)return!1;if(t){let u=n.tr.step(d);u.setSelection(be.create(u.doc,i)),t(u.scrollIntoView())}return!0}function po(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const oh=(n,e,t)=>{let{$head:r,empty:o}=n.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;i=fc(r)}let l=i&&i.nodeBefore;return!l||!Ce.isSelectable(l)?!1:(e&&e(n.tr.setSelection(Ce.create(n.doc,i.pos-l.nodeSize)).scrollIntoView()),!0)};function fc(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function sh(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const ih=(n,e,t)=>{let r=sh(n,t);if(!r)return!1;let o=pc(r);if(!o)return!1;let i=o.nodeAfter;if(uh(n,o,e,1))return!0;if(r.parent.content.size==0&&(po(i,"start")||Ce.isSelectable(i))){let l=Di(n.doc,r.before(),r.after(),fe.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(po(i,"start")?Ae.findFrom(a.doc.resolve(a.mapping.map(o.pos)),1):Ce.create(a.doc,a.mapping.map(o.pos))),e(a.scrollIntoView())}return!0}}return i.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0):!1},lh=(n,e,t)=>{let{$head:r,empty:o}=n.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;i=pc(r)}let l=i&&i.nodeAfter;return!l||!Ce.isSelectable(l)?!1:(e&&e(n.tr.setSelection(Ce.create(n.doc,i.pos)).scrollIntoView()),!0)};function pc(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const hB=(n,e)=>{let t=n.selection,r=t instanceof Ce,o;if(r){if(t.node.isTextblock||!lr(n.doc,t.from))return!1;o=t.from}else if(o=Ni(n.doc,t.from,-1),o==null)return!1;if(e){let i=n.tr.join(o);r&&i.setSelection(Ce.create(i.doc,o-n.doc.resolve(o).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},mB=(n,e)=>{let t=n.selection,r;if(t instanceof Ce){if(t.node.isTextblock||!lr(n.doc,t.to))return!1;r=t.to}else if(r=Ni(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},gB=(n,e)=>{let{$from:t,$to:r}=n.selection,o=t.blockRange(r),i=o&&ao(o);return i==null?!1:(e&&e(n.tr.lift(o,i).scrollIntoView()),!0)},ah=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
56
+ `).scrollIntoView()),!0)};function hc(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const yB=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let o=t.node(-1),i=t.indexAfter(-1),l=hc(o.contentMatchAt(i));if(!l||!o.canReplaceWith(i,i,l))return!1;if(e){let a=t.after(),c=n.tr.replaceWith(a,a,l.createAndFill());c.setSelection(Ae.near(c.doc.resolve(a),1)),e(c.scrollIntoView())}return!0},ch=(n,e)=>{let t=n.selection,{$from:r,$to:o}=t;if(t instanceof jt||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=hc(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let l=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,a=n.tr.insert(l,i.createAndFill());a.setSelection(be.create(a.doc,l+1)),e(a.scrollIntoView())}return!0},dh=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let i=t.before();if(In(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let r=t.blockRange(),o=r&&ao(r);return o==null?!1:(e&&e(n.tr.lift(r,o).scrollIntoView()),!0)};function bB(n){return(e,t)=>{if(e.selection instanceof Ce&&e.selection.node.isBlock){let{$from:h}=e.selection;return!h.parentOffset||!In(e.doc,h.pos)?!1:(t&&t(e.tr.split(h.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let r=e.tr;!e.selection.empty&&(e.selection instanceof be||e.selection instanceof jt)&&r.deleteSelection();let{$from:o}=r.selection,i=r.steps.length,l=[],a,c,d=!1,u=!1;for(let h=o.depth;;h--)if(o.node(h).isBlock){d=o.end(h)==o.pos+(o.depth-h),u=o.start(h)==o.pos-(o.depth-h),c=hc(o.node(h-1).contentMatchAt(o.indexAfter(h-1))),l.unshift(d&&c?{type:c}:null),a=h;break}else{if(h==1)return!1;l.unshift(null)}let f=o.pos,p=In(r.doc,f,l.length,l);if(p||(l[0]=c?{type:c}:null,p=In(r.doc,f,l.length,l)),!p)return!1;if(r.split(f,l.length,l),!d&&u&&o.node(a).type!=c){let h=r.mapping.slice(i),m=h.map(o.before(a)),g=r.doc.resolve(m);c&&o.node(a-1).canReplaceWith(g.index(),g.index()+1,c)&&r.setNodeMarkup(h.map(o.before(a)),c)}return t&&t(r.scrollIntoView()),!0}}const kB=bB(),wB=(n,e)=>{let{$from:t,to:r}=n.selection,o,i=t.sharedDepth(r);return i==0?!1:(o=t.before(i),e&&e(n.tr.setSelection(Ce.create(n.doc,o))),!0)};function xB(n,e,t){let r=e.nodeBefore,o=e.nodeAfter,i=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(o.isTextblock||lr(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function uh(n,e,t,r){let o=e.nodeBefore,i=e.nodeAfter,l,a,c=o.type.spec.isolating||i.type.spec.isolating;if(!c&&xB(n,e,t))return!0;let d=!c&&e.parent.canReplace(e.index(),e.index()+1);if(d&&(l=(a=o.contentMatchAt(o.childCount)).findWrapping(i.type))&&a.matchType(l[0]||i.type).validEnd){if(t){let h=e.pos+i.nodeSize,m=ee.empty;for(let b=l.length-1;b>=0;b--)m=ee.from(l[b].create(null,m));m=ee.from(o.copy(m));let g=n.tr.step(new pt(e.pos-1,h,e.pos,h,new fe(m,1,0),l.length,!0)),y=g.doc.resolve(h+2*l.length);y.nodeAfter&&y.nodeAfter.type==o.type&&lr(g.doc,y.pos)&&g.join(y.pos),t(g.scrollIntoView())}return!0}let u=i.type.spec.isolating||r>0&&c?null:Ae.findFrom(e,1),f=u&&u.$from.blockRange(u.$to),p=f&&ao(f);if(p!=null&&p>=e.depth)return t&&t(n.tr.lift(f,p).scrollIntoView()),!0;if(d&&po(i,"start",!0)&&po(o,"end")){let h=o,m=[];for(;m.push(h),!h.isTextblock;)h=h.lastChild;let g=i,y=1;for(;!g.isTextblock;g=g.firstChild)y++;if(h.canReplace(h.childCount,h.childCount,g.content)){if(t){let b=ee.empty;for(let v=m.length-1;v>=0;v--)b=ee.from(m[v].copy(b));let w=n.tr.step(new pt(e.pos-m.length,e.pos+i.nodeSize,e.pos+y,e.pos+i.nodeSize-y,new fe(b,m.length,0),0,!0));t(w.scrollIntoView())}return!0}}return!1}function fh(n){return function(e,t){let r=e.selection,o=n<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(t&&t(e.tr.setSelection(be.create(e.doc,n<0?o.start(i):o.end(i)))),!0):!1}}const vB=fh(-1),CB=fh(1);function SB(n,e=null){return function(t,r){let{$from:o,$to:i}=t.selection,l=o.blockRange(i),a=l&&oc(l,n,e);return a?(r&&r(t.tr.wrap(l,a).scrollIntoView()),!0):!1}}function ph(n,e=null){return function(t,r){let o=!1;for(let i=0;i<t.selection.ranges.length&&!o;i++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[i];t.doc.nodesBetween(l,a,(c,d)=>{if(o)return!1;if(!(!c.isTextblock||c.hasMarkup(n,e)))if(c.type==n)o=!0;else{let u=t.doc.resolve(d),f=u.index();o=u.parent.canReplaceWith(f,f+1,n)}})}if(!o)return!1;if(r){let i=t.tr;for(let l=0;l<t.selection.ranges.length;l++){let{$from:{pos:a},$to:{pos:c}}=t.selection.ranges[l];i.setBlockType(a,c,n,e)}r(i.scrollIntoView())}return!0}}function mc(...n){return function(e,t,r){for(let o=0;o<n.length;o++)if(n[o](e,t,r))return!0;return!1}}mc(eh,nh,oh),mc(eh,ih,lh),mc(ah,ch,dh,kB),typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";const EB=Object.freeze(Object.defineProperty({__proto__:null,ContentMatch:rr,DOMParser:Dr,DOMSerializer:or,Fragment:ee,Mark:Ue,MarkType:Go,Node:mn,NodeRange:qo,NodeType:Ya,ReplaceError:io,ResolvedPos:lo,Schema:Xa,Slice:fe},Symbol.toStringTag,{value:"Module"}));function MB(n,e=null){return function(t,r){let{$from:o,$to:i}=t.selection,l=o.blockRange(i);if(!l)return!1;let a=r?t.tr:null;return AB(a,l,n,e)?(r&&r(a.scrollIntoView()),!0):!1}}function AB(n,e,t,r=null){let o=!1,i=e,l=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let c=l.resolve(e.start-2);i=new qo(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new qo(e.$from,l.resolve(e.$to.end(e.depth)),e.depth)),o=!0}let a=oc(i,t,r,e);return a?(n&&_B(n,e,a,o,t),!0):!1}function _B(n,e,t,r,o){let i=ee.empty;for(let u=t.length-1;u>=0;u--)i=ee.from(t[u].type.create(t[u].attrs,i));n.step(new pt(e.start-(r?2:0),e.end,e.start,e.end,new fe(i,0,0),t.length,!0));let l=0;for(let u=0;u<t.length;u++)t[u].type==o&&(l=u+1);let a=t.length-l,c=e.start+t.length-(r?2:0),d=e.parent;for(let u=e.startIndex,f=e.endIndex,p=!0;u<f;u++,p=!1)!p&&In(n.doc,c,a)&&(n.split(c,a),c+=2*a),c+=d.child(u).nodeSize;return n}function TB(n){return function(e,t){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,l=>l.childCount>0&&l.firstChild.type==n);return i?t?r.node(i.depth-1).type==n?BB(e,t,n,i):NB(e,t,i):!0:!1}}function BB(n,e,t,r){let o=n.tr,i=r.end,l=r.$to.end(r.depth);i<l&&(o.step(new pt(i-1,l,i,l,new fe(ee.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new qo(o.doc.resolve(r.$from.pos),o.doc.resolve(l),r.depth));const a=ao(r);if(a==null)return!1;o.lift(r,a);let c=o.doc.resolve(o.mapping.map(i,-1)-1);return lr(o.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&o.join(c.pos),e(o.scrollIntoView()),!0}function NB(n,e,t){let r=n.tr,o=t.parent;for(let h=t.end,m=t.endIndex-1,g=t.startIndex;m>g;m--)h-=o.child(m).nodeSize,r.delete(h-1,h+1);let i=r.doc.resolve(t.start),l=i.nodeAfter;if(r.mapping.map(t.end)!=t.start+i.nodeAfter.nodeSize)return!1;let a=t.startIndex==0,c=t.endIndex==o.childCount,d=i.node(-1),u=i.index(-1);if(!d.canReplace(u+(a?0:1),u+1,l.content.append(c?ee.empty:ee.from(o))))return!1;let f=i.pos,p=f+l.nodeSize;return r.step(new pt(f-(a?1:0),p+(c?1:0),f+1,p-1,new fe((a?ee.empty:ee.from(o.copy(ee.empty))).append(c?ee.empty:ee.from(o.copy(ee.empty))),a?0:1,c?0:1),a?0:1)),e(r.scrollIntoView()),!0}function DB(n){return function(e,t){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,d=>d.childCount>0&&d.firstChild.type==n);if(!i)return!1;let l=i.startIndex;if(l==0)return!1;let a=i.parent,c=a.child(l-1);if(c.type!=n)return!1;if(t){let d=c.lastChild&&c.lastChild.type==a.type,u=ee.from(d?n.create():null),f=new fe(ee.from(n.create(null,ee.from(a.type.create(null,u)))),d?3:1,0),p=i.start,h=i.end;t(e.tr.step(new pt(p-(d?3:1),h,p,h,f,1,!0)).scrollIntoView())}return!0}}const vt=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},ho=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let gc=null;const On=function(n,e,t){let r=gc||(gc=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},VB=function(){gc=null},Lr=function(n,e,t,r){return t&&(hh(n,e,t,r,-1)||hh(n,e,t,r,1))},$B=/^(img|br|input|textarea|hr)$/i;function hh(n,e,t,r,o){for(var i;;){if(n==t&&e==r)return!0;if(e==(o<0?0:Gt(n))){let l=n.parentNode;if(!l||l.nodeType!=1||ns(n)||$B.test(n.nodeName)||n.contentEditable=="false")return!1;e=vt(n)+(o<0?0:1),n=l}else if(n.nodeType==1){let l=n.childNodes[e+(o<0?-1:0)];if(l.nodeType==1&&l.contentEditable=="false")if(!((i=l.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=o;else return!1;else n=l,e=o<0?Gt(n):0}else return!1}}function Gt(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function LB(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Gt(n)}else if(n.parentNode&&!ns(n))e=vt(n),n=n.parentNode;else return null}}function IB(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!ns(n))e=vt(n)+1,n=n.parentNode;else return null}}function OB(n,e,t){for(let r=e==0,o=e==Gt(n);r||o;){if(n==t)return!0;let i=vt(n);if(n=n.parentNode,!n)return!1;r=r&&i==0,o=o&&i==Gt(n)}}function ns(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Li=function(n){return n.focusNode&&Lr(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Ir(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function RB(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function FB(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(Gt(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(Gt(r.startContainer),r.startOffset)}}}const gn=typeof navigator<"u"?navigator:null,mh=typeof document<"u"?document:null,ar=gn&&gn.userAgent||"",yc=/Edge\/(\d+)/.exec(ar),gh=/MSIE \d/.exec(ar),bc=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ar),Ot=!!(gh||bc||yc),cr=gh?document.documentMode:bc?+bc[1]:yc?+yc[1]:0,Jt=!Ot&&/gecko\/(\d+)/i.test(ar);Jt&&+(/Firefox\/(\d+)/.exec(ar)||[0,0])[1];const kc=!Ot&&/Chrome\/(\d+)/.exec(ar),Ct=!!kc,yh=kc?+kc[1]:0,_t=!Ot&&!!gn&&/Apple Computer/.test(gn.vendor),mo=_t&&(/Mobile\/\w+/.test(ar)||!!gn&&gn.maxTouchPoints>2),Yt=mo||(gn?/Mac/.test(gn.platform):!1),bh=gn?/Win/.test(gn.platform):!1,Rn=/Android \d/.test(ar),rs=!!mh&&"webkitFontSmoothing"in mh.documentElement.style,PB=rs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function zB(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Fn(n,e){return typeof n=="number"?n:n[e]}function HB(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function kh(n,e,t){if(!xc(e)&&e.left==0)return;let r=n.someProp("scrollThreshold")||0,o=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let l=t||n.dom;l;){if(l.nodeType!=1){l=ho(l);continue}let a=l,c=a==i.body,d=c?zB(i):HB(a),u=0,f=0;if(e.top<d.top+Fn(r,"top")?f=-(d.top-e.top+Fn(o,"top")):e.bottom>d.bottom-Fn(r,"bottom")&&(f=e.bottom-e.top>d.bottom-d.top?e.top+Fn(o,"top")-d.top:e.bottom-d.bottom+Fn(o,"bottom")),e.left<d.left+Fn(r,"left")?u=-(d.left-e.left+Fn(o,"left")):e.right>d.right-Fn(r,"right")&&(u=e.right-d.right+Fn(o,"right")),u||f)if(c)i.defaultView.scrollBy(u,f);else{let h=a.scrollLeft,m=a.scrollTop;f&&(a.scrollTop+=f),u&&(a.scrollLeft+=u);let g=a.scrollLeft-h,y=a.scrollTop-m;e={left:e.left-g,top:e.top-y,right:e.right-g,bottom:e.bottom-y}}let p=c?"fixed":getComputedStyle(l).position;if(/^(fixed|sticky)$/.test(p))break;l=p=="absolute"?l.offsetParent:ho(l)}}function jB(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,o;for(let i=(e.left+e.right)/2,l=t+1;l<Math.min(innerHeight,e.bottom);l+=5){let a=n.root.elementFromPoint(i,l);if(!a||a==n.dom||!n.dom.contains(a))continue;let c=a.getBoundingClientRect();if(c.top>=t-20){r=a,o=c.top;break}}return{refDOM:r,refTop:o,stack:wh(n.dom)}}function wh(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=ho(r));return e}function UB({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;xh(t,r==0?0:r-e)}function xh(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:o,left:i}=n[t];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let go=null;function WB(n){if(n.setActive)return n.setActive();if(go)return n.focus(go);let e=wh(n);n.focus(go==null?{get preventScroll(){return go={preventScroll:!0},!0}}:void 0),go||(go=!1,xh(e,0))}function vh(n,e){let t,r=2e8,o,i=0,l=e.top,a=e.top,c,d;for(let u=n.firstChild,f=0;u;u=u.nextSibling,f++){let p;if(u.nodeType==1)p=u.getClientRects();else if(u.nodeType==3)p=On(u).getClientRects();else continue;for(let h=0;h<p.length;h++){let m=p[h];if(m.top<=l&&m.bottom>=a){l=Math.max(m.bottom,l),a=Math.min(m.top,a);let g=m.left>e.left?m.left-e.left:m.right<e.left?e.left-m.right:0;if(g<r){t=u,r=g,o=g&&t.nodeType==3?{left:m.right<e.left?m.right:m.left,top:e.top}:e,u.nodeType==1&&g&&(i=f+(e.left>=(m.left+m.right)/2?1:0));continue}}else m.top>e.top&&!c&&m.left<=e.left&&m.right>=e.left&&(c=u,d={left:Math.max(m.left,Math.min(m.right,e.left)),top:m.top});!t&&(e.left>=m.right&&e.top>=m.top||e.left>=m.left&&e.top>=m.bottom)&&(i=f+1)}}return!t&&c&&(t=c,o=d,r=0),t&&t.nodeType==3?KB(t,o):!t||r&&t.nodeType==1?{node:n,offset:i}:vh(t,o)}function KB(n,e){let t=n.nodeValue.length,r=document.createRange(),o;for(let i=0;i<t;i++){r.setEnd(n,i+1),r.setStart(n,i);let l=dr(r,1);if(l.top!=l.bottom&&wc(e,l)){o={node:n,offset:i+(e.left>=(l.left+l.right)/2?1:0)};break}}return r.detach(),o||{node:n,offset:0}}function wc(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function qB(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function GB(n,e,t){let{node:r,offset:o}=vh(e,t),i=-1;if(r.nodeType==1&&!r.firstChild){let l=r.getBoundingClientRect();i=l.left!=l.right&&t.left>(l.left+l.right)/2?1:-1}return n.docView.posFromDOM(r,o,i)}function JB(n,e,t,r){let o=-1;for(let i=e,l=!1;i!=n.dom;){let a=n.docView.nearestDesc(i,!0),c;if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent||!a.contentDOM)&&((c=a.dom.getBoundingClientRect()).width||c.height)&&(a.node.isBlock&&a.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(a.dom.nodeName)&&(!l&&c.left>r.left||c.top>r.top?o=a.posBefore:(!l&&c.right<r.left||c.bottom<r.top)&&(o=a.posAfter),l=!0),!a.contentDOM&&o<0&&!a.node.isText))return(a.node.isBlock?r.top<(c.top+c.bottom)/2:r.left<(c.left+c.right)/2)?a.posBefore:a.posAfter;i=a.dom.parentNode}return o>-1?o:n.docView.posFromDOM(e,t,-1)}function Ch(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),i=o;;){let l=n.childNodes[i];if(l.nodeType==1){let a=l.getClientRects();for(let c=0;c<a.length;c++){let d=a[c];if(wc(e,d))return Ch(l,e,d)}}if((i=(i+1)%r)==o)break}return n}function YB(n,e){let t=n.dom.ownerDocument,r,o=0,i=FB(t,e.left,e.top);i&&({node:r,offset:o}=i);let l=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),a;if(!l||!n.dom.contains(l.nodeType!=1?l.parentNode:l)){let d=n.dom.getBoundingClientRect();if(!wc(e,d)||(l=Ch(n.dom,e,d),!l))return null}if(_t)for(let d=l;r&&d;d=ho(d))d.draggable&&(r=void 0);if(l=qB(l,e),r){if(Jt&&r.nodeType==1&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let u=r.childNodes[o],f;u.nodeName=="IMG"&&(f=u.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&o++}let d;rs&&o&&r.nodeType==1&&(d=r.childNodes[o-1]).nodeType==1&&d.contentEditable=="false"&&d.getBoundingClientRect().top>=e.top&&o--,r==n.dom&&o==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?a=n.state.doc.content.size:(o==0||r.nodeType!=1||r.childNodes[o-1].nodeName!="BR")&&(a=JB(n,r,o,e))}a==null&&(a=GB(n,l,e));let c=n.docView.nearestDesc(l,!0);return{pos:a,inside:c?c.posAtStart-c.border:-1}}function xc(n){return n.top<n.bottom||n.left<n.right}function dr(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(xc(r))return r}return Array.prototype.find.call(t,xc)||n.getBoundingClientRect()}const XB=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Sh(n,e,t){let{node:r,offset:o,atom:i}=n.docView.domFromPos(e,t<0?-1:1),l=rs||Jt;if(r.nodeType==3)if(l&&(XB.test(r.nodeValue)||(t<0?!o:o==r.nodeValue.length))){let c=dr(On(r,o,o),t);if(Jt&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let d=dr(On(r,o-1,o-1),-1);if(d.top==c.top){let u=dr(On(r,o,o+1),-1);if(u.top!=c.top)return ss(u,u.left<d.left)}}return c}else{let c=o,d=o,u=t<0?1:-1;return t<0&&!o?(d++,u=-1):t>=0&&o==r.nodeValue.length?(c--,u=1):t<0?c--:d++,ss(dr(On(r,c,d),u),u<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(t<0||o==Gt(r))){let c=r.childNodes[o-1];if(c.nodeType==1)return vc(c.getBoundingClientRect(),!1)}if(i==null&&o<Gt(r)){let c=r.childNodes[o];if(c.nodeType==1)return vc(c.getBoundingClientRect(),!0)}return vc(r.getBoundingClientRect(),t>=0)}if(i==null&&o&&(t<0||o==Gt(r))){let c=r.childNodes[o-1],d=c.nodeType==3?On(c,Gt(c)-(l?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(d)return ss(dr(d,1),!1)}if(i==null&&o<Gt(r)){let c=r.childNodes[o];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let d=c?c.nodeType==3?On(c,0,l?0:1):c.nodeType==1?c:null:null;if(d)return ss(dr(d,-1),!0)}return ss(dr(r.nodeType==3?On(r):r,-t),t>=0)}function ss(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function vc(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Eh(n,e,t){let r=n.state,o=n.root.activeElement;r!=e&&n.updateState(e),o!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),o!=n.dom&&o&&o.focus()}}function ZB(n,e,t){let r=e.selection,o=t=="up"?r.$from:r.$to;return Eh(n,e,()=>{let{node:i}=n.docView.domFromPos(o.pos,t=="up"?-1:1);for(;;){let a=n.docView.nearestDesc(i,!0);if(!a)break;if(a.node.isBlock){i=a.contentDOM||a.dom;break}i=a.dom.parentNode}let l=Sh(n,o.pos,1);for(let a=i.firstChild;a;a=a.nextSibling){let c;if(a.nodeType==1)c=a.getClientRects();else if(a.nodeType==3)c=On(a,0,a.nodeValue.length).getClientRects();else continue;for(let d=0;d<c.length;d++){let u=c[d];if(u.bottom>u.top+1&&(t=="up"?l.top-u.top>(u.bottom-l.top)*2:u.bottom-l.bottom>(l.bottom-u.top)*2))return!1}}return!0})}const QB=/[\u0590-\u08ac]/;function eN(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,l=o==r.parent.content.size,a=n.domSelection();return a?!QB.test(r.parent.textContent)||!a.modify?t=="left"||t=="backward"?i:l:Eh(n,e,()=>{let{focusNode:c,focusOffset:d,anchorNode:u,anchorOffset:f}=n.domSelectionRange(),p=a.caretBidiLevel;a.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:m,focusOffset:g}=n.domSelectionRange(),y=m&&!h.contains(m.nodeType==1?m:m.parentNode)||c==m&&d==g;try{a.collapse(u,f),c&&(c!=u||d!=f)&&a.extend&&a.extend(c,d)}catch{}return p!=null&&(a.caretBidiLevel=p),y}):r.pos==r.start()||r.pos==r.end()}let Mh=null,Ah=null,_h=!1;function tN(n,e,t){return Mh==e&&Ah==t?_h:(Mh=e,Ah=t,_h=t=="up"||t=="down"?ZB(n,e,t):eN(n,e,t))}const Xt=0,Th=1,Or=2,cn=3;class is{constructor(e,t,r,o){this.parent=e,this.children=t,this.dom=r,this.contentDOM=o,this.dirty=Xt,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let o=this.children[t];if(o==e)return r;r+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,l;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((l=i.pmViewDesc)&&l.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(l)+l.size:this.posAtStart}else{let i,l;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((l=i.pmViewDesc)&&l.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(l):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>vt(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),l;if(i&&(!t||i.node))if(r&&(l=i.nodeDOM)&&!(l.nodeType==1?l.contains(e.nodeType==1?e:e.parentNode):l==e))r=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let o=this.children[t],i=r+o.size;if(r==e&&i!=r){for(;!o.border&&o.children.length;)for(let l=0;l<o.children.length;l++){let a=o.children[l];if(a.size){o=a;break}}return o}if(e<i)return o.descAt(e-r-o.border);r=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let i=0;r<this.children.length;r++){let l=this.children[r],a=i+l.size;if(a>e||l instanceof Dh){o=e-i;break}i=a}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof Bh&&i.side>=0;r--);if(t<=0){let i,l=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,l=!1);return i&&t&&l&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?vt(i.dom)+1:0}}else{let i,l=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,l=!1);return i&&l&&!i.border&&!i.domAtom?i.domFromPos(0,t):{node:this.contentDOM,offset:i?vt(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,i=-1;for(let l=r,a=0;;a++){let c=this.children[a],d=l+c.size;if(o==-1&&e<=d){let u=l+c.border;if(e>=u&&t<=d-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(e,t,u);e=l;for(let f=a;f>0;f--){let p=this.children[f-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){o=vt(p.dom)+1;break}e-=p.size}o==-1&&(o=0)}if(o>-1&&(d>t||a==this.children.length-1)){t=d;for(let u=a+1;u<this.children.length;u++){let f=this.children[u];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){i=vt(f.dom);break}t+=f.size}i==-1&&(i=this.contentDOM.childNodes.length);break}l=d}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,o=!1){let i=Math.min(e,t),l=Math.max(e,t);for(let h=0,m=0;h<this.children.length;h++){let g=this.children[h],y=m+g.size;if(i>m&&l<y)return g.setSelection(e-m-g.border,t-m-g.border,r,o);m=y}let a=this.domFromPos(e,e?-1:1),c=t==e?a:this.domFromPos(t,t?-1:1),d=r.root.getSelection(),u=r.domSelectionRange(),f=!1;if((Jt||_t)&&e==t){let{node:h,offset:m}=a;if(h.nodeType==3){if(f=!!(m&&h.nodeValue[m-1]==`
57
+ `),f&&m==h.nodeValue.length)for(let g=h,y;g;g=g.parentNode){if(y=g.nextSibling){y.nodeName=="BR"&&(a=c={node:y.parentNode,offset:vt(y)+1});break}let b=g.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let g=h.childNodes[m-1];f=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(Jt&&u.focusNode&&u.focusNode!=c.node&&u.focusNode.nodeType==1){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(o=!0)}if(!(o||f&&_t)&&Lr(a.node,a.offset,u.anchorNode,u.anchorOffset)&&Lr(c.node,c.offset,u.focusNode,u.focusOffset))return;let p=!1;if((d.extend||e==t)&&!(f&&Jt)){d.collapse(a.node,a.offset);try{e!=t&&d.extend(c.node,c.offset),p=!0}catch{}}if(!p){if(e>t){let m=a;a=c,c=m}let h=document.createRange();h.setEnd(c.node,c.offset),h.setStart(a.node,a.offset),d.removeAllRanges(),d.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,o=0;o<this.children.length;o++){let i=this.children[o],l=r+i.size;if(r==l?e<=l&&t>=r:e<l&&t>r){let a=r+i.border,c=l-i.border;if(e>=a&&t<=c){this.dirty=e==r||t==l?Or:Th,e==a&&t==c&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=cn:i.markDirty(e-a,t-a);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Or:cn}r=l}this.dirty=Or}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?Or:Th;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Bh extends is{constructor(e,t,r,o){let i,l=t.type.toDOM;if(typeof l=="function"&&(l=l(r,()=>{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(l.nodeType!=1){let a=document.createElement("span");a.appendChild(l),l=a}l.contentEditable="false",l.classList.add("ProseMirror-widget")}super(e,[],l,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==Xt&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class nN extends is{constructor(e,t,r,o){super(e,[],t,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class ur extends is{constructor(e,t,r,o,i){super(e,[],r,o),this.mark=t,this.spec=i}static create(e,t,r,o){let i=o.nodeViews[t.type.name],l=i&&i(t,o,r);return(!l||!l.dom)&&(l=or.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new ur(e,t,l.dom,l.contentDOM||l.dom,l)}parseRule(){return this.dirty&cn||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=cn&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Xt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Xt}}slice(e,t,r){let o=ur.create(this.parent,this.mark,!0,r),i=this.children,l=this.size;t<l&&(i=Sc(i,t,l,r)),e>0&&(i=Sc(i,0,e,r));for(let a=0;a<i.length;a++)i[a].parent=o;return o.children=i,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class fr extends is{constructor(e,t,r,o,i,l,a){super(e,[],i,l),this.node=t,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=a}static create(e,t,r,o,i,l){let a=i.nodeViews[t.type.name],c,d=a&&a(t,i,()=>{if(!c)return l;if(c.parent)return c.parent.posBeforeChild(c)},r,o),u=d&&d.dom,f=d&&d.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:f}=or.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!f&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let p=u;return u=Lh(u,r,t),d?c=new rN(e,t,r,o,u,f||null,p,d):t.isText?new Ii(e,t,r,o,u,p):new fr(e,t,r,o,u,f||null,p)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let o=this.children[r];if(this.dom.contains(o.dom.parentNode)){t.contentElement=o.dom.parentNode;break}}if(!t.contentElement){let r=e&&e.find(o=>o.nodeType==1&&e.indexOf(o.parentNode)<0&&this.dom.contains(o));r?t.contentElement=r:t.getContent=()=>ee.empty}}return t}matchesNode(e,t,r){return this.dirty==Xt&&e.eq(this.node)&&Oi(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,o=t,i=e.composing?this.localCompositionInfo(e,t):null,l=i&&i.pos>-1?i:null,a=i&&i.pos<0,c=new sN(this,l&&l.node,e);aN(this.node,this.innerDeco,(d,u,f)=>{d.spec.marks?c.syncToMarks(d.spec.marks,r,e,u):d.type.side>=0&&!f&&c.syncToMarks(u==this.node.childCount?Ue.none:this.node.child(u).marks,r,e,u),c.placeWidget(d,e,o)},(d,u,f,p)=>{c.syncToMarks(d.marks,r,e,p);let h;c.findNodeMatch(d,u,f,p)||a&&e.state.selection.from>o&&e.state.selection.to<o+d.nodeSize&&(h=c.findIndexWithChild(i.node))>-1&&c.updateNodeAt(d,u,f,h,e)||c.updateNextNode(d,u,f,e,p,o)||c.addNode(d,u,f,e,o),o+=d.nodeSize}),c.syncToMarks([],r,e,0),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==Or)&&(l&&this.protectLocalComposition(e,l),Vh(this.contentDOM,this.children,e),mo&&cN(this.dom))}localCompositionInfo(e,t){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof be)||r<t||o>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let l=i.nodeValue,a=dN(this.node.content,l,r-t,o-t);return a<0?null:{node:i,pos:a,text:l}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:o}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let l=new nN(this,i,t,o);e.input.compositionNodes.push(l),this.children=Sc(this.children,r,r+o.length,e,l)}update(e,t,r,o){return this.dirty==cn||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,o),!0)}updateInner(e,t,r,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=Xt}updateOuterDeco(e){if(Oi(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=$h(this.dom,this.nodeDOM,Cc(this.outerDeco,this.node,t),Cc(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Nh(n,e,t,r,o){Lh(r,e,n);let i=new fr(void 0,n,e,t,r,r,r);return i.contentDOM&&i.updateChildren(o,0),i}class Ii extends fr{constructor(e,t,r,o,i,l){super(e,t,r,o,i,null,l)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,o){return this.dirty==cn||this.dirty!=Xt&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Xt||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=Xt,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let o=this.node.cut(e,t),i=document.createTextNode(o.text);return new Ii(this.parent,o,this.outerDeco,this.innerDeco,i,i)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=cn)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Dh extends is{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Xt&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class rN extends fr{constructor(e,t,r,o,i,l,a,c){super(e,t,r,o,i,l,a),this.spec=c}update(e,t,r,o){if(this.dirty==cn)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,r);return i&&this.updateInner(e,t,r,o),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,o){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Vh(n,e,t){let r=n.firstChild,o=!1;for(let i=0;i<e.length;i++){let l=e[i],a=l.dom;if(a.parentNode==n){for(;a!=r;)r=Ih(r),o=!0;r=r.nextSibling}else o=!0,n.insertBefore(a,r);if(l instanceof ur){let c=r?r.previousSibling:n.lastChild;Vh(l.contentDOM,l.children,t),r=c?c.nextSibling:n.firstChild}}for(;r;)r=Ih(r),o=!0;o&&t.trackWrites==n&&(t.trackWrites=null)}const ls=function(n){n&&(this.nodeName=n)};ls.prototype=Object.create(null);const Rr=[new ls];function Cc(n,e,t){if(n.length==0)return Rr;let r=t?Rr[0]:new ls,o=[r];for(let i=0;i<n.length;i++){let l=n[i].type.attrs;if(l){l.nodeName&&o.push(r=new ls(l.nodeName));for(let a in l){let c=l[a];c!=null&&(t&&o.length==1&&o.push(r=new ls(e.isInline?"span":"div")),a=="class"?r.class=(r.class?r.class+" ":"")+c:a=="style"?r.style=(r.style?r.style+";":"")+c:a!="nodeName"&&(r[a]=c))}}}return o}function $h(n,e,t,r){if(t==Rr&&r==Rr)return e;let o=e;for(let i=0;i<r.length;i++){let l=r[i],a=t[i];if(i){let c;a&&a.nodeName==l.nodeName&&o!=n&&(c=o.parentNode)&&c.nodeName.toLowerCase()==l.nodeName||(c=document.createElement(l.nodeName),c.pmIsDeco=!0,c.appendChild(o),a=Rr[0]),o=c}oN(o,a||Rr[0],l)}return o}function oN(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],o=t.class?t.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)o.indexOf(r[i])==-1&&n.classList.remove(r[i]);for(let i=0;i<o.length;i++)r.indexOf(o[i])==-1&&n.classList.add(o[i]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(e.style);)n.style.removeProperty(o[1])}t.style&&(n.style.cssText+=t.style)}}function Lh(n,e,t){return $h(n,n,Rr,Cc(e,t,n.nodeType!=1))}function Oi(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Ih(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class sN{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=iN(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r,o){let i=0,l=this.stack.length>>1,a=Math.min(l,e.length);for(;i<a&&(i==l-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<l;)this.destroyRest(),this.top.dirty=Xt,this.index=this.stack.pop(),this.top=this.stack.pop(),l--;for(;l<e.length;){this.stack.push(this.top,this.index+1);let c=-1,d=this.top.children.length;o<this.preMatch.index&&(d=Math.min(this.index+3,d));for(let u=this.index;u<d;u++){let f=this.top.children[u];if(f.matchesMark(e[l])&&!this.isLocked(f.dom)){c=u;break}}if(c<0&&this.index<this.top.children.length){let u=this.top.children[this.index];u instanceof ur&&u.dirty!=cn&&u.mark.type==e[l].type&&u.spec.update&&!this.isLocked(u.dom)&&u.spec.update(e[l])&&(u.mark=e[l],c=this.index,this.changed=!0)}if(c>-1)c>this.index&&(this.changed=!0,this.destroyBetween(this.index,c)),this.top=this.top.children[this.index];else{let u=ur.create(this.top,e[l],t,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,l++}}findNodeMatch(e,t,r,o){let i=-1,l;if(o>=this.preMatch.index&&(l=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&l.matchesNode(e,t,r))i=this.top.children.indexOf(l,this.index);else for(let a=this.index,c=Math.min(this.top.children.length,a+5);a<c;a++){let d=this.top.children[a];if(d.matchesNode(e,t,r)&&!this.preMatch.matched.has(d)){i=a;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,r,o,i){let l=this.top.children[o];return l.dirty==cn&&l.dom==l.contentDOM&&(l.dirty=Or),l.update(e,t,r,i)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}e=t}}updateNextNode(e,t,r,o,i,l){for(let a=this.index;a<this.top.children.length;a++){let c=this.top.children[a];if(c instanceof fr){let d=this.preMatch.matched.get(c);if(d!=null&&d!=i)return!1;let u=c.dom,f,p=this.isLocked(u)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=cn&&Oi(t,c.outerDeco));if(!p&&c.update(e,t,r,o))return this.destroyBetween(this.index,a),c.dom!=u&&(this.changed=!0),this.index++,!0;if(!p&&(f=this.recreateWrapper(c,e,t,r,o,l)))return this.destroyBetween(this.index,a),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=Or,f.updateChildren(o,l+1),f.dirty=Xt),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,o,i,l){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Oi(r,e.outerDeco)||!o.eq(e.innerDeco))return null;let a=fr.create(this.top,t,r,o,i,l);if(a.contentDOM){a.children=e.children,e.children=[];for(let c of a.children)c.parent=a}return e.destroy(),a}addNode(e,t,r,o,i){let l=fr.create(this.top,e,t,r,o,i);l.contentDOM&&l.updateChildren(o,i+1),this.top.children.splice(this.index++,0,l),this.changed=!0}placeWidget(e,t,r){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let i=new Bh(this.top,e,t,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof ur;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Ii)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((_t||Ct)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new Dh(this.top,[],r,null);t!=this.top?t.children.push(o):t.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function iN(n,e){let t=e,r=t.children.length,o=n.childCount,i=new Map,l=[];e:for(;o>0;){let a;for(;;)if(r){let d=t.children[r-1];if(d instanceof ur)t=d,r=d.children.length;else{a=d,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let c=a.node;if(c){if(c!=n.child(o-1))break;--o,i.set(a,o),l.push(a)}}return{index:o,matched:i,matches:l.reverse()}}function lN(n,e){return n.type.side-e.type.side}function aN(n,e,t,r){let o=e.locals(n),i=0;if(o.length==0){for(let d=0;d<n.childCount;d++){let u=n.child(d);r(u,o,e.forChild(i,u),d),i+=u.nodeSize}return}let l=0,a=[],c=null;for(let d=0;;){let u,f;for(;l<o.length&&o[l].to==i;){let y=o[l++];y.widget&&(u?(f||(f=[u])).push(y):u=y)}if(u)if(f){f.sort(lN);for(let y=0;y<f.length;y++)t(f[y],d,!!c)}else t(u,d,!!c);let p,h;if(c)h=-1,p=c,c=null;else if(d<n.childCount)h=d,p=n.child(d++);else break;for(let y=0;y<a.length;y++)a[y].to<=i&&a.splice(y--,1);for(;l<o.length&&o[l].from<=i&&o[l].to>i;)a.push(o[l++]);let m=i+p.nodeSize;if(p.isText){let y=m;l<o.length&&o[l].from<y&&(y=o[l].from);for(let b=0;b<a.length;b++)a[b].to<y&&(y=a[b].to);y<m&&(c=p.cut(y-i),p=p.cut(0,y-i),m=y,h=-1)}else for(;l<o.length&&o[l].to<m;)l++;let g=p.isInline&&!p.isLeaf?a.filter(y=>!y.inline):a.slice();r(p,g,e.forChild(i,p),h),i=m}}function cN(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function dN(n,e,t,r){for(let o=0,i=0;o<n.childCount&&i<=r;){let l=n.child(o++),a=i;if(i+=l.nodeSize,!l.isText)continue;let c=l.text;for(;o<n.childCount;){let d=n.child(o++);if(i+=d.nodeSize,!d.isText)break;c+=d.text}if(i>=t){if(i>=r&&c.slice(r-e.length-a,r-a)==e)return r-e.length;let d=a<r?c.lastIndexOf(e,r-a-1):-1;if(d>=0&&d+e.length+a>=t)return a+d;if(t==r&&c.length>=r+e.length-a&&c.slice(r-a,r-a+e.length)==e)return r}}return-1}function Sc(n,e,t,r,o){let i=[];for(let l=0,a=0;l<n.length;l++){let c=n[l],d=a,u=a+=c.size;d>=t||u<=e?i.push(c):(d<e&&i.push(c.slice(0,e-d,r)),o&&(i.push(o),o=void 0),u>t&&i.push(c.slice(t-d,c.size,r)))}return i}function Ec(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),i=o&&o.size==0,l=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(l<0)return null;let a=r.resolve(l),c,d;if(Li(t)){for(c=l;o&&!o.node;)o=o.parent;let f=o.node;if(o&&f.isAtom&&Ce.isSelectable(f)&&o.parent&&!(f.isInline&&OB(t.focusNode,t.focusOffset,o.dom))){let p=o.posBefore;d=new Ce(l==p?a:r.resolve(p))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=l,p=l;for(let h=0;h<t.rangeCount;h++){let m=t.getRangeAt(h);f=Math.min(f,n.docView.posFromDOM(m.startContainer,m.startOffset,1)),p=Math.max(p,n.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(f<0)return null;[c,l]=p==n.state.selection.anchor?[p,f]:[f,p],a=r.resolve(l)}else c=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(c<0)return null}let u=r.resolve(c);if(!d){let f=e=="pointer"||n.state.selection.head<a.pos&&!i?1:-1;d=Ac(n,u,a,f)}return d}function Oh(n){return n.editable?n.hasFocus():Uh(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Pn(n,e=!1){let t=n.state.selection;if(zh(n,t),!Oh(n))return;let r=n.input.mouseDown;if(!e&&Ct&&r){let o=n.domSelectionRange(),i=n.domObserver.currentSelection;if(o.anchorNode&&i.anchorNode&&Lr(o.anchorNode,o.anchorOffset,i.anchorNode,i.anchorOffset)&&r.delaySelUpdate()){n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)fN(n);else{let{anchor:o,head:i}=t,l,a;Rh&&!(t instanceof be)&&(t.$from.parent.inlineContent||(l=Fh(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(a=Fh(n,t.to))),n.docView.setSelection(o,i,n,e),Rh&&(l&&Ph(l),a&&Ph(a)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&uN(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}const Rh=_t||Ct&&yh<63;function Fh(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),o=r<t.childNodes.length?t.childNodes[r]:null,i=r?t.childNodes[r-1]:null;if(_t&&o&&o.contentEditable=="false")return Mc(o);if((!o||o.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(o)return Mc(o);if(i)return Mc(i)}}function Mc(n){return n.contentEditable="true",_t&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Ph(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function uN(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Oh(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function fN(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,vt(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&Ot&&cr<=11&&(t.disabled=!0,t.disabled=!1)}function zh(n,e){if(e instanceof Ce){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Hh(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Hh(n)}function Hh(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Ac(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||be.between(e,t,r)}function jh(n){return n.editable&&!n.hasFocus()?!1:Uh(n)}function Uh(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function pN(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Lr(e.node,e.offset,t.anchorNode,t.anchorOffset)}function _c(n,e){let{$anchor:t,$head:r}=n.selection,o=e>0?t.max(r):t.min(r),i=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return i&&Ae.findFrom(i,e)}function pr(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Wh(n,e,t){let r=n.state.selection;if(r instanceof be)if(t.indexOf("s")>-1){let{$head:o}=r,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let l=n.state.doc.resolve(o.pos+i.nodeSize*(e<0?-1:1));return pr(n,new be(r.$anchor,l))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=_c(n.state,e);return o&&o instanceof Ce?pr(n,o):!1}else if(!(Yt&&t.indexOf("m")>-1)){let o=r.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,l;if(!i||i.isText)return!1;let a=e<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(l=n.docView.descAt(a))&&!l.contentDOM?Ce.isSelectable(i)?pr(n,new Ce(e<0?n.state.doc.resolve(o.pos-i.nodeSize):o)):rs?pr(n,new be(n.state.doc.resolve(e<0?a:a+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Ce&&r.node.isInline)return pr(n,new be(e>0?r.$to:r.$from));{let o=_c(n.state,e);return o?pr(n,o):!1}}}function Ri(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function as(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function yo(n,e){return e<0?hN(n):mN(n)}function hN(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,i,l=!1;for(Jt&&t.nodeType==1&&r<Ri(t)&&as(t.childNodes[r],-1)&&(l=!0);;)if(r>0){if(t.nodeType!=1)break;{let a=t.childNodes[r-1];if(as(a,-1))o=t,i=--r;else if(a.nodeType==3)t=a,r=t.nodeValue.length;else break}}else{if(Kh(t))break;{let a=t.previousSibling;for(;a&&as(a,-1);)o=t.parentNode,i=vt(a),a=a.previousSibling;if(a)t=a,r=Ri(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}l?Tc(n,t,r):o&&Tc(n,o,i)}function mN(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=Ri(t),i,l;for(;;)if(r<o){if(t.nodeType!=1)break;let a=t.childNodes[r];if(as(a,1))i=t,l=++r;else break}else{if(Kh(t))break;{let a=t.nextSibling;for(;a&&as(a,1);)i=a.parentNode,l=vt(a)+1,a=a.nextSibling;if(a)t=a,r=0,o=Ri(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}i&&Tc(n,i,l)}function Kh(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function gN(n,e){for(;n&&e==n.childNodes.length&&!ns(n);)e=vt(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function yN(n,e){for(;n&&!e&&!ns(n);)e=vt(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Tc(n,e,t){if(e.nodeType!=3){let i,l;(l=gN(e,t))?(e=l,t=0):(i=yN(e,t))&&(e=i,t=i.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Li(r)){let i=document.createRange();i.setEnd(e,t),i.setStart(e,t),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:o}=n;setTimeout(()=>{n.state==o&&Pn(n)},50)}function qh(n,e){let t=n.state.doc.resolve(e);if(!(Ct||bh)&&t.parent.inlineContent){let o=n.coordsAtPos(e);if(e>t.start()){let i=n.coordsAtPos(e-1),l=(i.top+i.bottom)/2;if(l>o.top&&l<o.bottom&&Math.abs(i.left-o.left)>1)return i.left<o.left?"ltr":"rtl"}if(e<t.end()){let i=n.coordsAtPos(e+1),l=(i.top+i.bottom)/2;if(l>o.top&&l<o.bottom&&Math.abs(i.left-o.left)>1)return i.left>o.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Gh(n,e,t){let r=n.state.selection;if(r instanceof be&&!r.empty||t.indexOf("s")>-1||Yt&&t.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let l=_c(n.state,e);if(l&&l instanceof Ce)return pr(n,l)}if(!o.parent.inlineContent){let l=e<0?o:i,a=r instanceof jt?Ae.near(l,e):Ae.findFrom(l,e);return a?pr(n,a):!1}return!1}function Jh(n,e){if(!(n.state.selection instanceof be))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(i&&!i.isText){let l=n.state.tr;return e<0?l.delete(t.pos-i.nodeSize,t.pos):l.delete(t.pos,t.pos+i.nodeSize),n.dispatch(l),!0}return!1}function Yh(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function bN(n){if(!_t||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Yh(n,r,"true"),setTimeout(()=>Yh(n,r,"false"),20)}return!1}function kN(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function wN(n,e){let t=e.keyCode,r=kN(e);if(t==8||Yt&&t==72&&r=="c")return Jh(n,-1)||yo(n,-1);if(t==46&&!e.shiftKey||Yt&&t==68&&r=="c")return Jh(n,1)||yo(n,1);if(t==13||t==27)return!0;if(t==37||Yt&&t==66&&r=="c"){let o=t==37?qh(n,n.state.selection.from)=="ltr"?-1:1:-1;return Wh(n,o,r)||yo(n,o)}else if(t==39||Yt&&t==70&&r=="c"){let o=t==39?qh(n,n.state.selection.from)=="ltr"?1:-1:1;return Wh(n,o,r)||yo(n,o)}else{if(t==38||Yt&&t==80&&r=="c")return Gh(n,-1,r)||yo(n,-1);if(t==40||Yt&&t==78&&r=="c")return bN(n)||Gh(n,1,r)||yo(n,1);if(r==(Yt?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Bc(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,i--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let l=n.someProp("clipboardSerializer")||or.fromSchema(n.state.schema),a=rm(),c=a.createElement("div");c.appendChild(l.serializeFragment(r,{document:a}));let d=c.firstChild,u,f=0;for(;d&&d.nodeType==1&&(u=nm[d.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let m=a.createElement(u[h]);for(;c.firstChild;)m.appendChild(c.firstChild);c.appendChild(m),f++}d=c.firstChild}d&&d.nodeType==1&&d.setAttribute("data-pm-slice",`${o} ${i}${f?` -${f}`:""} ${JSON.stringify(t)}`);let p=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
58
+
59
+ `);return{dom:c,text:p,slice:e}}function Xh(n,e,t,r,o){let i=o.parent.type.spec.code,l,a;if(!t&&!e)return null;let c=!!e&&(r||i||!t);if(c){if(n.someProp("transformPastedText",p=>{e=p(e,i||r,n)}),i)return a=new fe(ee.from(n.state.schema.text(e.replace(/\r\n?/g,`
60
+ `))),0,0),n.someProp("transformPasted",p=>{a=p(a,n,!0)}),a;let f=n.someProp("clipboardTextParser",p=>p(e,o,r,n));if(f)a=f;else{let p=o.marks(),{schema:h}=n.state,m=or.fromSchema(h);l=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let y=l.appendChild(document.createElement("p"));g&&y.appendChild(m.serializeNode(h.text(g,p)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),l=SN(t),rs&&EN(l);let d=l&&l.querySelector("[data-pm-slice]"),u=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let p=l.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;l=p}if(a||(a=(n.someProp("clipboardParser")||n.someProp("domParser")||Dr.fromSchema(n.state.schema)).parseSlice(l,{preserveWhitespace:!!(c||u),context:o,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!xN.test(p.parentNode.nodeName)?{ignore:!0}:null}})),u)a=MN(tm(a,+u[1],+u[2]),u[4]);else if(a=fe.maxOpen(vN(a.content,o),!0),a.openStart||a.openEnd){let f=0,p=0;for(let h=a.content.firstChild;f<a.openStart&&!h.type.spec.isolating;f++,h=h.firstChild);for(let h=a.content.lastChild;p<a.openEnd&&!h.type.spec.isolating;p++,h=h.lastChild);a=tm(a,f,p)}return n.someProp("transformPasted",f=>{a=f(a,n,c)}),a}const xN=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function vN(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),i,l=[];if(n.forEach(a=>{if(!l)return;let c=o.findWrapping(a.type),d;if(!c)return l=null;if(d=l.length&&i.length&&Qh(c,i,a,l[l.length-1],0))l[l.length-1]=d;else{l.length&&(l[l.length-1]=em(l[l.length-1],i.length));let u=Zh(a,c);l.push(u),o=o.matchType(u.type),i=c}}),l)return ee.from(l)}return n}function Zh(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,ee.from(n));return n}function Qh(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let i=Qh(n,e,t,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?t.type:n[o+1]))return r.copy(r.content.append(ee.from(Zh(t,n,o+1))))}}function em(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,em(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(ee.empty,!0);return n.copy(t.append(r))}function Nc(n,e,t,r,o,i){let l=e<0?n.firstChild:n.lastChild,a=l.content;return n.childCount>1&&(i=0),o<r-1&&(a=Nc(a,e,t,r,o+1,i)),o>=t&&(a=e<0?l.contentMatchAt(0).fillBefore(a,i<=o).append(a):a.append(l.contentMatchAt(l.childCount).fillBefore(ee.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,l.copy(a))}function tm(n,e,t){return e<n.openStart&&(n=new fe(Nc(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new fe(Nc(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const nm={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function rm(){return document.implementation.createHTMLDocument("title")}let Dc=null;function CN(n){let e=window.trustedTypes;return e?(Dc||(Dc=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Dc.createHTML(n)):n}function SN(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=rm(),r=t.body,o=/<([a-z][^>\s]+)/i.exec(n),i;if((i=o&&nm[o[1].toLowerCase()])&&(n=i.map(l=>"<"+l+">").join("")+n+i.map(l=>"</"+l+">").reverse().join("")),r.innerHTML=CN(n),i)for(let l=0;l<i.length;l++)r=r.querySelector(i[l])||r;for(let l=0;l<t.styleSheets.length;l++){let a=t.styleSheets[l];for(let c=0;c<a.rules.length;c++){let d=a.rules[c];if(d instanceof CSSStyleRule){let u=r.querySelectorAll(d.selectorText);for(let f=0;f<u.length;f++)u[f].style.cssText+=d.style.cssText}}}return r}function EN(n){let e=n.querySelectorAll(Ct?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function MN(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:o,openStart:i,openEnd:l}=n;for(let a=r.length-2;a>=0;a-=2){let c=t.nodes[r[a]];if(!c||c.hasRequiredAttrs())break;o=ee.from(c.create(r[a+1],o)),i++,l++}return new fe(o,i,l)}const $t={},Lt={},AN={touchstart:!0,touchmove:!0};class _N{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function TN(n){for(let e in $t){let t=$t[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{NN(n,r)&&!$c(n,r)&&(n.editable||!(r.type in Lt))&&t(n,r)},AN[e]?{passive:!0}:void 0)}_t&&n.dom.addEventListener("input",()=>null),Vc(n)}function zn(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function BN(n){n.input.mouseDown&&n.input.mouseDown.done(),n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Vc(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>$c(n,r))})}function $c(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function NN(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function DN(n,e){!$c(n,e)&&$t[e.type]&&(n.editable||!(e.type in Lt))&&$t[e.type](n,e)}Lt.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!lm(n)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Rn&&Ct&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),mo&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",o=>o(n,Ir(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||wN(n,t)?t.preventDefault():zn(n,"key")},Lt.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},Lt.keypress=(n,e)=>{let t=e;if(lm(n)||!t.charCode||t.ctrlKey&&!t.altKey||Yt&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof be)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode),i=()=>n.state.tr.insertText(o).scrollIntoView();!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",l=>l(n,r.$from.pos,r.$to.pos,o,i))&&n.dispatch(i()),t.preventDefault()}};function cs(n){return{left:n.clientX,top:n.clientY}}function VN(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Lc(n,e,t,r,o){if(r==-1)return!1;let i=n.state.doc.resolve(r);for(let l=i.depth+1;l>0;l--)if(n.someProp(e,a=>l>i.depth?a(n,t,i.nodeAfter,i.before(l),o,!0):a(n,t,i.node(l),i.before(l),o,!1)))return!0;return!1}function ds(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function $N(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&Ce.isSelectable(r)?(ds(n,new Ce(t)),!0):!1}function LN(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof Ce&&(r=t.node);let i=n.state.doc.resolve(e);for(let l=i.depth+1;l>0;l--){let a=l>i.depth?i.nodeAfter:i.node(l);if(Ce.isSelectable(a)){r&&t.$from.depth>0&&l>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?o=i.before(t.$from.depth):o=i.before(l);break}}return o!=null?(ds(n,Ce.create(n.state.doc,o)),!0):!1}function IN(n,e,t,r,o){return Lc(n,"handleClickOn",e,t,r)||n.someProp("handleClick",i=>i(n,e,r))||(o?LN(n,t):$N(n,t))}function ON(n,e,t,r){return Lc(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function RN(n,e,t,r){return Lc(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))||FN(n,t,r)}function FN(n,e,t){if(t.button!=0)return!1;let r=om(n,e,!0),o=n.state.doc;return r?(ds(n,r),r instanceof be&&o.eq(n.state.doc)&&(n.input.mouseDown=new zN(n,r)),!0):!1}function om(n,e,t){let r=n.state.doc;if(e==-1)return r.inlineContent?be.create(r,0,r.content.size):null;let o=r.resolve(e);for(let i=o.depth+1;i>0;i--){let l=i>o.depth?o.nodeAfter:o.node(i),a=o.before(i);if(l.inlineContent)return be.create(r,a+1,a+1+l.content.size);if(t&&Ce.isSelectable(l))return Ce.create(r,a)}return null}function Ic(n){return Fi(n)}const sm=Yt?"metaKey":"ctrlKey";$t.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Ic(n),o=Date.now(),i="singleClick";o-n.input.lastClick.time<500&&VN(t,n.input.lastClick)&&!t[sm]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?i="doubleClick":n.input.lastClick.type=="doubleClick"&&(i="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:i,button:t.button},n.input.mouseDown&&n.input.mouseDown.done();let l=n.posAtCoords(cs(t));l&&(i=="singleClick"?n.input.mouseDown=new PN(n,l,t,!!r):(i=="doubleClick"?ON:RN)(n,l.pos,l.inside,t)?t.preventDefault():zn(n,"pointer"))};class im{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}}class PN extends im{constructor(e,t,r,o){super(e),this.pos=t,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[sm],this.allowDefault=r.shiftKey;let i,l;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),l=t.inside;else{let u=e.state.doc.resolve(t.pos);i=u.parent,l=u.depth?u.before():0}const a=o?null:r.target,c=a?e.docView.nearestDesc(a,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:d}=e.state;r.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||d instanceof Ce&&d.from<=l&&d.to>l)&&(this.mightDrag={node:i,pos:l,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Jt&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),zn(e,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||Pn(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(cs(e))),this.updateAllowDefault(e),this.allowDefault||!t?zn(this.view,"pointer"):IN(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||_t&&this.mightDrag&&!this.mightDrag.node.isAtom||Ct&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(ds(this.view,Ae.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):zn(this.view,"pointer")}move(e){this.updateAllowDefault(e),zn(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}}class zN extends im{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),zn(this.view,"pointer");let t=this.view.posAtCoords(cs(e)),r=t&&om(this.view,t.inside,!1);if(!r)return;let{doc:o}=this.view.state,i=this.startSelection,[l,a]=r.from<i.from?[i.to,r.from]:[i.from,r.to];ds(this.view,be.create(o,l,a))}}$t.touchstart=n=>{n.input.lastTouch=Date.now(),Ic(n),zn(n,"pointer")},$t.touchmove=n=>{n.input.lastTouch=Date.now(),zn(n,"pointer")},$t.contextmenu=n=>Ic(n);function lm(n,e){return n.composing?!0:_t&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const HN=Rn?5e3:-1;Lt.compositionstart=Lt.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof be&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Ct&&bh&&jN(n)))n.markCursor=n.state.storedMarks||t.marks(),Fi(n,!0),n.markCursor=null;else if(Fi(n,!e.selection.empty),Jt&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let o=r.focusNode,i=r.focusOffset;o&&o.nodeType==1&&i!=0;){let l=i<0?o.lastChild:o.childNodes[i-1];if(!l)break;if(l.nodeType==3){let a=n.domSelection();a&&a.collapse(l,l.nodeValue.length);break}else o=l,i=-1}}n.input.composing=!0}am(n,HN)};function jN(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return r.nodeType==1&&r.contentEditable=="false"}Lt.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now(),n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,am(n,20))};function am(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Fi(n),e))}function cm(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function UN(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=LB(e.focusNode,e.focusOffset),r=IB(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let o=r.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||r==i)return i;if(!o||!o.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let l=t.pmViewDesc;if(!(!l||!l.isText(t.nodeValue)))return r}}return t||r}function Fi(n,e=!1){if(!(Rn&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),cm(n),e||n.docView&&n.docView.dirty){let t=Ec(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function WN(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const us=Ot&&cr<15||mo&&PB<604;$t.copy=Lt.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let i=us?null:t.clipboardData,l=r.content(),{dom:a,text:c}=Bc(n,l);i?(t.preventDefault(),i.clearData(),i.setData("text/html",a.innerHTML),i.setData("text/plain",c)):WN(n,a),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function KN(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function qN(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?fs(n,r.value,null,o,e):fs(n,r.textContent,r.innerHTML,o,e)},50)}function fs(n,e,t,r,o){let i=Xh(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",c=>c(n,o,i||fe.empty)))return!0;if(!i)return!1;let l=KN(i),a=l?n.state.tr.replaceSelectionWith(l,r):n.state.tr.replaceSelection(i);return n.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function dm(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Lt.paste=(n,e)=>{let t=e;if(n.composing&&!Rn)return;let r=us?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&fs(n,dm(r),r.getData("text/html"),o,t)?t.preventDefault():qN(n,t)};class um{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const GN=Yt?"altKey":"ctrlKey";function fm(n,e){let t;return n.someProp("dragCopies",r=>{t=t||r(e)}),t!=null?!t:!e[GN]}$t.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=n.state.selection,i=o.empty?null:n.posAtCoords(cs(t)),l;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof Ce?o.to-1:o.to))){if(r&&r.mightDrag)l=Ce.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let f=n.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=n.docView&&(l=Ce.create(n.state.doc,f.posBefore))}}let a=(l||n.state.selection).content(),{dom:c,text:d,slice:u}=Bc(n,a);(!t.dataTransfer.files.length||!Ct||yh>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(us?"Text":"text/html",c.innerHTML),t.dataTransfer.effectAllowed="copyMove",us||t.dataTransfer.setData("text/plain",d),n.dragging=new um(u,fm(n,t),l)},$t.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},Lt.dragover=Lt.dragenter=(n,e)=>e.preventDefault(),Lt.drop=(n,e)=>{try{JN(n,e,n.dragging)}finally{n.dragging=null}};function JN(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(cs(e));if(!r)return;let o=n.state.doc.resolve(r.pos),i=t&&t.slice;i?n.someProp("transformPasted",h=>{i=h(i,n,!1)}):i=Xh(n,dm(e.dataTransfer),us?null:e.dataTransfer.getData("text/html"),!1,o);let l=!!(t&&fm(n,e));if(n.someProp("handleDrop",h=>h(n,e,i||fe.empty,l))){e.preventDefault();return}if(!i)return;e.preventDefault();let a=i?Pp(n.state.doc,o.pos,i):o.pos;a==null&&(a=o.pos);let c=n.state.tr;if(l){let{node:h}=t;h?h.replace(c):c.deleteSelection()}let d=c.mapping.map(a),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,f=c.doc;if(u?c.replaceRangeWith(d,d,i.content.firstChild):c.replaceRange(d,d,i),c.doc.eq(f))return;let p=c.doc.resolve(d);if(u&&Ce.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new Ce(p));else{let h=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,y,b)=>h=b),c.setSelection(Ac(n,p,c.doc.resolve(h)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))}$t.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Pn(n)},20))},$t.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},$t.beforeinput=(n,e)=>{if(Rn&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",i=>i(n,Ir(8,"Backspace")))))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in Lt)$t[n]=Lt[n];function ps(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Pi{constructor(e,t){this.toDOM=e,this.spec=t||Fr,this.side=this.spec.side||0}map(e,t,r,o){let{pos:i,deleted:l}=e.mapResult(t.from+o,this.side<0?-1:1);return l?null:new Tt(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Pi&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&ps(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class hr{constructor(e,t){this.attrs=e,this.spec=t||Fr}map(e,t,r,o){let i=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,l=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return i>=l?null:new Tt(i,l,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof hr&&ps(this.attrs,e.attrs)&&ps(this.spec,e.spec)}static is(e){return e.type instanceof hr}destroy(){}}class Oc{constructor(e,t){this.attrs=e,this.spec=t||Fr}map(e,t,r,o){let i=e.mapResult(t.from+o,1);if(i.deleted)return null;let l=e.mapResult(t.to+o,-1);return l.deleted||l.pos<=i.pos?null:new Tt(i.pos-r,l.pos-r,this)}valid(e,t){let{index:r,offset:o}=e.content.findIndex(t.from),i;return o==t.from&&!(i=e.child(r)).isText&&o+i.nodeSize==t.to}eq(e){return this==e||e instanceof Oc&&ps(this.attrs,e.attrs)&&ps(this.spec,e.spec)}destroy(){}}let Tt=class Hs{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new Hs(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new Hs(e,e,new Pi(t,r))}static inline(e,t,r,o){return new Hs(e,t,new hr(r,o))}static node(e,t,r,o){return new Hs(e,t,new Oc(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof hr}get widget(){return this.type instanceof Pi}};const bo=[],Fr={};class Oe{constructor(e,t){this.local=e.length?e:bo,this.children=t.length?t:bo}static create(e,t){return t.length?zi(t,e,0,Fr):Bt}find(e,t,r){let o=[];return this.findInner(e??0,t??1e9,o,0,r),o}findInner(e,t,r,o,i){for(let l=0;l<this.local.length;l++){let a=this.local[l];a.from<=t&&a.to>=e&&(!i||i(a.spec))&&r.push(a.copy(a.from+o,a.to+o))}for(let l=0;l<this.children.length;l+=3)if(this.children[l]<t&&this.children[l+1]>e){let a=this.children[l]+1;this.children[l+2].findInner(e-a,t-a,r,o+a,i)}}map(e,t,r){return this==Bt||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Fr)}mapInner(e,t,r,o,i){let l;for(let a=0;a<this.local.length;a++){let c=this.local[a].map(e,r,o);c&&c.type.valid(t,c)?(l||(l=[])).push(c):i.onRemove&&i.onRemove(this.local[a].spec)}return this.children.length?YN(this.children,l||[],e,t,r,o,i):l?new Oe(l.sort(Pr),bo):Bt}add(e,t){return t.length?this==Bt?Oe.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let o,i=0;e.forEach((a,c)=>{let d=c+r,u;if(u=hm(t,a,d)){for(o||(o=this.children.slice());i<o.length&&o[i]<c;)i+=3;o[i]==c?o[i+2]=o[i+2].addInner(a,u,d+1):o.splice(i,0,c,c+a.nodeSize,zi(u,a,d+1,Fr)),i+=3}});let l=pm(i?mm(t):t,-r);for(let a=0;a<l.length;a++)l[a].type.valid(e,l[a])||l.splice(a--,1);return new Oe(l.length?this.local.concat(l).sort(Pr):this.local,o||this.children)}remove(e){return e.length==0||this==Bt?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,o=this.local;for(let i=0;i<r.length;i+=3){let l,a=r[i]+t,c=r[i+1]+t;for(let u=0,f;u<e.length;u++)(f=e[u])&&f.from>a&&f.to<c&&(e[u]=null,(l||(l=[])).push(f));if(!l)continue;r==this.children&&(r=this.children.slice());let d=r[i+2].removeInner(l,a+1);d!=Bt?r[i+2]=d:(r.splice(i,3),i-=3)}if(o.length){for(let i=0,l;i<e.length;i++)if(l=e[i])for(let a=0;a<o.length;a++)o[a].eq(l,t)&&(o==this.local&&(o=this.local.slice()),o.splice(a--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new Oe(o,r):Bt}forChild(e,t){if(this==Bt)return this;if(t.isLeaf)return Oe.empty;let r,o;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=e){this.children[a]==e&&(r=this.children[a+2]);break}let i=e+1,l=i+t.content.size;for(let a=0;a<this.local.length;a++){let c=this.local[a];if(c.from<l&&c.to>i&&c.type instanceof hr){let d=Math.max(i,c.from)-i,u=Math.min(l,c.to)-i;d<u&&(o||(o=[])).push(c.copy(d,u))}}if(o){let a=new Oe(o.sort(Pr),bo);return r?new mr([a,r]):a}return r||Bt}eq(e){if(this==e)return!0;if(!(e instanceof Oe)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Rc(this.localsInner(e))}localsInner(e){if(this==Bt)return bo;if(e.inlineContent||!this.local.some(hr.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof hr||t.push(this.local[r]);return t}forEachSet(e){e(this)}}Oe.empty=new Oe([],[]),Oe.removeOverlap=Rc;const Bt=Oe.empty;class mr{constructor(e){this.members=e}map(e,t){const r=this.members.map(o=>o.map(e,t,Fr));return mr.from(r)}forChild(e,t){if(t.isLeaf)return Oe.empty;let r=[];for(let o=0;o<this.members.length;o++){let i=this.members[o].forChild(e,t);i!=Bt&&(i instanceof mr?r=r.concat(i.members):r.push(i))}return mr.from(r)}eq(e){if(!(e instanceof mr)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let o=0;o<this.members.length;o++){let i=this.members[o].localsInner(e);if(i.length)if(!t)t=i;else{r&&(t=t.slice(),r=!1);for(let l=0;l<i.length;l++)t.push(i[l])}}return t?Rc(r?t:t.sort(Pr)):bo}static from(e){switch(e.length){case 0:return Bt;case 1:return e[0];default:return new mr(e.every(t=>t instanceof Oe)?e:e.reduce((t,r)=>t.concat(r instanceof Oe?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function YN(n,e,t,r,o,i,l){let a=n.slice();for(let d=0,u=i;d<t.maps.length;d++){let f=0;t.maps[d].forEach((p,h,m,g)=>{let y=g-m-(h-p);for(let b=0;b<a.length;b+=3){let w=a[b+1];if(w<0||p>w+u-f)continue;let v=a[b]+u-f;h>=v?a[b+1]=p<=v?-2:-1:p>=u&&y&&(a[b]+=y,a[b+1]+=y)}f+=y}),u=t.maps[d].map(u,-1)}let c=!1;for(let d=0;d<a.length;d+=3)if(a[d+1]<0){if(a[d+1]==-2){c=!0,a[d+1]=-1;continue}let u=t.map(n[d]+i),f=u-o;if(f<0||f>=r.content.size){c=!0;continue}let p=t.map(n[d+1]+i,-1),h=p-o,{index:m,offset:g}=r.content.findIndex(f),y=r.maybeChild(m);if(y&&g==f&&g+y.nodeSize==h){let b=a[d+2].mapInner(t,y,u+1,n[d]+i+1,l);b!=Bt?(a[d]=f,a[d+1]=h,a[d+2]=b):(a[d+1]=-2,c=!0)}else c=!0}if(c){let d=XN(a,n,e,t,o,i,l),u=zi(d,r,0,l);e=u.local;for(let f=0;f<a.length;f+=3)a[f+1]<0&&(a.splice(f,3),f-=3);for(let f=0,p=0;f<u.children.length;f+=3){let h=u.children[f];for(;p<a.length&&a[p]<h;)p+=3;a.splice(p,0,u.children[f],u.children[f+1],u.children[f+2])}}return new Oe(e.sort(Pr),a)}function pm(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let o=n[r];t.push(new Tt(o.from+e,o.to+e,o.type))}return t}function XN(n,e,t,r,o,i,l){function a(c,d){for(let u=0;u<c.local.length;u++){let f=c.local[u].map(r,o,d);f?t.push(f):l.onRemove&&l.onRemove(c.local[u].spec)}for(let u=0;u<c.children.length;u+=3)a(c.children[u+2],c.children[u]+d+1)}for(let c=0;c<n.length;c+=3)n[c+1]==-1&&a(n[c+2],e[c]+i+1);return t}function hm(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,o=null;for(let i=0,l;i<n.length;i++)(l=n[i])&&l.from>t&&l.to<r&&((o||(o=[])).push(l),n[i]=null);return o}function mm(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function zi(n,e,t,r){let o=[],i=!1;e.forEach((a,c)=>{let d=hm(n,a,c+t);if(d){i=!0;let u=zi(d,a,t+c+1,r);u!=Bt&&o.push(c,c+a.nodeSize,u)}});let l=pm(i?mm(n):n,-t).sort(Pr);for(let a=0;a<l.length;a++)l[a].type.valid(e,l[a])||(r.onRemove&&r.onRemove(l[a].spec),l.splice(a--,1));return l.length||o.length?new Oe(l,o):Bt}function Pr(n,e){return n.from-e.from||n.to-e.to}function Rc(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){let i=e[o];if(i.from==r.from){i.to!=r.to&&(e==n&&(e=n.slice()),e[o]=i.copy(i.from,r.to),gm(e,o+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,i.from),gm(e,o,r.copy(i.from,r.to)));break}}}return e}function gm(n,e,t){for(;e<n.length&&Pr(t,n[e])>0;)e++;n.splice(e,0,t)}function Fc(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=Bt&&e.push(r)}),n.cursorWrapper&&e.push(Oe.create(n.state.doc,[n.cursorWrapper.deco])),mr.from(e)}const ZN={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},QN=Ot&&cr<=11;class eD{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class tD{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new eD,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let o=0;o<r.length;o++)this.queue.push(r[o]);Ot&&cr<=11&&r.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():_t&&e.composing&&r.some(o=>o.type=="childList"&&o.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),QN&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,ZN)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(jh(this.view)){if(this.suppressingSelectionUpdates)return Pn(this.view);if(Ot&&cr<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Lr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let i=e.focusNode;i;i=ho(i))t.add(i);for(let i=e.anchorNode;i;i=ho(i))if(t.has(i)){r=i;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&jh(e)&&!this.ignoreSelectionChange(r),i=-1,l=-1,a=!1,c=[];if(e.editable)for(let u=0;u<t.length;u++){let f=this.registerMutation(t[u],c);f&&(i=i<0?f.from:Math.min(f.from,i),l=l<0?f.to:Math.max(f.to,l),f.typeOver&&(a=!0))}if(c.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||Ct&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(u=>u.type=="childList"&&u.removedNodes.length))){for(let u of c)if(u.nodeName=="BR"&&u.parentNode){let f=u.nextSibling;for(;f&&f.nodeType==1;){if(f.contentEditable=="false"){u.parentNode.removeChild(u);break}f=f.firstChild}}}else if(Jt&&c.length){let u=c.filter(f=>f.nodeName=="BR");if(u.length==2){let[f,p]=u;f.parentNode&&f.parentNode.parentNode==p.parentNode?p.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let p of u){let h=p.parentNode;h&&h.nodeName=="LI"&&(!f||oD(e,f)!=h)&&p.remove()}}}let d=null;i<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Li(r)&&(d=Ec(e))&&d.eq(Ae.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Pn(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||o)&&(i>-1&&(e.docView.markDirty(i,l),nD(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,sD(e,c)),this.handleDOMChange(i,l,a,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Pn(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let f=e.addedNodes[u];t.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let o=e.previousSibling,i=e.nextSibling;if(Ot&&cr<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:f,nextSibling:p}=e.addedNodes[u];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(o=f),(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(i=p)}let l=o&&o.parentNode==e.target?vt(o)+1:0,a=r.localPosFromDOM(e.target,l,-1),c=i&&i.parentNode==e.target?vt(i):e.target.childNodes.length,d=r.localPosFromDOM(e.target,c,1);return{from:a,to:d}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let ym=new WeakMap,bm=!1;function nD(n){if(!ym.has(n)&&(ym.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Jt,bm)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),bm=!0}}function km(n,e){let t=e.startContainer,r=e.startOffset,o=e.endContainer,i=e.endOffset,l=n.domAtPos(n.state.selection.anchor);return Lr(l.node,l.offset,o,i)&&([t,r,o,i]=[o,i,t,r]),{anchorNode:t,anchorOffset:r,focusNode:o,focusOffset:i}}function rD(n,e){if(e.getComposedRanges){let o=e.getComposedRanges(n.root)[0];if(o)return km(n,o)}let t;function r(o){o.preventDefault(),o.stopImmediatePropagation(),t=o.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?km(n,t):null}function oD(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function sD(n,e){var t;let{focusNode:r,focusOffset:o}=n.domSelectionRange();for(let i of e)if(((t=i.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let l=i.nextSibling;for(;l&&l.nodeName!="TD"&&l.nodeName!="TH";)l=l.nextSibling;if(l){let a=l;for(;;){let c=a.firstChild;if(!c||c.nodeType!=1||c.contentEditable=="false"||/^(BR|IMG)$/.test(c.nodeName))break;a=c}a.insertBefore(i,a.firstChild),r==i&&n.domSelection().collapse(i,o)}else i.parentNode.removeChild(i)}}function iD(n,e,t,r){let{node:o,fromOffset:i,toOffset:l,from:a,to:c}=n.docView.parseRange(e,t),d=n.domSelectionRange(),u,f=d.anchorNode;if(f&&n.dom.contains(f.nodeType==1?f:f.parentNode)&&(u=[{node:f,offset:d.anchorOffset}],Li(d)||u.push({node:d.focusNode,offset:d.focusOffset})),Ct&&n.input.lastKeyCode===8)for(let b=l;b>i;b--){let w=o.childNodes[b-1],v=w.pmViewDesc;if(w.nodeName=="BR"&&!v){l=b;break}if(!v||v.size)break}let p=n.state.doc,h=n.someProp("domParser")||Dr.fromSchema(n.state.schema),m=p.resolve(a),g=null,y=h.parse(o,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:i,to:l,preserveWhitespace:m.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:lD(r),context:m});if(u&&u[0].pos!=null){let b=u[0].pos,w=u[1]&&u[1].pos;w==null&&(w=b),g={anchor:b+a,head:w+a}}return{doc:y,sel:g,from:a,to:c}}const lD=n=>e=>{let t=e.pmViewDesc;if(t)return t.parseRule(n);if(e.nodeName=="BR"&&e.parentNode){if(_t&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||_t&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},aD=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function cD(n,e,t,r,o){let i=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let T=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,M=Ec(n,T);if(M&&!n.state.selection.eq(M)){if(Ct&&Rn&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",A=>A(n,Ir(13,"Enter"))))return;let _=n.state.tr.setSelection(M);T=="pointer"?_.setMeta("pointer",!0):T=="key"&&_.scrollIntoView(),i&&_.setMeta("composition",i),n.dispatch(_)}return}let l=n.state.doc.resolve(e),a=l.sharedDepth(t);e=l.before(a+1),t=n.state.doc.resolve(t).after(a+1);let c=n.state.selection,d=iD(n,e,t,o),u=n.state.doc,f=u.slice(d.from,d.to),p,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(p=n.state.selection.to,h="end"):(p=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let m=fD(f.content,d.doc.content,d.from,p,h);if(m&&n.input.domChangeCount++,(mo&&n.input.lastIOSEnter>Date.now()-225||Rn)&&o.some(T=>T.nodeType==1&&!aD.test(T.nodeName))&&(!m||m.endA>=m.endB)&&n.someProp("handleKeyDown",T=>T(n,Ir(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!m)if(r&&c instanceof be&&!c.empty&&c.$head.sameParent(c.$anchor)&&!n.composing&&!(d.sel&&d.sel.anchor!=d.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(d.sel){let T=wm(n,n.state.doc,d.sel);if(T&&!T.eq(n.state.selection)){let M=n.state.tr.setSelection(T);i&&M.setMeta("composition",i),n.dispatch(M)}}return}n.state.selection.from<n.state.selection.to&&m.start==m.endB&&n.state.selection instanceof be&&(m.start>n.state.selection.from&&m.start<=n.state.selection.from+2&&n.state.selection.from>=d.from?m.start=n.state.selection.from:m.endA<n.state.selection.to&&m.endA>=n.state.selection.to-2&&n.state.selection.to<=d.to&&(m.endB+=n.state.selection.to-m.endA,m.endA=n.state.selection.to)),Ot&&cr<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>d.from&&d.doc.textBetween(m.start-d.from-1,m.start-d.from+1)=="  "&&(m.start--,m.endA--,m.endB--);let g=d.doc.resolveNoCache(m.start-d.from),y=d.doc.resolveNoCache(m.endB-d.from),b=u.resolve(m.start),w=g.sameParent(y)&&g.parent.inlineContent&&b.end()>=m.endA;if((mo&&n.input.lastIOSEnter>Date.now()-225&&(!w||o.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!w&&g.pos<d.doc.content.size&&(!g.sameParent(y)||!g.parent.inlineContent)&&g.pos<y.pos&&!/\S/.test(d.doc.textBetween(g.pos,y.pos,"","")))&&n.someProp("handleKeyDown",T=>T(n,Ir(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>m.start&&uD(u,m.start,m.endA,g,y)&&n.someProp("handleKeyDown",T=>T(n,Ir(8,"Backspace")))){Rn&&Ct&&n.domObserver.suppressSelectionUpdates();return}Ct&&m.endB==m.start&&(n.input.lastChromeDelete=Date.now()),Rn&&!w&&g.start()!=y.start()&&y.parentOffset==0&&g.depth==y.depth&&d.sel&&d.sel.anchor==d.sel.head&&d.sel.head==m.endA&&(m.endB-=2,y=d.doc.resolveNoCache(m.endB-d.from),setTimeout(()=>{n.someProp("handleKeyDown",function(T){return T(n,Ir(13,"Enter"))})},20));let v=m.start,E=m.endA,N=T=>{let M=T||n.state.tr.replace(v,E,d.doc.slice(m.start-d.from,m.endB-d.from));if(d.sel){let _=wm(n,M.doc,d.sel);_&&!(Ct&&n.composing&&_.empty&&(m.start!=m.endB||n.input.lastChromeDelete<Date.now()-100)&&(_.head==v||_.head==M.mapping.map(E)-1)||Ot&&_.empty&&_.head==v)&&M.setSelection(_)}return i&&M.setMeta("composition",i),M.scrollIntoView()},R;if(w)if(g.pos==y.pos){Ot&&cr<=11&&g.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Pn(n),20));let T=N(n.state.tr.delete(v,E)),M=u.resolve(m.start).marksAcross(u.resolve(m.endA));M&&T.ensureMarks(M),n.dispatch(T)}else if(m.endA==m.endB&&(R=dD(g.parent.content.cut(g.parentOffset,y.parentOffset),b.parent.content.cut(b.parentOffset,m.endA-b.start())))){let T=N(n.state.tr);R.type=="add"?T.addMark(v,E,R.mark):T.removeMark(v,E,R.mark),n.dispatch(T)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let T=g.parent.textBetween(g.parentOffset,y.parentOffset),M=()=>N(n.state.tr.insertText(T,v,E));n.someProp("handleTextInput",_=>_(n,v,E,T,M))||n.dispatch(M())}else n.dispatch(N());else n.dispatch(N())}function wm(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Ac(n,e.resolve(t.anchor),e.resolve(t.head))}function dD(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,o=t,i=r,l,a,c;for(let u=0;u<r.length;u++)o=r[u].removeFromSet(o);for(let u=0;u<t.length;u++)i=t[u].removeFromSet(i);if(o.length==1&&i.length==0)a=o[0],l="add",c=u=>u.mark(a.addToSet(u.marks));else if(o.length==0&&i.length==1)a=i[0],l="remove",c=u=>u.mark(a.removeFromSet(u.marks));else return null;let d=[];for(let u=0;u<e.childCount;u++)d.push(c(e.child(u)));if(ee.from(d).eq(n))return{mark:a,type:l}}function uD(n,e,t,r,o){if(t-e<=o.pos-r.pos||Pc(r,!0,!1)<o.pos)return!1;let i=n.resolve(e);if(!r.parent.isTextblock){let a=i.nodeAfter;return a!=null&&t==e+a.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let l=n.resolve(Pc(i,!0,!0));return!l.parent.isTextblock||l.pos>t||Pc(l,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(l.parent.content)}function Pc(n,e,t){let r=n.depth,o=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,o++,e=!1;if(t){let i=n.node(r).maybeChild(n.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function fD(n,e,t,r,o){let i=n.findDiffStart(e,t),l=t+n.size,a=t+e.size;if(i==null)return null;let{a:c,b:d}=n.findDiffEnd(e,l,a);if(o=="end"){let u=Math.max(0,i-Math.min(c,d));r-=c+u-i}if(c<i&&l<a){let u=r<=i&&r>=c?i-r:0;i-=u,d=i+(d-c),c=i}else if(d<i){let u=r<=i&&r>=d?i-r:0;i-=u,c=i+(c-d),d=i}return{start:i,endA:c,endB:d}}class xm{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new _N,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Mm),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Sm(this),Cm(this),this.nodeViews=Em(this),this.docView=Nh(this.state.doc,vm(this),Fc(this),this.dom,this),this.domObserver=new tD(this,(r,o,i,l)=>cD(this,r,o,i,l)),this.domObserver.start(),TN(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Vc(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Mm),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let o=this.state,i=!1,l=!1;e.storedMarks&&this.composing&&(cm(this),l=!0),this.state=e;let a=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=Em(this);hD(h,this.nodeViews)&&(this.nodeViews=h,i=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&Vc(this),this.editable=Sm(this),Cm(this);let c=Fc(this),d=vm(this),u=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",f=i||!this.docView.matchesNode(e.doc,d,c);(f||!e.selection.eq(o.selection))&&(l=!0);let p=u=="preserve"&&l&&this.dom.style.overflowAnchor==null&&jB(this);if(l){this.domObserver.stop();let h=f&&(Ot||Ct)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&pD(o.selection,e.selection);if(f){let g=Ct?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=UN(this)),(i||!this.docView.update(e.doc,d,c,this))&&(this.docView.updateOuterDeco(d),this.docView.destroy(),this.docView=Nh(e.doc,d,c,this.dom,this)),g&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}let m=this.input.mouseDown;h||!(m&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&pN(this)&&m.delaySelUpdate())?Pn(this,h):(zh(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():p&&UB(p)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof Ce){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&kh(this,t.getBoundingClientRect(),e)}else kh(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,o=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let i=r.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==r.node&&(o=i)}this.dragging=new um(e.slice,e.move,o<0?void 0:Ce.create(this.state.doc,o))}someProp(e,t){let r=this._props&&this._props[e],o;if(r!=null&&(o=t?t(r):r))return o;for(let l=0;l<this.directPlugins.length;l++){let a=this.directPlugins[l].props[e];if(a!=null&&(o=t?t(a):a))return o}let i=this.state.plugins;if(i)for(let l=0;l<i.length;l++){let a=i[l].props[e];if(a!=null&&(o=t?t(a):a))return o}}hasFocus(){if(Ot){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&WB(this.dom),Pn(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return YB(this,e)}coordsAtPos(e,t=1){return Sh(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let o=this.docView.posFromDOM(e,t,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return tN(this,t||this.state,e)}pasteHTML(e,t){return fs(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return fs(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Bc(this,e)}destroy(){this.docView&&(BN(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Fc(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,VB())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return DN(this,e)}domSelectionRange(){let e=this.domSelection();return e?_t&&this.root.nodeType===11&&RB(this.dom.ownerDocument)==this.dom&&rD(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}xm.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function vm(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[Tt.node(0,n.state.doc.content.size,e)]}function Cm(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Tt.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Sm(n){return!n.someProp("editable",e=>e(n.state)===!1)}function pD(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Em(n){let e=Object.create(null);function t(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function hD(n,e){let t=0,r=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)r++;return t!=r}function Mm(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}for(var gr={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Hi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},mD=typeof navigator<"u"&&/Mac/.test(navigator.platform),gD=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),St=0;St<10;St++)gr[48+St]=gr[96+St]=String(St);for(var St=1;St<=24;St++)gr[St+111]="F"+St;for(var St=65;St<=90;St++)gr[St]=String.fromCharCode(St+32),Hi[St]=String.fromCharCode(St);for(var zc in gr)Hi.hasOwnProperty(zc)||(Hi[zc]=gr[zc]);function yD(n){var e=mD&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||gD&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Hi:gr)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const bD=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),kD=typeof navigator<"u"&&/Win/.test(navigator.platform);function wD(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,o,i,l;for(let a=0;a<e.length-1;a++){let c=e[a];if(/^(cmd|meta|m)$/i.test(c))l=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))o=!0;else if(/^s(hift)?$/i.test(c))i=!0;else if(/^mod$/i.test(c))bD?l=!0:o=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(t="Alt-"+t),o&&(t="Ctrl-"+t),l&&(t="Meta-"+t),i&&(t="Shift-"+t),t}function xD(n){let e=Object.create(null);for(let t in n)e[wD(t)]=n[t];return e}function Hc(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function vD(n){return new Ke({props:{handleKeyDown:jc(n)}})}function jc(n){let e=xD(n);return function(t,r){let o=yD(r),i,l=e[Hc(o,r)];if(l&&l(t.state,t.dispatch,t))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let a=e[Hc(o,r,!1)];if(a&&a(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(kD&&r.ctrlKey&&r.altKey)&&(i=gr[r.keyCode])&&i!=o){let a=e[Hc(i,r)];if(a&&a(t.state,t.dispatch,t))return!0}}return!1}}var CD=Object.defineProperty,Uc=(n,e)=>{for(var t in e)CD(n,t,{get:e[t],enumerable:!0})};function hs(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:o}=t,{storedMarks:i}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return o},get tr(){return r=t.selection,o=t.doc,i=t.storedMarks,t}}}var ms=class{constructor(n){this.editor=n.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=n.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:n,editor:e,state:t}=this,{view:r}=e,{tr:o}=t,i=this.buildProps(o);return Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...d)=>{const u=a(...d)(i);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(o),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(n,e=!0){const{rawCommands:t,editor:r,state:o}=this,{view:i}=r,l=[],a=!!n,c=n||o.tr,d=()=>(!a&&e&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(c),l.every(f=>f===!0)),u={...Object.fromEntries(Object.entries(t).map(([f,p])=>[f,(...m)=>{const g=this.buildProps(c,e),y=p(...m)(g);return l.push(y),u}])),run:d};return u}createCan(n){const{rawCommands:e,state:t}=this,r=!1,o=n||t.tr,i=this.buildProps(o,r);return{...Object.fromEntries(Object.entries(e).map(([a,c])=>[a,(...d)=>c(...d)({...i,dispatch:void 0})])),chain:()=>this.createChain(o,r)}}buildProps(n,e=!0){const{rawCommands:t,editor:r,state:o}=this,{view:i}=r,l={tr:n,editor:r,view:i,state:hs({state:o,transaction:n}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(n,e),can:()=>this.createCan(n),get commands(){return Object.fromEntries(Object.entries(t).map(([a,c])=>[a,(...d)=>c(...d)(l)]))}};return l}},Wc={};Uc(Wc,{blur:()=>SD,clearContent:()=>ED,clearNodes:()=>MD,command:()=>AD,createParagraphNear:()=>_D,cut:()=>TD,deleteCurrentNode:()=>BD,deleteNode:()=>ND,deleteRange:()=>DD,deleteSelection:()=>LD,enter:()=>ID,exitCode:()=>OD,extendMarkRange:()=>RD,first:()=>FD,focus:()=>PD,forEach:()=>zD,insertContent:()=>HD,insertContentAt:()=>jD,insertDefaultBlock:()=>UD,joinBackward:()=>qD,joinDown:()=>KD,joinForward:()=>GD,joinItemBackward:()=>JD,joinItemForward:()=>YD,joinTextblockBackward:()=>XD,joinTextblockForward:()=>ZD,joinUp:()=>WD,keyboardShortcut:()=>eV,lift:()=>tV,liftEmptyBlock:()=>nV,liftListItem:()=>rV,newlineInCode:()=>oV,resetAttributes:()=>sV,scrollIntoView:()=>iV,selectAll:()=>lV,selectNodeBackward:()=>aV,selectNodeForward:()=>cV,selectParentNode:()=>dV,selectTextblockEnd:()=>uV,selectTextblockStart:()=>fV,setContent:()=>pV,setMark:()=>SV,setMeta:()=>EV,setNode:()=>MV,setNodeSelection:()=>AV,setTextDirection:()=>_V,setTextSelection:()=>TV,sinkListItem:()=>BV,splitBlock:()=>NV,splitListItem:()=>DV,toggleList:()=>$V,toggleMark:()=>LV,toggleNode:()=>IV,toggleWrap:()=>OV,undoInputRule:()=>RV,unsetAllMarks:()=>FV,unsetMark:()=>PV,unsetTextDirection:()=>zV,updateAttributes:()=>HV,updateDecorations:()=>UV,wrapIn:()=>WV,wrapInList:()=>KV});var SD=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window?.getSelection())==null||t.removeAllRanges())}),!0),ED=(n=!0)=>({commands:e})=>e.setContent("",{emitUpdate:n}),MD=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:o}=r;return t&&o.forEach(({$from:i,$to:l})=>{n.doc.nodesBetween(i.pos,l.pos,(a,c)=>{if(a.type.isText)return;const{doc:d,mapping:u}=e,f=d.resolve(u.map(c)),p=d.resolve(u.map(c+a.nodeSize)),h=f.blockRange(p);if(!h)return;const m=ao(h);if(a.type.isTextblock){const{defaultType:g}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(h.start,g)}(m||m===0)&&e.lift(h,m)})}),!0},AD=n=>e=>n(e),_D=()=>({state:n,dispatch:e})=>ch(n,e),TD=(n,e)=>({editor:t,tr:r})=>{const{state:o}=t,i=o.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const l=r.mapping.map(e);return r.insert(l,i.content),r.setSelection(new be(r.doc.resolve(Math.max(l-1,0)))),!0},BD=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const o=n.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===r.type){if(e){const a=o.before(i),c=o.after(i);n.delete(a,c).scrollIntoView()}return!0}return!1};function at(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}var ND=n=>({tr:e,state:t,dispatch:r})=>{const o=at(n,t.schema),i=e.selection.$anchor;for(let l=i.depth;l>0;l-=1)if(i.node(l).type===o){if(r){const c=i.before(l),d=i.after(l);e.delete(c,d).scrollIntoView()}return!0}return!1},DD=n=>({tr:e,dispatch:t})=>{const{from:r,to:o}=n;return t&&e.delete(r,o),!0},VD=n=>n.content?/^text(\*|\+)/.test(n.content):!1,Am=(n,e,t)=>{if(!n.parent.isInline||t==="left"&&n.pos>n.start()||t==="right"&&n.pos<n.end())return n.pos;const r=e.nodes[n.parent.type.name].spec;return VD(r)?t==="left"?n.start()-1:n.end()+1:n.pos},$D=(n,e,t)=>{const r=Am(n,t,"left"),o=Am(e,t,"right");return{from:r,to:o}},LD=()=>({state:n,dispatch:e})=>{if(n.selection.empty)return!1;if(e){const t=n.tr,{ranges:r}=n.selection,o=t.steps.length;r.forEach(i=>{const l=t.mapping.slice(o),a=t.doc.resolve(l.map(i.$from.pos)),c=t.doc.resolve(l.map(i.$to.pos)),{from:d,to:u}=$D(a,c,n.schema);t.deleteRange(d,u)}),t.selection.empty||t.setSelection(be.near(t.doc.resolve(t.selection.from))),t.scrollIntoView(),e(t)}return!0},ID=()=>({commands:n})=>n.keyboardShortcut("Enter"),OD=()=>({state:n,dispatch:e})=>yB(n,e);function ji(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function gs(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(o=>t.strict?e[o]===n[o]:ji(e[o])?e[o].test(n[o]):e[o]===n[o]):!0}function _m(n,e,t={}){return n.find(r=>r.type===e&&gs(Object.fromEntries(Object.keys(t).map(o=>[o,r.attrs[o]])),t))}function Tm(n,e,t={}){return!!_m(n,e,t)}function Ui(n,e,t){if(!n||!e)return;let r=n.parent.childAfter(n.parentOffset);if((!r.node||!r.node.marks.some(d=>d.type===e))&&(r=n.parent.childBefore(n.parentOffset)),!r.node||!r.node.marks.some(d=>d.type===e))return;if(!t){const d=r.node.marks.find(u=>u.type===e);d&&(t=d.attrs)}if(!_m([...r.node.marks],e,t))return;let i=r.index,l=n.start()+r.offset,a=i+1,c=l+r.node.nodeSize;for(;i>0&&Tm([...n.parent.child(i-1).marks],e,t);)i-=1,l-=n.parent.child(i).nodeSize;for(;a<n.parent.childCount&&Tm([...n.parent.child(a).marks],e,t);)c+=n.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function yn(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}var RD=(n,e)=>({tr:t,state:r,dispatch:o})=>{const i=yn(n,r.schema),{doc:l,selection:a}=t,{$from:c,from:d,to:u}=a;if(o){const f=Ui(c,i,e);if(f&&f.from<=d&&f.to>=u){const p=be.create(l,f.from,f.to);t.setSelection(p)}}return!0},FD=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function Wi(n){return n instanceof be}function bn(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function Ki(n,e=null){if(!e)return null;const t=Ae.atStart(n),r=Ae.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const o=t.from,i=r.to;return e==="all"?be.create(n,bn(0,o,i),bn(n.content.size,o,i)):be.create(n,bn(e,o,i),bn(e,o,i))}function ys(){return["Android"].includes(navigator.platform)||/android/i.test(navigator.userAgent)}function zr(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Bm(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var PD=(n=null,e={})=>({editor:t,view:r,tr:o,dispatch:i})=>{e={scrollIntoView:!0,...e};const l=()=>{(zr()||ys())&&r.dom.focus(),Bm()&&!zr()&&!ys()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e?.scrollIntoView&&t.commands.scrollIntoView())})};try{if(r.hasFocus()&&n===null||n===!1)return!0}catch{return!1}if(i&&n===null&&!Wi(t.state.selection))return l(),!0;const a=Ki(o.doc,n)||t.state.selection,c=t.state.selection.eq(a);return i&&(c||o.setSelection(a),c&&o.storedMarks&&o.setStoredMarks(o.storedMarks),l()),!0},zD=(n,e)=>t=>n.every((r,o)=>e(r,{...t,index:o})),HD=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),Nm=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&Nm(r)}return n};function ko(n){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return Nm(t)}function Dm(n){return typeof n?.nodesBetween=="function"}function Hr(n,e,t){if(Dm(n))return n;const r=typeof n=="object"&&n!==null;t={slice:!0,parseOptions:{},...t};const o=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return ee.fromArray(n.map(a=>e.nodeFromJSON(a)));const l=e.nodeFromJSON(n);return t.errorOnInvalidContent&&l.check(),l}catch(i){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",i),Hr("",e,t)}if(o){if(t.errorOnInvalidContent){let l=!1,a="";const c=new Xa({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:d=>(l=!0,a=typeof d=="string"?d:d.outerHTML,null)}]}})});if(t.slice?Dr.fromSchema(c).parseSlice(ko(n),t.parseOptions):Dr.fromSchema(c).parse(ko(n),t.parseOptions),t.errorOnInvalidContent&&l)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const i=Dr.fromSchema(e);return t.slice?i.parseSlice(ko(n),t.parseOptions).content:i.parse(ko(n),t.parseOptions)}return Hr("",e,t)}function Vm(n){return!("type"in n)}function Kc(n,e,t){const r=n.steps.length-1;if(r<e)return;const o=n.steps[r];if(!(o instanceof lt||o instanceof pt))return;const i=n.mapping.maps[r];let l=0;i.forEach((a,c,d,u)=>{l===0&&(l=u)}),n.setSelection(Ae.near(n.doc.resolve(l),t))}var jD=(n,e,t)=>({tr:r,dispatch:o,editor:i})=>{var l;if(o){t={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let a;const c=y=>{i.emit("contentError",{editor:i,error:y,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},d={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{Hr(e,i.schema,{parseOptions:d,errorOnInvalidContent:!0})}catch(y){c(y)}try{a=Hr(e,i.schema,{parseOptions:d,errorOnInvalidContent:(l=t.errorOnInvalidContent)!=null?l:i.options.enableContentCheck})}catch(y){return c(y),!1}let{from:u,to:f}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},p=!0,h=!0;const m=Vm(a)?a.content:[a];if(m.forEach(y=>{y.check(),p=p?y.isText&&y.marks.length===0:!1,h=h?y.isBlock:!1}),u===f&&h){const{parent:y}=r.doc.resolve(u);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(u-=1,f+=1)}let g;if(p)Array.isArray(e)?g=e.map(y=>y.text||"").join(""):Dm(e)?g=m.map(y=>{var b;return(b=y.text)!=null?b:""}).join(""):typeof e=="object"&&e&&e.text?g=e.text:g=e,r.insertText(g,u,f);else{g=ee.from(m);const y=r.doc.resolve(u),b=y.node(),w=y.parentOffset===0,v=b.isText||b.isTextblock,E=b.content.size>0;w&&v&&E&&h&&(u=Math.max(0,u-1)),r.replaceWith(u,f,m)}t.updateSelection&&Kc(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:g}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:g})}return!0};function qc(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}var UD=(n={})=>({tr:e,dispatch:t,editor:r})=>{const{pos:o,attrs:i,content:l,updateSelection:a=!0}=n;let c;typeof o=="number"?c=e.doc.resolve(o):o?c=o:c=e.selection.$from;const d=qc(c.parent.contentMatchAt(c.index()));if(!d)return!1;const u=Object.keys(d.spec.attrs||{}),f=i?Object.fromEntries(Object.entries(i).filter(([h])=>u.includes(h))):{};let p;if(l){const h=Hr(l,r.schema);p=d.createAndFill(f,h)}else p=d.createAndFill(f);return p?(t&&(e.insert(c.pos,p),a&&Kc(e,e.steps.length-1,-1)),!0):!1},WD=()=>({state:n,dispatch:e})=>hB(n,e),KD=()=>({state:n,dispatch:e})=>mB(n,e),qD=()=>({state:n,dispatch:e})=>nh(n,e),GD=()=>({state:n,dispatch:e})=>ih(n,e),JD=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Ni(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},YD=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Ni(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},XD=()=>({state:n,dispatch:e})=>fB(n,e),ZD=()=>({state:n,dispatch:e})=>pB(n,e);function Gc(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function QD(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,o,i,l;for(let a=0;a<e.length-1;a+=1){const c=e[a];if(/^(cmd|meta|m)$/i.test(c))l=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))o=!0;else if(/^s(hift)?$/i.test(c))i=!0;else if(/^mod$/i.test(c))zr()||Gc()?l=!0:o=!0;else throw new Error(`Unrecognized modifier name: ${c}`)}return r&&(t=`Alt-${t}`),o&&(t=`Ctrl-${t}`),l&&(t=`Meta-${t}`),i&&(t=`Shift-${t}`),t}var eV=n=>({editor:e,view:t,tr:r,dispatch:o})=>{const i=QD(n).split(/-(?!$)/),l=i.find(d=>!["Alt","Ctrl","Meta","Shift"].includes(d)),a=new KeyboardEvent("keydown",{key:l==="Space"?" ":l,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),c=e.captureTransaction(()=>{t.someProp("handleKeyDown",d=>d(t,a))});return c?.steps.forEach(d=>{const u=d.map(r.mapping);u&&o&&r.maybeStep(u)}),!0};function kn(n,e,t={}){const{from:r,to:o,empty:i}=n.selection,l=e?at(e,n.schema):null,a=[];n.doc.nodesBetween(r,o,(f,p)=>{if(f.isText)return;const h=Math.max(r,p),m=Math.min(o,p+f.nodeSize);a.push({node:f,from:h,to:m})});const c=o-r,d=a.filter(f=>l?l.name===f.node.type.name:!0).filter(f=>gs(f.node.attrs,t,{strict:!1}));return i?!!d.length:d.reduce((f,p)=>f+p.to-p.from,0)>=c}var tV=(n,e={})=>({state:t,dispatch:r})=>{const o=at(n,t.schema);return kn(t,o,e)?gB(t,r):!1},nV=()=>({state:n,dispatch:e})=>dh(n,e),rV=n=>({state:e,dispatch:t})=>{const r=at(n,e.schema);return TB(r)(e,t)},oV=()=>({state:n,dispatch:e})=>ah(n,e);function bs(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function Jc(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,o)=>(t.includes(o)||(r[o]=n[o]),r),{})}var sV=(n,e)=>({tr:t,state:r,dispatch:o})=>{let i=null,l=null;const a=bs(typeof n=="string"?n:n.name,r.schema);if(!a)return!1;a==="node"&&(i=at(n,r.schema)),a==="mark"&&(l=yn(n,r.schema));let c=!1;return t.selection.ranges.forEach(d=>{r.doc.nodesBetween(d.$from.pos,d.$to.pos,(u,f)=>{i&&i===u.type&&(c=!0,o&&t.setNodeMarkup(f,void 0,Jc(u.attrs,e))),l&&u.marks.length&&u.marks.forEach(p=>{l===p.type&&(c=!0,o&&t.addMark(f,f+u.nodeSize,l.create(Jc(p.attrs,e))))})})}),c},iV=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),lV=()=>({tr:n,dispatch:e})=>{if(e){const t=new jt(n.doc);n.setSelection(t)}return!0},aV=()=>({state:n,dispatch:e})=>oh(n,e),cV=()=>({state:n,dispatch:e})=>lh(n,e),dV=()=>({state:n,dispatch:e})=>wB(n,e),uV=()=>({state:n,dispatch:e})=>CB(n,e),fV=()=>({state:n,dispatch:e})=>vB(n,e);function qi(n,e,t={},r={}){return Hr(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}var pV=(n,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:r={}}={})=>({editor:o,tr:i,dispatch:l,commands:a})=>{const{doc:c}=i;if(r.preserveWhitespace!=="full"){const d=qi(n,o.schema,r,{errorOnInvalidContent:e??o.options.enableContentCheck});if(l){const u=Vm(d)?d.content:[d];i.replaceWith(0,c.content.size,u).setMeta("preventUpdate",!t)}return!0}return l&&i.setMeta("preventUpdate",!t),a.insertContentAt({from:0,to:c.content.size},n,{parseOptions:r,errorOnInvalidContent:e??o.options.enableContentCheck})};function Yc(n,e){const t=yn(e,n.schema),{from:r,to:o,empty:i}=n.selection,l=[];i?(n.storedMarks&&l.push(...n.storedMarks),l.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,o,c=>{l.push(...c.marks)});const a=l.find(c=>c.type.name===t.name);return a?{...a.attrs}:{}}function Xc(n,e){const t=new lc(n);return e.forEach(r=>{r.steps.forEach(o=>{t.step(o)})}),t}function hV(n,e){const t=[];return n.descendants((r,o)=>{e(r)&&t.push({node:r,pos:o})}),t}function $m(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(o,i)=>{t(o)&&r.push({node:o,pos:i})}),r}function wo(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function ks(n){return e=>wo(e.$from,n)}function ke(n,e,t){return n.config[e]===void 0&&n.parent?ke(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?ke(n.parent,e,t):null}):n.config[e]}function Gi(n){return n.map(e=>{const t={name:e.name,options:e.options,storage:e.storage},r=ke(e,"addExtensions",t);return r?[e,...Gi(r())]:e}).flat(10)}function ws(n,e){const t=or.fromSchema(e).serializeFragment(n),o=document.implementation.createHTMLDocument().createElement("div");return o.appendChild(t),o.innerHTML}function Zc(n){return typeof n=="function"}function Re(n,e=void 0,...t){return Zc(n)?e?n.bind(e)(...t):n(...t):n}function Lm(n={}){return Object.keys(n).length===0&&n.constructor===Object}function jr(n){const e=n.filter(o=>o.type==="extension"),t=n.filter(o=>o.type==="node"),r=n.filter(o=>o.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function Qc(n){const e=[],{nodeExtensions:t,markExtensions:r}=jr(n),o=[...t,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},l=t.filter(d=>d.name!=="text").map(d=>d.name),a=r.map(d=>d.name),c=[...l,...a];return n.forEach(d=>{const u={name:d.name,options:d.options,storage:d.storage,extensions:o},f=ke(d,"addGlobalAttributes",u);if(!f)return;f().forEach(h=>{let m;Array.isArray(h.types)?m=h.types:h.types==="*"?m=c:h.types==="nodes"?m=l:h.types==="marks"?m=a:m=[],m.forEach(g=>{Object.entries(h.attributes).forEach(([y,b])=>{e.push({type:g,name:y,attribute:{...i,...b}})})})})}),o.forEach(d=>{const u={name:d.name,options:d.options,storage:d.storage},f=ke(d,"addAttributes",u);if(!f)return;const p=f();Object.entries(p).forEach(([h,m])=>{const g={...i,...m};typeof g?.default=="function"&&(g.default=g.default()),g?.isRequired&&g?.default===void 0&&delete g.default,e.push({type:d.name,name:h,attribute:g})})}),e}function mV(n){const e=[];let t="",r=!1,o=!1,i=0;const l=n.length;for(let a=0;a<l;a+=1){const c=n[a];if(c==="'"&&!o){r=!r,t+=c;continue}if(c==='"'&&!r){o=!o,t+=c;continue}if(!r&&!o){if(c==="("){i+=1,t+=c;continue}if(c===")"&&i>0){i-=1,t+=c;continue}if(c===";"&&i===0){e.push(t),t="";continue}}t+=c}return t&&e.push(t),e}function Im(n){const e=[],t=mV(n||""),r=t.length;for(let o=0;o<r;o+=1){const i=t[o],l=i.indexOf(":");if(l===-1)continue;const a=i.slice(0,l).trim(),c=i.slice(l+1).trim();a&&c&&e.push([a,c])}return e}function ze(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([o,i])=>{if(!r[o]){r[o]=i;return}if(o==="class"){const a=i?String(i).split(" "):[],c=r[o]?r[o].split(" "):[],d=a.filter(u=>!c.includes(u));r[o]=[...c,...d].join(" ")}else if(o==="style"){const a=new Map([...Im(r[o]),...Im(i)]);r[o]=Array.from(a.entries()).map(([c,d])=>`${c}: ${d}`).join("; ")}else r[o]=i}),r},{})}function Ur(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>ze(t,r),{})}function Om(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function ed(n,e){return"style"in n?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const o=e.reduce((i,l)=>{const a=l.attribute.parseHTML?l.attribute.parseHTML(t):Om(t.getAttribute(l.name));return a==null?i:{...i,[l.name]:a}},{});return{...r,...o}}}}function Rm(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&Lm(t)?!1:t!=null))}function Fm(n){var e,t;const r={};return!((e=n?.attribute)!=null&&e.isRequired)&&"default"in(n?.attribute||{})&&(r.default=n.attribute.default),((t=n?.attribute)==null?void 0:t.validate)!==void 0&&(r.validate=n.attribute.validate),[n.name,r]}function td(n,e){var t;const r=Qc(n),{nodeExtensions:o,markExtensions:i}=jr(n),l=(t=o.find(d=>ke(d,"topNode")))==null?void 0:t.name,a=Object.fromEntries(o.map(d=>{const u=r.filter(b=>b.type===d.name),f={name:d.name,options:d.options,storage:d.storage,editor:e},p=n.reduce((b,w)=>{const v=ke(w,"extendNodeSchema",f);return{...b,...v?v(d):{}}},{}),h=Rm({...p,content:Re(ke(d,"content",f)),marks:Re(ke(d,"marks",f)),group:Re(ke(d,"group",f)),inline:Re(ke(d,"inline",f)),atom:Re(ke(d,"atom",f)),selectable:Re(ke(d,"selectable",f)),draggable:Re(ke(d,"draggable",f)),code:Re(ke(d,"code",f)),whitespace:Re(ke(d,"whitespace",f)),linebreakReplacement:Re(ke(d,"linebreakReplacement",f)),defining:Re(ke(d,"defining",f)),isolating:Re(ke(d,"isolating",f)),attrs:Object.fromEntries(u.map(Fm))}),m=Re(ke(d,"parseHTML",f));m&&(h.parseDOM=m.map(b=>ed(b,u)));const g=ke(d,"renderHTML",f);g&&(h.toDOM=b=>g({node:b,HTMLAttributes:Ur(b,u)}));const y=ke(d,"renderText",f);return y&&(h.toText=y),[d.name,h]})),c=Object.fromEntries(i.map(d=>{const u=r.filter(y=>y.type===d.name),f={name:d.name,options:d.options,storage:d.storage,editor:e},p=n.reduce((y,b)=>{const w=ke(b,"extendMarkSchema",f);return{...y,...w?w(d):{}}},{}),h=Rm({...p,inclusive:Re(ke(d,"inclusive",f)),excludes:Re(ke(d,"excludes",f)),group:Re(ke(d,"group",f)),spanning:Re(ke(d,"spanning",f)),code:Re(ke(d,"code",f)),attrs:Object.fromEntries(u.map(Fm))}),m=Re(ke(d,"parseHTML",f));m&&(h.parseDOM=m.map(y=>ed(y,u)));const g=ke(d,"renderHTML",f);return g&&(h.toDOM=y=>g({mark:y,HTMLAttributes:Ur(y,u)})),[d.name,h]}));return new Xa({topNode:l,nodes:a,marks:c})}function Pm(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}function xo(n){return n.sort((t,r)=>{const o=ke(t,"priority")||100,i=ke(r,"priority")||100;return o>i?-1:o<i?1:0})}function Ji(n){const e=xo(Gi(n)),t=Pm(e.map(r=>r.name));return t.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${t.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function Yi(n,e){const t=Ji(n);return td(t,e)}function gV(n,e){const t=Yi(e),r=mn.fromJSON(t,n);return ws(r.content,t)}function yV(n,e){const t=Yi(e),r=ko(n);return Dr.fromSchema(t).parse(r).toJSON()}function nd(n,e,t){const{from:r,to:o}=e,{blockSeparator:i=`
61
+
62
+ `,textSerializers:l={}}=t||{};let a="";return n.nodesBetween(r,o,(c,d,u,f)=>{var p;c.isBlock&&d>r&&(a+=i);const h=l?.[c.type.name];if(h)return u&&(a+=h({node:c,pos:d,parent:u,index:f,range:e})),!1;c.isText&&(a+=(p=c?.text)==null?void 0:p.slice(Math.max(r,d)-d,o-d))}),a}function rd(n,e){const t={from:0,to:n.content.size};return nd(n,t,e)}function Xi(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function bV(n,e,t){const{blockSeparator:r=`
63
+
64
+ `,textSerializers:o={}}=t||{},i=Yi(e),l=mn.fromJSON(i,n);return rd(l,{blockSeparator:r,textSerializers:{...Xi(i),...o}})}function zm(n,e){const t=at(e,n.schema),{from:r,to:o}=n.selection,i=[];n.doc.nodesBetween(r,o,a=>{i.push(a)});const l=i.reverse().find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function od(n,e){const t=bs(typeof e=="string"?e:e.name,n.schema);return t==="node"?zm(n,e):t==="mark"?Yc(n,e):{}}function Hm(n,e=JSON.stringify){const t={};return n.filter(r=>{const o=e(r);return Object.prototype.hasOwnProperty.call(t,o)?!1:t[o]=!0})}function kV(n){const e=Hm(n);return e.length===1?e:e.filter((t,r)=>!e.filter((i,l)=>l!==r).some(i=>t.oldRange.from>=i.oldRange.from&&t.oldRange.to<=i.oldRange.to&&t.newRange.from>=i.newRange.from&&t.newRange.to<=i.newRange.to))}function xs(n){const{mapping:e,steps:t}=n,r=[];return e.maps.forEach((o,i)=>{const l=[];if(o.ranges.length)o.forEach((a,c)=>{l.push({from:a,to:c})});else{const{from:a,to:c}=t[i];if(a===void 0||c===void 0)return;l.push({from:a,to:c})}l.forEach(({from:a,to:c})=>{const d=e.slice(i).map(a,-1),u=e.slice(i).map(c),f=e.invert().map(d,-1),p=e.invert().map(u);r.push({oldRange:{from:f,to:p},newRange:{from:d,to:u}})})}),kV(r)}function jm(n,e=0){const r=n.type===n.type.schema.topNodeType?0:1,o=e,i=o+n.nodeSize,l=n.marks.map(d=>{const u={type:d.type.name};return Object.keys(d.attrs).length&&(u.attrs={...d.attrs}),u}),a={...n.attrs},c={type:n.type.name,from:o,to:i};return Object.keys(a).length&&(c.attrs=a),l.length&&(c.marks=l),n.content.childCount&&(c.content=[],n.forEach((d,u)=>{var f;(f=c.content)==null||f.push(jm(d,e+u+r))})),n.text&&(c.text=n.text),c}function Zi(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(o=>{const i=t.resolve(n),l=Ui(i,o.type);l&&r.push({mark:o,...l})}):t.nodesBetween(n,e,(o,i)=>{!o||o?.nodeSize===void 0||r.push(...o.marks.map(l=>({from:i,to:i+o.nodeSize,mark:l})))}),r}var Um=(n,e,t,r=20)=>{const o=n.doc.resolve(t);let i=r,l=null;for(;i>0&&l===null;){const a=o.node(i);a?.type.name===e?l=a:i-=1}return[l,i]},Wm=n=>{const e=n.depth-1;if(e<0)return null;const t=n.index(e);return t===0?null:n.node(e).child(t-1)};function Wr(n,e){return e.nodes[n]||e.marks[n]||null}function vs(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const o=n.find(i=>i.type===e&&i.name===r);return o?o.attribute.keepOnSplit:!1}))}var Km=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(o,i,l,a)=>{var c,d;const u=((d=(c=o.type.spec).toText)==null?void 0:d.call(c,{node:o,pos:i,parent:l,index:a}))||o.textContent||"%leaf%";t+=o.isAtom&&!o.isText?u:u.slice(0,Math.max(0,r-i))}),t};function Qi(n,e,t={}){const{empty:r,ranges:o}=n.selection,i=e?yn(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(f=>i?i.name===f.type.name:!0).find(f=>gs(f.attrs,t,{strict:!1}));let l=0;const a=[];if(o.forEach(({$from:f,$to:p})=>{const h=f.pos,m=p.pos;n.doc.nodesBetween(h,m,(g,y)=>{if(i&&g.inlineContent&&!g.type.allowsMarkType(i))return!1;if(!g.isText&&!g.marks.length)return;const b=Math.max(h,y),w=Math.min(m,y+g.nodeSize),v=w-b;l+=v,a.push(...g.marks.map(E=>({mark:E,from:b,to:w})))})}),l===0)return!1;const c=a.filter(f=>i?i.name===f.mark.type.name:!0).filter(f=>gs(f.mark.attrs,t,{strict:!1})).reduce((f,p)=>f+p.to-p.from,0),d=a.filter(f=>i?f.mark.type!==i&&f.mark.type.excludes(i):!0).reduce((f,p)=>f+p.to-p.from,0);return(c>0?c+d:c)>=l}function qm(n,e,t={}){if(!e)return kn(n,null,t)||Qi(n,null,t);const r=bs(e,n.schema);return r==="node"?kn(n,e,t):r==="mark"?Qi(n,e,t):!1}var Gm=(n,e)=>{const{$from:t,$to:r,$anchor:o}=n.selection;if(e){const i=ks(a=>a.type.name===e)(n.selection);if(!i)return!1;const l=n.doc.resolve(i.pos+1);return o.pos+1===l.end()}return!(r.parentOffset<r.parent.nodeSize-2||t.pos!==r.pos)},Jm=n=>{const{$from:e,$to:t}=n.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function sd(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function el(n,e){const{nodeExtensions:t}=jr(e),r=t.find(l=>l.name===n);if(!r)return!1;const o={name:r.name,options:r.options,storage:r.storage},i=Re(ke(r,"group",o));return typeof i!="string"?!1:i.split(" ").includes("list")}function vo(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return!/\S/.test((r=n.text)!=null?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let o=!0;return n.content.forEach(i=>{o!==!1&&(vo(i,{ignoreWhitespace:t,checkChildren:e})||(o=!1))}),o}return!1}function id(n){return n instanceof Ce}function wV({selection:n,pos:e,nodeSize:t,selectedOnTextSelection:r=!1}){const{from:o,to:i}=n;return!!(o<=e&&i>=e+t||r&&Wi(n)&&o>e&&i<e+t)}var ld=class tb{constructor(e){this.position=e}static fromJSON(e){return new tb(e.position)}toJSON(){return{position:this.position}}};function Ym(n,e){const t=e.mapping.mapResult(n.position);return{position:new ld(t.pos),mapResult:t}}function Xm(n){return new ld(n)}function xV(n,e,t){const o=n.state.doc.content.size,i=bn(e,0,o),l=bn(t,0,o),a=n.coordsAtPos(i),c=n.coordsAtPos(l,-1),d=Math.min(a.top,c.top),u=Math.max(a.bottom,c.bottom),f=Math.min(a.left,c.left),p=Math.max(a.right,c.right),h=p-f,m=u-d,b={top:d,bottom:u,left:f,right:p,width:h,height:m,x:f,y:d};return{...b,toJSON:()=>b}}function Zm({json:n,validMarks:e,validNodes:t,options:r,rewrittenContent:o=[]}){return n.marks&&Array.isArray(n.marks)&&(n.marks=n.marks.filter(i=>{if(i==null)return!1;const l=typeof i=="string"?i:i.type;return e.has(l)?!0:(o.push({original:JSON.parse(JSON.stringify(i)),unsupported:l}),!1)})),n.content&&Array.isArray(n.content)&&(n.content=n.content.map(i=>i==null?null:Zm({json:i,validMarks:e,validNodes:t,options:r,rewrittenContent:o}).json).filter(i=>i!=null)),n.type&&!t.has(n.type)?(o.push({original:JSON.parse(JSON.stringify(n)),unsupported:n.type}),n.content&&Array.isArray(n.content)&&r?.fallbackToParagraph!==!1?(n.type="paragraph",{json:n,rewrittenContent:o}):{json:null,rewrittenContent:o}):{json:n,rewrittenContent:o}}function vV(n,e,t){return Zm({json:n,validNodes:new Set(Object.keys(e.nodes)),validMarks:new Set(Object.keys(e.marks)),options:t})}function CV(n,e,t){var r;const{selection:o}=e;let i=null;if(Wi(o)&&(i=o.$cursor),i){const a=(r=n.storedMarks)!=null?r:i.marks();return i.parent.type.allowsMarkType(t)&&(!!t.isInSet(a)||!a.some(d=>d.type.excludes(t)))}const{ranges:l}=o;return l.some(({$from:a,$to:c})=>{let d=a.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(a.pos,c.pos,(u,f,p)=>{if(d)return!1;if(u.isInline){const h=!p||p.type.allowsMarkType(t),m=!!t.isInSet(u.marks)||!u.marks.some(g=>g.type.excludes(t));d=h&&m}return!d}),d})}var SV=(n,e={})=>({tr:t,state:r,dispatch:o})=>{const{selection:i}=t,{empty:l,ranges:a}=i,c=yn(n,r.schema);if(o)if(l){const d=Yc(r,c);t.addStoredMark(c.create({...d,...e}))}else a.forEach(d=>{const u=d.$from.pos,f=d.$to.pos;r.doc.nodesBetween(u,f,(p,h)=>{const m=Math.max(h,u),g=Math.min(h+p.nodeSize,f);p.marks.find(b=>b.type===c)?p.marks.forEach(b=>{c===b.type&&t.addMark(m,g,c.create({...b.attrs,...e}))}):t.addMark(m,g,c.create(e))})});return CV(r,t,c)},EV=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),MV=(n,e={})=>({state:t,dispatch:r,chain:o})=>{const i=at(n,t.schema);let l;return t.selection.$anchor.sameParent(t.selection.$head)&&(l=t.selection.$anchor.parent.attrs),i.isTextblock?o().command(({commands:a})=>ph(i,{...l,...e})(t)?!0:a.clearNodes()).command(({state:a})=>ph(i,{...l,...e})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},AV=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,o=bn(n,0,r.content.size),i=Ce.create(r,o);e.setSelection(i)}return!0},_V=(n,e)=>({tr:t,state:r,dispatch:o})=>{const{selection:i}=r;let l,a;return typeof e=="number"?(l=e,a=e):e&&"from"in e&&"to"in e?(l=e.from,a=e.to):(l=i.from,a=i.to),o&&t.doc.nodesBetween(l,a,(c,d)=>{c.isText||t.setNodeMarkup(d,void 0,{...c.attrs,dir:n})}),!0},TV=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:o,to:i}=typeof n=="number"?{from:n,to:n}:n,l=be.atStart(r).from,a=be.atEnd(r).to,c=bn(o,l,a),d=bn(i,l,a),u=be.create(r,c,d);e.setSelection(u)}return!0},BV=n=>({state:e,dispatch:t})=>{const r=at(n,e.schema);return DB(r)(e,t)};function Qm(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(o=>e?.includes(o.type.name));n.tr.ensureMarks(r)}}var NV=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:o})=>{const{selection:i,doc:l}=e,{$from:a,$to:c}=i,d=o.extensionManager.attributes,u=vs(d,a.node().type.name,a.node().attrs);if(i instanceof Ce&&i.node.isBlock)return!a.parentOffset||!In(l,a.pos)?!1:(r&&(n&&Qm(t,o.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const f=c.parentOffset===c.parent.content.size,p=a.depth===0?void 0:qc(a.node(-1).contentMatchAt(a.indexAfter(-1)));let h=f&&p?[{type:p,attrs:u}]:void 0,m=In(e.doc,e.mapping.map(a.pos),1,h);if(!h&&!m&&In(e.doc,e.mapping.map(a.pos),1,p?[{type:p}]:void 0)&&(m=!0,h=p?[{type:p,attrs:u}]:void 0),r){if(m&&(i instanceof be&&e.deleteSelection(),e.split(e.mapping.map(a.pos),1,h),p&&!f&&!a.parentOffset&&a.parent.type!==p)){const g=e.mapping.map(a.before()),y=e.doc.resolve(g);a.node(-1).canReplaceWith(y.index(),y.index()+1,p)&&e.setNodeMarkup(e.mapping.map(a.before()),p)}n&&Qm(t,o.extensionManager.splittableMarks),e.scrollIntoView()}return m},DV=(n,e={})=>({tr:t,state:r,dispatch:o,editor:i})=>{var l;const a=at(n,r.schema),{$from:c,$to:d}=r.selection,u=r.selection.node;if(u&&u.isBlock||c.depth<2||!c.sameParent(d))return!1;const f=c.node(-1);if(f.type!==a)return!1;const p=i.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==a||c.index(-2)!==c.node(-2).childCount-1)return!1;if(o){let b=ee.empty;const w=c.index(-1)?1:c.index(-2)?2:3;for(let M=c.depth-w;M>=c.depth-3;M-=1)b=ee.from(c.node(M).copy(b));const v=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,E={...vs(p,c.node().type.name,c.node().attrs),...e},N=((l=a.contentMatch.defaultType)==null?void 0:l.createAndFill(E))||void 0;b=b.append(ee.from(a.createAndFill(null,N)||void 0));const R=c.before(c.depth-(w-1));t.replace(R,c.after(-v),new fe(b,4-w,0));let T=-1;t.doc.nodesBetween(R,t.doc.content.size,(M,_)=>{if(T>-1)return!1;M.isTextblock&&M.content.size===0&&(T=_+1)}),T>-1&&t.setSelection(be.near(t.doc.resolve(T))),t.scrollIntoView()}return!0}const h=d.pos===c.end()?f.contentMatchAt(0).defaultType:null,m={...vs(p,f.type.name,f.attrs),...e},g={...vs(p,c.node().type.name,c.node().attrs),...e};t.delete(c.pos,d.pos);const y=h?[{type:a,attrs:m},{type:h,attrs:g}]:[{type:a,attrs:m}];if(!In(t.doc,c.pos,2))return!1;if(o){const{selection:b,storedMarks:w}=r,{splittableMarks:v}=i.extensionManager,E=w||b.$to.parentOffset&&b.$from.marks();if(t.split(c.pos,2,y).scrollIntoView(),!E||!o)return!0;const N=E.filter(R=>v.includes(R.type.name));t.ensureMarks(N)}return!0};function eg(n){return!n||n==="1"?null:n}function tg(n,e){return eg(n)===eg(e)}var ad=(n,e)=>{const t=ks(l=>l.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const o=n.doc.nodeAt(r);return!(t.node.type===o?.type&&lr(n.doc,t.pos))||!tg(t.node.attrs.type,o?.attrs.type)||n.join(t.pos),!0},cd=(n,e)=>{const t=ks(l=>l.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const o=n.doc.nodeAt(r);return!(t.node.type===o?.type&&lr(n.doc,r))||!tg(t.node.attrs.type,o?.attrs.type)||n.join(r),!0};function VV(n){const e=n.doc,t=e.firstChild;if(!t)return null;const r=e.resolve(1),o=e.resolve(t.nodeSize-1);return be.between(r,o)}var $V=(n,e,t,r={})=>({editor:o,tr:i,state:l,dispatch:a,chain:c,commands:d,can:u})=>{const{extensions:f,splittableMarks:p}=o.extensionManager,h=at(n,l.schema),m=at(e,l.schema),{selection:g,storedMarks:y}=l,{$from:b,$to:w}=g,v=b.blockRange(w),E=y||g.$to.parentOffset&&g.$from.marks();if(!v)return!1;const N=ks(Z=>el(Z.type.name,f))(g),R=g.from===0&&g.to===l.doc.content.size,T=l.doc.content.content,M=T.length===1?T[0]:null,_=R&&M&&el(M.type.name,f)?{node:M,pos:0}:null,A=N??_,L=!!N&&v.depth>=1&&v.depth-N.depth<=1,z=!!_;if((L||z)&&A){if(A.node.type===h)return R&&z?c().command(({tr:Z,dispatch:D})=>{const P=VV(Z);return P?(Z.setSelection(P),D&&D(Z),!0):!1}).liftListItem(m).run():d.liftListItem(m);if(el(A.node.type.name,f)&&h.validContent(A.node.content))return c().command(()=>(i.setNodeMarkup(A.pos,h),!0)).command(()=>ad(i,h)).command(()=>cd(i,h)).run()}return!t||!E||!a?c().command(()=>u().wrapInList(h,r)?!0:d.clearNodes()).wrapInList(h,r).command(()=>ad(i,h)).command(()=>cd(i,h)).run():c().command(()=>{const Z=u().wrapInList(h,r),D=E.filter(P=>p.includes(P.type.name));return i.ensureMarks(D),Z?!0:d.clearNodes()}).wrapInList(h,r).command(()=>ad(i,h)).command(()=>cd(i,h)).run()},LV=(n,e={},t={})=>({state:r,commands:o})=>{const{extendEmptyMarkRange:i=!1}=t,l=yn(n,r.schema);return Qi(r,l,e)?o.unsetMark(l,{extendEmptyMarkRange:i}):o.setMark(l,e)},IV=(n,e,t={})=>({state:r,commands:o})=>{const i=at(n,r.schema),l=at(e,r.schema),a=kn(r,i,t);let c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),a?o.setNode(l,c):o.setNode(i,{...c,...t})},OV=(n,e={})=>({state:t,commands:r})=>{const o=at(n,t.schema);return kn(t,o,e)?r.lift(o):r.wrapIn(o,e)},RV=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const o=t[r];let i;if(o.spec.isInputRules&&(i=o.getState(n))){if(e){const l=n.tr,a=i.transform;for(let c=a.steps.length-1;c>=0;c-=1)l.step(a.steps[c].invert(a.docs[c]));if(i.text){const c=l.doc.resolve(i.from).marks();l.replaceWith(i.from,i.to,n.schema.text(i.text,c))}else l.delete(i.from,i.to)}return!0}}return!1},FV=(n={})=>({tr:e,dispatch:t,editor:r})=>{const{ignoreClearable:o=!1}=n,{selection:i}=e,{empty:l,ranges:a}=i;if(l)return!0;const{nonClearableMarks:c}=r.extensionManager;if(t){const d=Object.values(r.schema.marks).filter(u=>o||!c.includes(u.name));a.forEach(u=>{for(const f of d)e.removeMark(u.$from.pos,u.$to.pos,f)})}return!0},PV=(n,e={})=>({tr:t,state:r,dispatch:o})=>{var i;const{extendEmptyMarkRange:l=!1}=e,{selection:a}=t,c=yn(n,r.schema),{$from:d,empty:u,ranges:f}=a;if(!o)return!0;if(u&&l){let{from:p,to:h}=a;const m=(i=d.marks().find(y=>y.type===c))==null?void 0:i.attrs,g=Ui(d,c,m);g&&(p=g.from,h=g.to),t.removeMark(p,h,c)}else f.forEach(p=>{t.removeMark(p.$from.pos,p.$to.pos,c)});return t.removeStoredMark(c),!0},zV=n=>({tr:e,state:t,dispatch:r})=>{const{selection:o}=t;let i,l;return typeof n=="number"?(i=n,l=n):n&&"from"in n&&"to"in n?(i=n.from,l=n.to):(i=o.from,l=o.to),r&&e.doc.nodesBetween(i,l,(a,c)=>{if(a.isText)return;const d={...a.attrs};delete d.dir,e.setNodeMarkup(c,void 0,d)}),!0},HV=(n,e={})=>({tr:t,state:r,dispatch:o})=>{let i=null,l=null;const a=bs(typeof n=="string"?n:n.name,r.schema);if(!a)return!1;a==="node"&&(i=at(n,r.schema)),a==="mark"&&(l=yn(n,r.schema));let c=!1;return t.selection.ranges.forEach(d=>{const u=d.$from.pos,f=d.$to.pos;let p,h,m,g;t.selection.empty?r.doc.nodesBetween(u,f,(y,b)=>{i&&i===y.type&&(c=!0,m=Math.max(b,u),g=Math.min(b+y.nodeSize,f),p=b,h=y)}):r.doc.nodesBetween(u,f,(y,b)=>{b<u&&i&&i===y.type&&(c=!0,m=Math.max(b,u),g=Math.min(b+y.nodeSize,f),p=b,h=y),b>=u&&b<=f&&(i&&i===y.type&&(c=!0,o&&t.setNodeMarkup(b,void 0,{...y.attrs,...e})),l&&y.marks.length&&y.marks.forEach(w=>{if(l===w.type&&(c=!0,o)){const v=Math.max(b,u),E=Math.min(b+y.nodeSize,f);t.addMark(v,E,l.create({...w.attrs,...e}))}}))}),h&&(p!==void 0&&o&&t.setNodeMarkup(p,void 0,{...h.attrs,...e}),l&&h.marks.length&&h.marks.forEach(y=>{l===y.type&&o&&t.addMark(m,g,l.create({...y.attrs,...e}))}))}),c},jV="__tiptap_decorations__",Kr=new Qe(jV),UV=n=>({tr:e,dispatch:t})=>(t&&e.setMeta(Kr,{type:"force",name:n}),!0),WV=(n,e={})=>({state:t,dispatch:r})=>{const o=at(n,t.schema);return SB(o,e)(t,r)},KV=(n,e={})=>({state:t,dispatch:r})=>{const o=at(n,t.schema);return MB(o,e)(t,r)},Co=new WeakMap;function qV(n,e){var t,r;Co.set(n,((t=Co.get(n))!=null?t:0)+1);try{return e()}finally{const o=((r=Co.get(n))!=null?r:1)-1;o>0?Co.set(n,o):Co.delete(n)}}function GV(n){return Co.has(n)}var JV=class{constructor(){this.callbacks={}}on(n,e){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(e),this}emit(n,...e){const t=this.callbacks[n];return t&&t.forEach(r=>r.apply(this,e)),this}off(n,e){const t=this.callbacks[n];return t&&(e?this.callbacks[n]=t.filter(r=>r!==e):delete this.callbacks[n]),this}once(n,e){const t=(...r)=>{this.off(n,t),e.apply(this,r)};return this.on(n,t)}removeAllListeners(){this.callbacks={}}},ng=typeof process<"u"&&process.env.NODE_ENV!=="production";function YV(n){return n.kind==="widget"}function rg(n,e){const t=[],r=new Set;for(const o of n)o.kind==="widget"&&YV(o)&&r.add(o.key),t.push(o.toPMDecoration(e));return{decorations:t,widgetKeys:r}}function XV(n,e,t){const{decorations:r,widgetKeys:o}=rg(e,t);return{set:Oe.create(n,r),widgetKeys:o}}function og({position:n,from:e,to:t,docSize:r}){return n<e?!1:n<t?!0:n===t&&t===r}function ZV({decorations:n,from:e,to:t,docSize:r,extensionName:o,warnedExtensions:i}){return n.filter(l=>og({position:l.anchor,from:e,to:t,docSize:r})?!0:(l.anchor===t||i.has(o)||(i.add(o),console.warn(`[tiptap warn]: Extension "${o}" returned a decoration outside the requested range [${e}, ${t}). It was ignored.`)),!1))}function sg(n){var e;const t=(e=n.spec)==null?void 0:e.key;return typeof t=="string"?t:void 0}function QV(n){var e,t,r;const o=new Map,i=new Map;for(const l of n.find()){const a=sg(l);if(!a)continue;const c=(e=l.spec.extensionName)!=null?e:"unknown",d=(t=o.get(a))!=null?t:new Set;d.add(c),o.set(a,d),i.set(a,((r=i.get(a))!=null?r:0)+1)}return Array.from(o,([l,a])=>({key:l,extensions:a})).filter(({key:l})=>{var a;return((a=i.get(l))!=null?a:0)>1})}function ig(n){return n.jsonID==="attr"}function e$(n){let e=!1;if(n.getMap().forEach(()=>{e=!0}),e||ig(n))return!0;const t=n;return typeof t.from=="number"&&typeof t.to=="number"}function t$(n,e){let t=null,r=0,o=0;for(let i=0;i<n.childCount&&!(o>e.to);i+=1){const l=o+n.child(i).nodeSize;l>=e.from&&(t===null&&(t=o),r=l),o=l}return t===null?null:{from:t,to:r}}function n$(n,e){if(n.steps.some(i=>!e$(i)))return{type:"full"};const t=xs(n).map(({newRange:i})=>i);n.steps.forEach((i,l)=>{if(!ig(i))return;const a=n.mapping.slice(l);t.push({from:a.map(i.pos,-1),to:a.map(i.pos+1)})});const r=[];for(const i of t){const l=t$(e,i);l&&r.push(l)}r.sort((i,l)=>i.from-l.from);const o=[];for(const i of r){const l=o[o.length-1];l&&i.from<=l.to?l.to=Math.max(l.to,i.to):o.push({...i})}return{type:"ranges",ranges:o}}function lg(n,e,t,r){return n.map(e,t,{onRemove:o=>{const i=o?.key;typeof i=="string"&&r.delete(i)}})}function r$(n,e,t){var r,o;const i=(r=e.decorationSetsByExtension[n])!=null?r:Oe.empty,l=new Set((o=e.widgetKeysByExtension[n])!=null?o:[]);return{set:lg(i,t.mapping,t.doc,l),widgetKeys:l}}function ag(n,e){const t=Object.values(e).flatMap(r=>r.find());return Oe.create(n,t)}function cg(n){const e=new Set;for(const t of Object.values(n))for(const r of t)e.add(r);return e}function o$(n,e){var t;switch((t=e.update)!=null?t:"document"){case"document":if(e.createInRange)throw new Error(`[tiptap error]: Extension "${n}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);return;case"changedRanges":if(!e.createInRange)throw new Error(`[tiptap error]: Extension "${n}" uses the "changedRanges" decoration update strategy but does not provide createInRange().`);return;case"manual":if(e.createInRange)throw new Error(`[tiptap error]: Extension "${n}" uses the "manual" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the "changedRanges" strategy.`);if(e.shouldUpdate)throw new Error(`[tiptap error]: Extension "${n}" cannot combine the "manual" decoration update strategy with shouldUpdate().`);return;default:throw new Error(`[tiptap error]: Extension "${n}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`)}}function s$(n,e,t){return t?!0:n.update==="manual"?!1:n.shouldUpdate?n.shouldUpdate(e):e.tr.docChanged}var dg=new Set;function ug(n){var e,t,r;return(r=(t=(e=n.extensionManager)==null?void 0:e.decorationManager)==null?void 0:t.liveWidgetKeys())!=null?r:dg}var fg=class{constructor(n){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:e})=>{const t=Kr.getState(e);t&&this.warnDuplicateWidgetKeys(t)},this.editor=n.editor,this.entries=this.resolveEntries(n.entries),this.entries.forEach(({name:e,spec:t})=>o$(e,t)),this.plugin=this.entries.length>0?this.createPlugin():null,this.editor.on("beforeTransaction",this.handleBeforeTransaction)}destroy(){this.editor.off("beforeTransaction",this.handleBeforeTransaction)}liveWidgetKeys(){var n,e;return(e=(n=Kr.getState(this.editor.state))==null?void 0:n.widgetKeys)!=null?e:dg}get mountedView(){return this.editor.isDestroyed?null:this.editor.view}resolveEntries(n){const e=[];for(const{name:t,addDecorations:r}of n){const o=r();o&&e.push({name:t,spec:o})}return e}createPlugin(){const{editor:n,entries:e}=this;return new Ke({key:Kr,state:{init:(t,r)=>{const o={},i={};for(const{name:a,spec:c}of e){const{set:d,widgetKeys:u}=this.buildFullSet(a,c,r);o[a]=d,i[a]=u}const l={decorationSetsByExtension:o,widgetKeysByExtension:i,mergedDecorationSet:this.buildMergedSet(r.doc,o),widgetKeys:cg(i)};return this.warnDuplicateWidgetKeys(l),l},apply:(t,r,o,i)=>{const l=t.getMeta(Kr),a=l?.type==="force"&&!l.name,c=l?.type==="force"?l.name:void 0,d={},u={},f=new Set;if(qV(n,()=>{for(const{name:h,spec:m}of e){const g=a||c===h;if(s$(m,{editor:n,tr:t,oldState:o,newState:i},g))if(m.update==="changedRanges"&&t.docChanged&&!g){const b=this.applyChangedRangesRecompute(h,m,r,t,i);d[h]=b.set,u[h]=b.widgetKeys,f.add(h)}else{const{set:b,widgetKeys:w}=this.buildFullSet(h,m,i);d[h]=b,u[h]=w,f.add(h)}else{const b=r$(h,r,t);d[h]=b.set,u[h]=b.widgetKeys}}}),f.size===0&&!t.docChanged)return r;const p=this.mergeAfterApply({entries:e,previous:r,tr:t,decorationSetsByExtension:d,recomputedNames:f});return{decorationSetsByExtension:d,widgetKeysByExtension:u,mergedDecorationSet:p,widgetKeys:cg(u)}}},props:{decorations(t){var r,o;return(o=(r=Kr.getState(t))==null?void 0:r.mergedDecorationSet)!=null?o:Oe.empty}}})}applyChangedRangesRecompute(n,e,t,r,o){const i=n$(r,o.doc);return i.type==="full"?this.buildFullSet(n,e,o):this.rebuildRanges(n,e,t,r,o,i.ranges)}rebuildRanges(n,e,t,r,o,i){var l,a;const c=(l=t.decorationSetsByExtension[n])!=null?l:Oe.empty,d=new Set((a=t.widgetKeysByExtension[n])!=null?a:[]);let u=lg(c,r.mapping,r.doc,d);const f=o.doc.content.size;for(const{from:p,to:h}of i){const m=u.find(p,h).filter(w=>og({position:w.from,from:p,to:h,docSize:f}));for(const w of m){const v=sg(w);v&&d.delete(v)}u=u.remove(m);const g=ZV({decorations:this.runCreate(n,"createInRange",()=>e.createInRange({editor:this.editor,state:o,view:this.mountedView,from:p,to:h})),from:p,to:h,docSize:f,extensionName:n,warnedExtensions:this.warnedOutOfRangeExtensions}),{decorations:y,widgetKeys:b}=rg(g,n);u=u.add(o.doc,y);for(const w of b)d.add(w)}return{set:u,widgetKeys:d}}buildFullSet(n,e,t){const r=this.runCreate(n,"create",()=>e.create({editor:this.editor,state:t,view:this.mountedView}));return XV(t.doc,r,n)}runCreate(n,e,t){try{return t()}catch(r){return console.error(`[tiptap error]: Extension "${n}" threw in \`addDecorations().${e}()\`. Its decorations were dropped for this update.`,r),[]}}warnDuplicateWidgetKeys(n){if(!ng)return;if(n.widgetKeys.size===0){this.warnedWidgetKeys.clear();return}const e=QV(n.mergedDecorationSet),t=new Set(e.map(({key:r})=>r));for(const{key:r,extensions:o}of e){if(this.warnedWidgetKeys.has(r))continue;const i=Array.from(o).map(l=>`"${l}"`).join(", ");console.warn(`[tiptap warn]: Duplicate widget decoration key "${r}" in extension${o.size===1?"":"s"} ${i}. Widget decoration keys must be globally unique, otherwise ProseMirror misplaces the widget DOM. Use a stable, unique key (e.g. \`comment-\${id}\`).`)}this.warnedWidgetKeys=t}buildMergedSet(n,e){const t=Object.keys(e);return t.length===1?e[t[0]]:ag(n,e)}mergeAfterApply({entries:n,previous:e,tr:t,decorationSetsByExtension:r,recomputedNames:o}){return n.length===1?r[n[0].name]:o.size===0?e.mergedDecorationSet.map(t.mapping,t.doc):ag(t.doc,r)}};function dd(n,e){if(n===e)return!0;if(!n||!e)return!1;const t=Object.keys(n),r=Object.keys(e);return t.length!==r.length?!1:t.every(o=>Object.prototype.hasOwnProperty.call(e,o)&&Object.is(n[o],e[o]))}function pg(n,e){const{selection:t}=n,{$from:r}=t;if(t instanceof Ce){const i=r.index();return r.parent.canReplaceWith(i,i+1,e)}let o=r.depth;for(;o>=0;){const i=r.index(o);if(r.node(o).contentMatchAt(i).matchType(e))return!0;o-=1}return!1}function hg(n,e,t){const r=document.querySelector(`style[data-tiptap-style${t?`-${t}`:""}]`);if(r!==null)return r;const o=document.createElement("style");return e&&o.setAttribute("nonce",e),o.setAttribute(`data-tiptap-style${t?`-${t}`:""}`,""),o.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(o),o}function i$(n){return n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function qr(n,e){const t=n.getAttribute("style");if(!t)return null;const r=t.split(";").map(i=>i.trim()).filter(Boolean),o=e.toLowerCase();for(let i=r.length-1;i>=0;i-=1){const l=r[i],a=l.indexOf(":");if(a===-1)continue;if(l.slice(0,a).trim().toLowerCase()===o)return l.slice(a+1).trim()}return null}function l$(n){return n.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&amp;/g,"&")}function a$(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function c$(){return typeof navigator<"u"?/Firefox/.test(navigator.userAgent):!1}function mg(n){return typeof n=="number"}function d$(n){return Object.prototype.toString.call(n).slice(8,-1)}function Cs(n){return d$(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function u$(n){return typeof n=="string"}var gg={};Uc(gg,{createAtomBlockMarkdownSpec:()=>yg,createBlockMarkdownSpec:()=>bg,createInlineMarkdownSpec:()=>kg,parseAttributes:()=>tl,parseIndentedBlocks:()=>rl,renderNestedMarkdownContent:()=>ol,serializeAttributes:()=>nl});function tl(n){if(!n?.trim())return{};const e={},t=[],r=n.replace(/["']([^"']*)["']/g,d=>(t.push(d),`__QUOTED_${t.length-1}__`)),o=r.match(/(?:^|\s)\.([\w-]+)/g);if(o){const d=o.map(u=>u.trim().slice(1));e.class=d.join(" ")}const i=r.match(/(?:^|\s)#([\w-]+)/);i&&(e.id=i[1]);const l=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(l)).forEach(([,d,u])=>{var f;const p=parseInt(((f=u.match(/__QUOTED_(\d+)__/))==null?void 0:f[1])||"0",10),h=t[p];h&&(e[d]=h.slice(1,-1))});const c=r.replace(/(?:^|\s)\.([\w-]+)/g,"").replace(/(?:^|\s)#([\w-]+)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return c&&c.split(/\s+/).filter(Boolean).forEach(u=>{u.match(/^[a-zA-Z][\w-]*$/)&&(e[u]=!0)}),e}function nl(n){if(!n||Object.keys(n).length===0)return"";const e=[];return n.class&&String(n.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),n.id&&e.push(`#${n.id}`),Object.entries(n).forEach(([t,r])=>{t==="class"||t==="id"||(r===!0?e.push(t):r!==!1&&r!=null&&e.push(`${t}="${String(r)}"`))}),e.join(" ")}function yg(n){const{nodeName:e,name:t,parseAttributes:r=tl,serializeAttributes:o=nl,defaultAttributes:i={},requiredAttributes:l=[],allowedAttributes:a}=n,c=t||e,d=u=>{if(!a)return u;const f={};return a.forEach(p=>{p in u&&(f[p]=u[p])}),f};return{parseMarkdown:(u,f)=>{const p={...i,...u.attributes};return f.createNode(e,p,[])},markdownTokenizer:{name:e,level:"block",start(u){var f;const p=new RegExp(`^:::${c}(?:\\s|$)`,"m"),h=(f=u.match(p))==null?void 0:f.index;return h!==void 0?h:-1},tokenize(u,f,p){const h=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),m=u.match(h);if(!m)return;const g=m[1]||"",y=r(g);if(!l.find(w=>!(w in y)))return{type:e,raw:m[0],attributes:y}}},renderMarkdown:u=>{const f=d(u.attrs||{}),p=o(f),h=p?` {${p}}`:"";return`:::${c}${h} :::`}}}function bg(n){const{nodeName:e,name:t,getContent:r,parseAttributes:o=tl,serializeAttributes:i=nl,defaultAttributes:l={},content:a="block",allowedAttributes:c}=n,d=t||e,u=f=>{if(!c)return f;const p={};return c.forEach(h=>{h in f&&(p[h]=f[h])}),p};return{parseMarkdown:(f,p)=>{let h;if(r){const g=r(f);h=typeof g=="string"?[{type:"text",text:g}]:g}else a==="block"?h=p.parseChildren(f.tokens||[]):h=p.parseInline(f.tokens||[]);const m={...l,...f.attributes};return p.createNode(e,m,h)},markdownTokenizer:{name:e,level:"block",start(f){var p;const h=new RegExp(`^:::${d}`,"m"),m=(p=f.match(h))==null?void 0:p.index;return m!==void 0?m:-1},tokenize(f,p,h){var m;const g=new RegExp(`^:::${d}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),y=f.match(g);if(!y)return;const[b,w=""]=y,v=o(w);let E=1;const N=b.length;let R="";const T=/^:::([\w-]*)(\s.*)?/gm,M=f.slice(N);for(T.lastIndex=0;;){const _=T.exec(M);if(_===null)break;const A=_.index,L=_[1];if(!((m=_[2])!=null&&m.endsWith(":::"))){if(L)E+=1;else if(E-=1,E===0){const z=M.slice(0,A);R=z.trim();const Z=f.slice(0,N+A+_[0].length);let D=[];if(R)if(a==="block")for(D=h.blockTokens(z),D.forEach(P=>{P.text&&(!P.tokens||P.tokens.length===0)&&(P.tokens=h.inlineTokens(P.text))});D.length>0;){const P=D[D.length-1];if(P.type==="paragraph"&&(!P.text||P.text.trim()===""))D.pop();else break}else D=h.inlineTokens(R);return{type:e,raw:Z,attributes:v,content:R,tokens:D}}}}}},renderMarkdown:(f,p)=>{const h=u(f.attrs||{}),m=i(h),g=m?` {${m}}`:"",y=p.renderChildren(f.content||[],`
65
+
66
+ `);return`:::${d}${g}
67
+
68
+ ${y}
69
+
70
+ :::`}}}function f$(n){if(!n.trim())return{};const e={},t=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=t.exec(n);for(;r!==null;){const[,o,i,l]=r;e[o]=i||l,r=t.exec(n)}return e}function p$(n){return Object.entries(n).filter(([,e])=>e!=null).map(([e,t])=>`${e}="${t}"`).join(" ")}function kg(n){const{nodeName:e,name:t,getContent:r,parseAttributes:o=f$,serializeAttributes:i=p$,defaultAttributes:l={},selfClosing:a=!1,allowedAttributes:c}=n,d=t||e,u=p=>{if(!c)return p;const h={};return c.forEach(m=>{const g=typeof m=="string"?m:m.name,y=typeof m=="string"?void 0:m.skipIfDefault;if(g in p){const b=p[g];if(y!==void 0&&b===y)return;h[g]=b}}),h},f=d.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(p,h)=>{const m={...l,...p.attributes};if(a)return h.createNode(e,m);const g=r?r(p):p.content||"";return g?h.createNode(e,m,[h.createTextNode(g)]):h.createNode(e,m,[])},markdownTokenizer:{name:e,level:"inline",start(p){const h=a?new RegExp(`\\[${f}\\s*[^\\]]*\\]`):new RegExp(`\\[${f}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${f}\\]`),m=p.match(h),g=m?.index;return g!==void 0?g:-1},tokenize(p,h,m){const g=a?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),y=p.match(g);if(!y)return;let b="",w="";if(a){const[,E]=y;w=E}else{const[,E,N]=y;w=E,b=N||""}const v=o(w.trim());return{type:e,raw:y[0],content:b.trim(),attributes:v}}},renderMarkdown:p=>{let h="";r?h=r(p):p.content&&p.content.length>0&&(h=p.content.filter(b=>b.type==="text").map(b=>b.text).join(""));const m=u(p.attrs||{}),g=i(m),y=g?` ${g}`:"";return a?`[${d}${y}]`:`[${d}${y}]${h}[/${d}]`}}}function rl(n,e,t){var r,o,i,l;const a=n.split(`
71
+ `),c=[];let d="",u=0;const f=e.baseIndentSize||2;for(;u<a.length;){const p=a[u],h=p.match(e.itemPattern);if(!h){if(c.length>0)break;if(p.trim()===""){u+=1,d=`${d}${p}
72
+ `;continue}else return}const m=e.extractItemData(h),{indentLevel:g,mainContent:y}=m;d=`${d}${p}
73
+ `;const b=[y];for(u+=1;u<a.length;){const N=a[u];if(N.trim()===""){const T=a.slice(u+1).findIndex(A=>A.trim()!=="");if(T===-1)break;if((((o=(r=a[u+1+T].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:o.length)||0)>g){b.push(N),d=`${d}${N}
74
+ `,u+=1;continue}else break}if((((l=(i=N.match(/^(\s*)/))==null?void 0:i[1])==null?void 0:l.length)||0)>g)b.push(N),d=`${d}${N}
75
+ `,u+=1;else break}let w;const v=b.slice(1);if(v.length>0){const N=v.map(R=>R.slice(g+f)).join(`
76
+ `);N.trim()&&(e.customNestedParser?w=e.customNestedParser(N):w=t.blockTokens(N))}const E=e.createToken(m,w);c.push(E)}if(c.length!==0)return{items:c,raw:d}}function ol(n,e,t,r){if(!n||!Array.isArray(n.content))return"";const o=typeof t=="function"?t(r):t,[i,...l]=n.content,a=e.renderChildren([i]);let c=`${o}${a}`;return l&&l.length>0&&l.forEach((d,u)=>{var f,p;const h=(p=(f=e.renderChild)==null?void 0:f.call(e,d,u+1))!=null?p:e.renderChildren([d]);if(h!=null){const m=h.split(`
77
+ `).map(g=>g?e.indent(g):e.indent("")).join(`
78
+ `);c+=d.type==="paragraph"?`
79
+
80
+ ${m}`:`
81
+ ${m}`}}),c}function wg(n){return typeof n.type=="string"?n.type:n.type.name}function h$(n,e){if(n.length!==e.length)return!1;const t=Array.from({length:e.length},()=>!1);return n.every(r=>{const o=wg(r),i=e.findIndex((l,a)=>!t[a]&&o===wg(l)&&dd(r.attrs,l.attrs));return i===-1?!1:(t[i]=!0,!0)})}function ud(n,e){const t={...n};return Cs(n)&&Cs(e)&&Object.keys(e).forEach(r=>{Cs(e[r])&&Cs(n[r])?t[r]=ud(n[r],e[r]):t[r]=e[r]}),t}function fd(n,e,t={}){const{state:r}=e,{doc:o,tr:i}=r,l=n;o.descendants((a,c)=>{const d=i.mapping.map(c),u=i.mapping.map(c)+a.nodeSize;let f=null;if(a.marks.forEach(h=>{if(h!==l)return!1;f=h}),!f)return;let p=!1;if(Object.keys(t).forEach(h=>{t[h]!==f.attrs[h]&&(p=!0)}),p){const h=n.type.create({...n.attrs,...t});i.removeMark(d,u,n.type),i.addMark(d,u,h)}}),i.docChanged&&e.view.dispatch(i)}var m$=class{constructor(n,e,t){this.component=n,this.editor=e.editor,this.options={...t},this.mark=e.mark,this.HTMLAttributes=e.HTMLAttributes}get dom(){return this.editor.view.dom}get contentDOM(){return null}updateAttributes(n,e){fd(e||this.mark,this.editor,n)}ignoreMutation(n){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:n}):n.type==="selection"||this.dom.contains(n.target)&&n.type==="childList"&&(zr()||ys())&&this.editor.isFocused&&[...Array.from(n.addedNodes),...Array.from(n.removedNodes)].every(t=>t.isContentEditable)?!1:this.contentDOM===n.target&&n.type==="attributes"?!0:!this.contentDOM.contains(n.target)}},Gr=class{constructor(n){var e;this.find=n.find,this.handler=n.handler,this.undoable=(e=n.undoable)!=null?e:!0}},g$=(n,e)=>{if(ji(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function sl(n){var e;const{editor:t,from:r,to:o,text:i,rules:l,plugin:a}=n,{view:c}=t;if(c.composing)return!1;const d=c.state.doc.resolve(r);if(d.parent.type.spec.code||(e=d.nodeBefore||d.nodeAfter)!=null&&e.marks.find(p=>p.type.spec.code))return!1;let u=!1;const f=Km(d)+i;return l.forEach(p=>{if(u)return;const h=g$(f,p.find);if(!h)return;const m=h[0].length-i.length;if(m>0){const R=d.parentOffset-m;if(R<0||d.parent.textBetween(R,d.parentOffset)!==h[0].slice(0,m))return}const g=c.state.tr,y=hs({state:c.state,transaction:g}),b={from:r-(h[0].length-i.length),to:o},{commands:w,chain:v,can:E}=new ms({editor:t,state:y});p.handler({state:y,range:b,match:h,commands:w,chain:v,can:E})===null||!g.steps.length||(p.undoable&&g.setMeta(a,{transform:g,from:r,to:o,text:i}),c.dispatch(g),u=!0)}),u}function xg(n){const{editor:e,rules:t}=n,r=new Ke({state:{init(){return null},apply(o,i,l){const a=o.getMeta(r);if(a)return a;const c=o.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:u}=c;typeof u=="string"?u=u:u=ws(ee.from(u),l.schema);const{from:f}=c,p=f+u.length;sl({editor:e,from:f,to:p,text:u,rules:t,plugin:r})}),o.selectionSet||o.docChanged?null:i}},props:{handleTextInput(o,i,l,a){return sl({editor:e,from:i,to:l,text:a,rules:t,plugin:r})},handleDOMEvents:{compositionend:o=>(setTimeout(()=>{const{$cursor:i}=o.state.selection;i&&sl({editor:e,from:i.pos,to:i.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(o,i){if(i.key!=="Enter")return!1;const{$cursor:l}=o.state.selection;return l?sl({editor:e,from:l.pos,to:l.pos,text:`
82
+ `,rules:t,plugin:r}):!1}},isInputRules:!0});return r}var il=class{constructor(n={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...n},this.name=this.config.name}get options(){return{...Re(ke(this,"addOptions",{name:this.name}))}}get storage(){return{...Re(ke(this,"addStorage",{name:this.name,options:this.options}))}}configure(n={}){const e=this.extend({...this.config,addOptions:()=>ud(this.options,n)});return e.name=this.name,e.parent=this.parent,this.child=null,e}extend(n={}){const e=new this.constructor({...this.config,...n});return e.parent=this,this.child=e,e.name="name"in n?n.name:e.parent.name,e}},Zt=class nb extends il{constructor(){super(...arguments),this.type="mark"}static create(e={}){const t=typeof e=="function"?e():e;return new nb(t)}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,o=e.state.selection.$from;if(o.pos===o.end()){const l=o.marks();if(!!!l.find(d=>d?.type.name===t.name))return!1;const c=l.find(d=>d?.type.name===t.name);return c&&r.removeStoredMark(c),r.insertText(" ",o.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},Ss=class{constructor(n){this.find=n.find,this.handler=n.handler}},y$=(n,e,t)=>{if(ji(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(o=>{const i=[o.text];return i.index=o.index,i.input=n,i.data=o.data,o.replaceWith&&(o.text.includes(o.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(o.replaceWith)),i}):[]};function b$(n){const{editor:e,state:t,from:r,to:o,rule:i,pasteEvent:l,dropEvent:a}=n,{commands:c,chain:d,can:u}=new ms({editor:e,state:t}),f=[];return t.doc.nodesBetween(r,o,(h,m)=>{var g,y,b,w,v;if((y=(g=h.type)==null?void 0:g.spec)!=null&&y.code||!(h.isText||h.isTextblock||h.isInline))return;const E=(v=(w=(b=h.content)==null?void 0:b.size)!=null?w:h.nodeSize)!=null?v:0,N=Math.max(r,m),R=Math.min(o,m+E);if(N>=R)return;const T=h.isText?h.text||"":h.textBetween(N-m,R-m,void 0,"");y$(T,i.find,l).forEach(_=>{if(_.index===void 0)return;const A=N+_.index+1,L=A+_[0].length,z={from:t.tr.mapping.map(A),to:t.tr.mapping.map(L)},Z=i.handler({state:t,range:z,match:_,commands:c,chain:d,can:u,pasteEvent:l,dropEvent:a});f.push(Z)})}),f.every(h=>h!==null)}var ll=null,k$=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)==null||e.setData("text/html",n),t};function vg(n){const{editor:e,rules:t}=n;let r=null,o=!1,i=!1,l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}const c=({state:u,from:f,to:p,rule:h,pasteEvt:m})=>{const g=u.tr,y=hs({state:u,transaction:g});if(!(!b$({editor:e,state:y,from:Math.max(f-1,0),to:p.b-1,rule:h,pasteEvent:m,dropEvent:a})||!g.steps.length)){try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}return l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g}};return t.map(u=>new Ke({view(f){const p=m=>{var g;r=(g=f.dom.parentElement)!=null&&g.contains(m.target)?f.dom.parentElement:null,r&&(ll=e)},h=()=>{ll&&(ll=null)};return window.addEventListener("dragstart",p),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",p),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(f,p)=>{if(i=r===f.dom.parentElement,a=p,!i){const h=ll;h?.isEditable&&setTimeout(()=>{const m=h.state.selection;m&&h.commands.deleteRange({from:m.from,to:m.to})},10)}return!1},paste:(f,p)=>{var h;const m=(h=p.clipboardData)==null?void 0:h.getData("text/html");return l=p,o=!!m?.includes("data-pm-slice"),!1}}},appendTransaction:(f,p,h)=>{const m=f[0],g=m.getMeta("uiEvent")==="paste"&&!o,y=m.getMeta("uiEvent")==="drop"&&!i,b=m.getMeta("applyPasteRules"),w=!!b;if(!g&&!y&&!w)return;if(w){let{text:N}=b;typeof N=="string"?N=N:N=ws(ee.from(N),h.schema);const{from:R}=b,T=R+N.length,M=k$(N);return c({rule:u,state:h,from:R,to:{b:T},pasteEvt:M})}const v=p.doc.content.findDiffStart(h.doc.content),E=p.doc.content.findDiffEnd(h.doc.content);if(!(!mg(v)||!E||v===E.b))return c({rule:u,state:h,from:v,to:E,pasteEvt:l})}}))}var al=class{constructor(n,e){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=e,this.baseExtensions=n,this.extensions=Ji(n),this.schema=td(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((n,e)=>{const t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Wr(e.name,this.schema)},r=ke(e,"addCommands",t);return r?{...n,...r()}:n},{})}get plugins(){const{editor:n}=this,t=xo([...this.extensions].reverse()).flatMap(o=>{const i={name:o.name,options:o.options,storage:this.editor.extensionStorage[o.name],editor:n,type:Wr(o.name,this.schema)},l=[],a=ke(o,"addKeyboardShortcuts",i);let c={};if(o.type==="mark"&&ke(o,"exitable",i)&&(c.ArrowRight=()=>Zt.handleExit({editor:n,mark:o})),a){const h=Object.fromEntries(Object.entries(a()).map(([m,g])=>[m,()=>g({editor:n})]));c={...c,...h}}const d=vD(c);l.push(d);const u=ke(o,"addInputRules",i);if(sd(o,n.options.enableInputRules)&&u){const h=u();if(h&&h.length){const m=xg({editor:n,rules:h}),g=Array.isArray(m)?m:[m];l.push(...g)}}const f=ke(o,"addPasteRules",i);if(sd(o,n.options.enablePasteRules)&&f){const h=f();if(h&&h.length){const m=vg({editor:n,rules:h});l.push(...m)}}const p=ke(o,"addProseMirrorPlugins",i);if(p){const h=p();l.push(...h)}return l}),r=this.createDecorationPlugin();return r&&t.push(r),t}createDecorationPlugin(){var n;const{editor:e}=this;(n=this.decorationManager)==null||n.destroy();const t=[];return this.extensions.forEach(r=>{const o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:Wr(r.name,this.schema)},i=ke(r,"addDecorations",o);i&&t.push({name:r.name,addDecorations:i})}),this.decorationManager=new fg({editor:e,entries:t}),this.decorationManager.plugin}get attributes(){return Qc(this.extensions)}get nodeViews(){const{editor:n}=this,{nodeExtensions:e}=jr(this.extensions);return Object.fromEntries(e.filter(t=>!!ke(t,"addNodeView")).map(t=>{const r=this.attributes.filter(c=>c.type===t.name),o={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:at(t.name,this.schema)},i=ke(t,"addNodeView",o);if(!i)return[];const l=i();if(!l)return[];const a=(c,d,u,f,p)=>{const h=Ur(c,r);return l({node:c,view:d,getPos:u,decorations:f,innerDecorations:p,editor:n,extension:t,HTMLAttributes:h})};return[t.name,a]}))}dispatchTransaction(n){const{editor:e}=this;return xo([...this.extensions].reverse()).reduceRight((r,o)=>{const i={name:o.name,options:o.options,storage:this.editor.extensionStorage[o.name],editor:e,type:Wr(o.name,this.schema)},l=ke(o,"dispatchTransaction",i);return l?a=>{l.call(i,{transaction:a,next:r})}:r},n)}transformPastedHTML(n){const{editor:e}=this;return xo([...this.extensions]).reduce((r,o)=>{const i={name:o.name,options:o.options,storage:this.editor.extensionStorage[o.name],editor:e,type:Wr(o.name,this.schema)},l=ke(o,"transformPastedHTML",i);return l?(a,c)=>{const d=r(a,c);return l.call(i,d)}:r},n||(r=>r))}get markViews(){const{editor:n}=this,{markExtensions:e}=jr(this.extensions);return Object.fromEntries(e.filter(t=>!!ke(t,"addMarkView")).map(t=>{const r=this.attributes.filter(a=>a.type===t.name),o={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:yn(t.name,this.schema)},i=ke(t,"addMarkView",o);if(!i)return[];const l=(a,c,d)=>{const u=Ur(a,r);return i()({mark:a,view:c,inline:d,editor:n,extension:t,HTMLAttributes:u,updateAttributes:f=>{fd(a,n,f)}})};return[t.name,l]}))}destroy(){var n;(n=this.decorationManager)==null||n.destroy(),this.extensions.forEach(e=>{let t=e;for(;t.parent;){const r=t.parent;r.child===t&&(r.child=null),t=r}}),this.extensions=[],this.baseExtensions=[],this.decorationManager=null,this.schema=null,this.editor=null}setupExtensions(){const n=this.extensions;this.editor.extensionStorage=Object.fromEntries(n.map(e=>[e.name,e.storage])),n.forEach(e=>{var t,r;const o={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Wr(e.name,this.schema)};e.type==="mark"&&(((t=Re(ke(e,"keepOnSplit",o)))==null||t)&&this.splittableMarks.push(e.name),(r=Re(ke(e,"clearable",o)))==null||r||this.nonClearableMarks.push(e.name));const i=ke(e,"onBeforeCreate",o),l=ke(e,"onCreate",o),a=ke(e,"onUpdate",o),c=ke(e,"onSelectionUpdate",o),d=ke(e,"onTransaction",o),u=ke(e,"onFocus",o),f=ke(e,"onBlur",o),p=ke(e,"onDestroy",o);i&&this.editor.on("beforeCreate",i),l&&this.editor.on("create",l),a&&this.editor.on("update",a),c&&this.editor.on("selectionUpdate",c),d&&this.editor.on("transaction",d),u&&this.editor.on("focus",u),f&&this.editor.on("blur",f),p&&this.editor.on("destroy",p)})}};al.resolve=Ji,al.sort=xo,al.flatten=Gi;var Cg={};Uc(Cg,{ClipboardTextSerializer:()=>Sg,Commands:()=>Eg,Delete:()=>Mg,Drop:()=>Ag,Editable:()=>_g,FocusEvents:()=>Bg,Keymap:()=>Ng,Paste:()=>Dg,Tabindex:()=>Vg,TextDirection:()=>$g,focusEventsPluginKey:()=>Tg});var He=class rb extends il{constructor(){super(...arguments),this.type="extension"}static create(e={}){const t=typeof e=="function"?e():e;return new rb(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},Sg=He.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Ke({key:new Qe("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:o}=e,i=Xi(t),{blockSeparator:l}=this.options,a={...l!==void 0?{blockSeparator:l}:{},textSerializers:i};return[...o.ranges].sort((d,u)=>d.$from.pos-u.$from.pos).map(({$from:d,$to:u})=>nd(r,{from:d.pos,to:u.pos},a)).join(l??`
83
+
84
+ `)}}})]}}),Eg=He.create({name:"commands",addCommands(){return{...Wc}}}),Mg=He.create({name:"delete",onUpdate({transaction:n,appendedTransactions:e}){var t,r,o;const i=()=>{var l,a,c,d;if((d=(c=(a=(l=this.editor.options.coreExtensionOptions)==null?void 0:l.delete)==null?void 0:a.filterTransaction)==null?void 0:c.call(a,n))!=null?d:n.getMeta("y-sync$"))return;const u=Xc(n.before,[n,...e]);xs(u).forEach(h=>{u.mapping.mapResult(h.oldRange.from).deletedAfter&&u.mapping.mapResult(h.oldRange.to).deletedBefore&&u.before.nodesBetween(h.oldRange.from,h.oldRange.to,(m,g)=>{const y=g+m.nodeSize-2,b=h.oldRange.from<=g&&y<=h.oldRange.to;this.editor.emit("delete",{type:"node",node:m,from:g,to:y,newFrom:u.mapping.map(g),newTo:u.mapping.map(y),deletedRange:h.oldRange,newRange:h.newRange,partial:!b,editor:this.editor,transaction:n,combinedTransform:u})})});const p=u.mapping;u.steps.forEach((h,m)=>{var g,y;if(h instanceof an){const b=p.slice(m).map(h.from,-1),w=p.slice(m).map(h.to),v=p.invert().map(b,-1),E=p.invert().map(w),N=b>0?(g=u.doc.nodeAt(b-1))==null?void 0:g.marks.some(T=>T.eq(h.mark)):!1,R=(y=u.doc.nodeAt(w))==null?void 0:y.marks.some(T=>T.eq(h.mark));this.editor.emit("delete",{type:"mark",mark:h.mark,from:h.from,to:h.to,deletedRange:{from:v,to:E},newRange:{from:b,to:w},partial:!!(R||N),editor:this.editor,transaction:n,combinedTransform:u})}})};(o=(r=(t=this.editor.options.coreExtensionOptions)==null?void 0:t.delete)==null?void 0:r.async)==null||o?setTimeout(i,0):i()}}),Ag=He.create({name:"drop",addProseMirrorPlugins(){return[new Ke({key:new Qe("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),_g=He.create({name:"editable",addProseMirrorPlugins(){return[new Ke({key:new Qe("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Tg=new Qe("focusEvents"),Bg=He.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new Ke({key:Tg,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Ng=He.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:l})=>[()=>l.undoInputRule(),()=>l.command(({tr:a})=>{const{selection:c,doc:d}=a,{empty:u,$anchor:f}=c,{pos:p,parent:h}=f,m=f.parent.isTextblock&&p>0?a.doc.resolve(p-1):f,g=m.parent.type.spec.isolating,y=f.pos-f.parentOffset,b=g&&m.parent.childCount===1?y===f.pos:Ae.atStart(d).from===p;return!u||!h.type.isTextblock||h.textContent.length||!b||b&&f.parent.type.name==="paragraph"?!1:l.clearNodes()}),()=>l.deleteSelection(),()=>l.joinBackward(),()=>l.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:l})=>[()=>l.deleteSelection(),()=>l.deleteCurrentNode(),()=>l.joinForward(),()=>l.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:l})=>[()=>l.newlineInCode(),()=>l.createParagraphNear(),()=>l.liftEmptyBlock(),()=>l.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},o={...r},i={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return zr()||Gc()?i:o},addProseMirrorPlugins(){return[new Ke({key:new Qe("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(g=>g.getMeta("composition")))return;const r=n.some(g=>g.docChanged)&&!e.doc.eq(t.doc),o=n.some(g=>g.getMeta("preventClearDocument"));if(!r||o)return;const{empty:i,from:l,to:a}=e.selection,c=Ae.atStart(e.doc).from,d=Ae.atEnd(e.doc).to;if(i||!(l===c&&a===d)||!vo(t.doc))return;const p=t.tr,h=hs({state:t,transaction:p}),{commands:m}=new ms({editor:this.editor,state:h});if(m.clearNodes(),!!p.steps.length)return p}})]}}),Dg=He.create({name:"paste",addProseMirrorPlugins(){return[new Ke({key:new Qe("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),Vg=He.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new Ke({key:new Qe("tabindex"),props:{attributes:()=>{var n;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(n=this.options.value)!=null?n:"0"}}}})]}}),$g=He.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:n}=jr(this.extensions);return[{types:n.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const t=e.getAttribute("dir");return t&&(t==="ltr"||t==="rtl"||t==="auto")?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new Ke({key:new Qe("textDirection"),props:{attributes:()=>{const n=this.options.direction;return n?{dir:n}:{}}}})]}}),Lg=!1;function w$(n){if(Lg)return;Lg=!0;let e;try{e=lt.fromJSON(n,{from:0,to:0}).slice.content}catch{return}e instanceof ee||console.warn("[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.")}var Ig=class js{constructor(e,t,r=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=o}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new js(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new js(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new js(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,r)=>{const o=t.isBlock&&!t.isTextblock,i=t.isAtom&&!t.isText,l=t.isInline,a=this.pos+r+(i?0:1);if(a<0||a>this.resolvedPos.doc.nodeSize-2)return;const c=this.resolvedPos.doc.resolve(a);if(!o&&!l&&c.depth<=this.depth)return;const d=new js(c,this.editor,o,o||l?t:null);o&&(d.actualDepth=this.depth+1),e.push(d)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,o=this.parent;for(;o&&!r;){if(o.node.type.name===e)if(Object.keys(t).length>0){const i=o.node.attrs,l=Object.keys(t);for(let a=0;a<l.length;a+=1){const c=l[a];if(i[c]!==t[c])break}}else r=o;o=o.parent}return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let o=[];if(!this.children||this.children.length===0)return o;const i=Object.keys(t);return this.children.forEach(l=>{r&&o.length>0||(l.node.type.name===e&&i.every(c=>t[c]===l.node.attrs[c])&&o.push(l),!(r&&o.length>0)&&(o=o.concat(l.querySelectorAll(e,t,r))))}),o}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},x$=`.ProseMirror {
85
+ position: relative;
86
+ }
87
+
88
+ .ProseMirror {
89
+ word-wrap: break-word;
90
+ white-space: pre-wrap;
91
+ white-space: break-spaces;
92
+ -webkit-font-variant-ligatures: none;
93
+ font-variant-ligatures: none;
94
+ font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
95
+ }
96
+
97
+ .ProseMirror [contenteditable="false"] {
98
+ white-space: normal;
99
+ }
100
+
101
+ .ProseMirror [contenteditable="false"] [contenteditable="true"] {
102
+ white-space: pre-wrap;
103
+ }
104
+
105
+ .ProseMirror pre {
106
+ white-space: pre-wrap;
107
+ }
108
+
109
+ img.ProseMirror-separator {
110
+ display: inline !important;
111
+ border: none !important;
112
+ margin: 0 !important;
113
+ width: 0 !important;
114
+ height: 0 !important;
115
+ }
116
+
117
+ .ProseMirror-gapcursor {
118
+ display: none;
119
+ pointer-events: none;
120
+ position: absolute;
121
+ margin: 0;
122
+ }
123
+
124
+ .ProseMirror-gapcursor:after {
125
+ content: "";
126
+ display: block;
127
+ position: absolute;
128
+ top: -2px;
129
+ width: 20px;
130
+ border-top: 1px solid black;
131
+ animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
132
+ }
133
+
134
+ @keyframes ProseMirror-cursor-blink {
135
+ to {
136
+ visibility: hidden;
137
+ }
138
+ }
139
+
140
+ .ProseMirror-hideselection *::selection {
141
+ background: transparent;
142
+ }
143
+
144
+ .ProseMirror-hideselection *::-moz-selection {
145
+ background: transparent;
146
+ }
147
+
148
+ .ProseMirror-hideselection * {
149
+ caret-color: transparent;
150
+ }
151
+
152
+ .ProseMirror-focused .ProseMirror-gapcursor {
153
+ display: block;
154
+ }`,v$=class extends JV{constructor(n={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.hasWarnedStaleDecorationRead=!1,this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:Ym,createMappablePosition:Xm},this.setOptions(n),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:t,slice:r,moved:o})=>this.options.onDrop(t,r,o)),this.on("paste",({event:t,slice:r})=>this.options.onPaste(t,r)),this.on("delete",this.options.onDelete);const e=this.createDoc();if(!this.editorState){const t=Ki(e,this.options.autofocus);this.editorState=$r.create({doc:e,schema:this.schema,selection:t||void 0})}w$(this.schema),this.options.element&&this.mount(this.options.element)}mount(n){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(n),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){this.editorState=this.editorView.state;const n=this.editorView.dom;n?.editor&&delete n.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(n){console.warn("Failed to remove CSS element:",n)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=hg(x$,this.options.injectNonce))}setOptions(n={}){this.options={...this.options,...n},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(n,e=!0){this.setOptions({editable:n}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:n=>{this.editorState=n},dispatch:n=>{this.dispatchTransaction(n)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(n,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in n)return Reflect.get(n,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return ng&&!this.hasWarnedStaleDecorationRead&&GV(this)&&(this.hasWarnedStaleDecorationRead=!0,console.warn("[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.")),this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(n,e){const t=Zc(e)?e(n,[...this.state.plugins]):[...this.state.plugins,n],r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}unregisterPlugin(n){if(this.isDestroyed)return;const e=this.state.plugins;let t=e;if([].concat(n).forEach(o=>{const i=typeof o=="string"?`${o}$`:o.key;t=t.filter(l=>!l.key.startsWith(i))}),e.length===t.length)return;const r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}createExtensionManager(){var n,e,t,r;const i=[...this.options.enableCoreExtensions?[_g,Sg.configure({blockSeparator:(e=(n=this.options.coreExtensionOptions)==null?void 0:n.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Eg,Bg,Ng,Vg.configure({value:(r=(t=this.options.coreExtensionOptions)==null?void 0:t.tabindex)==null?void 0:r.value}),Ag,Dg,Mg,$g.configure({direction:this.options.textDirection})].filter(l=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[l.name]!==!1:!0):[],...this.options.extensions].filter(l=>["extension","node","mark"].includes(l?.type));this.extensionManager=new al(i,this)}createCommandManager(){this.commandManager=new ms({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let n;try{n=qi(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;const t=qi(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=$r.create({doc:t,schema:this.schema,selection:Ki(t,this.options.autofocus)||void 0}),this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(r=>r.name!=="collaboration"),this.createExtensionManager()}}),this.editorState.doc}return n}createView(n){const{editorProps:e,enableExtensionDispatchTransaction:t}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),o=t?this.extensionManager.dispatchTransaction(r):r,i=e.transformPastedHTML,l=this.extensionManager.transformPastedHTML(i);this.editorView=new xm(n,{...e,attributes:{role:"textbox",...e?.attributes},dispatchTransaction:o,transformPastedHTML:l,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const a=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(a),this.prependClass(),this.injectCSS();const c=this.view.dom;c.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(n){this.isCapturingTransaction=!0,n(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(n){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=n;return}n.steps.forEach(d=>{var u;return(u=this.capturedTransaction)==null?void 0:u.step(d)});return}const{state:e,transactions:t}=this.state.applyTransaction(n),r=!this.state.selection.eq(e.selection),o=t.includes(n),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:n,nextState:e}),!o)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:n,appendedTransactions:t.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:n});const l=t.findLast(d=>d.getMeta("focus")||d.getMeta("blur")),a=l?.getMeta("focus"),c=l?.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:l}),c&&this.emit("blur",{editor:this,event:c.event,transaction:l}),!(n.getMeta("preventUpdate")||!t.some(d=>d.docChanged)||i.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:n,appendedTransactions:t.slice(1)})}getAttributes(n){return od(this.state,n)}isActive(n,e){const t=typeof n=="string"?n:null,r=typeof n=="string"?e:n;return qm(this.state,t,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return ws(this.state.doc.content,this.schema)}getText(n){const{blockSeparator:e=`
155
+
156
+ `,textSerializers:t={}}=n||{};return rd(this.state.doc,{blockSeparator:e,textSerializers:{...Xi(this.schema),...t}})}get isEmpty(){return vo(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var n,e;return(e=(n=this.editorView)==null?void 0:n.isDestroyed)!=null?e:!0}$node(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelector(n,e))||null}$nodes(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelectorAll(n,e))||null}$pos(n){const e=this.state.doc.resolve(n),t=n>0&&e.nodeAfter&&!e.nodeAfter.isText&&e.nodeAfter.isAtom?e.nodeAfter:null;return new Ig(e,this,!1,t)}get $doc(){return this.$pos(0)}},Es=class{static Inline(n,e,t={},r){return new Og(n,e,t,r)}static Node(n,e,t={},r){return new Rg(n,e,t,r)}static Widget(n,e,t){const{key:r,...o}=t;return new Fg(n,e,r,o)}},Og=class extends Es{constructor(n,e,t={},r){super(),this.kind="inline",this.from=n,this.to=e,this.attrs=t,this.spec=r}get anchor(){return this.from}toPMDecoration(n){const e=n?{...this.spec,extensionName:n}:this.spec;return Tt.inline(this.from,this.to,this.attrs,e)}},Rg=class extends Es{constructor(n,e,t={},r){super(),this.kind="node",this.from=n,this.to=e,this.attrs=t,this.spec=r}get anchor(){return this.from}toPMDecoration(n){const e=n?{...this.spec,extensionName:n}:this.spec;return Tt.node(this.from,this.to,this.attrs,e)}},Fg=class extends Es{constructor(n,e,t,r){super(),this.kind="widget",this.pos=n,this.render=e,this.key=t,this.spec=r}get anchor(){return this.pos}toPMDecoration(n){const e=n?{...this.spec,key:this.key,extensionName:n}:{...this.spec,key:this.key};return Tt.widget(this.pos,this.render,e)}};function C$(n,e){const t=n;let r=t[e];if(!r){r={renderers:new Map,props:new Map,pendingProps:new Map,flushScheduled:!1},t[e]=r;const o=r;n.on("destroy",()=>{o.pendingProps.clear(),o.renderers.forEach(i=>i.destroy()),o.renderers.clear(),o.props.clear()})}return r}function S$(n){n.flushScheduled=!1;for(const[e,t]of n.pendingProps){const r=n.renderers.get(e);r&&(r.updateProps(t),n.props.set(e,{...t}))}n.pendingProps.clear()}function E$(n){var e;const{editor:t,pos:r,key:o,props:i,cacheKey:l,context:a,create:c,materialize:d,side:u,relaxedSide:f,marks:p,stopEvent:h,ignoreSelection:m,destroy:g}=n,y=C$(t,l);if(y.renderers.has(o)){const w=(e=y.pendingProps.get(o))!=null?e:y.props.get(o);(!w||!dd(w,i))&&(y.pendingProps.set(o,i),y.flushScheduled||(y.flushScheduled=!0,queueMicrotask(()=>S$(y))))}const b=(w,v)=>{const E={...i,...a(v)};let N=y.renderers.get(o);return N?N.updateProps(E):(N=c(E),y.renderers.set(o,N),y.props.set(o,{...i})),d(N)};return Es.Widget(r,b,{key:o,side:u,relaxedSide:f,marks:p,stopEvent:h,ignoreSelection:m,destroy:w=>{var v;if(!ug(t).has(o))try{(v=y.renderers.get(o))==null||v.destroy(),y.renderers.delete(o),y.props.delete(o),y.pendingProps.delete(o)}finally{g?.(w)}}})}function Hn(n){return new Gr({find:n.find,handler:({state:e,range:t,match:r})=>{const o=Re(n.getAttributes,void 0,r);if(o===!1||o===null)return null;const{tr:i}=e,l=r[r.length-1],a=r[0];if(l){const c=a.search(/\S/),d=t.from+a.indexOf(l),u=d+l.length;if(Zi(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===n.type&&g!==h.mark.type)).filter(h=>h.to>d).length)return null;u<t.to&&i.delete(u,t.to),d>t.from&&i.delete(t.from+c,d);const p=t.from+c+l.length;i.addMark(t.from+c,p,n.type.create(o||{})),i.removeStoredMark(n.type)}},undoable:n.undoable})}function pd(n){return new Gr({find:n.find,handler:({state:e,range:t,match:r})=>{const o=Re(n.getAttributes,void 0,r)||{},{tr:i}=e,l=t.from;let a=t.to;const c=n.type.create(o);if(r[1]){const d=r[0].lastIndexOf(r[1]);let u=l+d;u>a?u=a:a=u+r[1].length;const f=r[0][r[0].length-1];i.insertText(f,l+r[0].length-1),i.replaceWith(u,a,c)}else if(r[0]){const d=n.type.isInline?l:l-1;i.insert(d,n.type.create(o)).delete(i.mapping.map(l),i.mapping.map(a))}i.scrollIntoView()},undoable:n.undoable})}function cl(n){return new Gr({find:n.find,handler:({state:e,range:t,match:r})=>{const o=e.doc.resolve(t.from),i=Re(n.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,i)},undoable:n.undoable})}function M$(n){return new Gr({find:n.find,handler:({state:e,range:t,match:r})=>{let o=n.replace,i=t.from;const l=t.to;if(r[1]){const a=r[0].lastIndexOf(r[1]);o+=r[0].slice(a+r[1].length),i+=a;const c=i-l;c>0&&(o=r[0].slice(a-c,a)+o,i=l)}e.tr.insertText(o,i,l)},undoable:n.undoable})}function Jr(n){return new Gr({find:n.find,handler:({state:e,range:t,match:r,chain:o})=>{const i=Re(n.getAttributes,void 0,r)||{},l=e.tr.delete(t.from,t.to),c=l.doc.resolve(t.from).blockRange(),d=c&&oc(c,n.type,i);if(!d)return null;if(l.wrap(c,d),n.keepMarks&&n.editor){const{selection:f,storedMarks:p}=e,{splittableMarks:h}=n.editor.extensionManager,m=p||f.$to.parentOffset&&f.$from.marks();if(m){const g=m.filter(y=>h.includes(y.type.name));l.ensureMarks(g)}}if(n.keepAttributes){const f=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";o().updateAttributes(f,i).run()}const u=l.doc.resolve(t.from-1).nodeBefore;u&&u.type===n.type&&lr(l.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&l.join(t.from-1)},undoable:n.undoable})}function A$(n){return n.children}var Pg=(n,e)=>{if(n==="slot")return 0;if(n instanceof Function)return n(e);const{children:t,...r}=e??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[n,r,t]},_$=n=>"touches"in n,hd=class{constructor(n){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=a=>{if(!this.isResizing||!this.activeHandle)return;const c=a.clientX-this.startX,d=a.clientY-this.startY;this.handleResize(c,d)},this.handleTouchMove=a=>{if(!this.isResizing||!this.activeHandle)return;const c=a.touches[0];if(!c)return;const d=c.clientX-this.startX,u=c.clientY-this.startY;this.handleResize(d,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;const a=this.element.offsetWidth,c=this.element.offsetHeight;this.onCommit(a,c),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=a=>{a.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=a=>{a.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,t,r,o,i,l;this.node=n.node,this.editor=n.editor,this.element=n.element,this.element.draggable=!1,this.contentElement=n.contentElement,this.getPos=n.getPos,this.onResize=n.onResize,this.onCommit=n.onCommit,this.onUpdate=n.onUpdate,(e=n.options)!=null&&e.min&&(this.minSize={...this.minSize,...n.options.min}),(t=n.options)!=null&&t.max&&(this.maxSize=n.options.max),(r=n?.options)!=null&&r.directions&&(this.directions=n.options.directions),(o=n.options)!=null&&o.preserveAspectRatio&&(this.preserveAspectRatio=n.options.preserveAspectRatio),(i=n.options)!=null&&i.className&&(this.classNames={container:n.options.className.container||"",wrapper:n.options.className.wrapper||"",handle:n.options.className.handle||"",resizing:n.options.className.resizing||""}),(l=n.options)!=null&&l.createCustomHandle&&(this.createCustomHandle=n.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var n;return(n=this.contentElement)!=null?n:null}handleEditorUpdate(){const n=this.editor.isEditable;n!==this.lastEditableState&&(this.lastEditableState=n,n?n&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(n,e,t){return n.type!==this.node.type?!1:(this.node=n,this.onUpdate?this.onUpdate(n,e,t):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const n=document.createElement("div");return n.dataset.resizeContainer="",n.dataset.node=this.node.type.name,n.style.display=this.node.type.isInline?"inline-flex":"flex",this.classNames.container&&(n.className=this.classNames.container),n.appendChild(this.wrapper),n}createWrapper(){const n=document.createElement("div");return n.style.position="relative",n.style.display="block",n.dataset.resizeWrapper="",this.classNames.wrapper&&(n.className=this.classNames.wrapper),n.appendChild(this.element),n}createHandle(n){const e=document.createElement("div");return e.dataset.resizeHandle=n,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(n,e){const t=e.includes("top"),r=e.includes("bottom"),o=e.includes("left"),i=e.includes("right");t&&(n.style.top="0"),r&&(n.style.bottom="0"),o&&(n.style.left="0"),i&&(n.style.right="0"),(e==="top"||e==="bottom")&&(n.style.left="0",n.style.right="0"),(e==="left"||e==="right")&&(n.style.top="0",n.style.bottom="0")}attachHandles(){this.directions.forEach(n=>{let e;this.createCustomHandle?e=this.createCustomHandle(n):e=this.createHandle(n),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${n}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(n)),this.createCustomHandle||this.positionHandle(e,n),e.addEventListener("mousedown",t=>this.handleResizeStart(t,n)),e.addEventListener("touchstart",t=>this.handleResizeStart(t,n)),this.handleMap.set(n,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(n=>n.remove()),this.handleMap.clear()}applyInitialSize(){const n=this.node.attrs.width,e=this.node.attrs.height;n?(this.element.style.width=`${n}px`,this.initialWidth=n):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(n,e){n.preventDefault(),n.stopPropagation(),this.isResizing=!0,this.activeHandle=e,_$(n)?(this.startX=n.touches[0].clientX,this.startY=n.touches[0].clientY):(this.startX=n.clientX,this.startY=n.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(n,e){if(!this.activeHandle)return;const t=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:o}=this.calculateNewDimensions(this.activeHandle,n,e),i=this.applyConstraints(r,o,t);this.element.style.width=`${i.width}px`,this.element.style.height=`${i.height}px`,this.onResize&&this.onResize(i.width,i.height)}calculateNewDimensions(n,e,t){let r=this.startWidth,o=this.startHeight;const i=n.includes("right"),l=n.includes("left"),a=n.includes("bottom"),c=n.includes("top");return i?r=this.startWidth+e:l&&(r=this.startWidth-e),a?o=this.startHeight+t:c&&(o=this.startHeight-t),(n==="right"||n==="left")&&(r=this.startWidth+(i?e:-e)),(n==="top"||n==="bottom")&&(o=this.startHeight+(a?t:-t)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,o,n):{width:r,height:o}}applyConstraints(n,e,t){var r,o,i,l;if(!t){let d=Math.max(this.minSize.width,n),u=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(d=Math.min(this.maxSize.width,d)),(o=this.maxSize)!=null&&o.height&&(u=Math.min(this.maxSize.height,u)),{width:d,height:u}}let a=n,c=e;return a<this.minSize.width&&(a=this.minSize.width,c=a/this.aspectRatio),c<this.minSize.height&&(c=this.minSize.height,a=c*this.aspectRatio),(i=this.maxSize)!=null&&i.width&&a>this.maxSize.width&&(a=this.maxSize.width,c=a/this.aspectRatio),(l=this.maxSize)!=null&&l.height&&c>this.maxSize.height&&(c=this.maxSize.height,a=c*this.aspectRatio),{width:a,height:c}}applyAspectRatio(n,e,t){const r=t==="left"||t==="right",o=t==="top"||t==="bottom";return r?{width:n,height:n/this.aspectRatio}:o?{width:e*this.aspectRatio,height:e}:{width:n,height:n/this.aspectRatio}}},T$=hd,ft=class ob extends il{constructor(){super(...arguments),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new ob(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},B$=class{constructor(n,e,t){this.isDragging=!1,this.component=n,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...t},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=()=>{try{return e.getPos()}catch{return}},this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(n){var e,t,r,o,i,l,a;const{view:c}=this.editor,d=n.target,u=d.nodeType===3?(e=d.parentElement)==null?void 0:e.closest("[data-drag-handle]"):d.closest("[data-drag-handle]");if(!this.dom||(t=this.contentDOM)!=null&&t.contains(d)||!u)return;let f=0,p=0;if(this.dom!==u){const w=this.dom.getBoundingClientRect(),v=u.getBoundingClientRect(),E=(o=n.offsetX)!=null?o:(r=n.nativeEvent)==null?void 0:r.offsetX,N=(l=n.offsetY)!=null?l:(i=n.nativeEvent)==null?void 0:i.offsetY;f=v.x-w.x+E,p=v.y-w.y+N}const h=this.dom.cloneNode(!0);try{const w=this.dom.getBoundingClientRect();h.style.width=`${Math.round(w.width)}px`,h.style.height=`${Math.round(w.height)}px`,h.style.boxSizing="border-box",h.style.pointerEvents="none"}catch{}let m=null;try{m=document.createElement("div"),m.style.position="absolute",m.style.top="-9999px",m.style.left="-9999px",m.style.pointerEvents="none",m.appendChild(h),document.body.appendChild(m),(a=n.dataTransfer)==null||a.setDragImage(h,f,p)}finally{m&&setTimeout(()=>{try{m?.remove()}catch{}},0)}const g=this.getPos();if(typeof g!="number")return;const y=Ce.create(c.state.doc,g),b=c.state.tr.setSelection(y);c.dispatch(b)}stopEvent(n){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:n});const t=n.target;if(!(this.dom.contains(t)&&!((e=this.contentDOM)!=null&&e.contains(t))))return!1;const o=n.type.startsWith("drag"),i=n.type==="dragover"||n.type==="dragenter",l=n.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(t.tagName)||t.isContentEditable)&&!l&&!o)return!0;const{isEditable:c}=this.editor,{isDragging:d}=this,u=!!this.node.type.spec.draggable,f=Ce.isSelectable(this.node),p=n.type==="copy",h=n.type==="paste",m=n.type==="cut",g=n.type==="mousedown";if(!u&&f&&o&&n.target===this.dom&&n.preventDefault(),u&&o&&!d&&n.target===this.dom)return n.preventDefault(),!1;if(u&&c&&!d&&g){const y=t.closest("[data-drag-handle]");y&&(this.dom===y||this.dom.contains(y))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(d||i||l||p||h||m||g&&f)}ignoreMutation(n){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:n}):this.node.isLeaf||this.node.isAtom?!0:n.type==="selection"||this.dom.contains(n.target)&&n.type==="childList"&&(zr()||ys())&&this.editor.isFocused&&[...Array.from(n.addedNodes),...Array.from(n.removedNodes)].every(t=>t.isContentEditable)?!1:this.contentDOM===n.target&&n.type==="attributes"?!0:!this.contentDOM.contains(n.target)}updateAttributes(n){this.editor.commands.command(({tr:e})=>{const t=this.getPos();return typeof t!="number"?!1:(e.setNodeMarkup(t,void 0,{...this.node.attrs,...n}),!0)})}deleteNode(){const n=this.getPos();if(typeof n!="number")return;const e=n+this.node.nodeSize;this.editor.commands.deleteRange({from:n,to:e})}};function wn(n){return new Ss({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:o})=>{const i=Re(n.getAttributes,void 0,r,o);if(i===!1||i===null)return null;const{tr:l}=e,a=r[r.length-1],c=r[0];let d=t.to;if(a){const u=c.search(/\S/),f=t.from+c.indexOf(a),p=f+a.length;if(Zi(t.from,t.to,e.doc).filter(g=>g.mark.type.excluded.find(b=>b===n.type&&b!==g.mark.type)).filter(g=>g.to>f).length)return null;p<t.to&&l.delete(p,t.to),f>t.from&&l.delete(t.from+u,f),d=t.from+u+a.length,l.addMark(t.from+u,d,n.type.create(i||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||l.removeStoredMark(n.type)}}})}function N$(n){return new Ss({find:n.find,handler({match:e,chain:t,range:r,pasteEvent:o}){const i=Re(n.getAttributes,void 0,e,o),l=Re(n.getContent,void 0,i);if(i===!1||i===null)return null;const a={type:n.type.name,attrs:i};l&&(a.content=l),e.input&&t().deleteRange(r).insertContentAt(r.from,a)}})}function D$(n){return new Ss({find:n.find,handler:({state:e,range:t,match:r})=>{let o=n.replace,i=t.from;const l=t.to;if(r[1]){const a=r[0].lastIndexOf(r[1]);o+=r[0].slice(a+r[1].length),i+=a;const c=i-l;c>0&&(o=r[0].slice(a-c,a)+o,i=l)}e.tr.insertText(o,i,l)}})}var V$=class{constructor(n){this.transaction=n,this.currentStep=this.transaction.steps.length}map(n){let e=!1;return{position:this.transaction.steps.slice(this.currentStep).reduce((r,o)=>{const i=o.getMap().mapResult(r);return i.deleted&&(e=!0),i.pos},n),deleted:e}}};const $$=Object.freeze(Object.defineProperty({__proto__:null,CommandManager:ms,DECORATION_MANAGER_PLUGIN_KEY:Kr,Decoration:Es,DecorationManager:fg,Editor:v$,Extendable:il,Extension:He,Fragment:A$,InlineDecoration:Og,InputRule:Gr,MappablePosition:ld,Mark:Zt,MarkView:m$,Node:ft,NodeDecoration:Rg,NodePos:Ig,NodeView:B$,PasteRule:Ss,ResizableNodeView:hd,ResizableNodeview:T$,Tracker:V$,WidgetDecoration:Fg,attrsEqual:dd,callOrReturn:Re,canInsertNode:pg,combineTransactionSteps:Xc,commands:Wc,createAtomBlockMarkdownSpec:yg,createBlockMarkdownSpec:bg,createChainableState:hs,createDocument:qi,createElement:Pg,createInlineMarkdownSpec:kg,createMappablePosition:Xm,createNodeFromContent:Hr,createStyleTag:hg,createWidgetDecoration:E$,decodeHtmlEntities:l$,defaultBlockAt:qc,deleteProps:Jc,elementFromString:ko,encodeHtmlEntities:a$,escapeForRegEx:i$,extensions:Cg,findChildren:hV,findChildrenInRange:$m,findDuplicates:Pm,findParentNode:ks,findParentNodeClosestToPos:wo,flattenExtensions:Gi,fromString:Om,generateHTML:gV,generateJSON:yV,generateText:bV,getAttributes:od,getAttributesFromExtensions:Qc,getChangedRanges:xs,getDebugJSON:jm,getExtensionField:ke,getHTMLFromFragment:ws,getMarkAttributes:Yc,getMarkRange:Ui,getMarkType:yn,getMarksBetween:Zi,getNodeAtPosition:Um,getNodeAttributes:zm,getNodeType:at,getPreviousBlockSibling:Wm,getRenderedAttributes:Ur,getSchema:Yi,getSchemaByResolvedExtensions:td,getSchemaTypeByName:Wr,getSchemaTypeNameByName:bs,getSplittedAttributes:vs,getStyleProperty:qr,getText:rd,getTextBetween:nd,getTextContentFromNodes:Km,getTextSerializersFromSchema:Xi,getUpdatedPosition:Ym,h:Pg,injectExtensionAttributesToParseRule:ed,inputRulesPlugin:xg,isActive:qm,isAndroid:ys,isAtEndOfNode:Gm,isAtStartOfNode:Jm,isEmptyObject:Lm,isExtensionRulesEnabled:sd,isFirefox:c$,isFunction:Zc,isList:el,isMacOS:Gc,isMarkActive:Qi,isNodeActive:kn,isNodeEmpty:vo,isNodeSelection:id,isNodeViewSelected:wV,isNumber:mg,isPlainObject:Cs,isRegExp:ji,isSafari:Bm,isString:u$,isTextSelection:Wi,isiOS:zr,liveWidgetKeys:ug,markInputRule:Hn,markPasteRule:wn,markdown:gg,marksEqual:h$,mergeAttributes:ze,mergeDeep:ud,minMax:bn,nodeInputRule:pd,nodePasteRule:N$,objectIncludes:gs,parseAttributes:tl,parseIndentedBlocks:rl,pasteRulesPlugin:vg,posToDOMRect:xV,removeDuplicates:Hm,renderNestedMarkdownContent:ol,resolveExtensions:Ji,resolveFocusPosition:Ki,rewriteUnknownContent:vV,selectionToInsertionEnd:Kc,serializeAttributes:nl,sortExtensions:xo,splitExtensions:jr,textInputRule:M$,textPasteRule:D$,textblockTypeInputRule:cl,updateMarkViewAttributes:fd,wrappingInputRule:Jr},Symbol.toStringTag,{value:"Module"}));var dl=(n,e)=>{if(n==="slot")return 0;if(n instanceof Function)return n(e);const{children:t,...r}=e??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[n,r,t]},L$=(n,e)=>{var t;const{state:r}=n,{selection:o}=r;if(!o.empty)return!1;const{$from:i}=o;if(i.parentOffset!==0)return!1;const l=i.depth-1;if(l<0)return!1;const a=i.node(l),c=i.index(l);if(c===0)return!1;if(a.type===e)return n.commands.lift(e.name);const d=a.child(c-1);if(d.type!==e||!((t=d.lastChild)!=null&&t.isTextblock))return!1;const p=i.before()-1-1;return n.commands.command(({tr:h,dispatch:m})=>{if(!m)return!0;const g=i.parent.content,y=new fe(g,0,0);return h.replace(p,i.after(),y),h.setSelection(be.create(h.doc,p+g.size)),h.scrollIntoView(),m(h),!0})},I$=/^\s*>\s$/,O$=ft.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return dl("blockquote",{...ze(this.options.HTMLAttributes,n),children:dl("slot",{})})},parseMarkdown:(n,e)=>{var t;const r=(t=e.parseBlockChildren)!=null?t:e.parseChildren;return e.createNode("blockquote",void 0,r(n.tokens||[]))},renderMarkdown:(n,e)=>{if(!n.content)return"";const t=">",r=[];return n.content.forEach((o,i)=>{var l,a;const u=((a=(l=e.renderChild)==null?void 0:l.call(e,o,i))!=null?a:e.renderChildren([o])).split(`
157
+ `).map(f=>f.trim()===""?t:`${t} ${f}`);r.push(u.join(`
158
+ `))}),r.join(`
159
+ ${t}
160
+ `)},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>L$(this.editor,this.type)}},addInputRules(){return[Jr({find:I$,type:this.type})]}}),R$=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,F$=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,P$=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,z$=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,H$=Zt.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return dl("strong",{...ze(this.options.HTMLAttributes,n),children:dl("slot",{})})},markdownTokenName:"strong",parseMarkdown:(n,e)=>e.applyMark("bold",e.parseInline(n.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(n,e)=>`**${e.renderChildren(n)}**`,addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Hn({find:R$,type:this.type}),Hn({find:P$,type:this.type})]},addPasteRules(){return[wn({find:F$,type:this.type}),wn({find:z$,type:this.type})]}}),j$=n=>{const e=/`([^`]+)`(?!`)$/.exec(n);return!e||e.index>0&&n[e.index-1]==="`"?null:{index:e.index,text:e[0],replaceWith:e[1]}},U$=n=>{const e=/`([^`]+)`(?!`)/g,t=[];let r;for(;(r=e.exec(n))!==null;)r.index>0&&n[r.index-1]==="`"||t.push({index:r.index,text:r[0],replaceWith:r[1]});return t},W$=Zt.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",ze(this.options.HTMLAttributes,n),0]},markdownTokenName:"codespan",parseMarkdown:(n,e)=>e.applyMark("code",[{type:"text",text:n.text||""}]),renderMarkdown:(n,e)=>n.content?`\`${e.renderChildren(n.content)}\``:"",addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Hn({find:j$,type:this.type})]},addPasteRules(){return[wn({find:U$,type:this.type})]}}),md=4,K$=/^```([a-z]+)?[\s\n]$/,q$=/^~~~([a-z]+)?[\s\n]$/,G$=ft.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:md,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options;if(!t)return null;const i=[...((e=n.firstElementChild)==null?void 0:e.classList)||[]].filter(l=>l.startsWith(t)).map(l=>l.replace(t,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",ze(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(n,e)=>{var t,r;return((t=n.raw)==null?void 0:t.startsWith("```"))===!1&&((r=n.raw)==null?void 0:r.startsWith("~~~"))===!1&&n.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:n.lang||null},n.text?[e.createTextNode(n.text)]:[])},renderMarkdown:(n,e)=>{var t;let r="";const o=((t=n.attrs)==null?void 0:t.language)||"";return n.content?r=[`\`\`\`${o}`,e.renderChildren(n.content),"```"].join(`
161
+ `):r=`\`\`\`${o}
162
+
163
+ \`\`\``,r},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:n})=>{var e;if(!this.options.enableTabIndentation)return!1;const t=(e=this.options.tabSize)!=null?e:md,{state:r}=n,{selection:o}=r,{$from:i,empty:l}=o;if(i.parent.type!==this.type)return!1;const a=" ".repeat(t);return l?n.commands.insertContent(a):n.commands.command(({tr:c})=>{const{from:d,to:u}=o,h=r.doc.textBetween(d,u,`
164
+ `,`
165
+ `).split(`
166
+ `).map(m=>a+m).join(`
167
+ `);return c.replaceWith(d,u,r.schema.text(h)),!0})},"Shift-Tab":({editor:n})=>{var e;if(!this.options.enableTabIndentation)return!1;const t=(e=this.options.tabSize)!=null?e:md,{state:r}=n,{selection:o}=r,{$from:i,empty:l}=o;return i.parent.type!==this.type?!1:l?n.commands.command(({tr:a})=>{var c;const{pos:d}=i,u=i.start(),f=i.end(),h=r.doc.textBetween(u,f,`
168
+ `,`
169
+ `).split(`
170
+ `);let m=0,g=0;const y=d-u;for(let R=0;R<h.length;R+=1){if(g+h[R].length>=y){m=R;break}g+=h[R].length+1}const w=((c=h[m].match(/^ */))==null?void 0:c[0])||"",v=Math.min(w.length,t);if(v===0)return!0;let E=u;for(let R=0;R<m;R+=1)E+=h[R].length+1;return a.delete(E,E+v),d-E<=v&&a.setSelection(be.create(a.doc,E)),!0}):n.commands.command(({tr:a})=>{const{from:c,to:d}=o,p=r.doc.textBetween(c,d,`
171
+ `,`
172
+ `).split(`
173
+ `).map(h=>{var m;const g=((m=h.match(/^ */))==null?void 0:m[0])||"",y=Math.min(g.length,t);return h.slice(y)}).join(`
174
+ `);return a.replaceWith(c,d,r.schema.text(p)),!0})},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:o}=t;if(!o||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,l=r.parent.textContent.endsWith(`
175
+
176
+ `);return!i||!l?!1:n.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:n})=>{if(!this.options.exitOnArrowUp)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:o}=t;if(!o||r.parent.type!==this.type||r.parentOffset!==0)return!1;const i=r.before();return i>0?!1:n.commands.insertDefaultBlock({pos:i})},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:o,empty:i}=t;if(!i||o.parent.type!==this.type||!(o.parentOffset===o.parent.nodeSize-2))return!1;const a=o.after();return a===void 0?!1:r.nodeAt(a)?n.commands.command(({tr:d})=>(d.setSelection(Ae.near(r.resolve(a))),!0)):n.commands.exitCode()}}},addInputRules(){return[cl({find:K$,type:this.type,getAttributes:n=>({language:n[1]})}),cl({find:q$,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new Ke({key:new Qe("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),o=r?JSON.parse(r):void 0,i=o?.mode;if(!t||!i)return!1;const{tr:l,schema:a}=n.state,c=a.text(t.replace(/\r\n?/g,`
177
+ `));return l.replaceSelectionWith(this.type.create({language:i},c)),l.selection.$from.parent.type!==this.type&&l.setSelection(be.near(l.doc.resolve(Math.max(0,l.selection.from-2)))),l.setMeta("paste",!0),n.dispatch(l),!0}}})]}}),J$=ft.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
178
+
179
+ `):""}),Y$=ft.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",ze(this.options.HTMLAttributes,n)]},renderText(){return`
180
+ `},renderMarkdown:()=>`
181
+ `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:o,storedMarks:i}=t;if(o.$from.parent.type.spec.isolating)return!1;const{keepMarks:l}=this.options,{splittableMarks:a}=r.extensionManager,c=i||o.$to.parentOffset&&o.$from.marks();return e().insertContent({type:this.name}).command(({tr:d,dispatch:u})=>{if(u&&c&&l){const f=c.filter(p=>a.includes(p.type.name));d.ensureMarks(f)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),gd=ft.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,ze(this.options.HTMLAttributes,e),0]},parseMarkdown:(n,e)=>e.createNode("heading",{level:n.depth||1},e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>{var t;const r=(t=n.attrs)!=null&&t.level?parseInt(n.attrs.level,10):1,o="#".repeat(r);return n.content?`${o} ${e.renderChildren(n.content)}`:""},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>cl({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),X$=gd;const Z$=Object.freeze(Object.defineProperty({__proto__:null,Heading:gd,default:X$},Symbol.toStringTag,{value:"Module"}));var Q$=ft.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",ze(this.options.HTMLAttributes,n)]},markdownTokenName:"hr",parseMarkdown:(n,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!pg(e,e.schema.nodes[this.name]))return!1;const{selection:t}=e,{$to:r}=t,o=n();return id(t)?o.insertContentAt(r.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({state:i,tr:l,dispatch:a})=>{if(a){const{$to:c}=l.selection,d=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?l.setSelection(be.create(l.doc,c.pos+1)):c.nodeAfter.isBlock?l.setSelection(Ce.create(l.doc,c.pos)):l.setSelection(be.create(l.doc,c.pos));else{const u=i.schema.nodes[this.options.nextNodeType]||c.parent.type.contentMatch.defaultType,f=u?.create();f&&(l.insert(d,f),l.setSelection(be.create(l.doc,d+1)))}l.scrollIntoView()}return!0}).run()}}},addInputRules(){return[pd({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),eL=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,tL=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,nL=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,rL=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,oL=Zt.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(n,e)=>e.applyMark("italic",e.parseInline(n.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(n,e)=>`*${e.renderChildren(n)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Hn({find:eL,type:this.type}),Hn({find:nL,type:this.type})]},addPasteRules(){return[wn({find:tL,type:this.type}),wn({find:rL,type:this.type})]}});const sL="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",iL="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",yd="numeric",bd="ascii",kd="alpha",Ms="asciinumeric",As="alphanumeric",wd="domain",zg="emoji",lL="scheme",aL="slashscheme",xd="whitespace";function cL(n,e){return n in e||(e[n]=[]),e[n]}function Yr(n,e,t){e[yd]&&(e[Ms]=!0,e[As]=!0),e[bd]&&(e[Ms]=!0,e[kd]=!0),e[Ms]&&(e[As]=!0),e[kd]&&(e[As]=!0),e[As]&&(e[wd]=!0),e[zg]&&(e[wd]=!0);for(const r in e){const o=cL(r,t);o.indexOf(n)<0&&o.push(n)}}function dL(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function Rt(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}Rt.groups={},Rt.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let r=0;r<e.jr.length;r++){const o=e.jr[r][0],i=e.jr[r][1];if(i&&o.test(n))return i}return e.jd},has(n,e=!1){return e?n in this.j:!!this.go(n)},ta(n,e,t,r){for(let o=0;o<n.length;o++)this.tt(n[o],e,t,r)},tr(n,e,t,r){r=r||Rt.groups;let o;return e&&e.j?o=e:(o=new Rt(e),t&&r&&Yr(e,t,r)),this.jr.push([n,o]),o},ts(n,e,t,r){let o=this;const i=n.length;if(!i)return o;for(let l=0;l<i-1;l++)o=o.tt(n[l]);return o.tt(n[i-1],e,t,r)},tt(n,e,t,r){r=r||Rt.groups;const o=this;if(e&&e.j)return o.j[n]=e,e;const i=e;let l,a=o.go(n);if(a?(l=new Rt,Object.assign(l.j,a.j),l.jr.push.apply(l.jr,a.jr),l.jd=a.jd,l.t=a.t):l=new Rt,i){if(r)if(l.t&&typeof l.t=="string"){const c=Object.assign(dL(l.t,r),t);Yr(i,c,r)}else t&&Yr(i,t,r);l.t=i}return o.j[n]=l,l}};const $e=(n,e,t,r,o)=>n.ta(e,t,r,o),tt=(n,e,t,r,o)=>n.tr(e,t,r,o),Hg=(n,e,t,r,o)=>n.ts(e,t,r,o),ce=(n,e,t,r,o)=>n.tt(e,t,r,o),jn="WORD",vd="UWORD",jg="ASCIINUMERICAL",Ug="ALPHANUMERICAL",_s="LOCALHOST",Cd="TLD",Sd="UTLD",ul="SCHEME",So="SLASH_SCHEME",Ed="NUM",Md="WS",Ad="NL",Ts="OPENBRACE",Bs="CLOSEBRACE",fl="OPENBRACKET",pl="CLOSEBRACKET",hl="OPENPAREN",ml="CLOSEPAREN",gl="OPENANGLEBRACKET",yl="CLOSEANGLEBRACKET",bl="FULLWIDTHLEFTPAREN",kl="FULLWIDTHRIGHTPAREN",wl="LEFTCORNERBRACKET",xl="RIGHTCORNERBRACKET",vl="LEFTWHITECORNERBRACKET",Cl="RIGHTWHITECORNERBRACKET",Sl="FULLWIDTHLESSTHAN",El="FULLWIDTHGREATERTHAN",Ml="AMPERSAND",Al="APOSTROPHE",_l="ASTERISK",yr="AT",Tl="BACKSLASH",Bl="BACKTICK",Nl="CARET",Xr="COLON",_d="COMMA",Dl="DOLLAR",xn="DOT",Vl="EQUALS",Td="EXCLAMATION",Qt="HYPHEN",Ns="PERCENT",$l="PIPE",Ll="PLUS",Il="POUND",Ds="QUERY",Bd="QUOTE",Wg="FULLWIDTHMIDDLEDOT",Nd="SEMI",vn="SLASH",Vs="TILDE",Ol="UNDERSCORE",Kg="EMOJI",Rl="SYM";var qg=Object.freeze({__proto__:null,ALPHANUMERICAL:Ug,AMPERSAND:Ml,APOSTROPHE:Al,ASCIINUMERICAL:jg,ASTERISK:_l,AT:yr,BACKSLASH:Tl,BACKTICK:Bl,CARET:Nl,CLOSEANGLEBRACKET:yl,CLOSEBRACE:Bs,CLOSEBRACKET:pl,CLOSEPAREN:ml,COLON:Xr,COMMA:_d,DOLLAR:Dl,DOT:xn,EMOJI:Kg,EQUALS:Vl,EXCLAMATION:Td,FULLWIDTHGREATERTHAN:El,FULLWIDTHLEFTPAREN:bl,FULLWIDTHLESSTHAN:Sl,FULLWIDTHMIDDLEDOT:Wg,FULLWIDTHRIGHTPAREN:kl,HYPHEN:Qt,LEFTCORNERBRACKET:wl,LEFTWHITECORNERBRACKET:vl,LOCALHOST:_s,NL:Ad,NUM:Ed,OPENANGLEBRACKET:gl,OPENBRACE:Ts,OPENBRACKET:fl,OPENPAREN:hl,PERCENT:Ns,PIPE:$l,PLUS:Ll,POUND:Il,QUERY:Ds,QUOTE:Bd,RIGHTCORNERBRACKET:xl,RIGHTWHITECORNERBRACKET:Cl,SCHEME:ul,SEMI:Nd,SLASH:vn,SLASH_SCHEME:So,SYM:Rl,TILDE:Vs,TLD:Cd,UNDERSCORE:Ol,UTLD:Sd,UWORD:vd,WORD:jn,WS:Md});const Un=/[a-z]/,$s=new RegExp("\\p{L}","u"),Dd=new RegExp("\\p{Emoji}","u"),Wn=/\d/,Vd=/\s/,Gg="\r",$d=`
182
+ `,uL="️",fL="‍",Ld="";let Fl=null,Pl=null;function pL(n=[]){const e={};Rt.groups=e;const t=new Rt;Fl==null&&(Fl=Yg(sL)),Pl==null&&(Pl=Yg(iL)),ce(t,"'",Al),ce(t,"{",Ts),ce(t,"}",Bs),ce(t,"[",fl),ce(t,"]",pl),ce(t,"(",hl),ce(t,")",ml),ce(t,"<",gl),ce(t,">",yl),ce(t,"(",bl),ce(t,")",kl),ce(t,"「",wl),ce(t,"」",xl),ce(t,"『",vl),ce(t,"』",Cl),ce(t,"<",Sl),ce(t,">",El),ce(t,"&",Ml),ce(t,"*",_l),ce(t,"@",yr),ce(t,"`",Bl),ce(t,"^",Nl),ce(t,":",Xr),ce(t,",",_d),ce(t,"$",Dl),ce(t,".",xn),ce(t,"=",Vl),ce(t,"!",Td),ce(t,"-",Qt),ce(t,"%",Ns),ce(t,"|",$l),ce(t,"+",Ll),ce(t,"#",Il),ce(t,"?",Ds),ce(t,'"',Bd),ce(t,"/",vn),ce(t,";",Nd),ce(t,"~",Vs),ce(t,"_",Ol),ce(t,"\\",Tl),ce(t,"・",Wg);const r=tt(t,Wn,Ed,{[yd]:!0});tt(r,Wn,r);const o=tt(r,Un,jg,{[Ms]:!0}),i=tt(r,$s,Ug,{[As]:!0}),l=tt(t,Un,jn,{[bd]:!0});tt(l,Wn,o),tt(l,Un,l),tt(o,Wn,o),tt(o,Un,o);const a=tt(t,$s,vd,{[kd]:!0});tt(a,Un),tt(a,Wn,i),tt(a,$s,a),tt(i,Wn,i),tt(i,Un),tt(i,$s,i);const c=ce(t,$d,Ad,{[xd]:!0}),d=ce(t,Gg,Md,{[xd]:!0}),u=tt(t,Vd,Md,{[xd]:!0});ce(t,Ld,u),ce(d,$d,c),ce(d,Ld,u),tt(d,Vd,u),ce(u,Gg),ce(u,$d),tt(u,Vd,u),ce(u,Ld,u);const f=tt(t,Dd,Kg,{[zg]:!0});ce(f,"#"),tt(f,Dd,f),ce(f,uL,f);const p=ce(f,fL);ce(p,"#"),tt(p,Dd,f);const h=[[Un,l],[Wn,o]],m=[[Un,null],[$s,a],[Wn,i]];for(let g=0;g<Fl.length;g++)br(t,Fl[g],Cd,jn,h);for(let g=0;g<Pl.length;g++)br(t,Pl[g],Sd,vd,m);Yr(Cd,{tld:!0,ascii:!0},e),Yr(Sd,{utld:!0,alpha:!0},e),br(t,"file",ul,jn,h),br(t,"mailto",ul,jn,h),br(t,"http",So,jn,h),br(t,"https",So,jn,h),br(t,"ftp",So,jn,h),br(t,"ftps",So,jn,h),Yr(ul,{scheme:!0,ascii:!0},e),Yr(So,{slashscheme:!0,ascii:!0},e),n=n.sort((g,y)=>g[0]>y[0]?1:-1);for(let g=0;g<n.length;g++){const y=n[g][0],w=n[g][1]?{[lL]:!0}:{[aL]:!0};y.indexOf("-")>=0?w[wd]=!0:Un.test(y)?Wn.test(y)?w[Ms]=!0:w[bd]=!0:w[yd]=!0,Hg(t,y,y,w)}return Hg(t,"localhost",_s,{ascii:!0}),t.jd=new Rt(Rl),{start:t,tokens:Object.assign({groups:e},qg)}}function Jg(n,e){const t=hL(e.replace(/[A-Z]/g,a=>a.toLowerCase())),r=t.length,o=[];let i=0,l=0;for(;l<r;){let a=n,c=null,d=0,u=null,f=-1,p=-1;for(;l<r&&(c=a.go(t[l]));)a=c,a.accepts()?(f=0,p=0,u=a):f>=0&&(f+=t[l].length,p++),d+=t[l].length,i+=t[l].length,l++;i-=f,l-=p,d-=f,o.push({t:u.t,v:e.slice(i-d,i),s:i-d,e:i})}return o}function hL(n){const e=[],t=n.length;let r=0;for(;r<t;){let o=n.charCodeAt(r),i,l=o<55296||o>56319||r+1===t||(i=n.charCodeAt(r+1))<56320||i>57343?n[r]:n.slice(r,r+2);e.push(l),r+=l.length}return e}function br(n,e,t,r,o){let i;const l=e.length;for(let a=0;a<l-1;a++){const c=e[a];n.j[c]?i=n.j[c]:(i=new Rt(r),i.jr=o.slice(),n.j[c]=i),n=i}return i=new Rt(t),i.jr=o.slice(),n.j[e[l-1]]=i,i}function Yg(n){const e=[],t=[];let r=0,o="0123456789";for(;r<n.length;){let i=0;for(;o.indexOf(n[r+i])>=0;)i++;if(i>0){e.push(t.join(""));for(let l=parseInt(n.substring(r,r+i),10);l>0;l--)t.pop();r+=i}else t.push(n[r]),r++}return e}const Ls={defaultProtocol:"http",events:null,format:Xg,formatHref:Xg,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Id(n,e=null){let t=Object.assign({},Ls);n&&(t=Object.assign(t,n instanceof Id?n.o:n));const r=t.ignoreTags,o=[];for(let i=0;i<r.length;i++)o.push(r[i].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=o}Id.prototype={o:Ls,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const r=e!=null;let o=this.o[n];return o&&(typeof o=="object"?(o=t.t in o?o[t.t]:Ls[n],typeof o=="function"&&r&&(o=o(e,t))):typeof o=="function"&&r&&(o=o(e,t.t,t)),o)},getObj(n,e,t){let r=this.o[n];return typeof r=="function"&&e!=null&&(r=r(e,t.t,t)),r},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function Xg(n){return n}function Zg(n,e){this.t="token",this.v=n,this.tk=e}Zg.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),r=n.get("format",e,this);return t&&r.length>t?r.substring(0,t)+"…":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=Ls.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),o=n.get("tagName",t,e),i=this.toFormattedString(n),l={},a=n.get("className",t,e),c=n.get("target",t,e),d=n.get("rel",t,e),u=n.getObj("attributes",t,e),f=n.getObj("events",t,e);return l.href=r,a&&(l.class=a),c&&(l.target=c),d&&(l.rel=d),u&&Object.assign(l,u),{tagName:o,attributes:l,content:i,eventListeners:f}}};function zl(n,e){class t extends Zg{constructor(o,i){super(o,i),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const mL=zl("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Qg=zl("text"),gL=zl("nl"),Hl=zl("url",{isLink:!0,toHref(n=Ls.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==_s&&n[1].t===Xr}}),en=n=>new Rt(n);function yL({groups:n}){const e=n.domain.concat([Ml,_l,yr,Tl,Bl,Nl,Dl,Vl,Qt,Ed,Ns,$l,Ll,Il,vn,Rl,Vs,Ol]),t=[Al,Xr,_d,xn,Td,Ns,Ds,Bd,Nd,gl,yl,Ts,Bs,pl,fl,hl,ml,bl,kl,wl,xl,vl,Cl,Sl,El],r=[Ml,Al,_l,Tl,Bl,Nl,Dl,Vl,Qt,Ts,Bs,Ns,$l,Ll,Il,Ds,vn,Rl,Vs,Ol],o=en(),i=ce(o,Vs);$e(i,r,i),$e(i,n.domain,i);const l=en(),a=en(),c=en();$e(o,n.domain,l),$e(o,n.scheme,a),$e(o,n.slashscheme,c),$e(l,r,i),$e(l,n.domain,l);const d=ce(l,yr);ce(i,yr,d),ce(a,yr,d),ce(c,yr,d);const u=ce(i,xn);$e(u,r,i),$e(u,n.domain,i);const f=en();$e(d,n.domain,f),$e(f,n.domain,f);const p=ce(f,xn);$e(p,n.domain,f);const h=en(mL);$e(p,n.tld,h),$e(p,n.utld,h),ce(d,_s,h);const m=ce(f,Qt);ce(m,Qt,m),$e(m,n.domain,f),$e(h,n.domain,f),ce(h,xn,p),ce(h,Qt,m);const g=ce(l,Qt),y=ce(l,xn);ce(g,Qt,g),$e(g,n.domain,l),$e(y,r,i),$e(y,n.domain,l);const b=en(Hl);$e(y,n.tld,b),$e(y,n.utld,b),$e(b,n.domain,l),$e(b,r,i),ce(b,xn,y),ce(b,Qt,g),ce(b,yr,d);const w=ce(b,Xr),v=en(Hl);$e(w,n.numeric,v);const E=en(Hl),N=en();$e(E,e,E),$e(E,t,N),$e(N,e,E),$e(N,t,N),ce(b,vn,E),ce(v,vn,E);const R=ce(a,Xr),T=ce(c,Xr),M=ce(T,vn),_=ce(M,vn);$e(a,n.domain,l),ce(a,xn,y),ce(a,Qt,g),$e(c,n.domain,l),ce(c,xn,y),ce(c,Qt,g),$e(R,n.domain,E),ce(R,vn,E),ce(R,Ds,E),$e(_,n.domain,E),$e(_,e,E),ce(_,vn,E);const A=[[Ts,Bs],[fl,pl],[hl,ml],[gl,yl],[bl,kl],[wl,xl],[vl,Cl],[Sl,El]];for(let L=0;L<A.length;L++){const[z,Z]=A[L],D=ce(E,z);ce(N,z,D);const P=en(Hl);$e(D,e,P);const ne=en();$e(D,t,ne),ce(D,Z,E),$e(P,e,P),$e(P,t,ne),$e(ne,e,P),$e(ne,t,ne),ce(P,Z,E),ce(ne,Z,E)}return ce(o,_s,b),ce(o,Ad,gL),{start:o,tokens:qg}}function bL(n,e,t){let r=t.length,o=0,i=[],l=[];for(;o<r;){let a=n,c=null,d=null,u=0,f=null,p=-1;for(;o<r&&!(c=a.go(t[o].t));)l.push(t[o++]);for(;o<r&&(d=c||a.go(t[o].t));)c=null,a=d,a.accepts()?(p=0,f=a):p>=0&&p++,o++,u++;if(p<0)o-=u,o<r&&(l.push(t[o]),o++);else{l.length>0&&(i.push(Od(Qg,e,l)),l=[]),o-=p,u-=p;const h=f.t,m=t.slice(o-u,o);i.push(Od(h,e,m))}}return l.length>0&&i.push(Od(Qg,e,l)),i}function Od(n,e,t){const r=t[0].s,o=t[t.length-1].e,i=e.slice(r,o);return new n(i,t)}const kL=typeof console<"u"&&console&&console.warn||(()=>{}),wL="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Xe={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function xL(){return Rt.groups={},Xe.scanner=null,Xe.parser=null,Xe.tokenQueue=[],Xe.pluginQueue=[],Xe.customSchemes=[],Xe.initialized=!1,Xe}function ey(n,e=!1){if(Xe.initialized&&kL(`linkifyjs: already initialized - will not register custom scheme "${n}" ${wL}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
183
+ 1. Must only contain digits, lowercase ASCII letters or "-"
184
+ 2. Cannot start or end with "-"
185
+ 3. "-" cannot repeat`);Xe.customSchemes.push([n,e])}function vL(){Xe.scanner=pL(Xe.customSchemes);for(let n=0;n<Xe.tokenQueue.length;n++)Xe.tokenQueue[n][1]({scanner:Xe.scanner});Xe.parser=yL(Xe.scanner.tokens);for(let n=0;n<Xe.pluginQueue.length;n++)Xe.pluginQueue[n][1]({scanner:Xe.scanner,parser:Xe.parser});return Xe.initialized=!0,Xe}function Rd(n){return Xe.initialized||vL(),bL(Xe.parser.start,n,Jg(Xe.scanner.start,n))}Rd.scan=Jg;function ty(n,e=null,t=null){if(e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new Id(t),o=Rd(n),i=[];for(let l=0;l<o.length;l++){const a=o[l];a.isLink&&(!e||a.t===e)&&r.check(a)&&i.push(a.toFormattedObject(r))}return i}var Fd="[\0-   ᠎ -\u2029  ]",CL=new RegExp(Fd),SL=new RegExp(`${Fd}$`),EL=new RegExp(Fd,"g");function ML(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function AL(n){return new Ke({key:new Qe("autolink"),appendTransaction:(e,t,r)=>{const o=e.some(d=>d.docChanged)&&!t.doc.eq(r.doc),i=e.some(d=>d.getMeta("preventAutolink"));if(!o||i)return;const{tr:l}=r,a=Xc(t.doc,[...e]);if(xs(a).forEach(({newRange:d})=>{const u=$m(r.doc,d,h=>h.isTextblock);let f,p;if(u.length>1)f=u[0],p=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(u.length){const h=r.doc.textBetween(d.from,d.to," "," ");if(!SL.test(h))return;f=u[0],p=r.doc.textBetween(f.pos,d.to,void 0," ")}if(f&&p){const h=p.split(CL).filter(Boolean);if(h.length<=0)return!1;const m=h[h.length-1],g=f.pos+p.lastIndexOf(m);if(!m)return!1;const y=Rd(m).map(b=>b.toObject(n.defaultProtocol));if(!ML(y))return!1;y.filter(b=>b.isLink).map(b=>({...b,from:g+b.start+1,to:g+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>n.validate(b.value)).filter(b=>n.shouldAutoLink(b.value)).forEach(b=>{Zi(b.from,b.to,r.doc).some(w=>w.mark.type===n.type)||l.addMark(b.from,b.to,n.type.create({href:b.href}))})}}),!!l.steps.length)return l}})}function _L(n){return new Ke({key:new Qe("handleClickLink"),props:{handleClick:(e,t,r)=>{var o,i;if(r.button!==0||!e.editable)return!1;let l=null;if(r.target instanceof HTMLAnchorElement)l=r.target;else{const c=r.target;if(!c)return!1;const d=n.editor.view.dom;l=c.closest("a"),l&&!d.contains(l)&&(l=null)}if(!l)return!1;let a=!1;if(n.enableClickSelection&&(a=n.editor.commands.extendMarkRange(n.type.name)),n.openOnClick){const c=od(e.state,n.type.name),d=(o=l.href)!=null?o:c.href,u=(i=l.target)!=null?i:c.target;d&&(window.open(d,u),a=!0)}return a}}})}var TL=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,BL=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function ny(n,e){let t=0;for(let r=e-1;r>=0&&n[r]==="\\";r-=1)t+=1;return t%2===1}function NL(n,e){let t=0,r=0;for(;r<e;){if(n[r]!=="`"){r+=1;continue}if(t===0&&ny(n,r)){r+=1;continue}let o=0;for(;r<e&&n[r]==="`";)o+=1,r+=1;t===0?t=o:o===t&&(t=0)}return t>0}function ry(n,e,t){var r,o;const[,i,l]=e;return(e.index?n[e.index-1]:void 0)==="!"||ny(n,(r=e.index)!=null?r:0)||NL(n,(o=e.index)!=null?o:0)?!1:!!i.trim()&&t(l)}function oy(n){var e,t;const[r,o,i,,l,a,c]=n,d=(e=l??a)!=null?e:c;return{index:(t=n.index)!=null?t:0,text:r,replaceWith:o,data:{href:i,title:d||null,markdown:!0}}}function DL(n,e){return n.index<e.index+e.text.length&&e.index<n.index+n.text.length}function sy(n){var e,t,r;return{href:(e=n.data)==null?void 0:e.href,title:(r=(t=n.data)==null?void 0:t.title)!=null?r:null}}function VL(n){const e=Hn({find:t=>{const r=TL.exec(t);return!r||!ry(t,r,n.isAllowedHref)?null:oy(r)},type:n.type,getAttributes:sy});return new Gr({find:e.find,handler:t=>{const r=e.handler(t);return r!==null&&t.state.tr.steps.length&&t.state.tr.setMeta("preventAutolink",!0),r}})}function $L(n){const e=wn({find:t=>{var r,o;const i=[];for(const a of t.matchAll(BL))ry(t,a,n.isAllowedHref)&&i.push(oy(a));const l=((o=(r=n.findPlainUrls)==null?void 0:r.call(n,t))!=null?o:[]).filter(a=>!i.some(c=>DL(c,a)));return[...i,...l]},type:n.type,getAttributes:sy});return new Ss({find:e.find,handler:t=>{var r;const o=e.handler(t);return o!==null&&t.state.tr.steps.length&&((r=t.match.data)!=null&&r.markdown)&&t.state.tr.setMeta("preventAutolink",!0),o}})}function LL(n){return new Ke({key:new Qe("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{shouldAutoLink:o}=n,{state:i}=e,{selection:l}=i,{empty:a}=l;if(a)return!1;let c="";r.content.forEach(u=>{c+=u.textContent});const d=ty(c,{defaultProtocol:n.defaultProtocol}).find(u=>u.isLink&&u.value===c);return!c||!d||o!==void 0&&!o(d.value)?!1:n.editor.commands.setMark(n.type,{href:d.href})}}})}var IL=/https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z]{2,}\b(?:[-a-zA-Z0-9@:%._+~#=?!&/]*)(?:[-a-zA-Z0-9@:%._+~#=?!&/]*)/gi;function Cn(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const o=typeof r=="string"?r:r.scheme;o&&t.push(o)}),!n||n.replace(EL,"").match(new RegExp(`^(?:(?:${t.map(r=>r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,"i"))}var Pd=Zt.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){ey(n);return}ey(n.scheme,n.optionalSlashes)})},onDestroy(){xL()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!Cn(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(n),t=/^[a-z][a-z0-9+.-]*:/i.test(n);if(e||t&&!n.includes("@"))return!0;const o=(n.includes("@")?n.split("@").pop():n).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(o)||!/\./.test(o))}}},addAttributes(){var n,e,t;return{href:{default:null,parseHTML(r){return r.getAttribute("href")}},target:{default:(n=this.options.HTMLAttributes.target)!=null?n:null},rel:{default:(e=this.options.HTMLAttributes.rel)!=null?e:null},class:{default:(t=this.options.HTMLAttributes.class)!=null?t:null},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!Cn(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!Cn(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",ze(this.options.HTMLAttributes,n),0]:["a",ze(this.options.HTMLAttributes,{...n,href:""}),0]},markdownTokenName:"link",parseMarkdown:(n,e)=>e.applyMark("link",e.parseInline(n.tokens||[]),{href:n.href,title:n.title||null}),renderMarkdown:(n,e)=>{var t,r,o,i;const l=(r=(t=n.attrs)==null?void 0:t.href)!=null?r:"",a=(i=(o=n.attrs)==null?void 0:o.title)!=null?i:"",c=e.renderChildren(n);return a?`[${c}](${l} "${a}")`:`[${c}](${l})`},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!Cn(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n||{};return t&&!this.options.isAllowedUri(t,{defaultValidate:r=>!!Cn(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addInputRules(){return this.options.markdownLinks?[VL({type:this.type,isAllowedHref:n=>this.options.isAllowedUri(n,{defaultValidate:e=>!!Cn(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){const n=e=>{const t=[];if(e){const{protocols:r,defaultProtocol:o}=this.options;ty(e).filter(l=>l.isLink&&this.options.isAllowedUri(l.value,{defaultValidate:a=>!!Cn(a,r),protocols:r,defaultProtocol:o})).forEach(l=>{this.options.shouldAutoLink(l.value)&&t.push({text:l.value,data:{href:l.href},index:l.start})})}return t};return this.options.markdownLinks?[$L({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:t=>!!Cn(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:n})]:[wn({find:n,type:this.type,getAttributes:e=>{var t;return{href:(t=e.data)==null?void 0:t.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(AL({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!Cn(o,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),n.push(_L({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&n.push(LL({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),n}}),OL=Pd;const RL=Object.freeze(Object.defineProperty({__proto__:null,Link:Pd,default:OL,isAllowedUri:Cn,pasteRegex:IL},Symbol.toStringTag,{value:"Module"}));var FL=Object.defineProperty,PL=(n,e)=>{for(var t in e)FL(n,t,{get:e[t],enumerable:!0})},zL="listItem",iy="textStyle",ly=/^\s*([-+*])\s$/,ay=ft.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",ze(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>n.type!=="list"||n.ordered?[]:{type:"bulletList",content:n.items?e.parseChildren(n.items):[]},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
186
+ `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(zL,this.editor.getAttributes(iy)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=Jr({find:ly,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Jr({find:ly,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(iy),editor:this.editor})),[n]}}),HL=(n,e,t)=>{const{selection:r}=n;if(!r.empty)return null;const{$from:o}=r;if(!o.parent.isTextblock||o.parentOffset!==o.parent.content.size)return null;let i=-1;for(let h=o.depth;h>0;h-=1)if(o.node(h).type.name===e){i=h;break}if(i<0)return null;const l=o.node(i),a=o.index(i);if(a+1>=l.childCount)return null;const c=l.child(a+1);if(!t.includes(c.type.name))return null;const d=n.schema.nodes[e];let u=!1;if(c.forEach(h=>{h.type===d&&h.childCount>1&&(u=!0)}),!u)return null;const f=n.doc.resolve(o.after()).nodeAfter;if(!f||!t.includes(f.type.name))return null;const p=[];return f.forEach(h=>{p.push(h)}),p.length===0?null:{listItemDepth:i,nestedList:f,nestedListPos:o.after(),insertPos:o.after(i),items:p}},jL=(n,e,t,r)=>{const o=HL(n,t,r);if(!o)return!1;const{selection:i}=n,{nestedList:l,nestedListPos:a,insertPos:c,items:d}=o,u=n.tr;u.delete(a,a+l.nodeSize);const f=u.mapping.map(c);return u.insert(f,ee.from(d)),u.setSelection(i.map(u.doc,u.mapping)),e&&e(u),!0},UL=(n,e,t)=>jL(n.state,n.view.dispatch,e,t),cy=(n,e)=>He.create({name:`${n}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){const t=()=>UL(this.editor,n,e);return{Delete:t,"Mod-Delete":t}}}),dy=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],jl="abcdefghijklmnopqrstuvwxyz",WL="[a-zA-Z]{1,2}",uy=String.raw`\d+|[ivxlcdmIVXLCDM]+|${WL}`;function Ul(n){let e=n,t="";for(const[r,o]of dy)for(;e>=r;)t+=o,e-=r;return t}function zd(n){return Ul(n).toUpperCase()}function fy(n){const e=n.toLowerCase();let t=0,r=0;for(;t<e.length;){let o=!1;for(const[i,l]of dy)if(e.startsWith(l,t)){r+=i,t+=l.length,o=!0;break}if(!o)return 0}return r}function KL(n){if(!/^[ivxlcdmIVXLCDM]+$/.test(n))return!1;const e=fy(n);return e<=0?!1:(n===n.toLowerCase()?Ul(e):zd(e))===n}function qL(n){const e=n.toLowerCase();if(e.length===1)return e.charCodeAt(0)-97+1;if(e.length===2){const t=e.charCodeAt(0)-97,r=e.charCodeAt(1)-97;return(t+1)*26+r+1}return 0}function Wl(n){if(n<=26)return jl[n-1];const e=Math.floor((n-1)/26)-1,t=(n-1)%26;return e<0?jl[t]:jl[e]+jl[t]}function Kl(n){if(!(!n||/^\d+$/.test(n))){if(KL(n))return n===n.toLowerCase()?"i":"I";if(/^[a-z]{1,2}$/.test(n))return"a";if(/^[A-Z]{1,2}$/.test(n))return"A"}}function Hd(n){if(/^\d+$/.test(n))return parseInt(n,10);const e=Kl(n);if(e==="i"||e==="I")return fy(n);if(e==="a"||e==="A"){const r=qL(n);return r>0?r:1}const t=parseInt(n,10);return Number.isNaN(t)?1:t}function GL(n,e){if(n==="numeric")return String(e);switch(n){case"a":return Wl(e);case"A":return Wl(e).toUpperCase();case"i":return Ul(e);case"I":return zd(e);default:return String(e)}}function JL(n){var e;if(n.length===0)return!1;const t=(e=Kl(n[0]))!=null?e:"numeric",r=Hd(n[0]);if(r<1)return!1;for(let o=0;o<n.length;o++){const i=GL(t,r+o);if(n[o]!==i)return!1}return!0}function YL(n){return{type:Kl(n),start:Hd(n)}}function XL(n){const{type:e,start:t}=YL(n),r={};return e&&(r.type=e),t!==1&&(r.start=t),r}function ZL(n,e,t=". "){const r=e+1;if(!n||n==="1")return`${r}${t}`;switch(n){case"a":return`${Wl(r)}${t}`;case"A":return`${Wl(r).toUpperCase()}${t}`;case"i":return`${Ul(r)}${t}`;case"I":return`${zd(r)}${t}`;default:return`${r}${t}`}}function QL(n){var e,t;const r=(e=n.tokens)==null?void 0:e[0];return!!(n.text&&((t=n.tokens)==null?void 0:t.length)===1&&r?.type==="list"&&r.ordered&&r.raw===n.text)}function eI(n,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(n)):e.parseInline([{type:"text",raw:n,text:n}])}var py=ft.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",ze(this.options.HTMLAttributes,n),0]},markdownTokenName:"list_item",parseMarkdown:(n,e)=>{var t;if(n.type!=="list_item")return[];const r=(t=e.parseBlockChildren)!=null?t:e.parseChildren;let o=[];if(n.tokens&&n.tokens.length>0){if(QL(n))return{type:"listItem",content:[{type:"paragraph",content:eI(n.text||"",e)}]};if(n.tokens.some(l=>l.type==="paragraph"))o=r(n.tokens);else{const l=n.tokens[0];if(l&&l.type==="text"&&l.tokens&&l.tokens.length>0){if(o=[{type:"paragraph",content:e.parseInline(l.tokens)}],n.tokens.length>1){const c=n.tokens.slice(1),d=r(c);o.push(...d)}}else o=r(n.tokens)}}return o.length===0&&(o=[{type:"paragraph",content:[]}]),{type:"listItem",content:o}},renderMarkdown:(n,e,t)=>ol(n,e,r=>{var o,i,l,a;if(r.parentType==="bulletList")return"- ";if(r.parentType==="orderedList"){const c=((i=(o=r.meta)==null?void 0:o.parentAttrs)==null?void 0:i.start)||1,d=(a=(l=r.meta)==null?void 0:l.parentAttrs)==null?void 0:a.type,u=c-1+(r.index||0);return ZL(d,u,". ")}return"- "},t),addExtensions(){return[cy(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),tI={};PL(tI,{findListItemPos:()=>ql,getNextListDepth:()=>jd,handleBackspace:()=>Ud,handleDelete:()=>Wd,handleTab:()=>yy,hasListBefore:()=>hy,hasListItemAfter:()=>nI,hasListItemBefore:()=>rI,listItemHasSubList:()=>oI,nextListIsDeeper:()=>my,nextListIsHigher:()=>gy});var ql=(n,e)=>{const{$from:t}=e.selection,r=at(n,e.schema);let o=null,i=t.depth,l=t.pos,a=null;for(;i>0&&a===null;)o=t.node(i),o.type===r?a=i:(i-=1,l-=1);return a===null?null:{$pos:e.doc.resolve(l),depth:a}},jd=(n,e)=>{const t=ql(n,e);if(!t)return!1;const[,r]=Um(e,n,t.$pos.pos+4);return r},hy=(n,e,t)=>{const{$anchor:r}=n.selection,o=Math.max(0,r.pos-2),i=n.doc.resolve(o).node();return!(!i||!t.includes(i.type.name))},Ud=(n,e,t)=>{if(n.commands.undoInputRule())return!0;if(n.state.selection.from!==n.state.selection.to)return!1;if(!kn(n.state,e)&&hy(n.state,e,t)){const{$anchor:i}=n.state.selection,l=n.state.doc.resolve(i.before()-1),a=[];l.node().descendants((u,f)=>{u.type.name===e&&a.push({node:u,pos:f})});const c=a.at(-1);if(!c)return!1;const d=n.state.doc.resolve(l.start()+c.pos+1);return n.chain().cut({from:i.start()-1,to:i.end()+1},d.end()).joinForward().run()}if(!kn(n.state,e)||!Jm(n.state))return!1;const{$from:r}=n.state.selection,o=r.depth-1;return r.node(o).type!==n.schema.nodes[e]||r.index(o)!==0?!1:n.chain().liftListItem(e).run()},my=(n,e)=>{const t=jd(n,e),r=ql(n,e);return!r||!t?!1:t>r.depth},gy=(n,e)=>{const t=jd(n,e),r=ql(n,e);return!r||!t?!1:t<r.depth},Wd=(n,e)=>{if(!kn(n.state,e)||!Gm(n.state,e))return!1;const{selection:t}=n.state,{$from:r,$to:o}=t;return!t.empty&&r.sameParent(o)?!1:my(e,n.state)?n.chain().focus(n.state.selection.from+4).lift(e).joinBackward().run():gy(e,n.state)?n.chain().joinForward().joinBackward().run():n.commands.joinItemForward()},yy=(n,e,t)=>{const{state:r}=n,{selection:o}=r;if(!o.empty)return!1;const{$from:i}=o;if(i.parentOffset!==0||!i.parent.isTextblock||kn(r,e))return!1;const l=Wm(i);if(!l||!t.includes(l.type.name))return!1;const a=l.lastChild;if(!a||a.type.name!==e)return!1;const c=i.parent;if(!a.canReplace(a.childCount,a.childCount,ee.from(c)))return!1;const d=i.before(),u=i.after(),f=d-2;return n.commands.command(({tr:p,dispatch:h})=>(h&&(p.delete(d,u).insert(f,ee.from(c)),p.setSelection(be.create(p.doc,f+1)),p.scrollIntoView()),!0))},nI=(n,e)=>{var t;const{$anchor:r}=e.selection,o=e.doc.resolve(r.pos-r.parentOffset-2);return!(o.index()===o.parent.childCount-1||((t=o.nodeAfter)==null?void 0:t.type.name)!==n)},rI=(n,e)=>{var t;const{$anchor:r}=e.selection,o=e.doc.resolve(r.pos-2);return!(o.index()===0||((t=o.nodeBefore)==null?void 0:t.type.name)!==n)},oI=(n,e,t)=>{if(!t)return!1;const r=at(n,e.schema);let o=!1;return t.descendants(i=>{i.type===r&&(o=!0)}),o},by=He.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&Wd(n,t)&&(e=!0)}),e},"Mod-Delete":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&Wd(n,t)&&(e=!0)}),e},Backspace:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&Ud(n,t,r)&&(e=!0)}),e},"Mod-Backspace":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&Ud(n,t,r)&&(e=!0)}),e},Tab:({editor:n})=>{for(const{itemName:e,wrapperNames:t}of this.options.listTypes)if(n.state.schema.nodes[e]!==void 0&&yy(n,e,t))return!0;return!1}}}}),Kd=new RegExp(`^(\\s*)(${uy})([.)])\\s+(.*)$`),sI=/^\s/,Eo={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function iI(n){return Kd.test(n.trimStart())}function lI(n){const e=n.trimStart();return Eo.bulletItem.test(e)||iI(e)||Eo.heading.test(e)||Eo.thematicBreak.test(e)&&!e.startsWith("-")||/^>\s?/.test(e)||Eo.codeFence.test(e)||Eo.blockMath.test(e)}function aI(n){return Object.values(Eo).some(e=>e.test(n))}function cI(n){const e=[],t=[];let r=!1;return n.forEach(o=>{if(r){t.push(o);return}if(o.trim()===""){r=!0,t.push(o);return}if(e.length>0&&lI(o)){r=!0,t.push(o);return}e.push(o)}),{paragraphLines:e,blockLines:t}}function dI(n){const e=[];let t=0,r=0;for(;t<n.length;){const o=n[t],i=o.match(Kd);if(!i)break;const[,l,a,c,d]=i,u=l.length,f=parseInt(a,10),p=isNaN(f)?Kl(a):void 0,h=isNaN(f)?Hd(a):f,m=[d];let g=t+1;const y=[o];let b=!1;for(;g<n.length;){const w=n[g];if(w.match(Kd))break;if(w.trim()==="")y.push(w),m.push(""),b=!0,g+=1;else if(w.match(sI)){const E=w.length-w.trimStart().length,N=u+a.length+1;y.push(w),m.push(w.slice(Math.min(E,N))),g+=1}else{if(b||aI(w))break;y.push(w),m.push(w),g+=1}}e.push({indent:u,number:h,type:p,content:m.join(`
187
+ `).trim(),contentLines:m,raw:y.join(`
188
+ `)}),r=g,t=g}return[e,r]}var uI=new RegExp(`^(${uy})([.)])\\s+(.+)$`);function fI(n){const e=n.split(`
189
+ `).filter(i=>i.trim().length>0);if(e.length===0)return null;const t=[];for(const i of e){const l=i.trim().match(uI);if(!l)return null;t.push({marker:l[1],content:l[3]})}const r=t.map(i=>i.marker);return JL(r)?{type:"orderedList",attrs:XL(t[0].marker),content:t.map(i=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:i.content}]}]}))}:null}function ky(n,e,t){const r=[];let o=0;for(;o<n.length;){const i=n[o];if(i.indent===e){const{paragraphLines:l,blockLines:a}=cI(i.contentLines),c=l.join(`
190
+ `).trim(),d=[];c&&d.push({type:"paragraph",raw:c,tokens:t.inlineTokens(c)});const u=a.join(`
191
+ `).trim();if(u){const h=t.blockTokens(u);d.push(...h)}let f=o+1;const p=[];for(;f<n.length&&n[f].indent>e;)p.push(n[f]),f+=1;if(p.length>0){const h=Math.min(...p.map(g=>g.indent)),m=ky(p,h,t);d.push({type:"list",ordered:!0,start:p[0].number,typeMarker:p[0].type,items:m,raw:p.map(g=>g.raw).join(`
192
+ `)})}r.push({type:"list_item",raw:i.raw,tokens:d}),o=f}else o+=1}return r}function pI(n,e){return n.map(t=>{if(t.type!=="list_item")return e.parseChildren([t])[0];const r=[];return t.tokens&&t.tokens.length>0&&t.tokens.forEach(o=>{if(o.type==="paragraph"||o.type==="list"||o.type==="blockquote"||o.type==="code")r.push(...e.parseChildren([o]));else if(o.type==="text"&&o.tokens){const i=e.parseChildren([o]);r.push({type:"paragraph",content:i})}else{const i=e.parseChildren([o]);i.length>0&&r.push(...i)}}),{type:"listItem",content:r}})}var hI="listItem",wy="textStyle",xy=/^(\d+)\.\s$/;function vy(n){const e=n.match(/list-style-type\s*:\s*([^;]+)/i);if(!e)return null;switch(e[1].trim().toLowerCase()){case"upper-roman":return"I";case"lower-roman":return"i";case"upper-alpha":case"upper-latin":return"A";case"lower-alpha":case"lower-latin":return"a";default:return null}}var Cy=ft.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>{const e=n.getAttribute("type");if(e)return e;const t=n.getAttribute("style");if(t){const o=vy(t);if(o)return o}const r=n.querySelector("li");if(r){const o=r.getAttribute("style");if(o){const i=vy(o);if(i)return i}}return null}}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,type:t,...r}=n,o=ze(this.options.HTMLAttributes,r);return e!==1&&(o.start=e),t&&t!=="1"&&(o.type=t),["ol",o,0]},markdownTokenName:"list",parseMarkdown:(n,e)=>{if(n.type!=="list"||!n.ordered)return[];const t=n.start||1,r=n.typeMarker,o=n.items?pI(n.items,e):[],i={};return t!==1&&(i.start=t),r&&(i.type=r),Object.keys(i).length>0?{type:"orderedList",attrs:i,content:o}:{type:"orderedList",content:o}},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
193
+ `):"",markdownTokenizer:{name:"orderedList",level:"block",start:()=>-1,tokenize:(n,e,t)=>{var r,o;const i=n.split(`
194
+ `),[l,a]=dI(i);if(l.length===0)return;const c=ky(l,l[0].indent,t);if(c.length===0)return;const d=((r=l[0])==null?void 0:r.number)||1,u=(o=l[0])==null?void 0:o.type;return{type:"list",ordered:!0,start:d,typeMarker:u,items:c,raw:i.slice(0,a).join(`
195
+ `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(hI,this.editor.getAttributes(wy)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new Ke({props:{handlePaste:(n,e)=>{var t,r;const o=(t=e.clipboardData)==null?void 0:t.getData("text/html");if(o?.trim())return!1;const i=(r=e.clipboardData)==null?void 0:r.getData("text/plain");if(!i)return!1;const l=fI(i);if(!l)return!1;try{const a=n.state.schema.nodeFromJSON(l),c=n.state.tr.replaceSelectionWith(a);return n.dispatch(c),!0}catch{return!1}}}})]},addInputRules(){const n=(t,r)=>(!r.attrs.type||r.attrs.type==="1")&&r.childCount+r.attrs.start===+t[1];let e=Jr({find:xy,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:n});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Jr({find:xy,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(wy)}),joinPredicate:n,editor:this.editor})),[e]}}),mI=/^\s*(\[([( |x])?\])\s$/,gI="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0",yI=(n,e,t)=>{var r;return((r=t?.checkboxLabel)==null?void 0:r.call(t,n,e))||`Task item checkbox for ${n.textContent||"empty task item"}`},bI=ft.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:n=>{const e=n.getAttribute("data-checked");return e===""||e==="true"},renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:n=>{var e;return(e=n.querySelector("div"))!=null?e:n}}]},renderHTML({node:n,HTMLAttributes:e}){return["li",ze(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(n,e)=>{const t=[];if(n.tokens&&n.tokens.length>0?t.push(e.createNode("paragraph",{},e.parseInline(n.tokens))):n.text?t.push(e.createNode("paragraph",{},[e.createNode("text",{text:n.text})])):t.push(e.createNode("paragraph",{},[])),n.nestedTokens&&n.nestedTokens.length>0){const r=e.parseChildren(n.nestedTokens);t.push(...r)}return e.createNode("taskItem",{checked:n.checked||!1},t)},renderMarkdown:(n,e)=>{var t;const o=`- [${(t=n.attrs)!=null&&t.checked?"x":" "}] `;return ol(n,e,o)},addExtensions(){return this.options.nested?[cy(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){const n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:r})=>{const o=document.createElement("li"),i=document.createElement("label"),l=document.createElement("span"),a=document.createElement("input"),c=document.createElement("div");l.style.cssText=gI;const d=f=>{const p=yI(f,f.attrs.checked,this.options.a11y);a.setAttribute("aria-label",p),l.textContent=p};d(n),i.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",f=>f.preventDefault()),a.addEventListener("change",f=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}const{checked:p}=f.target;r.isEditable&&typeof t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{const m=t();if(typeof m!="number")return!1;const g=h.doc.nodeAt(m);return h.setNodeMarkup(m,void 0,{...g?.attrs,checked:p}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,p)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([f,p])=>{o.setAttribute(f,p)}),o.dataset.checked=n.attrs.checked,a.checked=n.attrs.checked,i.append(a,l),o.append(i,c),Object.entries(e).forEach(([f,p])=>{o.setAttribute(f,p)});let u=new Set(Object.keys(e));return{dom:o,contentDOM:c,update:f=>{if(f.type!==this.type)return!1;o.dataset.checked=f.attrs.checked,a.checked=f.attrs.checked,d(f);const p=r.extensionManager.attributes,h=Ur(f,p),m=new Set(Object.keys(h)),g=this.options.HTMLAttributes;return u.forEach(y=>{m.has(y)||(y in g?o.setAttribute(y,g[y]):o.removeAttribute(y))}),Object.entries(h).forEach(([y,b])=>{b==null?y in g?o.setAttribute(y,g[y]):o.removeAttribute(y):o.setAttribute(y,b)}),u=m,!0}}}},addInputRules(){return[Jr({find:mI,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),kI=ft.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:n}){return["ul",ze(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},parseMarkdown:(n,e)=>e.createNode("taskList",{},e.parseChildren(n.items||[])),renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
196
+ `):"",markdownTokenizer:{name:"taskList",level:"block",start(n){var e;const t=(e=n.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return t!==void 0?t:-1},tokenize(n,e,t){const r=i=>{const l=rl(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,c)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:t.inlineTokens(a.mainContent),nestedTokens:c}),customNestedParser:r},t);if(l){const a={type:"taskList",raw:l.raw,items:l.items},c=i.slice(l.raw.length);return c.trim()?[a,...t.blockTokens(c)]:[a]}return t.blockTokens(i)},o=rl(n,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,l)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:t.inlineTokens(i.mainContent),nestedTokens:l}),customNestedParser:r},t);if(o)return{type:"taskList",raw:o.raw,items:o.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});He.create({name:"listKit",addExtensions(){const n=[];return this.options.bulletList!==!1&&n.push(ay.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(py.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(by.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(Cy.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(bI.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(kI.configure(this.options.taskList)),n}});var Gl="&nbsp;",qd=" ",Gd=ft.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",ze(this.options.HTMLAttributes,n),0]},parseMarkdown:(n,e)=>{const t=n.tokens||[];if(t.length===1&&t[0].type==="image")return e.parseChildren([t[0]]);const r=e.parseInline(t);return t.length===1&&t[0].type==="text"&&(t[0].raw===Gl||t[0].text===Gl||t[0].raw===qd||t[0].text===qd)&&r.length===1&&r[0].type==="text"&&(r[0].text===Gl||r[0].text===qd)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(n,e,t)=>{var r,o;if(!n)return"";const i=Array.isArray(n.content)?n.content:[];if(i.length===0){const l=Array.isArray((r=t?.previousNode)==null?void 0:r.content)?t.previousNode.content:[];return((o=t?.previousNode)==null?void 0:o.type)==="paragraph"&&l.length===0?Gl:""}return e.renderChildren(i)},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),wI=Gd;const xI=Object.freeze(Object.defineProperty({__proto__:null,Paragraph:Gd,default:wI},Symbol.toStringTag,{value:"Module"}));var vI=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,CI=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,SI=Zt.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",ze(this.options.HTMLAttributes,n),0]},markdownTokenName:"del",parseMarkdown:(n,e)=>e.applyMark("strike",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`~~${e.renderChildren(n)}~~`,addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Hn({find:vI,type:this.type})]},addPasteRules(){return[wn({find:CI,type:this.type})]}}),EI=ft.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""}),MI=Zt.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",ze(this.options.HTMLAttributes,n),0]},parseMarkdown(n,e){return e.applyMark(this.name||"underline",e.parseInline(n.tokens||[]))},renderMarkdown(n,e){return`++${e.renderChildren(n)}++`},markdownTokenizer:{name:"underline",level:"inline",start(n){return n.indexOf("++")},tokenize(n,e,t){const o=/^(\+\+)([\s\S]+?)(\+\+)/.exec(n);if(!o)return;const i=o[2].trim();return{type:"underline",raw:o[0],text:i,tokens:t.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function AI(n={}){return new Ke({view(e){return new _I(e,n)}})}class _I{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let i=l=>{this[o](l)};return e.dom.addEventListener(o,i),{name:o,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,o=this.editorView.dom,i=o.getBoundingClientRect(),l=i.width/o.offsetWidth,a=i.height/o.offsetHeight;if(t){let f=e.nodeBefore,p=e.nodeAfter;if(f||p){let h=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(h){let m=h.getBoundingClientRect(),g=f?m.bottom:m.top;f&&p&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*a;r={left:m.left,right:m.right,top:g-y,bottom:g+y}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*l;r={left:f.left-p,right:f.left+p,top:f.top,bottom:f.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let d,u;if(!c||c==document.body&&getComputedStyle(c).position=="static")d=-pageXOffset,u=-pageYOffset;else{let f=c.getBoundingClientRect(),p=f.width/c.offsetWidth,h=f.height/c.offsetHeight;d=f.left-c.scrollLeft*p,u=f.top-c.scrollTop*h}this.element.style.left=(r.left-d)/l+"px",this.element.style.top=(r.top-u)/a+"px",this.element.style.width=(r.right-r.left)/l+"px",this.element.style.height=(r.bottom-r.top)/a+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),o=r&&r.type.spec.disableDropCursor,i=typeof o=="function"?o(this.editorView,t,e):o;if(!t||i)return null;let l=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=Pp(this.editorView.state.doc,l,this.editorView.dragging.slice);a!=null&&(l=a)}return l}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class nt extends Ae{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return nt.valid(r)?new nt(r):Ae.near(r)}content(){return fe.empty}eq(e){return e instanceof nt&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new nt(e.resolve(t.pos))}getBookmark(){return new Jd(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!TI(e)||!BI(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let o=t.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&nt.valid(e))return e;let o=e.pos,i=null;for(let l=e.depth;;l--){let a=e.node(l);if(t>0?e.indexAfter(l)<a.childCount:e.index(l)>0){i=a.child(t>0?e.indexAfter(l):e.index(l)-1);break}else if(l==0)return null;o+=t;let c=e.doc.resolve(o);if(nt.valid(c))return c}for(;;){let l=t>0?i.firstChild:i.lastChild;if(!l){if(i.isAtom&&!i.isText&&!Ce.isSelectable(i)){e=e.doc.resolve(o+i.nodeSize*t),r=!1;continue e}break}i=l,o+=t;let a=e.doc.resolve(o);if(nt.valid(a))return a}return null}}}nt.prototype.visible=!1,nt.findFrom=nt.findGapCursorFrom,Ae.jsonID("gapcursor",nt);class Jd{constructor(e){this.pos=e}map(e){return new Jd(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return nt.valid(t)?new nt(t):Ae.near(t)}}function Sy(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function TI(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||Sy(o.type))return!0;if(o.inlineContent)return!1}}return!0}function BI(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||Sy(o.type))return!0;if(o.inlineContent)return!1}}return!0}function NI(){return new Ke({props:{decorations:LI,createSelectionBetween(n,e,t){return e.pos==t.pos&&nt.valid(t)?new nt(t):null},handleClick:VI,handleKeyDown:DI,handleDOMEvents:{beforeinput:$I}}})}const DI=jc({ArrowLeft:Jl("horiz",-1),ArrowRight:Jl("horiz",1),ArrowUp:Jl("vert",-1),ArrowDown:Jl("vert",1)});function Jl(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,i){let l=r.selection,a=e>0?l.$to:l.$from,c=l.empty;if(l instanceof be){if(!i.endOfTextblock(t)||a.depth==0)return!1;c=!1,a=r.doc.resolve(e>0?a.after():a.before())}let d=nt.findGapCursorFrom(a,e,c);return d?(o&&o(r.tr.setSelection(new nt(d))),!0):!1}}function VI(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!nt.valid(r))return!1;let o=n.posAtCoords({left:t.clientX,top:t.clientY});return o&&o.inside>-1&&Ce.isSelectable(n.state.doc.nodeAt(o.inside))?!1:(n.dispatch(n.state.tr.setSelection(new nt(r))),!0)}function $I(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof nt))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let o=ee.empty;for(let l=r.length-1;l>=0;l--)o=ee.from(r[l].createAndFill(null,o));let i=n.state.tr.replace(t.pos,t.pos,new fe(o,0,0));return i.setSelection(be.near(i.doc.resolve(t.pos+1))),n.dispatch(i),!1}function LI(n){if(!(n.selection instanceof nt))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Oe.create(n.doc,[Tt.widget(n.selection.head,e,{key:"gapcursor"})])}var Yl=200,ht=function(){};ht.prototype.append=function(e){return e.length?(e=ht.from(e),!this.length&&e||e.length<Yl&&this.leafAppend(e)||this.length<Yl&&e.leafPrepend(this)||this.appendInner(e)):this},ht.prototype.prepend=function(e){return e.length?ht.from(e).append(this):this},ht.prototype.appendInner=function(e){return new II(this,e)},ht.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?ht.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},ht.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},ht.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)},ht.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(i,l){return o.push(e(i,l))},t,r),o},ht.from=function(e){return e instanceof ht?e:e&&e.length?new Ey(e):ht.empty};var Ey=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,i){return o==0&&i==this.length?this:new e(this.values.slice(o,i))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,i,l,a){for(var c=i;c<l;c++)if(o(this.values[c],a+c)===!1)return!1},e.prototype.forEachInvertedInner=function(o,i,l,a){for(var c=i-1;c>=l;c--)if(o(this.values[c],a+c)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=Yl)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=Yl)return new e(o.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(ht);ht.empty=new Ey([]);var II=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,o,i,l){var a=this.left.length;if(o<a&&this.left.forEachInner(r,o,Math.min(i,a),l)===!1||i>a&&this.right.forEachInner(r,Math.max(o-a,0),Math.min(this.length,i)-a,l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,i,l){var a=this.left.length;if(o>a&&this.right.forEachInvertedInner(r,o-a,Math.max(i,a)-a,l+a)===!1||i<a&&this.left.forEachInvertedInner(r,Math.min(o,a),i,l)===!1)return!1},e.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var i=this.left.length;return o<=i?this.left.slice(r,o):r>=i?this.right.slice(r-i,o-i):this.left.slice(r,i).append(this.right.slice(0,o-i))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(ht);const OI=500;class dn{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,i;t&&(o=this.remapping(r,this.items.length),i=o.maps.length);let l=e.tr,a,c,d=[],u=[];return this.items.forEach((f,p)=>{if(!f.step){o||(o=this.remapping(r,p+1),i=o.maps.length),i--,u.push(f);return}if(o){u.push(new Sn(f.map));let h=f.step.map(o.slice(i)),m;h&&l.maybeStep(h).doc&&(m=l.mapping.maps[l.mapping.maps.length-1],d.push(new Sn(m,void 0,void 0,d.length+u.length))),i--,m&&o.appendMap(m,i)}else l.maybeStep(f.step);if(f.selection)return a=o?f.selection.map(o.slice(i)):f.selection,c=new dn(this.items.slice(0,r).append(u.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:l,selection:a}}addTransform(e,t,r,o){let i=[],l=this.eventCount,a=this.items,c=!o&&a.length?a.get(a.length-1):null;for(let u=0;u<e.steps.length;u++){let f=e.steps[u].invert(e.docs[u]),p=new Sn(e.mapping.maps[u],f,t),h;(h=c&&c.merge(p))&&(p=h,u?i.pop():a=a.slice(0,a.length-1)),i.push(p),t&&(l++,t=void 0),o||(c=p)}let d=l-r.depth;return d>FI&&(a=RI(a,d),l-=d),new dn(a.append(i),l)}remapping(e,t){let r=new Xo;return this.items.forEach((o,i)=>{let l=o.mirrorOffset!=null&&i-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,l)},e,t),r}addMaps(e){return this.eventCount==0?this:new dn(this.items.append(e.map(t=>new Sn(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],o=Math.max(0,this.items.length-t),i=e.mapping,l=e.steps.length,a=this.eventCount;this.items.forEach(p=>{p.selection&&a--},o);let c=t;this.items.forEach(p=>{let h=i.getMirror(--c);if(h==null)return;l=Math.min(l,h);let m=i.maps[h];if(p.step){let g=e.steps[h].invert(e.docs[h]),y=p.selection&&p.selection.map(i.slice(c+1,h));y&&a++,r.push(new Sn(m,g,y))}else r.push(new Sn(m))},o);let d=[];for(let p=t;p<l;p++)d.push(new Sn(i.maps[p]));let u=this.items.slice(0,o).append(d).append(r),f=new dn(u,a);return f.emptyItemCount()>OI&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,o=[],i=0;return this.items.forEach((l,a)=>{if(a>=e)o.push(l),l.selection&&i++;else if(l.step){let c=l.step.map(t.slice(r)),d=c&&c.getMap();if(r--,d&&t.appendMap(d,r),c){let u=l.selection&&l.selection.map(t.slice(r));u&&i++;let f=new Sn(d.invert(),c,u),p,h=o.length-1;(p=o.length&&o[h].merge(f))?o[h]=p:o.push(f)}}else l.map&&r--},this.items.length,0),new dn(ht.from(o.reverse()),i)}}dn.empty=new dn(ht.empty,0);function RI(n,e){let t;return n.forEach((r,o)=>{if(r.selection&&e--==0)return t=o,!1}),n.slice(t)}class Sn{constructor(e,t,r,o){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Sn(t.getMap().invert(),t,this.selection)}}}class kr{constructor(e,t,r,o,i){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=o,this.prevComposition=i}}const FI=20;function PI(n,e,t,r){let o=t.getMeta(Zr),i;if(o)return o.historyState;t.getMeta(jI)&&(n=new kr(n.done,n.undone,null,0,-1));let l=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(l&&l.getMeta(Zr))return l.getMeta(Zr).redo?new kr(n.done.addTransform(t,void 0,r,Xl(e)),n.undone,My(t.mapping.maps),n.prevTime,n.prevComposition):new kr(n.done,n.undone.addTransform(t,void 0,r,Xl(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(l&&l.getMeta("addToHistory")===!1)){let a=t.getMeta("composition"),c=n.prevTime==0||!l&&n.prevComposition!=a&&(n.prevTime<(t.time||0)-r.newGroupDelay||!zI(t,n.prevRanges)),d=l?Yd(n.prevRanges,t.mapping):My(t.mapping.maps);return new kr(n.done.addTransform(t,c?e.selection.getBookmark():void 0,r,Xl(e)),dn.empty,d,t.time,a??n.prevComposition)}else return(i=t.getMeta("rebased"))?new kr(n.done.rebased(t,i),n.undone.rebased(t,i),Yd(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new kr(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Yd(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function zI(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,o)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&o>=e[i]&&(t=!0)}),t}function My(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,o,i,l)=>e.push(i,l));return e}function Yd(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let o=e.map(n[r],1),i=e.map(n[r+1],-1);o<=i&&t.push(o,i)}return t}function HI(n,e,t){let r=Xl(e),o=Zr.get(e).spec.config,i=(t?n.undone:n.done).popEvent(e,r);if(!i)return null;let l=i.selection.resolve(i.transform.doc),a=(t?n.done:n.undone).addTransform(i.transform,e.selection.getBookmark(),o,r),c=new kr(t?a:i.remaining,t?i.remaining:a,null,0,-1);return i.transform.setSelection(l).setMeta(Zr,{redo:t,historyState:c})}let Xd=!1,Ay=null;function Xl(n){let e=n.plugins;if(Ay!=e){Xd=!1,Ay=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Xd=!0;break}}return Xd}const Zr=new Qe("history"),jI=new Qe("closeHistory");function UI(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new Ke({key:Zr,state:{init(){return new kr(dn.empty,dn.empty,null,0,-1)},apply(e,t,r){return PI(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,o=r=="historyUndo"?Ty:r=="historyRedo"?By:null;return!o||!e.editable?!1:(t.preventDefault(),o(e.state,e.dispatch))}}}})}function _y(n,e){return(t,r)=>{let o=Zr.getState(t);if(!o||(n?o.undone:o.done).eventCount==0)return!1;if(r){let i=HI(o,t,n);i&&r(e?i.scrollIntoView():i)}return!0}}const Ty=_y(!1,!0),By=_y(!0,!0);He.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=n?.node||this.editor.state.doc;if((n?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=n=>{const e=n?.node||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new Ke({key:new Qe("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const o=this.options.limit,i=this.options.autoTrim;if(o==null||o===0||i===!1){n=!0;return}const l=this.storage.characters({node:r.doc});if(l>o){const a=l-o,c=0,d=a;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);const u=r.tr.deleteRange(c,d);return n=!0,u}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const o=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=r||o>r&&i>r&&i<=o)return!0;if(o>r&&i>r&&i>o||!e.getMeta("paste"))return!1;const a=e.selection.$head.pos,c=i-r,d=a-c,u=a;return e.deleteRange(d,u),!(this.storage.characters({node:e.doc})>r)}})]}});var WI=He.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[AI(this.options)]}});He.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Ke({key:new Qe("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:o}=e,i=[];if(!t||!r)return Oe.create(n,[]);let l=0;this.options.mode==="deepest"&&n.descendants((c,d)=>{if(c.isText)return;if(!(o>=d&&o<=d+c.nodeSize-1))return!1;l+=1});let a=0;return n.descendants((c,d)=>{if(c.isText||!(o>=d&&o<=d+c.nodeSize-1))return!1;if(a+=1,this.options.mode==="deepest"&&l-a>0||this.options.mode==="shallowest"&&a>1)return this.options.mode==="deepest";i.push(Tt.node(d,d+c.nodeSize,{class:this.options.className}))}),Oe.create(n,i)}}})]}});var KI=He.create({name:"gapCursor",addProseMirrorPlugins(){return[NI()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=Re(ke(n,"allowGapCursor",t)))!=null?e:null}}}),Ny="placeholder",Dy=new Qe("tiptap__placeholder");function Vy(n){const{editor:e,placeholder:t,dataAttribute:r,pos:o,node:i,isEmptyDoc:l,hasAnchor:a,classes:{emptyNode:c,emptyEditor:d}}=n,u=[c];return l&&u.push(d),Tt.node(o,o+i.nodeSize,{class:u.join(" "),[r]:typeof t=="function"?t({editor:e,node:i,pos:o,hasAnchor:a}):t})}function $y(n,e){return typeof n=="function"?n(e):n}function Ly({editor:n,options:e,dataAttribute:t,doc:r,selection:o,from:i,to:l}){const{anchor:a}=o,c=[],d=n.isEmpty;return r.nodesBetween(i,l,(u,f)=>{const p=a>=f&&a<=f+u.nodeSize,h=!u.isLeaf&&vo(u);return u.type.isTextblock&&(p||!e.showOnlyCurrent)&&h&&c.push(Vy({editor:n,isEmptyDoc:d,dataAttribute:t,hasAnchor:p,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:$y(e.emptyNodeClass,{editor:n,node:u,pos:f,hasAnchor:p})},node:u,pos:f})),e.includeChildren}),c}function Iy({editor:n,options:e,dataAttribute:t,doc:r,selection:o}){if(!(n.isEditable||!e.showOnlyWhenEditable))return null;const{anchor:l}=o,a=[],c=n.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){const u=r.resolve(l),f=u.depth>0?u.node(1):u.nodeAfter,p=u.depth>0?u.before(1):l;if(f&&f.type.isTextblock&&vo(f)){const h=l>=p&&l<=p+f.nodeSize;a.push(Vy({editor:n,isEmptyDoc:c,dataAttribute:t,hasAnchor:h,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:$y(e.emptyNodeClass,{editor:n,node:f,pos:p,hasAnchor:h})},node:f,pos:p}))}}else a.push(...Ly({editor:n,options:e,dataAttribute:t,doc:r,selection:o,from:0,to:r.content.size}));return Oe.create(r,a)}function Is(n,e){var t;const r=n.resolve(e);if(r.depth===0){const l=(t=r.nodeAfter)!=null?t:r.nodeBefore;if(!l)return{from:e,to:e};const a=r.nodeAfter?e:e-l.nodeSize;return{from:a,to:a+l.nodeSize}}const o=r.before(1),i=r.node(1);return{from:o,to:o+i.nodeSize}}function Os(n,e){return{from:Math.max(0,e.from-1),to:Math.min(n.content.size,e.to-1)}}function qI(n,e,t){const r=[];return n.forEach((o,i)=>{const l=i,a=l+o.nodeSize,c=l+1,d=a+1;c<t&&d>e&&r.push({from:l,to:a})}),r}function GI(n){if(n.length===0)return[];const e=[...n].sort((r,o)=>r.from-o.from),t=[{...e[0]}];for(let r=1;r<e.length;r+=1){const o=t[t.length-1],i=e[r];i.from<=o.to?o.to=Math.max(o.to,i.to):t.push({...i})}return t}function JI(n,e){const t=qI(n,e.from,e.to);return t.push(Os(n,Is(n,e.from))),e.to>e.from?t.push(Os(n,Is(n,Math.min(e.to,n.content.size+1)-1))):e.from<n.content.size+1&&t.push(Os(n,Is(n,Math.min(e.from+1,n.content.size)))),t}function YI(n,e,t){const r=[];if(n.docChanged){const o=xs(n);for(const i of o)r.push(...JI(t.doc,i.newRange))}return n.selectionSet&&(r.push(Os(t.doc,Is(t.doc,n.mapping.map(e.selection.anchor)))),r.push(Os(t.doc,Is(t.doc,t.selection.anchor)))),GI(r)}function XI(n,e,t){const r=Math.max(0,Math.min(n,t.content.size)),o=Math.max(r,Math.min(e,t.content.size));return{from:r,to:o}}function ZI({decorations:n,ranges:e,editor:t,options:r,dataAttribute:o,doc:i,selection:l}){let a=n;for(const c of e){const{from:d,to:u}=XI(c.from,c.to,i),f=a.find(d,u).filter(h=>h.from>=d&&h.to<=u);f.length&&(a=a.remove(f));const p=Ly({editor:t,options:r,dataAttribute:o,doc:i,selection:l,from:d,to:u});p.length&&(a=a.add(i,p))}return a}function QI({editor:n,options:e,dataAttribute:t}){return{init(r,o){const i=Iy({editor:n,options:e,dataAttribute:t,doc:o.doc,selection:o.selection});return i??Oe.empty},apply(r,o,i,l){if(!r.docChanged&&!r.selectionSet)return o;const a=o.map(r.mapping,r.doc),c=YI(r,i,l);return ZI({decorations:a,ranges:c,editor:n,options:e,dataAttribute:t,doc:l.doc,selection:l.selection})}}}function eO(n){return n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function tO({editor:n,options:e}){const t=e.dataAttribute?`data-${eO(e.dataAttribute)}`:`data-${Ny}`,r=e.showOnlyCurrent&&!e.includeChildren;return new Ke({key:Dy,...r?{}:{state:QI({editor:n,options:e,dataAttribute:t})},props:{decorations:r?({doc:o,selection:i})=>Iy({editor:n,options:e,dataAttribute:t,doc:o,selection:i}):o=>{var i;return e.showOnlyWhenEditable&&!n.isEditable?Oe.empty:(i=Dy.getState(o))!=null?i:Oe.empty}}})}He.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Ny,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[tO({editor:this.editor,options:this.options})]}});function Zd(n,e){return!n.selection.empty&&!id(n.selection)&&e.isEditable}function nO(n,e){return Zd(n,e)&&!e.isFocused&&!e.view.dragging}function rO(){var n;(n=window.getSelection())==null||n.removeAllRanges()}function oO(n){n.focus()}He.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new Ke({key:new Qe("selection"),props:{decorations(t){return nO(t,n)?Oe.create(t.doc,[Tt.inline(t.selection.from,t.selection.to,{class:e.className})]):null},handleDOMEvents:{blur(t){return Zd(t.state,n)&&rO(),!1},focus(t){return Zd(t.state,n)&&requestAnimationFrame(()=>{!n.isDestroyed&&t.hasFocus()&&oO(t)}),!1}}}})]}});var sO="skipTrailingNode";function Oy({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||e?.type===n}var iO=He.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new Qe(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:n.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,o])=>o).filter(o=>(this.options.notAfter||[]).concat(t).includes(o.name));return[new Ke({key:e,appendTransaction:(o,i,l)=>{const{doc:a,tr:c,schema:d}=l,u=e.getState(l),f=a.content.size,p=d.nodes[t];if(!o.some(h=>h.getMeta(sO))&&u)return c.insert(f,p.create())},state:{init:(o,i)=>{const l=i.tr.doc.lastChild;return!Oy({node:l,types:r})},apply:(o,i)=>{if(!o.docChanged||o.getMeta("__uniqueIDTransaction"))return i;const l=o.doc.lastChild;return!Oy({node:l,types:r})}}})]}}),lO=He.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>Ty(n,e),redo:()=>({state:n,dispatch:e})=>By(n,e)}},addProseMirrorPlugins(){return[UI(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Ry=He.create({name:"starterKit",addExtensions(){var n,e,t,r;const o=[];return this.options.bold!==!1&&o.push(H$.configure(this.options.bold)),this.options.blockquote!==!1&&o.push(O$.configure(this.options.blockquote)),this.options.bulletList!==!1&&o.push(ay.configure(this.options.bulletList)),this.options.code!==!1&&o.push(W$.configure(this.options.code)),this.options.codeBlock!==!1&&o.push(G$.configure(this.options.codeBlock)),this.options.document!==!1&&o.push(J$.configure(this.options.document)),this.options.dropcursor!==!1&&o.push(WI.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&o.push(KI.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&o.push(Y$.configure(this.options.hardBreak)),this.options.heading!==!1&&o.push(gd.configure(this.options.heading)),this.options.undoRedo!==!1&&o.push(lO.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&o.push(Q$.configure(this.options.horizontalRule)),this.options.italic!==!1&&o.push(oL.configure(this.options.italic)),this.options.listItem!==!1&&o.push(py.configure(this.options.listItem)),this.options.listKeymap!==!1&&o.push(by.configure((n=this.options)==null?void 0:n.listKeymap)),this.options.link!==!1&&o.push(Pd.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&o.push(Cy.configure(this.options.orderedList)),this.options.paragraph!==!1&&o.push(Gd.configure(this.options.paragraph)),this.options.strike!==!1&&o.push(SI.configure(this.options.strike)),this.options.text!==!1&&o.push(EI.configure(this.options.text)),this.options.underline!==!1&&o.push(MI.configure((t=this.options)==null?void 0:t.underline)),this.options.trailingNode!==!1&&o.push(iO.configure((r=this.options)==null?void 0:r.trailingNode)),o}}),aO=Ry;const cO=Object.freeze(Object.defineProperty({__proto__:null,StarterKit:Ry,default:aO},Symbol.toStringTag,{value:"Module"}));var dO=20,Fy=(n,e=0)=>{const t=[];return!n.children.length||e>dO||Array.from(n.children).forEach(r=>{r.tagName==="SPAN"?t.push(r):r.children.length&&t.push(...Fy(r,e+1))}),t},uO=n=>{if(!n.children.length)return;const e=Fy(n);e&&e.forEach(t=>{var r,o;const i=t.getAttribute("style"),l=(o=(r=t.parentElement)==null?void 0:r.closest("span"))==null?void 0:o.getAttribute("style");t.setAttribute("style",`${l};${i}`)})},Py=Zt.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:n=>n.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&uO(n),{}):!1}]},renderHTML({HTMLAttributes:n}){return["span",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleTextStyle:n=>({commands:e})=>e.toggleMark(this.name,n),removeEmptyTextStyle:()=>({tr:n})=>{const{selection:e}=n;return n.doc.nodesBetween(e.from,e.to,(t,r)=>{if(t.isTextblock)return!0;t.marks.filter(o=>o.type===this.type).some(o=>Object.values(o.attrs).some(i=>!!i))||n.removeMark(r,r+t.nodeSize,this.type)}),!0}}}}),zy=He.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:n=>{var e;const t=(e=qr(n,"background-color"))!=null?e:n.style.backgroundColor;return t?.replace(/['"]+/g,"")},renderHTML:n=>n.backgroundColor?{style:`background-color: ${n.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:n=>({chain:e})=>e().setMark("textStyle",{backgroundColor:n}).run(),unsetBackgroundColor:()=>({chain:n})=>n().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),Hy=He.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:n=>{var e;const t=(e=qr(n,"color"))!=null?e:n.style.color;return t?.replace(/['"]+/g,"")},renderHTML:n=>n.color?{style:`color: ${n.color}`}:{}}}}]},addCommands(){return{setColor:n=>({chain:e})=>e().setMark("textStyle",{color:n}).run(),unsetColor:()=>({chain:n})=>n().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),jy=He.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:n=>{var e;return(e=qr(n,"font-family"))!=null?e:n.style.fontFamily},renderHTML:n=>n.fontFamily?{style:`font-family: ${n.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:n=>({chain:e})=>e().setMark("textStyle",{fontFamily:n}).run(),unsetFontFamily:()=>({chain:n})=>n().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),Uy=He.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:n=>{var e;return(e=qr(n,"font-size"))!=null?e:n.style.fontSize},renderHTML:n=>n.fontSize?{style:`font-size: ${n.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:n=>({chain:e})=>e().setMark("textStyle",{fontSize:n}).run(),unsetFontSize:()=>({chain:n})=>n().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),Wy=He.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:n=>{var e;return(e=qr(n,"line-height"))!=null?e:n.style.lineHeight},renderHTML:n=>n.lineHeight?{style:`line-height: ${n.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:n=>({chain:e})=>e().setMark("textStyle",{lineHeight:n}).run(),unsetLineHeight:()=>({chain:n})=>n().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}}),fO=He.create({name:"textStyleKit",addExtensions(){const n=[];return this.options.backgroundColor!==!1&&n.push(zy.configure(this.options.backgroundColor)),this.options.color!==!1&&n.push(Hy.configure(this.options.color)),this.options.fontFamily!==!1&&n.push(jy.configure(this.options.fontFamily)),this.options.fontSize!==!1&&n.push(Uy.configure(this.options.fontSize)),this.options.lineHeight!==!1&&n.push(Wy.configure(this.options.lineHeight)),this.options.textStyle!==!1&&n.push(Py.configure(this.options.textStyle)),n}});const pO=Object.freeze(Object.defineProperty({__proto__:null,BackgroundColor:zy,Color:Hy,FontFamily:jy,FontSize:Uy,LineHeight:Wy,TextStyle:Py,TextStyleKit:fO},Symbol.toStringTag,{value:"Module"}));let Qd,eu;if(typeof WeakMap<"u"){let n=new WeakMap;Qd=e=>n.get(e),eu=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Qd=r=>{for(let o=0;o<n.length;o+=2)if(n[o]==r)return n[o+1]},eu=(r,o)=>(t==10&&(t=0),n[t++]=r,n[t++]=o)}var rt=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const r=e%this.width,o=e/this.width|0;let i=r+1,l=o+1;for(let a=1;i<this.width&&this.map[e+a]==t;a++)i++;for(let a=1;l<this.height&&this.map[e+this.width*a]==t;a++)l++;return{left:r,top:o,right:i,bottom:l}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:r,right:o,top:i,bottom:l}=this.findCell(n);return e=="horiz"?(t<0?r==0:o==this.width)?null:this.map[i*this.width+(t<0?r-1:o)]:(t<0?i==0:l==this.height)?null:this.map[r+this.width*(t<0?i-1:l)]}rectBetween(n,e){const{left:t,right:r,top:o,bottom:i}=this.findCell(n),{left:l,right:a,top:c,bottom:d}=this.findCell(e);return{left:Math.min(t,l),top:Math.min(o,c),right:Math.max(r,a),bottom:Math.max(i,d)}}cellsInRect(n){const e=[],t={};for(let r=n.top;r<n.bottom;r++)for(let o=n.left;o<n.right;o++){const i=r*this.width+o,l=this.map[i];t[l]||(t[l]=!0,!(o==n.left&&o&&this.map[i-1]==l||r==n.top&&r&&this.map[i-this.width]==l)&&e.push(l))}return e}positionAt(n,e,t){for(let r=0,o=0;;r++){const i=o+t.child(r).nodeSize;if(r==n){let l=e+n*this.width;const a=(n+1)*this.width;for(;l<a&&this.map[l]<o;)l++;return l==a?i-1:this.map[l]}o=i}}static get(n){return Qd(n)||eu(n,hO(n))}};function hO(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=mO(n),t=n.childCount,r=[];let o=0,i=null;const l=[];for(let d=0,u=e*t;d<u;d++)r[d]=0;for(let d=0,u=0;d<t;d++){const f=n.child(d);u++;for(let m=0;;m++){for(;o<r.length&&r[o]!=0;)o++;if(m==f.childCount)break;const g=f.child(m),{colspan:y,rowspan:b,colwidth:w}=g.attrs;for(let v=0;v<b;v++){if(v+d>=t){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:b-v});break}const E=o+v*e;for(let N=0;N<y;N++){r[E+N]==0?r[E+N]=u:(i||(i=[])).push({type:"collision",row:d,pos:u,n:y-N});const R=w&&w[N];if(R){const T=(E+N)%e*2,M=l[T];M==null||M!=R&&l[T+1]==1?(l[T]=R,l[T+1]=1):M==R&&l[T+1]++}}}o+=y,u+=g.nodeSize}const p=(d+1)*e;let h=0;for(;o<p;)r[o++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:d,n:h}),u++}(e===0||t===0)&&(i||(i=[])).push({type:"zero_sized"});const a=new rt(e,t,r,i);let c=!1;for(let d=0;!c&&d<l.length;d+=2)l[d]!=null&&l[d+1]<t&&(c=!0);return c&&gO(a,l,n),a}function mO(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){const o=n.child(r);let i=0;if(t)for(let l=0;l<r;l++){const a=n.child(l);for(let c=0;c<a.childCount;c++){const d=a.child(c);l+d.attrs.rowspan>r&&(i+=d.attrs.colspan)}}for(let l=0;l<o.childCount;l++){const a=o.child(l);i+=a.attrs.colspan,a.attrs.rowspan>1&&(t=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function gO(n,e,t){n.problems||(n.problems=[]);const r={};for(let o=0;o<n.map.length;o++){const i=n.map[o];if(r[i])continue;r[i]=!0;const l=t.nodeAt(i);if(!l)throw new RangeError(`No cell with offset ${i} found`);let a=null;const c=l.attrs;for(let d=0;d<c.colspan;d++){const u=e[(o+d)%n.width*2];u!=null&&(!c.colwidth||c.colwidth[d]!=u)&&((a||(a=yO(c)))[d]=u)}a&&n.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:a})}}function yO(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Nt(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const r=n.nodes[t],o=r.spec.tableRole;o&&(e[o]=r)}}return e}const wr=new Qe("selectingCells");function Qr(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function bO(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function un(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function Zl(n){const e=n.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=Qr(e.$head)||kO(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function kO(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function tu(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function wO(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function nu(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function Ky(n,e,t){const r=n.node(-1),o=rt.get(r),i=n.start(-1),l=o.nextCell(n.pos-i,e,t);return l==null?null:n.node(0).resolve(i+l)}function eo(n,e,t=1){const r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function qy(n,e,t=1){const r={...n,colspan:n.colspan+t};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<t;o++)r.colwidth.splice(e,0,0)}return r}function xO(n,e,t){const r=Nt(e.type.schema).header_cell;for(let o=0;o<n.height;o++)if(e.nodeAt(n.map[t+o*n.width]).type!=r)return!1;return!0}var Je=class Xn extends Ae{constructor(e,t=e){const r=e.node(-1),o=rt.get(r),i=e.start(-1),l=o.rectBetween(e.pos-i,t.pos-i),a=e.node(0),c=o.cellsInRect(l).filter(u=>u!=t.pos-i);c.unshift(t.pos-i);const d=c.map(u=>{const f=r.nodeAt(u);if(!f)throw new RangeError(`No cell with offset ${u} found`);const p=i+u+1;return new Wp(a.resolve(p),a.resolve(p+f.content.size))});super(d[0].$from,d[0].$to,d),this.$anchorCell=e,this.$headCell=t}map(e,t){const r=e.resolve(t.map(this.$anchorCell.pos)),o=e.resolve(t.map(this.$headCell.pos));if(tu(r)&&tu(o)&&nu(r,o)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Xn.rowSelection(r,o):i&&this.isColSelection()?Xn.colSelection(r,o):new Xn(r,o)}return be.between(r,o)}content(){const e=this.$anchorCell.node(-1),t=rt.get(e),r=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},l=[];for(let c=o.top;c<o.bottom;c++){const d=[];for(let u=c*t.width+o.left,f=o.left;f<o.right;f++,u++){const p=t.map[u];if(i[p])continue;i[p]=!0;const h=t.findCell(p);let m=e.nodeAt(p);if(!m)throw new RangeError(`No cell with offset ${p} found`);const g=o.left-h.left,y=h.right-o.right;if(g>0||y>0){let b=m.attrs;if(g>0&&(b=eo(b,0,g)),y>0&&(b=eo(b,b.colspan-y,y)),h.left<o.left){if(m=m.type.createAndFill(b),!m)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else m=m.type.create(b,m.content)}if(h.top<o.top||h.bottom>o.bottom){const b={...m.attrs,rowspan:Math.min(h.bottom,o.bottom)-Math.max(h.top,o.top)};h.top<o.top?m=m.type.createAndFill(b):m=m.type.create(b,m.content)}d.push(m)}l.push(e.child(c).copy(ee.from(d)))}const a=this.isColSelection()&&this.isRowSelection()?e:l;return new fe(ee.from(a),1,1)}replace(e,t=fe.empty){const r=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){const{$from:a,$to:c}=o[l],d=e.mapping.slice(r);e.replace(d.map(a.pos),d.map(c.pos),l?fe.empty:t)}const i=Ae.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new fe(ee.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),r=rt.get(t),o=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let l=0;l<i.length;l++)e(t.nodeAt(i[l]),o+i[l])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const r=e.node(-1),o=rt.get(r),i=e.start(-1),l=o.findCell(e.pos-i),a=o.findCell(t.pos-i),c=e.node(0);return l.top<=a.top?(l.top>0&&(e=c.resolve(i+o.map[l.left])),a.bottom<o.height&&(t=c.resolve(i+o.map[o.width*(o.height-1)+a.right-1]))):(a.top>0&&(t=c.resolve(i+o.map[a.left])),l.bottom<o.height&&(e=c.resolve(i+o.map[o.width*(o.height-1)+l.right-1]))),new Xn(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=rt.get(e),r=this.$anchorCell.start(-1),o=t.colCount(this.$anchorCell.pos-r),i=t.colCount(this.$headCell.pos-r);if(Math.min(o,i)>0)return!1;const l=o+this.$anchorCell.nodeAfter.attrs.colspan,a=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(l,a)==t.width}eq(e){return e instanceof Xn&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),o=rt.get(r),i=e.start(-1),l=o.findCell(e.pos-i),a=o.findCell(t.pos-i),c=e.node(0);return l.left<=a.left?(l.left>0&&(e=c.resolve(i+o.map[l.top*o.width])),a.right<o.width&&(t=c.resolve(i+o.map[o.width*(a.top+1)-1]))):(a.left>0&&(t=c.resolve(i+o.map[a.top*o.width])),l.right<o.width&&(e=c.resolve(i+o.map[o.width*(l.top+1)-1]))),new Xn(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new Xn(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new Xn(e.resolve(t),e.resolve(r))}getBookmark(){return new vO(this.$anchorCell.pos,this.$headCell.pos)}};Je.prototype.visible=!1,Ae.jsonID("cell",Je);var vO=class sb{constructor(e,t){this.anchor=e,this.head=t}map(e){return new sb(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&nu(t,r)?new Je(t,r):Ae.near(r,1)}};function CO(n){if(!(n.selection instanceof Je))return null;const e=[];return n.selection.forEachCell((t,r)=>{e.push(Tt.node(r,r+t.nodeSize,{class:"selectedCell"}))}),Oe.create(n.doc,e)}function SO({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,r=e.pos,o=n.depth;for(;o>=0&&!(n.after(o+1)<n.end(o));o--,t++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return t==r&&/row|table/.test(n.node(o).type.spec.tableRole)}function EO({$from:n,$to:e}){let t,r;for(let o=n.depth;o>0;o--){const i=n.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){t=i;break}}for(let o=e.depth;o>0;o--){const i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return t!==r&&e.parentOffset===0}function MO(n,e,t){const r=(e||n).selection,o=(e||n).doc;let i,l;if(r instanceof Ce&&(l=r.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell")i=Je.create(o,r.from);else if(l=="row"){const a=o.resolve(r.from+1);i=Je.rowSelection(a,a)}else if(!t){const a=rt.get(r.node),c=r.from+1,d=c+a.map[a.width*a.height-1];i=Je.create(o,c+1,d)}}else r instanceof be&&SO(r)?i=be.create(o,r.from):r instanceof be&&EO(r)&&(i=be.create(o,r.$from.start(),r.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}const AO=new Qe("fix-tables");function Gy(n,e,t,r){const o=n.childCount,i=e.childCount;e:for(let l=0,a=0;l<i;l++){const c=e.child(l);for(let d=a,u=Math.min(o,l+3);d<u;d++)if(n.child(d)==c){a=d+1,t+=c.nodeSize;continue e}r(c,t),a<o&&n.child(a).sameMarkup(c)?Gy(n.child(a),c,t+1,r):c.nodesBetween(0,c.content.size,r,t+1),t+=c.nodeSize}}function Jy(n,e){let t;const r=(o,i)=>{o.type.spec.tableRole=="table"&&(t=_O(n,o,i,t))};return e?e.doc!=n.doc&&Gy(e.doc,n.doc,0,r):n.doc.descendants(r),t}function _O(n,e,t,r){const o=rt.get(e);if(!o.problems)return r;r||(r=n.tr);const i=[];for(let c=0;c<o.height;c++)i.push(0);for(let c=0;c<o.problems.length;c++){const d=o.problems[c];if(d.type=="collision"){const u=e.nodeAt(d.pos);if(!u)continue;const f=u.attrs;for(let p=0;p<f.rowspan;p++)i[d.row+p]+=d.n;r.setNodeMarkup(r.mapping.map(t+1+d.pos),null,eo(f,f.colspan-d.n,d.n))}else if(d.type=="missing")i[d.row]+=d.n;else if(d.type=="overlong_rowspan"){const u=e.nodeAt(d.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(t+1+d.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-d.n})}else if(d.type=="colwidth mismatch"){const u=e.nodeAt(d.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(t+1+d.pos),null,{...u.attrs,colwidth:d.colwidth})}else if(d.type=="zero_sized"){const u=r.mapping.map(t);r.delete(u,u+e.nodeSize)}}let l,a;for(let c=0;c<i.length;c++)i[c]&&(l==null&&(l=c),a=c);for(let c=0,d=t+1;c<o.height;c++){const u=e.child(c),f=d+u.nodeSize,p=i[c];if(p>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);const m=[];for(let y=0;y<p;y++){const b=Nt(n.schema)[h].createAndFill();b&&m.push(b)}const g=(c==0||l==c-1)&&a==c?d+1:f-1;r.insert(r.mapping.map(g),m)}d=f}return r.setMeta(AO,{fixTables:!0})}function En(n){const e=n.selection,t=Zl(n),r=t.node(-1),o=t.start(-1),i=rt.get(r);return{...e instanceof Je?i.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):i.findCell(t.pos-o),tableStart:o,map:i,table:r}}function Yy(n,{map:e,tableStart:t,table:r},o){let i=o>0?-1:0;xO(e,r,o+i)&&(i=o==0||o==e.width?null:0);for(let l=0;l<e.height;l++){const a=l*e.width+o;if(o>0&&o<e.width&&e.map[a-1]==e.map[a]){const c=e.map[a],d=r.nodeAt(c);n.setNodeMarkup(n.mapping.map(t+c),null,qy(d.attrs,o-e.colCount(c))),l+=d.attrs.rowspan-1}else{const c=i==null?Nt(r.type.schema).cell:r.nodeAt(e.map[a+i]).type,d=e.positionAt(l,o,r);n.insert(n.mapping.map(t+d),c.createAndFill())}}return n}function TO(n,e){if(!un(n))return!1;if(e){const t=En(n);e(Yy(n.tr,t,t.left))}return!0}function BO(n,e){if(!un(n))return!1;if(e){const t=En(n);e(Yy(n.tr,t,t.right))}return!0}function NO(n,{map:e,table:t,tableStart:r},o){const i=n.mapping.maps.length;for(let l=0;l<e.height;){const a=l*e.width+o,c=e.map[a],d=t.nodeAt(c),u=d.attrs;if(o>0&&e.map[a-1]==c||o<e.width-1&&e.map[a+1]==c)n.setNodeMarkup(n.mapping.slice(i).map(r+c),null,eo(u,o-e.colCount(c)));else{const f=n.mapping.slice(i).map(r+c);n.delete(f,f+d.nodeSize)}l+=u.rowspan}}function DO(n,e){if(!un(n))return!1;if(e){const t=En(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let o=t.right-1;NO(r,t,o),o!=t.left;o--){const i=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");t.table=i,t.map=rt.get(i)}e(r)}return!0}function VO(n,e,t){var r;const o=Nt(e.type.schema).header_cell;for(let i=0;i<n.width;i++)if(((r=e.nodeAt(n.map[i+t*n.width]))===null||r===void 0?void 0:r.type)!=o)return!1;return!0}function Xy(n,{map:e,tableStart:t,table:r},o){let i=t;for(let d=0;d<o;d++)i+=r.child(d).nodeSize;const l=[];let a=o>0?-1:0;VO(e,r,o+a)&&(a=o==0||o==e.height?null:0);for(let d=0,u=e.width*o;d<e.width;d++,u++)if(o>0&&o<e.height&&e.map[u]==e.map[u-e.width]){const f=e.map[u],p=r.nodeAt(f).attrs;n.setNodeMarkup(t+f,null,{...p,rowspan:p.rowspan+1}),d+=p.colspan-1}else{var c;const f=a==null?Nt(r.type.schema).cell:(c=r.nodeAt(e.map[u+a*e.width]))===null||c===void 0?void 0:c.type,p=f?.createAndFill();p&&l.push(p)}return n.insert(i,Nt(r.type.schema).row.create(null,l)),n}function $O(n,e){if(!un(n))return!1;if(e){const t=En(n);e(Xy(n.tr,t,t.top))}return!0}function LO(n,e){if(!un(n))return!1;if(e){const t=En(n);e(Xy(n.tr,t,t.bottom))}return!0}function IO(n,{map:e,table:t,tableStart:r},o){let i=0;for(let d=0;d<o;d++)i+=t.child(d).nodeSize;const l=i+t.child(o).nodeSize,a=n.mapping.maps.length;n.delete(i+r,l+r);const c=new Set;for(let d=0,u=o*e.width;d<e.width;d++,u++){const f=e.map[u];if(!c.has(f)){if(c.add(f),o>0&&f==e.map[u-e.width]){const p=t.nodeAt(f).attrs;n.setNodeMarkup(n.mapping.slice(a).map(f+r),null,{...p,rowspan:p.rowspan-1}),d+=p.colspan-1}else if(o<e.height&&f==e.map[u+e.width]){const p=t.nodeAt(f),h=p.attrs,m=p.type.create({...h,rowspan:p.attrs.rowspan-1},p.content),g=e.positionAt(o+1,d,t);n.insert(n.mapping.slice(a).map(r+g),m),d+=h.colspan-1}}}}function OO(n,e){if(!un(n))return!1;if(e){const t=En(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let o=t.bottom-1;IO(r,t,o),o!=t.top;o--){const i=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");t.table=i,t.map=rt.get(t.table)}e(r)}return!0}function Zy(n){const e=n.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function RO({width:n,height:e,map:t},r){let o=r.top*n+r.left,i=o,l=(r.bottom-1)*n+r.left,a=o+(r.right-r.left-1);for(let c=r.top;c<r.bottom;c++){if(r.left>0&&t[i]==t[i-1]||r.right<n&&t[a]==t[a+1])return!0;i+=n,a+=n}for(let c=r.left;c<r.right;c++){if(r.top>0&&t[o]==t[o-n]||r.bottom<e&&t[l]==t[l+n])return!0;o++,l++}return!1}function Qy(n,e){const t=n.selection;if(!(t instanceof Je)||t.$anchorCell.pos==t.$headCell.pos)return!1;const r=En(n),{map:o}=r;if(RO(o,r))return!1;if(e){const i=n.tr,l={};let a=ee.empty,c,d;for(let u=r.top;u<r.bottom;u++)for(let f=r.left;f<r.right;f++){const p=o.map[u*o.width+f],h=r.table.nodeAt(p);if(!(l[p]||!h))if(l[p]=!0,c==null)c=p,d=h;else{Zy(h)||(a=a.append(h.content));const m=i.mapping.map(p+r.tableStart);i.delete(m,m+h.nodeSize)}}if(c==null||d==null)return!0;if(i.setNodeMarkup(c+r.tableStart,null,{...qy(d.attrs,d.attrs.colspan,r.right-r.left-d.attrs.colspan),rowspan:r.bottom-r.top}),a.size>0){const u=c+1+d.content.size,f=Zy(d)?c+1:u;i.replaceWith(f+r.tableStart,u+r.tableStart,a)}i.setSelection(new Je(i.doc.resolve(c+r.tableStart))),e(i)}return!0}function e0(n,e){const t=Nt(n.schema);return FO(({node:r})=>t[r.type.spec.tableRole])(n,e)}function FO(n){return(e,t)=>{const r=e.selection;let o,i;if(r instanceof Je){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;o=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var l;if(o=bO(r.$from),!o)return!1;i=(l=Qr(r.$from))===null||l===void 0?void 0:l.pos}if(o==null||i==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(t){let a=o.attrs;const c=[],d=a.colwidth;a.rowspan>1&&(a={...a,rowspan:1}),a.colspan>1&&(a={...a,colspan:1});const u=En(e),f=e.tr;for(let h=0;h<u.right-u.left;h++)c.push(d?{...a,colwidth:d&&d[h]?[d[h]]:null}:a);let p;for(let h=u.top;h<u.bottom;h++){let m=u.map.positionAt(h,u.left,u.table);h==u.top&&(m+=o.nodeSize);for(let g=u.left,y=0;g<u.right;g++,y++)g==u.left&&h==u.top||f.insert(p=f.mapping.map(m+u.tableStart,1),n({node:o,row:h,col:g}).createAndFill(c[y]))}f.setNodeMarkup(i,n({node:o,row:u.top,col:u.left}),c[0]),r instanceof Je&&f.setSelection(new Je(f.doc.resolve(r.$anchorCell.pos),p?f.doc.resolve(p):void 0)),t(f)}return!0}}function PO(n,e){return function(t,r){if(!un(t))return!1;const o=Zl(t);if(o.nodeAfter.attrs[n]===e)return!1;if(r){const i=t.tr;t.selection instanceof Je?t.selection.forEachCell((l,a)=>{l.attrs[n]!==e&&i.setNodeMarkup(a,null,{...l.attrs,[n]:e})}):i.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[n]:e}),r(i)}return!0}}function zO(n){return function(e,t){if(!un(e))return!1;if(t){const r=Nt(e.schema),o=En(e),i=e.tr,l=o.map.cellsInRect(n=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:n=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),a=l.map(c=>o.table.nodeAt(c));for(let c=0;c<l.length;c++)a[c].type==r.header_cell&&i.setNodeMarkup(o.tableStart+l[c],r.cell,a[c].attrs);if(i.steps.length===0)for(let c=0;c<l.length;c++)i.setNodeMarkup(o.tableStart+l[c],r.header_cell,a[c].attrs);t(i)}return!0}}function t0(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let o=0;o<r.length;o++){const i=e.table.nodeAt(r[o]);if(i&&i.type!==t.header_cell)return!1}return!0}function Rs(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?zO(n):function(t,r){if(!un(t))return!1;if(r){const o=Nt(t.schema),i=En(t),l=t.tr,a=t0("row",i,o),c=t0("column",i,o),d=(n==="column"?a:n==="row"&&c)?1:0,u=n=="column"?{left:0,top:d,right:1,bottom:i.map.height}:n=="row"?{left:d,top:0,right:i.map.width,bottom:1}:i,f=n=="column"?c?o.cell:o.header_cell:n=="row"?a?o.cell:o.header_cell:o.cell;i.map.cellsInRect(u).forEach(p=>{const h=p+i.tableStart,m=l.doc.nodeAt(h);m&&l.setNodeMarkup(h,f,m.attrs)}),r(l)}return!0}}Rs("row",{useDeprecatedLogic:!0}),Rs("column",{useDeprecatedLogic:!0});const HO=Rs("cell",{useDeprecatedLogic:!0});function jO(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,o=n.before();r>=0;r--){const i=n.node(-1).child(r),l=i.lastChild;if(l)return o-1-l.nodeSize;o-=i.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let r=n.indexAfter(-1),o=n.after();r<t.childCount;r++){const i=t.child(r);if(i.childCount)return o+1;o+=i.nodeSize}}return null}function n0(n){return function(e,t){if(!un(e))return!1;const r=jO(Zl(e),n);if(r==null)return!1;if(t){const o=e.doc.resolve(r);t(e.tr.setSelection(be.between(o,wO(o))).scrollIntoView())}return!0}}function UO(n,e){const t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}function Ql(n,e){const t=n.selection;if(!(t instanceof Je))return!1;if(e){const r=n.tr,o=Nt(n.schema).cell.createAndFill().content;t.forEachCell((i,l)=>{i.content.eq(o)||r.replace(r.mapping.map(l+1),r.mapping.map(l+i.nodeSize-1),new fe(o,0,0))}),r.docChanged&&e(r)}return!0}function WO(n){if(n.size===0)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;const o=e.child(0),i=o.type.spec.tableRole,l=o.type.schema,a=[];if(i=="row")for(let c=0;c<e.childCount;c++){let d=e.child(c).content;const u=c?0:Math.max(0,t-1),f=c<e.childCount-1?0:Math.max(0,r-1);(u||f)&&(d=ru(Nt(l).row,new fe(d,u,f)).content),a.push(d)}else if(i=="cell"||i=="header_cell")a.push(t||r?ru(Nt(l).row,new fe(e,t,r)).content:e);else return null;return KO(l,a)}function KO(n,e){const t=[];for(let o=0;o<e.length;o++){const i=e[o];for(let l=i.childCount-1;l>=0;l--){const{rowspan:a,colspan:c}=i.child(l).attrs;for(let d=o;d<o+a;d++)t[d]=(t[d]||0)+c}}let r=0;for(let o=0;o<t.length;o++)r=Math.max(r,t[o]);for(let o=0;o<t.length;o++)if(o>=e.length&&e.push(ee.empty),t[o]<r){const i=Nt(n).cell.createAndFill(),l=[];for(let a=t[o];a<r;a++)l.push(i);e[o]=e[o].append(ee.from(l))}return{height:e.length,width:r,rows:e}}function ru(n,e){const t=n.createAndFill();return new lc(t).replace(0,t.content.size,e).doc}function qO({width:n,height:e,rows:t},r,o){if(n!=r){const i=[],l=[];for(let a=0;a<t.length;a++){const c=t[a],d=[];for(let u=i[a]||0,f=0;u<r;f++){let p=c.child(f%c.childCount);u+p.attrs.colspan>r&&(p=p.type.createChecked(eo(p.attrs,p.attrs.colspan,u+p.attrs.colspan-r),p.content)),d.push(p),u+=p.attrs.colspan;for(let h=1;h<p.attrs.rowspan;h++)i[a+h]=(i[a+h]||0)+p.attrs.colspan}l.push(ee.from(d))}t=l,n=r}if(e!=o){const i=[];for(let l=0,a=0;l<o;l++,a++){const c=[],d=t[a%e];for(let u=0;u<d.childCount;u++){let f=d.child(u);l+f.attrs.rowspan>o&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,o-f.attrs.rowspan)},f.content)),c.push(f)}i.push(ee.from(c))}t=i,e=o}return{width:n,height:e,rows:t}}function GO(n,e,t,r,o,i,l){const a=n.doc.type.schema,c=Nt(a);let d,u;if(o>e.width)for(let f=0,p=0;f<e.height;f++){const h=t.child(f);p+=h.nodeSize;const m=[];let g;h.lastChild==null||h.lastChild.type==c.cell?g=d||(d=c.cell.createAndFill()):g=u||(u=c.header_cell.createAndFill());for(let y=e.width;y<o;y++)m.push(g);n.insert(n.mapping.slice(l).map(p-1+r),m)}if(i>e.height){const f=[];for(let m=0,g=(e.height-1)*e.width;m<Math.max(e.width,o);m++){const y=m>=e.width?!1:t.nodeAt(e.map[g+m]).type==c.header_cell;f.push(y?u||(u=c.header_cell.createAndFill()):d||(d=c.cell.createAndFill()))}const p=c.row.create(null,ee.from(f)),h=[];for(let m=e.height;m<i;m++)h.push(p);n.insert(n.mapping.slice(l).map(r+t.nodeSize-2),h)}return!!(d||u)}function r0(n,e,t,r,o,i,l,a){if(l==0||l==e.height)return!1;let c=!1;for(let d=o;d<i;d++){const u=l*e.width+d,f=e.map[u];if(e.map[u-e.width]==f){c=!0;const p=t.nodeAt(f),{top:h,left:m}=e.findCell(f);n.setNodeMarkup(n.mapping.slice(a).map(f+r),null,{...p.attrs,rowspan:l-h}),n.insert(n.mapping.slice(a).map(e.positionAt(l,m,t)),p.type.createAndFill({...p.attrs,rowspan:h+p.attrs.rowspan-l})),d+=p.attrs.colspan-1}}return c}function o0(n,e,t,r,o,i,l,a){if(l==0||l==e.width)return!1;let c=!1;for(let d=o;d<i;d++){const u=d*e.width+l,f=e.map[u];if(e.map[u-1]==f){c=!0;const p=t.nodeAt(f),h=e.colCount(f),m=n.mapping.slice(a).map(f+r);n.setNodeMarkup(m,null,eo(p.attrs,l-h,p.attrs.colspan-(l-h))),n.insert(m+p.nodeSize,p.type.createAndFill(eo(p.attrs,0,l-h))),d+=p.attrs.rowspan-1}}return c}function s0(n,e,t,r,o){let i=t?n.doc.nodeAt(t-1):n.doc;if(!i)throw new Error("No table found");let l=rt.get(i);const{top:a,left:c}=r,d=c+o.width,u=a+o.height,f=n.tr;let p=0;function h(){if(i=t?f.doc.nodeAt(t-1):f.doc,!i)throw new Error("No table found");l=rt.get(i),p=f.mapping.maps.length}GO(f,l,i,t,d,u,p)&&h(),r0(f,l,i,t,c,d,a,p)&&h(),r0(f,l,i,t,c,d,u,p)&&h(),o0(f,l,i,t,a,u,c,p)&&h(),o0(f,l,i,t,a,u,d,p)&&h();for(let m=a;m<u;m++){const g=l.positionAt(m,c,i),y=l.positionAt(m,d,i);f.replace(f.mapping.slice(p).map(g+t),f.mapping.slice(p).map(y+t),new fe(o.rows[m-a],0,0))}h(),f.setSelection(new Je(f.doc.resolve(t+l.positionAt(a,c,i)),f.doc.resolve(t+l.positionAt(u-1,d-1,i)))),e(f)}const JO=jc({ArrowLeft:ta("horiz",-1),ArrowRight:ta("horiz",1),ArrowUp:ta("vert",-1),ArrowDown:ta("vert",1),"Shift-ArrowLeft":na("horiz",-1),"Shift-ArrowRight":na("horiz",1),"Shift-ArrowUp":na("vert",-1),"Shift-ArrowDown":na("vert",1),Backspace:Ql,"Mod-Backspace":Ql,Delete:Ql,"Mod-Delete":Ql});function ea(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function ta(n,e){return(t,r,o)=>{if(!o)return!1;const i=t.selection;if(i instanceof Je)return ea(t,r,Ae.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;const l=i0(o,n,e);if(l==null)return!1;if(n=="horiz")return ea(t,r,Ae.near(t.doc.resolve(i.head+e),e));{const a=t.doc.resolve(l),c=Ky(a,n,e);let d;return c?d=Ae.near(c,1):e<0?d=Ae.near(t.doc.resolve(a.before(-1)),-1):d=Ae.near(t.doc.resolve(a.after(-1)),1),ea(t,r,d)}}}function na(n,e){return(t,r,o)=>{if(!o)return!1;const i=t.selection;let l;if(i instanceof Je)l=i;else{const c=i0(o,n,e);if(c==null)return!1;l=new Je(t.doc.resolve(c))}const a=Ky(l.$headCell,n,e);return a?ea(t,r,new Je(l.$anchorCell,a)):!1}}function YO(n,e){const t=n.state.doc,r=Qr(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new Je(r))),!0):!1}function XO(n,e,t){if(!un(n.state))return!1;let r=WO(t);const o=n.state.selection;if(o instanceof Je){r||(r={width:1,height:1,rows:[ee.from(ru(Nt(n.state.schema).cell,t))]});const i=o.$anchorCell.node(-1),l=o.$anchorCell.start(-1),a=rt.get(i).rectBetween(o.$anchorCell.pos-l,o.$headCell.pos-l);return r=qO(r,a.right-a.left,a.bottom-a.top),s0(n.state,n.dispatch,l,a,r),!0}else if(r){const i=Zl(n.state),l=i.start(-1);return s0(n.state,n.dispatch,l,rt.get(i.node(-1)).findCell(i.pos-l),r),!0}else return!1}function ZO(n,e){var t;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=l0(n,e.target);let o;if(e.shiftKey&&n.state.selection instanceof Je)i(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=Qr(n.state.selection.$anchor))!=null&&((t=ou(n,e))===null||t===void 0?void 0:t.pos)!=o.pos)i(o,e),e.preventDefault();else if(!r)return;function i(c,d){let u=ou(n,d);const f=wr.getState(n.state)==null;if(!u||!nu(c,u))if(f)u=c;else return;const p=new Je(c,u);if(f||!n.state.selection.eq(p)){const h=n.state.tr.setSelection(p);f&&h.setMeta(wr,c.pos),n.dispatch(h)}}function l(){n.root.removeEventListener("mouseup",l),n.root.removeEventListener("dragstart",l),n.root.removeEventListener("mousemove",a),wr.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(wr,-1))}function a(c){const d=c,u=wr.getState(n.state);let f;if(u!=null)f=n.state.doc.resolve(u);else if(l0(n,d.target)!=r&&(f=ou(n,e),!f))return l();f&&i(f,d)}n.root.addEventListener("mouseup",l),n.root.addEventListener("dragstart",l),n.root.addEventListener("mousemove",a)}function i0(n,e,t){if(!(n.state.selection instanceof be))return null;const{$head:r}=n.state.selection;for(let o=r.depth-1;o>=0;o--){const i=r.node(o);if((t<0?r.index(o):r.indexAfter(o))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const l=r.before(o),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function l0(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function ou(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});if(!t)return null;let{inside:r,pos:o}=t;return r>=0&&Qr(n.state.doc.resolve(r))||Qr(n.state.doc.resolve(o))}var QO=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),su(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,su(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function su(n,e,t,r,o,i){let l=0,a=!0,c=e.firstChild;const d=n.firstChild;if(d){for(let f=0,p=0;f<d.childCount;f++){const{colspan:h,colwidth:m}=d.child(f).attrs;for(let g=0;g<h;g++,p++){const y=o==p?i:m&&m[g],b=y?y+"px":"";if(l+=y||r,y||(a=!1),c)c.style.width!=b&&(c.style.width=b),c=c.nextSibling;else{const w=document.createElement("col");w.style.width=b,e.appendChild(w)}}}for(;c;){var u;const f=c.nextSibling;(u=c.parentNode)===null||u===void 0||u.removeChild(c),c=f}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}const Ut=new Qe("tableColumnResizing");function eR({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:r=QO,lastColumnResizable:o=!0}={}){const i=new Ke({key:Ut,state:{init(l,a){var c;const d=(c=i.spec)===null||c===void 0||(c=c.props)===null||c===void 0?void 0:c.nodeViews,u=Nt(a.schema).table.name;return r&&d&&(d[u]=(f,p)=>new r(f,t,p)),new tR(-1,!1)},apply(l,a){return a.apply(l)}},props:{attributes:l=>{const a=Ut.getState(l);return a&&a.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(l,a)=>{nR(l,a,n,o)},mouseleave:l=>{rR(l)},mousedown:(l,a)=>{oR(l,a,e,t)}},decorations:l=>{const a=Ut.getState(l);if(a&&a.activeHandle>-1)return cR(l,a.activeHandle)},nodeViews:{}}});return i}var tR=class da{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,r=e.getMeta(Ut);if(r&&r.setHandle!=null)return new da(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new da(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let o=e.mapping.map(t.activeHandle,-1);return tu(e.doc.resolve(o))||(o=-1),new da(o,t.dragging)}return t}};function nR(n,e,t,r){if(!n.editable)return;const o=Ut.getState(n.state);if(o&&!o.dragging){const i=iR(e.target);let l=-1;if(i){const{left:a,right:c}=i.getBoundingClientRect();e.clientX-a<=t?l=a0(n,e,"left",t):c-e.clientX<=t&&(l=a0(n,e,"right",t))}if(l!=o.activeHandle){if(!r&&l!==-1){const a=n.state.doc.resolve(l),c=a.node(-1),d=rt.get(c),u=a.start(-1);if(d.colCount(a.pos-u)+a.nodeAfter.attrs.colspan-1==d.width-1)return}d0(n,l)}}}function rR(n){if(!n.editable)return;const e=Ut.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&d0(n,-1)}function oR(n,e,t,r){var o;if(!n.editable)return!1;const i=(o=n.dom.ownerDocument.defaultView)!==null&&o!==void 0?o:window,l=Ut.getState(n.state);if(!l||l.activeHandle==-1||l.dragging)return!1;const a=n.state.doc.nodeAt(l.activeHandle),c=sR(n,l.activeHandle,a.attrs);n.dispatch(n.state.tr.setMeta(Ut,{setDragging:{startX:e.clientX,startWidth:c}}));function d(f){i.removeEventListener("mouseup",d),i.removeEventListener("mousemove",u);const p=Ut.getState(n.state);p?.dragging&&(lR(n,p.activeHandle,c0(p.dragging,f,t)),n.dispatch(n.state.tr.setMeta(Ut,{setDragging:null})))}function u(f){if(!f.which)return d(f);const p=Ut.getState(n.state);if(p&&p.dragging){const h=c0(p.dragging,f,t);u0(n,p.activeHandle,h,r)}}return u0(n,l.activeHandle,c,r),i.addEventListener("mouseup",d),i.addEventListener("mousemove",u),e.preventDefault(),!0}function sR(n,e,{colspan:t,colwidth:r}){const o=r&&r[r.length-1];if(o)return o;const i=n.domAtPos(e);let l=i.node.childNodes[i.offset].offsetWidth,a=t;if(r)for(let c=0;c<t;c++)r[c]&&(l-=r[c],a--);return l/a}function iR(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function a0(n,e,t,r){const o=t=="right"?-r:r,i=n.posAtCoords({left:e.clientX+o,top:e.clientY});if(!i)return-1;const{pos:l}=i,a=Qr(n.state.doc.resolve(l));if(!a)return-1;if(t=="right")return a.pos;const c=rt.get(a.node(-1)),d=a.start(-1),u=c.map.indexOf(a.pos-d);return u%c.width==0?-1:d+c.map[u-1]}function c0(n,e,t){const r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function d0(n,e){n.dispatch(n.state.tr.setMeta(Ut,{setHandle:e}))}function lR(n,e,t){const r=n.state.doc.resolve(e),o=r.node(-1),i=rt.get(o),l=r.start(-1),a=i.colCount(r.pos-l)+r.nodeAfter.attrs.colspan-1,c=n.state.tr;for(let d=0;d<i.height;d++){const u=d*i.width+a;if(d&&i.map[u]==i.map[u-i.width])continue;const f=i.map[u],p=o.nodeAt(f).attrs,h=p.colspan==1?0:a-i.colCount(f);if(p.colwidth&&p.colwidth[h]==t)continue;const m=p.colwidth?p.colwidth.slice():aR(p.colspan);m[h]=t,c.setNodeMarkup(l+f,null,{...p,colwidth:m})}c.docChanged&&n.dispatch(c)}function u0(n,e,t,r){const o=n.state.doc.resolve(e),i=o.node(-1),l=o.start(-1),a=rt.get(i).colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1;let c=n.domAtPos(o.start(-1)).node;for(;c&&c.nodeName!="TABLE";)c=c.parentNode;c&&su(i,c.firstChild,c,r,a,t)}function aR(n){return Array(n).fill(0)}function cR(n,e){const t=[],r=n.doc.resolve(e),o=r.node(-1);if(!o)return Oe.empty;const i=rt.get(o),l=r.start(-1),a=i.colCount(r.pos-l)+r.nodeAfter.attrs.colspan-1;for(let d=0;d<i.height;d++){const u=a+d*i.width;if((a==i.width-1||i.map[u]!=i.map[u+1])&&(d==0||i.map[u]!=i.map[u-i.width])){var c;const f=i.map[u],p=l+f+o.nodeAt(f).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",!((c=Ut.getState(n))===null||c===void 0)&&c.dragging&&t.push(Tt.node(l+f,l+f+o.nodeAt(f).nodeSize,{class:"column-resize-dragging"})),t.push(Tt.widget(p,h))}}return Oe.create(n.doc,t)}function dR({allowTableNodeSelection:n=!1}={}){return new Ke({key:wr,state:{init(){return null},apply(e,t){const r=e.getMeta(wr);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;const{deleted:o,pos:i}=e.mapping.mapResult(t);return o?null:i}},props:{decorations:CO,handleDOMEvents:{mousedown:ZO},createSelectionBetween(e){return wr.getState(e.state)!=null?e.state.selection:null},handleTripleClick:YO,handleKeyDown:JO,handlePaste:XO},appendTransaction(e,t,r){return MO(r,Jy(r,t),n)}})}function ra(n){return n==="left"||n==="right"||n==="center"?n:null}function uR(n){const e=(n.style.textAlign||"").trim().toLowerCase(),t=(n.getAttribute("align")||"").trim().toLowerCase();return ra(e||t)}function fR(n){return ra(n?.align)}function f0(){return{default:null,parseHTML:n=>uR(n),renderHTML:n=>n.align?{style:`text-align: ${n.align}`}:{}}}function pR(n){var e;const t=n.parentElement,r=n.closest("table");if(!t||!r)return null;const o=Array.from(t.children).indexOf(n),i=(e=r.querySelectorAll("colgroup > col")[o])==null?void 0:e.getAttribute("width");return i?[parseInt(i,10)]:null}function p0(n){const e=n.getAttribute("colwidth");return e?e.split(",").map(t=>parseInt(t,10)):pR(n)}var hR=/[ \t\r\n\f]+/g;function h0(n){var e;return n.children.length>0?!1:((e=n.textContent)!=null?e:"").replace(hR,"")===""}function m0(n){const e=n.createAndFill();if(!e)throw new Error(`[tiptap error]: "${n.name}" has no default content to backfill.`);return e.content}var g0=ft.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:p0},align:f0()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td",getAttrs:n=>h0(n)?{}:!1,getContent:(n,e)=>m0(e.nodes[this.name])},{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",ze(this.options.HTMLAttributes,n),0]}}),y0=ft.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:p0},align:f0()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th",getAttrs:n=>h0(n)?{}:!1,getContent:(n,e)=>m0(e.nodes[this.name])},{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",ze(this.options.HTMLAttributes,n),0]}}),b0=ft.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",ze(this.options.HTMLAttributes,n),0]}});function iu(n,e){return e?["width",`${Math.max(e,n)}px`]:["min-width",`${n}px`]}function lu(n,e,t,r,o,i){var l;let a=0,c=!0,d=e.firstChild;const u=n.firstChild;if(u!==null)for(let p=0,h=0;p<u.childCount;p+=1){const{colspan:m,colwidth:g}=u.child(p).attrs;for(let y=0;y<m;y+=1,h+=1){const b=o===h?i:g&&g[y],w=b?`${b}px`:"";if(a+=b||r,b||(c=!1),d){if(d.style.width!==w){const[v,E]=iu(r,b);d.style.setProperty(v,E)}d=d.nextSibling}else{const v=document.createElement("col"),[E,N]=iu(r,b);v.style.setProperty(E,N),e.appendChild(v)}}}for(;d;){const p=d.nextSibling;(l=d.parentNode)==null||l.removeChild(d),d=p}const f=n.attrs.style&&typeof n.attrs.style=="string"&&/\bwidth\s*:/i.test(n.attrs.style);c&&!f?(t.style.width=`${a}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${a}px`)}var k0=class{constructor(n,e,t,r={}){this.node=n,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table"));for(const[o,i]of Object.entries(r))i!=null&&(o==="style"?this.table.style.cssText=String(i):this.table.setAttribute(o,String(i)));n.attrs.style&&(this.table.style.cssText=n.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),lu(n,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(n){return n.type!==this.node.type?!1:(this.node=n,lu(n,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(n){const e=n.target,t=this.dom.contains(e),r=this.contentDOM.contains(e);return!!(t&&!r&&(n.type==="attributes"||n.type==="childList"||n.type==="characterData"))}};function w0(n,e,t,r){let o=0,i=!0;const l=[],a=n.firstChild;if(!a)return{};for(let f=0,p=0;f<a.childCount;f+=1){const{colspan:h,colwidth:m}=a.child(f).attrs;for(let g=0;g<h;g+=1,p+=1){const y=t===p?r:m&&m[g];o+=y||e,y||(i=!1);const[b,w]=iu(e,y);l.push(["col",{style:`${b}: ${w}`}])}}const c=i?`${o}px`:"",d=i?"":`${o}px`;return{colgroup:["colgroup",{},...l],tableWidth:c,tableMinWidth:d}}function x0(n,e){return e?n.createChecked(null,e):n.createAndFill()}function mR(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;const e={};return Object.keys(n.nodes).forEach(t=>{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function v0(n,e,t,r,o){const i=mR(n),l=[],a=[];for(let d=0;d<t;d+=1){const u=x0(i.cell,o);if(u&&a.push(u),r){const f=x0(i.header_cell,o);f&&l.push(f)}}const c=[];for(let d=0;d<e;d+=1)c.push(i.row.createChecked(null,r&&d===0?l:a));return i.table.createChecked(null,c)}function gR(n){return n instanceof Je}var oa=({editor:n})=>{const{selection:e}=n.state;if(!gR(e))return!1;let t=0;const r=wo(e.ranges[0].$from,i=>i.type.name==="table");return r?.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1};function C0(n,e){const t=n.mapping.map(e),r=wo(n.selection.$from,l=>l.type.name==="table");if(r?.pos===t)return;const o=n.doc.nodeAt(t);if(!o)return;const i=t+o.nodeSize-1;n.setSelection(be.near(n.doc.resolve(i),-1))}var S0="";function E0(n){let e="",t=0;for(;t<n.length;){if(n[t]==="\\"&&t+1<n.length){e+=n[t]+n[t+1],t+=2;continue}if(n[t]!=="`"){e+=n[t++];continue}let r=0;for(;t+r<n.length&&n[t+r]==="`";)r+=1;let o=t+r,i=!1;for(;o<n.length;){if(n[o]!=="`"){o+=1;continue}let l=0;for(;o+l<n.length&&n[o+l]==="`";)l+=1;if(l===r){const a=n.slice(t+r,o);e+=n.slice(t,t+r)+a.replace(new RegExp("(?<!\\\\)\\|","g"),"\\|")+n.slice(o,o+r),t=o+r,i=!0;break}o+=l}i||(e+=n.slice(t,t+r),t+=r)}return e}function M0(n){return n.split(`
197
+ `).map(e=>!e.includes("|")||!e.includes("`")?e:E0(e)).join(`
198
+ `)}function yR(n){return(n||"").replace(/\s+/g," ").trim()}function A0(n,e,t={}){var r;const o=(r=t.cellLineSeparator)!=null?r:S0;if(!n||!n.content||n.content.length===0)return"";const i=[];n.content.forEach(g=>{const y=[];g.content&&g.content.forEach(b=>{let w="";b.content&&Array.isArray(b.content)&&b.content.length>1?w=b.content.map(T=>e.renderChildren(T)).join(o):w=b.content?e.renderChildren(b.content):"";const v=yR(w.split(o).join(`
199
+ `).replace(/[ \t]*\r?\n[ \t]*/g,"<br>")),E=b.type==="tableHeader",N=fR(b.attrs);y.push({text:v,isHeader:E,align:N})}),i.push(y)});const l=i.reduce((g,y)=>Math.max(g,y.length),0);if(l===0)return"";const a=Array.from({length:l}).fill(0);i.forEach(g=>{var y;for(let b=0;b<l;b+=1){const v=(((y=g[b])==null?void 0:y.text)||"").length;v>a[b]&&(a[b]=v),a[b]<3&&(a[b]=3)}});const c=(g,y)=>g+" ".repeat(Math.max(0,y-g.length)),d=i[0],u=d.some(g=>g.isHeader),f=Array.from({length:l}).fill(null);i.forEach(g=>{var y;for(let b=0;b<l;b+=1)!f[b]&&((y=g[b])!=null&&y.align)&&(f[b]=g[b].align)});let p=`
200
+ `;const h=Array.from({length:l}).map((g,y)=>u&&d[y]&&d[y].text||"");return p+=`| ${h.map((g,y)=>c(g,a[y])).join(" | ")} |
201
+ `,p+=`| ${a.map((g,y)=>{const b=Math.max(3,g),w=f[y];return w==="left"?`:${"-".repeat(b)}`:w==="right"?`${"-".repeat(b)}:`:w==="center"?`:${"-".repeat(b)}:`:"-".repeat(b)}).join(" | ")} |
202
+ `,(u?i.slice(1):i).forEach(g=>{p+=`| ${Array.from({length:l}).fill(0).map((y,b)=>c(g[b]&&g[b].text||"",a[b])).join(" | ")} |
203
+ `}),p}var bR=A0,_0=ft.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:k0,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){const{colgroup:t,tableWidth:r,tableMinWidth:o}=w0(n,this.options.cellMinWidth),i=e.style;function l(){return i||(r?`width: ${r}`:`min-width: ${o}`)}const a=["table",ze(this.options.HTMLAttributes,e,{style:l()}),t,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},a]:a},parseMarkdown:(n,e)=>{const t=[],r=Array.isArray(n.align)?n.align:[];if(n.header){const o=[];n.header.forEach((i,l)=>{var a;const c=ra((a=r[l])!=null?a:i.align),d=c?{align:c}:{};o.push(e.createNode("tableHeader",d,[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),t.push(e.createNode("tableRow",{},o))}return n.rows&&n.rows.forEach(o=>{const i=[];o.forEach((l,a)=>{var c;const d=ra((c=r[a])!=null?c:l.align),u=d?{align:d}:{};i.push(e.createNode("tableCell",u,[{type:"paragraph",content:e.parseInline(l.tokens)}]))}),t.push(e.createNode("tableRow",{},i))}),e.createNode("table",void 0,t)},renderMarkdown:(n,e)=>bR(n,e),markdownTokenizer:{name:"table",level:"block",start:n=>{const e=n.split(`
204
+ `);if(e.length<2)return-1;const t=e[1];return!/^[ \t|:]*-[ \t|:-]*$/.test(t)||!t.includes("|")?-1:e[0].includes("|")?0:-1},tokenize(n,e,t){const r=n.indexOf(`
205
+
206
+ `),o=r>=0?n.slice(0,r):n,i=o.split(`
207
+ `);if(i.length<2)return;const l=i[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(l)||!l.includes("|"))return;const a=M0(o);if(a===o)return;const d=t.blockTokens(a)[0];if(d?.type!=="table"||!d.raw)return;const u=d.raw.split(`
208
+ `).length,f=n.split(`
209
+ `).slice(0,u).join(`
210
+ `);return{...d,raw:f}}},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:o,editor:i})=>{const l=v0(i.schema,n,e,t);if(o){const a=r.selection.from+1;r.replaceSelectionWith(l).scrollIntoView().setSelection(be.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>TO(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>BO(n,e),deleteColumn:()=>({state:n,dispatch:e})=>{const t=wo(n.selection.$from,r=>r.type.name==="table");return DO(n,e&&(r=>{t&&C0(r,t.pos),e(r)}))},addRowBefore:()=>({state:n,dispatch:e})=>$O(n,e),addRowAfter:()=>({state:n,dispatch:e})=>LO(n,e),deleteRow:()=>({state:n,dispatch:e})=>{const t=wo(n.selection.$from,r=>r.type.name==="table");return OO(n,e&&(r=>{t&&C0(r,t.pos),e(r)}))},deleteTable:()=>({state:n,dispatch:e})=>UO(n,e),mergeCells:()=>({state:n,dispatch:e})=>Qy(n,e),splitCell:()=>({state:n,dispatch:e})=>e0(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>Rs("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>Rs("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>HO(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>Qy(n,e)?!0:e0(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>PO(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>n0(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>n0(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&Jy(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=Je.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:oa,"Mod-Backspace":oa,Delete:oa,"Mod-Delete":oa}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[eR({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],dR({allowTableNodeSelection:this.options.allowTableNodeSelection})]},addNodeView(){const n=this.options.resizable&&this.editor.isEditable,e=this.options.View;return n||!e?null:({node:t,view:r,HTMLAttributes:o})=>{const i=ze(this.options.HTMLAttributes,o);return new e(t,this.options.cellMinWidth,r,i)}},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:Re(ke(n,"tableRole",e))}}}),kR=He.create({name:"tableKit",addExtensions(){const n=[];return this.options.table!==!1&&n.push(_0.configure(this.options.table)),this.options.tableCell!==!1&&n.push(g0.configure(this.options.tableCell)),this.options.tableHeader!==!1&&n.push(y0.configure(this.options.tableHeader)),this.options.tableRow!==!1&&n.push(b0.configure(this.options.tableRow)),n}});const wR=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_CELL_LINE_SEPARATOR:S0,Table:_0,TableCell:g0,TableHeader:y0,TableKit:kR,TableRow:b0,TableView:k0,createColGroup:w0,createTable:v0,escapeTableCellPipes:E0,preprocessTablePipes:M0,renderTableToMarkdown:A0,updateColumns:lu},Symbol.toStringTag,{value:"Module"}));var T0=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,B0=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,N0=Zt.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:n=>n.getAttribute("data-color")||qr(n,"background-color")||n.style.backgroundColor,renderHTML:n=>n.color?{"data-color":n.color,style:`background-color: ${n.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:n}){return["mark",ze(this.options.HTMLAttributes,n),0]},renderMarkdown:(n,e)=>`==${e.renderChildren(n)}==`,parseMarkdown:(n,e)=>e.applyMark("highlight",e.parseInline(n.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:n=>n.indexOf("=="),tokenize(n,e,t){const o=/^(==)([^=]+)(==)/.exec(n);if(o){const i=o[2].trim(),l=t.inlineTokens(i);return{type:"highlight",raw:o[0],text:i,tokens:l}}}},addCommands(){return{setHighlight:n=>({commands:e})=>e.setMark(this.name,n),toggleHighlight:n=>({commands:e})=>e.toggleMark(this.name,n),unsetHighlight:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Hn({find:T0,type:this.type})]},addPasteRules(){return[wn({find:B0,type:this.type})]}}),xR=N0;const vR=Object.freeze(Object.defineProperty({__proto__:null,Highlight:N0,default:xR,inputRegex:T0,pasteRegex:B0},Symbol.toStringTag,{value:"Module"}));var D0=Zt.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(n){return n!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:n}){return["sub",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{setSubscript:()=>({commands:n})=>n.setMark(this.name),toggleSubscript:()=>({commands:n})=>n.toggleMark(this.name),unsetSubscript:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),CR=D0;const SR=Object.freeze(Object.defineProperty({__proto__:null,Subscript:D0,default:CR},Symbol.toStringTag,{value:"Module"}));var V0=Zt.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(n){return n!=="super"?!1:null}}]},renderHTML({HTMLAttributes:n}){return["sup",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{setSuperscript:()=>({commands:n})=>n.setMark(this.name),toggleSuperscript:()=>({commands:n})=>n.toggleMark(this.name),unsetSuperscript:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),ER=V0;const MR=Object.freeze(Object.defineProperty({__proto__:null,Superscript:V0,default:ER},Symbol.toStringTag,{value:"Module"}));var $0=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,L0=ft.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:n}){return["img",ze(this.options.HTMLAttributes,n)]},parseMarkdown:(n,e)=>e.createNode("image",{src:n.href,title:n.title,alt:n.text}),renderMarkdown:n=>{var e,t,r,o,i,l;const a=(t=(e=n.attrs)==null?void 0:e.src)!=null?t:"",c=(o=(r=n.attrs)==null?void 0:r.alt)!=null?o:"",d=(l=(i=n.attrs)==null?void 0:i.title)!=null?l:"";return d?`![${c}](${a} "${d}")`:`![${c}](${a})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;const{directions:n,minWidth:e,minHeight:t,alwaysPreserveAspectRatio:r}=this.options.resize,o=new Set(["src","width","height"]);return({node:i,getPos:l,HTMLAttributes:a,editor:c})=>{const d=document.createElement("img");d.draggable=!1;const u=ze(this.options.HTMLAttributes,a);Object.entries(u).forEach(([y,b])=>{if(b!=null)switch(y){case"src":case"width":case"height":break;default:d.setAttribute(y,b);break}}),u.src!==null&&(d.src=u.src);let f={...a};const p=y=>{if(typeof y=="string"&&y!==""){d.getAttribute("src")!==y&&(d.src=y);return}d.hasAttribute("src")&&d.removeAttribute("src"),d.src!==""&&(d.src="")};p(a.src);const h=y=>{if(y.type!==i.type)return!1;const b=c.extensionManager.attributes.filter(v=>v.type===y.type.name),w=Ur(y,b);return Object.keys(f).forEach(v=>{!o.has(v)&&!(v in w)&&d.removeAttribute(v)}),Object.entries(w).forEach(([v,E])=>{o.has(v)||(E!=null?d.setAttribute(v,E):d.removeAttribute(v))}),p(w.src),f=w,!0},m=new hd({element:d,editor:c,node:i,getPos:l,onResize:(y,b)=>{d.style.width=`${y}px`,d.style.height=`${b}px`},onCommit:(y,b)=>{const w=l();w!==void 0&&this.editor.chain().setNodeSelection(w).updateAttributes(this.name,{width:y,height:b}).run()},onUpdate:h,options:{directions:n,min:{width:e,height:t},preserveAspectRatio:r===!0}}),g=m.dom;return g.style.visibility="hidden",g.style.pointerEvents="none",d.onload=()=>{g.style.visibility="",g.style.pointerEvents=""},m}},addCommands(){return{setImage:n=>({commands:e})=>e.insertContent({type:this.name,attrs:n})}},addInputRules(){return[pd({find:$0,type:this.type,getAttributes:n=>{const[,,e,t,r]=n;return{src:t,alt:e,title:r}}})]}}),AR=L0;const _R=Object.freeze(Object.defineProperty({__proto__:null,Image:L0,default:AR,inputRegex:$0},Symbol.toStringTag,{value:"Module"}));var I0=He.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:n=>{const e=n.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:n=>n.textAlign?{style:`text-align: ${n.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:n=>({commands:e})=>this.options.alignments.includes(n)?this.options.types.map(t=>e.updateAttributes(t,{textAlign:n})).some(t=>t):!1,unsetTextAlign:()=>({commands:n})=>this.options.types.map(e=>n.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:n=>({editor:e,commands:t})=>this.options.alignments.includes(n)?e.isActive({textAlign:n})?t.unsetTextAlign():t.setTextAlign(n):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),TR=I0;const BR=Object.freeze(Object.defineProperty({__proto__:null,TextAlign:I0,default:TR},Symbol.toStringTag,{value:"Module"}));Se.ModalEdit=Sf,Se.VForm=zt,Se.VsInputAddress=kf,Se.VsInputArray=bf,Se.VsInputArraySelect=pi,Se.VsInputCheckbox=_u,Se.VsInputCodegen=pf,Se.VsInputColor=gf,Se.VsInputContainer=Gu,Se.VsInputDate=Iu,Se.VsInputEmail=ga,Se.VsInputFile=Hu,Se.VsInputFile2=ri,Se.VsInputFile64=oi,Se.VsInputFileList=Ku,Se.VsInputInlineSelect=ii,Se.VsInputKeyValue=hf,Se.VsInputMask=qs,Se.VsInputMonaco=La,Se.VsInputNumber=Eu,Se.VsInputRadio=ba,Se.VsInputRange=yf,Se.VsInputRichtext=Zu,Se.VsInputSelect=Ba,Se.VsInputSlug=ff,Se.VsInputStatic=ma,Se.VsInputSwitcher=ha,Se.VsInputTag=uf,Se.VsInputTel=ya,Se.VsInputText=no,Se.VsInputTextArray=mf,Se.VsInputTextarea=Xu,Se.base64ToBlob=_a,Se.base64ToObjectUrl=Uu,Se.default=zt,Se.downloadBase64File=Wu,Se.fileToBase64=ju,Se.hasMapLayerPreset=Cu,Se.inputs=wf,Se.resolveMapLayerPreset=Us,Se.richtextLocaleEn=Ef,Se.richtextLocaleUk=Mf,Se.richtextMessages=Oa,Se.vsInputDatatable=Qu,Se.vsInputMap=df,Object.defineProperties(Se,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));