define(["require","exports","../.chunks/forms-B_v2vU59.amd","../.chunks/core-DJS4o9Vt.amd","vue","../utils/clipboard.amd","../utils/string.amd","../utils/route.amd","../.chunks/utils-DNzj9OOY.amd","../.chunks/dialogs.vue_vue_type_script_setup_true_lang-B3hYoW1m.amd"],(function(E,n,r,g,c,p,f,d,u,m){"use strict";if(typeof c>"u")var c=window.Vue;class S{#s;#t;#e;#a;#c;#i=[];#o=[];#n=[];#r=[];constructor(t){this.#t=t.store,this.#s=this.#t.$id,this.#e=t.options.Page,this.#a=t.options.user,this.#c=t.options.Api,this.#i=t.options.tpaNamesUrlHash||[],this.#o=t.options.tpaNamesStorage||[],this.#n=t.options.tpaNamesStorageLocal||[],this.#r=t.options.tpaNamesGuestLink||[],t.store.genGuestLink=(s,a)=>this.genGuestLink(s,a),this.#a.guest_data?.data||(this.#u(),this.#u(!0),this.#f()),this.#S(),this.#k();const e=r.debounce(()=>{this.#m(),this.#l(),this.#l(!0)});t.store.$subscribe(e)}async genGuestLink(t,e){const s=this.#g();e=Object.assign(e,Object.fromEntries(s));const a=await this.#c.gen(t).setParams(e).call();if(a?.errors)return;const i=a.result;await p.guestLinkToClipboard(i)}#g(){const t=new Map;return this.#r.forEach(e=>{const s=f.camelToSnakeCase(e);t.set(s,this.#t[e])}),t}#h(t){t.forEach((e,s)=>{const a=this.#t[s];if(e!=null&&a!==void 0&&e?.constructor&&e.constructor===a.constructor){if(s.indexOf("date")===0&&!Array.isArray(e)){if(typeof e=="string"&&!/\d\d\d\d-\d\d-\d\d/.test(e))return}this.#t[s]=e}})}#p(t){const e=new Map;return t.forEach((s,a)=>{s!==null&&(s=JSON.stringify(s),e.set(a,s))}),e}#d(t){const e=new Map;return t.forEach((s,a)=>{if(!(s==null||s==="false")){try{if(typeof s=="string"&&!/^\d\d\d\d-\d\d-\d\d$/.test(s)&&(s=JSON.parse(s)),s==null||s==="false")return}catch{}e.set(a,s)}}),e}#f(){let t;try{t=JSON.parse(d.getHash(this.#s))}catch{}if(!t)return;const e=new Map;this.#i.forEach(s=>{const a=t[s];a&&e.set(s,a)}),this.#h(e)}#m(){const t=new Map;this.#i.forEach(a=>{const i=this.#t[a];t.set(a,i)});const e=Object.fromEntries(t),s=JSON.stringify(e);d.setHash(this.#s,s)}#u(t=!1){const e=new Map;let s=this.#o,a="state:"+this.#s;t&&(s=this.#n,a="state:"+this.#s+":"+location.pathname),s.forEach(o=>{const h=localStorage.getItem(a+":"+o);e.set(o,h)});const i=this.#d(e);this.#h(i)}#l(t=!1){const e=new Map;let s=this.#o,a="state:"+this.#s;t&&(s=this.#n,a="state:"+this.#s+":"+location.pathname),s.forEach(o=>{const h=this.#t[o];e.set(o,h)});const i=this.#p(e);s.forEach(o=>{const h=i.get(o);localStorage.setItem(a+":"+o,h)})}#S(){const t=this.#a?.guest_data?.data;if(!t)return;this.#a.id===-1&&(this.#a.positionsReverseDates=t.positionsReverseDates);const e=new Map;this.#r.forEach(i=>{const o=t[i];e.set(i,o)});const s=this.#d(e);this.#h(s);const a=$(".mod_guest_title");if(this.#t.competitorsIds?.length===1&&this.#e.page.data.competitors){let i=this.#e.page.data.competitors.filter(o=>o.id===t.competitorsIds[0]);i.length&&($("a",a).attr("href","http://"+i[0].url),$("a",a).text(i[0].name))}}#k(){this.#t.regionsIndexes&&c.watch(this.#t.regionsIndexes,t=>{if(!t.length)return;t.forEach((a,i)=>t[i]=a);const e=TplProjectSelectorRegion.genSearchersMap(),s=[];e.forEach(a=>{a.regions.forEach(i=>{i.index!==-1&&s.push(i.index)})}),this.#t.regionsIndexes=t.filter(a=>s.includes(a))},{immediate:!0}),this.#t.competitorsIds&&c.watch(this.#t.competitorsIds,t=>{if(!t.length)return;t.forEach((s,a)=>t[a]=s);const e=[this.#e.page.data.project.id];this.#e.page.data.project.competitors.forEach(s=>{s.on>=0&&e.push(s.id)}),this.#t.competitorsIds=t.filter(s=>e.includes(s))},{immediate:!0})}}const k=l=>{const t=l;!t.options.tpaNamesUrlHash?.length&&!t.options.tpaNamesStorage?.length&&!t.options.tpaNamesStorageLocal?.length&&!t.options.tpaNamesGuestLink?.length||new S(t)};n.Core=r.Core,n.i18nPlugin=r.i18n,n.useI18n=r.useI18n,n.useI18nLang=r.useI18nLang,n.corePlugin=g.core,n.useAsyncTopDialog=u.useAsyncTopDialog,n.useTopDialog=u.useTopDialog,n.TopDialogWorker=m.TopDialogWorker,n.piniaTPAPlugin=k,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})}));
//# sourceMappingURL=app.amd.js.map
