PageSourceSearch

https://captiv8.io/insights/assets/formatQueryForBackend-BLbbr9GM.js

js captiv8.io collected 2026-10-01 11:42:20 UTC 8,157 bytes, 4 lines download raw bytes

1
2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f17540b5-436a-5e0f-958f-706b2382eea5")}catch(e){}}();
3import{o as e}from"./rolldown-runtime-eil0g4P7.js";import{E as t,k as n}from"./vendor-react-core-UKDSgKSw.js";import{a as r}from"./utils-Buch3xkY.js";import"./translation-CbfJyhfk.js";import{t as i}from"./translateParseString-HJrsWBPA.js";import{s as a}from"./social-uivFLCLt.js";import{t as o}from"./isEmpty-DYGy-S8C.js";import{t as s}from"./Button-Dd3dauOe.js";import{t as c}from"./FormGroup-DERJkrgy.js";import{t as l}from"./useAppDispatch-dwoGHCCS.js";import{t as u}from"./Modal-B8wTt1lM.js";import{t as d}from"./useFetch-D64sJPDy.js";import{c as f,l as p,r as m}from"./vendor-ui-forms-BXu2-GHx.js";import{t as h}from"./NotificationBlock-C2NsBh1d.js";import{t as g}from"./HookFormTextField-Dtxf3Fvh.js";import{t as _}from"./useSimpleForm-C__kPPwE.js";import{t as v}from"./HookFormSelectField-dUWToX_w.js";import{t as y}from"./HookFormTextAreaField-CIiONIrk.js";import{t as b}from"./organizationCampaignTemplates-9eKdaPz0.js";import{t as x}from"./actions-EMen4R8z.js";var S=r(`NAME`,`AUTHOR`,`CREATED_AT`,`LAST_UPDATE`,`LAST_UPDATE_BY`,`VISIBILITY`,`ACTIONS`),{NAME:C,AUTHOR:w,CREATED_AT:T,LAST_UPDATE:E,LAST_UPDATE_BY:D,VISIBILITY:O,ACTIONS:k}=S,A={[C]:i(`Name`),[w]:i(`Author`),[T]:i(`Created`),[E]:i(`Last update`),[D]:i(`Last updated by`),[O]:i(`Visibility`),[k]:i(`Actions`)},{STORY:j,IMAGE:M,VIDEO:N,REEL:P,CAROUSEL:F,TEXT:I}=a,L={[j]:i(`Story`),[M]:i(`Image`),[N]:i(`Video`),[P]:i(`Reel`),[F]:i(`Carousel`),[I]:i(`Text`)},R=e(n()),z=t(),B=[],V={popoverProps:{className:`popover-autosuggestions __v2`,gap:8},renderOptionPending:!0,clearable:!0,searchable:!0,hideArrow:!0,withoutTranslateOptions:!0,clearInputValueAfterSelect:!0,minimumInputLength:0,valueWholeObject:!0,itemToString:()=>``,mapOptionsData:e=>e,valueKey:`id`,ignoreInitialFetch:!0},H=(e,t)=>(0,z.jsx)(c,{verticalSpacing:`16`,children:(0,z.jsx)(`ul`,{className:`form-tags __v2`,children:e.map((e,n)=>(0,z.jsxs)(`li`,{className:`form-tags__list-item`,children:[(0,z.jsx)(`span`,{className:`form-tags__item`,children:(0,z.jsx)(`span`,{className:`form-tags__item-name`,children:e.name})}),(0,z.jsx)(s,{withoutBaseClasses:!0,className:`form-tags__close`,onClick:()=>t(n)})]},`${e.id}_${n}`))})}),U=()=>{let{setValue:e,control:t}=f(),n=l(),[r=[],a=[],s=[]]=p({control:t,name:[`filter_criteria.organizations`,`filter_criteria.brands`,`filter_criteria.campaign_tags`]}),u=(0,R.useCallback)(e=>n(x.getPortfolioReportsOrgs({q:e})),[n]),m=(0,R.useCallback)(e=>n(x.getPortfolioReportsBrands({q:e})),[n]),_=(0,R.useCallback)(e=>n(x.getPortfolioReportsCampaignTags({q:e})),[n]),{result:S}=d({action:()=>b.fetchAvailableOrganizationCampaignTemplates(`portfolio_report`),withDispatch:!0}),C=S??[],{result:w}=d({action:()=>x.getPortfolioReportsOrgs({q:``}),withDispatch:!0}),{result:T}=d({action:()=>x.getPortfolioReportsBrands({q:``}),withDispatch:!0}),{result:E}=d({action:()=>x.getPortfolioReportsCampaignTags({q:``}),withDispatch:!0}),D=(0,R.useCallback)((t,n)=>r=>{if(r?.id){let{id:i,label:a,name:o}=r,s=Number(i);if(n.some(e=>e.id===s))return;let c={id:s,name:a||o||String(i)};e(t,[...n,c])}},[e]),O=(0,R.useCallback)((t,n)=>r=>{e(t,n.filter((e,t)=>t!==r))},[e]);return(0,z.jsxs)(z.Fragment,{children:[o(r)&&(0,z.jsx)(h,{className:`__size-medium __bottom-space-16`,description:i(`No organizations selected. You'll see results from all organizations and sub-organizations that match this criteria.`)}),(0,z.jsx)(c,{verticalSpacing:`16`,children:(0,z.jsx)(g,{name:`title`,fieldProps:{label:i(`Name`)}})}),(0,z.jsx)(c,{verticalSpacing:`16`,children:(0,z.jsx)(y,{name:`description`,fieldProps:{label:i(`Description`),parseErrorMessage:!0}})}),(0,z.jsx)(c,{verticalSpacing:`16`,children:(0,z.jsx)(v,{name:`template_id`,popoverProps:{className:`popover-autosuggestions __v2`,gap:8},fieldProps:{label:i(`Report Template`)},clearable:!0,searchable:!0,withoutTranslateOptions:!0,options:C.map(({id:e,title:t})=>({id:String(e),title:t})),valueKey:`id`,titleKey:`title`})}),(0,z.jsx)(c,{verticalSpacing:`8`,children:(0,z.jsx)(v,{...V,name:`organization`,placeholder:i(`Search organization`),fieldProps:{label:i(`Organizations`)},options:w??B,onFetchSuggestions:u,onChange:D(`filter_criteria.organizations`,r),titleKey:`label`})}),!o(r)&&H(r,O(`filter_criteria.organizations`,r)),(0,z.jsx)(c,{verticalSpacing:`8`,children:(0,z.jsx)(v,{...V,name:`brand`,placeholder:i(`Search brand`),fieldProps:{label:i(`Brands`)},options:T??B,onFetchSuggestions:m,onChange:D(`filter_criteria.brands`,a),titleKey:`label`})}
3),!o(a)&&H(a,O(`filter_criteria.brands`,a)),(0,z.jsx)(c,{verticalSpacing:`8`,children:(0,z.jsx)(v,{...V,name:`campaign_tag`,placeholder:i(`Search tag`),fieldProps:{label:i(`Campaign Tags`)},options:E??B,onFetchSuggestions:_,onChange:D(`filter_criteria.campaign_tags`,s),titleKey:`label`})}),!o(s)&&H(s,O(`filter_criteria.campaign_tags`,s))]})},W=(e,t)=>{let n=Array.isArray(e)?e:[];if(o(n))return[];let r=new Map((Array.isArray(t)?t:[]).map(e=>[Number(e.id),e.label||e.name||String(e.id)]));return n.map(e=>({id:e,name:r.get(e)??String(e)}))},G=e=>Array.isArray(e)?e:void 0,K=e=>{let{organizations:t,brands:n,campaign_tags:r}=e||{};return{organizations:W(G(t)),brands:W(G(n)),campaign_tags:W(G(r))}},q=e=>{let{organizations:t=[],brands:n=[],campaign_tags:r=[]}=e||{},i=t.map(({id:e})=>e),a=n.map(({id:e})=>e),s=r.map(({id:e})=>e),c={organizations:o(i)?void 0:i,brands:o(a)?void 0:a,campaign_tags:o(s)?void 0:s};return Object.fromEntries(Object.entries(c).filter(([,e])=>e!==void 0))},J=({title:e,description:t,template_id:n,filter_criteria:r})=>({title:e,description:t,template_id:n?Number(n):void 0,filter_criteria:q(r)}),Y=({values:e,onRefetch:t,onSuccess:n,closeModal:r})=>{t?.(),n?.(J(e)),r()},X=({report:e,modalProps:t,isModalOpen:n,closeModal:r,onSuccess:a,onRefetch:s})=>{let c=l(),[f,p]=(0,R.useState)(e);(0,R.useEffect)(()=>{p(e)},[e]);let{id:h}=e||{},{filter_criteria:g,title:v,description:y}=f||{},b=n&&h&&!g,{pending:S}=d({action:()=>x.getPortfolioReportById({portfolio_report_id:h}),withDispatch:!0,isFetch:!!b,updateProps:b,onSuccessCallback:e=>p(e)}),{organizations:C,brands:w,campaign_tags:T}=g||{},E=!o(C),D=!o(w),O=!o(T),k=n&&!!h,{handleSubmit:A,formProps:j,formProps:{formState:{isSubmitting:M},reset:N,setValue:P}}=_({defaultValues:(0,R.useMemo)(()=>({title:v??``,description:y??``,template_id:null,filter_criteria:K(g)}),[v,y,g]),enableReinitialize:!0,withReset:!0,valuesFormatter:J,onSubmit:(0,R.useCallback)(e=>h?c(x.updatePortfolioReportById({portfolio_report_id:h,...e})):Promise.reject(),[c,h]),onSuccessCallback:(0,R.useCallback)((e,t,n)=>Y({values:n,onRefetch:s,onSuccess:a,closeModal:r}),[s,a,r])});return d({action:()=>x.getPortfolioReportsOrgs({q:``,portfolio_report_id:h}),withDispatch:!0,isFetch:k&&E,updateProps:[n,h,E],onSuccessCallback:e=>{P(`filter_criteria.organizations`,W(C,e))}}),d({action:()=>x.getPortfolioReportsBrands({q:``,portfolio_report_id:h}),withDispatch:!0,isFetch:k&&D,updateProps:[n,h,D],onSuccessCallback:e=>{P(`filter_criteria.brands`,W(w,e))}}),d({action:()=>x.getPortfolioReportsCampaignTags({q:``,portfolio_report_id:h}),withDispatch:!0,isFetch:k&&O,updateProps:[n,h,O],onSuccessCallback:e=>{P(`filter_criteria.campaign_tags`,W(T,e))}}),(0,z.jsx)(u,{...t,width:660,onCloseCallback:()=>{N()},title:i(`Edit Portfolio Report`),submitAction:A,submitTitle:i(`Save`),cancelTitle:i(`Cancel`),pending:M||S,body:(0,z.jsx)(m,{...j,children:(0,z.jsx)(U,{})})})},Z=e=>e.map(e=>{let t=String(e).match(/^(\d+):/);return Number(t?t[1]:e)}),Q=e=>{let{brands:t,organizations:n,creators:r,campaign_tags:i,campaigns:a,...s}=e,c={};return Object.keys(s).forEach(e=>{s[e]!==void 0&&(c[e]=s[e])}),t&&!o(t)&&(c.brands=Z(t)),n&&!o(n)&&(c.organizations=Z(n)),r&&!o(r)&&(c.creators=Z(r)),i&&!o(i)&&(c.campaign_tags=Z(i)),a&&!o(a)&&(c.campaigns=Z(a)),c};export{S as a,U as i,X as n,A as o,q as r,L as s,Q as t};
4//# debugId=f17540b5-436a-5e0f-958f-706b2382eea5

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.