import{d as ra,f as S,a as z,s as p}from"../chunks/DktbhmWA.js";import{p as oa,d as N,e as na,u as ia,a as ca,c as a,s,b as P,r as e,g as d,h as T,t as F,i as la}from"../chunks/CPWcrcMP.js";import{i as H}from"../chunks/0jvM7PZf.js";import{S as va,e as da,i as pa,A as _a,s as M,a as fa}from"../chunks/BxBMkMrU.js";import"../chunks/DUxDMF0-.js";import{G as ma}from"../chunks/CtdL8EMg.js";import{g as U}from"../chunks/Dulyqw6d.js";import{C as ua}from"../chunks/KvYou6FZ.js";import{T as ba}from"../chunks/C1ObK9-9.js";var xa=S('<a class="btn btn-primary btn-sm">Add Zone</a>'),ha=(n,_)=>U("/zones/"+_()),ga=(n,_)=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),U("/zones/"+_()))},ya=n=>n.stopPropagation(),ka=S('<div role="link" tabindex="0" class="mt-4 grid gap-8 lg:gap-12 border-2 border-primary p-2 rounded-xl cursor-pointer"><div class="flex justify-between items-center w-full"><h3 class="text-3xl font-semibold"> </h3> <div class="flex items-center gap-2"><span class="badge badge-secondary h-8"> </span> <span><!></span> <a class="btn btn-primary btn-sm"> </a></div></div> <div><h3 class="text-l">Location: <span class="text-gray-400"> </span></h3> <h3 class="text-l">Description: <span class="text-gray-400"> </span></h3> <h3 class="text-l">Supplies: <span class="text-gray-400"> </span></h3></div></div>'),wa=S('<section><div class="container mx-auto"><div class="flex items-center gap-2 sticky bg-base-100 z-40" style="top:4.11rem"><!></div> <div class="flex justify-between text-left mb-2"><h2 class="text-4xl font-semibold ">Zones</h2> <!></div> <!></div></section>');function $a(n,_){oa(_,!0);const V=new va(["Zones/+/+"]);let Z=N(na({})),j=N(0);ia(()=>{const c=V.getData(),r={};for(const[m,l]of Object.entries(c)){const t=m.split("/");if(t.length<3)continue;const o=t[1],v=t[2];if(!(!o||!v)){r[o]||(r[o]={});try{r[o][v]=l}catch(f){console.warn(`Failed to parse field "${v}" with value "${l}"`,f)}}}P(j,Math.max(...Object.keys(r).map(Number))+1),P(Z,r,!0)});const A=T(()=>!_a.canEditZones);var x=wa(),D=a(x),h=a(D),q=a(h);ma(q,{}),e(h);var g=s(h,2),B=s(a(g),2);{var J=c=>{var r=xa();F(()=>M(r,"href","/zones/new_"+d(j)+"/edit")),z(c,r)};H(B,c=>{d(A)||c(J)})}e(g);var K=s(g,2);da(K,17,()=>Object.entries(d(Z)),pa,(c,r)=>{var m=T(()=>la(d(r),2));let l=()=>d(m)[0],t=()=>d(m)[1];var o=ka();o.__click=[ha,l],o.__keydown=[ga,l];var v=a(o),f=a(v),Q=a(f,!0);e(f);var E=s(f,2),y=a(E),R=a(y);e(y);var u=s(y,2);let I;var W=a(u);{var X=i=>{ua(i,{})},Y=i=>{ba(i,{})};H(W,i=>{t().Status==="1"?i(X):i(Y,!1)})}e(u);var b=s(u,2);b.__click=[ya];var aa=a(b,!0);e(b),e(E),e(v);var O=s(v,2),k=a(O),$=s(a(k)),ea=a($,!0);e($),e(k);var w=s(k,2),C=s(a(w)),ta=a(C,!0);e(C),e(w);var G=s(w,2),L=s(a(G)),sa=a(L,!0);e(L),e(G),e(O),e(o),F(i=>{p(Q,t().Name),p(R,`Zone ${l()??""}`),I=fa(u,1,"badge h-8",null,I,i),M(b,"href","/zones/"+l()+"/edit"),p(aa,d(A)?"View":"Edit"),p(ea,t().Location),p(ta,t().Description),p(sa,t().Supplies)},[()=>({"badge-success":t().Status==="1","badge-error":t().Status==="2"||t().Status==="3"||t().Status==="4"})]),z(c,o)}),e(D),e(x),z(n,x),ca()}ra(["click","keydown"]);export{$a as component};
