@hot-updater/console 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.output/nitro.json +1 -1
- package/.output/public/assets/{ConsoleFeatureUnavailable-jB4Loglh.js → ConsoleFeatureUnavailable-Bf8tgug-.js} +1 -1
- package/.output/public/assets/{EventDetails-B6yUsyNA.js → EventDetails-CgtEWl-Y.js} +1 -1
- package/.output/public/assets/HashValueDisplay-DvXl147n.js +1 -0
- package/.output/public/assets/{InsightsPageHeader-B892oVml.js → InsightsPageHeader-eViliItR.js} +1 -1
- package/.output/public/assets/{NotFoundPage-DIqCpWa3.js → NotFoundPage-HomiHjdL.js} +1 -1
- package/.output/public/assets/{alert-dialog-Bbk_4-WJ.js → alert-dialog-BSs_5Od-.js} +1 -1
- package/.output/public/assets/{api-DCM0wr6O.js → api-DSWk32Mz.js} +1 -1
- package/.output/public/assets/api-keys-CHA2X9W0.js +1 -0
- package/.output/public/assets/api-keys-D0yD891K.js +1 -0
- package/.output/public/assets/arrow-left-vK2qGQsd.js +1 -0
- package/.output/public/assets/arrow-up-right-Dz8o-Kab.js +1 -0
- package/.output/public/assets/chevron-right-CBl7aqu_.js +1 -0
- package/.output/public/assets/{clipboard-DS9ucUQL.js → clipboard-BYT_TJ0K.js} +1 -1
- package/.output/public/assets/{console-features-api-BH5m_PtQ.js → console-features-api-BD7j--gS.js} +1 -1
- package/.output/public/assets/{dialog-Bqbb7B0N.js → dialog-YKZpU5St.js} +1 -1
- package/.output/public/assets/{dist-LxKJB-Vu.js → dist-B7eA4Mtf.js} +1 -1
- package/.output/public/assets/{empty-CuT2UhFp.js → empty-L3UcNk_l.js} +1 -1
- package/.output/public/assets/{field-BBDpjIqu.js → field-DNqNwq7i.js} +1 -1
- package/.output/public/assets/{index-6o51GkFe.js → index-C-dDMnWK.js} +4 -4
- package/.output/public/assets/{input-group-ja_30qaF.js → input-group-C9ZIjV0o.js} +1 -1
- package/.output/public/assets/insights-C54__dPi.js +1 -0
- package/.output/public/assets/insights-DM0CTj58.js +2 -0
- package/.output/public/assets/insights-SVMoazdd.js +42 -0
- package/.output/public/assets/{insights-api-BigAU9sZ.js → insights-api-BsX1zQDf.js} +1 -1
- package/.output/public/assets/insights-search-B-F2wop6.js +1 -0
- package/.output/public/assets/insights-usage-rpc-CSAoKS_b.js +1 -0
- package/.output/public/assets/insights_.distribution-BAaD6rZK.js +1 -0
- package/.output/public/assets/insights_.distribution-C6tGV7qU.js +2 -0
- package/.output/public/assets/insights_.distribution-oxPmgcHr.js +1 -0
- package/.output/public/assets/installations-1jALHnM3.js +1 -0
- package/.output/public/assets/installations-DUidui9Z.js +1 -0
- package/.output/public/assets/{installations-BazSJXE0.js → installations-RfpwK-ld.js} +2 -2
- package/.output/public/assets/{key-round-wS_SIZ6b.js → key-round-CrqLmblG.js} +1 -1
- package/.output/public/assets/{list-CgrYiadM.js → list-BSpjGUS6.js} +1 -1
- package/.output/public/assets/{refresh-cw-BYgoNCco.js → refresh-cw-BMlpOsfM.js} +1 -1
- package/.output/public/assets/remote-config-BcoOZ9fs.js +1 -0
- package/.output/public/assets/remote-config-BtStN5bt.js +1 -0
- package/.output/public/assets/{remote-config-Br56BODb.js → remote-config-Cwwsatrr.js} +4 -4
- package/.output/public/assets/routes-Bc3J564t.js +2 -0
- package/.output/public/assets/routes-Bxu5_zNh.js +1 -0
- package/.output/public/assets/search-B_o3avCI.js +1 -0
- package/.output/public/assets/select-BE-xONpm.js +1 -0
- package/.output/public/assets/{sidebar-DNVyJPfX.js → sidebar-CQ6iq0qe.js} +1 -1
- package/.output/public/assets/smartphone--CTny1h9.js +1 -0
- package/.output/public/assets/{switch-DZ1TPwx-.js → switch-DR0WP2g8.js} +1 -1
- package/.output/public/assets/{table-Gm4qRWwE.js → table-DW0243Jw.js} +1 -1
- package/.output/public/assets/tabs-B4Ffq4fD.js +1 -0
- package/.output/public/assets/{undo-2-CmrHjwFc.js → undo-2-Dcq6sgUo.js} +1 -1
- package/.output/public/assets/{useCompositeListItem-9E4pj_CH.js → useCompositeListItem-VmWjhZ9j.js} +1 -1
- package/.output/public/assets/{valueToPercent-CH8GCHaL.js → valueToPercent-C-rPd_Or.js} +1 -1
- package/.output/server/{__23tanstack-start-server-fn-resolver-BpRlos5Q.mjs → __23tanstack-start-server-fn-resolver-CludPNXL.mjs} +40 -40
- package/.output/server/_libs/@base-ui/react+[...].mjs +20 -20
- package/.output/server/_libs/@tanstack/react-router+[...].mjs +1 -1
- package/.output/server/_libs/@tanstack/react-router-ssr-query+[...].mjs +1 -1
- package/.output/server/_libs/recharts+[...].mjs +1 -1
- package/.output/server/_libs/sonner.mjs +1 -1
- package/.output/server/_ssr/{BundleIdDisplay-x94o9rlU.mjs → BundleIdDisplay-CAIibMnZ.mjs} +2 -2
- package/.output/server/_ssr/{ConsoleFeatureUnavailable-ldW8v8-q.mjs → ConsoleFeatureUnavailable-CTbvhAts.mjs} +6 -6
- package/.output/server/_ssr/{EventDetails-Q8kfj9Nr.mjs → EventDetails-Dz5O2hup.mjs} +6 -6
- package/.output/server/_ssr/{HashValueDisplay-n1GholGS.mjs → HashValueDisplay-BBUzwDu0.mjs} +2 -2
- package/.output/server/_ssr/{InsightsPageHeader-BSUX3Ye9.mjs → InsightsPageHeader-BisxLsg_.mjs} +6 -6
- package/.output/server/_ssr/{NotFoundPage-DZzOOzS3.mjs → NotFoundPage-oKeLJAKO.mjs} +2 -2
- package/.output/server/_ssr/{alert-dialog-C43Doa0I.mjs → alert-dialog-D9gKu-6B.mjs} +1 -1
- package/.output/server/_ssr/{api-oZjRn9tP.mjs → api-Ctf4ONl0.mjs} +3 -3
- package/.output/server/_ssr/{api-keys-CEnM9fqG.mjs → api-keys-BYVLgcvB.mjs} +2 -2
- package/.output/server/_ssr/{api-keys-B4sYm8dM.mjs → api-keys-CBdMIgQH.mjs} +7 -7
- package/.output/server/_ssr/{api-keys-rpc-BIFuUgMt.mjs → api-keys-rpc-D_MGDGrN.mjs} +3 -3
- package/.output/server/_ssr/{api-rpc-BNiFRRK8.mjs → api-rpc-BOn0fmSj.mjs} +3 -3
- package/.output/server/_ssr/{auth-rpc-DnZqYxyq.mjs → auth-rpc-MuU8dCi_.mjs} +4 -4
- package/.output/server/_ssr/{auth.server-DFpyxRDd.mjs → auth.server-QA_53YPj.mjs} +2 -2
- package/.output/server/_ssr/{config.server-DskXCAyI.mjs → config.server-fNcSQwfX.mjs} +3 -3
- package/.output/server/_ssr/{console-access-BJfAXknd.mjs → console-access-C6aSaMHp.mjs} +2 -2
- package/.output/server/_ssr/{console-features-api-C9kiKvaV.mjs → console-features-api-nN-3jUli.mjs} +5 -5
- package/.output/server/_ssr/{console-features-rpc-P0GL7Z-R.mjs → console-features-rpc-By6Aak_o.mjs} +3 -3
- package/.output/server/_ssr/{dialog-BbYDMjdC.mjs → dialog-IVRlM1J9.mjs} +1 -1
- package/.output/server/_ssr/{empty-CVLGfxuu.mjs → empty-CXw7UkQ9.mjs} +2 -2
- package/.output/server/_ssr/{field-asw83X0v.mjs → field-D5rycmNU.mjs} +2 -2
- package/.output/server/_ssr/{input-group-CuYJHosb.mjs → input-group-CcwGtPaf.mjs} +1 -1
- package/.output/server/_ssr/{insights-B55FG5fm.mjs → insights-BO3tHc8m.mjs} +5 -5
- package/.output/server/_ssr/{insights-CWnHIFUV.mjs → insights-BfjtzxAt.mjs} +2 -2
- package/.output/server/_ssr/{insights-CpLpedFZ.mjs → insights-CKC8xDHf.mjs} +24 -24
- package/.output/server/_ssr/{insights-api-sjws23WF.mjs → insights-api-CxvjRcJY.mjs} +3 -3
- package/.output/server/_ssr/{insights-failures-rpc-BvbWvqNf.mjs → insights-failures-rpc-3LR3gf5_.mjs} +4 -4
- package/.output/server/_ssr/{insights-recovery-rpc-GiYXdkaY.mjs → insights-recovery-rpc-KZuPFtPi.mjs} +3 -3
- package/.output/server/_ssr/{insights-rpc-DP_8Rmz4.mjs → insights-rpc-B5DF87z1.mjs} +3 -3
- package/.output/server/_ssr/{InsightsInfo-DuJFatQO.mjs → insights-search--Biw1Q83.mjs} +31 -31
- package/.output/server/_ssr/{insights-usage-rpc-BiolgB8e.mjs → insights-usage-rpc-BjyoZrsk.mjs} +3 -3
- package/.output/server/_ssr/{insights-usage-rpc-KStL0zOx.mjs → insights-usage-rpc-Dvt-RmGH.mjs} +3 -3
- package/.output/server/_ssr/{insights_.distribution-CVrnbP3R.mjs → insights_.distribution-C9WdD2pp.mjs} +2 -2
- package/.output/server/_ssr/{insights_.distribution-DN9pR422.mjs → insights_.distribution-Czd0R3x1.mjs} +13 -13
- package/.output/server/_ssr/{insights_.distribution-D2HaNTAA.mjs → insights_.distribution-DMcff9C5.mjs} +5 -5
- package/.output/server/_ssr/{installations-DD1g__Nc.mjs → installations-BZg4I7rk.mjs} +4 -4
- package/.output/server/_ssr/{installations-BSCmFq8Q.mjs → installations-CETpe6aH.mjs} +10 -10
- package/.output/server/_ssr/{installations-BHmbbnH8.mjs → installations-CbX4TTtL.mjs} +2 -2
- package/.output/server/_ssr/{release-adoption-rpc-BsstqxUp.mjs → release-adoption-rpc-CEY0I6O4.mjs} +5 -5
- package/.output/server/_ssr/{remote-config-Dv1ccMo-.mjs → remote-config-BZoufETF.mjs} +2 -2
- package/.output/server/_ssr/{remote-config-C2Ee8lXO.mjs → remote-config-CORErMXh.mjs} +2 -2
- package/.output/server/_ssr/{remote-config-of0lGQH8.mjs → remote-config-D2VfWi8m.mjs} +16 -16
- package/.output/server/_ssr/{remote-config-rpc-BzX31mUS.mjs → remote-config-rpc-DKcBdTyh.mjs} +3 -3
- package/.output/server/_ssr/{router-D8NuoJ_I.mjs → router-CRDbJodQ.mjs} +14 -14
- package/.output/server/_ssr/{routes-V8sDybGf.mjs → routes-Bpmxf-r8.mjs} +12 -12
- package/.output/server/_ssr/{routes-DgvnFqDy.mjs → routes-DC3sK0ON.mjs} +38 -25
- package/.output/server/_ssr/{select-t3iXRwc9.mjs → select-CzanJCWl.mjs} +1 -1
- package/.output/server/_ssr/{server-h4VxnExB.mjs → server-C4JCTB-q.mjs} +3 -3
- package/.output/server/_ssr/{sidebar-DJcErBMo.mjs → sidebar-DcFhy0Zq.mjs} +18 -18
- package/.output/server/_ssr/ssr.mjs +1 -1
- package/.output/server/_ssr/{switch-E-btwMGt.mjs → switch-DAHDLynM.mjs} +2 -2
- package/.output/server/_ssr/{table-37Dd23TN.mjs → table-DNcXrt9t.mjs} +1 -1
- package/.output/server/_ssr/{tabs-DEFnTm95.mjs → tabs-BlbEfZeV.mjs} +2 -2
- package/.output/server/_tanstack-start-manifest_v-DaM-WBL0.mjs +139 -0
- package/.output/server/index.mjs +265 -265
- package/package.json +7 -7
- package/src/components/{features/insights/InsightsInfo.tsx → InfoTooltip.tsx} +1 -1
- package/src/components/features/insights/AppUsage.tsx +3 -3
- package/src/components/features/insights/InsightsOverview.tsx +5 -5
- package/src/components/features/insights/ReleaseActivity.tsx +5 -5
- package/src/components/features/insights/ReportingDevicesSummary.tsx +3 -3
- package/src/components/features/insights/UpdateFailures.tsx +2 -4
- package/src/components/features/releases/ReleaseEditorSheet.tsx +33 -21
- package/src/routes/insights_.distribution.tsx +3 -3
- package/.output/public/assets/HashValueDisplay-BFX_kY3-.js +0 -1
- package/.output/public/assets/InsightsInfo-BNO0WznZ.js +0 -1
- package/.output/public/assets/api-keys-CIO9L_wu.js +0 -1
- package/.output/public/assets/api-keys-DVTL_--f.js +0 -1
- package/.output/public/assets/arrow-left-CnMYpqB7.js +0 -1
- package/.output/public/assets/arrow-up-right-BtffZA6e.js +0 -1
- package/.output/public/assets/chevron-right-BqD5wtFb.js +0 -1
- package/.output/public/assets/insights-CmraDzQh.js +0 -1
- package/.output/public/assets/insights-CxZ2GCYV.js +0 -2
- package/.output/public/assets/insights-usage-rpc-DYEhsCKT.js +0 -1
- package/.output/public/assets/insights-vNRCrfnS.js +0 -42
- package/.output/public/assets/insights_.distribution-ChOerfJt.js +0 -1
- package/.output/public/assets/insights_.distribution-D-e4iga8.js +0 -1
- package/.output/public/assets/insights_.distribution-DZtkibX1.js +0 -2
- package/.output/public/assets/installations-ClHTqdAO.js +0 -1
- package/.output/public/assets/installations-DpKsBuHi.js +0 -1
- package/.output/public/assets/remote-config-BWwHOkCK.js +0 -1
- package/.output/public/assets/remote-config-CXOi0LRu.js +0 -1
- package/.output/public/assets/routes-B88Erkpk.js +0 -2
- package/.output/public/assets/routes-CfzsAleC.js +0 -1
- package/.output/public/assets/search-DaTDPW25.js +0 -1
- package/.output/public/assets/select-BZZBXMkr.js +0 -1
- package/.output/public/assets/smartphone-DpTFgtKf.js +0 -1
- package/.output/public/assets/tabs-C7FOEjFC.js +0 -1
- package/.output/server/_tanstack-start-manifest_v-55AGsehh.mjs +0 -139
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Wr as e,ar as t,cr as n,nr as r,rr as i}from"./sidebar-
|
|
1
|
+
import{Wr as e,ar as t,cr as n,nr as r,rr as i}from"./sidebar-CQ6iq0qe.js";import{m as a}from"./useCompositeListItem-VmWjhZ9j.js";var o=t(`chart-no-axes-combined`,[[`path`,{d:`M12 16v5`,key:`zza2cw`}],[`path`,{d:`M16 14v7`,key:`1g90b9`}],[`path`,{d:`M20 10v11`,key:`1iqoj0`}],[`path`,{d:`m22 3-8.646 8.646a.5.5 0 0 1-.708 0L9.354 8.354a.5.5 0 0 0-.707 0L2 15`,key:`1fw8x9`}],[`path`,{d:`M4 18v3`,key:`1yp0dc`}],[`path`,{d:`M8 14v7`,key:`n3cwzv`}]]),s=t(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),c={"24h":{durationMs:864e5,intervalMs:36e5},"7d":{durationMs:7*864e5,intervalMs:6*36e5},"30d":{durationMs:30*864e5,intervalMs:864e5}},l=e=>Math.ceil(e/36e5)*36e5;function u(e){if(!e||e.platform!==`ios`&&e.platform!==`android`||typeof e.channel!=`string`||!e.channel.trim()||e.channel.length>1024||e.releaseId!==void 0&&(typeof e.releaseId!=`string`||!e.releaseId.trim()||e.releaseId.length>36)||(e.window===void 0?e.releaseId===void 0:!Object.hasOwn(c,e.window)))throw Error(`Choose a platform, channel, and time window.`);return e}var d=({failedUpdates:e,downloads:t})=>e+t===0?null:e/(e+t),f=({failedInstallations:e,activeInstallations:t})=>t===0?null:Math.min(1,e/t),p=e=>e===null?`—`:`${(e*100).toFixed(2)}%`,m={check:`Update check`,download:`Download`,install:`Install`},h={network:`Network`,http:`HTTP error`,invalid_response:`Invalid response`,hash_mismatch:`Hash mismatch`,signature:`Signature`,patch:`Patch`,extract:`Extract`,storage:`Storage`,unknown:`No reason reported`},g=e=>m[e]??`Unknown stage`,_=e=>h[e]??`Unknown reason`,v=e=>[...e.httpStatus==null?[]:[`HTTP ${e.httpStatus}`],...e.originCode==null?[]:[e.originCode],...e.transport==null?[]:[e.transport],...e.resource==null?[]:[e.resource]],y=e=>{let t=e.errorMessage||(e.reason===`unknown`?`The client did not report a detailed cause`:_(e.reason));return[`${g(e.stage)} failed: ${t}`,...v(e)].join(` · `)},b=i({method:`GET`}).middleware([r]).handler(e(`0d1dacdd1e5ee6b100e5c142fb9af03602b6f2c6fe6af79312b36c223d7f8f97`)),x=i({method:`GET`}).middleware([r]).handler(e(`b4388826a9b515fb4d2113270aa8ded1c50ba13d7f07ac2b268c41396e87d0a3`)),S={rawDays:90,dailyDays:400},C=e=>`${e.toLocaleString(`en`)} ${e===1?`day`:`days`}`,w=({dailyDays:e})=>e>=364;i({method:`GET`}).middleware([r]).handler(e(`ff00311d412c8cdfa8ad5b0ba1eb6aa7471d0cc12170e6cc645deb91603d42dd`));var T=i({method:`GET`}).middleware([r]).handler(e(`d4c50f40701055145f24873dc90f3c55a5494457a6a03a743339b2ac4545eb19`)),E=i({method:`GET`}).middleware([r]).handler(e(`3c04bc6624be6dfdd80cf96819f9c6d0455e59a7bb4c0374b6afb0162ffd15b0`)),D=i({method:`GET`}).middleware([r]).handler(e(`6726f1ed9eda1f0cb4c1f1ad1023faee435ddcfd0b7c55ef08ca7f2f7f577370`)),O=i({method:`GET`}).middleware([r]).handler(e(`c6f18db42ac40385dbff247095197ee9f3fd3a97dc914efd368ce0ded1f098c6`)),k=i({method:`GET`}).middleware([r]).handler(e(`735c501f6d5ea81a445ff2b6b2ea6a1b589e3c6f63a465a881822c80ae71e7d1`)),A=3e4,j={reportingInstallations:e=>[`insights`,`reporting-installations`,e],events:e=>[`insights`,`events`,e],installations:e=>[`insights`,`installations`,e],installation:e=>[`insights`,`installation`,e],installationEvents:e=>[`insights`,`installation-events`,e]},M=(e,t)=>n({queryKey:j.events(e),queryFn:()=>T({data:e}),enabled:t,refetchOnWindowFocus:!0,staleTime:A}),N=(e,t)=>n({queryKey:j.installations(e),queryFn:()=>k({data:e}),enabled:t&&e.identity.length>0,staleTime:A}),P=(e,t)=>n({queryKey:j.installation(e),queryFn:()=>D({data:{installId:e}}),enabled:t&&e.length>0,staleTime:A}),F=(e,t)=>n({queryKey:j.installationEvents(e),queryFn:()=>E({data:e}),enabled:t&&e.installId.length>0,refetchOnWindowFocus:!0,staleTime:A}),I=(e,t=!0)=>n({queryKey:[`insights`,`update-failures`,e],queryFn:()=>b({data:u(e)}),enabled:t,refetchOnWindowFocus:!0,staleTime:A}),L=()=>n({queryKey:[`insights`,`retention`],queryFn:()=>O(),staleTime:1/0}).data??S,R=(e,t)=>a({queryKey:[`insights`,`failure-reports`,e],queryFn:({pageParam:t})=>x({data:{...e,cursor:t}}),initialPageParam:void 0,getNextPageParam:e=>e.nextCursor??void 0,enabled:t,staleTime:A});export{p as _,N as a,s as b,S as c,f as d,y as f,g,_ as h,P as i,C as l,d as m,M as n,L as o,v as p,F as r,I as s,R as t,w as u,l as v,o as x,c as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Fn as e,Ur as t,ei as n,it as r,nt as i,ri as a,tt as o}from"./sidebar-CQ6iq0qe.js";import{b as ee}from"./insights-api-BsX1zQDf.js";var s=a(n(),1),c=t();function l({label:t,children:n}){let a=(0,s.useId)(),[l,u]=(0,s.useState)(!1);return(0,c.jsxs)(o,{open:l,onOpenChange:u,triggerId:a,children:[(0,c.jsx)(r,{id:a,"aria-describedby":l?`${a}-description`:void 0,closeOnClick:!1,onClick:()=>u(e=>!e),render:(0,c.jsx)(e,{"aria-label":t,className:`size-11 sm:size-7`,size:`icon`,variant:`ghost`}),children:(0,c.jsx)(ee,{})}),(0,c.jsx)(i,{id:`${a}-description`,role:`tooltip`,className:`max-w-64`,side:`bottom`,children:n})]})}var u=`[a-zA-Z0-9-]`,d=String.raw`0|[1-9]\d*`,f=String.raw`\d+`,p=String.raw`\d*[a-zA-Z-]${u}*`,m=String.raw`(${d})\.(${d})\.(${d})`,te=String.raw`(${f})\.(${f})\.(${f})`,h=`(?:${p}|${d})`,g=`(?:${p}|${f})`,_=String.raw`(?:-(${h}(?:\.${h})*))`,v=String.raw`(?:-?(${g}(?:\.${g})*))`,y=`${u}+`,b=String.raw`(?:\+(${y}(?:\.${y})*))`,x=`v?${m}${_}?${b}?`,S=String.raw`[v=\s]*${te}${v}?${b}?`,C=String.raw`${d}|x|X|\*`,w=String.raw`${f}|x|X|\*`;String.raw`[v=\s]*(${C})(?:\.(${C})(?:\.(${C})(?:${_})?${b}?)?)?`,String.raw`[v=\s]*(${w})(?:\.(${w})(?:\.(${w})(?:${v})?${b}?)?)?`,String.raw`(?:\^)`;var T=String.raw`(^|[^\d])(\d{1,${16}})(?:\.(\d{1,${16}}))?(?:\.(\d{1,${16}}))?`,E=String.raw`${T}(?:$|[^\d])`,D=String.raw`${T}(?:${_})?(?:${b})?(?:$|[^\d])`;function O(e){let t=[[String.raw`\s`,1],[String.raw`\d`,256],[u,250]];for(let[n,r]of t)e=e.split(`${n}*`).join(`${n}{0,${r}}`).split(`${n}+`).join(`${n}{1,${r}}`);return e}function k(e,t){return new RegExp(O(e),t)}k(`^${x}$`),k(`^${S}$`),k(E),k(D),k(`^${_}$`),k(`^${v}$`);var ne=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return typeof t.baseBundleId==`string`&&typeof t.baseFileHash==`string`&&typeof t.patchFileHash==`string`&&typeof t.patchStorageUri==`string`},re=e=>Array.isArray(e)?e.filter(ne):[],ie=e=>{let t=re(e.patches),n=new Set;return t.filter(e=>n.has(e.baseBundleId)?!1:(n.add(e.baseBundleId),!0))},A=e=>ie(e)[0]??null,j=e=>A(e)?.baseBundleId??null,M=e=>A(e)?.baseFileHash??null,N=e=>A(e)?.patchFileHash??null,P=1e3,F=P,I=`Invalid cohort. Use 1-1000 or a lowercase slug without spaces, up to 64 characters.`,L=/^[a-z0-9-]+$/;function R(e){if(!/^\d+$/.test(e))return null;let t=Number.parseInt(e,10);return Number.isNaN(t)||t<1||t>1e3?null:t}function z(e,t){return(e%t+t)%t}function B(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t|=0}return t}function V(e,t){let n=Math.abs(e),r=Math.abs(t);for(;r!==0;){let e=n%r;n=r,r=e}return n}function H(e,t){let n=0,r=1,i=t,a=z(e,t);for(;a!==0;){let e=Math.floor(i/a);[n,r]=[r,n-e*r],[i,a]=[a,i-e*a]}if(i>1)throw Error(`No modular inverse for ${e} mod ${t}`);return z(n,t)}function U(e){let t=z(B(`${e}:multiplier`),997);for(t===0&&(t=1);V(t,P)!==1;)t=z(t+1,P),t===0&&(t=1);let n=z(B(`${e}:offset`),P);return{multiplier:t,offset:n,inverseMultiplier:H(t,P)}}function W(e){return e==null?F:e<=0?0:e>=1e3?P:Math.floor(e)}function G(e){let t=e.trim().toLowerCase(),n=R(t);return n===null?t:String(n)}function K(e){return R(G(e))}function q(e){return K(e)!==null}function J(e){let t=G(e);return t.length>0&&t.length<=64&&!/^\d+$/.test(t)&&L.test(t)}function ae(e){let t=G(e);return q(t)||J(t)}function oe(e,t){if(t<1||t>1e3)throw Error(`Invalid numeric cohort: ${t}`);let{offset:n,inverseMultiplier:r}=U(e);return z(r*(t-1-n),P)}var se=/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,Y=e=>typeof e==`string`&&se.test(e),X=e=>{if(!Y(e))throw TypeError(`Expected a canonical lowercase UUIDv7`);let t=e.split(`-`).join(``).slice(0,12);return Number.parseInt(t,16)},Z=e=>typeof e==`string`&&e.trim().length>0&&e.length<=1024?e:void 0,Q=e=>e===`24h`||e===`7d`||e===`30d`?e:void 0,ce=e=>e===`adoption`||e===`crashes`?e:void 0,le=e=>e===`12m`?e:Q(e);function $(e){return{platform:e.platform===`all`||e.platform===`ios`||e.platform===`android`?e.platform:void 0,channel:Z(e.channel),appVersion:Z(e.appVersion),window:le(e.window),bundleWindow:Q(e.bundleWindow),healthPlatform:e.healthPlatform===`ios`||e.healthPlatform===`android`?e.healthPlatform:void 0,healthChannel:Z(e.healthChannel),releaseId:Z(e.releaseId),healthChart:ce(e.healthChart),bundles:Z(e.bundles)}}function ue(e){return{...$(e),version:Z(e.version),page:typeof e.page==`number`&&Number.isSafeInteger(e.page)&&e.page>0?e.page:void 0}}function de(e,t=Date.now()){if(!Y(e))return`7d`;let n=t-X(e);return n<=864e5?`24h`:n<=7*864e5?`7d`:`30d`}var fe=e=>e===void 0?void 0:[...new Set(e.split(`,`).filter(e=>e.length>0))];export{X as a,oe as c,N as d,ae as f,l as h,$ as i,j as l,W as m,fe as n,I as o,G as p,ue as r,P as s,de as t,M as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Bn as e,Jn as t,Ln as n,Ur as r,Ut as i,Wr as a,ar as o,ei as s,nr as c,qt as l,ri as u,rr as d}from"./sidebar-CQ6iq0qe.js";import{r as f,t as p}from"./valueToPercent-C-rPd_Or.js";var m=o(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),h=u(s()),g=h.createContext(void 0);function _(){let e=h.useContext(g);if(e===void 0)throw Error(t(51));return e}var v=function(e){return e.complete=`data-complete`,e.indeterminate=`data-indeterminate`,e.progressing=`data-progressing`,e}({}),y={status(e){return e===`progressing`?{[v.progressing]:``}:e===`complete`?{[v.complete]:``}:e===`indeterminate`?{[v.indeterminate]:``}:null}},b=r();function x(e,t){return t==null?`indeterminate progress`:e||`${t}%`}var S=h.forwardRef(function(t,n){let{format:r,getAriaValueText:a=x,locale:o,max:s=100,min:c=0,value:u,render:d,className:p,children:m,style:_,...v}=t,[S,C]=h.useState(),w=l(r),T=`indeterminate`;Number.isFinite(u)&&(T=u===s?`complete`:`progressing`);let E=f(u,o,w.current),D=h.useMemo(()=>({status:T}),[T]),O={"aria-labelledby":S,"aria-valuemax":s,"aria-valuemin":c,"aria-valuenow":u??void 0,"aria-valuetext":a(E,u),role:`progressbar`,children:(0,b.jsxs)(h.Fragment,{children:[m,(0,b.jsx)(`span`,{role:`presentation`,style:i,children:`x`})]})},k=h.useMemo(()=>({formattedValue:E,max:s,min:c,setLabelId:C,state:D,status:T,value:u}),[E,s,c,C,D,T,u]),A=e(`div`,t,{state:D,ref:n,props:[O,v],stateAttributesMapping:y});return(0,b.jsx)(g.Provider,{value:k,children:A})}),C=h.forwardRef(function(t,n){let{render:r,className:i,style:a,...o}=t,{state:s}=_();return e(`div`,t,{state:s,ref:n,props:o,stateAttributesMapping:y})}),w=h.forwardRef(function(t,n){let{render:r,className:i,style:a,...o}=t,{max:s,min:c,value:l,state:u}=_(),d=Number.isFinite(l)&&l!==null?p(l,c,s):null;return e(`div`,t,{state:u,ref:n,props:[{style:d==null?{}:{insetInlineStart:0,height:`inherit`,width:`${d}%`}},o],stateAttributesMapping:y})});function T({className:e,children:t,value:r,...i}){return(0,b.jsxs)(S,{value:r,"data-slot":`progress`,className:n(`w-full`,e),...i,children:[t,(0,b.jsx)(E,{children:(0,b.jsx)(D,{})})]})}function E({className:e,...t}){return(0,b.jsx)(C,{className:n(`relative flex h-1 w-full items-center overflow-x-hidden rounded-md bg-muted`,e),"data-slot":`progress-track`,...t})}function D({className:e,...t}){return(0,b.jsx)(w,{"data-slot":`progress-indicator`,className:n(`h-full bg-primary transition-transform motion-reduce:transition-none`,e),...t})}var O=d({method:`GET`}).middleware([c]).handler(a(`8a98cd9c178e4a54185d62c25a95f09d3d59850c43d3f5baa1563e1614ad942e`));export{T as n,m as r,O as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./ConsoleFeatureUnavailable-Bf8tgug-.js";var t=e;export{t as notFoundComponent};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/insights_.distribution-BAaD6rZK.js","assets/ConsoleFeatureUnavailable-Bf8tgug-.js","assets/sidebar-CQ6iq0qe.js","assets/console-features-api-BD7j--gS.js","assets/arrow-up-right-Dz8o-Kab.js","assets/NotFoundPage-HomiHjdL.js","assets/empty-L3UcNk_l.js","assets/insights_.distribution-oxPmgcHr.js","assets/select-BE-xONpm.js","assets/useCompositeListItem-VmWjhZ9j.js","assets/field-DNqNwq7i.js","assets/insights-usage-rpc-CSAoKS_b.js","assets/valueToPercent-C-rPd_Or.js","assets/arrow-left-vK2qGQsd.js","assets/insights-api-BsX1zQDf.js","assets/insights-search-B-F2wop6.js","assets/InsightsPageHeader-eViliItR.js","assets/tabs-B4Ffq4fD.js","assets/list-BSpjGUS6.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./console-features-api-BD7j--gS.js";import{a as t,c as n,s as r}from"./useCompositeListItem-VmWjhZ9j.js";import{r as i}from"./insights-search-B-F2wop6.js";var a=n(`/insights_/distribution`)({beforeLoad:({context:t})=>e(t.queryClient,`insightsAnalytics`),notFoundComponent:r(()=>t(()=>import(`./insights_.distribution-BAaD6rZK.js`),__vite__mapDeps([0,1,2,3,4,5,6])),`notFoundComponent`),component:r(()=>t(()=>import(`./insights_.distribution-oxPmgcHr.js`),__vite__mapDeps([7,2,8,9,3,10,11,12,13,4,14,15,16,17,18,6])),`component`),validateSearch:i});export{a as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as e,Fn as t,In as n,Ur as r,cr as i}from"./sidebar-CQ6iq0qe.js";import{l as a}from"./console-features-api-BD7j--gS.js";import{t as o}from"./arrow-left-vK2qGQsd.js";import{t as s}from"./arrow-up-right-Dz8o-Kab.js";import{o as c,u as ee}from"./insights-api-BsX1zQDf.js";import{_ as te,a as l,f as u,h as d,l as f,m as p,p as m,t as h,u as g,v as _,y as ne}from"./field-DNqNwq7i.js";import{N as v,a as re,i as y,n as b,o as x,r as S,t as C}from"./select-BE-xONpm.js";import{n as w,r as T,t as E}from"./insights-usage-rpc-CSAoKS_b.js";import{h as D,i as O}from"./insights-search-B-F2wop6.js";import{i as k,o as A,r as j,t as M}from"./empty-L3UcNk_l.js";import{t as N}from"./insights_.distribution-C6tGV7qU.js";import{i as P}from"./valueToPercent-C-rPd_Or.js";import{c as ie,n as F,o as I,t as L}from"./InsightsPageHeader-eViliItR.js";var R=r(),z=20,B=new Intl.DateTimeFormat(`en`,{month:`short`,day:`numeric`,timeZone:`UTC`}),V=e=>e.releaseId??(e.builtinBundleId?`Built-in bundle ${e.builtinBundleId}`:`Unknown bundle`);function H({bundleId:e}){return(0,R.jsxs)(`div`,{className:`flex min-h-11 min-w-0 flex-wrap items-center gap-2 md:min-h-9`,children:[(0,R.jsx)(F,{}),(0,R.jsx)(P,{bundleId:e,className:`text-muted-foreground`})]})}function U(){let r=N.useSearch(),P=c(),F=N.useNavigate(),U={platform:r.platform??`all`,channel:r.channel??`production`,appVersion:r.appVersion,window:r.window??`24h`},W=i({queryKey:[`insights`,`app-usage`,U],queryFn:()=>E({data:U}),staleTime:3e4}),G=W.error?void 0:W.data,K=G?`since ${B.format(G.distributionSinceMs)}, 00:00 UTC`:`in this period`,q=(G?.bundleDistribution??[]).filter(e=>!r.version||e.appVersion===r.version),J=q.reduce((e,t)=>e+t.installations,0),Y=Math.max(1,Math.ceil(q.length/z)),X=Math.min(r.page??1,Y),Z=[...new Set([...G?.versions.map(e=>e.name)??[],...r.version?[r.version]:[]])],Q=O(r),$=e=>void F({search:{...r,page:void 0,...e}});return(0,R.jsxs)(`div`,{className:`flex h-svh min-h-0 flex-col`,children:[(0,R.jsx)(L,{view:`distribution`,overviewSearch:Q}),(0,R.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto bg-muted/5 px-4 py-6 sm:p-8`,children:(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-6xl flex-col gap-6`,children:[(0,R.jsxs)(a,{to:`/insights`,search:Q,className:n({variant:`ghost`,className:`h-11 w-fit sm:h-9`}),children:[(0,R.jsx)(o,{"aria-hidden":`true`,"data-icon":`inline-start`}),`Back to overview`]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[(0,R.jsx)(`h2`,{className:`text-2xl font-semibold tracking-tight`,children:`Distribution`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(I,{twelveMonths:ee(P),window:U.window,onWindowChange:e=>$({window:e})}),(0,R.jsx)(t,{"aria-label":`Refresh distribution`,variant:`ghost`,size:`icon`,className:`size-11 sm:size-9`,disabled:W.isFetching,onClick:()=>void W.refetch(),children:(0,R.jsx)(T,{"aria-hidden":`true`})})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-4`,children:[(0,R.jsxs)(h,{className:`w-full sm:w-64`,children:[(0,R.jsx)(l,{htmlFor:`distribution-version`,children:`App version`}),(0,R.jsxs)(C,{items:Object.fromEntries([[`all`,`All versions`],...Z.map(e=>[`version:${e}`,e])]),value:r.version?`version:${r.version}`:`all`,onValueChange:e=>{e!==null&&$({version:e===`all`?void 0:e.slice(8)})},children:[(0,R.jsx)(re,{id:`distribution-version`,className:`min-h-11 w-full sm:min-h-9`,children:(0,R.jsx)(x,{})}),(0,R.jsx)(b,{children:(0,R.jsxs)(S,{children:[(0,R.jsx)(y,{value:`all`,children:`All versions`}),Z.map(e=>(0,R.jsx)(y,{value:`version:${e}`,children:e},e))]})})]})]}),(0,R.jsxs)(`div`,{className:`flex min-h-9 flex-wrap items-center gap-2`,"aria-label":`Distribution scope`,children:[(0,R.jsxs)(f,{variant:`outline`,className:`gap-1.5`,children:[U.platform===`all`?null:(0,R.jsx)(v,{platform:U.platform,className:`size-3.5`}),U.platform===`all`?`All platforms`:U.platform===`ios`?`iOS`:`Android`]}),(0,R.jsx)(f,{variant:`outline`,children:U.channel}),U.appVersion?(0,R.jsxs)(f,{variant:`outline`,children:[`Reports from `,U.appVersion]}):null]})]}),(0,R.jsxs)(p,{"aria-label":`Bundles by app version`,role:`region`,className:`min-w-0`,children:[(0,R.jsxs)(_,{className:`flex flex-col gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsx)(ne,{children:`Bundles by app version`}),(0,R.jsxs)(D,{label:`How bundle distribution is counted`,children:[`Each installation counts once, by its latest report`,` `,K,`. Shares are within each app version. Built-in bundle: the bundle the native build shipped, by its ID. Unknown bundle: no deployment and no built-in bundle ID.`]})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-1`,children:[W.isPending?(0,R.jsx)(e,{className:`h-9 w-16`}):(0,R.jsx)(`p`,{className:`text-3xl font-semibold tabular-nums`,children:G?`${G.truncated?`≥`:``}${J.toLocaleString()}`:`—`}),(0,R.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Reporting installations`})]})]}),(0,R.jsxs)(d,{className:`flex min-w-0 flex-col gap-4`,children:[G?.truncated?(0,R.jsxs)(g,{children:[(0,R.jsx)(m,{children:`Partial history`}),(0,R.jsxs)(u,{children:[`Counts and shares reflect reports since`,` `,new Date(G.sinceMs).toLocaleString(`en`,{timeZone:`UTC`}),` `,`UTC. Choose a shorter period for a more complete view.`]})]}):null,W.isPending?(0,R.jsx)(e,{"aria-label":`Loading bundle distribution`,className:`h-64`}):W.error?(0,R.jsxs)(`div`,{className:`flex flex-col items-start gap-4`,children:[(0,R.jsx)(ie,{error:W.error,fallbackTitle:`Distribution unavailable`}),(0,R.jsx)(t,{variant:`outline`,onClick:()=>void W.refetch(),children:`Retry distribution`})]}):q.length===0?(0,R.jsxs)(M,{children:[(0,R.jsxs)(k,{children:[(0,R.jsx)(A,{children:`No bundles reported`}),(0,R.jsx)(j,{children:`Choose another version or period, or change the filters in the overview.`})]}),(0,R.jsx)(t,{variant:`outline`,onClick:()=>$({version:void 0}),children:`Show all versions`})]}):(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{"aria-hidden":`true`,className:`hidden grid-cols-[8rem_minmax(0,1fr)_7rem_7rem] gap-4 border-b px-3 pb-3 text-xs text-muted-foreground md:grid`,children:[(0,R.jsx)(`span`,{children:`App version`}),(0,R.jsx)(`span`,{children:`Bundle ID`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Active installations`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Version share`})]}),(0,R.jsx)(`ul`,{"aria-label":`Bundle distribution`,className:`divide-y`,children:q.slice((X-1)*z,X*z).map(e=>{let t=G?.versions.find(t=>t.name===e.appVersion)?.installations??0,n=t>0?e.installations/t*100:0;return(0,R.jsxs)(`li`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-4 gap-y-3 px-1 py-4 md:grid-cols-[8rem_minmax(0,1fr)_7rem_7rem] md:px-3`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,R.jsx)(`span`,{className:`truncate text-sm font-medium`,title:e.appVersion,children:e.appVersion}),(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,R.jsx)(v,{platform:e.platform,className:`size-3.5`}),e.platform===`ios`?`iOS`:`Android`]})]}),(0,R.jsxs)(`div`,{className:`col-span-2 row-start-2 min-w-0 md:col-span-1 md:row-auto`,children:[e.releaseId?(0,R.jsxs)(a,{to:`/`,search:{releaseId:e.releaseId},"aria-label":`Review bundle ${e.releaseId} for app version ${e.appVersion}`,className:`flex min-h-11 min-w-0 items-center gap-2 text-xs underline-offset-4 hover:underline md:min-h-9`,children:[(0,R.jsx)(`span`,{className:`break-all font-mono`,children:e.releaseId}),(0,R.jsx)(s,{"aria-hidden":`true`,className:`size-3.5 shrink-0`})]}):e.builtinBundleId?null:(0,R.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Unknown bundle`}),e.builtinBundleId?(0,R.jsx)(H,{bundleId:e.builtinBundleId}):null]}),(0,R.jsxs)(`div`,{className:`col-start-2 row-start-1 text-right md:col-auto md:row-auto`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium tabular-nums`,children:e.installations.toLocaleString()}),(0,R.jsx)(`span`,{className:`ml-1 text-xs text-muted-foreground md:sr-only`,children:`active`}),(0,R.jsxs)(`p`,{className:`mt-1 text-xs tabular-nums text-muted-foreground md:hidden`,children:[n.toFixed(1),`% of version`]})]}),(0,R.jsxs)(`div`,{className:`hidden flex-col gap-2 md:flex`,children:[(0,R.jsxs)(`span`,{className:`text-right text-sm tabular-nums`,children:[n.toFixed(1),`%`]}),(0,R.jsx)(w,{"aria-label":`${V(e)} share in ${e.appVersion} on ${e.platform}`,value:n})]})]},JSON.stringify([e.appVersion,e.platform,e.releaseId,e.builtinBundleId]))})})]})]}),G&&q.length>0?(0,R.jsxs)(te,{className:`flex flex-wrap items-center justify-between gap-3 border-t pt-4`,children:[(0,R.jsxs)(`p`,{className:`text-xs tabular-nums text-muted-foreground`,children:[(X-1)*z+1,`–`,Math.min(X*z,q.length),` of `,q.length]}),(0,R.jsxs)(`nav`,{"aria-label":`Distribution pages`,className:`flex gap-2`,children:[(0,R.jsx)(t,{variant:`outline`,className:`h-11 sm:h-9`,disabled:X<=1,onClick:()=>$({page:X-1}),children:`Previous`}),(0,R.jsx)(t,{variant:`outline`,className:`h-11 sm:h-9`,disabled:X>=Y,onClick:()=>$({page:X+1}),children:`Next`})]})]}):null]})]})})]})}export{U as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./ConsoleFeatureUnavailable-Bf8tgug-.js";var t=e;export{t as notFoundComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as e,Fn as t,In as n,Ln as r,Ur as i,ei as a,et as o,ir as s,ri as c}from"./sidebar-CQ6iq0qe.js";import{d as l,l as u,u as d}from"./console-features-api-BD7j--gS.js";import{a as f,c as p,i as m,n as h,o as g,r as _,s as v,t as y}from"./installations-RfpwK-ld.js";import{o as b,u as x}from"./useCompositeListItem-VmWjhZ9j.js";import{a as S,n as C,o as w,r as T,t as E}from"./EventDetails-CgtEWl-Y.js";import{t as D}from"./arrow-left-vK2qGQsd.js";import{t as O}from"./arrow-up-right-Dz8o-Kab.js";import{a as ee,c as k,i as te,l as A,n as ne,o as re,r as ie}from"./insights-api-BsX1zQDf.js";import{a as j,g as M,h as N,m as P,t as F,v as I,x as ae,y as L}from"./field-DNqNwq7i.js";import{n as R,t as z}from"./HashValueDisplay-DvXl147n.js";import{t as oe}from"./refresh-cw-BMlpOsfM.js";import{i as se,n as B,r as ce,t as le}from"./input-group-C9ZIjV0o.js";import{t as ue}from"./search-B_o3avCI.js";import{a as V,i as H,n as U,o as W,r as G,t as K}from"./table-DW0243Jw.js";import{a as de,c as q,n as fe,r as pe,t as me}from"./InsightsPageHeader-eViliItR.js";function he(){p(l(),!0)}function ge(e){return he(),v(l(),e)}function _e(e){let t=l();return d(t.stores.location,x(e,t))}var J=c(a(),1),Y=i();function ve({events:e,formatter:t,renderIdentity:n}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`px-4 pb-2 text-xs text-muted-foreground sm:px-6`,children:`Time in your browser zone`}),(0,Y.jsx)(`ol`,{"aria-label":`Events`,className:`divide-y border-y`,children:e.map(e=>(0,Y.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-3 px-4 py-4 sm:px-6`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-1`,children:[(0,Y.jsx)(T,{event:e}),(0,Y.jsx)(`div`,{className:`text-xs tabular-nums`,children:(0,Y.jsx)(C,{value:e.receivedAtMs,formatter:t,touch:!0})})]}),n?.(e),(0,Y.jsxs)(`dl`,{className:`flex flex-wrap gap-x-2 gap-y-1 text-sm`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{className:`sr-only`,children:`App`}),(0,Y.jsxs)(`dd`,{children:[e.platform===`ios`?`iOS`:`Android`,` `,e.appVersion]})]}),(0,Y.jsxs)(`div`,{className:`min-w-0 text-muted-foreground`,children:[(0,Y.jsx)(`dt`,{className:`sr-only`,children:`Channel`}),(0,Y.jsx)(`dd`,{className:`wrap-anywhere`,children:e.channel})]})]}),(0,Y.jsx)(`div`,{className:`text-xs`,"aria-label":`Bundle`,children:(0,Y.jsx)(E,{event:e,touch:!0})})]},e.id))})]})}function X({hasPrevious:e,label:n,nextCursor:r,onNext:i,onPrevious:a,pageLength:o,pageNumber:s}){return(0,Y.jsxs)(`nav`,{"aria-label":`${n} pagination`,className:`flex flex-wrap items-center justify-between gap-3 border-t px-4 py-3 sm:px-6`,children:[(0,Y.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[`Page `,s,` · `,o.toLocaleString(),` rows`]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(t,{className:`h-11 min-w-11 px-3 lg:h-8 lg:min-w-0 lg:px-2`,disabled:!e,onClick:a,size:`sm`,type:`button`,variant:`outline`,children:`Previous`}),(0,Y.jsx)(t,{className:`h-11 min-w-11 px-3 lg:h-8 lg:min-w-0 lg:px-2`,disabled:r===null,onClick:i,size:`sm`,type:`button`,variant:`outline`,children:`Next`})]})]})}var ye=e=>_.filter((t,n)=>n===0||f[t].durationMs<=e*864e5);function be({event:e,eventsLocation:t,touch:r=!1}){return(0,Y.jsxs)(`div`,{className:r?`flex min-w-0 flex-wrap items-center justify-between gap-2`:`flex min-w-0 flex-col items-start gap-2`,children:[(0,Y.jsxs)(u,{className:n({className:r?`-ml-2 h-auto min-h-11 min-w-0 flex-1 justify-start gap-2 whitespace-normal text-sm`:`-ml-2 max-w-full justify-start`,size:`sm`,variant:`ghost`}),to:`/installations`,search:{...t,query:e.installId||void 0,installId:e.installId},state:e=>({insightsPagination:{eventsBack:e.insightsPagination?.eventsBack}}),"aria-label":`View history for ${e.userId??`anonymous installation`} (${e.installId})`,children:[(0,Y.jsx)(`span`,{className:r?`min-w-0 text-left wrap-anywhere`:`truncate`,children:e.userId??`Anonymous installation`}),(0,Y.jsx)(O,{"aria-hidden":`true`,"data-icon":`inline-end`})]}),(0,Y.jsx)(z,{value:e.installId,maxLength:13,buttonClassName:r?`min-h-11 px-3`:void 0})]})}function xe({children:n,description:r,error:i,eventsLocation:a,history:o,isFetching:s,isLoading:c,onNext:l,onPrevious:u,onRangeChange:d,onRefresh:p,pageNumber:m,range:h,rawDays:_=90,title:v=`All events`}){let y=w(),b=m>1,x=ye(_),S=h===void 0?void 0:g(h),D=S!==void 0&&x.includes(S)?S:void 0,O=D!==void 0&&d?(0,Y.jsx)(t,{className:`h-11 px-3 lg:h-8`,onClick:()=>d(D),type:`button`,variant:`outline`,children:`Show the last ${f[D].period}`}):null;return(0,Y.jsxs)(P,{className:`@container min-w-0 shadow-sm`,"aria-busy":s,children:[(0,Y.jsxs)(I,{className:`gap-4 p-4 sm:p-6`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Y.jsx)(L,{children:(0,Y.jsx)(`h2`,{children:v})}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[h!==void 0&&d?(0,Y.jsx)(de,{label:`Time range`,onPeriodChange:d,period:h,periods:x.map(e=>({value:e,name:`Last ${f[e].period}`}))}):null,(0,Y.jsxs)(t,{className:`h-11 lg:h-8`,disabled:s,onClick:p,size:`lg`,variant:`outline`,children:[(0,Y.jsx)(oe,{"aria-hidden":`true`,"data-icon":`inline-start`}),`Refresh`]})]})]}),r?(0,Y.jsx)(M,{children:r}):null]}),n]}),(0,Y.jsx)(N,{className:`min-w-0 p-0`,children:c?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4 p-6`,role:`status`,"aria-label":`Loading events`,children:[(0,Y.jsx)(e,{className:`h-12 w-full`}),(0,Y.jsx)(e,{className:`h-12 w-full`}),(0,Y.jsx)(e,{className:`h-12 w-full`})]}):i?(0,Y.jsx)(`div`,{className:`px-6 pb-6`,children:(0,Y.jsx)(q,{error:i,fallbackTitle:`Event history unavailable`})}):o?(0,Y.jsxs)(Y.Fragment,{children:[o.data.length>0?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`@[58rem]:hidden`,children:(0,Y.jsx)(ve,{events:o.data,formatter:y,renderIdentity:e=>(0,Y.jsx)(be,{event:e,eventsLocation:a,touch:!0})})}),(0,Y.jsx)(`div`,{className:`hidden @[58rem]:block`,children:(0,Y.jsxs)(K,{className:`min-w-4xl table-fixed`,children:[(0,Y.jsx)(V,{children:(0,Y.jsxs)(W,{className:`[&>th]:px-4 sm:[&>th]:px-6`,children:[(0,Y.jsx)(H,{className:`w-64`,children:`Time`}),(0,Y.jsx)(H,{className:`w-48`,children:`Event`}),(0,Y.jsx)(H,{className:`w-48`,children:`User / installation`}),(0,Y.jsx)(H,{className:`w-32`,children:`App`}),(0,Y.jsx)(H,{className:`w-52`,children:`Bundle`})]})}),(0,Y.jsx)(U,{children:o.data.map(e=>(0,Y.jsxs)(W,{className:`[&>td]:px-4 [&>td]:py-4 [&>td]:align-top sm:[&>td]:px-6`,children:[(0,Y.jsx)(G,{className:`whitespace-normal text-xs tabular-nums`,children:(0,Y.jsx)(C,{value:e.receivedAtMs,formatter:y})}),(0,Y.jsx)(G,{children:(0,Y.jsx)(T,{event:e})}),(0,Y.jsx)(G,{children:(0,Y.jsx)(be,{event:e,eventsLocation:a})}),(0,Y.jsx)(G,{className:`whitespace-normal text-xs`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`span`,{children:[e.platform===`ios`?`iOS`:`Android`,` `,e.appVersion]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e.channel})]})}),(0,Y.jsx)(G,{className:`whitespace-normal text-xs`,children:(0,Y.jsx)(E,{event:e})})]},e.id))})]})})]}):(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 px-4 pb-4 sm:px-6 sm:pb-6`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:b?`No older events in this range.`:h===void 0?v===`All events`?`No events recorded yet`:`No matching reports in this period`:`No events in the last ${f[h].period}.`}),b?null:O]}),h!==void 0&&o.nextCursor===null&&(o.data.length>0||b)?(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-t px-4 py-3 sm:px-6`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Start of range reached`}),O]}):null,o.data.length>0||b||o.nextCursor?(0,Y.jsx)(X,{hasPrevious:b,label:v,nextCursor:o.nextCursor,onNext:l,onPrevious:u,pageLength:o.data.length,pageNumber:m}):null]}):null})]})}var Se=e=>e.userId??`—`,Ce=e=>`lastKnownBundleId`in e?e.lastKnownBundleId:e.type===`UPDATE_DOWNLOADED`||e.type===`UPDATE_FAILED`?e.fromBundleId:e.toBundleId;function we({error:n,history:r,isLoading:i,onNext:a,onPrevious:s,onRefresh:c,pageNumber:l,retention:u=k,selectedEvent:d,selectedInstallId:f}){let p=w(),m=d?Ce(d):void 0,h=d&&`pendingBundleId`in d?d.pendingBundleId:d&&`type`in d&&d.type===`UPDATE_DOWNLOADED`?d.toBundleId:null;return(0,Y.jsxs)(P,{className:`@container min-h-0 min-w-0 shadow-sm`,children:[(0,Y.jsx)(I,{className:`p-4 sm:p-6`,children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,Y.jsx)(L,{className:`text-sm font-medium`,children:(0,Y.jsx)(`h2`,{children:f===void 0?`Select an installation`:`Installation history`})}),f===void 0?null:(0,Y.jsxs)(M,{children:[`Bundle changes and update failures are kept for`,` `,A(u.rawDays),`; the latest report, for`,` `,A(u.dailyDays),` after the installation last reports.`]})]}),c&&f!==void 0?(0,Y.jsxs)(t,{className:`h-11 lg:h-8`,size:`lg`,variant:`outline`,onClick:c,disabled:i,children:[(0,Y.jsx)(oe,{"aria-hidden":`true`,"data-icon":`inline-start`}),`Refresh`]}):null]})}),(0,Y.jsxs)(N,{className:`min-h-0 p-0`,children:[f!==void 0&&d?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`section`,{"aria-labelledby":`latest-installation-state`,className:`px-4 pb-4 sm:px-6 sm:pb-6`,children:[(0,Y.jsx)(`h3`,{className:`sr-only`,id:`latest-installation-state`,children:`Latest reported state`}),(0,Y.jsxs)(`dl`,{className:`grid grid-cols-2 gap-4 @[36rem]:grid-cols-3`,children:[(0,Y.jsxs)(`div`,{className:`col-span-2 min-w-0 @[36rem]:col-span-1`,children:[(0,Y.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`User ID`}),(0,Y.jsx)(`dd`,{className:`mt-1 text-sm font-medium wrap-anywhere`,children:Se(d)})]}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Install ID`}),(0,Y.jsx)(`dd`,{className:`mt-1 font-mono text-xs`,children:(0,Y.jsx)(z,{value:f,buttonClassName:`min-h-11 px-3 lg:min-h-0 lg:px-1.5`})})]}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Last known bundle`}),(0,Y.jsxs)(`dd`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-2 font-mono text-xs`,children:[m?(0,Y.jsx)(z,{value:m,buttonClassName:`min-h-11 px-3 lg:min-h-0 lg:px-1.5`}):`—`,pe(m,d.minBundleId)?(0,Y.jsx)(fe,{}):null]})]}),h?(0,Y.jsxs)(`div`,{className:`col-span-2 min-w-0`,children:[(0,Y.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Downloaded · Not launched yet`}),(0,Y.jsx)(`dd`,{className:`mt-1 text-xs`,children:(0,Y.jsx)(z,{value:h})})]}):null]}),d.httpResponse?(0,Y.jsx)(`div`,{className:`mt-4`,children:(0,Y.jsx)(S,{event:d})}):null]}),(0,Y.jsx)(o,{})]}):null,f===void 0?null:i?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3 p-6`,role:`status`,"aria-label":`Loading installation history`,children:[(0,Y.jsx)(e,{className:`h-10 w-full`}),(0,Y.jsx)(e,{className:`h-10 w-full`}),(0,Y.jsx)(e,{className:`h-10 w-full`})]}):n?(0,Y.jsx)(`div`,{className:`p-6`,children:(0,Y.jsx)(q,{error:n instanceof Error?n:Error(),fallbackTitle:`Installation history unavailable`})}):r&&r.data.length>0?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`@[48rem]:hidden`,children:(0,Y.jsx)(ve,{events:r.data,formatter:p})}),(0,Y.jsx)(`div`,{className:`hidden @[48rem]:block`,children:(0,Y.jsxs)(K,{className:`min-w-3xl table-fixed`,children:[(0,Y.jsx)(V,{children:(0,Y.jsxs)(W,{className:`[&>th]:px-4 sm:[&>th]:px-6`,children:[(0,Y.jsx)(H,{className:`w-64`,children:`Time`}),(0,Y.jsx)(H,{className:`w-48`,children:`Event`}),(0,Y.jsx)(H,{className:`w-32`,children:`App`}),(0,Y.jsx)(H,{className:`w-52`,children:`Bundle`})]})}),(0,Y.jsx)(U,{children:r.data.map(e=>(0,Y.jsxs)(W,{className:`[&>td]:px-4 [&>td]:py-4 [&>td]:align-top sm:[&>td]:px-6`,children:[(0,Y.jsx)(G,{className:`whitespace-normal text-xs tabular-nums`,children:(0,Y.jsx)(C,{value:e.receivedAtMs,formatter:p})}),(0,Y.jsx)(G,{children:(0,Y.jsx)(T,{event:e})}),(0,Y.jsx)(G,{className:`whitespace-normal text-xs`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`span`,{children:[e.platform===`ios`?`iOS`:`Android`,` `,e.appVersion]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e.channel})]})}),(0,Y.jsx)(G,{className:`whitespace-normal text-xs`,children:(0,Y.jsx)(E,{event:e})})]},e.id))})]})}),(0,Y.jsx)(X,{hasPrevious:l>1,label:`Installation history`,nextCursor:r.nextCursor,onNext:a,onPrevious:s,pageLength:r.data.length,pageNumber:l})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:l>1?`No older bundle changes.`:`No bundle changes recorded yet.`}),r&&(l>1||r.nextCursor)?(0,Y.jsx)(X,{hasPrevious:l>1,label:`Installation history`,nextCursor:r.nextCursor,onNext:a,onPrevious:s,pageLength:0,pageNumber:l}):null]})]})]})}var Te=e=>e.lastKnownBundleId,Ee=e=>e.userId??`—`;function De({error:e,onNext:i,onPrevious:a,onSelect:o,pageNumber:s,results:c,selectedInstallId:l}){let[u,d]=(0,J.useState)(!1),f=(0,J.useId)(),p=(0,J.useRef)(null),m=!e&&c&&c.data.length>0;return(0,Y.jsxs)(P,{className:`min-h-0 min-w-0 shadow-sm`,children:[(0,Y.jsx)(I,{className:`p-4 sm:px-6`,children:(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:(0,Y.jsx)(L,{className:`text-sm font-medium`,children:(0,Y.jsx)(`h2`,{children:`Matching installations`})})}),(0,Y.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:m?(0,Y.jsx)(t,{"aria-controls":f,"aria-expanded":u,"aria-label":u?`Hide matching installations`:`Show matching installations`,className:`size-11 lg:hidden`,onClick:()=>d(!u),ref:p,size:`icon-lg`,variant:`ghost`,children:(0,Y.jsx)(b,{"aria-hidden":`true`,className:r(u&&`rotate-180`)})}):null})]})}),(0,Y.jsxs)(N,{className:r(`min-h-0 p-0`,m&&!u&&`hidden lg:block`),id:f,children:[e?(0,Y.jsx)(`div`,{className:`p-6`,children:(0,Y.jsx)(q,{error:e instanceof Error?e:Error(),fallbackTitle:`Installation search unavailable`})}):c&&c.data.length>0?(0,Y.jsx)(`ul`,{"aria-label":`Matching installations`,className:`divide-y`,children:c.data.map(e=>{let t=Te(e),n=e.installId===l;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{"aria-label":`${Ee(e)}, install ID ${e.installId}`,"aria-pressed":n,className:`group flex w-full min-w-0 flex-col gap-2 border-l-2 border-transparent px-4 py-4 text-left outline-none transition-colors hover:bg-muted/40 focus-visible:border-ring focus-visible:bg-muted/40 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/30 aria-pressed:border-primary aria-pressed:bg-muted/60 motion-reduce:transition-none sm:px-6`,onClick:()=>{o(e.installId),d(!1),p.current?.focus()},type:`button`,children:[(0,Y.jsxs)(`span`,{className:`flex w-full min-w-0 items-center justify-between gap-3`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium`,children:Ee(e)}),n?(0,Y.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-xs font-medium text-primary`,children:[(0,Y.jsx)(ae,{"aria-hidden":`true`,className:`size-3.5`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`Selected`})]}):null]}),(0,Y.jsx)(`span`,{className:`flex flex-wrap items-center gap-2`,children:(0,Y.jsx)(`span`,{className:`font-mono text-xs`,title:e.installId,children:R(e.installId)})}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Bundle`}),t?(0,Y.jsx)(`span`,{className:`font-mono text-xs`,title:t,children:R(t)}):(0,Y.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`—`})]})]})},e.installId)})}):(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 p-4 sm:px-6`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No matches`}),(0,Y.jsx)(`a`,{className:n({variant:`outline`,className:`h-11 px-3 lg:h-8`}),href:`#installation-history-search`,children:`Edit search`})]}),c&&(c.data.length>0||s>1||c.nextCursor)?(0,Y.jsx)(X,{hasPrevious:s>1,label:`Installation results`,nextCursor:c.nextCursor,onNext:i,onPrevious:a,pageLength:c.data.length,pageNumber:s}):null]})]})}function Oe({draftQuery:e,onDraftQueryChange:n,onSubmit:r,onClear:i}){return(0,Y.jsx)(`form`,{"aria-label":`Find installation`,onSubmit:t=>{t.preventDefault(),e.trim()&&r()},role:`search`,children:(0,Y.jsxs)(F,{className:`gap-2`,children:[(0,Y.jsx)(j,{className:`sr-only`,htmlFor:`installation-history-search`,children:`User ID or installation ID`}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsxs)(le,{className:`h-11 w-auto min-w-0 flex-1 basis-44 lg:h-8`,children:[(0,Y.jsx)(B,{children:(0,Y.jsx)(ue,{"aria-hidden":`true`})}),(0,Y.jsx)(se,{autoComplete:`off`,className:`h-11 text-base md:text-base lg:h-8 lg:text-xs`,id:`installation-history-search`,maxLength:1024,name:`installation`,onChange:e=>n(e.target.value),placeholder:`User ID or installation ID`,spellCheck:!1,type:`search`,value:e}),e.length>0?(0,Y.jsx)(B,{align:`inline-end`,children:(0,Y.jsx)(ce,{"aria-label":`Clear installation lookup`,className:`size-11 lg:size-5`,onClick:i,size:`icon-xs`,children:(0,Y.jsx)(s,{"aria-hidden":`true`})})}):null]}),(0,Y.jsx)(t,{"aria-label":`Find installation`,className:`h-11 px-3 lg:h-8`,disabled:e.trim().length===0,size:`lg`,type:`submit`,variant:`outline`,children:`Find`})]})]})})}function ke(){return(0,Y.jsxs)(`div`,{className:`grid items-stretch gap-6 lg:min-h-96 lg:grid-cols-[minmax(18rem,20rem)_minmax(0,1fr)]`,children:[(0,Y.jsx)(e,{className:`h-64 w-full lg:h-full`}),(0,Y.jsx)(e,{className:`h-64 w-full lg:h-full`})]})}var Ae=20,je=50,Z=()=>Date.now(),Q=(e,t)=>[...e,t??``],$=e=>({cursor:e?.at(-1)||void 0,stack:e.slice(0,-1)});function Me(){let e=y.useSearch(),n=y.useNavigate(),r=re(),[i,a]=(0,J.useState)(e.query??``),[o]=(0,J.useState)(Z),[s]=(0,J.useState)(Z),c=_e({select:e=>e.state.insightsPagination}),l=c?.eventsBack??[],u=c?.searchBack??[],d=c?.historyBack??[],f=e.query?.trim()??``,p=f.length>0,g=e.installId!==void 0,_=p||g,v=e.eventsBefore??o,b=e.eventsRange??`7d`,x=e.historyBefore??s,S=(t,r=!1,i={})=>{n({to:`/installations`,search:{...e,...t},state:e=>({...e,insightsPagination:{...e.insightsPagination,...i}}),replace:r})};(0,J.useEffect)(()=>{a(e.query??``)},[e.query]),(0,J.useEffect)(()=>{e.eventsBefore===void 0&&S({eventsBefore:v},!0)},[v,e.eventsBefore]),(0,J.useEffect)(()=>{g&&e.historyBefore===void 0&&S({historyBefore:x},!0)},[g,x,e.historyBefore]);let C=ne({...m(b,v),cursor:e.eventsCursor,limit:20},!_),w=ee({cursor:e.searchCursor,identity:f,limit:Ae},p);(0,J.useEffect)(()=>{let e=w.data?.data[0]?.installId;!p||g||e===void 0||S({historyBefore:Z(),historyCursor:void 0,installId:e},!0,{historyBack:[]})},[p,g,w.data?.data]);let T=te(e.installId??``,g),E=ie({beforeReceivedAtMs:x,cursor:e.historyCursor,installId:e.installId??``,limit:je},g),O=T.data??w.data?.data.find(({installId:t})=>t===e.installId)??E.data?.data[0],k=_?`installation-history-${e.historyCursor??`first`}`:`all-events-${e.eventsCursor??`first`}`,j=(0,J.useRef)(null),M=ge({id:k,getKey:h});(0,J.useLayoutEffect)(()=>{!_&&!C.isLoading&&j.current&&(j.current.scrollTop=M?.scrollY??0)},[C.isLoading,_,M?.scrollY,k]);let F=()=>{a(``),S({historyBefore:void 0,historyCursor:void 0,installId:void 0,query:void 0,searchCursor:void 0},!1,{historyBack:[],searchBack:[]})},I=(0,Y.jsx)(Oe,{draftQuery:i,onClear:F,onDraftQueryChange:a,onSubmit:()=>{let e=i.trim();if(!e){F();return}S({historyBefore:void 0,historyCursor:void 0,installId:void 0,query:e,searchCursor:void 0},!1,{historyBack:[],searchBack:[]})}});return(0,Y.jsxs)(`div`,{className:`flex h-svh min-h-0 flex-col`,children:[(0,Y.jsx)(me,{view:`events`}),(0,Y.jsx)(`div`,{ref:j,"data-scroll-restoration-id":k,id:`insights-events-scroll`,className:`min-h-0 min-w-0 flex-1 overflow-y-auto bg-muted/5 p-3 sm:p-6`,children:(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-4 sm:gap-6`,children:[_?(0,Y.jsx)(P,{className:`shadow-sm`,children:(0,Y.jsxs)(N,{className:`flex flex-col gap-3 p-4 sm:p-6`,children:[(0,Y.jsxs)(t,{className:`-ml-2 h-11 self-start lg:h-8`,onClick:F,variant:`ghost`,children:[(0,Y.jsx)(D,{"aria-hidden":`true`,"data-icon":`inline-start`}),`Back to all events`]}),I]})}):null,_?w.isLoading&&p?(0,Y.jsx)(ke,{}):(0,Y.jsxs)(`div`,{className:`grid min-h-0 min-w-0 items-stretch gap-4 sm:gap-6 ${p?`lg:min-h-96 lg:grid-cols-[minmax(18rem,20rem)_minmax(0,1fr)]`:`lg:grid-cols-1`}`,children:[p?(0,Y.jsx)(De,{error:w.error,onNext:()=>{w.data?.nextCursor&&S({installId:void 0,searchCursor:w.data.nextCursor},!0,{searchBack:Q(u,e.searchCursor)})},onPrevious:()=>{let e=$(u);S({installId:void 0,searchCursor:e.cursor},!0,{searchBack:e.stack})},onSelect:e=>{S({historyBefore:Z(),historyCursor:void 0,installId:e},!1,{historyBack:[]})},pageNumber:u.length+1,results:w.data,selectedInstallId:e.installId}):null,(0,Y.jsx)(we,{error:E.error??T.error,history:E.data,isLoading:E.isLoading||T.isLoading,onNext:()=>{E.data?.nextCursor&&S({historyCursor:E.data.nextCursor},!0,{historyBack:Q(d,e.historyCursor)})},onPrevious:()=>{let e=$(d);S({historyCursor:e.cursor},!0,{historyBack:e.stack})},onRefresh:()=>{S({historyBefore:Z(),historyCursor:void 0},!0,{historyBack:[]})},pageNumber:d.length+1,retention:r,selectedEvent:O,selectedInstallId:e.installId})]}):(0,Y.jsx)(xe,{description:`Downloads, launches, crashes, update failures, and other changes to what an installation runs, newest first, kept for ${A(r.rawDays)}. Launches that change nothing aren't listed.`,error:C.error,eventsLocation:{eventsBefore:v,eventsCursor:e.eventsCursor,eventsRange:e.eventsRange},history:C.data,isFetching:C.isFetching,isLoading:C.isLoading,onNext:()=>{C.data?.nextCursor&&S({eventsCursor:C.data.nextCursor},!0,{eventsBack:Q(l,e.eventsCursor)})},onPrevious:()=>{let e=$(l);S({eventsCursor:e.cursor},!0,{eventsBack:e.stack})},onRangeChange:e=>{S({eventsBefore:Z(),eventsCursor:void 0,eventsRange:e},!1,{eventsBack:[]})},onRefresh:()=>{S({eventsBefore:Z(),eventsCursor:void 0},!0,{eventsBack:[]})},pageNumber:l.length+1,range:b,rawDays:r.rawDays,children:I})]})},k)]})}export{Me as component};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/installations-
|
|
2
|
-
import{r as e}from"./console-features-api-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/installations-1jALHnM3.js","assets/ConsoleFeatureUnavailable-Bf8tgug-.js","assets/sidebar-CQ6iq0qe.js","assets/console-features-api-BD7j--gS.js","assets/arrow-up-right-Dz8o-Kab.js","assets/NotFoundPage-HomiHjdL.js","assets/empty-L3UcNk_l.js","assets/installations-DUidui9Z.js","assets/useCompositeListItem-VmWjhZ9j.js","assets/EventDetails-CgtEWl-Y.js","assets/insights-api-BsX1zQDf.js","assets/field-DNqNwq7i.js","assets/HashValueDisplay-DvXl147n.js","assets/dist-B7eA4Mtf.js","assets/input-group-C9ZIjV0o.js","assets/smartphone--CTny1h9.js","assets/InsightsPageHeader-eViliItR.js","assets/tabs-B4Ffq4fD.js","assets/list-BSpjGUS6.js","assets/arrow-left-vK2qGQsd.js","assets/refresh-cw-BMlpOsfM.js","assets/search-B_o3avCI.js","assets/table-DW0243Jw.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./console-features-api-BD7j--gS.js";import{a as t,c as n,s as r}from"./useCompositeListItem-VmWjhZ9j.js";function i(){try{return sessionStorage}catch{return}}var a=`tsr-scroll-restoration-v1_3`,o=i();function s(){try{return JSON.parse(o?.getItem(`tsr-scroll-restoration-v1_3`)||`{}`)}catch{return{}}}var c=s(),l=`data-scroll-restoration-id`,u=e=>e.state.__TSR_key||e.href;function d(e){let t=e.getAttribute(l);if(t)return`[${l}="${t}"]`;let n=``,r=e,i;for(;i=r.parentNode;){let e=1,t=r;for(;t=t.previousElementSibling;)e++;let a=`${r.localName}:nth-child(${e})`;n=n?`${a} > ${n}`:a,r=i}return n}function f(e,t){let n=c[(t.getKey||u)(e.latestLocation)];if(!n)return;if(t.id)return n[`[${l}="${t.id}"]`];let r=t.getElement?.();if(r)return n[r===window?m:d(r)]}var p=!1,m=`window`;function h(e){try{return typeof e==`function`?e():document.querySelector(e)}catch{}}function g(e){let t=new Set;for(let n of e){if(n===m)continue;let e=h(n);e&&t.add(e)}return t}function _(e,t){let n=t??e.options.scrollRestoration,r=e._scroll;n&&(r.e=!0);let i=e.options.getScrollRestorationKey||u,s=new Set,l=e=>{let t=c[e]||={};for(let e of s)e===document?t[m]={scrollX,scrollY}:e.isConnected&&(t[d(e)]={scrollX:e.scrollLeft,scrollY:e.scrollTop})};n&&!r.s&&(r.s=!0,p=!1,history.scrollRestoration=`manual`,document.addEventListener(`scroll`,e=>{p||s.add(e.target)},!0),e.subscribe(`onBeforeLoad`,e=>{e.fromLocation&&l(i(e.fromLocation)),s.clear()}),addEventListener(`pagehide`,()=>{history.scrollRestoration=`auto`,l(i(e.stores.resolvedLocation.get()??e.stores.location.get()));try{o?.setItem(a,JSON.stringify(c))}catch{}}),addEventListener(`pageshow`,e=>{e.persisted&&(history.scrollRestoration=`manual`)})),!r.r&&(r.r=!0,e.subscribe(`onRendered`,t=>{let n=e.options.scrollRestorationBehavior,a=e.options.scrollToTopSelectors,o=r.n,l=r.h,u;if(s.clear(),r.n=!0,r.h=!1,typeof e.options.scrollRestoration==`function`&&!e.options.scrollRestoration({location:e.latestLocation}))return;let d=i(t.toLocation),f=t.fromLocation&&i(t.fromLocation);if(r.e&&f&&f!==d){let e=c[f];if(e){let t=c[d];for(let n in e){if(n===m){if(o)continue}else{let e=h(n);if(!e||o&&a&&(u??=g(a),u.has(e)))continue}t||=c[d]={},t[n]??=e[n]}}}p=!0;try{let e=t.toLocation.hash,i=t.toLocation.state.__hashScrollIntoViewOptions??!0,s=!1;if(o){!e&&a&&(u??=g(a));let t=e&&i&&l,o=r.e?c[d]:void 0;if(o)for(let e in o){let{scrollX:r,scrollY:i}=o[e];if(e===m){if(t)continue;scrollTo({top:i,left:r,behavior:n}),s=!0}else{let t=h(e);t&&(t.scrollLeft=r,t.scrollTop=i,u?.delete(t))}}if(!e){let e={top:0,left:0,behavior:n};if(s||scrollTo(e),u)for(let t of u)t.scrollTo(e)}}!s&&e&&i&&document.getElementById(e)?.scrollIntoView(i)}finally{p=!1}}))}var v=864e5,y={"24h":{period:`24 hours`,durationMs:v},"7d":{period:`7 days`,durationMs:7*v},"30d":{period:`30 days`,durationMs:30*v},"90d":{period:`90 days`,durationMs:90*v}},b=Object.keys(y),x=e=>b[b.indexOf(e)+1],S=(e,t)=>({beforeReceivedAtMs:t,sinceMs:Math.max(0,t-y[e].durationMs)}),C=e=>typeof e==`string`&&e.length>0?e:void 0,w=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0?e:void 0,T=e=>b.find(t=>t===e);function E(e){let t=D(e.search);return t.query===void 0&&t.installId===void 0?`/installations?eventsBefore=${t.eventsBefore??`new`}&eventsRange=${t.eventsRange??`7d`}&eventsCursor=${t.eventsCursor??`first`}`:e.state.__TSR_key}function D(e){return{query:typeof e.query==`string`?e.query:void 0,installId:typeof e.installId==`string`?e.installId:void 0,eventsCursor:C(e.eventsCursor),eventsBefore:w(e.eventsBefore),eventsRange:T(e.eventsRange),searchCursor:C(e.searchCursor),historyCursor:C(e.historyCursor),historyBefore:w(e.historyBefore)}}var O=n(`/installations`)({beforeLoad:({context:t})=>e(t.queryClient,`insights`),notFoundComponent:r(()=>t(()=>import(`./installations-1jALHnM3.js`),__vite__mapDeps([0,1,2,3,4,5,6])),`notFoundComponent`),component:r(()=>t(()=>import(`./installations-DUidui9Z.js`),__vite__mapDeps([7,2,8,3,9,10,11,12,13,14,15,16,17,18,6,19,4,20,21,22])),`component`),staticData:{scrollRestorationKey:E},validateSearch:D});export{y as a,_ as c,S as i,E as n,x as o,b as r,f as s,O as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ar as e}from"./sidebar-
|
|
1
|
+
import{ar as e}from"./sidebar-CQ6iq0qe.js";var t=e(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]);export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ar as e}from"./sidebar-
|
|
1
|
+
import{ar as e}from"./sidebar-CQ6iq0qe.js";var t=e(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]);export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ar as e}from"./sidebar-
|
|
1
|
+
import{ar as e}from"./sidebar-CQ6iq0qe.js";var t=e(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]);export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Ur as e}from"./sidebar-CQ6iq0qe.js";import{n as t,t as n}from"./remote-config-Cwwsatrr.js";var r=e();function i(){let{tab:e=`parameters`}=n.useSearch(),i=n.useNavigate();return(0,r.jsx)(t,{onTabChange:e=>void i({search:e===`parameters`?{}:{tab:e},replace:!0}),tab:e})}export{i as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./ConsoleFeatureUnavailable-Bf8tgug-.js";var t=e;export{t as notFoundComponent};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/remote-config-
|
|
2
|
-
import{
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/remote-config-BtStN5bt.js","assets/ConsoleFeatureUnavailable-Bf8tgug-.js","assets/sidebar-CQ6iq0qe.js","assets/console-features-api-BD7j--gS.js","assets/arrow-up-right-Dz8o-Kab.js","assets/NotFoundPage-HomiHjdL.js","assets/empty-L3UcNk_l.js","assets/remote-config-BcoOZ9fs.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{$ as e,Bn as t,Fn as n,Gn as r,Hn as i,Hr as a,Jn as o,Ln as s,Rn as c,Ur as l,Vn as u,Wr as d,Yt as f,Z as p,Zn as m,ar as h,cr as g,ei as _,fn as v,ir as y,jr as b,nr as x,p as S,ri as C,rr as w,ut as T}from"./sidebar-CQ6iq0qe.js";import{r as ee}from"./console-features-api-BD7j--gS.js";import{a as te,c as E,i as D,m as O,s as k}from"./useCompositeListItem-VmWjhZ9j.js";import{a as ne,d as re,i as ie,l as ae,n as oe,o as se,r as ce,s as le,t as ue}from"./alert-dialog-BSs_5Od-.js";import{h as de,i as fe}from"./api-DSWk32Mz.js";import{a as A,b as j,d as M,f as N,g as pe,h as me,i as he,l as P,m as ge,n as _e,o as ve,p as F,r as I,s as ye,t as L,u as R,v as z,y as be}from"./field-DNqNwq7i.js";import{N as xe,a as Se,i as B,n as Ce,o as we,r as V,s as Te,t as Ee}from"./select-BE-xONpm.js";import{t as De}from"./clipboard-BYT_TJ0K.js";import{a as Oe,c as H,i as ke,l as Ae,n as je,o as Me,r as Ne,t as Pe}from"./dialog-YKZpU5St.js";import{t as Fe}from"./refresh-cw-BMlpOsfM.js";import{i as Ie,n as Le,o as Re,r as ze,s as Be,t as Ve}from"./input-group-C9ZIjV0o.js";import{t as He}from"./search-B_o3avCI.js";import{a as Ue,i as We,n as U,o as Ge,r as Ke,s as qe,t as Je}from"./switch-DR0WP2g8.js";import{t as Ye}from"./smartphone--CTny1h9.js";import{t as Xe}from"./undo-2-Dcq6sgUo.js";import{n as W}from"./dist-B7eA4Mtf.js";import{a as Ze,i as Qe,n as $e,o as et,r as tt,t as nt}from"./tabs-B4Ffq4fD.js";import{a as rt,i as it,n as at,o as ot,r as st,t as ct}from"./empty-L3UcNk_l.js";var lt=h(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),ut=h(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),dt=h(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),ft=h(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),pt=h(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),mt=h(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),ht=h(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),gt=h(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),G=C(_()),K=l(),_t=C(Ue(),1),vt=C(We(),1),yt=w({method:`GET`}).middleware([x]).handler(d(`0ccfae64b399b03d820328fa98a38e2caa0b622d3da5a7ca633c5a0e8101e3f6`)),bt=w({method:`GET`}).middleware([x]).handler(d(`3377db68b9d1d971971595469029c0466da0777a177b294d655cd0c039737f1a`)),xt=w({method:`GET`}).middleware([x]).handler(d(`af71e3c55a659ce46093e33b9d70e729359610eec7d576502e8f0e26c785b317`)),St=w({method:`POST`}).middleware([x]).handler(d(`4182bf9ccbb675700638f30bc6122517ccd90b16a339a6823a0f5f6c808d70a6`)),Ct=w({method:`POST`}).middleware([x]).handler(d(`98c10bdc514eb4d3fe65af546be44452b492a81092cfe45625778a4c9f731727`)),wt=w({method:`POST`}).middleware([x]).handler(d(`1371bff16085636e2c44b60a573ae434b556c63045c40a0a93a93ab69ec47999`)),q={all:[`remote-config`],active:[`remote-config`,`active`],versions:[`remote-config`,`versions`],version:e=>[`remote-config`,`version`,e],preview:e=>[`remote-config`,`preview`,e]},Tt=()=>g({queryKey:q.active,queryFn:()=>yt(),staleTime:6e4}),Et=({enabled:e})=>O({queryKey:q.versions,queryFn:({pageParam:e})=>bt({data:e===void 0?{}:{cursor:e}}),initialPageParam:void 0,getNextPageParam:e=>e.next,staleTime:6e4,enabled:e}),Dt=e=>g({queryKey:q.version(e??0),queryFn:()=>xt({data:{version:e}}),enabled:e!==null,staleTime:1/0}),Ot=()=>{let e=a();return async()=>{await Promise.all([e.invalidateQueries({queryKey:q.active}),e.invalidateQueries({queryKey:q.versions})])}},kt=()=>{let e=Ot();return re({mutationFn:e=>St({data:e}),onSuccess:async t=>{(t.status===`published`||t.status===`conflict`)&&await e()}})},At=()=>re({mutationFn:e=>Ct({data:e}),onSuccess:Ot()}),jt=e=>g({queryKey:q.preview(e),queryFn:()=>wt({data:e}),placeholderData:b,staleTime:1/0}),J={STRING:`String`,NUMBER:`Number`,BOOLEAN:`Boolean`,JSON:`JSON`},Y={platform:`Platform`,channel:`Channel`,appVersion:`App version`,percent:`Percentage of installs`,cohort:`Cohort`,fingerprint:`Fingerprint`,dateTime:`Date and time`},X=(e,t)=>e!==void 0&&Object.hasOwn(e,t)?e[t]:void 0,Mt=(e,t)=>JSON.stringify(e)===JSON.stringify(t),Nt=(e,t,n,r)=>{let i=Object.entries(e.parameters),a=t===null?-1:i.findIndex(([e])=>e===t),o=a===-1?[...i.filter(([e])=>e!==n),[n,r]]:i.map((e,t)=>t===a?[n,r]:e);return{...e,parameters:Object.fromEntries(o)}},Pt=(e,t)=>({...e,parameters:Object.fromEntries(Object.entries(e.parameters).filter(([e])=>e!==t))}),Ft=(e,t)=>Object.fromEntries(Object.entries(e.parameters).map(([e,n])=>{let{conditionalValues:r,...i}=n,a=Object.entries(r??{}).flatMap(([e,n])=>{let r=t(e);return r===null?[]:[[r,n]]});return[e,a.length===0?i:{...i,conditionalValues:Object.fromEntries(a)}]})),It=(e,t,n)=>t===null?{...e,conditions:[...e.conditions,n]}:{conditions:e.conditions.map(e=>e.name===t?n:e),parameters:t===n.name?e.parameters:Ft(e,e=>e===t?n.name:e)},Lt=(e,t)=>({conditions:e.conditions.filter(e=>e.name!==t),parameters:Ft(e,e=>e===t?null:e)}),Rt=(e,t,n)=>{let r=t+n;if(r<0||r>=e.conditions.length)return e;let i=[...e.conditions];return[i[t],i[r]]=[i[r],i[t]],{...e,conditions:i}},zt=(e,t)=>Object.entries(e.parameters).filter(([,e])=>X(e.conditionalValues,t)!==void 0).map(([e])=>e),Bt=(e,t=3)=>e.length<=t?e.join(`, `):`${e.slice(0,t).join(`, `)} +${e.length-t}`,Vt=e=>Number.isInteger(e)?String(e):e.toFixed(1),Ht=e=>{let t=new Intl.DateTimeFormat(`en`,{timeZone:e,timeZoneName:e===`UTC`?`short`:`shortOffset`,year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`});return e=>t.format(new Date(e))},Ut=Ht(`UTC`),Wt=(e=new Date)=>{let t=new Date(e);t.setMinutes(60,0,0);let n=new Date(e);n.setDate(n.getDate()+1),n.setHours(9,0,0,0);let r=new Date(e);return r.setSeconds(0,0),[{label:`Now`,iso:r.toISOString()},{label:`Next hour`,iso:t.toISOString()},{label:`Tomorrow 09:00`,iso:n.toISOString()}]},Gt=(e,t=new Date)=>{let n=e===void 0?t:new Date(e),r=e=>{let t=new Date(n);return t.setDate(t.getDate()+e),t.setSeconds(0,0),t.toISOString()};return[{label:`+1 day`,iso:r(1)},{label:`+1 week`,iso:r(7)}]},Kt=e=>{if(e===void 0)return``;let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`},qt=e=>{if(e.length===0)return;let t=new Date(e).getTime();return Number.isFinite(t)?new Date(t).toISOString():void 0},Jt=(e,t=Ut)=>{switch(e.type){case`platform`:return`Platform is ${Bt(e.platforms.map(e=>e===`ios`?`iOS`:`Android`))}`;case`channel`:return`Channel is ${Bt(e.channels)}`;case`appVersion`:return`App version ${e.range}`;case`cohort`:return`Cohort is ${Bt(e.cohorts)}`;case`percent`:return e.from===0?`${Vt(e.to)}% of installs`:`${Vt(e.from)}–${Vt(e.to)}% of installs`;case`fingerprint`:return`Fingerprint is ${Bt(e.hashes.map(e=>e.slice(0,8)))}`;case`dateTime`:return e.from!==void 0&&e.to!==void 0?`From ${t(e.from)} until ${t(e.to)}`:e.from===void 0?`Until ${t(e.to??``)}`:`From ${t(e.from)}`}},Z=e=>`value`in e?e.value.length===0?`""`:e.value:`In-app default`,Yt=()=>{let e=crypto.getRandomValues(new Uint8Array(6));return Array.from(e,e=>e.toString(36).padStart(2,`0`)).join(``).slice(0,8)},Xt=(e,t)=>({added:Object.keys(t).filter(t=>!Object.hasOwn(e,t)),changed:Object.keys(t).filter(n=>Object.hasOwn(e,n)&&JSON.stringify(e[n])!==JSON.stringify(t[n])),removed:Object.keys(e).filter(e=>!Object.hasOwn(t,e))}),Zt=(e,t)=>{let n=e=>Object.fromEntries(e.conditions.map(e=>[e.name,e])),r=(e,t)=>e.conditions.map(({name:e})=>e).filter(e=>t.conditions.some(t=>t.name===e));return{parameters:Xt(e.parameters,t.parameters),conditions:Xt(n(e),n(t)),reordered:r(e,t).join(`
|
|
3
3
|
`)!==r(t,e).join(`
|
|
4
|
-
`)}},Q=`Not set`,Qt=(e,t)=>{let n=[],r=(e,t,r)=>{(t===null?r!==Q:t!==r)&&n.push({field:e,before:t,after:r})};r(`Type`,e===null?null:J[e.valueType],J[t.valueType]),r(`Default`,e===null?null:Z(e.defaultValue),Z(t.defaultValue));let i=new Set([...Object.keys(e?.conditionalValues??{}),...Object.keys(t.conditionalValues??{})]);for(let n of i){let i=X(e?.conditionalValues,n),a=X(t.conditionalValues,n);r(`When ${n}`,e===null?null:i===void 0?Q:Z(i),a===void 0?Q:Z(a))}return r(`Description`,e===null?null:e.description??Q,t.description??Q),n},$t=(e,t,n=Ut)=>{let r=e=>e.rules.map(e=>Jt(e,n)).join(` · `),i=r(t);if(e===null)return[{field:`Rules`,before:null,after:i}];let a=r(e);return a===i?[]:[{field:`Rules`,before:a,after:i}]},en=`hot-updater:remote-config-draft`,$=e=>typeof e==`object`&&!!e&&!Array.isArray(e),tn=e=>$(e)&&(typeof e.value==`string`||e.useInAppDefault===!0),nn=e=>$(e)&&$(e.parameters)&&Array.isArray(e.conditions)&&Object.values(e.parameters).every(e=>$(e)&&Object.hasOwn(J,String(e.valueType))&&tn(e.defaultValue)&&(e.conditionalValues===void 0||$(e.conditionalValues)&&Object.values(e.conditionalValues).every(tn)))&&e.conditions.every(e=>$(e)&&typeof e.name==`string`&&Array.isArray(e.rules)&&e.rules.every(e=>$(e)&&Object.hasOwn(Y,String(e.type)))),rn=e=>{try{let t=window.localStorage.getItem(en);if(t===null)return null;let n=JSON.parse(t);return!$(n)||n.baseVersion!==e.version||!nn(n.base)||!nn(n.template)||!Mt(n.base,e.template)||Mt(n.template,e.template)?null:{baseVersion:e.version,base:n.base,template:n.template}}catch{return null}},an=e=>{try{return e===null?window.localStorage.removeItem(en):window.localStorage.setItem(en,JSON.stringify(e)),!0}catch{return!1}},on=/^[A-Za-z_][A-Za-z0-9_]{0,255}$/u,sn=(e,t)=>e.length===0?`Enter a key.`:on.test(e)?t.includes(e)?`Another parameter uses this key.`:null:`Start with a letter or _, then use letters, digits, and _.`,cn=(e,t)=>{if(e===`NUMBER`)return t.trim().length>0&&Number.isFinite(Number(t))?null:`Enter a number.`;if(e===`JSON`)try{return JSON.parse(t),null}catch{return`Enter valid JSON.`}return e===`BOOLEAN`&&t!==`true`&&t!==`false`?`Choose true or false.`:null},ln=(e,t,n)=>{let r=e.map(e=>Jt(e,n)).join(` · `),i=r.length<=100?r:`${r.slice(0,99).trimEnd()}…`;if(i.length===0||!t.includes(i))return i;for(let e=2;;e+=1){let n=` (${e})`,r=`${i.slice(0,100-n.length)}${n}`;if(!t.includes(r))return r}},un=(e,t)=>{let n=e.trim();return n.length===0?`Enter a name.`:n.length>100?`Use 100 characters or fewer.`:t.includes(n)?`Another condition uses this name.`:null},dn=e=>[...new Set(e.split(/[\n,]/u).map(e=>e.trim()).filter(e=>e.length>0))],fn=e=>{switch(e.type){case`platform`:return e.platforms.length===0?`Choose a platform.`:null;case`channel`:return e.channels.length===0?`Enter a channel.`:null;case`appVersion`:return e.range.trim().length===0?`Enter a version range, such as >=1.4.0.`:null;case`cohort`:return e.cohorts.length===0?`Enter a cohort.`:null;case`percent`:return e.from>=e.to||e.from<0||e.to>100||Math.abs(e.to*10-Math.round(e.to*10))>1e-9||Math.abs(e.from*10-Math.round(e.from*10))>1e-9?`Use a range from 0 to 100 in steps of 0.1.`:null;case`fingerprint`:return e.hashes.length===0?`Enter a fingerprint.`:null;case`dateTime`:return e.from===void 0&&e.to===void 0?`Choose a start, an end, or both.`:e.from!==void 0&&e.to!==void 0&&e.from>=e.to?`End after the start.`:null}},pn=e=>{switch(e){case`platform`:return{type:e,platforms:[`ios`]};case`channel`:return{type:e,channels:[]};case`appVersion`:return{type:e,range:``};case`cohort`:return{type:e,cohorts:[]};case`percent`:return{type:e,seed:Yt(),from:0,to:10};case`fingerprint`:return{type:e,hashes:[]};case`dateTime`:return{type:e,from:Wt()[1].iso}}},mn=G.createContext(void 0);function hn(e=!0){let t=G.useContext(mn);if(t===void 0&&!e)throw Error(
|
|
4
|
+
`)}},Q=`Not set`,Qt=(e,t)=>{let n=[],r=(e,t,r)=>{(t===null?r!==Q:t!==r)&&n.push({field:e,before:t,after:r})};r(`Type`,e===null?null:J[e.valueType],J[t.valueType]),r(`Default`,e===null?null:Z(e.defaultValue),Z(t.defaultValue));let i=new Set([...Object.keys(e?.conditionalValues??{}),...Object.keys(t.conditionalValues??{})]);for(let n of i){let i=X(e?.conditionalValues,n),a=X(t.conditionalValues,n);r(`When ${n}`,e===null?null:i===void 0?Q:Z(i),a===void 0?Q:Z(a))}return r(`Description`,e===null?null:e.description??Q,t.description??Q),n},$t=(e,t,n=Ut)=>{let r=e=>e.rules.map(e=>Jt(e,n)).join(` · `),i=r(t);if(e===null)return[{field:`Rules`,before:null,after:i}];let a=r(e);return a===i?[]:[{field:`Rules`,before:a,after:i}]},en=`hot-updater:remote-config-draft`,$=e=>typeof e==`object`&&!!e&&!Array.isArray(e),tn=e=>$(e)&&(typeof e.value==`string`||e.useInAppDefault===!0),nn=e=>$(e)&&$(e.parameters)&&Array.isArray(e.conditions)&&Object.values(e.parameters).every(e=>$(e)&&Object.hasOwn(J,String(e.valueType))&&tn(e.defaultValue)&&(e.conditionalValues===void 0||$(e.conditionalValues)&&Object.values(e.conditionalValues).every(tn)))&&e.conditions.every(e=>$(e)&&typeof e.name==`string`&&Array.isArray(e.rules)&&e.rules.every(e=>$(e)&&Object.hasOwn(Y,String(e.type)))),rn=e=>{try{let t=window.localStorage.getItem(en);if(t===null)return null;let n=JSON.parse(t);return!$(n)||n.baseVersion!==e.version||!nn(n.base)||!nn(n.template)||!Mt(n.base,e.template)||Mt(n.template,e.template)?null:{baseVersion:e.version,base:n.base,template:n.template}}catch{return null}},an=e=>{try{return e===null?window.localStorage.removeItem(en):window.localStorage.setItem(en,JSON.stringify(e)),!0}catch{return!1}},on=/^[A-Za-z_][A-Za-z0-9_]{0,255}$/u,sn=(e,t)=>e.length===0?`Enter a key.`:on.test(e)?t.includes(e)?`Another parameter uses this key.`:null:`Start with a letter or _, then use letters, digits, and _.`,cn=(e,t)=>{if(e===`NUMBER`)return t.trim().length>0&&Number.isFinite(Number(t))?null:`Enter a number.`;if(e===`JSON`)try{return JSON.parse(t),null}catch{return`Enter valid JSON.`}return e===`BOOLEAN`&&t!==`true`&&t!==`false`?`Choose true or false.`:null},ln=(e,t,n)=>{let r=e.map(e=>Jt(e,n)).join(` · `),i=r.length<=100?r:`${r.slice(0,99).trimEnd()}…`;if(i.length===0||!t.includes(i))return i;for(let e=2;;e+=1){let n=` (${e})`,r=`${i.slice(0,100-n.length)}${n}`;if(!t.includes(r))return r}},un=(e,t)=>{let n=e.trim();return n.length===0?`Enter a name.`:n.length>100?`Use 100 characters or fewer.`:t.includes(n)?`Another condition uses this name.`:null},dn=e=>[...new Set(e.split(/[\n,]/u).map(e=>e.trim()).filter(e=>e.length>0))],fn=e=>{switch(e.type){case`platform`:return e.platforms.length===0?`Choose a platform.`:null;case`channel`:return e.channels.length===0?`Enter a channel.`:null;case`appVersion`:return e.range.trim().length===0?`Enter a version range, such as >=1.4.0.`:null;case`cohort`:return e.cohorts.length===0?`Enter a cohort.`:null;case`percent`:return e.from>=e.to||e.from<0||e.to>100||Math.abs(e.to*10-Math.round(e.to*10))>1e-9||Math.abs(e.from*10-Math.round(e.from*10))>1e-9?`Use a range from 0 to 100 in steps of 0.1.`:null;case`fingerprint`:return e.hashes.length===0?`Enter a fingerprint.`:null;case`dateTime`:return e.from===void 0&&e.to===void 0?`Choose a start, an end, or both.`:e.from!==void 0&&e.to!==void 0&&e.from>=e.to?`End after the start.`:null}},pn=e=>{switch(e){case`platform`:return{type:e,platforms:[`ios`]};case`channel`:return{type:e,channels:[]};case`appVersion`:return{type:e,range:``};case`cohort`:return{type:e,cohorts:[]};case`percent`:return{type:e,seed:Yt(),from:0,to:10};case`fingerprint`:return{type:e,hashes:[]};case`dateTime`:return{type:e,from:Wt()[1].iso}}},mn=G.createContext(void 0);function hn(e=!0){let t=G.useContext(mn);if(t===void 0&&!e)throw Error(o(7));return t}function gn(e){let{render:n,className:r,style:a,state:o=i,props:s=u,refs:c=u,metadata:l,stateAttributesMapping:d,tag:f=`div`,...p}=e,{compositeProps:m,compositeRef:h}=et({metadata:l});return t(f,e,{state:o,ref:[...c,h],props:[m,...s,p],stateAttributesMapping:d})}var _n=G.forwardRef(function(e,n){let{className:i,defaultPressed:a=!1,disabled:o=!1,form:s,onPressedChange:c,pressed:l,render:u,type:d,value:p,nativeButton:m=!0,style:h,...g}=e,_=T(p||void 0),y=hn(),b=y?.value??[],x=y?void 0:a,S=(o||y?.disabled)??!1,[C,w]=D({controlled:y?_!==void 0&&b.indexOf(_)>-1:l,default:x,name:`Toggle`,state:`pressed`}),{getButtonProps:ee,buttonRef:te}=r({disabled:S,native:m}),E={disabled:S,pressed:C},O=[te,n],k=[{"aria-pressed":C,onClick(e){let t=!C,n=f(v,e.nativeEvent);_&&y?.setGroupValue?.(_,t,n),c?.(t,n),!n.isCanceled&&w(t)}},g,ee],ne=t(`button`,e,{enabled:!y,state:E,ref:O,props:k});return y?(0,K.jsx)(gn,{tag:`button`,render:u,className:i,style:h,state:E,refs:O,props:k}):ne}),vn=function(e){return e.disabled=`data-disabled`,e.orientation=`data-orientation`,e.multiple=`data-multiple`,e}({}),yn={multiple(e){return e?{[vn.multiple]:``}:null}},bn=G.forwardRef(function(e,n){let{defaultValue:r,disabled:i=!1,loopFocus:a=!0,onValueChange:o,orientation:s=`horizontal`,multiple:c=!1,value:l,className:d,render:f,style:p,...h}=e,g=Te(!0),_=G.useMemo(()=>l!==void 0||r!==void 0,[l,r]),v=(g?.disabled??!1)||i,[y,b]=D({controlled:l,default:l===void 0?r??u:void 0,name:`ToggleGroup`,state:`value`}),x=m((e,t,n)=>{let r;c?(r=y.slice(),t?r.push(e):r.splice(y.indexOf(e),1)):r=t?[e]:[],o?.(r,n),!n.isCanceled&&b(r)}),S={disabled:v,multiple:c,orientation:s},C=G.useMemo(()=>({disabled:v,orientation:s,setGroupValue:x,value:y,isValueInitialized:_}),[v,s,x,y,_]),w={role:`group`},T=t(`div`,e,{enabled:!!g,state:S,ref:n,props:[w,h],stateAttributesMapping:yn});return(0,K.jsx)(mn.Provider,{value:C,children:g?T:(0,K.jsx)(Ze,{render:f,className:d,style:p,state:S,refs:[n],props:[w,h],stateAttributesMapping:yn,loopFocus:a,enableHomeAndEndKeys:!0,orientation:s})})}),xn=c(`group/toggle inline-flex items-center justify-center gap-1 rounded-md text-xs font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-transparent`,outline:`border border-input bg-transparent hover:bg-muted`},size:{default:`h-7 min-w-7 px-2 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5`,sm:`h-6 min-w-6 rounded-[min(var(--radius-md),8px)] px-2 text-[0.625rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3`,lg:`h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`}},defaultVariants:{variant:`default`,size:`default`}}),Sn=G.createContext({size:`default`,variant:`default`,spacing:2,orientation:`horizontal`});function Cn({className:e,variant:t,size:n,spacing:r=2,orientation:i=`horizontal`,children:a,...o}){return(0,K.jsx)(bn,{"data-slot":`toggle-group`,"data-variant":t,"data-size":n,"data-spacing":r,"data-orientation":i,style:{"--gap":r},className:s(`group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-md data-[size=sm]:rounded-[min(var(--radius-md),8px)] data-vertical:flex-col data-vertical:items-stretch`,e),...o,children:(0,K.jsx)(Sn.Provider,{value:{variant:t,size:n,spacing:r,orientation:i},children:a})})}function wn({className:e,children:t,variant:n=`default`,size:r=`default`,...i}){let a=G.useContext(Sn);return(0,K.jsx)(_n,{"data-slot":`toggle-group-item`,"data-variant":a.variant||n,"data-size":a.size||r,"data-spacing":a.spacing,className:s(`shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-md group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-md group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-md group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-md group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t`,xn({variant:a.variant||n,size:a.size||r}),e),...i,children:t})}function Tn(){let[e,t]=(0,G.useState)(`UTC`);return(0,G.useEffect)(()=>{t(Intl.DateTimeFormat().resolvedOptions().timeZone)},[]),{timeZone:e,dateTimeText:(0,G.useMemo)(()=>Ht(e),[e])}}var En=Object.keys(Y);function Dn({id:e,values:t,onChange:n,placeholder:r,multiline:i=!1}){let[a,o]=(0,G.useState)(t.join(`, `)),[s,c]=(0,G.useState)(t);s!==t&&(c(t),dn(a).join(`
|
|
5
5
|
`)!==t.join(`
|
|
6
|
-
`)&&o(t.join(`, `)));let l=e=>{o(e),n(dn(e))};return i?(0,K.jsx)(Re,{className:`min-h-20 font-mono text-xs`,id:e,onChange:e=>l(e.target.value),placeholder:r,spellCheck:!1,value:a}):(0,K.jsx)(f,{autoComplete:`off`,className:`min-h-11 sm:min-h-9`,id:e,onChange:e=>l(e.target.value),placeholder:r,value:a})}function On({id:e,label:n,value:r,presets:i,onChange:a}){return(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:e,children:n}),(0,K.jsxs)(Ve,{className:`h-11 sm:h-9`,children:[(0,K.jsx)(Ie,{className:`h-11 tabular-nums sm:h-9`,id:e,onChange:e=>a(qt(e.target.value)),type:`datetime-local`,value:Kt(r)}),r===void 0?null:(0,K.jsx)(Le,{align:`inline-end`,children:(0,K.jsx)(ze,{"aria-label":`Clear ${n.toLowerCase()}`,className:`size-11 sm:size-5`,onClick:()=>a(void 0),size:`icon-xs`,children:(0,K.jsx)(v,{})})})]}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:i.map(e=>(0,K.jsx)(t,{"aria-pressed":e.iso===r,className:`min-h-11 sm:min-h-6`,onClick:()=>a(e.iso),size:`xs`,type:`button`,variant:e.iso===r?`secondary`:`outline`,children:e.label},e.label))})]})}function kn({rule:e,onChange:n}){let r=(0,G.useId)(),i=fe();switch(e.type){case`platform`:return(0,K.jsx)(Cn,{"aria-label":`Platforms`,multiple:!0,onValueChange:t=>n({...e,platforms:t.filter(e=>e===`ios`||e===`android`)}),value:[...e.platforms],variant:`outline`,children:[`ios`,`android`].map(e=>(0,K.jsxs)(wn,{className:`min-h-11 px-3 sm:min-h-8`,value:e,children:[(0,K.jsx)(xe,{className:`size-3.5`,platform:e}),e===`ios`?`iOS`:`Android`]},e))});case`channel`:{let a=(i.data??[]).map(({name:e})=>e).filter(t=>!e.channels.includes(t));return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(Dn,{id:`${r}-channels`,onChange:t=>n({...e,channels:t}),placeholder:`production, beta`,values:e.channels}),a.length>0?(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Add:`}),a.slice(0,8).map(r=>(0,K.jsxs)(t,{className:`min-h-11 sm:min-h-6`,onClick:()=>n({...e,channels:[...e.channels,r]}),size:`xs`,type:`button`,variant:`outline`,children:[(0,K.jsx)(H,{"data-icon":`inline-start`}),r]},r))]}):null]})}case`appVersion`:return(0,K.jsx)(f,{"aria-label":`App version range`,autoComplete:`off`,className:`min-h-11 font-mono sm:min-h-9`,onChange:t=>n({...e,range:t.target.value}),placeholder:`>=1.4.0`,value:e.range});case`cohort`:return(0,K.jsx)(Dn,{id:`${r}-cohorts`,onChange:t=>n({...e,cohorts:t}),placeholder:`1, 2, beta-testers`,values:e.cohorts});case`percent`:return(0,K.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[repeat(2,minmax(0,8rem))_minmax(0,1fr)]`,children:[(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${r}-from`,children:`From %`}),(0,K.jsx)(f,{className:`min-h-11 tabular-nums sm:min-h-9`,id:`${r}-from`,inputMode:`decimal`,max:100,min:0,onChange:t=>n({...e,from:Number(t.target.value)}),step:.1,type:`number`,value:e.from})]}),(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${r}-to`,children:`To %`}),(0,K.jsx)(f,{className:`min-h-11 tabular-nums sm:min-h-9`,id:`${r}-to`,inputMode:`decimal`,max:100,min:0,onChange:t=>n({...e,to:Number(t.target.value)}),step:.1,type:`number`,value:e.to})]}),(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${r}-seed`,children:`Seed`}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(f,{autoComplete:`off`,className:`min-h-11 font-mono sm:min-h-9`,id:`${r}-seed`,onChange:t=>n({...e,seed:t.target.value}),value:e.seed}),(0,K.jsx)(t,{"aria-label":`New seed`,className:`size-11 sm:size-9`,onClick:()=>n({...e,seed:Yt()}),size:`icon`,type:`button`,variant:`outline`,children:(0,K.jsx)(Fe,{})})]})]})]});case`fingerprint`:return(0,K.jsx)(Dn,{id:`${r}-hashes`,multiline:!0,onChange:t=>n({...e,hashes:t}),placeholder:`One fingerprint hash per line`,values:e.hashes});case`dateTime`:{let t=(t,r)=>{let{[t]:i,...a}=e;n(r===void 0?a:{...a,[t]:r})};return(0,K.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,K.jsx)(On,{id:`${r}-from`,label:`From`,onChange:e=>t(`from`,e),presets:Wt(),value:e.from}),(0,K.jsx)(On,{id:`${r}-until`,label:`Until`,onChange:e=>t(`to`,e),presets:Gt(e.from),value:e.to})]})}}}var An={platform:`Devices on any of these platforms.`,channel:`Devices on any of these channels, separated by commas.`,appVersion:`A semver range of native app versions, as release targets use: 2.x, >=1.4.0 <2.0.0.`,percent:`Installs whose numeric cohort lands in this share. Rules with one seed split the same order, so 0–10 and 10–20 never overlap.`,cohort:`Numeric cohorts from 1 to 1000, or custom cohort names.`,fingerprint:`Native builds with any of these fingerprints.`,dateTime:`Leave either end empty to keep it open. Devices get the change at their next fetch.`};function jn({open:e,onOpenChange:t,condition:n,takenNames:r,onSave:i}){let a=Ke(e);return(0,K.jsx)(Pe,{onOpenChange:t,open:e,children:(0,K.jsx)(je,{className:`max-h-[calc(100svh-2rem)] overflow-y-auto sm:max-w-xl`,children:(0,K.jsx)(Mn,{condition:n,onCancel:()=>t(!1),onSave:e=>{i(e),t(!1)},takenNames:r},a)})})}function Mn({condition:e,takenNames:n,onSave:r,onCancel:i}){let a=(0,G.useId)(),{dateTimeText:o,timeZone:s}=Tn(),[c,l]=(0,G.useState)(()=>e===null||e.name===ln(e.rules,n,o)?``:e.name),[u,d]=(0,G.useState)(e===null?[pn(`platform`)]:[...e.rules]),[p,m]=(0,G.useState)(!1),h=ln(u,n,o),g=c.trim().length===0?h:c,_=un(g,n),v=u.map(fn),y=En.filter(e=>!u.some(t=>t.type===e)),b=_!==null||u.length===0||v.some(e=>e!==null);return(0,K.jsxs)(`form`,{className:`flex flex-col gap-4`,noValidate:!0,onSubmit:e=>{e.preventDefault(),e.stopPropagation(),m(!0),!b&&r({name:g.trim(),rules:u.map(e=>e.type===`appVersion`?{...e,range:e.range.trim()}:e)})},children:[(0,K.jsxs)(Oe,{children:[(0,K.jsx)(Me,{children:e===null?`Add condition`:`Edit condition`}),(0,K.jsx)(Ne,{children:`A device matches when it matches every rule.`})]}),(0,K.jsxs)(he,{children:[(0,K.jsxs)(L,{"data-invalid":p&&_!==null||void 0,children:[(0,K.jsx)(A,{htmlFor:`${a}-name`,children:`Name`}),(0,K.jsx)(f,{autoComplete:`off`,className:`min-h-11 sm:min-h-9`,id:`${a}-name`,maxLength:101,onChange:e=>l(e.target.value),placeholder:h||`Beta testers on iOS`,value:c}),(0,K.jsx)(_e,{children:`Optional: without one, it is named after its rules.`}),(0,K.jsx)(I,{children:p?_:null})]}),(0,K.jsxs)(ye,{children:[(0,K.jsx)(ve,{variant:`label`,children:`Rules`}),u.length===0?(0,K.jsx)(I,{children:p?`Add at least one rule.`:null}):null,(0,K.jsx)(`ol`,{className:`flex flex-col gap-3`,children:u.map((e,n)=>(0,K.jsx)(`li`,{className:`rounded-lg border p-3`,children:(0,K.jsxs)(L,{"data-invalid":p&&v[n]!==null||void 0,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium`,children:Y[e.type]}),(0,K.jsx)(t,{"aria-label":`Remove the ${Y[e.type].toLowerCase()} rule`,className:`size-11 sm:size-7`,onClick:()=>d(u.filter((e,t)=>t!==n)),size:`icon-sm`,type:`button`,variant:`ghost`,children:(0,K.jsx)(Ge,{})})]}),(0,K.jsx)(kn,{onChange:e=>d(u.map((t,r)=>r===n?e:t)),rule:e}),(0,K.jsx)(_e,{children:e.type===`dateTime`?`In your time zone, ${s}. ${An.dateTime}`:An[e.type]}),(0,K.jsx)(I,{children:p?v[n]:null})]})},e.type))}),y.length>0?(0,K.jsxs)(Ee,{items:Object.fromEntries(y.map(e=>[e,Y[e]])),onValueChange:e=>{e!==null&&d([...u,pn(e)])},value:null,children:[(0,K.jsxs)(Se,{"aria-label":`Add a rule`,className:`min-h-11 w-full sm:min-h-9 sm:w-56`,children:[(0,K.jsx)(H,{"aria-hidden":`true`,className:`size-3.5`}),(0,K.jsx)(we,{placeholder:`Add a rule`})]}),(0,K.jsx)(Ce,{alignItemWithTrigger:!1,children:(0,K.jsx)(V,{children:y.map(e=>(0,K.jsx)(B,{value:e,children:Y[e]},e))})})]}):null]})]}),(0,K.jsxs)(ke,{children:[(0,K.jsx)(t,{onClick:i,type:`button`,variant:`outline`,children:`Cancel`}),(0,K.jsx)(t,{type:`submit`,children:e===null?`Add condition`:`Save condition`})]})]})}function Nn({condition:e,dateTimeText:t}){let n=e.rules.map(e=>Jt(e,t)).join(` · `);return n===e.name?null:(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})}function Pn({template:e,onSaveCondition:n,onRemoveCondition:r,onMoveCondition:i}){let[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(null),l=U(a),u=U(s),{dateTimeText:d}=Tn(),{conditions:f}=e,p=l?.condition?.name??null,m=t=>{let n=zt(e,t);n.length===0?r(t):c({name:t,users:n})};return(0,K.jsxs)(ge,{className:`overflow-hidden shadow-sm`,children:[(0,K.jsxs)(z,{className:`flex-row flex-wrap items-center justify-between gap-3 space-y-0 border-b px-4 py-3 sm:px-6`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(be,{className:`text-sm`,children:(0,K.jsx)(`h2`,{children:`Conditions`})}),(0,K.jsx)(pe,{className:`text-xs`,children:`Listed by priority: when several match a device, the first wins.`})]}),(0,K.jsxs)(t,{className:`min-h-11 sm:min-h-7`,onClick:()=>o({condition:null}),children:[(0,K.jsx)(H,{"data-icon":`inline-start`}),`Add condition`]})]}),(0,K.jsx)(me,{className:`p-0`,children:f.length===0?(0,K.jsxs)(ct,{className:`py-10`,children:[(0,K.jsxs)(it,{children:[(0,K.jsx)(rt,{variant:`icon`,children:(0,K.jsx)(pt,{})}),(0,K.jsx)(ot,{children:`No conditions`}),(0,K.jsx)(st,{children:`Add a condition to give some devices other values: a platform, channel, app version range, cohort, or a share of installs.`})]}),(0,K.jsx)(at,{children:(0,K.jsxs)(t,{className:`min-h-11 sm:min-h-7`,onClick:()=>o({condition:null}),children:[(0,K.jsx)(H,{"data-icon":`inline-start`}),`Add condition`]})})]}):(0,K.jsx)(`ol`,{"aria-label":`Conditions`,className:`divide-y`,children:f.map((n,r)=>{let a=zt(e,n.name);return(0,K.jsxs)(`li`,{className:`grid gap-3 px-4 py-3 sm:px-6 md:grid-cols-[auto_minmax(0,1fr)_auto] md:items-center`,children:[(0,K.jsx)(`span`,{"aria-label":`Priority ${r+1}`,className:`flex size-6 items-center justify-center rounded-md bg-muted text-xs font-medium tabular-nums`,children:r+1}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`truncate text-sm font-medium`,children:n.name}),(0,K.jsx)(Nn,{condition:n,dateTimeText:d}),(0,K.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:a.length===0?`No parameter uses it yet`:`Sets ${a.length===1?`1 parameter`:`${a.length} parameters`}: ${a.slice(0,3).join(`, `)}${a.length>3?`…`:``}`})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1 md:justify-end`,children:[(0,K.jsx)(t,{"aria-label":`Move ${n.name} up`,className:`size-11 md:size-7`,disabled:r===0,onClick:()=>i(r,-1),size:`icon`,variant:`ghost`,children:(0,K.jsx)(ut,{})}),(0,K.jsx)(t,{"aria-label":`Move ${n.name} down`,className:`size-11 md:size-7`,disabled:r===f.length-1,onClick:()=>i(r,1),size:`icon`,variant:`ghost`,children:(0,K.jsx)(lt,{})}),(0,K.jsxs)(t,{"aria-label":`Edit ${n.name}`,className:`min-h-11 md:min-h-7`,onClick:()=>o({condition:n}),size:`sm`,variant:`outline`,children:[(0,K.jsx)(ht,{"data-icon":`inline-start`}),`Edit`]}),(0,K.jsx)(t,{"aria-label":`Delete ${n.name}`,className:`size-11 md:size-7`,onClick:()=>m(n.name),size:`icon`,variant:`ghost`,children:(0,K.jsx)(Ge,{})})]})]},n.name)})})}),(0,K.jsx)(jn,{condition:l?.condition??null,onOpenChange:e=>{e||o(null)},onSave:e=>n(p,e),open:a!==null,takenNames:f.map(({name:e})=>e).filter(e=>e!==p)}),(0,K.jsx)(ue,{onOpenChange:e=>{e||c(null)},open:s!==null,children:(0,K.jsxs)(ie,{children:[(0,K.jsxs)(le,{children:[(0,K.jsxs)(ae,{children:[`Delete `,u?.name,`?`]}),(0,K.jsxs)(ne,{children:[u?.users.length===1?`1 parameter has a value for it`:`${u?.users.length} parameters have a value for it`,` `,`(`,u?.users.join(`, `),`). Those values are removed too, so matching devices get the default value after you publish.`]})]}),(0,K.jsxs)(se,{children:[(0,K.jsx)(ce,{children:`Cancel`}),(0,K.jsx)(oe,{onClick:e=>{e.preventDefault(),s!==null&&r(s.name),c(null)},variant:`destructive`,children:`Delete condition`})]})]})})]})}var Fn=e=>e===`BOOLEAN`?`false`:e===`NUMBER`?`0`:e===`JSON`?`{}`:``,In=(e,t)=>`value`in t?cn(e,t.value):null;function Ln({id:e,label:n,valueType:r,value:i,onChange:a,showErrors:o}){let s=!(`value`in i),c=`value`in i?i.value:``,l=o?In(r,i):null,u=e=>a({value:e});return(0,K.jsxs)(L,{"data-invalid":l!==null||void 0,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,K.jsx)(A,{htmlFor:e,id:`${e}-label`,children:n}),(0,K.jsxs)(`div`,{className:`flex min-h-11 items-center gap-2 text-xs text-muted-foreground sm:min-h-0`,children:[(0,K.jsx)(Je,{checked:s,id:`${e}-in-app-default`,onCheckedChange:e=>a(e?{useInAppDefault:!0}:{value:Fn(r)})}),(0,K.jsx)(`label`,{htmlFor:`${e}-in-app-default`,children:`Use in-app default`})]})]}),s?(0,K.jsxs)(`p`,{className:`rounded-md border border-dashed px-3 py-2 text-xs text-muted-foreground`,id:e,children:[`Devices keep the default set in the app's`,` `,(0,K.jsxs)(`code`,{className:`font-mono`,children:[`remoteConfig(`,`{ defaults }`,`)`]}),`.`]}):r===`BOOLEAN`?(0,K.jsxs)(Cn,{"aria-labelledby":`${e}-label`,id:e,onValueChange:e=>{let[t]=e;(t===`true`||t===`false`)&&u(t)},value:[c],variant:`outline`,children:[(0,K.jsx)(wn,{className:`min-h-11 px-4 sm:min-h-8`,value:`true`,children:`true`}),(0,K.jsx)(wn,{className:`min-h-11 px-4 sm:min-h-8`,value:`false`,children:`false`})]}):r===`NUMBER`?(0,K.jsx)(f,{"aria-invalid":l!==null||void 0,autoComplete:`off`,className:`min-h-11 font-mono sm:min-h-9`,id:e,inputMode:`decimal`,onChange:e=>u(e.target.value),value:c}):r===`JSON`?(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(Re,{"aria-invalid":l!==null||void 0,className:`min-h-24 font-mono text-xs`,id:e,onChange:e=>u(e.target.value),spellCheck:!1,value:c}),(0,K.jsxs)(t,{className:`self-start`,disabled:cn(`JSON`,c)!==null,onClick:()=>u(JSON.stringify(JSON.parse(c),null,2)),size:`sm`,type:`button`,variant:`outline`,children:[(0,K.jsx)(dt,{"data-icon":`inline-start`}),`Format JSON`]})]}):(0,K.jsx)(Re,{"aria-invalid":l!==null||void 0,className:`min-h-11 text-sm sm:min-h-9`,id:e,onChange:e=>u(e.target.value),rows:2,value:c}),(0,K.jsx)(I,{children:l})]})}var Rn=Object.keys(J),zn={STRING:`getString`,NUMBER:`getNumber`,BOOLEAN:`getBoolean`,JSON:`getString`},Bn=(e,t)=>`value`in e&&In(t,e)!==null?{value:Fn(t)}:e;function Vn({open:e,onOpenChange:t,parameterKey:n,parameter:r,takenKeys:i,conditions:a,onSave:o,onAddCondition:s}){let c=Ke(e);return(0,K.jsx)(Pe,{onOpenChange:t,open:e,children:(0,K.jsx)(je,{className:`max-h-[calc(100svh-2rem)] overflow-y-auto data-nested-dialog-open:after:absolute data-nested-dialog-open:after:inset-0 data-nested-dialog-open:after:rounded-xl data-nested-dialog-open:after:bg-background/70 sm:max-w-2xl`,children:(0,K.jsx)(Hn,{conditions:a,onAddCondition:s,onCancel:()=>t(!1),onSave:(e,n)=>{o(e,n),t(!1)},parameter:r,parameterKey:n,takenKeys:i},c)})})}function Hn({parameterKey:e,parameter:n,takenKeys:r,conditions:i,onSave:a,onCancel:o,onAddCondition:s}){let c=(0,G.useId)(),{dateTimeText:l}=Tn(),[u,d]=(0,G.useState)(e??``),[p,m]=(0,G.useState)(n?.valueType??`STRING`),[h,g]=(0,G.useState)(n?.description??``),_=h.trim().length>256,[y,b]=(0,G.useState)(n?.defaultValue??{value:``}),[x,S]=(0,G.useState)(n?.conditionalValues??{}),[C,w]=(0,G.useState)({}),[T,ee]=(0,G.useState)(!1),[te,E]=(0,G.useState)(!1),D=sn(u.trim(),r),O=i.filter(({name:e})=>X(x,e)!==void 0),k=i.filter(({name:e})=>X(x,e)===void 0),ne=D!==null||_||[y,...Object.values(x)].some(e=>In(p,e)!==null),re=e=>{m(e),b(Bn(y,e)),S(Object.fromEntries(Object.entries(x).map(([t,n])=>[t,Bn(n,e)])))},ie=e=>{let t=X(C,e);S({...x,[e]:t===void 0?{value:Fn(p)}:Bn(t,p)})},ae=e=>{let{[e]:t,...n}=x;t!==void 0&&w({...C,[e]:t}),S(n)};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`form`,{className:`flex flex-col gap-4`,noValidate:!0,onSubmit:e=>{if(e.preventDefault(),ee(!0),ne)return;let t=Object.fromEntries(O.map(({name:e})=>[e,X(x,e)]));a(u.trim(),{valueType:p,defaultValue:y,...Object.keys(t).length===0?{}:{conditionalValues:t},...h.trim().length===0?{}:{description:h.trim()}})},children:[(0,K.jsxs)(Oe,{children:[(0,K.jsx)(Me,{children:e===null?`Add parameter`:`Edit parameter`}),(0,K.jsxs)(Ne,{children:[`The app reads it with`,` `,(0,K.jsxs)(`code`,{className:`font-mono`,children:[`hotUpdater.remoteConfig.`,zn[p],`("`,u.trim()||`key`,`")`]}),`, which is null when neither the server nor the app's defaults have a value.`]})]}),(0,K.jsxs)(he,{children:[(0,K.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-[minmax(0,1fr)_11rem]`,children:[(0,K.jsxs)(L,{"data-invalid":T&&D!==null||void 0,children:[(0,K.jsx)(A,{htmlFor:`${c}-key`,children:`Key`}),(0,K.jsx)(f,{autoComplete:`off`,className:`min-h-11 font-mono sm:min-h-9`,id:`${c}-key`,maxLength:257,onChange:e=>d(e.target.value),placeholder:`welcome_message`,spellCheck:!1,value:u}),(0,K.jsx)(I,{children:T?D:null})]}),(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${c}-type`,children:`Type`}),(0,K.jsxs)(Ee,{items:J,onValueChange:e=>{e!==null&&re(e)},value:p,children:[(0,K.jsx)(Se,{className:`min-h-11 w-full sm:min-h-9`,id:`${c}-type`,children:(0,K.jsx)(we,{})}),(0,K.jsx)(Ce,{children:(0,K.jsx)(V,{children:Rn.map(e=>(0,K.jsx)(B,{value:e,children:J[e]},e))})})]})]})]}),(0,K.jsxs)(L,{"data-invalid":_||void 0,children:[(0,K.jsx)(A,{htmlFor:`${c}-description`,children:`Description`}),(0,K.jsx)(f,{autoComplete:`off`,className:`min-h-11 sm:min-h-9`,id:`${c}-description`,onChange:e=>g(e.target.value),placeholder:`Optional: what the app does with it`,value:h}),(0,K.jsx)(I,{children:_?`Use 256 characters or fewer.`:null})]}),(0,K.jsx)(Ln,{id:`${c}-default`,label:`Default value`,onChange:b,showErrors:T,value:y,valueType:p}),(0,K.jsxs)(ye,{children:[(0,K.jsx)(ve,{variant:`label`,children:`Conditional values`}),(0,K.jsx)(_e,{children:`Devices that match a condition get its value. When several match, the first in the Conditions list wins. Removing a value keeps the condition, and its devices get the default value.`}),O.length>0?(0,K.jsx)(`ul`,{className:`flex flex-col gap-3`,children:O.map(e=>(0,K.jsxs)(`li`,{className:`rounded-lg border p-3`,children:[(0,K.jsxs)(`div`,{className:`mb-2 flex items-start justify-between gap-2`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`truncate text-sm font-medium`,children:e.name}),(0,K.jsx)(Nn,{condition:e,dateTimeText:l})]}),(0,K.jsxs)(t,{"aria-label":`Remove the value for ${e.name}`,className:`min-h-11 shrink-0 text-muted-foreground sm:min-h-7`,onClick:()=>ae(e.name),size:`sm`,type:`button`,variant:`ghost`,children:[(0,K.jsx)(v,{"data-icon":`inline-start`}),`Remove value`]})]}),(0,K.jsx)(Ln,{id:`${c}-${e.name}`,label:(0,K.jsxs)(K.Fragment,{children:[`Value`,(0,K.jsxs)(`span`,{className:`sr-only`,children:[` for `,e.name]})]}),onChange:t=>S({...x,[e.name]:t}),showErrors:T,value:X(x,e.name),valueType:p})]},e.name))}):null,(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[k.length>0?(0,K.jsxs)(Ee,{items:Object.fromEntries(k.map(({name:e})=>[e,e])),onValueChange:e=>{e!==null&&ie(e)},value:null,children:[(0,K.jsxs)(Se,{"aria-label":`Add a value for a condition`,className:`min-h-11 w-full sm:min-h-9 sm:w-64`,children:[(0,K.jsx)(H,{"aria-hidden":`true`,className:`size-3.5`}),(0,K.jsx)(we,{placeholder:`Add a value for a condition`})]}),(0,K.jsx)(Ce,{alignItemWithTrigger:!1,children:(0,K.jsx)(V,{children:k.map(({name:e})=>(0,K.jsx)(B,{value:e,children:e},e))})})]}):null,(0,K.jsxs)(t,{className:`min-h-11 sm:min-h-9`,onClick:()=>E(!0),type:`button`,variant:`outline`,children:[(0,K.jsx)(H,{"data-icon":`inline-start`}),`New condition`]})]})]})]}),(0,K.jsxs)(ke,{children:[(0,K.jsx)(t,{onClick:o,type:`button`,variant:`outline`,children:`Cancel`}),(0,K.jsx)(t,{type:`submit`,children:e===null?`Add parameter`:`Save parameter`})]})]}),(0,K.jsx)(jn,{condition:null,onOpenChange:E,onSave:e=>{s(e),ie(e.name)},open:te,takenNames:i.map(({name:e})=>e)})]})}function Un({text:e}){return(0,K.jsx)(`span`,{className:`line-clamp-2 block min-w-0 break-words font-mono text-xs text-foreground`,title:e,children:e})}function Wn({parameterKey:e,parameter:n,conditions:r,onEdit:i,onRemove:a}){let o=r.filter(({name:e})=>X(n.conditionalValues,e)!==void 0);return(0,K.jsxs)(`li`,{className:`grid gap-3 px-4 py-3 sm:px-6 md:grid-cols-[minmax(0,15rem)_minmax(0,1fr)_auto] md:items-start`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`truncate font-mono text-sm font-medium`,children:e}),(0,K.jsx)(P,{className:`shrink-0`,variant:`outline`,children:J[n.valueType]})]}),n.description===void 0?null:(0,K.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n.description})]}),(0,K.jsxs)(`dl`,{className:`grid min-w-0 grid-cols-[minmax(0,9rem)_minmax(0,1fr)] gap-x-3 gap-y-1.5 text-xs`,children:[o.map(({name:e})=>(0,K.jsxs)(`div`,{className:`contents`,children:[(0,K.jsx)(`dt`,{className:`line-clamp-2 break-words text-muted-foreground`,title:e,children:e}),(0,K.jsx)(`dd`,{className:`min-w-0`,children:(0,K.jsx)(Un,{text:Z(X(n.conditionalValues,e))})})]},e)),(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:`Default`}),(0,K.jsx)(`dd`,{className:`min-w-0`,children:`value`in n.defaultValue?(0,K.jsx)(Un,{text:Z(n.defaultValue)}):(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`In-app default`})})]}),(0,K.jsxs)(`div`,{className:`flex gap-1 md:justify-end`,children:[(0,K.jsxs)(t,{"aria-label":`Edit ${e}`,className:`min-h-11 md:min-h-7`,onClick:i,size:`sm`,variant:`outline`,children:[(0,K.jsx)(ht,{"data-icon":`inline-start`}),`Edit`]}),(0,K.jsx)(t,{"aria-label":`Delete ${e}`,className:`size-11 md:size-7`,onClick:a,size:`icon`,variant:`ghost`,children:(0,K.jsx)(Ge,{})})]})]})}function Gn({template:e,onSaveParameter:n,onRemoveParameter:r,onAddCondition:i}){let[a,o]=(0,G.useState)(null),s=U(a),[c,l]=(0,G.useState)(``),u=Object.keys(e.parameters),d=u.filter(e=>e.toLowerCase().includes(c.trim().toLowerCase())),f=s?.key??null;return(0,K.jsxs)(ge,{className:`overflow-hidden shadow-sm`,children:[(0,K.jsxs)(z,{className:`flex-row flex-wrap items-center justify-between gap-3 space-y-0 border-b px-4 py-3 sm:px-6`,children:[(0,K.jsx)(be,{className:`text-sm`,children:(0,K.jsx)(`h2`,{children:`Parameters`})}),(0,K.jsxs)(`div`,{className:`flex w-full flex-wrap gap-2 sm:w-auto`,children:[u.length>5?(0,K.jsxs)(Ve,{className:`min-h-11 w-full sm:min-h-8 sm:w-56`,children:[(0,K.jsx)(Le,{children:(0,K.jsx)(He,{"aria-hidden":`true`})}),(0,K.jsx)(Ie,{"aria-label":`Filter parameters by key`,className:`text-base sm:text-xs`,onChange:e=>l(e.target.value),placeholder:`Filter by key`,value:c})]}):null,(0,K.jsxs)(t,{className:`min-h-11 sm:min-h-7`,onClick:()=>o({key:null,parameter:null}),children:[(0,K.jsx)(H,{"data-icon":`inline-start`}),`Add parameter`]})]})]}),(0,K.jsx)(me,{className:`p-0`,children:u.length===0?(0,K.jsxs)(ct,{className:`py-10`,children:[(0,K.jsxs)(it,{children:[(0,K.jsx)(rt,{variant:`icon`,children:(0,K.jsx)(qe,{})}),(0,K.jsx)(ot,{children:`No parameters`}),(0,K.jsx)(st,{children:`Add a parameter, give it a default, then publish to change the app without a new build.`})]}),(0,K.jsx)(at,{children:(0,K.jsxs)(t,{className:`min-h-11 sm:min-h-7`,onClick:()=>o({key:null,parameter:null}),children:[(0,K.jsx)(H,{"data-icon":`inline-start`}),`Add parameter`]})})]}):d.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-10 text-center text-xs text-muted-foreground`,children:[(0,K.jsx)(`p`,{className:`font-medium text-foreground`,children:`No matching keys`}),(0,K.jsx)(t,{onClick:()=>l(``),size:`sm`,variant:`outline`,children:`Clear filter`})]}):(0,K.jsx)(`ul`,{"aria-label":`Parameters`,className:`divide-y`,children:d.map(t=>(0,K.jsx)(Wn,{conditions:e.conditions,onEdit:()=>o({key:t,parameter:e.parameters[t]??null}),onRemove:()=>r(t),parameter:e.parameters[t],parameterKey:t},t))})}),(0,K.jsx)(Vn,{conditions:e.conditions,onAddCondition:i,onOpenChange:e=>{e||o(null)},onSave:(e,t)=>n(f,e,t),open:a!==null,parameter:s?.parameter??null,parameterKey:f,takenKeys:u.filter(e=>e!==f)})]})}var Kn={platform:`ios`,channel:`production`,appVersion:`1.0.0`,cohort:`1`,fingerprintHash:``,at:``},qn=(e,t=300)=>{let[n,r]=(0,G.useState)(e);return(0,G.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n};function Jn({template:e,isDraft:t}){let n=(0,G.useId)(),[r,i]=(0,G.useState)(Kn),{at:a,...o}=qn(r),c=qt(a),l=jt({template:e,context:{...o,...c===void 0?{}:{now:Date.parse(c)}}}),u=Object.keys(e.parameters),d=(e,t)=>i({...r,[e]:t});return(0,K.jsxs)(ge,{className:`overflow-hidden shadow-sm`,children:[(0,K.jsxs)(z,{className:`border-b px-4 py-3 sm:px-6`,children:[(0,K.jsx)(be,{className:`text-sm`,children:(0,K.jsx)(`h2`,{children:`Preview a device`})}),(0,K.jsx)(pe,{className:`text-xs`,children:t?`The values this device would get once your changes are published, now or at the time you pick.`:`The values this device gets from the active version, now or at the time you pick.`})]}),(0,K.jsxs)(me,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,K.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:[(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${n}-platform`,children:`Platform`}),(0,K.jsxs)(Ee,{items:{ios:`iOS`,android:`Android`},onValueChange:e=>{(e===`ios`||e===`android`)&&d(`platform`,e)},value:r.platform,children:[(0,K.jsx)(Se,{className:`min-h-11 w-full sm:min-h-9`,id:`${n}-platform`,children:(0,K.jsxs)(we,{children:[(0,K.jsx)(xe,{className:`size-3.5`,platform:r.platform}),r.platform===`ios`?`iOS`:`Android`]})}),(0,K.jsx)(Ce,{children:(0,K.jsxs)(V,{children:[(0,K.jsxs)(B,{value:`ios`,children:[(0,K.jsx)(xe,{className:`size-3.5`,platform:`ios`}),`iOS`]}),(0,K.jsxs)(B,{value:`android`,children:[(0,K.jsx)(xe,{className:`size-3.5`,platform:`android`}),`Android`]})]})})]})]}),[[`channel`,`Channel`,`production`],[`appVersion`,`App version`,`1.0.0`],[`cohort`,`Cohort`,`1-1000 or a name`],[`fingerprintHash`,`Fingerprint`,`Optional`]].map(([e,t,i])=>(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${n}-${e}`,children:t}),(0,K.jsx)(f,{autoComplete:`off`,className:`min-h-11 text-base sm:min-h-9 sm:text-xs`,id:`${n}-${e}`,onChange:t=>d(e,t.target.value),placeholder:i,spellCheck:!1,value:r[e]})]},e)),(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${n}-at`,children:`Time`}),(0,K.jsxs)(Ve,{className:`h-11 sm:h-9`,children:[(0,K.jsx)(Ie,{className:`h-11 text-base tabular-nums sm:h-9 sm:text-xs`,id:`${n}-at`,onChange:e=>d(`at`,e.target.value),type:`datetime-local`,value:r.at}),r.at.length===0?null:(0,K.jsx)(Le,{align:`inline-end`,children:(0,K.jsx)(ze,{className:`min-h-11 sm:min-h-6`,onClick:()=>d(`at`,``),size:`xs`,children:`Now`})})]})]})]}),u.length===0?(0,K.jsx)(ct,{className:`border py-8`,children:(0,K.jsxs)(it,{children:[(0,K.jsx)(rt,{variant:`icon`,children:(0,K.jsx)(Ye,{})}),(0,K.jsx)(ot,{children:`Nothing to preview`}),(0,K.jsx)(st,{children:`Add a parameter, and its value for this device shows here.`})]})}):l.data?.status===`invalid`?(0,K.jsxs)(R,{variant:`destructive`,children:[(0,K.jsx)(j,{}),(0,K.jsx)(F,{children:`The draft has problems to fix first`}),(0,K.jsx)(N,{children:(0,K.jsx)(`ul`,{className:`list-disc pl-4`,children:l.data.issues.slice(0,5).map(e=>(0,K.jsxs)(`li`,{children:[e.path===``?``:`${e.path}: `,e.message]},`${e.path}:${e.message}`))})})]}):l.isError?(0,K.jsxs)(R,{variant:`destructive`,children:[(0,K.jsx)(j,{}),(0,K.jsx)(F,{children:`The preview couldn't be loaded`}),(0,K.jsx)(N,{children:`Check the connection, then change a field to try again.`})]}):l.data===void 0?(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(`span`,{className:`sr-only`,children:`Loading the preview`}),u.slice(0,4).map(e=>(0,K.jsx)(s,{className:`h-8 w-full`},e))]}):(0,K.jsx)(`dl`,{"aria-busy":l.isFetching||void 0,className:`divide-y rounded-lg border`,children:u.map(e=>{let t=l.data.status===`ok`?l.data.parameters[e]:void 0;return(0,K.jsxs)(`div`,{className:`grid gap-1 px-3 py-2.5 sm:grid-cols-[minmax(0,14rem)_minmax(0,1fr)_auto] sm:items-center sm:gap-3`,children:[(0,K.jsx)(`dt`,{className:`truncate font-mono text-xs font-medium`,children:e}),(0,K.jsx)(`dd`,{className:`min-w-0 truncate font-mono text-xs`,children:t===void 0?`…`:t.value===null?(0,K.jsx)(`span`,{className:`font-sans text-muted-foreground`,children:`In-app default`}):(0,K.jsx)(`span`,{title:t.value,children:t.value.length===0?`""`:t.value})}),(0,K.jsx)(`dd`,{children:t?.condition===void 0?null:t.condition===null?(0,K.jsx)(P,{variant:`outline`,children:`Default value`}):(0,K.jsx)(P,{variant:`secondary`,children:t.condition})})]},e)})})]})]})}function Yn({name:e,fields:t}){return(0,K.jsxs)(`li`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`break-words font-mono`,children:e}),t.length===0?null:(0,K.jsx)(`ul`,{className:`mt-0.5 flex flex-col gap-0.5`,children:t.map(e=>(0,K.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-x-1.5 text-muted-foreground`,children:[(0,K.jsx)(`span`,{children:e.field}),e.before===null?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`max-w-full truncate font-mono line-through decoration-muted-foreground/60`,title:e.before,children:e.before}),(0,K.jsx)(de,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`to`})]}),(0,K.jsx)(`span`,{className:`max-w-full truncate font-mono text-foreground`,title:e.after,children:e.after})]},e.field))})]})}function Xn({label:e,changes:t,describe:n}){let r=[[`Added`,t.added],[`Changed`,t.changed],[`Removed`,t.removed]];return r.every(([,e])=>e.length===0)?null:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-xs font-medium`,children:e}),(0,K.jsx)(`dl`,{className:`mt-1 grid grid-cols-[5rem_minmax(0,1fr)] gap-x-3 gap-y-1 text-xs`,children:r.map(([e,t])=>t.length===0?null:(0,K.jsxs)(`div`,{className:`contents`,children:[(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,K.jsx)(`dd`,{className:`min-w-0`,children:e===`Removed`?(0,K.jsx)(`span`,{className:`break-words font-mono`,children:t.join(`, `)}):(0,K.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:t.map(e=>(0,K.jsx)(Yn,{fields:n(e),name:e},e))})})]},e))})]})}function Zn({open:e,onOpenChange:n,base:r,baseVersion:i,draft:a,onPublished:o,onLoadLatest:s,onPublishOver:c}){let l=(0,G.useId)(),u=kt(),[d,p]=(0,G.useState)(``),[m,h]=(0,G.useState)(null),{dateTimeText:g}=Tn(),_=Zt(r,a),v=e=>{let t=Object.hasOwn(r.parameters,e)?r.parameters[e]:null,n=Object.hasOwn(a.parameters,e)?a.parameters[e]:null;return n===null?[]:Qt(t,n)},y=e=>{let t=r.conditions.find(t=>t.name===e)??null,n=a.conditions.find(t=>t.name===e)??null;return n===null?[]:$t(t,n,g)},b=d.trim().length>256,x=e=>{u.isPending||(n(e),e||(h(null),u.reset()))};return(0,K.jsx)(Pe,{onOpenChange:x,open:e,children:(0,K.jsx)(je,{className:`max-h-[calc(100svh-2rem)] overflow-y-auto sm:max-w-lg`,children:(0,K.jsxs)(`form`,{className:`flex flex-col gap-4`,noValidate:!0,onSubmit:async e=>{if(e.preventDefault(),!b)try{let e=await u.mutateAsync({template:a,baseVersion:i,...d.trim().length===0?{}:{description:d.trim()}});h(e),e.status===`published`&&(W.success(`Published version ${e.version.version}`),p(``),h(null),n(!1),o())}catch(e){W.error(e instanceof Error?e.message:`Unable to publish`)}},children:[(0,K.jsxs)(Oe,{children:[(0,K.jsx)(Me,{children:`Publish changes`}),(0,K.jsxs)(Ne,{children:[`This becomes version `,i+1,`. Devices get its values on their next fetch; earlier versions stay available to roll back to.`]})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border p-3`,children:[(0,K.jsx)(Xn,{changes:_.parameters,describe:v,label:`Parameters`}),(0,K.jsx)(Xn,{changes:_.conditions,describe:y,label:`Conditions`}),_.reordered?(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Condition priority changed.`}):null]}),m?.status===`invalid`?(0,K.jsxs)(R,{variant:`destructive`,children:[(0,K.jsx)(j,{}),(0,K.jsx)(F,{children:`The server refused the template`}),(0,K.jsx)(N,{children:(0,K.jsx)(`ul`,{className:`list-disc pl-4`,children:m.issues.slice(0,6).map(e=>(0,K.jsxs)(`li`,{children:[e.path===``?``:`${e.path}: `,e.message]},`${e.path}:${e.message}`))})})]}):null,m?.status===`conflict`?(0,K.jsxs)(R,{children:[(0,K.jsx)(j,{}),(0,K.jsxs)(F,{children:[`Version `,m.currentVersion,` was published while you edited`]}),(0,K.jsx)(N,{children:`Load it to review what changed, or publish yours after it, replacing its values.`}),(0,K.jsxs)(`div`,{className:`col-span-full mt-2 flex flex-wrap gap-2`,children:[(0,K.jsxs)(t,{onClick:()=>{x(!1),s()},size:`sm`,type:`button`,variant:`outline`,children:[`Load version `,m.currentVersion]}),(0,K.jsx)(t,{onClick:()=>{c(m.currentVersion),h(null)},size:`sm`,type:`button`,variant:`ghost`,children:`Publish mine after it`})]})]}):null,(0,K.jsxs)(L,{"data-invalid":b||void 0,children:[(0,K.jsx)(A,{htmlFor:`${l}-description`,children:`Description`}),(0,K.jsx)(f,{autoComplete:`off`,className:`min-h-11 sm:min-h-9`,id:`${l}-description`,onChange:e=>p(e.target.value),placeholder:`What changed and why`,value:d}),(0,K.jsx)(_e,{children:`Shown in the version history.`}),(0,K.jsx)(I,{children:b?`Use 256 characters or fewer.`:null})]}),(0,K.jsxs)(ke,{children:[(0,K.jsx)(t,{disabled:u.isPending,onClick:()=>x(!1),type:`button`,variant:`outline`,children:`Cancel`}),(0,K.jsxs)(t,{disabled:u.isPending||m?.status===`conflict`,type:`submit`,children:[u.isPending?(0,K.jsx)(Ae,{className:`animate-spin`,"data-icon":`inline-start`}):(0,K.jsx)(gt,{"data-icon":`inline-start`}),`Publish version `,i+1]})]})]})})})}function Qn({ms:e}){let t=new Date(e);return(0,K.jsx)(`time`,{className:`tabular-nums`,dateTime:t.toISOString(),title:`${t.toISOString().replace(`T`,` `).slice(0,19)} UTC`,children:(0,_t.default)(e).format(`YYYY/MM/DD HH:mm`)})}function $n({open:e,version:n,onOpenChange:r}){let i=Dt(n),a=i.data===null||i.data===void 0?null:JSON.stringify(i.data.template,null,2);return(0,K.jsx)(Pe,{onOpenChange:r,open:e,children:(0,K.jsxs)(je,{className:`max-h-[calc(100svh-2rem)] grid-rows-[auto_minmax(0,1fr)] sm:max-w-2xl`,children:[(0,K.jsxs)(Oe,{children:[(0,K.jsxs)(Me,{children:[`Version `,n]}),(0,K.jsx)(Ne,{children:`The template as it was published, in the JSON the admin API takes.`})]}),i.isLoading?(0,K.jsx)(s,{className:`h-48 w-full`}):i.isError?(0,K.jsxs)(R,{variant:`destructive`,children:[(0,K.jsx)(j,{}),(0,K.jsx)(F,{children:`This version couldn't be loaded`}),(0,K.jsx)(N,{children:`Check the connection and try again.`}),(0,K.jsx)(M,{children:(0,K.jsxs)(t,{onClick:()=>void i.refetch(),size:`xs`,variant:`outline`,children:[(0,K.jsx)(Fe,{"data-icon":`inline-start`}),`Retry`]})})]}):a===null?(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Version `,n,` no longer exists.`]}):(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-2`,children:[(0,K.jsx)(`pre`,{className:`min-h-0 overflow-auto rounded-md bg-muted p-3 font-mono text-xs`,children:a}),(0,K.jsxs)(t,{className:`self-end`,onClick:()=>{navigator.clipboard.writeText(a).then(()=>W.success(`Template JSON copied`),()=>W.error(`Unable to copy the template`))},size:`sm`,variant:`outline`,children:[(0,K.jsx)(De,{"data-icon":`inline-start`}),`Copy JSON`]})]})]})})}function er({activeVersion:e,hasDraft:n,onRolledBack:r,onStartEditing:i}){let a=Et({enabled:!0}),o=At(),[c,l]=(0,G.useState)(null),[u,d]=(0,G.useState)(null),f=U(c),p=U(u),m=a.data?.pages.flatMap(e=>e.versions)??[],h=async e=>{if(e.preventDefault(),u!==null)try{let e=await o.mutateAsync({version:u.source,baseVersion:u.next-1});e.status===`published`?(W.success(`Version ${e.version.version} restores version ${u.source}`),r()):e.status===`conflict`?W.error(`Version ${e.currentVersion} was published meanwhile. Review it, then roll back again.`):W.error(`That version no longer exists.`),d(null)}catch(e){W.error(e instanceof Error?e.message:`Unable to roll back`)}};return(0,K.jsxs)(ge,{className:`overflow-hidden shadow-sm`,children:[(0,K.jsx)(z,{className:`border-b px-4 py-3 sm:px-6`,children:(0,K.jsx)(be,{className:`text-sm`,children:(0,K.jsx)(`h2`,{children:`Versions`})})}),(0,K.jsx)(me,{className:`p-0`,children:a.isError?(0,K.jsx)(`div`,{className:`p-4`,children:(0,K.jsxs)(R,{variant:`destructive`,children:[(0,K.jsx)(j,{}),(0,K.jsx)(F,{children:`Versions couldn't be loaded`}),(0,K.jsx)(N,{children:`Check the connection and try again.`}),(0,K.jsx)(M,{children:(0,K.jsxs)(t,{onClick:()=>void a.refetch(),size:`xs`,variant:`outline`,children:[(0,K.jsx)(Fe,{"data-icon":`inline-start`}),`Retry`]})})]})}):a.isLoading?(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 p-4 sm:p-6`,children:[(0,K.jsx)(`span`,{className:`sr-only`,children:`Loading versions`}),Array.from({length:3},(e,t)=>(0,K.jsx)(s,{className:`h-10 w-full`},t))]}):m.length===0?(0,K.jsxs)(ct,{className:`py-10`,children:[(0,K.jsxs)(it,{children:[(0,K.jsx)(rt,{variant:`icon`,children:(0,K.jsx)(mt,{})}),(0,K.jsx)(ot,{children:`No versions yet`}),(0,K.jsx)(st,{children:`Your first publish becomes version 1. Every publish after it is kept here, ready to roll back to.`})]}),(0,K.jsx)(at,{children:(0,K.jsx)(t,{className:`min-h-11 sm:min-h-7`,onClick:i,children:`Add a parameter`})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`ol`,{"aria-label":`Versions`,className:`divide-y`,children:m.map(n=>(0,K.jsxs)(`li`,{className:`grid gap-2 px-4 py-3 sm:px-6 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsxs)(`span`,{className:`text-sm font-medium tabular-nums`,children:[`Version `,n.version]}),n.version===e?(0,K.jsx)(P,{children:`Active`}):null,n.updateType===`ROLLBACK`?(0,K.jsxs)(P,{variant:`outline`,children:[`Rollback to v`,n.rollbackSource]}):null]}),(0,K.jsxs)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:[(0,K.jsx)(Qn,{ms:n.createdAtMs}),n.description===null||n.updateType===`ROLLBACK`&&n.description===`Rollback to version ${n.rollbackSource}`?null:(0,K.jsxs)(K.Fragment,{children:[` · `,n.description]})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-1 md:justify-end`,children:[(0,K.jsxs)(t,{"aria-label":`View version ${n.version}`,className:`min-h-11 md:min-h-7`,onClick:()=>l(n.version),size:`sm`,variant:`ghost`,children:[(0,K.jsx)(ft,{"data-icon":`inline-start`}),`View`]}),(0,K.jsxs)(t,{"aria-label":`Roll back to version ${n.version}`,className:`min-h-11 md:min-h-7`,disabled:n.version===e,onClick:()=>d({source:n.version,next:e+1}),size:`sm`,variant:`outline`,children:[(0,K.jsx)(Be,{"data-icon":`inline-start`}),`Roll back`]})]})]},n.version))}),a.hasNextPage?(0,K.jsx)(`div`,{className:`border-t px-4 py-3 sm:px-6`,children:(0,K.jsxs)(t,{className:`min-h-11 w-full sm:min-h-7 sm:w-auto`,disabled:a.isFetchingNextPage,onClick:()=>void a.fetchNextPage(),variant:`outline`,children:[a.isFetchingNextPage?(0,K.jsx)(Ae,{className:`animate-spin`,"data-icon":`inline-start`}):null,`Load older versions`]})}):null]})}),(0,K.jsx)($n,{onOpenChange:e=>{e||l(null)},open:c!==null,version:f}),(0,K.jsx)(ue,{onOpenChange:e=>{!o.isPending&&!e&&d(null)},open:u!==null,children:(0,K.jsxs)(ie,{children:[(0,K.jsxs)(le,{children:[(0,K.jsxs)(ae,{children:[`Roll back to version `,p?.source,`?`]}),(0,K.jsxs)(ne,{children:[`Version `,p?.next,` will publish a copy of version`,` `,p?.source,`, and devices get its values on their next fetch.`,n?` Your unpublished changes are discarded.`:``]})]}),(0,K.jsxs)(se,{children:[(0,K.jsx)(ce,{disabled:o.isPending,children:`Cancel`}),(0,K.jsxs)(oe,{disabled:o.isPending,onClick:e=>void h(e),children:[o.isPending?(0,K.jsx)(Ae,{className:`animate-spin`,"data-icon":`inline-start`}):(0,K.jsx)(Be,{"data-icon":`inline-start`}),`Roll back`]})]})]})})]})}_t.default.extend(vt.default);var tr=[`parameters`,`conditions`,`preview`,`versions`];function nr({tab:e,onTabChange:n}){let r=Tt(),[i,a]=(0,G.useState)(null),[o,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(!1),p=r.data,m=i?.template??p?.template,h=i!==null&&p!==void 0&&!Mt(i.template,p.template),g=h&&p!==void 0&&i.baseVersion!==p.version;(0,G.useEffect)(()=>{if(o||p===void 0)return;c(!0);let e=rn(p);e!==null&&(a(e),u(!0))},[p,o]),(0,G.useEffect)(()=>{if(i===null||!h||an(i))return;let e=e=>e.preventDefault();return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[i,h]);let _=()=>{a(null),u(!1),an(null)},v=e=>{p===void 0||m===void 0||(u(!1),a({baseVersion:i?.baseVersion??p.version,base:i?.base??p.template,template:e(m)}))},y={parameters:m===void 0?null:Object.keys(m.parameters).length,conditions:m?.conditions.length??null};return(0,K.jsxs)(`div`,{className:`flex h-svh min-h-0 flex-col`,children:[(0,K.jsxs)(`header`,{className:`sticky top-0 z-10 flex shrink-0 flex-wrap items-center gap-x-3 gap-y-2 border-b bg-background px-3 py-3 sm:min-h-12 sm:bg-card/70 sm:px-4 sm:backdrop-blur-sm`,children:[(0,K.jsx)(x,{className:`-ml-1 size-11 lg:size-7`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(qe,{"aria-hidden":`true`,className:`size-3.5 text-muted-foreground`}),(0,K.jsx)(`h1`,{className:`text-sm font-medium`,children:`Remote Config`})]}),p===void 0?null:(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:p.version===0?`Nothing published yet`:(0,K.jsxs)(K.Fragment,{children:[`Version `,p.version,p.updatedAtMs===null?null:(0,K.jsxs)(K.Fragment,{children:[` · published `,(0,K.jsx)(`time`,{dateTime:new Date(p.updatedAtMs).toISOString(),title:(0,_t.default)(p.updatedAtMs).format(`YYYY/MM/DD HH:mm:ss`),children:(0,_t.default)(p.updatedAtMs).fromNow()})]})]})}),h?(0,K.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,K.jsx)(P,{className:`hidden sm:inline-flex`,variant:`secondary`,children:`Unpublished changes`}),(0,K.jsxs)(t,{className:`min-h-11 lg:min-h-7`,onClick:_,variant:`ghost`,children:[(0,K.jsx)(Xe,{"data-icon":`inline-start`}),`Discard`]}),(0,K.jsxs)(t,{className:`min-h-11 lg:min-h-7`,onClick:()=>f(!0),children:[(0,K.jsx)(gt,{"data-icon":`inline-start`}),`Publish changes`]})]}):null]}),(0,K.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto bg-muted/5 p-3 sm:p-6`,children:(0,K.jsxs)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-4`,children:[r.isError?(0,K.jsxs)(R,{variant:`destructive`,children:[(0,K.jsx)(j,{}),(0,K.jsx)(F,{children:`Remote Config couldn't be loaded`}),(0,K.jsx)(N,{children:`Check the connection and try again.`}),(0,K.jsx)(M,{children:(0,K.jsxs)(t,{onClick:()=>void r.refetch(),size:`xs`,variant:`outline`,children:[(0,K.jsx)(Fe,{"data-icon":`inline-start`}),`Retry`]})})]}):null,l&&h&&i!==null?(0,K.jsxs)(R,{children:[(0,K.jsx)(mt,{}),(0,K.jsx)(F,{children:`Your unpublished changes are back`}),(0,K.jsxs)(N,{children:[`This browser kept them from your last visit, on version`,` `,i.baseVersion,`.`]}),(0,K.jsx)(M,{children:(0,K.jsx)(t,{onClick:_,size:`xs`,variant:`outline`,children:`Discard them`})})]}):null,g&&i!==null&&p!==void 0?(0,K.jsxs)(R,{children:[(0,K.jsx)(j,{}),(0,K.jsxs)(F,{children:[`Version `,p.version,` was published while you edited`]}),(0,K.jsxs)(N,{children:[`Your draft started from version `,i.baseVersion,`. Discard it to review version `,p.version,`, or publish yours after it.`]}),(0,K.jsx)(M,{children:(0,K.jsxs)(t,{onClick:_,size:`xs`,variant:`outline`,children:[`Load version `,p.version]})})]}):null,(0,K.jsxs)(nt,{onValueChange:e=>n(e),value:e,children:[(0,K.jsx)(tt,{"aria-label":`Remote Config views`,className:`max-w-full group-data-horizontal/tabs:h-auto`,children:[[`parameters`,`Parameters`,y.parameters],[`conditions`,`Conditions`,y.conditions],[`preview`,`Preview`,null],[`versions`,`Versions`,null]].map(([e,t,n])=>(0,K.jsxs)(Qe,{className:`min-h-11 flex-none px-3 lg:min-h-7`,value:e,children:[t,n===null?null:(0,K.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:n})]},e))}),m===void 0||p===void 0?r.isError?null:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 pt-2`,children:[(0,K.jsx)(`span`,{className:`sr-only`,children:`Loading Remote Config`}),(0,K.jsx)(s,{className:`h-14 w-full`}),(0,K.jsx)(s,{className:`h-14 w-full`}),(0,K.jsx)(s,{className:`h-14 w-full`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)($e,{value:`parameters`,children:(0,K.jsx)(Gn,{onAddCondition:e=>v(t=>It(t,null,e)),onRemoveParameter:e=>v(t=>Pt(t,e)),onSaveParameter:(e,t,n)=>v(r=>Nt(r,e,t,n)),template:m})}),(0,K.jsx)($e,{value:`conditions`,children:(0,K.jsx)(Pn,{onMoveCondition:(e,t)=>v(n=>Rt(n,e,t)),onRemoveCondition:e=>v(t=>Lt(t,e)),onSaveCondition:(e,t)=>v(n=>It(n,e,t)),template:m})}),(0,K.jsx)($e,{value:`preview`,children:(0,K.jsx)(Jn,{isDraft:h,template:m})}),(0,K.jsx)($e,{value:`versions`,children:(0,K.jsx)(er,{activeVersion:p.version,hasDraft:h,onRolledBack:_,onStartEditing:()=>n(`parameters`)})})]})]})]})}),p!==void 0&&i!==null?(0,K.jsx)(Zn,{base:p.template,baseVersion:i.baseVersion,draft:i.template,onLoadLatest:_,onOpenChange:f,onPublishOver:e=>a({...i,baseVersion:e,base:p.template}),onPublished:_,open:d}):null]})}var rr=E(`/remote-config`)({beforeLoad:({context:e})=>ee(e.queryClient,`remoteConfig`),notFoundComponent:k(()=>te(()=>import(`./remote-config-CXOi0LRu.js`),__vite__mapDeps([0,1,2,3,4,5,6])),`notFoundComponent`),component:k(()=>te(()=>import(`./remote-config-BWwHOkCK.js`),__vite__mapDeps([7,2])),`component`),validateSearch:e=>tr.includes(e.tab)&&e.tab!==`parameters`?{tab:e.tab}:{}});export{nr as n,rr as t};
|
|
6
|
+
`)&&o(t.join(`, `)));let l=e=>{o(e),n(dn(e))};return i?(0,K.jsx)(Re,{className:`min-h-20 font-mono text-xs`,id:e,onChange:e=>l(e.target.value),placeholder:r,spellCheck:!1,value:a}):(0,K.jsx)(p,{autoComplete:`off`,className:`min-h-11 sm:min-h-9`,id:e,onChange:e=>l(e.target.value),placeholder:r,value:a})}function On({id:e,label:t,value:r,presets:i,onChange:a}){return(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:e,children:t}),(0,K.jsxs)(Ve,{className:`h-11 sm:h-9`,children:[(0,K.jsx)(Ie,{className:`h-11 tabular-nums sm:h-9`,id:e,onChange:e=>a(qt(e.target.value)),type:`datetime-local`,value:Kt(r)}),r===void 0?null:(0,K.jsx)(Le,{align:`inline-end`,children:(0,K.jsx)(ze,{"aria-label":`Clear ${t.toLowerCase()}`,className:`size-11 sm:size-5`,onClick:()=>a(void 0),size:`icon-xs`,children:(0,K.jsx)(y,{})})})]}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:i.map(e=>(0,K.jsx)(n,{"aria-pressed":e.iso===r,className:`min-h-11 sm:min-h-6`,onClick:()=>a(e.iso),size:`xs`,type:`button`,variant:e.iso===r?`secondary`:`outline`,children:e.label},e.label))})]})}function kn({rule:e,onChange:t}){let r=(0,G.useId)(),i=fe();switch(e.type){case`platform`:return(0,K.jsx)(Cn,{"aria-label":`Platforms`,multiple:!0,onValueChange:n=>t({...e,platforms:n.filter(e=>e===`ios`||e===`android`)}),value:[...e.platforms],variant:`outline`,children:[`ios`,`android`].map(e=>(0,K.jsxs)(wn,{className:`min-h-11 px-3 sm:min-h-8`,value:e,children:[(0,K.jsx)(xe,{className:`size-3.5`,platform:e}),e===`ios`?`iOS`:`Android`]},e))});case`channel`:{let a=(i.data??[]).map(({name:e})=>e).filter(t=>!e.channels.includes(t));return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(Dn,{id:`${r}-channels`,onChange:n=>t({...e,channels:n}),placeholder:`production, beta`,values:e.channels}),a.length>0?(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Add:`}),a.slice(0,8).map(r=>(0,K.jsxs)(n,{className:`min-h-11 sm:min-h-6`,onClick:()=>t({...e,channels:[...e.channels,r]}),size:`xs`,type:`button`,variant:`outline`,children:[(0,K.jsx)(H,{"data-icon":`inline-start`}),r]},r))]}):null]})}case`appVersion`:return(0,K.jsx)(p,{"aria-label":`App version range`,autoComplete:`off`,className:`min-h-11 font-mono sm:min-h-9`,onChange:n=>t({...e,range:n.target.value}),placeholder:`>=1.4.0`,value:e.range});case`cohort`:return(0,K.jsx)(Dn,{id:`${r}-cohorts`,onChange:n=>t({...e,cohorts:n}),placeholder:`1, 2, beta-testers`,values:e.cohorts});case`percent`:return(0,K.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[repeat(2,minmax(0,8rem))_minmax(0,1fr)]`,children:[(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${r}-from`,children:`From %`}),(0,K.jsx)(p,{className:`min-h-11 tabular-nums sm:min-h-9`,id:`${r}-from`,inputMode:`decimal`,max:100,min:0,onChange:n=>t({...e,from:Number(n.target.value)}),step:.1,type:`number`,value:e.from})]}),(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${r}-to`,children:`To %`}),(0,K.jsx)(p,{className:`min-h-11 tabular-nums sm:min-h-9`,id:`${r}-to`,inputMode:`decimal`,max:100,min:0,onChange:n=>t({...e,to:Number(n.target.value)}),step:.1,type:`number`,value:e.to})]}),(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${r}-seed`,children:`Seed`}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(p,{autoComplete:`off`,className:`min-h-11 font-mono sm:min-h-9`,id:`${r}-seed`,onChange:n=>t({...e,seed:n.target.value}),value:e.seed}),(0,K.jsx)(n,{"aria-label":`New seed`,className:`size-11 sm:size-9`,onClick:()=>t({...e,seed:Yt()}),size:`icon`,type:`button`,variant:`outline`,children:(0,K.jsx)(Fe,{})})]})]})]});case`fingerprint`:return(0,K.jsx)(Dn,{id:`${r}-hashes`,multiline:!0,onChange:n=>t({...e,hashes:n}),placeholder:`One fingerprint hash per line`,values:e.hashes});case`dateTime`:{let n=(n,r)=>{let{[n]:i,...a}=e;t(r===void 0?a:{...a,[n]:r})};return(0,K.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,K.jsx)(On,{id:`${r}-from`,label:`From`,onChange:e=>n(`from`,e),presets:Wt(),value:e.from}),(0,K.jsx)(On,{id:`${r}-until`,label:`Until`,onChange:e=>n(`to`,e),presets:Gt(e.from),value:e.to})]})}}}var An={platform:`Devices on any of these platforms.`,channel:`Devices on any of these channels, separated by commas.`,appVersion:`A semver range of native app versions, as release targets use: 2.x, >=1.4.0 <2.0.0.`,percent:`Installs whose numeric cohort lands in this share. Rules with one seed split the same order, so 0–10 and 10–20 never overlap.`,cohort:`Numeric cohorts from 1 to 1000, or custom cohort names.`,fingerprint:`Native builds with any of these fingerprints.`,dateTime:`Leave either end empty to keep it open. Devices get the change at their next fetch.`};function jn({open:e,onOpenChange:t,condition:n,takenNames:r,onSave:i}){let a=Ke(e);return(0,K.jsx)(Pe,{onOpenChange:t,open:e,children:(0,K.jsx)(je,{className:`max-h-[calc(100svh-2rem)] overflow-y-auto sm:max-w-xl`,children:(0,K.jsx)(Mn,{condition:n,onCancel:()=>t(!1),onSave:e=>{i(e),t(!1)},takenNames:r},a)})})}function Mn({condition:e,takenNames:t,onSave:r,onCancel:i}){let a=(0,G.useId)(),{dateTimeText:o,timeZone:s}=Tn(),[c,l]=(0,G.useState)(()=>e===null||e.name===ln(e.rules,t,o)?``:e.name),[u,d]=(0,G.useState)(e===null?[pn(`platform`)]:[...e.rules]),[f,m]=(0,G.useState)(!1),h=ln(u,t,o),g=c.trim().length===0?h:c,_=un(g,t),v=u.map(fn),y=En.filter(e=>!u.some(t=>t.type===e)),b=_!==null||u.length===0||v.some(e=>e!==null);return(0,K.jsxs)(`form`,{className:`flex flex-col gap-4`,noValidate:!0,onSubmit:e=>{e.preventDefault(),e.stopPropagation(),m(!0),!b&&r({name:g.trim(),rules:u.map(e=>e.type===`appVersion`?{...e,range:e.range.trim()}:e)})},children:[(0,K.jsxs)(Oe,{children:[(0,K.jsx)(Me,{children:e===null?`Add condition`:`Edit condition`}),(0,K.jsx)(Ne,{children:`A device matches when it matches every rule.`})]}),(0,K.jsxs)(he,{children:[(0,K.jsxs)(L,{"data-invalid":f&&_!==null||void 0,children:[(0,K.jsx)(A,{htmlFor:`${a}-name`,children:`Name`}),(0,K.jsx)(p,{autoComplete:`off`,className:`min-h-11 sm:min-h-9`,id:`${a}-name`,maxLength:101,onChange:e=>l(e.target.value),placeholder:h||`Beta testers on iOS`,value:c}),(0,K.jsx)(_e,{children:`Optional: without one, it is named after its rules.`}),(0,K.jsx)(I,{children:f?_:null})]}),(0,K.jsxs)(ye,{children:[(0,K.jsx)(ve,{variant:`label`,children:`Rules`}),u.length===0?(0,K.jsx)(I,{children:f?`Add at least one rule.`:null}):null,(0,K.jsx)(`ol`,{className:`flex flex-col gap-3`,children:u.map((e,t)=>(0,K.jsx)(`li`,{className:`rounded-lg border p-3`,children:(0,K.jsxs)(L,{"data-invalid":f&&v[t]!==null||void 0,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium`,children:Y[e.type]}),(0,K.jsx)(n,{"aria-label":`Remove the ${Y[e.type].toLowerCase()} rule`,className:`size-11 sm:size-7`,onClick:()=>d(u.filter((e,n)=>n!==t)),size:`icon-sm`,type:`button`,variant:`ghost`,children:(0,K.jsx)(Ge,{})})]}),(0,K.jsx)(kn,{onChange:e=>d(u.map((n,r)=>r===t?e:n)),rule:e}),(0,K.jsx)(_e,{children:e.type===`dateTime`?`In your time zone, ${s}. ${An.dateTime}`:An[e.type]}),(0,K.jsx)(I,{children:f?v[t]:null})]})},e.type))}),y.length>0?(0,K.jsxs)(Ee,{items:Object.fromEntries(y.map(e=>[e,Y[e]])),onValueChange:e=>{e!==null&&d([...u,pn(e)])},value:null,children:[(0,K.jsxs)(Se,{"aria-label":`Add a rule`,className:`min-h-11 w-full sm:min-h-9 sm:w-56`,children:[(0,K.jsx)(H,{"aria-hidden":`true`,className:`size-3.5`}),(0,K.jsx)(we,{placeholder:`Add a rule`})]}),(0,K.jsx)(Ce,{alignItemWithTrigger:!1,children:(0,K.jsx)(V,{children:y.map(e=>(0,K.jsx)(B,{value:e,children:Y[e]},e))})})]}):null]})]}),(0,K.jsxs)(ke,{children:[(0,K.jsx)(n,{onClick:i,type:`button`,variant:`outline`,children:`Cancel`}),(0,K.jsx)(n,{type:`submit`,children:e===null?`Add condition`:`Save condition`})]})]})}function Nn({condition:e,dateTimeText:t}){let n=e.rules.map(e=>Jt(e,t)).join(` · `);return n===e.name?null:(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})}function Pn({template:e,onSaveCondition:t,onRemoveCondition:r,onMoveCondition:i}){let[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(null),l=U(a),u=U(s),{dateTimeText:d}=Tn(),{conditions:f}=e,p=l?.condition?.name??null,m=t=>{let n=zt(e,t);n.length===0?r(t):c({name:t,users:n})};return(0,K.jsxs)(ge,{className:`overflow-hidden shadow-sm`,children:[(0,K.jsxs)(z,{className:`flex-row flex-wrap items-center justify-between gap-3 space-y-0 border-b px-4 py-3 sm:px-6`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(be,{className:`text-sm`,children:(0,K.jsx)(`h2`,{children:`Conditions`})}),(0,K.jsx)(pe,{className:`text-xs`,children:`Listed by priority: when several match a device, the first wins.`})]}),(0,K.jsxs)(n,{className:`min-h-11 sm:min-h-7`,onClick:()=>o({condition:null}),children:[(0,K.jsx)(H,{"data-icon":`inline-start`}),`Add condition`]})]}),(0,K.jsx)(me,{className:`p-0`,children:f.length===0?(0,K.jsxs)(ct,{className:`py-10`,children:[(0,K.jsxs)(it,{children:[(0,K.jsx)(rt,{variant:`icon`,children:(0,K.jsx)(pt,{})}),(0,K.jsx)(ot,{children:`No conditions`}),(0,K.jsx)(st,{children:`Add a condition to give some devices other values: a platform, channel, app version range, cohort, or a share of installs.`})]}),(0,K.jsx)(at,{children:(0,K.jsxs)(n,{className:`min-h-11 sm:min-h-7`,onClick:()=>o({condition:null}),children:[(0,K.jsx)(H,{"data-icon":`inline-start`}),`Add condition`]})})]}):(0,K.jsx)(`ol`,{"aria-label":`Conditions`,className:`divide-y`,children:f.map((t,r)=>{let a=zt(e,t.name);return(0,K.jsxs)(`li`,{className:`grid gap-3 px-4 py-3 sm:px-6 md:grid-cols-[auto_minmax(0,1fr)_auto] md:items-center`,children:[(0,K.jsx)(`span`,{"aria-label":`Priority ${r+1}`,className:`flex size-6 items-center justify-center rounded-md bg-muted text-xs font-medium tabular-nums`,children:r+1}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`truncate text-sm font-medium`,children:t.name}),(0,K.jsx)(Nn,{condition:t,dateTimeText:d}),(0,K.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:a.length===0?`No parameter uses it yet`:`Sets ${a.length===1?`1 parameter`:`${a.length} parameters`}: ${a.slice(0,3).join(`, `)}${a.length>3?`…`:``}`})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1 md:justify-end`,children:[(0,K.jsx)(n,{"aria-label":`Move ${t.name} up`,className:`size-11 md:size-7`,disabled:r===0,onClick:()=>i(r,-1),size:`icon`,variant:`ghost`,children:(0,K.jsx)(ut,{})}),(0,K.jsx)(n,{"aria-label":`Move ${t.name} down`,className:`size-11 md:size-7`,disabled:r===f.length-1,onClick:()=>i(r,1),size:`icon`,variant:`ghost`,children:(0,K.jsx)(lt,{})}),(0,K.jsxs)(n,{"aria-label":`Edit ${t.name}`,className:`min-h-11 md:min-h-7`,onClick:()=>o({condition:t}),size:`sm`,variant:`outline`,children:[(0,K.jsx)(ht,{"data-icon":`inline-start`}),`Edit`]}),(0,K.jsx)(n,{"aria-label":`Delete ${t.name}`,className:`size-11 md:size-7`,onClick:()=>m(t.name),size:`icon`,variant:`ghost`,children:(0,K.jsx)(Ge,{})})]})]},t.name)})})}),(0,K.jsx)(jn,{condition:l?.condition??null,onOpenChange:e=>{e||o(null)},onSave:e=>t(p,e),open:a!==null,takenNames:f.map(({name:e})=>e).filter(e=>e!==p)}),(0,K.jsx)(ue,{onOpenChange:e=>{e||c(null)},open:s!==null,children:(0,K.jsxs)(ie,{children:[(0,K.jsxs)(le,{children:[(0,K.jsxs)(ae,{children:[`Delete `,u?.name,`?`]}),(0,K.jsxs)(ne,{children:[u?.users.length===1?`1 parameter has a value for it`:`${u?.users.length} parameters have a value for it`,` `,`(`,u?.users.join(`, `),`). Those values are removed too, so matching devices get the default value after you publish.`]})]}),(0,K.jsxs)(se,{children:[(0,K.jsx)(ce,{children:`Cancel`}),(0,K.jsx)(oe,{onClick:e=>{e.preventDefault(),s!==null&&r(s.name),c(null)},variant:`destructive`,children:`Delete condition`})]})]})})]})}var Fn=e=>e===`BOOLEAN`?`false`:e===`NUMBER`?`0`:e===`JSON`?`{}`:``,In=(e,t)=>`value`in t?cn(e,t.value):null;function Ln({id:e,label:t,valueType:r,value:i,onChange:a,showErrors:o}){let s=!(`value`in i),c=`value`in i?i.value:``,l=o?In(r,i):null,u=e=>a({value:e});return(0,K.jsxs)(L,{"data-invalid":l!==null||void 0,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,K.jsx)(A,{htmlFor:e,id:`${e}-label`,children:t}),(0,K.jsxs)(`div`,{className:`flex min-h-11 items-center gap-2 text-xs text-muted-foreground sm:min-h-0`,children:[(0,K.jsx)(Je,{checked:s,id:`${e}-in-app-default`,onCheckedChange:e=>a(e?{useInAppDefault:!0}:{value:Fn(r)})}),(0,K.jsx)(`label`,{htmlFor:`${e}-in-app-default`,children:`Use in-app default`})]})]}),s?(0,K.jsxs)(`p`,{className:`rounded-md border border-dashed px-3 py-2 text-xs text-muted-foreground`,id:e,children:[`Devices keep the default set in the app's`,` `,(0,K.jsxs)(`code`,{className:`font-mono`,children:[`remoteConfig(`,`{ defaults }`,`)`]}),`.`]}):r===`BOOLEAN`?(0,K.jsxs)(Cn,{"aria-labelledby":`${e}-label`,id:e,onValueChange:e=>{let[t]=e;(t===`true`||t===`false`)&&u(t)},value:[c],variant:`outline`,children:[(0,K.jsx)(wn,{className:`min-h-11 px-4 sm:min-h-8`,value:`true`,children:`true`}),(0,K.jsx)(wn,{className:`min-h-11 px-4 sm:min-h-8`,value:`false`,children:`false`})]}):r===`NUMBER`?(0,K.jsx)(p,{"aria-invalid":l!==null||void 0,autoComplete:`off`,className:`min-h-11 font-mono sm:min-h-9`,id:e,inputMode:`decimal`,onChange:e=>u(e.target.value),value:c}):r===`JSON`?(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(Re,{"aria-invalid":l!==null||void 0,className:`min-h-24 font-mono text-xs`,id:e,onChange:e=>u(e.target.value),spellCheck:!1,value:c}),(0,K.jsxs)(n,{className:`self-start`,disabled:cn(`JSON`,c)!==null,onClick:()=>u(JSON.stringify(JSON.parse(c),null,2)),size:`sm`,type:`button`,variant:`outline`,children:[(0,K.jsx)(dt,{"data-icon":`inline-start`}),`Format JSON`]})]}):(0,K.jsx)(Re,{"aria-invalid":l!==null||void 0,className:`min-h-11 text-sm sm:min-h-9`,id:e,onChange:e=>u(e.target.value),rows:2,value:c}),(0,K.jsx)(I,{children:l})]})}var Rn=Object.keys(J),zn={STRING:`getString`,NUMBER:`getNumber`,BOOLEAN:`getBoolean`,JSON:`getString`},Bn=(e,t)=>`value`in e&&In(t,e)!==null?{value:Fn(t)}:e;function Vn({open:e,onOpenChange:t,parameterKey:n,parameter:r,takenKeys:i,conditions:a,onSave:o,onAddCondition:s}){let c=Ke(e);return(0,K.jsx)(Pe,{onOpenChange:t,open:e,children:(0,K.jsx)(je,{className:`max-h-[calc(100svh-2rem)] overflow-y-auto data-nested-dialog-open:after:absolute data-nested-dialog-open:after:inset-0 data-nested-dialog-open:after:rounded-xl data-nested-dialog-open:after:bg-background/70 sm:max-w-2xl`,children:(0,K.jsx)(Hn,{conditions:a,onAddCondition:s,onCancel:()=>t(!1),onSave:(e,n)=>{o(e,n),t(!1)},parameter:r,parameterKey:n,takenKeys:i},c)})})}function Hn({parameterKey:e,parameter:t,takenKeys:r,conditions:i,onSave:a,onCancel:o,onAddCondition:s}){let c=(0,G.useId)(),{dateTimeText:l}=Tn(),[u,d]=(0,G.useState)(e??``),[f,m]=(0,G.useState)(t?.valueType??`STRING`),[h,g]=(0,G.useState)(t?.description??``),_=h.trim().length>256,[v,b]=(0,G.useState)(t?.defaultValue??{value:``}),[x,S]=(0,G.useState)(t?.conditionalValues??{}),[C,w]=(0,G.useState)({}),[T,ee]=(0,G.useState)(!1),[te,E]=(0,G.useState)(!1),D=sn(u.trim(),r),O=i.filter(({name:e})=>X(x,e)!==void 0),k=i.filter(({name:e})=>X(x,e)===void 0),ne=D!==null||_||[v,...Object.values(x)].some(e=>In(f,e)!==null),re=e=>{m(e),b(Bn(v,e)),S(Object.fromEntries(Object.entries(x).map(([t,n])=>[t,Bn(n,e)])))},ie=e=>{let t=X(C,e);S({...x,[e]:t===void 0?{value:Fn(f)}:Bn(t,f)})},ae=e=>{let{[e]:t,...n}=x;t!==void 0&&w({...C,[e]:t}),S(n)};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`form`,{className:`flex flex-col gap-4`,noValidate:!0,onSubmit:e=>{if(e.preventDefault(),ee(!0),ne)return;let t=Object.fromEntries(O.map(({name:e})=>[e,X(x,e)]));a(u.trim(),{valueType:f,defaultValue:v,...Object.keys(t).length===0?{}:{conditionalValues:t},...h.trim().length===0?{}:{description:h.trim()}})},children:[(0,K.jsxs)(Oe,{children:[(0,K.jsx)(Me,{children:e===null?`Add parameter`:`Edit parameter`}),(0,K.jsxs)(Ne,{children:[`The app reads it with`,` `,(0,K.jsxs)(`code`,{className:`font-mono`,children:[`hotUpdater.remoteConfig.`,zn[f],`("`,u.trim()||`key`,`")`]}),`, which is null when neither the server nor the app's defaults have a value.`]})]}),(0,K.jsxs)(he,{children:[(0,K.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-[minmax(0,1fr)_11rem]`,children:[(0,K.jsxs)(L,{"data-invalid":T&&D!==null||void 0,children:[(0,K.jsx)(A,{htmlFor:`${c}-key`,children:`Key`}),(0,K.jsx)(p,{autoComplete:`off`,className:`min-h-11 font-mono sm:min-h-9`,id:`${c}-key`,maxLength:257,onChange:e=>d(e.target.value),placeholder:`welcome_message`,spellCheck:!1,value:u}),(0,K.jsx)(I,{children:T?D:null})]}),(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${c}-type`,children:`Type`}),(0,K.jsxs)(Ee,{items:J,onValueChange:e=>{e!==null&&re(e)},value:f,children:[(0,K.jsx)(Se,{className:`min-h-11 w-full sm:min-h-9`,id:`${c}-type`,children:(0,K.jsx)(we,{})}),(0,K.jsx)(Ce,{children:(0,K.jsx)(V,{children:Rn.map(e=>(0,K.jsx)(B,{value:e,children:J[e]},e))})})]})]})]}),(0,K.jsxs)(L,{"data-invalid":_||void 0,children:[(0,K.jsx)(A,{htmlFor:`${c}-description`,children:`Description`}),(0,K.jsx)(p,{autoComplete:`off`,className:`min-h-11 sm:min-h-9`,id:`${c}-description`,onChange:e=>g(e.target.value),placeholder:`Optional: what the app does with it`,value:h}),(0,K.jsx)(I,{children:_?`Use 256 characters or fewer.`:null})]}),(0,K.jsx)(Ln,{id:`${c}-default`,label:`Default value`,onChange:b,showErrors:T,value:v,valueType:f}),(0,K.jsxs)(ye,{children:[(0,K.jsx)(ve,{variant:`label`,children:`Conditional values`}),(0,K.jsx)(_e,{children:`Devices that match a condition get its value. When several match, the first in the Conditions list wins. Removing a value keeps the condition, and its devices get the default value.`}),O.length>0?(0,K.jsx)(`ul`,{className:`flex flex-col gap-3`,children:O.map(e=>(0,K.jsxs)(`li`,{className:`rounded-lg border p-3`,children:[(0,K.jsxs)(`div`,{className:`mb-2 flex items-start justify-between gap-2`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`truncate text-sm font-medium`,children:e.name}),(0,K.jsx)(Nn,{condition:e,dateTimeText:l})]}),(0,K.jsxs)(n,{"aria-label":`Remove the value for ${e.name}`,className:`min-h-11 shrink-0 text-muted-foreground sm:min-h-7`,onClick:()=>ae(e.name),size:`sm`,type:`button`,variant:`ghost`,children:[(0,K.jsx)(y,{"data-icon":`inline-start`}),`Remove value`]})]}),(0,K.jsx)(Ln,{id:`${c}-${e.name}`,label:(0,K.jsxs)(K.Fragment,{children:[`Value`,(0,K.jsxs)(`span`,{className:`sr-only`,children:[` for `,e.name]})]}),onChange:t=>S({...x,[e.name]:t}),showErrors:T,value:X(x,e.name),valueType:f})]},e.name))}):null,(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[k.length>0?(0,K.jsxs)(Ee,{items:Object.fromEntries(k.map(({name:e})=>[e,e])),onValueChange:e=>{e!==null&&ie(e)},value:null,children:[(0,K.jsxs)(Se,{"aria-label":`Add a value for a condition`,className:`min-h-11 w-full sm:min-h-9 sm:w-64`,children:[(0,K.jsx)(H,{"aria-hidden":`true`,className:`size-3.5`}),(0,K.jsx)(we,{placeholder:`Add a value for a condition`})]}),(0,K.jsx)(Ce,{alignItemWithTrigger:!1,children:(0,K.jsx)(V,{children:k.map(({name:e})=>(0,K.jsx)(B,{value:e,children:e},e))})})]}):null,(0,K.jsxs)(n,{className:`min-h-11 sm:min-h-9`,onClick:()=>E(!0),type:`button`,variant:`outline`,children:[(0,K.jsx)(H,{"data-icon":`inline-start`}),`New condition`]})]})]})]}),(0,K.jsxs)(ke,{children:[(0,K.jsx)(n,{onClick:o,type:`button`,variant:`outline`,children:`Cancel`}),(0,K.jsx)(n,{type:`submit`,children:e===null?`Add parameter`:`Save parameter`})]})]}),(0,K.jsx)(jn,{condition:null,onOpenChange:E,onSave:e=>{s(e),ie(e.name)},open:te,takenNames:i.map(({name:e})=>e)})]})}function Un({text:e}){return(0,K.jsx)(`span`,{className:`line-clamp-2 block min-w-0 break-words font-mono text-xs text-foreground`,title:e,children:e})}function Wn({parameterKey:e,parameter:t,conditions:r,onEdit:i,onRemove:a}){let o=r.filter(({name:e})=>X(t.conditionalValues,e)!==void 0);return(0,K.jsxs)(`li`,{className:`grid gap-3 px-4 py-3 sm:px-6 md:grid-cols-[minmax(0,15rem)_minmax(0,1fr)_auto] md:items-start`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`truncate font-mono text-sm font-medium`,children:e}),(0,K.jsx)(P,{className:`shrink-0`,variant:`outline`,children:J[t.valueType]})]}),t.description===void 0?null:(0,K.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:t.description})]}),(0,K.jsxs)(`dl`,{className:`grid min-w-0 grid-cols-[minmax(0,9rem)_minmax(0,1fr)] gap-x-3 gap-y-1.5 text-xs`,children:[o.map(({name:e})=>(0,K.jsxs)(`div`,{className:`contents`,children:[(0,K.jsx)(`dt`,{className:`line-clamp-2 break-words text-muted-foreground`,title:e,children:e}),(0,K.jsx)(`dd`,{className:`min-w-0`,children:(0,K.jsx)(Un,{text:Z(X(t.conditionalValues,e))})})]},e)),(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:`Default`}),(0,K.jsx)(`dd`,{className:`min-w-0`,children:`value`in t.defaultValue?(0,K.jsx)(Un,{text:Z(t.defaultValue)}):(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`In-app default`})})]}),(0,K.jsxs)(`div`,{className:`flex gap-1 md:justify-end`,children:[(0,K.jsxs)(n,{"aria-label":`Edit ${e}`,className:`min-h-11 md:min-h-7`,onClick:i,size:`sm`,variant:`outline`,children:[(0,K.jsx)(ht,{"data-icon":`inline-start`}),`Edit`]}),(0,K.jsx)(n,{"aria-label":`Delete ${e}`,className:`size-11 md:size-7`,onClick:a,size:`icon`,variant:`ghost`,children:(0,K.jsx)(Ge,{})})]})]})}function Gn({template:e,onSaveParameter:t,onRemoveParameter:r,onAddCondition:i}){let[a,o]=(0,G.useState)(null),s=U(a),[c,l]=(0,G.useState)(``),u=Object.keys(e.parameters),d=u.filter(e=>e.toLowerCase().includes(c.trim().toLowerCase())),f=s?.key??null;return(0,K.jsxs)(ge,{className:`overflow-hidden shadow-sm`,children:[(0,K.jsxs)(z,{className:`flex-row flex-wrap items-center justify-between gap-3 space-y-0 border-b px-4 py-3 sm:px-6`,children:[(0,K.jsx)(be,{className:`text-sm`,children:(0,K.jsx)(`h2`,{children:`Parameters`})}),(0,K.jsxs)(`div`,{className:`flex w-full flex-wrap gap-2 sm:w-auto`,children:[u.length>5?(0,K.jsxs)(Ve,{className:`min-h-11 w-full sm:min-h-8 sm:w-56`,children:[(0,K.jsx)(Le,{children:(0,K.jsx)(He,{"aria-hidden":`true`})}),(0,K.jsx)(Ie,{"aria-label":`Filter parameters by key`,className:`text-base sm:text-xs`,onChange:e=>l(e.target.value),placeholder:`Filter by key`,value:c})]}):null,(0,K.jsxs)(n,{className:`min-h-11 sm:min-h-7`,onClick:()=>o({key:null,parameter:null}),children:[(0,K.jsx)(H,{"data-icon":`inline-start`}),`Add parameter`]})]})]}),(0,K.jsx)(me,{className:`p-0`,children:u.length===0?(0,K.jsxs)(ct,{className:`py-10`,children:[(0,K.jsxs)(it,{children:[(0,K.jsx)(rt,{variant:`icon`,children:(0,K.jsx)(qe,{})}),(0,K.jsx)(ot,{children:`No parameters`}),(0,K.jsx)(st,{children:`Add a parameter, give it a default, then publish to change the app without a new build.`})]}),(0,K.jsx)(at,{children:(0,K.jsxs)(n,{className:`min-h-11 sm:min-h-7`,onClick:()=>o({key:null,parameter:null}),children:[(0,K.jsx)(H,{"data-icon":`inline-start`}),`Add parameter`]})})]}):d.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-10 text-center text-xs text-muted-foreground`,children:[(0,K.jsx)(`p`,{className:`font-medium text-foreground`,children:`No matching keys`}),(0,K.jsx)(n,{onClick:()=>l(``),size:`sm`,variant:`outline`,children:`Clear filter`})]}):(0,K.jsx)(`ul`,{"aria-label":`Parameters`,className:`divide-y`,children:d.map(t=>(0,K.jsx)(Wn,{conditions:e.conditions,onEdit:()=>o({key:t,parameter:e.parameters[t]??null}),onRemove:()=>r(t),parameter:e.parameters[t],parameterKey:t},t))})}),(0,K.jsx)(Vn,{conditions:e.conditions,onAddCondition:i,onOpenChange:e=>{e||o(null)},onSave:(e,n)=>t(f,e,n),open:a!==null,parameter:s?.parameter??null,parameterKey:f,takenKeys:u.filter(e=>e!==f)})]})}var Kn={platform:`ios`,channel:`production`,appVersion:`1.0.0`,cohort:`1`,fingerprintHash:``,at:``},qn=(e,t=300)=>{let[n,r]=(0,G.useState)(e);return(0,G.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n};function Jn({template:t,isDraft:n}){let r=(0,G.useId)(),[i,a]=(0,G.useState)(Kn),{at:o,...s}=qn(i),c=qt(o),l=jt({template:t,context:{...s,...c===void 0?{}:{now:Date.parse(c)}}}),u=Object.keys(t.parameters),d=(e,t)=>a({...i,[e]:t});return(0,K.jsxs)(ge,{className:`overflow-hidden shadow-sm`,children:[(0,K.jsxs)(z,{className:`border-b px-4 py-3 sm:px-6`,children:[(0,K.jsx)(be,{className:`text-sm`,children:(0,K.jsx)(`h2`,{children:`Preview a device`})}),(0,K.jsx)(pe,{className:`text-xs`,children:n?`The values this device would get once your changes are published, now or at the time you pick.`:`The values this device gets from the active version, now or at the time you pick.`})]}),(0,K.jsxs)(me,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,K.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:[(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${r}-platform`,children:`Platform`}),(0,K.jsxs)(Ee,{items:{ios:`iOS`,android:`Android`},onValueChange:e=>{(e===`ios`||e===`android`)&&d(`platform`,e)},value:i.platform,children:[(0,K.jsx)(Se,{className:`min-h-11 w-full sm:min-h-9`,id:`${r}-platform`,children:(0,K.jsxs)(we,{children:[(0,K.jsx)(xe,{className:`size-3.5`,platform:i.platform}),i.platform===`ios`?`iOS`:`Android`]})}),(0,K.jsx)(Ce,{children:(0,K.jsxs)(V,{children:[(0,K.jsxs)(B,{value:`ios`,children:[(0,K.jsx)(xe,{className:`size-3.5`,platform:`ios`}),`iOS`]}),(0,K.jsxs)(B,{value:`android`,children:[(0,K.jsx)(xe,{className:`size-3.5`,platform:`android`}),`Android`]})]})})]})]}),[[`channel`,`Channel`,`production`],[`appVersion`,`App version`,`1.0.0`],[`cohort`,`Cohort`,`1-1000 or a name`],[`fingerprintHash`,`Fingerprint`,`Optional`]].map(([e,t,n])=>(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${r}-${e}`,children:t}),(0,K.jsx)(p,{autoComplete:`off`,className:`min-h-11 text-base sm:min-h-9 sm:text-xs`,id:`${r}-${e}`,onChange:t=>d(e,t.target.value),placeholder:n,spellCheck:!1,value:i[e]})]},e)),(0,K.jsxs)(L,{children:[(0,K.jsx)(A,{htmlFor:`${r}-at`,children:`Time`}),(0,K.jsxs)(Ve,{className:`h-11 sm:h-9`,children:[(0,K.jsx)(Ie,{className:`h-11 text-base tabular-nums sm:h-9 sm:text-xs`,id:`${r}-at`,onChange:e=>d(`at`,e.target.value),type:`datetime-local`,value:i.at}),i.at.length===0?null:(0,K.jsx)(Le,{align:`inline-end`,children:(0,K.jsx)(ze,{className:`min-h-11 sm:min-h-6`,onClick:()=>d(`at`,``),size:`xs`,children:`Now`})})]})]})]}),u.length===0?(0,K.jsx)(ct,{className:`border py-8`,children:(0,K.jsxs)(it,{children:[(0,K.jsx)(rt,{variant:`icon`,children:(0,K.jsx)(Ye,{})}),(0,K.jsx)(ot,{children:`Nothing to preview`}),(0,K.jsx)(st,{children:`Add a parameter, and its value for this device shows here.`})]})}):l.data?.status===`invalid`?(0,K.jsxs)(R,{variant:`destructive`,children:[(0,K.jsx)(j,{}),(0,K.jsx)(F,{children:`The draft has problems to fix first`}),(0,K.jsx)(N,{children:(0,K.jsx)(`ul`,{className:`list-disc pl-4`,children:l.data.issues.slice(0,5).map(e=>(0,K.jsxs)(`li`,{children:[e.path===``?``:`${e.path}: `,e.message]},`${e.path}:${e.message}`))})})]}):l.isError?(0,K.jsxs)(R,{variant:`destructive`,children:[(0,K.jsx)(j,{}),(0,K.jsx)(F,{children:`The preview couldn't be loaded`}),(0,K.jsx)(N,{children:`Check the connection, then change a field to try again.`})]}):l.data===void 0?(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(`span`,{className:`sr-only`,children:`Loading the preview`}),u.slice(0,4).map(t=>(0,K.jsx)(e,{className:`h-8 w-full`},t))]}):(0,K.jsx)(`dl`,{"aria-busy":l.isFetching||void 0,className:`divide-y rounded-lg border`,children:u.map(e=>{let t=l.data.status===`ok`?l.data.parameters[e]:void 0;return(0,K.jsxs)(`div`,{className:`grid gap-1 px-3 py-2.5 sm:grid-cols-[minmax(0,14rem)_minmax(0,1fr)_auto] sm:items-center sm:gap-3`,children:[(0,K.jsx)(`dt`,{className:`truncate font-mono text-xs font-medium`,children:e}),(0,K.jsx)(`dd`,{className:`min-w-0 truncate font-mono text-xs`,children:t===void 0?`…`:t.value===null?(0,K.jsx)(`span`,{className:`font-sans text-muted-foreground`,children:`In-app default`}):(0,K.jsx)(`span`,{title:t.value,children:t.value.length===0?`""`:t.value})}),(0,K.jsx)(`dd`,{children:t?.condition===void 0?null:t.condition===null?(0,K.jsx)(P,{variant:`outline`,children:`Default value`}):(0,K.jsx)(P,{variant:`secondary`,children:t.condition})})]},e)})})]})]})}function Yn({name:e,fields:t}){return(0,K.jsxs)(`li`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`break-words font-mono`,children:e}),t.length===0?null:(0,K.jsx)(`ul`,{className:`mt-0.5 flex flex-col gap-0.5`,children:t.map(e=>(0,K.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-x-1.5 text-muted-foreground`,children:[(0,K.jsx)(`span`,{children:e.field}),e.before===null?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`max-w-full truncate font-mono line-through decoration-muted-foreground/60`,title:e.before,children:e.before}),(0,K.jsx)(de,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`to`})]}),(0,K.jsx)(`span`,{className:`max-w-full truncate font-mono text-foreground`,title:e.after,children:e.after})]},e.field))})]})}function Xn({label:e,changes:t,describe:n}){let r=[[`Added`,t.added],[`Changed`,t.changed],[`Removed`,t.removed]];return r.every(([,e])=>e.length===0)?null:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-xs font-medium`,children:e}),(0,K.jsx)(`dl`,{className:`mt-1 grid grid-cols-[5rem_minmax(0,1fr)] gap-x-3 gap-y-1 text-xs`,children:r.map(([e,t])=>t.length===0?null:(0,K.jsxs)(`div`,{className:`contents`,children:[(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,K.jsx)(`dd`,{className:`min-w-0`,children:e===`Removed`?(0,K.jsx)(`span`,{className:`break-words font-mono`,children:t.join(`, `)}):(0,K.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:t.map(e=>(0,K.jsx)(Yn,{fields:n(e),name:e},e))})})]},e))})]})}function Zn({open:e,onOpenChange:t,base:r,baseVersion:i,draft:a,onPublished:o,onLoadLatest:s,onPublishOver:c}){let l=(0,G.useId)(),u=kt(),[d,f]=(0,G.useState)(``),[m,h]=(0,G.useState)(null),{dateTimeText:g}=Tn(),_=Zt(r,a),v=e=>{let t=Object.hasOwn(r.parameters,e)?r.parameters[e]:null,n=Object.hasOwn(a.parameters,e)?a.parameters[e]:null;return n===null?[]:Qt(t,n)},y=e=>{let t=r.conditions.find(t=>t.name===e)??null,n=a.conditions.find(t=>t.name===e)??null;return n===null?[]:$t(t,n,g)},b=d.trim().length>256,x=e=>{u.isPending||(t(e),e||(h(null),u.reset()))};return(0,K.jsx)(Pe,{onOpenChange:x,open:e,children:(0,K.jsx)(je,{className:`max-h-[calc(100svh-2rem)] overflow-y-auto sm:max-w-lg`,children:(0,K.jsxs)(`form`,{className:`flex flex-col gap-4`,noValidate:!0,onSubmit:async e=>{if(e.preventDefault(),!b)try{let e=await u.mutateAsync({template:a,baseVersion:i,...d.trim().length===0?{}:{description:d.trim()}});h(e),e.status===`published`&&(W.success(`Published version ${e.version.version}`),f(``),h(null),t(!1),o())}catch(e){W.error(e instanceof Error?e.message:`Unable to publish`)}},children:[(0,K.jsxs)(Oe,{children:[(0,K.jsx)(Me,{children:`Publish changes`}),(0,K.jsxs)(Ne,{children:[`This becomes version `,i+1,`. Devices get its values on their next fetch; earlier versions stay available to roll back to.`]})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border p-3`,children:[(0,K.jsx)(Xn,{changes:_.parameters,describe:v,label:`Parameters`}),(0,K.jsx)(Xn,{changes:_.conditions,describe:y,label:`Conditions`}),_.reordered?(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Condition priority changed.`}):null]}),m?.status===`invalid`?(0,K.jsxs)(R,{variant:`destructive`,children:[(0,K.jsx)(j,{}),(0,K.jsx)(F,{children:`The server refused the template`}),(0,K.jsx)(N,{children:(0,K.jsx)(`ul`,{className:`list-disc pl-4`,children:m.issues.slice(0,6).map(e=>(0,K.jsxs)(`li`,{children:[e.path===``?``:`${e.path}: `,e.message]},`${e.path}:${e.message}`))})})]}):null,m?.status===`conflict`?(0,K.jsxs)(R,{children:[(0,K.jsx)(j,{}),(0,K.jsxs)(F,{children:[`Version `,m.currentVersion,` was published while you edited`]}),(0,K.jsx)(N,{children:`Load it to review what changed, or publish yours after it, replacing its values.`}),(0,K.jsxs)(`div`,{className:`col-span-full mt-2 flex flex-wrap gap-2`,children:[(0,K.jsxs)(n,{onClick:()=>{x(!1),s()},size:`sm`,type:`button`,variant:`outline`,children:[`Load version `,m.currentVersion]}),(0,K.jsx)(n,{onClick:()=>{c(m.currentVersion),h(null)},size:`sm`,type:`button`,variant:`ghost`,children:`Publish mine after it`})]})]}):null,(0,K.jsxs)(L,{"data-invalid":b||void 0,children:[(0,K.jsx)(A,{htmlFor:`${l}-description`,children:`Description`}),(0,K.jsx)(p,{autoComplete:`off`,className:`min-h-11 sm:min-h-9`,id:`${l}-description`,onChange:e=>f(e.target.value),placeholder:`What changed and why`,value:d}),(0,K.jsx)(_e,{children:`Shown in the version history.`}),(0,K.jsx)(I,{children:b?`Use 256 characters or fewer.`:null})]}),(0,K.jsxs)(ke,{children:[(0,K.jsx)(n,{disabled:u.isPending,onClick:()=>x(!1),type:`button`,variant:`outline`,children:`Cancel`}),(0,K.jsxs)(n,{disabled:u.isPending||m?.status===`conflict`,type:`submit`,children:[u.isPending?(0,K.jsx)(Ae,{className:`animate-spin`,"data-icon":`inline-start`}):(0,K.jsx)(gt,{"data-icon":`inline-start`}),`Publish version `,i+1]})]})]})})})}function Qn({ms:e}){let t=new Date(e);return(0,K.jsx)(`time`,{className:`tabular-nums`,dateTime:t.toISOString(),title:`${t.toISOString().replace(`T`,` `).slice(0,19)} UTC`,children:(0,_t.default)(e).format(`YYYY/MM/DD HH:mm`)})}function $n({open:t,version:r,onOpenChange:i}){let a=Dt(r),o=a.data===null||a.data===void 0?null:JSON.stringify(a.data.template,null,2);return(0,K.jsx)(Pe,{onOpenChange:i,open:t,children:(0,K.jsxs)(je,{className:`max-h-[calc(100svh-2rem)] grid-rows-[auto_minmax(0,1fr)] sm:max-w-2xl`,children:[(0,K.jsxs)(Oe,{children:[(0,K.jsxs)(Me,{children:[`Version `,r]}),(0,K.jsx)(Ne,{children:`The template as it was published, in the JSON the admin API takes.`})]}),a.isLoading?(0,K.jsx)(e,{className:`h-48 w-full`}):a.isError?(0,K.jsxs)(R,{variant:`destructive`,children:[(0,K.jsx)(j,{}),(0,K.jsx)(F,{children:`This version couldn't be loaded`}),(0,K.jsx)(N,{children:`Check the connection and try again.`}),(0,K.jsx)(M,{children:(0,K.jsxs)(n,{onClick:()=>void a.refetch(),size:`xs`,variant:`outline`,children:[(0,K.jsx)(Fe,{"data-icon":`inline-start`}),`Retry`]})})]}):o===null?(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Version `,r,` no longer exists.`]}):(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-2`,children:[(0,K.jsx)(`pre`,{className:`min-h-0 overflow-auto rounded-md bg-muted p-3 font-mono text-xs`,children:o}),(0,K.jsxs)(n,{className:`self-end`,onClick:()=>{navigator.clipboard.writeText(o).then(()=>W.success(`Template JSON copied`),()=>W.error(`Unable to copy the template`))},size:`sm`,variant:`outline`,children:[(0,K.jsx)(De,{"data-icon":`inline-start`}),`Copy JSON`]})]})]})})}function er({activeVersion:t,hasDraft:r,onRolledBack:i,onStartEditing:a}){let o=Et({enabled:!0}),s=At(),[c,l]=(0,G.useState)(null),[u,d]=(0,G.useState)(null),f=U(c),p=U(u),m=o.data?.pages.flatMap(e=>e.versions)??[],h=async e=>{if(e.preventDefault(),u!==null)try{let e=await s.mutateAsync({version:u.source,baseVersion:u.next-1});e.status===`published`?(W.success(`Version ${e.version.version} restores version ${u.source}`),i()):e.status===`conflict`?W.error(`Version ${e.currentVersion} was published meanwhile. Review it, then roll back again.`):W.error(`That version no longer exists.`),d(null)}catch(e){W.error(e instanceof Error?e.message:`Unable to roll back`)}};return(0,K.jsxs)(ge,{className:`overflow-hidden shadow-sm`,children:[(0,K.jsx)(z,{className:`border-b px-4 py-3 sm:px-6`,children:(0,K.jsx)(be,{className:`text-sm`,children:(0,K.jsx)(`h2`,{children:`Versions`})})}),(0,K.jsx)(me,{className:`p-0`,children:o.isError?(0,K.jsx)(`div`,{className:`p-4`,children:(0,K.jsxs)(R,{variant:`destructive`,children:[(0,K.jsx)(j,{}),(0,K.jsx)(F,{children:`Versions couldn't be loaded`}),(0,K.jsx)(N,{children:`Check the connection and try again.`}),(0,K.jsx)(M,{children:(0,K.jsxs)(n,{onClick:()=>void o.refetch(),size:`xs`,variant:`outline`,children:[(0,K.jsx)(Fe,{"data-icon":`inline-start`}),`Retry`]})})]})}):o.isLoading?(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 p-4 sm:p-6`,children:[(0,K.jsx)(`span`,{className:`sr-only`,children:`Loading versions`}),Array.from({length:3},(t,n)=>(0,K.jsx)(e,{className:`h-10 w-full`},n))]}):m.length===0?(0,K.jsxs)(ct,{className:`py-10`,children:[(0,K.jsxs)(it,{children:[(0,K.jsx)(rt,{variant:`icon`,children:(0,K.jsx)(mt,{})}),(0,K.jsx)(ot,{children:`No versions yet`}),(0,K.jsx)(st,{children:`Your first publish becomes version 1. Every publish after it is kept here, ready to roll back to.`})]}),(0,K.jsx)(at,{children:(0,K.jsx)(n,{className:`min-h-11 sm:min-h-7`,onClick:a,children:`Add a parameter`})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`ol`,{"aria-label":`Versions`,className:`divide-y`,children:m.map(e=>(0,K.jsxs)(`li`,{className:`grid gap-2 px-4 py-3 sm:px-6 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsxs)(`span`,{className:`text-sm font-medium tabular-nums`,children:[`Version `,e.version]}),e.version===t?(0,K.jsx)(P,{children:`Active`}):null,e.updateType===`ROLLBACK`?(0,K.jsxs)(P,{variant:`outline`,children:[`Rollback to v`,e.rollbackSource]}):null]}),(0,K.jsxs)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:[(0,K.jsx)(Qn,{ms:e.createdAtMs}),e.description===null||e.updateType===`ROLLBACK`&&e.description===`Rollback to version ${e.rollbackSource}`?null:(0,K.jsxs)(K.Fragment,{children:[` · `,e.description]})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-1 md:justify-end`,children:[(0,K.jsxs)(n,{"aria-label":`View version ${e.version}`,className:`min-h-11 md:min-h-7`,onClick:()=>l(e.version),size:`sm`,variant:`ghost`,children:[(0,K.jsx)(ft,{"data-icon":`inline-start`}),`View`]}),(0,K.jsxs)(n,{"aria-label":`Roll back to version ${e.version}`,className:`min-h-11 md:min-h-7`,disabled:e.version===t,onClick:()=>d({source:e.version,next:t+1}),size:`sm`,variant:`outline`,children:[(0,K.jsx)(Be,{"data-icon":`inline-start`}),`Roll back`]})]})]},e.version))}),o.hasNextPage?(0,K.jsx)(`div`,{className:`border-t px-4 py-3 sm:px-6`,children:(0,K.jsxs)(n,{className:`min-h-11 w-full sm:min-h-7 sm:w-auto`,disabled:o.isFetchingNextPage,onClick:()=>void o.fetchNextPage(),variant:`outline`,children:[o.isFetchingNextPage?(0,K.jsx)(Ae,{className:`animate-spin`,"data-icon":`inline-start`}):null,`Load older versions`]})}):null]})}),(0,K.jsx)($n,{onOpenChange:e=>{e||l(null)},open:c!==null,version:f}),(0,K.jsx)(ue,{onOpenChange:e=>{!s.isPending&&!e&&d(null)},open:u!==null,children:(0,K.jsxs)(ie,{children:[(0,K.jsxs)(le,{children:[(0,K.jsxs)(ae,{children:[`Roll back to version `,p?.source,`?`]}),(0,K.jsxs)(ne,{children:[`Version `,p?.next,` will publish a copy of version`,` `,p?.source,`, and devices get its values on their next fetch.`,r?` Your unpublished changes are discarded.`:``]})]}),(0,K.jsxs)(se,{children:[(0,K.jsx)(ce,{disabled:s.isPending,children:`Cancel`}),(0,K.jsxs)(oe,{disabled:s.isPending,onClick:e=>void h(e),children:[s.isPending?(0,K.jsx)(Ae,{className:`animate-spin`,"data-icon":`inline-start`}):(0,K.jsx)(Be,{"data-icon":`inline-start`}),`Roll back`]})]})]})})]})}_t.default.extend(vt.default);var tr=[`parameters`,`conditions`,`preview`,`versions`];function nr({tab:t,onTabChange:r}){let i=Tt(),[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(!1),p=i.data,m=a?.template??p?.template,h=a!==null&&p!==void 0&&!Mt(a.template,p.template),g=h&&p!==void 0&&a.baseVersion!==p.version;(0,G.useEffect)(()=>{if(s||p===void 0)return;c(!0);let e=rn(p);e!==null&&(o(e),u(!0))},[p,s]),(0,G.useEffect)(()=>{if(a===null||!h||an(a))return;let e=e=>e.preventDefault();return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[a,h]);let _=()=>{o(null),u(!1),an(null)},v=e=>{p===void 0||m===void 0||(u(!1),o({baseVersion:a?.baseVersion??p.version,base:a?.base??p.template,template:e(m)}))},y={parameters:m===void 0?null:Object.keys(m.parameters).length,conditions:m?.conditions.length??null};return(0,K.jsxs)(`div`,{className:`flex h-svh min-h-0 flex-col`,children:[(0,K.jsxs)(`header`,{className:`sticky top-0 z-10 flex shrink-0 flex-wrap items-center gap-x-3 gap-y-2 border-b bg-background px-3 py-3 sm:min-h-12 sm:bg-card/70 sm:px-4 sm:backdrop-blur-sm`,children:[(0,K.jsx)(S,{className:`-ml-1 size-11 lg:size-7`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(qe,{"aria-hidden":`true`,className:`size-3.5 text-muted-foreground`}),(0,K.jsx)(`h1`,{className:`text-sm font-medium`,children:`Remote Config`})]}),p===void 0?null:(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:p.version===0?`Nothing published yet`:(0,K.jsxs)(K.Fragment,{children:[`Version `,p.version,p.updatedAtMs===null?null:(0,K.jsxs)(K.Fragment,{children:[` · published `,(0,K.jsx)(`time`,{dateTime:new Date(p.updatedAtMs).toISOString(),title:(0,_t.default)(p.updatedAtMs).format(`YYYY/MM/DD HH:mm:ss`),children:(0,_t.default)(p.updatedAtMs).fromNow()})]})]})}),h?(0,K.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,K.jsx)(P,{className:`hidden sm:inline-flex`,variant:`secondary`,children:`Unpublished changes`}),(0,K.jsxs)(n,{className:`min-h-11 lg:min-h-7`,onClick:_,variant:`ghost`,children:[(0,K.jsx)(Xe,{"data-icon":`inline-start`}),`Discard`]}),(0,K.jsxs)(n,{className:`min-h-11 lg:min-h-7`,onClick:()=>f(!0),children:[(0,K.jsx)(gt,{"data-icon":`inline-start`}),`Publish changes`]})]}):null]}),(0,K.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto bg-muted/5 p-3 sm:p-6`,children:(0,K.jsxs)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-4`,children:[i.isError?(0,K.jsxs)(R,{variant:`destructive`,children:[(0,K.jsx)(j,{}),(0,K.jsx)(F,{children:`Remote Config couldn't be loaded`}),(0,K.jsx)(N,{children:`Check the connection and try again.`}),(0,K.jsx)(M,{children:(0,K.jsxs)(n,{onClick:()=>void i.refetch(),size:`xs`,variant:`outline`,children:[(0,K.jsx)(Fe,{"data-icon":`inline-start`}),`Retry`]})})]}):null,l&&h&&a!==null?(0,K.jsxs)(R,{children:[(0,K.jsx)(mt,{}),(0,K.jsx)(F,{children:`Your unpublished changes are back`}),(0,K.jsxs)(N,{children:[`This browser kept them from your last visit, on version`,` `,a.baseVersion,`.`]}),(0,K.jsx)(M,{children:(0,K.jsx)(n,{onClick:_,size:`xs`,variant:`outline`,children:`Discard them`})})]}):null,g&&a!==null&&p!==void 0?(0,K.jsxs)(R,{children:[(0,K.jsx)(j,{}),(0,K.jsxs)(F,{children:[`Version `,p.version,` was published while you edited`]}),(0,K.jsxs)(N,{children:[`Your draft started from version `,a.baseVersion,`. Discard it to review version `,p.version,`, or publish yours after it.`]}),(0,K.jsx)(M,{children:(0,K.jsxs)(n,{onClick:_,size:`xs`,variant:`outline`,children:[`Load version `,p.version]})})]}):null,(0,K.jsxs)(nt,{onValueChange:e=>r(e),value:t,children:[(0,K.jsx)(tt,{"aria-label":`Remote Config views`,className:`max-w-full group-data-horizontal/tabs:h-auto`,children:[[`parameters`,`Parameters`,y.parameters],[`conditions`,`Conditions`,y.conditions],[`preview`,`Preview`,null],[`versions`,`Versions`,null]].map(([e,t,n])=>(0,K.jsxs)(Qe,{className:`min-h-11 flex-none px-3 lg:min-h-7`,value:e,children:[t,n===null?null:(0,K.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:n})]},e))}),m===void 0||p===void 0?i.isError?null:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 pt-2`,children:[(0,K.jsx)(`span`,{className:`sr-only`,children:`Loading Remote Config`}),(0,K.jsx)(e,{className:`h-14 w-full`}),(0,K.jsx)(e,{className:`h-14 w-full`}),(0,K.jsx)(e,{className:`h-14 w-full`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)($e,{value:`parameters`,children:(0,K.jsx)(Gn,{onAddCondition:e=>v(t=>It(t,null,e)),onRemoveParameter:e=>v(t=>Pt(t,e)),onSaveParameter:(e,t,n)=>v(r=>Nt(r,e,t,n)),template:m})}),(0,K.jsx)($e,{value:`conditions`,children:(0,K.jsx)(Pn,{onMoveCondition:(e,t)=>v(n=>Rt(n,e,t)),onRemoveCondition:e=>v(t=>Lt(t,e)),onSaveCondition:(e,t)=>v(n=>It(n,e,t)),template:m})}),(0,K.jsx)($e,{value:`preview`,children:(0,K.jsx)(Jn,{isDraft:h,template:m})}),(0,K.jsx)($e,{value:`versions`,children:(0,K.jsx)(er,{activeVersion:p.version,hasDraft:h,onRolledBack:_,onStartEditing:()=>r(`parameters`)})})]})]})]})}),p!==void 0&&a!==null?(0,K.jsx)(Zn,{base:p.template,baseVersion:a.baseVersion,draft:a.template,onLoadLatest:_,onOpenChange:f,onPublishOver:e=>o({...a,baseVersion:e,base:p.template}),onPublished:_,open:d}):null]})}var rr=E(`/remote-config`)({beforeLoad:({context:e})=>ee(e.queryClient,`remoteConfig`),notFoundComponent:k(()=>te(()=>import(`./remote-config-BtStN5bt.js`),__vite__mapDeps([0,1,2,3,4,5,6])),`notFoundComponent`),component:k(()=>te(()=>import(`./remote-config-BcoOZ9fs.js`),__vite__mapDeps([7,2])),`component`),validateSearch:e=>tr.includes(e.tab)&&e.tab!==`parameters`?{tab:e.tab}:{}});export{nr as n,rr as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/routes-Bxu5_zNh.js","assets/sidebar-CQ6iq0qe.js","assets/useCompositeListItem-VmWjhZ9j.js","assets/console-features-api-BD7j--gS.js","assets/alert-dialog-BSs_5Od-.js","assets/select-BE-xONpm.js","assets/field-DNqNwq7i.js","assets/switch-DR0WP2g8.js","assets/valueToPercent-C-rPd_Or.js","assets/api-DSWk32Mz.js","assets/chevron-right-CBl7aqu_.js","assets/HashValueDisplay-DvXl147n.js","assets/dist-B7eA4Mtf.js","assets/list-BSpjGUS6.js","assets/dialog-YKZpU5St.js","assets/input-group-C9ZIjV0o.js","assets/insights-search-B-F2wop6.js","assets/insights-api-BsX1zQDf.js","assets/table-DW0243Jw.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{$ as e,In as t,Ln as n,Ur as r,Wr as i,ar as a,cr as o,et as s,nr as c,rr as l}from"./sidebar-CQ6iq0qe.js";import{a as u,i as d,l as f,o as p}from"./console-features-api-BD7j--gS.js";import{a as ee,c as m,s as h}from"./useCompositeListItem-VmWjhZ9j.js";import{_ as g,m as _,s as v,x as y}from"./insights-api-BsX1zQDf.js";import{_ as b,h as x,m as S,v as C,y as w}from"./field-DNqNwq7i.js";import{t as T}from"./key-round-CrqLmblG.js";import{s as te}from"./switch-DR0WP2g8.js";import{h as E,t as D}from"./insights-search-B-F2wop6.js";var O=a(`chart-line`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`m19 9-5 5-4-4-3 3`,key:`2osh9i`}]]),k=a(`package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),A=r(),j={apiKeys:{navigation:{icon:(0,A.jsx)(T,{}),paths:[`/api-keys`],link:({onClick:e})=>(0,A.jsx)(f,{to:`/api-keys`,onClick:e})}}},M=l({method:`GET`}).middleware([c]).handler(i(`b4bf4c461903edcdc44eea52468c737b5b600a586f542138ff022dcbbe86c45c`));function N(e){let t=e.map(({releaseId:e,platform:t,channel:n})=>({releaseId:e,platform:t,channel:n})).sort((e,t)=>e.releaseId.localeCompare(t.releaseId));return o({queryKey:[`bundle-activity`,t],queryFn:()=>M({data:t}),enabled:t.length>0,staleTime:3e4})}var P=[{label:`Downloaded`,field:`downloads`,color:`text-primary/85`},{label:`Launched`,field:`launched`,color:`text-success/85`},{label:`Crashed`,field:`failedLaunches`,color:`text-warning/85`}],F=e=>{let t=e.launched+e.failedLaunches;return t===0?`—`:`${(e.failedLaunches/t*100).toFixed(2)}%`},I=e=>Math.max(0,e.downloads-e.launched-e.failedLaunches);function L(){return(0,A.jsx)(E,{label:`About release insight metrics`,children:`Downloaded: got this bundle. Launched: ran it. Crashed: crashed on it and rolled back. Once every installation restarts, Downloaded = Launched + Crashed.`})}function R({report:t,loading:r=!1,input:i,variant:a=`inline`}){if(!t)return r?(0,A.jsx)(e,{"aria-label":`Loading release insights`,className:a===`card`?`h-16 w-full`:`h-4 w-40`}):(0,A.jsx)(`span`,{"aria-label":`Release insights unavailable`,className:`text-sm text-muted-foreground`,children:`—`});let o=i?.builtIn===!0,s=o?0:I(t),c=(0,A.jsx)(`dl`,{className:n(a===`card`?`grid grid-cols-[1fr_1fr_auto] gap-4`:`flex min-w-[220px] flex-wrap items-baseline gap-x-3 gap-y-1`),children:P.map(({label:e,field:r,color:i})=>(0,A.jsxs)(`div`,{className:n(`flex`,a===`card`?`min-w-0 flex-col gap-1`:`items-baseline gap-1.5 whitespace-nowrap`),children:[(0,A.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:e}),(0,A.jsxs)(`dd`,{className:n(`flex flex-wrap items-baseline gap-x-1.5 tabular-nums`,a===`card`?`text-xl font-semibold`:`text-sm font-medium`,t[r]>0&&!(r===`downloads`&&o)?i:`text-muted-foreground`),children:[r===`downloads`&&o?(0,A.jsx)(`span`,{title:`The built-in bundle is never downloaded`,children:`—`}):t[r].toLocaleString(),r===`failedLaunches`?(0,A.jsxs)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:[`(`,F(t),`)`]}):null]})]},r))});return(0,A.jsxs)(`div`,{className:n(`flex`,a===`card`?`flex-col gap-2`:`items-center gap-1`),children:[i?(0,A.jsx)(f,{className:`min-w-0 rounded-sm hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,to:`/insights`,search:{healthPlatform:i.platform,healthChannel:i.channel,releaseId:i.releaseId,bundleWindow:D(i.releaseId)},children:c}):c,a===`card`&&s>0?(0,A.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[s.toLocaleString(),` downloaded but not launched yet: waiting for a restart, or passed over for a newer bundle.`]}):null,a===`inline`?(0,A.jsx)(L,{}):null]})}function z({input:t}){let r=v({platform:t.platform,channel:t.channel,releaseId:t.releaseId}),i=r.data;return(0,A.jsxs)(`div`,{className:`flex items-center gap-1`,children:[i?(0,A.jsx)(`dl`,{children:(0,A.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-1.5`,children:[(0,A.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Download failures`}),(0,A.jsxs)(`dd`,{className:n(`flex items-baseline gap-1.5 text-sm font-medium tabular-nums`,i.failedUpdates>0?`text-warning/85`:`text-muted-foreground`),children:[i.failedUpdates.toLocaleString(),(0,A.jsxs)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:[`(`,g(_(i)),`)`]})]})]})}):r.isPending?(0,A.jsx)(e,{"aria-label":`Loading download failures`,className:`h-4 w-40`}):(0,A.jsx)(`span`,{"aria-label":`Download failures unavailable`,className:`text-sm text-muted-foreground`,children:`—`}),(0,A.jsx)(E,{label:`About download failures`,children:`Failed downloads or installs of this bundle, at most one per installation a day. Rate = failures ÷ (failures + downloads).`})]})}function B({input:e}){let n=N([e]);return(0,A.jsxs)(S,{children:[(0,A.jsxs)(C,{className:`flex-row items-center justify-between px-4 pt-4 pb-3`,children:[(0,A.jsx)(w,{className:`text-sm font-medium`,children:`Insights`}),(0,A.jsx)(L,{})]}),(0,A.jsxs)(x,{className:`flex flex-col gap-3 px-4 pb-4`,children:[(0,A.jsx)(R,{variant:`card`,input:e,loading:n.isFetching,report:n.data?.[e.releaseId]}),(0,A.jsx)(s,{}),(0,A.jsx)(z,{input:e})]}),(0,A.jsx)(b,{className:`px-4 pb-4`,children:(0,A.jsxs)(f,{className:t({variant:`outline`,size:`sm`}),to:`/insights`,search:{healthPlatform:e.platform,healthChannel:e.channel,releaseId:e.releaseId,bundleWindow:D(e.releaseId),healthChart:`adoption`},children:[(0,A.jsx)(O,{"aria-hidden":`true`,"data-icon":`inline-start`}),`View adoption`]})})]})}function V({input:e}){return d(`insightsAnalytics`)?null:(0,A.jsxs)(S,{children:[(0,A.jsx)(C,{className:`px-4 pt-4 pb-3`,children:(0,A.jsx)(w,{className:`text-sm font-medium`,children:`Insights`})}),(0,A.jsx)(x,{className:`px-4 pb-4`,children:(0,A.jsx)(z,{input:e})})]})}function H({releaseId:e,releases:t}){let n=N(t);return(0,A.jsx)(R,{input:t.find(t=>t.releaseId===e),loading:n.isFetching,report:n.data?.[e]})}var U={Cell:H},W={insights:{navigation:{icon:(0,A.jsx)(y,{}),paths:[`/insights`,`/insights/distribution`,`/installations`],link:({features:e,onClick:t})=>e.insightsAnalytics?(0,A.jsx)(f,{to:`/insights`,onClick:t}):(0,A.jsx)(f,{to:`/installations`,onClick:t})},releaseSection:({release:e})=>(0,A.jsx)(V,{input:e})},insightsAnalytics:{releaseColumn:U,releaseSection:({release:e})=>(0,A.jsx)(B,{input:e})}},G={remoteConfig:{navigation:{icon:(0,A.jsx)(te,{}),paths:[`/remote-config`],link:({onClick:e})=>(0,A.jsx)(f,{to:`/remote-config`,onClick:e})}}},K={...W,...j,...G},q=Object.keys(p),J=()=>{let e=u().data?.features;return e===void 0?[]:q.flatMap(t=>{let n=K[t];return n!==void 0&&e[t]?[{...n,feature:t,label:p[t].label,features:e}]:[]})},Y=()=>J().flatMap(({feature:e,label:t,releaseColumn:n})=>n===void 0?[]:[{...n,feature:e,label:t}]);function X({release:e}){return J().map(({feature:t,releaseSection:n})=>n===void 0?null:(0,A.jsx)(n,{release:e},t))}var Z=e=>typeof e==`string`&&e.trim().length>0?e.trim():void 0;function Q(e){let t=Z(e.beforeReleaseId),n=t?void 0:Z(e.afterReleaseId),r=e.enabled===!0||e.enabled===`true`?!0:e.enabled===!1||e.enabled===`false`?!1:void 0,i=Z(e.bundleId),a=i?void 0:Z(e.scopeKey),o=i||a?void 0:Z(e.channelId),s=o===void 0?void 0:e.platform===`android`?`android`:`ios`;return{afterReleaseId:n,beforeReleaseId:t,bundleId:i,channelId:o,enabled:a||o?r:void 0,platform:s,releaseId:Z(e.releaseId),scopeKey:a}}function $(e){let t=e.enabled===void 0?{}:{enabled:e.enabled};return e.bundleId?{kind:`bundle`,bundleId:e.bundleId}:e.scopeKey?{kind:`scope`,scopeKey:e.scopeKey,...t}:e.channelId&&e.platform?{kind:`channelPlatform`,channelId:e.channelId,platform:e.platform,...t}:{kind:`all`}}function ne(e){return $(e).kind!==`all`}function re(e,t){let n={...e,...t};return t.bundleId?Q({bundleId:n.bundleId}):t.scopeKey?Q({scopeKey:n.scopeKey,enabled:n.enabled}):`channelId`in t||`platform`in t?Q({channelId:n.channelId,enabled:n.enabled,platform:n.platform}):Q({bundleId:n.bundleId,channelId:n.channelId,enabled:n.enabled,platform:n.platform,scopeKey:n.scopeKey})}var ie=m(`/`)({component:h(()=>ee(()=>import(`./routes-Bxu5_zNh.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18])),`component`),validateSearch:Q});export{X as a,k as c,re as i,ne as n,J as o,$ as r,Y as s,ie as t};
|