1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2498,4834,5800,7358],{17358:(e,t,r)=>{"use strict";r.d(t,{JR:()=>w,_G:()=>c,be:()=>o,gB:()=>f,gl:()=>A});var n=r(55729),i=r(70047),s=r(80118);function o(e,t,r){let n=e.slice();return n.splice(r<0?n.length+r:r,0,n.splice(t,1)[0]),n}function a(e){return null!==e&&e>=0}let l=e=>{let{rects:t,activeIndex:r,overIndex:n,index:i}=e,s=o(t,n,r),a=t[i],l=s[i];return l&&a?{x:l.left-a.left,y:l.top-a.top,scaleX:l.width/a.width,scaleY:l.height/a.height}:null},d={scaleX:1,scaleY:1},c=e=>{var t,r,n,i;let s,o,a,{activeIndex:l,activeNodeRect:c,index:u,rects:m,overIndex:f}=e,h=null!=(t=m[l])?t:c;if(!h)return null;if(u===l){let e=m[f];return e?{x:0,y:l<f?e.top+e.height-(h.top+h.height):e.top-h.top,...d}:null}let p=(r=m,n=u,i=l,s=r[n],o=r[n-1],a=r[n+1],s?i<n?o?s.top-(o.top+o.height):a?a.top-(s.top+s.height):0:a?a.top-(s.top+s.height):o?s.top-(o.top+o.height):0:0);return u>l&&u<=f?{x:0,y:-h.height-p,...d}:u<l&&u>=f?{x:0,y:h.height+p,...d}:{x:0,y:0,...d}},u="Sortable",m=n.createContext({activeIndex:-1,containerId:u,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:l,disabled:{draggable:!1,droppable:!1}});function f(e){let{children:t,id:r,items:o,strategy:a=l,disabled:d=!1}=e,{active:c,dragOverlay:f,droppableRects:h,over:p,measureDroppableContainers:g}=(0,i.fF)(),x=(0,s.YG)(u,r),y=null!==f.rect,v=(0,n.useMemo)(()=>o.map(e=>"object"==typeof e&&"id"in e?e.id:e),[o]),A=null!=c,j=c?v.indexOf(c.id):-1,b=p?v.indexOf(p.id):-1,w=(0,n.useRef)(v),S=!function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}(v,w.current),C=-1!==b&&-1===j||S,I="boolean"==typeof d?{draggable:d,droppable:d}:d;(0,s.Es)(()=>{S&&A&&g(v)},[S,v,A,g]),(0,n.useEffect)(()=>{w.current=v},[v]);let k=(0,n.useMemo)(()=>({activeIndex:j,containerId:x,disabled:I,disableTransforms:C,items:v,overIndex:b,useDragOverlay:y,sortedRects:v.reduce((e,t,r)=>{let n=h.get(t);return n&&(e[r]=n),e},Array(v.length)),strategy:a}),[j,x,I.draggable,I.droppable,C,v,b,h,y,a]);return n.createElement(m.Provider,{value:k},t)}let h=e=>{let{id:t,items:r,activeIndex:n,overIndex:i}=e;return o(r,n,i).indexOf(t)},p=e=>{let{containerId:t,isSorting:r,wasDragging:n,index:i,items:s,newIndex:o,previousItems:a,previousContainerId:l,transition:d}=e;return!!d&&!!n&&(a===s||i!==o)&&(!!r||o!==i&&t===l)},g={duration:200,easing:"ease"},x="transform",y=s.Ks.Transition.toString({property:x,duration:0,easing:"linear"}),v={roleDescription:"sortable"};function A(e){var t,r,o,l;let{animateLayoutChanges:d=p,attributes:c,disabled:u,data:f,getNewIndex:A=h,id:j,strategy:b,resizeObserverConfig:w,transition:S=g}=e,{items:C,containerId:I,activeIndex:k,disabled:D,disableTransforms:E,sortedRects:$,overIndex:q,useDragOverlay:R,strategy:z}=(0,n.useContext)(m),T=(t=u,r=D,"boolean"==typeof t?{draggable:t,droppable:!1}:{draggable:null!=(o=null==t?void 0:t.draggable)?o:r.draggable,droppable:null!=(l=null==t?void 0:t.droppable)?l:r.droppable}),U=C.indexOf(j),P=(0,n.useMemo)(()=>({sortable:{containerId:I,index:U,items:C},...f}),[I,f,U,C]),M=(0,n.useMemo)(()=>C.slice(C.indexOf(j)),[C,j]),{rect:N,node:F,isOver:H,setNodeRef:L}=(0,i.zM)({id:j,data:P,disabled:T.droppable,resizeObserverConfig:{updateMeasurementsFor:M,...w}}),{active:O,activatorEvent:J,activeNodeRect:_,attributes:V,setNodeRef:W,listeners:Z,isDragging:B,over:G,setActivatorNodeRef:Q,transform:Y}=(0,i.PM)({id:j,data:P,attributes:{...v,...c},disabled:T.draggable}),X=(0,s.jn)(L,W),K=!!O,ee=K&&!E&&a(k)&&a(q),et=!R&&B,er=et&&ee?Y:null,en=ee?null!=er?er:(null!=b?b:z)({rects:$,activeNodeRect:_,activeIndex:k,overIndex:q,index:U}):null,ei=a(k)&&a(q)?A({id:j,items:C,activeIndex:k,overIndex:q}):U,es=null==O?void 0:O.id,eo=(0,n.useRef)({activeId:es,items:C,newIndex:ei,containerId:I}),ea=C!==eo.current.items,el=d({active:O,containerId:I,isDragging:B,isSorting:K,id:j,index:U,items:C,newIndex:eo.current.newIndex,previousItems:eo.current.items,previousContainerId:eo.current.containerId,transition:S,wasDragging:null!=eo.current.activeId}),ed=function(e){let{disabled:t,index:r,node:o,rect:a}
1=e,[l,d]=(0,n.useState)(null),c=(0,n.useRef)(r);return(0,s.Es)(()=>{if(!t&&r!==c.current&&o.current){let e=a.current;if(e){let t=(0,i.Sj)(o.current,{ignoreTransform:!0}),r={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(r.x||r.y)&&d(r)}}r!==c.current&&(c.current=r)},[t,r,o,a]),(0,n.useEffect)(()=>{l&&d(null)},[l]),l}({disabled:!el,index:U,node:F,rect:N});return(0,n.useEffect)(()=>{K&&eo.current.newIndex!==ei&&(eo.current.newIndex=ei),I!==eo.current.containerId&&(eo.current.containerId=I),C!==eo.current.items&&(eo.current.items=C)},[K,ei,I,C]),(0,n.useEffect)(()=>{if(es===eo.current.activeId)return;if(null!=es&&null==eo.current.activeId){eo.current.activeId=es;return}let e=setTimeout(()=>{eo.current.activeId=es},50);return()=>clearTimeout(e)},[es]),{active:O,activeIndex:k,attributes:V,data:P,rect:N,index:U,newIndex:ei,items:C,isOver:H,isSorting:K,isDragging:B,listeners:Z,node:F,overIndex:q,over:G,setNodeRef:X,setActivatorNodeRef:Q,setDroppableNodeRef:L,setDraggableNodeRef:W,transform:null!=ed?ed:en,transition:ed||ea&&eo.current.newIndex===U?y:(!et||(0,s.kx)(J))&&S&&(K||el)?s.Ks.Transition.toString({...S,property:x}):void 0}}function j(e){if(!e)return!1;let t=e.data.current;return!!t&&"sortable"in t&&"object"==typeof t.sortable&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable}let b=[i.vL.Down,i.vL.Right,i.vL.Up,i.vL.Left],w=(e,t)=>{let{context:{active:r,collisionRect:n,droppableRects:o,droppableContainers:a,over:l,scrollableAncestors:d}}=t;if(b.includes(e.code)){if(e.preventDefault(),!r||!n)return;let t=[];a.getEnabled().forEach(r=>{if(!r||null!=r&&r.disabled)return;let s=o.get(r.id);if(s)switch(e.code){case i.vL.Down:n.top<s.top&&t.push(r);break;case i.vL.Up:n.top>s.top&&t.push(r);break;case i.vL.Left:n.left>s.left&&t.push(r);break;case i.vL.Right:n.left<s.left&&t.push(r)}});let m=(0,i.y$)({active:r,collisionRect:n,droppableRects:o,droppableContainers:t,pointerCoordinates:null}),f=(0,i.Vy)(m,"id");if(f===(null==l?void 0:l.id)&&m.length>1&&(f=m[1].id),null!=f){let e=a.get(r.id),t=a.get(f),l=t?o.get(t.id):null,m=null==t?void 0:t.node.current;if(m&&l&&e&&t){var c,u;let r=(0,i.sl)(m).some((e,t)=>d[t]!==e),o=S(e,t),a=(c=e,u=t,!!j(c)&&!!j(u)&&!!S(c,u)&&c.data.current.sortable.index<u.data.current.sortable.index),f=r||!o?{x:0,y:0}:{x:a?n.width-l.width:0,y:a?n.height-l.height:0},h={x:l.left,y:l.top};return f.x&&f.y?h:(0,s.Re)(h,f)}}}};function S(e,t){return!!j(e)&&!!j(t)&&e.data.current.sortable.containerId===t.data.current.sortable.containerId}},20237:(e,t,r)=>{"use strict";r.d(t,{s:()=>a});var n=r(6029),i=r(50800),s=r(69849),o=r(70934);function a({code:e,setCode:t}){return(0,n.jsx)(i.A,{sx:{"& .block-picker":{boxShadow:"none !important",borderRadius:"0 !important"},"& input":{textAlign:"center",padding:"1.5rem !important",display:"block !important",fontSize:"16px !important"}},children:(0,n.jsx)(s.kH,{color:e,onChange:e=>{t(e.hex)},triangle:"hide",width:"100%",colors:o.t0})})}},22498:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>s});var n=r(854),i=r(6029);let s=(0,n.A)((0,i.jsx)("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2M9 17H7v-5h2zm4 0h-2v-3h2zm0-5h-2v-2h2zm4 5h-2V7h2z"}),"Analytics")},37269:(e,t,r)=>{"use strict";r.d(t,{o:()=>l});var n=r(20466),i=r(96358),s=r(36607),o=r(95583),a=r(31560);function l(e,t,r){let l,[d,c]=(0,s.x)(r?.in,e,t),u=(0,i.q)(),m=r?.locale??u.locale??n.c,f=r?.weekStartsOn??r?.locale?.options?.weekStartsOn??u.weekStartsOn??u.locale?.options?.weekStartsOn??0,h=(0,o.m)(d,c);if(isNaN(h))throw RangeError("Invalid time value");l=h<-6?"other":h<-1?"lastWeek":h<0?"yesterday":h<1?"today":h<2?"tomorrow":h<7?"nextWeek":"other";let p=m.formatRelative(l,d,c,{locale:m,weekStartsOn:f});return(0,a.GP)(d,p,{locale:m,weekStartsOn:f})}},37913:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});var n=r(854),i=r(6029);let s=(0,n.A)((0,i.jsx)("path",{d:"M16.56 8.94 7.62 0 6.21 1.41l2.38 2.38-5.15 5.15c-.59.59-.59 1.54 0 2.12l5.5 5.5c.29.29.68.44 1.06.44s.77-.15 1.06-.44l5.5-5.5c.59-.58.59-1.53 0-2.12M5.21 10 10 5.21 14.79 10zM19 11.5s-2 2.17-2 3.5c0 1.1.9 2 2 2s2-.9 2-2c0-1.33-2-3.5-2-3.5M2 20h20v4H2z"}),"FormatColorFill")},45802:(e,t,r)=>{"use strict";r.d(t,{A:()=>d});
1var n=r(6029),i=r(96902),s=r(81278),o=r(55729),a=r(71184),l=r(24192);function d(e){let{query:t}=(0,s.useRouter)(),r=t.network,d=Array.isArray(r)?r[0]:r??"",c=(0,a.Es)(e=>e.user),u=(0,a.Es)(e=>e.profile),m=(0,a.Es)(e=>e.network),[f,h]=o.useState(!1),{Component:p,...g}=e,x=e.auth??(!0!==e.noAuthForPublicNetwork||!m?.public),y=!!e.noAuthForPublicNetwork&&!m,v={...g,isLoading:y},A=m&&(c&&u?{auth:!0,user:c,profile:u,network:m}:{auth:!1,network:m}),j=(0,o.useRef)(void 0);A&&(j.current=A);let b=j.current;return o.useEffect(()=>{h(m?.slug!==d)},[m?.slug,d]),(0,n.jsx)(l.A,{...v,auth:x,children:b&&!f?(0,n.jsx)(p,{...b}):(0,n.jsx)(i.A,{})})}d.defaultProps={...l.G,auth:void 0}},47645:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>eX});var n=r(6029),i=r(20602),s=r(74796),o=r(7758),a=r(12657),l=r(2779),d=r(70047),c=r(17358),u=r(80118),m=r(854);let f=(0,m.A)((0,n.jsx)("path",{d:"M3 10h11v2H3zm0-2h11V6H3zm0 8h7v-2H3zm15.01-3.13.71-.71c.39-.39 1.02-.39 1.41 0l.71.71c.39.39.39 1.02 0 1.41l-.71.71zm-.71.71-5.3 5.3V21h2.12l5.3-5.3z"}),"EditNote"),h=(0,m.A)((0,n.jsx)("path",{d:"M3 10h11v2H3zm0-4h11v2H3zm0 8h7v2H3zm17.59-2.07-4.25 4.24-2.12-2.12-1.41 1.41L16.34 19 22 13.34z"}),"PlaylistAddCheck"),p=(0,m.A)((0,n.jsx)("path",{d:"M22 7h-9v2h9zm0 8h-9v2h9zM5.54 11 2 7.46l1.41-1.41 2.12 2.12 4.24-4.24 1.41 1.41zm0 8L2 15.46l1.41-1.41 2.12 2.12 4.24-4.24 1.41 1.41z"}),"Checklist"),g=(0,m.A)((0,n.jsx)("path",{d:"M4.59 6.89c.7-.71 1.4-1.35 1.71-1.22.5.2
10 1.03-.3 1.52-.25.42-2.86 3.89-2.86 6.31 0 1.28.48 2.34 1.34 2.98.75.56 1.74.73 2.64.46 1.07-.31 1.95-1.4 3.06-2.77 1.21-1.49 2.83-3.44 4.08-3.44 1.63 0 1.65 1.01 1.76 1.79-3.78.64-5.38 3.67-5.38 5.37s1.44 3.09 3.21 3.09c1.63 0 4.29-1.33 4.69-6.1H21v-2.5h-2.47c-.15-1.65-1.09-4.2-4.03-4.2-2.25 0-4.18 1.91-4.94 2.84-.58.73-2.06 2.48-2.29 2.72-.25.3-.68.84-1.11.84-.45 0-.72-.83-.36-1.92.35-1.09 1.4-2.86 1.85-3.52.78-1.14 1.3-1.92 1.3-3.28C8.95 3.69 7.31 3 6.44 3 5.12 3 3.97 4 3.72 4.25c-.36.36-.66.66-.88.93zm9.29 11.66c-.31 0-.74-.26-.74-.72 0-.6.73-2.2 2.87-2.76-.3 2.69-1.43 3.48-2.13 3.48"}),"Gesture");var x=r(12470),y=r(94574);let v=(0,m.A)((0,n.jsx)("path",{d:"M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9m-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8z"}),"Restore");var A=r(8461),j=r(98770),b=r(95444),w=r(22498),S=r(52861),C=r(56188),I=r(50800),k=r(59716),D=r(96902),E=r(86800),$=r(77620),q=r(99798),R=r(66129),z=r(67224),T=r(65668),U=r(56972),P=r(62100),M=r(51149),N=r(16276),F=r(66172),H=r(61263),L=r(28862),O=r(16851),J=r(66860),_=r(32965),V=r(91783),W=r(37269),Z=r(61489),B=r(68997),G=r(82203),Q=r.n(G),Y=r(81278),X=r(55729),K=r(73858),ee=r(45802),et=r(24223),er=r(78035),en=r(27388),ei=r(72877),es=r(2670),eo=r(81540),ea=r(49637),el=r(84287),ed=r(30042),ec=r(95816),eu=r.n(ec),em=r(35792),ef=r(68485),eh=r(71184),ep=r(91681),eg=r(67970),ex=r(45791),ey=r(71891);function ev({isOpen:e,onClose:t,form:r}){let a=(0,eh.VG)(),l=(0,eh.UY)(),[d,c]=(0,X.useState)([]),[u,m]=(0,X.useState)([]),[f,h]=(0,X.useState)([]),p=async()=>{let e;if(!l||!a||(h(e=[...eu()(d)&&eu()(u)?["Please select at least one group or user to assign the form to"]:[]]),e).length>0)return!1;let n=new Date,c=(0,Z.wP)(r.ref.firestore),m=e=>({date:n,status:s.DocStatuses.Active,description:e,actor:(0,o.ay)(l)}),f=[],p=[];for(let e of d){let t=(0,Z.H9)(r.ref,"formAssignments",`profile_${e.id}`).withConverter(ef.m.formAssignment.write),i={createdAt:n,formId:r.id,formRef:r.ref,formName:r.name,assignedAt:n,assignedBy:(0,o.ay)(l),target:{type:"profile",profile:(0,o.ay)(e),profileId:e.id},latestDocUpdate:m(`${l.name} assigned form ${r.name} to ${e.name}`)};c.set(t,i,{merge:!0}),f.push({ref:t,assignedProfile:e})}for(let e of u){let t=(0,Z.H9)(r.ref,"formAssignments",`group_${e.id}`).withConverter(ef.m.formAssignment.write),i=(0,Z.H9)((0,Z.rJ)(a.ref,"feedPosts")).withConverter(ef.m.feedPost.write),s=new URLSearchParams({postId:i.id,feedId:e.id,feedType:"group"}),d=m(`${l.name} assigned form ${r.name} to group ${e.name}`),u={createdAt:n,formId:r.id,formRef:r.ref,formName:r.name,assignedAt:n,assignedBy:(0,o.ay)(l),target:{type:"group",group:e,groupId:e.id},latestDocUpdate:m(`${l.name} assigned form ${r.name} to group ${e.name}`)},f={createdAt:n,url:`${(0,ep.Ug)(a.slug,e.slug)}?${s.toString()}`,network:(0,ei.b)(a),feedType:"group",newsfeedId:e.id,parentPostId:null,rootPostId:null,date:n,sticky:!1,title:"",description:`<p>${l.name} assigned the form <a href="${(0,ep.Er)(a.slug,r.slug)}"><strong>${r.name}</strong></a> to ${e.name}.</p><converge-form formid="${r.id}"></converge-form>`,avatar:l.photoURL||"",profile:(0,o.ay)(l),latestDocUpdate:d,postType:er.wz.Message,group:(0,en.cf)(e)};c.set(t,u,{merge:!0}),c.set(i,f),p.push({ref:t,group:e})}await c.commit();let g=(0,i.xl)();return await Promise.all([...f.map(({ref:e,assignedProfile:t})=>(0,em.I)({network:a,profile:l,traceId:g,action:i.Jb.created,entityType:i.uE.formAssignment,entityRef:e,entityName:`${r.name} â ${t.name}`,entityUrl:(0,ep.Er)(a.slug,r.slug),description:`${l.name} assigned form "${r.name}" to ${t.name}`,actorDescription:"web client form assign flow",data:{formId:r.id,formSlug:r.slug,target:"profile",profileId:t.id}})),...p.map(({ref:e,group:t})=>(0,em.I)({network:a,profile:l,traceId:g,action:i.Jb.created,entityType:i.uE.formAssignment,entityRef:e,entityName:`${r.name} â ${t.name}`,entityUrl:(0,ep.Er)(a.slug,r.slug),description:`${l.name} assigned form "${r.name}" to group ${t.name}`,actorDescription:"web client form assign flow",data:{formId:r.id,formSlug:r.slug,target:"group",groupId:t.id}}))]),t(),!0};return(0,n.jsxs)(es.A,{maxWidth:"md",fullWidth:!0,open:e,onClose:t,children:[(0,n.jsxs)(eo.A,{children:['Assign "',r.name,'" Form']}),(0,n.jsxs)(ea.A,{children:[(0,n.jsxs)(T.A,{spacing:2,children:[a&&(0,n.jsx)(I.A,{children:(0,n.jsx)(ey.A,{sx:{width:"100%"},label:"Assign to Users",variant:"outlined",network:a,multiple:!0,selected:d,onUserSelected:c})}),(0,n.jsx)(I.A,{children:(0,n.jsx)(ex.A,{initSelected:u,onSetGroups:e=>m(e||[]),multiple:!0,required:!1,label:"Assign to Groups"})})]}),f.length>0&&(0,n.jsxs)(J.A,{severity:"error",sx:{width:"100%",mt:2},children:[(0,n.jsx)(el.A,{children:"Couldn't assign form"}),(0,n.jsx)("ul",{children:f.map(e=>(0,n.jsx)("li",{children:e},e))})]})]}),(0,n.jsxs)(ed.A,{children:[(0,n.jsx)(M.A,{onClick:t,children:"Cancel"}),(0,n.jsx)(eg.n,{startIcon:(0,n.jsx)(b.A,{}),variant:"contained",color:"primary",successMessage:()=>"Form assigned successfully!",handleSubmit:p,children:"Assign Form"})]})]})}var eA=r(22144),ej=r(86650),eb=r(12364),ew=r.n(eb),eS=r(31170),eC=r(60526),eI=r(18858),ek=r(70934);let eD={borderTopLeftRadius:e=>e.shape.borderRadius,borderTopRightRadius:e=>e.shape.borderRadius,borderBottomLeftRadius:0,borderBottomRightRadius:0,overflow:"hidden"},eE=(0,X.forwardRef)(function({form:e,network:t,questionCount:r,canEditForms:o,isEditing:a,onSaveStarted:l,onSaveSucceeded:d},c){let u=(0,eh.UY)(),m=(0,eh.En)(),f=(0,X.useRef)(l),h=(0,X.useRef)(d);f.current=l,h.current=d;let p=e.backgroundColor||ek.t0[0],g=e.latestDocUpdate.status,[x,y]=(0,X.useState)(e.name),[v,A]=(0,X.useState)(e.description??""),j=g===s.DocStatuses.Published,b=g===s.DocStatuses.Draft,w=g===s.DocStatuses.Deleted,S=async r=>{f.current?.(),await (0,Z.mZ)(e.ref,{photoUrls:r}),h.current?.(),u&&await (0,em.I)({network:t,profile:u,action:i.Jb.updated,entityType:i.uE.form,entityRef:e.ref,entityName:e.n
1ame,entityUrl:(0,ep.Er)(t.slug,e.slug),description:`${u.name} updated cover image on form "${e.name}"`,actorDescription:"web client form header",data:{field:"photoUrls",photoUrls:r}})},C=async r=>{f.current?.(),await (0,Z.mZ)(e.ref,{backgroundColor:r}),h.current?.(),u&&await (0,em.I)({network:t,profile:u,action:i.Jb.updated,entityType:i.uE.form,entityRef:e.ref,entityName:e.name,entityUrl:(0,ep.Er)(t.slug,e.slug),description:`${u.name} updated cover color on form "${e.name}"`,actorDescription:"web client form header",data:{field:"backgroundColor",before:e.backgroundColor,after:r}})},k=(0,X.useMemo)(()=>ew()(async r=>{let n=r.trim();if(!u||!n||n===e.name)return;let s=e.name;f.current?.(),await (0,Z.mZ)(e.ref,{name:n}),h.current?.(),await (0,em.I)({network:t,profile:u,action:i.Jb.updated,entityType:i.uE.form,entityRef:e.ref,entityName:n,entityUrl:(0,ep.Er)(t.slug,e.slug),description:`${u.name} renamed form "${s}" to "${n}"`,actorDescription:"web client form header",data:{field:"name",before:s,after:n}})},600),[e.ref,e.name,e.slug,t,u]),D=(0,X.useMemo)(()=>ew()(async r=>{u&&r!==(e.description??"")&&(f.current?.(),await (0,Z.mZ)(e.ref,{description:r}),h.current?.(),await (0,em.I)({network:t,profile:u,action:i.Jb.updated,entityType:i.uE.form,entityRef:e.ref,entityName:e.name,entityUrl:(0,ep.Er)(t.slug,e.slug),description:`${u.name} updated description on form "${e.name}"`,actorDescription:"web client form header",data:{field:"description"}}))},600),[e.ref,e.name,e.slug,e.description,t,u]);return(0,X.useEffect)(()=>()=>{k.flush(),D.flush()},[k,D]),(0,X.useImperativeHandle)(c,()=>({async flushPendingSaves(){await Promise.all([k.flush(),D.flush()])},getDraftName:()=>x}),[x,k,D]),(0,n.jsxs)(H.A,{sx:{p:0,...eD},children:[(0,n.jsx)(I.A,{minHeight:300,mb:3,position:"relative",display:"flex",children:(0,n.jsx)(eC._,{sx:eD,title:e.name,url:e.photoUrls?.[0]??"",color:p,onColorUpdate:e=>{C(e)},onImageUpdate:e=>{S(e)},isEditing:o&&a})}),(0,n.jsxs)(F.A,{sx:{pb:3},children:[(0,n.jsxs)(T.A,{direction:{xs:"column",sm:"row"},justifyContent:"space-between",alignItems:{xs:"flex-start",sm:"center"},gap:1,children:[(0,n.jsx)(M.A,{component:Q(),href:(0,ep.Ht)(t.slug),startIcon:(0,n.jsx)(eA.A,{}),size:"small",color:"inherit",sx:{color:"text.secondary"},children:"All forms"}),(0,n.jsxs)(T.A,{direction:"row",spacing:1,alignItems:"center",children:[(m||!j)&&(0,n.jsx)(ej.A,{size:"small",label:j?"Published":w?"Deleted":b?"Draft":g,color:j?"primary":"secondary"}),(0,n.jsxs)(N.A,{variant:"body2",color:"text.secondary",children:[r," ",1===r?"question":"questions"]})]})]}),(0,n.jsxs)(T.A,{sx:{mt:2},spacing:1,children:[(0,n.jsx)(eI.A,{fieldType:eI.y.Text,label:"Form name",value:x,isEditing:o&&a,onChange:e=>{"string"==typeof e&&(y(e),k(e))},helperText:o&&a&&!x.trim()?"Not saved â form name is required.":void 0,textFieldSx:{"& .MuiInputBase-input":{fontSize:"2rem",fontWeight:700,lineHeight:1.15}},displayValue:(0,n.jsx)(N.A,{variant:"h3",sx:{fontWeight:700,lineHeight:1.15},children:e.name})}),(0,n.jsx)(eI.A,{fieldType:eI.y.Html,label:"Description",value:v,isEditing:o&&a,minimalControls:!0,onChange:e=>{"string"==typeof e&&(A(e),D(e))},displayValue:e.description?(0,n.jsx)(I.A,{sx:{color:"text.secondary","& p":{m:0}},children:(0,n.jsx)(eS._,{html:e.description})}):(0,n.jsx)(N.A,{variant:"body2",color:"text.disabled",fontStyle:"italic",children:"No description"})})]})]})]})});var e$=r(36247),eq=r(52123);function eR({form:e,network:t}){let r=(0,eh.UY)(),[i,s]=(0,X.useState)(e.reviewers??[]),[a,l]=(0,X.useState)(!1),[d,c]=(0,X.useState)(),u=(0,X.useRef)(0);(0,X.useEffect)(()=>{a||s(e.reviewers??[])},[e.reviewers,a]);let m=async t=>{let n=(0,e$.US)(t),i=u.current+1;u.current=i,s(n),l(!0),c(void 0);try{if(!r)throw Error("Your profile is still loading.");let t={date:new Date,status:e.latestDocUpdate.status,description:`${r.name} updated reviewers for ${e.name}`,actor:(0,o.ay)(r)};await (0,Z.mZ)(e.ref,{reviewers:n,reviewerIds:n.map(({id:e})=>e),latestDocUpdate:t,"latestDocUpdate.date":(0,Z.O5)()})}catch(t){if(i!==u.current)return;s(e.reviewers??[]),c(t instanceof Error?t.message:"Could not save reviewers."),(0,eq.Tj)({severity:"error",message:"Could not save reviewers"})}finally{i===u.current&&l(!1)}};return(0,n.jsxs)(T.A,{spacing:1,children:[(0,n.jsx)(N.A,{variant:"h6",children:"Form Reviewers"}),(0,n.jsx)(ey.A,{label:"Form Reviewers",helperText:e$.ej,network:t,multiple:!0,selected:i,onUserSelected:e=>{m(e)}}),a&&(0,n.jsx)(N.A,{variant:"caption",color:"text.secondary",children:"Saving reviewersâ¦"}),d&&(0,n.jsx)(J.A,{severity:"error",children:d})]})}var ez=r(83233),eT=r(98696),eU=r(73041),eP=r(10028),eM=r(62545),eN=r(32782),eF=r(96785),eH=r(94427),eL=r(68307),eO=r(36780),eJ=r(95634);function e_(e,t){return(0,a.cC)(e)||(0,a.Sj)(e)?{...e,choices:t}:e}function eV({index:e,total:t,question:r,onChange:i,onMoveUp:s,onMoveDown:o,onDelete:l,isCompact:d=!1,validationErrors:c,dragHandle:u}
1){let[m,f]=(0,X.useState)(r.input),[h,p]=(0,X.useState)(r.required),g=(0,X.useRef)(new Map),x=(0,eO.a)(),y=(0,eJ.QZ)(m.questionHtml),[v,j]=(0,X.useState)(()=>!!y),b=v&&!!c?.length,w=e=>{f(e),i({input:e})};return(0,n.jsx)(H.A,{variant:"outlined",sx:{p:{xs:2,md:3},"&:hover .question-handle":{opacity:1}},children:(0,n.jsxs)(T.A,{spacing:2,children:[(0,n.jsxs)(T.A,{direction:"row",alignItems:"center",spacing:1,children:[(0,n.jsx)(I.A,{className:"question-handle",ref:u?.setActivatorNodeRef,...u?.attributes,...u?.listeners,sx:{display:"inline-flex",opacity:{xs:.6,md:.4},transition:"opacity 120ms ease",cursor:u?"grab":"default",touchAction:"none"},children:(0,n.jsx)(ez.A,{fontSize:"small"})}),(0,n.jsx)(eN.A,{sx:{width:24,height:24,fontSize:"0.75rem",bgcolor:"action.selected",color:"text.secondary",fontVariantNumeric:"tabular-nums"},children:e+1}),(0,n.jsx)(I.A,{sx:{flex:1}}),(0,n.jsx)(eF.A,{select:!0,size:"small",value:m.type,onChange:e=>{var t;(t=e.target.value)===m.type||w({...(0,eJ.Tf)(t),questionHtml:m.questionHtml})},sx:{minWidth:{xs:0,sm:180},flexShrink:1},children:Object.entries(eJ.Kw).map(([e,t])=>(0,n.jsx)(O.A,{value:e,children:t},e))}),!x&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(U.A,{title:"Move up",children:(0,n.jsx)("span",{children:(0,n.jsx)(P.A,{size:"small",onClick:s,disabled:0===e,children:(0,n.jsx)(eT.A,{fontSize:"small"})})})}),(0,n.jsx)(U.A,{title:"Move down",children:(0,n.jsx)("span",{children:(0,n.jsx)(P.A,{size:"small",onClick:o,disabled:e===t-1,children:(0,n.jsx)(eU.A,{fontSize:"small"})})})})]}),(0,n.jsx)(U.A,{title:"Delete question",children:(0,n.jsx)(P.A,{size:"small",color:"error",onClick:l,children:(0,n.jsx)(A.A,{fontSize:"small"})})})]}),d?(0,n.jsx)(N.A,{variant:"body2",color:"text.secondary",children:y||"Untitled question"}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eL.A,{initialHtml:m.questionHtml,onChange:e=>{v||j(!0),w({...m,questionHtml:e})},placeholder:"Ask a clear, friendly question...",isFormEmbedDisabled:!0,disableStickyMenuBar:!0}),b&&c&&(0,n.jsxs)(J.A,{severity:"warning",variant:"outlined",children:["Not saved â"," ",c.map(e=>e.toLowerCase()).join(" ")]}),((0,a.cC)(m)||(0,a.Sj)(m))&&(0,n.jsxs)(T.A,{spacing:1,children:[m.choices.map((e,t)=>(0,n.jsxs)(T.A,{direction:"row",spacing:1,alignItems:"center",children:[(0,n.jsxs)(N.A,{variant:"body2",color:"text.disabled",sx:{width:24,flexShrink:0,textAlign:"right",fontVariantNumeric:"tabular-nums"},children:[t+1,"."]}),(0,n.jsx)(eF.A,{fullWidth:!0,size:"small",value:e.label,inputRef:t=>{t?g.current.set(e.id,t):g.current.delete(e.id)},onChange:r=>{let n=[...m.choices];n[t]={...e,label:r.target.value},w(e_(m,n))},placeholder:`Option ${t+1}`}),(0,n.jsx)(U.A,{title:"Remove option",children:(0,n.jsx)("span",{children:(0,n.jsx)(P.A,{size:"small",disabled:m.choices.length<=2,onClick:()=>{let e=m.choices.filter((e,r)=>r!==t);w(e_(m,e))},children:(0,n.jsx)(eP.A,{fontSize:"small"})})})})]},e.id)),(0,n.jsx)(I.A,{children:(0,n.jsx)(M.A,{variant:"text",startIcon:(0,n.jsx)(eM.A,{}),onClick:()=>{let e={id:(0,eJ.je)(),label:""},t=[...m.choices,e];w(e_(m,t)),requestAnimationFrame(()=>{g.current.get(e.id)?.focus()})},children:"Add option"})})]}),(0,a.EL)(m)&&(0,n.jsx)(N.A,{variant:"body2",color:"text.secondary",children:"Respondents will see a multi-line text field."}),(0,a.re)(m)&&(0,n.jsx)(eF.A,{label:"Signature label",size:"small",value:m.signatureLabel??"",placeholder:"Signature",onChange:e=>w({...m,signatureLabel:e.target.value}),sx:{maxWidth:320}}),(0,n.jsx)(_.A,{control:(0,n.jsx)(eH.A,{checked:h,onChange:e=>{p(e.target.checked),i({required:e.target.checked})}}),label:"Required"})]})]})})}var eW=r(35752),eZ=r(20900),eB=r(66054);let eG=[{type:a.gx.Written,label:"Written answer",icon:f},{type:a.gx.SingleChoice,label:"Single choice",icon:h},{type:a.gx.MultipleChoice,label:"Multiple choice",icon:p},{type:a.gx.Signature,label:"Signature",icon:g}];function eQ({question:e,index:t,total:r,isCompact:i,validationErrors:s,onChange:o,onMoveUp:a,onMoveDown:l,onDelete:d}){let{attributes:m,listeners:f,setActivatorNodeRef:h,setNodeRef:p,transform:g,transition:x,isDragging:y}=(0,c.gl)({id:e.id});return(0,n.jsx)(I.A,{ref:p,sx:{transform:u.Ks.Transform.toString(g),transition:x,opacity:y?.6:1},children:(0,n.jsx)(eV,{question:e,index:t,total:r,isCompact:i,validationErrors:s,dragHandle:{attributes:m,listeners:f,
1setActivatorNodeRef:h},onChange:o,onMoveUp:a,onMoveDown:l,onDelete:d})})}function eY(){let e=(0,k.A)(),t=(0,eO.a)(),r=(0,Y.useRouter)(),a=(0,eh.VG)(),u=(0,eh.UY)(),m=(0,eh.En)(),f="string"==typeof r.query.slug?r.query.slug:"",{form:h,isLoading:p}=(0,eZ.mN)(f),{questions:g,isLoading:G}=(0,eZ.Vd)(h),{canPerform:ee}=(0,eB.J)(l.P.formsCreateEdit),{canPerform:er}=(0,eB.J)(l.P.formsPublish),{canPerform:en}=(0,eB.J)(l.P.formsAssign),{canPerform:ei}=(0,eB.J)(l.P.formsAnalyze),{canPerform:es}=(0,eB.J)(l.P.formsArchive),[eo,ea]=(0,X.useState)(!1),[el,ed]=(0,X.useState)(!1),[ec,eu]=(0,X.useState)(!1),[eg,ex]=(0,X.useState)(null),[ey,eA]=(0,X.useState)({}),[ej,eb]=(0,X.useState)(null),ew="1"===r.query.edit&&ee,eS=(0,d.FR)((0,d.MS)(d.AN,{activationConstraint:{distance:8}})),eC=(0,X.useRef)(null),eI=(0,X.useRef)(0),ek=(0,X.useRef)(!1),[eD,ez]=(0,X.useState)(!1),[eT,eU]=(0,X.useState)(),eP=()=>{eI.current+=1,ez(!0)},eM=()=>{eI.current=Math.max(0,eI.current-1),eU(new Date),0===eI.current&&ez(!1)},eN=()=>{eI.current=Math.max(0,eI.current-1),ek.current||(ek.current=!0,(0,eq.Tj)({severity:"error",message:"Couldn't save your latest change. You may not have permission to edit this form, or your connection dropped. Try again."})),0===eI.current&&(ez(!1),ek.current=!1)},{queue:eF,flush:eH}=function(e=600,t={}){let r=(0,X.useRef)(new Map),n=(0,X.useRef)(t);n.current=t;let i=(0,X.useCallback)(async()=>{let e=r.current;if(0===e.size)return;n.current.onPending?.();let t=[];for(let[,r]of e)clearTimeout(r.timer),t.push((0,Z.mZ)(r.ref,r.data).catch(e=>{n.current.onError?.(e)}));e.clear(),await Promise.all(t),n.current.onSaved?.(new Date)},[]),s=(0,X.useCallback)(()=>{i()},[i]);return(0,X.useEffect)(()=>{let e=()=>{"hidden"===document.visibilityState&&s()};return window.addEventListener("beforeunload",s),document.addEventListener("visibilitychange",e),()=>{window.removeEventListener("beforeunload",s),document.removeEventListener("visibilitychange",e),s()}},[s]),{queue:(0,X.useCallback)((t,i,s)=>{let o=r.current,a=o.get(t);a?clearTimeout(a.timer):n.current.onPending?.();let l={...a?.data??{},...s},d=setTimeout(async()=>{o.delete(t);try{await (0,Z.mZ)(i,l),n.current.onSaved?.(new Date)}catch(e){n.current.onError?.(e)}},e);
1o.set(t,{ref:i,data:l,timer:d})},[e]),flush:i}}(600,{onPending:eP,onSaved:eM,onError:eN}),eL=g.map(e=>{let t=ey[e.id];return{...e,...t,input:t?.input??e.input,required:t?.required??e.required}}),e_=new Map(eL.map(e=>[e.id,(0,eJ.bE)(e)])),eV=async({notify:e=!0}={})=>(await Promise.all([eH(),eC.current?.flushPendingSaves()]),e&&(0,eq.Tj)({message:"Draft saved"}),!0),eY=async e=>{if(!h||!u||!a)return;ex(null);let t=(0,Z.H9)((0,Z.rJ)(h.ref,"formQuestions")).withConverter(ef.m.formQuestion.write),r=new Date,n={date:r,status:s.DocStatuses.Active,description:`${u.name} added a form question`,actor:(0,o.ay)(u)},l={createdAt:r,createdBy:(0,o.ay)(u),input:(0,eJ.Tf)(e),required:!1,latestDocUpdate:n},d=(0,Z.wP)(h.ref.firestore);d.set(t,l),d.update(h.ref,{questionOrder:(0,Z.hq)(t.id)}),await d.commit(),await (0,em.I)({network:a,profile:u,action:i.Jb.created,entityType:i.uE.formQuestion,entityRef:t,entityName:`${h.name} question`,entityUrl:`${(0,ep.Er)(a.slug,h.slug)}?edit=1`,description:`${u.name} added a ${e} question to form "${h.name}"`,actorDescription:"web client form builder",data:{questionType:e,formId:h.id,formSlug:h.slug}})},eX=async(e,t)=>{if(!h||!u||!a)return;let r=[...h.questionOrder??[]],n=r.indexOf(e);if(n<0)return;let s="up"===t?n-1:n+1;if(!(s<0)&&!(s>=r.length)){[r[n],r[s]]=[r[s],r[n]],eP();try{await (0,Z.mZ)(h.ref,{questionOrder:r}),eM()}catch(t){eN();let e=t instanceof Error?t.message:"Unknown error";(0,eq.Tj)({severity:"error",message:`Failed to reorder questions: ${e}`});return}await (0,em.I)({network:a,profile:u,action:i.Jb.updated,entityType:i.uE.formQuestion,entityRef:(0,Z.H9)(h.ref,"formQuestions",e),entityName:`${h.name} question`,entityUrl:`${(0,ep.Er)(a.slug,h.slug)}?edit=1`,description:`${u.name} reordered a question on form "${h.name}" (${t})`,actorDescription:"web client form builder",data:{formId:h.id,formSlug:h.slug,direction:t,questionId:e,order:r}})}},eK=async(e,t,r)=>{if(!h||!u||!a||t===r)return;let n=(0,c.be)(h.questionOrder??[],t,r);eP();try{await (0,Z.mZ)(h.ref,{questionOrder:n}),eM()}catch(t){eN();let e=t instanceof Error?t.message:"Unknown error";(0,eq.Tj)({severity:"error",message:`Failed to reorder questions: ${e}`});return}await (0,em.I)({network:a,profile:u,action:i.Jb.updated,entityType:i.uE.formQuestion,entityRef:(0,Z.H9)(h.ref,"formQuestions",e),entityName:`${h.name} question`,entityUrl:`${(0,ep.Er)(a.slug,h.slug)}?edit=1`,description:`${u.name} reordered a question on form "${h.name}"`,actorDescription:"web client form builder drag and drop",data:{formId:h.id,formSlug:h.slug,questionId:e,oldIndex:t,newIndex:r,order:n}})},e0=async e=>{let t=String(e.active.id),r=e.over?String(e.over.id):null;if(eb(null),!r||t===r)return;let n=eL.findIndex(e=>e.id===t),i=eL.findIndex(e=>e.id===r);n<0||i<0||await eK(t,n,i)},e1=async e=>{if(!h||!u||!a)return;let t=(0,Z.H9)(h.ref,"formQuestions",e),r=(0,Z.wP)(h.ref.firestore);r.delete(t);let n=1===eL.length&&eL[0]?.id===e,l=h.latestDocUpdate.status===s.DocStatuses.Published,d=n&&l;if(d){let t={date:new Date,status:s.DocStatuses.Draft,description:`${h.name} reverted to draft after the last question was deleted`,actor:(0,o.ay)(u)};r.update(h.ref,{questionOrder:(0,Z.C3)(e),latestDocUpdate:t})}else r.update(h.ref,{questionOrder:(0,Z.C3)(e)});await r.commit(),eA(t=>{let r={...t};return delete r[e],r}),await (0,em.I)({network:a,profile:u,action:i.Jb.deleted,entityType:i.uE.formQuestion,entityRef:t,entityName:`${h.name} question`,entityUrl:`${(0,ep.Er)(a.slug,h.slug)}?edit=1`,description:`${u.name} deleted a question on form "${h.name}"`,actorDescription:"web client form builder",data:{formId:h.id,formSlug:h.slug,questionId:e}}),d&&(await (0,em.I)({network:a,profile:u,action:i.Jb.unpublished,entityType:i.uE.form,entityRef:h.ref,entityName:h.name,entityUrl:(0,ep.Er)(a.slug,h.slug),description:`Form "${h.name}" was reverted to draft because its last question was deleted`,actorDescription:"web client form builder auto-revert",data:{formId:h.id,formSlug:h.slug,version:h.version,reason:"last_question_deleted"}}),(0,eq.Tj)({severity:"info",message:"Form reverted to draft (no questions remaining)"}))}
1,e2=async()=>{var e;h&&u&&a&&(0!==(e=(0,eJ.Wc)({name:eC.current?.getDraftName()??h.name,questions:eL})).length&&((0,eq.Tj)({severity:"error",title:"Couldn't publish form",message:e.join("\n")}),1)||await eV({notify:!1})&&(await (0,Z.mZ)(h.ref,{latestDocUpdate:{date:new Date,status:s.DocStatuses.Published,description:`${u.name} published form ${h.name}`,actor:(0,o.ay)(u)}}),await (0,em.I)({network:a,profile:u,action:i.Jb.published,entityType:i.uE.form,entityRef:h.ref,entityName:h.name,entityUrl:(0,ep.Er)(a.slug,h.slug),description:`${u.name} published form "${h.name}"`,actorDescription:"web client form publish flow",data:{formId:h.id,formSlug:h.slug,version:h.version}}),(0,eq.Tj)({message:"Form published"})))},e3=async()=>{h&&u&&a&&(await (0,Z.mZ)(h.ref,{latestDocUpdate:{date:new Date,status:s.DocStatuses.Draft,description:`${u.name} reverted form ${h.name} to draft`,actor:(0,o.ay)(u)}}),await (0,em.I)({network:a,profile:u,action:i.Jb.unpublished,entityType:i.uE.form,entityRef:h.ref,entityName:h.name,entityUrl:(0,ep.Er)(a.slug,h.slug),description:`${u.name} reverted form "${h.name}" to draft`,actorDescription:"web client form unpublish flow",data:{formId:h.id,formSlug:h.slug,version:h.version}}),(0,eq.Tj)({message:"Form reverted to draft"}))},e9=async()=>{h&&u&&a&&(await (0,Z.mZ)(h.ref,{latestDocUpdate:{date:new Date,status:s.DocStatuses.Draft,description:`${u.name} restored form ${h.name}`,actor:(0,o.ay)(u)}}),await (0,em.I)({network:a,profile:u,action:i.Jb.updated,entityType:i.uE.form,entityRef:h.ref,entityName:h.name,entityUrl:(0,ep.Er)(a.slug,h.slug),description:`${u.name} restored form "${h.name}"`,actorDescription:"web client form restore flow",data:{formId:h.id,formSlug:h.slug,version:h.version}}),(0,eq.Tj)({message:"Form restored"}))},e6=async()=>{if(!h||!a)return;let e=(0,B.Qg)((0,B.Uz)(),"forms-deleteForm");await e({networkPath:a.ref.path,formId:h.id,hardDelete:ec})};if(p)return(0,n.jsx)(D.A,{});if(!h||!a)return(0,n.jsx)(et.A,{title:"404",children:"Form not found"});let e4=h.latestDocUpdate.status,e5=e4===s.DocStatuses.Published,e7=e4===s.DocStatuses.Deleted,e8=ew&&!e7,te=!!u&&(h.ownerIds?.includes(u.id)??!1),tt=er||ee&&te,tr=(0,e$.Yq)({form:h,profileId:u?.id,canAnalyzeAllForms:!!ei,isNetworkAdmin:!!m});return(0,n.jsxs)(I.A,{children:[(0,n.jsx)(eE,{ref:eC,form:h,network:a,questionCount:g.length,canEditForms:ee,isEditing:e8,onSaveStarted:eP,onSaveSucceeded:eM},h.id),(0,n.jsx)(E.A,{position:"sticky",color:"default",elevation:0,sx:{top:0,borderBottom:1,borderColor:"divider",backgroundColor:(0,$.X4)(e.palette.background.paper,.92),backdropFilter:"blur(6px)"}
1,children:(0,n.jsxs)(q.A,{sx:{gap:1,justifyContent:"space-between",flexWrap:"wrap",py:1},children:[ee&&!e7?(0,n.jsxs)(R.A,{size:"small",color:"primary",value:e8?"edit":"view",exclusive:!0,onChange:(e,t)=>(e=>{if(!e)return;let t=r.asPath.split("?")[0];r.push("edit"===e?`${t}?edit=1`:t,void 0,{shallow:!0})})(t),children:[(0,n.jsxs)(z.A,{value:"edit",sx:{gap:1,px:2},children:[(0,n.jsx)(x.A,{sx:{fontSize:18}})," Edit"]}),(0,n.jsxs)(z.A,{value:"view",sx:{gap:1,px:2},children:[(0,n.jsx)(y.A,{sx:{fontSize:18}})," View"]})]}):(0,n.jsx)(I.A,{}),(0,n.jsx)(T.A,{direction:"row",spacing:1,alignItems:"center",children:e7&&es?(0,n.jsxs)(n.Fragment,{children:[t?(0,n.jsx)(U.A,{title:"Restore",children:(0,n.jsx)(P.A,{color:"success",onClick:e9,children:(0,n.jsx)(v,{})})}):(0,n.jsx)(M.A,{variant:"outlined",color:"success",startIcon:(0,n.jsx)(v,{}),onClick:e9,children:"Restore"}),t?(0,n.jsx)(U.A,{title:"Permanently Delete",children:(0,n.jsx)(P.A,{color:"error",onClick:()=>{eu(!0),ed(!0)},children:(0,n.jsx)(A.A,{})})}):(0,n.jsx)(M.A,{variant:"outlined",color:"error",startIcon:(0,n.jsx)(A.A,{}),onClick:()=>{eu(!0),ed(!0)},children:"Permanently Delete"})]}):(0,n.jsxs)(n.Fragment,{children:[ee&&e8&&eT&&!t&&(0,n.jsx)(N.A,{variant:"caption",color:"text.secondary",children:eD?"Savingâ¦":`Saved at ${(0,W.o)(eT,new Date)}`}),ee&&e8&&!e7&&(0,n.jsx)(C.A,{variant:"outlined",loading:eD,onClick:()=>{eV()},children:"Save"}),tt&&!e5&&!e7&&(0,n.jsx)(M.A,{variant:"contained",onClick:e2,children:"Publish"}),tt&&e5&&(t?(0,n.jsx)(U.A,{title:"Revert to Draft",children:(0,n.jsx)(P.A,{color:"primary",onClick:e3,children:(0,n.jsx)(j.A,{})})}):(0,n.jsx)(M.A,{variant:"outlined",startIcon:(0,n.jsx)(j.A,{}),onClick:e3,children:"Revert to Draft"})),en&&e5&&(t?(0,n.jsx)(U.A,{title:"Assign",children:(0,n.jsx)(P.A,{color:"primary",onClick:()=>ea(!0),children:(0,n.jsx)(b.A,{})})}):(0,n.jsx)(M.A,{variant:"outlined",startIcon:(0,n.jsx)(b.A,{}),onClick:()=>ea(!0),children:"Assign"})),tr&&(t?(0,n.jsx)(U.A,{title:"Analytics",children:(0,n.jsx)(P.A,{component:Q(),href:(0,ep.eH)(a.slug,h.slug),color:"primary",children:(0,n.jsx)(w.default,{})})}):(0,n.jsx)(M.A,{component:Q(),href:(0,ep.eH)(a.slug,h.slug),variant:"outlined",startIcon:(0,n.jsx)(w.default,{}),children:"Analytics"})),es&&(t?(0,n.jsx)(U.A,{title:"Delete",children:(0,n.jsx)(P.A,{color:"error",onClick:()=>ed(!0),children:(0,n.jsx)(A.A,{})})}):(0,n.jsx)(M.A,{variant:"outlined",color:"error",startIcon:(0,n.jsx)(A.A,{}),onClick:()=>ed(!0),children:"Delete"}))]})})]})}),(0,n.jsxs)(F.A,{maxWidth:"md",sx:{py:{xs:3,md:5}},children:[G?(0,n.jsx)(D.A,{}):e8?(0,n.jsxs)(T.A,{spacing:2,children:[m&&(0,n.jsx)(H.A,{variant:"outlined",sx:{p:{xs:2,md:3}},children:(0,n.jsx)(eR,{form:h,network:a})}),0===g.length?(0,n.jsxs)(H.A,{variant:"outlined",sx:{py:6,textAlign:"center",borderStyle:"dashed"},children:[(0,n.jsx)(N.A,{variant:"h6",sx:{fontWeight:600},children:"No questions yet"}),(0,n.jsx)(N.A,{color:"text.secondary",sx:{mb:2},children:"Start by adding your first question."})]}):(0,n.jsx)(d.Mp,{sensors:eS,collisionDetection:d.fp,onDragStart:e=>{eb(String(e.active.id))},onDragEnd:e0,onDragCancel:()=>{eb(null)},children:(0,n.jsx)(c.gB,{items:eL.map(e=>e.id),strategy:c._G,children:(0,n.jsx)(T.A,{spacing:2,children:eL.map((e,t)=>(0,n.jsx)(eQ,{question:e,index:t,total:eL.length,isCompact:!!ej,validationErrors:e_.get(e.id),onChange:t=>{let r={};if(t.input&&(r.input=t.input),void 0!==t.required&&(r.required=t.required),0===Object.keys(r).length)return;
1let n={...e,...ey[e.id],...r,input:r.input??ey[e.id]?.input??e.input,required:r.required??ey[e.id]?.required??e.required};eA(t=>({...t,[e.id]:n})),(0,eJ.bE)(n).length>0||eF(e.id,e.ref.withConverter(ef.m.formQuestion.write),r)},onMoveUp:()=>eX(e.id,"up"),onMoveDown:()=>eX(e.id,"down"),onDelete:()=>e1(e.id)},e.id))})})}),(0,n.jsxs)(I.A,{children:[(0,n.jsx)(M.A,{variant:"contained",startIcon:(0,n.jsx)(S.A,{}),size:"large",onClick:e=>ex(e.currentTarget),children:"Add question"}),(0,n.jsx)(L.A,{anchorEl:eg,open:!!eg,onClose:()=>ex(null),children:eG.map(({type:e,label:t,icon:r})=>(0,n.jsxs)(O.A,{onClick:()=>eY(e),children:[(0,n.jsx)(r,{fontSize:"small",sx:{mr:1.5,color:"text.secondary"}}),t]},e))})]})]}):0===g.length?(0,n.jsx)(J.A,{severity:"info",children:"This form does not have questions yet."}):(0,n.jsx)(eW.F,{form:h,questions:g,preview:e4!==s.DocStatuses.Published}),eo&&(0,n.jsx)(ev,{isOpen:eo,onClose:()=>ea(!1),form:h}),el&&h&&a&&(0,n.jsx)(K.A,{isOpen:el,close:()=>{ed(!1),eu(!1)},severity:ec?"error":"warning",confirmTitle:`Are you sure you want to ${ec?"permanently delete":"delete"} the "${h.name}" form?`,confirmButtonTitle:`${ec?"Permanently Delete":"Delete"} "${h.name}"`,proceedWithAction:e6,onSuccess:()=>{eu(!1),ed(!1),(0,eq.Tj)({message:ec?`"${h.name}" form permanently deleted`:`"${h.name}" form deleted`}),r.push((0,ep.Ht)(a.slug))},children:(0,n.jsxs)(T.A,{spacing:2,children:[!e7&&(0,n.jsx)(_.A,{control:(0,n.jsx)(V.A,{checked:ec,onChange:e=>eu(e.target.checked),color:"error"}),label:"Permanently delete this form and all responses"}),ec&&(0,n.jsx)(J.A,{severity:"error",children:"This cannot be undone. The form, questions, drafts, assignments, and submissions will be permanently removed."})]})})]})]})}function eX(){return(0,n.jsx)(ee.A,{noAuthForPublicNetwork:!1,pageName:"Form",size:"xl",disableGutters:!0,Component:eY})}},52861:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});var n=r(854),i=r(6029);let s=(0,n.A)((0,i.jsx)("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z"}),"Add")},60526:(e,t,r)=>{"use strict";r.d(t,{_:()=>b});var n=r(6029),i=r(57609),s=r(37913),o=r(56188),a=r(50800),l=r(16276),d=r(56972),c=r(62100),u=r(2670),m=r(81540),f=r(49637),h=r(30042),p=r(51149),g=r(28862),x=r(16851),y=r(55729),v=r(29911),A=r(90060),j=r(20237);function b({isEditing:e,withColorInput:t=!0,title:r,url:i,color:s,onColorUpdate:o,onImageUpdate:d,sx:c}){let[u,m]=y.useState(i);y.useEffect(()=>{i?m(i):m("")},[i]);let f=async({photoUrls:e})=>{d(e),m(e.length?e[0]:"")},h=u?{backgroundImage:`linear-gradient(to bottom, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url("${u}")`,backgroundPosition:"center",backgroundSize:"cover"}:{backgroundColor:s,backgroundImage:"linear-gradient(to bottom, transparent 60%, rgba(0,0,0,0.08))"};return(0,n.jsxs)(a.A,{flex:1,position:"relative",sx:c,children:[(0,n.jsx)(a.A,{sx:{position:"relative",overflow:"hidden",height:"100%",display:"flex",textAlign:"center",justifyContent:"center",alignItems:"center",...h},children:"string"==typeof r?(0,n.jsx)(l.A,{zIndex:9,fontSize:30,color:"white",children:r}):r}),e&&(0,n.jsx)(w,{onPhotosUpdate:f,bgImage:u}),t&&e&&!u&&(0,n.jsx)(S,{color:s,onColorUpdate:t?o:()=>{}})]})}function w({onPhotosUpdate:e,bgImage:t}){let r=y.useRef(null),[s,o]=y.useState(null),[l,u]=y.useState((0,v.A)()),m=()=>{r.current?.click()};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("input",{hidden:!0,ref:r,onChange:e=>{let t=e.target.files?.[0];t&&(o(t),u((0,v.A)()))},multiple:!1,accept:"image/*",type:"file"},l),(0,n.jsx)(a.A,{sx:{position:"absolute",bottom:5,left:5},children:t?(0,n.jsx)(I,{onEdit:m,onDelete:()=>{e({photoUrls:[]})},children:(0,n.jsx)(d.A,{arrow:!0,placement:"right",title:t?"Change Cover Image":"Add Cover Image",children:(0,n.jsx)(c.A,{size:"small",sx:{color:"white"},children:(0,n.jsx)(i.A,{})})})}):(0,n.jsx)(d.A,{arrow:!0,placement:"right",title:t?"Change Cover Image":"Add Cover Image",children:(0,n.jsx)(c.A,{size:"small",sx:{color:"white"},onClick:m,children:(0,n.jsx)(i.A,{})})})}),s&&(0,n.jsx)(A.A,{showSaveCropButton:!0,onPhotosUploaded:e,initFiles:[s],sx:{mt:0},allowCrop:!0,avatarEditorProps:{border:10,width:1800,height:480}},s.name+l)]})}function S({color:e,onColorUpdate:t}){let[r,i]=y.useState(!1);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(a.A,{sx:{position:"absolute",bottom:5,left:50},children:(0,n.jsx)(d.A,{arrow:!0,placement:"right",title:"Change Cover C
1olor",children:(0,n.jsx)(c.A,{size:"small",sx:{color:"white"},onClick:()=>i(!0),children:(0,n.jsx)(s.A,{})})})}),r&&(0,n.jsx)(C,{close:()=>i(!1),color:e,onColorChange:t})]})}function C({color:e,onColorChange:t,close:r}){let[i,s]=y.useState(e);return y.useEffect(()=>{e&&s(e)},[e]),(0,n.jsxs)(u.A,{open:!0,closeAfterTransition:!0,sx:{alignItems:"center",justifyContent:"center"},children:[(0,n.jsx)(m.A,{children:"Cover Color"}),(0,n.jsx)(f.A,{children:(0,n.jsx)(j.s,{code:i,setCode:e=>s(e)})}),(0,n.jsxs)(h.A,{children:[(0,n.jsx)(p.A,{onClick:r,children:"Cancel"}),(0,n.jsx)(o.A,{onClick:()=>{t(i),r()},color:"primary",variant:"contained",children:"Update Color"})]})]})}function I({children:e,onEdit:t,onDelete:r}){let[i,s]=y.useState(null),o=()=>{s(null)};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(a.A,{onClick:e=>{s(e.currentTarget)},children:e}),(0,n.jsxs)(g.A,{anchorEl:i,open:!!i,onClose:o,children:[(0,n.jsx)(x.A,{onClick:()=>{t(),o()},children:"Update Cover Image"}),(0,n.jsx)(x.A,{onClick:()=>{r(),o()},color:"red",children:"Remove Image"})]})]})}},67970:(e,t,r)=>{"use strict";r.d(t,{n:()=>h});var n=r(6029),i=r(36018),s=r(65668),o=r(33009),a=r(16276),l=r(51149),d=r(95816),c=r.n(d),u=r(55729),m=r(36780),f=r(52123);function h(e){let[t,r]=(0,u.useState)(!1),[d,h]=(0,u.useState)([]),[p,g]=(0,u.useState)(),{successMessage:x,...y}=e,v=(0,m.a)();return(0,n.jsxs)(s.A,{direction:v?"column":"row",alignItems:"center",gap:1,width:v?"100%":"auto",children:[(0,n.jsx)(o.A,{orientation:"horizontal",in:!c()(p),children:(0,n.jsx)(a.A,{sx:{textWrap:"nowrap",fontSize:v?"0.8rem":"1rem",textAlign:v?"center":"left"},children:p})}),(0,n.jsx)(l.A,{fullWidth:v,startIcon:e.startIcon||(0,n.jsx)(i.A,{}),loadingPosition:"start",sx:{fontSize:v?"0.85rem":"1rem",padding:v?"8px 12px":"10px 16px",minWidth:v?"100%":"auto"},onClick:async()=>{r(!0),g("");try{if(await e.handleSubmit()){h([]);let t=x();t?.length&&((0,f.Tj)({message:t,severity:"info"}),e.inlineSuccessMessage&&g(e.inlineSuccessMessage()))}else throw Error("Failed to Save")}catch(e){console.error(e),h([e.message]),(0,f.Tj)({message:e.message,severity:"error"})}finally{r(!1)}},loading:t,...y})]})}},68307:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var n=r(71024);let i=r.n(n)()(()=>Promise.all([r.e(4373),r.e(4834),r.e(4548),r.e(8635),r.e(8213),r.e(1379),r.e(7616),r.e(6563),r.e(5245),r.e(5637),r.e(5062),r.e(9503),r.e(7692),r.e(32),r.e(602),r.e(9849),r.e(1868),r.e(9204),r.e(9145),r.e(5191),r.e(3739),r.e(317),r.e(966),r.e(4640),r.e(9496),r.e(1086),r.e(2622),r.e(4140),r.e(9689),r.e(5238),r.e(7767),r.e(300),r.e(6022),r.e(2187),r.e(1170),r.e(8858),r.e(7083)]).then(r.bind(r,27083)),{loadableGenerated:{webpack:()=>[27083]},ssr:!1})},73041:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});var n=r(854),i=r(6029);let s=(0,n.A)((0,i.jsx)("path",{d:"m20 12-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8z"}),"ArrowDownward")},83233:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});var n=r(854),i=r(6029);let s=(0,n.A)((0,i.jsx)("path",{d:"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2m-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}),"DragIndicator")},87070:(e,t,r)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/[network]/forms/[slug]",function(){return r(47645)}])},94574:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});var n=r(854),i=r(6029);let s=(0,n.A)((0,i.jsx)("path",{d:"M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5M12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5m0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3"}),"Visibility")},98696:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});var n=r(854),i=r(6029);let s=(0,n.A)((0,i.jsx)("path",{d:"m4 12 1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8z"}),"ArrowUpward")},98770:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});var n=r(854),i=r(6029);let s=(0,n.A)((0,i.jsx)("path",{d:"M21.99 8c0-.72-.37-1.35-.94-1.7L12 1 2.95 6.3C2.38 6.65 2 7.28 2 8v10c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2zM12 13 3.74 7.84 12 3l8.26 4.84z"}),"Drafts")}},e=>{e.O(0,[4548,1379,7616,6563,5245,5637,5062,9503,7692,32,602,9849,1868,9204,9145,5191,3739,317,966,4640,9496,1086,2622,4140,47,5238,7767,300,6022,2187,1170,636,6593,8792],()=>e(e.s=87070)),_N_E=e.O()}]);
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.