PageSourceSearch

https://osintltd.com/assets/preferences-BGzJ87Pi.js

js osintltd.com collected 2026-10-09 23:50:14 UTC 25,941 bytes, 5 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]="0a17094b-ca1d-5385-b531-b76aaae3c14a")}catch(e){}}();
3import{a as e,t}from"./jsx-runtime-CMgEUHpv.js";import{V as n}from"./dist-CAHjj65Z.js";import{t as r}from"./useTranslation-BymTnaHx.js";import{l as i}from"./components-B8bHjdou.js";import{t as a}from"./classnames-PxzWHlFm.js";import{t as o}from"./Typography-DJfjxaJy.js";import{r as s,t as c}from"./Section-C5SudLaW.js";import{t as l}from"./CheckIcon-DAWL0w4I.js";import{t as u}from"./useToast-aQCYBESc.js";import{f as d,g as f,h as p,i as m,l as h,m as g,o as _,r as v,t as y,u as b}from"./render-D-6lIDot.js";import{a as ee,r as te}from"./label-6Is4t9r1.js";import{t as x}from"./use-disposables-DmKy7YN_.js";import{n as S,t as C}from"./keyboard-BynAefDg.js";import{d as w,l as T,n as E,o as ne}from"./focus-management-zpJZeZqO.js";import{n as re}from"./use-owner-cdttaX9k.js";import{t as ie}from"./use-resolve-button-type-FJ7Z2j9u.js";import{a as ae,i as oe,n as D,r as O}from"./menu-BwR_gk66.js";import{n as se,t as ce}from"./hidden-tfADjw18.js";import{a as le,i as ue,r as k,t as A}from"./transition-zOPc9j2i.js";import{t as de}from"./bugs-DRRBxuGP.js";import{t as j}from"./radio-group-DrTf7ygM.js";import{t as M}from"./switch-DltAVPqm.js";import{t as fe}from"./Input-C6IbD1Sk.js";import{t as pe}from"./useTypedLoaderData-p1j97aJ6.js";import{n as me,t as he}from"./getMergedMetaData-BX84vd1a.js";import{n as ge,t as N}from"./Downgrade-z04MuHMA.js";var P=e(n());function _e({title:e,titleId:t,...n},r){return P.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?P.createElement(`title`,{id:t},e):null,P.createElement(`path`,{fillRule:`evenodd`,d:`M11.47 4.72a.75.75 0 0 1 1.06 0l3.75 3.75a.75.75 0 0 1-1.06 1.06L12 6.31 8.78 9.53a.75.75 0 0 1-1.06-1.06l3.75-3.75Zm-3.75 9.75a.75.75 0 0 1 1.06 0L12 17.69l3.22-3.22a.75.75 0 1 1 1.06 1.06l-3.75 3.75a.75.75 0 0 1-1.06 0l-3.75-3.75a.75.75 0 0 1 0-1.06Z`,clipRule:`evenodd`}))}var ve=P.forwardRef(_e);function F(e,t){let[n,r]=(0,P.useState)(e),i=p(e);return f(()=>r(i.current),[i,r,...t]),n}var ye=(e=>(e[e.Open=0]=`Open`,e[e.Closed=1]=`Closed`,e))(ye||{}),I=(e=>(e[e.Single=0]=`Single`,e[e.Multi=1]=`Multi`,e))(I||{}),be=(e=>(e[e.Pointer=0]=`Pointer`,e[e.Other=1]=`Other`,e))(be||{}),xe=(e=>(e[e.OpenListbox=0]=`OpenListbox`,e[e.CloseListbox=1]=`CloseListbox`,e[e.GoToOption=2]=`GoToOption`,e[e.Search=3]=`Search`,e[e.ClearSearch=4]=`ClearSearch`,e[e.RegisterOption=5]=`RegisterOption`,e[e.UnregisterOption=6]=`UnregisterOption`,e[e.RegisterLabel=7]=`RegisterLabel`,e))(xe||{});function L(e,t=e=>e){let n=e.activeOptionIndex===null?null:e.options[e.activeOptionIndex],r=E(t(e.options.slice()),e=>e.dataRef.current.domRef.current),i=n?r.indexOf(n):null;return i===-1&&(i=null),{options:r,activeOptionIndex:i}}var Se={1(e){return e.dataRef.current.disabled||e.listboxState===1?e:{...e,activeOptionIndex:null,listboxState:1}},0(e){if(e.dataRef.current.disabled||e.listboxState===0)return e;let t=e.activeOptionIndex,{isSelected:n}=e.dataRef.current,r=e.options.findIndex(e=>n(e.dataRef.current.value));return r!==-1&&(t=r),{...e,listboxState:0,activeOptionIndex:t}},2(e,t){if(e.dataRef.current.disabled||e.listboxState===1)return e;let n=L(e),r=oe(t,{resolveItems:()=>n.options,resolveActiveIndex:()=>n.activeOptionIndex,resolveId:e=>e.id,resolveDisabled:e=>e.dataRef.current.disabled});return{...e,...n,searchQuery:``,activeOptionIndex:r,activationTrigger:t.trigger??1}},3:(e,t)=>{if(e.dataRef.current.disabled||e.listboxState===1)return e;let n=+(e.searchQuery===``),r=e.searchQuery+t.value.toLowerCase(),i=(e.activeOptionIndex===null?e.options:e.options.slice(e.activeOptionIndex+n).concat(e.options.slice(0,e.activeOptionIndex+n))).find(e=>!e.dataRef.current.disabled&&e.dataRef.current.textValue?.startsWith(r)),a=i?e.options.indexOf(i):-1;return a===-1||a===e.activeOptionIndex?{...e,searchQuery:r}:{...e,searchQuery:r,activeOptionIndex:a,activationTrigger:1}},4(e){return e.dataRef.current.disabled||e.listboxState===1||e.searchQuery===``?e:{...e,searchQuery:``}},5:(e,t)=>{let n={id:t.id,dataRef:t.dataRef},r=L(e,e=>[...e,n]);return e.activeOptionIndex===null&&e.dataRef.current.isSelected(t.dataRef.current.value)&&(r.activeOptionIndex=r.options.indexOf(n)),{...e,...r}},6:(e,t)=>{let n=L(e,e=>{let n=e.findIndex(e=>e.id===t.id);return n!==-1&&e.splice(n,1),e});return{...e,...n,activationTrigger:1}},7:(e,t)=>({...e,labelId:t.id})},R=(0,P.createContext)(null);R.displayName=`ListboxActionsContext`;function z(e){let t=(0,P.useContext)(R);if(t===null){let t=Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,z),t}return t}var B=(0,P.createContext)(null);B.displayName=`ListboxDataContext`;function V(e){let t=(0,P.useContext)(B);if(t===null){let t=Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,V),t}return t}function Ce(e,t){return b(t.type,Se,e,t)}var we=P.Fragment;function Te(e,t){let{value:n,defaultValue:r,form:i,name:a,onChange:o,by:s=(e,t)=>e===t,disabled:c=!1,horizontal:l=!1,multiple:u=!1,...d}=e,p=l?`horizontal`:`vertical`,m=h(t),[v=u?[]:void 0,S]=ee(n,o,r),[C,w]=(0,P.useReducer)(Ce,{dataRef:(0,P.createRef)(),listboxState:1,options:[],searchQuery:``,labelId:null,activeOptionIndex:null,activationTrigger:1}),E=(0,P.useRef)({static:!1,hold:!1}),ie=(0,P.useRef)(null),ae=(0,P.useRef)(null),oe=(0,P.useRef)(null),D=g(typeof s==`string`?(e,t)=>{let n=s;return e?.[n]===t?.[n]}:s),le=(0,P.useCallback)(e=>b(A.mode,{1:()=>v.some(t=>D(t,e)),0:()=>D(v,e)}),[v]),A=(0,P.useMemo)(()=>({...C,value:v,disabled:c,mode:+!!u,orientation:p,compare:D,isSelected:le,optionsPropsRef:E,labelRef:ie,buttonRef:ae,optionsRef:oe}),[v,c,u,C]);f(()=>{C.dataRef.current=A},[A]),re([A.buttonRef,A.optionsRef],(e,t)=>{var n;w({type:1}),T(t,ne.Loose)||(e.preventDefault(),(n=A.buttonRef.current)==null||n.focus())},A.listboxState===0);let de=(0,P.useMemo)(()=>({open:A.listboxState===0,disabled:c,value:v}),[A,c,v]),j=g(e=>{let t=A.options.find(t=>
3t.id===e);t&&N(t.dataRef.current.value)}),M=g(()=>{if(A.activeOptionIndex!==null){let{dataRef:e,id:t}=A.options[A.activeOptionIndex];N(e.current.value),w({type:2,focus:O.Specific,id:t})}}),fe=g(()=>w({type:0})),pe=g(()=>w({type:1})),me=g((e,t,n)=>e===O.Specific?w({type:2,focus:O.Specific,id:t,trigger:n}):w({type:2,focus:e,trigger:n})),he=g((e,t)=>(w({type:5,id:e,dataRef:t}),()=>w({type:6,id:e}))),ge=g(e=>(w({type:7,id:e}),()=>w({type:7,id:null}))),N=g(e=>b(A.mode,{0(){return S?.(e)},1(){let t=A.value.slice(),n=t.findIndex(t=>D(t,e));return n===-1?t.push(e):t.splice(n,1),S?.(t)}})),_e=g(e=>w({type:3,value:e})),ve=g(()=>w({type:4})),F=(0,P.useMemo)(()=>({onChange:N,registerOption:he,registerLabel:ge,goToOption:me,closeListbox:pe,openListbox:fe,selectActiveOption:M,selectOption:j,search:_e,clearSearch:ve}),[]),ye={ref:m},I=(0,P.useRef)(null),be=x();return(0,P.useEffect)(()=>{I.current&&r!==void 0&&be.addEventListener(I.current,`reset`,()=>{S?.(r)})},[I,S]),P.createElement(R.Provider,{value:F},P.createElement(B.Provider,{value:A},P.createElement(ue,{value:b(A.listboxState,{0:k.Open,1:k.Closed})},a!=null&&v!=null&&te({[a]:v}).map(([e,t],n)=>P.createElement(se,{features:ce.Hidden,ref:n===0?e=>{I.current=e?.closest(`form`)??null}:void 0,..._({key:e,as:`input`,type:`hidden`,hidden:!0,readOnly:!0,form:i,disabled:c,name:e,value:t})})),y({ourProps:ye,theirProps:d,slot:de,defaultTag:we,name:`Listbox`}))))}var Ee=`button`;function De(e,t){let n=S(),{id:r=`headlessui-listbox-button-${n}`,...i}=e,a=V(`Listbox.Button`),o=z(`Listbox.Button`),s=h(a.buttonRef,t),c=x(),l=g(e=>{switch(e.key){case C.Space:case C.Enter:case C.ArrowDown:e.preventDefault(),o.openListbox(),c.nextFrame(()=>{a.value||o.goToOption(O.First)});break;case C.ArrowUp:e.preventDefault(),o.openListbox(),c.nextFrame(()=>{a.value||o.goToOption(O.Last)});break}}),u=g(e=>{switch(e.key){case C.Space:e.preventDefault();break}}),d=g(e=>{if(de(e.currentTarget))return e.preventDefault();a.listboxState===0?(o.closeListbox(),c.nextFrame(()=>a.buttonRef.current?.focus({preventScroll:!0}))):(e.preventDefault(),o.openListbox())}),f=F(()=>{if(a.labelId)return[a.labelId,r].join(` `)},[a.labelId,r]),p=(0,P.useMemo)(()=>({open:a.listboxState===0,disabled:a.disabled,value:a.value}),[a]);return y({ourProps:{ref:s,id:r,type:ie(e,a.buttonRef),"aria-haspopup":`listbox`,"aria-controls":a.optionsRef.current?.id,"aria-expanded":a.listboxState===0,"aria-labelledby":f,disabled:a.disabled,onKeyDown:l,onKeyUp:u,onClick:d},theirProps:i,slot:p,defaultTag:Ee,name:`Listbox.Button`})}var Oe=`label`;function ke(e,t){let n=S(),{id:r=`headlessui-listbox-label-${n}`,...i}=e,a=V(`Listbox.Label`),o=z(`Listbox.Label`),s=h(a.labelRef,t);f(()=>o.registerLabel(r),[r]);let c=g(()=>a.buttonRef.current?.focus({preventScroll:!0})),l=(0,P.useMemo)(()=>({open:a.listboxState===0,disabled:a.disabled}),[a]);return y({ourProps:{ref:s,id:r,onClick:c},theirProps:i,slot:l,defaultTag:Oe,name:`Listbox.Label`})}var Ae=`ul`,je=v.RenderStrategy|v.Static;function Me(e,t){var n;let r=S(),{id:i=`headlessui-listbox-options-${r}`,...a}=e,o=V(`Listbox.Options`),s=z(`Listbox.Options`),c=h(o.optionsRef,t),l=x(),u=x(),f=le(),p=f===null?o.listboxState===0:(f&k.Open)===k.Open;(0,P.useEffect)(()=>{let e=o.optionsRef.current;e&&o.listboxState===0&&e!==w(e)?.activeElement&&e.focus({preventScroll:!0})},[o.listboxState,o.optionsRef]);let m=g(e=>{switch(u.dispose(),e.key){case C.Space:if(o.searchQuery!==``)return e.preventDefault(),e.stopPropagation(),s.search(e.key);case C.Enter:if(e.preventDefault(),e.stopPropagation(),o.activeOptionIndex!==null){let{dataRef:e}=o.options[o.activeOptionIndex];s.onChange(e.current.value)}o.mode===0&&(s.closeListbox(),d().nextFrame(()=>o.buttonRef.current?.focus({preventScroll:!0})));break;case b(o.orientation,{vertical:C.ArrowDown,horizontal:C.ArrowRight}):return e.preventDefault(),e.stopPropagation(),s.goToOption(O.Next);case b(o.orientation,{vertical:C.ArrowUp,horizontal:C.ArrowLeft}):return e.preventDefault(),e.stopPropagation(),s.goToOption(O.Previous);case C.Home:case C.PageUp:return e.preventDefault(),e.stopPropagation(),s.goToOption(O.First);case C.End:case C.PageDown:return e.preventDefault(),e.stopPropagation(),s.goToOption(O.Last);case C.Escape:return e.preventDefault(),e.stopPropagation(),s.closeListbox(),l.nextFrame(()=>o.buttonRef.current?.focus({preventScroll:!0}));case C.Tab:e.preventDefault(),e.stopPropagation();break;default:e.key.length===1&&(s.search(e.key),u.setTimeout(()=>s.clearSearch(),350));break}}),_=F(()=>o.buttonRef.current?.id,[o.buttonRef.current]),v=(0,P.useMemo)(()=>({open:o.listboxState===0}),[o]);return y({ourProps:{"aria-activedescendant":o.activeOptionIndex===null||(n=o.options[o.activeOptionIndex])==null?void 0:n.id,"aria-multiselectable":o.mode===1?!0:void 0,"aria-labelledby":_,"aria-orientation":o.orientation,id:i,onKeyDown:m,role:`listbox`,tabIndex:0,ref:c},theirProps:a,slot:v,defaultTag:Ae,features:je,visible:p,name:`Listbox.Options`})}var Ne=`li`;function Pe(e,t){let n=S(),{id:r=`headlessui-listbox-option-${n}`,disabled:i=!1,value:a,...o}=e,s=V(`Listbox.Option`),c=z(`Listbox.Option`),l=s.activeOptionIndex===null?!1:s.options[s.activeOptionIndex].id===r,u=s.isSelected(a),m=(0,P.useRef)(null),_=D(m),v=p({disabled:i,value:a,domRef:m,get textValue(){return _()}}),b=h(t,m);f(()=>{if(s.listboxState!==0||!l||s.activationTrigger===0)return;let e=d();return e.requestAnimationFrame(()=>{var e,t;(t=(e=m.current)?.scrollIntoView)==null||t.call(e,{block:`nearest`})}),e.dispose},[m,l,s.listboxState,s.activationTrigger,s.activeOptionIndex]),f(()=>c.registerOption(r,v),[v,r]);let ee=g(e=>{if(i)return e.preventDefault();c.onChange(a),s.mode===0&&(c.closeListbox(),d().nextFrame(()=>s.buttonRef.current?.focus({preventScroll:!0})))}),te=g(()=>
3{if(i)return c.goToOption(O.Nothing);c.goToOption(O.Specific,r)}),x=ae(),C=g(e=>x.update(e)),w=g(e=>{x.wasMoved(e)&&(i||l||c.goToOption(O.Specific,r,0))}),T=g(e=>{x.wasMoved(e)&&(i||l&&c.goToOption(O.Nothing))}),E=(0,P.useMemo)(()=>({active:l,selected:u,disabled:i}),[l,u,i]);return y({ourProps:{id:r,ref:b,role:`option`,tabIndex:i===!0?void 0:-1,"aria-disabled":i===!0?!0:void 0,"aria-selected":u,disabled:void 0,onClick:ee,onFocus:te,onPointerEnter:C,onMouseEnter:C,onPointerMove:w,onMouseMove:w,onPointerLeave:T,onMouseLeave:T},theirProps:o,slot:E,defaultTag:Ne,name:`Listbox.Option`})}var Fe=m(Te),Ie=m(De),Le=m(ke),Re=m(Me),ze=m(Pe),H=Object.assign(Fe,{Button:Ie,Label:Le,Options:Re,Option:ze}),U=t(),W=(0,P.createContext)(void 0);W.displayName=`PreferencesContext`;var Be=({loaderData:e,children:t})=>{let{subscription:n,subscriberId:r,isLoggedIn:i,publication:a,preferences:o,organizationSubscriptions:s}=e,c=(0,P.useMemo)(()=>({publication:a,subscription:n||null,subscriberId:r,isLoggedIn:i,preferences:o,organizationSubscriptions:s}),[a,n,r,i,o,s]);return(0,U.jsx)(W.Provider,{value:c,children:t})},G=()=>{let e=(0,P.useContext)(W);if(e===void 0)throw Error(`usePreferencesContext must be used within a PreferencesProvider`);return e},Ve=({title:e,text:t})=>(0,U.jsx)(c,{title:e,children:(0,U.jsx)(`p`,{className:`mt-4 py-4 text-left text-gray-500 lg:py-8 lg:text-center`,children:t})}),K=e(a(),1),q=({checked:e,onChange:t})=>(0,U.jsxs)(M,{checked:e,onChange:t,className:(0,K.default)(`relative inline-flex h-6 w-11 items-center rounded-full`,e?`bg-[#111827]`:`bg-[#E5E7EB]`),children:[(0,U.jsx)(`span`,{className:`sr-only`,children:`Enable`}),(0,U.jsx)(`span`,{className:(0,K.default)(`inline-block h-5 w-5 transform rounded-full bg-white transition`,e?`translate-x-[22px]`:`translate-x-[2px]`)})]}),He=({organizationSubscription:e})=>{let[t,n]=(0,P.useState)(e.subscribed),{subscription:a}=G(),{t:s}=r(``,{keyPrefix:`preferences.organization_subscriptions`}),c=i(),l=c.data;return u(l?.toast),(0,U.jsxs)(`div`,{className:`flex flex-row items-center justify-between`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col w-2/3`,children:[(0,U.jsx)(o,{as:`p`,size:`sm`,weight:`medium`,className:`text-[#111827]`,children:e.name}),(0,U.jsx)(o,{as:`p`,size:`sm`,className:`font-medium text-[#374151]`,children:e.description})]}),(0,U.jsx)(q,{checked:t,onChange:t=>{let r=t===!0;n(r);let i=new FormData;i.append(`organization_subscription_success_message`,s(`toast.success`)),i.append(`organization_subscription_error_message`,s(`toast.error`)),i.append(`subscriber_id`,a?.subscriber_id||``),i.append(`publication_id`,e.publication_id),i.append(`subscribed`,String(r)),c.submit(i,{method:`patch`,action:`/update_subscriber_organization_subscription`})}})]})},Ue=()=>{let{subscription:e,publication:t,organizationSubscriptions:n}=G(),{t:i}=r(``,{keyPrefix:`preferences.organization_subscriptions`});return t.has_subscriber_preferences?(0,U.jsx)(c,{title:i(`title`),description:i(`description`,{subscriber_email:e.email}),children:(0,U.jsx)(`div`,{className:`flex flex-col gap-y-4`,children:n.map(e=>(0,U.jsx)(He,{organizationSubscription:e},e.publication_id))})}):(0,U.jsx)(Ve,{title:i(`title`),text:i(`empty_state`)})},J=function(e){return e.TEXT=`text`,e.SINGLE_CHOICE=`single_choice`,e.MULTIPLE_CHOICE=`multiple_choice`,e.DROPDOWN=`dropdown`,e.BOOLEAN=`boolean`,e}({}),Y=function(e){return e.RADIO_BUTTONS=`radio_buttons`,e.CHECKBOXES=`checkboxes`,e.NUMERALS=`numerals`,e.UNSTYLED=`unstyled`,e}({}),X=({description:e})=>(0,U.jsx)(o,{as:`p`,size:`sm`,className:`font-medium text-[#374151]`,children:e}),Z=({name:e})=>(0,U.jsx)(o,{as:`p`,size:`sm`,weight:`medium`,className:`text-[#111827]`,children:e}),We=({preference:e,onChange:t})=>{let[n,r]=(0,P.useState)(!!(e.value&&e.value.toString().toLowerCase()===`true`));return(0,U.jsxs)(`div`,{className:`flex flex-row items-center gap-x-4 gap-y-2`,children:[(0,U.jsxs)(`div`,{className:`flex w-80 flex-col gap-y-0.5`,children:[(0,U.jsx)(Z,{name:e.name}),(0,U.jsx)(X,{description:e.description})]}),(0,U.jsx)(q,{checked:n,onChange:e=>{let n=e===!0;r(n),t(n)}})]})},Ge=({options:e,selectedValue:t,onChange:n,placeholder:r})=>(0,U.jsx)(H,{value:t,onChange:n,children:(0,U.jsxs)(`div`,{className:`relative mt-1`,children:[(0,U.jsxs)(H.Button,{className:`relative w-full cursor-default rounded-lg border border-[#
3E5E7EB] bg-white py-2 pl-3 pr-10 text-left shadow-sm focus:outline-none focus-visible:border-indigo-500 focus-visible:ring-2 focus-visible:ring-white/75 focus-visible:ring-offset-2 focus-visible:ring-offset-orange-300 sm:text-sm`,children:[(0,U.jsx)(`span`,{className:`block truncate`,children:t.name||r}),(0,U.jsx)(`span`,{className:`pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2`,children:(0,U.jsx)(ve,{className:`h-5 w-5 text-gray-400`,"aria-hidden":`true`})})]}),(0,U.jsx)(A,{as:U.Fragment,leave:`transition ease-in duration-100`,leaveFrom:`opacity-100`,leaveTo:`opacity-0`,children:(0,U.jsx)(H.Options,{className:`absolute z-10 mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-sm ring-1 ring-black/5 focus:outline-none sm:text-sm`,children:e.map((e,n)=>{let r=t?.value===e.value;return(0,U.jsx)(H.Option,{className:({active:e})=>`relative cursor-default select-none px-2 py-2 text-[#111827] ${e&&`bg-[#E5E7EB]`}`,value:e,children:(0,U.jsxs)(`div`,{className:`flex flex-row items-center gap-x-2 truncate ${r?`font-medium`:`font-normal`}`,children:[r?(0,U.jsx)(l,{className:`h-4 w-4`,"aria-hidden":`true`}):null,e.name]})},n)})})})]})}),Ke=({preference:e,onChange:t})=>{let[n,r]=(0,P.useState)(e.value?{name:e.value,value:e.value}:{});return(0,U.jsxs)(`div`,{className:`flex flex-col gap-y-2`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-y-0.5`,children:[(0,U.jsx)(Z,{name:e.name}),(0,U.jsx)(X,{description:e.description})]}),(0,U.jsx)(`div`,{className:`w-96`,children:(0,U.jsx)(Ge,{onChange:e=>{r(e),t(e.value||``)},selectedValue:n,options:e.subscriber_preference_options.map(e=>({name:e.value,value:e.value})),placeholder:`Select option`})})]})},Q=({children:e,className:t,paddingClassName:n=`px-1 py-2`})=>(0,U.jsx)(`div`,{className:(0,K.default)(`w-full sm:w-96`,t,n),children:e}),$=({children:e,isSelected:t})=>(0,U.jsx)(o,{as:`p`,size:`sm`,weight:t?`medium`:`regular`,className:(0,K.default)(t?`text-[#111827]`:`text-[#374151]`),children:e}),qe=({name:e,value:t,onChange:n,isSelected:r})=>(0,U.jsxs)(Q,{paddingClassName:`px-0 py-1`,children:[(0,U.jsx)(`input`,{name:e,id:e,type:`checkbox`,className:`hidden`,onChange:e=>n(t,e.currentTarget.checked),value:t,"aria-hidden":!0}),(0,U.jsxs)(`label`,{htmlFor:e,className:`inline-flex flex-row items-center gap-x-2`,children:[(0,U.jsx)(`span`,{className:(0,K.default)(`flex h-4 w-4 items-center justify-center rounded-md border`,r?`border-[#111827]`:`border-[##6B7280]`),children:r?(0,U.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,children:[(0,U.jsx)(`rect`,{x:`0.5`,y:`0.5`,width:`15`,height:`15`,rx:`3.5`,fill:`#111827`,stroke:`#111827`}),(0,U.jsx)(`path`,{d:`M12.104 5.53608L12.0991 5.53018L12.0938 5.52467C11.9337 5.35887 11.6755 5.35845 11.5149 5.52341L7.32964 9.72698L5.29657 7.67973C5.13598 7.51467 4.87766 7.51505 4.71753 7.68089C4.56081 7.84318 4.56081 8.09929 4.71753 8.26158L4.71751 8.2616L4.71949 8.26358L6.8358 10.3947C6.9687 10.5317 7.1496 10.6 7.31783 10.6C7.50031 10.6 7.66872 10.5299 7.79976 10.3948L12.0652 6.11067C12.2386 5.94943 12.2371 5.69679 12.104 5.53608ZM7.41493 9.81286L7.41338 9.8113C7.41392 9.81183 7.41441 9.81236 7.41491 9.81288L7.41493 9.81286Z`,fill:`#F9FAFB`,stroke:`#F9FAFB`,strokeWidth:`0.4`})]}):null}),(0,U.jsx)($,{isSelected:r,children:t})]})]}),Je=({name:e,value:t,onChange:n,isSelected:r,index:i})=>(0,U.jsxs)(Q,{className:(0,K.default)(`hover:bg-[#F3F4F6]`,r?`rounded-sm bg-[#F3F4F6]`:``),children:[(0,U.jsx)(`input`,{name:e,id:e,type:`checkbox`,className:`hidden`,onChange:e=>n(t,e.currentTarget.checked),value:t,"aria-hidden":!0}),(0,U.jsxs)(`label`,{htmlFor:e,className:(0,K.default)(`inline-flex flex-row items-center justify-between gap-x-2`),children:[(0,U.jsxs)($,{isSelected:r,children:[typeof i==`number`?`${i+1}.`:null,` `,t]}),r?(0,U.jsx)(l,{className:`h-4 w-4`}):null]})]}),Ye=({value:e,isSelected:t})=>(0,U.jsx)(Q,{paddingClassName:`px-0 py-1`,children:(0,U.jsxs)(`div`,{className:`flex flex-row items-center gap-x-2`,children:[(0,U.jsx)(`span`,{className:`flex h-4 w-4 items-center justify-center rounded-full border border-[#111827] bg-white`,children:t?(0,U.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-[#111827]`,children:`\xA0`}):null}),(0,U.jsx)(j.Label,{children:(0,U.jsx)($,{isSelected:t,children:e})})]})}),Xe=e=>[Y.CHECKBOXES,Y.NUMERALS,Y.UNSTYLED].includes(e.display_type)?typeof e.value==`string`?e.value.split(`||`):Array.isArray(e.value)?e.value:[]:[],Ze=({preference:e,onChange:t})=>{let[n,r]=(0,P.useState)(e.display_type===Y.RADIO_BUTTONS&&e.value||null),[i,a]=(0,P.useState)(Xe(e)),o=e=>{r(e),t(e)},s=(e,n)=>{if(i.includes(e)){let n=[...i].filter(t=>t!==e);a(n),t(n.join(`||`))}else{let n=[...i,e];a(n),t(n.join(`||`))}};return(0,U.jsxs)(`div`,{className:`flex flex-col gap-x-4 gap-y-2`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-y-0.5`,children:[(0,U.jsx)(Z,{name:e.name}),(0,U.jsx)(X,{description:e.description})]}),e.display_type===Y.RADIO_BUTTONS?(0,U.jsx)(j,{value:n,onChange:o,children:(0,U.jsx)(`ul`,{className:`space-y-1`,children:e.subscriber_preference_options.map(e=>{let t=n===e.value;return(0,U.jsx)(`li`,{children:(0,U.jsx)(j.Option,{value:e.value,children:(0,U.jsx)(Ye,{value:e.value,isSelected:t})})},e.id)})})}):null,[Y.CHECKBOXES,Y.NUMERALS,Y.UNSTYLED].includes(e.display_type)?(0,U.jsx)(`ul`,{className:`space-y-1`,children:e.subscriber_preference_options.map((t,n)=>{let r=i.includes(t.value);switch(e.display_type){case Y.CHECKBOXES:return(0,U.jsx)(`li`,{children:(0,U.jsx)(qe,{name:`${e.id}-${t.id}`,value:t.value,isSelected:r,onChange:s})},t.id);case Y.NUMERALS:return(0,U.jsx)(`li`,{children:(0,U.jsx)(Je,{name:`${e.id}-${t.id}`,value:t.value,isSelected:r,onChange:s,index:n})},t.id);case Y.UNSTYLED:return(0,U.jsx)(`li`,{children:(0,U.jsx)(Je,{name:`${e.id}-${t.id}`,value:t.value,isSelected:r,onChange:s})},t.id);default:return null}})}):null]})},Qe=({preference:e,onChange:t})=>{let[n,r]=(0,P.useState)(e.value===!0||e.value===`true`),i=e=>{r(e),t(e)},a=e.newsletter_list,s=e.name||a?.name,c=e.description||a?.description;return(0,U.jsxs)(`div`,{className:`flex flex-row items-center gap-x-4 gap-y-2`,"data-newsletter-slug":a?.slug,children:[(0,U.jsxs)(`div`,{className:`flex flex-1 items-center gap-x-3`,children:[a?.logo_url?(0,U.jsx)(`img`,{src:a.logo_url,alt:s,className:`h-10 w-10 shrink-0 rounded-full object-cover`}):null,(0,U.jsxs)(`div`,{className:`flex flex-col gap-y-0.5`,children:[(0,U.jsx)(o,{as:`p`,size:`sm`,weight:`medium`,className:`text-[#111827]`,children:s}),c?(0,U.jsx)(o,{as:`p`,size:`xs`,className:`text-[#6B7280]`,children:c}):null]})]}),(0,U.jsx)(q,{checked:n,onChange:i})]})},$e=({preference:e,onChange:t})=>(0,U.jsxs)(`div`,{className:`flex flex-col gap-y-2`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-y-0.5`,children:[(0,U.jsx)(Z,{name:e.name}),(0,U.jsx)(X,{description:e.description})]}),(0,U.jsx)(`div`,{className:`w-96`,children:(0,U.jsx)(fe,{name:`preference-text-field-${e.id}`,placeholder:`Enter text here`,onBlur:e=>{e.currentTarget.value.trim()!==``&&t(e.currentTarget.value)},defaultValue:e.value})})]}),et=({preference:e})=>{let{subscription:t}=G(),{t:n}=r(``,{keyPrefix:`preferences`}),a=i(),o=a.data;u(o?.toast);let s=r=>{let i=new FormData;i.append(`preferences_success_message`,n(`toast.success`)),i.append(`preferences_error_message`,n(`toast.error`)),i.append(`subscriber_id`,t?.subscriber_id||``),i.append(`preference_value`,r),i.append(`preference_id`,e.id),a.submit(i,{method:`patch`,action:`/update_subscriber_preference`})};return e.newsletter_list?(0,U.jsx)(Qe,{onChange:s,preference:e}):(0,U.jsxs)(U.Fragment,{children:[e.preference_type===J.BOOLEAN?(0,U.jsx)(We,{onChange:s,preference:e}):null,e.preference_type===J.MULTIPLE_CHOICE?(0,U.jsx)(Ze,{onChange:s,preference:e}):null,e.preference_type===J.TEXT?(0,U.jsx)($e,{onChange:s,preference:e}):null,e.preference_type===J.DROPDOWN?(0,U.jsx)(Ke,{onChange:s,preference:e}):null]})},tt=()=>{let{subscription:e,publication:t,preferences:n}=G(),{t:i}=r(``,{keyPrefix:`preferences`});return!n||n.length===0||!t.has_subscriber_preferences||!e?(0,U.jsx)(Ve,{title:i(`title`),text:i(`empty_state`)}):(0,U.jsx)(c,{title:i(`title`),description:(0,U.jsxs)(U.Fragment,{children:[i(`description`,{subscriber_email:e.email}),(0,U.jsx)(`p`,{className:`text-xs text-gray-500`,children:i(`note`)})]}),children:(0,U.jsx)(`div`,{className:`flex flex-col gap-y-6`,children:n.map(e=>(0,U.jsx)(et,{preference:e},e.id))})})},nt=({data:e,matches:t})=>{let n=(t?.find(e=>e?.id===`root`))?.data?.publication,r=e?.metaTitle;return!n||!r?[{robots:`noindex`}]:he({canonicalUrl:me(e?.requestUrl),matches:t,returnEarlyCheck:!r,overrides:{robots:`noindex`,title:r,de
3scription:`Preferences - ${n.name}`}})},rt=()=>{let{subscription:e,publication:t,isLoggedIn:n,organizationSubscriptions:r}=G();return(0,U.jsxs)(s,{isLoggedIn:n,subscriberId:e?.subscriber_id||``,hasPreferencesEnabled:n&&t.has_subscriber_preferences,children:[e&&n?(0,U.jsxs)(U.Fragment,{children:[r&&r.length>0?(0,U.jsx)(Ue,{}):null,(0,U.jsx)(tt,{})]}):null,!!e&&(0,U.jsx)(N,{})]})},it=()=>{let e=pe();return(0,U.jsx)(Be,{loaderData:e,children:(0,U.jsx)(ge,{publication:e.publication,isLoggedIn:e.isLoggedIn,subscription:e.subscription,children:(0,U.jsx)(rt,{})})})};export{it as default,nt as meta};
4//# sourceMappingURL=preferences-BGzJ87Pi.js.map
5//# debugId=0a17094b-ca1d-5385-b531-b76aaae3c14a

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.