paracosm 0.9.996 → 0.9.1000

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.
@@ -106,7 +106,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
106
106
  "score": 0.82,
107
107
  "rationale": "Roles consistent with departmental authority; arithmetic checks out."
108
108
  }
109
- }`;function hp(e){e.preventDefault();let t=new URL(window.location.href);t.searchParams.set(`tab`,`settings`),t.searchParams.delete(`sub`),window.history.replaceState({},``,t.toString()),window.dispatchEvent(new PopStateEvent(`popstate`))}function gp(){return(0,x.jsxs)(`section`,{className:ai.guide,"aria-label":`How to author a RunArtifact JSON`,children:[(0,x.jsxs)(`div`,{className:ai.guideHead,children:[(0,x.jsx)(`h3`,{className:ai.guideTitle,children:`How to get a RunArtifact JSON`}),(0,x.jsxs)(`p`,{className:ai.guideSub,children:[`Studio takes a deterministic Paracosm `,(0,x.jsx)(`code`,{children:`RunArtifact`}),` — the JSON that a single sim run produces — and lets you inspect, promote to the Library, branch, or compare. Four steps to author one.`]})]}),(0,x.jsxs)(`ol`,{className:ai.guideSteps,children:[(0,x.jsxs)(`li`,{children:[(0,x.jsx)(`strong`,{children:`Configure a scenario in Settings.`}),` Pick a built-in (Frontier AI Lab, Submarine, Corporate Quarterly, T2D Protocol) or load your own. Set turns, seed, population, time-per-turn.`]}),(0,x.jsxs)(`li`,{children:[(0,x.jsx)(`strong`,{children:`Run the sim.`}),` Switch to the Sim tab, hit Run. The runtime emits events deterministically, the actor LLM produces dialogue and decisions, and the judge attaches a verdict at the end.`]}),(0,x.jsxs)(`li`,{children:[(0,x.jsx)(`strong`,{children:`Download the artifact.`}),` Sim output panel has a Save button — that JSON is the RunArtifact. You can also produce one from the CLI: `,(0,x.jsx)(`code`,{children:`paracosm run scenarios/frontier-ai-lab.json --turns 20 --out run.json`}),`.`]}),(0,x.jsxs)(`li`,{children:[(0,x.jsx)(`strong`,{children:`Drop it in the zone below.`}),` Single artifact or a bundle (array of artifacts, e.g. for branch comparisons). Max 10\xA0MB.`]})]}),(0,x.jsxs)(`div`,{className:ai.guideCtaRow,children:[(0,x.jsx)(`a`,{href:`?tab=settings`,onClick:hp,className:ai.guideCta,children:`Open Settings →`}),(0,x.jsx)(`a`,{href:`https://github.com/framerslab/paracosm/blob/master/docs/COOKBOOK.md`,target:`_blank`,rel:`noopener noreferrer`,className:ai.guideCtaSecondary,children:`Read the cookbook`}),(0,x.jsx)(`a`,{href:`https://github.com/framerslab/paracosm/tree/master/scenarios`,target:`_blank`,rel:`noopener noreferrer`,className:ai.guideCtaSecondary,children:`Browse example scenarios`})]}),(0,x.jsxs)(`details`,{className:ai.guideExample,children:[(0,x.jsx)(`summary`,{children:`Show an example RunArtifact`}),(0,x.jsx)(`pre`,{className:ai.guideExampleCode,children:(0,x.jsx)(`code`,{children:mp})}),(0,x.jsxs)(`p`,{className:ai.guideExampleNote,children:[`Real artifacts include the full event log, the per-turn snapshot of every actor, KPIs, and the judge verdict. The shape matches the `,(0,x.jsx)(`code`,{children:`RunArtifact`}),` Zod schema in `,(0,x.jsx)(`code`,{children:`schema/index.ts`}),`; bundles are a JSON array of artifacts.`]})]})]})}function _p(e){let{artifact:t,inline:n,onPromote:r,onCompare:i,promoteBusy:a,alreadyExisted:o}=e,s=t.metadata.mode,c=t.leader?.name??`<unnamed actor>`,l=t.metadata.scenario.name??t.metadata.scenario.id,u=b.useMemo(()=>{let e={},n=(t.trajectory?.timepoints?.[0])?.worldSnapshot?.metrics??{};for(let t of Object.keys(n))e[t]={id:t,label:t,range:[0,1]};return e},[t]);return(0,x.jsxs)(`div`,{className:ai.artifactView,children:[(0,x.jsxs)(`header`,{className:ai.artifactHead,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:ai.artifactScenario,children:l}),(0,x.jsxs)(`div`,{className:ai.artifactActor,children:[c,` · `,s]})]}),!n&&(0,x.jsxs)(`div`,{className:ai.artifactActions,children:[(0,x.jsx)(`button`,{type:`button`,className:ai.promoteBtn,onClick:r,disabled:a||o,children:o?`Already in Library`:a?`Promoting…`:`Promote to Library`}),(0,x.jsx)(`button`,{type:`button`,className:ai.compareBtn,onClick:i,children:`Compare`})]})]}),(0,x.jsx)(`div`,{className:ai.artifactBody,children:s===`turn-loop`?(0,x.jsx)(pr,{artifact:t}):(0,x.jsx)(dr,{artifact:t,metricSpecs:u})})]})}function vp(e){let{artifacts:t,bundleId:n,onPromote:r,onCompare:i,promoteBusy:a,alreadyExisted:o}=e,[s,c]=b.useState(null);if(s!==null&&t[s]){let e=t[s];return(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`button`,{type:`button`,className:ai.bundleDrillBack,onClick:()=>c(null),children:`← Back to bundle`}),(0,x.jsx)(_p,{artifact:e,inline:!0,onPromote:()=>{},onCompare:()=>{}})]})}return(0,x.jsxs)(`div`,{children:[n&&(0,x.jsx)(`div`,{className:ai.bundleIdChip,title:n,children:n.length>32?`${n.slice(0,28)}…`:n}),(0,x.jsxs)(`div`,{className:ai.bundleActions,children:[(0,x.jsx)(`button`,{type:`button`,className:ai.promoteBtn,onClick:r,disabled:a||o,children:o?`Already in Library`:a?`Promoting…`:`Promote bundle (${t.length})`}),(0,x.jsx)(`button`,{type:`button`,className:ai.compareBtn,onClick:i,children:`Compare bundle`})]}),(0,x.jsx)(`div`,{className:ai.bundleGrid,children:t.map((e,t)=>{let n=e.leader,r=e.cost?.totalUSD,i=e.trajectory?.timepoints?.length??0;return(0,x.jsxs)(`button`,{type:`button`,className:ai.bundleCard,onClick:()=>c(t),children:[(0,x.jsx)(`div`,{className:ai.bundleCardTitle,children:n?.name??`<unnamed>`}),(0,x.jsxs)(`div`,{className:ai.bundleCardMeta,children:[n?.archetype??``,` · `,i,` turn`,i===1?``:`s`,typeof r==`number`?` · $${r.toFixed(3)}`:``]})]},e.metadata.runId)})})]})}function yp(){let[e,t]=b.useState(!1),[n,r]=b.useState(null),[i,a]=b.useState(null);return{promoteSingle:b.useCallback(async e=>{t(!0),a(null);try{let t=await fetch(`/api/v1/library/import`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({artifact:e})});if(!t.ok){let e=await t.json().catch(()=>({}));return a(e.error??`Promote failed: HTTP ${t.status}`),null}let n={kind:`single`,...await t.json()};return r(n),n}catch(e){return a(e instanceof Error?e.message:String(e)),null}finally{t(!1)}},[]),promoteBundle:b.useCallback(async e=>{t(!0),a(null);try{let t=await fetch(`/api/v1/library/import`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({artifacts:e})});if(!t.ok){let e=await t.json().catch(()=>({}));return a(e.error??`Promote failed: HTTP ${t.status}`),null}let n={kind:`bundle`,...await t.json()};return r(n),n}catch(e){return a(e instanceof Error?e.message:String(e)),null}finally{t(!1)}},[]),busy:e,lastResult:n,error:i}}function bp(){let e=ew();return(0,b.useMemo)(()=>ne(e),[e.labels?.populationNoun,e.labels?.settlementNoun,e.labels?.timeUnitNoun,e.labels?.timeUnitNounPlural])}function xp(e,t){return typeof e==`number`&&typeof t==`number`?t>e?`up`:t<e?`down`:`unchanged`:e===t?`unchanged`:`changed`}function Sp(e,t){let n=[`metrics`,`capacities`,`statuses`,`environment`,`politics`],r=[],i=e.finalState,a=t.finalState;if(!i||!a)return r;for(let e of n){let t=i[e],n=a[e];if(t&&n)for(let i of Object.keys(t)){if(!(i in n))continue;let a=t[i],o=n[i],s=xp(a,o);if(s===`unchanged`)continue;let c=typeof a==`number`&&typeof o==`number`?o-a:void 0;r.push({bag:e,key:i,parentValue:a,branchValue:o,delta:c,direction:s})}}return r.sort((e,t)=>e.delta!==void 0&&t.delta!==void 0?Math.abs(t.delta)-Math.abs(e.delta):e.delta===void 0?t.delta===void 0?0:1:-1)}function Cp(e){if(e.delta!==void 0){let t=e.delta>0?`+`:``,n=Math.round(e.delta*10)/10;return`${e.key} ${t}${n}`}return`${e.key}: ${e.parentValue} → ${e.branchValue}`}var wp={tab:`_tab_e8hr7_1`,emptyState:`_emptyState_e8hr7_11`,parentCard:`_parentCard_e8hr7_48`,branchCard:`_branchCard_e8hr7_48`,branchList:`_branchList_e8hr7_77`,cardHeader:`_cardHeader_e8hr7_83`,branchMeta:`_branchMeta_e8hr7_91`,parentTitle:`_parentTitle_e8hr7_99`,branchTitle:`_branchTitle_e8hr7_99`,archetype:`_archetype_e8hr7_111`,meta:`_meta_e8hr7_117`,badge:`_badge_e8hr7_129`,status:`_status_e8hr7_143`,status_running:`_status_running_e8hr7_153`,status_complete:`_status_complete_e8hr7_158`,status_aborted:`_status_aborted_e8hr7_163`,status_error:`_status_error_e8hr7_168`,metrics:`_metrics_e8hr7_174`,metric:`_metric_e8hr7_174`,deltas:`_deltas_e8hr7_208`,delta:`_delta_e8hr7_208`,direction_up:`_direction_up_e8hr7_225`,direction_down:`_direction_down_e8hr7_229`,direction_changed:`_direction_changed_e8hr7_233`,more:`_more_e8hr7_238`,identical:`_identical_e8hr7_245`,error:`_error_e8hr7_253`};function Tp(){let{state:e}=Wt(),t=bp(),n=nw();return!e.parent&&e.branches.length===0?(0,x.jsxs)(`div`,{className:wp.emptyState,role:`region`,"aria-label":`Branches (empty)`,children:[(0,x.jsx)(`h2`,{children:`No branches yet`}),(0,x.jsxs)(`p`,{children:[`Run a simulation with snapshot capture enabled (default for dashboard runs), then open the `,(0,x.jsx)(`strong`,{children:`Reports`}),` tab and click`,` `,(0,x.jsxs)(`code`,{children:[`↳ Fork at `,t.Time,` N`]}),` on any completed turn to branch with a different leader.`]})]}):(0,x.jsxs)(`div`,{className:wp.tab,role:`region`,"aria-label":`Branches`,children:[e.parent&&(0,x.jsx)(Ep,{artifact:e.parent,labels:t}),(0,x.jsx)(`div`,{className:wp.branchList,children:e.branches.map(r=>(0,x.jsx)(Dp,{branch:r,parent:e.parent,labels:t,onOpen:()=>n(`reports`)},r.localId))})]})}function Ep({artifact:e,labels:t}){let n=e.finalState?.metrics??{},r=e.trajectory?.timepoints?.length??0;return(0,x.jsxs)(`section`,{className:wp.parentCard,"aria-label":`Parent run`,children:[(0,x.jsx)(`header`,{className:wp.cardHeader,children:(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`h3`,{className:wp.parentTitle,children:[e.metadata.scenario.name,` (parent)`]}),(0,x.jsxs)(`span`,{className:wp.meta,children:[r,` `,r===1?t.time:t.times,` completed · run`,` `,(0,x.jsx)(`code`,{children:e.metadata.runId})]})]})}),(0,x.jsx)(`dl`,{className:wp.metrics,children:Object.entries(n).slice(0,6).map(([e,t])=>(0,x.jsxs)(`div`,{className:wp.metric,children:[(0,x.jsx)(`dt`,{children:e}),(0,x.jsx)(`dd`,{children:Op(t)})]},e))})]})}function Dp({branch:e,parent:t,labels:n,onOpen:r}){let i=(0,b.useMemo)(()=>t&&e.artifact?Sp(t,e.artifact):[],[t,e.artifact]),a=e.status===`running`?`Running · ${n.Time} ${e.currentTurn}`:e.status.charAt(0).toUpperCase()+e.status.slice(1);return(0,x.jsxs)(`article`,{className:wp.branchCard,onClick:r,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r())},tabIndex:0,role:`button`,"aria-label":`Branch ${e.actorName}, forked at ${n.time} ${e.forkedAtTurn}`,children:[(0,x.jsxs)(`header`,{className:wp.cardHeader,children:[(0,x.jsxs)(`div`,{className:wp.branchMeta,children:[(0,x.jsxs)(`span`,{className:wp.badge,children:[`Forked at `,n.Time,` `,e.forkedAtTurn]}),(0,x.jsxs)(`h4`,{className:wp.branchTitle,children:[e.actorName,` `,(0,x.jsxs)(`span`,{className:wp.archetype,children:[`(`,e.actorArchetype,`)`]})]})]}),(0,x.jsx)(`span`,{className:`${wp.status} ${wp[`status_${e.status}`]}`,children:a})]}),e.status===`complete`&&i.length>0&&(0,x.jsxs)(`ul`,{className:wp.deltas,"aria-label":`Delta vs parent`,children:[i.slice(0,4).map(e=>(0,x.jsx)(`li`,{className:`${wp.delta} ${wp[`direction_${e.direction}`]}`,title:`${e.bag}: parent=${e.parentValue}, branch=${e.branchValue}`,children:Cp(e)},`${e.bag}.${e.key}`)),i.length>4&&(0,x.jsxs)(`li`,{className:wp.more,children:[`+`,i.length-4,` more`]})]}),e.status===`complete`&&i.length===0&&(0,x.jsx)(`p`,{className:wp.identical,children:`Identical final state. Leader overrides did not diverge.`}),e.status===`error`&&e.errorMessage&&(0,x.jsx)(`p`,{className:wp.error,role:`alert`,children:e.errorMessage})]})}function Op(e){return typeof e==`number`?Number.isInteger(e)?e.toString():(Math.round(e*100)/100).toString():String(e)}var kp={tablist:`_tablist_iq6lf_1`,tab:`_tab_iq6lf_1`,tabActive:`_tabActive_iq6lf_39`};function Ap({options:e,active:t,onChange:n,ariaLabel:r}){return(0,x.jsx)(`div`,{role:`tablist`,"aria-label":r,className:kp.tablist,children:e.map(e=>{let r=e.id===t,i=r?`${kp.tab} ${kp.tabActive}`:kp.tab;return(0,x.jsx)(`button`,{role:`tab`,"aria-selected":r,onClick:()=>n(e.id),type:`button`,className:i,children:e.label},e.id)})})}var jp=[`quickstart`,`sim`,`viz`,`settings`,`reports`,`chat`,`library`,`studio`,`about`],Mp={branches:{tab:`studio`,sub:`branches`},log:{tab:`settings`,sub:`log`}};function Np(e){return!!e&&jp.includes(e)}function Pp(e){let{tab:t}=Fp(e);return t}function Fp(e){let t=new URL(e),n=t.searchParams.get(`tab`),r=t.searchParams.get(`sub`);if(n&&Mp[n])return Mp[n];if(Np(n))return{tab:n,sub:r??void 0};let i=t.hash.replace(/^#/,``);return i&&Mp[i]?Mp[i]:Np(i)?{tab:i,sub:r??void 0}:{tab:`quickstart`}}function Ip(e,t){let n=new URL(e);return n.searchParams.set(`tab`,t),n.searchParams.delete(`sub`),n.hash=``,n.toString()}function Lp(e){if(typeof window>`u`)return;let t=new URL(window.location.href);e?t.searchParams.set(`sub`,e):t.searchParams.delete(`sub`),window.history.replaceState({},``,t.toString())}function Rp(e,t){if(!t)return Ip(e,`sim`);let n=new URL(e),r=new URL(t,n.origin);return r.pathname===`/sim`&&!r.searchParams.has(`tab`)&&r.searchParams.set(`tab`,`sim`),r.hash=``,r.toString()}var zp=[{id:`author`,label:`Author`},{id:`branches`,label:`Branches`}];function Bp({initialSubTab:e=`author`}={}){let[t,n]=b.useState(e),r=b.useCallback(e=>{n(e),Lp(e===`author`?null:e)},[]),[i,a]=b.useState(null),[o,s]=b.useState(!1),c=yp(),l=b.useCallback((e,t)=>{e.kind!==`error`&&a({input:e,filename:t,promote:null})},[]),u=b.useCallback(async()=>{if(!i||i.input.kind!==`single`)return;let e=await c.promoteSingle(i.input.artifact);e&&a(t=>t&&{...t,promote:e})},[i,c]),d=b.useCallback(async()=>{if(!i||i.input.kind!==`bundle`)return;let e=await c.promoteBundle(i.input.artifacts);e&&a(t=>t&&{...t,promote:e})},[i,c]),f=b.useCallback(()=>s(!0),[]),p=b.useCallback(()=>{a(null),s(!1)},[]),m=(()=>{if(i)return i.input.kind===`single`?[i.input.artifact]:i.input.artifacts})(),h=i?.promote?.kind===`bundle`?i.promote.bundleId:null;return(0,x.jsxs)(`div`,{className:ai.tab,children:[(0,x.jsx)(Ap,{options:zp,active:t,onChange:r,ariaLabel:`Studio sub-navigation`}),t===`branches`&&(0,x.jsx)(Tp,{}),t===`author`&&!i&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(gp,{}),(0,x.jsx)(pp,{onLoaded:l})]}),t===`author`&&i&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:ai.loadedBar,children:[(0,x.jsxs)(`span`,{children:[(0,x.jsx)(`strong`,{children:i.filename}),` · `,i.input.kind===`single`?`single artifact`:`bundle of ${i.input.artifacts.length}`,i.promote&&(i.promote.kind===`single`?i.promote.alreadyExisted?` · already in Library`:` · added to Library`:` · added to Library (${i.promote.runIds.length} runs)`)]}),(0,x.jsx)(`button`,{type:`button`,className:ai.bundleDrillBack,onClick:p,children:`Drop another`})]}),c.error&&(0,x.jsx)(`div`,{className:ai.errorBanner,role:`alert`,children:c.error}),i.input.kind===`single`&&(0,x.jsx)(_p,{artifact:i.input.artifact,onPromote:u,onCompare:f,promoteBusy:c.busy,alreadyExisted:i.promote?.kind===`single`&&i.promote.alreadyExisted}),i.input.kind===`bundle`&&(0,x.jsx)(vp,{artifacts:i.input.artifacts,bundleId:i.input.bundleId,onPromote:d,onCompare:f,promoteBusy:c.busy,alreadyExisted:i.promote?.kind===`bundle`&&i.promote.alreadyExisted.every(Boolean)})]}),(0,x.jsx)(ti,{bundleId:h,extraArtifacts:m,open:o,onClose:()=>s(!1)})]})}function Vp(e){let t=e.trim();if(!t)return{ok:!1,error:`URL is empty.`};if(t.length>2048)return{ok:!1,error:`URL exceeds 2048 characters.`};let n;try{n=new URL(t)}catch{return{ok:!1,error:`Not a valid URL.`}}return n.protocol!==`http:`&&n.protocol!==`https:`?{ok:!1,error:`Unsupported scheme ${n.protocol}. Use http or https.`}:{ok:!0,url:n}}function Hp(e,t=200,n=5e4){let r=e.trim();return r?r.length<t?{ok:!1,reason:`too-short`}:r.length>n?{ok:!1,reason:`too-long`}:{ok:!0}:{ok:!1,reason:`empty`}}function Up(e,t){let n=[`metrics`,`capacities`,`statuses`,`environment`,`politics`],r=e.finalState;if(!r||t.length===0)return[];let i=[];for(let e of n){let n=r[e];if(n)for(let r of Object.keys(n)){let a=n[r],o=t.map(t=>t.finalState?.[e]?.[r]).filter(e=>e!==void 0);if(o.length!==0){if(typeof a==`number`&&o.every(e=>typeof e==`number`)){let t=[...o].sort((e,t)=>e-t),n=t.length%2==0?(t[t.length/2-1]+t[t.length/2])/2:t[(t.length-1)/2],s=a-n;if(s===0)continue;i.push({bag:e,key:r,parentValue:n,branchValue:a,delta:s,direction:s>0?`up`:`down`})}else{let t=o.find(e=>e!==a);if(t===void 0)continue;i.push({bag:e,key:r,parentValue:t,branchValue:a,direction:`changed`})}}}}return i.sort((e,t)=>e.delta!==void 0&&t.delta!==void 0?Math.abs(t.delta)-Math.abs(e.delta):e.delta===void 0?t.delta===void 0?0:1:-1)}function Wp(e,t,n=`viz`){return Ke(e,t,n)}function Gp(e,t){let n=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=t,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}var Kp=`/assets/pdf.worker.min-iDqQPrd3.mjs`,qp=`modulepreload`,Jp=function(e){return`/`+e},Yp={},Xp=function(e){return e.pathname.endsWith(`.css`)},Zp=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=Jp(t,n);let r=s(t);if(r.href in Yp)return;Yp[r.href]=!0;let i=Xp(r);if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let o=document.createElement(`link`);if(o.rel=i?`stylesheet`:qp,i||(o.as=`script`),o.crossOrigin=``,o.href=r.href,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),i)return new Promise((e,t)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>t(Error(`Unable to preload CSS for ${r}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function Qp(){if(typeof window>`u`)return Kp;try{return new URL(Kp,window.location.origin).toString()}catch{return Kp}}var $p=null;async function em(){if($p)return $p;let e=await Zp(()=>import(`./pdf-BauhankZ.js`),[]);return e.GlobalWorkerOptions.workerSrc=Qp(),$p=e,e}async function tm(e,t={}){let{maxBytes:n=5e4,maxPages:r=100}=t;if(!e.name.toLowerCase().endsWith(`.pdf`)&&e.type!==`application/pdf`)throw Error(`File is not a PDF: ${e.name}`);let i=await em(),a=await e.arrayBuffer(),o=i.getDocument({data:a}),s=[],c=0,l=!1;try{let e=await o.promise,t=Math.min(e.numPages,r);for(let r=1;r<=t;r++){let t=(await(await e.getPage(r)).getTextContent()).items.map(e=>e.str??``).join(` `).replace(/\s+/g,` `).trim(),i=new Blob([t]).size;if(c+i>n){let e=n-c;if(e>0){let r=new TextEncoder().encode(t).slice(0,e),i=new TextDecoder(`utf-8`,{fatal:!1}).decode(r).replace(/�$/,``);s.push(i),c=n}l=!0;break}s.push(t),c+=i}let i=s.join(`
109
+ }`;function hp(e){e.preventDefault();let t=new URL(window.location.href);t.searchParams.set(`tab`,`settings`),t.searchParams.delete(`sub`),window.history.replaceState({},``,t.toString()),window.dispatchEvent(new PopStateEvent(`popstate`))}function gp(){return(0,x.jsxs)(`section`,{className:ai.guide,"aria-label":`How to author a RunArtifact JSON`,children:[(0,x.jsxs)(`div`,{className:ai.guideHead,children:[(0,x.jsx)(`h3`,{className:ai.guideTitle,children:`How to get a RunArtifact JSON`}),(0,x.jsxs)(`p`,{className:ai.guideSub,children:[`Studio takes a deterministic Paracosm `,(0,x.jsx)(`code`,{children:`RunArtifact`}),` — the JSON that a single sim run produces — and lets you inspect, promote to the Library, branch, or compare. Four steps to author one.`]})]}),(0,x.jsxs)(`ol`,{className:ai.guideSteps,children:[(0,x.jsxs)(`li`,{children:[(0,x.jsx)(`strong`,{children:`Configure a scenario in Settings.`}),` Pick a built-in (Frontier AI Lab, Submarine, Corporate Quarterly, T2D Protocol) or load your own. Set turns, seed, population, time-per-turn.`]}),(0,x.jsxs)(`li`,{children:[(0,x.jsx)(`strong`,{children:`Run the sim.`}),` Switch to the Sim tab, hit Run. The runtime emits events deterministically, the actor LLM produces dialogue and decisions, and the judge attaches a verdict at the end.`]}),(0,x.jsxs)(`li`,{children:[(0,x.jsx)(`strong`,{children:`Download the artifact.`}),` Sim output panel has a Save button — that JSON is the RunArtifact. You can also produce one from the CLI: `,(0,x.jsx)(`code`,{children:`paracosm run scenarios/frontier-ai-lab.json --turns 20 --out run.json`}),`.`]}),(0,x.jsxs)(`li`,{children:[(0,x.jsx)(`strong`,{children:`Drop it in the zone below.`}),` Single artifact or a bundle (array of artifacts, e.g. for branch comparisons). Max 10\xA0MB.`]})]}),(0,x.jsxs)(`div`,{className:ai.guideCtaRow,children:[(0,x.jsx)(`a`,{href:`?tab=settings`,onClick:hp,className:ai.guideCta,children:`Open Settings →`}),(0,x.jsx)(`a`,{href:`https://github.com/framerslab/paracosm/blob/master/docs/COOKBOOK.md`,target:`_blank`,rel:`noopener noreferrer`,className:ai.guideCtaSecondary,children:`Read the cookbook`}),(0,x.jsx)(`a`,{href:`https://github.com/framerslab/paracosm/tree/master/scenarios`,target:`_blank`,rel:`noopener noreferrer`,className:ai.guideCtaSecondary,children:`Browse example scenarios`})]}),(0,x.jsxs)(`details`,{className:ai.guideExample,children:[(0,x.jsx)(`summary`,{children:`Show an example RunArtifact`}),(0,x.jsx)(`pre`,{className:ai.guideExampleCode,children:(0,x.jsx)(`code`,{children:mp})}),(0,x.jsxs)(`p`,{className:ai.guideExampleNote,children:[`Real artifacts include the full event log, the per-turn snapshot of every actor, KPIs, and the judge verdict. The shape matches the `,(0,x.jsx)(`code`,{children:`RunArtifact`}),` Zod schema in `,(0,x.jsx)(`code`,{children:`schema/index.ts`}),`; bundles are a JSON array of artifacts.`]})]})]})}function _p(e){let{artifact:t,inline:n,onPromote:r,onCompare:i,promoteBusy:a,alreadyExisted:o}=e,s=t.metadata.mode,c=t.leader?.name??`<unnamed actor>`,l=t.metadata.scenario.name??t.metadata.scenario.id,u=b.useMemo(()=>{let e={},n=(t.trajectory?.timepoints?.[0])?.worldSnapshot?.metrics??{};for(let t of Object.keys(n))e[t]={id:t,label:t,range:[0,1]};return e},[t]);return(0,x.jsxs)(`div`,{className:ai.artifactView,children:[(0,x.jsxs)(`header`,{className:ai.artifactHead,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:ai.artifactScenario,children:l}),(0,x.jsxs)(`div`,{className:ai.artifactActor,children:[c,` · `,s]})]}),!n&&(0,x.jsxs)(`div`,{className:ai.artifactActions,children:[(0,x.jsx)(`button`,{type:`button`,className:ai.promoteBtn,onClick:r,disabled:a||o,children:o?`Already in Library`:a?`Promoting…`:`Promote to Library`}),(0,x.jsx)(`button`,{type:`button`,className:ai.compareBtn,onClick:i,children:`Compare`})]})]}),(0,x.jsx)(`div`,{className:ai.artifactBody,children:s===`turn-loop`?(0,x.jsx)(pr,{artifact:t}):(0,x.jsx)(dr,{artifact:t,metricSpecs:u})})]})}function vp(e){let{artifacts:t,bundleId:n,onPromote:r,onCompare:i,promoteBusy:a,alreadyExisted:o}=e,[s,c]=b.useState(null);if(s!==null&&t[s]){let e=t[s];return(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`button`,{type:`button`,className:ai.bundleDrillBack,onClick:()=>c(null),children:`← Back to bundle`}),(0,x.jsx)(_p,{artifact:e,inline:!0,onPromote:()=>{},onCompare:()=>{}})]})}return(0,x.jsxs)(`div`,{children:[n&&(0,x.jsx)(`div`,{className:ai.bundleIdChip,title:n,children:n.length>32?`${n.slice(0,28)}…`:n}),(0,x.jsxs)(`div`,{className:ai.bundleActions,children:[(0,x.jsx)(`button`,{type:`button`,className:ai.promoteBtn,onClick:r,disabled:a||o,children:o?`Already in Library`:a?`Promoting…`:`Promote bundle (${t.length})`}),(0,x.jsx)(`button`,{type:`button`,className:ai.compareBtn,onClick:i,children:`Compare bundle`})]}),(0,x.jsx)(`div`,{className:ai.bundleGrid,children:t.map((e,t)=>{let n=e.leader,r=e.cost?.totalUSD,i=e.trajectory?.timepoints?.length??0;return(0,x.jsxs)(`button`,{type:`button`,className:ai.bundleCard,onClick:()=>c(t),children:[(0,x.jsx)(`div`,{className:ai.bundleCardTitle,children:n?.name??`<unnamed>`}),(0,x.jsxs)(`div`,{className:ai.bundleCardMeta,children:[n?.archetype??``,` · `,i,` turn`,i===1?``:`s`,typeof r==`number`?` · $${r.toFixed(3)}`:``]})]},e.metadata.runId)})})]})}function yp(){let[e,t]=b.useState(!1),[n,r]=b.useState(null),[i,a]=b.useState(null);return{promoteSingle:b.useCallback(async e=>{t(!0),a(null);try{let t=await fetch(`/api/v1/library/import`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({artifact:e})});if(!t.ok){let e=await t.json().catch(()=>({}));return a(e.error??`Promote failed: HTTP ${t.status}`),null}let n={kind:`single`,...await t.json()};return r(n),n}catch(e){return a(e instanceof Error?e.message:String(e)),null}finally{t(!1)}},[]),promoteBundle:b.useCallback(async e=>{t(!0),a(null);try{let t=await fetch(`/api/v1/library/import`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({artifacts:e})});if(!t.ok){let e=await t.json().catch(()=>({}));return a(e.error??`Promote failed: HTTP ${t.status}`),null}let n={kind:`bundle`,...await t.json()};return r(n),n}catch(e){return a(e instanceof Error?e.message:String(e)),null}finally{t(!1)}},[]),busy:e,lastResult:n,error:i}}function bp(){let e=ew();return(0,b.useMemo)(()=>ne(e),[e.labels?.populationNoun,e.labels?.settlementNoun,e.labels?.timeUnitNoun,e.labels?.timeUnitNounPlural])}function xp(e,t){return typeof e==`number`&&typeof t==`number`?t>e?`up`:t<e?`down`:`unchanged`:e===t?`unchanged`:`changed`}function Sp(e,t){let n=[`metrics`,`capacities`,`statuses`,`environment`,`politics`],r=[],i=e.finalState,a=t.finalState;if(!i||!a)return r;for(let e of n){let t=i[e],n=a[e];if(t&&n)for(let i of Object.keys(t)){if(!(i in n))continue;let a=t[i],o=n[i],s=xp(a,o);if(s===`unchanged`)continue;let c=typeof a==`number`&&typeof o==`number`?o-a:void 0;r.push({bag:e,key:i,parentValue:a,branchValue:o,delta:c,direction:s})}}return r.sort((e,t)=>e.delta!==void 0&&t.delta!==void 0?Math.abs(t.delta)-Math.abs(e.delta):e.delta===void 0?t.delta===void 0?0:1:-1)}function Cp(e){if(e.delta!==void 0){let t=e.delta>0?`+`:``,n=Math.round(e.delta*10)/10;return`${e.key} ${t}${n}`}return`${e.key}: ${e.parentValue} → ${e.branchValue}`}var wp={tab:`_tab_e8hr7_1`,emptyState:`_emptyState_e8hr7_11`,parentCard:`_parentCard_e8hr7_48`,branchCard:`_branchCard_e8hr7_48`,branchList:`_branchList_e8hr7_77`,cardHeader:`_cardHeader_e8hr7_83`,branchMeta:`_branchMeta_e8hr7_91`,parentTitle:`_parentTitle_e8hr7_99`,branchTitle:`_branchTitle_e8hr7_99`,archetype:`_archetype_e8hr7_111`,meta:`_meta_e8hr7_117`,badge:`_badge_e8hr7_129`,status:`_status_e8hr7_143`,status_running:`_status_running_e8hr7_153`,status_complete:`_status_complete_e8hr7_158`,status_aborted:`_status_aborted_e8hr7_163`,status_error:`_status_error_e8hr7_168`,metrics:`_metrics_e8hr7_174`,metric:`_metric_e8hr7_174`,deltas:`_deltas_e8hr7_208`,delta:`_delta_e8hr7_208`,direction_up:`_direction_up_e8hr7_225`,direction_down:`_direction_down_e8hr7_229`,direction_changed:`_direction_changed_e8hr7_233`,more:`_more_e8hr7_238`,identical:`_identical_e8hr7_245`,error:`_error_e8hr7_253`};function Tp(){let{state:e}=Wt(),t=bp(),n=nw();return!e.parent&&e.branches.length===0?(0,x.jsxs)(`div`,{className:wp.emptyState,role:`region`,"aria-label":`Branches (empty)`,children:[(0,x.jsx)(`h2`,{children:`No branches yet`}),(0,x.jsxs)(`p`,{children:[`Run a simulation with snapshot capture enabled (default for dashboard runs), then open the `,(0,x.jsx)(`strong`,{children:`Reports`}),` tab and click`,` `,(0,x.jsxs)(`code`,{children:[`↳ Fork at `,t.Time,` N`]}),` on any completed turn to branch with a different leader.`]})]}):(0,x.jsxs)(`div`,{className:wp.tab,role:`region`,"aria-label":`Branches`,children:[e.parent&&(0,x.jsx)(Ep,{artifact:e.parent,labels:t}),(0,x.jsx)(`div`,{className:wp.branchList,children:e.branches.map(r=>(0,x.jsx)(Dp,{branch:r,parent:e.parent,labels:t,onOpen:()=>n(`reports`)},r.localId))})]})}function Ep({artifact:e,labels:t}){let n=e.finalState?.metrics??{},r=e.trajectory?.timepoints?.length??0;return(0,x.jsxs)(`section`,{className:wp.parentCard,"aria-label":`Parent run`,children:[(0,x.jsx)(`header`,{className:wp.cardHeader,children:(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`h3`,{className:wp.parentTitle,children:[e.metadata.scenario.name,` (parent)`]}),(0,x.jsxs)(`span`,{className:wp.meta,children:[r,` `,r===1?t.time:t.times,` completed · run`,` `,(0,x.jsx)(`code`,{children:e.metadata.runId})]})]})}),(0,x.jsx)(`dl`,{className:wp.metrics,children:Object.entries(n).slice(0,6).map(([e,t])=>(0,x.jsxs)(`div`,{className:wp.metric,children:[(0,x.jsx)(`dt`,{children:e}),(0,x.jsx)(`dd`,{children:Op(t)})]},e))})]})}function Dp({branch:e,parent:t,labels:n,onOpen:r}){let i=(0,b.useMemo)(()=>t&&e.artifact?Sp(t,e.artifact):[],[t,e.artifact]),a=e.status===`running`?`Running · ${n.Time} ${e.currentTurn}`:e.status.charAt(0).toUpperCase()+e.status.slice(1);return(0,x.jsxs)(`article`,{className:wp.branchCard,onClick:r,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r())},tabIndex:0,role:`button`,"aria-label":`Branch ${e.actorName}, forked at ${n.time} ${e.forkedAtTurn}`,children:[(0,x.jsxs)(`header`,{className:wp.cardHeader,children:[(0,x.jsxs)(`div`,{className:wp.branchMeta,children:[(0,x.jsxs)(`span`,{className:wp.badge,children:[`Forked at `,n.Time,` `,e.forkedAtTurn]}),(0,x.jsxs)(`h4`,{className:wp.branchTitle,children:[e.actorName,` `,(0,x.jsxs)(`span`,{className:wp.archetype,children:[`(`,e.actorArchetype,`)`]})]})]}),(0,x.jsx)(`span`,{className:`${wp.status} ${wp[`status_${e.status}`]}`,children:a})]}),e.status===`complete`&&i.length>0&&(0,x.jsxs)(`ul`,{className:wp.deltas,"aria-label":`Delta vs parent`,children:[i.slice(0,4).map(e=>(0,x.jsx)(`li`,{className:`${wp.delta} ${wp[`direction_${e.direction}`]}`,title:`${e.bag}: parent=${e.parentValue}, branch=${e.branchValue}`,children:Cp(e)},`${e.bag}.${e.key}`)),i.length>4&&(0,x.jsxs)(`li`,{className:wp.more,children:[`+`,i.length-4,` more`]})]}),e.status===`complete`&&i.length===0&&(0,x.jsx)(`p`,{className:wp.identical,children:`Identical final state. Leader overrides did not diverge.`}),e.status===`error`&&e.errorMessage&&(0,x.jsx)(`p`,{className:wp.error,role:`alert`,children:e.errorMessage})]})}function Op(e){return typeof e==`number`?Number.isInteger(e)?e.toString():(Math.round(e*100)/100).toString():String(e)}var kp={tablist:`_tablist_iq6lf_1`,tab:`_tab_iq6lf_1`,tabActive:`_tabActive_iq6lf_39`};function Ap({options:e,active:t,onChange:n,ariaLabel:r}){return(0,x.jsx)(`div`,{role:`tablist`,"aria-label":r,className:kp.tablist,children:e.map(e=>{let r=e.id===t,i=r?`${kp.tab} ${kp.tabActive}`:kp.tab;return(0,x.jsx)(`button`,{role:`tab`,"aria-selected":r,onClick:()=>n(e.id),type:`button`,className:i,children:e.label},e.id)})})}var jp=[`quickstart`,`sim`,`viz`,`settings`,`reports`,`chat`,`library`,`studio`,`about`],Mp={branches:{tab:`studio`,sub:`branches`},log:{tab:`settings`,sub:`log`}};function Np(e){return!!e&&jp.includes(e)}function Pp(e){let{tab:t}=Fp(e);return t}function Fp(e){let t=new URL(e),n=t.searchParams.get(`tab`),r=t.searchParams.get(`sub`);if(n&&Mp[n])return Mp[n];if(Np(n))return{tab:n,sub:r??void 0};let i=t.hash.replace(/^#/,``);return i&&Mp[i]?Mp[i]:Np(i)?{tab:i,sub:r??void 0}:{tab:`quickstart`}}function Ip(e,t){let n=new URL(e);return n.searchParams.set(`tab`,t),n.searchParams.delete(`sub`),n.hash=``,n.toString()}function Lp(e){if(typeof window>`u`)return;let t=new URL(window.location.href);e?t.searchParams.set(`sub`,e):t.searchParams.delete(`sub`),window.history.replaceState({},``,t.toString())}function Rp(e,t){if(!t)return Ip(e,`sim`);let n=new URL(e),r=new URL(t,n.origin);return r.pathname===`/sim`&&!r.searchParams.has(`tab`)&&r.searchParams.set(`tab`,`sim`),r.hash=``,r.toString()}var zp=[{id:`author`,label:`Author`},{id:`branches`,label:`Branches`}];function Bp({initialSubTab:e=`author`}={}){let[t,n]=b.useState(e),r=b.useCallback(e=>{n(e),Lp(e===`author`?null:e)},[]),[i,a]=b.useState(null),[o,s]=b.useState(!1),c=yp(),l=b.useCallback((e,t)=>{e.kind!==`error`&&a({input:e,filename:t,promote:null})},[]),u=b.useCallback(async()=>{if(!i||i.input.kind!==`single`)return;let e=await c.promoteSingle(i.input.artifact);e&&a(t=>t&&{...t,promote:e})},[i,c]),d=b.useCallback(async()=>{if(!i||i.input.kind!==`bundle`)return;let e=await c.promoteBundle(i.input.artifacts);e&&a(t=>t&&{...t,promote:e})},[i,c]),f=b.useCallback(()=>s(!0),[]),p=b.useCallback(()=>{a(null),s(!1)},[]),m=(()=>{if(i)return i.input.kind===`single`?[i.input.artifact]:i.input.artifacts})(),h=i?.promote?.kind===`bundle`?i.promote.bundleId:null;return(0,x.jsxs)(`div`,{className:ai.tab,children:[(0,x.jsx)(Ap,{options:zp,active:t,onChange:r,ariaLabel:`Studio sub-navigation`}),t===`branches`&&(0,x.jsx)(Tp,{}),t===`author`&&!i&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(gp,{}),(0,x.jsx)(pp,{onLoaded:l})]}),t===`author`&&i&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:ai.loadedBar,children:[(0,x.jsxs)(`span`,{children:[(0,x.jsx)(`strong`,{children:i.filename}),` · `,i.input.kind===`single`?`single artifact`:`bundle of ${i.input.artifacts.length}`,i.promote&&(i.promote.kind===`single`?i.promote.alreadyExisted?` · already in Library`:` · added to Library`:` · added to Library (${i.promote.runIds.length} runs)`)]}),(0,x.jsx)(`button`,{type:`button`,className:ai.bundleDrillBack,onClick:p,children:`Drop another`})]}),c.error&&(0,x.jsx)(`div`,{className:ai.errorBanner,role:`alert`,children:c.error}),i.input.kind===`single`&&(0,x.jsx)(_p,{artifact:i.input.artifact,onPromote:u,onCompare:f,promoteBusy:c.busy,alreadyExisted:i.promote?.kind===`single`&&i.promote.alreadyExisted}),i.input.kind===`bundle`&&(0,x.jsx)(vp,{artifacts:i.input.artifacts,bundleId:i.input.bundleId,onPromote:d,onCompare:f,promoteBusy:c.busy,alreadyExisted:i.promote?.kind===`bundle`&&i.promote.alreadyExisted.every(Boolean)})]}),(0,x.jsx)(ti,{bundleId:h,extraArtifacts:m,open:o,onClose:()=>s(!1)})]})}function Vp(e){let t=e.trim();if(!t)return{ok:!1,error:`URL is empty.`};if(t.length>2048)return{ok:!1,error:`URL exceeds 2048 characters.`};let n;try{n=new URL(t)}catch{return{ok:!1,error:`Not a valid URL.`}}return n.protocol!==`http:`&&n.protocol!==`https:`?{ok:!1,error:`Unsupported scheme ${n.protocol}. Use http or https.`}:{ok:!0,url:n}}function Hp(e,t=200,n=5e4){let r=e.trim();return r?r.length<t?{ok:!1,reason:`too-short`}:r.length>n?{ok:!1,reason:`too-long`}:{ok:!0}:{ok:!1,reason:`empty`}}function Up(e,t){let n=[`metrics`,`capacities`,`statuses`,`environment`,`politics`],r=e.finalState;if(!r||t.length===0)return[];let i=[];for(let e of n){let n=r[e];if(n)for(let r of Object.keys(n)){let a=n[r],o=t.map(t=>t.finalState?.[e]?.[r]).filter(e=>e!==void 0);if(o.length!==0){if(typeof a==`number`&&o.every(e=>typeof e==`number`)){let t=[...o].sort((e,t)=>e-t),n=t.length%2==0?(t[t.length/2-1]+t[t.length/2])/2:t[(t.length-1)/2],s=a-n;if(s===0)continue;i.push({bag:e,key:r,parentValue:n,branchValue:a,delta:s,direction:s>0?`up`:`down`})}else{let t=o.find(e=>e!==a);if(t===void 0)continue;i.push({bag:e,key:r,parentValue:t,branchValue:a,direction:`changed`})}}}}return i.sort((e,t)=>e.delta!==void 0&&t.delta!==void 0?Math.abs(t.delta)-Math.abs(e.delta):e.delta===void 0?t.delta===void 0?0:1:-1)}function Wp(e,t,n=`viz`){return Ke(e,t,n)}function Gp(e,t){let n=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=t,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}var Kp=`/assets/pdf.worker.min-CjEcRF4W.mjs`,qp=`modulepreload`,Jp=function(e){return`/`+e},Yp={},Xp=function(e){return e.pathname.endsWith(`.css`)},Zp=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=Jp(t,n);let r=s(t);if(r.href in Yp)return;Yp[r.href]=!0;let i=Xp(r);if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let o=document.createElement(`link`);if(o.rel=i?`stylesheet`:qp,i||(o.as=`script`),o.crossOrigin=``,o.href=r.href,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),i)return new Promise((e,t)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>t(Error(`Unable to preload CSS for ${r}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function Qp(){if(typeof window>`u`)return Kp;try{return new URL(Kp,window.location.origin).toString()}catch{return Kp}}var $p=null;async function em(){if($p)return $p;let e=await Zp(()=>import(`./pdf-D0rlhCn8.js`),[]);return e.GlobalWorkerOptions.workerSrc=Qp(),$p=e,e}async function tm(e,t={}){let{maxBytes:n=5e4,maxPages:r=100}=t;if(!e.name.toLowerCase().endsWith(`.pdf`)&&e.type!==`application/pdf`)throw Error(`File is not a PDF: ${e.name}`);let i=await em(),a=await e.arrayBuffer(),o=i.getDocument({data:a}),s=[],c=0,l=!1;try{let e=await o.promise,t=Math.min(e.numPages,r);for(let r=1;r<=t;r++){let t=(await(await e.getPage(r)).getTextContent()).items.map(e=>e.str??``).join(` `).replace(/\s+/g,` `).trim(),i=new Blob([t]).size;if(c+i>n){let e=n-c;if(e>0){let r=new TextEncoder().encode(t).slice(0,e),i=new TextDecoder(`utf-8`,{fatal:!1}).decode(r).replace(/�$/,``);s.push(i),c=n}l=!0;break}s.push(t),c+=i}let i=s.join(`
110
110
 
