PageSourceSearch

https://sarploy.org/assets/supabase-runtime-B7iRmc1j.js

js sarploy.org collected 2026-10-10 02:42:45 UTC 22,540 bytes, 1 lines download raw bytes

1var be=Object.defineProperty;var we=(e,t,n)=>t in e?be(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var T=(e,t,n)=>we(e,typeof t!="symbol"?t+"":t,n);import{r as Q}from"./framework-BIHo1AUa.js";import{c as Ie}from"./supabase-ChnqCKxs.js";const ee=20,te=1e4,ne=3e4;function ve(e=()=>Date.now()){const t=new Map;return function(i,s,r){const a=e(),c=`${i} ${s.replace(/^https?:\/\/[^/]+/,"").split("?")[0]}`,l=`${i} ${s} ${typeof r=="string"?r:""}`,E=(t.get(l)??[]).filter(o=>a-o<ne);E.push(a),t.set(l,E),t.size>300&&t.clear();const m=E.filter(o=>a-o<te).length;return{refused:m>ee||E.length>ee*(ne/te),count:m,label:c}}}function Ae(e){const t=`Stopped a repeating request: ${e.label} was sent ${e.count} times in 10 seconds.`;return console.error("[SARploy request loop]",t),new Response(JSON.stringify({code:"SARPLOY_LOOP",message:t}),{status:429})}const Re=["searchnet.","searchnet:","searchnet-","sarploy:","sarploy.gridOutline.","sarploy.linedGrids."],ye=new Set(["sarploy:password-recovery","sarploy:second-half","sarploy:two-screens","sarploy:directions-app","sarploy:free-map-saved","sarploy:install-for-alerts-dismissed","sarploy:notification-setup-dismissed","sarploy:organization-request-received","sarploy:tour-offered","sarploy:outbox:v1","sarploy:outbox:v1:warning"]),Te=["searchnet-","searchnet_"],Le="searchnet-operational-map-",ke=["searchnet-offline-sync-v1"],F="sarploy:outbox:v1",Ce="sarploy:outbox:v1:warning",Pe="sarploy:field-outbox-cleared";async function At(e){if(!(typeof window>"u")){if(e)try{const t=JSON.parse(window.localStorage.getItem(F)??"[]");if(!Array.isArray(t)||t.every(n=>n.userId===e))return}catch{}try{window.localStorage.removeItem(F),window.localStorage.removeItem(Ce)}catch{}window.dispatchEvent(new Event(Pe)),await fe("sarploy-outbox")}}function Rt(e){if(!e||typeof window>"u")return 0;try{const t=JSON.parse(window.localStorage.getItem(F)??"[]");return Array.isArray(t)?t.filter(n=>n.userId===e&&n.kind!=="trail").length:0}catch{return 0}}const Oe="sarploy:sensitive-state-reset",Ne="sarploy:fielddraft:v1:";function Be(e){return!ye.has(e)&&!e.startsWith(Ne)&&Re.some(t=>e.startsWith(t))}function se(e){if(e)for(let t=e.length-1;t>=0;t-=1){const n=e.key(t);n&&Be(n)&&e.removeItem(n)}}function fe(e){return typeof indexedDB>"u"?Promise.resolve():new Promise(t=>{const n=indexedDB.deleteDatabase(e);n.onsuccess=()=>t(),n.onerror=()=>t(),n.onblocked=()=>t()})}async function De(){if(typeof window>"u"||!("caches"in window))return;const e=await window.caches.keys();await Promise.all(e.filter(t=>!t.startsWith(Le)&&Te.some(n=>t.startsWith(n))).map(t=>window.caches.delete(t)))}const Ue="sarploy:clear-sensitive-state";let U=0;function yt(){return U}class $e extends Error{constructor(t){super(`${t} stopped: the person who started it signed out.`),this.name="SessionEndedError"}}function Tt(e,t){if(e!==U)throw new $e(t)}function Lt(){U+=1,ge=!0}let ge=!1;function Me(){return ge}async function kt(){var e,t;if(!(typeof window>"u")){U+=1,window.dispatchEvent(new Event(Ue));try{se(window.localStorage)}catch{}try{se(window.sessionStorage)}catch{}(t=(e=navigator.serviceWorker)==null?void 0:e.controller)==null||t.postMessage({type:"SEARCHNET_CLEAR_SENSITIVE_STATE"}),await Promise.all([De().catch(()=>{}),...ke.map(n=>fe(n))]),window.dispatchEvent(new Event(Oe))}}const ze={NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY:"sb_publishable_5yS1TDgrcVTGxf5i8aVRhQ_oSeSz44p",NEXT_PUBLIC_SUPABASE_URL:"https://vlbihdxxyourxpqwkgts.supabase.co"};let I=null;function Ct(e){I=e}function Pt(){return I}function Ot(){return I?{"x-sarploy-organization":I}:{}}let ie=!1;function qe(){if(!(ie||typeof window>"u")){ie=!0,console.warn("[SARploy] the organization was changed elsewhere; reloading to it");try{window.location.replace(`${window.location.origin}/`)}catch{}}}let L=null;const Fe=ve();let M=null;function xe(e){var i,s,r;const t=((i=e.NEXT_PUBLIC_SUPABASE_URL)==null?void 0:i.trim())||null,n=((s=e.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY)==null?void 0:s.trim())||((r=e.NEXT_PUBLIC_SUPABASE_ANON_KEY)==null?void 0:r.trim())||null;if(!t&&!n)return{isConfigured:!1,issue:null,message:null,url:t,key:n};if(!t)return{isConfigured:!1,issue:"missing_url",message:"NEXT_PUBLIC_SUPABASE_URL is not set.",url:t,key:n};if(!n)return{isConfigured:!1,issue:"missing_key",message:"NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY is not set.",url:t,key:n};try{const a=new URL(t);if(a.protocol!=="https:"&&a.hostname!=="localhost")return{isConfigured:!1,issue:"invalid_url",message:"NEXT_PUBLIC_SUPABASE_URL must be https (or localhost).",url:t,key:n}}catch{return{isConfigured:!1,issue:"invalid_url",message:"NEXT_PUBLIC_SUPABASE_URL is not a valid URL.",url:t,key:n}}return{isConfigured:!0,issue:null,message:null,url:t,key:n}}function j(){return xe(ze)}function re(){return j().isConfigured}function We(){const e=j();return!e.url||!e.key||!e.isConfigured?null:(L||(L=Ie(e.url,e.key,{auth:{persistSession:!0,autoRefreshToken:!0,detectSessionInUrl:!0,experimental:{passkey:!0}},global:{fetch:async(t,n)=>{const i=new Headers(n==null?void 0:n.headers),s=M;s&&i.set("Authorization",`Bearer ${s}`);const r=typeof t=="string"?t:t instanceof URL?t.href:t.url;if(Me()&&!r.includes("/auth/v1/"))return new Response(JSON.stringify({message:"account_ended: the page is reloading for the next account (temporarily unavailable)",code:"PT503"}),{status:503,headers:{"content-type":"application/json"}});I&&r.includes("/rest/v1/")&&i.set("x-sarploy-organization",I);const a=Fe(((n==null?void 0:n.method)??(t instanceof Request?t.method:"GET")).toUpperCase(),r,n==null?void 0:n.body);if(a.refused)return Ae(a);const c=await fetch(t,{...n,cache:"no-store",headers:i});return c.status===409&&I&&(await c.clone().text().catch(()=>"")).includes("organization_changed")&&qe(),c}}}),L.auth.getSession().then(({data:t})=>{var n;M=((n=t.session)==null?void 0:n.access_token)??null}),L.auth.onAuthStateChange((t,n)=>{M=(n==null?void 0:n.access_token)??null})),L)}function Nt(e){const t=j();return!t.url||!t.key?null:{url:`${t.url.replace(/\/$/,"")}/functions/v1/${e}`,apiKey:t.key}}function Bt(e){return e.isConfigured&&e.session?"backend":"local"}function Dt(e){return e==="backend"}const He=/\b(?:Bearer\s+\S+|eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+|sb_(?:secret|publishable)_[A-Za-z0-9_-]+|service_role\s*[:=]\s*\S+)\b/gi,Ve=/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi,Xe=/\b(?:\+?1[-.\s]?)?\(?\d{3}\)?[-.\s]\d{3}[-.\s]\d{4}\b/g,je=/\b\d{1,6}\s+[A-Za-z0-9.' -]{1,60}\s(?:Street|St|Road|Rd|Avenue|Ave|Boulevard|Blvd|Lane|Ln|Drive|Dr|Court|Ct|Way|Highway|Hwy)\b/gi,Ge=/([?&](?:token|apikey|signature|sig|access_token|refresh_token)=)[^&\s]+/gi,Ke=/\b[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\b/gi,Ye=new RegExp("(?<!\\d)-?\\d{1,3}\\.\\d{4,}\\s*[,/]\\s*-?\\d{1,3}\\.\\d{4,}(?!\\d)","g"),he=/\b(?:SQL|Supabase|PostgREST|RLS|row-level security|policy|schema cache|JWT|service_role|auth\.uid|permission denied|relation|column|function public\.|function not found|FunctionsFetchError)\b/i,x=25,Ze=/^[A-Za-z0-9_.:/-]{1,120}$/,B=[],W=new Set;let oe=0;function S(e){const t=(e==null?void 0:e.trim())??"";return Ze.test(t)?t:null}function Je(){return oe+=1,`runtime:${Date.now().toString(36)}:${oe.toString(36)}`}function $(e){return(e instanceof Error?e.message:e&&typeof e=="object"&&"message"in e?String(e.message??"unknown"):String(e??"unknown")).replace(He,"[redacted-secret]").replace(Ve,"[redacted-email]").replace(Xe,"[redacted-phone]").replace(je,"[redacted-address]").replace(Ge,"$1[redacted-secret]").replace(Ke,"[redacted-id]").replace(Ye,"[redacted-coordinates]").replace(/[\r\n\u2028\u2029]+/g," ").slice(0,240)}function Qe(e){var s;if(!e||typeof e!="object"||!("code"in e))return"unknown";const t=String(e.code??"unknown");if(!/^[A-Za-z0-9_.-]{1,64}$/.test(t))return"unknown";const n=e.diagnostic,i=typeof n=="string"?(s=/^([0-9A-Z]{5}|PGRST\d{3})(?= - |$)/.exec(n))==null?void 0:s[1]:void 0;return t==="backend_operation_failed"&&i?`${t}:${i}`:t}function Ut(e,t){const n=$(e).trim();return!n||he.test(n)?t:n}function et(e){const t=$(e).trim();return he.test(t)?"provider_error_redacted":t||"unknown"}function $t(e=x){return B.slice(0,Math.max(0,Math.min(e,x))).map(t=>({...t}))}function Mt(e){return W.add(e),()=>W.delete(e)}function tt(e,t,n={}){const i=e.replace(/[^A-Za-z0-9_.-]/g,"_").slice(0,80),s=S(n.clientActionId),r={event:i,
1code:Qe(t),detail:et(t),correlationId:S(n.correlationId)??s??Je(),clientActionId:s,organizationId:S(n.organizationId),searchId:S(n.searchId),incidentId:S(n.incidentId),operationId:S(n.operationId),userId:S(n.userId),userRole:S(n.userRole),rpcName:S(n.rpcName),capability:S(n.capability),recoveryState:S(n.recoveryState),occurredAt:new Date().toISOString()};B.unshift(r),B.length=Math.min(B.length,x);for(const a of W)try{a({...r})}catch{}if(typeof window<"u")try{window.dispatchEvent(new CustomEvent("searchnet:safe-runtime-issue",{detail:{...r}}))}catch{}return r}function nt(e){const t=e.eventType;if(t!=="INSERT"&&t!=="UPDATE"&&t!=="DELETE")return;const n=e.new&&Object.keys(e.new).length?e.new:void 0,i=e.old&&Object.keys(e.old).length?e.old:void 0;return[{event:t,record:n,old:i}]}function _(e,t){var n,i;return((n=e.new)==null?void 0:n[t])??((i=e.old)==null?void 0:i[t])??void 0}function st(e){return[e.organizationId??"no-org",e.searchId??"no-search",e.operationId??"no-operation",e.incidentId??"no-incident"].join(":")}function it(e){const t=[],n=i=>({organizationId:_(i,"organization_id")??e.organizationId??void 0,searchId:_(i,"search_id")??e.searchId??void 0,rowId:_(i,"id"),source:"realtime",rows:nt(i)});if(e.organizationId){const i=`organization_id=eq.${e.organizationId}`;t.push({table:"searches",filter:i,toChange:s=>({resource:"searches",...n(s)})},{table:"responder_profiles",filter:i,toChange:s=>({resource:"roster",...n(s)})},{table:"teams",filter:e.searchId?`search_id=eq.${e.searchId}`:i,toChange:s=>({resource:"teams",...n(s),teamId:_(s,"id")})},{table:"team_members",toChange:s=>({resource:"team_members",...n(s),teamId:_(s,"team_id")})},...e.responderOnly?[]:[{table:"search_intake_links",filter:i,toChange:s=>({resource:"intake_links",...n(s)})}])}if(e.operationId&&t.push({table:"operations",filter:`id=eq.${e.operationId}`,toChange:i=>({resource:"operations",...n(i),operationId:e.operationId??void 0})},{table:"audit_events",filter:`operation_id=eq.${e.operationId}`,toChange:i=>({resource:"audit",...n(i),operationId:e.operationId??void 0,incidentId:e.incidentId??void 0})},{table:"incidents",filter:`operation_id=eq.${e.operationId}`,toChange:i=>({resource:"incidents",...n(i),operationId:e.operationId??void 0})}),e.incidentId){const i=`incident_id=eq.${e.incidentId}`;t.push({table:"assignments",filter:i,toChange:s=>({resource:"assignments",...n(s),incidentId:e.incidentId??void 0,assignmentId:_(s,"id"),teamId:_(s,"assigned_team_id")})},{table:"grids",filter:i,toChange:s=>({resource:"grids",...n(s),incidentId:e.incidentId??void 0})},{table:"markers",filter:i,toChange:s=>({resource:"markers",...n(s),incidentId:e.incidentId??void 0,markerId:_(s,"id"),teamId:_(s,"team_id"),assignmentId:_(s,"assignment_id")})},{table:"markers",event:"DELETE",toChange:s=>({resource:"markers",...n(s),incidentId:e.incidentId??void 0,markerId:_(s,"id")})})}if(e.searchId){const i=`search_id=eq.${e.searchId}`;t.push({table:"search_locations",filter:i,toChange:s=>({resource:"searches",...n(s)})},{table:"search_areas",filter:i,toChange:s=>({resource:"grids",...n(s),incidentId:_(s,"incident_id")??e.incidentId??void 0})},{table:"next_grid_offers",filter:i,toChange:s=>({resource:"next_grid_offers",...n(s),teamId:_(s,"offered_to_team_id")})},{table:"search_check_ins",filter:i,toChange:s=>({resource:"check_ins",...n(s),teamId:_(s,"team_id")})},...e.responderOnly?[]:[{table:"intake_submissions",filter:i,toChange:s=>({resource:"intake",...n(s)})},{table:"search_closeouts",filter:i,toChange:s=>({resource:"closeouts",...n(s)})}])}return t}const rt=200,H=new Map,A=new Map;let z=null;const ot=750;let q=!1;function V(e){const t=H.get(e.resource);if(t)for(const n of t)n(e)}function at(e){return[e.resource,e.organizationId??"",e.searchId??"",e.operationId??"",e.incidentId??""].join(":")}function ct(e){const t=at(e),n=A.get(t),i=n===void 0?e.rows:n.rows&&e.rows&&n.rows.length+e.rows.length<=rt?[...n.rows,...e.rows]:void 0;A.set(t,{...e,rows:i}),!z&&(z=setTimeout(()=>{if(z=null,typeof document<"u"&&document.visibilityState==="hidden"){if(!q){q=!0;const r=()=>{if(document.visibilityState!=="visible")return;document.removeEventListener("visibilitychange",r),q=!1;const a=[...A.values()];A.clear();for(const c of a)V(c)};document.addEventListener("visibilitychange",r)}return}const s=[...A.values()];A.clear();for(const r of s)V(r)},ot))}function zt(e,t){const n=H.get(e)??new Set;
1return n.add(t),H.set(e,n),()=>{n.delete(t)}}function ae(...e){for(const t of e){const n=typeof t=="string"?{resource:t}:t;n.source==="realtime"?ct(n):V(n)}}const dt="sarploy:realtime-leader",X=2e3,lt=X*3;function _e(e,t){const n={isLeader:!1,disposed:!1};if(typeof window>"u"||typeof BroadcastChannel>"u")return n.isLeader=!0,t(!0),{get isLeader(){return n.isLeader},dispose:()=>{n.disposed=!0}};const i=`${Date.now()}-${Math.random().toString(36).slice(2)}`,s=new BroadcastChannel(`${dt}:${e}`);let r=0,a=null;const c=g=>g<i,l=g=>{n.disposed||n.isLeader===g||(n.isLeader=g,t(g))},E=()=>{a===null&&(s.postMessage({kind:"heartbeat",id:i}),a=window.setInterval(()=>{s.postMessage({kind:"heartbeat",id:i})},X))},m=()=>{a!==null&&(window.clearInterval(a),a=null)},o=()=>{n.disposed||n.isLeader||Date.now()-r<lt||(l(!0),E())};s.onmessage=g=>{const u=g.data;if(!(!u||n.disposed)){if(u.kind==="who-is-leader"){n.isLeader&&s.postMessage({kind:"heartbeat",id:i});return}if(u.kind==="standing-down"){u.id!==i&&(r=0,o());return}u.id!==i&&(r=Date.now(),n.isLeader&&c(u.id)&&(m(),l(!1)))}},l(!0),E(),s.postMessage({kind:"who-is-leader"});const d=window.setInterval(o,X),p=()=>{n.isLeader&&s.postMessage({kind:"standing-down",id:i})};return window.addEventListener("pagehide",p),{get isLeader(){return n.isLeader},dispose:()=>{n.disposed=!0,window.removeEventListener("pagehide",p),window.clearInterval(d),m(),p(),s.close()}}}const ut=6e4,ft="sarploy:realtime-forward";function qt({organizationId:e,searchId:t,operationId:n,incidentId:i,responderOnly:s=!1,enabled:r=!0}){const[a,c]=Q.useState(()=>r?e?re()?"connecting":"unavailable":"waiting-for-organization":"disabled");return Q.useEffect(()=>{if(!r){c("disabled");return}if(!e){c("waiting-for-organization");return}if(!re()){c("unavailable");return}const l=We();if(!l){c("unavailable");return}const E={organizationId:e,searchId:t,operationId:n,incidentId:i,responderOnly:s},m=st(E),o=typeof BroadcastChannel>"u"?null:new BroadcastChannel(`${ft}:${m}`);let d=null,p="connecting";const g=f=>{p=f,c(f),o==null||o.postMessage({kind:"leader-status",status:f})},u=f=>{var h;((h=f.data)==null?void 0:h.kind)==="leader-status-request"&&(o==null||o.postMessage({kind:"leader-status",status:p}))},v=f=>{const h=f.data;if(h){if("kind"in h&&h.kind==="leader-status"){w=h.status==="live",c(h.status);return}"kind"in h&&h.kind==="leader-status-request"||ae(h)}},G=it(E),K=f=>{ae(f),o==null||o.postMessage(f)};let w=!1;const R=()=>{for(const f of G)K(f.toChange({}))},Ee=()=>{const f=l.channel(`searchnet-ops-${m}`);g("connecting");for(const b of G)f.on("postgres_changes",{event:b.event??"*",schema:"public",table:b.table,...b.filter?{filter:b.filter}:{}},Se=>K(b.toChange(Se)));let h=!1,N=!1,y=null,J=0;return f.subscribe(b=>{if(b==="SUBSCRIBED"){h&&R(),h=!0,N=!1,w=!0,g("live");return}if(b==="CHANNEL_ERROR"||b==="TIMED_OUT"){if(w=!1,g("degraded"),document.visibilityState==="hidden"||(Date.now()-J>6e4&&(J=Date.now(),R()),N||y!==null))return;y=window.setTimeout(()=>{y=null,!(w||N)&&(N=!0,tt("realtime.subscription_degraded",Object.assign(new Error("Operational Realtime subscription degraded."),{code:b.toLowerCase()}),{correlationId:`realtime:${m}`,organizationId:e,searchId:t,operationId:n,incidentId:i,capability:"operational-realtime",recoveryState:"authoritative-refresh-requested"}))},3e4)}}),()=>{y!==null&&window.clearTimeout(y),l.removeChannel(f)}},pe=_e(m,f=>{if(f){w=!1,o==null||o.removeEventListener("message",v),o==null||o.addEventListener("message",u),d=Ee();return}d==null||d(),d=null,o==null||o.removeEventListener("message",u),w=!1,c("connecting"),o==null||o.addEventListener("message",v),o==null||o.postMessage({kind:"leader-status-request"}),R()}),Y=()=>R();let O=document.visibilityState==="hidden"?Date.now():null;const Z=()=>{if(document.visibilityState==="hidden"){O??(O=Date.now());return}const f=O===null?0:Date.now()-O;O=null,(!w||f>ut)&&R()};return window.addEventListener("online",Y),document.addEventListener("visibilitychange",Z),()=>{window.removeEventListener("online",Y),document.removeEventListener("visibilitychange",Z),pe.dispose(),d==null||d(),o==null||o.removeEventListener("message",v),o==null||o.removeEventListener("message",u),o==null||o.close()}},[r,i,n,e,s,t]),a}function D(e,t){if(!Number.isInteger(e)||e<=0)throw new Error(`${t} must be a positive integer.`)}async function me(e,t,n){const i=await e.fetchPage(t,t+n-1);if(i.error)throw i.error;return i.data??[]}
1class ce extends Error{constructor(t,n){super(`${t} exceeds the ${n.toLocaleString()}-record operational view limit. Narrow the active scope before continuing.`),this.name="OperationalCollectionLimitError"}}const de=1e3;async function Ft({label:e,pageSize:t,maximumRows:n,fetchPage:i}){if(D(t,"Page size"),D(n,"Maximum rows"),t>de)throw new Error(`${e}: page size over ${de}`);const s=[];let r=0;for(;s.length<=n;){const a=Math.min(t,n+1-s.length),c=await me({label:e,pageSize:t,fetchPage:i},r,a);if(c.length===0)return s;if(s.push(...c),r+=c.length,s.length>n)throw new ce(e,n);if(c.length<a)return s}throw new ce(e,n)}async function xt({label:e,pageSize:t,visibleRows:n,fetchPage:i}){D(t,"Page size"),D(n,"Visible rows");const s=n+1,r=[];let a=0;for(;r.length<s;){const c=Math.min(t,s-r.length),l=await me({label:e,pageSize:t,fetchPage:i},a,c);if(l.length===0)break;r.push(...l),a+=l.length}return{rows:r.slice(0,n),hasMore:r.length>n}}const gt=new Set(["PGRST202","PGRST204","PGRST205","42703","42883","42P01"]);function P(e){return e&&typeof e=="object"?e:{}}function C(e){if(e instanceof Error)return e.message;const t=P(e);return t.message||t.details||t.hint||""}class k extends Error{constructor(n){super(n.message,n.cause===void 0?void 0:{cause:n.cause});T(this,"code");T(this,"capability");T(this,"diagnostic");T(this,"status");this.name="BackendCapabilityError",this.code=n.code,this.capability=n.capability,this.diagnostic=n.diagnostic??null,this.status=n.status??null}}const ht=/^(22023|P0001|PT\d{3})$/,_t={assignment_stale_transition:"Changed on another screen a moment ago",assignment_debrief_requires_the_assigned_team:"Only this assignment's team can debrief",assignment_action_organization_mismatch:"This assignment is in another organization",assignment_dispatch_team_changed:"That team's grid just changed. Look again",assignment_dispatch_team_not_available:"That team cannot be sent right now",assignment_debrief_note_too_long:"The debrief note is too long",marker_review_changed:"Reviewed on another screen just now. Look again"},mt=/^[a-z][a-z0-9]*(_[a-z0-9]+)+(:|$)/,Et="SARploy is out of date. Update it, then try again.";function pt(e){if(!e||typeof e!="object")return!1;const t=e;return/\bupdate_required\b/.test(`${String(t.code??"")} ${String(t.message??"")} ${String(t.diagnostic??"")}`)}function St(e){const t=C(e).trim(),n=_t[t.split(":")[0].trim()];if(n)return`${n}.`;const i=String(P(e).code??"");return(i==="PT409"||i==="P0001")&&t&&!mt.test(t)&&$(t).trim()||null}function bt(e){const n=P(e).code??"",i=C(e).toLowerCase();return gt.has(n)?!0:ht.test(n)?!1:i.includes("could not find the function")||i.includes("schema cache")||i.includes("does not exist")||n==="22P02"&&i.includes("audit_event_name")}function Wt(e,t,n){var a;if(pt(e))return new k({code:"backend_operation_failed",capability:t,message:Et,diagnostic:le(e),status:503,cause:e});if(bt(e))return new k({code:"backend_capability_mismatch",capability:t,message:`${t} is unavailable because this app version is newer than the hosted operational schema. No data was changed. Complete the backend rollout before retrying.`});if(C(e).toLowerCase().includes("unresolved_assignments_block_closeout"))return new k({code:"unresolved_assignments_block_closeout",capability:t,message:"Unable to complete the trusted search closeout. Resolve or explicitly override outstanding assignments before retrying."});if(/failed to fetch|load failed|networkerror|network request failed|fetch failed/i.test(C(e)))return new k({code:"network_unreachable",capability:t,message:`${t} did not reach SARploy - this device's connection dropped. Nothing was saved; try again when it is back.`,cause:e});const i=le(e),s=P(e),r=Number(s.status??((a=s.context)==null?void 0:a.status));return new k({code:"backend_operation_failed",capability:t,message:St(e)??n,diagnostic:i,status:Number.isFinite(r)&&r>0?r:null,cause:e})}function le(e){const t=P(e),n=[];t.code&&n.push(String(t.code));const i=$(C(e)).trim();return i&&n.push(i.length>160?`${i.slice(0,160)}...`:i),n.join(" - ")||null}let ue=0;function Ht(e,t,n,i,s){const r=typeof BroadcastChannel>"u"?null:new BroadcastChannel(`sarploy:led:${t}`),a=d=>{var p,g;(p=d.data)!=null&&p.table&&d.data.payload?i(d.data.table,d.data.payload):(g=d.data)!=null&&g.status&&(s==null||s(d.data.status))},c=d=>{s==null||s(d),r==null||r.postMessage({status:d})};let l=null;const E=()=>{ue+=1;const d=e.channel(`led-${t}-${ue}`);for(const u of n)d.on("postgres_changes",{event:"*",schema:"public",table:u.table,...u.filter?{filter:u.filter}:{}},v=>{i(u.table,v),r==null||r.postMessage({table:u.table,payload:v})});let p=m,g=!1;return d.subscribe(u=>{c(u),u==="SUBSCRIBED"&&(p||g)&&(p=!1,c("TOOK_OVER")),u==="SUBSCRIBED"&&(g=!0)}),()=>{e.removeChannel(d)}};let m=!1;const o=_e(`led:${t}`,d=>{if(d){r==null||r.removeEventListener("message",a),l=E();return}m=!0,l==null||l(),l=null,r==null||r.addEventListener("message",a)});return()=>{o.dispose(),l==null||l(),r==null||r.removeEventListener("message",a),r==null||r.close()}}export{Tt as A,Ut as B,Pt as C,$ as D,Ce as E,F,pt as G,Pe as H,$t as I,k as J,ut as R,Ue as S,kt as a,At as b,yt as c,j as d,Lt as e,Bt as f,We as g,Me as h,re as i,Mt as j,Dt as k,tt as l,zt as m,ae as n,Nt as o,Ht as p,Qe as q,Ot as r,Ct as s,Ft as t,Rt as u,xt as v,Wt as w,Oe as x,qt as y,$e as z};

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.