PageSourceSearch

https://www.contagious.com/_next/static/chunks/431-bc43924aa47d640e.js

js contagious.com collected 2026-10-01 09:13:31 UTC 11,115 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[431],{19586:(e,t,l)=>{l.d(t,{dm:()=>c,uN:()=>a,yQ:()=>o});var n=l(29755);l(18731);let o=24,c=(e,t)=>e.split("/").slice(0,3).concat(t).join("/"),a=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,l=arguments.length>2?arguments[2]:void 0,o=l?(0,n.RH)(l).umsId:null;return!!e.find(e=>{let{roleType:l,userId:n}=e;return t.includes(null!=l?l:"Owner")&&n===o})}},38575:(e,t,l)=>{l.r(t),l.d(t,{CreateCollectionButton:()=>h});var n=l(95155),o=l(9171),c=l(30926);let a=(0,c.createServerReference)("7fe5d4d12e799eb1b5aec57e27ad53e41551345d8f",c.callServer,void 0,c.findSourceMapURL,"createCollection");var i=l(73497),r=l(9158),s=l(48668),d=l(37987),u=l(59197),m=l(38514),f=l(12115);let h=e=>{let[t,l]=(0,f.useState)(""),[c,h]=(0,f.useState)(),[p,C]=(0,f.useState)(!1),[g,v]=(0,f.useState)(!1),{t:x}=(0,o.B)(),{showToast:y}=(0,i.useToast)(),w=()=>{l(""),h(void 0),C(!1)},b=async()=>{v(!0);try{var n;let{collection:o}=await a({title:t,description:c});null==(n=e.onSave)||n.call(e,o),y({text:x("collections.createNewCollectionSuccess"),variant:"success"}),l(""),h(void 0),C(!1)}catch(e){y({text:e.message,variant:"error"})}v(!1)};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(r.default,{variant:"secondary",className:(0,m.AH)({w:"full"}),onClick:()=>C(!0),icon:{name:"Plus",position:"end"},children:x("collections.createNewCollection")}),(0,n.jsx)(s.A,{isOpen:p,closeModal:w,contentTitle:x("collections.createNewCollection"),buttons:[{copy:x("shared.cancel"),variant:"secondary",disabled:g,onClick:w},{copy:x("shared.saveChanges"),loading:g,disabled:!t,onClick:b}],children:(0,n.jsxs)(d.F,{flexDirection:"column",w:"full",gap:"spacing-large",paddingTop:"5rem",children:[(0,n.jsx)(u.default,{label:x("collections.createNewCollectionNameLabel"),type:"text",id:"edit-collection-name",name:"edit-collection-name",required:!0,onChange:e=>l(e.target.value),value:t}),(0,n.jsx)(u.default,{label:x("collections.createNewCollectionDescriptionLabel"),type:"text",id:"edit-collection-description",name:"edit-collection-description",onChange:e=>h(e.target.value),value:c})]})})]})}},73697:(e,t,l)=>{l.d(t,{CollectionsContentManager:()=>T});var n=l(95155),o=l(60753),c=l(96185),a=l(9158),i=l(12115),r=l(9171),s=l(38514),d=l(72322),u=l(8912),m=l(73497),f=l(19586),h=l(49562);async function p(e){let t=await fetch("/api/collections/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return t.ok?await t.json():{ok:!1,data:{collections:[]}}}async function C(e){let t=await fetch("/api/collection-items/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return t.ok?await t.json():{ok:!1,data:{collectionItems:[]}}}async function g(e){let t=await fetch("/api/collection-items",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return await t.json()}async function v(e){let t=await fetch("/api/collection-items/".concat(e),{method:"DELETE"});return await t.json()}async function x(e){let t=await fetch("/api/collections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return await t.json()}let y=(0,i.createContext)(void 0),w=e=>{let{children:t,contentId:l,contentType:o,tenantName:c,onCollectionItemCreated:a,onCollectionItemDeleted:s,onContentSavedStatusChange:d}=e,u=(0,i.useRef)(!1),w=(0,i.useRef)(null),b=(0,i.useRef)(d),{showToast:j}=(0,m.useToast)(),{t:N}=(0,r.B)(),{user:S}=(0,h.Jd)(),[k,I]=(0,i.useState)([]),[T,E]=(0,i.useState)([]),[R,D]=(0,i.useState)(null),[F,A]=(0,i.useState)([]),M=(0,i.useCallback)(async()=>{if(S){A(e=>[...e,"getCollections"]);try{var e;let t=await p({tenant:[c]});if(!t.ok){I([]),D(N("collections.getCollectionsErrorMessage"));return}let l=(null!=(e=t.data.collections)?e:[]).map(e=>{var t;return{...e,id:null!=(t=e.id)?t:void 0}});D(null),I(l.filter(e=>{var t;return"Active"===e.status&&(0,f.uN)(null!=(t=e.entityRoles)?t:[],["Owner","Publisher","Editor"],S)}))}catch(e){I([]),D(N("collections.getCollectionsErrorMessage"))}finally{A(e=>e.filter(e=>"getCollections"!==e))}}},[N,c,S]),O=(0,i.useCallback)(async()=>
1{if(S){A(e=>[...e,"getCollectionItems"]);try{var e;let t=await C({items:[{contentReference:l,contentType:o}],tenants:[c]});if(!t.ok){E([]),D(N("collections.getCollectionItemsErrorMessage"));return}let n=(null!=(e=t.data.collectionItems)?e:[]).map(e=>{var t,l,n;return{...e,id:null!=(t=e.id)?t:void 0,contentReference:null!=(l=e.contentReference)?l:void 0,collection:e.collection?{...e.collection,id:null!=(n=e.collection.id)?n:void 0}:e.collection}});D(null),E(n)}catch(e){E([]),D(N("collections.getCollectionItemsErrorMessage"))}finally{A(e=>e.filter(e=>"getCollectionItems"!==e))}}},[l,o,c,N,S]),B=(0,i.useCallback)(async e=>{A(e=>[...e,"createCollectionItem"]);try{let t=await g({collectionId:e,contentReference:l,contentType:o});if(!t.ok){D(N("collections.createNewCollectionItemFailed")),j({text:N("collections.createNewCollectionItemFailed"),variant:"error"});return}t.data.collectionItem&&(D(null),await O(),a&&a(t.data.collectionItem),j({text:N("collections.createNewCollectionItemSuccess"),variant:"success"}))}catch(e){D(N("collections.createNewCollectionItemFailed")),j({text:N("collections.createNewCollectionItemFailed"),variant:"error"})}finally{A(e=>e.filter(e=>"createCollectionItem"!==e))}},[l,o,O,a,j,N]),P=(0,i.useCallback)(async e=>{A(e=>[...e,"deleteCollectionItem"]);try{let t=T.find(t=>{let{contentReference:n,collection:o}=t;if(n&&o)return n===l&&o.id===e});if(!(null==t?void 0:t.id)||!(await v(t.id)).ok)return void D(N("collections.deleteCollectionItemFailed"));D(null),await O(),s&&s(t.id)}catch(e){D(N("collections.deleteCollectionItemFailed"))}finally{A(e=>e.filter(e=>"deleteCollectionItem"!==e))}},[l,T,O,s,N]),H=(0,i.useCallback)(async e=>{let{title:t,description:l}=e;A(e=>[...e,"createCollection"]);let n=!1;try{if(!(await x({title:t,description:l||void 0,tenant:c})).ok)return D(N("collections.createNewCollectionFailed")),n=!1;D(null),await M(),n=!0}catch(e){D(N("collections.createNewCollectionFailed")),n=!1}finally{A(e=>e.filter(e=>"createCollection"!==e))}return n},[c,M,N]),G=(0,i.useMemo)(()=>F.length>0,[F]),L=(0,i.useMemo)(()=>({collections:k,contentCollectionItems:T,contentId:l,contentType:o,error:R,loading:G,pendingApiRequests:F,addContentToCollection:B,createNewCollection:H,fetchCollections:M,fetchContentCollectionItems:O,removeContentFromCollection:P}),[k,T,l,o,R,G,F,B,H,M,O,P]);return(0,i.useEffect)(()=>{!u.current&&S&&(M(),O(),u.current=!0)},[M,O,S]),(0,i.useEffect)(()=>{b.current=d},[d]),(0,i.useEffect)(()=>{w.current=null},[l,o]),(0,i.useEffect)(()=>{let e=T.some(e=>"Active"===e.status);if(w.current!==e){var t;w.current=e,null==(t=b.current)||t.call(b,e)}},[T]),(0,n.jsx)(y.Provider,{value:L,children:t})};function b(){let e=(0,i.useContext)(y);if(void 0===e)throw Error("useCollections() must be called from within <CollectionsProvider />");return e}let j=e=>{let{collection:t}=e,{contentId:l,contentCollectionItems:o,loading:c,addContentToCollection:a,removeContentFromCollection:r}=b(),d=(0,i.useMemo)(()=>o.some(e=>!!e.contentReference&&!!e.collection&&e.contentReference===l&&e.collection.id===t.id&&"Active"===e.status),[o,t.id,l]);return t.id&&t.title?(0,n.jsx)(u.default,{inputType:"checkbox",id:"collection-selector-".concat(t.id,"-").concat(l),value:"collection-selector-".concat(t.id,"-").concat(l),label:t.title,checked:d,disabled:c,containerClassName:(0,s.AH)({py:"spacing-small",px:"spacing-medium","& span":{color:"interactive-light-bg"}}),onChangeCallback:async()=>{d?r(t.id):a(t.id)}}):null};var N=l(59197);let S=e=>{let{onSuccess:t,onCancel:l}=e,{t:o}=(0,r.B)(),{showToast:u}=(0,m.useToast)(),{contentId:f,loading:h,createNewCollection:p}=b(),[C,g]=(0,i.useState)(""),[v,x]=(0,i.useState)(""),y=(0,i.useRef)(null),w=(0,i.useCallback)(async e=>{if(e.preventDefault(),!C.trim())return void u({text:o("collections.createNewCollectionFailed"),variant:"error"});await p({title:C,description:v})?(u({text:o("collections.createNewCollectionSuccess"),variant:"success"}),t()):u({text:o("collections.createNewCollectionFailed"),variant:"error"})},[C,v,p,t,u,o]),j=(0,i.useCallback)(()=>{var e;g(""),x(""),null==(e=y.current)||e.reset(),l()},[l]);return(0,n.jsxs)("form",{ref:y,onSubmit:w,className:(0,s.AH)({display:"flex",flexDir:"column",py:"spacing-small",rowGap:"spacing-small"}),children:[(0,n.jsxs)(d.so,{flexDir:"column",rowGap:"spacing-small",children:[(0,n.jsx)(c.o,{bold:!0,size:"body-regular-short",as:"label",htmlFor:"create-collection-name-".concat(f),children:o("collections.createNewCollectionNameLabel")}),(0,n.jsx)(N.default,{type:"text",required:!0,id:"create-collection-name-".concat(f),name:"create-collection-name-".concat(f),value:C,onChange:e=>g(e.target.value)})]}),(0,n.jsxs)(d.so,{flexDir:"column",rowGap:"spacing-small",children:[(0,n.jsx)(c.o,{bold:!0,size:"body-regular-short",as:"label",htmlFor:"create-collection-name-".concat(f),children:o("collections.createNewCollectionDescriptionLabel")}),(0,n.jsx)(N.default,{type:"text",id:"create-collection-name-".concat(f),name:"create-collection-name-".concat(f),value:v,onCh
1ange:e=>x(e.target.value)})]}),(0,n.jsxs)(d.so,{flexDir:"row",columnGap:"spacing-medium",justifyContent:"flex-end",children:[(0,n.jsx)(a.default,{type:"button",variant:"secondary",onClick:j,disabled:h,children:o("shared.cancel")}),(0,n.jsx)(a.default,{type:"submit",variant:"primary",disabled:h||0===C.trim().length,loading:h,children:o("shared.saveChanges")})]})]})},k=[1,2,3,4,5,6],I=()=>{let{t:e}=(0,r.B)(),{collections:t,loading:l,pendingApiRequests:u,error:m}=b(),[f,h]=(0,i.useState)(!1);return(0,n.jsxs)(d.so,{flexDir:"column",children:[(0,n.jsxs)(d.so,{className:(0,s.AH)({flexDirection:"column",flexBasis:"auto",maxHeight:"24.4rem",overflowY:"auto","& > div:not(:last-child)":{borderBottom:"1px solid",borderBottomColor:"border-grey"}}),children:[u.includes("getCollections")&&0===t.length&&(0,n.jsx)(d.so,{flexDir:"column",p:"spacing-small",rowGap:"spacing-small",children:k.map(e=>(0,n.jsxs)(d.so,{flexDir:"row",columnGap:"spacing-medium",children:[(0,n.jsx)(o.A,{variant:"rect",width:"2.4rem",height:"2.4rem",borderRadius:"0.4rem"}),(0,n.jsx)(o.A,{width:"50%",height:"2rem"})]},e))}),!l&&m&&(0,n.jsx)(d.az,{p:"spacing-small",children:(0,n.jsx)(c.o,{children:m})}),!l&&!m&&0===t.length&&(0,n.jsx)(d.az,{p:"spacing-small",children:(0,n.jsx)(c.o,{children:e("collections.noCollectionsSavedMessage")})}),t.length>0&&t.map((e,t)=>{var l;return(0,n.jsx)(j,{collection:e},null!=(l=e.id)?l:"collection-".concat(t))})]}),(0,n.jsxs)(d.so,{className:(0,s.AH)({flexDirection:"column",flexBasis:"100%",py:"spacing-small",px:"spacing-medium",borderTop:"1px solid",borderTopColor:"border-grey"}),children:[(0,n.jsx)(a.default,{variant:"secondary",size:"sm",icon:{name:"Plus",position:"end"},disabled:f,onClick:()=>{h(!0)},children:e("collections.createNewCollection")}),f&&(0,n.jsx)(S,{onCancel:()=>h(!1),onSuccess:()=>h(!1)})]})]})},T=e=>(0,n.jsx)(w,{...e,children:(0,n.jsx)(I,{})})}}]);

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.