@ibgib/space-gib 0.0.35 → 0.0.36
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/dist/client/bootstrap.mjs +1 -1
- package/dist/client/{chunk-FIAGRVBY.mjs → chunk-5DTAUY3E.mjs} +204 -101
- package/dist/client/{chunk-XLQ3UCQY.mjs → chunk-J7X3XTAI.mjs} +1 -1
- package/dist/client/css/tutorial.css +327 -0
- package/dist/client/index.mjs +1 -1
- package/dist/client/script.mjs +1 -1
- package/dist/client/style.css +1 -0
- package/package.json +4 -4
- package/src/client/AUTO-GENERATED-version.mts +1 -1
- package/src/client/css/tutorial.css +327 -0
- package/src/client/style.css +1 -0
- package/src/client/ui/component/cosmos-navigator/cosmos-navigator.mts +31 -0
- package/src/client/ui/component/tutorial/index.mts +9 -0
- package/src/client/ui/component/tutorial/scripts/pitch-tour-script.mts +265 -0
- package/src/client/ui/component/tutorial/tutorial-controller.mts +622 -0
- package/src/client/ui/component/tutorial/tutorial-types.mts +45 -0
- package/src/client/ui/component/tutorial/tutorial.css +260 -0
- package/src/client/ui/shell/space-gib-shell-service.mts +28 -24
|
@@ -5,7 +5,7 @@ ${i.data.errors.join(`
|
|
|
5
5
|
`):"unknown error putting ibGibs";throw new Error(d)}if(s?.length??!1){let d=await e.argy({ibMetadata:Tt({space:e}),argData:{cmd:"put",isDna:!0,force:t,ibGibAddrs:s.map(b=>I({ibGib:b}))},ibGibs:s.concat()}),f=await e.witness(d);if(f.data?.success)f.data.warnings?.length>0&&f.data.warnings.forEach(b=>console.warn(`${r} ${b}`));else{let b=f?.data?.errors?.length>0?f.data.errors.join(`
|
|
6
6
|
`):"unknown error putting dna ibGibs";throw new Error(b)}}}catch(n){throw console.error(`${r} ${n.message}`),n}finally{P&&console.log(`${r} complete. (I: dc6835614ff1a1b82b179225023ae823)`)}}h(V,"persistTransformResult");async function zl({type:o,rel8nName:e,space:t}){let r=`[${zl.name}]`;try{if(!t)throw new Error("space required. (E: f73868a952ac4181a4f90ee6d86cacf3)");let n=await ia({type:o,space:t});if(!n)throw new Error(`couldn't get special (${o}) (E: a65bef190416479697605be486846731)`);let a=n.rel8ns?n.rel8ns[e]||[]:[],s=[];for(let i=0;i<a.length;i++){let c=a[i],l=await z({addr:c,space:t});if(l.success&&l.ibGibs?.length===1)s.push(l.ibGibs[0]);else throw new Error(`couldn't get addr: ${c} (E: 76ef256ee80149ab860c5786484b0e89)`)}return s}catch(n){throw console.error(`${r} ${n.message}`),n}}h(zl,"getSpecialRel8dIbGibs");async function ia({type:o,initialize:e,space:t,zeroSpace:r,fnUpdateBootstrap:n,fnBroadcast:a,fnGetInitializing:s,fnSetInitializing:i,dontWarnIfNotExist:c}){let l=`[${ia.name}]`;try{if(!t)throw new Error("space required. (E: d454b31d58764a9bb9c4e47fb5ef38b5)");let d=Me({type:o}),f=await ca({key:d,space:t,dontWarn:c||!!e});if(!f){if(e&&(!s||!i))throw new Error("if initialize, you must provide fnGetInitializeLock & fnSetInitializeLock. (E: 8eb322625d0c4538be089800882487de)");if(e&&!s()){i(!0);try{if(!r)throw new Error("zeroSpace required when 'initialize' truthy (E: 8582c92c637f90c9b2dbe0ec8355b523)");f=await Ql({type:o,space:t,zeroSpace:r,fnBroadcast:a,fnUpdateBootstrap:n})??void 0}catch(m){console.error(`${l} error initializing: ${m.message}`)}finally{i(!1)}}if(!f){if(s&&s())return console.warn(`${l} couldn't get addr, but we're still initializing...`),null;throw new Error("Special address not in config and couldn't initialize it either. (E: d8ebdc9eaaa640b99cd206f132962c93)")}}P&&console.log(`${l} getting addr: ${f}`);let b=await z({addr:f,space:t});if(b.success||(b=await z({addr:f,space:t}),b.success&&(console.warn(`${l} special ibgib was not stored in meta folder...putting in meta folder now for the future (W: e6f5571fd98c449bb2809359be5057cc)`),(await ce({ibGib:b.ibGibs[0],space:t})).success||console.warn(`${l} (UNEXPECTED) tried to put special in meta but success was false? (W: b934b53571c24057af172c790e6a7240)`))),!b.success)throw new Error(b.errorMsg);if(b.ibGibs?.length!==1)throw new Error("no ibGib in result (E: 3a42abdddc3648e292d63dc45c560064)");let p=b.ibGibs[0],u=await ve({ibGibs:[p],space:t});if(u?.data?.success&&u.data.addrs?.length===1){let m=I({ibGib:p}),g=u.data.addrs[0];g!==m&&console.warn(`${l} latest addr is not the one associated with the local space.
|
|
7
7
|
specialAddr: ${m}
|
|
8
|
-
latestAddr: ${g} (W: 141b69dc3c414efc9645bb76fcf12df9)`)}return p}catch(d){let f=`${l} ${d.message}`;return f.includes("d8ebdc9eaaa640b99cd206f132962c93")&&c||console.error(f),null}}h(ia,"getSpecialIbGib");async function ca({key:o,space:e,dontWarn:t}){let r=`[${ca.name}](${o})`;try{if(P&&console.log(`${r} getting... (I: 43e7bfc2515d45e5af8767b9a85b248e)`),!e)throw new Error("space required. (E: 4f135d4276e64054ba21aeb9c304ecec)");if(!e.rel8ns){(P||!t)&&console.warn(`${r} space.rel8ns falsy. (W: 7c642259fbf547dbaa1b2fdf0115f6ef)`);return}if(!e.rel8ns[o]){(P||!t)&&console.warn(`${r} space.rel8ns[${o}] falsy. (W: 3c1c49b9987b45cc96dd78b808f98e91)`);return}if(e.rel8ns[o].length===1)return P&&console.log(`${r} got (I: f13e71b693d5404c9535bda8ff0cc6a9)`),e.rel8ns[o][0];if(e.rel8ns[o].length>1)return(P||!t)&&console.warn(`${r} more than one config addr with ${o} rel8n. (W: 102f63eb74904bcfaac2eaf778043205)`),e.rel8ns[o][0];P&&console.log(`${r} didn't find (I: 1163e6ac60194d25b3f24881650edfad)`);return}catch(n){console.error(`${r} ${n.message}`);return}}h(ca,"getConfigAddr");async function Je({key:o,addr:e,space:t,zeroSpace:r,fnUpdateBootstrap:n}){let a=`[${Je.name}]`;try{if(!t)throw new Error("space required. (E: c28b663c991d44419aef1026cc689636)");if(!r)throw new Error("zeroSpace required. (E: d3707ae5265d464891ad216f64be6184)");let s={[o]:[e]},i=await ie({src:t.toIbGibDto(),dna:!1,linkedRel8ns:["past","ancestor",o],rel8nsToAddByAddr:s,nCounter:!0});if(!i.newIbGib)throw new Error("create new space failed.");await V({resTransform:i,space:r}),await V({resTransform:i,space:t});let c=i.newIbGib;return await t.loadIbGibDto(c),n?await n(c):console.warn(`${a} fnUpdateBootstrap is falsy. (W: 9fb874de2b19454dac18645e61ac463f)`),c}catch(s){throw console.error(`${a} ${s.message}`),s}}h(Je,"setConfigAddr");async function Jl({space:o}){let e=`[${Jl.name}]`;try{if(!o)throw new Error("space required. (E: f0d546101fba4c169256158114ab3c56)");let t=await ia({type:"roots",space:o});if(!t)throw new Error("Roots not initialized. (E: 89b1ba12ed12416aac41cef9fdaf1fc2)");if(!t.rel8ns)throw new Error("Roots not initialized properly. No rel8ns. (E: 8513a07cf530484db9521a2a3a27b7f6)");if(!t.rel8ns.current)throw new Error("Roots not initialized properly. No current root. (E: 459c3a007a30486d96fb8d83f696e239)");if(t.rel8ns.current.length===0)throw new Error("Invalid Roots: empty current root rel8n. (E: bede5864090440bca01ea7ab7fd107d6)");if(t.rel8ns.current.length>1)throw new Error("Invalid Roots: multiple current roots selected. (E: 97561acbf63a48ecaa037697bd26555a)");let r=t.rel8ns.current[0],n=await z({addr:r,space:o});if(n.ibGibs?.length===1)return n.ibGibs[0];throw new Error(`could not get current root. addr: ${r}`)}catch(t){console.error(`${e} ${t.message}`);return}}h(Jl,"getCurrentRoot");async function ui({root:o,space:e,zeroSpace:t,fnUpdateBootstrap:r,fnBroadcast:n}){let a=`[${ui.name}]`;try{if(P&&console.log(`${a} starting... (I: 7f16e845a80fe95d28923e4170f0c825)`),!o)throw new Error("root required.");if(!e)throw new Error("space required. (E: 186af2731c5342a78b063a0a4346f3db)");let s=I({ibGib:o}),i=await ia({type:"roots",space:e});if(!i)throw new Error("Roots not initialized. (E: a8232b9afac89d0d189534480b7a9825)");let l=await ie({src:i,dna:!1,linkedRel8ns:["past","ancestor","current"],rel8nsToAddByAddr:{current:[s]},nCounter:!0});await V({resTransform:l,space:e});let d=Me({type:"roots"}),f=l.newIbGib,b=I({ibGib:f});await Je({key:d,addr:b,space:e,zeroSpace:t,fnUpdateBootstrap:r}),await J({ibGib:f,space:e,fnBroadcast:n})}catch(s){throw console.error(`${a} ${s.message}`),s}finally{P&&console.log(`${a} complete. (I: 7f16e845a80fe95d28923e4170f0c825)`)}}h(ui,"setCurrentRoot");async function Zl({ibGib:o,linked:e,rel8nName:t,space:r,fnBroadcast:n,zeroSpace:a,fnUpdateBootstrap:s}){let i=`[${Zl.name}]`;try{if(!r)throw new Error("space required. (E: f2758eab3bb844d2b749515672d9e392)");if(!o)throw new Error("ibGib required (E: f1bfd67754a7271553f4af544d30bc22)");let c=await Jl({space:r});if(!c)throw new Error("currentRoot undefined (E: 5c2d84dafc664808866008f6eb535750");let l=ye({ibGib:o,defaultIfNone:"incomingAddr"}),d=I({ibGib:o});if(t&&l&&c.rel8ns&&c.rel8ns[t]&&c.rel8ns[t].includes(l))return;t=t||Ws;let f=await ie({src:c,dna:!1,linkedRel8ns:e?["past","ancestor",t]:["past","ancestor"],rel8nsToAddByAddr:{[t]:[d]},nCounter:!0});await V({resTransform:f,space:r});let b=f.newIbGib,p=I({ibGib:b});P&&console.log(`${i} updating _currentRoot root. newRootAddr: ${p}`),await J({ibGib:b,space:r,fnBroadcast:n}),await ui({root:b,space:r,zeroSpace:a,fnUpdateBootstrap:s,fnBroadcast:n})}catch(c){console.error(`${i} ${c.message}`);return}}h(Zl,"rel8ToCurrentRoot");async function hi({targetIbGib:o,space:e}){let t=`[${hi.name}]`;try{P&&console.log(`${t} starting... (I: 291638372117dbc983b4b7cbd8f52123)`);let r=await bi({targetIbGib:o}),n=await ce({ibGib:r,space:e});if(!n.success)throw new Error(`error putting metaStone in space. error: ${n.errorMsg??"[unknown error (E: 45f700f4f1ff463ca8f5353c8e796ac7)]"} (E: 4c25379e66365055e3e423561a7d6123)`)}catch(r){throw console.error(`${t} ${E(r)}`),r}finally{P&&console.log(`${t} complete.`)}}h(hi,"createAndSaveNewMetaStone");async function J({ibGib:o,space:e,fnBroadcast:t}){let r=`[${J.name}]`,n=P;try{let a=I({ibGib:o});if(r=`${r}[${a}]`,!e)throw new Error("space required. (E: ea0c03256f8a4062b460aa4de11f1e3e)");if(P&&console.log(`${r} starting...`),!Ne({ibGibAddr:a}).tjpGib&&!o.data?.isTjp){P&&console.log(`${r} incoming ibGib has no timeline, so no broadcast. still going to create a metastone for it and return early. (I: 649752e3b1be0e0ceb078e0ec2a84f23)`),await hi({targetIbGib:o,space:e});return}let i=ye({ibGib:o,defaultIfNone:"undefined"});if(!i){let u=o.data?.isTjp?o:await Ko({ibGib:o,space:e});u||(console.warn(`${r} tjp not found for ${a}? Should at least just be the ibGib's address itself. (W: d9b570e5bf6d4312bc7d9249ed3bbaad)`),u=o),i=I({ibGib:u})}if(!i)throw new Error("(UNEXPECTED) tjpAddr falsy? should be guaranteed at this point. (E: 39aafb70bc3c6d70b6d2cf8882311223)");let c=h(async()=>{P&&console.log(`${r} adding/replacing latest. tjp: ${i} (I: 7f848da003a2436089fd6f044d96bb42)`),await hi({targetIbGib:o,space:e}),t&&(P&&console.log(`${r} fnBroadcast is true...(I: 0e3b561fb5474a0598b5c6d698df5e1f)`),setTimeout(()=>{P&&console.log(`${r} broadcasting... (I: 61785937be0346f0959d476d7267ab24)`),t({ib:"IbGibTimelineUpdateInfo",tjpAddr:i,latestAddr:a,latestIbGib:o})}))},"replaceLatest");if(o.data?.isTjp){P&&console.log(`${r} ibGib.data?.isTjp true. replacingLatest and returning early. (I: 02c626e006668291550e278b461bcb23)`),await c();return}P&&console.log(`${r} ibGib.data?.isTjp is falsy. (I: 84940e3a9eff869c9474b7b92b864b23)`);let l=await ve({ibGibs:[o],space:e});if(!l.data)throw new Error("(UNEXPECTED) resLatest.data falsy? (E: af3d3914d96adcc5525e4db83cc5d223)");let{success:d,latestAddrsMap:f}=l.data;if(!d){let{errors:u}=l.data;throw u??=["[unknown error (E: 344857f1853641aa842cea3931f90428)]"],new Error(`resLatest.success falsy. errors: ${X(u)}. addr: ${a} (E: b66721da6e1ef9ac4f4089e86c059323)`)}if(!f)throw new Error("(UNEXPECTED) latestAddrsMap falsy but success truthy? (E: c34caff7a256503575ff3ff491dec823)");let b=Object.keys(f);if(b.length!==1)throw new Error("(UNEXPECTED) latestAddrsMap size isn't 1? (E: e11ffc2c18d473745b5bbfc3fe5e3a23)");if(b[0]!==a)throw new Error(`(UNEXPECTED) latestAddrsMap has 1 key (correct) but the key isn't the incoming ibGibAddr? (incorrect). incoming ibGibAddr: ${a}. key found: ${b[0]} (E: 82d79a95d2d7de90eae9db571a360f23)`);P&&(console.log(`${r} valid latestAddrsMap. console.dir(latestAddrsMap)... (I: e24de41622cabbef375172c3017cfd23)`),console.dir(f));let p=f[a];if(p)if(p===a){P&&console.log(`${r} no other found. possible idempotent replacement. addr: ${a} (I: 7f5bd5d3391be95919240f0e97976e22)`),await c();return}else{P&&console.log(`${r} different addr found. incoming ibgib addr is newer. existingLatestAddr: ${p}. incoming addr: ${a} (I: 6cadf13f82aabeb71d76babf1813e623)`);let u=await z({addr:p,space:e});if(!u.success||u.ibGibs?.length!==1){console.error(`Didn't find existing latest ibGib (${p}). I haven't implemented more robust multi-node/distributed strategies for this scenario yet. so we are going ahead with setting the incoming ibgib as the latest in the timeline. (E: 10f6cca6e5ef45bfacbfe48f652e2102)`),await c();return}let m=u.ibGibs[0];if(typeof o.data?.n=="number"&&o.data.n>=0){P&&console.log(`found ibGib.data.n (version counter), using this to determine latest ibGib: ${o.data.n}`);let y=o.data.n;if(typeof m.data?.n=="number"&&m.data.n>=0){let A=m.data.n;if(P&&console.log(`[registerNewIbGib] n_ibGib (${y}) vs n_existingLatest (${A}) in space: ${e.data?.name||e.ib}`),y>A)P&&console.log(`${r} is newer (I: 040d05ac2032f08c7fd0c4d8b2887323)`),await c();else{P&&console.log("is not newer, so we don't need to do anything else. (I: 14c25dc3314748dc909d61b77eb64354)"),console.warn(`${r} incoming ibGib (${a}) is NOT NEWER than existing latest (${p}). multiple branches for the same timeline? ignoring incoming ibGibAddr. n_ibGib: ${y}. n_existingLatest: ${A}. space.ib: ${e.ib} (W: 057baadca494473dabb26fb4fb879774)`);return}}else m.data?.isTjp&&o.data.n===0?await c():(console.warn(`${r} (UNEXPECTED) only existingLatestIbGib (isTjp: ${m.data?.isTjp}) has a data.n counter? ibGib.data.n: ${o.data.n}. usually this only happens when existing latest is a tjp and the new ibGib we are registering is n === 0. This is falsy in this instance though. We will go ahead and replace the latest with the new one, but this is an anomalous state. (W: 73d08aea17ad4e1481a5f97e2556a878)`),console.log(`${r} console.dir(existingLatestIbGib)... (I: 9ef7962d9cc74f1eb0409e5caf98e915)`),console.dir(m),console.log(`${r} console.dir(ibGib)... (I: 9ef7962d9cc74f1eb0409e5caf98e915)`),console.dir(o),await c())}else if(P&&console.log(`${r} no nCounter found. Trying brute force method.`),await fd({ibGib:o,ibGibAddr:a,existingLatest:m,existingLatestAddr:p,tjpAddr:i,space:e})===a)await c();else return}else if(p===null){P&&console.log(`${r} no existing tjp mapping so incoming ibgib is considered new to this space. ibGib addr: ${a} (I: 4f2bbc32b31e4fa982d95b3a785db82f)`),await c();return}else throw new Error("(UNEXPECTED) latestAddr is falsy but not null? the getLatestAddrs impl in the space should be guaranteed to provide either the incoming ibgib addr, the latest addr (if exists), or null if not found. (E: 3159dd531c0bc0efc1ece116adf28923)")}catch(a){throw console.error(`${r} ${a.message}`),a}finally{P&&console.log(`${r} complete.`),P=n}}h(J,"registerNewIbGib");async function ao({type:o,rel8nName:e,ibGibsToRel8:t,ibGibsToUnRel8:r,addrsToUnRel8:n,linked:a,severPast:s,deletePreviousSpecialIbGib:i,space:c,zeroSpace:l,fnUpdateBootstrap:d,fnBroadcast:f}){let b=`[${ao.name}](type:${o},rel8nName:${e})`;try{if(!c)throw new Error("space required. (E: 956192eea28047eba6dad81620bb96fb)");if((t??[]).length===0&&(r??[]).length===0&&(n??[]).length===0)throw new Error("either ibGibsToRel8 or ibGibsToUnRel8 required. (E: 5add49c8e46a54e2c6b057c22646a822)");if((r??[]).length>0&&(n??[]).length>0)throw new Error("can't provide both ibGibsToUnRel8 and addrsToUnRel8. There isn't a technical reason but I'm too tired right now to implement the overhead to enable this atow (05/2025). (E: 31ef66be26349cfe1b1f352389b99425)");let p=t?.map($=>I({ibGib:$}));n??=r?.map($=>I({ibGib:$}));let u=Me({type:o}),m=await ca({key:u,space:c});if(!m)throw new Error("specialAddr not found (E: 680dfd1caa3e4d7cb0f593b893a10f0d)");let g=await z({addr:m,space:c});if(!g.success)throw new Error("couldn't get special (E: 897f7671d2184515866c5a675d33b3dc)");if(!g.ibGibs)throw new Error("resGetSpecial.ibGibs falsy (E: 2405dd295b2444d88503f7731796a5a0)");if(g.ibGibs.length!==1)throw new Error(`resGetSpecial.ibGibs count is not 1 (${g.ibGibs.length}) (E: b4547789016a4729af30cd972a4ca4ab)`);let y=g.ibGibs[0],w=await ie({src:y,rel8nsToAddByAddr:p?{[e]:p}:void 0,rel8nsToRemoveByAddr:n?{[e]:n}:void 0,dna:!1,linkedRel8ns:a?[Se.past,e]:[Se.past],nCounter:!0}),A=w.newIbGib;if(s){if(w.intermediateIbGibs)throw new Error("new special creates intermediate ibgibs. so severing past is harder. (E: b580c0c56253494192e9c62212ee187d)");A.rel8ns.past=[],A.gib=await ee({ibGib:A})}await V({resTransform:w,space:c});let G=I({ibGib:A}),T=ye({ibGib:A});return await Je({key:u,addr:G,space:c,zeroSpace:l,fnUpdateBootstrap:d}),i&&await pi({addr:m,space:c}),await J({ibGib:A,fnBroadcast:f,space:c}),G}catch(p){throw console.error(`${b} ${p.message}`),p}}h(ao,"rel8ToSpecialIbGib");async function Ko({ibGib:o,naive:e=!0,space:t}){let r=`[${Ko.name}]`;try{if(!t)throw new Error("space required. (E: 941f973d50e84415b58724af173f52c2)");if(!o)throw new Error("ibGib required.");let n=I({ibGib:o}),{gib:a}=K({ibGibAddr:n});if(a===Q||await Ii({ibGib:o,naive:e}))return o;if(!o.rel8ns){P&&console.log(`${r} ibgib not tjp in data, and rel8ns is falsy. so tjp is undefined (I: acdadb76a7568807db7a68f6f866de22)`);return}if(o.rel8ns.tjp&&o.rel8ns.tjp.length>0){let f=o.rel8ns.tjp[0],b=await z({addr:f,space:t});if(b.success&&b.ibGibs?.length===1)return b.ibGibs[0];{let p=b.errorMsg??"[unspecified error in get result]";throw new Error(`ibGib references tjp but could not retrieve from space. res error: ${p} (E: 94f0340706ad48c794c6a62c1b235a22)`)}}let i=o.rel8ns.past||[];if(i.length===0){console.warn(`${r} past.length === 0, so there is no tjp.`),P&&console.log(`${r} ibgib is not tjp in data, not in tjp rel8n, and past is empty. so tjp is undefined (I: bf06f664917dcf4492fb9c4c106a6222)`);return}let c=i[i.length-1],l=await z({addr:c,space:t});if(!l.success||l.ibGibs?.length!==1)throw new Error(`get past failed. addr: ${c}`);let d=l.ibGibs[0];return await Ko({ibGib:d,naive:e,space:t})}catch(n){throw console.error(`${r} ${n.message}`),n}}h(Ko,"getTjpIbGib");async function Ql({type:o,space:e,zeroSpace:t,fnUpdateBootstrap:r,fnBroadcast:n}){let a=`[${Ql.name}]`;try{if(!e)throw new Error("space falsy and localUserSpace not initialized. (E: 66e7d3ff098248f0a5ddda51853c92e6)");switch(o){case"roots":return rd({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:r});case"tags":return ed({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:r});case"secrets":return nd({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:r});case"encryptions":return ad({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:r});case"outerspaces":return sd({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:r});case"autosyncs":return id({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:r});case"robbots":return cd({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:r});case"apps":return ld({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:r});default:return dd({type:o,space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:r})}}catch(s){throw console.error(`${a} ${s.message}`),s}}h(Ql,"createSpecial");async function Rt({type:o,skipRel8ToRoot:e,space:t,zeroSpace:r,fnUpdateBootstrap:n,fnBroadcast:a}){let s=`[${Rt.name}][${o||"falsy type?"}]`;try{P&&console.log(`${s} starting...`);let i=yi({type:o}),c=H.primitive({ib:i}),l=await Rn({src:c,destIb:i,linkedRel8ns:[Se.past,Se.ancestor],tjp:{uuid:!0,timestamp:!0},dna:!0,nCounter:!0});return await V({resTransform:l,space:t}),o!=="roots"&&o!=="latest"&&!e&&await Zl({ibGib:l.newIbGib,linked:!0,space:t,zeroSpace:r,fnBroadcast:a,fnUpdateBootstrap:n}),P&&console.log(`${s} complete.`),l.newIbGib}catch(i){throw console.error(`${s} ${i.message}`),i}}h(Rt,"createSpecialIbGib");async function ed({space:o,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:r}){let n=`[${ed.name}]`;try{if(!o)throw new Error("space required. (E: 9c05b9bd355943a39ca47afef67a50eb)");let a=Me({type:"tags"}),s=await Rt({type:"tags",space:o,zeroSpace:e,fnBroadcast:r,fnUpdateBootstrap:t}),i=I({ibGib:s});await Je({key:a,addr:i,space:o,zeroSpace:e,fnUpdateBootstrap:t});let c=[{text:"home",icon:"home-outline"},{text:"favorite",icon:"heart-outline"}];for(let l of c)i=(await td({...l,space:o,zeroSpace:e,fnBroadcast:r,fnUpdateBootstrap:t})).newTagsAddr,await Je({key:a,addr:i,space:o,zeroSpace:e,fnUpdateBootstrap:t});return i}catch(a){return console.error(`${n} ${a.message}`),null}}h(ed,"createSpecial_Tags");async function td({text:o,icon:e,description:t,space:r,zeroSpace:n,fnUpdateBootstrap:a,fnBroadcast:s}){let i=`[${td.name}]`;try{if(P&&console.log(`${i} starting...`),!r)throw new Error("space required. (E: 5def0b1afab74b0c9286e3ac5060cb8f)");if(!o)throw new Error(`${i} text required`);e=e||_l,t=t||Tl;let c=Or(o),l=H.primitive({ib:"tag"}),d=await H.firstGen({parentIbGib:l,ib:c,data:{text:o,icon:e,description:t},tjp:{uuid:!0,timestamp:!0},dna:!0,nCounter:!0}),f=d.newIbGib;await V({resTransform:d,space:r}),await J({ibGib:f,space:r,fnBroadcast:s});let b=await Oh({tagIbGib:f,space:r,zeroSpace:n,fnUpdateBootstrap:a,fnBroadcast:s});return{newTagIbGib:f,newTagsAddr:b}}catch(c){throw console.error(`${i} ${c.message}`),c}finally{P&&console.log(`${i} complete.`)}}h(td,"createTagIbGibAndSundry");async function rd({space:o,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:r}){let n=`[${rd.name}]`;try{if(!o)throw new Error("space required. (E: d12a8ea31163429fb6e53ff8e7579c57)");let a=Me({type:"roots"}),s=await Rt({type:"roots",space:o,zeroSpace:e,fnBroadcast:r,fnUpdateBootstrap:t}),i=I({ibGib:s});await Je({key:a,addr:i,space:o,zeroSpace:e,fnUpdateBootstrap:t});let l=["A","B","C","D","E","F","G"].map(f=>({text:`${f}root`,icon:Ys,description:Ks})),d;for(let f=0;f<l.length;f++){let b=l[f],p=await od({...b,space:o,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:r});if(d||(d=p.newRootIbGib),!p.newRootIbGib)throw new Error("(UNEXPECTED) resCreate.newRootIbGib falsy? (E: c9fb2c94a9c1d762c1699b41a4d5ad23)");i=p.newRootsAddr,await Je({key:a,addr:i,space:o,zeroSpace:e,fnUpdateBootstrap:t})}if(!d)throw new Error("(UNEXPECTED) firstRoot still falsy? (E: b2e2c926d242966e7ed7159e4b129e23)");if(await ui({root:d,space:o,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:r}),i=await ca({key:a,space:o}),!i)throw new Error("(UNEXPECTED) no roots address in config? (E: 76345340699a4738a195e48803ef0d31)");return i}catch(a){return console.error(`${n} ${a.message}`),null}}h(rd,"createSpecial_Roots");async function od({text:o,icon:e,description:t,space:r,zeroSpace:n,fnUpdateBootstrap:a,fnBroadcast:s}){let i=`[${od.name}]`;try{if(!r)throw new Error("space required. (E: cfa876e5c8c64a53a463ca7a645571c8)");o=o||Al,e=e||Ys,t=t||Ks;let c=$i(o),l=H.primitive({ib:"root"}),d=await H.firstGen({parentIbGib:l,ib:c,data:{text:o,icon:e,description:t},linkedRel8ns:[Se.past,Se.ancestor],tjp:{uuid:!0,timestamp:!0},dna:!0,nCounter:!0}),{newIbGib:f}=d;await V({resTransform:d,space:r});let b=await ao({type:"roots",rel8nName:Vs,ibGibsToRel8:[f],space:r,zeroSpace:n,fnUpdateBootstrap:a,fnBroadcast:s});return{newRootIbGib:f,newRootsAddr:b}}catch(c){throw console.error(`${i} ${c.message}`),c}}h(od,"createRootIbGib");async function nd({space:o,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:r}){let n=`[${nd.name}]`;try{if(!o)throw new Error("space required. (E: 340960cd5ad24addb300b23d9722e30a)");let a,s=Me({type:"secrets"}),i=await Rt({type:"secrets",space:o,zeroSpace:e,fnBroadcast:r,fnUpdateBootstrap:t});return a=I({ibGib:i}),await Je({key:s,addr:a,space:o,zeroSpace:e,fnUpdateBootstrap:t}),a}catch(a){return console.error(`${n} ${a.message}`),null}}h(nd,"createSpecial_Secrets");async function ad({space:o,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:r}){let n=`[${ad.name}]`;try{if(!o)throw new Error("space required. (E: 5084e698b6924e7090697ca50075ca59)");let a,s=Me({type:"encryptions"}),i=await Rt({type:"encryptions",space:o,zeroSpace:e,fnBroadcast:r,fnUpdateBootstrap:t});return a=I({ibGib:i}),await Je({key:s,addr:a,space:o,zeroSpace:e,fnUpdateBootstrap:t}),a}catch(a){return console.error(`${n} ${a.message}`),null}}h(ad,"createSpecial_Encryptions");async function sd({space:o,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:r}){let n=`[${sd.name}]`;try{if(!o)throw new Error("space required. (E: 99dd9e92535c470482eb9f6625a33831)");let a,s=Me({type:"outerspaces"}),i=await Rt({type:"outerspaces",space:o,zeroSpace:e,fnBroadcast:r,fnUpdateBootstrap:t});return a=I({ibGib:i}),await Je({key:s,addr:a,space:o,zeroSpace:e,fnUpdateBootstrap:t}),a}catch(a){return console.error(`${n} ${a.message}`),null}}h(sd,"createSpecial_OuterSpaces");async function id({space:o,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:r}){let n=`[${id.name}]`;try{if(!o)throw new Error("space required. (E: f01cf6a4a460486796e16d505d629522)");let a,s=Me({type:"autosyncs"}),i=await Rt({type:"autosyncs",space:o,zeroSpace:e,fnBroadcast:r,fnUpdateBootstrap:t});return a=I({ibGib:i}),await Je({key:s,addr:a,space:o,zeroSpace:e,fnUpdateBootstrap:t}),a}catch(a){return console.error(`${n} ${a.message}`),null}}h(id,"createSpecial_Autosyncs");async function cd({space:o,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:r}){let n=`[${cd.name}]`;try{if(!o)throw new Error("space required. (E: f01cf6a4a460486796e16d505d629522)");let a,s=Me({type:"robbots"}),i=await Rt({type:"robbots",space:o,zeroSpace:e,fnBroadcast:r,fnUpdateBootstrap:t});return a=I({ibGib:i}),await Je({key:s,addr:a,space:o,zeroSpace:e,fnUpdateBootstrap:t}),a}catch(a){return console.error(`${n} ${a.message}`),null}}h(cd,"createSpecial_Robbots");async function ld({space:o,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:r}){let n=`[${ld.name}]`;try{if(!o)throw new Error("space required. (E: f01cf6a4a460486796e16d505d629522)");let a,s=Me({type:"apps"}),i=await Rt({type:"apps",space:o,zeroSpace:e,fnBroadcast:r,fnUpdateBootstrap:t});return a=I({ibGib:i}),await Je({key:s,addr:a,space:o,zeroSpace:e,fnUpdateBootstrap:t}),a=await sa({defaultAppData:Bl,defaultAppRel8ns:kl,space:o,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:r}),a=await sa({defaultAppData:jl,defaultAppRel8ns:ql,space:o,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:r}),a=await sa({defaultAppData:Xl,defaultAppRel8ns:Hl,space:o,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:r}),a}catch(a){return console.error(`${n} ${a.message}`),null}}h(ld,"createSpecial_Apps");async function sa({defaultAppData:o,defaultAppRel8ns:e,space:t,zeroSpace:r,fnUpdateBootstrap:n,fnBroadcast:a}){let s=`[${sa.name}]`;try{P&&console.log(`${s} starting... (I: 677f68789abdc7316887e8f38c764e22)`),P&&console.log(`${s} starting...`);let i=B(o),c=e?B(e):void 0;i.uuid=!i.uuid||i.uuid===ii?await q():i.uuid;let{classname:l}=i,d=si({appData:i,classname:l}),f=await H.firstGen({ib:d,parentIbGib:H.primitive({ib:`app ${l}`}),data:i,rel8ns:c,dna:!0,linkedRel8ns:[Se.ancestor,Se.past],nCounter:!0,tjp:{timestamp:!0}});return await V({resTransform:f,space:t}),await J({ibGib:f.newIbGib,fnBroadcast:a,space:t}),await ao({type:"apps",rel8nName:Vn,ibGibsToRel8:[f.newIbGib],fnBroadcast:a,fnUpdateBootstrap:n,space:t,zeroSpace:r})}catch(i){throw console.error(`${s} ${i.message}`),i}finally{P&&console.log(`${s} complete.`)}}h(sa,"createApp");async function dd({type:o,space:e,zeroSpace:t,fnUpdateBootstrap:r,fnBroadcast:n}){let a=`[${dd.name}]`;try{if(!e)throw new Error("space required. (E: c7bbafcbe901418db4c6048f17f53091)");P&&console.log(`${a} creating special of type: ${o} (I: 283c8bb30ed6f9698b74b886c6078622)`);let s,i=Me({type:o}),c=await Rt({type:o,space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:r});return s=I({ibGib:c}),await Je({key:i,addr:s,space:e,zeroSpace:t,fnUpdateBootstrap:r}),s}catch(s){return console.error(`${a} ${s.message}`),null}}h(dd,"createSpecial_Default");async function fd({ibGib:o,ibGibAddr:e,existingLatest:t,existingLatestAddr:r,tjpAddr:n,space:a}){let s=`[${fd.name}][${e}]`;try{if(P&&console.log(`${s} starting...`),!a)throw new Error("space required. (E: 64eb9a271f5d43deadec30b9638746c8)");let i=o.rel8ns?.past||[],c=t.rel8ns?.past||[];if(i.length===1&&c.length===0)return P&&console.log(`prospective has a past, so it "must" be newer. (won't quote "must" anymore)`),e;if(c.length===1&&i.length===0)return P&&console.log("existing has a past, so it must be newer."),r;if(c.length===0&&i.length===0)return console.warn(`${s} neither existing latest nor prospective new ibGib has a past, so keeping existing.`),r;if(c.includes(e))return P&&console.log("existing by definition is newer"),r;if(i.includes(r))return P&&console.log("ibGib by definition is newer"),e;if(r===e)return P&&console.log("they're the same!"),r;if(r===n&&t.rel8ns?.tjp?.length===1)return P&&console.log("ibGib must be newer because the existingLatestAddr is the tjp, which is by definition first in unique past."),e;if(e===n&&o.rel8ns?.tjp?.length===1)return P&&console.log("existing must be newer because the ibGibAddr is the tjp, which is by definition first in unique past."),r;P&&console.log(`${s} brute forcing through iterating the pasts.`);let l,d=-1,f=h(async(u,m,g)=>{let y=u.rel8ns?.past||[];if(y.includes(g))return l=I({ibGib:u}),-1;if(y.length===0)return m;let w=m+y.length;if(d!==-1&&w>d)return l=I({ibGib:u}),-1;let A=await z({addr:y[0],space:a});if(!A.success||A.ibGibs?.length!==1)throw new Error(`Couldn't load past addr (xPast[0]): ${y[0]}`);return f(A.ibGibs[0],m+y.length,g)},"getPastCount");P&&console.log(`${s} doing ibGibPastCount`);let b=await f(o,0,r);if(l)return l;P&&console.log(`${s} Doing existingPastCount`),d=b;let p=await f(t,0,e);return l||(b>p?(P&&console.log(`${s} ibGibPastCount (${b}) is longer than existingPastCount (${p}), so ibGib is newer.`),l=e):(P&&console.log(`${s} existingPastCount (${p}) is longer than ibGibPastCount (${b}), so ibGib is newer.`),l=r),l)}catch(i){throw console.error(`${s} ${i.message}`),i}finally{P&&console.log(`${s} complete.`)}}h(fd,"getLatestAddr_Brute");function Oh({tagIbGib:o,space:e,zeroSpace:t,fnUpdateBootstrap:r,fnBroadcast:n}){return ao({type:"tags",rel8nName:zs,ibGibsToRel8:[o],space:e,zeroSpace:t,fnUpdateBootstrap:r,fnBroadcast:n})}h(Oh,"rel8TagToTagsIbGib");function la({ibGibs:o,ibGibAddrs:e}){let t=`[${la.name}]`;try{if(!o&&!e)throw new Error("either ibGibs or ibGibAddrs required. (E: 37776788620f4966b0964945ce181fc6)");o&&e&&console.warn(`${t} both ibGibs and ibGibAddrs provided. You should only provide one. Only ibGibAddrs will be checked. (W: dc13f9e197834e2daaba3bcfd08418db)`);let r=e?e.concat():o.map(n=>I({ibGib:n}));for(let n=0;n<r.length;n++){let a=r[n];if(r.filter(s=>s===a).length>1)throw new Error(`duplicate addr found: ${a} (E: 70fbef040dd449c38c667d53b8092053)`)}}catch(r){throw console.error(`${t} ${r.message}`),r}}h(la,"throwIfDuplicates");function mi({space:o,scope:e}){let t=`[${mi.name}]`;try{if(P&&console.log(`${t} starting...`),!o)throw new Error("space required. (E: 3ba16e6c3e5e47948b0e63448da11752)");if(!o.data?.uuid)throw new Error("invalid space (space.data.uuid falsy) (E: 273262b32f2ef27b2e690bc699f33822)");if(!e)throw new Error("scope required. (E: f47801d6c45e2247b42a53d9b604b522)");for(;e.includes(Ue);)P&&console.log(`${t} scope contains ibgib delimiter...replacing... (I: 0f456fd7cc6552a799673a0c5b4a7d22)`),e=e.replace(Ue,"_");let r=o.data.uuid,n=`${yl} ${r} ${e}`;return I({ib:n,gib:Q})}catch(r){throw console.error(`${t} ${r.message}`),r}finally{P&&console.log(`${t} complete.`)}}h(mi,"getSpaceLockAddr");async function pt({space:o,scope:e,secondsValid:t,maxDelayMs:r,fn:n,callerInstanceId:a,maxLockAttempts:s}){let i=`[${pt.name}]`;try{if(P&&console.log(`${i} starting...`),!o)throw new Error("space required. (E: 66fd8f21a5b2b572d18cdeb9472a7722)");if(!t)throw new Error("secondsValid required. (E: 92c5610e57ceede5ce83cff86d5c2a22)");if(t<0)throw new Error("secondsValid must be positive. (E: 970a7510c517235d7a355a843d18d222)");if(!n)throw new Error("fn required (E: 7022e280252ec2faf756b6db05c56e22)");let c;P&&console.log(`${i} attempting to acquire lock with scope ${e} (I: fed36d42a975b1c52897a4df804ac722)`);let l;r=(r??0)>0?r:$l;let d=0;s=s??!1?s:Il;do{if(l=await bd({space:o,scope:e,secondsValid:t,instanceId:a}),l?.data?.success)break;let b=Math.ceil(Math.random()*r);await De(b),d++}while(d<s);if(l?.data?.success)P&&console.log(`${i} lock acquired. (I: d847fa953ee131a57e1a89c537342722)`);else throw new Error(`could not acquire lock after ${d} attempts with intermittent delays of ${r} ms (E: 898c559dbd0c9bf20c14cf87a8f1e222)`);let f=`${i}[fn]`;try{P&&console.log(`${f} starting... (I: c2f7bedf95d3f1dd1f76de34a68d3f22)`),c=await n()}catch(b){throw console.error(`${f} ${b.message}`),b}finally{P&&console.log(`${f} unlocking space with scope: ${e} (I: 21034d9c3395499756e9000e40417d22)`),await hd({space:o,scope:e,instanceId:a}),P&&console.log(`${f} complete. (I: 79d8ac03714a4d429c7e6c2ac6e18d22)`)}return c}catch(c){throw console.error(`${i} ${c.message}`),c}finally{P&&console.log(`${i} complete.`)}}h(pt,"execInSpaceWithLocking");async function zo({zeroSpace:o}){let e=`[${zo.name}]`;try{if(P&&console.log(`${e} starting...`),!o)throw new Error("zeroSpace required. (E: 66fd8f21a5b2b572d18cdeb9472a7722)");let t=lr;P&&console.log(`${e} getting from zeroSpace...`);let r=await o.argy({ibMetadata:Tt({space:o}),argData:{cmd:"get",ibGibAddrs:[t]}}),n=await o.witness(r);if(n?.data?.success&&n.ibGibs?.length===1){let a=n.ibGibs[0];return P&&console.log(`${e} bootstrapibGib found: ${X(a)}`),await ci(a)?a:(P&&console.log(`${e} bootstrapIbGib was invalid. (I: cce66b26805404fc85525d565e1f8b22)`),null)}else return P&&console.log(`${e} bootstrapIbGib NOT found. (I: 421562993bf3464eb507d2967d311e22)`),null}catch(t){throw console.error(`${e} ${t.message}`),t}finally{P&&console.log(`${e} complete.`)}}h(zo,"getValidatedBootstrapIbGib");async function Lh({zeroSpace:o,bootstrapIbGib:e,localSpaceId:t,lock:r,callerInstanceId:n,fnDtoToSpace:a,localSpaceCacheSvc:s}){let i=`[${Lh.name}]`;try{if(!o)throw new Error("zeroSpace required. (E: 0793781a98c456a666cfa9eb960bcd22)");if(!e)if(P&&console.log(`${i} bootstrap falsy, so loading it... (I: f2366e38283495a38b5501297aa34422)`),r){let d=lr;P&&console.log(`${i} using locked version of loading bootstrap... (I: 52b9b11999674e586d051c2b23f59b22)`),e=await pt({space:o,scope:d,fn:h(async()=>{let f=await zo({zeroSpace:o});if(f)return f;throw new Error("(UNEXPECTED) unable to get bootstrap ibgib? (E: c111dc7627acbfb992134ddf4064ea23)")},"fn"),callerInstanceId:n,secondsValid:qn})}else P&&console.log(`${i} lock is false, so just getting the bootstrap ibgib (I: 49d55e5a824510bb3ee0ccd9f5ec3322)`),e=await zo({zeroSpace:o})??void 0;if(!e)throw new Error("bootstrapIbGib falsy. not initialized? (E: 91f5c82b5e124178d958701ebcb09822)");if(!e.data)throw new Error("(UNEXPECTED) bootstrapIbGib.data required. invalid bootstrap? (E: 568c6b837c1a39f7a25d188a90167423)");if(t=t??e.data[At],!e.rel8ns)throw new Error("(UNEXPECTED) bootstrapIbGib.rel8ns falsy? it should have been validated by now. (E: 817d9a2a0b98ec0c177cd7ab149b9426)");if(!e.rel8ns[t])throw new Error(`localSpaceId (${t}) not found in bootstrapIbGib.rel8ns (E: 8869884093984ec43f942fea24bd9926)`);let c=e.rel8ns[t][0],l=h(async()=>{let d=await o.argy({ibMetadata:Tt({space:o}),argData:{cmd:"get",ibGibAddrs:[c]}}),f=await o.witness(d);if(f?.data?.success&&f.ibGibs?.length===1){let b=f.ibGibs[0],p=await a(b);return s&&(p.cacheSvc=s),p}else throw new Error(`Could not get local space addr (${c}) specified in bootstrap space (${I({ibGib:e})}). (E: 6d6b45e7eae4472697ddc971438e4922)`)},"fnGet");return r?(P&&console.log(`${i} getting localSpaceId (${t}) WITH locking (I: c48a0e4ac5971cdbc57273dd35f8a522)`),await pt({space:o,scope:t,fn:h(()=>l(),"fn"),callerInstanceId:n,secondsValid:qn})):(P&&console.log(`${i} getting localSpaceId (${t}) WITHOUT locking (I: 48e504835dee4006839df8820d860b22)`),l())}catch(c){throw console.error(`${i} ${c.message}`),c}}h(Lh,"getLocalSpace");async function bd({space:o,scope:e,secondsValid:t,instanceId:r}){let n=`[${bd.name}]`;try{if(P&&console.log(`${n} starting...`),!o)throw new Error("space required. (E: 5c0a7197a75f483a82d74e5eea60df37)");if(!e)throw new Error("scope required. (E: c7f1dde9570f4df3b450faa2c2f85122)");if(!t)throw new Error("secondsValid required and positive (E: b42b6733638b46c06c9aff59a6c49822)");if(t<0)throw new Error("secondsValid must be positive (E: bbe3b6d567583bfb35a1c0825eb29622)");let a,s=mi({space:o,scope:e}),i,c=await z({addr:s,space:o,force:!0});if(c.success&&c.ibGibs?.length===1?(i=c.ibGibs[0],i?.data?.expirationUTC?Bs({expirationTimestampUTC:i.data.expirationUTC})&&(console.warn(`${n} ignoring expired existing lock in space at ${s}. Should be overwritten (W: 7421c5b051724b189f88cecbbd449b22)`),i=void 0):(console.error(`${n} (UNEXPECTED) exisingLock.data.expirationUTC falsy? (E: 218dc0e935534a149d0be153c532cf25)`),i=void 0)):P&&console.log(`${n} existing lock not found for ${s} (I: 191af56ec4e2db3d19084e46bf949222)`),i){if(!i.data)throw new Error("(UNEXPECTED) existingLock.data falsy? (E: 00069b4662e5566d971760d15e293723)");a=B(i),a.data.alreadyLocked=!0,a.data.success=!1}else{let{ib:l,gib:d}=K({ibGibAddr:s});a={ib:l,gib:d,data:{scope:e,secondsValid:t,instanceId:r,expirationUTC:Fs({seconds:t})}};let f=await o.argy({ibMetadata:Tt({space:o}),argData:{cmd:"put",force:!0,ibGibAddrs:[s]},ibGibs:[a]}),b=await o.witness(f);if(b.data?.success)if((b.data.addrsAlreadyHave??[]).includes(s)){P&&console.log(`${n} racelost! addrsAlreadyHave includes spaceLockAddr (${s}) (I: 2e8a1562947c40698110b64251141753)`);let p=await z({addr:s,space:o,force:!0});if(p.success&&p.ibGibs?.length===1){let u=p.ibGibs[0];a=B(u),a.data.alreadyLocked=!0,a.data.success=!1}else{let u=`${n} (UNEXPECTED) addrsAlreadyHave true, but couldn't get lock? (E: 8374a2b6628b49369363bc5843105763)`;console.error(u),a.data.success=!1,a.data.errorMsg=u}}else a.data.success=!0;else{let p=`${n} there was an error putting the lock in the space: ${b.data?.errors?.join("|")}`;a.data.success=!1,a.data.errorMsg=p,console.error(p)}}return a}catch(a){throw console.error(`${n} ${a.message}`),a}finally{P&&console.log(`${n} complete.`)}}h(bd,"lockSpace");async function hd({space:o,scope:e,instanceId:t}){let r=`[${hd.name}]`;try{if(P&&console.log(`${r} starting...`),!o)throw new Error("space required. (E: 5c0a7197a75f483a82d74e5eea60df37)");if(!e)throw new Error("scope required. (E: c7f1dde9570f4df3b450faa2c2f85122)");let n=mi({space:o,scope:e}),a=await pi({addr:n,space:o,force:!0});if(a.success){let{ib:s,gib:i}=K({ibGibAddr:n});return{ib:s,gib:i,data:{success:!0,instanceId:t,scope:e}}}else{let s=`Delete lock in space failed. delete errorMsg: ${a.errorMsg}`;if(s.includes("not implemented"))throw new Error(s);if(s.toLowerCase().includes("does not exist")||s.toLowerCase().includes("doesn't exist")||s.toLowerCase().includes("not found")){P&&console.log(`${r} ${s} (I: b647916fd0f3e5366e9387131be21c22)`);let{ib:i,gib:c}=K({ibGibAddr:n});return{ib:i,gib:c,data:{action:"unlock",success:!0,instanceId:t,scope:e}}}else console.warn(`${r} ${s} (W: 14c84fcac15944bd9a417099964d5d9d)`)}}catch(n){throw console.error(`${r} ${n.message}`),n}finally{P&&console.log(`${r} complete.`)}}h(hd,"unlockSpace");async function Rh({space:o,zeroSpace:e,setSpaceAsDefault:t,createIfNotFound:r}){let n=`[${Rh.name}]`;try{if(P&&console.log(`${n} starting...`),!o)throw new Error("space required. (E: 6fc19548fa7d1d5219e19871f280a322)");if(!o.data?.uuid)throw new Error("space.data.uuid required (E: 6483188ca6f2ed2085fd355595f3ab22)");if(!e)throw new Error("zeroSpace required. (E: abbf156e18b1018d96273e22a260f122)");let a=o.data.uuid,s=I({ibGib:o}),i=await zo({zeroSpace:e});if(i){if(P&&console.log(`${n} updating existing bootstrap (I: 977d4aa7ed47bef73b35743c05ce0722)`),i.data.spaceIds.includes(a)){P&&console.log(`${n} space already rel8d to bootstrap, possibly updating its addr (I: b5e2c515ef732d4bbcf02625a9e7c722)`);let c=i.rel8ns[a][0];c===s?P&&console.log(`${n} bootstrap already rel8d to space (I: c1be027b23e7350c64790a631cae2822)`):(P&&console.log(`${n} updating rel8ns[${a}] with newSpaceAddr (${s}). (Old address: ${c})(I: 297a9b0061fd471b8d28a06e04a6ad22)`),i.rel8ns[a]=[s])}else P&&console.log(`${n} new space being rel8d. adding spaceId to data.spaceIds and amending rel8ns (I: 40903d71719aa1d56e498299f5699a22)`),i.data.spaceIds.push(a),i.rel8ns[a]=[s];t&&(P&&console.log(`${n} setting spaceId (${a}) as default space (I: f85eda6c6ad2b0bec9750ce3c7795b22)`),i.data[At]=a)}else{if(!r){P&&console.log(`${n} bootstrapIbGib not found but createIfNotFound falsy, so returning early. (I: 5c67d85a8599a5ba4a6780f26a66ea22)`);return}P&&console.log(`${n} creating new bootstrap ibgib for spaceId (${a}) with address of (${s}) (I: 651959c27bf2ebc5be1f7f44e2b9e422)`);let{ib:c,gib:l}=K({ibGibAddr:lr});i=H.primitive({ib:c}),i.gib=l,i.data={[At]:a,[Wn]:[a]},i.rel8ns={[a]:[s]}}if(!i)throw new Error("(UNEXPECTED) bootstrapIbGib still falsy? (E: cf21d7f1756710a66aa0e6a28d762723)");P&&console.log(`${n} saving bootstrapIbGib: ${X(i)} (I: 3cceca0b98dde90e4a58a734be252322)`),await gi({zeroSpace:e,bootstrapIbGib:i}),P&&console.log(`${n} complete.`)}catch(a){throw console.error(`${n} ${a.message}`),a}}h(Rh,"updateBootstrapIbGib");async function gi({zeroSpace:o,bootstrapIbGib:e}){let t=`[${gi.name}]`;if(!o)throw new Error("zeroSpace required. (E: 818fa8430b8040dca1917f9db0972b22)");if(!e)throw new Error("bootstrapIbGib required. (E: cf21d7f1756710a66aa0e6a28d762723)");let r=await o.argy({ibMetadata:e.ib,argData:{cmd:"put",force:!0,ibGibAddrs:[I({ibGib:e})]},ibGibs:[e]});P&&console.log(`${t} zeroSpace will witness/put... (I: 1be9aca22ffc4951b6690965a7aeae5b)`);let n=await o.witness(r);if(n?.data?.success)P&&console.log(`${t} zero space put complete. (I: ac3056d655e841f1a3c442bcc64942f9)`);else throw new Error(`${n?.data?.errors?.join("|")||"There was a problem with zeroSpace witnessing the bootstrap^gib primitive."}`)}h(gi,"persistBootstrapIbGibInZeroSpace");async function Uh({spaceId:o,zeroSpace:e}){let t=`[${Uh.name}]`;if(!o)throw new Error("spaceId required. (E: 52f9c31405e24c2999e5a1b32d201a23)");if(!e)throw new Error("zeroSpace required. (E: a115f4007b2c4819a58cf093d5823b23)");await pt({space:e,scope:lr,fn:h(async()=>{let n=await zo({zeroSpace:e});if(!n)throw new Error("bootstrapIbGib falsy in zeroSpace (E: e36a512781b0467ba1bf1d927a7c1d23)");if(!n.data)throw new Error("bootstrapIbGib.data falsy in zeroSpace (E: 8f92104192b44d71891b092481029ab0)");let a=n.data,s=a[Wn]??[];if(s.length<=1)throw new Error(`Cannot delete space (${o}). It is the only remaining local space. (E: 9c27f71120014b08b5e9f89993380e23)`);if(o===a[At])throw new Error(`Cannot delete space (${o}). It is the default local space. Please select a new default space before deleting. (E: f3c30a5170d14b4fb2478d102e3b2e23)`);if(!s.includes(o))throw new Error(`Space (${o}) not found in bootstrap spaceIds. (E: 61fa940e79124430a618e470bc551d23)`);a[Wn]=s.filter(i=>i!==o),n.rel8ns&&delete n.rel8ns[o],await gi({zeroSpace:e,bootstrapIbGib:n})},"fn"),secondsValid:qn})}h(Uh,"deregisterLocalSpaceFromBootstrap");async function Mh({spaceId:o,zeroSpace:e}){let t=`[${Mh.name}]`;if(!o)throw new Error("spaceId required. (E: 7c2a10529a1b412a8069e22e5190b623)");if(!e)throw new Error("zeroSpace required. (E: f112a512019c41a590b512a8e0915623)");let r=await e.argy({ibMetadata:Tt({space:e}),argData:{cmd:"get",ibGibAddrs:[o]}}),n=await e.witness(r);if(n?.data?.success&&(n.ibGibs?.length??0)>0){let a=I({ibGib:n.ibGibs[0]}),s=await e.argy({ibMetadata:Tt({space:e}),argData:{cmd:"delete",ibGibAddrs:[a]}});await e.witness(s)}}h(Mh,"deleteSpaceRecordFromZeroSpace");function Tt({space:o}){return`${o.ib} ${ft()}`}h(Tt,"getSpaceArgMetadata");function pd({space:o}){return`${o.ib} ${ft()}`}h(pd,"getSpaceResultMetadata");function Ei({space:o,spaceData:e,classname:t}){let r=`[${Ei.name}]`;try{if(!o&&!e)throw new Error("either space or spaceData required (E: 4dabec34ee77d67c9cc30ee3c3049622)");if(o&&!o.data)throw new Error("(UNEXPECTED) given space has falsy space.data? (E: 058d298876ebbeada7bbddb9e3da2f23)");if(o&&e){if(o.data.uuid!==e.uuid)throw new Error("(UNEXPECTED) both space and spaceData given, but uuid don't match? (E: efdd4603cba93a17340a76811fe56b24)");if(o.data.n!==e.n)throw new Error("(UNEXPECTED) both space and spaceData given, but n don't match? (E: e51278a707c9bccc57a08a4b86524524)")}if(e??=o.data,!e)throw new Error("(UNEXPECTED) spaceData falsy? (thought this was a compiler problem that this was even possible.) (E: b3c7ffedcae4b1f45b263b3825930b24)");if(t&&e.classname&&t!==e.classname)throw new Error(`both classname arg (${t}) and spaceData.classname (${e.classname}) are different truthy values. (E: f98f012ee876eb8fbe7403f7b53e4624)`);if(t||=e.classname,!t)throw new Error("classname required (E: fa3af4613ad56742dab51d1b0d839322)");if(t.includes(" "))throw new Error(`invalid classname (${t}). cannot contain spaces (E: 243adbf720dcce7904e2665933208b22)`);let n=e?.name||Bn;if(n.includes(" "))throw new Error("invalid space name. cannot contain spaces (E: a8450e1651081412c8ac018520182422)");let a=e?.uuid||void 0;if(!a)throw new Error("invalid space, spaceData.uuid falsy (E: 50ae723a9ab24f4fc7132613e65faf23)");if(a.includes(" "))throw new Error("invalid space id. cannot contain spaces (E: 8696830fe7f54bfa85e670a063f3e089)");let s=e.type??void 0,i=e.subtype??void 0;if(s&&!i)throw new Error(`spaceType (${s}) is set but spaceSubtype is falsy. (E: 878ab960d7987ae2331103b4a00d0d24)`);return`${na} ${jn} ${t} ${n} ${a} ${s} ${i}`}catch(n){throw console.error(`${r} ${n.message}`),n}}h(Ei,"getSpaceIb");function Fh({ib:o}){let e=`[${Fh.name}]`;if(!o){let t=`${e} ib required (E: dd5244f62f964359a86e59bb08ee47e6)`;throw console.error(t),new Error(t)}return o.startsWith(`${na} ${jn} `)}h(Fh,"isSpaceIb");function da({spaceIb:o}){let e=`[${da.name}]`;try{if(!o)throw new Error("spaceIb required (E: fa5424cfb7e846e2851562f2f417944f)");let[t,r,n,a,s,i,c]=o.split(" ");if(t!==na)throw new Error(`invalid spaceIb (${o}). witnessAtom !== WITNESS_ATOM (E: 5ae1ca12cf8f30ae341f3e582b025224)`);if(r!==jn)throw new Error(`invalid spaceIb (${o}). spaceAtom !== SPACE_ATOM (E: 9cc6b6f30e13455eb29748148a94fa0f)`);if(!n)throw new Error(`invalid spaceIb (${o}). spaceClassname falsy (E: 00d3392da007ca8b2840b16b199d9a24)`);if(!a)throw new Error(`invalid spaceIb (${o}). spaceName falsy (E: b957d8e74ef34d889fa64c60c7a5ea0b)`);if(!s)throw new Error(`invalid spaceIb (${o}). spaceId falsy (E: 7a1773722d8e46a0866d683130b65b89)`);let l;if(i&&i!=="undefined")if(Zn.includes(i))l=i;else throw new Error(`invalid spaceIb (${o}). spaceType (${i}) is set but not a valid type. valid types: ${Zn.join(", ")} (E: 838f4638a88cfbf3545a3a3a38b6dd24)`);let d;if(c&&c!=="undefined")if(Qn.includes(c))d=c;else throw new Error(`invalid spaceIb (${o}). spaceSubtype (${c}) is set but not a valid subtype. valid subtypes: ${Qn.join(", ")} (E: 5bdcf23027f94e73860e4340313b04ab)`);return{spaceClassname:n,spaceName:a,spaceId:s,spaceType:l,spaceSubtype:d}}catch(t){throw console.error(`${e} ${t.message}`),t}}h(da,"parseSpaceIb");async function ve({ibGibs:o,addrs:e,tjps:t,tjpAddrs:r,space:n}){let a=`[${ve.name}]`;try{if(P&&console.log(`${a} starting...`),!n)throw new Error("space required. (E: 4d188d6c863246f28aa575753a052304)");if(o=o??[],e=e??[],t=t??[],r=r??[],e.length===0&&o.length===0&&t.length===0&&r.length===0)throw new Error("Either addrs, ibGibs, tjps, or tjpAddrs required. (E: 7c6ebfbab98d4d21a431b144457fd991)");let s=new Set(r.concat(t.map(l=>I({ibGib:l})))),i=Array.from(s).map(l=>K({ibGibAddr:l}).gib);o.map(l=>I({ibGib:l})).concat(e).forEach(l=>{let{gib:d}=K({ibGibAddr:l});i.some(b=>d.includes(b))||s.add(l)}),P&&console.log(`${a}[testing] ${n.data?.name||n.ib} (${n.data?.uuid||"[space.data.uuid falsy]"}) addrsToQuery: ${Array.from(s)} (I: 8a2202912c364238b6d6eb09577bc246)`);let c=await n.argy({ibMetadata:Tt({space:n}),argData:{cmd:"get",cmdModifiers:["latest","addrs"],ibGibAddrs:Array.from(s)}});return await n.witness(c)}catch(s){throw console.error(`${a} ${s.message}`),s}}h(ve,"getLatestAddrs");function wi({ibGib_Context:o}){let e=`[${wi.name}]`;try{if(P&&console.log(`${e} starting... (I: 5f583fd94d27731a65d514e731b8aa22)`),!Jo({ibGib:o}))return;if(["roots","autosyncs"].some(r=>o.ib.includes(r)))throw new Error("cannot perform a modification of this type on this special ibgib (E: b8fb718a7323fc54454464b973412722)")}catch(t){throw console.error(`${e} ${t.message}`),t}finally{P&&console.log(`${e} complete.`)}}h(wi,"throwIfContextIsSpecial");async function Bh({ibGib_Context:o,rel8nName_Context:e,addr:t,space:r,zeroSpace:n,fnUpdateBootstrap:a,fnBroadcast:s}){let i=`[${Bh.name}]`;try{if(P&&console.log(`${i} starting... (I: 2dc486bb2d516e4534f437aaf5ec7f22)`),!o)throw new Error("ibGib_Context required (E: 75f7bfa93145d6dffe85d488443ca722)");if(!e)throw new Error("rel8nName_Context required (E: 12aaa43de9e34b68b25dc9a2a68ad6b9)");if(!t)throw new Error("addr required (E: e27df3bdc5a2554697cc9597afc4e422)");if(!r)throw new Error("space required (E: 2e3562486ed2956a770ed9e8d77a3f22)");let c=Jo({ibGib:o});c&&wi({ibGib_Context:o});let l=await ie({src:o,rel8nsToAddByAddr:{[Sl]:[t]},rel8nsToRemoveByAddr:{[e]:[t]},dna:!0,nCounter:!0});if(await V({resTransform:l,space:r}),c){let d=I({ibGib:l.newIbGib}),f=ba({ib:o.ib}),b=Me({type:f});await Je({key:b,addr:d,space:r,zeroSpace:n,fnUpdateBootstrap:a})}await J({ibGib:l.newIbGib,fnBroadcast:s,space:r})}catch(c){throw console.error(`${i} ${c.message}`),c}finally{P&&console.log(`${i} complete.`)}}h(Bh,"trash");async function kh({ibGib_Context:o,rel8nName_Context:e,addr:t,space:r,zeroSpace:n,fnUpdateBootstrap:a,fnBroadcast:s}){let i=`[${kh.name}]`;try{if(P&&console.log(`${i} starting... (I: 38098552b830495187299bb24fcddff0)`),!o)throw new Error("ibGib_Context required (E: d819e8c4db5b4c0bb721300ba434cd40)");if(!e)throw new Error("rel8nName_Context required (E: de061adff8c04429a211aa09116a532d)");if(!t)throw new Error("addr required (E: 7059ebb8ef6149ea94e22f961d6b5c81)");if(!r)throw new Error("space required (E: e19566f2d42347798621447edcae312e)");let c=Jo({ibGib:o});c&&wi({ibGib_Context:o});let l=await ie({src:o,rel8nsToAddByAddr:{[Gl]:[t]},rel8nsToRemoveByAddr:{[e]:[t]},dna:!0,nCounter:!0});if(await V({resTransform:l,space:r}),c){let d=I({ibGib:l.newIbGib}),f=ba({ib:o.ib}),b=Me({type:f});await Je({key:b,addr:d,space:r,zeroSpace:n,fnUpdateBootstrap:a})}await J({ibGib:l.newIbGib,fnBroadcast:s,space:r})}catch(c){throw console.error(`${i} ${c.message}`),c}finally{P&&console.log(`${i} complete.`)}}h(kh,"archive");function fa(o){let e=`[${fa.name}]`;try{if(!o)return console.error(`${e} name is falsy`),!1;let t=/[\w~.-]+/,r=o.match(t);if(r?.length!==1||r[0].length!==o.length)return console.error(`${e} name can only contain letters, numbers, underscores, hyphens, dots, and tildes`),!1;let n=/[a-zA-Z\d]/;return o[0].match(n)?!0:(console.error(`${e} name must start with a letter or number`),!1)}catch(t){return console.error(`${e} ${t.message}`),!1}}h(fa,"spaceNameIsValid");var ge=!1;function ot(o,e){return typeof o=="object"&&o!==null?`v:1^spaceId:${o.spaceId}^${o.ibGibAddr}`:`v:1^spaceId:${o}^${e}`}h(ot,"getSpaceQualifiedIbGibAddr");function ha(o){try{if(typeof o!="string"||!o.match(Hn))return!1;let t=Jt({sqAddr:o});return!0}catch{return!1}}h(ha,"isSpaceQualifiedAddr");function Jt({sqAddr:o}){let e=`[${Jt.name}]`;if(!o)throw new Error(`${e} sqAddr falsy (E: 3c7af8b05a68272478e830c89b617d26)`);if(typeof o!="string")throw new Error(`(UNEXPECTED) ${e} sqAddr not a string? (E: 172fd36b0e7d02905263bdef1374da26)`);let t=o.match(Hn);if(!t)throw new Error(`${e} invalid sqAddr (${o}). does not match SQ Addr regexp: ${Hn.source} (E: 71c93b63d4a82970c3bada8d92d4f826)`);let r=t[1],n=parseInt(r,10),a=t[2],s=t[3],i=qt({addr:s})??[];if(i.length>0)throw new Error(`${e} invalid sqAddr. ibGibAddr part is not a valid ibGibAddr. errors: ${i.join(",")} (E: 8e105870eb58c78978169d1d7b275526)`);let{ib:c,gib:l}=K({ibGibAddr:s});return{version:n,spaceId:a,ibGibAddr:s,ib:c,gib:l}}h(Jt,"parseSpaceQualifiedIbGibAddr");async function Ai({ibGib:o,rel8nNames:e,space:t}){let r=`[${Ai.name}]`;try{if(!o)throw new Error("ibGib required (E: 9764881f4c59113a98faabb87aba5826)");if(!t)throw new Error("space required (E: ee110894949865a8a9075938471e1826)");e||(e=Object.keys(o.rel8ns||{}));let n={};for(let a of e){let s=o.rel8ns?.[a]||[];if(s.length>0){let i=await z({addrs:s,space:t});if(i.success&&i.ibGibs?.length===s.length)n[a]=i.ibGibs.concat();else throw new Error(`Problem getting rel8d ibgibs for rel8nName: ${a}. ${i.errorMsg||"Unknown error"} (E: 372b27ed859ca276fe132e7cd3cd1826)`)}else n[a]=[]}return n}catch(n){throw console.error(`${r} ${E(n)}`),n}}h(Ai,"getRel8dIbGibs");async function _t({parentPrimitiveIb:o,ib:e,ibRegExpPattern:t,data:r,rel8ns:n}){let a=`[${_t.name}]`;try{if(!o)throw new Error("parentPrimitiveIb required. (E: 88ddf188cc5a4340b597abefba1481e2)");if(cr({ib:o})!==null)throw new Error(`Invalid parentPrimitiveIb: ${o}. (E:5aec0320956d492ebeeaca41eb1fe1c6)`);if(!e)throw new Error("ib required. (E: 7bbc88f4f2e842d6b00126e55b1783e4)");let s=t?new RegExp(t):gl;if(!e.match(s))throw new Error(`invalid ib. does not match regexp (${s})`);let i=Object.keys(n??{}),c=[...sr,"tjp"];if(i.some(b=>c.includes(b)))throw new Error(`Invalid rel8ns. forbiddenRel8nNames: ${c}. rel8ns keys: ${Object.keys(n??{})}. (E: 837a993c265c4362b6aa0b1a234ea5f8)`);let f=(await H.firstGen({ib:e,parentIbGib:H.primitive({ib:o}),data:r,rel8ns:n,dna:!1,noTimestamp:!0,nCounter:!1})).newIbGib;return f?.rel8ns?.past&&delete f.rel8ns.past,f?.rel8ns?.tjp&&delete f.rel8ns.tjp,f?.rel8ns?.identity&&delete f.rel8ns.identity,f.gib=await ee({ibGib:{ib:f.ib,data:f.data,rel8ns:f.rel8ns},hasTjp:!1}),f}catch(s){throw console.error(`${a} ${s.message}`),s}}h(_t,"constantIbGib");function pa({binHash:o,binExt:e,binEncoding:t}){return t?e?`bin ${o} ${e} enc=${t}`:`bin ${o} enc=${t}`:e?`bin ${o} ${e}`:`bin ${o}`}h(pa,"getBinIb");function Bw({addr:o}){return ud({addr:o})}h(Bw,"getBinHashAndExt");function ud({addr:o}){let e=`[${ud.name}]`;try{if(!Wo({addr:o}))throw new Error("not a bin address (E: df0804d129bc4888bd6939cb76c5e0f6)");let{ib:t}=K({ibGibAddr:o}),r=t.split(" ");if(r.length===2)return{binHash:r[1],binExt:""};if(r.length===3)return r[2].startsWith("enc=")?{binHash:r[1],binExt:"",binEncoding:r[2].substring(4)}:{binHash:r[1],binExt:r[2]};if(r.length===4){if(!r[3].startsWith("enc="))throw new Error(`bin ib (${t}) has 4 space-delimited pieces. we expect therefore the form to be bin \${binHash} \${binExt} enc=\${binEncoding}. but ibPieces[3] doesn't start with "enc=". (E: 87196d7cdd7c12d982cc8204a1163524)`);return{binHash:r[1],binExt:r[2],binEncoding:r[3].substring(4)}}else throw new Error('(UNEXPECTED) ibPieces.length not 2, 3, or 4? atow (01/2024) the only components of a bin ib are: atom, binHash, binExt, binEncoding. binExt and binEncoding are optional, with binEncoding being prefixed with "enc=". (E: b05df3c1b3949f76464a83c9fd1c4f24)')}catch(t){throw console.error(`${e} ${t.message}`),t}}h(ud,"parseBinIb");function Wo({ibGib:o,addr:e}){let t=`[${Wo.name}]`;try{if(!o&&!e)throw new Error("either ibGib or addr required. (E: c935b51e773f41a2a547c556e9dc16c6)");if(o&&!o.data)return!1;e=e||I({ibGib:o});let{ib:r,gib:n}=K({ibGibAddr:e});if(!r||!n||!r.startsWith("bin "))return!1;if(n.length!==64)throw new Error('ib starts with "bin " but gib length is not 64, so return false. Two things: 1) bin ibgibs are expected to be stones, i.e., have no temporal junction point and only a single punctiliar hash for the gib. the default hash used atow (01/2024) is sha-256, so the length should be 64. But this may not be true if using another hash algorithm. need to change this function when this becomes the case. (W: 60725d65d13c4b4fbb7b96d7feb19d67)');let a=r.split(" ");if(a.length===2){if(!a[1].match(Ie))throw new Error('(UNEXPECTED) ib starts with "bin " but space-delimited !ibPieces[1].match(UUID_REGEXP)? (E: f6baca2ff155f1017b278a5d7597a224)')}else if(a.length===3){if(!a[1].match(Ie))throw new Error('(UNEXPECTED) ib starts with "bin " but space-delimited !ibPieces[1].match(UUID_REGEXP)? (E: 8d0443d6cada4b50be79a8390a7a426c)')}else if(a.length===4){if(!a[1].match(Ie))throw new Error('(UNEXPECTED) ib starts with "bin " but space-delimited !ibPieces[1].match(UUID_REGEXP)? (E: 3209eacc0a3848a59593d4c3ee956191)');if(!a[3].startsWith("enc="))throw new Error('(UNEXPECTED) ib starts with "bin " but space-delimited !ibPieces[3].startsWith("enc=")? (E: 4c8a0c3b07a90d30e3d1a4373d57d824)')}else throw new Error('(UNEXPECTED) ib starts with "bin " but space-delimited ibPieces length is not 2, 3 or 4? (E: c7eccf88518304997c7e42b32e08d224)');return!0}catch(r){throw console.error(`${t} ${r.message}`),r}}h(Wo,"isBinary");function yi({type:o}){if(!o.match(Js))throw new Error(`special ibgib type must not have spaces and just be alphanumerics. regexp: ${Js.source} (E: 6c1c92521b7f076cc4666e4915593723)`);return`meta special ${o}`}h(yi,"getSpecialIbGibIb");function ba({ib:o}){let e=`[${ba.name}]`;try{if(ge&&console.log(`${e} starting... (I: c82ba222bd345ee6b695df4d63a23322)`),!o)throw new Error("ib required (E: 08897145f7138e644fe01c4a59353322)");if(!Jo({ib:o}))throw new Error("ib is not special (E: 174aff63b992adff3ac2394643735922)");let t=o.split(" ");if(t.length<3)throw new Error('invalid ib. should be space-delimited in form of "meta special [type]" (E: ffd89e2cbe63427f98634ab897aab222)');let r=t[2];return Object.values(jo).some(n=>n===r)||console.warn(`unknown special type (${r}). This may be expected, but atow I am adding special types to the SpecialIbGibType enum-like. (W: f4e26c3ebb57fe49d69014a4ba32a922)`),r}catch(t){throw console.error(`${e} ${t.message}`),t}finally{ge&&console.log(`${e} complete.`)}}h(ba,"getSpecialTypeFromIb");function jh({type:o}){return`${yi({type:o})}^${Q}`}h(jh,"getSpecialIbGibAddr");function Me({type:o}){return`${Cl} ${jh({type:o})}`}h(Me,"getSpecialConfigKey");function Jo({ib:o,ibGib:e}){if(!o&&!e?.ib)throw new Error("either ib or ibGib.ib required (E: b4cf539638d7966c2e351987f55e1a23)");return(o??e?.ib)?.startsWith("meta special")}h(Jo,"isSpecial");function $i(o){let e=`[${$i.name}]`;if(!o)throw new Error(`${e} text required.`);return`root ${o}`}h($i,"getRootIb");function Or(o){let e=`[${Or.name}]`;if(!o)throw new Error(`${e} tag required.`);return`tag ${o}`}h(Or,"tagTextToIb");function nt({ibGibs:o,filterPrimitives:e}){let t=`[${nt.name}]`;try{let r={},n={},a={};return(e?o.filter(i=>i.gib??i.gib!==Q):o).forEach(i=>{md({ibGib:i})?(i.rel8ns?.dna??[]).length>0?r[i.gib]=i:n[i.gib]=i:a[i.gib]=i}),{mapWithTjp_YesDna:r,mapWithTjp_NoDna:n,mapWithoutTjps:a}}catch(r){throw console.error(`${t} ${r.message}`),r}}h(nt,"splitPerTjpAndOrDna");function at({ibGibs:o}){let e=`[${at.name}]`;try{ge&&console.log(`${e} starting...`);let{mapWithTjp_YesDna:t,mapWithTjp_NoDna:r}=nt({ibGibs:o,filterPrimitives:!0}),n={...t,...r},a=Object.values(n),s=Uo({items:a,keyFn:h(i=>i.data?.isTjp?I({ibGib:i}):i.rel8ns?.tjp?i.rel8ns?.tjp[0]??"":(ge&&console.log(`${e} neither isTjp nor x.rel8ns.tjp truthy (I: ec9a5597bf53dec1bd3d83350abbf823)`),""),"keyFn")});return ge&&console.log(`${e} sorting (ascending) ibGibsWithTjpGroupedByTjpAddr: ${X(s)} (I: 9b9fff5ce61444a6cb06d62db9a99422)`),Object.entries(s).forEach(([i,c])=>{c.some(l=>l.data?.n===void 0)&&console.warn(`${e} timeline includes ibgibs with ibGib.data?.n === undefined (W: cab9a6b64a38c4279fe82c3569bbab22)`),c.sort((l,d)=>(l.data?.n??-1)>(d.data?.n??-1)?1:-1)}),ge&&console.log(`${e} after sort ibGibsWithTjpGroupedByTjpAddr: ${X(s)} (I: 9b9fff5ce61444a6cb06d62db9a99422)`),s}catch(t){throw console.error(`${e} ${t.message}`),t}finally{ge&&console.log(`${e} complete.`)}}h(at,"getTimelinesGroupedByTjp");function md({ibGib:o}){let e=`[${md.name}]`;if(!o)throw new Error("(UNEXPECTED) ibGib falsy? (E: ce3a59f9db14e6158bb2c438ca1a3823)");if((o.rel8ns?.tjp?.length??0)>0||o.data?.isTjp)return!0;let t=["fork^gib","mut8^gib","rel8^gib"];return(o.rel8ns?.ancestor??[]).some(n=>t.includes(n))?!1:o.gib?o.gib.includes(vt)?!0:o.gib===Q?!1:!!Ne({ibGibAddr:I({ibGib:o})}).tjpGib:(console.warn(`${e} ibGib.gib falsy. (W: 6400d780822b44d992846f1196509be3)`),!1)}h(md,"hasTjp");function ye({ibGib:o,defaultIfNone:e="undefined"}){let t=`[${ye.name}]`;try{let r=gd({ibGibs:[o],defaultIfNone:e});return r&&Object.keys(r).length===1?Object.values(r)[0]:void 0}catch(r){throw console.error(`${t} ${r.message}`),r}}h(ye,"getTjpAddr");function gd({ibGibs:o,defaultIfNone:e="undefined"}){let t=`[${gd.name}]`;try{let r={};return o.forEach(n=>{let a=I({ibGib:n}),s;n.rel8ns?.tjp?.length??!1?s=n.rel8ns.tjp[n.rel8ns.tjp.length-1]:n.data?.isTjp||e==="incomingAddr"?s=a:s=void 0,r[a]=s}),r}catch(r){throw console.error(`${t} ${r.message}`),r}}h(gd,"getTjpAddrs");async function Ii({ibGib:o,naive:e=!0}){let t=`[${Ii.name}]`;try{if(!o)throw new Error("ibGib required.");if(e){if(o.data)return o.data.isTjp?!0:o.rel8ns?o.rel8ns.past&&o.rel8ns.past.length>0?!1:!!(o.rel8ns.past&&o.rel8ns.past.length===0):(ge&&console.log(`${t} ibGib.rel8ns falsy (I: c69c9e78b34845311ce7c674d7195622)`),!1);throw new Error("loaded ibGib required (data).")}else throw new Error("only naive implemented right now.")}catch(r){throw console.error(`${t} ${r.message}`),r}}h(Ii,"isTjp_Naive");function Fe({ibGib:o}){let e=`[${Fe.name}]`;o.ib||console.warn(`${e} ibGib.ib is falsy. (W: e60e41c2a1fc48268379d88ce13cb77b)`),o.gib||console.warn(`${e} ibGib.gib is falsy. (W: fb3889cbf0684ae4ac51e48f28570377)`);let t={ib:(o.ib||"").slice()};return o.gib&&(t.gib=o.gib.slice()),o.data&&(Wo({ibGib:o})?t.data=o.data.slice():t.data=B(o.data)),o.rel8ns&&(t.rel8ns=B(o.rel8ns)),t}h(Fe,"toDto");function Lr(o){let e=`[${Lr.name}]`;try{return ge&&console.log(`${e} starting... (I: 57aef93fc6cc2309523b5c72a6b11823)`),!!o&&typeof o.ib=="string"}catch(t){throw console.error(`${e} ${t.message}`),t}finally{ge&&console.log(`${e} complete.`)}}h(Lr,"isIbGib");function hr({ibGib:o,data:e,timestamp:t}){let r=`[${hr.name}]`;try{ge&&console.log(`${r} starting... (I: 35cb68744bcf6139d78e37de644fad23)`),t=t||e?.timestamp||o?.data?.timestamp;let n=o?.data?.timestampMs||e?.timestampMs;if(!t){let a=`${r} timestamp is falsy. (W: 5f1f1182c8804807b886a3d922ac3dcf)`;return console.warn(a),{valid:!1,emsg:a}}if(typeof t=="string")if(Number.isInteger(Number.parseInt(t))){let a=Number.parseInt(t),s=new Date;if(s.setTime(a),s.toString()!==Xn)return ge&&console.log(`${r} valid timestampInTicks string (I: 7069a1c3047f3bbc92b78674b20f5b23)`),{valid:!0,date:s,utc:s.toUTCString(),ticks:s.getTime().toString(),ms:n};{let i=`${r} data.timestamp (${t}) is an integer string but not a valid timestampInTicks string. (produces invalid date) (E: f49fbb600fe1426c8805dfc8afbe5cf3)`;return console.error(i),{valid:!1,emsg:i}}}else{let a=new Date(t);if(a.toString()!==Xn)return{valid:!0,date:a,utc:a.toUTCString(),ticks:a.getTime().toString(),ms:n};{let s=`${r} data.timestamp is a non-integer string but not a valid date timestamp string (new date instantiated produces invalid date). (W: c6c90f7f3bfb49838d2081ba84fdb5fb)`;return console.warn(s),{valid:!1,emsg:s}}}else if(typeof t=="number")if(Number.isInteger(t)){console.warn(`${r} expected data.timestamp to be a string but is a number (W: 9d786f4d4e8d4279b5af7bee19bf721b)`);let a=new Date;if(a.setTime(t),a.toString()!==Xn)return{valid:!0,date:a,utc:a.toUTCString(),ticks:a.getTime().toString(),ms:n};{let s=`${r} timestamp (${t}) is an integer number but not a valid timestampInTicks (new date setTime produces invalid date). (W: c6c90f7f3bfb49838d2081ba84fdb5fb)`;return console.warn(s),{valid:!1,emsg:s}}}else{let a=`${r} timestamp (${t}) is a non-integer number (supposed to be a string either timestamp string or ticks). (E: 2963d95f8d3b464c992b0bff948b4479)`;return console.error(a),{valid:!1,emsg:a}}else{let a=`${r} unknown typeof timestamp (${typeof t}). (E: 12458a9c16c84e4f859b5771a30dd2ef)`;return console.error(a),{valid:!1,emsg:a}}}catch(n){throw console.error(`${r} ${E(n)}`),n}finally{ge&&console.log(`${r} complete.`)}}h(hr,"getTimestampInfo");async function Ve({addrs:o,readCache_graph:e,readCache_array:t,space:r}){let n=`[${Ve.name}]`;try{ge&&console.log(`${n} starting... (I: 5db66871239dfa05182277f886a20926)`),e??={},t??=[];let a={...e};t.forEach(l=>a[I({ibGib:l})]=l);let s=Object.keys(e),i=o.filter(l=>!s.includes(l));if(i.length>0){ge&&console.log(`${n} ${i.length} addrsNotFoundInCache: ${i} (I: fccbd18116ffb849f813aaebfc6c0826)`);let l=[r],d=i.concat();for(let f of l){let b=await z({addrs:d,space:f});if(b.success&&b.ibGibs&&b.ibGibs.length===d.length)b.ibGibs.forEach(p=>a[I({ibGib:p})]=p),d=[];else if(b.ibGibs&&b.ibGibs.length>0){if(d=d.filter(p=>!b.ibGibs.some(u=>I({ibGib:u})===p)),d.length===0)break}else ge&&console.log(`${n} no addrs found in space (${f.ib}). trying next space. (I: 4f99d8bacbb10ab3f8737a752564b326)`)}if(d.length>0)throw new Error(`could not get all addrs from cache or spaces. addrsStillNotFound: ${d}. spaces: ${l.map(f=>f.ib).join("|")} (E: 0c6418f83dd85bda886e56f5b98f3126)`)}let c=[];for(let l of o){let d=a[l];if(!d)throw new Error(`(UNEXPECTED) allIbGibs_graph doesn't have addr? We're expecting logic to preclude this at this point. addr: ${l} (E: f68e1d236ae5e3eb08da9933c8230626)`);c.push(d)}return c}catch(a){throw console.error(`${n} ${E(a)}`),a}finally{ge&&console.log(`${n} complete.`)}}h(Ve,"getIbGibsFromCache_fallbackToSpaces");async function ae({addr:o,space:e,metaspace:t}){let r=`[${ae.name}]`;try{if(ge&&console.log(`${r} starting... (I: 9252059c96132637381b3be5486e6826)`),!o)throw new Error("(UNEXPECTED) addr falsy? (E: aeb9084d7f68dabb8a49fd68526ff826)");if(!e)throw new Error("(UNEXPECTED) space falsy? (E: 3ec9df4de82847e13f087bea6f98b826)");let n=ha(o)?Jt({sqAddr:o}).ibGibAddr:o,a=qt({addr:n})??[];if(a.length>0)throw new Error(`invalid incoming addr (${o}). (if space-qualified, then invalid extracted ibGibAddr). errors: ${a.join(", ")} (E: 040dbbcac39990abc8871a1d08b3d826)`);let s;try{let i=await z({space:e,addrs:[n]});if(!i.success||i.errorMsg)throw new Error(`resGet failed. resGet.success: ${i.success}.errorMsg: ${i.errorMsg} (E: 13f3d82381b87f8078583ad8b3676826)`);if(!i.ibGibs)throw new Error("(UNEXPECTED) resGet.success and no errorMsg, but resGet.ibGibs falsy? (E: f3a75e6fe96b07d288ba9b3976e84826)");if(i.ibGibs.length===0)throw new Error("(UNEXPECTED) resGet.success and no errorMsg, but resGet.ibGibs empty? (E: 4a06589d30050208284fef68adf20426)");if(i.ibGibs.length>1)throw new Error("(UNEXPECTED) resGet.success and no errorMsg, but resGet.ibGibs.length > 1? what in the world? (E: a4d01caa4a78a0a1581b3bb8748af826)");s=i.ibGibs[0]}catch(i){ge&&console.log(`${r} suppressing error: ${E(i)} (I: 1256ce73d8e8b567ff4fee4ea48c5d26)`)}return s}catch(n){throw console.error(`${r} ${E(n)}`),n}finally{ge&&console.log(`${r} complete.`)}}h(ae,"getIbGibFromSpace");async function st({addrs:o,space:e}){let t=`[${st.name}]`;try{if(ge&&console.log(`${t} starting... (I: 648eb9b61718fbc1684aabc60cba6826)`),!o)throw new Error("(UNEXPECTED) addrs falsy? (E: 258e489345f1c4b5794e4618f4118c26)");if(!e)throw new Error("(UNEXPECTED) space falsy? (E: 9cb95bc39b41c1756c6e85384f766a26)");if(o.length===0)return[];let r=o.map(i=>ha(i)?Jt({sqAddr:i}).ibGibAddr:i);for(let i of r){let c=qt({addr:i})??[];if(c.length>0)throw new Error(`invalid incoming addr (${i}). errors: ${c.join(", ")} (E: 1674df15579c46cecd035ff637f41426)`)}let n=await z({space:e,addrs:r});if(!n.success||n.errorMsg)throw new Error(`resGet failed. resGet.success: ${n.success}. errorMsg: ${n.errorMsg} (E: 1a4c08eabeb957f388a79d7b42b60b26)`);if(!n.ibGibs||n.ibGibs.length!==r.length){let c=n.rawResultIbGib?.data?.addrsNotFound??"unknown";throw new Error(`couldn't find all addrs. addrsNotFound: ${c}? resGet.errorMsg: ${n.errorMsg} (E: 5ee272792fe8af335a8fd918c0971a26)`)}let a=new Map;for(let i of n.ibGibs||[]){let c=I({ibGib:i});a.set(c,i)}let s=[];for(let i of r){let c=a.get(i);c&&s.push(c)}return s}catch(r){throw console.error(`${t} ${E(r)}`),r}finally{ge&&console.log(`${t} complete.`)}}h(st,"getIbGibsFromSpace");async function ua({ibGib:o,space:e}){let t=`[${ua.name}]`;try{ge&&console.log(`${t} starting... (I: 64f6a8bd1248f8c3c8c86834431adb26)`);let r=I({ibGib:o}),n=ye({ibGib:o,defaultIfNone:"undefined"});if(!n)return ge&&console.log(`${t} tjpAddr falsy. returning incoming ibGib (no timeline means no latest tip possible) (I: 621528e00b6988f0abb8a161e7042226)`),o;let a=await ve({ibGibs:[o],space:e});if(!a)throw new Error("(UNEXPECTED) resLatest falsy? (E: 8ce878315ec4020c082ee7796084b826)");if(!a.data)throw new Error("(UNEXPECTED) resLatest.data falsy? (E: 3af5a84dd1eba399fcca51e179b36826)");if(!a.data.latestAddrsMap)throw new Error("(UNEXPECTED) resLatest.data.latestAddrsMap falsy? (E: 37276c35ae58f65cb674389343c2fc26)");let{latestAddrsMap:s}=a.data,i=s[r]??s[n]??r;if(i&&i!==r){let c=await ae({addr:i,space:e});if(c&&(c.data?.n??0)>=(o.data?.n??0))return c;console.warn(`${t} did not find latest. using incoming ibGib (W: 1079fd20b9183fc8a8fef55a8ad2d826)`)}return o}catch(r){throw console.error(`${t} ${E(r)}`),r}finally{ge&&console.log(`${t} complete.`)}}h(ua,"resolveLatestIbGibInSpace");async function ma({ibGibs:o,space:e}){let t=`[${ma.name}]`;try{if(ge&&console.log(`${t} starting... (I: 8b0c418702fb42a6a12ee0153833f426)`),!e)throw new Error("space required. (E: b65c19273c524e9389271630af220926)");if(!o||o.length===0)return[];let r=[],n=[],a=[];for(let b of o){let p=I({ibGib:b}),u=ye({ibGib:b,defaultIfNone:"undefined"});n.push(p),a.push(u||""),u&&r.push(b)}if(r.length===0)return o;let s=await ve({ibGibs:r,space:e});if(!s||!s.data||!s.data.latestAddrsMap)throw new Error("(UNEXPECTED) resLatest or latestAddrsMap falsy? (E: a951d3820ff541c88ba46f7725902126)");let{latestAddrsMap:i}=s.data,c=[],l=[];for(let b=0;b<o.length;b++){let p=n[b],u=a[b],m=i[p]??i[u]??p;l.push(m),m&&m!==p&&c.push(m)}let d=new Map;if(c.length>0){let b=Array.from(new Set(c)),p=await st({addrs:b,space:e});for(let u of p){let m=I({ibGib:u});d.set(m,u)}}let f=[];for(let b=0;b<o.length;b++){let p=o[b],u=l[b];if(u&&u!==n[b]){let m=d.get(u);if(m&&(m.data?.n??0)>=(p.data?.n??0)){f.push(m);continue}}f.push(p)}return f}catch(r){throw console.error(`${t} ${E(r)}`),r}finally{ge&&console.log(`${t} complete.`)}}h(ma,"resolveLatestIbGibsInSpace");var Ed=!1,qh="space_gib_db",Xh="space_gib_store",Hh="space_gib_api_key";var Vh="agent";var Hw=Or(Vh);var Vw={dbName:qh,storeName:Xh,additionalStoreNames:[Fn],apiKeyName:Hh};var wd="0.0.35";var pr=!1,zw="[web^gib timer]",ga="ibgib";var Wh="agent",Jw="body-outline",Zw="This tag tracks the active agents for the current local user space.",Qw=Or(Wh),yd="#78f87e88",$d="#78f87e10",Id="#ffffff";var e2="AUTOMATED_TEXT";var Gt=!1;function Ad(o){return new Promise((e,t)=>{let r=new Blob([o],{type:"application/octet-stream"}),n=new FileReader;n.onload=()=>{let s=n.result.split(",")[1];e(s)},n.onerror=a=>t(a),n.readAsDataURL(r)})}h(Ad,"uint8ArrayToBase64");async function _d(o){let e=`data:application/octet-stream;base64,${o}`,n=await(await(await fetch(e)).blob()).arrayBuffer();return new Uint8Array(n)}h(_d,"base64ToUint8Array");async function Ea({graph:o}){let e=`[${Ea.name}]`;try{Gt&&console.log(`${e} starting... (I: 4ddb8803cf68e1d3d35f60680cb69825)`);let t=JSON.parse(JSON.stringify(o));for(let n in t)o[n].data instanceof Uint8Array&&(t[n].data={_dataType:"Uint8Array_Base64",value:await Ad(o[n].data)});let r=JSON.stringify(t);return Gt&&console.log(`${e} jsonString.length: ${r.length} (I: 56dec8ad0931ab8ba9b5ca3d4e66be25)`),r}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Gt&&console.log(`${e} complete.`)}}h(Ea,"serializeGraphToString");async function wa({jsonString:o}){let e=`[${wa.name}]`;try{Gt&&console.log(`${e} starting... (I: 52e1a1fb1adcc75168fbc6d819868825)`);let r=JSON.parse(o,h((n,a)=>(a&&a._dataType==="Uint8Array_Base64",a),"reviver"));for(let n in r){let a=r[n].data;a&&a._dataType==="Uint8Array_Base64"&&(r[n].data=await _d(a.value))}return r}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Gt&&console.log(`${e} complete.`)}}h(wa,"deserializeStringToGraph");async function Td(o){let e=`[${Td.name}]`;try{Gt&&console.log(`${e} starting... (I: 8d306868b718596fe8f562bd5118d825)`);let t=await Ea({graph:o}),r=new TextEncoder().encode(t),a=new Response(r).body.pipeThrough(new CompressionStream("gzip"));return await new Response(a).blob()}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Gt&&console.log(`${e} complete.`)}}h(Td,"compressIbGibToBlob");async function Yh(o){let e=o.stream().pipeThrough(new DecompressionStream("gzip")),t=await new Response(e).text();return await wa({jsonString:t})}h(Yh,"decompressIbGibFromBlob");async function _i({graph:o}){let e=`[${_i.name}]`;try{Gt&&console.log(`${e} starting... (I: 1352f8540c08f0b725952df8f18c4825)`);let r=await(await Td(o)).arrayBuffer(),n=new Uint8Array(r);return await Ad(n)}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Gt&&console.log(`${e} complete.`)}}h(_i,"compressIbGibGraphToString");async function Ti({compressedBase64:o}){let e=`[${Ti.name}]`;try{Gt&&console.log(`${e} starting... (I: 5f3fa940a2c8f8d7b877978ae7f87825)`);let t=await _d(o),r=new Blob([t],{type:"application/gzip"});return await Yh(r)}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Gt&&console.log(`${e} complete.`)}}h(Ti,"decompressIbGibGraphFromString");var Gd="export";var Zo=!1;function Sd({data:o}){let e=`[${Sd.name}]`;try{Zo&&console.log(`${e} starting... (I: 158dfaeb9613a1531be71a9735184624)`);let{graphSize:t,dependencyGraphAsString:r,timestamp:n}=o,a=r.length,s=ft(n),i=o.compression==="gzip"?"gzip":"raw";if(!o.timestamp)throw new Error("(UNEXPECTED) data.timestamp falsy? (E: 2f5bc88488cbf260634239a8a8396825)");let c=new Date(o.timestamp),{ib:l,gib:d}=K({ibGibAddr:o.contextIbGibAddr}),b=Ne({gib:d}).tjpGib??d,p=c.toISOString().slice(0,19).replace("T","_").replace(/:/g,"").replace(/ /g,"_");return`${Gd} ${p} ${i} ${t} ${a} ${b}`}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Zo&&console.log(`${e} complete.`)}}h(Sd,"getRawExportIb");async function Gi({ibGib:o,metaspace:e,space:t,compress:r,live:n,ignoreErrors:a}){let s=`[${Gi.name}]`;try{if(Zo&&console.log(`${s} starting... (I: 0b6ba8608ba8bde0682a0936b9a01825)`),!o)throw new Error("(UNEXPECTED) ibGib falsy? (E: d2898eea744360865f0da5fb91baae22)");let i=I({ibGib:o}),c=[],l=await ne({ibGib:o})??[];if(l.length>0){let y=`ibGib had validation errors: ${l} (E: 84890bbc0598192498178a98ae299825)`;if(a)c.push({errorMsg:y,ibGibAddr:i});else throw new Error(y)}let d=await e.getDependencyGraph({ibGib:o,live:n,space:t}),f=r?await _i({graph:d}):await Ea({graph:d}),b=ye({ibGib:o,defaultIfNone:"incomingAddr"})??i,p=new Date,u={contextIbGibAddr:i,tjpAddr:b,dependencyGraphAsString:f,graphSize:Object.keys(d).length,timestamp:rt(p),timestampMs:p.getMilliseconds()};r&&(u.compression="gzip");let m={ib:Sd({data:u}),data:u},g=await ee({ibGib:m,hasTjp:!1});return m.gib=g,Zo&&console.log(`${s} JSON.stringify(exportIbGib).length: ${JSON.stringify(m).length} (I: db3a8d913a91d8fc5d6e45981e034822)`),{rawExportIbGib:m,manifest:Object.keys(d),errors:c.length>0?c:void 0}}catch(i){throw console.error(`${s} ${E(i)}`),i}finally{Zo&&console.log(`${s} complete.`)}}h(Gi,"getRawExportIbGib");var g2="ibgib-shell-ready",E2="ibgib-ui-busy",w2="ibgib-ui-message",y2="ibgib-identity-request-change",$2="ibgib-identity-changed",I2="ibgib-identity-update-available",A2="ibgib-identity-renewal-required",_2="show-identity-manager",T2="show-keystone-creator",G2="show-add-device",S2="show-privacy-policy";var xd=pr;async function ur({title:o,msg:e,prompt:t,showInput:r,defaultValue:n,okButtonTitle:a,cancelButtonTitle:s,isPassword:i,isBusy:c,animationEmoji:l,passkeys:d,passkeyButtonTitle:f,onPasskeyAuth:b}){let p=`[${ur.name}]`;try{xd&&console.log(`${p} starting... (I: 037b228a2568181cd3eb25dba4e03225)`);let u=document.getElementById("fullscreen-dialog"),m=document.getElementById("fullscreen-dialog-body"),g=document.getElementById("fullscreen-dialog-title"),y=document.getElementById("fullscreen-dialog-message"),w=document.getElementById("fullscreen-dialog-prompt-input"),A=document.getElementById("fullscreen-dialog-ok-button"),G=document.getElementById("fullscreen-dialog-cancel-button");if(!u||!m||!g||!y||!w||!A||!G)throw new Error("(UNEXPECTED) One or more dialog elements not found in DOM (E: 578e37c0271cc57a99e95e780ad18a25)");if(g.textContent=o||"",[...y.childNodes].forEach(x=>y.removeChild(x)),(e||"").split(`
|
|
8
|
+
latestAddr: ${g} (W: 141b69dc3c414efc9645bb76fcf12df9)`)}return p}catch(d){let f=`${l} ${d.message}`;return f.includes("d8ebdc9eaaa640b99cd206f132962c93")&&c||console.error(f),null}}h(ia,"getSpecialIbGib");async function ca({key:o,space:e,dontWarn:t}){let r=`[${ca.name}](${o})`;try{if(P&&console.log(`${r} getting... (I: 43e7bfc2515d45e5af8767b9a85b248e)`),!e)throw new Error("space required. (E: 4f135d4276e64054ba21aeb9c304ecec)");if(!e.rel8ns){(P||!t)&&console.warn(`${r} space.rel8ns falsy. (W: 7c642259fbf547dbaa1b2fdf0115f6ef)`);return}if(!e.rel8ns[o]){(P||!t)&&console.warn(`${r} space.rel8ns[${o}] falsy. (W: 3c1c49b9987b45cc96dd78b808f98e91)`);return}if(e.rel8ns[o].length===1)return P&&console.log(`${r} got (I: f13e71b693d5404c9535bda8ff0cc6a9)`),e.rel8ns[o][0];if(e.rel8ns[o].length>1)return(P||!t)&&console.warn(`${r} more than one config addr with ${o} rel8n. (W: 102f63eb74904bcfaac2eaf778043205)`),e.rel8ns[o][0];P&&console.log(`${r} didn't find (I: 1163e6ac60194d25b3f24881650edfad)`);return}catch(n){console.error(`${r} ${n.message}`);return}}h(ca,"getConfigAddr");async function Je({key:o,addr:e,space:t,zeroSpace:r,fnUpdateBootstrap:n}){let a=`[${Je.name}]`;try{if(!t)throw new Error("space required. (E: c28b663c991d44419aef1026cc689636)");if(!r)throw new Error("zeroSpace required. (E: d3707ae5265d464891ad216f64be6184)");let s={[o]:[e]},i=await ie({src:t.toIbGibDto(),dna:!1,linkedRel8ns:["past","ancestor",o],rel8nsToAddByAddr:s,nCounter:!0});if(!i.newIbGib)throw new Error("create new space failed.");await V({resTransform:i,space:r}),await V({resTransform:i,space:t});let c=i.newIbGib;return await t.loadIbGibDto(c),n?await n(c):console.warn(`${a} fnUpdateBootstrap is falsy. (W: 9fb874de2b19454dac18645e61ac463f)`),c}catch(s){throw console.error(`${a} ${s.message}`),s}}h(Je,"setConfigAddr");async function Jl({space:o}){let e=`[${Jl.name}]`;try{if(!o)throw new Error("space required. (E: f0d546101fba4c169256158114ab3c56)");let t=await ia({type:"roots",space:o});if(!t)throw new Error("Roots not initialized. (E: 89b1ba12ed12416aac41cef9fdaf1fc2)");if(!t.rel8ns)throw new Error("Roots not initialized properly. No rel8ns. (E: 8513a07cf530484db9521a2a3a27b7f6)");if(!t.rel8ns.current)throw new Error("Roots not initialized properly. No current root. (E: 459c3a007a30486d96fb8d83f696e239)");if(t.rel8ns.current.length===0)throw new Error("Invalid Roots: empty current root rel8n. (E: bede5864090440bca01ea7ab7fd107d6)");if(t.rel8ns.current.length>1)throw new Error("Invalid Roots: multiple current roots selected. (E: 97561acbf63a48ecaa037697bd26555a)");let r=t.rel8ns.current[0],n=await z({addr:r,space:o});if(n.ibGibs?.length===1)return n.ibGibs[0];throw new Error(`could not get current root. addr: ${r}`)}catch(t){console.error(`${e} ${t.message}`);return}}h(Jl,"getCurrentRoot");async function ui({root:o,space:e,zeroSpace:t,fnUpdateBootstrap:r,fnBroadcast:n}){let a=`[${ui.name}]`;try{if(P&&console.log(`${a} starting... (I: 7f16e845a80fe95d28923e4170f0c825)`),!o)throw new Error("root required.");if(!e)throw new Error("space required. (E: 186af2731c5342a78b063a0a4346f3db)");let s=I({ibGib:o}),i=await ia({type:"roots",space:e});if(!i)throw new Error("Roots not initialized. (E: a8232b9afac89d0d189534480b7a9825)");let l=await ie({src:i,dna:!1,linkedRel8ns:["past","ancestor","current"],rel8nsToAddByAddr:{current:[s]},nCounter:!0});await V({resTransform:l,space:e});let d=Me({type:"roots"}),f=l.newIbGib,b=I({ibGib:f});await Je({key:d,addr:b,space:e,zeroSpace:t,fnUpdateBootstrap:r}),await J({ibGib:f,space:e,fnBroadcast:n})}catch(s){throw console.error(`${a} ${s.message}`),s}finally{P&&console.log(`${a} complete. (I: 7f16e845a80fe95d28923e4170f0c825)`)}}h(ui,"setCurrentRoot");async function Zl({ibGib:o,linked:e,rel8nName:t,space:r,fnBroadcast:n,zeroSpace:a,fnUpdateBootstrap:s}){let i=`[${Zl.name}]`;try{if(!r)throw new Error("space required. (E: f2758eab3bb844d2b749515672d9e392)");if(!o)throw new Error("ibGib required (E: f1bfd67754a7271553f4af544d30bc22)");let c=await Jl({space:r});if(!c)throw new Error("currentRoot undefined (E: 5c2d84dafc664808866008f6eb535750");let l=ye({ibGib:o,defaultIfNone:"incomingAddr"}),d=I({ibGib:o});if(t&&l&&c.rel8ns&&c.rel8ns[t]&&c.rel8ns[t].includes(l))return;t=t||Ws;let f=await ie({src:c,dna:!1,linkedRel8ns:e?["past","ancestor",t]:["past","ancestor"],rel8nsToAddByAddr:{[t]:[d]},nCounter:!0});await V({resTransform:f,space:r});let b=f.newIbGib,p=I({ibGib:b});P&&console.log(`${i} updating _currentRoot root. newRootAddr: ${p}`),await J({ibGib:b,space:r,fnBroadcast:n}),await ui({root:b,space:r,zeroSpace:a,fnUpdateBootstrap:s,fnBroadcast:n})}catch(c){console.error(`${i} ${c.message}`);return}}h(Zl,"rel8ToCurrentRoot");async function hi({targetIbGib:o,space:e}){let t=`[${hi.name}]`;try{P&&console.log(`${t} starting... (I: 291638372117dbc983b4b7cbd8f52123)`);let r=await bi({targetIbGib:o}),n=await ce({ibGib:r,space:e});if(!n.success)throw new Error(`error putting metaStone in space. error: ${n.errorMsg??"[unknown error (E: 45f700f4f1ff463ca8f5353c8e796ac7)]"} (E: 4c25379e66365055e3e423561a7d6123)`)}catch(r){throw console.error(`${t} ${E(r)}`),r}finally{P&&console.log(`${t} complete.`)}}h(hi,"createAndSaveNewMetaStone");async function J({ibGib:o,space:e,fnBroadcast:t}){let r=`[${J.name}]`,n=P;try{let a=I({ibGib:o});if(r=`${r}[${a}]`,!e)throw new Error("space required. (E: ea0c03256f8a4062b460aa4de11f1e3e)");if(P&&console.log(`${r} starting...`),!Ne({ibGibAddr:a}).tjpGib&&!o.data?.isTjp){P&&console.log(`${r} incoming ibGib has no timeline, so no broadcast. still going to create a metastone for it and return early. (I: 649752e3b1be0e0ceb078e0ec2a84f23)`),await hi({targetIbGib:o,space:e});return}let i=ye({ibGib:o,defaultIfNone:"undefined"});if(!i){let u=o.data?.isTjp?o:await Ko({ibGib:o,space:e});u||(console.warn(`${r} tjp not found for ${a}? Should at least just be the ibGib's address itself. (W: d9b570e5bf6d4312bc7d9249ed3bbaad)`),u=o),i=I({ibGib:u})}if(!i)throw new Error("(UNEXPECTED) tjpAddr falsy? should be guaranteed at this point. (E: 39aafb70bc3c6d70b6d2cf8882311223)");let c=h(async()=>{P&&console.log(`${r} adding/replacing latest. tjp: ${i} (I: 7f848da003a2436089fd6f044d96bb42)`),await hi({targetIbGib:o,space:e}),t&&(P&&console.log(`${r} fnBroadcast is true...(I: 0e3b561fb5474a0598b5c6d698df5e1f)`),setTimeout(()=>{P&&console.log(`${r} broadcasting... (I: 61785937be0346f0959d476d7267ab24)`),t({ib:"IbGibTimelineUpdateInfo",tjpAddr:i,latestAddr:a,latestIbGib:o})}))},"replaceLatest");if(o.data?.isTjp){P&&console.log(`${r} ibGib.data?.isTjp true. replacingLatest and returning early. (I: 02c626e006668291550e278b461bcb23)`),await c();return}P&&console.log(`${r} ibGib.data?.isTjp is falsy. (I: 84940e3a9eff869c9474b7b92b864b23)`);let l=await ve({ibGibs:[o],space:e});if(!l.data)throw new Error("(UNEXPECTED) resLatest.data falsy? (E: af3d3914d96adcc5525e4db83cc5d223)");let{success:d,latestAddrsMap:f}=l.data;if(!d){let{errors:u}=l.data;throw u??=["[unknown error (E: 344857f1853641aa842cea3931f90428)]"],new Error(`resLatest.success falsy. errors: ${X(u)}. addr: ${a} (E: b66721da6e1ef9ac4f4089e86c059323)`)}if(!f)throw new Error("(UNEXPECTED) latestAddrsMap falsy but success truthy? (E: c34caff7a256503575ff3ff491dec823)");let b=Object.keys(f);if(b.length!==1)throw new Error("(UNEXPECTED) latestAddrsMap size isn't 1? (E: e11ffc2c18d473745b5bbfc3fe5e3a23)");if(b[0]!==a)throw new Error(`(UNEXPECTED) latestAddrsMap has 1 key (correct) but the key isn't the incoming ibGibAddr? (incorrect). incoming ibGibAddr: ${a}. key found: ${b[0]} (E: 82d79a95d2d7de90eae9db571a360f23)`);P&&(console.log(`${r} valid latestAddrsMap. console.dir(latestAddrsMap)... (I: e24de41622cabbef375172c3017cfd23)`),console.dir(f));let p=f[a];if(p)if(p===a){P&&console.log(`${r} no other found. possible idempotent replacement. addr: ${a} (I: 7f5bd5d3391be95919240f0e97976e22)`),await c();return}else{P&&console.log(`${r} different addr found. incoming ibgib addr is newer. existingLatestAddr: ${p}. incoming addr: ${a} (I: 6cadf13f82aabeb71d76babf1813e623)`);let u=await z({addr:p,space:e});if(!u.success||u.ibGibs?.length!==1){console.error(`Didn't find existing latest ibGib (${p}). I haven't implemented more robust multi-node/distributed strategies for this scenario yet. so we are going ahead with setting the incoming ibgib as the latest in the timeline. (E: 10f6cca6e5ef45bfacbfe48f652e2102)`),await c();return}let m=u.ibGibs[0];if(typeof o.data?.n=="number"&&o.data.n>=0){P&&console.log(`found ibGib.data.n (version counter), using this to determine latest ibGib: ${o.data.n}`);let y=o.data.n;if(typeof m.data?.n=="number"&&m.data.n>=0){let A=m.data.n;if(P&&console.log(`[registerNewIbGib] n_ibGib (${y}) vs n_existingLatest (${A}) in space: ${e.data?.name||e.ib}`),y>A)P&&console.log(`${r} is newer (I: 040d05ac2032f08c7fd0c4d8b2887323)`),await c();else{P&&console.log("is not newer, so we don't need to do anything else. (I: 14c25dc3314748dc909d61b77eb64354)"),console.warn(`${r} incoming ibGib (${a}) is NOT NEWER than existing latest (${p}). multiple branches for the same timeline? ignoring incoming ibGibAddr. n_ibGib: ${y}. n_existingLatest: ${A}. space.ib: ${e.ib} (W: 057baadca494473dabb26fb4fb879774)`);return}}else m.data?.isTjp&&o.data.n===0?await c():(console.warn(`${r} (UNEXPECTED) only existingLatestIbGib (isTjp: ${m.data?.isTjp}) has a data.n counter? ibGib.data.n: ${o.data.n}. usually this only happens when existing latest is a tjp and the new ibGib we are registering is n === 0. This is falsy in this instance though. We will go ahead and replace the latest with the new one, but this is an anomalous state. (W: 73d08aea17ad4e1481a5f97e2556a878)`),console.log(`${r} console.dir(existingLatestIbGib)... (I: 9ef7962d9cc74f1eb0409e5caf98e915)`),console.dir(m),console.log(`${r} console.dir(ibGib)... (I: 9ef7962d9cc74f1eb0409e5caf98e915)`),console.dir(o),await c())}else if(P&&console.log(`${r} no nCounter found. Trying brute force method.`),await fd({ibGib:o,ibGibAddr:a,existingLatest:m,existingLatestAddr:p,tjpAddr:i,space:e})===a)await c();else return}else if(p===null){P&&console.log(`${r} no existing tjp mapping so incoming ibgib is considered new to this space. ibGib addr: ${a} (I: 4f2bbc32b31e4fa982d95b3a785db82f)`),await c();return}else throw new Error("(UNEXPECTED) latestAddr is falsy but not null? the getLatestAddrs impl in the space should be guaranteed to provide either the incoming ibgib addr, the latest addr (if exists), or null if not found. (E: 3159dd531c0bc0efc1ece116adf28923)")}catch(a){throw console.error(`${r} ${a.message}`),a}finally{P&&console.log(`${r} complete.`),P=n}}h(J,"registerNewIbGib");async function ao({type:o,rel8nName:e,ibGibsToRel8:t,ibGibsToUnRel8:r,addrsToUnRel8:n,linked:a,severPast:s,deletePreviousSpecialIbGib:i,space:c,zeroSpace:l,fnUpdateBootstrap:d,fnBroadcast:f}){let b=`[${ao.name}](type:${o},rel8nName:${e})`;try{if(!c)throw new Error("space required. (E: 956192eea28047eba6dad81620bb96fb)");if((t??[]).length===0&&(r??[]).length===0&&(n??[]).length===0)throw new Error("either ibGibsToRel8 or ibGibsToUnRel8 required. (E: 5add49c8e46a54e2c6b057c22646a822)");if((r??[]).length>0&&(n??[]).length>0)throw new Error("can't provide both ibGibsToUnRel8 and addrsToUnRel8. There isn't a technical reason but I'm too tired right now to implement the overhead to enable this atow (05/2025). (E: 31ef66be26349cfe1b1f352389b99425)");let p=t?.map($=>I({ibGib:$}));n??=r?.map($=>I({ibGib:$}));let u=Me({type:o}),m=await ca({key:u,space:c});if(!m)throw new Error("specialAddr not found (E: 680dfd1caa3e4d7cb0f593b893a10f0d)");let g=await z({addr:m,space:c});if(!g.success)throw new Error("couldn't get special (E: 897f7671d2184515866c5a675d33b3dc)");if(!g.ibGibs)throw new Error("resGetSpecial.ibGibs falsy (E: 2405dd295b2444d88503f7731796a5a0)");if(g.ibGibs.length!==1)throw new Error(`resGetSpecial.ibGibs count is not 1 (${g.ibGibs.length}) (E: b4547789016a4729af30cd972a4ca4ab)`);let y=g.ibGibs[0],w=await ie({src:y,rel8nsToAddByAddr:p?{[e]:p}:void 0,rel8nsToRemoveByAddr:n?{[e]:n}:void 0,dna:!1,linkedRel8ns:a?[Se.past,e]:[Se.past],nCounter:!0}),A=w.newIbGib;if(s){if(w.intermediateIbGibs)throw new Error("new special creates intermediate ibgibs. so severing past is harder. (E: b580c0c56253494192e9c62212ee187d)");A.rel8ns.past=[],A.gib=await ee({ibGib:A})}await V({resTransform:w,space:c});let G=I({ibGib:A}),T=ye({ibGib:A});return await Je({key:u,addr:G,space:c,zeroSpace:l,fnUpdateBootstrap:d}),i&&await pi({addr:m,space:c}),await J({ibGib:A,fnBroadcast:f,space:c}),G}catch(p){throw console.error(`${b} ${p.message}`),p}}h(ao,"rel8ToSpecialIbGib");async function Ko({ibGib:o,naive:e=!0,space:t}){let r=`[${Ko.name}]`;try{if(!t)throw new Error("space required. (E: 941f973d50e84415b58724af173f52c2)");if(!o)throw new Error("ibGib required.");let n=I({ibGib:o}),{gib:a}=K({ibGibAddr:n});if(a===Q||await Ii({ibGib:o,naive:e}))return o;if(!o.rel8ns){P&&console.log(`${r} ibgib not tjp in data, and rel8ns is falsy. so tjp is undefined (I: acdadb76a7568807db7a68f6f866de22)`);return}if(o.rel8ns.tjp&&o.rel8ns.tjp.length>0){let f=o.rel8ns.tjp[0],b=await z({addr:f,space:t});if(b.success&&b.ibGibs?.length===1)return b.ibGibs[0];{let p=b.errorMsg??"[unspecified error in get result]";throw new Error(`ibGib references tjp but could not retrieve from space. res error: ${p} (E: 94f0340706ad48c794c6a62c1b235a22)`)}}let i=o.rel8ns.past||[];if(i.length===0){console.warn(`${r} past.length === 0, so there is no tjp.`),P&&console.log(`${r} ibgib is not tjp in data, not in tjp rel8n, and past is empty. so tjp is undefined (I: bf06f664917dcf4492fb9c4c106a6222)`);return}let c=i[i.length-1],l=await z({addr:c,space:t});if(!l.success||l.ibGibs?.length!==1)throw new Error(`get past failed. addr: ${c}`);let d=l.ibGibs[0];return await Ko({ibGib:d,naive:e,space:t})}catch(n){throw console.error(`${r} ${n.message}`),n}}h(Ko,"getTjpIbGib");async function Ql({type:o,space:e,zeroSpace:t,fnUpdateBootstrap:r,fnBroadcast:n}){let a=`[${Ql.name}]`;try{if(!e)throw new Error("space falsy and localUserSpace not initialized. (E: 66e7d3ff098248f0a5ddda51853c92e6)");switch(o){case"roots":return rd({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:r});case"tags":return ed({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:r});case"secrets":return nd({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:r});case"encryptions":return ad({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:r});case"outerspaces":return sd({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:r});case"autosyncs":return id({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:r});case"robbots":return cd({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:r});case"apps":return ld({space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:r});default:return dd({type:o,space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:r})}}catch(s){throw console.error(`${a} ${s.message}`),s}}h(Ql,"createSpecial");async function Rt({type:o,skipRel8ToRoot:e,space:t,zeroSpace:r,fnUpdateBootstrap:n,fnBroadcast:a}){let s=`[${Rt.name}][${o||"falsy type?"}]`;try{P&&console.log(`${s} starting...`);let i=yi({type:o}),c=H.primitive({ib:i}),l=await Rn({src:c,destIb:i,linkedRel8ns:[Se.past,Se.ancestor],tjp:{uuid:!0,timestamp:!0},dna:!0,nCounter:!0});return await V({resTransform:l,space:t}),o!=="roots"&&o!=="latest"&&!e&&await Zl({ibGib:l.newIbGib,linked:!0,space:t,zeroSpace:r,fnBroadcast:a,fnUpdateBootstrap:n}),P&&console.log(`${s} complete.`),l.newIbGib}catch(i){throw console.error(`${s} ${i.message}`),i}}h(Rt,"createSpecialIbGib");async function ed({space:o,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:r}){let n=`[${ed.name}]`;try{if(!o)throw new Error("space required. (E: 9c05b9bd355943a39ca47afef67a50eb)");let a=Me({type:"tags"}),s=await Rt({type:"tags",space:o,zeroSpace:e,fnBroadcast:r,fnUpdateBootstrap:t}),i=I({ibGib:s});await Je({key:a,addr:i,space:o,zeroSpace:e,fnUpdateBootstrap:t});let c=[{text:"home",icon:"home-outline"},{text:"favorite",icon:"heart-outline"}];for(let l of c)i=(await td({...l,space:o,zeroSpace:e,fnBroadcast:r,fnUpdateBootstrap:t})).newTagsAddr,await Je({key:a,addr:i,space:o,zeroSpace:e,fnUpdateBootstrap:t});return i}catch(a){return console.error(`${n} ${a.message}`),null}}h(ed,"createSpecial_Tags");async function td({text:o,icon:e,description:t,space:r,zeroSpace:n,fnUpdateBootstrap:a,fnBroadcast:s}){let i=`[${td.name}]`;try{if(P&&console.log(`${i} starting...`),!r)throw new Error("space required. (E: 5def0b1afab74b0c9286e3ac5060cb8f)");if(!o)throw new Error(`${i} text required`);e=e||_l,t=t||Tl;let c=Or(o),l=H.primitive({ib:"tag"}),d=await H.firstGen({parentIbGib:l,ib:c,data:{text:o,icon:e,description:t},tjp:{uuid:!0,timestamp:!0},dna:!0,nCounter:!0}),f=d.newIbGib;await V({resTransform:d,space:r}),await J({ibGib:f,space:r,fnBroadcast:s});let b=await Oh({tagIbGib:f,space:r,zeroSpace:n,fnUpdateBootstrap:a,fnBroadcast:s});return{newTagIbGib:f,newTagsAddr:b}}catch(c){throw console.error(`${i} ${c.message}`),c}finally{P&&console.log(`${i} complete.`)}}h(td,"createTagIbGibAndSundry");async function rd({space:o,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:r}){let n=`[${rd.name}]`;try{if(!o)throw new Error("space required. (E: d12a8ea31163429fb6e53ff8e7579c57)");let a=Me({type:"roots"}),s=await Rt({type:"roots",space:o,zeroSpace:e,fnBroadcast:r,fnUpdateBootstrap:t}),i=I({ibGib:s});await Je({key:a,addr:i,space:o,zeroSpace:e,fnUpdateBootstrap:t});let l=["A","B","C","D","E","F","G"].map(f=>({text:`${f}root`,icon:Ys,description:Ks})),d;for(let f=0;f<l.length;f++){let b=l[f],p=await od({...b,space:o,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:r});if(d||(d=p.newRootIbGib),!p.newRootIbGib)throw new Error("(UNEXPECTED) resCreate.newRootIbGib falsy? (E: c9fb2c94a9c1d762c1699b41a4d5ad23)");i=p.newRootsAddr,await Je({key:a,addr:i,space:o,zeroSpace:e,fnUpdateBootstrap:t})}if(!d)throw new Error("(UNEXPECTED) firstRoot still falsy? (E: b2e2c926d242966e7ed7159e4b129e23)");if(await ui({root:d,space:o,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:r}),i=await ca({key:a,space:o}),!i)throw new Error("(UNEXPECTED) no roots address in config? (E: 76345340699a4738a195e48803ef0d31)");return i}catch(a){return console.error(`${n} ${a.message}`),null}}h(rd,"createSpecial_Roots");async function od({text:o,icon:e,description:t,space:r,zeroSpace:n,fnUpdateBootstrap:a,fnBroadcast:s}){let i=`[${od.name}]`;try{if(!r)throw new Error("space required. (E: cfa876e5c8c64a53a463ca7a645571c8)");o=o||Al,e=e||Ys,t=t||Ks;let c=$i(o),l=H.primitive({ib:"root"}),d=await H.firstGen({parentIbGib:l,ib:c,data:{text:o,icon:e,description:t},linkedRel8ns:[Se.past,Se.ancestor],tjp:{uuid:!0,timestamp:!0},dna:!0,nCounter:!0}),{newIbGib:f}=d;await V({resTransform:d,space:r});let b=await ao({type:"roots",rel8nName:Vs,ibGibsToRel8:[f],space:r,zeroSpace:n,fnUpdateBootstrap:a,fnBroadcast:s});return{newRootIbGib:f,newRootsAddr:b}}catch(c){throw console.error(`${i} ${c.message}`),c}}h(od,"createRootIbGib");async function nd({space:o,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:r}){let n=`[${nd.name}]`;try{if(!o)throw new Error("space required. (E: 340960cd5ad24addb300b23d9722e30a)");let a,s=Me({type:"secrets"}),i=await Rt({type:"secrets",space:o,zeroSpace:e,fnBroadcast:r,fnUpdateBootstrap:t});return a=I({ibGib:i}),await Je({key:s,addr:a,space:o,zeroSpace:e,fnUpdateBootstrap:t}),a}catch(a){return console.error(`${n} ${a.message}`),null}}h(nd,"createSpecial_Secrets");async function ad({space:o,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:r}){let n=`[${ad.name}]`;try{if(!o)throw new Error("space required. (E: 5084e698b6924e7090697ca50075ca59)");let a,s=Me({type:"encryptions"}),i=await Rt({type:"encryptions",space:o,zeroSpace:e,fnBroadcast:r,fnUpdateBootstrap:t});return a=I({ibGib:i}),await Je({key:s,addr:a,space:o,zeroSpace:e,fnUpdateBootstrap:t}),a}catch(a){return console.error(`${n} ${a.message}`),null}}h(ad,"createSpecial_Encryptions");async function sd({space:o,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:r}){let n=`[${sd.name}]`;try{if(!o)throw new Error("space required. (E: 99dd9e92535c470482eb9f6625a33831)");let a,s=Me({type:"outerspaces"}),i=await Rt({type:"outerspaces",space:o,zeroSpace:e,fnBroadcast:r,fnUpdateBootstrap:t});return a=I({ibGib:i}),await Je({key:s,addr:a,space:o,zeroSpace:e,fnUpdateBootstrap:t}),a}catch(a){return console.error(`${n} ${a.message}`),null}}h(sd,"createSpecial_OuterSpaces");async function id({space:o,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:r}){let n=`[${id.name}]`;try{if(!o)throw new Error("space required. (E: f01cf6a4a460486796e16d505d629522)");let a,s=Me({type:"autosyncs"}),i=await Rt({type:"autosyncs",space:o,zeroSpace:e,fnBroadcast:r,fnUpdateBootstrap:t});return a=I({ibGib:i}),await Je({key:s,addr:a,space:o,zeroSpace:e,fnUpdateBootstrap:t}),a}catch(a){return console.error(`${n} ${a.message}`),null}}h(id,"createSpecial_Autosyncs");async function cd({space:o,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:r}){let n=`[${cd.name}]`;try{if(!o)throw new Error("space required. (E: f01cf6a4a460486796e16d505d629522)");let a,s=Me({type:"robbots"}),i=await Rt({type:"robbots",space:o,zeroSpace:e,fnBroadcast:r,fnUpdateBootstrap:t});return a=I({ibGib:i}),await Je({key:s,addr:a,space:o,zeroSpace:e,fnUpdateBootstrap:t}),a}catch(a){return console.error(`${n} ${a.message}`),null}}h(cd,"createSpecial_Robbots");async function ld({space:o,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:r}){let n=`[${ld.name}]`;try{if(!o)throw new Error("space required. (E: f01cf6a4a460486796e16d505d629522)");let a,s=Me({type:"apps"}),i=await Rt({type:"apps",space:o,zeroSpace:e,fnBroadcast:r,fnUpdateBootstrap:t});return a=I({ibGib:i}),await Je({key:s,addr:a,space:o,zeroSpace:e,fnUpdateBootstrap:t}),a=await sa({defaultAppData:Bl,defaultAppRel8ns:kl,space:o,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:r}),a=await sa({defaultAppData:jl,defaultAppRel8ns:ql,space:o,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:r}),a=await sa({defaultAppData:Xl,defaultAppRel8ns:Hl,space:o,zeroSpace:e,fnUpdateBootstrap:t,fnBroadcast:r}),a}catch(a){return console.error(`${n} ${a.message}`),null}}h(ld,"createSpecial_Apps");async function sa({defaultAppData:o,defaultAppRel8ns:e,space:t,zeroSpace:r,fnUpdateBootstrap:n,fnBroadcast:a}){let s=`[${sa.name}]`;try{P&&console.log(`${s} starting... (I: 677f68789abdc7316887e8f38c764e22)`),P&&console.log(`${s} starting...`);let i=B(o),c=e?B(e):void 0;i.uuid=!i.uuid||i.uuid===ii?await q():i.uuid;let{classname:l}=i,d=si({appData:i,classname:l}),f=await H.firstGen({ib:d,parentIbGib:H.primitive({ib:`app ${l}`}),data:i,rel8ns:c,dna:!0,linkedRel8ns:[Se.ancestor,Se.past],nCounter:!0,tjp:{timestamp:!0}});return await V({resTransform:f,space:t}),await J({ibGib:f.newIbGib,fnBroadcast:a,space:t}),await ao({type:"apps",rel8nName:Vn,ibGibsToRel8:[f.newIbGib],fnBroadcast:a,fnUpdateBootstrap:n,space:t,zeroSpace:r})}catch(i){throw console.error(`${s} ${i.message}`),i}finally{P&&console.log(`${s} complete.`)}}h(sa,"createApp");async function dd({type:o,space:e,zeroSpace:t,fnUpdateBootstrap:r,fnBroadcast:n}){let a=`[${dd.name}]`;try{if(!e)throw new Error("space required. (E: c7bbafcbe901418db4c6048f17f53091)");P&&console.log(`${a} creating special of type: ${o} (I: 283c8bb30ed6f9698b74b886c6078622)`);let s,i=Me({type:o}),c=await Rt({type:o,space:e,zeroSpace:t,fnBroadcast:n,fnUpdateBootstrap:r});return s=I({ibGib:c}),await Je({key:i,addr:s,space:e,zeroSpace:t,fnUpdateBootstrap:r}),s}catch(s){return console.error(`${a} ${s.message}`),null}}h(dd,"createSpecial_Default");async function fd({ibGib:o,ibGibAddr:e,existingLatest:t,existingLatestAddr:r,tjpAddr:n,space:a}){let s=`[${fd.name}][${e}]`;try{if(P&&console.log(`${s} starting...`),!a)throw new Error("space required. (E: 64eb9a271f5d43deadec30b9638746c8)");let i=o.rel8ns?.past||[],c=t.rel8ns?.past||[];if(i.length===1&&c.length===0)return P&&console.log(`prospective has a past, so it "must" be newer. (won't quote "must" anymore)`),e;if(c.length===1&&i.length===0)return P&&console.log("existing has a past, so it must be newer."),r;if(c.length===0&&i.length===0)return console.warn(`${s} neither existing latest nor prospective new ibGib has a past, so keeping existing.`),r;if(c.includes(e))return P&&console.log("existing by definition is newer"),r;if(i.includes(r))return P&&console.log("ibGib by definition is newer"),e;if(r===e)return P&&console.log("they're the same!"),r;if(r===n&&t.rel8ns?.tjp?.length===1)return P&&console.log("ibGib must be newer because the existingLatestAddr is the tjp, which is by definition first in unique past."),e;if(e===n&&o.rel8ns?.tjp?.length===1)return P&&console.log("existing must be newer because the ibGibAddr is the tjp, which is by definition first in unique past."),r;P&&console.log(`${s} brute forcing through iterating the pasts.`);let l,d=-1,f=h(async(u,m,g)=>{let y=u.rel8ns?.past||[];if(y.includes(g))return l=I({ibGib:u}),-1;if(y.length===0)return m;let w=m+y.length;if(d!==-1&&w>d)return l=I({ibGib:u}),-1;let A=await z({addr:y[0],space:a});if(!A.success||A.ibGibs?.length!==1)throw new Error(`Couldn't load past addr (xPast[0]): ${y[0]}`);return f(A.ibGibs[0],m+y.length,g)},"getPastCount");P&&console.log(`${s} doing ibGibPastCount`);let b=await f(o,0,r);if(l)return l;P&&console.log(`${s} Doing existingPastCount`),d=b;let p=await f(t,0,e);return l||(b>p?(P&&console.log(`${s} ibGibPastCount (${b}) is longer than existingPastCount (${p}), so ibGib is newer.`),l=e):(P&&console.log(`${s} existingPastCount (${p}) is longer than ibGibPastCount (${b}), so ibGib is newer.`),l=r),l)}catch(i){throw console.error(`${s} ${i.message}`),i}finally{P&&console.log(`${s} complete.`)}}h(fd,"getLatestAddr_Brute");function Oh({tagIbGib:o,space:e,zeroSpace:t,fnUpdateBootstrap:r,fnBroadcast:n}){return ao({type:"tags",rel8nName:zs,ibGibsToRel8:[o],space:e,zeroSpace:t,fnUpdateBootstrap:r,fnBroadcast:n})}h(Oh,"rel8TagToTagsIbGib");function la({ibGibs:o,ibGibAddrs:e}){let t=`[${la.name}]`;try{if(!o&&!e)throw new Error("either ibGibs or ibGibAddrs required. (E: 37776788620f4966b0964945ce181fc6)");o&&e&&console.warn(`${t} both ibGibs and ibGibAddrs provided. You should only provide one. Only ibGibAddrs will be checked. (W: dc13f9e197834e2daaba3bcfd08418db)`);let r=e?e.concat():o.map(n=>I({ibGib:n}));for(let n=0;n<r.length;n++){let a=r[n];if(r.filter(s=>s===a).length>1)throw new Error(`duplicate addr found: ${a} (E: 70fbef040dd449c38c667d53b8092053)`)}}catch(r){throw console.error(`${t} ${r.message}`),r}}h(la,"throwIfDuplicates");function mi({space:o,scope:e}){let t=`[${mi.name}]`;try{if(P&&console.log(`${t} starting...`),!o)throw new Error("space required. (E: 3ba16e6c3e5e47948b0e63448da11752)");if(!o.data?.uuid)throw new Error("invalid space (space.data.uuid falsy) (E: 273262b32f2ef27b2e690bc699f33822)");if(!e)throw new Error("scope required. (E: f47801d6c45e2247b42a53d9b604b522)");for(;e.includes(Ue);)P&&console.log(`${t} scope contains ibgib delimiter...replacing... (I: 0f456fd7cc6552a799673a0c5b4a7d22)`),e=e.replace(Ue,"_");let r=o.data.uuid,n=`${yl} ${r} ${e}`;return I({ib:n,gib:Q})}catch(r){throw console.error(`${t} ${r.message}`),r}finally{P&&console.log(`${t} complete.`)}}h(mi,"getSpaceLockAddr");async function pt({space:o,scope:e,secondsValid:t,maxDelayMs:r,fn:n,callerInstanceId:a,maxLockAttempts:s}){let i=`[${pt.name}]`;try{if(P&&console.log(`${i} starting...`),!o)throw new Error("space required. (E: 66fd8f21a5b2b572d18cdeb9472a7722)");if(!t)throw new Error("secondsValid required. (E: 92c5610e57ceede5ce83cff86d5c2a22)");if(t<0)throw new Error("secondsValid must be positive. (E: 970a7510c517235d7a355a843d18d222)");if(!n)throw new Error("fn required (E: 7022e280252ec2faf756b6db05c56e22)");let c;P&&console.log(`${i} attempting to acquire lock with scope ${e} (I: fed36d42a975b1c52897a4df804ac722)`);let l;r=(r??0)>0?r:$l;let d=0;s=s??!1?s:Il;do{if(l=await bd({space:o,scope:e,secondsValid:t,instanceId:a}),l?.data?.success)break;let b=Math.ceil(Math.random()*r);await De(b),d++}while(d<s);if(l?.data?.success)P&&console.log(`${i} lock acquired. (I: d847fa953ee131a57e1a89c537342722)`);else throw new Error(`could not acquire lock after ${d} attempts with intermittent delays of ${r} ms (E: 898c559dbd0c9bf20c14cf87a8f1e222)`);let f=`${i}[fn]`;try{P&&console.log(`${f} starting... (I: c2f7bedf95d3f1dd1f76de34a68d3f22)`),c=await n()}catch(b){throw console.error(`${f} ${b.message}`),b}finally{P&&console.log(`${f} unlocking space with scope: ${e} (I: 21034d9c3395499756e9000e40417d22)`),await hd({space:o,scope:e,instanceId:a}),P&&console.log(`${f} complete. (I: 79d8ac03714a4d429c7e6c2ac6e18d22)`)}return c}catch(c){throw console.error(`${i} ${c.message}`),c}finally{P&&console.log(`${i} complete.`)}}h(pt,"execInSpaceWithLocking");async function zo({zeroSpace:o}){let e=`[${zo.name}]`;try{if(P&&console.log(`${e} starting...`),!o)throw new Error("zeroSpace required. (E: 66fd8f21a5b2b572d18cdeb9472a7722)");let t=lr;P&&console.log(`${e} getting from zeroSpace...`);let r=await o.argy({ibMetadata:Tt({space:o}),argData:{cmd:"get",ibGibAddrs:[t]}}),n=await o.witness(r);if(n?.data?.success&&n.ibGibs?.length===1){let a=n.ibGibs[0];return P&&console.log(`${e} bootstrapibGib found: ${X(a)}`),await ci(a)?a:(P&&console.log(`${e} bootstrapIbGib was invalid. (I: cce66b26805404fc85525d565e1f8b22)`),null)}else return P&&console.log(`${e} bootstrapIbGib NOT found. (I: 421562993bf3464eb507d2967d311e22)`),null}catch(t){throw console.error(`${e} ${t.message}`),t}finally{P&&console.log(`${e} complete.`)}}h(zo,"getValidatedBootstrapIbGib");async function Lh({zeroSpace:o,bootstrapIbGib:e,localSpaceId:t,lock:r,callerInstanceId:n,fnDtoToSpace:a,localSpaceCacheSvc:s}){let i=`[${Lh.name}]`;try{if(!o)throw new Error("zeroSpace required. (E: 0793781a98c456a666cfa9eb960bcd22)");if(!e)if(P&&console.log(`${i} bootstrap falsy, so loading it... (I: f2366e38283495a38b5501297aa34422)`),r){let d=lr;P&&console.log(`${i} using locked version of loading bootstrap... (I: 52b9b11999674e586d051c2b23f59b22)`),e=await pt({space:o,scope:d,fn:h(async()=>{let f=await zo({zeroSpace:o});if(f)return f;throw new Error("(UNEXPECTED) unable to get bootstrap ibgib? (E: c111dc7627acbfb992134ddf4064ea23)")},"fn"),callerInstanceId:n,secondsValid:qn})}else P&&console.log(`${i} lock is false, so just getting the bootstrap ibgib (I: 49d55e5a824510bb3ee0ccd9f5ec3322)`),e=await zo({zeroSpace:o})??void 0;if(!e)throw new Error("bootstrapIbGib falsy. not initialized? (E: 91f5c82b5e124178d958701ebcb09822)");if(!e.data)throw new Error("(UNEXPECTED) bootstrapIbGib.data required. invalid bootstrap? (E: 568c6b837c1a39f7a25d188a90167423)");if(t=t??e.data[At],!e.rel8ns)throw new Error("(UNEXPECTED) bootstrapIbGib.rel8ns falsy? it should have been validated by now. (E: 817d9a2a0b98ec0c177cd7ab149b9426)");if(!e.rel8ns[t])throw new Error(`localSpaceId (${t}) not found in bootstrapIbGib.rel8ns (E: 8869884093984ec43f942fea24bd9926)`);let c=e.rel8ns[t][0],l=h(async()=>{let d=await o.argy({ibMetadata:Tt({space:o}),argData:{cmd:"get",ibGibAddrs:[c]}}),f=await o.witness(d);if(f?.data?.success&&f.ibGibs?.length===1){let b=f.ibGibs[0],p=await a(b);return s&&(p.cacheSvc=s),p}else throw new Error(`Could not get local space addr (${c}) specified in bootstrap space (${I({ibGib:e})}). (E: 6d6b45e7eae4472697ddc971438e4922)`)},"fnGet");return r?(P&&console.log(`${i} getting localSpaceId (${t}) WITH locking (I: c48a0e4ac5971cdbc57273dd35f8a522)`),await pt({space:o,scope:t,fn:h(()=>l(),"fn"),callerInstanceId:n,secondsValid:qn})):(P&&console.log(`${i} getting localSpaceId (${t}) WITHOUT locking (I: 48e504835dee4006839df8820d860b22)`),l())}catch(c){throw console.error(`${i} ${c.message}`),c}}h(Lh,"getLocalSpace");async function bd({space:o,scope:e,secondsValid:t,instanceId:r}){let n=`[${bd.name}]`;try{if(P&&console.log(`${n} starting...`),!o)throw new Error("space required. (E: 5c0a7197a75f483a82d74e5eea60df37)");if(!e)throw new Error("scope required. (E: c7f1dde9570f4df3b450faa2c2f85122)");if(!t)throw new Error("secondsValid required and positive (E: b42b6733638b46c06c9aff59a6c49822)");if(t<0)throw new Error("secondsValid must be positive (E: bbe3b6d567583bfb35a1c0825eb29622)");let a,s=mi({space:o,scope:e}),i,c=await z({addr:s,space:o,force:!0});if(c.success&&c.ibGibs?.length===1?(i=c.ibGibs[0],i?.data?.expirationUTC?Bs({expirationTimestampUTC:i.data.expirationUTC})&&(console.warn(`${n} ignoring expired existing lock in space at ${s}. Should be overwritten (W: 7421c5b051724b189f88cecbbd449b22)`),i=void 0):(console.error(`${n} (UNEXPECTED) exisingLock.data.expirationUTC falsy? (E: 218dc0e935534a149d0be153c532cf25)`),i=void 0)):P&&console.log(`${n} existing lock not found for ${s} (I: 191af56ec4e2db3d19084e46bf949222)`),i){if(!i.data)throw new Error("(UNEXPECTED) existingLock.data falsy? (E: 00069b4662e5566d971760d15e293723)");a=B(i),a.data.alreadyLocked=!0,a.data.success=!1}else{let{ib:l,gib:d}=K({ibGibAddr:s});a={ib:l,gib:d,data:{scope:e,secondsValid:t,instanceId:r,expirationUTC:Fs({seconds:t})}};let f=await o.argy({ibMetadata:Tt({space:o}),argData:{cmd:"put",force:!0,ibGibAddrs:[s]},ibGibs:[a]}),b=await o.witness(f);if(b.data?.success)if((b.data.addrsAlreadyHave??[]).includes(s)){P&&console.log(`${n} racelost! addrsAlreadyHave includes spaceLockAddr (${s}) (I: 2e8a1562947c40698110b64251141753)`);let p=await z({addr:s,space:o,force:!0});if(p.success&&p.ibGibs?.length===1){let u=p.ibGibs[0];a=B(u),a.data.alreadyLocked=!0,a.data.success=!1}else{let u=`${n} (UNEXPECTED) addrsAlreadyHave true, but couldn't get lock? (E: 8374a2b6628b49369363bc5843105763)`;console.error(u),a.data.success=!1,a.data.errorMsg=u}}else a.data.success=!0;else{let p=`${n} there was an error putting the lock in the space: ${b.data?.errors?.join("|")}`;a.data.success=!1,a.data.errorMsg=p,console.error(p)}}return a}catch(a){throw console.error(`${n} ${a.message}`),a}finally{P&&console.log(`${n} complete.`)}}h(bd,"lockSpace");async function hd({space:o,scope:e,instanceId:t}){let r=`[${hd.name}]`;try{if(P&&console.log(`${r} starting...`),!o)throw new Error("space required. (E: 5c0a7197a75f483a82d74e5eea60df37)");if(!e)throw new Error("scope required. (E: c7f1dde9570f4df3b450faa2c2f85122)");let n=mi({space:o,scope:e}),a=await pi({addr:n,space:o,force:!0});if(a.success){let{ib:s,gib:i}=K({ibGibAddr:n});return{ib:s,gib:i,data:{success:!0,instanceId:t,scope:e}}}else{let s=`Delete lock in space failed. delete errorMsg: ${a.errorMsg}`;if(s.includes("not implemented"))throw new Error(s);if(s.toLowerCase().includes("does not exist")||s.toLowerCase().includes("doesn't exist")||s.toLowerCase().includes("not found")){P&&console.log(`${r} ${s} (I: b647916fd0f3e5366e9387131be21c22)`);let{ib:i,gib:c}=K({ibGibAddr:n});return{ib:i,gib:c,data:{action:"unlock",success:!0,instanceId:t,scope:e}}}else console.warn(`${r} ${s} (W: 14c84fcac15944bd9a417099964d5d9d)`)}}catch(n){throw console.error(`${r} ${n.message}`),n}finally{P&&console.log(`${r} complete.`)}}h(hd,"unlockSpace");async function Rh({space:o,zeroSpace:e,setSpaceAsDefault:t,createIfNotFound:r}){let n=`[${Rh.name}]`;try{if(P&&console.log(`${n} starting...`),!o)throw new Error("space required. (E: 6fc19548fa7d1d5219e19871f280a322)");if(!o.data?.uuid)throw new Error("space.data.uuid required (E: 6483188ca6f2ed2085fd355595f3ab22)");if(!e)throw new Error("zeroSpace required. (E: abbf156e18b1018d96273e22a260f122)");let a=o.data.uuid,s=I({ibGib:o}),i=await zo({zeroSpace:e});if(i){if(P&&console.log(`${n} updating existing bootstrap (I: 977d4aa7ed47bef73b35743c05ce0722)`),i.data.spaceIds.includes(a)){P&&console.log(`${n} space already rel8d to bootstrap, possibly updating its addr (I: b5e2c515ef732d4bbcf02625a9e7c722)`);let c=i.rel8ns[a][0];c===s?P&&console.log(`${n} bootstrap already rel8d to space (I: c1be027b23e7350c64790a631cae2822)`):(P&&console.log(`${n} updating rel8ns[${a}] with newSpaceAddr (${s}). (Old address: ${c})(I: 297a9b0061fd471b8d28a06e04a6ad22)`),i.rel8ns[a]=[s])}else P&&console.log(`${n} new space being rel8d. adding spaceId to data.spaceIds and amending rel8ns (I: 40903d71719aa1d56e498299f5699a22)`),i.data.spaceIds.push(a),i.rel8ns[a]=[s];t&&(P&&console.log(`${n} setting spaceId (${a}) as default space (I: f85eda6c6ad2b0bec9750ce3c7795b22)`),i.data[At]=a)}else{if(!r){P&&console.log(`${n} bootstrapIbGib not found but createIfNotFound falsy, so returning early. (I: 5c67d85a8599a5ba4a6780f26a66ea22)`);return}P&&console.log(`${n} creating new bootstrap ibgib for spaceId (${a}) with address of (${s}) (I: 651959c27bf2ebc5be1f7f44e2b9e422)`);let{ib:c,gib:l}=K({ibGibAddr:lr});i=H.primitive({ib:c}),i.gib=l,i.data={[At]:a,[Wn]:[a]},i.rel8ns={[a]:[s]}}if(!i)throw new Error("(UNEXPECTED) bootstrapIbGib still falsy? (E: cf21d7f1756710a66aa0e6a28d762723)");P&&console.log(`${n} saving bootstrapIbGib: ${X(i)} (I: 3cceca0b98dde90e4a58a734be252322)`),await gi({zeroSpace:e,bootstrapIbGib:i}),P&&console.log(`${n} complete.`)}catch(a){throw console.error(`${n} ${a.message}`),a}}h(Rh,"updateBootstrapIbGib");async function gi({zeroSpace:o,bootstrapIbGib:e}){let t=`[${gi.name}]`;if(!o)throw new Error("zeroSpace required. (E: 818fa8430b8040dca1917f9db0972b22)");if(!e)throw new Error("bootstrapIbGib required. (E: cf21d7f1756710a66aa0e6a28d762723)");let r=await o.argy({ibMetadata:e.ib,argData:{cmd:"put",force:!0,ibGibAddrs:[I({ibGib:e})]},ibGibs:[e]});P&&console.log(`${t} zeroSpace will witness/put... (I: 1be9aca22ffc4951b6690965a7aeae5b)`);let n=await o.witness(r);if(n?.data?.success)P&&console.log(`${t} zero space put complete. (I: ac3056d655e841f1a3c442bcc64942f9)`);else throw new Error(`${n?.data?.errors?.join("|")||"There was a problem with zeroSpace witnessing the bootstrap^gib primitive."}`)}h(gi,"persistBootstrapIbGibInZeroSpace");async function Uh({spaceId:o,zeroSpace:e}){let t=`[${Uh.name}]`;if(!o)throw new Error("spaceId required. (E: 52f9c31405e24c2999e5a1b32d201a23)");if(!e)throw new Error("zeroSpace required. (E: a115f4007b2c4819a58cf093d5823b23)");await pt({space:e,scope:lr,fn:h(async()=>{let n=await zo({zeroSpace:e});if(!n)throw new Error("bootstrapIbGib falsy in zeroSpace (E: e36a512781b0467ba1bf1d927a7c1d23)");if(!n.data)throw new Error("bootstrapIbGib.data falsy in zeroSpace (E: 8f92104192b44d71891b092481029ab0)");let a=n.data,s=a[Wn]??[];if(s.length<=1)throw new Error(`Cannot delete space (${o}). It is the only remaining local space. (E: 9c27f71120014b08b5e9f89993380e23)`);if(o===a[At])throw new Error(`Cannot delete space (${o}). It is the default local space. Please select a new default space before deleting. (E: f3c30a5170d14b4fb2478d102e3b2e23)`);if(!s.includes(o))throw new Error(`Space (${o}) not found in bootstrap spaceIds. (E: 61fa940e79124430a618e470bc551d23)`);a[Wn]=s.filter(i=>i!==o),n.rel8ns&&delete n.rel8ns[o],await gi({zeroSpace:e,bootstrapIbGib:n})},"fn"),secondsValid:qn})}h(Uh,"deregisterLocalSpaceFromBootstrap");async function Mh({spaceId:o,zeroSpace:e}){let t=`[${Mh.name}]`;if(!o)throw new Error("spaceId required. (E: 7c2a10529a1b412a8069e22e5190b623)");if(!e)throw new Error("zeroSpace required. (E: f112a512019c41a590b512a8e0915623)");let r=await e.argy({ibMetadata:Tt({space:e}),argData:{cmd:"get",ibGibAddrs:[o]}}),n=await e.witness(r);if(n?.data?.success&&(n.ibGibs?.length??0)>0){let a=I({ibGib:n.ibGibs[0]}),s=await e.argy({ibMetadata:Tt({space:e}),argData:{cmd:"delete",ibGibAddrs:[a]}});await e.witness(s)}}h(Mh,"deleteSpaceRecordFromZeroSpace");function Tt({space:o}){return`${o.ib} ${ft()}`}h(Tt,"getSpaceArgMetadata");function pd({space:o}){return`${o.ib} ${ft()}`}h(pd,"getSpaceResultMetadata");function Ei({space:o,spaceData:e,classname:t}){let r=`[${Ei.name}]`;try{if(!o&&!e)throw new Error("either space or spaceData required (E: 4dabec34ee77d67c9cc30ee3c3049622)");if(o&&!o.data)throw new Error("(UNEXPECTED) given space has falsy space.data? (E: 058d298876ebbeada7bbddb9e3da2f23)");if(o&&e){if(o.data.uuid!==e.uuid)throw new Error("(UNEXPECTED) both space and spaceData given, but uuid don't match? (E: efdd4603cba93a17340a76811fe56b24)");if(o.data.n!==e.n)throw new Error("(UNEXPECTED) both space and spaceData given, but n don't match? (E: e51278a707c9bccc57a08a4b86524524)")}if(e??=o.data,!e)throw new Error("(UNEXPECTED) spaceData falsy? (thought this was a compiler problem that this was even possible.) (E: b3c7ffedcae4b1f45b263b3825930b24)");if(t&&e.classname&&t!==e.classname)throw new Error(`both classname arg (${t}) and spaceData.classname (${e.classname}) are different truthy values. (E: f98f012ee876eb8fbe7403f7b53e4624)`);if(t||=e.classname,!t)throw new Error("classname required (E: fa3af4613ad56742dab51d1b0d839322)");if(t.includes(" "))throw new Error(`invalid classname (${t}). cannot contain spaces (E: 243adbf720dcce7904e2665933208b22)`);let n=e?.name||Bn;if(n.includes(" "))throw new Error("invalid space name. cannot contain spaces (E: a8450e1651081412c8ac018520182422)");let a=e?.uuid||void 0;if(!a)throw new Error("invalid space, spaceData.uuid falsy (E: 50ae723a9ab24f4fc7132613e65faf23)");if(a.includes(" "))throw new Error("invalid space id. cannot contain spaces (E: 8696830fe7f54bfa85e670a063f3e089)");let s=e.type??void 0,i=e.subtype??void 0;if(s&&!i)throw new Error(`spaceType (${s}) is set but spaceSubtype is falsy. (E: 878ab960d7987ae2331103b4a00d0d24)`);return`${na} ${jn} ${t} ${n} ${a} ${s} ${i}`}catch(n){throw console.error(`${r} ${n.message}`),n}}h(Ei,"getSpaceIb");function Fh({ib:o}){let e=`[${Fh.name}]`;if(!o){let t=`${e} ib required (E: dd5244f62f964359a86e59bb08ee47e6)`;throw console.error(t),new Error(t)}return o.startsWith(`${na} ${jn} `)}h(Fh,"isSpaceIb");function da({spaceIb:o}){let e=`[${da.name}]`;try{if(!o)throw new Error("spaceIb required (E: fa5424cfb7e846e2851562f2f417944f)");let[t,r,n,a,s,i,c]=o.split(" ");if(t!==na)throw new Error(`invalid spaceIb (${o}). witnessAtom !== WITNESS_ATOM (E: 5ae1ca12cf8f30ae341f3e582b025224)`);if(r!==jn)throw new Error(`invalid spaceIb (${o}). spaceAtom !== SPACE_ATOM (E: 9cc6b6f30e13455eb29748148a94fa0f)`);if(!n)throw new Error(`invalid spaceIb (${o}). spaceClassname falsy (E: 00d3392da007ca8b2840b16b199d9a24)`);if(!a)throw new Error(`invalid spaceIb (${o}). spaceName falsy (E: b957d8e74ef34d889fa64c60c7a5ea0b)`);if(!s)throw new Error(`invalid spaceIb (${o}). spaceId falsy (E: 7a1773722d8e46a0866d683130b65b89)`);let l;if(i&&i!=="undefined")if(Zn.includes(i))l=i;else throw new Error(`invalid spaceIb (${o}). spaceType (${i}) is set but not a valid type. valid types: ${Zn.join(", ")} (E: 838f4638a88cfbf3545a3a3a38b6dd24)`);let d;if(c&&c!=="undefined")if(Qn.includes(c))d=c;else throw new Error(`invalid spaceIb (${o}). spaceSubtype (${c}) is set but not a valid subtype. valid subtypes: ${Qn.join(", ")} (E: 5bdcf23027f94e73860e4340313b04ab)`);return{spaceClassname:n,spaceName:a,spaceId:s,spaceType:l,spaceSubtype:d}}catch(t){throw console.error(`${e} ${t.message}`),t}}h(da,"parseSpaceIb");async function ve({ibGibs:o,addrs:e,tjps:t,tjpAddrs:r,space:n}){let a=`[${ve.name}]`;try{if(P&&console.log(`${a} starting...`),!n)throw new Error("space required. (E: 4d188d6c863246f28aa575753a052304)");if(o=o??[],e=e??[],t=t??[],r=r??[],e.length===0&&o.length===0&&t.length===0&&r.length===0)throw new Error("Either addrs, ibGibs, tjps, or tjpAddrs required. (E: 7c6ebfbab98d4d21a431b144457fd991)");let s=new Set(r.concat(t.map(l=>I({ibGib:l})))),i=Array.from(s).map(l=>K({ibGibAddr:l}).gib);o.map(l=>I({ibGib:l})).concat(e).forEach(l=>{let{gib:d}=K({ibGibAddr:l});i.some(b=>d.includes(b))||s.add(l)}),P&&console.log(`${a}[testing] ${n.data?.name||n.ib} (${n.data?.uuid||"[space.data.uuid falsy]"}) addrsToQuery: ${Array.from(s)} (I: 8a2202912c364238b6d6eb09577bc246)`);let c=await n.argy({ibMetadata:Tt({space:n}),argData:{cmd:"get",cmdModifiers:["latest","addrs"],ibGibAddrs:Array.from(s)}});return await n.witness(c)}catch(s){throw console.error(`${a} ${s.message}`),s}}h(ve,"getLatestAddrs");function wi({ibGib_Context:o}){let e=`[${wi.name}]`;try{if(P&&console.log(`${e} starting... (I: 5f583fd94d27731a65d514e731b8aa22)`),!Jo({ibGib:o}))return;if(["roots","autosyncs"].some(r=>o.ib.includes(r)))throw new Error("cannot perform a modification of this type on this special ibgib (E: b8fb718a7323fc54454464b973412722)")}catch(t){throw console.error(`${e} ${t.message}`),t}finally{P&&console.log(`${e} complete.`)}}h(wi,"throwIfContextIsSpecial");async function Bh({ibGib_Context:o,rel8nName_Context:e,addr:t,space:r,zeroSpace:n,fnUpdateBootstrap:a,fnBroadcast:s}){let i=`[${Bh.name}]`;try{if(P&&console.log(`${i} starting... (I: 2dc486bb2d516e4534f437aaf5ec7f22)`),!o)throw new Error("ibGib_Context required (E: 75f7bfa93145d6dffe85d488443ca722)");if(!e)throw new Error("rel8nName_Context required (E: 12aaa43de9e34b68b25dc9a2a68ad6b9)");if(!t)throw new Error("addr required (E: e27df3bdc5a2554697cc9597afc4e422)");if(!r)throw new Error("space required (E: 2e3562486ed2956a770ed9e8d77a3f22)");let c=Jo({ibGib:o});c&&wi({ibGib_Context:o});let l=await ie({src:o,rel8nsToAddByAddr:{[Sl]:[t]},rel8nsToRemoveByAddr:{[e]:[t]},dna:!0,nCounter:!0});if(await V({resTransform:l,space:r}),c){let d=I({ibGib:l.newIbGib}),f=ba({ib:o.ib}),b=Me({type:f});await Je({key:b,addr:d,space:r,zeroSpace:n,fnUpdateBootstrap:a})}await J({ibGib:l.newIbGib,fnBroadcast:s,space:r})}catch(c){throw console.error(`${i} ${c.message}`),c}finally{P&&console.log(`${i} complete.`)}}h(Bh,"trash");async function kh({ibGib_Context:o,rel8nName_Context:e,addr:t,space:r,zeroSpace:n,fnUpdateBootstrap:a,fnBroadcast:s}){let i=`[${kh.name}]`;try{if(P&&console.log(`${i} starting... (I: 38098552b830495187299bb24fcddff0)`),!o)throw new Error("ibGib_Context required (E: d819e8c4db5b4c0bb721300ba434cd40)");if(!e)throw new Error("rel8nName_Context required (E: de061adff8c04429a211aa09116a532d)");if(!t)throw new Error("addr required (E: 7059ebb8ef6149ea94e22f961d6b5c81)");if(!r)throw new Error("space required (E: e19566f2d42347798621447edcae312e)");let c=Jo({ibGib:o});c&&wi({ibGib_Context:o});let l=await ie({src:o,rel8nsToAddByAddr:{[Gl]:[t]},rel8nsToRemoveByAddr:{[e]:[t]},dna:!0,nCounter:!0});if(await V({resTransform:l,space:r}),c){let d=I({ibGib:l.newIbGib}),f=ba({ib:o.ib}),b=Me({type:f});await Je({key:b,addr:d,space:r,zeroSpace:n,fnUpdateBootstrap:a})}await J({ibGib:l.newIbGib,fnBroadcast:s,space:r})}catch(c){throw console.error(`${i} ${c.message}`),c}finally{P&&console.log(`${i} complete.`)}}h(kh,"archive");function fa(o){let e=`[${fa.name}]`;try{if(!o)return console.error(`${e} name is falsy`),!1;let t=/[\w~.-]+/,r=o.match(t);if(r?.length!==1||r[0].length!==o.length)return console.error(`${e} name can only contain letters, numbers, underscores, hyphens, dots, and tildes`),!1;let n=/[a-zA-Z\d]/;return o[0].match(n)?!0:(console.error(`${e} name must start with a letter or number`),!1)}catch(t){return console.error(`${e} ${t.message}`),!1}}h(fa,"spaceNameIsValid");var ge=!1;function ot(o,e){return typeof o=="object"&&o!==null?`v:1^spaceId:${o.spaceId}^${o.ibGibAddr}`:`v:1^spaceId:${o}^${e}`}h(ot,"getSpaceQualifiedIbGibAddr");function ha(o){try{if(typeof o!="string"||!o.match(Hn))return!1;let t=Jt({sqAddr:o});return!0}catch{return!1}}h(ha,"isSpaceQualifiedAddr");function Jt({sqAddr:o}){let e=`[${Jt.name}]`;if(!o)throw new Error(`${e} sqAddr falsy (E: 3c7af8b05a68272478e830c89b617d26)`);if(typeof o!="string")throw new Error(`(UNEXPECTED) ${e} sqAddr not a string? (E: 172fd36b0e7d02905263bdef1374da26)`);let t=o.match(Hn);if(!t)throw new Error(`${e} invalid sqAddr (${o}). does not match SQ Addr regexp: ${Hn.source} (E: 71c93b63d4a82970c3bada8d92d4f826)`);let r=t[1],n=parseInt(r,10),a=t[2],s=t[3],i=qt({addr:s})??[];if(i.length>0)throw new Error(`${e} invalid sqAddr. ibGibAddr part is not a valid ibGibAddr. errors: ${i.join(",")} (E: 8e105870eb58c78978169d1d7b275526)`);let{ib:c,gib:l}=K({ibGibAddr:s});return{version:n,spaceId:a,ibGibAddr:s,ib:c,gib:l}}h(Jt,"parseSpaceQualifiedIbGibAddr");async function Ai({ibGib:o,rel8nNames:e,space:t}){let r=`[${Ai.name}]`;try{if(!o)throw new Error("ibGib required (E: 9764881f4c59113a98faabb87aba5826)");if(!t)throw new Error("space required (E: ee110894949865a8a9075938471e1826)");e||(e=Object.keys(o.rel8ns||{}));let n={};for(let a of e){let s=o.rel8ns?.[a]||[];if(s.length>0){let i=await z({addrs:s,space:t});if(i.success&&i.ibGibs?.length===s.length)n[a]=i.ibGibs.concat();else throw new Error(`Problem getting rel8d ibgibs for rel8nName: ${a}. ${i.errorMsg||"Unknown error"} (E: 372b27ed859ca276fe132e7cd3cd1826)`)}else n[a]=[]}return n}catch(n){throw console.error(`${r} ${E(n)}`),n}}h(Ai,"getRel8dIbGibs");async function _t({parentPrimitiveIb:o,ib:e,ibRegExpPattern:t,data:r,rel8ns:n}){let a=`[${_t.name}]`;try{if(!o)throw new Error("parentPrimitiveIb required. (E: 88ddf188cc5a4340b597abefba1481e2)");if(cr({ib:o})!==null)throw new Error(`Invalid parentPrimitiveIb: ${o}. (E:5aec0320956d492ebeeaca41eb1fe1c6)`);if(!e)throw new Error("ib required. (E: 7bbc88f4f2e842d6b00126e55b1783e4)");let s=t?new RegExp(t):gl;if(!e.match(s))throw new Error(`invalid ib. does not match regexp (${s})`);let i=Object.keys(n??{}),c=[...sr,"tjp"];if(i.some(b=>c.includes(b)))throw new Error(`Invalid rel8ns. forbiddenRel8nNames: ${c}. rel8ns keys: ${Object.keys(n??{})}. (E: 837a993c265c4362b6aa0b1a234ea5f8)`);let f=(await H.firstGen({ib:e,parentIbGib:H.primitive({ib:o}),data:r,rel8ns:n,dna:!1,noTimestamp:!0,nCounter:!1})).newIbGib;return f?.rel8ns?.past&&delete f.rel8ns.past,f?.rel8ns?.tjp&&delete f.rel8ns.tjp,f?.rel8ns?.identity&&delete f.rel8ns.identity,f.gib=await ee({ibGib:{ib:f.ib,data:f.data,rel8ns:f.rel8ns},hasTjp:!1}),f}catch(s){throw console.error(`${a} ${s.message}`),s}}h(_t,"constantIbGib");function pa({binHash:o,binExt:e,binEncoding:t}){return t?e?`bin ${o} ${e} enc=${t}`:`bin ${o} enc=${t}`:e?`bin ${o} ${e}`:`bin ${o}`}h(pa,"getBinIb");function Bw({addr:o}){return ud({addr:o})}h(Bw,"getBinHashAndExt");function ud({addr:o}){let e=`[${ud.name}]`;try{if(!Wo({addr:o}))throw new Error("not a bin address (E: df0804d129bc4888bd6939cb76c5e0f6)");let{ib:t}=K({ibGibAddr:o}),r=t.split(" ");if(r.length===2)return{binHash:r[1],binExt:""};if(r.length===3)return r[2].startsWith("enc=")?{binHash:r[1],binExt:"",binEncoding:r[2].substring(4)}:{binHash:r[1],binExt:r[2]};if(r.length===4){if(!r[3].startsWith("enc="))throw new Error(`bin ib (${t}) has 4 space-delimited pieces. we expect therefore the form to be bin \${binHash} \${binExt} enc=\${binEncoding}. but ibPieces[3] doesn't start with "enc=". (E: 87196d7cdd7c12d982cc8204a1163524)`);return{binHash:r[1],binExt:r[2],binEncoding:r[3].substring(4)}}else throw new Error('(UNEXPECTED) ibPieces.length not 2, 3, or 4? atow (01/2024) the only components of a bin ib are: atom, binHash, binExt, binEncoding. binExt and binEncoding are optional, with binEncoding being prefixed with "enc=". (E: b05df3c1b3949f76464a83c9fd1c4f24)')}catch(t){throw console.error(`${e} ${t.message}`),t}}h(ud,"parseBinIb");function Wo({ibGib:o,addr:e}){let t=`[${Wo.name}]`;try{if(!o&&!e)throw new Error("either ibGib or addr required. (E: c935b51e773f41a2a547c556e9dc16c6)");if(o&&!o.data)return!1;e=e||I({ibGib:o});let{ib:r,gib:n}=K({ibGibAddr:e});if(!r||!n||!r.startsWith("bin "))return!1;if(n.length!==64)throw new Error('ib starts with "bin " but gib length is not 64, so return false. Two things: 1) bin ibgibs are expected to be stones, i.e., have no temporal junction point and only a single punctiliar hash for the gib. the default hash used atow (01/2024) is sha-256, so the length should be 64. But this may not be true if using another hash algorithm. need to change this function when this becomes the case. (W: 60725d65d13c4b4fbb7b96d7feb19d67)');let a=r.split(" ");if(a.length===2){if(!a[1].match(Ie))throw new Error('(UNEXPECTED) ib starts with "bin " but space-delimited !ibPieces[1].match(UUID_REGEXP)? (E: f6baca2ff155f1017b278a5d7597a224)')}else if(a.length===3){if(!a[1].match(Ie))throw new Error('(UNEXPECTED) ib starts with "bin " but space-delimited !ibPieces[1].match(UUID_REGEXP)? (E: 8d0443d6cada4b50be79a8390a7a426c)')}else if(a.length===4){if(!a[1].match(Ie))throw new Error('(UNEXPECTED) ib starts with "bin " but space-delimited !ibPieces[1].match(UUID_REGEXP)? (E: 3209eacc0a3848a59593d4c3ee956191)');if(!a[3].startsWith("enc="))throw new Error('(UNEXPECTED) ib starts with "bin " but space-delimited !ibPieces[3].startsWith("enc=")? (E: 4c8a0c3b07a90d30e3d1a4373d57d824)')}else throw new Error('(UNEXPECTED) ib starts with "bin " but space-delimited ibPieces length is not 2, 3 or 4? (E: c7eccf88518304997c7e42b32e08d224)');return!0}catch(r){throw console.error(`${t} ${r.message}`),r}}h(Wo,"isBinary");function yi({type:o}){if(!o.match(Js))throw new Error(`special ibgib type must not have spaces and just be alphanumerics. regexp: ${Js.source} (E: 6c1c92521b7f076cc4666e4915593723)`);return`meta special ${o}`}h(yi,"getSpecialIbGibIb");function ba({ib:o}){let e=`[${ba.name}]`;try{if(ge&&console.log(`${e} starting... (I: c82ba222bd345ee6b695df4d63a23322)`),!o)throw new Error("ib required (E: 08897145f7138e644fe01c4a59353322)");if(!Jo({ib:o}))throw new Error("ib is not special (E: 174aff63b992adff3ac2394643735922)");let t=o.split(" ");if(t.length<3)throw new Error('invalid ib. should be space-delimited in form of "meta special [type]" (E: ffd89e2cbe63427f98634ab897aab222)');let r=t[2];return Object.values(jo).some(n=>n===r)||console.warn(`unknown special type (${r}). This may be expected, but atow I am adding special types to the SpecialIbGibType enum-like. (W: f4e26c3ebb57fe49d69014a4ba32a922)`),r}catch(t){throw console.error(`${e} ${t.message}`),t}finally{ge&&console.log(`${e} complete.`)}}h(ba,"getSpecialTypeFromIb");function jh({type:o}){return`${yi({type:o})}^${Q}`}h(jh,"getSpecialIbGibAddr");function Me({type:o}){return`${Cl} ${jh({type:o})}`}h(Me,"getSpecialConfigKey");function Jo({ib:o,ibGib:e}){if(!o&&!e?.ib)throw new Error("either ib or ibGib.ib required (E: b4cf539638d7966c2e351987f55e1a23)");return(o??e?.ib)?.startsWith("meta special")}h(Jo,"isSpecial");function $i(o){let e=`[${$i.name}]`;if(!o)throw new Error(`${e} text required.`);return`root ${o}`}h($i,"getRootIb");function Or(o){let e=`[${Or.name}]`;if(!o)throw new Error(`${e} tag required.`);return`tag ${o}`}h(Or,"tagTextToIb");function nt({ibGibs:o,filterPrimitives:e}){let t=`[${nt.name}]`;try{let r={},n={},a={};return(e?o.filter(i=>i.gib??i.gib!==Q):o).forEach(i=>{md({ibGib:i})?(i.rel8ns?.dna??[]).length>0?r[i.gib]=i:n[i.gib]=i:a[i.gib]=i}),{mapWithTjp_YesDna:r,mapWithTjp_NoDna:n,mapWithoutTjps:a}}catch(r){throw console.error(`${t} ${r.message}`),r}}h(nt,"splitPerTjpAndOrDna");function at({ibGibs:o}){let e=`[${at.name}]`;try{ge&&console.log(`${e} starting...`);let{mapWithTjp_YesDna:t,mapWithTjp_NoDna:r}=nt({ibGibs:o,filterPrimitives:!0}),n={...t,...r},a=Object.values(n),s=Uo({items:a,keyFn:h(i=>i.data?.isTjp?I({ibGib:i}):i.rel8ns?.tjp?i.rel8ns?.tjp[0]??"":(ge&&console.log(`${e} neither isTjp nor x.rel8ns.tjp truthy (I: ec9a5597bf53dec1bd3d83350abbf823)`),""),"keyFn")});return ge&&console.log(`${e} sorting (ascending) ibGibsWithTjpGroupedByTjpAddr: ${X(s)} (I: 9b9fff5ce61444a6cb06d62db9a99422)`),Object.entries(s).forEach(([i,c])=>{c.some(l=>l.data?.n===void 0)&&console.warn(`${e} timeline includes ibgibs with ibGib.data?.n === undefined (W: cab9a6b64a38c4279fe82c3569bbab22)`),c.sort((l,d)=>(l.data?.n??-1)>(d.data?.n??-1)?1:-1)}),ge&&console.log(`${e} after sort ibGibsWithTjpGroupedByTjpAddr: ${X(s)} (I: 9b9fff5ce61444a6cb06d62db9a99422)`),s}catch(t){throw console.error(`${e} ${t.message}`),t}finally{ge&&console.log(`${e} complete.`)}}h(at,"getTimelinesGroupedByTjp");function md({ibGib:o}){let e=`[${md.name}]`;if(!o)throw new Error("(UNEXPECTED) ibGib falsy? (E: ce3a59f9db14e6158bb2c438ca1a3823)");if((o.rel8ns?.tjp?.length??0)>0||o.data?.isTjp)return!0;let t=["fork^gib","mut8^gib","rel8^gib"];return(o.rel8ns?.ancestor??[]).some(n=>t.includes(n))?!1:o.gib?o.gib.includes(vt)?!0:o.gib===Q?!1:!!Ne({ibGibAddr:I({ibGib:o})}).tjpGib:(console.warn(`${e} ibGib.gib falsy. (W: 6400d780822b44d992846f1196509be3)`),!1)}h(md,"hasTjp");function ye({ibGib:o,defaultIfNone:e="undefined"}){let t=`[${ye.name}]`;try{let r=gd({ibGibs:[o],defaultIfNone:e});return r&&Object.keys(r).length===1?Object.values(r)[0]:void 0}catch(r){throw console.error(`${t} ${r.message}`),r}}h(ye,"getTjpAddr");function gd({ibGibs:o,defaultIfNone:e="undefined"}){let t=`[${gd.name}]`;try{let r={};return o.forEach(n=>{let a=I({ibGib:n}),s;n.rel8ns?.tjp?.length??!1?s=n.rel8ns.tjp[n.rel8ns.tjp.length-1]:n.data?.isTjp||e==="incomingAddr"?s=a:s=void 0,r[a]=s}),r}catch(r){throw console.error(`${t} ${r.message}`),r}}h(gd,"getTjpAddrs");async function Ii({ibGib:o,naive:e=!0}){let t=`[${Ii.name}]`;try{if(!o)throw new Error("ibGib required.");if(e){if(o.data)return o.data.isTjp?!0:o.rel8ns?o.rel8ns.past&&o.rel8ns.past.length>0?!1:!!(o.rel8ns.past&&o.rel8ns.past.length===0):(ge&&console.log(`${t} ibGib.rel8ns falsy (I: c69c9e78b34845311ce7c674d7195622)`),!1);throw new Error("loaded ibGib required (data).")}else throw new Error("only naive implemented right now.")}catch(r){throw console.error(`${t} ${r.message}`),r}}h(Ii,"isTjp_Naive");function Fe({ibGib:o}){let e=`[${Fe.name}]`;o.ib||console.warn(`${e} ibGib.ib is falsy. (W: e60e41c2a1fc48268379d88ce13cb77b)`),o.gib||console.warn(`${e} ibGib.gib is falsy. (W: fb3889cbf0684ae4ac51e48f28570377)`);let t={ib:(o.ib||"").slice()};return o.gib&&(t.gib=o.gib.slice()),o.data&&(Wo({ibGib:o})?t.data=o.data.slice():t.data=B(o.data)),o.rel8ns&&(t.rel8ns=B(o.rel8ns)),t}h(Fe,"toDto");function Lr(o){let e=`[${Lr.name}]`;try{return ge&&console.log(`${e} starting... (I: 57aef93fc6cc2309523b5c72a6b11823)`),!!o&&typeof o.ib=="string"}catch(t){throw console.error(`${e} ${t.message}`),t}finally{ge&&console.log(`${e} complete.`)}}h(Lr,"isIbGib");function hr({ibGib:o,data:e,timestamp:t}){let r=`[${hr.name}]`;try{ge&&console.log(`${r} starting... (I: 35cb68744bcf6139d78e37de644fad23)`),t=t||e?.timestamp||o?.data?.timestamp;let n=o?.data?.timestampMs||e?.timestampMs;if(!t){let a=`${r} timestamp is falsy. (W: 5f1f1182c8804807b886a3d922ac3dcf)`;return console.warn(a),{valid:!1,emsg:a}}if(typeof t=="string")if(Number.isInteger(Number.parseInt(t))){let a=Number.parseInt(t),s=new Date;if(s.setTime(a),s.toString()!==Xn)return ge&&console.log(`${r} valid timestampInTicks string (I: 7069a1c3047f3bbc92b78674b20f5b23)`),{valid:!0,date:s,utc:s.toUTCString(),ticks:s.getTime().toString(),ms:n};{let i=`${r} data.timestamp (${t}) is an integer string but not a valid timestampInTicks string. (produces invalid date) (E: f49fbb600fe1426c8805dfc8afbe5cf3)`;return console.error(i),{valid:!1,emsg:i}}}else{let a=new Date(t);if(a.toString()!==Xn)return{valid:!0,date:a,utc:a.toUTCString(),ticks:a.getTime().toString(),ms:n};{let s=`${r} data.timestamp is a non-integer string but not a valid date timestamp string (new date instantiated produces invalid date). (W: c6c90f7f3bfb49838d2081ba84fdb5fb)`;return console.warn(s),{valid:!1,emsg:s}}}else if(typeof t=="number")if(Number.isInteger(t)){console.warn(`${r} expected data.timestamp to be a string but is a number (W: 9d786f4d4e8d4279b5af7bee19bf721b)`);let a=new Date;if(a.setTime(t),a.toString()!==Xn)return{valid:!0,date:a,utc:a.toUTCString(),ticks:a.getTime().toString(),ms:n};{let s=`${r} timestamp (${t}) is an integer number but not a valid timestampInTicks (new date setTime produces invalid date). (W: c6c90f7f3bfb49838d2081ba84fdb5fb)`;return console.warn(s),{valid:!1,emsg:s}}}else{let a=`${r} timestamp (${t}) is a non-integer number (supposed to be a string either timestamp string or ticks). (E: 2963d95f8d3b464c992b0bff948b4479)`;return console.error(a),{valid:!1,emsg:a}}else{let a=`${r} unknown typeof timestamp (${typeof t}). (E: 12458a9c16c84e4f859b5771a30dd2ef)`;return console.error(a),{valid:!1,emsg:a}}}catch(n){throw console.error(`${r} ${E(n)}`),n}finally{ge&&console.log(`${r} complete.`)}}h(hr,"getTimestampInfo");async function Ve({addrs:o,readCache_graph:e,readCache_array:t,space:r}){let n=`[${Ve.name}]`;try{ge&&console.log(`${n} starting... (I: 5db66871239dfa05182277f886a20926)`),e??={},t??=[];let a={...e};t.forEach(l=>a[I({ibGib:l})]=l);let s=Object.keys(e),i=o.filter(l=>!s.includes(l));if(i.length>0){ge&&console.log(`${n} ${i.length} addrsNotFoundInCache: ${i} (I: fccbd18116ffb849f813aaebfc6c0826)`);let l=[r],d=i.concat();for(let f of l){let b=await z({addrs:d,space:f});if(b.success&&b.ibGibs&&b.ibGibs.length===d.length)b.ibGibs.forEach(p=>a[I({ibGib:p})]=p),d=[];else if(b.ibGibs&&b.ibGibs.length>0){if(d=d.filter(p=>!b.ibGibs.some(u=>I({ibGib:u})===p)),d.length===0)break}else ge&&console.log(`${n} no addrs found in space (${f.ib}). trying next space. (I: 4f99d8bacbb10ab3f8737a752564b326)`)}if(d.length>0)throw new Error(`could not get all addrs from cache or spaces. addrsStillNotFound: ${d}. spaces: ${l.map(f=>f.ib).join("|")} (E: 0c6418f83dd85bda886e56f5b98f3126)`)}let c=[];for(let l of o){let d=a[l];if(!d)throw new Error(`(UNEXPECTED) allIbGibs_graph doesn't have addr? We're expecting logic to preclude this at this point. addr: ${l} (E: f68e1d236ae5e3eb08da9933c8230626)`);c.push(d)}return c}catch(a){throw console.error(`${n} ${E(a)}`),a}finally{ge&&console.log(`${n} complete.`)}}h(Ve,"getIbGibsFromCache_fallbackToSpaces");async function ae({addr:o,space:e,metaspace:t}){let r=`[${ae.name}]`;try{if(ge&&console.log(`${r} starting... (I: 9252059c96132637381b3be5486e6826)`),!o)throw new Error("(UNEXPECTED) addr falsy? (E: aeb9084d7f68dabb8a49fd68526ff826)");if(!e)throw new Error("(UNEXPECTED) space falsy? (E: 3ec9df4de82847e13f087bea6f98b826)");let n=ha(o)?Jt({sqAddr:o}).ibGibAddr:o,a=qt({addr:n})??[];if(a.length>0)throw new Error(`invalid incoming addr (${o}). (if space-qualified, then invalid extracted ibGibAddr). errors: ${a.join(", ")} (E: 040dbbcac39990abc8871a1d08b3d826)`);let s;try{let i=await z({space:e,addrs:[n]});if(!i.success||i.errorMsg)throw new Error(`resGet failed. resGet.success: ${i.success}.errorMsg: ${i.errorMsg} (E: 13f3d82381b87f8078583ad8b3676826)`);if(!i.ibGibs)throw new Error("(UNEXPECTED) resGet.success and no errorMsg, but resGet.ibGibs falsy? (E: f3a75e6fe96b07d288ba9b3976e84826)");if(i.ibGibs.length===0)throw new Error("(UNEXPECTED) resGet.success and no errorMsg, but resGet.ibGibs empty? (E: 4a06589d30050208284fef68adf20426)");if(i.ibGibs.length>1)throw new Error("(UNEXPECTED) resGet.success and no errorMsg, but resGet.ibGibs.length > 1? what in the world? (E: a4d01caa4a78a0a1581b3bb8748af826)");s=i.ibGibs[0]}catch(i){ge&&console.log(`${r} suppressing error: ${E(i)} (I: 1256ce73d8e8b567ff4fee4ea48c5d26)`)}return s}catch(n){throw console.error(`${r} ${E(n)}`),n}finally{ge&&console.log(`${r} complete.`)}}h(ae,"getIbGibFromSpace");async function st({addrs:o,space:e}){let t=`[${st.name}]`;try{if(ge&&console.log(`${t} starting... (I: 648eb9b61718fbc1684aabc60cba6826)`),!o)throw new Error("(UNEXPECTED) addrs falsy? (E: 258e489345f1c4b5794e4618f4118c26)");if(!e)throw new Error("(UNEXPECTED) space falsy? (E: 9cb95bc39b41c1756c6e85384f766a26)");if(o.length===0)return[];let r=o.map(i=>ha(i)?Jt({sqAddr:i}).ibGibAddr:i);for(let i of r){let c=qt({addr:i})??[];if(c.length>0)throw new Error(`invalid incoming addr (${i}). errors: ${c.join(", ")} (E: 1674df15579c46cecd035ff637f41426)`)}let n=await z({space:e,addrs:r});if(!n.success||n.errorMsg)throw new Error(`resGet failed. resGet.success: ${n.success}. errorMsg: ${n.errorMsg} (E: 1a4c08eabeb957f388a79d7b42b60b26)`);if(!n.ibGibs||n.ibGibs.length!==r.length){let c=n.rawResultIbGib?.data?.addrsNotFound??"unknown";throw new Error(`couldn't find all addrs. addrsNotFound: ${c}? resGet.errorMsg: ${n.errorMsg} (E: 5ee272792fe8af335a8fd918c0971a26)`)}let a=new Map;for(let i of n.ibGibs||[]){let c=I({ibGib:i});a.set(c,i)}let s=[];for(let i of r){let c=a.get(i);c&&s.push(c)}return s}catch(r){throw console.error(`${t} ${E(r)}`),r}finally{ge&&console.log(`${t} complete.`)}}h(st,"getIbGibsFromSpace");async function ua({ibGib:o,space:e}){let t=`[${ua.name}]`;try{ge&&console.log(`${t} starting... (I: 64f6a8bd1248f8c3c8c86834431adb26)`);let r=I({ibGib:o}),n=ye({ibGib:o,defaultIfNone:"undefined"});if(!n)return ge&&console.log(`${t} tjpAddr falsy. returning incoming ibGib (no timeline means no latest tip possible) (I: 621528e00b6988f0abb8a161e7042226)`),o;let a=await ve({ibGibs:[o],space:e});if(!a)throw new Error("(UNEXPECTED) resLatest falsy? (E: 8ce878315ec4020c082ee7796084b826)");if(!a.data)throw new Error("(UNEXPECTED) resLatest.data falsy? (E: 3af5a84dd1eba399fcca51e179b36826)");if(!a.data.latestAddrsMap)throw new Error("(UNEXPECTED) resLatest.data.latestAddrsMap falsy? (E: 37276c35ae58f65cb674389343c2fc26)");let{latestAddrsMap:s}=a.data,i=s[r]??s[n]??r;if(i&&i!==r){let c=await ae({addr:i,space:e});if(c&&(c.data?.n??0)>=(o.data?.n??0))return c;console.warn(`${t} did not find latest. using incoming ibGib (W: 1079fd20b9183fc8a8fef55a8ad2d826)`)}return o}catch(r){throw console.error(`${t} ${E(r)}`),r}finally{ge&&console.log(`${t} complete.`)}}h(ua,"resolveLatestIbGibInSpace");async function ma({ibGibs:o,space:e}){let t=`[${ma.name}]`;try{if(ge&&console.log(`${t} starting... (I: 8b0c418702fb42a6a12ee0153833f426)`),!e)throw new Error("space required. (E: b65c19273c524e9389271630af220926)");if(!o||o.length===0)return[];let r=[],n=[],a=[];for(let b of o){let p=I({ibGib:b}),u=ye({ibGib:b,defaultIfNone:"undefined"});n.push(p),a.push(u||""),u&&r.push(b)}if(r.length===0)return o;let s=await ve({ibGibs:r,space:e});if(!s||!s.data||!s.data.latestAddrsMap)throw new Error("(UNEXPECTED) resLatest or latestAddrsMap falsy? (E: a951d3820ff541c88ba46f7725902126)");let{latestAddrsMap:i}=s.data,c=[],l=[];for(let b=0;b<o.length;b++){let p=n[b],u=a[b],m=i[p]??i[u]??p;l.push(m),m&&m!==p&&c.push(m)}let d=new Map;if(c.length>0){let b=Array.from(new Set(c)),p=await st({addrs:b,space:e});for(let u of p){let m=I({ibGib:u});d.set(m,u)}}let f=[];for(let b=0;b<o.length;b++){let p=o[b],u=l[b];if(u&&u!==n[b]){let m=d.get(u);if(m&&(m.data?.n??0)>=(p.data?.n??0)){f.push(m);continue}}f.push(p)}return f}catch(r){throw console.error(`${t} ${E(r)}`),r}finally{ge&&console.log(`${t} complete.`)}}h(ma,"resolveLatestIbGibsInSpace");var Ed=!1,qh="space_gib_db",Xh="space_gib_store",Hh="space_gib_api_key";var Vh="agent";var Hw=Or(Vh);var Vw={dbName:qh,storeName:Xh,additionalStoreNames:[Fn],apiKeyName:Hh};var wd="0.0.36";var pr=!1,zw="[web^gib timer]",ga="ibgib";var Wh="agent",Jw="body-outline",Zw="This tag tracks the active agents for the current local user space.",Qw=Or(Wh),yd="#78f87e88",$d="#78f87e10",Id="#ffffff";var e2="AUTOMATED_TEXT";var Gt=!1;function Ad(o){return new Promise((e,t)=>{let r=new Blob([o],{type:"application/octet-stream"}),n=new FileReader;n.onload=()=>{let s=n.result.split(",")[1];e(s)},n.onerror=a=>t(a),n.readAsDataURL(r)})}h(Ad,"uint8ArrayToBase64");async function _d(o){let e=`data:application/octet-stream;base64,${o}`,n=await(await(await fetch(e)).blob()).arrayBuffer();return new Uint8Array(n)}h(_d,"base64ToUint8Array");async function Ea({graph:o}){let e=`[${Ea.name}]`;try{Gt&&console.log(`${e} starting... (I: 4ddb8803cf68e1d3d35f60680cb69825)`);let t=JSON.parse(JSON.stringify(o));for(let n in t)o[n].data instanceof Uint8Array&&(t[n].data={_dataType:"Uint8Array_Base64",value:await Ad(o[n].data)});let r=JSON.stringify(t);return Gt&&console.log(`${e} jsonString.length: ${r.length} (I: 56dec8ad0931ab8ba9b5ca3d4e66be25)`),r}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Gt&&console.log(`${e} complete.`)}}h(Ea,"serializeGraphToString");async function wa({jsonString:o}){let e=`[${wa.name}]`;try{Gt&&console.log(`${e} starting... (I: 52e1a1fb1adcc75168fbc6d819868825)`);let r=JSON.parse(o,h((n,a)=>(a&&a._dataType==="Uint8Array_Base64",a),"reviver"));for(let n in r){let a=r[n].data;a&&a._dataType==="Uint8Array_Base64"&&(r[n].data=await _d(a.value))}return r}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Gt&&console.log(`${e} complete.`)}}h(wa,"deserializeStringToGraph");async function Td(o){let e=`[${Td.name}]`;try{Gt&&console.log(`${e} starting... (I: 8d306868b718596fe8f562bd5118d825)`);let t=await Ea({graph:o}),r=new TextEncoder().encode(t),a=new Response(r).body.pipeThrough(new CompressionStream("gzip"));return await new Response(a).blob()}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Gt&&console.log(`${e} complete.`)}}h(Td,"compressIbGibToBlob");async function Yh(o){let e=o.stream().pipeThrough(new DecompressionStream("gzip")),t=await new Response(e).text();return await wa({jsonString:t})}h(Yh,"decompressIbGibFromBlob");async function _i({graph:o}){let e=`[${_i.name}]`;try{Gt&&console.log(`${e} starting... (I: 1352f8540c08f0b725952df8f18c4825)`);let r=await(await Td(o)).arrayBuffer(),n=new Uint8Array(r);return await Ad(n)}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Gt&&console.log(`${e} complete.`)}}h(_i,"compressIbGibGraphToString");async function Ti({compressedBase64:o}){let e=`[${Ti.name}]`;try{Gt&&console.log(`${e} starting... (I: 5f3fa940a2c8f8d7b877978ae7f87825)`);let t=await _d(o),r=new Blob([t],{type:"application/gzip"});return await Yh(r)}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Gt&&console.log(`${e} complete.`)}}h(Ti,"decompressIbGibGraphFromString");var Gd="export";var Zo=!1;function Sd({data:o}){let e=`[${Sd.name}]`;try{Zo&&console.log(`${e} starting... (I: 158dfaeb9613a1531be71a9735184624)`);let{graphSize:t,dependencyGraphAsString:r,timestamp:n}=o,a=r.length,s=ft(n),i=o.compression==="gzip"?"gzip":"raw";if(!o.timestamp)throw new Error("(UNEXPECTED) data.timestamp falsy? (E: 2f5bc88488cbf260634239a8a8396825)");let c=new Date(o.timestamp),{ib:l,gib:d}=K({ibGibAddr:o.contextIbGibAddr}),b=Ne({gib:d}).tjpGib??d,p=c.toISOString().slice(0,19).replace("T","_").replace(/:/g,"").replace(/ /g,"_");return`${Gd} ${p} ${i} ${t} ${a} ${b}`}catch(t){throw console.error(`${e} ${E(t)}`),t}finally{Zo&&console.log(`${e} complete.`)}}h(Sd,"getRawExportIb");async function Gi({ibGib:o,metaspace:e,space:t,compress:r,live:n,ignoreErrors:a}){let s=`[${Gi.name}]`;try{if(Zo&&console.log(`${s} starting... (I: 0b6ba8608ba8bde0682a0936b9a01825)`),!o)throw new Error("(UNEXPECTED) ibGib falsy? (E: d2898eea744360865f0da5fb91baae22)");let i=I({ibGib:o}),c=[],l=await ne({ibGib:o})??[];if(l.length>0){let y=`ibGib had validation errors: ${l} (E: 84890bbc0598192498178a98ae299825)`;if(a)c.push({errorMsg:y,ibGibAddr:i});else throw new Error(y)}let d=await e.getDependencyGraph({ibGib:o,live:n,space:t}),f=r?await _i({graph:d}):await Ea({graph:d}),b=ye({ibGib:o,defaultIfNone:"incomingAddr"})??i,p=new Date,u={contextIbGibAddr:i,tjpAddr:b,dependencyGraphAsString:f,graphSize:Object.keys(d).length,timestamp:rt(p),timestampMs:p.getMilliseconds()};r&&(u.compression="gzip");let m={ib:Sd({data:u}),data:u},g=await ee({ibGib:m,hasTjp:!1});return m.gib=g,Zo&&console.log(`${s} JSON.stringify(exportIbGib).length: ${JSON.stringify(m).length} (I: db3a8d913a91d8fc5d6e45981e034822)`),{rawExportIbGib:m,manifest:Object.keys(d),errors:c.length>0?c:void 0}}catch(i){throw console.error(`${s} ${E(i)}`),i}finally{Zo&&console.log(`${s} complete.`)}}h(Gi,"getRawExportIbGib");var g2="ibgib-shell-ready",E2="ibgib-ui-busy",w2="ibgib-ui-message",y2="ibgib-identity-request-change",$2="ibgib-identity-changed",I2="ibgib-identity-update-available",A2="ibgib-identity-renewal-required",_2="show-identity-manager",T2="show-keystone-creator",G2="show-add-device",S2="show-privacy-policy";var xd=pr;async function ur({title:o,msg:e,prompt:t,showInput:r,defaultValue:n,okButtonTitle:a,cancelButtonTitle:s,isPassword:i,isBusy:c,animationEmoji:l,passkeys:d,passkeyButtonTitle:f,onPasskeyAuth:b}){let p=`[${ur.name}]`;try{xd&&console.log(`${p} starting... (I: 037b228a2568181cd3eb25dba4e03225)`);let u=document.getElementById("fullscreen-dialog"),m=document.getElementById("fullscreen-dialog-body"),g=document.getElementById("fullscreen-dialog-title"),y=document.getElementById("fullscreen-dialog-message"),w=document.getElementById("fullscreen-dialog-prompt-input"),A=document.getElementById("fullscreen-dialog-ok-button"),G=document.getElementById("fullscreen-dialog-cancel-button");if(!u||!m||!g||!y||!w||!A||!G)throw new Error("(UNEXPECTED) One or more dialog elements not found in DOM (E: 578e37c0271cc57a99e95e780ad18a25)");if(g.textContent=o||"",[...y.childNodes].forEach(x=>y.removeChild(x)),(e||"").split(`
|
|
9
9
|
`).forEach(x=>{let L=document.createElement("p");L.textContent=x,y.appendChild(L)}),l){let x=document.createElement("div");x.id="fullscreen-dialog-animation-emoji",x.textContent=l,x.style.fontSize="3.5rem",x.style.textAlign="center",x.style.margin="1.5rem 0",x.style.animation="spin-bounce 5s infinite ease-in-out",y.appendChild(x)}let $=document.getElementById("fullscreen-dialog-passkey-container");$&&$.remove();let _=null,S=null,D=null,C=Object.values(d||{}).filter(x=>x!=null);if(C.length>0&&b&&!c){_=document.createElement("div"),_.id="fullscreen-dialog-passkey-container",_.style.margin="1rem 0",_.style.textAlign="center",S=document.createElement("button"),S.id="fullscreen-dialog-btn-passkey",S.type="button",S.className="action-btn",S.style.width="100%",S.style.padding="0.75rem 1rem",S.style.background="linear-gradient(135deg, #1b5e20, #2e7d32)",S.style.color="#ffffff",S.style.fontWeight="bold",S.style.borderRadius="8px",S.style.border="1px solid rgba(255,255,255,0.2)",S.style.cursor="pointer",S.style.fontSize="0.95rem",S.style.marginBottom="0.75rem",S.textContent=f||"\u{1F6E1}\uFE0F Touch ID / Security Key",C.length>1&&(D=document.createElement("select"),D.style.width="100%",D.style.padding="0.4rem",D.style.marginBottom="0.5rem",D.style.borderRadius="4px",D.style.background="rgba(0,0,0,0.3)",D.style.color="inherit",D.style.border="1px solid rgba(255,255,255,0.2)",C.forEach((L,U)=>{let O=document.createElement("option");O.value=U.toString(),O.textContent=`${L.name||"Key"} (${L.credentialId?.substring(0,8)}...)`,D.appendChild(O)}),_.appendChild(D)),_.appendChild(S);let x=document.createElement("div");x.style.display="flex",x.style.alignItems="center",x.style.justifyContent="center",x.style.gap="0.5rem",x.style.fontSize="0.8rem",x.style.color="var(--clr-text-secondary, #b3b3b3)",x.style.margin="0.5rem 0",x.innerHTML=`
|
|
10
10
|
<span style="flex: 1; height: 1px; background: rgba(255,255,255,0.15);"></span>
|
|
11
11
|
<span>OR enter Password below</span>
|