Coffee journaling on ATProto (alpha) alpha.arabica.social
coffee

fix: page fixes #2

closed opened by pdewey.com targeting main from refactor-svelte
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:hm5f3dnm6jdhrc55qp2npdja/sh.tangled.repo.pull/3mdercwj6h222
+384 -3160
Diff #0
+18 -9
CLAUDE.md
··· 7 7 - **Language:** Go 1.21+ 8 8 - **HTTP:** stdlib `net/http` with Go 1.22 routing 9 9 - **Storage:** AT Protocol PDS (user data), BoltDB (sessions/feed registry) 10 - - **Frontend:** HTMX + Alpine.js + Tailwind CSS 11 - - **Templates:** html/template 10 + - **Frontend:** Svelte SPA with client-side routing 11 + - **Legacy:** HTMX partials still used for some dynamic content (being phased out) 12 12 - **Logging:** zerolog 13 13 14 14 ## Project Structure ··· 26 26 public_client.go # Unauthenticated public API access 27 27 nsid.go # Collection NSIDs and AT-URI builders 28 28 handlers/ 29 - handlers.go # HTTP handlers for all routes 29 + handlers.go # HTTP handlers (API endpoints + HTMX partials) 30 30 auth.go # OAuth login/logout/callback 31 31 bff/ 32 - render.go # Template rendering helpers 32 + render.go # Legacy template rendering (HTMX partials only) 33 33 helpers.go # View helpers (formatting, etc.) 34 34 database/ 35 35 store.go # Store interface definition ··· 43 43 logging.go # Request logging middleware 44 44 routing/ 45 45 routing.go # Router setup and middleware chain 46 + frontend/ # Svelte SPA source code 47 + src/ 48 + routes/ # Page components 49 + components/ # Reusable components 50 + stores/ # Svelte stores (auth, cache) 51 + lib/ # Utilities (router, API client) 52 + public/ # Built SPA assets 46 53 lexicons/ # AT Protocol lexicon definitions (JSON) 47 - templates/ # HTML templates 48 - web/static/ # CSS, JS, manifest 54 + templates/partials/ # Legacy HTMX partial templates (being phased out) 55 + web/static/ # Static assets (CSS, icons, service worker) 56 + app/ # Built Svelte SPA 49 57 ``` 50 58 51 59 ## Key Concepts ··· 83 91 84 92 1. Request hits middleware (logging, auth check) 85 93 2. Auth middleware extracts DID + session ID from cookies 86 - 3. Handler creates `AtprotoStore` scoped to user 87 - 4. Store methods make XRPC calls to user's PDS 88 - 5. Results rendered via BFF templates or returned as JSON 94 + 3. For SPA routes: Serve index.html (client-side routing) 95 + 4. For API routes: Handler creates `AtprotoStore` scoped to user 96 + 5. Store methods make XRPC calls to user's PDS 97 + 6. Results returned as JSON (for SPA) or HTML fragments (legacy HTMX partials) 89 98 90 99 ### Caching 91 100
+10 -5
frontend/src/App.svelte
··· 43 43 currentRoute = BrewForm; 44 44 params = { mode: "create" }; 45 45 }) 46 - .on("/brews/:id", (routeParams) => { 47 - currentRoute = BrewView; 48 - params = routeParams; 49 - }) 50 46 .on("/brews/:id/edit", (routeParams) => { 51 47 currentRoute = BrewForm; 52 48 params = { ...routeParams, mode: "edit" }; 53 49 }) 50 + .on("/brews/:did/:rkey", (routeParams) => { 51 + currentRoute = BrewView; 52 + params = routeParams; 53 + }) 54 + .on("/brews/:id", (routeParams) => { 55 + currentRoute = BrewView; 56 + params = routeParams; 57 + }) 54 58 .on("/manage", () => { 55 59 currentRoute = Manage; 56 60 params = {}; ··· 72 76 params = {}; 73 77 }); 74 78 75 - // Start router 79 + // Start router and resolve current path 76 80 router.listen(); 81 + router.route(window.location.pathname); 77 82 }); 78 83 </script> 79 84
+14 -1
frontend/src/components/FeedCard.svelte
··· 39 39 </div> 40 40 41 41 <!-- Action header --> 42 - <div class="mb-2 text-sm text-brown-700">{item.Action}</div> 42 + <div class="mb-2 text-sm text-brown-700"> 43 + {#if item.RecordType === 'brew' && item.Brew} 44 + <span>added a </span> 45 + <a 46 + href="/brews/{item.Author.did}/{item.Brew.rkey}" 47 + on:click|preventDefault={() => navigate(`/brews/${item.Author.did}/${item.Brew.rkey}`)} 48 + class="font-semibold text-brown-800 hover:text-brown-900 hover:underline cursor-pointer" 49 + > 50 + new brew 51 + </a> 52 + {:else} 53 + {item.Action} 54 + {/if} 55 + </div> 43 56 44 57 <!-- Record content --> 45 58 {#if item.RecordType === 'brew' && item.Brew}
+1 -4
frontend/src/lib/router.js
··· 4 4 * Simple client-side router using navaid 5 5 * Handles browser history and navigation 6 6 */ 7 - const router = navaid('/', () => { 8 - // Default handler (fallback to home) 9 - window.location.hash = '/'; 10 - }); 7 + const router = navaid('/'); 11 8 12 9 /** 13 10 * Navigate to a route programmatically
+6 -5
frontend/src/routes/BrewForm.svelte
··· 82 82 }); 83 83 84 84 function addPour() { 85 - pours = [...pours, { water_amount: '', time_seconds: '' }]; 85 + pours = [...pours, { water_amount: 0, time_seconds: 0 }]; 86 86 } 87 87 88 88 function removePour(index) { ··· 90 90 } 91 91 92 92 async function handleSubmit() { 93 - if (!form.bean_rkey) { 94 - alert('Please select a coffee bean'); 93 + // Validate required fields 94 + if (!form.bean_rkey || form.bean_rkey === '') { 95 + error = 'Please select a coffee bean'; 95 96 return; 96 97 } 97 98 ··· 365 366 <span class="text-sm font-medium text-brown-700 min-w-[60px]">Pour {i + 1}:</span> 366 367 <input 367 368 type="number" 368 - bind:value={pour.Water} 369 + bind:value={pour.water_amount} 369 370 placeholder="Water (g)" 370 371 class="flex-1 rounded border border-brown-300 px-3 py-2 text-sm" 371 372 /> 372 373 <input 373 374 type="number" 374 - bind:value={pour.Time} 375 + bind:value={pour.time_seconds} 375 376 placeholder="Time (s)" 376 377 class="flex-1 rounded border border-brown-300 px-3 py-2 text-sm" 377 378 />
+44 -9
frontend/src/routes/BrewView.svelte
··· 2 2 import { onMount } from 'svelte'; 3 3 import { authStore } from '../stores/auth.js'; 4 4 import { cacheStore } from '../stores/cache.js'; 5 - import { navigate } from '../lib/router.js'; 5 + import { navigate, back } from '../lib/router.js'; 6 6 import { api } from '../lib/api.js'; 7 7 8 - export let id; // RKey from route 8 + export let id = null; // RKey from route (for own brews) 9 + export let did = null; // DID from route (for other users' brews) 10 + export let rkey = null; // RKey from route (for other users' brews) 9 11 10 12 let brew = null; 11 13 let loading = true; ··· 13 15 let isOwnProfile = false; 14 16 15 17 $: isAuthenticated = $authStore.isAuthenticated; 18 + $: currentUserDID = $authStore.user?.did; 16 19 17 20 // Calculate total water from pours if water_amount is 0 18 21 $: totalWater = brew && (brew.water_amount || 0) === 0 && brew.pours && brew.pours.length > 0 ··· 25 28 return; 26 29 } 27 30 28 - // Load from cache first 29 - await cacheStore.load(); 30 - const brews = $cacheStore.brews || []; 31 - brew = brews.find(b => b.rkey === id); 31 + // Determine if viewing own brew or someone else's 32 + if (did && rkey) { 33 + // Viewing another user's brew 34 + isOwnProfile = did === currentUserDID; 35 + await loadBrewFromAPI(did, rkey); 36 + } else if (id) { 37 + // Viewing own brew (legacy route) 38 + isOwnProfile = true; 39 + await loadBrewFromCache(id); 40 + } 41 + 32 42 loading = false; 33 - isOwnProfile = true; // Currently viewing own profile 34 43 }); 35 44 45 + async function loadBrewFromCache(brewRKey) { 46 + await cacheStore.load(); 47 + const brews = $cacheStore.brews || []; 48 + brew = brews.find(b => b.rkey === brewRKey); 49 + if (!brew) { 50 + error = 'Brew not found'; 51 + } 52 + } 53 + 54 + async function loadBrewFromAPI(userDID, brewRKey) { 55 + try { 56 + // Fetch brew from API using AT-URI 57 + const atURI = `at://${userDID}/social.arabica.alpha.brew/${brewRKey}`; 58 + brew = await api.get(`/api/brew?uri=${encodeURIComponent(atURI)}`); 59 + } catch (err) { 60 + console.error('Failed to load brew:', err); 61 + error = err.message || 'Failed to load brew'; 62 + } 63 + } 64 + 36 65 async function deleteBrew() { 37 66 if (!confirm('Are you sure you want to delete this brew?')) { 38 67 return; 39 68 } 40 69 70 + const brewRKey = rkey || id; 71 + if (!brewRKey) { 72 + alert('Cannot delete brew: missing ID'); 73 + return; 74 + } 75 + 41 76 try { 42 - await api.delete(`/brews/${id}`); 77 + await api.delete(`/brews/${brewRKey}`); 43 78 await cacheStore.invalidate(); 44 79 navigate('/brews'); 45 80 } catch (err) { ··· 96 131 {#if isOwnProfile} 97 132 <div class="flex gap-2"> 98 133 <button 99 - on:click={() => navigate(`/brews/${brew.rkey}/edit`)} 134 + on:click={() => navigate(`/brews/${rkey || id || brew.rkey}/edit`)} 100 135 class="inline-flex items-center bg-brown-300 text-brown-900 px-4 py-2 rounded-lg hover:bg-brown-400 font-medium transition-colors" 101 136 > 102 137 Edit
+28 -1
frontend/src/routes/Brews.svelte
··· 3 3 import { authStore } from '../stores/auth.js'; 4 4 import { cacheStore } from '../stores/cache.js'; 5 5 import { navigate } from '../lib/router.js'; 6 + import { api } from '../lib/api.js'; 6 7 7 8 let brews = []; 8 9 let loading = true; 10 + let deleting = null; // Track which brew is being deleted 9 11 10 12 $: isAuthenticated = $authStore.isAuthenticated; 11 13 ··· 48 50 49 51 return null; 50 52 } 53 + 54 + async function deleteBrew(rkey) { 55 + if (!confirm('Are you sure you want to delete this brew?')) { 56 + return; 57 + } 58 + 59 + deleting = rkey; 60 + try { 61 + await api.delete(`/brews/${rkey}`); 62 + await cacheStore.invalidate(); 63 + brews = $cacheStore.brews || []; 64 + } catch (err) { 65 + alert('Failed to delete brew: ' + err.message); 66 + } finally { 67 + deleting = null; 68 + } 69 + } 51 70 </script> 52 71 53 72 <svelte:head> ··· 137 156 </span> 138 157 {/if} 139 158 140 - <div class="flex gap-2"> 159 + <div class="flex gap-2 items-center"> 141 160 <a 142 161 href="/brews/{brew.rkey}" 143 162 on:click|preventDefault={() => navigate(`/brews/${brew.rkey}`)} ··· 153 172 > 154 173 Edit 155 174 </a> 175 + <span class="text-brown-400">|</span> 176 + <button 177 + on:click={() => deleteBrew(brew.rkey)} 178 + disabled={deleting === brew.rkey} 179 + class="text-red-600 hover:text-red-800 text-sm font-medium hover:underline disabled:opacity-50" 180 + > 181 + {deleting === brew.rkey ? 'Deleting...' : 'Delete'} 182 + </button> 156 183 </div> 157 184 </div> 158 185 </div>
+4
frontend/src/routes/Manage.svelte
··· 76 76 77 77 async function saveBean() { 78 78 try { 79 + console.log('Saving bean with data:', beanForm); 79 80 if (editingBean) { 81 + console.log('Updating bean:', editingBean.rkey); 80 82 await api.put(`/api/beans/${editingBean.rkey}`, beanForm); 81 83 } else { 84 + console.log('Creating new bean'); 82 85 await api.post('/api/beans', beanForm); 83 86 } 84 87 await cacheStore.invalidate(); 85 88 showBeanModal = false; 86 89 } catch (err) { 90 + console.error('Bean save error:', err); 87 91 alert('Failed to save bean: ' + err.message); 88 92 } 89 93 }
-142
internal/bff/render.go
··· 168 168 } 169 169 170 170 // RenderHome renders the home page 171 - func RenderHome(w http.ResponseWriter, isAuthenticated bool, userDID string, userProfile *UserProfile, feedItems []*feed.FeedItem) error { 172 - t, err := parsePageTemplate("home.tmpl") 173 - if err != nil { 174 - return err 175 - } 176 - data := &PageData{ 177 - Title: "Home", 178 - IsAuthenticated: isAuthenticated, 179 - UserDID: userDID, 180 - UserProfile: userProfile, 181 - FeedItems: feedItems, 182 - } 183 - return t.ExecuteTemplate(w, "layout", data) 184 - } 185 171 186 172 // RenderBrewList renders the brew list page 187 - func RenderBrewList(w http.ResponseWriter, brews []*models.Brew, isAuthenticated bool, userDID string, userProfile *UserProfile) error { 188 - t, err := parsePageTemplate("brew_list.tmpl") 189 - if err != nil { 190 - return err 191 - } 192 - brewList := make([]*BrewListData, len(brews)) 193 - for i, brew := range brews { 194 - brewList[i] = &BrewListData{ 195 - Brew: brew, 196 - TempFormatted: FormatTemp(brew.Temperature), 197 - TimeFormatted: FormatTime(brew.TimeSeconds), 198 - RatingFormatted: FormatRating(brew.Rating), 199 - } 200 - } 201 - 202 - data := &PageData{ 203 - Title: "All Brews", 204 - Brews: brewList, 205 - IsAuthenticated: isAuthenticated, 206 - UserDID: userDID, 207 - UserProfile: userProfile, 208 - } 209 - return t.ExecuteTemplate(w, "layout", data) 210 - } 211 173 212 174 // RenderBrewForm renders the brew form page 213 - func RenderBrewForm(w http.ResponseWriter, beans []*models.Bean, roasters []*models.Roaster, grinders []*models.Grinder, brewers []*models.Brewer, brew *models.Brew, isAuthenticated bool, userDID string, userProfile *UserProfile) error { 214 - t, err := parsePageTemplate("brew_form.tmpl") 215 - if err != nil { 216 - return err 217 - } 218 - var brewData *BrewData 219 - title := "New Brew" 220 - 221 - if brew != nil { 222 - title = "Edit Brew" 223 - brewData = &BrewData{ 224 - Brew: brew, 225 - PoursJSON: PoursToJSON(brew.Pours), 226 - } 227 - } 228 - 229 - data := &PageData{ 230 - Title: title, 231 - Beans: beans, 232 - Roasters: roasters, 233 - Grinders: grinders, 234 - Brewers: brewers, 235 - Brew: brewData, 236 - IsAuthenticated: isAuthenticated, 237 - UserDID: userDID, 238 - UserProfile: userProfile, 239 - } 240 - return t.ExecuteTemplate(w, "layout", data) 241 - } 242 175 243 176 // RenderBrewView renders the brew view page 244 - func RenderBrewView(w http.ResponseWriter, brew *models.Brew, isAuthenticated bool, userDID string, userProfile *UserProfile, isOwner bool) error { 245 - t, err := parsePageTemplate("brew_view.tmpl") 246 - if err != nil { 247 - return err 248 - } 249 - 250 - // If water amount is not set but pours exist, sum the pours 251 - displayBrew := brew 252 - if brew.WaterAmount == 0 && len(brew.Pours) > 0 { 253 - // Create a copy to avoid modifying the original 254 - brewCopy := *brew 255 - for _, pour := range brew.Pours { 256 - brewCopy.WaterAmount += pour.WaterAmount 257 - } 258 - displayBrew = &brewCopy 259 - } 260 - 261 - brewData := &BrewData{ 262 - Brew: displayBrew, 263 - PoursJSON: PoursToJSON(brew.Pours), 264 - } 265 - 266 - data := &PageData{ 267 - Title: "View Brew", 268 - Brew: brewData, 269 - IsAuthenticated: isAuthenticated, 270 - UserDID: userDID, 271 - UserProfile: userProfile, 272 - IsOwnProfile: isOwner, // Reuse IsOwnProfile field to indicate ownership 273 - } 274 - return t.ExecuteTemplate(w, "layout", data) 275 - } 276 177 277 178 // RenderManage renders the manage page 278 - func RenderManage(w http.ResponseWriter, beans []*models.Bean, roasters []*models.Roaster, grinders []*models.Grinder, brewers []*models.Brewer, isAuthenticated bool, userDID string, userProfile *UserProfile) error { 279 - t, err := parsePageTemplate("manage.tmpl") 280 - if err != nil { 281 - return err 282 - } 283 - data := &PageData{ 284 - Title: "Manage", 285 - Beans: beans, 286 - Roasters: roasters, 287 - Grinders: grinders, 288 - Brewers: brewers, 289 - IsAuthenticated: isAuthenticated, 290 - UserDID: userDID, 291 - UserProfile: userProfile, 292 - } 293 - return t.ExecuteTemplate(w, "layout", data) 294 - } 295 179 296 180 // RenderFeedPartial renders just the feed partial (for HTMX async loading) 297 181 func RenderFeedPartial(w http.ResponseWriter, feedItems []*feed.FeedItem, isAuthenticated bool) error { ··· 377 261 } 378 262 379 263 // RenderProfile renders a user's public profile page 380 - func RenderProfile(w http.ResponseWriter, profile *atproto.Profile, brews []*models.Brew, beans []*models.Bean, roasters []*models.Roaster, grinders []*models.Grinder, brewers []*models.Brewer, isAuthenticated bool, userDID string, userProfile *UserProfile, isOwnProfile bool) error { 381 - t, err := parsePageTemplate("profile.tmpl") 382 - if err != nil { 383 - return err 384 - } 385 - 386 - displayName := profile.Handle 387 - if profile.DisplayName != nil && *profile.DisplayName != "" { 388 - displayName = *profile.DisplayName 389 - } 390 - 391 - data := &ProfilePageData{ 392 - Title: displayName + "'s Profile", 393 - Profile: profile, 394 - Brews: brews, 395 - Beans: beans, 396 - Roasters: roasters, 397 - Grinders: grinders, 398 - Brewers: brewers, 399 - IsAuthenticated: isAuthenticated, 400 - UserDID: userDID, 401 - UserProfile: userProfile, 402 - IsOwnProfile: isOwnProfile, 403 - } 404 - return t.ExecuteTemplate(w, "layout", data) 405 - } 406 264 407 265 // RenderProfilePartial renders just the profile content partial (for HTMX async loading) 408 266 func RenderProfilePartial(w http.ResponseWriter, brews []*models.Brew, beans []*models.Bean, roasters []*models.Roaster, grinders []*models.Grinder, brewers []*models.Brewer, isOwnProfile bool, profileHandle string) error {
+251 -567
internal/handlers/handlers.go
··· 141 141 } 142 142 143 143 // Home page 144 - func (h *Handler) HandleHome(w http.ResponseWriter, r *http.Request) { 145 - // Check if user is authenticated 146 - didStr, err := atproto.GetAuthenticatedDID(r.Context()) 147 - isAuthenticated := err == nil && didStr != "" 148 - 149 - // Fetch user profile for authenticated users 150 - var userProfile *bff.UserProfile 151 - if isAuthenticated { 152 - userProfile = h.getUserProfile(r.Context(), didStr) 153 - } 154 - 155 - // Don't fetch feed items here - let them load async via HTMX 156 - if err := bff.RenderHome(w, isAuthenticated, didStr, userProfile, nil); err != nil { 157 - http.Error(w, "Failed to render page", http.StatusInternalServerError) 158 - log.Error().Err(err).Msg("Failed to render home page") 159 - } 160 - } 161 144 162 145 // Community feed partial (loaded async via HTMX) 163 146 func (h *Handler) HandleFeedPartial(w http.ResponseWriter, r *http.Request) { ··· 455 438 } 456 439 457 440 // List all brews 458 - func (h *Handler) HandleBrewList(w http.ResponseWriter, r *http.Request) { 459 - // Require authentication 460 - _, authenticated := h.getAtprotoStore(r) 461 - if !authenticated { 462 - http.Redirect(w, r, "/login", http.StatusFound) 463 - return 464 - } 465 - 466 - didStr, _ := atproto.GetAuthenticatedDID(r.Context()) 467 - userProfile := h.getUserProfile(r.Context(), didStr) 468 - 469 - // Don't fetch brews here - let them load async via HTMX 470 - if err := bff.RenderBrewList(w, nil, authenticated, didStr, userProfile); err != nil { 471 - http.Error(w, "Failed to render page", http.StatusInternalServerError) 472 - log.Error().Err(err).Msg("Failed to render brew list page") 473 - } 474 - } 475 441 476 442 // Show new brew form 477 - func (h *Handler) HandleBrewNew(w http.ResponseWriter, r *http.Request) { 478 - // Require authentication 479 - _, authenticated := h.getAtprotoStore(r) 480 - if !authenticated { 481 - http.Redirect(w, r, "/login", http.StatusFound) 482 - return 483 - } 484 - 485 - didStr, _ := atproto.GetAuthenticatedDID(r.Context()) 486 - userProfile := h.getUserProfile(r.Context(), didStr) 487 - 488 - // Don't fetch data from PDS - client will populate dropdowns from cache 489 - // This makes the page load much faster 490 - if err := bff.RenderBrewForm(w, nil, nil, nil, nil, nil, authenticated, didStr, userProfile); err != nil { 491 - http.Error(w, "Failed to render page", http.StatusInternalServerError) 492 - log.Error().Err(err).Msg("Failed to render brew form") 493 - } 494 - } 495 443 496 444 // Show brew view page 497 - func (h *Handler) HandleBrewView(w http.ResponseWriter, r *http.Request) { 498 - rkey := validateRKey(w, r.PathValue("id")) 499 - if rkey == "" { 500 - return 501 - } 502 - 503 - // Check if owner (DID or handle) is specified in query params 504 - owner := r.URL.Query().Get("owner") 505 - 506 - // Check authentication 507 - didStr, err := atproto.GetAuthenticatedDID(r.Context()) 508 - isAuthenticated := err == nil && didStr != "" 509 - 510 - var userProfile *bff.UserProfile 511 - if isAuthenticated { 512 - userProfile = h.getUserProfile(r.Context(), didStr) 513 - } 514 - 515 - var brew *models.Brew 516 - var brewOwnerDID string 517 - var isOwner bool 518 - 519 - if owner != "" { 520 - // Viewing someone else's brew - use public client 521 - publicClient := atproto.NewPublicClient() 522 - 523 - // Resolve owner to DID if it's a handle 524 - if strings.HasPrefix(owner, "did:") { 525 - brewOwnerDID = owner 526 - } else { 527 - resolved, err := publicClient.ResolveHandle(r.Context(), owner) 528 - if err != nil { 529 - log.Warn().Err(err).Str("handle", owner).Msg("Failed to resolve handle for brew view") 530 - http.Error(w, "User not found", http.StatusNotFound) 531 - return 532 - } 533 - brewOwnerDID = resolved 534 - } 535 - 536 - // Fetch the brew record from the owner's PDS 537 - record, err := publicClient.GetRecord(r.Context(), brewOwnerDID, atproto.NSIDBrew, rkey) 538 - if err != nil { 539 - log.Error().Err(err).Str("did", brewOwnerDID).Str("rkey", rkey).Msg("Failed to get brew record") 540 - http.Error(w, "Brew not found", http.StatusNotFound) 541 - return 542 - } 543 - 544 - // Convert record to brew 545 - brew, err = atproto.RecordToBrew(record.Value, record.URI) 546 - if err != nil { 547 - log.Error().Err(err).Msg("Failed to convert brew record") 548 - http.Error(w, "Failed to load brew", http.StatusInternalServerError) 549 - return 550 - } 551 - 552 - // Resolve references (bean, grinder, brewer) 553 - if err := h.resolveBrewReferences(r.Context(), brew, brewOwnerDID, record.Value); err != nil { 554 - log.Warn().Err(err).Msg("Failed to resolve some brew references") 555 - // Don't fail the request, just log the warning 556 - } 557 - 558 - // Check if viewing user is the owner 559 - isOwner = isAuthenticated && didStr == brewOwnerDID 560 - } else { 561 - // Viewing own brew - require authentication 562 - store, authenticated := h.getAtprotoStore(r) 563 - if !authenticated { 564 - http.Redirect(w, r, "/login", http.StatusFound) 565 - return 566 - } 567 - 568 - brew, err = store.GetBrewByRKey(r.Context(), rkey) 569 - if err != nil { 570 - http.Error(w, "Brew not found", http.StatusNotFound) 571 - log.Error().Err(err).Str("rkey", rkey).Msg("Failed to get brew for view") 572 - return 573 - } 574 - 575 - brewOwnerDID = didStr 576 - isOwner = true 577 - } 578 - 579 - if err := bff.RenderBrewView(w, brew, isAuthenticated, didStr, userProfile, isOwner); err != nil { 580 - http.Error(w, "Failed to render page", http.StatusInternalServerError) 581 - log.Error().Err(err).Msg("Failed to render brew view") 582 - } 583 - } 584 445 585 446 // resolveBrewReferences resolves bean, grinder, and brewer references for a brew 586 447 func (h *Handler) resolveBrewReferences(ctx context.Context, brew *models.Brew, ownerDID string, record map[string]interface{}) error { ··· 630 491 } 631 492 632 493 // Show edit brew form 633 - func (h *Handler) HandleBrewEdit(w http.ResponseWriter, r *http.Request) { 634 - rkey := validateRKey(w, r.PathValue("id")) 635 - if rkey == "" { 636 - return 637 - } 638 - 639 - // Require authentication 640 - store, authenticated := h.getAtprotoStore(r) 641 - if !authenticated { 642 - http.Redirect(w, r, "/login", http.StatusFound) 643 - return 644 - } 645 - 646 - didStr, _ := atproto.GetAuthenticatedDID(r.Context()) 647 - userProfile := h.getUserProfile(r.Context(), didStr) 648 - 649 - brew, err := store.GetBrewByRKey(r.Context(), rkey) 650 - if err != nil { 651 - http.Error(w, "Brew not found", http.StatusNotFound) 652 - log.Error().Err(err).Str("rkey", rkey).Msg("Failed to get brew for edit") 653 - return 654 - } 655 - 656 - // Don't fetch dropdown data from PDS - client will populate from cache 657 - // This makes the page load much faster 658 - if err := bff.RenderBrewForm(w, nil, nil, nil, nil, brew, authenticated, didStr, userProfile); err != nil { 659 - http.Error(w, "Failed to render page", http.StatusInternalServerError) 660 - log.Error().Err(err).Msg("Failed to render brew edit form") 661 - } 662 - } 663 494 664 495 // maxPours is the maximum number of pours allowed in a single brew 665 496 const maxPours = 100 ··· 771 602 return 772 603 } 773 604 774 - if err := r.ParseForm(); err != nil { 775 - http.Error(w, "Invalid form data", http.StatusBadRequest) 776 - return 777 - } 605 + // Check content type - support both JSON and form data 606 + contentType := r.Header.Get("Content-Type") 607 + isJSON := strings.Contains(contentType, "application/json") 778 608 779 - // Validate input 780 - temperature, waterAmount, coffeeAmount, timeSeconds, rating, pours, validationErrs := validateBrewRequest(r) 781 - if len(validationErrs) > 0 { 782 - // Return first validation error 783 - http.Error(w, validationErrs[0].Message, http.StatusBadRequest) 784 - return 785 - } 609 + var req models.CreateBrewRequest 786 610 787 - // Validate required fields 788 - beanRKey := r.FormValue("bean_rkey") 789 - if beanRKey == "" { 790 - http.Error(w, "Bean selection is required", http.StatusBadRequest) 791 - return 792 - } 793 - if !atproto.ValidateRKey(beanRKey) { 794 - http.Error(w, "Invalid bean selection", http.StatusBadRequest) 795 - return 796 - } 611 + if isJSON { 612 + // Parse JSON body 613 + if err := json.NewDecoder(r.Body).Decode(&req); err != nil { 614 + http.Error(w, "Invalid JSON body", http.StatusBadRequest) 615 + return 616 + } 617 + } else { 618 + // Parse form data (legacy support) 619 + if err := r.ParseForm(); err != nil { 620 + http.Error(w, "Invalid form data", http.StatusBadRequest) 621 + return 622 + } 797 623 798 - // Validate optional rkeys 799 - grinderRKey := r.FormValue("grinder_rkey") 800 - if errMsg := validateOptionalRKey(grinderRKey, "Grinder selection"); errMsg != "" { 801 - http.Error(w, errMsg, http.StatusBadRequest) 802 - return 803 - } 804 - brewerRKey := r.FormValue("brewer_rkey") 805 - if errMsg := validateOptionalRKey(brewerRKey, "Brewer selection"); errMsg != "" { 806 - http.Error(w, errMsg, http.StatusBadRequest) 807 - return 624 + // Validate input 625 + temperature, waterAmount, coffeeAmount, timeSeconds, rating, pours, validationErrs := validateBrewRequest(r) 626 + if len(validationErrs) > 0 { 627 + // Return first validation error 628 + http.Error(w, validationErrs[0].Message, http.StatusBadRequest) 629 + return 630 + } 631 + 632 + // Validate required fields 633 + beanRKey := r.FormValue("bean_rkey") 634 + if beanRKey == "" { 635 + http.Error(w, "Bean selection is required", http.StatusBadRequest) 636 + return 637 + } 638 + if !atproto.ValidateRKey(beanRKey) { 639 + http.Error(w, "Invalid bean selection", http.StatusBadRequest) 640 + return 641 + } 642 + 643 + // Validate optional rkeys 644 + grinderRKey := r.FormValue("grinder_rkey") 645 + if errMsg := validateOptionalRKey(grinderRKey, "Grinder selection"); errMsg != "" { 646 + http.Error(w, errMsg, http.StatusBadRequest) 647 + return 648 + } 649 + brewerRKey := r.FormValue("brewer_rkey") 650 + if errMsg := validateOptionalRKey(brewerRKey, "Brewer selection"); errMsg != "" { 651 + http.Error(w, errMsg, http.StatusBadRequest) 652 + return 653 + } 654 + 655 + req = models.CreateBrewRequest{ 656 + BeanRKey: beanRKey, 657 + Method: r.FormValue("method"), 658 + Temperature: temperature, 659 + WaterAmount: waterAmount, 660 + CoffeeAmount: coffeeAmount, 661 + TimeSeconds: timeSeconds, 662 + GrindSize: r.FormValue("grind_size"), 663 + GrinderRKey: grinderRKey, 664 + BrewerRKey: brewerRKey, 665 + TastingNotes: r.FormValue("tasting_notes"), 666 + Rating: rating, 667 + Pours: pours, 668 + } 808 669 } 809 670 810 - req := &models.CreateBrewRequest{ 811 - BeanRKey: beanRKey, 812 - Method: r.FormValue("method"), 813 - Temperature: temperature, 814 - WaterAmount: waterAmount, 815 - CoffeeAmount: coffeeAmount, 816 - TimeSeconds: timeSeconds, 817 - GrindSize: r.FormValue("grind_size"), 818 - GrinderRKey: grinderRKey, 819 - BrewerRKey: brewerRKey, 820 - TastingNotes: r.FormValue("tasting_notes"), 821 - Rating: rating, 822 - Pours: pours, 671 + // Validate JSON request 672 + if isJSON { 673 + if req.BeanRKey == "" { 674 + http.Error(w, "Bean selection is required", http.StatusBadRequest) 675 + return 676 + } 677 + if !atproto.ValidateRKey(req.BeanRKey) { 678 + http.Error(w, "Invalid bean selection", http.StatusBadRequest) 679 + return 680 + } 681 + if errMsg := validateOptionalRKey(req.GrinderRKey, "Grinder selection"); errMsg != "" { 682 + http.Error(w, errMsg, http.StatusBadRequest) 683 + return 684 + } 685 + if errMsg := validateOptionalRKey(req.BrewerRKey, "Brewer selection"); errMsg != "" { 686 + http.Error(w, errMsg, http.StatusBadRequest) 687 + return 688 + } 823 689 } 824 690 825 - _, err := store.CreateBrew(r.Context(), req, 1) // User ID not used with atproto 691 + brew, err := store.CreateBrew(r.Context(), &req, 1) // User ID not used with atproto 826 692 if err != nil { 827 693 http.Error(w, "Failed to create brew", http.StatusInternalServerError) 828 694 log.Error().Err(err).Msg("Failed to create brew") 829 695 return 830 696 } 831 697 832 - // Redirect to brew list 833 - w.Header().Set("HX-Redirect", "/brews") 834 - w.WriteHeader(http.StatusOK) 698 + // Return JSON for API calls, redirect for HTMX 699 + if isJSON { 700 + w.Header().Set("Content-Type", "application/json") 701 + if err := json.NewEncoder(w).Encode(brew); err != nil { 702 + log.Error().Err(err).Msg("Failed to encode brew response") 703 + } 704 + } else { 705 + // Redirect to brew list 706 + w.Header().Set("HX-Redirect", "/brews") 707 + w.WriteHeader(http.StatusOK) 708 + } 835 709 } 836 710 837 711 // Update existing brew ··· 848 722 return 849 723 } 850 724 851 - if err := r.ParseForm(); err != nil { 852 - http.Error(w, "Invalid form data", http.StatusBadRequest) 853 - return 854 - } 725 + // Check content type - support both JSON and form data 726 + contentType := r.Header.Get("Content-Type") 727 + isJSON := strings.Contains(contentType, "application/json") 855 728 856 - // Validate input 857 - temperature, waterAmount, coffeeAmount, timeSeconds, rating, pours, validationErrs := validateBrewRequest(r) 858 - if len(validationErrs) > 0 { 859 - http.Error(w, validationErrs[0].Message, http.StatusBadRequest) 860 - return 861 - } 729 + var req models.CreateBrewRequest 862 730 863 - // Validate required fields 864 - beanRKey := r.FormValue("bean_rkey") 865 - if beanRKey == "" { 866 - http.Error(w, "Bean selection is required", http.StatusBadRequest) 867 - return 868 - } 869 - if !atproto.ValidateRKey(beanRKey) { 870 - http.Error(w, "Invalid bean selection", http.StatusBadRequest) 871 - return 872 - } 731 + if isJSON { 732 + // Parse JSON body 733 + if err := json.NewDecoder(r.Body).Decode(&req); err != nil { 734 + http.Error(w, "Invalid JSON body", http.StatusBadRequest) 735 + return 736 + } 737 + } else { 738 + // Parse form data (legacy support) 739 + if err := r.ParseForm(); err != nil { 740 + http.Error(w, "Invalid form data", http.StatusBadRequest) 741 + return 742 + } 873 743 874 - // Validate optional rkeys 875 - grinderRKey := r.FormValue("grinder_rkey") 876 - if errMsg := validateOptionalRKey(grinderRKey, "Grinder selection"); errMsg != "" { 877 - http.Error(w, errMsg, http.StatusBadRequest) 878 - return 879 - } 880 - brewerRKey := r.FormValue("brewer_rkey") 881 - if errMsg := validateOptionalRKey(brewerRKey, "Brewer selection"); errMsg != "" { 882 - http.Error(w, errMsg, http.StatusBadRequest) 883 - return 744 + // Validate input 745 + temperature, waterAmount, coffeeAmount, timeSeconds, rating, pours, validationErrs := validateBrewRequest(r) 746 + if len(validationErrs) > 0 { 747 + http.Error(w, validationErrs[0].Message, http.StatusBadRequest) 748 + return 749 + } 750 + 751 + // Validate required fields 752 + beanRKey := r.FormValue("bean_rkey") 753 + if beanRKey == "" { 754 + http.Error(w, "Bean selection is required", http.StatusBadRequest) 755 + return 756 + } 757 + if !atproto.ValidateRKey(beanRKey) { 758 + http.Error(w, "Invalid bean selection", http.StatusBadRequest) 759 + return 760 + } 761 + 762 + // Validate optional rkeys 763 + grinderRKey := r.FormValue("grinder_rkey") 764 + if errMsg := validateOptionalRKey(grinderRKey, "Grinder selection"); errMsg != "" { 765 + http.Error(w, errMsg, http.StatusBadRequest) 766 + return 767 + } 768 + brewerRKey := r.FormValue("brewer_rkey") 769 + if errMsg := validateOptionalRKey(brewerRKey, "Brewer selection"); errMsg != "" { 770 + http.Error(w, errMsg, http.StatusBadRequest) 771 + return 772 + } 773 + 774 + req = models.CreateBrewRequest{ 775 + BeanRKey: beanRKey, 776 + Method: r.FormValue("method"), 777 + Temperature: temperature, 778 + WaterAmount: waterAmount, 779 + CoffeeAmount: coffeeAmount, 780 + TimeSeconds: timeSeconds, 781 + GrindSize: r.FormValue("grind_size"), 782 + GrinderRKey: grinderRKey, 783 + BrewerRKey: brewerRKey, 784 + TastingNotes: r.FormValue("tasting_notes"), 785 + Rating: rating, 786 + Pours: pours, 787 + } 884 788 } 885 789 886 - req := &models.CreateBrewRequest{ 887 - BeanRKey: beanRKey, 888 - Method: r.FormValue("method"), 889 - Temperature: temperature, 890 - WaterAmount: waterAmount, 891 - CoffeeAmount: coffeeAmount, 892 - TimeSeconds: timeSeconds, 893 - GrindSize: r.FormValue("grind_size"), 894 - GrinderRKey: grinderRKey, 895 - BrewerRKey: brewerRKey, 896 - TastingNotes: r.FormValue("tasting_notes"), 897 - Rating: rating, 898 - Pours: pours, 790 + // Validate JSON request 791 + if isJSON { 792 + if req.BeanRKey == "" { 793 + http.Error(w, "Bean selection is required", http.StatusBadRequest) 794 + return 795 + } 796 + if !atproto.ValidateRKey(req.BeanRKey) { 797 + http.Error(w, "Invalid bean selection", http.StatusBadRequest) 798 + return 799 + } 800 + if errMsg := validateOptionalRKey(req.GrinderRKey, "Grinder selection"); errMsg != "" { 801 + http.Error(w, errMsg, http.StatusBadRequest) 802 + return 803 + } 804 + if errMsg := validateOptionalRKey(req.BrewerRKey, "Brewer selection"); errMsg != "" { 805 + http.Error(w, errMsg, http.StatusBadRequest) 806 + return 807 + } 899 808 } 900 809 901 - err := store.UpdateBrewByRKey(r.Context(), rkey, req) 810 + err := store.UpdateBrewByRKey(r.Context(), rkey, &req) 902 811 if err != nil { 903 812 http.Error(w, "Failed to update brew", http.StatusInternalServerError) 904 813 log.Error().Err(err).Str("rkey", rkey).Msg("Failed to update brew") 905 814 return 906 815 } 907 816 908 - // Redirect to brew list 909 - w.Header().Set("HX-Redirect", "/brews") 910 - w.WriteHeader(http.StatusOK) 817 + // Return JSON for API calls, redirect for HTMX 818 + if isJSON { 819 + w.WriteHeader(http.StatusOK) 820 + } else { 821 + // Redirect to brew list 822 + w.Header().Set("HX-Redirect", "/brews") 823 + w.WriteHeader(http.StatusOK) 824 + } 911 825 } 912 826 913 827 // Delete brew ··· 934 848 } 935 849 936 850 // Export brews as JSON 937 - func (h *Handler) HandleBrewExport(w http.ResponseWriter, r *http.Request) { 938 - // Require authentication 939 - store, authenticated := h.getAtprotoStore(r) 940 - if !authenticated { 941 - http.Error(w, "Authentication required", http.StatusUnauthorized) 851 + 852 + // Get a public brew by AT-URI 853 + func (h *Handler) HandleBrewGetPublic(w http.ResponseWriter, r *http.Request) { 854 + atURI := r.URL.Query().Get("uri") 855 + if atURI == "" { 856 + http.Error(w, "Missing 'uri' query parameter", http.StatusBadRequest) 942 857 return 943 858 } 944 859 945 - brews, err := store.ListBrews(r.Context(), 1) // User ID is not used with atproto 860 + // Parse AT-URI to extract DID, collection, and rkey 861 + components, err := atproto.ResolveATURI(atURI) 946 862 if err != nil { 947 - http.Error(w, "Failed to fetch brews", http.StatusInternalServerError) 948 - log.Error().Err(err).Msg("Failed to list brews for export") 863 + http.Error(w, "Invalid AT-URI", http.StatusBadRequest) 864 + log.Error().Err(err).Str("uri", atURI).Msg("Failed to parse AT-URI") 949 865 return 950 866 } 951 867 952 - w.Header().Set("Content-Type", "application/json") 953 - w.Header().Set("Content-Disposition", "attachment; filename=arabica-brews.json") 868 + // Fetch the record from the user's PDS using PublicClient 869 + publicClient := atproto.NewPublicClient() 870 + recordEntry, err := publicClient.GetRecord(r.Context(), components.DID, components.Collection, components.RKey) 871 + if err != nil { 872 + http.Error(w, "Failed to fetch brew", http.StatusInternalServerError) 873 + log.Error().Err(err).Str("uri", atURI).Msg("Failed to fetch public brew") 874 + return 875 + } 876 + 877 + // Convert the record to a Brew model 878 + brew, err := atproto.RecordToBrew(recordEntry.Value, atURI) 879 + if err != nil { 880 + http.Error(w, "Failed to parse brew record", http.StatusInternalServerError) 881 + log.Error().Err(err).Str("uri", atURI).Msg("Failed to convert record to brew") 882 + return 883 + } 884 + 885 + // Fetch referenced entities (bean, grinder, brewer) if they exist 886 + if brew.BeanRKey != "" { 887 + beanURI := atproto.BuildATURI(components.DID, atproto.NSIDBean, brew.BeanRKey) 888 + beanRecord, err := publicClient.GetRecord(r.Context(), components.DID, atproto.NSIDBean, brew.BeanRKey) 889 + if err == nil { 890 + bean, err := atproto.RecordToBean(beanRecord.Value, beanURI) 891 + if err == nil { 892 + brew.Bean = bean 893 + 894 + // Fetch roaster if referenced 895 + if bean.RoasterRKey != "" { 896 + roasterURI := atproto.BuildATURI(components.DID, atproto.NSIDRoaster, bean.RoasterRKey) 897 + roasterRecord, err := publicClient.GetRecord(r.Context(), components.DID, atproto.NSIDRoaster, bean.RoasterRKey) 898 + if err == nil { 899 + roaster, err := atproto.RecordToRoaster(roasterRecord.Value, roasterURI) 900 + if err == nil { 901 + brew.Bean.Roaster = roaster 902 + } 903 + } 904 + } 905 + } 906 + } 907 + } 954 908 955 - encoder := json.NewEncoder(w) 956 - encoder.SetIndent("", " ") 957 - if err := encoder.Encode(brews); err != nil { 958 - log.Error().Err(err).Msg("Failed to encode brews for export") 909 + if brew.GrinderRKey != "" { 910 + grinderURI := atproto.BuildATURI(components.DID, atproto.NSIDGrinder, brew.GrinderRKey) 911 + grinderRecord, err := publicClient.GetRecord(r.Context(), components.DID, atproto.NSIDGrinder, brew.GrinderRKey) 912 + if err == nil { 913 + grinder, err := atproto.RecordToGrinder(grinderRecord.Value, grinderURI) 914 + if err == nil { 915 + brew.GrinderObj = grinder 916 + } 917 + } 918 + } 919 + 920 + if brew.BrewerRKey != "" { 921 + brewerURI := atproto.BuildATURI(components.DID, atproto.NSIDBrewer, brew.BrewerRKey) 922 + brewerRecord, err := publicClient.GetRecord(r.Context(), components.DID, atproto.NSIDBrewer, brew.BrewerRKey) 923 + if err == nil { 924 + brewer, err := atproto.RecordToBrewer(brewerRecord.Value, brewerURI) 925 + if err == nil { 926 + brew.BrewerObj = brewer 927 + } 928 + } 959 929 } 930 + 931 + w.Header().Set("Content-Type", "application/json") 932 + json.NewEncoder(w).Encode(brew) 960 933 } 961 934 962 935 // API endpoint to list all user data (beans, roasters, grinders, brewers, brews) ··· 1136 1109 } 1137 1110 1138 1111 // Manage page 1139 - func (h *Handler) HandleManage(w http.ResponseWriter, r *http.Request) { 1140 - // Require authentication 1141 - _, authenticated := h.getAtprotoStore(r) 1142 - if !authenticated { 1143 - http.Redirect(w, r, "/login", http.StatusFound) 1144 - return 1145 - } 1146 - 1147 - didStr, _ := atproto.GetAuthenticatedDID(r.Context()) 1148 - userProfile := h.getUserProfile(r.Context(), didStr) 1149 - 1150 - // Don't fetch data here - let it load async via HTMX 1151 - if err := bff.RenderManage(w, nil, nil, nil, nil, authenticated, didStr, userProfile); err != nil { 1152 - http.Error(w, "Failed to render page", http.StatusInternalServerError) 1153 - log.Error().Err(err).Msg("Failed to render manage page") 1154 - } 1155 - } 1156 1112 1157 1113 // Bean update/delete handlers 1158 1114 func (h *Handler) HandleBeanUpdate(w http.ResponseWriter, r *http.Request) { ··· 1495 1451 } 1496 1452 1497 1453 // About page 1498 - func (h *Handler) HandleAbout(w http.ResponseWriter, r *http.Request) { 1499 - // Check if user is authenticated 1500 - didStr, err := atproto.GetAuthenticatedDID(r.Context()) 1501 - isAuthenticated := err == nil && didStr != "" 1502 - 1503 - var userProfile *bff.UserProfile 1504 - if isAuthenticated { 1505 - userProfile = h.getUserProfile(r.Context(), didStr) 1506 - } 1507 - 1508 - data := &bff.PageData{ 1509 - Title: "About", 1510 - IsAuthenticated: isAuthenticated, 1511 - UserDID: didStr, 1512 - UserProfile: userProfile, 1513 - } 1514 - 1515 - if err := bff.RenderTemplate(w, r, "about.tmpl", data); err != nil { 1516 - http.Error(w, "Failed to render page", http.StatusInternalServerError) 1517 - log.Error().Err(err).Msg("Failed to render about page") 1518 - } 1519 - } 1520 1454 1521 1455 // Terms of Service page 1522 - func (h *Handler) HandleTerms(w http.ResponseWriter, r *http.Request) { 1523 - // Check if user is authenticated 1524 - didStr, err := atproto.GetAuthenticatedDID(r.Context()) 1525 - isAuthenticated := err == nil && didStr != "" 1526 - 1527 - var userProfile *bff.UserProfile 1528 - if isAuthenticated { 1529 - userProfile = h.getUserProfile(r.Context(), didStr) 1530 - } 1531 - 1532 - data := &bff.PageData{ 1533 - Title: "Terms of Service", 1534 - IsAuthenticated: isAuthenticated, 1535 - UserDID: didStr, 1536 - UserProfile: userProfile, 1537 - } 1538 - 1539 - if err := bff.RenderTemplate(w, r, "terms.tmpl", data); err != nil { 1540 - http.Error(w, "Failed to render page", http.StatusInternalServerError) 1541 - log.Error().Err(err).Msg("Failed to render terms page") 1542 - } 1543 - } 1544 1456 1545 1457 // fetchAllData is a helper that fetches all data types in parallel using errgroup. 1546 1458 // This is used by handlers that need beans, roasters, grinders, and brewers. ··· 1579 1491 } 1580 1492 1581 1493 // HandleProfile displays a user's public profile with their brews and gear 1582 - func (h *Handler) HandleProfile(w http.ResponseWriter, r *http.Request) { 1583 - actor := r.PathValue("actor") 1584 - if actor == "" { 1585 - http.Error(w, "Actor parameter is required", http.StatusBadRequest) 1586 - return 1587 - } 1588 - 1589 - ctx := r.Context() 1590 - publicClient := atproto.NewPublicClient() 1591 - 1592 - // Determine if actor is a DID or handle 1593 - var did string 1594 - var err error 1595 - 1596 - if strings.HasPrefix(actor, "did:") { 1597 - // It's already a DID 1598 - did = actor 1599 - } else { 1600 - // It's a handle, resolve to DID 1601 - did, err = publicClient.ResolveHandle(ctx, actor) 1602 - if err != nil { 1603 - log.Warn().Err(err).Str("handle", actor).Msg("Failed to resolve handle") 1604 - http.Error(w, "User not found", http.StatusNotFound) 1605 - return 1606 - } 1607 - 1608 - // Redirect to canonical URL with handle (we'll get the handle from profile) 1609 - // For now, continue with the DID we have 1610 - } 1611 - 1612 - // Fetch profile 1613 - profile, err := publicClient.GetProfile(ctx, did) 1614 - if err != nil { 1615 - log.Warn().Err(err).Str("did", did).Msg("Failed to fetch profile") 1616 - http.Error(w, "User not found", http.StatusNotFound) 1617 - return 1618 - } 1619 - 1620 - // If the URL used a DID but we have the handle, redirect to the canonical handle URL 1621 - if strings.HasPrefix(actor, "did:") && profile.Handle != "" { 1622 - http.Redirect(w, r, "/profile/"+profile.Handle, http.StatusFound) 1623 - return 1624 - } 1625 - 1626 - // Fetch all user data in parallel 1627 - g, gCtx := errgroup.WithContext(ctx) 1628 - 1629 - var brews []*models.Brew 1630 - var beans []*models.Bean 1631 - var roasters []*models.Roaster 1632 - var grinders []*models.Grinder 1633 - var brewers []*models.Brewer 1634 - 1635 - // Maps for resolving references 1636 - var beanMap map[string]*models.Bean 1637 - var beanRoasterRefMap map[string]string 1638 - var roasterMap map[string]*models.Roaster 1639 - var brewerMap map[string]*models.Brewer 1640 - var grinderMap map[string]*models.Grinder 1641 - 1642 - // Fetch beans 1643 - g.Go(func() error { 1644 - output, err := publicClient.ListRecords(gCtx, did, atproto.NSIDBean, 100) 1645 - if err != nil { 1646 - return err 1647 - } 1648 - beanMap = make(map[string]*models.Bean) 1649 - beanRoasterRefMap = make(map[string]string) 1650 - beans = make([]*models.Bean, 0, len(output.Records)) 1651 - for _, record := range output.Records { 1652 - bean, err := atproto.RecordToBean(record.Value, record.URI) 1653 - if err != nil { 1654 - continue 1655 - } 1656 - beans = append(beans, bean) 1657 - beanMap[record.URI] = bean 1658 - if roasterRef, ok := record.Value["roasterRef"].(string); ok && roasterRef != "" { 1659 - beanRoasterRefMap[record.URI] = roasterRef 1660 - } 1661 - } 1662 - return nil 1663 - }) 1664 - 1665 - // Fetch roasters 1666 - g.Go(func() error { 1667 - output, err := publicClient.ListRecords(gCtx, did, atproto.NSIDRoaster, 100) 1668 - if err != nil { 1669 - return err 1670 - } 1671 - roasterMap = make(map[string]*models.Roaster) 1672 - roasters = make([]*models.Roaster, 0, len(output.Records)) 1673 - for _, record := range output.Records { 1674 - roaster, err := atproto.RecordToRoaster(record.Value, record.URI) 1675 - if err != nil { 1676 - continue 1677 - } 1678 - roasters = append(roasters, roaster) 1679 - roasterMap[record.URI] = roaster 1680 - } 1681 - return nil 1682 - }) 1683 - 1684 - // Fetch grinders 1685 - g.Go(func() error { 1686 - output, err := publicClient.ListRecords(gCtx, did, atproto.NSIDGrinder, 100) 1687 - if err != nil { 1688 - return err 1689 - } 1690 - grinderMap = make(map[string]*models.Grinder) 1691 - grinders = make([]*models.Grinder, 0, len(output.Records)) 1692 - for _, record := range output.Records { 1693 - grinder, err := atproto.RecordToGrinder(record.Value, record.URI) 1694 - if err != nil { 1695 - continue 1696 - } 1697 - grinders = append(grinders, grinder) 1698 - grinderMap[record.URI] = grinder 1699 - } 1700 - return nil 1701 - }) 1702 - 1703 - // Fetch brewers 1704 - g.Go(func() error { 1705 - output, err := publicClient.ListRecords(gCtx, did, atproto.NSIDBrewer, 100) 1706 - if err != nil { 1707 - return err 1708 - } 1709 - brewerMap = make(map[string]*models.Brewer) 1710 - brewers = make([]*models.Brewer, 0, len(output.Records)) 1711 - for _, record := range output.Records { 1712 - brewer, err := atproto.RecordToBrewer(record.Value, record.URI) 1713 - if err != nil { 1714 - continue 1715 - } 1716 - brewers = append(brewers, brewer) 1717 - brewerMap[record.URI] = brewer 1718 - } 1719 - return nil 1720 - }) 1721 - 1722 - // Fetch brews 1723 - g.Go(func() error { 1724 - output, err := publicClient.ListRecords(gCtx, did, atproto.NSIDBrew, 100) 1725 - if err != nil { 1726 - return err 1727 - } 1728 - brews = make([]*models.Brew, 0, len(output.Records)) 1729 - for _, record := range output.Records { 1730 - brew, err := atproto.RecordToBrew(record.Value, record.URI) 1731 - if err != nil { 1732 - continue 1733 - } 1734 - // Store the raw record for reference resolution later 1735 - brew.BeanRKey = "" // Will be resolved after all data is fetched 1736 - if beanRef, ok := record.Value["beanRef"].(string); ok { 1737 - brew.BeanRKey = beanRef 1738 - } 1739 - if grinderRef, ok := record.Value["grinderRef"].(string); ok { 1740 - brew.GrinderRKey = grinderRef 1741 - } 1742 - if brewerRef, ok := record.Value["brewerRef"].(string); ok { 1743 - brew.BrewerRKey = brewerRef 1744 - } 1745 - brews = append(brews, brew) 1746 - } 1747 - return nil 1748 - }) 1749 - 1750 - if err := g.Wait(); err != nil { 1751 - log.Error().Err(err).Str("did", did).Msg("Failed to fetch user data") 1752 - http.Error(w, "Failed to load profile data", http.StatusInternalServerError) 1753 - return 1754 - } 1755 - 1756 - // Resolve references for beans (roaster refs) 1757 - for _, bean := range beans { 1758 - if roasterRef, found := beanRoasterRefMap[atproto.BuildATURI(did, atproto.NSIDBean, bean.RKey)]; found { 1759 - if roaster, found := roasterMap[roasterRef]; found { 1760 - bean.Roaster = roaster 1761 - } 1762 - } 1763 - } 1764 - 1765 - // Resolve references for brews 1766 - for _, brew := range brews { 1767 - // Resolve bean reference 1768 - if brew.BeanRKey != "" { 1769 - if bean, found := beanMap[brew.BeanRKey]; found { 1770 - brew.Bean = bean 1771 - } 1772 - } 1773 - // Resolve grinder reference 1774 - if brew.GrinderRKey != "" { 1775 - if grinder, found := grinderMap[brew.GrinderRKey]; found { 1776 - brew.GrinderObj = grinder 1777 - } 1778 - } 1779 - // Resolve brewer reference 1780 - if brew.BrewerRKey != "" { 1781 - if brewer, found := brewerMap[brew.BrewerRKey]; found { 1782 - brew.BrewerObj = brewer 1783 - } 1784 - } 1785 - } 1786 - 1787 - // Sort brews in reverse chronological order (newest first) 1788 - sort.Slice(brews, func(i, j int) bool { 1789 - return brews[i].CreatedAt.After(brews[j].CreatedAt) 1790 - }) 1791 - 1792 - // Check if current user is authenticated (for nav bar state) 1793 - didStr, err := atproto.GetAuthenticatedDID(ctx) 1794 - isAuthenticated := err == nil && didStr != "" 1795 - 1796 - var userProfile *bff.UserProfile 1797 - if isAuthenticated { 1798 - userProfile = h.getUserProfile(ctx, didStr) 1799 - } 1800 - 1801 - // Check if the viewing user is the profile owner 1802 - isOwnProfile := isAuthenticated && didStr == did 1803 - 1804 - // Render profile page 1805 - if err := bff.RenderProfile(w, profile, brews, beans, roasters, grinders, brewers, isAuthenticated, didStr, userProfile, isOwnProfile); err != nil { 1806 - http.Error(w, "Failed to render page", http.StatusInternalServerError) 1807 - log.Error().Err(err).Msg("Failed to render profile page") 1808 - } 1809 - } 1810 1494 1811 1495 // HandleProfilePartial returns profile data content (loaded async via HTMX) 1812 1496 func (h *Handler) HandleProfilePartial(w http.ResponseWriter, r *http.Request) {
+7 -17
internal/routing/routing.go
··· 48 48 // API endpoint for feed (JSON) 49 49 mux.HandleFunc("GET /api/feed-json", h.HandleFeedAPI) 50 50 51 + // API endpoint for fetching public brew by AT-URI 52 + mux.HandleFunc("GET /api/brew", h.HandleBrewGetPublic) 53 + 51 54 // API endpoint for profile data (JSON for Svelte) 52 55 mux.HandleFunc("GET /api/profile-json/{actor}", h.HandleProfileAPI) 53 56 54 - // HTMX partials (loaded async via HTMX) 57 + // HTMX partials (legacy - being phased out) 55 58 // These return HTML fragments and should only be accessed via HTMX 59 + // Still used by manage page and some dynamic content 56 60 mux.Handle("GET /api/feed", middleware.RequireHTMXMiddleware(http.HandlerFunc(h.HandleFeedPartial))) 57 61 mux.Handle("GET /api/brews", middleware.RequireHTMXMiddleware(http.HandlerFunc(h.HandleBrewListPartial))) 58 62 mux.Handle("GET /api/manage", middleware.RequireHTMXMiddleware(http.HandlerFunc(h.HandleManagePartial))) 59 63 mux.Handle("GET /api/profile/{actor}", middleware.RequireHTMXMiddleware(http.HandlerFunc(h.HandleProfilePartial))) 60 64 61 - // Old page routes (commented out - now handled by Svelte SPA) 62 - // mux.HandleFunc("GET /{$}", h.HandleHome) // {$} means exact match 63 - // mux.HandleFunc("GET /about", h.HandleAbout) 64 - // mux.HandleFunc("GET /terms", h.HandleTerms) 65 - // mux.HandleFunc("GET /manage", h.HandleManage) 66 - // mux.HandleFunc("GET /brews", h.HandleBrewList) 67 - // mux.HandleFunc("GET /brews/new", h.HandleBrewNew) 68 - // mux.HandleFunc("GET /brews/{id}", h.HandleBrewView) 69 - // mux.HandleFunc("GET /brews/{id}/edit", h.HandleBrewEdit) 70 - 71 - // API routes for brews (POST/PUT/DELETE still needed by Svelte) 65 + // Brew CRUD API routes (used by Svelte SPA) 72 66 mux.Handle("POST /brews", cop.Handler(http.HandlerFunc(h.HandleBrewCreate))) 73 67 mux.Handle("PUT /brews/{id}", cop.Handler(http.HandlerFunc(h.HandleBrewUpdate))) 74 68 mux.Handle("DELETE /brews/{id}", cop.Handler(http.HandlerFunc(h.HandleBrewDelete))) 75 - // mux.HandleFunc("GET /brews/export", h.HandleBrewExport) 76 69 77 - // API routes for CRUD operations 70 + // Entity CRUD API routes (used by Svelte SPA) 78 71 mux.Handle("POST /api/beans", cop.Handler(http.HandlerFunc(h.HandleBeanCreate))) 79 72 mux.Handle("PUT /api/beans/{id}", cop.Handler(http.HandlerFunc(h.HandleBeanUpdate))) 80 73 mux.Handle("DELETE /api/beans/{id}", cop.Handler(http.HandlerFunc(h.HandleBeanDelete))) ··· 91 84 mux.Handle("PUT /api/brewers/{id}", cop.Handler(http.HandlerFunc(h.HandleBrewerUpdate))) 92 85 mux.Handle("DELETE /api/brewers/{id}", cop.Handler(http.HandlerFunc(h.HandleBrewerDelete))) 93 86 94 - // Profile routes (public user profiles) - commented out, handled by SPA 95 - // mux.HandleFunc("GET /profile/{actor}", h.HandleProfile) 96 - 97 87 // Static files (must come after specific routes) 98 88 fs := http.FileServer(http.Dir("web/static")) 99 89 mux.Handle("GET /static/", http.StripPrefix("/static/", fs))
-12
templates/404.tmpl
··· 1 - {{define "content"}} 2 - <div class="max-w-4xl mx-auto"> 3 - <div class="bg-gradient-to-br from-brown-100 to-brown-200 rounded-xl shadow-xl p-8 text-center border border-brown-300"> 4 - <div class="text-6xl mb-4 font-bold text-brown-800">404</div> 5 - <h2 class="text-2xl font-bold text-brown-900 mb-4">Page Not Found</h2> 6 - <p class="text-brown-700 mb-6">The page you're looking for doesn't exist or has been moved.</p> 7 - <a href="/" class="inline-block bg-gradient-to-r from-brown-700 to-brown-800 text-white py-3 px-6 rounded-lg hover:from-brown-800 hover:to-brown-900 transition-all font-medium shadow-lg hover:shadow-xl"> 8 - Back to Home 9 - </a> 10 - </div> 11 - </div> 12 - {{end}}
-112
templates/about.tmpl
··· 1 - {{template "layout" .}} 2 - 3 - {{define "content"}} 4 - <div class="max-w-3xl mx-auto"> 5 - <div class="flex items-center gap-3 mb-8"> 6 - <button 7 - data-back-button 8 - data-fallback="/" 9 - class="inline-flex items-center text-brown-700 hover:text-brown-900 font-medium transition-colors cursor-pointer"> 10 - <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> 11 - <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"></path> 12 - </svg> 13 - </button> 14 - <h1 class="text-4xl font-bold text-brown-900">About Arabica</h1> 15 - <span class="text-sm bg-amber-400 text-brown-900 px-3 py-1 rounded-md font-semibold shadow-sm">ALPHA</span> 16 - </div> 17 - 18 - <div class="bg-amber-50 border-l-4 border-amber-400 p-4 mb-6 rounded-r-lg"> 19 - <p class="text-sm text-brown-800"> 20 - <strong>Alpha Software:</strong> Arabica is currently in early development. Features may change, and data structures could be modified in future updates. 21 - </p> 22 - </div> 23 - 24 - <div class="prose prose-lg max-w-none space-y-6"> 25 - <section> 26 - <h2 class="text-2xl font-semibold text-brown-900 mb-4">Your Coffee Journey, Your Data</h2> 27 - <p class="text-brown-800 leading-relaxed"> 28 - Arabica is a coffee brew tracking application built on the AT Protocol, a decentralized social networking protocol. 29 - Unlike traditional apps where your data is locked in a company's database, Arabica stores your brew logs, 30 - coffee beans, and equipment information in <strong>your own Personal Data Server (PDS)</strong>. 31 - </p> 32 - </section> 33 - 34 - <section class="bg-gradient-to-br from-brown-100 to-brown-200 p-6 rounded-xl border border-brown-300"> 35 - <h3 class="text-xl font-semibold text-brown-900 mb-3">What Makes Arabica Different?</h3> 36 - <ul class="list-disc list-inside space-y-2 text-brown-800"> 37 - <li><strong>You own your data</strong> - All your brew logs live in your PDS, not our servers</li> 38 - <li><strong>Portable identity</strong> - Switch PDS providers anytime without losing your data</li> 39 - <li><strong>Privacy by design</strong> - You control who sees your brews</li> 40 - <li><strong>Open protocol</strong> - Built on the AT Protocol, the same technology powering Bluesky</li> 41 - </ul> 42 - </section> 43 - 44 - <section> 45 - <h2 class="text-2xl font-semibold text-brown-900 mb-4">Features</h2> 46 - <div class="grid md:grid-cols-2 gap-4"> 47 - <div class="bg-gradient-to-br from-brown-50 to-brown-100 border border-brown-200 p-4 rounded-lg shadow-md"> 48 - <h4 class="font-semibold text-brown-900 mb-2">Track Your Brews</h4> 49 - <p class="text-brown-700 text-sm">Log every detail: beans, grind size, water temp, brew time, and tasting notes</p> 50 - </div> 51 - <div class="bg-gradient-to-br from-brown-50 to-brown-100 border border-brown-200 p-4 rounded-lg shadow-md"> 52 - <h4 class="font-semibold text-brown-900 mb-2">Manage Equipment</h4> 53 - <p class="text-brown-700 text-sm">Keep track of your grinders, brewers, beans, and roasters</p> 54 - </div> 55 - <div class="bg-gradient-to-br from-brown-50 to-brown-100 border border-brown-200 p-4 rounded-lg shadow-md"> 56 - <h4 class="font-semibold text-brown-900 mb-2">Community Feed</h4> 57 - <p class="text-brown-700 text-sm">Share your best brews with the community (coming soon: likes and comments!)</p> 58 - </div> 59 - <div class="bg-gradient-to-br from-brown-50 to-brown-100 border border-brown-200 p-4 rounded-lg shadow-md"> 60 - <h4 class="font-semibold text-brown-900 mb-2">Export Your Data</h4> 61 - <p class="text-brown-700 text-sm">Export all your brews anytime in JSON format</p> 62 - </div> 63 - </div> 64 - </section> 65 - 66 - <section> 67 - <h2 class="text-2xl font-semibold text-brown-900 mb-4">The AT Protocol Advantage</h2> 68 - <p class="text-brown-800 leading-relaxed"> 69 - The AT Protocol is a decentralized social networking protocol that gives users true ownership of their data 70 - and identity. When you use Arabica: 71 - </p> 72 - <ul class="list-disc list-inside space-y-2 text-brown-800 mt-3"> 73 - <li>Your brew data is stored as ATProto records in collections on your PDS</li> 74 - <li>You authenticate via OAuth with your PDS, not with us</li> 75 - <li>References between records (like linking a brew to a bean) use AT-URIs</li> 76 - <li>Your identity is portable - change PDS providers without losing your account</li> 77 - </ul> 78 - </section> 79 - 80 - <section class="bg-gradient-to-br from-amber-50 to-brown-100 border-2 border-brown-300 p-6 rounded-xl shadow-lg"> 81 - <h3 class="text-xl font-semibold text-brown-900 mb-3">Getting Started</h3> 82 - <p class="text-brown-800 mb-4"> 83 - To use Arabica, you'll need an account on a PDS that supports the AT Protocol. 84 - The easiest way is to create a Bluesky account at <a href="https://bsky.app" class="text-brown-700 hover:underline font-medium" target="_blank" rel="noopener noreferrer">bsky.app</a>. 85 - </p> 86 - <p class="text-brown-800"> 87 - Once you have an account, simply log in with your handle (e.g., yourname.bsky.social) and start tracking your brews! 88 - </p> 89 - </section> 90 - 91 - <section> 92 - <h2 class="text-2xl font-semibold text-brown-900 mb-4">Open Source</h2> 93 - <p class="text-brown-800 leading-relaxed"> 94 - Arabica is open source software. You can view the code, contribute, or even run your own instance. 95 - Visit our <a href="https://github.com/ptdewey/arabica" class="text-brown-700 hover:underline font-medium" target="_blank" rel="noopener noreferrer">GitHub repository</a> to learn more. 96 - </p> 97 - </section> 98 - </div> 99 - 100 - <div class="mt-12 text-center"> 101 - {{if not .IsAuthenticated}} 102 - <a href="/login" class="inline-block bg-gradient-to-r from-brown-700 to-brown-800 text-white px-8 py-3 rounded-lg hover:from-brown-800 hover:to-brown-900 transition-all font-semibold shadow-lg hover:shadow-xl"> 103 - Get Started 104 - </a> 105 - {{else}} 106 - <a href="/brews/new" class="inline-block bg-gradient-to-r from-brown-700 to-brown-800 text-white px-8 py-3 rounded-lg hover:from-brown-800 hover:to-brown-900 transition-all font-semibold shadow-lg hover:shadow-xl"> 107 - Log Your Next Brew 108 - </a> 109 - {{end}} 110 - </div> 111 - </div> 112 - {{end}}
-278
templates/brew_form.tmpl
··· 1 - {{define "content"}} 2 - <script src="/static/js/brew-form.js?v=0.2.0"></script> 3 - 4 - <div class="max-w-2xl mx-auto" x-data="brewForm()"> 5 - <div class="bg-gradient-to-br from-brown-100 to-brown-200 rounded-xl shadow-xl p-8 border border-brown-300"> 6 - <!-- Header with Back Button --> 7 - <div class="flex items-center gap-3 mb-6"> 8 - <button 9 - data-back-button 10 - data-fallback="/brews" 11 - class="inline-flex items-center text-brown-700 hover:text-brown-900 font-medium transition-colors cursor-pointer"> 12 - <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> 13 - <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"></path> 14 - </svg> 15 - </button> 16 - <h2 class="text-3xl font-bold text-brown-900"> 17 - {{if .Brew}}Edit Brew{{else}}New Brew{{end}} 18 - </h2> 19 - </div> 20 - 21 - <form 22 - {{if .Brew}} 23 - hx-put="/brews/{{.Brew.RKey}}" 24 - {{else}} 25 - hx-post="/brews" 26 - {{end}} 27 - hx-target="body" 28 - class="space-y-6" 29 - {{if and .Brew .Brew.Pours}} 30 - data-pours='{{.Brew.PoursJSON}}' 31 - {{end}} 32 - x-init="init()"> 33 - 34 - <!-- Bean Selection --> 35 - <div> 36 - <label class="block text-sm font-medium text-brown-900 mb-2">Coffee Bean</label> 37 - <div class="flex gap-2"> 38 - <select 39 - name="bean_rkey" 40 - required 41 - class="flex-1 rounded-lg border-2 border-brown-300 shadow-sm focus:border-brown-600 focus:ring-brown-600 text-base py-3 px-4 truncate max-w-full bg-white"> 42 - <option value="">Select a bean...</option> 43 - {{if .Beans}} 44 - {{range .Beans}} 45 - <option 46 - value="{{.RKey}}" 47 - {{if and $.Brew (eq $.Brew.BeanRKey .RKey)}}selected{{end}} 48 - class="truncate"> 49 - {{if .Name}}{{.Name}} ({{.Origin}} - {{.RoastLevel}}){{else}}{{.Origin}} - {{.RoastLevel}}{{end}} 50 - </option> 51 - {{end}} 52 - {{else if .Brew}} 53 - <!-- Edit mode without server data - put selected value for JS to preserve --> 54 - <option value="{{.Brew.BeanRKey}}" selected>Loading...</option> 55 - {{end}} 56 - </select> 57 - <button 58 - type="button" 59 - @click="showBeanForm = true; editingBean = null; beanForm = {name: '', origin: '', roast_level: '', process: '', description: '', roaster_rkey: ''}" 60 - class="bg-brown-300 text-brown-900 px-4 py-2 rounded-lg hover:bg-brown-400 font-medium transition-colors"> 61 - + New 62 - </button> 63 - </div> 64 - </div> 65 - 66 - <!-- Coffee Amount --> 67 - <div> 68 - <label class="block text-sm font-medium text-brown-900 mb-2">Coffee Amount (grams)</label> 69 - <input 70 - type="number" 71 - name="coffee_amount" 72 - step="0.1" 73 - {{if and .Brew (gt .Brew.CoffeeAmount 0)}}value="{{.Brew.CoffeeAmount}}"{{end}} 74 - placeholder="e.g. 18" 75 - class="w-full rounded-lg border-2 border-brown-300 shadow-sm focus:border-brown-600 focus:ring-brown-600 text-base py-3 px-4 bg-white"/> 76 - <p class="text-sm text-brown-700 mt-1">Amount of ground coffee used</p> 77 - </div> 78 - 79 - <!-- Grinder --> 80 - <div> 81 - <label class="block text-sm font-medium text-brown-900 mb-2">Grinder</label> 82 - <div class="flex gap-2"> 83 - <select 84 - name="grinder_rkey" 85 - class="flex-1 rounded-lg border-2 border-brown-300 shadow-sm focus:border-brown-600 focus:ring-brown-600 text-base py-3 px-4 truncate max-w-full bg-white"> 86 - <option value="">Select a grinder...</option> 87 - {{if .Grinders}} 88 - {{range .Grinders}} 89 - <option 90 - value="{{.RKey}}" 91 - {{if and $.Brew (eq $.Brew.GrinderRKey .RKey)}}selected{{end}} 92 - class="truncate"> 93 - {{.Name}} 94 - </option> 95 - {{end}} 96 - {{else if and .Brew .Brew.GrinderRKey}} 97 - <!-- Edit mode without server data - put selected value for JS to preserve --> 98 - <option value="{{.Brew.GrinderRKey}}" selected>Loading...</option> 99 - {{end}} 100 - </select> 101 - <button 102 - type="button" 103 - @click="showGrinderForm = true; editingGrinder = null; grinderForm = {name: '', grinder_type: '', burr_type: '', notes: ''}" 104 - class="bg-brown-300 text-brown-900 px-4 py-2 rounded-lg hover:bg-brown-400 font-medium transition-colors"> 105 - + New 106 - </button> 107 - </div> 108 - </div> 109 - 110 - <!-- Grind Size --> 111 - <div> 112 - <label class="block text-sm font-medium text-brown-900 mb-2">Grind Size</label> 113 - <input 114 - type="text" 115 - name="grind_size" 116 - {{if .Brew}}value="{{.Brew.GrindSize}}"{{end}} 117 - placeholder="e.g. 18, Medium, 3.5, Fine" 118 - class="w-full rounded-lg border-2 border-brown-300 shadow-sm focus:border-brown-600 focus:ring-brown-600 text-base py-3 px-4 bg-white"/> 119 - <p class="text-sm text-brown-700 mt-1">Enter a number (grinder setting) or description (e.g. "Medium", "Fine")</p> 120 - </div> 121 - 122 - <!-- Brew Method --> 123 - <div> 124 - <label class="block text-sm font-medium text-brown-900 mb-2">Brew Method</label> 125 - <div class="flex gap-2"> 126 - <select 127 - name="brewer_rkey" 128 - class="flex-1 rounded-lg border-2 border-brown-300 shadow-sm focus:border-brown-600 focus:ring-brown-600 text-base py-3 px-4 truncate max-w-full bg-white"> 129 - <option value="">Select brew method...</option> 130 - {{if .Brewers}} 131 - {{range .Brewers}} 132 - <option 133 - value="{{.RKey}}" 134 - {{if and $.Brew (eq $.Brew.BrewerRKey .RKey)}}selected{{end}} 135 - class="truncate"> 136 - {{.Name}} 137 - </option> 138 - {{end}} 139 - {{else if and .Brew .Brew.BrewerRKey}} 140 - <!-- Edit mode without server data - put selected value for JS to preserve --> 141 - <option value="{{.Brew.BrewerRKey}}" selected>Loading...</option> 142 - {{end}} 143 - </select> 144 - <button 145 - type="button" 146 - @click="showBrewerForm = true; editingBrewer = null; brewerForm = {name: '', brewer_type: '', description: ''}" 147 - class="bg-brown-300 text-brown-900 px-4 py-2 rounded-lg hover:bg-brown-400 font-medium transition-colors"> 148 - + New 149 - </button> 150 - </div> 151 - </div> 152 - 153 - <!-- Water Amount --> 154 - <div> 155 - <label class="block text-sm font-medium text-brown-900 mb-2">Water Amount (grams)</label> 156 - <input 157 - type="number" 158 - name="water_amount" 159 - step="1" 160 - {{if and .Brew (gt .Brew.WaterAmount 0)}}value="{{.Brew.WaterAmount}}"{{end}} 161 - placeholder="e.g. 250" 162 - class="w-full rounded-lg border-2 border-brown-300 shadow-sm focus:border-brown-600 focus:ring-brown-600 text-base py-3 px-4 bg-white"/> 163 - <p class="text-sm text-brown-700 mt-1">Total water used (or leave empty if using pours below)</p> 164 - </div> 165 - 166 - <!-- Pours Section --> 167 - <div> 168 - <div class="flex items-center justify-between mb-2"> 169 - <label class="block text-sm font-medium text-brown-900">Pours (Optional)</label> 170 - <button 171 - type="button" 172 - @click="addPour()" 173 - class="text-sm bg-brown-300 text-brown-900 px-3 py-1 rounded-lg hover:bg-brown-400 font-medium transition-colors"> 174 - + Add Pour 175 - </button> 176 - </div> 177 - <p class="text-sm text-brown-700 mb-3">Track individual pours for bloom and subsequent additions</p> 178 - 179 - <div class="space-y-3"> 180 - <template x-for="(pour, index) in pours" :key="index"> 181 - <div class="flex gap-2 items-center bg-brown-50 p-3 rounded-lg border border-brown-200"> 182 - <div class="flex-1"> 183 - <label class="text-xs text-brown-700 font-medium" x-text="'Pour ' + (index + 1)"></label> 184 - <input 185 - type="number" 186 - :name="'pour_water_' + index" 187 - x-model="pour.water" 188 - placeholder="Water (g)" 189 - class="w-full rounded-md border-brown-300 text-sm py-2 px-3 mt-1 bg-white"/> 190 - </div> 191 - <div class="flex-1"> 192 - <label class="text-xs text-brown-700 font-medium">Time (sec)</label> 193 - <input 194 - type="number" 195 - :name="'pour_time_' + index" 196 - x-model="pour.time" 197 - placeholder="e.g. 45" 198 - class="w-full rounded-md border-brown-300 text-sm py-2 px-3 mt-1 bg-white"/> 199 - </div> 200 - <button 201 - type="button" 202 - @click="removePour(index)" 203 - class="text-brown-700 hover:text-brown-900 mt-5 font-bold" 204 - x-show="pours.length > 0"> 205 - 206 - </button> 207 - </div> 208 - </template> 209 - </div> 210 - </div> 211 - 212 - <!-- Temperature --> 213 - <div> 214 - <label class="block text-sm font-medium text-brown-900 mb-2">Temperature</label> 215 - <input 216 - type="number" 217 - name="temperature" 218 - step="0.1" 219 - {{if and .Brew (gt .Brew.Temperature 0.0)}}value="{{printf "%.1f" .Brew.Temperature}}"{{end}} 220 - placeholder="e.g. 93.5" 221 - class="w-full rounded-lg border-2 border-brown-300 shadow-sm focus:border-brown-600 focus:ring-brown-600 text-base py-3 px-4 bg-white"/> 222 - </div> 223 - 224 - <!-- Brew Time --> 225 - <div> 226 - <label class="block text-sm font-medium text-brown-900 mb-2">Brew Time (seconds)</label> 227 - <input 228 - type="number" 229 - name="time_seconds" 230 - {{if and .Brew (gt .Brew.TimeSeconds 0)}}value="{{.Brew.TimeSeconds}}"{{end}} 231 - placeholder="e.g. 180" 232 - class="w-full rounded-lg border-2 border-brown-300 shadow-sm focus:border-brown-600 focus:ring-brown-600 text-base py-3 px-4 bg-white"/> 233 - </div> 234 - 235 - <!-- Tasting Notes --> 236 - <div> 237 - <label class="block text-sm font-medium text-brown-900 mb-2">Tasting Notes</label> 238 - <textarea 239 - name="tasting_notes" 240 - rows="4" 241 - placeholder="Describe the flavors, aroma, and your thoughts..." 242 - class="w-full rounded-lg border-2 border-brown-300 shadow-sm focus:border-brown-600 focus:ring-brown-600 text-base py-3 px-4 bg-white">{{if .Brew}}{{.Brew.TastingNotes}}{{end}}</textarea> 243 - </div> 244 - 245 - <!-- Rating --> 246 - <div> 247 - <label class="block text-sm font-medium text-brown-900 mb-2">Rating</label> 248 - <input 249 - type="range" 250 - name="rating" 251 - min="1" 252 - max="10" 253 - {{if .Brew}}value="{{.Brew.Rating}}"{{else}}value="5"{{end}} 254 - x-model="rating" 255 - x-init="rating = $el.value" 256 - class="w-full accent-brown-700"/> 257 - <div class="text-center text-2xl font-bold text-brown-800"> 258 - <span x-text="rating"></span>/10 259 - </div> 260 - </div> 261 - 262 - <!-- Submit --> 263 - <div> 264 - <button 265 - type="submit" 266 - class="w-full bg-gradient-to-r from-brown-700 to-brown-800 text-white py-3 px-6 rounded-xl hover:from-brown-800 hover:to-brown-900 transition-all font-semibold text-lg shadow-lg hover:shadow-xl"> 267 - {{if .Brew}}Update Brew{{else}}Save Brew{{end}} 268 - </button> 269 - </div> 270 - </form> 271 - </div> 272 - 273 - <!-- Modals (outside form but within Alpine scope) --> 274 - {{template "bean_form_modal" .}} 275 - {{template "grinder_form_modal" .}} 276 - {{template "brewer_form_modal" .}} 277 - </div> 278 - {{end}}
-62
templates/brew_list.tmpl
··· 1 - {{define "content"}} 2 - <div class="max-w-6xl mx-auto"> 3 - <div class="mb-6 flex items-center justify-between"> 4 - <h2 class="text-3xl font-bold text-brown-900">Your Brews</h2> 5 - <a href="/brews/new" 6 - class="bg-gradient-to-r from-brown-700 to-brown-800 text-white py-2 px-4 rounded-lg hover:from-brown-800 hover:to-brown-900 transition-all font-medium shadow-lg hover:shadow-xl"> 7 - + New Brew 8 - </a> 9 - </div> 10 - 11 - <div hx-get="/api/brews" hx-trigger="load" hx-swap="innerHTML"> 12 - <!-- Loading skeleton --> 13 - <div class="overflow-x-auto bg-gradient-to-br from-brown-100 to-brown-200 rounded-xl shadow-xl border border-brown-300"> 14 - <table class="min-w-full divide-y divide-brown-300"> 15 - <thead class="bg-brown-200/80"> 16 - <tr> 17 - <th class="px-4 py-3 text-left text-xs font-medium text-brown-900 uppercase tracking-wider">📅 Date</th> 18 - <th class="px-4 py-3 text-left text-xs font-medium text-brown-900 uppercase tracking-wider">☕ Bean</th> 19 - <th class="px-4 py-3 text-left text-xs font-medium text-brown-900 uppercase tracking-wider">🫖 Brewer</th> 20 - <th class="px-4 py-3 text-left text-xs font-medium text-brown-900 uppercase tracking-wider">🔧 Variables</th> 21 - <th class="px-4 py-3 text-left text-xs font-medium text-brown-900 uppercase tracking-wider">📝 Notes</th> 22 - <th class="px-4 py-3 text-left text-xs font-medium text-brown-900 uppercase tracking-wider">⭐ Rating</th> 23 - <th class="px-4 py-3 text-left text-xs font-medium text-brown-900 uppercase tracking-wider">Actions</th> 24 - </tr> 25 - </thead> 26 - <tbody class="bg-brown-50/60 divide-y divide-brown-200"> 27 - {{range iterate 5}} 28 - <tr class="animate-pulse"> 29 - <td class="px-4 py-4 whitespace-nowrap"> 30 - <div class="h-4 bg-brown-300 rounded w-20"></div> 31 - </td> 32 - <td class="px-4 py-4"> 33 - <div class="h-4 bg-brown-300 rounded w-32 mb-2"></div> 34 - <div class="h-3 bg-brown-200 rounded w-24"></div> 35 - </td> 36 - <td class="px-4 py-4"> 37 - <div class="h-4 bg-brown-300 rounded w-24"></div> 38 - </td> 39 - <td class="px-4 py-4"> 40 - <div class="h-3 bg-brown-200 rounded w-20 mb-1"></div> 41 - <div class="h-3 bg-brown-200 rounded w-16"></div> 42 - </td> 43 - <td class="px-4 py-4"> 44 - <div class="h-3 bg-brown-200 rounded w-40"></div> 45 - </td> 46 - <td class="px-4 py-4"> 47 - <div class="h-5 bg-amber-200 rounded-full w-14"></div> 48 - </td> 49 - <td class="px-4 py-4"> 50 - <div class="flex gap-2"> 51 - <div class="h-4 bg-brown-300 rounded w-10"></div> 52 - <div class="h-4 bg-brown-300 rounded w-12"></div> 53 - </div> 54 - </td> 55 - </tr> 56 - {{end}} 57 - </tbody> 58 - </table> 59 - </div> 60 - </div> 61 - </div> 62 - {{end}}
-174
templates/brew_view.tmpl
··· 1 - {{define "content"}} 2 - <div class="max-w-2xl mx-auto"> 3 - <div class="bg-gradient-to-br from-brown-100 to-brown-200 rounded-xl shadow-xl p-8 border border-brown-300"> 4 - <!-- Header with title and actions --> 5 - <div class="flex justify-between items-start mb-6"> 6 - <div> 7 - <h2 class="text-3xl font-bold text-brown-900">Brew Details</h2> 8 - <p class="text-sm text-brown-600 mt-1">{{.Brew.CreatedAt.Format "January 2, 2006 at 3:04 PM"}}</p> 9 - </div> 10 - {{if .IsOwnProfile}} 11 - <div class="flex gap-2"> 12 - <a href="/brews/{{.Brew.RKey}}/edit" 13 - class="inline-flex items-center bg-brown-300 text-brown-900 px-4 py-2 rounded-lg hover:bg-brown-400 font-medium transition-colors"> 14 - Edit 15 - </a> 16 - <button 17 - hx-delete="/brews/{{.Brew.RKey}}" 18 - hx-confirm="Are you sure you want to delete this brew?" 19 - hx-target="body" 20 - class="inline-flex items-center bg-brown-200 text-brown-700 px-4 py-2 rounded-lg hover:bg-brown-300 font-medium transition-colors"> 21 - Delete 22 - </button> 23 - </div> 24 - {{end}} 25 - </div> 26 - 27 - <div class="space-y-6"> 28 - <!-- Rating (prominent at top) --> 29 - {{if hasValue .Brew.Rating}} 30 - <div class="text-center py-4 bg-brown-50 rounded-lg border border-brown-200"> 31 - <div class="text-4xl font-bold text-brown-800"> 32 - {{.Brew.Rating}}/10 33 - </div> 34 - <div class="text-sm text-brown-600 mt-1">Rating</div> 35 - </div> 36 - {{end}} 37 - 38 - <!-- Coffee Bean --> 39 - <div class="bg-brown-50 rounded-lg p-4 border border-brown-200"> 40 - <h3 class="text-sm font-medium text-brown-600 uppercase tracking-wider mb-2">Coffee Bean</h3> 41 - {{if .Brew.Bean}} 42 - <div class="font-bold text-lg text-brown-900"> 43 - {{if .Brew.Bean.Name}}{{.Brew.Bean.Name}}{{else}}{{.Brew.Bean.Origin}}{{end}} 44 - </div> 45 - {{if and .Brew.Bean.Roaster .Brew.Bean.Roaster.Name}} 46 - <div class="text-sm text-brown-700 mt-1"> 47 - by {{.Brew.Bean.Roaster.Name}} 48 - </div> 49 - {{end}} 50 - <div class="flex flex-wrap gap-3 mt-2 text-sm text-brown-600"> 51 - {{if .Brew.Bean.Origin}}<span>Origin: {{.Brew.Bean.Origin}}</span>{{end}} 52 - {{if .Brew.Bean.RoastLevel}}<span>Roast: {{.Brew.Bean.RoastLevel}}</span>{{end}} 53 - </div> 54 - {{else}} 55 - <span class="text-brown-400">Not specified</span> 56 - {{end}} 57 - </div> 58 - 59 - <!-- Brew Parameters --> 60 - <div class="grid grid-cols-2 gap-4"> 61 - <!-- Brew Method --> 62 - <div class="bg-brown-50 rounded-lg p-4 border border-brown-200"> 63 - <h3 class="text-sm font-medium text-brown-600 uppercase tracking-wider mb-2">Brew Method</h3> 64 - {{if .Brew.BrewerObj}} 65 - <div class="font-semibold text-brown-900">{{.Brew.BrewerObj.Name}}</div> 66 - {{else if .Brew.Method}} 67 - <div class="font-semibold text-brown-900">{{.Brew.Method}}</div> 68 - {{else}} 69 - <span class="text-brown-400">Not specified</span> 70 - {{end}} 71 - </div> 72 - 73 - <!-- Grinder --> 74 - <div class="bg-brown-50 rounded-lg p-4 border border-brown-200"> 75 - <h3 class="text-sm font-medium text-brown-600 uppercase tracking-wider mb-2">Grinder</h3> 76 - {{if .Brew.GrinderObj}} 77 - <div class="font-semibold text-brown-900">{{.Brew.GrinderObj.Name}}</div> 78 - {{else}} 79 - <span class="text-brown-400">Not specified</span> 80 - {{end}} 81 - </div> 82 - 83 - <!-- Coffee Amount --> 84 - <div class="bg-brown-50 rounded-lg p-4 border border-brown-200"> 85 - <h3 class="text-sm font-medium text-brown-600 uppercase tracking-wider mb-2">Coffee</h3> 86 - {{if hasValue .Brew.CoffeeAmount}} 87 - <div class="font-semibold text-brown-900">{{.Brew.CoffeeAmount}}g</div> 88 - {{else}} 89 - <span class="text-brown-400">Not specified</span> 90 - {{end}} 91 - </div> 92 - 93 - <!-- Water Amount --> 94 - <div class="bg-brown-50 rounded-lg p-4 border border-brown-200"> 95 - <h3 class="text-sm font-medium text-brown-600 uppercase tracking-wider mb-2">Water</h3> 96 - {{if hasValue .Brew.WaterAmount}} 97 - <div class="font-semibold text-brown-900">{{.Brew.WaterAmount}}g</div> 98 - {{else}} 99 - <span class="text-brown-400">Not specified</span> 100 - {{end}} 101 - </div> 102 - 103 - <!-- Grind Size --> 104 - <div class="bg-brown-50 rounded-lg p-4 border border-brown-200"> 105 - <h3 class="text-sm font-medium text-brown-600 uppercase tracking-wider mb-2">Grind Size</h3> 106 - {{if .Brew.GrindSize}} 107 - <div class="font-semibold text-brown-900">{{.Brew.GrindSize}}</div> 108 - {{else}} 109 - <span class="text-brown-400">Not specified</span> 110 - {{end}} 111 - </div> 112 - 113 - <!-- Temperature --> 114 - <div class="bg-brown-50 rounded-lg p-4 border border-brown-200"> 115 - <h3 class="text-sm font-medium text-brown-600 uppercase tracking-wider mb-2">Temperature</h3> 116 - {{if hasTemp .Brew.Temperature}} 117 - <div class="font-semibold text-brown-900">{{formatTemp .Brew.Temperature}}</div> 118 - {{else}} 119 - <span class="text-brown-400">Not specified</span> 120 - {{end}} 121 - </div> 122 - 123 - <!-- Brew Time --> 124 - <div class="bg-brown-50 rounded-lg p-4 border border-brown-200 col-span-2"> 125 - <h3 class="text-sm font-medium text-brown-600 uppercase tracking-wider mb-2">Brew Time</h3> 126 - {{if hasValue .Brew.TimeSeconds}} 127 - <div class="font-semibold text-brown-900">{{formatTime .Brew.TimeSeconds}}</div> 128 - {{else}} 129 - <span class="text-brown-400">Not specified</span> 130 - {{end}} 131 - </div> 132 - </div> 133 - 134 - <!-- Pours --> 135 - {{if .Brew.Pours}} 136 - <div class="bg-brown-50 rounded-lg p-4 border border-brown-200"> 137 - <h3 class="text-sm font-medium text-brown-600 uppercase tracking-wider mb-3">Pours</h3> 138 - <div class="space-y-2"> 139 - {{range .Brew.Pours}} 140 - <div class="flex justify-between items-center bg-white p-3 rounded-lg border border-brown-200"> 141 - <div class="flex gap-4 text-sm"> 142 - <span class="font-semibold text-brown-800">{{.WaterAmount}}g</span> 143 - <span class="text-brown-600">@ {{formatTime .TimeSeconds}}</span> 144 - </div> 145 - </div> 146 - {{end}} 147 - </div> 148 - </div> 149 - {{end}} 150 - 151 - <!-- Tasting Notes --> 152 - {{if .Brew.TastingNotes}} 153 - <div class="bg-brown-50 rounded-lg p-4 border border-brown-200"> 154 - <h3 class="text-sm font-medium text-brown-600 uppercase tracking-wider mb-2">Tasting Notes</h3> 155 - <div class="text-brown-900 whitespace-pre-wrap">{{.Brew.TastingNotes}}</div> 156 - </div> 157 - {{end}} 158 - 159 - <!-- Back Button --> 160 - <div class="pt-4"> 161 - <button 162 - data-back-button 163 - data-fallback="/brews" 164 - class="inline-flex items-center text-brown-700 hover:text-brown-900 font-medium transition-colors cursor-pointer"> 165 - <svg class="w-5 h-5 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> 166 - <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"></path> 167 - </svg> 168 - Back 169 - </button> 170 - </div> 171 - </div> 172 - </div> 173 - </div> 174 - {{end}}
-93
templates/home.tmpl
··· 1 - {{define "content"}} 2 - <div class="max-w-4xl mx-auto"> 3 - <div class="bg-gradient-to-br from-brown-100 to-brown-200 rounded-xl shadow-xl p-8 mb-8 border border-brown-300"> 4 - <div class="flex items-center gap-3 mb-4"> 5 - <h2 class="text-3xl font-bold text-brown-900">Welcome to Arabica</h2> 6 - <span class="text-xs bg-amber-400 text-brown-900 px-2 py-1 rounded-md font-semibold shadow-sm">ALPHA</span> 7 - </div> 8 - <p class="text-brown-800 mb-2 text-lg">Track your coffee brewing journey with detailed logs of every cup.</p> 9 - <p class="text-sm text-brown-700 italic mb-6">Note: Arabica is currently in alpha. Features and data structures may change.</p> 10 - 11 - {{if .IsAuthenticated}} 12 - <!-- Authenticated: Show app actions --> 13 - <div class="mb-6"> 14 - <p class="text-sm text-brown-700">Logged in as: <span class="font-mono text-brown-900 font-semibold">{{.UserDID}}</span></p> 15 - </div> 16 - <div class="grid grid-cols-1 md:grid-cols-2 gap-4"> 17 - <a href="/brews/new" 18 - class="block bg-gradient-to-br from-brown-700 to-brown-800 text-white text-center py-4 px-6 rounded-xl hover:from-brown-800 hover:to-brown-900 transition-all shadow-lg hover:shadow-xl transform"> 19 - <span class="text-xl font-semibold">☕ Add New Brew</span> 20 - </a> 21 - <a href="/brews" 22 - class="block bg-gradient-to-br from-brown-500 to-brown-600 text-white text-center py-4 px-6 rounded-xl hover:from-brown-600 hover:to-brown-700 transition-all shadow-lg hover:shadow-xl"> 23 - <span class="text-xl font-semibold">📋 View All Brews</span> 24 - </a> 25 - </div> 26 - {{else}} 27 - <!-- Not authenticated: Show login --> 28 - <div> 29 - <p class="text-brown-800 mb-6 text-center text-lg">Please log in with your AT Protocol handle to start tracking your brews.</p> 30 - <form method="POST" action="/auth/login" class="max-w-md mx-auto"> 31 - <div class="relative"> 32 - <label for="handle" class="block text-sm font-medium text-brown-900 mb-2">Your Handle</label> 33 - <input 34 - type="text" 35 - id="handle" 36 - name="handle" 37 - placeholder="alice.bsky.social" 38 - autocomplete="off" 39 - required 40 - class="w-full px-4 py-3 border-2 border-brown-300 rounded-lg focus:ring-2 focus:ring-brown-600 focus:border-brown-600 bg-white" 41 - /> 42 - <!-- FIX: image is way too big--> 43 - <div id="autocomplete-results" class="hidden absolute z-10 w-full mt-1 bg-brown-50 border-2 border-brown-300 rounded-lg shadow-lg max-h-60 overflow-y-auto"></div> 44 - </div> 45 - <button 46 - type="submit" 47 - class="w-full mt-4 bg-gradient-to-r from-brown-700 to-brown-800 text-white py-3 px-8 rounded-lg hover:from-brown-800 hover:to-brown-900 transition-all text-lg font-semibold shadow-lg hover:shadow-xl"> 48 - Log In 49 - </button> 50 - </form> 51 - 52 - <script src="/static/js/handle-autocomplete.js?v=0.2.0"></script> 53 - </div> 54 - {{end}} 55 - </div> 56 - 57 - <!-- Community Feed --> 58 - <div class="bg-gradient-to-br from-brown-100 to-brown-200 rounded-xl shadow-xl p-6 mb-8 border border-brown-300"> 59 - <h3 class="text-xl font-bold text-brown-900 mb-4">☕ Community Feed</h3> 60 - <div hx-get="/api/feed" hx-trigger="load" hx-swap="innerHTML"> 61 - <!-- Loading state --> 62 - <div class="space-y-4"> 63 - <div class="animate-pulse"> 64 - <div class="bg-brown-50 rounded-lg p-4 border border-brown-200"> 65 - <div class="flex items-center gap-3 mb-3"> 66 - <div class="w-10 h-10 rounded-full bg-brown-300"></div> 67 - <div class="flex-1"> 68 - <div class="h-4 bg-brown-300 rounded w-1/4 mb-2"></div> 69 - <div class="h-3 bg-brown-200 rounded w-1/6"></div> 70 - </div> 71 - </div> 72 - <div class="bg-brown-200 rounded-lg p-3"> 73 - <div class="h-4 bg-brown-300 rounded w-3/4 mb-2"></div> 74 - <div class="h-3 bg-brown-200 rounded w-1/2"></div> 75 - </div> 76 - </div> 77 - </div> 78 - </div> 79 - </div> 80 - </div> 81 - 82 - <div class="bg-gradient-to-br from-amber-50 to-brown-100 rounded-xl p-6 border-2 border-brown-300 shadow-lg"> 83 - <h3 class="text-lg font-bold text-brown-900 mb-3">✨ About Arabica</h3> 84 - <ul class="text-brown-800 space-y-2 leading-relaxed"> 85 - <li class="flex items-start"><span class="mr-2">🔒</span><span><strong>Decentralized:</strong> Your data lives in your Personal Data Server (PDS)</span></li> 86 - <li class="flex items-start"><span class="mr-2">🚀</span><span><strong>Portable:</strong> Own your coffee brewing history</span></li> 87 - <li class="flex items-start"><span class="mr-2">📊</span><span>Track brewing variables like temperature, time, and grind size</span></li> 88 - <li class="flex items-start"><span class="mr-2">🌍</span><span>Organize beans by origin and roaster</span></li> 89 - <li class="flex items-start"><span class="mr-2">📝</span><span>Add tasting notes and ratings to each brew</span></li> 90 - </ul> 91 - </div> 92 - </div> 93 - {{end}}
-35
templates/layout.tmpl
··· 1 - {{define "layout"}} 2 - <!DOCTYPE html> 3 - <html lang="en" class="h-full"> 4 - <head> 5 - <meta charset="UTF-8" /> 6 - <meta name="viewport" content="width=device-width, initial-scale=1.0" /> 7 - <meta name="description" content="Arabica is a coffee brew tracking app built on AT Protocol. Your brewing data is stored in your own Personal Data Server, giving you full ownership and portability." /> 8 - <meta property="og:title" content="Arabica - Coffee Brew Tracker" /> 9 - <meta property="og:description" content="Track your coffee brewing journey. Built on AT Protocol, your data stays yours." /> 10 - <meta property="og:type" content="website" /> 11 - <meta name="theme-color" content="#4a2c2a" /> 12 - <title>{{.Title}} - Arabica</title> 13 - <link rel="icon" href="/static/favicon.svg" type="image/svg+xml" /> 14 - <link rel="icon" href="/static/favicon-32.svg" type="image/svg+xml" sizes="32x32" /> 15 - <link rel="apple-touch-icon" href="/static/icon-192.svg" /> 16 - <link rel="stylesheet" href="/static/css/output.css?v=0.2.0" /> 17 - <style>[x-cloak] { display: none !important; }</style> 18 - <link rel="manifest" href="/static/manifest.json" /> 19 - <script src="/static/js/alpine.min.js?v=0.2.0" defer></script> 20 - <script src="/static/js/htmx.min.js?v=0.2.0"></script> 21 - {{if .IsAuthenticated}} 22 - <script src="/static/js/data-cache.js?v=0.2.0"></script> 23 - {{end}} 24 - <script src="/static/js/back-button.js?v=0.2.0"></script> 25 - <script src="/static/js/sw-register.js?v=0.2.0"></script> 26 - </head> 27 - <body class="bg-brown-50 min-h-full flex flex-col"{{if .UserDID}} data-user-did="{{.UserDID}}"{{end}}> 28 - {{template "header" .}} 29 - <main class="flex-grow container mx-auto px-4 py-8"> 30 - {{template "content" .}} 31 - </main> 32 - {{template "footer" .}} 33 - </body> 34 - </html> 35 - {{end}}
-240
templates/profile.tmpl
··· 1 - {{define "content"}} 2 - {{if .IsOwnProfile}} 3 - <!-- Load manage page JavaScript before Alpine.js processes the page --> 4 - <script src="/static/js/manage-page.js?v=0.2.0"></script> 5 - {{end}} 6 - <!-- Load profile stats updater --> 7 - <script src="/static/js/profile-stats.js?v=0.2.0"></script> 8 - {{if .IsOwnProfile}} 9 - <div class="max-w-4xl mx-auto" x-data="managePage()"> 10 - {{else}} 11 - <div class="max-w-4xl mx-auto" x-data="{ activeTab: 'brews' }"> 12 - {{end}} 13 - <!-- Profile Header --> 14 - <div class="bg-gradient-to-br from-brown-100 to-brown-200 rounded-xl shadow-xl p-6 mb-6 border border-brown-300"> 15 - <div class="flex items-center gap-4"> 16 - {{if .Profile.Avatar}} 17 - {{$safeAvatar := safeAvatarURL .Profile.Avatar}} 18 - {{if $safeAvatar}} 19 - <img src="{{$safeAvatar}}" alt="" class="w-20 h-20 rounded-full object-cover border-2 border-brown-300" /> 20 - {{else}} 21 - <div class="w-20 h-20 rounded-full bg-brown-300 flex items-center justify-center"> 22 - <span class="text-brown-600 text-2xl">?</span> 23 - </div> 24 - {{end}} 25 - {{else}} 26 - <div class="w-20 h-20 rounded-full bg-brown-300 flex items-center justify-center"> 27 - <span class="text-brown-600 text-2xl">?</span> 28 - </div> 29 - {{end}} 30 - <div> 31 - {{if .Profile.DisplayName}} 32 - <h1 class="text-2xl font-bold text-brown-900">{{.Profile.DisplayName}}</h1> 33 - {{end}} 34 - <p class="text-brown-700">@{{.Profile.Handle}}</p> 35 - </div> 36 - </div> 37 - </div> 38 - 39 - <!-- Stats (load immediately with placeholder values) --> 40 - <div class="grid grid-cols-2 md:grid-cols-5 gap-4 mb-6"> 41 - <div class="bg-gradient-to-br from-brown-100 to-brown-200 rounded-lg shadow-md p-4 text-center border border-brown-300"> 42 - <div class="text-2xl font-bold text-brown-800" data-stat="brews">-</div> 43 - <div class="text-sm text-brown-700">Brews</div> 44 - </div> 45 - <div class="bg-gradient-to-br from-brown-100 to-brown-200 rounded-lg shadow-md p-4 text-center border border-brown-300"> 46 - <div class="text-2xl font-bold text-brown-800" data-stat="beans">-</div> 47 - <div class="text-sm text-brown-700">Beans</div> 48 - </div> 49 - <div class="bg-gradient-to-br from-brown-100 to-brown-200 rounded-lg shadow-md p-4 text-center border border-brown-300"> 50 - <div class="text-2xl font-bold text-brown-800" data-stat="roasters">-</div> 51 - <div class="text-sm text-brown-700">Roasters</div> 52 - </div> 53 - <div class="bg-gradient-to-br from-brown-100 to-brown-200 rounded-lg shadow-md p-4 text-center border border-brown-300"> 54 - <div class="text-2xl font-bold text-brown-800" data-stat="grinders">-</div> 55 - <div class="text-sm text-brown-700">Grinders</div> 56 - </div> 57 - <div class="bg-gradient-to-br from-brown-100 to-brown-200 rounded-lg shadow-md p-4 text-center border border-brown-300"> 58 - <div class="text-2xl font-bold text-brown-800" data-stat="brewers">-</div> 59 - <div class="text-sm text-brown-700">Brewers</div> 60 - </div> 61 - </div> 62 - 63 - <!-- Tabs for content sections --> 64 - <div> 65 - <!-- Tab buttons (show immediately) --> 66 - <div class="bg-gradient-to-br from-brown-100 to-brown-200 rounded-xl shadow-md mb-4 border border-brown-300"> 67 - <div class="flex border-b border-brown-300"> 68 - <button 69 - @click="activeTab = 'brews'" 70 - :class="activeTab === 'brews' ? 'border-b-2 border-brown-700 text-brown-900' : 'text-brown-600 hover:text-brown-800'" 71 - class="flex-1 py-3 px-4 text-center font-medium transition-colors"> 72 - Brews 73 - </button> 74 - <button 75 - @click="activeTab = 'beans'" 76 - :class="activeTab === 'beans' ? 'border-b-2 border-brown-700 text-brown-900' : 'text-brown-600 hover:text-brown-800'" 77 - class="flex-1 py-3 px-4 text-center font-medium transition-colors"> 78 - Beans 79 - </button> 80 - <button 81 - @click="activeTab = 'gear'" 82 - :class="activeTab === 'gear' ? 'border-b-2 border-brown-700 text-brown-900' : 'text-brown-600 hover:text-brown-800'" 83 - class="flex-1 py-3 px-4 text-center font-medium transition-colors"> 84 - Gear 85 - </button> 86 - </div> 87 - </div> 88 - 89 - <!-- Tab content loaded via HTMX --> 90 - <div id="profile-content" hx-get="/api/profile/{{.Profile.Handle}}" hx-trigger="load" hx-swap="innerHTML" hx-on::after-swap="Alpine.initTree(document.getElementById('profile-content'))"> 91 - <!-- Loading skeleton --> 92 - <div class="animate-pulse"> 93 - <!-- Brews Tab Skeleton --> 94 - <div> 95 - <div class="overflow-x-auto bg-gradient-to-br from-brown-100 to-brown-200 rounded-xl shadow-xl border border-brown-300"> 96 - <table class="min-w-full divide-y divide-brown-300"> 97 - <thead class="bg-brown-200/80"> 98 - <tr> 99 - <th class="px-6 py-3 text-left text-xs font-medium text-brown-900 uppercase tracking-wider">Date</th> 100 - <th class="px-6 py-3 text-left text-xs font-medium text-brown-900 uppercase tracking-wider">Bean</th> 101 - <th class="px-6 py-3 text-left text-xs font-medium text-brown-900 uppercase tracking-wider">Method</th> 102 - <th class="px-6 py-3 text-left text-xs font-medium text-brown-900 uppercase tracking-wider">Rating</th> 103 - <th class="px-6 py-3 text-left text-xs font-medium text-brown-900 uppercase tracking-wider">Notes</th> 104 - </tr> 105 - </thead> 106 - <tbody class="bg-brown-50/60 divide-y divide-brown-200"> 107 - {{range iterate 3}} 108 - <tr> 109 - <td class="px-6 py-4"><div class="h-4 bg-brown-300 rounded w-20"></div></td> 110 - <td class="px-6 py-4"><div class="h-4 bg-brown-300 rounded w-32"></div></td> 111 - <td class="px-6 py-4"><div class="h-4 bg-brown-300 rounded w-24"></div></td> 112 - <td class="px-6 py-4"><div class="h-4 bg-brown-300 rounded w-16"></div></td> 113 - <td class="px-6 py-4"><div class="h-4 bg-brown-300 rounded w-40"></div></td> 114 - </tr> 115 - {{end}} 116 - </tbody> 117 - </table> 118 - </div> 119 - </div> 120 - </div> 121 - </div> 122 - </div> 123 - 124 - {{if .IsOwnProfile}} 125 - <!-- Bean Form Modal --> 126 - <div x-cloak x-show="showBeanForm" class="fixed inset-0 bg-black/40 flex items-center justify-center z-50"> 127 - <div class="bg-gradient-to-br from-brown-100 to-brown-200 rounded-xl border-2 border-brown-300 p-8 max-w-md w-full mx-4 shadow-2xl"> 128 - <h3 class="text-xl font-semibold mb-4 text-brown-900" x-text="editingBean ? 'Edit Bean' : 'Add Bean'"></h3> 129 - <div class="space-y-4"> 130 - <input type="text" x-model="beanForm.name" placeholder="Name *" 131 - class="w-full rounded-lg border-2 border-brown-300 bg-white shadow-sm py-2 px-3 focus:border-brown-600 focus:ring-brown-600" /> 132 - <input type="text" x-model="beanForm.origin" placeholder="Origin *" 133 - class="w-full rounded-lg border-2 border-brown-300 bg-white shadow-sm py-2 px-3 focus:border-brown-600 focus:ring-brown-600" /> 134 - <select x-model="beanForm.roaster_rkey" class="w-full rounded-lg border-2 border-brown-300 bg-white shadow-sm py-2 px-3 focus:border-brown-600 focus:ring-brown-600"> 135 - <option value="">Select Roaster (Optional)</option> 136 - {{range .Roasters}} 137 - <option value="{{.RKey}}">{{.Name}}</option> 138 - {{end}} 139 - </select> 140 - <select x-model="beanForm.roast_level" class="w-full rounded-lg border-2 border-brown-300 bg-white shadow-sm py-2 px-3 focus:border-brown-600 focus:ring-brown-600"> 141 - <option value="">Select Roast Level (Optional)</option> 142 - <option value="Ultra-Light">Ultra-Light</option> 143 - <option value="Light">Light</option> 144 - <option value="Medium-Light">Medium-Light</option> 145 - <option value="Medium">Medium</option> 146 - <option value="Medium-Dark">Medium-Dark</option> 147 - <option value="Dark">Dark</option> 148 - </select> 149 - <input type="text" x-model="beanForm.process" placeholder="Process (e.g. Washed, Natural, Honey)" 150 - class="w-full rounded-lg border-2 border-brown-300 bg-white shadow-sm py-2 px-3 focus:border-brown-600 focus:ring-brown-600" /> 151 - <textarea x-model="beanForm.description" placeholder="Description" rows="3" 152 - class="w-full rounded-lg border-2 border-brown-300 bg-white shadow-sm py-2 px-3 focus:border-brown-600 focus:ring-brown-600"></textarea> 153 - <div class="flex gap-2"> 154 - <button @click="saveBean()" 155 - class="flex-1 bg-gradient-to-r from-brown-700 to-brown-800 text-white px-4 py-2 rounded-lg hover:from-brown-800 hover:to-brown-900 font-medium transition-all shadow-md">Save</button> 156 - <button @click="showBeanForm = false" 157 - class="flex-1 bg-brown-300 text-brown-900 px-4 py-2 rounded-lg hover:bg-brown-400 font-medium transition-colors">Cancel</button> 158 - </div> 159 - </div> 160 - </div> 161 - </div> 162 - 163 - <!-- Roaster Form Modal --> 164 - <div x-cloak x-show="showRoasterForm" class="fixed inset-0 bg-black/40 flex items-center justify-center z-50"> 165 - <div class="bg-gradient-to-br from-brown-100 to-brown-200 rounded-xl border-2 border-brown-300 p-8 max-w-md w-full mx-4 shadow-2xl"> 166 - <h3 class="text-xl font-semibold mb-4 text-brown-900" x-text="editingRoaster ? 'Edit Roaster' : 'Add Roaster'"></h3> 167 - <div class="space-y-4"> 168 - <input type="text" x-model="roasterForm.name" placeholder="Name *" 169 - class="w-full rounded-lg border-2 border-brown-300 bg-white shadow-sm py-2 px-3 focus:border-brown-600 focus:ring-brown-600" /> 170 - <input type="text" x-model="roasterForm.location" placeholder="Location" 171 - class="w-full rounded-lg border-2 border-brown-300 bg-white shadow-sm py-2 px-3 focus:border-brown-600 focus:ring-brown-600" /> 172 - <input type="url" x-model="roasterForm.website" placeholder="Website" 173 - class="w-full rounded-lg border-2 border-brown-300 bg-white shadow-sm py-2 px-3 focus:border-brown-600 focus:ring-brown-600" /> 174 - <div class="flex gap-2"> 175 - <button @click="saveRoaster()" 176 - class="flex-1 bg-gradient-to-r from-brown-700 to-brown-800 text-white px-4 py-2 rounded-lg hover:from-brown-800 hover:to-brown-900 font-medium transition-all shadow-md">Save</button> 177 - <button @click="showRoasterForm = false" 178 - class="flex-1 bg-brown-300 text-brown-900 px-4 py-2 rounded-lg hover:bg-brown-400 font-medium transition-colors">Cancel</button> 179 - </div> 180 - </div> 181 - </div> 182 - </div> 183 - 184 - <!-- Grinder Form Modal --> 185 - <div x-cloak x-show="showGrinderForm" class="fixed inset-0 bg-black/40 flex items-center justify-center z-50"> 186 - <div class="bg-gradient-to-br from-brown-100 to-brown-200 rounded-xl border-2 border-brown-300 p-8 max-w-md w-full mx-4 shadow-2xl"> 187 - <h3 class="text-xl font-semibold mb-4 text-brown-900" x-text="editingGrinder ? 'Edit Grinder' : 'Add Grinder'"></h3> 188 - <div class="space-y-4"> 189 - <input type="text" x-model="grinderForm.name" placeholder="Name *" 190 - class="w-full rounded-lg border-2 border-brown-300 bg-white shadow-sm py-2 px-3 focus:border-brown-600 focus:ring-brown-600" /> 191 - <select x-model="grinderForm.grinder_type" class="w-full rounded-lg border-2 border-brown-300 bg-white shadow-sm py-2 px-3 focus:border-brown-600 focus:ring-brown-600"> 192 - <option value="">Select Grinder Type *</option> 193 - <option value="Hand">Hand</option> 194 - <option value="Electric">Electric</option> 195 - <option value="Portable Electric">Portable Electric</option> 196 - </select> 197 - <select x-model="grinderForm.burr_type" class="w-full rounded-lg border-2 border-brown-300 bg-white shadow-sm py-2 px-3 focus:border-brown-600 focus:ring-brown-600"> 198 - <option value="">Select Burr Type (Optional)</option> 199 - <option value="Conical">Conical</option> 200 - <option value="Flat">Flat</option> 201 - </select> 202 - <textarea x-model="grinderForm.notes" placeholder="Notes" rows="3" 203 - class="w-full rounded-lg border-2 border-brown-300 bg-white shadow-sm py-2 px-3 focus:border-brown-600 focus:ring-brown-600"></textarea> 204 - <div class="flex gap-2"> 205 - <button @click="saveGrinder()" 206 - class="flex-1 bg-gradient-to-r from-brown-700 to-brown-800 text-white px-4 py-2 rounded-lg hover:from-brown-800 hover:to-brown-900 font-medium transition-all shadow-md">Save</button> 207 - <button @click="showGrinderForm = false" 208 - class="flex-1 bg-brown-300 text-brown-900 px-4 py-2 rounded-lg hover:bg-brown-400 font-medium transition-colors">Cancel</button> 209 - </div> 210 - </div> 211 - </div> 212 - </div> 213 - 214 - <!-- Brewer Form Modal --> 215 - <div x-cloak x-show="showBrewerForm" class="fixed inset-0 bg-black/40 flex items-center justify-center z-50"> 216 - <div class="bg-gradient-to-br from-brown-100 to-brown-200 rounded-xl border-2 border-brown-300 p-8 max-w-md w-full mx-4 shadow-2xl"> 217 - <h3 class="text-xl font-semibold mb-4 text-brown-900" x-text="editingBrewer ? 'Edit Brewer' : 'Add Brewer'"></h3> 218 - <div class="space-y-4"> 219 - <input type="text" x-model="brewerForm.name" placeholder="Name *" 220 - class="w-full rounded-lg border-2 border-brown-300 bg-white shadow-sm py-2 px-3 focus:border-brown-600 focus:ring-brown-600" /> 221 - <input type="text" x-model="brewerForm.brewer_type" placeholder="Type (e.g., Pour-Over, Immersion, Espresso)" 222 - class="w-full rounded-lg border-2 border-brown-300 bg-white shadow-sm py-2 px-3 focus:border-brown-600 focus:ring-brown-600" /> 223 - <textarea x-model="brewerForm.description" placeholder="Description" rows="3" 224 - class="w-full rounded-lg border-2 border-brown-300 bg-white shadow-sm py-2 px-3 focus:border-brown-600 focus:ring-brown-600"></textarea> 225 - <div class="flex gap-2"> 226 - <button @click="saveBrewer()" 227 - class="flex-1 bg-gradient-to-r from-brown-700 to-brown-800 text-white px-4 py-2 rounded-lg hover:from-brown-800 hover:to-brown-900 font-medium transition-all shadow-md">Save</button> 228 - <button @click="showBrewerForm = false" 229 - class="flex-1 bg-brown-300 text-brown-900 px-4 py-2 rounded-lg hover:bg-brown-400 font-medium transition-colors">Cancel</button> 230 - </div> 231 - </div> 232 - </div> 233 - </div> 234 - {{end}} 235 - </div> 236 - 237 - <style> 238 - [x-cloak] { display: none !important; } 239 - </style> 240 - {{end}}
-156
templates/terms.tmpl
··· 1 - {{template "layout" .}} 2 - 3 - {{define "content"}} 4 - <div class="max-w-3xl mx-auto"> 5 - <div class="flex items-center gap-3 mb-8"> 6 - <button 7 - data-back-button 8 - data-fallback="/" 9 - class="inline-flex items-center text-brown-700 hover:text-brown-900 font-medium transition-colors cursor-pointer"> 10 - <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> 11 - <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"></path> 12 - </svg> 13 - </button> 14 - <h1 class="text-4xl font-bold text-brown-800">Terms of Service</h1> 15 - </div> 16 - 17 - <div class="prose prose-lg max-w-none space-y-6"> 18 - <section class="bg-green-50 border border-green-200 p-6 rounded-lg mb-8"> 19 - <h2 class="text-2xl font-semibold text-green-900 mb-4">The Simple Truth</h2> 20 - <p class="text-gray-800 text-lg leading-relaxed"> 21 - <strong>You own all of your data.</strong> Period. Your brew logs, coffee beans, equipment information, 22 - and any other data you create in Arabica belongs to you and is stored in your Personal Data Server (PDS), 23 - not on our servers. 24 - </p> 25 - </section> 26 - 27 - <section> 28 - <h2 class="text-2xl font-semibold text-brown-800 mb-4">1. Your Data Ownership</h2> 29 - <p class="text-gray-700 leading-relaxed"> 30 - All data you create through Arabica is stored in your AT Protocol Personal Data Server (PDS). 31 - Arabica acts as an interface to your PDS but does not own, claim rights to, or permanently store your data. 32 - </p> 33 - <ul class="list-disc list-inside space-y-2 text-gray-700 mt-3"> 34 - <li>You retain full ownership and control of your data</li> 35 - <li>You can export your data at any time</li> 36 - <li>You can delete your data at any time</li> 37 - <li>You can switch PDS providers without losing your data</li> 38 - <li>You can stop using Arabica and your data remains in your PDS</li> 39 - </ul> 40 - </section> 41 - 42 - <section> 43 - <h2 class="text-2xl font-semibold text-brown-800 mb-4">2. What We Store</h2> 44 - <p class="text-gray-700 leading-relaxed mb-3"> 45 - Arabica's servers store minimal data necessary for the application to function: 46 - </p> 47 - <ul class="list-disc list-inside space-y-2 text-gray-700"> 48 - <li><strong>Session information</strong> - Temporary authentication tokens to keep you logged in</li> 49 - <li><strong>Feed registry</strong> - List of users who've opted into the community feed</li> 50 - <li><strong>Temporary cache</strong> - Short-lived cache (5 minutes) of your data to improve performance</li> 51 - </ul> 52 - <p class="text-gray-700 leading-relaxed mt-3"> 53 - We do <strong>not</strong> store your brew logs, beans, equipment, or any other user-generated content 54 - on our servers. That data lives exclusively in your PDS. 55 - </p> 56 - </section> 57 - 58 - <section> 59 - <h2 class="text-2xl font-semibold text-brown-800 mb-4">3. Authentication</h2> 60 - <p class="text-gray-700 leading-relaxed"> 61 - Arabica uses OAuth to authenticate with your PDS. We never see or store your PDS password. 62 - Authentication is handled between your browser and your PDS, with Arabica receiving only 63 - temporary access tokens to read and write data on your behalf. 64 - </p> 65 - </section> 66 - 67 - <section> 68 - <h2 class="text-2xl font-semibold text-brown-800 mb-4">4. Community Feed</h2> 69 - <p class="text-gray-700 leading-relaxed"> 70 - If you opt into the community feed, Arabica will periodically read your public brew records 71 - from your PDS to display them to other users. This is done by: 72 - </p> 73 - <ul class="list-disc list-inside space-y-2 text-gray-700 mt-3"> 74 - <li>Making public API calls to your PDS</li> 75 - <li>Temporarily caching brew data for feed display</li> 76 - <li>Not storing your data permanently on our servers</li> 77 - </ul> 78 - <p class="text-gray-700 leading-relaxed mt-3"> 79 - You can opt out of the community feed at any time, and we'll stop reading your brews. 80 - </p> 81 - </section> 82 - 83 - <section> 84 - <h2 class="text-2xl font-semibold text-brown-800 mb-4">5. Service Availability</h2> 85 - <p class="text-gray-700 leading-relaxed"> 86 - Arabica is provided "as is" without warranties of any kind. We make reasonable efforts to keep 87 - the service running but do not guarantee uptime or availability. Since your data is stored in 88 - your PDS (not our servers), you won't lose your data if Arabica goes offline. 89 - </p> 90 - </section> 91 - 92 - <section> 93 - <h2 class="text-2xl font-semibold text-brown-800 mb-4">6. Privacy</h2> 94 - <p class="text-gray-700 leading-relaxed"> 95 - We respect your privacy and follow these principles: 96 - </p> 97 - <ul class="list-disc list-inside space-y-2 text-gray-700 mt-3"> 98 - <li>We don't sell your data (because we don't have it to sell!)</li> 99 - <li>We don't track you across websites</li> 100 - <li>We use minimal analytics to understand service usage</li> 101 - <li>We don't share your data with third parties</li> 102 - <li>Your PDS and the AT Protocol control the privacy of your brew data</li> 103 - </ul> 104 - </section> 105 - 106 - <section> 107 - <h2 class="text-2xl font-semibold text-brown-800 mb-4">7. Open Source</h2> 108 - <p class="text-gray-700 leading-relaxed"> 109 - Arabica is open source software. You can review the code, run your own instance, or contribute 110 - improvements. The transparency of open source means you can verify that we're handling your data 111 - as described in these terms. 112 - </p> 113 - </section> 114 - 115 - <section> 116 - <h2 class="text-2xl font-semibold text-brown-800 mb-4">8. Changes to Terms</h2> 117 - <p class="text-gray-700 leading-relaxed"> 118 - We may update these terms occasionally. If we make significant changes, we'll notify users through 119 - the application. Continued use of Arabica after changes constitutes acceptance of the new terms. 120 - </p> 121 - </section> 122 - 123 - <section> 124 - <h2 class="text-2xl font-semibold text-brown-800 mb-4">9. Acceptable Use</h2> 125 - <p class="text-gray-700 leading-relaxed"> 126 - Please use Arabica responsibly: 127 - </p> 128 - <ul class="list-disc list-inside space-y-2 text-gray-700 mt-3"> 129 - <li>Don't attempt to access other users' data without permission</li> 130 - <li>Don't abuse the service with excessive API requests</li> 131 - <li>Don't use Arabica for illegal purposes</li> 132 - <li>Be respectful in community interactions</li> 133 - </ul> 134 - </section> 135 - 136 - <section> 137 - <h2 class="text-2xl font-semibold text-brown-800 mb-4">10. Contact</h2> 138 - <p class="text-gray-700 leading-relaxed"> 139 - Questions about these terms? You can reach us through our GitHub repository or by email at 140 - <a href="mailto:mail@arabica.systems" class="text-blue-600 hover:underline">mail@arabica.systems</a>. 141 - </p> 142 - </section> 143 - 144 - <section class="bg-gray-100 p-6 rounded-lg mt-8"> 145 - <p class="text-sm text-gray-600"> 146 - <strong>Last Updated:</strong> January 2026<br> 147 - <strong>Effective Date:</strong> January 2026 148 - </p> 149 - </section> 150 - </div> 151 - 152 - <div class="mt-12 text-center"> 153 - <a href="/" class="text-blue-600 hover:underline">Back to Home</a> 154 - </div> 155 - </div> 156 - {{end}}
+1 -1
web/static/app/index.html
··· 18 18 <!-- Web Manifest --> 19 19 <link rel="manifest" href="/static/manifest.json"> 20 20 <meta name="theme-color" content="#78350f"> 21 - <script type="module" crossorigin src="/static/app/assets/index-Du5RSqvf.js"></script> 21 + <script type="module" crossorigin src="/static/app/assets/index-PnQOiph1.js"></script> 22 22 <link rel="stylesheet" crossorigin href="/static/app/assets/index-C3lHx5fe.css"> 23 23 </head> 24 24 <body class="bg-brown-50 text-brown-900 min-h-screen">
-6
web/static/js/alpine.min.js
··· 1 - (()=>{var nt=!1,it=!1,G=[],ot=-1;function Ut(e){In(e)}function In(e){G.includes(e)||G.push(e),$n()}function Wt(e){let t=G.indexOf(e);t!==-1&&t>ot&&G.splice(t,1)}function $n(){!it&&!nt&&(nt=!0,queueMicrotask(Ln))}function Ln(){nt=!1,it=!0;for(let e=0;e<G.length;e++)G[e](),ot=e;G.length=0,ot=-1,it=!1}var R,N,F,at,st=!0;function Gt(e){st=!1,e(),st=!0}function Jt(e){R=e.reactive,F=e.release,N=t=>e.effect(t,{scheduler:r=>{st?Ut(r):r()}}),at=e.raw}function ct(e){N=e}function Yt(e){let t=()=>{};return[n=>{let i=N(n);return e._x_effects||(e._x_effects=new Set,e._x_runEffects=()=>{e._x_effects.forEach(o=>o())}),e._x_effects.add(i),t=()=>{i!==void 0&&(e._x_effects.delete(i),F(i))},i},()=>{t()}]}function Oe(e,t){let r=!0,n,i=N(()=>{let o=e();JSON.stringify(o),r?n=o:queueMicrotask(()=>{t(o,n),n=o}),r=!1});return()=>F(i)}var Xt=[],Zt=[],Qt=[];function er(e){Qt.push(e)}function re(e,t){typeof t=="function"?(e._x_cleanups||(e._x_cleanups=[]),e._x_cleanups.push(t)):(t=e,Zt.push(t))}function Re(e){Xt.push(e)}function Te(e,t,r){e._x_attributeCleanups||(e._x_attributeCleanups={}),e._x_attributeCleanups[t]||(e._x_attributeCleanups[t]=[]),e._x_attributeCleanups[t].push(r)}function lt(e,t){e._x_attributeCleanups&&Object.entries(e._x_attributeCleanups).forEach(([r,n])=>{(t===void 0||t.includes(r))&&(n.forEach(i=>i()),delete e._x_attributeCleanups[r])})}function tr(e){for(e._x_effects?.forEach(Wt);e._x_cleanups?.length;)e._x_cleanups.pop()()}var ut=new MutationObserver(mt),ft=!1;function pe(){ut.observe(document,{subtree:!0,childList:!0,attributes:!0,attributeOldValue:!0}),ft=!0}function dt(){jn(),ut.disconnect(),ft=!1}var de=[];function jn(){let e=ut.takeRecords();de.push(()=>e.length>0&&mt(e));let t=de.length;queueMicrotask(()=>{if(de.length===t)for(;de.length>0;)de.shift()()})}function m(e){if(!ft)return e();dt();let t=e();return pe(),t}var pt=!1,Ce=[];function rr(){pt=!0}function nr(){pt=!1,mt(Ce),Ce=[]}function mt(e){if(pt){Ce=Ce.concat(e);return}let t=[],r=new Set,n=new Map,i=new Map;for(let o=0;o<e.length;o++)if(!e[o].target._x_ignoreMutationObserver&&(e[o].type==="childList"&&(e[o].removedNodes.forEach(s=>{s.nodeType===1&&s._x_marker&&r.add(s)}),e[o].addedNodes.forEach(s=>{if(s.nodeType===1){if(r.has(s)){r.delete(s);return}s._x_marker||t.push(s)}})),e[o].type==="attributes")){let s=e[o].target,a=e[o].attributeName,c=e[o].oldValue,l=()=>{n.has(s)||n.set(s,[]),n.get(s).push({name:a,value:s.getAttribute(a)})},u=()=>{i.has(s)||i.set(s,[]),i.get(s).push(a)};s.hasAttribute(a)&&c===null?l():s.hasAttribute(a)?(u(),l()):u()}i.forEach((o,s)=>{lt(s,o)}),n.forEach((o,s)=>{Xt.forEach(a=>a(s,o))});for(let o of r)t.some(s=>s.contains(o))||Zt.forEach(s=>s(o));for(let o of t)o.isConnected&&Qt.forEach(s=>s(o));t=null,r=null,n=null,i=null}function Me(e){return k(B(e))}function D(e,t,r){return e._x_dataStack=[t,...B(r||e)],()=>{e._x_dataStack=e._x_dataStack.filter(n=>n!==t)}}function B(e){return e._x_dataStack?e._x_dataStack:typeof ShadowRoot=="function"&&e instanceof ShadowRoot?B(e.host):e.parentNode?B(e.parentNode):[]}function k(e){return new Proxy({objects:e},Fn)}var Fn={ownKeys({objects:e}){return Array.from(new Set(e.flatMap(t=>Object.keys(t))))},has({objects:e},t){return t==Symbol.unscopables?!1:e.some(r=>Object.prototype.hasOwnProperty.call(r,t)||Reflect.has(r,t))},get({objects:e},t,r){return t=="toJSON"?Bn:Reflect.get(e.find(n=>Reflect.has(n,t))||{},t,r)},set({objects:e},t,r,n){let i=e.find(s=>Object.prototype.hasOwnProperty.call(s,t))||e[e.length-1],o=Object.getOwnPropertyDescriptor(i,t);return o?.set&&o?.get?o.set.call(n,r)||!0:Reflect.set(i,t,r)}};function Bn(){return Reflect.ownKeys(this).reduce((t,r)=>(t[r]=Reflect.get(this,r),t),{})}function ne(e){let t=n=>typeof n=="object"&&!Array.isArray(n)&&n!==null,r=(n,i="")=>{Object.entries(Object.getOwnPropertyDescriptors(n)).forEach(([o,{value:s,enumerable:a}])=>{if(a===!1||s===void 0||typeof s=="object"&&s!==null&&s.__v_skip)return;let c=i===""?o:`${i}.${o}`;typeof s=="object"&&s!==null&&s._x_interceptor?n[o]=s.initialize(e,c,o):t(s)&&s!==n&&!(s instanceof Element)&&r(s,c)})};return r(e)}function Ne(e,t=()=>{}){let r={initialValue:void 0,_x_interceptor:!0,initialize(n,i,o){return e(this.initialValue,()=>zn(n,i),s=>ht(n,i,s),i,o)}};return t(r),n=>{if(typeof n=="object"&&n!==null&&n._x_interceptor){let i=r.initialize.bind(r);r.initialize=(o,s,a)=>{let c=n.initialize(o,s,a);return r.initialValue=c,i(o,s,a)}}else r.initialValue=n;return r}}function zn(e,t){return t.split(".").reduce((r,n)=>r[n],e)}function ht(e,t,r){if(typeof t=="string"&&(t=t.split(".")),t.length===1)e[t[0]]=r;else{if(t.length===0)throw error;return e[t[0]]||(e[t[0]]={}),ht(e[t[0]],t.slice(1),r)}}var ir={};function y(e,t){ir[e]=t}function K(e,t){let r=Hn(t);return Object.entries(ir).forEach(([n,i])=>{Object.defineProperty(e,`$${n}`,{get(){return i(t,r)},enumerable:!1})}),e}function Hn(e){let[t,r]=_t(e),n={interceptor:Ne,...t};return re(e,r),n}function or(e,t,r,...n){try{return r(...n)}catch(i){ie(i,e,t)}}function ie(...e){return sr(...e)}var sr=Kn;function ar(e){sr=e}function Kn(e,t,r=void 0){e=Object.assign(e??{message:"No error message given."},{el:t,expression:r}),console.warn(`Alpine Expression Error: ${e.message} 2 - 3 - ${r?'Expression: "'+r+`" 4 - 5 - `:""}`,t),setTimeout(()=>{throw e},0)}var oe=!0;function De(e){let t=oe;oe=!1;let r=e();return oe=t,r}function T(e,t,r={}){let n;return x(e,t)(i=>n=i,r),n}function x(...e){return cr(...e)}var cr=xt;function lr(e){cr=e}var ur;function fr(e){ur=e}function xt(e,t){let r={};K(r,e);let n=[r,...B(e)],i=typeof t=="function"?Vn(n,t):Un(n,t,e);return or.bind(null,e,t,i)}function Vn(e,t){return(r=()=>{},{scope:n={},params:i=[],context:o}={})=>{if(!oe){me(r,t,k([n,...e]),i);return}let s=t.apply(k([n,...e]),i);me(r,s)}}var gt={};function qn(e,t){if(gt[e])return gt[e];let r=Object.getPrototypeOf(async function(){}).constructor,n=/^[\n\s]*if.*\(.*\)/.test(e.trim())||/^(let|const)\s/.test(e.trim())?`(async()=>{ ${e} })()`:e,o=(()=>{try{let s=new r(["__self","scope"],`with (scope) { __self.result = ${n} }; __self.finished = true; return __self.result;`);return Object.defineProperty(s,"name",{value:`[Alpine] ${e}`}),s}catch(s){return ie(s,t,e),Promise.resolve()}})();return gt[e]=o,o}function Un(e,t,r){let n=qn(t,r);return(i=()=>{},{scope:o={},params:s=[],context:a}={})=>{n.result=void 0,n.finished=!1;let c=k([o,...e]);if(typeof n=="function"){let l=n.call(a,n,c).catch(u=>ie(u,r,t));n.finished?(me(i,n.result,c,s,r),n.result=void 0):l.then(u=>{me(i,u,c,s,r)}).catch(u=>ie(u,r,t)).finally(()=>n.result=void 0)}}}function me(e,t,r,n,i){if(oe&&typeof t=="function"){let o=t.apply(r,n);o instanceof Promise?o.then(s=>me(e,s,r,n)).catch(s=>ie(s,i,t)):e(o)}else typeof t=="object"&&t instanceof Promise?t.then(o=>e(o)):e(t)}function dr(...e){return ur(...e)}function pr(e,t,r={}){let n={};K(n,e);let i=[n,...B(e)],o=k([r.scope??{},...i]),s=r.params??[];if(t.includes("await")){let a=Object.getPrototypeOf(async function(){}).constructor,c=/^[\n\s]*if.*\(.*\)/.test(t.trim())||/^(let|const)\s/.test(t.trim())?`(async()=>{ ${t} })()`:t;return new a(["scope"],`with (scope) { let __result = ${c}; return __result }`).call(r.context,o)}else{let a=/^[\n\s]*if.*\(.*\)/.test(t.trim())||/^(let|const)\s/.test(t.trim())?`(()=>{ ${t} })()`:t,l=new Function(["scope"],`with (scope) { let __result = ${a}; return __result }`).call(r.context,o);return typeof l=="function"&&oe?l.apply(o,s):l}}var wt="x-";function C(e=""){return wt+e}function mr(e){wt=e}var ke={};function d(e,t){return ke[e]=t,{before(r){if(!ke[r]){console.warn(String.raw`Cannot find directive \`${r}\`. \`${e}\` will use the default order of execution`);return}let n=J.indexOf(r);J.splice(n>=0?n:J.indexOf("DEFAULT"),0,e)}}}function hr(e){return Object.keys(ke).includes(e)}function _e(e,t,r){if(t=Array.from(t),e._x_virtualDirectives){let o=Object.entries(e._x_virtualDirectives).map(([a,c])=>({name:a,value:c})),s=Et(o);o=o.map(a=>s.find(c=>c.name===a.name)?{name:`x-bind:${a.name}`,value:`"${a.value}"`}:a),t=t.concat(o)}let n={};return t.map(xr((o,s)=>n[o]=s)).filter(br).map(Gn(n,r)).sort(Jn).map(o=>Wn(e,o))}function Et(e){return Array.from(e).map(xr()).filter(t=>!br(t))}var yt=!1,he=new Map,_r=Symbol();function gr(e){yt=!0;let t=Symbol();_r=t,he.set(t,[]);let r=()=>{for(;he.get(t).length;)he.get(t).shift()();he.delete(t)},n=()=>{yt=!1,r()};e(r),n()}function _t(e){let t=[],r=a=>t.push(a),[n,i]=Yt(e);return t.push(i),[{Alpine:z,effect:n,cleanup:r,evaluateLater:x.bind(x,e),evaluate:T.bind(T,e)},()=>t.forEach(a=>a())]}function Wn(e,t){let r=()=>{},n=ke[t.type]||r,[i,o]=_t(e);Te(e,t.original,o);let s=()=>{e._x_ignore||e._x_ignoreSelf||(n.inline&&n.inline(e,t,i),n=n.bind(n,e,t,i),yt?he.get(_r).push(n):n())};return s.runCleanups=o,s}var Pe=(e,t)=>({name:r,value:n})=>(r.startsWith(e)&&(r=r.replace(e,t)),{name:r,value:n}),Ie=e=>e;function xr(e=()=>{}){return({name:t,value:r})=>{let{name:n,value:i}=yr.reduce((o,s)=>s(o),{name:t,value:r});return n!==t&&e(n,t),{name:n,value:i}}}var yr=[];function se(e){yr.push(e)}function br({name:e}){return wr().test(e)}var wr=()=>new RegExp(`^${wt}([^:^.]+)\\b`);function Gn(e,t){return({name:r,value:n})=>{r===n&&(n="");let i=r.match(wr()),o=r.match(/:([a-zA-Z0-9\-_:]+)/),s=r.match(/\.[^.\]]+(?=[^\]]*$)/g)||[],a=t||e[r]||r;return{type:i?i[1]:null,value:o?o[1]:null,modifiers:s.map(c=>c.replace(".","")),expression:n,original:a}}}var bt="DEFAULT",J=["ignore","ref","data","id","anchor","bind","init","for","model","modelable","transition","show","if",bt,"teleport"];function Jn(e,t){let r=J.indexOf(e.type)===-1?bt:e.type,n=J.indexOf(t.type)===-1?bt:t.type;return J.indexOf(r)-J.indexOf(n)}function Y(e,t,r={}){e.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,composed:!0,cancelable:!0}))}function P(e,t){if(typeof ShadowRoot=="function"&&e instanceof ShadowRoot){Array.from(e.children).forEach(i=>P(i,t));return}let r=!1;if(t(e,()=>r=!0),r)return;let n=e.firstElementChild;for(;n;)P(n,t,!1),n=n.nextElementSibling}function E(e,...t){console.warn(`Alpine Warning: ${e}`,...t)}var Er=!1;function vr(){Er&&E("Alpine has already been initialized on this page. Calling Alpine.start() more than once can cause problems."),Er=!0,document.body||E("Unable to initialize. Trying to load Alpine before `<body>` is available. Did you forget to add `defer` in Alpine's `<script>` tag?"),Y(document,"alpine:init"),Y(document,"alpine:initializing"),pe(),er(t=>S(t,P)),re(t=>$(t)),Re((t,r)=>{_e(t,r).forEach(n=>n())});let e=t=>!X(t.parentElement,!0);Array.from(document.querySelectorAll(Or().join(","))).filter(e).forEach(t=>{S(t)}),Y(document,"alpine:initialized"),setTimeout(()=>{Xn()})}var vt=[],Sr=[];function Ar(){return vt.map(e=>e())}function Or(){return vt.concat(Sr).map(e=>e())}function $e(e){vt.push(e)}function Le(e){Sr.push(e)}function X(e,t=!1){return I(e,r=>{if((t?Or():Ar()).some(i=>r.matches(i)))return!0})}function I(e,t){if(e){if(t(e))return e;if(e._x_teleportBack&&(e=e._x_teleportBack),e.parentNode instanceof ShadowRoot)return I(e.parentNode.host,t);if(e.parentElement)return I(e.parentElement,t)}}function Cr(e){return Ar().some(t=>e.matches(t))}var Rr=[];function Tr(e){Rr.push(e)}var Yn=1;function S(e,t=P,r=()=>{}){I(e,n=>n._x_ignore)||gr(()=>{t(e,(n,i)=>{n._x_marker||(r(n,i),Rr.forEach(o=>o(n,i)),_e(n,n.attributes).forEach(o=>o()),n._x_ignore||(n._x_marker=Yn++),n._x_ignore&&i())})})}function $(e,t=P){t(e,r=>{tr(r),lt(r),delete r._x_marker})}function Xn(){[["ui","dialog",["[x-dialog], [x-popover]"]],["anchor","anchor",["[x-anchor]"]],["sort","sort",["[x-sort]"]]].forEach(([t,r,n])=>{hr(r)||n.some(i=>{if(document.querySelector(i))return E(`found "${i}", but missing ${t} plugin`),!0})})}var St=[],At=!1;function ae(e=()=>{}){return queueMicrotask(()=>{At||setTimeout(()=>{je()})}),new Promise(t=>{St.push(()=>{e(),t()})})}function je(){for(At=!1;St.length;)St.shift()()}function Mr(){At=!0}function ge(e,t){return Array.isArray(t)?Nr(e,t.join(" ")):typeof t=="object"&&t!==null?Zn(e,t):typeof t=="function"?ge(e,t()):Nr(e,t)}function Nr(e,t){let r=o=>o.split(" ").filter(Boolean),n=o=>o.split(" ").filter(s=>!e.classList.contains(s)).filter(Boolean),i=o=>(e.classList.add(...o),()=>{e.classList.remove(...o)});return t=t===!0?t="":t||"",i(n(t))}function Zn(e,t){let r=a=>a.split(" ").filter(Boolean),n=Object.entries(t).flatMap(([a,c])=>c?r(a):!1).filter(Boolean),i=Object.entries(t).flatMap(([a,c])=>c?!1:r(a)).filter(Boolean),o=[],s=[];return i.forEach(a=>{e.classList.contains(a)&&(e.classList.remove(a),s.push(a))}),n.forEach(a=>{e.classList.contains(a)||(e.classList.add(a),o.push(a))}),()=>{s.forEach(a=>e.classList.add(a)),o.forEach(a=>e.classList.remove(a))}}function Z(e,t){return typeof t=="object"&&t!==null?Qn(e,t):ei(e,t)}function Qn(e,t){let r={};return Object.entries(t).forEach(([n,i])=>{r[n]=e.style[n],n.startsWith("--")||(n=ti(n)),e.style.setProperty(n,i)}),setTimeout(()=>{e.style.length===0&&e.removeAttribute("style")}),()=>{Z(e,r)}}function ei(e,t){let r=e.getAttribute("style",t);return e.setAttribute("style",t),()=>{e.setAttribute("style",r||"")}}function ti(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function xe(e,t=()=>{}){let r=!1;return function(){r?t.apply(this,arguments):(r=!0,e.apply(this,arguments))}}d("transition",(e,{value:t,modifiers:r,expression:n},{evaluate:i})=>{typeof n=="function"&&(n=i(n)),n!==!1&&(!n||typeof n=="boolean"?ni(e,r,t):ri(e,n,t))});function ri(e,t,r){Dr(e,ge,""),{enter:i=>{e._x_transition.enter.during=i},"enter-start":i=>{e._x_transition.enter.start=i},"enter-end":i=>{e._x_transition.enter.end=i},leave:i=>{e._x_transition.leave.during=i},"leave-start":i=>{e._x_transition.leave.start=i},"leave-end":i=>{e._x_transition.leave.end=i}}[r](t)}function ni(e,t,r){Dr(e,Z);let n=!t.includes("in")&&!t.includes("out")&&!r,i=n||t.includes("in")||["enter"].includes(r),o=n||t.includes("out")||["leave"].includes(r);t.includes("in")&&!n&&(t=t.filter((g,b)=>b<t.indexOf("out"))),t.includes("out")&&!n&&(t=t.filter((g,b)=>b>t.indexOf("out")));let s=!t.includes("opacity")&&!t.includes("scale"),a=s||t.includes("opacity"),c=s||t.includes("scale"),l=a?0:1,u=c?ye(t,"scale",95)/100:1,p=ye(t,"delay",0)/1e3,h=ye(t,"origin","center"),w="opacity, transform",H=ye(t,"duration",150)/1e3,Ae=ye(t,"duration",75)/1e3,f="cubic-bezier(0.4, 0.0, 0.2, 1)";i&&(e._x_transition.enter.during={transformOrigin:h,transitionDelay:`${p}s`,transitionProperty:w,transitionDuration:`${H}s`,transitionTimingFunction:f},e._x_transition.enter.start={opacity:l,transform:`scale(${u})`},e._x_transition.enter.end={opacity:1,transform:"scale(1)"}),o&&(e._x_transition.leave.during={transformOrigin:h,transitionDelay:`${p}s`,transitionProperty:w,transitionDuration:`${Ae}s`,transitionTimingFunction:f},e._x_transition.leave.start={opacity:1,transform:"scale(1)"},e._x_transition.leave.end={opacity:l,transform:`scale(${u})`})}function Dr(e,t,r={}){e._x_transition||(e._x_transition={enter:{during:r,start:r,end:r},leave:{during:r,start:r,end:r},in(n=()=>{},i=()=>{}){Fe(e,t,{during:this.enter.during,start:this.enter.start,end:this.enter.end},n,i)},out(n=()=>{},i=()=>{}){Fe(e,t,{during:this.leave.during,start:this.leave.start,end:this.leave.end},n,i)}})}window.Element.prototype._x_toggleAndCascadeWithTransitions=function(e,t,r,n){let i=document.visibilityState==="visible"?requestAnimationFrame:setTimeout,o=()=>i(r);if(t){e._x_transition&&(e._x_transition.enter||e._x_transition.leave)?e._x_transition.enter&&(Object.entries(e._x_transition.enter.during).length||Object.entries(e._x_transition.enter.start).length||Object.entries(e._x_transition.enter.end).length)?e._x_transition.in(r):o():e._x_transition?e._x_transition.in(r):o();return}e._x_hidePromise=e._x_transition?new Promise((s,a)=>{e._x_transition.out(()=>{},()=>s(n)),e._x_transitioning&&e._x_transitioning.beforeCancel(()=>a({isFromCancelledTransition:!0}))}):Promise.resolve(n),queueMicrotask(()=>{let s=kr(e);s?(s._x_hideChildren||(s._x_hideChildren=[]),s._x_hideChildren.push(e)):i(()=>{let a=c=>{let l=Promise.all([c._x_hidePromise,...(c._x_hideChildren||[]).map(a)]).then(([u])=>u?.());return delete c._x_hidePromise,delete c._x_hideChildren,l};a(e).catch(c=>{if(!c.isFromCancelledTransition)throw c})})})};function kr(e){let t=e.parentNode;if(t)return t._x_hidePromise?t:kr(t)}function Fe(e,t,{during:r,start:n,end:i}={},o=()=>{},s=()=>{}){if(e._x_transitioning&&e._x_transitioning.cancel(),Object.keys(r).length===0&&Object.keys(n).length===0&&Object.keys(i).length===0){o(),s();return}let a,c,l;ii(e,{start(){a=t(e,n)},during(){c=t(e,r)},before:o,end(){a(),l=t(e,i)},after:s,cleanup(){c(),l()}})}function ii(e,t){let r,n,i,o=xe(()=>{m(()=>{r=!0,n||t.before(),i||(t.end(),je()),t.after(),e.isConnected&&t.cleanup(),delete e._x_transitioning})});e._x_transitioning={beforeCancels:[],beforeCancel(s){this.beforeCancels.push(s)},cancel:xe(function(){for(;this.beforeCancels.length;)this.beforeCancels.shift()();o()}),finish:o},m(()=>{t.start(),t.during()}),Mr(),requestAnimationFrame(()=>{if(r)return;let s=Number(getComputedStyle(e).transitionDuration.replace(/,.*/,"").replace("s",""))*1e3,a=Number(getComputedStyle(e).transitionDelay.replace(/,.*/,"").replace("s",""))*1e3;s===0&&(s=Number(getComputedStyle(e).animationDuration.replace("s",""))*1e3),m(()=>{t.before()}),n=!0,requestAnimationFrame(()=>{r||(m(()=>{t.end()}),je(),setTimeout(e._x_transitioning.finish,s+a),i=!0)})})}function ye(e,t,r){if(e.indexOf(t)===-1)return r;let n=e[e.indexOf(t)+1];if(!n||t==="scale"&&isNaN(n))return r;if(t==="duration"||t==="delay"){let i=n.match(/([0-9]+)ms/);if(i)return i[1]}return t==="origin"&&["top","right","left","center","bottom"].includes(e[e.indexOf(t)+2])?[n,e[e.indexOf(t)+2]].join(" "):n}var L=!1;function A(e,t=()=>{}){return(...r)=>L?t(...r):e(...r)}function Pr(e){return(...t)=>L&&e(...t)}var Ir=[];function V(e){Ir.push(e)}function $r(e,t){Ir.forEach(r=>r(e,t)),L=!0,jr(()=>{S(t,(r,n)=>{n(r,()=>{})})}),L=!1}var Be=!1;function Lr(e,t){t._x_dataStack||(t._x_dataStack=e._x_dataStack),L=!0,Be=!0,jr(()=>{oi(t)}),L=!1,Be=!1}function oi(e){let t=!1;S(e,(n,i)=>{P(n,(o,s)=>{if(t&&Cr(o))return s();t=!0,i(o,s)})})}function jr(e){let t=N;ct((r,n)=>{let i=t(r);return F(i),()=>{}}),e(),ct(t)}function be(e,t,r,n=[]){switch(e._x_bindings||(e._x_bindings=R({})),e._x_bindings[t]=r,t=n.includes("camel")?pi(t):t,t){case"value":si(e,r);break;case"style":ci(e,r);break;case"class":ai(e,r);break;case"selected":case"checked":li(e,t,r);break;default:Br(e,t,r);break}}function si(e,t){if(Ot(e))e.attributes.value===void 0&&(e.value=t),window.fromModel&&(typeof t=="boolean"?e.checked=we(e.value)===t:e.checked=Fr(e.value,t));else if(ze(e))Number.isInteger(t)?e.value=t:!Array.isArray(t)&&typeof t!="boolean"&&![null,void 0].includes(t)?e.value=String(t):Array.isArray(t)?e.checked=t.some(r=>Fr(r,e.value)):e.checked=!!t;else if(e.tagName==="SELECT")di(e,t);else{if(e.value===t)return;e.value=t===void 0?"":t}}function ai(e,t){e._x_undoAddedClasses&&e._x_undoAddedClasses(),e._x_undoAddedClasses=ge(e,t)}function ci(e,t){e._x_undoAddedStyles&&e._x_undoAddedStyles(),e._x_undoAddedStyles=Z(e,t)}function li(e,t,r){Br(e,t,r),fi(e,t,r)}function Br(e,t,r){[null,void 0,!1].includes(r)&&hi(t)?e.removeAttribute(t):(zr(t)&&(r=t),ui(e,t,r))}function ui(e,t,r){e.getAttribute(t)!=r&&e.setAttribute(t,r)}function fi(e,t,r){e[t]!==r&&(e[t]=r)}function di(e,t){let r=[].concat(t).map(n=>n+"");Array.from(e.options).forEach(n=>{n.selected=r.includes(n.value)})}function pi(e){return e.toLowerCase().replace(/-(\w)/g,(t,r)=>r.toUpperCase())}function Fr(e,t){return e==t}function we(e){return[1,"1","true","on","yes",!0].includes(e)?!0:[0,"0","false","off","no",!1].includes(e)?!1:e?Boolean(e):null}var mi=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected","shadowrootclonable","shadowrootdelegatesfocus","shadowrootserializable"]);function zr(e){return mi.has(e)}function hi(e){return!["aria-pressed","aria-checked","aria-expanded","aria-selected"].includes(e)}function Hr(e,t,r){return e._x_bindings&&e._x_bindings[t]!==void 0?e._x_bindings[t]:Vr(e,t,r)}function Kr(e,t,r,n=!0){if(e._x_bindings&&e._x_bindings[t]!==void 0)return e._x_bindings[t];if(e._x_inlineBindings&&e._x_inlineBindings[t]!==void 0){let i=e._x_inlineBindings[t];return i.extract=n,De(()=>T(e,i.expression))}return Vr(e,t,r)}function Vr(e,t,r){let n=e.getAttribute(t);return n===null?typeof r=="function"?r():r:n===""?!0:zr(t)?!![t,"true"].includes(n):n}function ze(e){return e.type==="checkbox"||e.localName==="ui-checkbox"||e.localName==="ui-switch"}function Ot(e){return e.type==="radio"||e.localName==="ui-radio"}function He(e,t){let r;return function(){let n=this,i=arguments,o=function(){r=null,e.apply(n,i)};clearTimeout(r),r=setTimeout(o,t)}}function Ke(e,t){let r;return function(){let n=this,i=arguments;r||(e.apply(n,i),r=!0,setTimeout(()=>r=!1,t))}}function Ve({get:e,set:t},{get:r,set:n}){let i=!0,o,s,a=N(()=>{let c=e(),l=r();if(i)n(Ct(c)),i=!1;else{let u=JSON.stringify(c),p=JSON.stringify(l);u!==o?n(Ct(c)):u!==p&&t(Ct(l))}o=JSON.stringify(e()),s=JSON.stringify(r())});return()=>{F(a)}}function Ct(e){return typeof e=="object"?JSON.parse(JSON.stringify(e)):e}function qr(e){(Array.isArray(e)?e:[e]).forEach(r=>r(z))}var Q={},Ur=!1;function Wr(e,t){if(Ur||(Q=R(Q),Ur=!0),t===void 0)return Q[e];Q[e]=t,ne(Q[e]),typeof t=="object"&&t!==null&&t.hasOwnProperty("init")&&typeof t.init=="function"&&Q[e].init()}function Gr(){return Q}var Jr={};function Yr(e,t){let r=typeof t!="function"?()=>t:t;return e instanceof Element?Rt(e,r()):(Jr[e]=r,()=>{})}function Xr(e){return Object.entries(Jr).forEach(([t,r])=>{Object.defineProperty(e,t,{get(){return(...n)=>r(...n)}})}),e}function Rt(e,t,r){let n=[];for(;n.length;)n.pop()();let i=Object.entries(t).map(([s,a])=>({name:s,value:a})),o=Et(i);return i=i.map(s=>o.find(a=>a.name===s.name)?{name:`x-bind:${s.name}`,value:`"${s.value}"`}:s),_e(e,i,r).map(s=>{n.push(s.runCleanups),s()}),()=>{for(;n.length;)n.pop()()}}var Zr={};function Qr(e,t){Zr[e]=t}function en(e,t){return Object.entries(Zr).forEach(([r,n])=>{Object.defineProperty(e,r,{get(){return(...i)=>n.bind(t)(...i)},enumerable:!1})}),e}var _i={get reactive(){return R},get release(){return F},get effect(){return N},get raw(){return at},version:"3.15.4",flushAndStopDeferringMutations:nr,dontAutoEvaluateFunctions:De,disableEffectScheduling:Gt,startObservingMutations:pe,stopObservingMutations:dt,setReactivityEngine:Jt,onAttributeRemoved:Te,onAttributesAdded:Re,closestDataStack:B,skipDuringClone:A,onlyDuringClone:Pr,addRootSelector:$e,addInitSelector:Le,setErrorHandler:ar,interceptClone:V,addScopeToNode:D,deferMutations:rr,mapAttributes:se,evaluateLater:x,interceptInit:Tr,initInterceptors:ne,injectMagics:K,setEvaluator:lr,setRawEvaluator:fr,mergeProxies:k,extractProp:Kr,findClosest:I,onElRemoved:re,closestRoot:X,destroyTree:$,interceptor:Ne,transition:Fe,setStyles:Z,mutateDom:m,directive:d,entangle:Ve,throttle:Ke,debounce:He,evaluate:T,evaluateRaw:dr,initTree:S,nextTick:ae,prefixed:C,prefix:mr,plugin:qr,magic:y,store:Wr,start:vr,clone:Lr,cloneNode:$r,bound:Hr,$data:Me,watch:Oe,walk:P,data:Qr,bind:Yr},z=_i;function Tt(e,t){let r=Object.create(null),n=e.split(",");for(let i=0;i<n.length;i++)r[n[i]]=!0;return t?i=>!!r[i.toLowerCase()]:i=>!!r[i]}var gi="itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly";var Vs=Tt(gi+",async,autofocus,autoplay,controls,default,defer,disabled,hidden,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected");var tn=Object.freeze({}),qs=Object.freeze([]);var xi=Object.prototype.hasOwnProperty,Ee=(e,t)=>xi.call(e,t),q=Array.isArray,ce=e=>rn(e)==="[object Map]";var yi=e=>typeof e=="string",qe=e=>typeof e=="symbol",ve=e=>e!==null&&typeof e=="object";var bi=Object.prototype.toString,rn=e=>bi.call(e),Mt=e=>rn(e).slice(8,-1);var Ue=e=>yi(e)&&e!=="NaN"&&e[0]!=="-"&&""+parseInt(e,10)===e;var We=e=>{let t=Object.create(null);return r=>t[r]||(t[r]=e(r))},wi=/-(\w)/g,Us=We(e=>e.replace(wi,(t,r)=>r?r.toUpperCase():"")),Ei=/\B([A-Z])/g,Ws=We(e=>e.replace(Ei,"-$1").toLowerCase()),Nt=We(e=>e.charAt(0).toUpperCase()+e.slice(1)),Gs=We(e=>e?`on${Nt(e)}`:""),Dt=(e,t)=>e!==t&&(e===e||t===t);var kt=new WeakMap,Se=[],j,ee=Symbol("iterate"),Pt=Symbol("Map key iterate");function vi(e){return e&&e._isEffect===!0}function ln(e,t=tn){vi(e)&&(e=e.raw);let r=Ai(e,t);return t.lazy||r(),r}function un(e){e.active&&(fn(e),e.options.onStop&&e.options.onStop(),e.active=!1)}var Si=0;function Ai(e,t){let r=function(){if(!r.active)return e();if(!Se.includes(r)){fn(r);try{return Ci(),Se.push(r),j=r,e()}finally{Se.pop(),dn(),j=Se[Se.length-1]}}};return r.id=Si++,r.allowRecurse=!!t.allowRecurse,r._isEffect=!0,r.active=!0,r.raw=e,r.deps=[],r.options=t,r}function fn(e){let{deps:t}=e;if(t.length){for(let r=0;r<t.length;r++)t[r].delete(e);t.length=0}}var le=!0,$t=[];function Oi(){$t.push(le),le=!1}function Ci(){$t.push(le),le=!0}function dn(){let e=$t.pop();le=e===void 0?!0:e}function M(e,t,r){if(!le||j===void 0)return;let n=kt.get(e);n||kt.set(e,n=new Map);let i=n.get(r);i||n.set(r,i=new Set),i.has(j)||(i.add(j),j.deps.push(i),j.options.onTrack&&j.options.onTrack({effect:j,target:e,type:t,key:r}))}function W(e,t,r,n,i,o){let s=kt.get(e);if(!s)return;let a=new Set,c=u=>{u&&u.forEach(p=>{(p!==j||p.allowRecurse)&&a.add(p)})};if(t==="clear")s.forEach(c);else if(r==="length"&&q(e))s.forEach((u,p)=>{(p==="length"||p>=n)&&c(u)});else switch(r!==void 0&&c(s.get(r)),t){case"add":q(e)?Ue(r)&&c(s.get("length")):(c(s.get(ee)),ce(e)&&c(s.get(Pt)));break;case"delete":q(e)||(c(s.get(ee)),ce(e)&&c(s.get(Pt)));break;case"set":ce(e)&&c(s.get(ee));break}let l=u=>{u.options.onTrigger&&u.options.onTrigger({effect:u,target:e,key:r,type:t,newValue:n,oldValue:i,oldTarget:o}),u.options.scheduler?u.options.scheduler(u):u()};a.forEach(l)}var Ri=Tt("__proto__,__v_isRef,__isVue"),pn=new Set(Object.getOwnPropertyNames(Symbol).map(e=>Symbol[e]).filter(qe)),Ti=mn();var Mi=mn(!0);var nn=Ni();function Ni(){let e={};return["includes","indexOf","lastIndexOf"].forEach(t=>{e[t]=function(...r){let n=_(this);for(let o=0,s=this.length;o<s;o++)M(n,"get",o+"");let i=n[t](...r);return i===-1||i===!1?n[t](...r.map(_)):i}}),["push","pop","shift","unshift","splice"].forEach(t=>{e[t]=function(...r){Oi();let n=_(this)[t].apply(this,r);return dn(),n}}),e}function mn(e=!1,t=!1){return function(n,i,o){if(i==="__v_isReactive")return!e;if(i==="__v_isReadonly")return e;if(i==="__v_raw"&&o===(e?t?Wi:xn:t?Ui:gn).get(n))return n;let s=q(n);if(!e&&s&&Ee(nn,i))return Reflect.get(nn,i,o);let a=Reflect.get(n,i,o);return(qe(i)?pn.has(i):Ri(i))||(e||M(n,"get",i),t)?a:It(a)?!s||!Ue(i)?a.value:a:ve(a)?e?yn(a):et(a):a}}var Di=ki();function ki(e=!1){return function(r,n,i,o){let s=r[n];if(!e&&(i=_(i),s=_(s),!q(r)&&It(s)&&!It(i)))return s.value=i,!0;let a=q(r)&&Ue(n)?Number(n)<r.length:Ee(r,n),c=Reflect.set(r,n,i,o);return r===_(o)&&(a?Dt(i,s)&&W(r,"set",n,i,s):W(r,"add",n,i)),c}}function Pi(e,t){let r=Ee(e,t),n=e[t],i=Reflect.deleteProperty(e,t);return i&&r&&W(e,"delete",t,void 0,n),i}function Ii(e,t){let r=Reflect.has(e,t);return(!qe(t)||!pn.has(t))&&M(e,"has",t),r}function $i(e){return M(e,"iterate",q(e)?"length":ee),Reflect.ownKeys(e)}var Li={get:Ti,set:Di,deleteProperty:Pi,has:Ii,ownKeys:$i},ji={get:Mi,set(e,t){return console.warn(`Set operation on key "${String(t)}" failed: target is readonly.`,e),!0},deleteProperty(e,t){return console.warn(`Delete operation on key "${String(t)}" failed: target is readonly.`,e),!0}};var Lt=e=>ve(e)?et(e):e,jt=e=>ve(e)?yn(e):e,Ft=e=>e,Qe=e=>Reflect.getPrototypeOf(e);function Ge(e,t,r=!1,n=!1){e=e.__v_raw;let i=_(e),o=_(t);t!==o&&!r&&M(i,"get",t),!r&&M(i,"get",o);let{has:s}=Qe(i),a=n?Ft:r?jt:Lt;if(s.call(i,t))return a(e.get(t));if(s.call(i,o))return a(e.get(o));e!==i&&e.get(t)}function Je(e,t=!1){let r=this.__v_raw,n=_(r),i=_(e);return e!==i&&!t&&M(n,"has",e),!t&&M(n,"has",i),e===i?r.has(e):r.has(e)||r.has(i)}function Ye(e,t=!1){return e=e.__v_raw,!t&&M(_(e),"iterate",ee),Reflect.get(e,"size",e)}function on(e){e=_(e);let t=_(this);return Qe(t).has.call(t,e)||(t.add(e),W(t,"add",e,e)),this}function sn(e,t){t=_(t);let r=_(this),{has:n,get:i}=Qe(r),o=n.call(r,e);o?_n(r,n,e):(e=_(e),o=n.call(r,e));let s=i.call(r,e);return r.set(e,t),o?Dt(t,s)&&W(r,"set",e,t,s):W(r,"add",e,t),this}function an(e){let t=_(this),{has:r,get:n}=Qe(t),i=r.call(t,e);i?_n(t,r,e):(e=_(e),i=r.call(t,e));let o=n?n.call(t,e):void 0,s=t.delete(e);return i&&W(t,"delete",e,void 0,o),s}function cn(){let e=_(this),t=e.size!==0,r=ce(e)?new Map(e):new Set(e),n=e.clear();return t&&W(e,"clear",void 0,void 0,r),n}function Xe(e,t){return function(n,i){let o=this,s=o.__v_raw,a=_(s),c=t?Ft:e?jt:Lt;return!e&&M(a,"iterate",ee),s.forEach((l,u)=>n.call(i,c(l),c(u),o))}}function Ze(e,t,r){return function(...n){let i=this.__v_raw,o=_(i),s=ce(o),a=e==="entries"||e===Symbol.iterator&&s,c=e==="keys"&&s,l=i[e](...n),u=r?Ft:t?jt:Lt;return!t&&M(o,"iterate",c?Pt:ee),{next(){let{value:p,done:h}=l.next();return h?{value:p,done:h}:{value:a?[u(p[0]),u(p[1])]:u(p),done:h}},[Symbol.iterator](){return this}}}}function U(e){return function(...t){{let r=t[0]?`on key "${t[0]}" `:"";console.warn(`${Nt(e)} operation ${r}failed: target is readonly.`,_(this))}return e==="delete"?!1:this}}function Fi(){let e={get(o){return Ge(this,o)},get size(){return Ye(this)},has:Je,add:on,set:sn,delete:an,clear:cn,forEach:Xe(!1,!1)},t={get(o){return Ge(this,o,!1,!0)},get size(){return Ye(this)},has:Je,add:on,set:sn,delete:an,clear:cn,forEach:Xe(!1,!0)},r={get(o){return Ge(this,o,!0)},get size(){return Ye(this,!0)},has(o){return Je.call(this,o,!0)},add:U("add"),set:U("set"),delete:U("delete"),clear:U("clear"),forEach:Xe(!0,!1)},n={get(o){return Ge(this,o,!0,!0)},get size(){return Ye(this,!0)},has(o){return Je.call(this,o,!0)},add:U("add"),set:U("set"),delete:U("delete"),clear:U("clear"),forEach:Xe(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach(o=>{e[o]=Ze(o,!1,!1),r[o]=Ze(o,!0,!1),t[o]=Ze(o,!1,!0),n[o]=Ze(o,!0,!0)}),[e,r,t,n]}var[Bi,zi,Hi,Ki]=Fi();function hn(e,t){let r=t?e?Ki:Hi:e?zi:Bi;return(n,i,o)=>i==="__v_isReactive"?!e:i==="__v_isReadonly"?e:i==="__v_raw"?n:Reflect.get(Ee(r,i)&&i in n?r:n,i,o)}var Vi={get:hn(!1,!1)};var qi={get:hn(!0,!1)};function _n(e,t,r){let n=_(r);if(n!==r&&t.call(e,n)){let i=Mt(e);console.warn(`Reactive ${i} contains both the raw and reactive versions of the same object${i==="Map"?" as keys":""}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`)}}var gn=new WeakMap,Ui=new WeakMap,xn=new WeakMap,Wi=new WeakMap;function Gi(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function Ji(e){return e.__v_skip||!Object.isExtensible(e)?0:Gi(Mt(e))}function et(e){return e&&e.__v_isReadonly?e:bn(e,!1,Li,Vi,gn)}function yn(e){return bn(e,!0,ji,qi,xn)}function bn(e,t,r,n,i){if(!ve(e))return console.warn(`value cannot be made reactive: ${String(e)}`),e;if(e.__v_raw&&!(t&&e.__v_isReactive))return e;let o=i.get(e);if(o)return o;let s=Ji(e);if(s===0)return e;let a=new Proxy(e,s===2?n:r);return i.set(e,a),a}function _(e){return e&&_(e.__v_raw)||e}function It(e){return Boolean(e&&e.__v_isRef===!0)}y("nextTick",()=>ae);y("dispatch",e=>Y.bind(Y,e));y("watch",(e,{evaluateLater:t,cleanup:r})=>(n,i)=>{let o=t(n),a=Oe(()=>{let c;return o(l=>c=l),c},i);r(a)});y("store",Gr);y("data",e=>Me(e));y("root",e=>X(e));y("refs",e=>(e._x_refs_proxy||(e._x_refs_proxy=k(Yi(e))),e._x_refs_proxy));function Yi(e){let t=[];return I(e,r=>{r._x_refs&&t.push(r._x_refs)}),t}var Bt={};function zt(e){return Bt[e]||(Bt[e]=0),++Bt[e]}function wn(e,t){return I(e,r=>{if(r._x_ids&&r._x_ids[t])return!0})}function En(e,t){e._x_ids||(e._x_ids={}),e._x_ids[t]||(e._x_ids[t]=zt(t))}y("id",(e,{cleanup:t})=>(r,n=null)=>{let i=`${r}${n?`-${n}`:""}`;return Xi(e,i,t,()=>{let o=wn(e,r),s=o?o._x_ids[r]:zt(r);return n?`${r}-${s}-${n}`:`${r}-${s}`})});V((e,t)=>{e._x_id&&(t._x_id=e._x_id)});function Xi(e,t,r,n){if(e._x_id||(e._x_id={}),e._x_id[t])return e._x_id[t];let i=n();return e._x_id[t]=i,r(()=>{delete e._x_id[t]}),i}y("el",e=>e);vn("Focus","focus","focus");vn("Persist","persist","persist");function vn(e,t,r){y(t,n=>E(`You can't use [$${t}] without first installing the "${e}" plugin here: https://alpinejs.dev/plugins/${r}`,n))}d("modelable",(e,{expression:t},{effect:r,evaluateLater:n,cleanup:i})=>{let o=n(t),s=()=>{let u;return o(p=>u=p),u},a=n(`${t} = __placeholder`),c=u=>a(()=>{},{scope:{__placeholder:u}}),l=s();c(l),queueMicrotask(()=>{if(!e._x_model)return;e._x_removeModelListeners.default();let u=e._x_model.get,p=e._x_model.set,h=Ve({get(){return u()},set(w){p(w)}},{get(){return s()},set(w){c(w)}});i(h)})});d("teleport",(e,{modifiers:t,expression:r},{cleanup:n})=>{e.tagName.toLowerCase()!=="template"&&E("x-teleport can only be used on a <template> tag",e);let i=Sn(r),o=e.content.cloneNode(!0).firstElementChild;e._x_teleport=o,o._x_teleportBack=e,e.setAttribute("data-teleport-template",!0),o.setAttribute("data-teleport-target",!0),e._x_forwardEvents&&e._x_forwardEvents.forEach(a=>{o.addEventListener(a,c=>{c.stopPropagation(),e.dispatchEvent(new c.constructor(c.type,c))})}),D(o,{},e);let s=(a,c,l)=>{l.includes("prepend")?c.parentNode.insertBefore(a,c):l.includes("append")?c.parentNode.insertBefore(a,c.nextSibling):c.appendChild(a)};m(()=>{s(o,i,t),A(()=>{S(o)})()}),e._x_teleportPutBack=()=>{let a=Sn(r);m(()=>{s(e._x_teleport,a,t)})},n(()=>m(()=>{o.remove(),$(o)}))});var Zi=document.createElement("div");function Sn(e){let t=A(()=>document.querySelector(e),()=>Zi)();return t||E(`Cannot find x-teleport element for selector: "${e}"`),t}var An=()=>{};An.inline=(e,{modifiers:t},{cleanup:r})=>{t.includes("self")?e._x_ignoreSelf=!0:e._x_ignore=!0,r(()=>{t.includes("self")?delete e._x_ignoreSelf:delete e._x_ignore})};d("ignore",An);d("effect",A((e,{expression:t},{effect:r})=>{r(x(e,t))}));function ue(e,t,r,n){let i=e,o=c=>n(c),s={},a=(c,l)=>u=>l(c,u);if(r.includes("dot")&&(t=Qi(t)),r.includes("camel")&&(t=eo(t)),r.includes("passive")&&(s.passive=!0),r.includes("capture")&&(s.capture=!0),r.includes("window")&&(i=window),r.includes("document")&&(i=document),r.includes("debounce")){let c=r[r.indexOf("debounce")+1]||"invalid-wait",l=tt(c.split("ms")[0])?Number(c.split("ms")[0]):250;o=He(o,l)}if(r.includes("throttle")){let c=r[r.indexOf("throttle")+1]||"invalid-wait",l=tt(c.split("ms")[0])?Number(c.split("ms")[0]):250;o=Ke(o,l)}return r.includes("prevent")&&(o=a(o,(c,l)=>{l.preventDefault(),c(l)})),r.includes("stop")&&(o=a(o,(c,l)=>{l.stopPropagation(),c(l)})),r.includes("once")&&(o=a(o,(c,l)=>{c(l),i.removeEventListener(t,o,s)})),(r.includes("away")||r.includes("outside"))&&(i=document,o=a(o,(c,l)=>{e.contains(l.target)||l.target.isConnected!==!1&&(e.offsetWidth<1&&e.offsetHeight<1||e._x_isShown!==!1&&c(l))})),r.includes("self")&&(o=a(o,(c,l)=>{l.target===e&&c(l)})),(ro(t)||Cn(t))&&(o=a(o,(c,l)=>{no(l,r)||c(l)})),i.addEventListener(t,o,s),()=>{i.removeEventListener(t,o,s)}}function Qi(e){return e.replace(/-/g,".")}function eo(e){return e.toLowerCase().replace(/-(\w)/g,(t,r)=>r.toUpperCase())}function tt(e){return!Array.isArray(e)&&!isNaN(e)}function to(e){return[" ","_"].includes(e)?e:e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[_\s]/,"-").toLowerCase()}function ro(e){return["keydown","keyup"].includes(e)}function Cn(e){return["contextmenu","click","mouse"].some(t=>e.includes(t))}function no(e,t){let r=t.filter(o=>!["window","document","prevent","stop","once","capture","self","away","outside","passive","preserve-scroll"].includes(o));if(r.includes("debounce")){let o=r.indexOf("debounce");r.splice(o,tt((r[o+1]||"invalid-wait").split("ms")[0])?2:1)}if(r.includes("throttle")){let o=r.indexOf("throttle");r.splice(o,tt((r[o+1]||"invalid-wait").split("ms")[0])?2:1)}if(r.length===0||r.length===1&&On(e.key).includes(r[0]))return!1;let i=["ctrl","shift","alt","meta","cmd","super"].filter(o=>r.includes(o));return r=r.filter(o=>!i.includes(o)),!(i.length>0&&i.filter(s=>((s==="cmd"||s==="super")&&(s="meta"),e[`${s}Key`])).length===i.length&&(Cn(e.type)||On(e.key).includes(r[0])))}function On(e){if(!e)return[];e=to(e);let t={ctrl:"control",slash:"/",space:" ",spacebar:" ",cmd:"meta",esc:"escape",up:"arrow-up",down:"arrow-down",left:"arrow-left",right:"arrow-right",period:".",comma:",",equal:"=",minus:"-",underscore:"_"};return t[e]=e,Object.keys(t).map(r=>{if(t[r]===e)return r}).filter(r=>r)}d("model",(e,{modifiers:t,expression:r},{effect:n,cleanup:i})=>{let o=e;t.includes("parent")&&(o=e.parentNode);let s=x(o,r),a;typeof r=="string"?a=x(o,`${r} = __placeholder`):typeof r=="function"&&typeof r()=="string"?a=x(o,`${r()} = __placeholder`):a=()=>{};let c=()=>{let h;return s(w=>h=w),Rn(h)?h.get():h},l=h=>{let w;s(H=>w=H),Rn(w)?w.set(h):a(()=>{},{scope:{__placeholder:h}})};typeof r=="string"&&e.type==="radio"&&m(()=>{e.hasAttribute("name")||e.setAttribute("name",r)});let u=e.tagName.toLowerCase()==="select"||["checkbox","radio"].includes(e.type)||t.includes("lazy")?"change":"input",p=L?()=>{}:ue(e,u,t,h=>{l(Ht(e,t,h,c()))});if(t.includes("fill")&&([void 0,null,""].includes(c())||ze(e)&&Array.isArray(c())||e.tagName.toLowerCase()==="select"&&e.multiple)&&l(Ht(e,t,{target:e},c())),e._x_removeModelListeners||(e._x_removeModelListeners={}),e._x_removeModelListeners.default=p,i(()=>e._x_removeModelListeners.default()),e.form){let h=ue(e.form,"reset",[],w=>{ae(()=>e._x_model&&e._x_model.set(Ht(e,t,{target:e},c())))});i(()=>h())}e._x_model={get(){return c()},set(h){l(h)}},e._x_forceModelUpdate=h=>{h===void 0&&typeof r=="string"&&r.match(/\./)&&(h=""),window.fromModel=!0,m(()=>be(e,"value",h)),delete window.fromModel},n(()=>{let h=c();t.includes("unintrusive")&&document.activeElement.isSameNode(e)||e._x_forceModelUpdate(h)})});function Ht(e,t,r,n){return m(()=>{if(r instanceof CustomEvent&&r.detail!==void 0)return r.detail!==null&&r.detail!==void 0?r.detail:r.target.value;if(ze(e))if(Array.isArray(n)){let i=null;return t.includes("number")?i=Kt(r.target.value):t.includes("boolean")?i=we(r.target.value):i=r.target.value,r.target.checked?n.includes(i)?n:n.concat([i]):n.filter(o=>!io(o,i))}else return r.target.checked;else{if(e.tagName.toLowerCase()==="select"&&e.multiple)return t.includes("number")?Array.from(r.target.selectedOptions).map(i=>{let o=i.value||i.text;return Kt(o)}):t.includes("boolean")?Array.from(r.target.selectedOptions).map(i=>{let o=i.value||i.text;return we(o)}):Array.from(r.target.selectedOptions).map(i=>i.value||i.text);{let i;return Ot(e)?r.target.checked?i=r.target.value:i=n:i=r.target.value,t.includes("number")?Kt(i):t.includes("boolean")?we(i):t.includes("trim")?i.trim():i}}})}function Kt(e){let t=e?parseFloat(e):null;return oo(t)?t:e}function io(e,t){return e==t}function oo(e){return!Array.isArray(e)&&!isNaN(e)}function Rn(e){return e!==null&&typeof e=="object"&&typeof e.get=="function"&&typeof e.set=="function"}d("cloak",e=>queueMicrotask(()=>m(()=>e.removeAttribute(C("cloak")))));Le(()=>`[${C("init")}]`);d("init",A((e,{expression:t},{evaluate:r})=>typeof t=="string"?!!t.trim()&&r(t,{},!1):r(t,{},!1)));d("text",(e,{expression:t},{effect:r,evaluateLater:n})=>{let i=n(t);r(()=>{i(o=>{m(()=>{e.textContent=o})})})});d("html",(e,{expression:t},{effect:r,evaluateLater:n})=>{let i=n(t);r(()=>{i(o=>{m(()=>{e.innerHTML=o,e._x_ignoreSelf=!0,S(e),delete e._x_ignoreSelf})})})});se(Pe(":",Ie(C("bind:"))));var Tn=(e,{value:t,modifiers:r,expression:n,original:i},{effect:o,cleanup:s})=>{if(!t){let c={};Xr(c),x(e,n)(u=>{Rt(e,u,i)},{scope:c});return}if(t==="key")return so(e,n);if(e._x_inlineBindings&&e._x_inlineBindings[t]&&e._x_inlineBindings[t].extract)return;let a=x(e,n);o(()=>a(c=>{c===void 0&&typeof n=="string"&&n.match(/\./)&&(c=""),m(()=>be(e,t,c,r))})),s(()=>{e._x_undoAddedClasses&&e._x_undoAddedClasses(),e._x_undoAddedStyles&&e._x_undoAddedStyles()})};Tn.inline=(e,{value:t,modifiers:r,expression:n})=>{t&&(e._x_inlineBindings||(e._x_inlineBindings={}),e._x_inlineBindings[t]={expression:n,extract:!1})};d("bind",Tn);function so(e,t){e._x_keyExpression=t}$e(()=>`[${C("data")}]`);d("data",(e,{expression:t},{cleanup:r})=>{if(ao(e))return;t=t===""?"{}":t;let n={};K(n,e);let i={};en(i,n);let o=T(e,t,{scope:i});(o===void 0||o===!0)&&(o={}),K(o,e);let s=R(o);ne(s);let a=D(e,s);s.init&&T(e,s.init),r(()=>{s.destroy&&T(e,s.destroy),a()})});V((e,t)=>{e._x_dataStack&&(t._x_dataStack=e._x_dataStack,t.setAttribute("data-has-alpine-state",!0))});function ao(e){return L?Be?!0:e.hasAttribute("data-has-alpine-state"):!1}d("show",(e,{modifiers:t,expression:r},{effect:n})=>{let i=x(e,r);e._x_doHide||(e._x_doHide=()=>{m(()=>{e.style.setProperty("display","none",t.includes("important")?"important":void 0)})}),e._x_doShow||(e._x_doShow=()=>{m(()=>{e.style.length===1&&e.style.display==="none"?e.removeAttribute("style"):e.style.removeProperty("display")})});let o=()=>{e._x_doHide(),e._x_isShown=!1},s=()=>{e._x_doShow(),e._x_isShown=!0},a=()=>setTimeout(s),c=xe(p=>p?s():o(),p=>{typeof e._x_toggleAndCascadeWithTransitions=="function"?e._x_toggleAndCascadeWithTransitions(e,p,s,o):p?a():o()}),l,u=!0;n(()=>i(p=>{!u&&p===l||(t.includes("immediate")&&(p?a():o()),c(p),l=p,u=!1)}))});d("for",(e,{expression:t},{effect:r,cleanup:n})=>{let i=lo(t),o=x(e,i.items),s=x(e,e._x_keyExpression||"index");e._x_prevKeys=[],e._x_lookup={},r(()=>co(e,i,o,s)),n(()=>{Object.values(e._x_lookup).forEach(a=>m(()=>{$(a),a.remove()})),delete e._x_prevKeys,delete e._x_lookup})});function co(e,t,r,n){let i=s=>typeof s=="object"&&!Array.isArray(s),o=e;r(s=>{uo(s)&&s>=0&&(s=Array.from(Array(s).keys(),f=>f+1)),s===void 0&&(s=[]);let a=e._x_lookup,c=e._x_prevKeys,l=[],u=[];if(i(s))s=Object.entries(s).map(([f,g])=>{let b=Mn(t,g,f,s);n(v=>{u.includes(v)&&E("Duplicate key on x-for",e),u.push(v)},{scope:{index:f,...b}}),l.push(b)});else for(let f=0;f<s.length;f++){let g=Mn(t,s[f],f,s);n(b=>{u.includes(b)&&E("Duplicate key on x-for",e),u.push(b)},{scope:{index:f,...g}}),l.push(g)}let p=[],h=[],w=[],H=[];for(let f=0;f<c.length;f++){let g=c[f];u.indexOf(g)===-1&&w.push(g)}c=c.filter(f=>!w.includes(f));let Ae="template";for(let f=0;f<u.length;f++){let g=u[f],b=c.indexOf(g);if(b===-1)c.splice(f,0,g),p.push([Ae,f]);else if(b!==f){let v=c.splice(f,1)[0],O=c.splice(b-1,1)[0];c.splice(f,0,O),c.splice(b,0,v),h.push([v,O])}else H.push(g);Ae=g}for(let f=0;f<w.length;f++){let g=w[f];g in a&&(m(()=>{$(a[g]),a[g].remove()}),delete a[g])}for(let f=0;f<h.length;f++){let[g,b]=h[f],v=a[g],O=a[b],te=document.createElement("div");m(()=>{O||E('x-for ":key" is undefined or invalid',o,b,a),O.after(te),v.after(O),O._x_currentIfEl&&O.after(O._x_currentIfEl),te.before(v),v._x_currentIfEl&&v.after(v._x_currentIfEl),te.remove()}),O._x_refreshXForScope(l[u.indexOf(b)])}for(let f=0;f<p.length;f++){let[g,b]=p[f],v=g==="template"?o:a[g];v._x_currentIfEl&&(v=v._x_currentIfEl);let O=l[b],te=u[b],fe=document.importNode(o.content,!0).firstElementChild,qt=R(O);D(fe,qt,o),fe._x_refreshXForScope=Dn=>{Object.entries(Dn).forEach(([kn,Pn])=>{qt[kn]=Pn})},m(()=>{v.after(fe),A(()=>S(fe))()}),typeof te=="object"&&E("x-for key cannot be an object, it must be a string or an integer",o),a[te]=fe}for(let f=0;f<H.length;f++)a[H[f]]._x_refreshXForScope(l[u.indexOf(H[f])]);o._x_prevKeys=u})}function lo(e){let t=/,([^,\}\]]*)(?:,([^,\}\]]*))?$/,r=/^\s*\(|\)\s*$/g,n=/([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/,i=e.match(n);if(!i)return;let o={};o.items=i[2].trim();let s=i[1].replace(r,"").trim(),a=s.match(t);return a?(o.item=s.replace(t,"").trim(),o.index=a[1].trim(),a[2]&&(o.collection=a[2].trim())):o.item=s,o}function Mn(e,t,r,n){let i={};return/^\[.*\]$/.test(e.item)&&Array.isArray(t)?e.item.replace("[","").replace("]","").split(",").map(s=>s.trim()).forEach((s,a)=>{i[s]=t[a]}):/^\{.*\}$/.test(e.item)&&!Array.isArray(t)&&typeof t=="object"?e.item.replace("{","").replace("}","").split(",").map(s=>s.trim()).forEach(s=>{i[s]=t[s]}):i[e.item]=t,e.index&&(i[e.index]=r),e.collection&&(i[e.collection]=n),i}function uo(e){return!Array.isArray(e)&&!isNaN(e)}function Nn(){}Nn.inline=(e,{expression:t},{cleanup:r})=>{let n=X(e);n._x_refs||(n._x_refs={}),n._x_refs[t]=e,r(()=>delete n._x_refs[t])};d("ref",Nn);d("if",(e,{expression:t},{effect:r,cleanup:n})=>{e.tagName.toLowerCase()!=="template"&&E("x-if can only be used on a <template> tag",e);let i=x(e,t),o=()=>{if(e._x_currentIfEl)return e._x_currentIfEl;let a=e.content.cloneNode(!0).firstElementChild;return D(a,{},e),m(()=>{e.after(a),A(()=>S(a))()}),e._x_currentIfEl=a,e._x_undoIf=()=>{m(()=>{$(a),a.remove()}),delete e._x_currentIfEl},a},s=()=>{e._x_undoIf&&(e._x_undoIf(),delete e._x_undoIf)};r(()=>i(a=>{a?o():s()})),n(()=>e._x_undoIf&&e._x_undoIf())});d("id",(e,{expression:t},{evaluate:r})=>{r(t).forEach(i=>En(e,i))});V((e,t)=>{e._x_ids&&(t._x_ids=e._x_ids)});se(Pe("@",Ie(C("on:"))));d("on",A((e,{value:t,modifiers:r,expression:n},{cleanup:i})=>{let o=n?x(e,n):()=>{};e.tagName.toLowerCase()==="template"&&(e._x_forwardEvents||(e._x_forwardEvents=[]),e._x_forwardEvents.includes(t)||e._x_forwardEvents.push(t));let s=ue(e,t,r,a=>{o(()=>{},{scope:{$event:a},params:[a]})});i(()=>s())}));rt("Collapse","collapse","collapse");rt("Intersect","intersect","intersect");rt("Focus","trap","focus");rt("Mask","mask","mask");function rt(e,t,r){d(t,n=>E(`You can't use [x-${t}] without first installing the "${e}" plugin here: https://alpinejs.dev/plugins/${r}`,n))}z.setEvaluator(xt);z.setRawEvaluator(pr);z.setReactivityEngine({reactive:et,effect:ln,release:un,raw:_});var Vt=z;window.Alpine=Vt;queueMicrotask(()=>{Vt.start()});})(); 6 -
-65
web/static/js/back-button.js
··· 1 - /** 2 - * Smart back button implementation for Arabica 3 - * Handles browser history navigation with intelligent fallbacks 4 - */ 5 - 6 - /** 7 - * Initialize a back button with smart navigation 8 - * @param {HTMLElement} button - The back button element 9 - */ 10 - function initBackButton(button) { 11 - if (!button) return; 12 - 13 - button.addEventListener('click', function(e) { 14 - e.preventDefault(); 15 - handleBackNavigation(button); 16 - }); 17 - } 18 - 19 - /** 20 - * Handle back navigation with fallback logic 21 - * @param {HTMLElement} button - The back button element 22 - */ 23 - function handleBackNavigation(button) { 24 - const fallbackUrl = button.getAttribute('data-fallback') || '/brews'; 25 - const referrer = document.referrer; 26 - const currentUrl = window.location.href; 27 - 28 - // Check if there's actual browser history to go back to 29 - // We can't directly check history.length in a reliable way across browsers, 30 - // but we can check if the referrer is from the same origin 31 - const hasSameOriginReferrer = referrer && 32 - referrer.startsWith(window.location.origin) && 33 - referrer !== currentUrl; 34 - 35 - if (hasSameOriginReferrer) { 36 - // Safe to use history.back() - we came from within the app 37 - window.history.back(); 38 - } else { 39 - // No referrer or external referrer - use fallback 40 - // This handles direct links, external referrers, and bookmarks 41 - window.location.href = fallbackUrl; 42 - } 43 - } 44 - 45 - /** 46 - * Initialize all back buttons on the page 47 - */ 48 - function initAllBackButtons() { 49 - const buttons = document.querySelectorAll('[data-back-button]'); 50 - buttons.forEach(initBackButton); 51 - } 52 - 53 - // Initialize on DOM load 54 - if (document.readyState === 'loading') { 55 - document.addEventListener('DOMContentLoaded', initAllBackButtons); 56 - } else { 57 - initAllBackButtons(); 58 - } 59 - 60 - // Re-initialize after HTMX swaps (for dynamic content) 61 - if (document.body) { 62 - document.body.addEventListener('htmx:afterSwap', function() { 63 - initAllBackButtons(); 64 - }); 65 - }
-368
web/static/js/brew-form.js
··· 1 - /** 2 - * Alpine.js component for the brew form 3 - * Manages pours, new entity modals, and form state 4 - * Populates dropdowns from client-side cache for faster UX 5 - */ 6 - function brewForm() { 7 - return { 8 - // Modal state (matching manage page) 9 - showBeanForm: false, 10 - showGrinderForm: false, 11 - showBrewerForm: false, 12 - editingBean: null, 13 - editingGrinder: null, 14 - editingBrewer: null, 15 - 16 - // Form data (matching manage page with snake_case) 17 - beanForm: { 18 - name: "", 19 - origin: "", 20 - roast_level: "", 21 - process: "", 22 - description: "", 23 - roaster_rkey: "", 24 - }, 25 - grinderForm: { name: "", grinder_type: "", burr_type: "", notes: "" }, 26 - brewerForm: { name: "", brewer_type: "", description: "" }, 27 - 28 - // Brew form specific 29 - rating: 5, 30 - pours: [], 31 - 32 - // Dropdown data 33 - beans: [], 34 - grinders: [], 35 - brewers: [], 36 - roasters: [], 37 - dataLoaded: false, 38 - 39 - async init() { 40 - // Load existing pours if editing 41 - // $el is now the parent div, so find the form element 42 - const formEl = this.$el.querySelector("form"); 43 - const poursData = formEl?.getAttribute("data-pours"); 44 - if (poursData) { 45 - try { 46 - this.pours = JSON.parse(poursData); 47 - } catch (e) { 48 - console.error("Failed to parse pours data:", e); 49 - this.pours = []; 50 - } 51 - } 52 - 53 - // Populate dropdowns from cache using stale-while-revalidate pattern 54 - await this.loadDropdownData(); 55 - }, 56 - 57 - async loadDropdownData(forceRefresh = false) { 58 - if (!window.ArabicaCache) { 59 - console.warn("ArabicaCache not available"); 60 - return; 61 - } 62 - 63 - // If forcing refresh, always get fresh data 64 - if (forceRefresh) { 65 - try { 66 - const freshData = await window.ArabicaCache.refreshCache(true); 67 - if (freshData) { 68 - this.applyData(freshData); 69 - } 70 - } catch (e) { 71 - console.error("Failed to refresh dropdown data:", e); 72 - } 73 - return; 74 - } 75 - 76 - // First, try to immediately populate from cached data (sync) 77 - // This prevents flickering by showing data instantly 78 - const cachedData = window.ArabicaCache.getCachedData(); 79 - if (cachedData) { 80 - this.applyData(cachedData); 81 - } 82 - 83 - // Then refresh in background if cache is stale 84 - if (!window.ArabicaCache.isCacheValid()) { 85 - try { 86 - const freshData = await window.ArabicaCache.refreshCache(); 87 - if (freshData) { 88 - this.applyData(freshData); 89 - } 90 - } catch (e) { 91 - console.error("Failed to refresh dropdown data:", e); 92 - // We already have cached data displayed, so this is non-fatal 93 - } 94 - } 95 - }, 96 - 97 - applyData(data) { 98 - this.beans = data.beans || []; 99 - this.grinders = data.grinders || []; 100 - this.brewers = data.brewers || []; 101 - this.roasters = data.roasters || []; 102 - this.dataLoaded = true; 103 - 104 - // Populate the select elements 105 - this.populateDropdowns(); 106 - }, 107 - 108 - populateDropdowns() { 109 - // Get the current selected values (from server-rendered form when editing) 110 - // Use document.querySelector to ensure we find the form selects, not modal selects 111 - const beanSelect = document.querySelector('form select[name="bean_rkey"]'); 112 - const grinderSelect = document.querySelector('form select[name="grinder_rkey"]'); 113 - const brewerSelect = document.querySelector('form select[name="brewer_rkey"]'); 114 - 115 - const selectedBean = beanSelect?.value || ""; 116 - const selectedGrinder = grinderSelect?.value || ""; 117 - const selectedBrewer = brewerSelect?.value || ""; 118 - 119 - // Populate beans - using DOM methods to prevent XSS 120 - if (beanSelect && this.beans.length > 0) { 121 - // Clear existing options 122 - beanSelect.innerHTML = ""; 123 - 124 - // Add placeholder 125 - const placeholderOption = document.createElement("option"); 126 - placeholderOption.value = ""; 127 - placeholderOption.textContent = "Select a bean..."; 128 - beanSelect.appendChild(placeholderOption); 129 - 130 - // Add bean options 131 - this.beans.forEach((bean) => { 132 - const option = document.createElement("option"); 133 - option.value = bean.rkey || bean.RKey; 134 - const roasterName = bean.Roaster?.Name || bean.roaster?.name || ""; 135 - const roasterSuffix = roasterName ? ` - ${roasterName}` : ""; 136 - // Using textContent ensures all user input is safely escaped 137 - option.textContent = `${bean.Name || bean.name} (${bean.Origin || bean.origin} - ${bean.RoastLevel || bean.roast_level})${roasterSuffix}`; 138 - option.className = "truncate"; 139 - if ((bean.rkey || bean.RKey) === selectedBean) { 140 - option.selected = true; 141 - } 142 - beanSelect.appendChild(option); 143 - }); 144 - } 145 - 146 - // Populate grinders - using DOM methods to prevent XSS 147 - if (grinderSelect && this.grinders.length > 0) { 148 - // Clear existing options 149 - grinderSelect.innerHTML = ""; 150 - 151 - // Add placeholder 152 - const placeholderOption = document.createElement("option"); 153 - placeholderOption.value = ""; 154 - placeholderOption.textContent = "Select a grinder..."; 155 - grinderSelect.appendChild(placeholderOption); 156 - 157 - // Add grinder options 158 - this.grinders.forEach((grinder) => { 159 - const option = document.createElement("option"); 160 - option.value = grinder.rkey || grinder.RKey; 161 - // Using textContent ensures all user input is safely escaped 162 - option.textContent = grinder.Name || grinder.name; 163 - option.className = "truncate"; 164 - if ((grinder.rkey || grinder.RKey) === selectedGrinder) { 165 - option.selected = true; 166 - } 167 - grinderSelect.appendChild(option); 168 - }); 169 - } 170 - 171 - // Populate brewers - using DOM methods to prevent XSS 172 - if (brewerSelect && this.brewers.length > 0) { 173 - // Clear existing options 174 - brewerSelect.innerHTML = ""; 175 - 176 - // Add placeholder 177 - const placeholderOption = document.createElement("option"); 178 - placeholderOption.value = ""; 179 - placeholderOption.textContent = "Select brew method..."; 180 - brewerSelect.appendChild(placeholderOption); 181 - 182 - // Add brewer options 183 - this.brewers.forEach((brewer) => { 184 - const option = document.createElement("option"); 185 - option.value = brewer.rkey || brewer.RKey; 186 - // Using textContent ensures all user input is safely escaped 187 - option.textContent = brewer.Name || brewer.name; 188 - option.className = "truncate"; 189 - if ((brewer.rkey || brewer.RKey) === selectedBrewer) { 190 - option.selected = true; 191 - } 192 - brewerSelect.appendChild(option); 193 - }); 194 - } 195 - 196 - // Populate roasters in new bean modal - using DOM methods to prevent XSS 197 - const roasterSelect = document.querySelector('select[name="roaster_rkey_modal"]'); 198 - if (roasterSelect && this.roasters.length > 0) { 199 - // Clear existing options 200 - roasterSelect.innerHTML = ""; 201 - 202 - // Add placeholder 203 - const placeholderOption = document.createElement("option"); 204 - placeholderOption.value = ""; 205 - placeholderOption.textContent = "No roaster"; 206 - roasterSelect.appendChild(placeholderOption); 207 - 208 - // Add roaster options 209 - this.roasters.forEach((roaster) => { 210 - const option = document.createElement("option"); 211 - option.value = roaster.rkey || roaster.RKey; 212 - // Using textContent ensures all user input is safely escaped 213 - option.textContent = roaster.Name || roaster.name; 214 - roasterSelect.appendChild(option); 215 - }); 216 - } 217 - }, 218 - 219 - addPour() { 220 - this.pours.push({ water: "", time: "" }); 221 - }, 222 - 223 - removePour(index) { 224 - this.pours.splice(index, 1); 225 - }, 226 - 227 - async saveBean() { 228 - if (!this.beanForm.name || !this.beanForm.origin) { 229 - alert("Bean name and origin are required"); 230 - return; 231 - } 232 - 233 - const response = await fetch("/api/beans", { 234 - method: "POST", 235 - headers: { 236 - "Content-Type": "application/json", 237 - }, 238 - body: JSON.stringify(this.beanForm), 239 - }); 240 - 241 - if (response.ok) { 242 - const newBean = await response.json(); 243 - 244 - // Invalidate cache and refresh data in one call 245 - let freshData = null; 246 - if (window.ArabicaCache) { 247 - freshData = await window.ArabicaCache.invalidateAndRefresh(); 248 - } 249 - 250 - // Apply the fresh data to update dropdowns 251 - if (freshData) { 252 - this.applyData(freshData); 253 - } 254 - 255 - // Select the new bean 256 - const beanSelect = document.querySelector('form select[name="bean_rkey"]'); 257 - if (beanSelect && newBean.rkey) { 258 - beanSelect.value = newBean.rkey; 259 - } 260 - 261 - // Close modal and reset form 262 - this.showBeanForm = false; 263 - this.beanForm = { 264 - name: "", 265 - origin: "", 266 - roast_level: "", 267 - process: "", 268 - description: "", 269 - roaster_rkey: "", 270 - }; 271 - } else { 272 - const errorText = await response.text(); 273 - alert("Failed to add bean: " + errorText); 274 - } 275 - }, 276 - 277 - async saveGrinder() { 278 - if (!this.grinderForm.name) { 279 - alert("Grinder name is required"); 280 - return; 281 - } 282 - 283 - const response = await fetch("/api/grinders", { 284 - method: "POST", 285 - headers: { 286 - "Content-Type": "application/json", 287 - }, 288 - body: JSON.stringify(this.grinderForm), 289 - }); 290 - 291 - if (response.ok) { 292 - const newGrinder = await response.json(); 293 - 294 - // Invalidate cache and refresh data in one call 295 - let freshData = null; 296 - if (window.ArabicaCache) { 297 - freshData = await window.ArabicaCache.invalidateAndRefresh(); 298 - } 299 - 300 - // Apply the fresh data to update dropdowns 301 - if (freshData) { 302 - this.applyData(freshData); 303 - } 304 - 305 - // Select the new grinder 306 - const grinderSelect = document.querySelector('form select[name="grinder_rkey"]'); 307 - if (grinderSelect && newGrinder.rkey) { 308 - grinderSelect.value = newGrinder.rkey; 309 - } 310 - 311 - // Close modal and reset form 312 - this.showGrinderForm = false; 313 - this.grinderForm = { 314 - name: "", 315 - grinder_type: "", 316 - burr_type: "", 317 - notes: "", 318 - }; 319 - } else { 320 - const errorText = await response.text(); 321 - alert("Failed to add grinder: " + errorText); 322 - } 323 - }, 324 - 325 - async saveBrewer() { 326 - if (!this.brewerForm.name) { 327 - alert("Brewer name is required"); 328 - return; 329 - } 330 - 331 - const response = await fetch("/api/brewers", { 332 - method: "POST", 333 - headers: { 334 - "Content-Type": "application/json", 335 - }, 336 - body: JSON.stringify(this.brewerForm), 337 - }); 338 - 339 - if (response.ok) { 340 - const newBrewer = await response.json(); 341 - 342 - // Invalidate cache and refresh data in one call 343 - let freshData = null; 344 - if (window.ArabicaCache) { 345 - freshData = await window.ArabicaCache.invalidateAndRefresh(); 346 - } 347 - 348 - // Apply the fresh data to update dropdowns 349 - if (freshData) { 350 - this.applyData(freshData); 351 - } 352 - 353 - // Select the new brewer 354 - const brewerSelect = document.querySelector('form select[name="brewer_rkey"]'); 355 - if (brewerSelect && newBrewer.rkey) { 356 - brewerSelect.value = newBrewer.rkey; 357 - } 358 - 359 - // Close modal and reset form 360 - this.showBrewerForm = false; 361 - this.brewerForm = { name: "", brewer_type: "", description: "" }; 362 - } else { 363 - const errorText = await response.text(); 364 - alert("Failed to add brewer: " + errorText); 365 - } 366 - }, 367 - }; 368 - }
-320
web/static/js/data-cache.js
··· 1 - /** 2 - * Client-side data cache for Arabica 3 - * Caches beans, roasters, grinders, and brewers in localStorage 4 - * to reduce PDS round-trips on page loads. 5 - */ 6 - 7 - const CACHE_KEY = "arabica_data_cache"; 8 - const CACHE_VERSION = 1; 9 - const CACHE_TTL_MS = 30 * 1000; // 30 seconds (shorter for multi-device sync) 10 - const REFRESH_INTERVAL_MS = 30 * 1000; // 30 seconds 11 - 12 - // Module state 13 - let refreshTimer = null; 14 - let isRefreshing = false; 15 - let listeners = []; 16 - 17 - /** 18 - * Get the current cache from localStorage 19 - */ 20 - function getCache() { 21 - try { 22 - const raw = localStorage.getItem(CACHE_KEY); 23 - if (!raw) return null; 24 - 25 - const cache = JSON.parse(raw); 26 - 27 - // Check version 28 - if (cache.version !== CACHE_VERSION) { 29 - localStorage.removeItem(CACHE_KEY); 30 - return null; 31 - } 32 - 33 - return cache; 34 - } catch (e) { 35 - console.warn("Failed to read cache:", e); 36 - localStorage.removeItem(CACHE_KEY); 37 - return null; 38 - } 39 - } 40 - 41 - /** 42 - * Save data to the cache 43 - * Stores the user DID alongside the data for validation 44 - */ 45 - function setCache(data) { 46 - try { 47 - const cache = { 48 - version: CACHE_VERSION, 49 - timestamp: Date.now(), 50 - did: data.did || null, // Store user DID for cache validation 51 - data: data, 52 - }; 53 - localStorage.setItem(CACHE_KEY, JSON.stringify(cache)); 54 - } catch (e) { 55 - console.warn("Failed to write cache:", e); 56 - } 57 - } 58 - 59 - /** 60 - * Get the DID stored in the cache 61 - */ 62 - function getCachedDID() { 63 - const cache = getCache(); 64 - return cache?.did || null; 65 - } 66 - 67 - /** 68 - * Check if cache is valid (exists and not expired) 69 - */ 70 - function isCacheValid() { 71 - const cache = getCache(); 72 - if (!cache) return false; 73 - 74 - const age = Date.now() - cache.timestamp; 75 - return age < CACHE_TTL_MS; 76 - } 77 - 78 - /** 79 - * Get the current user's DID from the page 80 - */ 81 - function getCurrentUserDID() { 82 - return document.body?.dataset?.userDid || null; 83 - } 84 - 85 - /** 86 - * Get cached data if available and valid for the current user 87 - */ 88 - function getCachedData() { 89 - const cache = getCache(); 90 - if (!cache) return null; 91 - 92 - // Validate that cached data belongs to the current user 93 - const currentDID = getCurrentUserDID(); 94 - const cachedDID = cache.did; 95 - 96 - // If we have both DIDs and they don't match, cache is invalid 97 - if (currentDID && cachedDID && currentDID !== cachedDID) { 98 - console.log("Cache belongs to different user, invalidating"); 99 - invalidateCache(); 100 - return null; 101 - } 102 - 103 - // Return data even if expired - caller can decide to refresh 104 - return cache.data; 105 - } 106 - 107 - /** 108 - * Fetch fresh data from the API 109 - */ 110 - async function fetchFreshData() { 111 - const response = await fetch("/api/data", { 112 - credentials: "same-origin", 113 - }); 114 - 115 - if (!response.ok) { 116 - throw new Error(`Failed to fetch data: ${response.status}`); 117 - } 118 - 119 - return await response.json(); 120 - } 121 - 122 - /** 123 - * Refresh the cache from the API 124 - * Returns the fresh data 125 - * @param {boolean} force - If true, always fetch fresh data even if a refresh is in progress 126 - */ 127 - async function refreshCache(force = false) { 128 - if (isRefreshing) { 129 - // Wait for existing refresh to complete 130 - await new Promise((resolve) => { 131 - const checkInterval = setInterval(() => { 132 - if (!isRefreshing) { 133 - clearInterval(checkInterval); 134 - resolve(); 135 - } 136 - }, 100); 137 - }); 138 - 139 - // If not forcing, return the cached data from the completed refresh 140 - if (!force) { 141 - return getCachedData(); 142 - } 143 - // Otherwise, continue to do a new refresh with fresh data 144 - } 145 - 146 - isRefreshing = true; 147 - try { 148 - const data = await fetchFreshData(); 149 - 150 - // Check if user changed (different DID) 151 - const cachedDID = getCachedDID(); 152 - if (cachedDID && data.did && cachedDID !== data.did) { 153 - console.log("User changed, clearing stale cache"); 154 - invalidateCache(); 155 - } 156 - 157 - setCache(data); 158 - notifyListeners(data); 159 - return data; 160 - } finally { 161 - isRefreshing = false; 162 - } 163 - } 164 - 165 - /** 166 - * Get data - returns cached if valid, otherwise fetches fresh 167 - * @param {boolean} forceRefresh - Force a refresh even if cache is valid 168 - */ 169 - async function getData(forceRefresh = false) { 170 - if (!forceRefresh && isCacheValid()) { 171 - return getCachedData(); 172 - } 173 - 174 - // Try to get cached data while refreshing 175 - const cached = getCachedData(); 176 - 177 - try { 178 - return await refreshCache(); 179 - } catch (e) { 180 - console.warn("Failed to refresh cache:", e); 181 - // Return stale data if available 182 - if (cached) { 183 - return cached; 184 - } 185 - throw e; 186 - } 187 - } 188 - 189 - /** 190 - * Invalidate the cache (call after CRUD operations) 191 - */ 192 - function invalidateCache() { 193 - localStorage.removeItem(CACHE_KEY); 194 - } 195 - 196 - /** 197 - * Invalidate and immediately refresh the cache 198 - * Forces a fresh fetch even if a background refresh is in progress 199 - */ 200 - async function invalidateAndRefresh() { 201 - invalidateCache(); 202 - return await refreshCache(true); 203 - } 204 - 205 - /** 206 - * Register a listener for cache updates 207 - * @param {function} callback - Called with new data when cache is refreshed 208 - */ 209 - function addListener(callback) { 210 - listeners.push(callback); 211 - } 212 - 213 - /** 214 - * Remove a listener 215 - */ 216 - function removeListener(callback) { 217 - listeners = listeners.filter((l) => l !== callback); 218 - } 219 - 220 - /** 221 - * Notify all listeners of new data 222 - */ 223 - function notifyListeners(data) { 224 - listeners.forEach((callback) => { 225 - try { 226 - callback(data); 227 - } catch (e) { 228 - console.warn("Cache listener error:", e); 229 - } 230 - }); 231 - } 232 - 233 - /** 234 - * Start periodic background refresh 235 - */ 236 - function startPeriodicRefresh() { 237 - if (refreshTimer) return; 238 - 239 - refreshTimer = setInterval(async () => { 240 - try { 241 - await refreshCache(); 242 - } catch (e) { 243 - console.warn("Periodic refresh failed:", e); 244 - } 245 - }, REFRESH_INTERVAL_MS); 246 - } 247 - 248 - /** 249 - * Stop periodic background refresh 250 - */ 251 - function stopPeriodicRefresh() { 252 - if (refreshTimer) { 253 - clearInterval(refreshTimer); 254 - refreshTimer = null; 255 - } 256 - } 257 - 258 - /** 259 - * Initialize the cache - call on page load 260 - * Preloads data if not cached, starts periodic refresh 261 - */ 262 - async function init() { 263 - // Start periodic refresh 264 - startPeriodicRefresh(); 265 - 266 - // Preload if cache is empty or expired 267 - if (!isCacheValid()) { 268 - try { 269 - await refreshCache(); 270 - } catch (e) { 271 - console.warn("Initial cache load failed:", e); 272 - } 273 - } 274 - 275 - // Refresh when user returns to tab/app (handles multi-device sync) 276 - document.addEventListener("visibilitychange", () => { 277 - if (document.visibilityState === "visible" && !isCacheValid()) { 278 - refreshCache().catch((e) => 279 - console.warn("Visibility refresh failed:", e), 280 - ); 281 - } 282 - }); 283 - 284 - // For iOS PWA: refresh on focus 285 - window.addEventListener("focus", () => { 286 - if (!isCacheValid()) { 287 - refreshCache().catch((e) => console.warn("Focus refresh failed:", e)); 288 - } 289 - }); 290 - 291 - // Refresh on page show (back button, bfcache restore) 292 - window.addEventListener("pageshow", (event) => { 293 - if (event.persisted && !isCacheValid()) { 294 - refreshCache().catch((e) => console.warn("Pageshow refresh failed:", e)); 295 - } 296 - }); 297 - } 298 - 299 - /** 300 - * Preload cache - useful to call after login 301 - */ 302 - async function preload() { 303 - return await refreshCache(); 304 - } 305 - 306 - // Export as global for use in other scripts 307 - window.ArabicaCache = { 308 - getData, 309 - getCachedData, 310 - refreshCache, 311 - invalidateCache, 312 - invalidateAndRefresh, 313 - addListener, 314 - removeListener, 315 - startPeriodicRefresh, 316 - stopPeriodicRefresh, 317 - init, 318 - preload, 319 - isCacheValid, 320 - };
-153
web/static/js/handle-autocomplete.js
··· 1 - /** 2 - * Handle autocomplete for AT Protocol login 3 - * Provides typeahead search for Bluesky handles 4 - */ 5 - (function () { 6 - const input = document.getElementById("handle"); 7 - const results = document.getElementById("autocomplete-results"); 8 - 9 - // Exit early if elements don't exist (user might be authenticated) 10 - if (!input || !results) return; 11 - 12 - let debounceTimeout; 13 - let abortController; 14 - 15 - function debounce(func, wait) { 16 - return function executedFunction(...args) { 17 - const later = () => { 18 - clearTimeout(debounceTimeout); 19 - func(...args); 20 - }; 21 - clearTimeout(debounceTimeout); 22 - debounceTimeout = setTimeout(later, wait); 23 - }; 24 - } 25 - 26 - async function searchActors(query) { 27 - // Need at least 3 characters to search 28 - if (query.length < 3) { 29 - results.classList.add("hidden"); 30 - results.innerHTML = ""; 31 - return; 32 - } 33 - 34 - // Cancel previous request 35 - if (abortController) { 36 - abortController.abort(); 37 - } 38 - abortController = new AbortController(); 39 - 40 - try { 41 - const response = await fetch( 42 - `/api/search-actors?q=${encodeURIComponent(query)}`, 43 - { 44 - signal: abortController.signal, 45 - }, 46 - ); 47 - 48 - if (!response.ok) { 49 - results.classList.add("hidden"); 50 - results.innerHTML = ""; 51 - return; 52 - } 53 - 54 - const data = await response.json(); 55 - 56 - if (!data.actors || data.actors.length === 0) { 57 - results.innerHTML = 58 - '<div class="px-4 py-3 text-sm text-gray-500">No accounts found</div>'; 59 - results.classList.remove("hidden"); 60 - return; 61 - } 62 - 63 - // Clear previous results 64 - results.innerHTML = ""; 65 - 66 - // Create actor elements using DOM methods to prevent XSS 67 - data.actors.forEach((actor) => { 68 - const avatarUrl = actor.avatar || "/static/icon-placeholder.svg"; 69 - const displayName = actor.displayName || actor.handle; 70 - 71 - // Create container div 72 - const resultDiv = document.createElement("div"); 73 - resultDiv.className = 74 - "handle-result px-3 py-2 hover:bg-gray-100 cursor-pointer flex items-center gap-2"; 75 - resultDiv.setAttribute("data-handle", actor.handle); 76 - 77 - // Create avatar image 78 - const img = document.createElement("img"); 79 - // Validate URL scheme to prevent javascript: URLs 80 - if ( 81 - avatarUrl && 82 - (avatarUrl.startsWith("https://") || avatarUrl.startsWith("/static/")) 83 - ) { 84 - img.src = avatarUrl; 85 - } else { 86 - img.src = "/static/icon-placeholder.svg"; 87 - } 88 - img.alt = ""; // Empty alt for decorative images 89 - img.width = 32; 90 - img.height = 32; 91 - img.className = "w-6 h-6 rounded-full object-cover flex-shrink-0"; 92 - img.addEventListener("error", function () { 93 - this.src = "/static/icon-placeholder.svg"; 94 - }); 95 - 96 - // Create text container 97 - const textContainer = document.createElement("div"); 98 - textContainer.className = "flex-1 min-w-0"; 99 - 100 - // Create display name element 101 - const nameDiv = document.createElement("div"); 102 - nameDiv.className = "font-medium text-sm text-gray-900 truncate"; 103 - nameDiv.textContent = displayName; // textContent auto-escapes 104 - 105 - // Create handle element 106 - const handleDiv = document.createElement("div"); 107 - handleDiv.className = "text-xs text-gray-500 truncate"; 108 - handleDiv.textContent = "@" + actor.handle; // textContent auto-escapes 109 - 110 - // Assemble the elements 111 - textContainer.appendChild(nameDiv); 112 - textContainer.appendChild(handleDiv); 113 - resultDiv.appendChild(img); 114 - resultDiv.appendChild(textContainer); 115 - 116 - // Add click handler 117 - resultDiv.addEventListener("click", function () { 118 - input.value = actor.handle; // Use the actual handle from data, not DOM 119 - results.classList.add("hidden"); 120 - results.innerHTML = ""; 121 - }); 122 - 123 - results.appendChild(resultDiv); 124 - }); 125 - 126 - results.classList.remove("hidden"); 127 - } catch (error) { 128 - if (error.name !== "AbortError") { 129 - console.error("Error searching actors:", error); 130 - } 131 - } 132 - } 133 - 134 - const debouncedSearch = debounce(searchActors, 300); 135 - 136 - input.addEventListener("input", function (e) { 137 - debouncedSearch(e.target.value); 138 - }); 139 - 140 - // Hide results when clicking outside 141 - document.addEventListener("click", function (e) { 142 - if (!input.contains(e.target) && !results.contains(e.target)) { 143 - results.classList.add("hidden"); 144 - } 145 - }); 146 - 147 - // Show results again when input is focused 148 - input.addEventListener("focus", function () { 149 - if (results.innerHTML && input.value.length >= 3) { 150 - results.classList.remove("hidden"); 151 - } 152 - }); 153 - })();
-2
web/static/js/htmx.min.js
··· 1 - var htmx=function(){"use strict";const Q={onLoad:null,process:null,on:null,off:null,trigger:null,ajax:null,find:null,findAll:null,closest:null,values:function(e,t){const n=dn(e,t||"post");return n.values},remove:null,addClass:null,removeClass:null,toggleClass:null,takeClass:null,swap:null,defineExtension:null,removeExtension:null,logAll:null,logNone:null,logger:null,config:{historyEnabled:true,historyCacheSize:10,refreshOnHistoryMiss:false,defaultSwapStyle:"innerHTML",defaultSwapDelay:0,defaultSettleDelay:20,includeIndicatorStyles:true,indicatorClass:"htmx-indicator",requestClass:"htmx-request",addedClass:"htmx-added",settlingClass:"htmx-settling",swappingClass:"htmx-swapping",allowEval:true,allowScriptTags:true,inlineScriptNonce:"",inlineStyleNonce:"",attributesToSettle:["class","style","width","height"],withCredentials:false,timeout:0,wsReconnectDelay:"full-jitter",wsBinaryType:"blob",disableSelector:"[hx-disable], [data-hx-disable]",scrollBehavior:"instant",defaultFocusScroll:false,getCacheBusterParam:false,globalViewTransitions:false,methodsThatUseUrlParams:["get","delete"],selfRequestsOnly:true,ignoreTitle:false,scrollIntoViewOnBoost:true,triggerSpecsCache:null,disableInheritance:false,responseHandling:[{code:"204",swap:false},{code:"[23]..",swap:true},{code:"[45]..",swap:false,error:true}],allowNestedOobSwaps:true,historyRestoreAsHxRequest:true,reportValidityOfForms:false},parseInterval:null,location:location,_:null,version:"2.0.8"};Q.onLoad=V;Q.process=Ft;Q.on=xe;Q.off=be;Q.trigger=ae;Q.ajax=Ln;Q.find=f;Q.findAll=x;Q.closest=g;Q.remove=_;Q.addClass=K;Q.removeClass=G;Q.toggleClass=W;Q.takeClass=Z;Q.swap=ze;Q.defineExtension=_n;Q.removeExtension=zn;Q.logAll=j;Q.logNone=$;Q.parseInterval=d;Q._=e;const n={addTriggerHandler:St,bodyContains:se,canAccessLocalStorage:X,findThisElement:Se,filterValues:yn,swap:ze,hasAttribute:s,getAttributeValue:a,getClosestAttributeValue:ne,getClosestMatch:q,getExpressionVars:Rn,getHeaders:mn,getInputValues:dn,getInternalData:oe,getSwapSpecification:bn,getTriggerSpecs:st,getTarget:Ee,makeFragment:D,mergeObjects:le,makeSettleInfo:Sn,oobSwap:Te,querySelectorExt:ue,settleImmediately:Yt,shouldCancel:ht,triggerEvent:ae,triggerErrorEvent:fe,withExtensions:Vt};const de=["get","post","put","delete","patch"];const R=de.map(function(e){return"[hx-"+e+"], [data-hx-"+e+"]"}).join(", ");function d(e){if(e==undefined){return undefined}let t=NaN;if(e.slice(-2)=="ms"){t=parseFloat(e.slice(0,-2))}else if(e.slice(-1)=="s"){t=parseFloat(e.slice(0,-1))*1e3}else if(e.slice(-1)=="m"){t=parseFloat(e.slice(0,-1))*1e3*60}else{t=parseFloat(e)}return isNaN(t)?undefined:t}function ee(e,t){return e instanceof Element&&e.getAttribute(t)}function s(e,t){return!!e.hasAttribute&&(e.hasAttribute(t)||e.hasAttribute("data-"+t))}function a(e,t){return ee(e,t)||ee(e,"data-"+t)}function u(e){const t=e.parentElement;if(!t&&e.parentNode instanceof ShadowRoot)return e.parentNode;return t}function te(){return document}function y(e,t){return e.getRootNode?e.getRootNode({composed:t}):te()}function q(e,t){while(e&&!t(e)){e=u(e)}return e||null}function o(e,t,n){const r=a(t,n);const o=a(t,"hx-disinherit");var i=a(t,"hx-inherit");if(e!==t){if(Q.config.disableInheritance){if(i&&(i==="*"||i.split(" ").indexOf(n)>=0)){return r}else{return null}}if(o&&(o==="*"||o.split(" ").indexOf(n)>=0)){return"unset"}}return r}function ne(t,n){let r=null;q(t,function(e){return!!(r=o(t,ce(e),n))});if(r!=="unset"){return r}}function h(e,t){return e instanceof Element&&e.matches(t)}function A(e){const t=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i;const n=t.exec(e);if(n){return n[1].toLowerCase()}else{return""}}function L(e){if("parseHTMLUnsafe"in Document){return Document.parseHTMLUnsafe(e)}const t=new DOMParser;return t.parseFromString(e,"text/html")}function N(e,t){while(t.childNodes.length>0){e.append(t.childNodes[0])}}function r(e){const t=te().createElement("script");ie(e.attributes,function(e){t.setAttribute(e.name,e.value)});t.textContent=e.textContent;t.async=false;if(Q.config.inlineScriptNonce){t.nonce=Q.config.inlineScriptNonce}return t}function i(e){return e.matches("script")&&(e.type==="text/javascript"||e.type==="module"||e.type==="")}function I(e){Array.from(e.querySelectorAll("script")).forEach(e=>{if(i(e)){const t=r(e);const n=e.parentNode;try{n.insertBefore(t,e)}catch(e){H(e)}finally{e.remove()}}})}function D(e){const t=e.replace(/<head(\s[^>]*)?>[\s\S]*?<\/head>/i,"");const n=A(t);let r;if(n==="html"){r=new DocumentFragment;const i=L(e);N(r,i.body);r.title=i.title}else if(n==="body"){r=new DocumentFragment;const i=L(t);N(r,i.body);r.title=i.title}else{const i=L('<body><template class="internal-htmx-wrapper">'+t+"</template></body>");r=i.querySelector("template").content;r.title=i.title;var o=r.querySelector("title");if(o&&o.parentNode===r){o.remove();r.title=o.innerText}}if(r){if(Q.config.allowScriptTags){I(r)}else{r.querySelectorAll("script").forEach(e=>e.remove())}}return r}function re(e){if(e){e()}}function t(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function P(e){return typeof e==="function"}function k(e){return t(e,"Object")}function oe(e){const t="htmx-internal-data";let n=e[t];if(!n){n=e[t]={}}return n}function M(t){const n=[];if(t){for(let e=0;e<t.length;e++){n.push(t[e])}}return n}function ie(t,n){if(t){for(let e=0;e<t.length;e++){n(t[e])}}}function F(e){const t=e.getBoundingClientRect();const n=t.top;const r=t.bottom;return n<window.innerHeight&&r>=0}function se(e){return e.getRootNode({composed:true})===document}function B(e){return e.trim().split(/\s+/)}function le(e,t){for(const n in t){if(t.hasOwnProperty(n)){e[n]=t[n]}}return e}function v(e){try{return JSON.parse(e)}catch(e){H(e);return null}}function X(){const e="htmx:sessionStorageTest";try{sessionStorage.setItem(e,e);sessionStorage.removeItem(e);return true}catch(e){return false}}function U(e){const t=new URL(e,"http://x");if(t){e=t.pathname+t.search}if(e!="/"){e=e.replace(/\/+$/,"")}return e}function e(e){return On(te().body,function(){return eval(e)})}function V(t){const e=Q.on("htmx:load",function(e){t(e.detail.elt)});return e}function j(){Q.logger=function(e,t,n){if(console){console.log(t,e,n)}}}function $(){Q.logger=null}function f(e,t){if(typeof e!=="string"){return e.querySelector(t)}else{return f(te(),e)}}function x(e,t){if(typeof e!=="string"){return e.querySelectorAll(t)}else{return x(te(),e)}}function b(){return window}function _(e,t){e=w(e);if(t){b().setTimeout(function(){_(e);e=null},t)}else{u(e).removeChild(e)}}function ce(e){return e instanceof Element?e:null}function z(e){return e instanceof HTMLElement?e:null}function J(e){return typeof e==="string"?e:null}function p(e){return e instanceof Element||e instanceof Document||e instanceof DocumentFragment?e:null}function K(e,t,n){e=ce(w(e));if(!e){return}if(n){b().setTimeout(function(){K(e,t);e=null},n)}else{e.classList&&e.classList.add(t)}}function G(e,t,n){let r=ce(w(e));if(!r){return}if(n){b().setTimeout(function(){G(r,t);r=null},n)}else{if(r.classList){r.classList.remove(t);if(r.classList.length===0){r.removeAttribute("class")}}}}function W(e,t){e=w(e);e.classList.toggle(t)}function Z(e,t){e=w(e);ie(e.parentElement.children,function(e){G(e,t)});K(ce(e),t)}function g(e,t){e=ce(w(e));if(e){return e.closest(t)}return null}function l(e,t){return e.substring(0,t.length)===t}function Y(e,t){return e.substring(e.length-t.length)===t}function pe(e){const t=e.trim();if(l(t,"<")&&Y(t,"/>")){return t.substring(1,t.length-2)}else{return t}}function m(t,r,n){if(r.indexOf("global ")===0){return m(t,r.slice(7),true)}t=w(t);const o=[];{let t=0;let n=0;for(let e=0;e<r.length;e++){const l=r[e];if(l===","&&t===0){o.push(r.substring(n,e));n=e+1;continue}if(l==="<"){t++}else if(l==="/"&&e<r.length-1&&r[e+1]===">"){t--}}if(n<r.length){o.push(r.substring(n))}}const i=[];const s=[];while(o.length>0){const r=pe(o.shift());let e;if(r.indexOf("closest ")===0){e=g(ce(t),pe(r.slice(8)))}else if(r.indexOf("find ")===0){e=f(p(t),pe(r.slice(5)))}else if(r==="next"||r==="nextElementSibling"){e=ce(t).nextElementSibling}else if(r.indexOf("next ")===0){e=ge(t,pe(r.slice(5)),!!n)}else if(r==="previous"||r==="previousElementSibling"){e=ce(t).previousElementSibling}else if(r.indexOf("previous ")===0){e=me(t,pe(r.slice(9)),!!n)}else if(r==="document"){e=document}else if(r==="window"){e=window}else if(r==="body"){e=document.body}else if(r==="root"){e=y(t,!!n)}else if(r==="host"){e=t.getRootNode().host}else{s.push(r)}if(e){i.push(e)}}if(s.length>0){const e=s.join(",");const c=p(y(t,!!n));i.push(...M(c.querySelectorAll(e)))}return i}var ge=function(t,e,n){const r=p(y(t,n)).querySelectorAll(e);for(let e=0;e<r.length;e++){const o=r[e];if(o.compareDocumentPosition(t)===Node.DOCUMENT_POSITION_PRECEDING){return o}}};var me=function(t,e,n){const r=p(y(t,n)).querySelectorAll(e);for(let e=r.length-1;e>=0;e--){const o=r[e];if(o.compareDocumentPosition(t)===Node.DOCUMENT_POSITION_FOLLOWING){return o}}};function ue(e,t){if(typeof e!=="string"){return m(e,t)[0]}else{return m(te().body,e)[0]}}function w(e,t){if(typeof e==="string"){return f(p(t)||document,e)}else{return e}}function ye(e,t,n,r){if(P(t)){return{target:te().body,event:J(e),listener:t,options:n}}else{return{target:w(e),event:J(t),listener:n,options:r}}}function xe(t,n,r,o){Gn(function(){const e=ye(t,n,r,o);e.target.addEventListener(e.event,e.listener,e.options)});const e=P(n);return e?n:r}function be(t,n,r){Gn(function(){const e=ye(t,n,r);e.target.removeEventListener(e.event,e.listener)});return P(n)?n:r}const ve=te().createElement("output");function we(t,n){const e=ne(t,n);if(e){if(e==="this"){return[Se(t,n)]}else{const r=m(t,e);const o=/(^|,)(\s*)inherit(\s*)($|,)/.test(e);if(o){const i=ce(q(t,function(e){return e!==t&&s(ce(e),n)}));if(i){r.push(...we(i,n))}}if(r.length===0){H('The selector "'+e+'" on '+n+" returned no matches!");return[ve]}else{return r}}}}function Se(e,t){return ce(q(e,function(e){return a(ce(e),t)!=null}))}function Ee(e){const t=ne(e,"hx-target");if(t){if(t==="this"){return Se(e,"hx-target")}else{return ue(e,t)}}else{const n=oe(e);if(n.boosted){return te().body}else{return e}}}function Ce(e){return Q.config.attributesToSettle.includes(e)}function Oe(t,n){ie(Array.from(t.attributes),function(e){if(!n.hasAttribute(e.name)&&Ce(e.name)){t.removeAttribute(e.name)}});ie(n.attributes,function(e){if(Ce(e.name)){t.setAttribute(e.name,e.value)}})}function He(t,e){const n=Jn(e);for(let e=0;e<n.length;e++){const r=n[e];try{if(r.isInlineSwap(t)){return true}}catch(e){H(e)}}return t==="outerHTML"}function Te(e,o,i,t){t=t||te();let n="#"+CSS.escape(ee(o,"id"));let s="outerHTML";if(e==="true"){}else if(e.indexOf(":")>0){s=e.substring(0,e.indexOf(":"));n=e.substring(e.indexOf(":")+1)}else{s=e}o.removeAttribute("hx-swap-oob");o.removeAttribute("data-hx-swap-oob");const r=m(t,n,false);if(r.length){ie(r,function(e){let t;const n=o.cloneNode(true);t=te().createDocumentFragment();t.appendChild(n);if(!He(s,e)){t=p(n)}const r={shouldSwap:true,target:e,fragment:t};if(!ae(e,"htmx:oobBeforeSwap",r))return;e=r.target;if(r.shouldSwap){qe(t);$e(s,e,e,t,i);Re()}ie(i.elts,function(e){ae(e,"htmx:oobAfterSwap",r)})});o.parentNode.removeChild(o)}else{o.parentNode.removeChild(o);fe(te().body,"htmx:oobErrorNoTarget",{content:o})}return e}function Re(){const e=f("#--htmx-preserve-pantry--");if(e){for(const t of[...e.children]){const n=f("#"+t.id);n.parentNode.moveBefore(t,n);n.remove()}e.remove()}}function qe(e){ie(x(e,"[hx-preserve], [data-hx-preserve]"),function(e){const t=a(e,"id");const n=te().getElementById(t);if(n!=null){if(e.moveBefore){let e=f("#--htmx-preserve-pantry--");if(e==null){te().body.insertAdjacentHTML("afterend","<div id='--htmx-preserve-pantry--'></div>");e=f("#--htmx-preserve-pantry--")}e.moveBefore(n,null)}else{e.parentNode.replaceChild(n,e)}}})}function Ae(l,e,c){ie(e.querySelectorAll("[id]"),function(t){const n=ee(t,"id");if(n&&n.length>0){const r=n.replace("'","\\'");const o=t.tagName.replace(":","\\:");const e=p(l);const i=e&&e.querySelector(o+"[id='"+r+"']");if(i&&i!==e){const s=t.cloneNode();Oe(t,i);c.tasks.push(function(){Oe(t,s)})}}})}function Le(e){return function(){G(e,Q.config.addedClass);Ft(ce(e));Ne(p(e));ae(e,"htmx:load")}}function Ne(e){const t="[autofocus]";const n=z(h(e,t)?e:e.querySelector(t));if(n!=null){n.focus()}}function c(e,t,n,r){Ae(e,n,r);while(n.childNodes.length>0){const o=n.firstChild;K(ce(o),Q.config.addedClass);e.insertBefore(o,t);if(o.nodeType!==Node.TEXT_NODE&&o.nodeType!==Node.COMMENT_NODE){r.tasks.push(Le(o))}}}function Ie(e,t){let n=0;while(n<e.length){t=(t<<5)-t+e.charCodeAt(n++)|0}return t}function De(t){let n=0;for(let e=0;e<t.attributes.length;e++){const r=t.attributes[e];if(r.value){n=Ie(r.name,n);n=Ie(r.value,n)}}return n}function Pe(t){const n=oe(t);if(n.onHandlers){for(let e=0;e<n.onHandlers.length;e++){const r=n.onHandlers[e];be(t,r.event,r.listener)}delete n.onHandlers}}function ke(e){const t=oe(e);if(t.timeout){clearTimeout(t.timeout)}if(t.listenerInfos){ie(t.listenerInfos,function(e){if(e.on){be(e.on,e.trigger,e.listener)}})}Pe(e);ie(Object.keys(t),function(e){if(e!=="firstInitCompleted")delete t[e]})}function S(e){ae(e,"htmx:beforeCleanupElement");ke(e);ie(e.children,function(e){S(e)})}function Me(t,e,n){if(t.tagName==="BODY"){return je(t,e,n)}let r;const o=t.previousSibling;const i=u(t);if(!i){return}c(i,t,e,n);if(o==null){r=i.firstChild}else{r=o.nextSibling}n.elts=n.elts.filter(function(e){return e!==t});while(r&&r!==t){if(r instanceof Element){n.elts.push(r)}r=r.nextSibling}S(t);t.remove()}function Fe(e,t,n){return c(e,e.firstChild,t,n)}function Be(e,t,n){return c(u(e),e,t,n)}function Xe(e,t,n){return c(e,null,t,n)}function Ue(e,t,n){return c(u(e),e.nextSibling,t,n)}function Ve(e){S(e);const t=u(e);if(t){return t.removeChild(e)}}function je(e,t,n){const r=e.firstChild;c(e,r,t,n);if(r){while(r.nextSibling){S(r.nextSibling);e.removeChild(r.nextSibling)}S(r);e.removeChild(r)}}function $e(t,e,n,r,o){switch(t){case"none":return;case"outerHTML":Me(n,r,o);return;case"afterbegin":Fe(n,r,o);return;case"beforebegin":Be(n,r,o);return;case"beforeend":Xe(n,r,o);return;case"afterend":Ue(n,r,o);return;case"delete":Ve(n);return;default:var i=Jn(e);for(let e=0;e<i.length;e++){const s=i[e];try{const l=s.handleSwap(t,n,r,o);if(l){if(Array.isArray(l)){for(let e=0;e<l.length;e++){const c=l[e];if(c.nodeType!==Node.TEXT_NODE&&c.nodeType!==Node.COMMENT_NODE){o.tasks.push(Le(c))}}}return}}catch(e){H(e)}}if(t==="innerHTML"){je(n,r,o)}else{$e(Q.config.defaultSwapStyle,e,n,r,o)}}}function _e(e,n,r){var t=x(e,"[hx-swap-oob], [data-hx-swap-oob]");ie(t,function(e){if(Q.config.allowNestedOobSwaps||e.parentElement===null){const t=a(e,"hx-swap-oob");if(t!=null){Te(t,e,n,r)}}else{e.removeAttribute("hx-swap-oob");e.removeAttribute("data-hx-swap-oob")}});return t.length>0}function ze(h,d,p,g){if(!g){g={}}let m=null;let n=null;let e=function(){re(g.beforeSwapCallback);h=w(h);const r=g.contextElement?y(g.contextElement,false):te();const e=document.activeElement;let t={};t={elt:e,start:e?e.selectionStart:null,end:e?e.selectionEnd:null};const o=Sn(h);if(p.swapStyle==="textContent"){h.textContent=d}else{let n=D(d);o.title=g.title||n.title;if(g.historyRequest){n=n.querySelector("[hx-history-elt],[data-hx-history-elt]")||n}if(g.selectOOB){const i=g.selectOOB.split(",");for(let t=0;t<i.length;t++){const s=i[t].split(":",2);let e=s[0].trim();if(e.indexOf("#")===0){e=e.substring(1)}const l=s[1]||"true";const c=n.querySelector("#"+e);if(c){Te(l,c,o,r)}}}_e(n,o,r);ie(x(n,"template"),function(e){if(e.content&&_e(e.content,o,r)){e.remove()}});if(g.select){const u=te().createDocumentFragment();ie(n.querySelectorAll(g.select),function(e){u.appendChild(e)});n=u}qe(n);$e(p.swapStyle,g.contextElement,h,n,o);Re()}if(t.elt&&!se(t.elt)&&ee(t.elt,"id")){const f=document.getElementById(ee(t.elt,"id"));const a={preventScroll:p.focusScroll!==undefined?!p.focusScroll:!Q.config.defaultFocusScroll};if(f){if(t.start&&f.setSelectionRange){try{f.setSelectionRange(t.start,t.end)}catch(e){}}f.focus(a)}}h.classList.remove(Q.config.swappingClass);ie(o.elts,function(e){if(e.classList){e.classList.add(Q.config.settlingClass)}ae(e,"htmx:afterSwap",g.eventInfo)});re(g.afterSwapCallback);if(!p.ignoreTitle){Xn(o.title)}const n=function(){ie(o.tasks,function(e){e.call()});ie(o.elts,function(e){if(e.classList){e.classList.remove(Q.config.settlingClass)}ae(e,"htmx:afterSettle",g.eventInfo)});if(g.anchor){const e=ce(w("#"+g.anchor));if(e){e.scrollIntoView({block:"start",behavior:"auto"})}}En(o.elts,p);re(g.afterSettleCallback);re(m)};if(p.settleDelay>0){b().setTimeout(n,p.settleDelay)}else{n()}};let t=Q.config.globalViewTransitions;if(p.hasOwnProperty("transition")){t=p.transition}const r=g.contextElement||te();if(t&&ae(r,"htmx:beforeTransition",g.eventInfo)&&typeof Promise!=="undefined"&&document.startViewTransition){const o=new Promise(function(e,t){m=e;n=t});const i=e;e=function(){document.startViewTransition(function(){i();return o})}}try{if(p?.swapDelay&&p.swapDelay>0){b().setTimeout(e,p.swapDelay)}else{e()}}catch(e){fe(r,"htmx:swapError",g.eventInfo);re(n);throw e}}function Je(e,t,n){const r=e.getResponseHeader(t);if(r.indexOf("{")===0){const o=v(r);for(const i in o){if(o.hasOwnProperty(i)){let e=o[i];if(k(e)){n=e.target!==undefined?e.target:n}else{e={value:e}}ae(n,i,e)}}}else{const s=r.split(",");for(let e=0;e<s.length;e++){ae(n,s[e].trim(),[])}}}const Ke=/\s/;const E=/[\s,]/;const Ge=/[_$a-zA-Z]/;const We=/[_$a-zA-Z0-9]/;const Ze=['"',"'","/"];const C=/[^\s]/;const Ye=/[{(]/;const Qe=/[})]/;function et(e){const t=[];let n=0;while(n<e.length){if(Ge.exec(e.charAt(n))){var r=n;while(We.exec(e.charAt(n+1))){n++}t.push(e.substring(r,n+1))}else if(Ze.indexOf(e.charAt(n))!==-1){const o=e.charAt(n);var r=n;n++;while(n<e.length&&e.charAt(n)!==o){if(e.charAt(n)==="\\"){n++}n++}t.push(e.substring(r,n+1))}else{const i=e.charAt(n);t.push(i)}n++}return t}function tt(e,t,n){return Ge.exec(e.charAt(0))&&e!=="true"&&e!=="false"&&e!=="this"&&e!==n&&t!=="."}function nt(r,o,i){if(o[0]==="["){o.shift();let e=1;let t=" return (function("+i+"){ return (";let n=null;while(o.length>0){const s=o[0];if(s==="]"){e--;if(e===0){if(n===null){t=t+"true"}o.shift();t+=")})";try{const l=On(r,function(){return Function(t)()},function(){return true});l.source=t;return l}catch(e){fe(te().body,"htmx:syntax:error",{error:e,source:t});return null}}}else if(s==="["){e++}if(tt(s,n,i)){t+="(("+i+"."+s+") ? ("+i+"."+s+") : (window."+s+"))"}else{t=t+s}n=o.shift()}}}function O(e,t){let n="";while(e.length>0&&!t.test(e[0])){n+=e.shift()}return n}function rt(e){let t;if(e.length>0&&Ye.test(e[0])){e.shift();t=O(e,Qe).trim();e.shift()}else{t=O(e,E)}return t}const ot="input, textarea, select";function it(e,t,n){const r=[];const o=et(t);do{O(o,C);const l=o.length;const c=O(o,/[,\[\s]/);if(c!==""){if(c==="every"){const u={trigger:"every"};O(o,C);u.pollInterval=d(O(o,/[,\[\s]/));O(o,C);var i=nt(e,o,"event");if(i){u.eventFilter=i}r.push(u)}else{const f={trigger:c};var i=nt(e,o,"event");if(i){f.eventFilter=i}O(o,C);while(o.length>0&&o[0]!==","){const a=o.shift();if(a==="changed"){f.changed=true}else if(a==="once"){f.once=true}else if(a==="consume"){f.consume=true}else if(a==="delay"&&o[0]===":"){o.shift();f.delay=d(O(o,E))}else if(a==="from"&&o[0]===":"){o.shift();if(Ye.test(o[0])){var s=rt(o)}else{var s=O(o,E);if(s==="closest"||s==="find"||s==="next"||s==="previous"){o.shift();const h=rt(o);if(h.length>0){s+=" "+h}}}f.from=s}else if(a==="target"&&o[0]===":"){o.shift();f.target=rt(o)}else if(a==="throttle"&&o[0]===":"){o.shift();f.throttle=d(O(o,E))}else if(a==="queue"&&o[0]===":"){o.shift();f.queue=O(o,E)}else if(a==="root"&&o[0]===":"){o.shift();f[a]=rt(o)}else if(a==="threshold"&&o[0]===":"){o.shift();f[a]=O(o,E)}else{fe(e,"htmx:syntax:error",{token:o.shift()})}O(o,C)}r.push(f)}}if(o.length===l){fe(e,"htmx:syntax:error",{token:o.shift()})}O(o,C)}while(o[0]===","&&o.shift());if(n){n[t]=r}return r}function st(e){const t=a(e,"hx-trigger");let n=[];if(t){const r=Q.config.triggerSpecsCache;n=r&&r[t]||it(e,t,r)}if(n.length>0){return n}else if(h(e,"form")){return[{trigger:"submit"}]}else if(h(e,'input[type="button"], input[type="submit"]')){return[{trigger:"click"}]}else if(h(e,ot)){return[{trigger:"change"}]}else{return[{trigger:"click"}]}}function lt(e){oe(e).cancelled=true}function ct(e,t,n){const r=oe(e);r.timeout=b().setTimeout(function(){if(se(e)&&r.cancelled!==true){if(!pt(n,e,Xt("hx:poll:trigger",{triggerSpec:n,target:e}))){t(e)}ct(e,t,n)}},n.pollInterval)}function ut(e){return location.hostname===e.hostname&&ee(e,"href")&&ee(e,"href").indexOf("#")!==0}function ft(e){return g(e,Q.config.disableSelector)}function at(t,n,e){if(t instanceof HTMLAnchorElement&&ut(t)&&(t.target===""||t.target==="_self")||t.tagName==="FORM"&&String(ee(t,"method")).toLowerCase()!=="dialog"){n.boosted=true;let r,o;if(t.tagName==="A"){r="get";o=ee(t,"href")}else{const i=ee(t,"method");r=i?i.toLowerCase():"get";o=ee(t,"action");if(o==null||o===""){o=location.href}if(r==="get"&&o.includes("?")){o=o.replace(/\?[^#]+/,"")}}e.forEach(function(e){gt(t,function(e,t){const n=ce(e);if(ft(n)){S(n);return}he(r,o,n,t)},n,e,true)})}}function ht(e,t){if(e.type==="submit"&&t.tagName==="FORM"){return true}else if(e.type==="click"){const n=t.closest('input[type="submit"], button');if(n&&n.form&&n.type==="submit"){return true}const r=t.closest("a");const o=/^#.+/;if(r&&r.href&&!o.test(r.getAttribute("href"))){return true}}return false}function dt(e,t){return oe(e).boosted&&e instanceof HTMLAnchorElement&&t.type==="click"&&(t.ctrlKey||t.metaKey)}function pt(e,t,n){const r=e.eventFilter;if(r){try{return r.call(t,n)!==true}catch(e){const o=r.source;fe(te().body,"htmx:eventFilter:error",{error:e,source:o});return true}}return false}function gt(l,c,e,u,f){const a=oe(l);let t;if(u.from){t=m(l,u.from)}else{t=[l]}if(u.changed){if(!("lastValue"in a)){a.lastValue=new WeakMap}t.forEach(function(e){if(!a.lastValue.has(u)){a.lastValue.set(u,new WeakMap)}a.lastValue.get(u).set(e,e.value)})}ie(t,function(i){const s=function(e){if(!se(l)){i.removeEventListener(u.trigger,s);return}if(dt(l,e)){return}if(f||ht(e,i)){e.preventDefault()}if(pt(u,l,e)){return}const t=oe(e);t.triggerSpec=u;if(t.handledFor==null){t.handledFor=[]}if(t.handledFor.indexOf(l)<0){t.handledFor.push(l);if(u.consume){e.stopPropagation()}if(u.target&&e.target){if(!h(ce(e.target),u.target)){return}}if(u.once){if(a.triggeredOnce){return}else{a.triggeredOnce=true}}if(u.changed){const n=e.target;const r=n.value;const o=a.lastValue.get(u);if(o.has(n)&&o.get(n)===r){return}o.set(n,r)}if(a.delayed){clearTimeout(a.delayed)}if(a.throttle){return}if(u.throttle>0){if(!a.throttle){ae(l,"htmx:trigger");c(l,e);a.throttle=b().setTimeout(function(){a.throttle=null},u.throttle)}}else if(u.delay>0){a.delayed=b().setTimeout(function(){ae(l,"htmx:trigger");c(l,e)},u.delay)}else{ae(l,"htmx:trigger");c(l,e)}}};if(e.listenerInfos==null){e.listenerInfos=[]}e.listenerInfos.push({trigger:u.trigger,listener:s,on:i});i.addEventListener(u.trigger,s)})}let mt=false;let yt=null;function xt(){if(!yt){yt=function(){mt=true};window.addEventListener("scroll",yt);window.addEventListener("resize",yt);setInterval(function(){if(mt){mt=false;ie(te().querySelectorAll("[hx-trigger*='revealed'],[data-hx-trigger*='revealed']"),function(e){bt(e)})}},200)}}function bt(e){if(!s(e,"data-hx-revealed")&&F(e)){e.setAttribute("data-hx-revealed","true");const t=oe(e);if(t.initHash){ae(e,"revealed")}else{e.addEventListener("htmx:afterProcessNode",function(){ae(e,"revealed")},{once:true})}}}function vt(e,t,n,r){const o=function(){if(!n.loaded){n.loaded=true;ae(e,"htmx:trigger");t(e)}};if(r>0){b().setTimeout(o,r)}else{o()}}function wt(t,n,e){let i=false;ie(de,function(r){if(s(t,"hx-"+r)){const o=a(t,"hx-"+r);i=true;n.path=o;n.verb=r;e.forEach(function(e){St(t,e,n,function(e,t){const n=ce(e);if(ft(n)){S(n);return}he(r,o,n,t)})})}});return i}function St(r,e,t,n){if(e.trigger==="revealed"){xt();gt(r,n,t,e);bt(ce(r))}else if(e.trigger==="intersect"){const o={};if(e.root){o.root=ue(r,e.root)}if(e.threshold){o.threshold=parseFloat(e.threshold)}const i=new IntersectionObserver(function(t){for(let e=0;e<t.length;e++){const n=t[e];if(n.isIntersecting){ae(r,"intersect");break}}},o);i.observe(ce(r));gt(ce(r),n,t,e)}else if(!t.firstInitCompleted&&e.trigger==="load"){if(!pt(e,r,Xt("load",{elt:r}))){vt(ce(r),n,t,e.delay)}}else if(e.pollInterval>0){t.polling=true;ct(ce(r),n,e)}else{gt(r,n,t,e)}}function Et(e){const t=ce(e);if(!t){return false}const n=t.attributes;for(let e=0;e<n.length;e++){const r=n[e].name;if(l(r,"hx-on:")||l(r,"data-hx-on:")||l(r,"hx-on-")||l(r,"data-hx-on-")){return true}}return false}const Ct=(new XPathEvaluator).createExpression('.//*[@*[ starts-with(name(), "hx-on:") or starts-with(name(), "data-hx-on:") or'+' starts-with(name(), "hx-on-") or starts-with(name(), "data-hx-on-") ]]');function Ot(e,t){if(Et(e)){t.push(ce(e))}const n=Ct.evaluate(e);let r=null;while(r=n.iterateNext())t.push(ce(r))}function Ht(e){const t=[];if(e instanceof DocumentFragment){for(const n of e.childNodes){Ot(n,t)}}else{Ot(e,t)}return t}function Tt(e){if(e.querySelectorAll){const n=", [hx-boost] a, [data-hx-boost] a, a[hx-boost], a[data-hx-boost]";const r=[];for(const i in jn){const s=jn[i];if(s.getSelectors){var t=s.getSelectors();if(t){r.push(t)}}}const o=e.querySelectorAll(R+n+", form, [type='submit'],"+" [hx-ext], [data-hx-ext], [hx-trigger], [data-hx-trigger]"+r.flat().map(e=>", "+e).join(""));return o}else{return[]}}function Rt(e){const t=At(e.target);const n=Nt(e);if(n){n.lastButtonClicked=t}}function qt(e){const t=Nt(e);if(t){t.lastButtonClicked=null}}function At(e){return g(ce(e),"button, input[type='submit']")}function Lt(e){return e.form||g(e,"form")}function Nt(e){const t=At(e.target);if(!t){return}const n=Lt(t);if(!n){return}return oe(n)}function It(e){e.addEventListener("click",Rt);e.addEventListener("focusin",Rt);e.addEventListener("focusout",qt)}function Dt(t,e,n){const r=oe(t);if(!Array.isArray(r.onHandlers)){r.onHandlers=[]}let o;const i=function(e){On(t,function(){if(ft(t)){return}if(!o){o=new Function("event",n)}o.call(t,e)})};t.addEventListener(e,i);r.onHandlers.push({event:e,listener:i})}function Pt(t){Pe(t);for(let e=0;e<t.attributes.length;e++){const n=t.attributes[e].name;const r=t.attributes[e].value;if(l(n,"hx-on")||l(n,"data-hx-on")){const o=n.indexOf("-on")+3;const i=n.slice(o,o+1);if(i==="-"||i===":"){let e=n.slice(o+1);if(l(e,":")){e="htmx"+e}else if(l(e,"-")){e="htmx:"+e.slice(1)}else if(l(e,"htmx-")){e="htmx:"+e.slice(5)}Dt(t,e,r)}}}}function kt(t){ae(t,"htmx:beforeProcessNode");const n=oe(t);const e=st(t);const r=wt(t,n,e);if(!r){if(ne(t,"hx-boost")==="true"){at(t,n,e)}else if(s(t,"hx-trigger")){e.forEach(function(e){St(t,e,n,function(){})})}}if(t.tagName==="FORM"||ee(t,"type")==="submit"&&s(t,"form")){It(t)}n.firstInitCompleted=true;ae(t,"htmx:afterProcessNode")}function Mt(e){if(!(e instanceof Element)){return false}const t=oe(e);const n=De(e);if(t.initHash!==n){ke(e);t.initHash=n;return true}return false}function Ft(e){e=w(e);if(ft(e)){S(e);return}const t=[];if(Mt(e)){t.push(e)}ie(Tt(e),function(e){if(ft(e)){S(e);return}if(Mt(e)){t.push(e)}});ie(Ht(e),Pt);ie(t,kt)}function Bt(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function Xt(e,t){return new CustomEvent(e,{bubbles:true,cancelable:true,composed:true,detail:t})}function fe(e,t,n){ae(e,t,le({error:t},n))}function Ut(e){return e==="htmx:afterProcessNode"}function Vt(e,t,n){ie(Jn(e,[],n),function(e){try{t(e)}catch(e){H(e)}})}function H(e){console.error(e)}function ae(e,t,n){e=w(e);if(n==null){n={}}n.elt=e;const r=Xt(t,n);if(Q.logger&&!Ut(t)){Q.logger(e,t,n)}if(n.error){H(n.error);ae(e,"htmx:error",{errorInfo:n})}let o=e.dispatchEvent(r);const i=Bt(t);if(o&&i!==t){const s=Xt(i,r.detail);o=o&&e.dispatchEvent(s)}Vt(ce(e),function(e){o=o&&(e.onEvent(t,r)!==false&&!r.defaultPrevented)});return o}let jt;function $t(e){jt=e;if(X()){sessionStorage.setItem("htmx-current-path-for-history",e)}}$t(location.pathname+location.search);function _t(){const e=te().querySelector("[hx-history-elt],[data-hx-history-elt]");return e||te().body}function zt(t,e){if(!X()){return}const n=Kt(e);const r=te().title;const o=window.scrollY;if(Q.config.historyCacheSize<=0){sessionStorage.removeItem("htmx-history-cache");return}t=U(t);const i=v(sessionStorage.getItem("htmx-history-cache"))||[];for(let e=0;e<i.length;e++){if(i[e].url===t){i.splice(e,1);break}}const s={url:t,content:n,title:r,scroll:o};ae(te().body,"htmx:historyItemCreated",{item:s,cache:i});i.push(s);while(i.length>Q.config.historyCacheSize){i.shift()}while(i.length>0){try{sessionStorage.setItem("htmx-history-cache",JSON.stringify(i));break}catch(e){fe(te().body,"htmx:historyCacheError",{cause:e,cache:i});i.shift()}}}function Jt(t){if(!X()){return null}t=U(t);const n=v(sessionStorage.getItem("htmx-history-cache"))||[];for(let e=0;e<n.length;e++){if(n[e].url===t){return n[e]}}return null}function Kt(e){const t=Q.config.requestClass;const n=e.cloneNode(true);ie(x(n,"."+t),function(e){G(e,t)});ie(x(n,"[data-disabled-by-htmx]"),function(e){e.removeAttribute("disabled")});return n.innerHTML}function Gt(){const e=_t();let t=jt;if(X()){t=sessionStorage.getItem("htmx-current-path-for-history")}t=t||location.pathname+location.search;const n=te().querySelector('[hx-history="false" i],[data-hx-history="false" i]');if(!n){ae(te().body,"htmx:beforeHistorySave",{path:t,historyElt:e});zt(t,e)}if(Q.config.historyEnabled)history.replaceState({htmx:true},te().title,location.href)}function Wt(e){if(Q.config.getCacheBusterParam){e=e.replace(/org\.htmx\.cache-buster=[^&]*&?/,"");if(Y(e,"&")||Y(e,"?")){e=e.slice(0,-1)}}if(Q.config.historyEnabled){history.pushState({htmx:true},"",e)}$t(e)}function Zt(e){if(Q.config.historyEnabled)history.replaceState({htmx:true},"",e);$t(e)}function Yt(e){ie(e,function(e){e.call(undefined)})}function Qt(e){const t=new XMLHttpRequest;const n={swapStyle:"innerHTML",swapDelay:0,settleDelay:0};const r={path:e,xhr:t,historyElt:_t(),swapSpec:n};t.open("GET",e,true);if(Q.config.historyRestoreAsHxRequest){t.setRequestHeader("HX-Request","true")}t.setRequestHeader("HX-History-Restore-Request","true");t.setRequestHeader("HX-Current-URL",location.href);t.onload=function(){if(this.status>=200&&this.status<400){r.response=this.response;ae(te().body,"htmx:historyCacheMissLoad",r);ze(r.historyElt,r.response,n,{contextElement:r.historyElt,historyRequest:true});$t(r.path);ae(te().body,"htmx:historyRestore",{path:e,cacheMiss:true,serverResponse:r.response})}else{fe(te().body,"htmx:historyCacheMissLoadError",r)}};if(ae(te().body,"htmx:historyCacheMiss",r)){t.send()}}function en(e){Gt();e=e||location.pathname+location.search;const t=Jt(e);if(t){const n={swapStyle:"innerHTML",swapDelay:0,settleDelay:0,scroll:t.scroll};const r={path:e,item:t,historyElt:_t(),swapSpec:n};if(ae(te().body,"htmx:historyCacheHit",r)){ze(r.historyElt,t.content,n,{contextElement:r.historyElt,title:t.title});$t(r.path);ae(te().body,"htmx:historyRestore",r)}}else{if(Q.config.refreshOnHistoryMiss){Q.location.reload(true)}else{Qt(e)}}}function tn(e){let t=we(e,"hx-indicator");if(t==null){t=[e]}ie(t,function(e){const t=oe(e);t.requestCount=(t.requestCount||0)+1;e.classList.add.call(e.classList,Q.config.requestClass)});return t}function nn(e){let t=we(e,"hx-disabled-elt");if(t==null){t=[]}ie(t,function(e){const t=oe(e);t.requestCount=(t.requestCount||0)+1;e.setAttribute("disabled","");e.setAttribute("data-disabled-by-htmx","")});return t}function rn(e,t){ie(e.concat(t),function(e){const t=oe(e);t.requestCount=(t.requestCount||1)-1});ie(e,function(e){const t=oe(e);if(t.requestCount===0){e.classList.remove.call(e.classList,Q.config.requestClass)}});ie(t,function(e){const t=oe(e);if(t.requestCount===0){e.removeAttribute("disabled");e.removeAttribute("data-disabled-by-htmx")}})}function on(t,n){for(let e=0;e<t.length;e++){const r=t[e];if(r.isSameNode(n)){return true}}return false}function sn(e){const t=e;if(t.name===""||t.name==null||t.disabled||g(t,"fieldset[disabled]")){return false}if(t.type==="button"||t.type==="submit"||t.tagName==="image"||t.tagName==="reset"||t.tagName==="file"){return false}if(t.type==="checkbox"||t.type==="radio"){return t.checked}return true}function ln(t,e,n){if(t!=null&&e!=null){if(Array.isArray(e)){e.forEach(function(e){n.append(t,e)})}else{n.append(t,e)}}}function cn(t,n,r){if(t!=null&&n!=null){let e=r.getAll(t);if(Array.isArray(n)){e=e.filter(e=>n.indexOf(e)<0)}else{e=e.filter(e=>e!==n)}r.delete(t);ie(e,e=>r.append(t,e))}}function un(e){if(e instanceof HTMLSelectElement&&e.multiple){return M(e.querySelectorAll("option:checked")).map(function(e){return e.value})}if(e instanceof HTMLInputElement&&e.files){return M(e.files)}return e.value}function fn(t,n,r,e,o){if(e==null||on(t,e)){return}else{t.push(e)}if(sn(e)){const i=ee(e,"name");ln(i,un(e),n);if(o){an(e,r)}}if(e instanceof HTMLFormElement){ie(e.elements,function(e){if(t.indexOf(e)>=0){cn(e.name,un(e),n)}else{t.push(e)}if(o){an(e,r)}});new FormData(e).forEach(function(e,t){if(e instanceof File&&e.name===""){return}ln(t,e,n)})}}function an(e,t){const n=e;if(n.willValidate){ae(n,"htmx:validation:validate");if(!n.checkValidity()){if(ae(n,"htmx:validation:failed",{message:n.validationMessage,validity:n.validity})&&!t.length&&Q.config.reportValidityOfForms){n.reportValidity()}t.push({elt:n,message:n.validationMessage,validity:n.validity})}}}function hn(n,e){for(const t of e.keys()){n.delete(t)}e.forEach(function(e,t){n.append(t,e)});return n}function dn(e,t){const n=[];const r=new FormData;const o=new FormData;const i=[];const s=oe(e);if(s.lastButtonClicked&&!se(s.lastButtonClicked)){s.lastButtonClicked=null}let l=e instanceof HTMLFormElement&&e.noValidate!==true||a(e,"hx-validate")==="true";if(s.lastButtonClicked){l=l&&s.lastButtonClicked.formNoValidate!==true}if(t!=="get"){fn(n,o,i,Lt(e),l)}fn(n,r,i,e,l);if(s.lastButtonClicked||e.tagName==="BUTTON"||e.tagName==="INPUT"&&ee(e,"type")==="submit"){const u=s.lastButtonClicked||e;const f=ee(u,"name");ln(f,u.value,o)}const c=we(e,"hx-include");ie(c,function(e){fn(n,r,i,ce(e),l);if(!h(e,"form")){ie(p(e).querySelectorAll(ot),function(e){fn(n,r,i,e,l)})}});hn(r,o);return{errors:i,formData:r,values:kn(r)}}function pn(e,t,n){if(e!==""){e+="&"}if(String(n)==="[object Object]"){n=JSON.stringify(n)}const r=encodeURIComponent(n);e+=encodeURIComponent(t)+"="+r;return e}function gn(e){e=Dn(e);let n="";e.forEach(function(e,t){n=pn(n,t,e)});return n}function mn(e,t,n){const r={"HX-Request":"true","HX-Trigger":ee(e,"id"),"HX-Trigger-Name":ee(e,"name"),"HX-Target":a(t,"id"),"HX-Current-URL":location.href};Cn(e,"hx-headers",false,r);if(n!==undefined){r["HX-Prompt"]=n}if(oe(e).boosted){r["HX-Boosted"]="true"}return r}function yn(n,e){const t=ne(e,"hx-params");if(t){if(t==="none"){return new FormData}else if(t==="*"){return n}else if(t.indexOf("not ")===0){ie(t.slice(4).split(","),function(e){e=e.trim();n.delete(e)});return n}else{const r=new FormData;ie(t.split(","),function(t){t=t.trim();if(n.has(t)){n.getAll(t).forEach(function(e){r.append(t,e)})}});return r}}else{return n}}function xn(e){return!!ee(e,"href")&&ee(e,"href").indexOf("#")>=0}function bn(e,t){const n=t||ne(e,"hx-swap");const r={swapStyle:oe(e).boosted?"innerHTML":Q.config.defaultSwapStyle,swapDelay:Q.config.defaultSwapDelay,settleDelay:Q.config.defaultSettleDelay};if(Q.config.scrollIntoViewOnBoost&&oe(e).boosted&&!xn(e)){r.show="top"}if(n){const s=B(n);if(s.length>0){for(let e=0;e<s.length;e++){const l=s[e];if(l.indexOf("swap:")===0){r.swapDelay=d(l.slice(5))}else if(l.indexOf("settle:")===0){r.settleDelay=d(l.slice(7))}else if(l.indexOf("transition:")===0){r.transition=l.slice(11)==="true"}else if(l.indexOf("ignoreTitle:")===0){r.ignoreTitle=l.slice(12)==="true"}else if(l.indexOf("scroll:")===0){const c=l.slice(7);var o=c.split(":");const u=o.pop();var i=o.length>0?o.join(":"):null;r.scroll=u;r.scrollTarget=i}else if(l.indexOf("show:")===0){const f=l.slice(5);var o=f.split(":");const a=o.pop();var i=o.length>0?o.join(":"):null;r.show=a;r.showTarget=i}else if(l.indexOf("focus-scroll:")===0){const h=l.slice("focus-scroll:".length);r.focusScroll=h=="true"}else if(e==0){r.swapStyle=l}else{H("Unknown modifier in hx-swap: "+l)}}}}return r}function vn(e){return ne(e,"hx-encoding")==="multipart/form-data"||h(e,"form")&&ee(e,"enctype")==="multipart/form-data"}function wn(t,n,r){let o=null;Vt(n,function(e){if(o==null){o=e.encodeParameters(t,r,n)}});if(o!=null){return o}else{if(vn(n)){return hn(new FormData,Dn(r))}else{return gn(r)}}}function Sn(e){return{tasks:[],elts:[e]}}function En(e,t){const n=e[0];const r=e[e.length-1];if(t.scroll){var o=null;if(t.scrollTarget){o=ce(ue(n,t.scrollTarget))}if(t.scroll==="top"&&(n||o)){o=o||n;o.scrollTop=0}if(t.scroll==="bottom"&&(r||o)){o=o||r;o.scrollTop=o.scrollHeight}if(typeof t.scroll==="number"){b().setTimeout(function(){window.scrollTo(0,t.scroll)},0)}}if(t.show){var o=null;if(t.showTarget){let e=t.showTarget;if(t.showTarget==="window"){e="body"}o=ce(ue(n,e))}if(t.show==="top"&&(n||o)){o=o||n;o.scrollIntoView({block:"start",behavior:Q.config.scrollBehavior})}if(t.show==="bottom"&&(r||o)){o=o||r;o.scrollIntoView({block:"end",behavior:Q.config.scrollBehavior})}}}function Cn(r,e,o,i,s){if(i==null){i={}}if(r==null){return i}const l=a(r,e);if(l){let e=l.trim();let t=o;if(e==="unset"){return null}if(e.indexOf("javascript:")===0){e=e.slice(11);t=true}else if(e.indexOf("js:")===0){e=e.slice(3);t=true}if(e.indexOf("{")!==0){e="{"+e+"}"}let n;if(t){n=On(r,function(){if(s){return Function("event","return ("+e+")").call(r,s)}else{return Function("return ("+e+")").call(r)}},{})}else{n=v(e)}for(const c in n){if(n.hasOwnProperty(c)){if(i[c]==null){i[c]=n[c]}}}}return Cn(ce(u(r)),e,o,i,s)}function On(e,t,n){if(Q.config.allowEval){return t()}else{fe(e,"htmx:evalDisallowedError");return n}}function Hn(e,t,n){return Cn(e,"hx-vars",true,n,t)}function Tn(e,t,n){return Cn(e,"hx-vals",false,n,t)}function Rn(e,t){return le(Hn(e,t),Tn(e,t))}function qn(t,n,r){if(r!==null){try{t.setRequestHeader(n,r)}catch(e){t.setRequestHeader(n,encodeURIComponent(r));t.setRequestHeader(n+"-URI-AutoEncoded","true")}}}function An(t){if(t.responseURL){try{const e=new URL(t.responseURL);return e.pathname+e.search}catch(e){fe(te().body,"htmx:badResponseUrl",{url:t.responseURL})}}}function T(e,t){return t.test(e.getAllResponseHeaders())}function Ln(t,n,r){t=t.toLowerCase();if(r){if(r instanceof Element||typeof r==="string"){return he(t,n,null,null,{targetOverride:w(r)||ve,returnPromise:true})}else{let e=w(r.target);if(r.target&&!e||r.source&&!e&&!w(r.source)){e=ve}return he(t,n,w(r.source),r.event,{handler:r.handler,headers:r.headers,values:r.values,targetOverride:e,swapOverride:r.swap,select:r.select,returnPromise:true,push:r.push,replace:r.replace,selectOOB:r.selectOOB})}}else{return he(t,n,null,null,{returnPromise:true})}}function Nn(e){const t=[];while(e){t.push(e);e=e.parentElement}return t}function In(e,t,n){const r=new URL(t,location.protocol!=="about:"?location.href:window.origin);const o=location.protocol!=="about:"?location.origin:window.origin;const i=o===r.origin;if(Q.config.selfRequestsOnly){if(!i){return false}}return ae(e,"htmx:validateUrl",le({url:r,sameHost:i},n))}function Dn(e){if(e instanceof FormData)return e;const t=new FormData;for(const n in e){if(e.hasOwnProperty(n)){if(e[n]&&typeof e[n].forEach==="function"){e[n].forEach(function(e){t.append(n,e)})}else if(typeof e[n]==="object"&&!(e[n]instanceof Blob)){t.append(n,JSON.stringify(e[n]))}else{t.append(n,e[n])}}}return t}function Pn(r,o,e){return new Proxy(e,{get:function(t,e){if(typeof e==="number")return t[e];if(e==="length")return t.length;if(e==="push"){return function(e){t.push(e);r.append(o,e)}}if(typeof t[e]==="function"){return function(){t[e].apply(t,arguments);r.delete(o);t.forEach(function(e){r.append(o,e)})}}if(t[e]&&t[e].length===1){return t[e][0]}else{return t[e]}},set:function(e,t,n){e[t]=n;r.delete(o);e.forEach(function(e){r.append(o,e)});return true}})}function kn(o){return new Proxy(o,{get:function(e,t){if(typeof t==="symbol"){const r=Reflect.get(e,t);if(typeof r==="function"){return function(){return r.apply(o,arguments)}}else{return r}}if(t==="toJSON"){return()=>Object.fromEntries(o)}if(t in e){if(typeof e[t]==="function"){return function(){return o[t].apply(o,arguments)}}}const n=o.getAll(t);if(n.length===0){return undefined}else if(n.length===1){return n[0]}else{return Pn(e,t,n)}},set:function(t,n,e){if(typeof n!=="string"){return false}t.delete(n);if(e&&typeof e.forEach==="function"){e.forEach(function(e){t.append(n,e)})}else if(typeof e==="object"&&!(e instanceof Blob)){t.append(n,JSON.stringify(e))}else{t.append(n,e)}return true},deleteProperty:function(e,t){if(typeof t==="string"){e.delete(t)}return true},ownKeys:function(e){return Reflect.ownKeys(Object.fromEntries(e))},getOwnPropertyDescriptor:function(e,t){return Reflect.getOwnPropertyDescriptor(Object.fromEntries(e),t)}})}function he(t,n,r,o,i,k){let s=null;let l=null;i=i!=null?i:{};if(i.returnPromise&&typeof Promise!=="undefined"){var e=new Promise(function(e,t){s=e;l=t})}if(r==null){r=te().body}const M=i.handler||Vn;const F=i.select||null;if(!se(r)){re(s);return e}const c=i.targetOverride||ce(Ee(r));if(c==null||c==ve){fe(r,"htmx:targetError",{target:ne(r,"hx-target")});re(l);return e}let u=oe(r);const f=u.lastButtonClicked;if(f){const A=ee(f,"formaction");if(A!=null){n=A}const L=ee(f,"formmethod");if(L!=null){if(de.includes(L.toLowerCase())){t=L}else{re(s);return e}}}const a=ne(r,"hx-confirm");if(k===undefined){const K=function(e){return he(t,n,r,o,i,!!e)};const G={target:c,elt:r,path:n,verb:t,triggeringEvent:o,etc:i,issueRequest:K,question:a};if(ae(r,"htmx:confirm",G)===false){re(s);return e}}let h=r;let d=ne(r,"hx-sync");let p=null;let B=false;if(d){const N=d.split(":");const I=N[0].trim();if(I==="this"){h=Se(r,"hx-sync")}else{h=ce(ue(r,I))}d=(N[1]||"drop").trim();u=oe(h);if(d==="drop"&&u.xhr&&u.abortable!==true){re(s);return e}else if(d==="abort"){if(u.xhr){re(s);return e}else{B=true}}else if(d==="replace"){ae(h,"htmx:abort")}else if(d.indexOf("queue")===0){const W=d.split(" ");p=(W[1]||"last").trim()}}if(u.xhr){if(u.abortable){ae(h,"htmx:abort")}else{if(p==null){if(o){const D=oe(o);if(D&&D.triggerSpec&&D.triggerSpec.queue){p=D.triggerSpec.queue}}if(p==null){p="last"}}if(u.queuedRequests==null){u.queuedRequests=[]}if(p==="first"&&u.queuedRequests.length===0){u.queuedRequests.push(function(){he(t,n,r,o,i)})}else if(p==="all"){u.queuedRequests.push(function(){he(t,n,r,o,i)})}else if(p==="last"){u.queuedRequests=[];u.queuedRequests.push(function(){he(t,n,r,o,i)})}re(s);return e}}const g=new XMLHttpRequest;u.xhr=g;u.abortable=B;const m=function(){u.xhr=null;u.abortable=false;if(u.queuedRequests!=null&&u.queuedRequests.length>0){const e=u.queuedRequests.shift();e()}};const X=ne(r,"hx-prompt");if(X){var y=prompt(X);if(y===null||!ae(r,"htmx:prompt",{prompt:y,target:c})){re(s);m();return e}}if(a&&!k){if(!confirm(a)){re(s);m();return e}}let x=mn(r,c,y);if(t!=="get"&&!vn(r)){x["Content-Type"]="application/x-www-form-urlencoded"}if(i.headers){x=le(x,i.headers)}const U=dn(r,t);let b=U.errors;const V=U.formData;if(i.values){hn(V,Dn(i.values))}const j=Dn(Rn(r,o));const v=hn(V,j);let w=yn(v,r);if(Q.config.getCacheBusterParam&&t==="get"){w.set("org.htmx.cache-buster",ee(c,"id")||"true")}if(n==null||n===""){n=location.href}const S=Cn(r,"hx-request");const $=oe(r).boosted;let E=Q.config.methodsThatUseUrlParams.indexOf(t)>=0;const C={boosted:$,useUrlParams:E,formData:w,parameters:kn(w),unfilteredFormData:v,unfilteredParameters:kn(v),headers:x,elt:r,target:c,verb:t,errors:b,withCredentials:i.credentials||S.credentials||Q.config.withCredentials,timeout:i.timeout||S.timeout||Q.config.timeout,path:n,triggeringEvent:o};if(!ae(r,"htmx:configRequest",C)){re(s);m();return e}n=C.path;t=C.verb;x=C.headers;w=Dn(C.parameters);b=C.errors;E=C.useUrlParams;if(b&&b.length>0){ae(r,"htmx:validation:halted",C);re(s);m();return e}const _=n.split("#");const z=_[0];const O=_[1];let H=n;if(E){H=z;const Z=!w.keys().next().done;if(Z){if(H.indexOf("?")<0){H+="?"}else{H+="&"}H+=gn(w);if(O){H+="#"+O}}}if(!In(r,H,C)){fe(r,"htmx:invalidPath",C);re(l);m();return e}g.open(t.toUpperCase(),H,true);g.overrideMimeType("text/html");g.withCredentials=C.withCredentials;g.timeout=C.timeout;if(S.noHeaders){}else{for(const P in x){if(x.hasOwnProperty(P)){const Y=x[P];qn(g,P,Y)}}}const T={xhr:g,target:c,requestConfig:C,etc:i,boosted:$,select:F,pathInfo:{requestPath:n,finalRequestPath:H,responsePath:null,anchor:O}};g.onload=function(){try{const t=Nn(r);T.pathInfo.responsePath=An(g);M(r,T);if(T.keepIndicators!==true){rn(R,q)}ae(r,"htmx:afterRequest",T);ae(r,"htmx:afterOnLoad",T);if(!se(r)){let e=null;while(t.length>0&&e==null){const n=t.shift();if(se(n)){e=n}}if(e){ae(e,"htmx:afterRequest",T);ae(e,"htmx:afterOnLoad",T)}}re(s)}catch(e){fe(r,"htmx:onLoadError",le({error:e},T));throw e}finally{m()}};g.onerror=function(){rn(R,q);fe(r,"htmx:afterRequest",T);fe(r,"htmx:sendError",T);re(l);m()};g.onabort=function(){rn(R,q);fe(r,"htmx:afterRequest",T);fe(r,"htmx:sendAbort",T);re(l);m()};g.ontimeout=function(){rn(R,q);fe(r,"htmx:afterRequest",T);fe(r,"htmx:timeout",T);re(l);m()};if(!ae(r,"htmx:beforeRequest",T)){re(s);m();return e}var R=tn(r);var q=nn(r);ie(["loadstart","loadend","progress","abort"],function(t){ie([g,g.upload],function(e){e.addEventListener(t,function(e){ae(r,"htmx:xhr:"+t,{lengthComputable:e.lengthComputable,loaded:e.loaded,total:e.total})})})});ae(r,"htmx:beforeSend",T);const J=E?null:wn(g,r,w);g.send(J);return e}function Mn(e,t){const n=t.xhr;let r=null;let o=null;if(T(n,/HX-Push:/i)){r=n.getResponseHeader("HX-Push");o="push"}else if(T(n,/HX-Push-Url:/i)){r=n.getResponseHeader("HX-Push-Url");o="push"}else if(T(n,/HX-Replace-Url:/i)){r=n.getResponseHeader("HX-Replace-Url");o="replace"}if(r){if(r==="false"){return{}}else{return{type:o,path:r}}}const i=t.pathInfo.finalRequestPath;const s=t.pathInfo.responsePath;const l=t.etc.push||ne(e,"hx-push-url");const c=t.etc.replace||ne(e,"hx-replace-url");const u=oe(e).boosted;let f=null;let a=null;if(l){f="push";a=l}else if(c){f="replace";a=c}else if(u){f="push";a=s||i}if(a){if(a==="false"){return{}}if(a==="true"){a=s||i}if(t.pathInfo.anchor&&a.indexOf("#")===-1){a=a+"#"+t.pathInfo.anchor}return{type:f,path:a}}else{return{}}}function Fn(e,t){var n=new RegExp(e.code);return n.test(t.toString(10))}function Bn(e){for(var t=0;t<Q.config.responseHandling.length;t++){var n=Q.config.responseHandling[t];if(Fn(n,e.status)){return n}}return{swap:false}}function Xn(e){if(e){const t=f("title");if(t){t.textContent=e}else{window.document.title=e}}}function Un(e,t){if(t==="this"){return e}const n=ce(ue(e,t));if(n==null){fe(e,"htmx:targetError",{target:t});throw new Error(`Invalid re-target ${t}`)}return n}function Vn(t,e){const n=e.xhr;let r=e.target;const o=e.etc;const i=e.select;if(!ae(t,"htmx:beforeOnLoad",e))return;if(T(n,/HX-Trigger:/i)){Je(n,"HX-Trigger",t)}if(T(n,/HX-Location:/i)){let e=n.getResponseHeader("HX-Location");var s={};if(e.indexOf("{")===0){s=v(e);e=s.path;delete s.path}s.push=s.push||"true";Ln("get",e,s);return}const l=T(n,/HX-Refresh:/i)&&n.getResponseHeader("HX-Refresh")==="true";if(T(n,/HX-Redirect:/i)){e.keepIndicators=true;Q.location.href=n.getResponseHeader("HX-Redirect");l&&Q.location.reload();return}if(l){e.keepIndicators=true;Q.location.reload();return}const c=Mn(t,e);const u=Bn(n);const f=u.swap;let a=!!u.error;let h=Q.config.ignoreTitle||u.ignoreTitle;let d=u.select;if(u.target){e.target=Un(t,u.target)}var p=o.swapOverride;if(p==null&&u.swapOverride){p=u.swapOverride}if(T(n,/HX-Retarget:/i)){e.target=Un(t,n.getResponseHeader("HX-Retarget"))}if(T(n,/HX-Reswap:/i)){p=n.getResponseHeader("HX-Reswap")}var g=n.response;var m=le({shouldSwap:f,serverResponse:g,isError:a,ignoreTitle:h,selectOverride:d,swapOverride:p},e);if(u.event&&!ae(r,u.event,m))return;if(!ae(r,"htmx:beforeSwap",m))return;r=m.target;g=m.serverResponse;a=m.isError;h=m.ignoreTitle;d=m.selectOverride;p=m.swapOverride;e.target=r;e.failed=a;e.successful=!a;if(m.shouldSwap){if(n.status===286){lt(t)}Vt(t,function(e){g=e.transformResponse(g,n,t)});if(c.type){Gt()}var y=bn(t,p);if(!y.hasOwnProperty("ignoreTitle")){y.ignoreTitle=h}r.classList.add(Q.config.swappingClass);if(i){d=i}if(T(n,/HX-Reselect:/i)){d=n.getResponseHeader("HX-Reselect")}const x=o.selectOOB||ne(t,"hx-select-oob");const b=ne(t,"hx-select");ze(r,g,y,{select:d==="unset"?null:d||b,selectOOB:x,eventInfo:e,anchor:e.pathInfo.anchor,contextElement:t,afterSwapCallback:function(){if(T(n,/HX-Trigger-After-Swap:/i)){let e=t;if(!se(t)){e=te().body}Je(n,"HX-Trigger-After-Swap",e)}},afterSettleCallback:function(){if(T(n,/HX-Trigger-After-Settle:/i)){let e=t;if(!se(t)){e=te().body}Je(n,"HX-Trigger-After-Settle",e)}},beforeSwapCallback:function(){if(c.type){ae(te().body,"htmx:beforeHistoryUpdate",le({history:c},e));if(c.type==="push"){Wt(c.path);ae(te().body,"htmx:pushedIntoHistory",{path:c.path})}else{Zt(c.path);ae(te().body,"htmx:replacedInHistory",{path:c.path})}}}})}if(a){fe(t,"htmx:responseError",le({error:"Response Status Error Code "+n.status+" from "+e.pathInfo.requestPath},e))}}const jn={};function $n(){return{init:function(e){return null},getSelectors:function(){return null},onEvent:function(e,t){return true},transformResponse:function(e,t,n){return e},isInlineSwap:function(e){return false},handleSwap:function(e,t,n,r){return false},encodeParameters:function(e,t,n){return null}}}function _n(e,t){if(t.init){t.init(n)}jn[e]=le($n(),t)}function zn(e){delete jn[e]}function Jn(e,n,r){if(n==undefined){n=[]}if(e==undefined){return n}if(r==undefined){r=[]}const t=a(e,"hx-ext");if(t){ie(t.split(","),function(e){e=e.replace(/ /g,"");if(e.slice(0,7)=="ignore:"){r.push(e.slice(7));return}if(r.indexOf(e)<0){const t=jn[e];if(t&&n.indexOf(t)<0){n.push(t)}}})}return Jn(ce(u(e)),n,r)}var Kn=false;te().addEventListener("DOMContentLoaded",function(){Kn=true});function Gn(e){if(Kn||te().readyState==="complete"){e()}else{te().addEventListener("DOMContentLoaded",e)}}function Wn(){if(Q.config.includeIndicatorStyles!==false){const e=Q.config.inlineStyleNonce?` nonce="${Q.config.inlineStyleNonce}"`:"";const t=Q.config.indicatorClass;const n=Q.config.requestClass;te().head.insertAdjacentHTML("beforeend",`<style${e}>`+`.${t}{opacity:0;visibility: hidden} `+`.${n} .${t}, .${n}.${t}{opacity:1;visibility: visible;transition: opacity 200ms ease-in}`+"</style>")}}function Zn(){const e=te().querySelector('meta[name="htmx-config"]');if(e){return v(e.content)}else{return null}}function Yn(){const e=Zn();if(e){Q.config=le(Q.config,e)}}Gn(function(){Yn();Wn();let e=te().body;Ft(e);const t=te().querySelectorAll("[hx-trigger='restored'],[data-hx-trigger='restored']");e.addEventListener("htmx:abort",function(e){const t=e.detail.elt||e.target;const n=oe(t);if(n&&n.xhr){n.xhr.abort()}});const n=window.onpopstate?window.onpopstate.bind(window):null;window.onpopstate=function(e){if(e.state&&e.state.htmx){en();ie(t,function(e){ae(e,"htmx:restored",{document:te(),triggerEvent:ae})})}else{if(n){n(e)}}};b().setTimeout(function(){ae(e,"htmx:load",{});e=null},0)});return Q}(); 2 -
-287
web/static/js/manage-page.js
··· 1 - /** 2 - * Alpine.js component for the manage page 3 - * Handles CRUD operations for beans, roasters, grinders, and brewers 4 - */ 5 - function managePage() { 6 - return { 7 - tab: localStorage.getItem("manageTab") || "beans", 8 - activeTab: localStorage.getItem("profileTab") || "brews", 9 - showBeanForm: false, 10 - showRoasterForm: false, 11 - showGrinderForm: false, 12 - showBrewerForm: false, 13 - editingBean: null, 14 - editingRoaster: null, 15 - editingGrinder: null, 16 - editingBrewer: null, 17 - beanForm: { 18 - name: "", 19 - origin: "", 20 - roast_level: "", 21 - process: "", 22 - description: "", 23 - roaster_rkey: "", 24 - }, 25 - roasterForm: { name: "", location: "", website: "" }, 26 - grinderForm: { name: "", grinder_type: "", burr_type: "", notes: "" }, 27 - brewerForm: { name: "", brewer_type: "", description: "" }, 28 - 29 - init() { 30 - this.$watch("tab", (value) => { 31 - localStorage.setItem("manageTab", value); 32 - }); 33 - 34 - this.$watch("activeTab", (value) => { 35 - localStorage.setItem("profileTab", value); 36 - }); 37 - 38 - // Initialize cache in background 39 - if (window.ArabicaCache) { 40 - window.ArabicaCache.init(); 41 - } 42 - }, 43 - 44 - editBean( 45 - rkey, 46 - name, 47 - origin, 48 - roast_level, 49 - process, 50 - description, 51 - roaster_rkey, 52 - ) { 53 - this.editingBean = rkey; 54 - this.beanForm = { 55 - name, 56 - origin, 57 - roast_level, 58 - process, 59 - description, 60 - roaster_rkey: roaster_rkey || "", 61 - }; 62 - this.showBeanForm = true; 63 - }, 64 - 65 - async saveBean() { 66 - if (!this.beanForm.name || !this.beanForm.origin) { 67 - alert("Name and Origin are required"); 68 - return; 69 - } 70 - 71 - const url = this.editingBean 72 - ? `/api/beans/${this.editingBean}` 73 - : "/api/beans"; 74 - const method = this.editingBean ? "PUT" : "POST"; 75 - 76 - const response = await fetch(url, { 77 - method, 78 - headers: { 79 - "Content-Type": "application/json", 80 - }, 81 - body: JSON.stringify(this.beanForm), 82 - }); 83 - 84 - if (response.ok) { 85 - // Invalidate cache and reload 86 - if (window.ArabicaCache) { 87 - window.ArabicaCache.invalidateCache(); 88 - } 89 - window.location.reload(); 90 - } else { 91 - const errorText = await response.text(); 92 - alert("Failed to save bean: " + errorText); 93 - } 94 - }, 95 - 96 - async deleteBean(rkey) { 97 - if (!confirm("Are you sure you want to delete this bean?")) return; 98 - 99 - const response = await fetch(`/api/beans/${rkey}`, { 100 - method: "DELETE", 101 - }); 102 - if (response.ok) { 103 - // Invalidate cache and reload 104 - if (window.ArabicaCache) { 105 - window.ArabicaCache.invalidateCache(); 106 - } 107 - window.location.reload(); 108 - } else { 109 - const errorText = await response.text(); 110 - alert("Failed to delete bean: " + errorText); 111 - } 112 - }, 113 - 114 - editRoaster(rkey, name, location, website) { 115 - this.editingRoaster = rkey; 116 - this.roasterForm = { name, location, website }; 117 - this.showRoasterForm = true; 118 - }, 119 - 120 - async saveRoaster() { 121 - if (!this.roasterForm.name) { 122 - alert("Name is required"); 123 - return; 124 - } 125 - 126 - const url = this.editingRoaster 127 - ? `/api/roasters/${this.editingRoaster}` 128 - : "/api/roasters"; 129 - const method = this.editingRoaster ? "PUT" : "POST"; 130 - 131 - const response = await fetch(url, { 132 - method, 133 - headers: { 134 - "Content-Type": "application/json", 135 - }, 136 - body: JSON.stringify(this.roasterForm), 137 - }); 138 - 139 - if (response.ok) { 140 - // Invalidate cache and reload 141 - if (window.ArabicaCache) { 142 - window.ArabicaCache.invalidateCache(); 143 - } 144 - window.location.reload(); 145 - } else { 146 - const errorText = await response.text(); 147 - alert("Failed to save roaster: " + errorText); 148 - } 149 - }, 150 - 151 - async deleteRoaster(rkey) { 152 - if (!confirm("Are you sure you want to delete this roaster?")) return; 153 - 154 - const response = await fetch(`/api/roasters/${rkey}`, { 155 - method: "DELETE", 156 - }); 157 - if (response.ok) { 158 - // Invalidate cache and reload 159 - if (window.ArabicaCache) { 160 - window.ArabicaCache.invalidateCache(); 161 - } 162 - window.location.reload(); 163 - } else { 164 - const errorText = await response.text(); 165 - alert("Failed to delete roaster: " + errorText); 166 - } 167 - }, 168 - 169 - editGrinder(rkey, name, grinder_type, burr_type, notes) { 170 - this.editingGrinder = rkey; 171 - this.grinderForm = { name, grinder_type, burr_type, notes }; 172 - this.showGrinderForm = true; 173 - }, 174 - 175 - async saveGrinder() { 176 - if (!this.grinderForm.name || !this.grinderForm.grinder_type) { 177 - alert("Name and Grinder Type are required"); 178 - return; 179 - } 180 - 181 - const url = this.editingGrinder 182 - ? `/api/grinders/${this.editingGrinder}` 183 - : "/api/grinders"; 184 - const method = this.editingGrinder ? "PUT" : "POST"; 185 - 186 - const response = await fetch(url, { 187 - method, 188 - headers: { 189 - "Content-Type": "application/json", 190 - }, 191 - body: JSON.stringify(this.grinderForm), 192 - }); 193 - 194 - if (response.ok) { 195 - // Invalidate cache and reload 196 - if (window.ArabicaCache) { 197 - window.ArabicaCache.invalidateCache(); 198 - } 199 - window.location.reload(); 200 - } else { 201 - const errorText = await response.text(); 202 - alert("Failed to save grinder: " + errorText); 203 - } 204 - }, 205 - 206 - async deleteGrinder(rkey) { 207 - if (!confirm("Are you sure you want to delete this grinder?")) return; 208 - 209 - const response = await fetch(`/api/grinders/${rkey}`, { 210 - method: "DELETE", 211 - }); 212 - if (response.ok) { 213 - // Invalidate cache and reload 214 - if (window.ArabicaCache) { 215 - window.ArabicaCache.invalidateCache(); 216 - } 217 - window.location.reload(); 218 - } else { 219 - const errorText = await response.text(); 220 - alert("Failed to delete grinder: " + errorText); 221 - } 222 - }, 223 - 224 - editBrewer(rkey, name, brewer_type, description) { 225 - this.editingBrewer = rkey; 226 - this.brewerForm = { name, brewer_type, description }; 227 - this.showBrewerForm = true; 228 - }, 229 - 230 - editBrewerFromRow(row) { 231 - const rkey = row.dataset.rkey; 232 - const name = row.dataset.name; 233 - const brewer_type = row.dataset.brewerType || ""; 234 - const description = row.dataset.description || ""; 235 - this.editBrewer(rkey, name, brewer_type, description); 236 - }, 237 - 238 - async saveBrewer() { 239 - if (!this.brewerForm.name) { 240 - alert("Name is required"); 241 - return; 242 - } 243 - 244 - const url = this.editingBrewer 245 - ? `/api/brewers/${this.editingBrewer}` 246 - : "/api/brewers"; 247 - const method = this.editingBrewer ? "PUT" : "POST"; 248 - 249 - const response = await fetch(url, { 250 - method, 251 - headers: { 252 - "Content-Type": "application/json", 253 - }, 254 - body: JSON.stringify(this.brewerForm), 255 - }); 256 - 257 - if (response.ok) { 258 - // Invalidate cache and reload 259 - if (window.ArabicaCache) { 260 - window.ArabicaCache.invalidateCache(); 261 - } 262 - window.location.reload(); 263 - } else { 264 - const errorText = await response.text(); 265 - alert("Failed to save brewer: " + errorText); 266 - } 267 - }, 268 - 269 - async deleteBrewer(rkey) { 270 - if (!confirm("Are you sure you want to delete this brewer?")) return; 271 - 272 - const response = await fetch(`/api/brewers/${rkey}`, { 273 - method: "DELETE", 274 - }); 275 - if (response.ok) { 276 - // Invalidate cache and reload 277 - if (window.ArabicaCache) { 278 - window.ArabicaCache.invalidateCache(); 279 - } 280 - window.location.reload(); 281 - } else { 282 - const errorText = await response.text(); 283 - alert("Failed to delete brewer: " + errorText); 284 - } 285 - }, 286 - }; 287 - }
-36
web/static/js/profile-stats.js
··· 1 - /** 2 - * Profile stats updater 3 - * Listens for HTMX content swap and updates stats from data attributes 4 - */ 5 - 6 - document.addEventListener("DOMContentLoaded", function () { 7 - // Listen for HTMX afterSwap event on the profile content 8 - document.body.addEventListener("htmx:afterSwap", function (evt) { 9 - // Only handle swaps in the profile-content element 10 - if (evt.detail.target.id === "profile-content") { 11 - updateProfileStats(); 12 - } 13 - }); 14 - }); 15 - 16 - function updateProfileStats() { 17 - // Get stats data from the hidden div 18 - const statsData = document.getElementById("profile-stats-data"); 19 - if (!statsData) return; 20 - 21 - const stats = [ 22 - { selector: '[data-stat="brews"]', key: "brews" }, 23 - { selector: '[data-stat="beans"]', key: "beans" }, 24 - { selector: '[data-stat="roasters"]', key: "roasters" }, 25 - { selector: '[data-stat="grinders"]', key: "grinders" }, 26 - { selector: '[data-stat="brewers"]', key: "brewers" }, 27 - ]; 28 - 29 - stats.forEach(function (stat) { 30 - const value = statsData.dataset[stat.key]; 31 - const el = document.querySelector(stat.selector); 32 - if (el && value !== undefined) { 33 - el.textContent = value; 34 - } 35 - }); 36 - }

History

1 round 0 comments
sign up or login to add to the discussion
pdewey.com submitted #0
1 commit
expand
fix: page fixes
expand 0 comments
closed without merging