2 lines
11 KiB
JavaScript
2 lines
11 KiB
JavaScript
import{S as t,i as n,a as e,b as i,k as o,s as r,p as l,n as a,g as s,q as u,m as c,o as p,j as m,e as d,c as f,d as b,f as g,l as h,r as v,u as w,v as y}from"./index-db20528a.js";import{w as k}from"./index-720c0a59.js";import{getData as x,loadLocaleContent as j,sendData as C}from"../../../../../../../../../js/libraries/serverTools.js";import{addMarkersEntries as $,translate as S}from"../../../../../../../../../js/libraries/mapTools.js";import"../../../../../../../../../js/components/map-component.js";function T(t){let n,e,o,l,a,u,c,p,m,w,y,k,x,j,L,C,$,S,T,O,A=t[7];function J(t,n){return t[14]?t[14]&&!t[8]?N:z:M}let E=J(t),U=E(t),I=G(t),R=!(t[14]&&t[8])&&H(t);return{c(){n=d("div"),e=d("button"),o=f(),l=d("div"),U.c(),a=f(),u=d("div"),c=d("label"),c.textContent="Location:",p=f(),m=d("div"),w=d("input"),y=f(),k=d("div"),x=f(),I.c(),j=f(),L=d("button"),L.textContent="Submit",C=f(),$=d("p"),S=f(),R&&R.c(),b(e,"class","close-button"),b(c,"for","address-input"),b(w,"id","address-input"),b(w,"type","text"),w.readOnly=!0,b(k,"class","ghost-input"),b(m,"class","input-wrapper"),b(u,"id","address-input-wrapper"),b(u,"class","input-label-wrapper"),b(L,"id","submit-button"),b($,"id","confirmation-msg"),b(l,"id","text-container"),b(n,"id","container")},m(r,s){i(r,n,s),g(n,e),g(n,o),g(n,l),U.m(l,null),g(l,a),g(l,u),g(u,c),g(u,p),g(u,m),g(m,w),t[33](w),g(m,y),g(m,k),g(l,x),I.m(l,null),g(l,j),g(l,L),g(l,C),g(l,$),t[38]($),g(l,S),R&&R.m(l,null),T||(O=[h(e,"click",t[13]),h(w,"input",t[34]),h(L,"click",t[17])],T=!0)},p(t,n){E===(E=J(t))&&U?U.p(t,n):(U.d(1),U=E(t),U&&(U.c(),U.m(l,a))),128&n[0]&&r(A,A=t[7])?(I.d(1),I=G(t),I.c(),I.m(l,j)):I.p(t,n),t[14]&&t[8]?R&&(R.d(1),R=null):R?R.p(t,n):(R=H(t),R.c(),R.m(l,null))},d(e){e&&s(n),U.d(),t[33](null),I.d(e),t[38](null),R&&R.d(),T=!1,v(O)}}}function z(t){let n,e,o,r;return{c(){n=d("div"),e=d("button"),e.textContent="Leave",b(n,"id","button-line")},m(l,a){i(l,n,a),g(n,e),t[30](e),t[32](n),o||(r=h(e,"click",t[31]),o=!0)},p:a,d(e){e&&s(n),t[30](null),t[32](null),o=!1,r()}}}function N(t){let n,e,o,r,l,a,u,c;return{c(){n=d("div"),e=d("button"),o=y("Move"),l=f(),a=d("button"),a.textContent="Leave",b(e,"style",r="display: "+(t[8]?"none":"initial")),b(n,"id","button-line")},m(r,s){i(r,n,s),g(n,e),g(e,o),t[25](e),g(n,l),g(n,a),t[27](a),t[29](n),u||(c=[h(e,"click",t[26]),h(a,"click",t[28])],u=!0)},p(t,n){256&n[0]&&r!==(r="display: "+(t[8]?"none":"initial"))&&b(e,"style",r)},d(e){e&&s(n),t[25](null),t[27](null),t[29](null),u=!1,v(c)}}}function M(t){let n,e,o,r,l,u;return{c(){n=d("div"),e=d("button"),e.textContent="Create",o=f(),r=d("button"),r.textContent="Join",b(n,"id","button-line")},m(a,s){i(a,n,s),g(n,e),t[20](e),g(n,o),g(n,r),t[22](r),t[24](n),l||(u=[h(e,"click",t[21]),h(r,"click",t[23])],l=!0)},p:a,d(e){e&&s(n),t[20](null),t[22](null),t[24](null),l=!1,v(u)}}}function O(t){let n,e,o,r,l;return{c(){n=d("div"),e=d("label"),e.textContent="Members:",o=f(),r=d("div"),l=d("input"),b(e,"for","members-input"),b(l,"id","members-input"),b(l,"type","text"),l.value=1,b(r,"class","input-wrapper"),b(n,"id","members-input-wrapper"),b(n,"class","input-label-wrapper")},m(a,s){i(a,n,s),g(n,e),g(n,o),g(n,r),g(r,l),t[35](l)},p:a,d(e){e&&s(n),t[35](null)}}}function A(t){let n,e,o,r,l,u,c,p,m;return{c(){n=d("div"),e=d("label"),e.textContent="Contact:",o=f(),r=d("div"),l=d("input"),u=f(),c=d("div"),b(e,"for","contact-input"),b(l,"id","contact-input"),b(l,"type","text"),b(c,"class","ghost-input"),b(r,"class","input-wrapper"),b(n,"class","input-label-wrapper")},m(a,s){i(a,n,s),g(n,e),g(n,o),g(n,r),g(r,l),t[36](l),g(r,u),g(r,c),p||(m=h(l,"input",t[37]),p=!0)},p:a,d(e){e&&s(n),t[36](null),p=!1,m()}}}function G(t){let n,e,o=0==t[7]&&O(t),r=(0==t[7]||1==t[7])&&A(t);return{c(){o&&o.c(),n=f(),r&&r.c(),e=l()},m(t,l){o&&o.m(t,l),i(t,n,l),r&&r.m(t,l),i(t,e,l)},p(t,i){0==t[7]?o?o.p(t,i):(o=O(t),o.c(),o.m(n.parentNode,n)):o&&(o.d(1),o=null),0==t[7]||1==t[7]?r?r.p(t,i):(r=A(t),r.c(),r.m(e.parentNode,e)):r&&(r.d(1),r=null)},d(t){o&&o.d(t),t&&s(n),r&&r.d(t),t&&s(e)}}}function H(t){let n,e;return{c(){n=d("map-component"),w(n,"id","map"),w(n,"callback",e=t[39])},m(t,e){i(t,n,e)},p(t,i){1024&i[0]&&e!==(e=t[39])&&w(n,"callback",e)},d(t){t&&s(n)}}}function J(t){let n,e=3==t[9]&&T(t);return{c(){e&&e.c(),n=l()},m(t,o){e&&e.m(t,o),i(t,n,o)},p(t,i){3==t[9]?e?e.p(t,i):(e=T(t),e.c(),e.m(n.parentNode,n)):e&&(e.d(1),e=null)},d(t){e&&e.d(t),t&&s(n)}}}function E(t){let n,e=t[9],o=J(t);return{c(){o.c(),n=l(),this.c=a},m(t,e){o.m(t,e),i(t,n,e)},p(t,i){512&i[0]&&r(e,e=t[9])?(o.d(1),o=J(t),o.c(),o.m(n.parentNode,n)):o.p(t,i)},i:a,o:a,d(t){t&&s(n),o.d(t)}}}function U(t,n,e){let i=L.latLng(n,e);t.setLatLng(i)}function I(t){t.nextElementSibling.innerHTML=t.value}function R(t,n,e){let i,o,{map:r=null}=n,l=k(0);u(t,l,(t=>e(9,i=t)));let a,s,d,f,b,g=k({});u(t,g,(t=>e(10,o=t)));let h,v,w,y;x("/assets/groups.json",(t=>{a=JSON.parse(t),s={};for(let t of a){let n=t.country;null==t.contact&&(t.contact="https://discord.gg/Qk8KUk787z"),n in s?s[n].push(t):s[n]=[t]}l.update((t=>t+1))}));let T=["","",""],z={},N=function(t,n){let e=new L.Icon({iconUrl:"/img/common/markers/marker-black.png",shadowUrl:"https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png",iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],shadowSize:[41,41]});return L.marker([t,n],{icon:e})}(0,0);N.setOpacity(0);let M,O=[],A=c("profile-component"),G=A.closeGroupsAdd,H=A.maps,J=A.onLoadedGroups,E=A.userGroups,R=A.user,_=0!=E.length,q=_?2:0;_&&(M=null!=E[0].status,M&&(q=3));let D=j(g,"groups-component",l);function K(t,n){x(`https://nominatim.openstreetmap.org/reverse?lat=${t}&lon=${n}&format=jsonv2`,(t=>{let n=(t=JSON.parse(t)).address,i=n.city||n.town||n.village||n.hamlet,o=n.state,r=n.country;null!=o?r+=", "+o:o="",null!=i?r+=", "+i:i="",e(3,v.value=r,v),I(v)}))}function Q(t,n){x(`https://nominatim.openstreetmap.org/reverse?lat=${t}&lon=${n}&format=jsonv2&accept-language=en`,(t=>{let n=(t=JSON.parse(t)).address;if(null!=n){let t=n.city||n.town||n.village||n.hamlet,e=n.state,i=n.country;null!=e||(e=""),null!=t||(t=""),T=[i,e,t]}}))}function Y(t,n,e){let i,o="<b>"+n.Group+"</b><br>";for(let r of["location","members","contact"]){let l=n[r]+": ";if("contact"==r)o+=l+"<a href='"+t.contact+"' target='_blank' rel=noreferrer>"+t.contact+"</a>";else if("location"==r){let r,a=[t.country,t.state,t.town].filter((t=>null!=t&&null!=t));r="en"==e?a.map((t=>t)).join(", "):a.map((t=>S(n,t))).join(", "),o+=l+r+"<br>",i=[t.latitude,t.longitude]}else o+=l+t[r]+"<br>"}return{text:o,coordinates:i}}function B(t,n,i){e(19,r=t([22,0],2)),H.groupsAdd=r,$(a,s,r,n,i,Y,"green",{enableCountryGrouping:!1,pinCallback:P}),N.addTo(r),r.on("click",(function(t){if(0==q){let n=t.latlng.lat,e=t.latlng.lng;z.latitude=n,z.longitude=e,z.id=null,U(N,n,e),N.setOpacity(1),K(n,e),Q(n,e)}}))}function F(t){!1!==t?(0!=q||R.verified?e(2,h.innerHTML="Success!",h):e(2,h.innerHTML="You have been added to our database! Now go to our Discord to verify yourself.",h),e(2,h.style.color="green",h),0!=q&&1!=q||(E[0]={}),E[0].country=""==T[0]?null:T[0],E[0].state=""==T[1]?null:T[1],E[0].town=""==T[2]?null:T[2],E[0].members=z.members,J()):(e(2,h.innerHTML="Something went wrong.",h),e(2,h.style.color="red",h))}function P(t,n){if(1==q){let e=n.latlng.lat,i=n.latlng.lng;z.latitude=e,z.longitude=i,z.id=t.id,z.members=t.members,U(N,e,i),N.setOpacity(1),K(e,i),Q(e,i)}}function V(t){for(let t of O)null!=t&&(t.style.background="rgba(197, 43, 40, 0.319)",t.style.color="black");e(6,O[t].style.background="rgb(197, 43, 40)",O),e(6,O[t].style.color="white",O),e(7,q=t)}function W(){if(3==i)V(q),2!=q&&3!=q||e(3,v.value=function(t){if(null!=t)return[t.country,t.state,t.town].filter((t=>null!=t)).map((t=>"en"==D?t:S(o,t))).join(", ");return"Create or join group"}(E[0]),v);else{setTimeout((()=>W()),100)}}j(g,"countries",l),p((()=>{W()}));return t.$$set=t=>{"map"in t&&e(19,r=t.map)},[f,b,h,v,w,y,O,q,M,i,o,l,g,G,_,D,B,function(){if(""!=T[0]||3==q){let t,n;0==q?(t=y.value,n=w.value):1==q?n=w.value:2==q||3==q?(t="",n=""):3==q&&(t="",n="",T=[null,null,null],z.latitude=null,z.longitude=null),d={country:T[0],state:T[1],town:T[2],latitude:z.latitude,longitude:z.longitude,contact:""==n?null:n,members:""==t?null:parseInt(t),group_id:z.id,mode:q},""==d.state&&(d.state=null),""==d.town&&(d.town=null),C("/"+D+"/groups-add-post/",d,F)}},V,r,function(t){m[t?"unshift":"push"]((()=>{O[0]=t,e(6,O)}))},()=>V(0),function(t){m[t?"unshift":"push"]((()=>{O[1]=t,e(6,O)}))},()=>V(1),function(t){m[t?"unshift":"push"]((()=>{b=t,e(1,b)}))},function(t){m[t?"unshift":"push"]((()=>{O[2]=t,e(6,O)}))},()=>V(2),function(t){m[t?"unshift":"push"]((()=>{O[3]=t,e(6,O)}))},()=>V(3),function(t){m[t?"unshift":"push"]((()=>{f=t,e(0,f)}))},function(t){m[t?"unshift":"push"]((()=>{O[3]=t,e(6,O)}))},()=>V(3),function(t){m[t?"unshift":"push"]((()=>{f=t,e(0,f)}))},function(t){m[t?"unshift":"push"]((()=>{v=t,e(3,v)}))},()=>I(v),function(t){m[t?"unshift":"push"]((()=>{y=t,e(5,y)}))},function(t){m[t?"unshift":"push"]((()=>{w=t,e(4,w)}))},()=>I(w),function(t){m[t?"unshift":"push"]((()=>{h=t,e(2,h)}))},t=>B(t,o,D)]}class _ extends t{constructor(t){super(),this.shadowRoot.innerHTML="<style>@import '/css/common.css';#button-line{position:relative;width:fit-content;margin:auto;margin-top:1.5rem}#button-line button{font-family:var(--sans-serif,sans-serif);font-size:1.15rem;padding:1rem 0;width:7rem}#button-line :first-child{border-top-left-radius:1rem;border-bottom-left-radius:1rem;margin-right:0.1rem}#button-line :last-child{margin-left:0.1rem;border-top-right-radius:1rem;border-bottom-right-radius:1rem}.close-button{position:absolute;top:2rem;right:0rem;width:2rem;height:2rem;border:none;cursor:pointer;z-index:2}.close-button:hover{opacity:0.7}.close-button::before,.close-button::after{content:\"\";position:absolute;top:50%;left:50%;width:0.2rem;height:2rem;background-color:#000;border-radius:1rem}.close-button::before{transform:translate(-50%, -50%) rotate(45deg)}.close-button::after{transform:translate(-50%, -50%) rotate(-45deg)}#confirmation-msg{margin-top:0.5rem;margin-bottom:2rem}label{display:inline-block;font-family:var(--serif,serif);font-size:1.15rem;line-height:160%;color:#222222;width:6rem}input,.ghost-input{font-size:1.15rem;font-family:var(--serif,serif)}input{height:2.5rem;display:inline-block;position:relative}#address-input,#contact-input{width:100%}#address-input-wrapper{margin-top:2rem;margin-bottom:1rem}#members-input-wrapper{margin-bottom:1rem}#members-input{width:5rem}.ghost-input{display:block;visibility:hidden;height:0;padding-left:0.5rem;padding-right:0.5rem}.input-wrapper{display:inline-block;max-width:calc(100% - 5.5rem);min-width:min(20rem, calc(100% - 5.5rem));height:2.5rem}.input-label-wrapper{display:flex;justify-content:start}.input-label-wrapper label{position:relative;top:0.3rem}#submit-button{display:block;margin:auto;margin-top:2rem;padding:1rem 2rem;font-size:1.4rem;font-family:var(--sans-serif,sans-serif);border:0rem solid black;border-radius:0.5rem;background:#cb1816;color:white}#map{--height:30rem;--width:100%;--margin-top:2rem;--margin-bottom:0.5rem}#text-container{position:relative;max-width:calc(100vw - 4rem);margin:auto}#container{margin:auto;max-width:800px;margin-top:1rem;margin-bottom:4rem}#container p{text-align:justify}</style>",n(this,{target:this.shadowRoot,props:e(this.attributes),customElement:!0},R,E,r,{map:19},null,[-1,-1]),t&&(t.target&&i(t.target,this,t.anchor),t.props&&(this.$set(t.props),o()))}static get observedAttributes(){return["map"]}get map(){return this.$$.ctx[19]}set map(t){this.$$set({map:t}),o()}}customElements.define("groups-add-component",_);export{_ as default};
|