1/*! For license information please see 938.c4d57302.chunk.js.LICENSE.txt */ 2"use strict";(globalThis.webpackChunktrafficalerts=globalThis.webpackChunktrafficalerts||[]).push([[938],{1598(e,t,r){r.d(t,{Q:()=>o});var a=r(6931),n=r(7981);const s=[{id:"traffic-lights-out",name:"Traffic Lights Out",description:"Traffic lights not working / flashing (treat as a 4-way stop)",icon:"traffic-lights"}];function o(){var e;const t=null===(e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).enabled)||void 0===e||e;return(0,a.I)({queryKey:["alert_categories"],queryFn:async()=>{const{data:e,error:t}=await n.N.from("alert_categories").select("id,name,description,icon").order("name",{ascending:!0});if(t)throw t;const r=(null!==e&&void 0!==e?e:[]).map(e=>{const t="Other / Hazard"===(null===e||void 0===e?void 0:e.name)?"Other Hazard":null===e||void 0===e?void 0:e.name;return{...e,name:t}}),a=new Map(r.map(e=>[String(e.id).toLowerCase(),e]));for(const n of s){const e=String(n.id).toLowerCase();a.has(e)||a.set(e,{...n})}return Array.from(a.values()).sort((e,t)=>String(e.name).localeCompare(String(t.name),void 0,{sensitivity:"base"}))},enabled:t,staleTime:3e5})}},3074(e,t,r){r.r(t),r.d(t,{default:()=>N});var a=r(5043),n=r(3216),s=r(4655),o=r(6255),i=r(1487),l=r(7517),c=r(2054),d=r(9233),u=r(8006),g=r(9292),m=r(3677),p=r(871),h=r(8387),x=r(8910),f=r(8018),y=r(1598),v=r(4301),b=r(579);const w=["Eastern Cape","Free State","Gauteng","KwaZulu-Natal","Limpopo","Mpumalanga","Northern Cape","North West","Western Cape"];function N(){var e,t,r,N;const j=(0,n.Zp)(),k=(0,n.zy)(),{user:A,isAuthenticated:C}=(0,s.J)(),S=null!==(e=null===(t=k.state)||void 0===t?void 0:t.fromOnboarding)&&void 0!==e&&e,P=null!==(r=null===(N=k.state)||void 0===N?void 0:N.fromPhoneSignup)&&void 0!==r&&r,{data:_}=(0,o.HW)(),z=(0,o.OK)(),L=(0,o.RN)(),{pushToast:T}=(0,i.d)(),{data:D=[]}=(0,y.Q)(),{permission:F,osEnabled:E}=(0,l.VF)(),[H,M]=(0,a.useState)([]),[O,Y]=(0,a.useState)([]),[q,K]=(0,a.useState)(""),[R,W]=(0,a.useState)([]),[I,Q]=(0,a.useState)(!0),[V,Z]=(0,a.useState)("car_horn"),[$,B]=(0,a.useState)(!1),G=(0,a.useRef)(!1);(0,a.useEffect)(()=>{if(C){if(_&&!G.current){var e;G.current=!0,M(_.areas||[]);const t=(_.alert_types||[]).map(e=>{var t;return null!==(t=v.Ip[e])&&void 0!==t?t:e});Y(t),W(_.keywords||[]),K(""),Q(null===(e=_.play_sound_on_notification)||void 0===e||e),Z(_.sound_type||"car_horn")}}else j("/login",{state:{from:{pathname:"/preferences"}}})},[_,C,j]);const J=e=>{if(e.includes(",")){const t=e.split(","),r=t.slice(0,-1).join(","),a=t[t.length-1];if(r.trim()){const e=(0,x.uy)(r);e.length&&W(t=>(0,x.Nh)(t,e))}return void K(a.trimStart())}K(e)},U=H.length>0&&(O.length>0||R.length>0||""!==q.trim());return C?(0,b.jsx)(p.A,{showCreateButton:!1,children:(0,b.jsx)("div",{className:"mx-auto max-w-3xl space-y-6",children:(0,b.jsxs)("div",{className:"bg-white rounded-lg border border-gray-200 shadow p-6",children:[(0,b.jsxs)("div",{className:"flex items-center gap-3 mb-6",children:[(0,b.jsx)(c.A,{className:"text-orange-500",size:28}),(0,b.jsxs)("div",{children:[(0,b.jsx)("h1",{className:"text-2xl font-semibold text-gray-900",children:S||P?"Almost there \u2014 set your preferences":"Welcome! Set Your Preferences"}),(0,b.jsx)("p",{className:"text-sm text-gray-600 mt-1",children:S||P?"Choose your routes, incident types, and notification settings so you get the most relevant traffic alerts.":"Customize your experience to see the alerts that matter most to you."})]})]}),(0,b.jsxs)("form",{onSubmit:async e=>{if(e.preventDefault(),null!==A&&void 0!==A&&A.id)if(U){B(!0);try{let e=R;q.trim()&&(e=(0,x.Nh)(R,(0,x.uy)(q)),W(e),K("")),await z.mutateAsync({areas:H,alert_types:O,keywords:e,play_sound_on_notification:I,sound_type:V}),T({title:"Preferences saved",description:"Your preferences have been saved successfully.",variant:"success"});"granted"===F&&E||sessionStorage.setItem("showPushNotificationPrompt","true"),j("/")}catch(t){f.v.error("Failed to save preferences",t),T({title:"Failed to save",description:"Could not save your preferences. Please try again.",variant:"error"})}finally{B(!1)}}else T({title:"Selection required",description:"Please select at least one province and one alert type or keyword to save.",variant:"info"})},className:"space-y-8",children:[(0,b.jsxs)("div",{children:[(0,b.jsxs)("label",{className:"flex items-center gap-2 text-lg font-medium text-gray-900 mb-4",children:[(0,b.jsx)(u.A,{size:20,className:"text-orange-500"}
2),"Select Areas You Follow"]}),(0,b.jsx)("p",{className:"text-sm text-gray-600 mb-4",children:"Choose provinces or regions where you want to receive traffic alerts."}),(0,b.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:w.map(e=>(0,b.jsx)("button",{type:"button",onClick:()=>{return t=e,void M(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t]);var t},className:(0,h.A)("px-4 py-2 rounded-lg border text-sm font-medium transition",H.includes(e)?"bg-orange-50 border-orange-500 text-orange-700":"bg-white border-gray-300 text-gray-700 hover:border-orange-300 hover:bg-orange-50"),children:e},e))})]}),(0,b.jsxs)("div",{children:[(0,b.jsxs)("label",{className:"flex items-center gap-2 text-lg font-medium text-gray-900 mb-4",children:[(0,b.jsx)(d.A,{size:20,className:"text-orange-500"}),"Select Alert Types You Follow"]}),(0,b.jsx)("p",{className:"text-sm text-gray-600 mb-4",children:"Choose the types of alerts you want to see in your timeline."}),(0,b.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:D.map(e=>(0,b.jsx)("button",{type:"button",onClick:()=>{return t=e.id,void Y(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t]);var t},className:(0,h.A)("px-4 py-2 rounded-lg border text-sm font-medium transition",O.includes(e.id)?"bg-orange-50 border-orange-500 text-orange-700":"bg-white border-gray-300 text-gray-700 hover:border-orange-300 hover:bg-orange-50"),children:e.name},e.id))})]}),(0,b.jsxs)("div",{children:[(0,b.jsxs)("label",{className:"flex items-center gap-2 text-lg font-medium text-gray-900 mb-4",children:[(0,b.jsx)(g.A,{size:20,className:"text-orange-500"}),"Keyword Filters (Optional)"]}),(0,b.jsx)("p",{className:"text-sm text-gray-600 mb-4",children:'Enter keywords to prioritize alerts, e.g., "N3", "Van Reenen", "Town Hill", "Hazmat". Separate multiple keywords with commas.'}),(0,b.jsx)("div",{className:"flex flex-wrap gap-2 mb-3 min-h-[32px]",children:0===R.length?(0,b.jsx)("span",{className:"text-sm text-gray-500",children:"No keywords added yet."}):R.map(e=>(0,b.jsxs)("button",{type:"button",onClick:()=>(e=>{W(t=>(0,x.YR)(t,e))})(e),className:"inline-flex items-center gap-2 rounded-full border border-orange-200 bg-orange-50 px-3 py-1 text-xs font-semibold text-orange-700 transition hover:border-orange-300",children:[e,(0,b.jsx)("span",{"aria-hidden":"true",children:"\xd7"})]},e))}),(0,b.jsx)("input",{type:"text",value:q,onChange:e=>J(e.target.value),onPaste:e=>{const t=e.clipboardData.getData("text");if(!t)return;e.preventDefault();const r=t.replace(/[\r\n]+/g,", ");J(q?`${q}${r}`:r)},onKeyDown:e=>{"Enter"!==e.key&&","!==e.key||(e.preventDefault(),(()=>{const e=(0,x.uy)(q);0!==e.length?(W(t=>(0,x.Nh)(t,e)),K("")):K(e=>e.trim())})())},placeholder:"Type a keyword and press Enter or comma",className:"ta-text-input w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-orange-500 focus:border-orange-500 outline-none"})]}),(0,b.jsxs)("div",{children:[(0,b.jsxs)("label",{className:"flex items-center gap-2 text-lg font-medium text-gray-900 mb-4",children:[(0,b.jsx)(m.A,{size:20,className:"text-orange-500"}),"Notification Sound Settings"]}),(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsxs)("label",{className:"flex items-center gap-3 cursor-pointer",children:[(0,b.jsx)("input",{type:"checkbox",checked:I,onChange:e=>Q(e.target.checked),className:"w-5 h-5 text-orange-600 focus:ring-orange-500 rounded"}),(0,b.jsx)("span",{className:"text-sm text-gray-700",children:"Play sound on new notifications"})]}),I&&(0,b.jsxs)("div",{children:[(0,b.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Sound Type"}),(0,b.jsxs)("select",{value:V,onChange:e=>Z(e.target.value),className:"w-full md:w-64 px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-orange-500 focus:border-orange-500 outline-none",children:[(0,b.jsx)("option",{value:"car_horn",children:"Car Horn"}),(0,b.jsx)("option",{value:"none",children:"None"})]})]})]})]}),(0,b.jsxs)("div",{className:"flex gap-4 pt-4 border-t border-gray-200",children:[(0,b.jsx)("button",{type:"button",onClick:()=>{(async()=>
2{if(null!==A&&void 0!==A&&A.id&&!L.isPending)try{await L.mutateAsync(),j("/",{replace:!0})}catch(e){f.v.error("Failed to skip preferences setup",e),T({title:"Could not continue",description:"We could not save your choice. Please try again.",variant:"error"})}})()},className:"flex-1 px-6 py-3 text-sm font-medium text-gray-700 bg-gray-100 rounded-lg hover:bg-gray-200 transition disabled:opacity-50 disabled:cursor-not-allowed",disabled:$||L.isPending,children:L.isPending?"Continuing\u2026":"Skip for Now"}),(0,b.jsx)("button",{type:"submit",className:(0,h.A)("flex-1 px-6 py-3 text-sm font-medium text-white rounded-lg transition disabled:opacity-50 disabled:cursor-not-allowed",U?"bg-orange-600 hover:bg-orange-700":"bg-orange-400 opacity-60 cursor-not-allowed"),disabled:$,children:$?"Saving...":"Save Preferences"})]})]})]})})}):null}},8910(e,t,r){function a(e){return e.split(",").map(e=>e.trim()).filter(e=>e.length>0)}function n(e,t){const r=[...e],a=new Set(e.map(e=>e.toLowerCase()));return t.forEach(e=>{const t=e.toLowerCase();a.has(t)||(a.add(t),r.push(e))}),r}function s(e,t){const r=t.toLowerCase();return e.filter(e=>e.toLowerCase()!==r)}r.d(t,{Nh:()=>n,YR:()=>s,uy:()=>a})},2054(e,t,r){r.d(t,{A:()=>a});const a=(0,r(7784).A)("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]])},9292(e,t,r){r.d(t,{A:()=>a});const a=(0,r(7784).A)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]])},3677(e,t,r){r.d(t,{A:()=>a});const a=(0,r(7784).A)("volume-2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]])},1562(e,t,r){r.d(t,{A:()=>n});var a=r(2440);function n(e){return(0,a.w)(e,Date.now())}},6465(e,t,r){r.d(t,{r:()=>s});var a=r(1844),n=r(1176);function s(e,t,r){const[s,o]=(0,a.x)(r?.in,e,t);return+(0,n.o)(s)===+(0,n.o)(o)}},8344(e,t,r){r.d(t,{c:()=>o});var a=r(2440),n=r(1562),s=r(6465);function o(e,t){return(0,s.r)((0,a.w)(t?.in||e,e),(0,n.A)(t?.in||e))}},9172(e,t,r){r.d(t,{P:()=>c});var a=r(2440),n=r(1562),s=r(6465),o=r(2316);function i(e,t,r){const n=(0,o.a)(e,r?.in);return isNaN(t)?(0,a.w)(r?.in||e,NaN):t?(n.setDate(n.getDate()+t),n):n}function l(e,t,r){return i(e,-t,r)}function c(e,t){return(0,s.r)((0,a.w)(t?.in||e,e),l((0,n.A)(t?.in||e),1))}}}]); 3//# sourceMappingURL=938.c4d57302.chunk.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.