1(function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`3686179ba4b39e40ec26acbd4462fb1b7f111901`};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`695c0e5a-5bcd-455d-a18d-7b0a5b4f8fba`,e._sentryDebugIdIdentifier=`sentry-dbid-695c0e5a-5bcd-455d-a18d-7b0a5b4f8fba`)}catch{}})();import{t as e}from"./variables-v6-service-D6FexRcq.js";var t=e=>e?Array.isArray(e.message)?e.message.join(`; `):e.message??`Unknown error`:`Unknown error`,n=async()=>{try{let t=await e.listAll({scope_type:`global`});return{items:(Array.isArray(t?.body)?t.body:[]).filter(e=>(e.scope??[]).some(e=>e?.type===`global`)).map(e=>({id:e.id,key:e.key,value:e.value?.content??``,isSecret:!!e.value?.isSecret})),failed:!1,error:null}}catch(e){return{items:[],failed:!0,error:t(e)}}},r=(e,t)=>{e.add({closable:!0,severity:`error`,summary:`Error`,detail:t||`Failed to load global variables`,life:5e3})},i=(e,t)=>[{type:e,ids:[String(t)]}],a=e=>e?Array.isArray(e.message)?e.message.join(`; `):e.message??`Unknown error`:`Unknown error`,o=e=>e instanceof Set?e:new Set(Array.isArray(e)?e:[]),s=async({scopeType:t,scopeId:n})=>{try{let{body:r}=await e.listAll({scope_type:t,scope_id:String(n)}),i={},a=[],o=new Map;return(r??[]).forEach(e=>{let t=e.value?.isSecret??!1,n=t?``:String(e.value?.content??e.value??``);i[e.key]=n,t&&a.push(e.key),o.set(e.key,{id:e.id,value:n,secret:t,shared:(e.scope??[]).length>1})}),{variables:i,secretKeys:a,snapshot:o,failed:!1,error:null}}catch(e){return{variables:{},secretKeys:[],snapshot:new Map,failed:!0,error:a(e)}}},c=e=>Array.from(e?.entries?.()??[]).filter(([,e])=>!e?.shared).map(([e])=>e),l=(e,t,n,r)=>{let i=new Map,a=e??{};return Object.entries(n??{}).forEach(([e,n])=>{let o=t?.get?.(n);!o||o.shared||o.secret&&!r.has(e)||!(e in a)||n in a||t?.has?.(e)||[...i.values()].includes(n)||i.set(e,n)}),i},u=(e={},t,n,r)=>{let i=[],a=[],s=[],c=new Set,u=o(n),d=l(e,t,r,u);return Object.entries(e??{}).forEach(([e,n])=>{let r=d.get(e)??e;c.add(r);let o=t?.get?.(r),s=String(n??``),l=u.has(e);if(!o){i.push({key:e,value:s,secret:l});return}let f=r!==e,p=o.value!==s,m=!!o.secret!==l;(f||p||m)&&a.push({id:o.id,key:e,previousKey:r,value:s,previousValue:o.value,secret:l,previousSecret:!!o.secret})}),t?.forEach?.((e,t)=>{c.has(t)||s.push({id:e.id,key:t,shared:!!e.shared})}),{toCreate:i,toUpdate:a,toDelete:s}},d=(e={},t,n,r)=>{let i=u(e,t,r,n).toDelete.filter(e=>!e.shared).map(e=>e.key);return{deletedKeys:i,leavesNoVariables:i.length>0&&i.length===(t?.size??0)&&Object.keys(e??{}).length===0}},f=e=>e.toCreate.length>0||e.toUpdate.length>0||e.toDelete.length>0,p=async({scopeType:t,scopeId:n,variables:r,secretKeys:s})=>{let c=Object.entries(r??{});if(!c.length)return{failures:[]};let l=o(s),u=await Promise.allSettled(c.map(([r,a])=>e.create({key:r,value:String(a??``),secret:l.has(r),scope:i(t,n)}))),d=[];return u.forEach((e,t)=>{e.status===`rejected`&&d.push({key:c[t][0],message:a(e.reason)})}),{failures:d}},m=`shared with other resources, delete it from Variables`,h=async({scopeType:t,scopeId:n,diff:r})=>{let o=[];if(r.toCreate.forEach(r=>o.push({key:r.key,action:`create`,promise:e.create({key:r.key,value:r.value,secret:!!r.secret,scope:i(t,n)})})),r.toUpdate.forEach(t=>o.push({key:t.key,action:`update`,promise:e.edit({id:t.id,values:{key:t.key,value:t.value,secret:t.secret},initialValues:{key:t.previousKey??t.key,value:t.previousValue,secret:t.previousSecret}})})),r.toDelete.forEach(t=>o.push({key:t.key,action:t.shared?`shared-delete`:`delete`,promise:t.shared?Promise.reject(Error(m)):e.delete(t.id)})),!o.length)return{failures:[]};let s=await Promise.allSettled(o.map(e=>e.promise)),c=[];return s.forEach((e,t)=>{e.status===`rejected`&&c.push({key:o[t].key,action:o[t].action,message:a(e.reason)})}),{failures:c}},g=(e=[])=>{let t=e.map(e=>e.action===`shared-delete`?`${e.key} (${m})`:e.key),n=t.slice(0,5).join(`, `);return t.length>5?`${n}, ...`:n},_=(e=[],{current:t,original:n,renames:r,secretKeys:i}={})=>{let a=[];
1return l(t,n,r,o(i)).forEach((e,t)=>{n?.get?.(e)?.secret&&a.push(t)}),[...e,...a]},v=e=>Array.from(e?.entries?.()??[]).filter(([,e])=>e?.secret).map(([e])=>e),y=`Saving will skip variable sync to avoid data loss. Reload the page to try again.`,b=(e,t)=>{e.add({closable:!0,severity:`warn`,summary:`Could not load scoped variables`,detail:[t,y].filter(Boolean).join(`. `)})},x=e=>[{key:`*`,action:`sync`,message:e}];export{u as a,f as c,h as d,_ as f,p as i,s as l,r as m,c as n,d as o,n as p,x as r,g as s,v as t,b as u};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.