1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1269],{41269:(e,t,a)=>{a.r(t),a.d(t,{default:()=>P});var l=a(95155),s=a(12115),n=a(39390),i=a(14585),r=a(37401),d=a(82146),c=a(13038),o=a(12711),u=a(8683),p=a(12180),m=a(27896);let h={build:"Build",event:"Event",strike:"Strike",comm:"Communication",shift:"Shift"},x={build:"build",event:"event",strike:"strike",comm:"pre_production",shift:"event"},g={planned:"Planned",in_progress:"In Progress",complete:"Complete",blocked:"Blocked",cancelled:"Cancelled"},v={planned:["in_progress","blocked","cancelled"],in_progress:["complete","blocked","cancelled"],complete:["in_progress"],blocked:["planned","in_progress","cancelled"],cancelled:["planned"]},j={critical:"Critical",high:"High",medium:"Medium",low:"Low"};function b(e){var t,a;return Math.max(0,(null!=(t=e.idealCapacity)?t:0)-(null!=(a=e.currentCapacity)?a:0))}function f(e,t){var a,l,s,n;let i=e.startAt.toMillis(),r=null!=(s=null==(a=e.endAt)?void 0:a.toMillis())?s:i,d=t.startAt.toMillis();return i<(null!=(n=null==(l=t.endAt)?void 0:l.toMillis())?n:d)&&d<r}var y=a(90103);let k={build:"bg-orange-500/15 text-orange-300 border-orange-500/30",event:"bg-weavePink/15 text-weavePink border-weavePink/30",strike:"bg-yellow-500/15 text-attention-ink border-yellow-500/30",comm:"bg-weaveBlue/15 text-weaveBlue border-weaveBlue/30",shift:"bg-emerald-500/15 text-positive-ink border-emerald-500/30"},N=["build","event","strike","comm","shift"],w={planned:"bg-white/[0.04] text-t3 border-white/[0.06]",in_progress:"bg-weaveBlue/15 text-weaveBlue border-weaveBlue/30",complete:"bg-emerald-500/15 text-positive-ink border-emerald-500/30",blocked:"bg-red-500/15 text-negative-ink border-red-500/30",cancelled:"bg-white/[0.04] text-t3 border-white/[0.06] line-through"};function C(e,t){var a,l,s,i,r,d,c,o,u,p,m,h,x,g,v,j,b,f,y,k,N,w,C,I,A,D,S,T,M,P,B,L,R,F;return{id:e,eventId:null!=(a=t.eventId)?a:"",producerId:null!=(l=t.producerId)?l:"",title:null!=(s=t.title)?s:"",description:null!=(i=t.description)?i:void 0,notes:null!=(r=t.notes)?r:void 0,kind:null!=(d=t.kind)?d:"build",phase:null!=(c=t.phase)?c:"pre_production",startAt:null!=(o=t.startAt)?o:n.Timestamp.now(),endAt:null!=(u=t.endAt)?u:void 0,durationMs:null!=(p=t.durationMs)?p:void 0,status:null!=(m=t.status)?m:"planned",priority:t.priority,completedAt:null!=(h=t.completedAt)?h:void 0,placeId:null!=(x=t.placeId)?x:void 0,placeName:null!=(g=t.placeName)?g:void 0,projectId:null!=(v=t.projectId)?v:void 0,roleResponsible:null!=(j=t.roleResponsible)?j:void 0,lead:null!=(b=t.lead)?b:void 0,assignedMembers:Array.isArray(t.assignedMembers)?t.assignedMembers:[],dependsOnItemIds:null!=(f=t.dependsOnItemIds)?f:[],idealCapacity:null!=(y=t.idealCapacity)?y:void 0,currentCapacity:null!=(k=t.currentCapacity)?k:void 0,shiftType:null!=(N=t.shiftType)?N:void 0,stageTrack:null!=(w=t.stageTrack)?w:void 0,transport:null!=(C=t.transport)?C:void 0,channels:null!=(I=t.channels)?I:[],audience:null!=(A=t.audience)?A:[],link:null!=(D=t.link)?D:void 0,templateId:null!=(S=t.templateId)?S:void 0,attachmentRefs:null!=(T=t.attachmentRefs)?T:[],tags:null!=(M=t.tags)?M:[],isActive:!1!==t.isActive,isPinned:null!=(P=t.isPinned)&&P,createdAt:null!=(B=t.createdAt)?B:n.Timestamp.now(),updatedAt:null!=(L=t.updatedAt)?L:n.Timestamp.now(),createdBy:null!=(R=t.createdBy)?R:"",lastModifiedBy:null!=(F=t.lastModifiedBy)?F:void 0}}function I(e){return e?e.toDate().toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"}):"â"}function A(e){return e.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"})}function D(e){let t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-t.getDay()),t}function S(e){let t=e.toDate();return"".concat(t.getFullYear(),"-").concat(String(t.getMonth()+1).padStart(2,"0"),"-").concat(String(t.getDate()).padStart(2,"0"))}function T(e){if(!e)return"";let t=e.toDate(),a=e=>String(e).padStart(2,"0");return"".concat(t.getFullYear(),"-").concat(a(t.getMonth()+1),"-").concat(a(t.getDate()),"T").concat(a(t.getHours()),":").concat(a(t.getMinutes()))}function M(e){if(!e)return null;let t=new Date(e);return isNaN(t.getTime())?null:n.Timestamp.fromDate(t)}function P(){let{user:e}=(0,r.Y)(),{eventId:t}=(0,d._)();return t?e?(0,l.jsx)(B,{eventId:t,producerId:e.uid}):(0,l.jsx)(o.y$,{}):(0,l.jsx)(o.pp,{icon:(0,l.jsx)(u.CT,{className:"w-6 h-6 text-t3"}),heading:"Select an event",description:"The schedule scopes to a
1specific event. Pick one from the selector above."})}function B(e){var t,a;let{eventId:d,producerId:m}=e,{user:x,notify:j}=(0,r.Y)(),[b,f]=(0,s.useState)(!1),[w,I]=(0,s.useState)(null),[T,M]=(0,s.useState)(null),[P,B]=(0,s.useState)(""),[F,O]=(0,s.useState)("all"),[E,W]=(0,s.useState)("all"),[z,U]=(0,s.useState)("open"),[Y,X]=(0,s.useState)("list"),[K,V]=(0,s.useState)(()=>{let e=new Date;return e.setHours(0,0,0,0),e}),q="events/".concat(d,"/scheduleItems"),{data:J,loading:G}=(0,c.$)(q,[],C),Q=(0,s.useMemo)(()=>J.filter(e=>{if("all"!==F&&e.kind!==F||"all"!==E&&e.phase!==E)return!1;if("open"===z){if("complete"===e.status||"cancelled"===e.status)return!1}else if("all"!==z&&e.status!==z)return!1;if(P.trim()){var t,a,l,s,n;let i=P.trim().toLowerCase();if(!e.title.toLowerCase().includes(i)&&!(null!=(a=e.description)?a:"").toLowerCase().includes(i)&&!(null!=(l=null==(t=e.lead)?void 0:t.name)?l:"").toLowerCase().includes(i)&&!(null!=(s=e.placeName)?s:"").toLowerCase().includes(i)&&!(null!=(n=e.shiftType)?n:"").toLowerCase().includes(i))return!1}return!0}),[J,F,E,z,P]),Z=(0,s.useMemo)(()=>[...Q].sort((e,t)=>e.startAt.toMillis()-t.startAt.toMillis()),[Q]),ee=(0,s.useMemo)(()=>{let e=new Map;for(let t of Z){let a=S(t.startAt);e.has(a)||e.set(a,[]),e.get(a).push(t)}return Array.from(e.entries()).map(e=>{let[t,a]=e;return{key:t,date:a[0].startAt.toDate(),items:a}})},[Z]),et=(0,s.useMemo)(()=>{let e={},t={},a={all:J.length,open:0};for(let i of J){var l,s,n;e[i.kind]=(null!=(l=e[i.kind])?l:0)+1,t[i.phase]=(null!=(s=t[i.phase])?s:0)+1,a[i.status]=(null!=(n=a[i.status])?n:0)+1,"complete"!==i.status&&"cancelled"!==i.status&&(a.open+=1)}return{kind:e,phase:t,status:a}},[J]),ea=(0,s.useCallback)(async e=>{if(x)try{await (0,n.addDoc)((0,n.collection)(i.db,q),{..._(e),eventId:d,producerId:m,isActive:!0,createdAt:(0,n.serverTimestamp)(),updatedAt:(0,n.serverTimestamp)(),createdBy:x.uid,lastModifiedBy:x.uid}),j({type:"success",message:'"'.concat(e.title,'" added to schedule')}),f(!1)}catch(e){(0,p.WL)("createScheduleItem")(e),j({type:"error",message:"Failed to create schedule item"})}},[x,d,m,q,j]),el=(0,s.useCallback)(async(e,t)=>{if(x)try{await (0,n.updateDoc)((0,n.doc)(i.db,q,e.id),{..._(t),updatedAt:(0,n.serverTimestamp)(),lastModifiedBy:x.uid}),j({type:"success",message:"Schedule item updated"}),I(null)}catch(e){(0,p.WL)("updateScheduleItem")(e),j({type:"error",message:"Failed to update schedule item"})}},[x,q,j]),es=(0,s.useCallback)(async e=>{try{await (0,n.deleteDoc)((0,n.doc)(i.db,q,e.id)),j({type:"success",message:'Deleted "'.concat(e.title,'"')}),M(null)}catch(e){(0,p.WL)("deleteScheduleItem")(e),j({type:"error",message:"Failed to delete"})}},[q,j]),en=(0,s.useCallback)(async(e,t)=>{var a;if(a=e.status,v[a].includes(t))try{await (0,n.updateDoc)((0,n.doc)(i.db,q,e.id),{status:t,updatedAt:(0,n.serverTimestamp)(),..."complete"===t?{completedAt:(0,n.serverTimestamp)()}:{}})}catch(e){(0,p.WL)("quickStatusChange",j,void 0,"Couldn't update that schedule item's status. Please try again.")(e)}},[q,j]);return(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("h1",{className:"studio-title",children:"Schedule"}),(0,l.jsx)("p",{className:"studio-caption mt-0.5",children:"The unified time spine â every scheduled moment for this event. Filter by kind to get a Build, Event-day, Strike, Comms, or Shifts view; everything lives in one collection so cross-phase queries work."})]}),(0,l.jsx)(o.$n,{onClick:()=>f(!0),icon:(0,l.jsx)(u.c1,{className:"w-4 h-4"}),children:"New Item"})]}),(0,l.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,l.jsx)(o.pd,{value:P,onChange:e=>B(e.target.value),placeholder:"Search title, description, lead, place...",className:"max-w-sm"}),(0,l.jsxs)("div",{className:"studio-caption ml-auto",children:[Z.length," ",1===Z.length?"item":"items"]})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,l.jsx)(L,{label:"All Kinds",count:J.length,active:"all"===F,onClick:()=>O("all")}),N.map(e=>{var t;
1return(0,l.jsx)(L,{label:h[e],count:null!=(t=et.kind[e])?t:0,active:F===e,onClick:()=>O(e),colorClass:k[e]},e)})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,l.jsx)("span",{className:"studio-caption",children:"Phase:"}),(0,l.jsx)(L,{label:"All",count:J.length,active:"all"===E,onClick:()=>W("all"),small:!0}),Object.keys(y.XA).map(e=>{var t;return(0,l.jsx)(L,{label:y.XA[e],count:null!=(t=et.phase[e])?t:0,active:E===e,onClick:()=>W(e),small:!0},e)})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,l.jsx)("span",{className:"studio-caption",children:"Status:"}),(0,l.jsx)(L,{label:"Open",count:null!=(t=et.status.open)?t:0,active:"open"===z,onClick:()=>U("open"),small:!0}),(0,l.jsx)(L,{label:"All",count:null!=(a=et.status.all)?a:0,active:"all"===z,onClick:()=>U("all"),small:!0}),Object.keys(g).map(e=>{var t;return(0,l.jsx)(L,{label:g[e],count:null!=(t=et.status[e])?t:0,active:z===e,onClick:()=>U(e),small:!0},e)})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,l.jsx)("span",{className:"studio-caption",children:"View:"}),(0,l.jsx)(L,{label:"List",count:Z.length,active:"list"===Y,onClick:()=>X("list"),small:!0}),(0,l.jsx)(L,{label:"Week",count:Z.length,active:"week"===Y,onClick:()=>X("week"),small:!0}),(0,l.jsx)(L,{label:"Day",count:Z.length,active:"day"===Y,onClick:()=>X("day"),small:!0}),"list"!==Y&&(0,l.jsxs)("div",{className:"flex items-center gap-1 ml-2",children:[(0,l.jsx)("button",{type:"button",className:"px-2 py-0.5 rounded text-[11px] bg-white/[0.04] text-t2 border border-white/[0.06] hover:bg-white/[0.08]",onClick:()=>{let e=new Date(K);e.setDate(e.getDate()-("week"===Y?7:1)),V(e)},children:"â"}),(0,l.jsx)("button",{type:"button",className:"px-2 py-0.5 rounded text-[11px] bg-white/[0.04] text-t2 border border-white/[0.06] hover:bg-white/[0.08]",onClick:()=>{let e=new Date;e.setHours(0,0,0,0),V(e)},children:"Today"}),(0,l.jsx)("button",{type:"button",className:"px-2 py-0.5 rounded text-[11px] bg-white/[0.04] text-t2 border border-white/[0.06] hover:bg-white/[0.08]",onClick:()=>{let e=new Date(K);e.setDate(e.getDate()+("week"===Y?7:1)),V(e)},children:"â"}),(0,l.jsx)("span",{className:"studio-caption ml-2",children:"week"===Y?function(e){let t=D(e),a=new Date(t);return(a.setDate(a.getDate()+6),t.getMonth()===a.getMonth())?"".concat(t.toLocaleDateString("en-US",{month:"short",day:"numeric"})," â ").concat(a.getDate()):"".concat(t.toLocaleDateString("en-US",{month:"short",day:"numeric"})," â ").concat(a.toLocaleDateString("en-US",{month:"short",day:"numeric"}))}(K):A(K)})]})]}),G?(0,l.jsx)(o.y$,{}):0===Z.length&&0===J.length?(0,l.jsx)(o.pp,{icon:(0,l.jsx)(u.CT,{className:"w-6 h-6 text-t3"}),heading:"No schedule items yet",description:"Build the time spine for this event â coordination meetings, build tasks, event-day beats, shifts, strike timeline. All in one place, filtered by kind.",action:{label:"Add First Item",onClick:()=>f(!0)}}):"list"===Y?0===Z.length?(0,l.jsx)(o.pp,{icon:(0,l.jsx)(u.CT,{className:"w-6 h-6 text-t3"}),heading:"No items match",description:"Try a different filter or clear the search."}):(0,l.jsx)("div",{className:"space-y-4",children:ee.map(e=>(0,l.jsxs)("div",{className:"space-y-1.5",children:[(0,l.jsxs)("div",{className:"studio-label pb-1 border-b border-white/[0.04]",children:[A(e.date)," \xb7 ",e.items.length," ",1===e.items.length?"item":"items"]}),(0,l.jsx)("div",{className:"border border-white/[0.06] rounded-lg overflow-hidden",children:e.items.map(e=>(0,l.jsx)(R,{item:e,onEdit:()=>I(e),onDelete:()=>M(e),onStatusChange:t=>en(e,t)},e.id))})]},e.key))}):(0,l.jsx)($,{items:Z,viewMode:Y,anchorDate:K,onItemClick:e=>I(e)}),b&&(0,l.jsx)(H,{mode:"create",eventId:d,existingItems:J,onSubmit:ea,onClose:()=>f(!1)}),w&&(0,l.jsx)(H,{mode:"edit",eventId:d,existingItems:J,initial:w,onSubmit:e=>el(w,e),onClose:()=>I(null)}),T&&(0,l.jsx)(o.TM,{open:!0,title:"Delete this schedule item?",message:'"'.concat(T.title,'" will be removed from the schedule. Any items that depend on it will keep their reference but lose the link.'),confirmLabel:"Delete",confirmVariant:"danger",onConfirm:()=>es(T),onCancel:()=>M(null)})]})}function L(e){let{label:t,count:a,active:s,onClick:n,small:i=!1,colorClass:r}=e;return(0,l.jsxs)("button",{onClick:n,className:"inline-flex items-center gap-1.5 ".concat(i?"px-2 py-0.5 text-[10px]":"px-2.5 py-1 text-xs"," rounded-full transition border ").concat(s?r||"bg-brand text-surface-base font-medium border-brand":"bg-white/[0.04] text-t2 border-white/[0.06] hover:bg-white/[0.08]"),children:[(0,l.jsx)("span",{children:t}),(0,l.jsx)("span",{className:"text-[10px] opacity-60",children:a})]})}function R(e){let{item:t,onEdit:a,onDelete:s,onStatusChange:n}=e,i="shift"===t.kind;return i&&b(t),(0,l.jsxs)("div",{className:"flex items-center gap-3 p-3 hover:bg-white/[0.02] border-b border-white/[0.04] last:border-b-0 [content-visibility:auto] [contain-intrinsic-size:auto_72px]",children:[(0,l.jsxs)("div",{className:"studio-caption w-24 flex-shrink-0",children:[(0,l.jsx)("div",{className:"text-t1 font-medium",children:I(t.startAt)}),t.endAt&&(0,l.jsxs)("div",{className:"text-[10px] text-t3",children:["â ",I(t.endAt)]})]}),(0,l.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,l.jsx)("div",{className:"studio-body-strong truncate",children:t.title}),(0,l.jsxs)("div",{className:"flex items-center gap-1.5 mt-0.5 flex-wrap",children:[(0,l.jsx)(o.Ex,{className:"".concat(k[t.kind]," text-[9px] px-1.5 py-0"),children:h[t.kind]}),(0,l.jsx)(o.Ex,{className:"".concat(w[t.status]," text-[9px] px-1.5 py-0"),children:g[t.status]}),t.placeName&&(0,l.jsxs)("span",{className:"studio-micro truncate max-w-[120px]",children:["\uD83D\uDCCD ",t.placeName]}),t.lead&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("span",{className:"studio-micro",children:"\xb7"}),(0,l.jsx)(m.MemberInline,{name:t.lead.name,photoURL:t.lead.photoURL,size:"xs",className:"studio-micro"})]}),i&&null!=t.idealCapacity&&t.idealCapacity>0&&(0,l.jsx)(F,{item:t}),t.shiftType&&(0,l.jsx)("span",{className:"studio-micro",children:t.shiftType}),t.stageTrack&&(0,l.jsxs)("span",{className:"studio-micro",children:["\uD83C\uDFAD ",t.stageTrack]})]})]}),(0,l.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[(0,l.jsx)("button",{onClick:a,className:"p-1 rounded hover:bg-white/[0.08] text-t3 hover:text-t1","aria-label":"Edit",children:(0,l.jsx)(u.R2,{className:"w-3.5 h-3.5"})}),(0,l.jsx)("button",{onClick:s,className:"p-1 rounded hover:bg-white/[0.08] text-t3 hover:text-negative-ink","aria-label":"Delete",children:(0,l.jsx)(u.uc,{className:"w-3.5 h-3.5"})})]})]})}function F(e){var t,a;let{item:s}=e,n=s.idealCapacity?Math.min(1,(null!=(a=s.currentCapacity)?a:0)/s.idealCapacity):0,i=b(s);return(0,l.jsxs)(o.Ex,{className:"".concat(n>=1?"bg-emerald-500/15 text-positive-ink border-emerald-500/30":n>=.5?"bg-yellow-500/15 text-attention-ink border-yellow-500/30":"bg-red-500/15 text-negative-ink border-red-500/30"," text-[9px] px-1.5 py-0"),children:[null!=(t=s.currentCapacity)?t:0,"/",s.idealCapacity,i>
10&&" \xb7 need ".concat(i)]})}let O={title:"",description:"",notes:"",kind:"build",phase:"build",startAt:"",endAt:"",status:"planned",priority:"",placeId:void 0,placeName:"",projectId:void 0,roleResponsible:null,lead:{},assignedMembers:[],idealCapacity:"",shiftType:"",stageTrack:"",transport:"",channelsInput:"",audienceInput:"",link:"",isActive:!0,isPinned:!1,tagsInput:"",dependsOnItemIds:[],attachmentRefs:[]};function _(e){var t,a,l,s;let i=e.tagsInput.split(",").map(e=>e.trim()).filter(Boolean),r=e.channelsInput.split(",").map(e=>e.trim()).filter(Boolean),d=e.audienceInput.split(",").map(e=>e.trim()).filter(Boolean),c=null!=(t=M(e.startAt))?t:n.Timestamp.now(),o=M(e.endAt),u=o?function(e,t){if(!t)return;let a=e instanceof Date?e.getTime():e.toMillis(),l=(t instanceof Date?t.getTime():t.toMillis())-a;return l>0?l:void 0}(c.toDate(),o.toDate()):void 0;return{title:e.title.trim(),description:e.description.trim()||null,notes:e.notes.trim()||null,kind:e.kind,phase:e.phase,startAt:c,endAt:null!=o?o:null,durationMs:null!=u?u:null,status:e.status,priority:e.priority||null,placeId:null!=(a=e.placeId)?a:null,placeName:e.placeName.trim()||null,projectId:null!=(l=e.projectId)?l:null,roleResponsible:null!=(s=e.roleResponsible)?s:null,lead:e.lead.id&&e.lead.name?{id:e.lead.id,name:e.lead.name}:null,assignedMembers:e.assignedMembers,idealCapacity:"shift"===e.kind&&e.idealCapacity&&parseInt(e.idealCapacity,10)||null,shiftType:"shift"===e.kind&&e.shiftType.trim()||null,stageTrack:"event"===e.kind&&e.stageTrack.trim()||null,transport:"build"===e.kind&&e.transport.trim()||null,channels:"comm"===e.kind?r:[],audience:"comm"===e.kind?d:[],link:"comm"===e.kind&&e.link.trim()||null,isActive:e.isActive,isPinned:e.isPinned,tags:i,dependsOnItemIds:e.dependsOnItemIds,attachmentRefs:e.attachmentRefs}}function H(e){var t,a,i,r,d,c,p,v,b,k,w,C,I,A,D,S,P,B;let{mode:L,eventId:R,existingItems:F,initial:_,onSubmit:H,onClose:$}=e,[X,K]=(0,s.useState)(_?{title:_.title,description:null!=(i=_.description)?i:"",notes:null!=(r=_.notes)?r:"",kind:_.kind,phase:_.phase,startAt:T(_.startAt),endAt:T(_.endAt),status:_.status,priority:null!=(d=_.priority)?d:"",placeId:_.placeId,placeName:null!=(c=_.placeName)?c:"",projectId:_.projectId,roleResponsible:null!=(p=_.roleResponsible)?p:null,lead:_.lead?{id:_.lead.id,name:_.lead.name}:{},assignedMembers:null!=(v=_.assignedMembers)?v:[],idealCapacity:null!=_.idealCapacity?String(_.idealCapacity):"",shiftType:null!=(b=_.shiftType)?b:"",stageTrack:null!=(k=_.stageTrack)?k:"",transport:null!=(w=_.transport)?w:"",channelsInput:(null!=(C=_.channels)?C:[]).join(", "),audienceInput:(null!=(I=_.audience)?I:[]).join(", "),link:null!=(A=_.link)?A:"",isActive:!1!==_.isActive,isPinned:null!=(D=_.isPinned)&&D,tagsInput:(null!=(S=_.tags)?S:[]).join(", "),dependsOnItemIds:null!=(P=_.dependsOnItemIds)?P:[],attachmentRefs:null!=(B=_.attachmentRefs)?B:[]}:O),[V,q]=(0,s.useState)(!1),J=(e,t)=>{K(a=>({...a,[e]:t}))},G=(0,s.useMemo)(()=>{var e,t;let a=M(X.startAt);if(!a)return{members:[],place:[]};let l=M(X.endAt),s={id:null!=(e=null==_?void 0:_.id)?e:"__candidate__",eventId:R,producerId:"",title:X.title,kind:X.kind,phase:X.phase,startAt:a,endAt:null!=l?l:void 0,status:X.status,assignedMembers:null!=(t=null==_?void 0:_.assignedMembers)?t:[],placeId:null==_?void 0:_.placeId,placeName:X.placeName.trim()||void 0,createdAt:n.Timestamp.now(),updatedAt:n.Timestamp.now(),createdBy:""};return{members:function(e,t){var a;let l=new Set((null!=(a=e.assignedMembers)?a:[]).map(e=>e.id).filter(Boolean));return 0===l.size?[]:t.filter(t=>{var a;return t.id!==e.id&&!!f(e,t)&&(null!=(a=t.assignedMembers)?a:[]).some(e=>e.id&&l.has(e.id))})}(s,F),place:s.placeId?F.filter(e=>e.id!==s.id&&e.placeId===s.placeId&&f(s,e)):[]}},[X.startAt,X.endAt,X.placeName,X.kind,X.phase,X.status,X.title,_,R,F]),Q=async()=>{if(X.title.trim()&&X.startAt){q(!0);try{await H(X)}finally{q(!1)}}};return(0,l.jsx)(o.aF,{open:!0,onClose:$,size:"lg",children:(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,l.jsx)("h2",{className:"studio-subtitle",children:"create"===L?"New Schedule Item":"Edit Schedule Item"}),(0,l.jsx)("button",{onClick:$,className:"p-1 rounded hover:bg-white/[0.08] text-t3 hover:text-t1","aria-label":"Close",children:(0,l.jsx)(u.fK,{className:"w-5 h-5"})})]}),(G.members.length>0||G.place.length>0)&&(0,l.jsxs)("div",{className:"bg-orange-500/[0.08] border border-orange-500/30 rounded-md p-2 text-xs text-orange-200 space-y-1",children:[(0,l.jsx)("div",{className:"font-medium",children:"â Possible conflicts"}),G.place.length>0&&(0,l.jsxs)("div",{children:['Place "',X.placeName,'" overlaps with:'," ",G.place.map(e=>
1e.title).join(", ")]}),G.members.length>0&&(0,l.jsxs)("div",{children:["Assigned members already booked:"," ",G.members.map(e=>e.title).join(", ")]}),(0,l.jsx)("div",{className:"studio-micro italic pt-0.5",children:"Saving anyway is allowed â this is a heads-up, not a block."})]}),(0,l.jsx)(E,{children:"What"}),(0,l.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,l.jsxs)("div",{className:"col-span-2",children:[(0,l.jsx)(W,{children:"Title *"}),(0,l.jsx)(o.pd,{value:X.title,onChange:e=>J("title",e.target.value),placeholder:"e.g. 'Stage rigging', 'Team meeting', 'Sound check'",autoFocus:!0})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(W,{children:"Kind *"}),(0,l.jsx)("select",{value:X.kind,onChange:e=>(e=>{J("kind",e);let t=x[X.kind];X.phase===t&&J("phase",x[e])})(e.target.value),className:U,children:N.map(e=>(0,l.jsx)("option",{value:e,children:h[e]},e))})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(W,{children:"Phase *"}),(0,l.jsx)("select",{value:X.phase,onChange:e=>J("phase",e.target.value),className:U,children:Object.keys(y.XA).map(e=>(0,l.jsx)("option",{value:e,children:y.XA[e]},e))})]}),(0,l.jsxs)("div",{className:"col-span-2",children:[(0,l.jsx)(W,{children:"Description"}),(0,l.jsx)("textarea",{value:X.description,onChange:e=>J("description",e.target.value),rows:2,className:Y,placeholder:"What needs to happen here..."})]})]}),(0,l.jsx)(E,{children:"When"}),(0,l.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(W,{children:"Start *"}),(0,l.jsx)("input",{type:"datetime-local",value:X.startAt,onChange:e=>J("startAt",e.target.value),className:z})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(W,{children:"End"}),(0,l.jsx)("input",{type:"datetime-local",value:X.endAt,onChange:e=>J("endAt",e.target.value),className:z})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(W,{children:"Status"}),(0,l.jsx)("select",{value:X.status,onChange:e=>J("status",e.target.value),className:U,children:Object.keys(g).map(e=>(0,l.jsx)("option",{value:e,children:g[e]},e))})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(W,{children:"Priority"}),(0,l.jsxs)("select",{value:X.priority,onChange:e=>J("priority",e.target.value),className:U,children:[(0,l.jsx)("option",{value:"",children:"â"}),Object.keys(j).map(e=>(0,l.jsx)("option",{value:e,children:j[e]},e))]})]})]}),(0,l.jsx)(E,{children:"Where + Who"}),(0,l.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,l.jsxs)("div",{className:"col-span-2",children:[(0,l.jsx)(W,{children:"Place"}),(0,l.jsx)(m.PlaceSinglePicker,{eventId:R,value:X.placeId,onChange:(e,t)=>
1{J("placeId",null!=e?e:void 0),J("placeName",null!=t?t:"")}})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(W,{children:"Lead"}),(0,l.jsx)(m.MemberPicker,{value:X.lead,onChange:e=>J("lead",e),placeholder:"Who's running this..."})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(W,{children:"Role Responsible"}),(0,l.jsx)(m.SingleRolePicker,{eventId:R,value:null!=(t=X.roleResponsible)?t:void 0,onChange:e=>J("roleResponsible",e)})]}),(0,l.jsxs)("div",{className:"col-span-2",children:[(0,l.jsx)(W,{children:"shift"===X.kind?"Assigned Crew (counts toward capacity)":"Assigned Members"}),(0,l.jsx)(o.S1,{eventId:R,value:X.assignedMembers,onChange:e=>J("assignedMembers",e),placeholder:"shift"===X.kind?"Staff this shift...":"Assign helpers / co-leads...",emptyHint:"No members yet on this event."})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(W,{children:"Project"}),(0,l.jsx)(o.TT,{collectionPath:"events/".concat(R,"/projects"),value:X.projectId?[X.projectId]:[],onChange:e=>J("projectId",e[0]),max:1,getLabel:e=>e.name||"(untitled project)",getSubtitle:e=>e.category?y.Rt[e.category]:null,placeholder:"Optional project...",emptyHint:"No projects yet."})]})]}),"shift"===X.kind&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(E,{children:"Shift Details"}),(0,l.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(W,{children:"Ideal Capacity"}),(0,l.jsx)(o.pd,{value:X.idealCapacity,onChange:e=>J("idealCapacity",e.target.value),placeholder:"0",type:"number",inputMode:"numeric"})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(W,{children:"Shift Type"}),(0,l.jsx)(o.pd,{value:X.shiftType,onChange:e=>J("shiftType",e.target.value),placeholder:"Meal Prep, Stage Mgmt, Care Tent..."})]})]}),(0,l.jsx)("p",{className:"studio-caption italic",children:"Tip: assign members to this shift after creating it. `currentCapacity` will fill in automatically."})]}),"event"===X.kind&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(E,{children:"Event-Day Details"}),(0,l.jsxs)("div",{children:[(0,l.jsx)(W,{children:"Stage / Track"}),(0,l.jsx)(o.pd,{value:X.stageTrack,onChange:e=>J("stageTrack",e.target.value),placeholder:"Main Stage, Vignette 1, DJ Runway..."})]})]}),"build"===X.kind&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(E,{children:"Build Details"}),(0,l.jsx)("div",{className:"grid grid-cols-2 gap-3",children:(0,l.jsxs)("div",{className:"col-span-2",children:[(0,l.jsx)(W,{children:"Transport"}),(0,l.jsx)(o.pd,{value:X.transport,onChange:e=>J("transport",e.target.value),placeholder:"Box truck, Trailer, Delivered..."})]})}),(0,l.jsx)("p",{className:"studio-micro italic",children:'Tip: group related build tasks under a Project (e.g. "Yurt Setup"). Project = Bisous\'s "Build Unit" â same shape, with lead, team, ordering, places, status.'})]}),"comm"===X.kind&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(E,{children:"Communication Details"}),(0,l.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(W,{children:"Channels (comma-separated)"}),(0,l.jsx)(o.pd,{value:X.channelsInput,onChange:e=>J("channelsInput",e.target.value),placeholder:"email, zoom, whatsapp..."})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(W,{children:"Audience (comma-separated)"}),(0,l.jsx)(o.pd,{value:X.audienceInput,onChange:e=>J("audienceInput",e.target.value),placeholder:"all members, team leads, vendors..."})]}),(0,l.jsxs)("div",{className:"col-span-2",children:[(0,l.jsx)(W,{children:"Link"}),(0,l.jsx)(o.pd,{value:X.link,onChange:e=>J("link",e.target.value),placeholder:"https://zoom.us/... or calendar invite link"})]})]})]}),(0,l.jsx)(E,{children:"Notes"}),(0,l.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,l.jsxs)("div",{className:"col-span-2",children:[(0,l.jsx)(W,{children:"Notes"}),(0,l.jsx)("textarea",{value:X.notes,onChange:e=>J("notes",e.target.value),rows:2,className:Y,placeholder:"Internal notes..."})]}),(0,l.jsxs)("div",{className:"col-span-2",children:[(0,l.jsx)(W,{children:"Tags (comma-separated)"}),(0,l.jsx)(o.pd,{value:X.tagsInput,onChange:e=>J("tagsInput",e.target.value),placeholder:"recurring, critical-path..."})]}),(0,l.jsxs)("div",{className:"col-span-2 flex items-center gap-4 text-sm text-t2",children:[(0,l.jsxs)("label",{className:"inline-flex items-center gap-2 cursor-pointer",children:[(0,l.jsx)("input",{type:"checkbox",checked:X.isActive,onChange:e=>J("isActive",e.target.checked),className:"rounded"}),(0,l.jsx)("span",{children:"Active"})]}),(0,l.jsxs)("label",{className:"inline-flex items-center gap-2 cursor-pointer",children:[(0,l.jsx)("input",{type:"checkbox",checked:X.isPinned,onChange:e=>J("isPinned",e.target.checked),className:"rounded"}),(0,l.jsx)("span",{children:"Pinned"})]})]}),(0,l.jsxs)("div",{className:"col-span-2",children:[(0,l.jsx)(W,{children:"Depends on schedule items (must c
1omplete before this)"}),(0,l.jsx)(o.TT,{collectionPath:"events/".concat(R,"/scheduleItems"),value:X.dependsOnItemIds,onChange:e=>J("dependsOnItemIds",e),excludeIds:_?[_.id]:[],getLabel:e=>e.title||"(unnamed)",getSubtitle:e=>{var t;return null!=(t=e.kind)?t:null},placeholder:"Pick blocking itemsâ¦",emptyHint:"No other items yet."})]}),(0,l.jsx)("div",{className:"col-span-2",children:(0,l.jsx)(o.ik,{label:"Attachments",pathPrefix:"events/".concat(R,"/scheduleItems/").concat(null!=(a=null==_?void 0:_.id)?a:"new","/attachments"),value:X.attachmentRefs,onChange:e=>J("attachmentRefs",e)})})]}),(0,l.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[(0,l.jsx)(o.$n,{variant:"ghost",onClick:$,children:"Cancel"}),(0,l.jsx)(o.$n,{onClick:Q,disabled:!X.title.trim()||!X.startAt||V,children:V?"Saving...":"create"===L?"Create Item":"Save Changes"})]})]})})}function E(e){let{children:t}=e;return(0,l.jsx)("div",{className:"studio-label pt-2 border-t border-white/[0.04]",children:t})}function W(e){let{children:t}=e;return(0,l.jsx)("label",{className:"studio-caption block mb-1",children:t})}let z="w-full bg-card border border-card rounded-md px-2 py-1.5 text-sm text-t1 placeholder:text-t3/60",U=z+" text-t2",Y=z+" resize-none";function $(e){let{items:t,viewMode:a,anchorDate:i,onItemClick:r}=e,d=(0,s.useMemo)(()=>{if("week"===a){let e=D(i);return Array.from({length:7},(t,a)=>{let l=new Date(e);return l.setDate(l.getDate()+a),l})}let e=new Date(i);return e.setHours(0,0,0,0),[e]},[a,i]),c=(0,s.useMemo)(()=>{let e=new Map;for(let t of d)e.set(S(n.Timestamp.fromDate(t)),[]);for(let a of t){if(!a.startAt)continue;let t=S(a.startAt);e.has(t)&&e.get(t).push(a)}return e},[t,d]),o=new Date,u=6>o.getHours()||o.getHours()>=26?null:(o.getHours()-6)*60+o.getMinutes();return(0,l.jsx)("div",{className:"border border-white/[0.06] rounded-lg overflow-auto bg-surface-base",children:(0,l.jsxs)("div",{className:"relative",style:{minWidth:"week"===a?"".concat(1040,"px"):"".concat(340,"px")},children:[(0,l.jsxs)("div",{className:"grid sticky top-0 z-20 bg-surface-base border-b border-white/[0.08]",style:{gridTemplateColumns:"60px repeat(".concat(d.length,", minmax(140px, 1fr))")},children:[(0,l.jsx)("div",{className:"studio-label p-2",children:"Hour"}),d.map(e=>{let t=e.getFullYear()===o.getFullYear()&&e.getMonth()===o.getMonth()&&e.getDate()===o.getDate();return(0,l.jsxs)("div",{className:"p-2 text-center border-l border-white/[0.04] ".concat(t?"bg-weaveBlue/[0.05]":""),children:[(0,l.jsx)("div",{className:"studio-label",children:e.toLocaleDateString("en-US",{weekday:"short"})}),(0,l.jsx)("div",{className:"text-sm font-medium ".concat(t?"text-weaveBlue":"text-t1"),children:e.toLocaleDateString("en-US",{month:"short",day:"numeric"})})]},e.toISOString())})]}),(0,l.jsxs)("div",{className:"relative grid",style:{gridTemplateColumns:"60px repeat(".concat(d.length,", minmax(140px, 1fr))"),height:"".concat(1120,"px")},children:[(0,l.jsx)("div",{className:"border-r border-white/[0.04]",children:Array.from({length:20},(e,t)=>{let a=(6+t)%24;return(0,l.jsx)("div",{className:"studio-micro px-2 border-b border-white/[0.04] flex items-start justify-end",style:{height:"".concat(56,"px")},children:0===a?"12am":12===a?"12pm":a<12?"".concat(a,"am"):"".concat(a-12,"pm")},t)})}),d.map(e=>{var t;let a=S(n.Timestamp.fromDate(e)),s=null!=(t=c.get(a))?t:[],i=e.getFullYear()===o.getFullYear()&&e.getMonth()===o.getMonth()&&e.getDate()===o.getDate();return(0,l.jsxs)("div",{className:"relative border-l border-white/[0.04]",children:[Array.from({length:20},(e,t)=>(0,l.jsx)("div",{className:"border-b border-white/[0.04]",style:{height:"".concat(56,"px")}},t)),i&&null!=u&&(0,l.jsx)("div",{className:"absolute left-0 right-0 z-10 pointer-events-none",style:{top:"".concat(u/60*56,"px"),borderTop:"2px solid rgb(var(--color-red))"},children:(0,l.jsx)("div",{className:"absolute -left-1 -top-1.5 w-2.5 h-2.5 rounded-full",style:{background:"rgb(var(--color-red))"}})}),s.map(e=>(0,l.jsx)(X,{item:e,onClick:()=>r(e)},e.id))]},e.toISOString())})]})]})})}function X(e){var t,a;let{item:s,onClick:n}=e,i=s.startAt.toDate(),r=60*i.getHours()+i.getMinutes(),d=(i.getHours()-6)*60+i.getMinutes(),c=Math.max(15,((null!=(a=null==(t=s.endAt)?void 0:t.toDate())?a:new Date(i.getTime()+18e5)).getTime()-i.getTime())/6e4);return d<0||r/60>=26?null:(0,l.jsxs)("button",{type:"button",onClick:n,className:"absolute left-1 right-1 rounded text-left p-1.5 border overflow-hidden transition-shadow hover:shadow-lg z-[5] ".concat(k[s.kind]),style:{to
1p:"".concat(Math.max(0,d/60*56),"px"),height:"".concat(Math.max(20,c/60*56),"px")},title:s.title,children:[(0,l.jsx)("div",{className:"text-[10px] font-medium leading-tight truncate",children:s.title}),(0,l.jsxs)("div",{className:"text-[9px] opacity-70 leading-tight",children:[I(s.startAt),s.endAt&&" â ".concat(I(s.endAt))]}),s.placeName&&(0,l.jsxs)("div",{className:"text-[9px] opacity-70 leading-tight truncate",children:["\uD83D\uDCCD ",s.placeName]})]})}}}]);
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.