111
111
  `);if(i.trim().length===0){let e=Error(`PDF contains no extractable text. It may be a scanned image without OCR.`);throw e.code=`PDF_NO_TEXT`,e}return{text:i,pages:e.numPages,truncated:l}}finally{try{await o.destroy()}catch{}}}function nm(e){let t=rm(e.seedText.length>0?e.seedText:`<paste your scenario above>`),n=[];return n.push(`// Recreate this Quickstart run from your code.`),n.push(`import { runMany } from 'paracosm';`),n.push(``),e.sourceUrl&&e.sourceUrl.length>0?(n.push(`const { runs } = await runMany(`),n.push(` new URL('${im(e.sourceUrl)}'),`),n.push(` { count: ${e.actorCount} },`),n.push(`);`)):(n.push(`const { runs } = await runMany(`),n.push(` \`${t}\`,`),n.push(` { count: ${e.actorCount} },`),n.push(`);`)),n.push(``),n.push(`runs.forEach(({ actor, artifact }) => console.log(actor.name, artifact.fingerprint));`),n.join(`
112
112
  `)}function rm(e){return e.replace(/\\/g,`\\\\`).replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function im(e){return e.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`)}function am(e){let t={seedText:e.seedText.length>0?e.seedText:`<paste your scenario above>`};e.domainHint&&e.domainHint.trim().length>0&&(t.domainHint=e.domainHint),e.actorCount!==2&&(t.actorCount=e.actorCount);let n=`'${JSON.stringify(t).replace(/'/g,`'\\''`)}'`,r=[];return r.push(`# This compiles a typed ScenarioPackage from your prompt.`),r.push(`# For the full flow (auto-generate HEXACO leaders + simulate),`),r.push(`# install paracosm and use the TypeScript tab.`),r.push(`curl -X POST https://paracosm.agentos.sh/api/quickstart/compile-from-seed \\`),r.push(` -H 'Content-Type: application/json' \\`),r.push(` -d ${n}`),r.join(`