const S = Symbol(); const BUTTON_STYLE = ` input[type="button"], input[type="submit"] { padding: 12px 16px; cursor: pointer; border: none; border-width: 1px; border-radius: 5px; font-size: 14px; font-weight: 400; box-shadow: 0 10px 20px -6px rgba(0,0,0,.12); position: relative; margin-bottom: 20px; transition: .3s; background: #46b5d1; color: #fff; display: inline-block; font-weight: 400; text-align: center; vertical-align: middle; user-select: none; padding: .375rem .75rem; font-size: 1rem; line-height: 1.5; transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out, width: auto; height: calc(1.5em + 0.75rem + 2px); padding: .375rem .75rem; border: 1px solid #495057; color: #495057; background: white; } `; const FORM_STYLE = ` form { display: block; } form legend { margin: 16px 0; font-weight: bold; font-size: 20px; } form.inline div { display: flex; } form > div { display: block; margin-bottom: 1rem; } input, textarea { font-size: 16px; border: none; border-bottom-style: none; border-bottom-width: medium; border-bottom: 1px solid rgba(0,0,0,.1); border-radius: 2px; padding: 0; height: 36px; background: #fff; color: rgba(0,0,0,.8); font-size: 14px; box-shadow: none !important; display: block; width: 100%; height: calc(1.5em + 0.75rem + 2px); padding: .375rem .75rem; font-size: 1rem; font-weight: 400; line-height: 1.5; color: #495057; background-clip: padding-box; transition: border-color .15s ease-in-out , -webkit-box-shadow .15s ease-in-out; transition: border-color .15s ease-in-out , box-shadow .15s ease-in-out; transition: border-color .15s ease-in-out , box-shadow .15s ease-in-out , -webkit-box-shadow .15s ease-in-out; } input[type="text"], input[type="number"], input[type="email"], input[type="password"], textarea { width: calc(100% - 1.5rem - 2px); } label { color: #000; text-transform: uppercase; font-size: 12px; font-weight: 600; display: inline-block; margin-bottom: .5rem; } ${BUTTON_STYLE} `; class PseudoForm extends HTMLElement { reportValidity() { return this[S].querySelector("form").reportValidity(); } checkValidity() { return this[S].querySelector("form").checkValidity(); } get elements() { return this[S].querySelector("form").elements; } } const fireFbReady = ()=>{ for (let c of (!0, a))c(); }; let a = []; customElements.define("form-navigation", class extends HTMLElement { #a; static get observedAttributes() { return [ "next", "prev" ]; } constructor(){ super(); let b = this.#a = this.attachShadow({ mode: "closed" }); b.innerHTML = `
`, b.querySelector("#prev").addEventListener("click", (a)=>{ a.stopPropagation(), a.preventDefault(), this.prev(); }), b.querySelector("#next").addEventListener("click", (a)=>{ a.stopPropagation(), a.preventDefault(), this.next(); }); } attributeChangedCallback(a, b, c) { if (b !== c) switch(a){ case "next": this.#a.querySelector("#next").className = "hidden" === c ? "hidden" : ""; break; case "prev": this.#a.querySelector("#prev").className = "hidden" === c ? "hidden" : ""; } } next() { this.dispatchEvent(new CustomEvent("form:next", { bubbles: !0, composed: !0, detail: this.parentElement })); } prev() { this.dispatchEvent(new CustomEvent("form:prev", { bubbles: !0, composed: !0, detail: this.parentElement })); } }); customElements.define("local-business-item", class extends HTMLElement { #a; static get observedAttributes() { return [ "name", "price" ]; } constructor(){ super(); let a = this.#a = this.attachShadow({ mode: "closed" }); a.innerHTML = `

`; } connectedCallback() { this.#a.querySelector("#name").textContent = this.getAttribute("name"), this.#a.querySelector("#price").value = this.price(); } attributeChangedCallback(a, b, c) { if (b !== c) switch(a){ case "name": return this.#a.querySelector("#name").textContent = c; case "price": return this.#a.querySelector("#price").value = c; } } price(a) { let b = parseInt(a || this.getAttribute("price")); return isNaN(b) ? 0 : b; } }); customElements.define("local-business", class extends HTMLElement { #a; static get observedAttributes() { return [ "name", "service-id", "state" ]; } constructor(){ super(); let a = this.#a = this.attachShadow({ mode: "closed" }); a.innerHTML = `

`; } connectedCallback() { this.#a.querySelector("#name").textContent = this.getAttribute("name"); } attributeChangedCallback(a, b, c) { if (b !== c && "name" === a) return this.#a.querySelector("#name").textContent = c; } get name() { return this.getAttribute("name") || ""; } }); customElements.define("local-businesses", class extends HTMLElement { #a; static get observedAttributes() { return [ "filter" ]; } constructor(){ super(); let a = this.#a = this.attachShadow({ mode: "closed" }); a.innerHTML = `
`; { let b = a.querySelector("#filter"), c = null; b.addEventListener("change", (a)=>{ a.stopPropagation(), this.filter = a.target.value; }), b.addEventListener("keyup", (a)=>{ a.stopPropagation(); let b = a.target.value; c && clearTimeout(c), c = setTimeout(()=>{ this.filter = b, c = null; }, 1000 / 3); }); } } connectedCallback() { this.filter = this.getAttribute("filter"); } attributeChangedCallback(a, b, c) { if (b !== c && "filter" === a) return this.filter = c; } get filter() { return this.getAttribute("filter"); } set filter(a) { if (a && "" !== a) for (let b of (this.setAttribute("filter", a), this.querySelectorAll("local-service")))b.name && (b.name.includes(a) ? b.setAttribute("local-services-visible", "visible") : b.setAttribute("local-services-visible", "invisible")); else for (let c of (this.removeAttribute("filter"), this.querySelectorAll("local-service")))c.removeAttribute("local-services-visible"); } }); customElements.define("login-form", class extends HTMLElement { #a; static get observedAttributes() { return []; } constructor(){ super(); let b = this.#a = this.attachShadow({ mode: "closed" }); b.innerHTML = `
`; } connectedCallback() {} attributeChangedCallback(a, b, c) { if (b === c) return; } }); customElements.define("ow-account", class extends HTMLElement { #a; static get observedAttributes() { return [ "mode", "id", "name", "email", "facebook-id" ]; } constructor(){ super(); let b = this.#a = this.attachShadow({ mode: "closed" }); b.innerHTML = `
Nie masz konta? Utwórz nowe
Masz konta? Zaloguj się
`, b.querySelector("#switch-login > a").addEventListener("click", (a)=>{ a.stopPropagation(), a.preventDefault(), this.mode = "login"; }), b.querySelector("#switch-register > a").addEventListener("click", (a)=>{ a.stopPropagation(), a.preventDefault(), this.mode = "register"; }); } connectedCallback() { "" === this.mode && (this.mode = "login"); } attributeChangedCallback(a, b, c) { if (b !== c) switch(a){ case "mode": this.mode = c; break; case "id": this.id = c; break; case "name": this.name = c; break; case "email": this.email = c; break; case "facebook-id": this.facebook_id = c; } } get mode() { return this.getAttribute("mode") || ""; } set mode(a) { a = [ "login", "register", "display" ].includes(a) ? a : "login", this.setAttribute("mode", a); } get name() { return this.getAttribute("name") || ""; } set name(a) { this.setAttribute("name", a), this.#a.querySelector("#display #name").value = a; } get email() { return this.getAttribute("email") || ""; } set email(a) { this.setAttribute("email", a), this.#a.querySelector("#display #email").value = a; } get facebook_id() { return this.getAttribute("facebook-id"); } set facebook_id(a) { this.setAttribute("facebook-id", a), this.#a.querySelector("#display #facebook_id").value = a; } }); customElements.define("ow-nav", class extends HTMLElement { #a; constructor(){ super(); let a = this.#a = this.attachShadow({ mode: "closed" }); a.innerHTML = `
`; } }); customElements.define("ow-path", class extends HTMLElement { #a; static get observedAttributes() { return [ "selected", "path" ]; } constructor(){ super(); let a = this.#a = this.attachShadow({ mode: "closed" }); a.innerHTML = ` `; } connectedCallback() { this.selected = this.getAttribute("selected"); } attributeChangedCallback(a, b, c) { if (b !== c) switch(a){ case "selected": return this.selected = c; case "path": return this.path = c; } } get selected() { return "selected" === this.getAttribute("selected"); } set selected(a) { "selected" === a ? this.setAttribute("selected", "selected") : this.removeAttribute("selected"); } get path() { return this.getAttribute("path") || ""; } set path(a) { if (!a || "" === a) { this.removeAttribute("path"); return; } this.setAttribute("path", a), this.#a.querySelector("a").setAttribute("href", a); } }); customElements.define("price-view", class extends HTMLElement { #a; static get observedAttributes() { return [ "value", "currency" ]; } constructor(){ super(); let a = this.#a = this.attachShadow({ mode: "closed" }); a.innerHTML = ` `; } connectedCallback() { this.#a.querySelector("#price").textContent = this.formatted; } attributeChangedCallback(a, b, c) { b !== c && "price" === a && (this.value = c); } get formatted() { let a = this.value, b = a % 100; return `${Math.ceil(a / 100)},${b < 10 ? `0${b}` : b}${this.currency}`; } get value() { let a = parseInt(this.getAttribute("value")); return isNaN(a) ? 0 : a; } set value(a) { this.setAttribute("value", a), this.#a.querySelector("#price").textContent = this.formatted; } get currency() { return this.getAttribute("currency") || "PLN"; } }); customElements.define("price-input", class extends HTMLElement { #a; static get observedAttributes() { return [ "value", "currency", "required", "name" ]; } constructor(){ super(); let b = this.#a = this.attachShadow({ mode: "closed" }); b.innerHTML = `
`; let c = b.querySelector("#price"); c.addEventListener("change", (a)=>{ a.stopPropagation(), this.value = c.value; }); } connectedCallback() { this.#a.querySelector("#currency").textContent = this.currency, this.#a.querySelector("#price").value = this.value; } attributeChangedCallback(a, b, c) { if (b === c) return; let d = this.#a.querySelector("#price"); switch(a){ case "price": this.value = c; break; case "currency": this.currency = c; break; case "required": c ? d.setAttribute("required", "required") : d.removeAttribute("required"); break; case "readonly": c ? d.setAttribute("readonly", "readonly") : d.removeAttribute("readonly"); break; case "name": this.setAttribute("name", c); } } get value() { return Math.floor(100 * parseFloat(this.#a.querySelector("#price").value)); } set value(a) { this.setAttribute("value", a), this.#a.querySelector("#price").value = a; } get currency() { return this.getAttribute("currency") || "PLN"; } set currency(a) { this.setAttribute("currency", a), this.#a.querySelector("#currency").textContent = this.currency; } reportValidity() { return this.#a.querySelector("input").reportValidity(); } get name() { return this.getAttribute("name"); } set name(a) { this.setAttribute("name", a); } }); customElements.define("register-basic-form", class extends PseudoForm { #a; constructor(){ super(); let b = this.#a = this.attachShadow({ mode: "closed" }); b.innerHTML = `
`; let c = b.querySelector("form"); c.addEventListener("submit", (a)=>{ a.preventDefault(), a.stopPropagation(), b.querySelector("form-navigation").next(); }); } }); customElements.define("register-item-form-row", class extends PseudoForm { #a; static get observedAttributes() { return [ "idx", "name" ]; } constructor(){ super(), this.#a = this.attachShadow({ mode: "closed" }), this.addEventListener("item:removed", ()=>{ this.setAttribute("removed", "removed"); let a = this.parentElement; this.remove(), a.dispatchEvent(new CustomEvent("item:removed", { bubbles: !0, composed: !0 })); }); } connectedCallback() { let b = this.idx; this.#a.innerHTML = `
`; let c = this.#a.querySelector("image-input"); this.addEventListener("image-input:uploaded", (a)=>{ a.preventDefault(), a.stopPropagation(), this.picture_url = c.url; }), this.#a.querySelector("form").addEventListener("submit", (a)=>{ a.preventDefault(), a.stopPropagation(), this.reportValidity(); }), this.#a.querySelector(".remove").addEventListener("click", (a)=>{ a.preventDefault(), a.stopPropagation(), this.dispatchEvent(new CustomEvent("item:removed", { bubbles: !0, composed: !1 })); }); } attributeChangedCallback(a, b, c) { if (b !== c) switch(a){ case "idx": return this.updateNames(); case "picture-url": return this.picture_url = c; } } get inputs() { return [ c(this.#a.querySelector(".item-name")), c(this.#a.querySelector(".item-price")), ]; } updateNames() { let a = this.getAttribute("idx"); for (let b of this.#a.querySelectorAll(".field")){ let c = b.id; b.querySelector("input, price-input").setAttribute("name", `items[${a}][${c}]`); } } get idx() { return this.getAttribute("idx"); } set idx(a) { this.setAttribute("idx", a); } get picture_url() { return this.getAttribute("picture-url"); } set picture_url(a) { this.setAttribute("picture-url", a), this.#a.querySelector("image-input").url = a, this.#a.querySelector("#picture_url").value = a; } reportValidity() { return super.reportValidity() && this.#a.querySelector("price-input").reportValidity(); } }); let c = ({ name: a , value: b })=>({ name: a, value: b }); let c1 = (a)=>{ let b = 0; for (let c of a.querySelectorAll("register-item-form-row"))c.idx = b++; return b; }; customElements.define("register-items-form", class extends PseudoForm { #a; static get observedAttributes() { return []; } constructor(){ super(); let b = this.#a = this.attachShadow({ mode: "closed" }); b.innerHTML = `
`, this.addEventListener("item:removed", (a)=>{ a.stopPropagation(), c1(this); }), this.addEventListener("form:next", (a)=>{ for (let b of this.querySelectorAll("item-form-row"))b.reportValidity() || (a.stopPropagation(), a.preventDefault()); }), b.querySelector("#add-item").addEventListener("click", (a)=>{ a.stopPropagation(), a.preventDefault(), this.appendChild(document.createElement("register-item-form-row")), c1(this); }); } get inputs() { return [ ...this.querySelectorAll("register-item-form-row") ].map((a)=>a.inputs); } }); customElements.define("register-business-form", class extends PseudoForm { #a; constructor(){ super(); let b = this.#a = this.attachShadow({ mode: "closed" }); b.innerHTML = `
`, b.querySelector("form").addEventListener("submit", (a)=>{ a.preventDefault(), a.stopPropagation(), b.querySelector("form-navigation").next(); }); } }); customElements.define("register-submit-form", class extends PseudoForm { #a; constructor(){ super(); let b = this.#a = this.attachShadow({ mode: "closed" }); b.innerHTML = `
`; } updateField(a, b) { this.#a.querySelector(`[id="hidden-${a}"]`).value = b, this.#a.querySelector(`[id="preview-${a}"]`).value = b; } setItems(a) { let b = this.#a.querySelector("#items"); for (let c of (b.innerHTML = "", a)){ let d = b.appendChild(document.createElement("div")); d.className = "item-view"; let [e, f] = c; d.innerHTML = ` `; } } set accountType(a) { this.#a.querySelector("#account_type").value = a; } }); customElements.define("register-user-type", class extends HTMLElement { #a; constructor(){ super(); let a = this.#a = this.attachShadow({ mode: "closed" }); a.innerHTML = `
`; let b = a.querySelector("#user"); b.addEventListener("click", (a)=>{ a.preventDefault(), a.stopPropagation(), this.dispatchEvent(new CustomEvent("account:type:user", { bubbles: !0, composed: !0 })); }); let c = a.querySelector("#local-service"); c.addEventListener("click", (a)=>{ a.preventDefault(), a.stopPropagation(), this.dispatchEvent(new CustomEvent("account:type:local-service", { bubbles: !0, composed: !0 })); }); } }); customElements.define("register-user-form", class extends HTMLElement { #a; static get observedAttributes() { return [ "mode" ]; } constructor(){ super(); let b = this.#a = this.attachShadow({ mode: "closed" }); b.innerHTML = `
`; let c = b.querySelector("form"); b.querySelector("#fb-icon").addEventListener("click", (a)=>{ a.stopPropagation(), a.preventDefault(), this.mode = "facebook", FB.login((a)=>{ "connected" === a.status && FB.api("/me?fields=id,name,email", ({ id: a , name: b , email: d , ...e })=>{ console.log(a, b, d, e), c.querySelector("#email").value = d, c.querySelector("#login").value = b, c.querySelector("#password").value = crypto.randomUUID(), c.querySelector("#facebook_id").value = a, c.submit(); }); }, { scope: "public_profile,email", return_scopes: !0 }); }), b.querySelector("#email-icon").addEventListener("click", (a)=>{ a.stopPropagation(), a.preventDefault(), this.mode = "email"; }); } connectedCallback() { this.mode = ""; } attributeChangedCallback(a, b, c) { b !== c && "mode" === a && ("email" === c || "facebook" === c || "" === c) && (this.mode = c); } get mode() { return this.getAttribute("mode") || ""; } set mode(a) { this.setAttribute("mode", a); } }); customElements.define("register-form", class extends HTMLElement { static get observedAttributes() { return [ "step" ]; } constructor(){ super(); let c = this[S] = this.attachShadow({ mode: "closed" }); c.innerHTML = `
`; let d = c.querySelector("#step-4"); this[S].addEventListener("account:type:user", (a)=>{ a.stopPropagation(), d.accountType = "User", this.step = 40; }), this[S].addEventListener("account:type:local-service", (a)=>{ a.stopPropagation(), d.accountType = "Business", this.step = 1; }), this[S].addEventListener("form:next", (a)=>{ a.stopPropagation(); let b = c.querySelector(`#step-${this.step}`); this.#a(b, d) && (this.step = this.step + 1); }), this[S].addEventListener("form:prev", (a)=>{ a.stopPropagation(), this.step = this.step - 1; }), d.addEventListener("submit", (a)=>{ a.preventDefault(), a.stopPropagation(); }); } connectedCallback() { this.step = 0; } attributeChangedCallback(a, b, c) { if (b === c) return; } get step() { let a = parseInt(this.getAttribute("step")); return isNaN(a) ? 1 : a; } set step(a) { a < 0 || this.setAttribute("step", a); } #a(c, d) { for (let e of (c.reportValidity(), c.elements))if ("" !== e.name && !e.reportValidity()) return !1; let f = c.inputs; if (f) d.setItems(f); else for (let g of c.elements)"" !== g.name && d.updateField(g.name, g.value); return !0; } }); customElements.define("image-input", class extends HTMLElement { #a; static get observedAttributes() { return [ "width", "height", "account-id", "url" ]; } constructor(){ super(); let b = this.#a = this.attachShadow({ mode: "closed" }); b.innerHTML = `
`, b.querySelector("#save").addEventListener("click", (a)=>{ a.preventDefault(), a.stopPropagation(); let b = document.createElement("canvas"); b.width = this.width, b.height = this.height, b.getContext("2d").putImageData(h.getImageData(0, 0, this.width, this.height), 0, 0); let c = atob(b.toDataURL("image/webp", 1.0).split(",")[1]), d = []; for(let e = 0; e < c.length; e++)d.push(c.charCodeAt(e)); let f = new Blob([ new Uint8Array(d) ], { type: "image/webp" }), g = new FormData; g.append(`${crypto.randomUUID()}.webp`, f), fetch("/upload", { method: "POST", body: g }).then((a)=>a.json()).then(({ path: a })=>{ this.url = a, this.dispatchEvent(new CustomEvent("image-input:uploaded", { bubbles: !0, composed: !0 })); }); }); let c = new FileReader(), d = b.querySelector("#file"), e = b.querySelector("#view"), f = b.querySelector("img"), g = b.querySelector("canvas"), h = g.getContext("2d"); f.addEventListener("load", ()=>{ let a, b; f.width > f.height ? (a = 200, b = 200 * f.height / f.width) : (a = 200 * f.width / f.height, b = 200), this.setAttribute("width", a), this.setAttribute("height", b), f.width = a, f.height = b, h.clearRect(0, 0, 200, 200), h.drawImage(f, 0, 0, a, b); }), d.addEventListener("change", (a)=>{ a.stopPropagation(), c.addEventListener("loadend", (a)=>{ a.total === a.loaded && (f.src = a.target.result || ""); }), c.readAsDataURL(a.target.files[0]); }), e.addEventListener("click", (a)=>{ a.stopPropagation(), d.click(); }); } connectedCallback() { this.account_id = this.account_id, this.url = this.url; } attributeChangedCallback(a, b, c) { if (b !== c) switch(a){ case "account-id": return this.account_id = c; case "url": return this.url = c; } } get account_id() { return this.getAttribute("account-id"); } set account_id(a) { this.setAttribute("account-id", a); } get width() { let a = parseInt(this.getAttribute("width")); return isNaN(a) ? 0 : a; } get height() { let a = parseInt(this.getAttribute("height")); return isNaN(a) ? 0 : a; } get url() { return this.getAttribute("url"); } set url(a) { this.setAttribute("url", a), this.#a.querySelector("img").src = a; } }); customElements.define("business-item", class extends HTMLElement { #a; static get observedAttributes() { return [ "item-id", "name", "price", "picture-url", "item-order" ]; } constructor(){ super(); let a = this.#a = this.attachShadow({ mode: "closed" }); a.innerHTML = `
`; let b = a.querySelector("image-input"); this.addEventListener("image-input:uploaded", (c)=>{ c.preventDefault(), c.stopPropagation(), this.picture_url = b.url; let d = a.querySelector("form"); d.querySelector("#id").value = this.item_id, d.querySelector("#name").value = this.name, d.querySelector("#price").value = this.price, d.querySelector("#picture_url").value = this.picture_url, d.querySelector("#item_order").value = this.item_order, d.submit(); }); } connectedCallback() { this.item_id = this.item_id, this.name = this.name, this.price = this.price, this.picture_url = this.picture_url; } attributeChangedCallback(a, b, c) { if (b !== c) switch(a){ case "item-id": return this.item_id = c; case "name": return this.name = c; case "price": return this.price = c / 100.0; case "picture-url": return this.picture_url = c; } } get item_id() { return this.getAttribute("item-id"); } set item_id(a) { this.setAttribute("item-id", a); } get item_order() { return this.getAttribute("item-order"); } set item_order(a) { this.setAttribute("item-order", a); } get name() { return this.getAttribute("name"); } set name(a) { this.setAttribute("name", a), this.#a.querySelector("#name").textContent = a; } get price() { return this.#a.querySelector("price-input").value; } set price(a) { this.setAttribute("price", a), this.#a.querySelector("price-input").value = a; } get picture_url() { return this.getAttribute("picture-url"); } set picture_url(a) { this.setAttribute("picture-url", a), this.#a.querySelector("image-input").url = a; } }); customElements.define("business-items", class extends HTMLElement { #a; constructor(){ super(); let a = this.#a = this.attachShadow({ mode: "closed" }); a.innerHTML = ` `; } }); if (!document.querySelector("#facebook-jssdk")) { window.fbAsyncInit = ()=>{ FB.init({ appId: "1293538251053124", cookie: !0, xfbml: !0, version: "v14.0" }), FB.AppEvents.logPageView(), fireFbReady(); }; let b = document.createElement("script"); b.id = "facebook-jssdk", b.src = "https://connect.facebook.net/en_US/sdk.js", document.head.appendChild(b); }