dsh-open-artifact 0.8.1 → 0.8.2
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/lib/client.js +2 -2
- package/lib/index.js +41 -4
- package/package.json +1 -1
- package/skills/open-artifact/SKILL.md +1 -1
- package/vendor/artifact-types/data/scripts/cli.mjs +1 -1
- package/vendor/artifact-types/data/scripts/editors/data/assets/{index-CZiM2XTm.js → index-B041Zu27.js} +1 -1
- package/vendor/artifact-types/data/scripts/editors/data/index.html +1 -1
- package/vendor/artifact-types/{design/scripts/editors/design/assets/index-jhwXmpbV.js → data/scripts/editors/design/assets/index-D6-vjsn9.js} +1 -1
- package/vendor/artifact-types/data/scripts/editors/design/index.html +1 -1
- package/vendor/artifact-types/{design/scripts/editors/design-system/assets/index-7LPrsXBY.js → data/scripts/editors/design-system/assets/index-BoT2v4hc.js} +1 -1
- package/vendor/artifact-types/data/scripts/editors/design-system/index.html +1 -1
- package/vendor/artifact-types/{design/scripts/editors/slides/assets/index-y09Z-wXP.js → data/scripts/editors/slides/assets/index-b9M479Ro.js} +2 -2
- package/vendor/artifact-types/data/scripts/editors/slides/assets/{src-C48N4IXt.js → src-CxNLgI5_.js} +1 -1
- package/vendor/artifact-types/data/scripts/editors/slides/index.html +1 -1
- package/vendor/artifact-types/{design/scripts/editors/whiteboard/assets/index-DbekE4ru.js → data/scripts/editors/whiteboard/assets/index-TrzGo_VR.js} +1 -1
- package/vendor/artifact-types/data/scripts/editors/whiteboard/index.html +1 -1
- package/vendor/artifact-types/design/scripts/cli.mjs +1 -1
- package/vendor/artifact-types/{slides/scripts/editors/data/assets/index-CZiM2XTm.js → design/scripts/editors/data/assets/index-B041Zu27.js} +1 -1
- package/vendor/artifact-types/design/scripts/editors/data/index.html +1 -1
- package/vendor/artifact-types/{data/scripts/editors/design/assets/index-jhwXmpbV.js → design/scripts/editors/design/assets/index-D6-vjsn9.js} +1 -1
- package/vendor/artifact-types/design/scripts/editors/design/index.html +1 -1
- package/vendor/artifact-types/{design-system/scripts/editors/design-system/assets/index-7LPrsXBY.js → design/scripts/editors/design-system/assets/index-BoT2v4hc.js} +1 -1
- package/vendor/artifact-types/design/scripts/editors/design-system/index.html +1 -1
- package/vendor/artifact-types/{slides/scripts/editors/slides/assets/index-y09Z-wXP.js → design/scripts/editors/slides/assets/index-b9M479Ro.js} +2 -2
- package/vendor/artifact-types/{slides/scripts/editors/slides/assets/src-C48N4IXt.js → design/scripts/editors/slides/assets/src-CxNLgI5_.js} +1 -1
- package/vendor/artifact-types/design/scripts/editors/slides/index.html +1 -1
- package/vendor/artifact-types/{design-system/scripts/editors/whiteboard/assets/index-DbekE4ru.js → design/scripts/editors/whiteboard/assets/index-TrzGo_VR.js} +1 -1
- package/vendor/artifact-types/design/scripts/editors/whiteboard/index.html +1 -1
- package/vendor/artifact-types/design-system/scripts/cli.mjs +1 -1
- package/vendor/artifact-types/{design/scripts/editors/data/assets/index-CZiM2XTm.js → design-system/scripts/editors/data/assets/index-B041Zu27.js} +1 -1
- package/vendor/artifact-types/design-system/scripts/editors/data/index.html +1 -1
- package/vendor/artifact-types/{slides/scripts/editors/design/assets/index-jhwXmpbV.js → design-system/scripts/editors/design/assets/index-D6-vjsn9.js} +1 -1
- package/vendor/artifact-types/design-system/scripts/editors/design/index.html +1 -1
- package/vendor/artifact-types/{data/scripts/editors/design-system/assets/index-7LPrsXBY.js → design-system/scripts/editors/design-system/assets/index-BoT2v4hc.js} +1 -1
- package/vendor/artifact-types/design-system/scripts/editors/design-system/index.html +1 -1
- package/vendor/artifact-types/design-system/scripts/editors/slides/assets/{index-y09Z-wXP.js → index-b9M479Ro.js} +2 -2
- package/vendor/artifact-types/{design/scripts/editors/slides/assets/src-C48N4IXt.js → design-system/scripts/editors/slides/assets/src-CxNLgI5_.js} +1 -1
- package/vendor/artifact-types/design-system/scripts/editors/slides/index.html +1 -1
- package/vendor/artifact-types/{data/scripts/editors/whiteboard/assets/index-DbekE4ru.js → design-system/scripts/editors/whiteboard/assets/index-TrzGo_VR.js} +1 -1
- package/vendor/artifact-types/design-system/scripts/editors/whiteboard/index.html +1 -1
- package/vendor/artifact-types/slides/scripts/cli.mjs +1 -1
- package/vendor/artifact-types/{design-system/scripts/editors/data/assets/index-CZiM2XTm.js → slides/scripts/editors/data/assets/index-B041Zu27.js} +1 -1
- package/vendor/artifact-types/slides/scripts/editors/data/index.html +1 -1
- package/vendor/artifact-types/{design-system/scripts/editors/design/assets/index-jhwXmpbV.js → slides/scripts/editors/design/assets/index-D6-vjsn9.js} +1 -1
- package/vendor/artifact-types/slides/scripts/editors/design/index.html +1 -1
- package/vendor/artifact-types/slides/scripts/editors/design-system/assets/{index-7LPrsXBY.js → index-BoT2v4hc.js} +1 -1
- package/vendor/artifact-types/slides/scripts/editors/design-system/index.html +1 -1
- package/vendor/artifact-types/{data/scripts/editors/slides/assets/index-y09Z-wXP.js → slides/scripts/editors/slides/assets/index-b9M479Ro.js} +2 -2
- package/vendor/artifact-types/{design-system/scripts/editors/slides/assets/src-C48N4IXt.js → slides/scripts/editors/slides/assets/src-CxNLgI5_.js} +1 -1
- package/vendor/artifact-types/slides/scripts/editors/slides/index.html +1 -1
- package/vendor/artifact-types/slides/scripts/editors/whiteboard/assets/{index-DbekE4ru.js → index-TrzGo_VR.js} +1 -1
- package/vendor/artifact-types/slides/scripts/editors/whiteboard/index.html +1 -1
- package/vendor/artifact-types/whiteboard/scripts/cli.mjs +1 -1
- package/vendor/artifact-types/whiteboard/scripts/editors/data/assets/index-B041Zu27.js +126 -0
- package/vendor/artifact-types/whiteboard/scripts/editors/data/index.html +1 -1
- package/vendor/artifact-types/whiteboard/scripts/editors/design/assets/index-D6-vjsn9.js +215 -0
- package/vendor/artifact-types/whiteboard/scripts/editors/design/index.html +1 -1
- package/vendor/artifact-types/whiteboard/scripts/editors/design-system/assets/index-BoT2v4hc.js +139 -0
- package/vendor/artifact-types/whiteboard/scripts/editors/design-system/index.html +1 -1
- package/vendor/artifact-types/whiteboard/scripts/editors/slides/assets/index-b9M479Ro.js +569 -0
- package/vendor/artifact-types/whiteboard/scripts/editors/slides/assets/src-CxNLgI5_.js +1 -0
- package/vendor/artifact-types/whiteboard/scripts/editors/slides/index.html +1 -1
- package/vendor/artifact-types/whiteboard/scripts/editors/whiteboard/assets/index-TrzGo_VR.js +141 -0
- package/vendor/artifact-types/whiteboard/scripts/editors/whiteboard/index.html +1 -1
- package/vendor/frame-host/client/comments.js +1 -1
- package/vendor/frame-host/frame-host.mjs +1 -1
- package/vendor/home/assets/{index-CPvXdSVh.js → index-aY1m8xEm.js} +1 -1
- package/vendor/home/index.html +1 -1
- package/vendor/open-artifact.mjs +56 -38
- package/vendor/shell/assets/{index-DE0jNtst.js → index-ElpFysv2.js} +1 -1
- package/vendor/shell/index.html +1 -1
- package/vendor/artifact-types/whiteboard/scripts/editors/data/assets/index-CZiM2XTm.js +0 -126
- package/vendor/artifact-types/whiteboard/scripts/editors/design/assets/index-jhwXmpbV.js +0 -215
- package/vendor/artifact-types/whiteboard/scripts/editors/design-system/assets/index-7LPrsXBY.js +0 -139
- package/vendor/artifact-types/whiteboard/scripts/editors/slides/assets/index-y09Z-wXP.js +0 -569
- package/vendor/artifact-types/whiteboard/scripts/editors/slides/assets/src-C48N4IXt.js +0 -1
- package/vendor/artifact-types/whiteboard/scripts/editors/whiteboard/assets/index-DbekE4ru.js +0 -141
|
@@ -10,7 +10,7 @@ Error generating stack: `+x.message+`
|
|
|
10
10
|
`),i=vO(r,t.split(`
|
|
11
11
|
`)),l=vO(r,n.split(`
|
|
12
12
|
`));if(!i||!l)return null;const u=[];for(const h of i){const g=l.find(y=>yQ(h,y,o));if(!g){u.push(h);continue}if(!(g.start===h.start&&g.end===h.end&&gQ(g.lines,h.lines)))return null}u.push(...l),u.sort((h,g)=>h.start-g.start||h.end-g.end);const d=[];let f=0;for(const h of u)d.push(...r.slice(f,h.start),...h.lines),f=h.end;return d.push(...r.slice(f)),d.join(`
|
|
13
|
-
`)}const xQ="1.3.0";class Qf extends Error{code;paths;retryable;constructor(t,n,s,o){super(n),this.name="ArtifactError",this.code=t,s&&(this.paths=s),o&&(this.retryable=!0)}}function wO(e,t){if(!e||typeof e!="object")return!1;const n=e;return n.name!=="ArtifactError"||typeof n.code!="string"?!1:t===void 0||n.code===t}function vQ(e){return e==="owner"||e==="editor"}const SO={defaultMs:12e4,maxMs:6e5};function wQ(e,t={}){const n=t.timeoutMs??1e4,s=new Map;return Object.freeze({version:xQ,use:r=>{const i=s.get(r);if(i)return i;const l=new Promise(u=>{const d=setTimeout(()=>u(null),n);Promise.resolve().then(()=>e.get(r)).then(f=>{clearTimeout(d),u(f?Object.freeze(f):null)},()=>{clearTimeout(d),u(null)})});return s.set(r,l),l}})}function SQ(e,t){const n=globalThis.window?.openartifact;if(n)return n;const s=wQ(e,t);return Object.defineProperty(window,"openartifact",{value:s,configurable:!1,enumerable:!0,writable:!1}),s}const Bt={session:"_api/session",files:"_api/files",file:"_api/file",publish:"_api/publish",assets:"_api/assets",events:"_api/events",agentSend:"_api/agent/send",presence:"_api/presence",peers:"_api/peers",downloads:"_api/downloads",roomEmit:"_api/room/emit",dbGet:"_api/db/get",dbList:"_api/db/list",dbWrite:"_api/db/write",comments:"_api/comments",commentsCreate:"_api/comments/create",commentsReply:"_api/comments/reply",commentsResolve:"_api/comments/resolve",commentsMove:"_api/comments/move",commentsRemove:"_api/comments/remove",commentsSend:"_api/comments/send",history:"_api/history",historyFiles:"_api/history/files",historyFile:"_api/history/file",historyDiff:"_api/history/diff",historyRestore:"_api/history/restore",historyDismiss:"_api/history/dismiss",mcpTools:"_api/mcp/tools",mcpCall:"_api/mcp/call"};function kQ(e,t,n){return t===401||t===403?"removed":t<200||t>=300||!n||n.id===e.id&&n.role===e.role?null:"changed"}async function kO(e){let t={};try{t=await e.json()}catch{}const n=e.status===409?"conflict":e.status===403?"not_writer":e.status===404?"not_found":"unavailable";return new Qf(t.code??n,t.message??`HTTP ${e.status}`,t.paths,t.retryable===!0)}function EQ(){const e=new Uint8Array(8);return crypto.getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}function zP(e={}){const t=new URL(e.base??"./",location.href),n=EQ(),s=(N,_)=>{const D=new URL(N,t);for(const[P,L]of Object.entries(_??{}))D.searchParams.set(P,L);return D.toString()},o=async(N,_,D)=>{let P;try{P=await fetch(s(N,D),_)}catch(L){throw new Qf("unavailable",L instanceof Error?L.message:String(L))}if(!P.ok)throw await kO(P);return await P.json()},r=(N,_)=>o(N,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(_)}),i=new Map,l=(N,_)=>{for(const D of i.get(N)??[])D(_)},u=(N,_)=>{let D=i.get(N);return D||(D=new Set,i.set(N,D),h?.addEventListener(N,y)),D.add(_),k(),()=>D.delete(_)};let d=null,f=!1,h=null,g=null;const y=N=>{l(N.type,JSON.parse(N.data))},b=()=>{const N=new EventSource(s(Bt.events,{client:n}));h=N;for(const _ of i.keys())N.addEventListener(_,y);N.onerror=()=>{C().then(_=>{_||N.readyState!==EventSource.CLOSED||h!==N||(h=null,g=setTimeout(()=>{g=null,k()},2e3))})}};let v=!1,w=!1;const S=N=>{v||(v=!0,g&&clearTimeout(g),g=null,h?.close(),h=null,d?.close(),d=null,e.onAccessChange?e.onAccessChange(N):location.reload())},C=async()=>{if(v)return!0;if(!M||w)return!1;w=!0;try{const N=(await M.catch(()=>null))?.viewer;if(!N)return!1;let _;try{_=await fetch(s(Bt.session),{cache:"no-store"})}catch{return!1}const D=_.ok?(await _.json().catch(()=>null))?.viewer:null,P=kQ(N,_.status,D);return P&&S(P),P!==null}finally{w=!1}};function k(){if(d||h||g||v)return;if(typeof WebSocket>"u")return b();const N=new URL(s(Bt.events,{client:n}));N.protocol=N.protocol==="https:"?"wss:":"ws:";const _=new WebSocket(N);d=_,_.onopen=()=>{f=!0},_.onmessage=D=>{let P;try{P=JSON.parse(String(D.data))}catch{return}P.event&&l(P.event,P.data)},_.onclose=()=>{if(d===_&&(d=null),!v){if(!f)return b();C().then(D=>{D||d||h||g||(g=setTimeout(()=>{g=null,k()},2e3))})}}}let M=null;const j=()=>M??=o(Bt.session),O={async artifact(){const{artifact:N}=await j();return{id:N.id,title:async()=>(await o(Bt.session)).artifact.title,list:async()=>(await o(Bt.files)).files,readText:async D=>new TextDecoder().decode(await $(D)),readBytes:D=>$(D),publish:async D=>{const P={files:D,client:n};return o(Bt.publish,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(P)})},onChange:D=>u("files",D)}},async assets(){const{viewer:N}=await j();return vQ(N.role)?{upload:async(D,P)=>o(Bt.assets,{method:"POST",headers:{"content-type":D.type||"application/octet-stream"},body:D},P?.name?{name:P.name}:void 0)}:null},async user(){const{viewer:N}=await j();return{me:async()=>N}},async agent(){return{send:async(_,D)=>{const P={request:_,deliver:D?.deliver??"send"};return o(Bt.agentSend,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(P)})},status:async()=>(await o(Bt.session)).agent,onStatus:_=>u("agent",_)}},async room(){return{self:async()=>n,presence:async _=>{const D={client:n,patch:_};await o(Bt.presence,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(D)})},peers:async()=>(await o(Bt.peers)).peers,onPeers:_=>u("peers",_),emit:async(_,D)=>{const P={client:n,topic:_,data:D};await r(Bt.roomEmit,P)},onMessage:_=>u("room",_)}},async db(){const{stores:N}=await j();return N?.db?{get:async D=>(await o(Bt.dbGet,{cache:"no-store"},{path:D})).data,list:async D=>(await o(Bt.dbList,{cache:"no-store"},{collection:D})).documents,write:async D=>{const P={writes:D,client:n};await r(Bt.dbWrite,P)},onChange:D=>u("db",D)}:null},async comments(){const{stores:N}=await j();if(!N?.comments)return null;const _=async(P,L)=>(await r(P,L)).thread;return{list:async()=>(await o(Bt.comments,{cache:"no-store"})).threads,create:P=>_(Bt.commentsCreate,{input:P}),reply:(P,L)=>_(Bt.commentsReply,{threadId:P,text:L}),setResolved:(P,L)=>_(Bt.commentsResolve,{threadId:P,resolved:L}),move:(P,L,F)=>_(Bt.commentsMove,{threadId:P,anchor:L,...F?{location:F}:{}}),remove:async(P,L)=>{await r(Bt.commentsRemove,{threadId:P,...L?{messageId:L}:{}})},sendToAgent:P=>_(Bt.commentsSend,{threadId:P}),onChange:P=>u("comments",P)}},async history(){const{stores:N}=await j();if(!N?.history)return null;const _=(P,L)=>({n:String(P),...L===void 0?{}:{path:L}});return{list:()=>o(Bt.history,{cache:"no-store"}),files:async P=>(await o(Bt.historyFiles,{cache:"no-store"},_(P))).files,read:async(P,L)=>new TextDecoder().decode(await A(Bt.historyFile,_(P,L))),readBytes:(P,L)=>A(Bt.historyFile,_(P,L)),diff:(P,L)=>o(Bt.historyDiff,{cache:"no-store"},_(P,L)),restore:(P,L)=>r(Bt.historyRestore,{n:P,...L?{paths:L}:{},client:n}),dismissNotice:async P=>{await r(Bt.historyDismiss,{id:P})},onChange:P=>u("history",P)}},async mcp(){const{viewer:N}=await j();return N.role!=="owner"?null:{callTool:async(D,P,L,F)=>{const U=F?.signal;U?.throwIfAborted();const I={server:D,tool:P,args:L,...F?.timeoutMs===void 0?{}:{timeoutMs:F.timeoutMs}};try{return await o(Bt.mcpCall,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(I),...U?{signal:U}:{}})}catch(H){throw U?.aborted?U.reason:H}},listTools:D=>o(Bt.mcpTools,{cache:"no-store"},D===void 0?void 0:{server:D})}},async downloads(){return{save:async({name:_,data:D})=>o(Bt.downloads,{method:"POST",headers:{"content-type":D.type||"application/octet-stream"},body:D},{name:_})}}};function $(N){return A(Bt.file,{path:N})}async function A(N,_){let D;try{D=await fetch(s(N,_),{cache:"no-store"})}catch(P){throw new Qf("unavailable",P instanceof Error?P.message:String(P))}if(!D.ok)throw await kO(D);return new Uint8Array(await D.arrayBuffer())}return{get(N){const _=O[N];return _?_():null}}}const CQ="[Artifact comment sent to agent]",TQ="[Artifact edit request sent to agent]",MQ="[Artifact task finished]",RQ=1,jQ=1,AQ=/^[a-z][a-z0-9]{0,23}$/,OQ="may not have run: the artifact was updated before this call was answered",NQ=["quickstart","list","publish","read","open","call","adopt","delete","share"],$Q=["get","list","query","set","update","delete","str_replace","batch"],_Q=["read","reply","resolve","reopen","wait"],LQ=["share","export"],DQ={type:"object",properties:{action:{type:"string",enum:NQ,description:"What to do. Omitted: publish."},intent:{type:"string",description:"quickstart: what is being made (design, slides, whiteboard, document, data, other), or a few words about it."},scope:{type:"string",enum:["types","mine","all"],description:"list: the installed types, this session's and this workspace's artifacts (default), or every artifact."},type:{type:"string",description:"list: only artifacts of this type (an id, or open-artifact://type/<id>)."},query:{type:"string",description:"list: only artifacts whose title contains this text."},limit:{type:"integer",description:"list: how many to return (default 50, at most 200)."},cursor:{type:"string",description:"list: the next_cursor of the previous page."},type_url:{type:"string",description:"publish without url: the type to create from (open-artifact://type/<id>, from quickstart). read without url: the type to describe."},title:{type:"string",description:"publish without url: the new artifact's name."},folder:{type:"string",description:"publish without url, or adopt: where the artifact's folder goes (absolute, or relative to the workspace). Default <workspace>/artifacts/<slug>."},url:{type:"string",description:"An artifact: open-artifact://artifact/<id>, as publish returned it."},files:{type:"object",additionalProperties:!0,description:'publish with url: files to write under the artifact root, as {"rel/path": "text"} or {"rel/path": {"content": "...", "encoding": "base64"}}; null deletes.'},if_match:{type:"object",additionalProperties:!0,description:'publish with url: {"rel/path": sha256 | null | "*"}. Write only while the file still has the sha256 you read, does not exist (null), or anyway ("*"). One mismatch writes nothing and returns the current versions.'},check:{type:"boolean",description:"publish with url: run the type's check action after writing; its result comes back as check."},open:{type:"string",enum:["after_first_write","now"],description:"publish without url: after_first_write opens the page in your app once your first write lands; now opens it at once. Where your app cannot show pages by itself the result says so: open view_url in your app's built-in browser, if you have one."},related:{type:"boolean",description:"quickstart: list existing artifacts the recommended type can build on, such as design systems (default true)."},path:{type:"string",description:"read: one file or folder under the root (omitted: the record and the file list)."},paths:{type:"array",items:{type:"string"},description:"read: several files under the root at once."},name:{type:"string",description:"call: the action's name (check, upload, ...; read with url lists them)."},args:{type:"object",additionalProperties:!0,description:"call: the action's arguments. upload: {file: absolute path, name?, group?}."},panel:{type:"string",enum:LQ,description:"open: also open the page's Share panel (share), for the person to share it on the network, or its Export tab (export), for them to download a file."}}},zQ={type:"object",properties:{action:{type:"string",enum:$Q},url:{type:"string",description:"The artifact (open-artifact://artifact/<id>)."},collection:{type:"string"},doc_id:{type:"string"},path:{type:"string",description:"collection/doc_id, instead of the two."},data:{type:"object",additionalProperties:!0,description:"set / update: the document's fields."},file_path:{type:"string",description:"set / update: a JSON file holding the fields, instead of data."},if_match:{description:'set / update / delete / str_replace: the sha256 get returned (write only if unchanged), null (only if it does not exist) or "*" (replace whatever is there).'},field:{type:"string",description:"str_replace: the text field, as a dot path (body, notes.text)."},old:{type:"string",description:"str_replace: the passage to replace; it must occur exactly once."},new:{type:"string",description:"str_replace: the passage that replaces it."},where:{type:"array",items:{type:"object",additionalProperties:!0},description:"query: [{field, op, value}], all must hold. op: ==, !=, <, <=, >, >=, in, not-in (up to 30 values), array-contains."},order_by:{type:"object",additionalProperties:!0,description:'query: {field, dir: "asc" | "desc"}.'},limit:{type:"integer",description:"list / query: how many documents (default 100, at most 1000)."},cursor:{type:"string",description:"list / query: the next_cursor of the previous page."},out_file:{type:"string",description:"get / list / query: write the result to this JSON file (absolute, or relative to the workspace) and return only its path and counts."},writes:{type:"array",items:{type:"object",additionalProperties:!0},description:"batch: [{op: set|update|delete|str_replace, path | collection+doc_id, data | file_path, if_match?, field?, old?, new?}], at most 500."}},required:["action","url"]},PQ={type:"object",properties:{action:{type:"string",enum:_Q},url:{type:"string",description:"The artifact (open-artifact://artifact/<id>). wait: optional."},thread_id:{type:"string",description:'reply / resolve / reopen: the thread (after ";thread=" in the message).'},text:{type:"string",description:"reply: the answer."},resolve:{type:"boolean",description:"reply: resolve the thread too."},all:{type:"boolean",description:"read: resolved threads too."},since:{type:"string",description:"read: only threads with a message at or after this time (ISO 8601)."},acknowledge_duplicate:{type:"boolean",description:"reply: send the same text as your last reply in this thread again, on purpose."},timeout_ms:{type:"number",description:"wait: how long (default 600000)."}},required:["action"]},EO={Artifact:DQ,ArtifactData:zQ,ArtifactComments:PQ},IQ={Artifact:["Make and change artifacts: typed folders of files that open as live pages the person can view, edit, comment on and export. Actions:","- quickstart {intent}: call first for a new artifact; recommends a type and returns the call that creates it.",'- list {scope: "mine" | "all" | "types", type?, query?}: find existing artifacts, or the installed types.',"- publish {type_url, title, folder?, open?}: create an artifact; the result carries its root folder and the type's instructions. publish {url, files, if_match?, check?}: write files when you have no file tools of your own.","- read {url, path? | paths?}: the artifact's record, files and actions, or some of its files with their sha256. read {type_url}: a type's instructions, before creating.",`- open {url, panel?}: show it to the person in the computer's browser (or the app, when it shows pages), once its content is written. When your app has a built-in browser, open view_url there instead. panel "share" or "export" opens its Share panel or Export tab for them.`,"- call {url, name, args?}: run one of the type's actions (check, upload, ...). A long one answers {task, pending: true}; its result comes later as a message.","- adopt {url | folder}: take over an artifact, or add an existing folder. Only when the person asks.","- share {url}: whether it is shared on the local network, and its links. Only the person changes that, in the page's Share panel.","- delete {url}: forget an artifact; its folder stays. Only when the person asks."].join(`
|
|
13
|
+
`)}const xQ="1.3.0";class Qf extends Error{code;paths;retryable;constructor(t,n,s,o){super(n),this.name="ArtifactError",this.code=t,s&&(this.paths=s),o&&(this.retryable=!0)}}function wO(e,t){if(!e||typeof e!="object")return!1;const n=e;return n.name!=="ArtifactError"||typeof n.code!="string"?!1:t===void 0||n.code===t}function vQ(e){return e==="owner"||e==="editor"}const SO={defaultMs:12e4,maxMs:6e5};function wQ(e,t={}){const n=t.timeoutMs??1e4,s=new Map;return Object.freeze({version:xQ,use:r=>{const i=s.get(r);if(i)return i;const l=new Promise(u=>{const d=setTimeout(()=>u(null),n);Promise.resolve().then(()=>e.get(r)).then(f=>{clearTimeout(d),u(f?Object.freeze(f):null)},()=>{clearTimeout(d),u(null)})});return s.set(r,l),l}})}function SQ(e,t){const n=globalThis.window?.openartifact;if(n)return n;const s=wQ(e,t);return Object.defineProperty(window,"openartifact",{value:s,configurable:!1,enumerable:!0,writable:!1}),s}const Bt={session:"_api/session",files:"_api/files",file:"_api/file",publish:"_api/publish",assets:"_api/assets",events:"_api/events",agentSend:"_api/agent/send",presence:"_api/presence",peers:"_api/peers",downloads:"_api/downloads",roomEmit:"_api/room/emit",dbGet:"_api/db/get",dbList:"_api/db/list",dbWrite:"_api/db/write",comments:"_api/comments",commentsCreate:"_api/comments/create",commentsReply:"_api/comments/reply",commentsResolve:"_api/comments/resolve",commentsMove:"_api/comments/move",commentsRemove:"_api/comments/remove",commentsSend:"_api/comments/send",history:"_api/history",historyFiles:"_api/history/files",historyFile:"_api/history/file",historyDiff:"_api/history/diff",historyRestore:"_api/history/restore",historyDismiss:"_api/history/dismiss",mcpTools:"_api/mcp/tools",mcpCall:"_api/mcp/call"};function kQ(e,t,n){return t===401||t===403?"removed":t<200||t>=300||!n||n.id===e.id&&n.role===e.role?null:"changed"}async function kO(e){let t={};try{t=await e.json()}catch{}const n=e.status===409?"conflict":e.status===403?"not_writer":e.status===404?"not_found":"unavailable";return new Qf(t.code??n,t.message??`HTTP ${e.status}`,t.paths,t.retryable===!0)}function EQ(){const e=new Uint8Array(8);return crypto.getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}function zP(e={}){const t=new URL(e.base??"./",location.href),n=EQ(),s=(N,_)=>{const D=new URL(N,t);for(const[P,L]of Object.entries(_??{}))D.searchParams.set(P,L);return D.toString()},o=async(N,_,D)=>{let P;try{P=await fetch(s(N,D),_)}catch(L){throw new Qf("unavailable",L instanceof Error?L.message:String(L))}if(!P.ok)throw await kO(P);return await P.json()},r=(N,_)=>o(N,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(_)}),i=new Map,l=(N,_)=>{for(const D of i.get(N)??[])D(_)},u=(N,_)=>{let D=i.get(N);return D||(D=new Set,i.set(N,D),h?.addEventListener(N,y)),D.add(_),k(),()=>D.delete(_)};let d=null,f=!1,h=null,g=null;const y=N=>{l(N.type,JSON.parse(N.data))},b=()=>{const N=new EventSource(s(Bt.events,{client:n}));h=N;for(const _ of i.keys())N.addEventListener(_,y);N.onerror=()=>{C().then(_=>{_||N.readyState!==EventSource.CLOSED||h!==N||(h=null,g=setTimeout(()=>{g=null,k()},2e3))})}};let v=!1,w=!1;const S=N=>{v||(v=!0,g&&clearTimeout(g),g=null,h?.close(),h=null,d?.close(),d=null,e.onAccessChange?e.onAccessChange(N):location.reload())},C=async()=>{if(v)return!0;if(!M||w)return!1;w=!0;try{const N=(await M.catch(()=>null))?.viewer;if(!N)return!1;let _;try{_=await fetch(s(Bt.session),{cache:"no-store"})}catch{return!1}const D=_.ok?(await _.json().catch(()=>null))?.viewer:null,P=kQ(N,_.status,D);return P&&S(P),P!==null}finally{w=!1}};function k(){if(d||h||g||v)return;if(typeof WebSocket>"u")return b();const N=new URL(s(Bt.events,{client:n}));N.protocol=N.protocol==="https:"?"wss:":"ws:";const _=new WebSocket(N);d=_,_.onopen=()=>{f=!0},_.onmessage=D=>{let P;try{P=JSON.parse(String(D.data))}catch{return}P.event&&l(P.event,P.data)},_.onclose=()=>{if(d===_&&(d=null),!v){if(!f)return b();C().then(D=>{D||d||h||g||(g=setTimeout(()=>{g=null,k()},2e3))})}}}let M=null;const j=()=>M??=o(Bt.session),O={async artifact(){const{artifact:N}=await j();return{id:N.id,title:async()=>(await o(Bt.session)).artifact.title,list:async()=>(await o(Bt.files)).files,readText:async D=>new TextDecoder().decode(await $(D)),readBytes:D=>$(D),publish:async D=>{const P={files:D,client:n};return o(Bt.publish,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(P)})},onChange:D=>u("files",D)}},async assets(){const{viewer:N}=await j();return vQ(N.role)?{upload:async(D,P)=>o(Bt.assets,{method:"POST",headers:{"content-type":D.type||"application/octet-stream"},body:D},P?.name?{name:P.name}:void 0)}:null},async user(){const{viewer:N}=await j();return{me:async()=>N}},async agent(){return{send:async(_,D)=>{const P={request:_,deliver:D?.deliver??"send"};return o(Bt.agentSend,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(P)})},status:async()=>(await o(Bt.session)).agent,onStatus:_=>u("agent",_)}},async room(){return{self:async()=>n,presence:async _=>{const D={client:n,patch:_};await o(Bt.presence,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(D)})},peers:async()=>(await o(Bt.peers)).peers,onPeers:_=>u("peers",_),emit:async(_,D)=>{const P={client:n,topic:_,data:D};await r(Bt.roomEmit,P)},onMessage:_=>u("room",_)}},async db(){const{stores:N}=await j();return N?.db?{get:async D=>(await o(Bt.dbGet,{cache:"no-store"},{path:D})).data,list:async D=>(await o(Bt.dbList,{cache:"no-store"},{collection:D})).documents,write:async D=>{const P={writes:D,client:n};await r(Bt.dbWrite,P)},onChange:D=>u("db",D)}:null},async comments(){const{stores:N}=await j();if(!N?.comments)return null;const _=async(P,L)=>(await r(P,L)).thread;return{list:async()=>(await o(Bt.comments,{cache:"no-store"})).threads,create:P=>_(Bt.commentsCreate,{input:P}),reply:(P,L)=>_(Bt.commentsReply,{threadId:P,text:L}),setResolved:(P,L)=>_(Bt.commentsResolve,{threadId:P,resolved:L}),move:(P,L,F)=>_(Bt.commentsMove,{threadId:P,anchor:L,...F?{location:F}:{}}),remove:async(P,L)=>{await r(Bt.commentsRemove,{threadId:P,...L?{messageId:L}:{}})},sendToAgent:P=>_(Bt.commentsSend,{threadId:P}),onChange:P=>u("comments",P)}},async history(){const{stores:N}=await j();if(!N?.history)return null;const _=(P,L)=>({n:String(P),...L===void 0?{}:{path:L}});return{list:()=>o(Bt.history,{cache:"no-store"}),files:async P=>(await o(Bt.historyFiles,{cache:"no-store"},_(P))).files,read:async(P,L)=>new TextDecoder().decode(await A(Bt.historyFile,_(P,L))),readBytes:(P,L)=>A(Bt.historyFile,_(P,L)),diff:(P,L)=>o(Bt.historyDiff,{cache:"no-store"},_(P,L)),restore:(P,L)=>r(Bt.historyRestore,{n:P,...L?{paths:L}:{},client:n}),dismissNotice:async P=>{await r(Bt.historyDismiss,{id:P})},onChange:P=>u("history",P)}},async mcp(){const{viewer:N}=await j();return N.role!=="owner"?null:{callTool:async(D,P,L,F)=>{const U=F?.signal;U?.throwIfAborted();const I={server:D,tool:P,args:L,...F?.timeoutMs===void 0?{}:{timeoutMs:F.timeoutMs}};try{return await o(Bt.mcpCall,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(I),...U?{signal:U}:{}})}catch(H){throw U?.aborted?U.reason:H}},listTools:D=>o(Bt.mcpTools,{cache:"no-store"},D===void 0?void 0:{server:D})}},async downloads(){return{save:async({name:_,data:D})=>o(Bt.downloads,{method:"POST",headers:{"content-type":D.type||"application/octet-stream"},body:D},{name:_})}}};function $(N){return A(Bt.file,{path:N})}async function A(N,_){let D;try{D=await fetch(s(N,_),{cache:"no-store"})}catch(P){throw new Qf("unavailable",P instanceof Error?P.message:String(P))}if(!D.ok)throw await kO(D);return new Uint8Array(await D.arrayBuffer())}return{get(N){const _=O[N];return _?_():null}}}const CQ="[Artifact comment sent to agent]",TQ="[Artifact edit request sent to agent]",MQ="[Artifact task finished]",RQ=1,jQ=1,AQ=/^[a-z][a-z0-9]{0,23}$/,OQ="may not have run: the artifact was updated before this call was answered",NQ=["quickstart","list","publish","read","open","call","adopt","delete","share"],$Q=["get","list","query","set","update","delete","str_replace","batch"],_Q=["read","reply","resolve","reopen","wait"],LQ=["share","export"],DQ={type:"object",properties:{action:{type:"string",enum:NQ,description:"What to do. Omitted: publish."},intent:{type:"string",description:"quickstart: what is being made (design, design-system, slides, whiteboard, document, data, other), or a few words about it."},scope:{type:"string",enum:["types","mine","all"],description:"list: the installed types, this session's and this workspace's artifacts (default), or every artifact."},type:{type:"string",description:"list: only artifacts of this type (an id, or open-artifact://type/<id>)."},query:{type:"string",description:"list: only artifacts whose title contains this text."},limit:{type:"integer",description:"list: how many to return (default 50, at most 200)."},cursor:{type:"string",description:"list: the next_cursor of the previous page."},type_url:{type:"string",description:"publish without url: the type to create from (open-artifact://type/<id>, from quickstart). read without url: the type to describe."},title:{type:"string",description:"publish without url: the new artifact's name."},folder:{type:"string",description:"publish without url, or adopt: where the artifact's folder goes (absolute, or relative to the workspace). Default <workspace>/artifacts/<slug>."},url:{type:"string",description:"An artifact: open-artifact://artifact/<id>, as publish returned it."},files:{type:"object",additionalProperties:!0,description:'publish with url: files to write under the artifact root, as {"rel/path": "text"} or {"rel/path": {"content": "...", "encoding": "base64"}}; null deletes.'},if_match:{type:"object",additionalProperties:!0,description:'publish with url: {"rel/path": sha256 | null | "*"}. Write only while the file still has the sha256 you read, does not exist (null), or anyway ("*"). One mismatch writes nothing and returns the current versions.'},check:{type:"boolean",description:"publish with url: run the type's check action after writing; its result comes back as check."},open:{type:"string",enum:["after_first_write","now"],description:"publish without url: after_first_write opens the page in your app once your first write lands; now opens it at once. Where your app cannot show pages by itself the result says so: open view_url in your app's built-in browser, if you have one."},related:{type:"boolean",description:"quickstart: list existing artifacts the recommended type can build on, such as design systems (default true)."},path:{type:"string",description:"read: one file or folder under the root (omitted: the record and the file list)."},paths:{type:"array",items:{type:"string"},description:"read: several files under the root at once."},name:{type:"string",description:"call: the action's name (check, upload, ...; read with url lists them)."},args:{type:"object",additionalProperties:!0,description:"call: the action's arguments. upload: {file: absolute path, name?, group?}."},panel:{type:"string",enum:LQ,description:"open: also open the page's Share panel (share), for the person to share it on the network, or its Export tab (export), for them to download a file."}}},zQ={type:"object",properties:{action:{type:"string",enum:$Q},url:{type:"string",description:"The artifact (open-artifact://artifact/<id>)."},collection:{type:"string"},doc_id:{type:"string"},path:{type:"string",description:"collection/doc_id, instead of the two."},data:{type:"object",additionalProperties:!0,description:"set / update: the document's fields."},file_path:{type:"string",description:"set / update: a JSON file holding the fields, instead of data."},if_match:{description:'set / update / delete / str_replace: the sha256 get returned (write only if unchanged), null (only if it does not exist) or "*" (replace whatever is there).'},field:{type:"string",description:"str_replace: the text field, as a dot path (body, notes.text)."},old:{type:"string",description:"str_replace: the passage to replace; it must occur exactly once."},new:{type:"string",description:"str_replace: the passage that replaces it."},where:{type:"array",items:{type:"object",additionalProperties:!0},description:"query: [{field, op, value}], all must hold. op: ==, !=, <, <=, >, >=, in, not-in (up to 30 values), array-contains."},order_by:{type:"object",additionalProperties:!0,description:'query: {field, dir: "asc" | "desc"}.'},limit:{type:"integer",description:"list / query: how many documents (default 100, at most 1000)."},cursor:{type:"string",description:"list / query: the next_cursor of the previous page."},out_file:{type:"string",description:"get / list / query: write the result to this JSON file (absolute, or relative to the workspace) and return only its path and counts."},writes:{type:"array",items:{type:"object",additionalProperties:!0},description:"batch: [{op: set|update|delete|str_replace, path | collection+doc_id, data | file_path, if_match?, field?, old?, new?}], at most 500."}},required:["action","url"]},PQ={type:"object",properties:{action:{type:"string",enum:_Q},url:{type:"string",description:"The artifact (open-artifact://artifact/<id>). wait: optional."},thread_id:{type:"string",description:'reply / resolve / reopen: the thread (after ";thread=" in the message).'},text:{type:"string",description:"reply: the answer."},resolve:{type:"boolean",description:"reply: resolve the thread too."},all:{type:"boolean",description:"read: resolved threads too."},since:{type:"string",description:"read: only threads with a message at or after this time (ISO 8601)."},acknowledge_duplicate:{type:"boolean",description:"reply: send the same text as your last reply in this thread again, on purpose."},timeout_ms:{type:"number",description:"wait: how long (default 600000)."}},required:["action"]},EO={Artifact:DQ,ArtifactData:zQ,ArtifactComments:PQ},IQ={Artifact:["Make and change artifacts: typed folders of files that open as live pages the person can view, edit, comment on and export. Actions:","- quickstart {intent}: call first for a new artifact; recommends a type and returns the call that creates it.",'- list {scope: "mine" | "all" | "types", type?, query?}: find existing artifacts, or the installed types.',"- publish {type_url, title, folder?, open?}: create an artifact; the result carries its root folder and the type's instructions. publish {url, files, if_match?, check?}: write files when you have no file tools of your own.","- read {url, path? | paths?}: the artifact's record, files and actions, or some of its files with their sha256. read {type_url}: a type's instructions, before creating.",`- open {url, panel?}: show it to the person in the computer's browser (or the app, when it shows pages), once its content is written. When your app has a built-in browser, open view_url there instead. panel "share" or "export" opens its Share panel or Export tab for them.`,"- call {url, name, args?}: run one of the type's actions (check, upload, ...). A long one answers {task, pending: true}; its result comes later as a message.","- adopt {url | folder}: take over an artifact, or add an existing folder. Only when the person asks.","- share {url}: whether it is shared on the local network, and its links. Only the person changes that, in the page's Share panel.","- delete {url}: forget an artifact; its folder stays. Only when the person asks."].join(`
|
|
14
14
|
`),ArtifactData:'Read and write the document store of an artifact whose type keeps one (its instructions say so). get, list and query read documents with their sha256; set, update, delete, str_replace and batch write them. update merges fields, and {"__delete__": true} removes one; str_replace changes one passage of a long text field. Replacing or deleting an existing document needs if_match: the sha256 you read, or "*". Your writes show live on open pages.',ArtifactComments:`Comments the person leaves on their artifact's page, kept in the artifact's own folder on this computer (no outside service). read lists the threads; reply answers one (thread_id is after ";thread=" in the message), with resolve: true when it is done; resolve and reopen change a thread's state. A thread sent to you is the person asking for your answer in it, so replying there is what they asked for. Answer only threads sent to you, in one or two lines. wait blocks until the next message for this session: use it only when nothing else can wake you.`},BQ={Artifact:{title:"Artifact",openWorldHint:!1},ArtifactData:{title:"Artifact data",openWorldHint:!1},ArtifactComments:{title:"Artifact comments",destructiveHint:!1,openWorldHint:!1}};Object.keys(EO).map(e=>({name:e,description:IQ[e],inputSchema:EO[e],annotations:BQ[e]}));const HQ=300,FQ=12,CO=["Artifact","ArtifactData","ArtifactComments"];function ka(e,t=HQ){const n=String(e??"").replace(/[<>]/g,"").replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,t-1).trimEnd()}…`:n}function UQ(e){const t=ka(e,Number.MAX_SAFE_INTEGER),n=t.search(/[.!?。!?](\s|$)/);return n>=0?t.slice(0,n+1):t}function VQ(e){const t=ka(e,24);return/^[a-z0-9]{1,5}$/i.test(t)?t.toUpperCase():t}const TO=e=>!e||/[.!?。!?…]$/.test(e)?e:`${e}.`;function qQ(e,t=!1){const n=ka(e.title,80)||e.id;if(t)return`- ${e.id}: ${n}`;const s=ka(e.when)||ka(UQ(e.description)),o=(e.exports??[]).map(VQ).filter(Boolean),r=[TO(n),TO(s),o.length?`Exports: ${o.join(", ")}.`:""].filter(Boolean);return`- ${e.id}: ${r.join(" ")}`}const GQ="Open Artifact lets you make artifacts: typed folders of files (a slide deck, a design canvas, a whiteboard, a data dashboard and more) that open as live pages the person can view, edit, comment on and export. You make and change them with the Artifact, ArtifactData and ArtifactComments tools.",WQ=`<where_output_goes>
|
|
15
15
|
Decide where your output will live before you make anything.
|
|
16
16
|
- Something the person will read once and move on from (an answer, an explanation, a summary, a short report) goes in your reply, however long it is. A diagram or chart that explains your answer goes in the reply too, when you can show one there.
|
|
@@ -566,4 +566,4 @@ ${ob()}`,y=O6(d,g,{width:ot,height:vt,outerWidth:f,outerHeight:h}),b=await N6(y,
|
|
|
566
566
|
`});return}if(vk.has(u.tagName)){s(),o(u,_5(u,l)),s();return}o(u,_5(u,l))}})};o(e,{});let r=ws(t);for(;r.length&&r[0].text.startsWith(`
|
|
567
567
|
`);)r=ws([{...r[0],text:r[0].text.slice(1)},...r.slice(1)]);for(;r.length&&r[r.length-1].text.endsWith(`
|
|
568
568
|
`);){const i=r[r.length-1];r=ws([...r.slice(0,-1),{...i,text:i.text.slice(0,-1)}])}return _pe(r)}function _pe(e){let t=e;for(CS(t)>ve.textChars&&(t=ree(t,0,ve.textChars));KP(t)>ve.inlineMarks&&t.some(n=>n.marks);){const n=t.map(s=>!!s.marks).lastIndexOf(!0);t=ws(t.map((s,o)=>o===n?{text:s.text}:s))}return t}function HB(e){const t=[...e.children].filter(n=>n.tagName==="LI").map(n=>{const s=BB(n);return s?{runs:zl(n),level:s}:{runs:zl(n)}});return t.length?t:[{runs:zl(e)}]}function Lpe(e,t){const n=[];let s=[];const o=()=>{if(s.length===0)return;const r=document.createElement("p");for(const l of s)r.appendChild(l.cloneNode(!0));const i=zl(r);(i.length||n.length===0)&&n.push({kind:"text",tag:"p",style:{},runs:i}),s=[]};return e.childNodes.forEach(r=>{if(r instanceof HTMLElement&&(r.tagName==="UL"||r.tagName==="OL")){o(),n.push({kind:"list",tag:r.tagName==="UL"?"ul":"ol",style:{},items:HB(r)});return}if(r instanceof HTMLElement&&vk.has(r.tagName)){o();const i=/^H[1-3]$/.test(r.tagName)?r.tagName.toLowerCase():"p";n.push({kind:"text",tag:i,style:{},runs:zl(r)});return}s.push(r)}),o(),n.map((r,i)=>{const l=t[i];return l&&l.kind===r.kind?{...r,style:l.style}:r})}let Eu=null,Cu=null,El=null;function L5(e){El=e}function Dr(){return Eu&&Eu.isConnected?Eu:null}function FB(){const e=Dr();if(e&&(e.focus({preventScroll:!0}),Cu)){const t=window.getSelection();t?.removeAllRanges(),t?.addRange(Cu)}}function Dpe(){const e=Cu??(window.getSelection()?.rangeCount?window.getSelection().getRangeAt(0):null);return!e||e.collapsed}function N0(e,t){const n=Dr();n&&(FB(),document.execCommand("styleWithCSS",!1,e==="foreColor"?"true":"false"),document.execCommand(e,!1,t),n.dispatchEvent(new Event("input",{bubbles:!0})))}function zpe(e){if(!Dr())return!1;try{return document.queryCommandState(e)}catch{return!1}}function Ppe(e){return e instanceof Element&&!!e.closest("[data-open-artifact-format-bar]")}function Ipe(e,t,n){switch(e.kind){case"text":{const s=zl(t);return hw(s,e.runs)?null:{...e,runs:s}}case"list":{const s=HB(t);return s.length===e.items.length&&s.every((r,i)=>hw(r.runs,e.items[i].runs)&&(r.level??0)===(e.items[i].level??0))?null:{...e,items:s}}case"textbox":{const s=Lpe(t,e.blocks),o=JSON.stringify(e.blocks);return JSON.stringify(s)===o?null:{...e,blocks:s}}case"table":{if(!n)return null;const s=t.querySelector(`[data-open-artifact-cell="${n[0]}:${n[1]}"]`),o=e.rows[n[0]]?.cells[n[1]];if(!s||!o)return null;const r=zl(s);return hw(r,o.runs)?null:wte(e,n[0],n[1],ws(r))}default:return null}}function Bpe(e,t,n,s,o){Ua(e,"Edit text",r=>{let i=!1;const l=Bn(r,t,u=>{const d=Ipe(u,n,s);return d?(i=!0,d):u});return i?l:null},{coalesce:o})}function Hpe(e,t){const n=window.getSelection();if(!n)return;let s=null;if(El){const r=document.caretPositionFromPoint?.(El.x,El.y);if(r&&e.contains(r.offsetNode))s=document.createRange(),s.setStart(r.offsetNode,r.offset);else{const i=document.caretRangeFromPoint?.(El.x,El.y);i&&e.contains(i.startContainer)&&(s=i)}El=null}s||(s=document.createRange(),s.selectNodeContents(e),t||s.collapse(!1)),n.removeAllRanges(),n.addRange(s)}function Sb(e,t,n,s){const{slideId:o,path:r,cell:i}=t,l=T.useRef(`text:${o}:${rs(r)}:${i?.join(":")??""}:${Date.now()}`),u=T.useRef(null);T.useLayoutEffect(()=>{const d=e.current;if(!d)return;d.innerHTML=n(),Eu=d,Cu=null,d.focus({preventScroll:!0}),Hpe(d,s.placeholder);const f=()=>{u.current&&clearTimeout(u.current),u.current=null,Bpe(o,r,d,i,l.current)},h=()=>{u.current&&clearTimeout(u.current),u.current=setTimeout(f,400)},g=v=>{if(v.key==="Escape"){v.preventDefault(),v.stopPropagation(),f(),se.getState().endTextEdit();return}if(v.key==="Enter"&&(s.lineBreakOnEnter||v.shiftKey)&&!v.isComposing){v.preventDefault(),document.execCommand("insertLineBreak");return}if(v.key==="Tab"&&!v.isComposing&&(t.node.kind==="list"||t.node.kind==="textbox")){const w=t.node.kind==="list"?d:window.getSelection()?.anchorNode?.parentElement?.closest("ul,ol");w&&d.contains(w)&&Npe(w,v.shiftKey?-1:1)&&(v.preventDefault(),h());return}if(v.key==="Tab"&&i&&t.node.kind==="table"){v.preventDefault(),f();const w=t.node,S=w.rows[0]?.cells.length??1,C=i[0]*S+i[1]+(v.shiftKey?-1:1),k=w.rows.length*S;if(C<0||C>=k){se.getState().endTextEdit();return}se.getState().startTextEdit({slideId:o,path:r,cell:[Math.floor(C/S),C%S]})}},y=v=>{v.preventDefault(),v.stopPropagation();const w=v.clipboardData?.getData("text/plain")??"";document.execCommand("insertText",!1,w)},b=v=>{const w=window.getSelection();w?.rangeCount&&d.contains(w.getRangeAt(0).startContainer)&&(Cu=w.getRangeAt(0).cloneRange()),!Ppe(v.relatedTarget)&&f()};return d.addEventListener("input",h),d.addEventListener("keydown",g),d.addEventListener("paste",y),d.addEventListener("blur",b),document.execCommand("defaultParagraphSeparator",!1,"p"),()=>{d.removeEventListener("input",h),d.removeEventListener("keydown",g),d.removeEventListener("paste",y),d.removeEventListener("blur",b),f(),Eu===d&&(Eu=null),Cu=null}},[])}const kb={contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!0,"data-open-artifact-editing":""};function Fpe(e){const{node:t,path:n}=e,s=T.useRef(null),o=hs();Sb(s,e,()=>wb(t.runs),{lineBreakOnEnter:!0,placeholder:UB(t)===mE}),Va(s,t.fit,[t]);const r=t.tag,i=Mn(t.style,{resolveUrl:o.resolveSrc});return p.jsx(r,{ref:s,className:"open-artifact-text","data-open-artifact-path":rs(n),"data-open-artifact-kind":"text",style:i,...kb})}function Upe(e){const{node:t,path:n}=e,s=T.useRef(null),o=hs();Sb(s,e,()=>IB(t),{lineBreakOnEnter:!1,placeholder:!1}),Va(s,t.fit,[t]);const r=t.tag;return p.jsx(r,{ref:s,className:"open-artifact-list","data-open-artifact-path":rs(n),"data-open-artifact-kind":"list",style:Mn(t.style,{resolveUrl:o.resolveSrc}),...kb})}function Vpe(e){const{node:t,path:n}=e,s=T.useRef(null),o=hs(),r=t.blocks.length===1&&t.blocks[0].kind==="text"&&UB(t.blocks[0])===mE;Sb(s,e,()=>$pe(t.blocks),{lineBreakOnEnter:!1,placeholder:r}),Va(s,t.fit,[t]);const i=Mn(t.style,{resolveUrl:o.resolveSrc});return t.indent!==void 0&&(i["--open-artifact-indent"]=`${t.indent}px`),p.jsx("div",{ref:s,className:"open-artifact-textbox","data-open-artifact-path":rs(n),"data-open-artifact-kind":"textbox",style:i,...kb})}function qpe(e){const{node:t,cell:n}=e,s=T.useRef(null),o=t.rows[n[0]].cells[n[1]];Sb(s,e,()=>wb(o.runs),{lineBreakOnEnter:!0,placeholder:!1});const r=o.tag;return p.jsx(r,{ref:s,"data-open-artifact-cell":`${n[0]}:${n[1]}`,style:Mn(o.style),...kb})}function Gpe(e){const{node:t,path:n,cell:s}=e,o=T.useRef(null),r=hs();return Va(o,t.fit,[t]),p.jsx("div",{ref:o,className:"open-artifact-tablebox","data-open-artifact-path":rs(n),"data-open-artifact-kind":"table",style:Mn(t.style,{resolveUrl:r.resolveSrc}),children:p.jsx("table",{className:"open-artifact-table",children:p.jsx("tbody",{children:t.rows.map((i,l)=>p.jsx("tr",{style:Mn(i.style),children:i.cells.map((u,d)=>{if(s&&s[0]===l&&s[1]===d)return p.jsx(qpe,{...e,node:t,cell:[l,d]},`edit-${l}-${d}`);const f=u.tag;return p.jsx(f,{"data-open-artifact-cell":`${l}:${d}`,style:Mn(u.style),children:p.jsx(Uu,{runs:u.runs,linkable:!1})},`view-${l}-${d}`)})},l))})})})}function UB(e){return e.runs.map(t=>t.text).join("")}function Wpe(e){switch(e.node.kind){case"text":return p.jsx(Fpe,{...e,node:e.node});case"list":return p.jsx(Upe,{...e,node:e.node});case"textbox":return p.jsx(Vpe,{...e,node:e.node});case"table":return p.jsx(Gpe,{...e,node:e.node})}}function zr({children:e,...t}){return p.jsx("svg",{viewBox:"0 0 16 16",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,...t,children:e})}function VB(e){return p.jsxs(zr,{...e,strokeWidth:1.2,children:[p.jsx("path",{d:"M1.5 7H6.5M4 7V13"}),p.jsx("path",{d:"M7.5 3.5H14.5M11 3.5V13"})]})}function Ype(e){return p.jsxs(zr,{...e,children:[p.jsx("path",{d:"M3.5 2.5V13.5M2 4L3.5 2.5L5 4M2 12L3.5 13.5L5 12"}),p.jsx("path",{d:"M7.5 4H14M7.5 8H14M7.5 12H14"})]})}function Kpe(e){return p.jsxs(zr,{...e,children:[p.jsx("path",{d:"M2 2.5V13.5M14 2.5V13.5"}),p.jsx("path",{d:"M5.25 11.5L8 4.5L10.75 11.5M6.2 9H9.8"})]})}function Xpe(e){return p.jsx(zr,{...e,children:p.jsx("path",{d:"M5.327 2.655H10.673M5.327 13.345H10.673M2.655 5.328V10.673M13.345 5.328V10.673"})})}function Zpe(e){return p.jsx(zr,{...e,children:p.jsx("path",{d:"M2.739 5.826V4.739C2.739 3.634 3.634 2.739 4.739 2.739H5.826M10.174 2.739H11.261C12.366 2.739 13.261 3.634 13.261 4.739V5.826M13.261 10.174V11.261C13.261 12.366 12.366 13.261 11.261 13.261H10.174M5.826 13.261H4.739C3.634 13.261 2.739 12.366 2.739 11.261V10.174"})})}const Qpe={top:"M3 3H13",right:"M13 3V13",bottom:"M3 13H13",left:"M3 3V13"};function Jpe({side:e,...t}){return p.jsxs(zr,{...t,children:[p.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1",strokeOpacity:.3,strokeDasharray:"1.5 1.5"}),p.jsx("path",{d:Qpe[e],strokeWidth:1.5})]})}const eme={"top-left":0,"top-right":90,"bottom-right":180,"bottom-left":270};function tme({corner:e,...t}){return p.jsx(zr,{...t,children:p.jsx("path",{d:"M3.5 12.5V8C3.5 5.515 5.515 3.5 8 3.5H12.5",transform:`rotate(${eme[e]} 8 8)`})})}function qB(e){return p.jsx(zr,{...e,strokeWidth:1.5,children:p.jsx("path",{d:"M2 8H14"})})}function GB(e){return p.jsx(zr,{...e,strokeWidth:1.5,children:p.jsx("path",{d:"M1.5 8H4.5M6.5 8H9.5M11.5 8H14.5"})})}function WB(e){return p.jsx(zr,{...e,strokeWidth:1.5,children:p.jsx("path",{d:"M2 8H2.01M5 8H5.01M8 8H8.01M11 8H11.01M14 8H14.01"})})}function YB(e){const t=String(e),n=t.indexOf(".");return n===-1||t.includes("e")?0:t.length-n-1}function KB(e){return Math.max(2,YB(e),Math.ceil(-Math.log10(Math.max(e,Number.EPSILON))))}function nme(e,t){const n=10**KB(t);return Math.round(e*n)/n}function sme(e,t,n){if(!(t>0)||!Number.isFinite(t)||!Number.isFinite(e))return e+0;const s=n==null&&Number.isInteger(t)?1:t,o=n??0,r=(e-o)/s,i=Math.round(Number(r.toPrecision(12))),l=10**Math.max(KB(s),YB(o)),u=Math.round((i*s+o)*l)/l+0;if(Math.abs(r)<1e12&&Number.isFinite(u))return u;const d=nme(e,t)+0;return Number.isFinite(d)?d:e+0}function ome(e,t){let n=t,s=null,o=!1;return{move(r,i){const l=e(),u=r-n;if(n=r,!o){if(u===0)return;o=!0}s===null&&(s=Number.isFinite(l.value)?l.value:0);const d=l.step??1,f=g=>Math.min(l.max??1/0,Math.max(l.min??-1/0,g));s=f(s+u*d*(i?10:1));const h=s===l.min||s===l.max?s:f(sme(s,d,l.origin));l.onScrub(h+0)},up(){o&&e().onScrubEnd?.()},get live(){return o}}}let Tf=null;function rme(e,t=window){Tf?.();const n=r=>{if(r.buttons===0){o();return}e.move(r.clientX,r.shiftKey)},s=r=>{r.key==="Escape"&&(e.live&&r.preventDefault(),o())},o=()=>{Tf===o&&(Tf=null),t.removeEventListener("mousemove",n),t.removeEventListener("mouseup",o),t.removeEventListener("blur",o),t.removeEventListener("keydown",s,!0),e.up()};return Tf=o,t.addEventListener("mousemove",n),t.addEventListener("mouseup",o),t.addEventListener("blur",o),t.addEventListener("keydown",s,!0),o}function ime(e){if(!(e.button!==0||e.pointerType==="touch"))try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}}function ame(e){const t=T.useRef(e);t.current=e;const n=T.useRef(null);return T.useEffect(()=>()=>{n.current&&n.current===Tf&&n.current()},[]),s=>{if(t.current.disabled||s.button!==0)return;s.preventDefault();const o=document.activeElement;o&&o!==s.currentTarget&&(o.tagName==="INPUT"||o.tagName==="TEXTAREA")&&o.blur(),n.current=rme(ome(()=>t.current,s.clientX))}}function ss({title:e,children:t,actions:n,collapsible:s=!1,defaultOpen:o=!s}){return s?p.jsxs(tZ,{defaultOpen:o,className:"border-t border-chrome-sep first:border-t-0",children:[p.jsxs(sZ,{className:"group flex min-h-10 w-full items-center gap-1 py-2 pl-4 pr-3 text-left outline-none focus-visible:bg-chrome-hover",children:[p.jsx("h3",{className:"min-w-0 flex-1 truncate text-[13px] font-[520] text-chrome-fg",children:e}),p.jsx(z2,{className:"size-4 text-chrome-muted transition-transform group-data-[panel-open]:rotate-90",strokeWidth:1.5})]}),p.jsx(cZ,{className:"flex min-w-0 flex-col pb-2",children:t})]}):p.jsxs("section",{className:"flex min-w-0 shrink-0 flex-col border-t border-chrome-sep pb-2 first:border-t-0",children:[p.jsxs("header",{className:"flex min-h-10 items-center gap-1 py-2 pl-4 pr-3",children:[p.jsx("h3",{className:"min-w-0 flex-1 truncate text-[13px] font-[520] text-chrome-fg",children:e}),n?p.jsx("div",{className:"-my-1 flex items-center gap-0.5",children:n}):null]}),t?p.jsx("div",{className:"flex min-w-0 flex-col",children:t}):null]})}function Be({label:e,children:t,className:n,tip:s,onReset:o,resetLabel:r}){return e===void 0?p.jsx("div",{className:Ie("flex min-h-8 min-w-0 flex-wrap items-center gap-1.5 px-4 py-px",n),children:t}):p.jsxs("div",{className:Ie("group/row grid min-h-8 min-w-0 grid-cols-[72px_minmax(0,1fr)] items-center gap-x-2 py-px pl-4 pr-3",n),children:[p.jsxs("span",{className:"flex min-w-0 items-center gap-0.5",title:s,children:[p.jsx("span",{className:"truncate text-[12px] text-chrome-muted",children:e}),o?p.jsx("button",{type:"button","aria-label":r??`Reset ${typeof e=="string"?e:""}`.trim(),title:r??`Reset ${typeof e=="string"?e:""}`.trim(),onClick:o,className:"flex size-4 shrink-0 items-center justify-center rounded-[4px] text-chrome-muted opacity-0 outline-none hover:bg-chrome-hover hover:text-chrome-fg focus-visible:opacity-100 group-hover/row:opacity-100",children:p.jsx(_u,{className:"size-3",strokeWidth:1.75})}):null]}),p.jsx("div",{className:"flex min-w-0 items-center gap-1.5",children:t})]})}function di({children:e,className:t}){return p.jsx("p",{className:Ie("px-4 py-1 text-[12px] leading-[1.45] text-chrome-muted",t),children:e})}const hd="h-6 min-w-0 rounded-[6px] bg-chrome-field text-[13px] text-chrome-fg outline-none shadow-[inset_0_0_0_1px_var(--chrome-field-ring)] transition-shadow hover:shadow-[inset_0_0_0_1px_var(--chrome-field-ring-strong)] focus-within:shadow-[inset_0_0_0_1px_var(--color-chrome-accent)] has-[:disabled]:opacity-50",XB=Ie(hd,"w-full px-2 placeholder:text-chrome-muted focus:shadow-[inset_0_0_0_1px_var(--color-chrome-accent)]"),Eb=T.forwardRef(function({className:t,...n},s){return p.jsx("input",{ref:s,className:Ie(XB,t),...n})});function _C({value:e,onCommit:t,className:n,...s}){const[o,r]=T.useState(e);T.useEffect(()=>r(e),[e]);const i=()=>{o!==e&&t(o)};return p.jsx("input",{className:Ie(XB,n),value:o,onChange:l=>r(l.target.value),onBlur:i,onKeyDown:l=>{l.key==="Enter"?(i(),l.currentTarget.blur()):l.key==="Escape"&&(r(e),l.currentTarget.blur())},...s})}function ZB(e){return e&&/(^|\s)w-/.test(e)?"":"w-full"}const lme={useGrouping:!1,maximumFractionDigits:3};function St({value:e,onChange:t,onCommit:n,label:s,unit:o,min:r,max:i,step:l=1,placeholder:u,className:d,steppers:f=!0,disabled:h,title:g,inherited:y=!1,...b}){const[v,w]=T.useState(null),S=T.useRef(null),C=ame({value:e??Number.NaN,step:l,min:r,max:i,disabled:h,onScrub:k=>{S.current=k,w(k),t?.(k)},onScrubEnd:()=>{const k=S.current;S.current=null,w(null),k!==null&&k!==e&&n(k)}});return p.jsxs(zz,{value:v??e,min:r,max:i,step:l,disabled:h,title:g,onValueChange:k=>t?.(k),onValueCommitted:k=>n(k),format:lme,className:Ie(hd,"group/num relative flex items-center",ZB(d),d),children:[s!==void 0?p.jsx("span",{"data-scrub":"",onMouseDown:C,onPointerDown:ime,className:Ie("flex h-full shrink-0 cursor-ew-resize items-center text-[11px] text-chrome-muted [&>svg]:size-3.5",typeof s=="string"?"whitespace-nowrap pl-2 pr-1.5":"w-6 justify-center"),children:s}):null,p.jsx(Iz,{placeholder:u,"aria-label":b["aria-label"],onKeyDown:k=>{if(k.key!=="Enter"||k.nativeEvent.isComposing)return;const M=k.currentTarget;M.blur(),M.focus()},className:Ie("h-full w-full min-w-0 bg-transparent text-[13px] tabular-nums text-chrome-fg outline-none",y?"placeholder:text-chrome-secondary":"placeholder:text-chrome-muted",s===void 0&&"pl-2")}),o?p.jsx("span",{className:"shrink-0 pr-2 text-[12px] text-chrome-muted group-focus-within/num:hidden",children:o}):null,f?p.jsxs("span",{className:"hidden h-full shrink-0 flex-col justify-center pr-0.5 group-focus-within/num:flex [@media(pointer:coarse)]:!hidden",children:[p.jsx(NK,{tabIndex:-1,"aria-label":"Increase",className:"flex h-2.5 w-4 items-center justify-center rounded-[3px] text-chrome-muted hover:bg-chrome-hover hover:text-chrome-fg",children:p.jsx(EL,{className:"size-3",strokeWidth:2})}),p.jsx($K,{tabIndex:-1,"aria-label":"Decrease",className:"flex h-2.5 w-4 items-center justify-center rounded-[3px] text-chrome-muted hover:bg-chrome-hover hover:text-chrome-fg",children:p.jsx(Fo,{className:"size-3",strokeWidth:2})})]}):null]})}function Ss({value:e,options:t,onChange:n,placeholder:s="—",className:o,icon:r,valueStyle:i,disabled:l,title:u,inherited:d=!1,...f}){const h=t.find(g=>g.value===e);return p.jsxs(QK,{value:e,disabled:l,onValueChange:g=>g!==null&&n(g),children:[p.jsxs(sX,{"aria-label":f["aria-label"],title:u,className:Ie(hd,"flex cursor-default items-center gap-1.5 pl-2 pr-[5px] text-left disabled:opacity-50",ZB(o),o),children:[r?p.jsx("span",{className:"flex shrink-0 text-chrome-muted [&>svg]:size-3.5",children:r}):null,p.jsx("span",{className:Ie("min-w-0 flex-1 truncate",!h&&(d?"text-chrome-secondary":"text-chrome-muted")),style:h?i??h.style:void 0,children:h?.label??s}),p.jsx(Fo,{className:"size-4 shrink-0 text-chrome-muted",strokeWidth:1.5})]}),p.jsx(oX,{children:p.jsx(iX,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[1000]",children:p.jsx(uX,{className:"max-h-[min(420px,var(--available-height))] min-w-[var(--anchor-width)] overflow-auto rounded-[14px] bg-chrome p-1.5 text-[13px] text-chrome-fg shadow-chrome-popup outline-none",children:p.jsx(fX,{children:t.map((g,y)=>{const b=g.group&&g.group!==t[y-1]?.group?g.group:null;return p.jsxs(T.Fragment,{children:[g.separated&&y>0?p.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-chrome-sep"}):null,b?p.jsx("div",{className:"px-2 pb-1 pt-2 text-[11px] font-[520] text-chrome-muted first:pt-1",children:b}):null,p.jsxs(hX,{value:g.value,disabled:g.disabled,title:g.disabled?g.reason:g.title,className:"flex min-h-7 cursor-default select-none items-center gap-2 rounded-[8px] py-0.5 pl-2 pr-2.5 outline-none data-[disabled]:opacity-40 data-[highlighted]:bg-chrome-hover",children:[p.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:p.jsx(pX,{children:p.jsx(Ni,{className:"size-4 text-chrome-accent",strokeWidth:2.25})})}),g.icon?p.jsx("span",{className:"flex shrink-0 text-chrome-muted [&>svg]:size-4",children:g.icon}):null,p.jsx(gX,{className:"min-w-0 flex-1 truncate",style:g.style,children:g.label}),g.hint?p.jsx("span",{className:"shrink-0 pl-3 text-[12px] tabular-nums text-chrome-muted",children:g.hint}):null]})]},g.value)})})})})})]})}function As({value:e,options:t,onChange:n,className:s,vertical:o=!1,...r}){return p.jsx(bP,{value:e===null?[]:[e],onValueChange:i=>{const l=i[0];l!==void 0&&n(l)},"aria-label":r["aria-label"],orientation:o?"vertical":"horizontal",className:Ie("flex items-center gap-0.5 rounded-[6px] bg-chrome-field p-px",o?"w-6 flex-col":"h-6 w-full",s),children:t.map(i=>p.jsx(xP,{value:i.value,disabled:i.disabled,"aria-label":i.title,title:i.disabled?i.reason??i.title:i.title,className:"flex h-[22px] min-w-0 flex-1 items-center justify-center rounded-[5px] px-1 text-[12px] in-data-[orientation=vertical]:w-[22px] in-data-[orientation=vertical]:flex-none text-chrome-muted outline-none hover:text-chrome-fg focus-visible:outline-2 focus-visible:outline-chrome-accent data-[disabled]:opacity-35 data-[pressed]:bg-chrome data-[pressed]:text-chrome-fg data-[pressed]:shadow-[0_0_0_1px_rgb(0_0_0/0.06),0_1px_2px_rgb(0_0_0/0.08)] [&>svg]:size-4",children:i.icon??i.label},i.value))})}function _1({checked:e,onChange:t,disabled:n,...s}){return p.jsx(pP,{checked:e,disabled:n,onCheckedChange:o=>t(o),"aria-label":s["aria-label"],className:"relative inline-flex h-4 w-7 shrink-0 items-center rounded-full bg-chrome-selected p-0.5 transition-colors data-[checked]:bg-chrome-accent disabled:opacity-40",children:p.jsx(mP,{className:"size-3 rounded-full bg-white shadow transition-transform data-[checked]:translate-x-3"})})}function cme({checked:e,onChange:t,disabled:n,...s}){return p.jsx("button",{type:"button",role:"checkbox","aria-checked":e,"aria-label":s["aria-label"],disabled:n,onClick:()=>t(!e),className:Ie("flex size-3.5 shrink-0 items-center justify-center rounded-[4px] outline-none focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-chrome-accent disabled:opacity-40",e?"bg-chrome-accent text-white":"shadow-[inset_0_0_0_1px_var(--chrome-field-ring-strong)]"),children:e?p.jsx(Ni,{className:"size-3",strokeWidth:3}):null})}function ume({value:e,min:t,max:n,step:s=1,onChange:o,onCommit:r,disabled:i,...l}){return p.jsx(oP,{value:e,disabled:i,min:t,max:n,step:s,onValueChange:u=>o(Array.isArray(u)?u[0]??t:u),onValueCommitted:u=>r?.(Array.isArray(u)?u[0]??t:u),className:"flex h-6 w-full items-center px-1 data-[disabled]:opacity-40",children:p.jsx(aP,{className:"flex h-4 w-full items-center",children:p.jsxs(lP,{className:"h-[3px] w-full rounded-full bg-chrome-selected",children:[p.jsx(uP,{className:"rounded-full bg-chrome-accent"}),p.jsx(cP,{"aria-label":l["aria-label"],className:"size-3.5 rounded-full bg-white shadow-[0_0_0_1px_rgb(0_0_0/0.12),0_1px_3px_rgb(0_0_0/0.2)] outline-none focus-visible:outline-2 focus-visible:outline-chrome-accent"})]})})})}const Os=T.forwardRef(function({label:t,icon:n,shortcut:s,active:o,size:r,noTooltip:i,reason:l,disabled:u,onClick:d,className:f,type:h="button",...g},y){const b=!!(u&&l),v=p.jsx("button",{ref:y,type:h,"aria-label":t,"aria-pressed":o===void 0?void 0:o,disabled:b?void 0:u,"aria-disabled":b?!0:void 0,onClick:b?w=>w.preventDefault():d,className:Ie("inline-flex size-6 shrink-0 items-center justify-center rounded-[6px] text-chrome-secondary outline-none transition-colors hover:bg-chrome-hover hover:text-chrome-fg focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-chrome-accent disabled:pointer-events-none disabled:opacity-35 aria-disabled:cursor-default aria-disabled:opacity-35 aria-disabled:hover:bg-transparent [&>svg]:size-4",o&&"bg-chrome-selected text-chrome-fg hover:bg-chrome-selected",f),...g,children:n});return i?v:p.jsx(Rn,{label:b?l:t,shortcut:b?void 0:s,side:"top",children:v})}),dme=["top","right","bottom","left"],fme=["top-left","top-right","bottom-right","bottom-left"],hme=["Top","Right","Bottom","Left"],pme=["Top left","Top right","Bottom right","Bottom left"],mme={sides:[0,1,2,3],corners:[0,1,3,2]},gme="The values differ — make them equal to use one field";function LC({label:e,kind:t,values:n,unit:s,min:o,max:r,step:i,placeholder:l="0",onCommit:u,toggleDisabledReason:d,onReset:f,disabled:h,title:g}){const y=n!==null&&n.some(j=>j!==n[0]),[b,v]=T.useState(y);T.useEffect(()=>{y&&v(!0)},[y]);const w=t==="sides"?"Per side":"Per corner",S=e.toLowerCase(),C=d??(b&&y?gme:void 0),k=t==="sides"?hme:pme,M=n===null||y?null:n[0];return p.jsxs(p.Fragment,{children:[p.jsxs(Be,{label:e,tip:g,onReset:f,children:[p.jsx(St,{"aria-label":e,value:M,placeholder:n===null?"Mixed":y?w:l,unit:s,min:o,max:r,step:i,disabled:h,onCommit:j=>j!==null&&u([j,j,j,j])}),p.jsx(Os,{label:`${b?"Hide":"Edit"} ${S} per ${t==="sides"?"side":"corner"}`,icon:t==="sides"?p.jsx(Xpe,{}):p.jsx(Zpe,{}),active:b,disabled:h||C!==void 0,reason:C,onClick:()=>v(!b)})]}),b&&d===void 0?p.jsx("div",{className:"grid grid-cols-2 gap-2 py-px pl-[96px] pr-[42px]",children:mme[t].map(j=>p.jsx(St,{"aria-label":`${e} ${k[j].toLowerCase()}`,title:k[j],label:t==="sides"?p.jsx(Jpe,{side:dme[j]}):p.jsx(tme,{corner:fme[j]}),value:n===null?null:n[j],placeholder:n===null?"Mixed":l,unit:s,min:o,max:r,step:i,steppers:!1,disabled:h,onCommit:O=>{const $=n?[...n]:[0,0,0,0];$[j]=O??0,u($)}},j))}):null]})}function DC({title:e,text:t,swatch:n,children:s,disabled:o,open:r,onOpenChange:i}){const[l,u]=T.useState(!1),d=r??l,f=h=>{u(h),i?.(h)};return p.jsxs(Sy,{open:d,onOpenChange:f,children:[p.jsxs(ky,{disabled:o,"aria-label":`${e}: ${t}`,className:Ie(hd,"flex w-full min-w-0 cursor-default items-center gap-1.5 pr-2 text-left disabled:opacity-50 data-[popup-open]:shadow-[inset_0_0_0_1px_var(--color-chrome-accent)]",n!==void 0?"pl-1":"pl-2"),children:[n!==void 0?p.jsx("span",{className:"size-4 shrink-0 rounded-[4px] shadow-[inset_0_0_0_1px_rgb(0_0_0/0.1)]",style:{background:n?`linear-gradient(${n}, ${n}), ${D5}`:D5}}):null,p.jsx("span",{className:"min-w-0 flex-1 truncate tabular-nums",children:t})]}),p.jsx(Ey,{children:p.jsx(Cy,{side:"left",align:"start",sideOffset:8,collisionPadding:8,className:"z-[1000]",children:p.jsxs(Ty,{className:"w-64 rounded-[14px] bg-chrome pb-2 text-chrome-fg shadow-chrome-popup outline-none origin-[var(--transform-origin)] transition-[opacity,transform] duration-100 data-[ending-style]:opacity-0 data-[starting-style]:scale-95 data-[starting-style]:opacity-0",children:[p.jsxs("div",{className:"flex h-11 items-center gap-2 pl-4 pr-2",children:[p.jsx(FY,{className:"min-w-0 flex-1 truncate text-[13px] font-[520]",children:e}),p.jsx(UY,{"aria-label":"Close",title:"Close",className:"flex size-7 shrink-0 items-center justify-center rounded-[8px] text-chrome-secondary outline-none hover:bg-chrome-hover hover:text-chrome-fg focus-visible:outline-2 focus-visible:outline-chrome-accent",children:p.jsx(_i,{className:"size-4",strokeWidth:1.5})})]}),p.jsx("div",{className:"flex flex-col",children:s})]})})})]})}const D5="repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0 / 8px 8px",Pl=T.forwardRef(function({variant:t="secondary",size:n,icon:s,className:o,children:r,type:i="button",...l},u){return p.jsxs("button",{ref:u,type:i,className:Ie("inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-[8px] px-2.5 text-[13px] font-control outline-none transition-colors focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-chrome-accent disabled:pointer-events-none disabled:opacity-40 [&>svg]:size-3.5",t==="primary"&&"bg-chrome-accent text-white hover:brightness-110",t==="secondary"&&"text-chrome-fg shadow-[inset_0_0_0_1px_var(--chrome-field-ring-strong)] hover:bg-chrome-hover",t==="ghost"&&"text-chrome-fg hover:bg-chrome-hover",t==="danger"&&"text-danger hover:bg-danger/10",o),...l,children:[s,r]})}),QB=12,yme=.2,bme=/#[0-9a-f]{3,8}\b|rgba?\([^)]*\)|hsla?\([^)]*\)/gi;function JB(e,t){if(e)for(const n of e.matchAll(bme)){const s=qn(n[0]);if(!s||s.a<yme)continue;const o=lb(n[0]);t.set(o,(t.get(o)??0)+1)}}function jg(e,t){for(const n of Object.values(e))JB(n,t)}function gf(e,t){for(const n of e)JB(n.marks?.color,t)}function xme(e,t){if(jg(e.style,t),e.kind==="text"&&gf(e.runs,t),e.kind==="list")for(const n of e.items)gf(n.runs,t);if(e.kind==="textbox")for(const n of e.blocks)if(n.kind==="text")gf(n.runs,t);else for(const s of n.items)gf(s.runs,t);if(e.kind==="table")for(const n of e.rows){jg(n.style,t);for(const s of n.cells)jg(s.style,t),gf(s.runs,t)}}function z5(e,t){const n=new Map;for(const s of e)jg(s.style,n),sd(s,o=>xme(o,n));return[...n.entries()].filter(([s])=>!t.has(s)).sort((s,o)=>o[1]-s[1]).slice(0,QB).map(([s])=>({label:s,value:s.toLowerCase()}))}function zi(){const e=ae(s=>s.revision),t=se(s=>s.current),n=ac(s=>s.systems);return T.useMemo(()=>{const s=ae.getState().slides;if(n.length===0){const u=z5(Object.values(s).map(d=>d.slide),new Set);return u.length?[{choices:u}]:[]}const o=[],r=new Set(n.flatMap(u=>u.colors.map(d=>lb(d.value)))),i=t?s[t]?.slide:void 0,l=i?z5([i],r):[];l.length&&o.push({title:"In this slide",choices:l});for(const u of n)u.colors.length&&o.push({title:u.title,choices:u.colors.map(d=>({label:d.name,value:d.value}))});return o},[e,t,n])}function vme(e,t){if(!t)return null;for(const n of e)for(const s of n.choices)if(JE(s.value,t))return s;return null}function eH({info:e}){const t=e.ratio>=e.target;return p.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",title:`${e.ratio.toFixed(1)}:1 on ${e.where}`,children:[p.jsx("span",{"aria-hidden":!0,className:"flex size-4 shrink-0 items-center justify-center rounded-[4px] shadow-[inset_0_0_0_1px_rgb(0_0_0/0.12)]",style:{background:e.ground,color:e.text},children:p.jsx(VB,{className:"size-3"})}),p.jsx("span",{className:Ie("truncate text-[12px]",t?"text-chrome-fg":"text-warning"),children:t?"Good contrast":"Poor contrast"})]})}function wme({info:e}){return e?p.jsx("div",{className:"flex h-6 items-center pl-[96px] pr-3",children:p.jsx(eH,{info:e})}):null}const wk="repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0 / 8px 8px",Sme="linear-gradient(135deg, #ffffff 50%, #141413 50%)";function lh(e){const{value:t,mixed:n=!1,effective:s,emptyLabel:o="None",groups:r,preview:i,disabled:l,title:u}=e,[d,f]=T.useState(!1),h=t?qn(t):null,g=vme(r,t),y=n?"Mixed":i?i.label:t===null?o:g?.label??lb(t),b=t??s??null,v=n?Sme:i?i.swatch:b?`linear-gradient(${b}, ${b}), ${wk}`:wk,w=!n&&!i&&h&&h.a<1?`${Math.round(h.a*100)}%`:null;return p.jsxs(Sy,{open:d,onOpenChange:f,children:[p.jsxs(ky,{disabled:l,title:u,"aria-label":`${e["aria-label"]}: ${y}`,className:Ie(hd,"flex w-full min-w-0 cursor-default items-center gap-1.5 pl-1 pr-2 text-left disabled:opacity-50 data-[popup-open]:shadow-[inset_0_0_0_1px_var(--color-chrome-accent)]"),children:[p.jsx("span",{className:"size-4 shrink-0 rounded-[4px] shadow-[inset_0_0_0_1px_rgb(0_0_0/0.1)]",style:{background:v}}),p.jsx("span",{className:"min-w-0 flex-1 truncate",children:y}),w?p.jsx("span",{className:"shrink-0 text-[12px] tabular-nums text-chrome-muted",children:w}):null]}),p.jsx(Ey,{children:p.jsx(Cy,{side:"bottom",align:"end",sideOffset:4,collisionPadding:8,className:"z-[1000]",children:p.jsx(Ty,{className:"w-64 rounded-[14px] bg-chrome p-4 text-chrome-fg shadow-chrome-popup outline-none origin-[var(--transform-origin)] transition-[opacity,transform] duration-100 data-[ending-style]:opacity-0 data-[starting-style]:scale-95 data-[starting-style]:opacity-0",children:p.jsx(tH,{value:n||i?null:t,fallback:s??null,groups:r,allowNone:e.allowNone,opaque:e.opaque,contrast:e.contrast,kinds:e.kinds,onPick:S=>{e.onCommit(S),S===null&&f(!1)},onClose:()=>f(!1)})})})})]})}function Xh({label:e,onReset:t,...n}){return p.jsxs(p.Fragment,{children:[p.jsx(Be,{label:e,onReset:t,children:p.jsx(lh,{...n})}),!n.mixed&&!n.preview?p.jsx(wme,{info:n.contrast??null}):null]})}function tH({value:e,fallback:t,groups:n,allowNone:s,opaque:o,contrast:r,kinds:i,onPick:l,onClose:u}){const d=n.some(v=>v.choices.length>0)||!!s,f=!i||i.value==="color",[h,g]=T.useState(d&&f?"system":"custom"),y=p.jsx("button",{type:"button","aria-label":"Close",title:"Close",onClick:u,className:"ml-auto flex size-7 shrink-0 items-center justify-center rounded-[8px] text-chrome-secondary outline-none hover:bg-chrome-hover hover:text-chrome-fg focus-visible:outline-2 focus-visible:outline-chrome-accent",children:p.jsx(_i,{className:"size-4",strokeWidth:1.5})}),b=p.jsxs("div",{className:"flex flex-col gap-3",children:[i?p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("span",{className:"w-10 shrink-0 text-[12px] text-chrome-muted",children:"Type"}),p.jsx(As,{"aria-label":"Fill type",value:i.value,options:i.options,onChange:i.onChange})]}):null,f?p.jsx(Tme,{value:e,fallback:t??null,opaque:o,contrast:r??null,onPick:l}):i?.content]});return d?p.jsxs(dZ,{value:h,onValueChange:v=>g(v),className:"flex flex-col gap-3",children:[p.jsxs("div",{className:"-mt-1 flex items-center gap-1",children:[p.jsx(yZ,{"aria-label":"Source",className:"flex items-center gap-1",children:["system","custom"].map(v=>p.jsx(hZ,{value:v,className:"h-7 rounded-[8px] px-2.5 text-[13px] text-chrome-secondary outline-none hover:bg-chrome-hover hover:text-chrome-fg data-[selected]:text-chrome-fg focus-visible:outline-2 focus-visible:outline-chrome-accent data-[selected]:bg-chrome-selected",children:v==="system"?"Theme":"Custom"},v))}),y]}),p.jsx(uO,{value:"system",className:"outline-none",children:p.jsx(kme,{value:e,groups:n,allowNone:s,onPick:l})}),p.jsx(uO,{value:"custom",className:"outline-none",children:b})]}):p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsxs("div",{className:"-mt-1 flex items-center",children:[p.jsx("span",{className:"text-[13px] font-[520]",children:"Color"}),y]}),b]})}function kme({value:e,groups:t,allowNone:n,onPick:s}){const[o,r]=T.useState(""),l=t.reduce((g,y)=>g+y.choices.length,0)>QB||t.some(g=>g.title),u=o.trim().toLowerCase(),d=t.map(g=>({...g,choices:u?g.choices.filter(y=>y.label.toLowerCase().includes(u)||lb(y.value).toLowerCase().includes(u)):g.choices})).filter(g=>g.choices.length>0),f=g=>{const y=[...g.currentTarget.querySelectorAll("button[data-color-row]")],b=y.indexOf(document.activeElement),v=g.key==="ArrowDown"?b+1:g.key==="ArrowUp"?b-1:g.key==="Home"?0:g.key==="End"?y.length-1:null;v!==null&&(g.preventDefault(),y[Math.max(0,Math.min(y.length-1,v))]?.focus())},h=(g,y,b,v,w)=>p.jsxs("button",{type:"button","data-color-row":!0,"aria-pressed":v,onClick:w,className:Ie("flex h-8 w-full items-center gap-2.5 rounded-[8px] px-2 text-left text-[13px] outline-none hover:bg-chrome-hover focus-visible:bg-chrome-hover",v&&"bg-chrome-hover"),children:[b,p.jsx("span",{className:"min-w-0 flex-1 truncate",children:y}),v?p.jsx(Ni,{className:"size-4 shrink-0 text-chrome-accent",strokeWidth:2.25}):null]},g);return p.jsxs("div",{className:"-mx-2 flex flex-col gap-1",children:[l?p.jsx("div",{className:"px-2 pb-1",children:p.jsx(Eb,{"aria-label":"Search colors",placeholder:"Search colors",value:o,onChange:g=>r(g.target.value)})}):null,p.jsxs("div",{className:"max-h-72 overflow-y-auto",onKeyDown:f,children:[n&&!u?h("none","None",p.jsx("span",{className:"size-4 shrink-0 rounded-[4px] border border-dashed border-chrome-muted"}),e===null,()=>s(null)):null,d.map((g,y)=>p.jsxs("div",{children:[g.title?p.jsx("div",{className:"px-2 pb-1 pt-2 text-[11px] font-[520] text-chrome-muted",children:g.title}):null,g.choices.map(b=>h(`${g.title??""}:${b.label}:${b.value}`,b.label,p.jsx("span",{className:"size-4 shrink-0 rounded-[4px] shadow-[inset_0_0_0_1px_rgb(0_0_0/0.12)]",style:{background:b.value}}),JE(b.value,e),()=>s(b.value)))]},g.title??y)),u&&d.length===0?p.jsx("p",{className:"px-2 py-2 text-[12px] text-chrome-muted",children:"No matches"}):null]})]})}const Eme={r:0,g:0,b:0,a:1};function Cme(e){const t=T.useRef(null),n=T.useRef(null),s=T.useRef(e);return s.current=e,T.useEffect(()=>()=>{n.current!==null&&cancelAnimationFrame(n.current)},[]),o=>{t.current={value:o},n.current===null&&(n.current=requestAnimationFrame(()=>{n.current=null,t.current&&s.current(t.current.value)}))}}function Tme({value:e,fallback:t,opaque:n,contrast:s,onPick:o}){const[r,i]=T.useState(()=>Vm(qn(e??t??"")??Eme)),l=Cme(o);T.useEffect(()=>{const y=e?qn(e):null;y&&!JE(Ol(Sg(r)),e)&&i(Vm(y,r.h))},[e]);const u=y=>{const b=n?{...y,a:1}:y;i(b),l(Ol(Sg(b)))},d=Sg({...r,a:1}),f=Ol(d),h=f.toUpperCase(),g=typeof window<"u"&&"EyeDropper"in window;return p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx(Mme,{hsva:r,onChange:u}),p.jsx(P5,{label:"Hue",value:r.h/360,background:"linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00)",thumb:`hsl(${r.h} 100% 50%)`,valueText:`${Math.round(r.h)}°`,onChange:y=>u({...r,h:y*360})}),n?null:p.jsx(P5,{label:"Opacity",value:r.a,background:`linear-gradient(to right, transparent, ${f}), ${wk}`,thumb:Ol({...d,a:r.a}),valueText:`${Math.round(r.a*100)}%`,onChange:y=>u({...r,a:Math.round(y*100)/100})}),p.jsxs("div",{className:"flex items-center gap-1.5",children:[g?p.jsx("button",{type:"button","aria-label":"Pick color from screen",title:"Pick color from screen",className:"flex size-6 shrink-0 items-center justify-center rounded-[6px] text-chrome-secondary outline-none hover:bg-chrome-hover hover:text-chrome-fg focus-visible:outline-2 focus-visible:outline-chrome-accent",onClick:()=>{const y=window.EyeDropper;new y().open().then(b=>{const v=qn(b.sRGBHex);v&&u(Vm({...v,a:r.a},r.h))}).catch(()=>{})},children:p.jsx(GW,{className:"size-4",strokeWidth:1.5})}):null,p.jsx(_C,{"aria-label":"Hex color",value:h,className:"min-w-0 flex-1 font-mono text-[12px] uppercase",onCommit:y=>{const b=y.trim(),v=qn(/^[0-9a-f]{3,8}$/i.test(b)?`#${b}`:b);v&&u(Vm({...v,a:n?1:v.a<1?v.a:r.a},r.h))}}),n?null:p.jsx(St,{"aria-label":"Opacity percent",className:"w-[64px] shrink-0",value:Math.round(r.a*100),unit:"%",min:0,max:100,steppers:!1,onCommit:y=>y!==null&&u({...r,a:Math.max(0,Math.min(100,y))/100})})]}),s?p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsx(eH,{info:s}),s.ratio<s.target&&s.fix?p.jsx(Pl,{size:"sm",className:"self-start",onClick:()=>s.fix&&o(s.fix),children:"Use a readable shade"}):null]}):null]})}function nH(e,t){const n=t.getBoundingClientRect();return{x:Math.max(0,Math.min(1,(e.clientX-n.left)/Math.max(1,n.width))),y:Math.max(0,Math.min(1,(e.clientY-n.top)/Math.max(1,n.height)))}}function sH(e){return e.shiftKey?.1:.01}function Mme({hsva:e,onChange:t}){const n=o=>{const{x:r,y:i}=nH(o,o.currentTarget);t({...e,s:r,v:1-i})},s=o=>{const r=sH(o),i=o.key==="ArrowLeft"?{s:e.s-r}:o.key==="ArrowRight"?{s:e.s+r}:o.key==="ArrowUp"?{v:e.v+r}:o.key==="ArrowDown"?{v:e.v-r}:null;i&&(o.preventDefault(),t({...e,s:Math.max(0,Math.min(1,i.s??e.s)),v:Math.max(0,Math.min(1,i.v??e.v))}))};return p.jsx("div",{role:"slider",tabIndex:0,"aria-label":"Saturation and brightness","aria-valuetext":`Saturation ${Math.round(e.s*100)}%, brightness ${Math.round(e.v*100)}%`,className:"relative aspect-[3/2] w-full cursor-crosshair touch-none rounded-[8px] outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-chrome-accent",style:{background:`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent), hsl(${e.h} 100% 50%)`},onPointerDown:o=>{o.currentTarget.setPointerCapture(o.pointerId),n(o)},onPointerMove:o=>{o.currentTarget.hasPointerCapture(o.pointerId)&&n(o)},onKeyDown:s,children:p.jsx("span",{className:"pointer-events-none absolute size-3.5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-[0_0_0_1px_rgb(0_0_0/0.25),0_1px_3px_rgb(0_0_0/0.3)]",style:{left:`${e.s*100}%`,top:`${(1-e.v)*100}%`,background:Ol(Sg({...e,a:1}))}})})}function P5({label:e,value:t,background:n,thumb:s,valueText:o,onChange:r}){const i=u=>r(nH(u,u.currentTarget).x),l=u=>{const d=sH(u),f=u.key==="ArrowLeft"||u.key==="ArrowDown"?t-d:u.key==="ArrowRight"||u.key==="ArrowUp"?t+d:u.key==="PageDown"?t-.1:u.key==="PageUp"?t+.1:u.key==="Home"?0:u.key==="End"?1:null;f!==null&&(u.preventDefault(),r(Math.max(0,Math.min(1,f))))};return p.jsx("div",{role:"slider",tabIndex:0,"aria-label":e,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(t*100),"aria-valuetext":o,className:"relative h-3 w-full cursor-pointer touch-none rounded-full shadow-[inset_0_0_0_1px_rgb(0_0_0/0.08)] outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-chrome-accent",style:{background:n,backgroundSize:n.includes("conic")?"auto, 8px 8px":void 0},onPointerDown:u=>{u.currentTarget.setPointerCapture(u.pointerId),i(u)},onPointerMove:u=>{u.currentTarget.hasPointerCapture(u.pointerId)&&i(u)},onKeyDown:l,children:p.jsx("span",{className:"pointer-events-none absolute top-1/2 size-3.5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-[0_0_0_1px_rgb(0_0_0/0.25),0_1px_3px_rgb(0_0_0/0.3)]",style:{left:`${t*100}%`,background:s}})})}function Rme(e){if(!e)return"section";switch(e.kind){case"text":return"text";case"list":return"list";case"textbox":return"textbox";case"box":return"div";case"image":return"img";case"table":return"table";case"svg":return"svg";case"shape":return"shape";case"icon":return"icon";case"connector":return"connector";case"embed":return"embed";case"rule":return"hr"}}function jme(e,t,n){const s=t.length?Ye(e,t)??null:null,o=s?s.style:e.style,r=t.length>1?Uy(e,t)?.style:e.style,i=s?Kt(s):!1,l=o.display==="grid"?"grid":o.display==="none"?"none":"flex";return{element:Rme(s),...s?.kind==="shape"?{shape:s.shape}:{},pinned:i,flowChild:!!s&&!i,gridChild:!!s&&!i&&r?.display==="grid",display:l,direction:o["flex-direction"]??"column",faces:n}}function oH(e,t,n,s,o){const r=s.trim();if(r==="")return{ok:!0,patch:{[n]:void 0}};const i=Jf(n,r,jme(e,t,o));if(!i.ok)return{ok:!1,reason:i.noop?`${n} has no effect here`:i.reason};const l={};for(const[u,d]of i.set)l[u]=d;return n==="border"&&(l["border-top"]=void 0,l["border-right"]=void 0,l["border-bottom"]=void 0,l["border-left"]=void 0),{ok:!0,patch:l,...i.warning||i.note?{note:i.warning??i.note}:{}}}function Ht(e,t){const n=e.nodes.length?e.nodes.map(o=>o.style[t]):[e.slide.style[t]],s=n[0];return{value:s,mixed:n.some(o=>o!==s)}}function qu(e){if(e==="0")return 0;const t=e?/^(-?[\d.]+)px$/.exec(e):null;return t?Number(t[1]):null}function Ame(){const e=ae(t=>t.index.faces);return T.useMemo(()=>new Set(Object.values(e).map(t=>t.family.toLowerCase())),[e])}function Ome(){return new Set(ai(ae.getState().index).map(e=>e.toLowerCase()))}function ht(e,t,n,s=t,o){const r=Ome(),i=[];for(const l of e.paths){const u=oH(e.slide,l,t,n,r);if(!u.ok)return tt.add({title:`Can't set ${t}`,description:u.reason}),!1;u.note&&tt.add({title:u.note}),i.push([l,u.patch])}return rH(s,i,o)}function yo(e,t,n,s){return rH(t,e.paths.map(o=>[o,typeof n=="function"?n(o.length?Ye(e.slide,o)??null:null):n]),s)}function rH(e,t,n){return jn(e,s=>{let o=s;for(const[r,i]of t)r.length&&!Ye(o,r)||(o=Na(o,r,i));return o},n?{coalesce:n}:{})}const iH=`A presentation carries up to ${ve.faces} typefaces, and every one is in use`;function Nme(){const e=new Set,t=n=>{for(const s of Ha(n??""))e.add(s.toLowerCase())};for(const n of Object.values(ae.getState().slides))t(n.slide.style["font-family"]),sd(n.slide,s=>t(s.style["font-family"]));return e}function aH(e,t){const n=Object.entries(e);if(n.some(([,o])=>o.family.toLowerCase()===t.family.toLowerCase()))return e;let s=n;if(s.length>=ve.faces){const o=Nme();if(s=n.filter(([,r])=>o.has(r.family.toLowerCase())),s.length>=ve.faces)return null}return{...Object.fromEntries(s),[OI(t.family)]:t}}function $me(){return aH(ae.getState().index.faces,{family:"\0"})!==null}function I5(e,t,n){const s=ae.getState(),o=n?aH(s.index.faces,n):s.index.faces;if(!o)return tt.add({title:`Can't add ${n.family}`,description:iH}),!1;if(o===s.index.faces)return ht(e,"font-family",t,"Font");const r=se.getState().current,i=Ar(r);if(!r||!i)return!1;const l=new Set(Object.values(o).map(d=>d.family.toLowerCase()));let u=i.slide;for(const d of e.paths){const f=oH(u,d,"font-family",t,l);if(!f.ok)return tt.add({title:"Can't set font-family",description:f.reason}),!1;d.length&&!Ye(u,d)||(u=Na(u,d,f.patch))}return s.apply("Font",{slides:{[r]:u},index:{...s.index,faces:o}},{focus:r}),!0}function zC({target:e,property:t,label:n,placeholder:s,className:o}){const r=Ht(e,t);return p.jsx(_C,{"aria-label":n??t,className:Ie("min-w-0 flex-1 font-mono text-xs",o),value:r.mixed?"":r.value??"",placeholder:r.mixed?"Mixed":s??"—",onCommit:i=>ht(e,t,i,n??t)})}function _me(e){return{fontWeight:e["font-weight"],textTransform:e["text-transform"],fontFamily:e["font-family"],fontStyle:e["font-style"]}}function lH(e){const t=ac(d=>d.systems),n=Ame(),s=T.useMemo(()=>{const d=$S.map(h=>{const g=a0[h];return{value:h,label:qte[h],hint:String(g.fontSize),style:{fontWeight:g.fontWeight,textTransform:g.uppercase?"uppercase":void 0},...t.length?{group:"Built-in"}:{}}});return[...t.flatMap(h=>h.styles.map(g=>({value:g.id,label:`${g.group?`${g.group} / `:""}${g.name}`,hint:g.declarations["font-size"]?.replace(/px$/,""),group:h.title,style:_me(g.declarations)}))),...d]},[t]),r=(e===null?[]:Array.isArray(e)?e:[e]).map(d=>Wte(d.tag,d.style)??Dae(t,d.tag,d.style)?.id??null),i=r.some(d=>d!==r[0]),l=i?null:r[0]??null;return{options:s,value:l,mixed:i,apply:d=>{const f=zae(d);if(f){const g=_ae(f,n);eo("Text style",y=>y.kind==="text"?nN(y,f.tag,g):y);return}if(!$S.includes(d))return;const h=d;eo("Text style",g=>g.kind==="text"?nN(g,a0[h].tag,iu(h)):g)}}}const cH={r:255,g:255,b:255,a:1},Lme={r:0,g:0,b:0,a:1};function Dme(e){if(!e)return null;const t=_h(e);if(!t.ok)return null;if(t.value.gradient||t.value.image)return"unknown";const n=t.value.color?qn(t.value.color):null;return n&&n.a>0?n:null}function uH(e,t,n){const s=[{style:e.style,where:"the slide background"}],o=n?t.length:t.length-1;for(let l=1;l<=o;l++){const u=Ye(e,t.slice(0,l));u&&s.push({style:u.style,where:l===t.length?"its fill":"the group fill"})}let r=cH,i="white";for(const l of s){const u=Dme(l.style.background);if(u==="unknown")return null;u&&(r=Dy(u,r),i=l.where)}return{color:r,where:i}}function PC(e,t){const n=uH(e,t,!0)?.color??cH;let s=Lme;const o=[e.style];for(let r=1;r<=t.length;r++){const i=Ye(e,t.slice(0,r));i&&o.push(i.style)}for(const r of o){const i=r.color?qn(r.color):null;i&&(s=i)}return{text:Dy(s,n),background:n}}function dH(e,t){if(e.nodes.length!==1)return null;const n=e.paths[0],s=e.nodes[0];if(s.style["background-clip"]==="text"||s.kind==="text"&&s.runs.some(g=>g.marks?.color))return null;const o=uH(e.slide,n,s.kind!=="icon");if(!o)return null;const r=t.color?qn(t.color):PC(e.slide,n).text;if(!r)return null;const i=Dy(r,o.color),l=t.size??qu(s.style["font-size"])??0,u=t.weight??Number(s.style["font-weight"]??400),d=l>=32||l>=24&&u>=700,f=t.kind==="icon"||d?3:4.5,h=zy(i,o.color);return{ratio:h,target:f,text:cr(i),ground:cr(o.color),where:o.where,fix:h>=f?null:M8(i,o.color,f)}}const Sk="image/png,image/jpeg,image/gif,image/webp,image/svg+xml",zme="video/mp4,video/quicktime,video/webm,.mov";function Pme(e,t,n,s){jn(t,o=>Bn(o,e,r=>r.kind==="image"?n(r):r),s?{coalesce:s}:{})}function L1(e,t,n){eo(e,s=>s.kind==="image"?t(s):s,n?{coalesce:n}:void 0)}function Ime(e){return!!(e.src||e.video)}function Bme(e){return Pu(Ei(e,null),void 0)}function fH({label:e,text:t,thumb:n,empty:s=!1,reason:o,tip:r,onPress:i,removeLabel:l,onRemove:u}){const d=o!==void 0;return p.jsxs(Be,{label:e,children:[p.jsxs("button",{type:"button","aria-label":s?`${e}: none`:`${e}: ${t}`,title:o??(s?void 0:r),"aria-disabled":d||void 0,onClick:d?void 0:i,className:Ie("flex h-7 min-w-0 flex-1 items-center gap-2 rounded-[6px] bg-chrome-field px-1.5 text-left text-[13px] text-chrome-fg outline-none hover:bg-chrome-hover focus-visible:ring-1 focus-visible:ring-chrome-accent",d&&"cursor-default text-chrome-muted hover:bg-chrome-field",s&&"text-chrome-muted"),children:[!s&&n!==void 0?p.jsx("span",{className:"size-[18px] shrink-0 overflow-hidden rounded-[4px] border border-chrome-sep bg-chrome",children:n?p.jsx("img",{alt:"",src:n,className:"size-full object-cover"}):null}):null,p.jsx("span",{className:"min-w-0 flex-1 truncate",children:t})]}),s?p.jsx(Os,{label:"Upload image…",icon:p.jsx(cY,{className:"size-3.5"}),disabled:d,reason:o,onClick:i}):u?p.jsx(Os,{label:l??"Remove",icon:p.jsx($i,{className:"size-3.5"}),onClick:u}):null]})}function Hme(e){return/^[^\s/\\]+\.(png|jpe?g|gif|webp|svg|mp4|mov|webm)$/i.test(e.trim())}function Fme(e){const t=e.alt?.trim()??"";if(Hme(t))return t;if(e.video?.link)return`${Of[e.video.link.provider]} video`;if(e.video)return"Uploaded video";const n=e.src&&!e.src.startsWith("/_blob/")?e.src.split("/").pop():void 0;if(n)return decodeURIComponent(n);const s=/\.([a-z0-9]+)$/i.exec(e.src??"")?.[1];return s?`${s.toUpperCase()} image`:"Image"}const Ume="A selected SVG image can't be cropped to fill its frame.";function Vme({target:e}){if(e.nodes.length===0||!e.nodes.every(b=>b.kind==="image"))return null;const t=e.nodes,n=t.length===1,s=t[0],o=e.paths[0],r=n?s.video:void 0,i=!t.some(Ime),l=t.some(b=>/\.svg($|\?)/i.test(b.src??"")),u=t.map(b=>b.style["object-fit"]==="contain"?"contain":"cover"),d=u.every(b=>b===u[0])?u[0]:null,f=t.map(b=>b.alt??""),h=f.every(b=>b===f[0]),g=(b,v)=>{dd(b,!1).then(w=>{w[0]&&v(w[0])})},y=()=>{r?.link?Tr.getState().open("videoLink"):g(r?`${zme},${Sk}`:Sk,b=>{y0(o,b)})};return p.jsxs(ss,{title:r?"Video":"Image",children:[p.jsx(fH,{label:r?"Video":"Image",text:n?i?"Add image…":Fme(s):"Mixed",thumb:r||!s.src?void 0:wo(s.src),empty:i,reason:n?void 0:"Select one image to replace it",tip:r?.link?"Change video link":r?"Replace the video…":"Replace the image…",onPress:y,removeLabel:r?"Remove video":"Remove image",onRemove:()=>L1(r?"Remove video":"Remove image",Bme)}),r?p.jsx(qme,{node:s,path:o,video:r}):null,r?.link&&!s.src?null:p.jsx(Be,{label:"Fit",children:p.jsx(As,{"aria-label":"Image fit",value:d,options:[{value:"cover",label:"Cover",...l?{disabled:!0,reason:Ume}:{}},{value:"contain",label:"Contain"}],onChange:b=>L1("Image fit",v=>b==="cover"&&/\.svg($|\?)/i.test(v.src??"")?v:Mte(b==="contain"?od(v,void 0):v,b))})}),r?p.jsx(Gme,{path:o,video:r}):null,p.jsx(Be,{label:"Alt text",children:p.jsx(Eb,{"aria-label":"Alt text",className:"min-w-0 flex-1",maxLength:ve.alt,value:h?f[0]:"",placeholder:h?"":"Mixed",onChange:b=>{const v=b.target.value;L1("Alt text",w=>Pu(w,w.src,v),"alt-text")}})})]})}function qme({node:e,path:t,video:n}){const s=n.still==="custom",o=s?"Custom cover image":e.src?n.link?`${Of[n.link.provider]} thumbnail`:"Video frame":"None";return p.jsx(fH,{label:"Cover image",text:o,thumb:e.src?wo(e.src):"",tip:"Set cover image",onPress:()=>{dd(Sk,!1).then(r=>{r[0]&&dre(t,r[0])})},removeLabel:"Reset cover image",onRemove:s?()=>{n.link?hre(t):fre(t)}:void 0})}function Gme({path:e,video:t}){const n=(o,r,i)=>Pme(e,o,l=>Ei(l,r),i),s=!!t.startOnClick;return p.jsxs(p.Fragment,{children:[p.jsx(Be,{label:"Autoplay",tip:"Automatically starts the video when it appears in a presentation.",children:p.jsx(_1,{"aria-label":"Autoplay",checked:!s,onChange:o=>n("Video autoplay",o?{startOnClick:void 0}:{startOnClick:!0,delay:void 0})})}),p.jsx(Be,{label:"Delay",children:p.jsx(St,{"aria-label":"Delay",value:s?null:t.delay??0,unit:"s",min:0,max:60,step:.5,disabled:s,title:s?"A video that starts on a click has no delay.":"Seconds to wait after the slide appears before the video starts.",onCommit:o=>n("Video delay",{delay:o?Math.min(60,o):void 0},"video-delay")})}),t.src?p.jsxs(p.Fragment,{children:[p.jsx(Be,{label:"Loop",children:p.jsx(_1,{"aria-label":"Loop",checked:t.loop!==!1,onChange:o=>n("Video loop",{loop:o?void 0:!1})})}),p.jsx(Be,{label:"Sound",children:p.jsx(_1,{"aria-label":"Sound",checked:!!t.sound,onChange:o=>n("Video sound",{sound:o||void 0})})})]}):null,t.link&&XP(t.link.provider)?p.jsx(Be,{label:"Start at",tip:"Seconds into the video where it starts playing.",children:p.jsx(St,{"aria-label":"Start at",value:t.link.start??0,unit:"s",min:0,max:86400,onCommit:o=>n("Video start time",{link:{...t.link,start:o?Math.round(o):void 0}})})}):null]})}function uu(e,t,n){jn(t,s=>Bn(s,e,o=>o.kind==="table"?n(o):o))}function Wme(e,t,n){return{...e,rows:e.rows.map((s,o)=>o===0?{...s,cells:s.cells.map((r,i)=>{if(i!==t)return r;const l={...r.style};return n===null?delete l.width:l.width=`${n}%`,{...r,style:l}})}:s)}}function Yme({target:e}){const t=e.nodes.length===1&&e.nodes[0].kind==="table"?e.nodes[0]:null;if(!t)return null;const n=e.paths[0],s=t.rows.length,o=po(t),r=Array.from({length:o},(i,l)=>{const u=t.rows[0]?.cells[l]?.style.width,d=u?/^([\d.]+)%$/.exec(u):null;return{value:d?Number(d[1]):null,placeholder:u&&!d?u:"auto"}});return p.jsxs(ss,{title:"Table",children:[p.jsx(Be,{label:"Columns",children:p.jsx(St,{"aria-label":"Columns",value:o,min:1,max:ve.tableColumns,onCommit:i=>i&&i!==o&&uu(n,"Table columns",l=>o0(l,s,i))})}),p.jsx(Be,{label:"Rows",children:p.jsx(St,{"aria-label":"Rows",value:s,min:1,max:ve.tableRows,onCommit:i=>i&&i!==s&&uu(n,"Table rows",l=>o0(l,i,o))})}),p.jsxs("div",{className:"flex flex-col gap-1 py-1 pl-4 pr-3",children:[p.jsx("div",{className:"text-[12px] text-chrome-muted",children:"Column widths"}),p.jsx("div",{className:"grid grid-cols-2 gap-2",children:r.map((i,l)=>p.jsx(St,{"aria-label":`Column ${l+1} width`,label:`Col ${l+1}`,value:i.value,placeholder:i.placeholder,min:1,max:100,steppers:!1,className:"[&_input]:placeholder:text-chrome-fg",onCommit:u=>uu(n,"Column width",d=>Wme(d,l,u))},l))})]}),p.jsx(Be,{label:"Header row",children:p.jsx(cme,{"aria-label":"Header row",checked:Cte(t),onChange:i=>uu(n,i?"Add header row":"Remove header row",l=>Ete(l,i))})})]})}function Kme({target:e}){return e.nodes.length!==1||e.nodes[0].kind!=="embed"?null:p.jsx(ss,{title:"Embed",children:p.jsx(di,{children:"This embed’s content is written by the agent — ask the agent in chat to change it."})})}const Xme={tl:{label:"Down-right",Icon:rW},tr:{label:"Down-left",Icon:oW},bl:{label:"Up-right",Icon:cW},br:{label:"Up-left",Icon:lW}},B5=[{value:"none",label:"None"},{value:"open",label:"Open"},{value:"filled",label:"Filled"}],Zme=[{value:"straight",label:"Straight"},{value:"elbow",label:"Elbow"},{value:"hv",label:"Bend: across, then down"},{value:"vh",label:"Bend: down, then across"}];function sg(e,t,n){const s=e.map(o=>o[t]??n);return s.every(o=>o===s[0])?s[0]:null}function D1(e,t){eo(e,n=>n.kind==="connector"?{...n,...t}:n)}function Qme({target:e}){const t=zi();if(e.nodes.length===0||!e.nodes.every(d=>d.kind==="connector"))return null;const n=e.nodes,s=n.every(d=>!d.points),o=Ht(e,"border-style"),r=Ht(e,"border-width"),i=Ht(e,"color"),l=o.mixed?null:o.value==="dashed"?"dashed":"solid",u=d=>{ht(e,"border-style",d==="dashed"?"dashed":"","Line style")};return p.jsxs(p.Fragment,{children:[p.jsxs(ss,{title:"Connector",children:[s?p.jsx(Be,{label:"Direction",children:p.jsx(As,{"aria-label":"Direction",value:sg(n,"from","tl"),options:GP.map(d=>{const{label:f,Icon:h}=Xme[d];return{value:d,title:f,label:p.jsx(h,{className:"size-4",strokeWidth:1.5})}}),onChange:d=>eo("Connector direction",f=>{if(f.kind!=="connector")return f;const{from:h,...g}=f;return d==="tl"?g:{...g,from:d}})})}):null,p.jsx(Be,{label:"Start",children:p.jsx(As,{"aria-label":"Start",value:sg(n,"headStart","none"),options:B5,onChange:d=>D1("Arrowhead",{headStart:d})})}),p.jsx(Be,{label:"End",children:p.jsx(As,{"aria-label":"End",value:sg(n,"headEnd","none"),options:B5,onChange:d=>D1("Arrowhead",{headEnd:d})})}),p.jsx(Be,{label:"Route",children:p.jsx(Ss,{"aria-label":"Route",value:sg(n,"route","straight"),placeholder:"Mixed",options:Zme,onChange:d=>D1("Connector route",{route:d})})}),p.jsx(Be,{label:"Style",children:p.jsx(As,{"aria-label":"Style",value:l,options:[{value:"solid",label:"Solid"},{value:"dashed",label:"Dashed"}],onChange:u})})]}),p.jsxs(ss,{title:"Appearance",children:[p.jsx(Be,{label:"Line",children:p.jsx(As,{"aria-label":"Line",value:l,options:[{value:"none",title:"None",label:p.jsx(dL,{className:"size-3.5",strokeWidth:1.5}),disabled:!0,reason:"A line always draws"},{value:"solid",title:"Solid",label:p.jsx(qB,{})},{value:"dashed",title:"Dashed",label:p.jsx(GB,{})},{value:"dotted",title:"Dotted",label:p.jsx(WB,{}),disabled:!0,reason:"A line is solid or dashed"}],onChange:u})}),p.jsx(Xh,{label:"Color","aria-label":"Line color",value:i.mixed?null:i.value??null,mixed:i.mixed,effective:cr(PC(e.slide,e.paths[0]).text),emptyLabel:"Theme default",groups:t,onReset:i.value?()=>ht(e,"color","","Line color"):void 0,onCommit:d=>ht(e,"color",d??"","Line color","line-color")}),p.jsx(Be,{label:"Width",children:p.jsx(St,{"aria-label":"Line width",value:r.mixed?null:Number.parseFloat(r.value??"")||null,placeholder:r.mixed?"Mixed":"2",unit:"px",min:1,max:32,onCommit:d=>ht(e,"border-width",d?`${d}px`:"","Line width","line-width")})})]})]})}function Jme({target:e}){const t=zi(),n=l=>l.kind==="rule"||l.kind==="shape"&&l.shape==="line";if(e.nodes.length===0||!e.nodes.every(n))return null;const s=Ht(e,"border"),o=s.value&&!s.mixed?Nf(s.value,32):null,r=o?.ok?o.value:{width:2,style:"solid",color:"#141413"},i=(l,u)=>{ht(e,"border",$f({...r,...l,style:"solid"}),u,"line")};return p.jsxs(ss,{title:"Line",children:[p.jsx(Be,{label:"Thickness",children:p.jsx(St,{"aria-label":"Thickness",value:s.mixed?null:r.width,placeholder:"Mixed",unit:"px",min:1,max:32,onCommit:l=>i({width:l??2},"Line thickness")})}),p.jsx(Xh,{label:"Color","aria-label":"Line color",value:s.mixed?null:r.color,mixed:s.mixed,groups:t,onCommit:l=>l&&i({color:l},"Line color")})]})}function ege(e){const t=e.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase();return t[0].toUpperCase()+t.slice(1)}function tge({target:e}){const t=zi();if(e.nodes.length===0||!e.nodes.every(l=>l.kind==="icon"))return null;const n=e.nodes.map(l=>l.kind==="icon"?l.name:null),s=n.every(l=>l===n[0])?n[0]:null,o=Ht(e,"color"),r=o.mixed?null:o.value??null,i=cr(PC(e.slide,e.paths[0]).text);return p.jsxs(ss,{title:"Icon",children:[p.jsx(Be,{label:"Glyph",children:p.jsx(Ss,{"aria-label":"Glyph",value:s,placeholder:"Mixed",options:WP.map(l=>{const u=u8[l];return{value:l,label:ege(l),icon:p.jsx(u,{size:14,strokeWidth:1.75})}}),onChange:l=>eo("Icon",u=>u.kind==="icon"?{...u,name:l}:u)})}),p.jsx(Xh,{label:"Color","aria-label":"Icon color",value:r,mixed:o.mixed,effective:i,emptyLabel:"Theme default",groups:t,contrast:o.mixed?null:dH(e,{kind:"icon",color:r??i}),onReset:r?()=>ht(e,"color","","Icon color"):void 0,onCommit:l=>ht(e,"color",l??"","Icon color","icon-color")})]})}const nge=40,sge=36,H5=16,nr={className:"size-4",strokeWidth:1.75},F5=[["left","Align left",B2],["center","Center",ez],["right","Align right",nz],["justify","Justify",oz]],oge=[[["left","Align left",Wg],["center","Align horizontal centers",P3],["right","Align right",F3]],[["top","Align top",Y3],["middle","Align vertical centers",D3],["bottom","Align bottom",B3]]];function rge(e){return Ba(e)||e.kind==="table"}function IC(){return!!Dr()&&!Dpe()}function Tu(){setTimeout(()=>{Dr()&&FB()},0)}function ige(e){const t=e.target;Dr()&&!t.closest("input, textarea, [contenteditable]")&&e.preventDefault()}function age(){const[,e]=T.useState(0);T.useEffect(()=>{const t=()=>e(n=>n+1);return document.addEventListener("selectionchange",t),()=>document.removeEventListener("selectionchange",t)},[])}function lge(e,t){return e===t?!0:!e||!t?!1:e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom&&e.band.left===t.band.left&&e.band.right===t.band.right&&e.band.top===t.band.top&&e.band.bottom===t.band.bottom}function cge(e){const t=document.querySelector("[data-open-artifact-stage]");if(!t)return null;const n=Dr(),s=n?[n]:e.map(d=>t.querySelector(`[data-open-artifact-path="${d.join(".")}"]`)).filter(d=>d!==null);if(s.length===0)return null;let o=1/0,r=-1/0,i=1/0,l=-1/0;for(const d of s){const f=d.getBoundingClientRect();o=Math.min(o,f.left),r=Math.max(r,f.right),i=Math.min(i,f.top),l=Math.max(l,f.bottom)}const u=t.getBoundingClientRect();return{left:Math.round(o),right:Math.round(r),top:Math.round(i),bottom:Math.round(l),band:{left:Math.round(u.left),right:Math.round(u.right),top:Math.round(u.top+$0+_0),bottom:Math.round(u.bottom-_0-$0)}}}function uge(e){const[t,n]=T.useState(null),s=e?e.map(o=>o.join(".")).join(","):null;return T.useLayoutEffect(()=>{if(!e){n(null);return}let o=0;const r=()=>{const i=cge(e);n(l=>lge(l,i)?l:i),o=requestAnimationFrame(r)};return r(),()=>cancelAnimationFrame(o)},[s]),t}function dge(){const e=window.getSelection();if(!Dr()||!e?.rangeCount)return null;const t=e.getRangeAt(0).getClientRects(),n=t.length?t[t.length-1]:e.getRangeAt(0).getBoundingClientRect();return n.height?{top:n.top,bottom:n.bottom}:null}function fge(){const{slide:e,paths:t,nodes:n,readOnly:s}=yb(),o=se(k=>k.textEdit),r=se(k=>k.tool),i=se(k=>k.cropping),l=gt(k=>!!(k.move||k.draft||k.marquee||k.draw)),u=se(k=>k.showProperties),d=!s&&hn()&&!u&&n.length>0&&n.every(rge)&&r==="select"&&!i&&!l,f=uge(d?t:null),h=T.useRef(null),[g,y]=T.useState(0);if(T.useLayoutEffect(()=>{h.current&&y(h.current.offsetWidth)}),!d||!f||!e)return null;const{band:b}=f;if(f.bottom<b.top||f.top>b.bottom)return null;const v=Ape(f.left,g,b.left,b.right),w=(f.left+f.right)/2,S=!o&&n.length===1&&w>=v-H5&&w<=v+g+H5?sge:0,{top:C}=jpe({selTop:f.top-S,selBottom:f.bottom,menuH:nge,bandTop:b.top,bandBottom:b.bottom,caret:dge});return p.jsx("div",{ref:h,"data-open-artifact-format-bar":!0,className:"pointer-events-none fixed z-30 flex",style:{left:v,top:C,maxWidth:b.right-b.left-16},children:n.length===1&&n[0].kind==="table"&&!o?p.jsx(gge,{table:n[0],path:t[0],commentAnchor:()=>Hu(e,t[0])}):p.jsx(hge,{nodes:n,paths:t,commentAnchor:()=>Hu(e,t.length===1?t[0]:null)})})}function hge({nodes:e,paths:t,commentAnchor:n}){age();const s=se(v=>v.textEdit!==null),o=e.length===1?e[0]:null,r=o?.kind==="text"?o:null,i=lH(r),l=e[0],u=l.style["text-align"]??"left",d=e.every(v=>(v.style["text-align"]??"left")===u),f=F5.find(([v])=>v===u)?.[2]??B2,h=o?.kind==="list"?o.tag:null,g=v=>{IC()?N0(v==="b"?"bold":v==="i"?"italic":"underline"):eo(v==="b"?"Bold":v==="i"?"Italic":"Underline",w=>xte(w,v))},y=v=>s&&Dr()?zpe(v==="b"?"bold":v==="i"?"italic":"underline"):e.every(w=>EI(w,v)),b=v=>{eo("List",w=>w.kind==="text"||w.kind==="list"?CI(w,v):w),Tu()};return p.jsxs(Lr,{role:"toolbar","aria-label":"Text format",className:"h-10 min-w-0 gap-0.5 overflow-x-auto px-1 [scrollbar-width:none]",onMouseDown:ige,children:[r?p.jsxs(p.Fragment,{children:[p.jsx(Js,{tip:{label:"Text style"},trigger:p.jsxs(Pt,{"aria-label":"Text style",className:"max-w-[148px] gap-0.5 pl-2 pr-1",children:[p.jsx("span",{className:"min-w-0 truncate",children:i.options.find(v=>v.value===i.value)?.label??"Custom"}),p.jsx(Fo,{className:"size-4 shrink-0 text-chrome-muted",strokeWidth:1.5})]}),children:i.options.map(v=>p.jsx(Et,{checked:v.value===i.value,onSelect:()=>{i.apply(v.value),Tu()},children:v.label},v.value))}),p.jsx(Mr,{})]}):null,p.jsx(bge,{value:l.style.color??null}),p.jsx(Rn,{label:"Bold",shortcut:`${nt}B`,children:p.jsx(Pt,{square:!0,"aria-label":"Bold",pressed:y("b"),onClick:()=>g("b"),children:p.jsx(IW,{...nr})})}),p.jsx(Rn,{label:"Italic",shortcut:`${nt}I`,children:p.jsx(Pt,{square:!0,"aria-label":"Italic",pressed:y("i"),onClick:()=>g("i"),children:p.jsx(DW,{...nr})})}),p.jsx(Rn,{label:"Underline",shortcut:`${nt}U`,children:p.jsx(Pt,{square:!0,"aria-label":"Underline",pressed:y("u"),onClick:()=>g("u"),children:p.jsx(fz,{...nr})})}),p.jsx(xge,{node:o}),p.jsx(Mr,{}),p.jsx(Js,{tip:{label:"Alignment"},trigger:p.jsxs(Pt,{"aria-label":"Alignment",className:"gap-0 pl-1.5 pr-0.5",children:[p.jsx(f,{...nr}),p.jsx(Fo,{className:"size-3.5 text-chrome-muted",strokeWidth:1.5})]}),children:F5.map(([v,w,S])=>p.jsx(Et,{checked:d&&u===v,icon:p.jsx(S,{className:"size-4"}),onSelect:()=>{U6("Align",{"text-align":v==="left"?void 0:v}),Tu()},children:w},v))}),e.length>1?p.jsx(yge,{nodes:e}):null,o&&(o.kind==="text"||o.kind==="list")?p.jsxs(Js,{tip:{label:"List"},trigger:p.jsxs(Pt,{"aria-label":"List",pressed:h!==null,className:"gap-0 pl-1.5 pr-0.5",children:[h==="ol"?p.jsx(qA,{...nr}):p.jsx(GA,{...nr}),p.jsx(Fo,{className:"size-3.5 text-chrome-muted",strokeWidth:1.5})]}),children:[p.jsx(Et,{checked:h===null,onSelect:()=>b(null),children:"No list"}),p.jsx(Et,{checked:h==="ul",icon:p.jsx(GA,{className:"size-4"}),onSelect:()=>b("ul"),children:"Bulleted list"}),p.jsx(Et,{checked:h==="ol",icon:p.jsx(qA,{className:"size-4"}),onSelect:()=>b("ol"),children:"Numbered list"})]}):null,p.jsx(Mr,{}),p.jsx(hH,{comment:t.length===1?n:null})]})}function hH({comment:e}){return p.jsxs(p.Fragment,{children:[f0()&&e?p.jsx(Rn,{label:"Comment on this element",children:p.jsx(Pt,{square:!0,"aria-label":"Comment",onClick:()=>Cn.getState().setDraft(e()),children:p.jsx(Rr,{...nr})})}):null,p.jsx(Rn,{label:"Open the Properties panel",shortcut:`${nt}\\`,children:p.jsx(Pt,{square:!0,"aria-label":"Properties",onClick:()=>se.getState().toggle("showProperties",!0),children:p.jsx(P2,{...nr})})})]})}function pge(){return p.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.25,strokeLinecap:"round","aria-hidden":"true",children:p.jsx("path",{d:"M3.865 4H12.135M3.865 8H12.135M3.865 12H12.135"})})}function mge(){return p.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.25,strokeLinecap:"round","aria-hidden":"true",children:p.jsx("path",{d:"M4 3.865V12.135M8 3.865V12.135M12 3.865V12.135"})})}function gge({table:e,path:t,commentAnchor:n}){const s=e.rows.length,o=po(e);return p.jsxs(Lr,{role:"toolbar","aria-label":"Table",className:"h-10 min-w-0 gap-1 overflow-x-auto px-1 [scrollbar-width:none]",children:[p.jsx(St,{"aria-label":"Rows",title:"Rows. Fewer rows drop the bottom rows’ text (undoable)",label:p.jsx(pge,{}),value:s,min:1,max:ve.tableRows,className:"w-[76px] shrink-0",onCommit:r=>r&&r!==s&&uu(t,"Table rows",i=>o0(i,r,po(i)))}),p.jsx(St,{"aria-label":"Columns",title:"Columns. Fewer columns drop the rightmost columns’ text (undoable)",label:p.jsx(mge,{}),value:o,min:1,max:ve.tableColumns,className:"w-[76px] shrink-0",onCommit:r=>r&&r!==o&&uu(t,"Table columns",i=>o0(i,i.rows.length,r))}),p.jsx(Mr,{}),p.jsx(hH,{comment:n})]})}function yge({nodes:e}){const t=ere(e);return t?p.jsx(Rn,{label:`Align items. ${t}`,children:p.jsx(Pt,{square:!0,"aria-label":"Align items",disabled:!0,children:p.jsx(Wg,{...nr})})}):p.jsx(Js,{tip:{label:"Align items"},trigger:p.jsxs(Pt,{"aria-label":"Align items",className:"gap-0 pl-1.5 pr-0.5",children:[p.jsx(Wg,{...nr}),p.jsx(Fo,{className:"size-3.5 text-chrome-muted",strokeWidth:1.5})]}),children:oge.map((n,s)=>[s>0?p.jsx(Da,{},`sep${s}`):null,...n.map(([o,r,i])=>p.jsx(Et,{icon:p.jsx(i,{className:"size-4"}),shortcut:`${IP}${p0[o]}`,onSelect:()=>IE(o),children:r},o))])})}function bge({value:e}){const t=zi(),[n,s]=T.useState(!1);return p.jsx(Az,{open:n,side:"bottom",align:"start",onOpenChange:o=>{s(o),o||Tu()},trigger:p.jsxs(Pt,{square:!0,"aria-label":"Text color",title:"Text color",className:"flex-col gap-0",children:[p.jsx("span",{className:"text-[14px] font-semibold leading-none",children:"A"}),p.jsx("span",{className:"mt-0.5 h-[3px] w-4 rounded-full shadow-[inset_0_0_0_1px_rgb(0_0_0/0.12)]",style:{background:e??"currentColor"}})]}),children:p.jsx("div",{"data-open-artifact-format-bar":!0,className:"w-60",children:p.jsx(tH,{value:e,groups:t,onClose:()=>{s(!1),Tu()},onPick:o=>{o&&(IC()?(N0("foreColor",o),s(!1)):U6("Text color",{color:o},{coalesce:"text-color"}))}})})})}function xge({node:e}){const[t,n]=T.useState(!1),s=e?vte(e):void 0,[o,r]=T.useState(s??""),i=e0(o.trim()),l=()=>{const d=o.trim();e0(d)&&(IC()?N0("createLink",d):eo("Link",f=>jS(f,"href",d)),n(!1))},u=()=>{Dr()?N0("unlink"):eo("Remove link",d=>jS(d,"href",void 0)),n(!1)};return p.jsx(Az,{open:t,side:"bottom",align:"start",onOpenChange:d=>{n(d),d?r(s??""):Tu()},trigger:p.jsx(Pt,{square:!0,"aria-label":"Link",title:`Link (${nt}K)`,pressed:!!s,children:p.jsx(HW,{...nr})}),children:p.jsxs("div",{"data-open-artifact-format-bar":!0,className:"flex w-72 flex-col gap-2",children:[p.jsx(Eb,{autoFocus:!0,"aria-label":"Link address",placeholder:"https://",value:o,onChange:d=>r(d.target.value),onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),l())}}),o.trim()&&!i?p.jsx("p",{className:"text-[12px] text-danger",children:"Links must start with http:// or https://"}):null,p.jsxs("div",{className:"flex justify-end gap-1",children:[s?p.jsx(Pl,{size:"sm",variant:"ghost",icon:p.jsx(lY,{className:"size-3.5"}),onClick:u,children:"Remove"}):null,p.jsx(Pl,{size:"sm",variant:"primary",disabled:!i,onClick:l,children:"Apply"})]})]})})}const Uf={className:"size-5",strokeWidth:1.5},Io={className:"size-4",strokeWidth:1.5},pH=[["rect","Rectangle",p.jsx(tY,{...Io},"r"),"R"],["rounded","Rounded rectangle",p.jsx(WW,{...Io},"rr"),`${Ny}R`],["ellipse","Ellipse",p.jsx(gW,{...Io},"e"),"O"],["diamond","Diamond (decision)",p.jsx(CW,{...Io},"d"),"D"]],mH=[["line","Line",p.jsx($i,{...Io},"l"),"L"],["connector","Connector",p.jsx(eY,{...Io},"c"),`${Ny}L`]],vge=[...pH,...mH],wge=[["arrow-right","Arrow right",p.jsx(vm,{...Io},"ar")],["arrow-left","Arrow left",p.jsx(vm,{...Io,className:"size-4 rotate-180"},"al")],["arrow-up","Arrow up",p.jsx(vm,{...Io,className:"size-4 -rotate-90"},"au")],["arrow-down","Arrow down",p.jsx(vm,{...Io,className:"size-4 rotate-90"},"ad")]];function Sge(){dd(pre,!0).then(e=>{e.length&&HE(e)})}function kge(){const e=se(n=>n.tool),t=vge.find(([n])=>n===e);return p.jsxs(Js,{side:"top",align:"center",tip:{label:t?t[1]:"Shapes",side:"top"},trigger:p.jsxs(Pt,{size:"lg",pressed:!!t,"aria-label":"Shapes",className:"gap-0 pl-1.5 pr-0.5",children:[t?p.jsx("span",{className:"flex size-5 items-center justify-center [&>svg]:size-5",children:t[2]}):p.jsx(QW,{...Uf}),p.jsx(Fo,{className:"size-3.5 text-chrome-muted",strokeWidth:1.5})]}),children:[pH.map(([n,s,o,r])=>p.jsx(Et,{icon:o,shortcut:r,onSelect:()=>se.getState().setTool(n),children:s},n)),wge.map(([n,s,o])=>p.jsx(Et,{icon:o,onSelect:()=>Y6(n),children:s},n)),p.jsx(Da,{}),mH.map(([n,s,o,r])=>p.jsx(Et,{icon:o,shortcut:r,onSelect:()=>se.getState().setTool(n),children:s},n))]})}function Ege(){return p.jsxs(Js,{side:"top",align:"center",tip:{label:"Image or video",side:"top"},trigger:p.jsx(Pt,{size:"lg",square:!0,"aria-label":"Image or video",children:p.jsx($u,{...Uf})}),children:[p.jsx(Et,{icon:p.jsx($u,{...Io}),onSelect:Sge,children:"Image or video from this computer…"}),p.jsx(Et,{icon:p.jsx(MW,{...Io}),onSelect:()=>Tr.getState().open("videoLink"),children:"Video link…"})]})}function Cge(){const e=Rt(h=>h.status.name),t=Rt(h=>h.status.busy),n=se(h=>h.selection.length),[s,o]=T.useState(""),[r,i]=T.useState(!1),[l,u]=T.useState(!1),d=async()=>{const h=s.trim();if(!(!h||r)){i(!0);try{await t6(h)&&o("")}finally{i(!1)}}},f=l||s.length>0;return p.jsxs("form",{className:Ie("flex h-8 shrink-0 items-center gap-1 rounded-[8px] bg-chrome-field pl-2.5 pr-1 transition-[width] duration-150",f?"w-64":"w-[100px]"),onSubmit:h=>{h.preventDefault(),d()},children:[t?p.jsx(Yg,{className:"size-4 shrink-0 animate-spin text-chrome-muted","aria-label":`${e} is working`}):null,p.jsx("input",{value:s,"aria-label":`Ask ${e}`,maxLength:4e3,placeholder:f?n?`Ask ${e} about the selection…`:`Ask ${e} to change this slide…`:`Ask ${e}`,className:"h-full min-w-0 flex-1 bg-transparent text-[14px] text-chrome-fg outline-none placeholder:text-chrome-muted",onFocus:()=>u(!0),onBlur:()=>u(!1),onChange:h=>o(h.target.value),onKeyDown:h=>{h.key==="Escape"&&(h.preventDefault(),h.currentTarget.blur())}}),f?p.jsx("button",{type:"submit","aria-label":"Send",disabled:!s.trim()||r,className:"flex size-6 shrink-0 items-center justify-center rounded-full bg-chrome-fg text-chrome outline-none disabled:opacity-30",children:r?p.jsx(Yg,{className:"size-3.5 animate-spin"}):p.jsx(D2,{className:"size-3.5",strokeWidth:2})}):null]})}function Tge({editing:e,ask:t}){const n=se(i=>i.tool),s=Cn(i=>i.available),o=Cn(i=>i.on),r=se.getState;return!e&&!s&&!t?null:p.jsxs(Lr,{role:"toolbar","aria-label":e?"Insert":"Comments",className:"max-w-full gap-1 p-1",children:[e?p.jsxs(p.Fragment,{children:[p.jsx(Rn,{label:"Text",shortcut:"T",side:"top",children:p.jsx(Pt,{size:"lg",square:!0,pressed:n==="text","aria-label":"Text",onClick:()=>r().setTool(n==="text"?"select":"text"),children:p.jsx(uz,{...Uf})})}),p.jsx(Ege,{}),p.jsx(Rn,{label:"Table",side:"top",children:p.jsx(Pt,{size:"lg",square:!0,"aria-label":"Table",onClick:()=>Tr.getState().open("table"),children:p.jsx(rY,{...Uf})})}),p.jsx(kge,{})]}):null,s?p.jsx(Rn,{label:o?"Stop commenting":"Comment",shortcut:"C",side:"top",children:p.jsx(Pt,{size:"lg",square:!0,pressed:o,"aria-label":o?"Stop commenting":"Comment",onClick:()=>Cn.getState().setOn(!o),children:p.jsx(Rr,{...Uf})})}):null,t?p.jsxs(p.Fragment,{children:[e||s?p.jsx(Mr,{className:"mx-0"}):null,p.jsx(Cge,{})]}):null]})}function U5({peer:e,ring:t}){return p.jsx("span",{className:Ie("flex size-6 shrink-0 items-center justify-center rounded-full text-[11px] font-semibold text-white ring-2 ring-chrome",t&&"outline-2 outline-offset-1 outline-chrome-accent"),style:{background:e.color},"aria-hidden":!0,children:e.kind==="agent"?p.jsx(Rh,{className:"size-3"}):e.name.slice(0,1).toUpperCase()})}function Mge({peers:e,following:t,leading:n,followers:s,agent:o,onFollow:r,onLead:i,onFollowAgent:l}){const u=e.filter(f=>f.kind==="person");if(e.length===0&&!o)return null;const d=e.slice(0,3);return p.jsx(Lr,{className:"pointer-events-auto flex items-center p-1",children:p.jsxs(Js,{align:"end",tip:{label:s?`${s} following you`:"People here"},trigger:p.jsxs(Pt,{size:"lg","aria-label":"People here and following",className:"gap-1.5 px-1.5",children:[d.length?p.jsx("span",{className:"flex -space-x-1.5",children:d.map(f=>p.jsx(U5,{peer:f,ring:f.id===t},f.id))}):p.jsx(qL,{className:"size-5",strokeWidth:1.5}),e.length>3?p.jsxs("span",{className:"text-xs text-chrome-muted",children:["+",e.length-3]}):null,n||s?p.jsxs("span",{className:Ie("flex items-center gap-1 rounded-full px-1.5 text-[11px] tabular-nums",n?"bg-chrome-pressed text-chrome-pressed-fg":"text-chrome-muted"),children:[p.jsx(WA,{className:"size-3","aria-hidden":!0}),s]}):null]}),children:[p.jsx(Et,{checked:n,icon:p.jsx(WA,{className:"size-4",strokeWidth:1.5}),description:n?s?`${s} ${s===1?"person is":"people are"} following you`:"No one is following yet":"Everyone here sees what you are looking at",onSelect:()=>i(!n),disabled:u.length===0&&!n,children:"Follow me"}),o?p.jsxs(Et,{checked:o.following,icon:p.jsx(Rh,{className:"size-4",strokeWidth:1.5}),description:"Your view follows what it changes",onSelect:()=>l(!o.following),children:["Follow ",o.name]}):null,u.length?p.jsxs(p.Fragment,{children:[p.jsx(Da,{}),p.jsx(AC,{children:"People here"}),u.map(f=>p.jsx(Et,{checked:t===f.id,icon:p.jsx(U5,{peer:f}),description:f.where,onSelect:()=>r(t===f.id?null:f.id),children:t===f.id?`Following ${f.name}`:`Follow ${f.name}`},f.id))]}):null]})})}function Rge({name:e,leading:t,followers:n,onStop:s}){return!e&&!t?null:p.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-[60px] z-20 flex justify-center",children:p.jsxs("div",{role:"status",className:"pointer-events-auto flex items-center gap-2 rounded-full bg-chrome-accent py-1 pl-3 pr-1 text-xs font-medium text-white shadow-chrome",children:[p.jsx("span",{children:e?`Following ${e}`:`Others follow you · ${n} following`}),p.jsx("span",{className:"text-white/70",children:e?"Esc to stop":""}),p.jsx("button",{type:"button","aria-label":e?"Stop following":"Stop leading",className:"flex size-5 items-center justify-center rounded-full hover:bg-white/20",onClick:s,children:p.jsx(_i,{className:"size-3.5"})})]})})}function jge({cursors:e,peers:t}){return e.length===0?null:p.jsx("div",{className:"pointer-events-none absolute inset-0 z-10","aria-hidden":!0,children:e.map(({peerId:n,x:s,y:o})=>{const r=t.find(l=>l.id===n);if(!r)return null;const i=r.color;return p.jsxs("div",{className:"absolute transition-[left,top] duration-75 ease-linear",style:{left:`${s*100}%`,top:`${o*100}%`},children:[p.jsx(UW,{className:"size-4 -translate-x-[3px] -translate-y-[2px] drop-shadow",style:{color:i,fill:i},strokeWidth:1.5}),p.jsx("span",{className:"absolute left-3 top-3 whitespace-nowrap rounded px-1 py-px text-[10px] font-medium text-white",style:{background:i},children:r.name})]},n)})})}function Age(e){const t=e.state?.slideIndex?`On slide ${e.state.slideIndex}`:void 0,n={id:e.id,name:e.name,kind:e.kind,color:e.color};return t?{...n,where:t}:n}function gH(){const e=Ci(t=>t.peers);return T.useMemo(()=>e.map(Age),[e])}function Oge(){const e=gH(),{following:t,leading:n,followers:s,status:o}=Rt(wE(l=>({following:l.following,leading:l.leading,followers:l.followers,status:l.status}))),r=e.find(l=>l.kind==="agent"),i=t===$a||r!==void 0&&t===r.id;return p.jsx(Mge,{peers:e,following:t,leading:n,followers:s,agent:o.available?{name:o.name,following:i}:null,onFollow:l=>Rt.getState().follow(l),onLead:l=>Rt.getState().setLeading(l),onFollowAgent:l=>l?Qne():Rt.getState().follow(null)})}function Nge(){const e=Ci(o=>o.peers),t=Rt(o=>Zne(o,e)),n=Rt(o=>o.leading),s=Rt(o=>o.followers);return p.jsx(Rge,{name:t,leading:n,followers:s,onStop:()=>t?Rt.getState().follow(null):Rt.getState().setLeading(!1)})}function $ge({id:e}){const t=tu(o=>o.cursors),n=gH(),s=T.useMemo(()=>Object.entries(t).filter(([,o])=>o.slideId===e).map(([o,r])=>({peerId:o,x:r.x,y:r.y})),[t,e]);return p.jsx(jge,{cursors:s,peers:n})}const $0=12,_0=40,_ge=$0+_0+8,Lge=8+_0+$0;function Dge({onStage:e,startCard:t}){const n=ae(r=>r.readOnly),s=Rt(r=>r.status.available),o=!n&&hn();return p.jsxs(p.Fragment,{children:[t?p.jsx("div",{className:"pointer-events-none absolute left-3 top-3 z-10 flex",children:p.jsx(xpe,{})}):null,p.jsxs("div",{className:"pointer-events-none absolute right-3 top-3 z-10 flex gap-2",children:[p.jsx(Oge,{}),p.jsx(Rpe,{onStage:e})]}),p.jsx(Nge,{}),e?p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-3 z-10 flex justify-center px-3",children:p.jsx(Tge,{editing:o,ask:s&&!n})}),p.jsx(fge,{})]}):null]})}function V5(e,t,n){if(n.x!==void 0&&n.y!==void 0)return{x:n.x,y:n.y};const s=o6(t,n),o=s&&Ye(t,s)?Bs(e.root,s):null;if(o){const r=ur(e.root,o,e.scale);return{x:r.x+r.w,y:r.y}}return{x:ot-48,y:48}}function zge(e){const t=e.root.getBoundingClientRect(),n=e.root.closest("[data-open-artifact-stage]")?.getBoundingClientRect();return n?{width:n.right-t.left,height:n.bottom-t.top}:{width:t.width,height:t.height}}function Pge({ctx:e,slide:t}){const n=Cn(h=>h.threads),s=Cn(h=>h.draft),o=gt(h=>h.layoutTick),r=Rt(h=>h.status),[i,l]=T.useState(()=>({points:new Map,viewport:{width:0,height:0}}));T.useLayoutEffect(()=>{const h=new Map;for(const g of n){const y=s6(g);y.slide===e.slideId&&h.set(y,V5(e,t,y))}s?.slide===e.slideId&&h.set(s,V5(e,t,s)),l({points:h,viewport:zge(e)})},[e,t,n,s,o]);const u=T.useCallback(h=>{const g=h.slide===e.slideId?i.points.get(h):void 0;return g?{world:g,state:"ok"}:null},[e.slideId,i]),d=T.useCallback(h=>{const g=e.root.getBoundingClientRect(),y=eu(e,t,g.left+h.x*e.scale,g.top+h.y*e.scale,[]);return Hu(t,y,h)},[e,t]),f=T.useMemo(()=>({x:0,y:0,zoom:e.scale}),[e.scale]);return p.jsx("div",{"data-open-artifact-comment-ui":!0,className:"contents",children:p.jsx(Xhe,{comments:sc,camera:f,viewport:i.viewport,place:u,anchorAt:d,agent:{available:r.available,name:r.name,wakesIdle:r.wakesIdle},piles:!1})})}function q5(e,t,n){const s=[];for(const o of n){const r=Ye(t,o),i=Bs(e.root,o);!r||!i||s.push({key:rs(o),path:o,box:YE(e.root,i,e.scale,ki(r))})}return s}function Ige(e,t){const n=gt(o=>o.relayout),s=t.map(rs).join(",");T.useLayoutEffect(()=>{if(typeof ResizeObserver>"u")return;const o=new ResizeObserver(()=>n());o.observe(e.root);for(const r of s?s.split(","):[]){const i=Bs(e.root,r);i&&o.observe(i)}return()=>o.disconnect()},[e.root,s,n])}function Bge({ctx:e,slide:t,children:n}){const s=se(_=>_.selection),o=se(_=>_.textEdit),r=se(_=>_.cropping),i=gt(_=>_.hover),l=gt(_=>_.move),u=gt(_=>_.guides),d=gt(_=>_.marquee),f=gt(_=>_.draw),h=gt(_=>_.layoutTick),g=gt(_=>!!(_.draft||_.move)),y=Cn(_=>_.on),b=Cn(_=>_.draft!==null||_.active!==null),[v,w]=T.useState([]),[S,C]=T.useState(null),k=qa(e),M=e.scale;Ige(e,s),T.useLayoutEffect(()=>{w(q5(e,t,s));const _=i&&(y||!s.some(D=>js(D,i)));C(_?q5(e,t,[i])[0]??null:null)},[e,t,s,i,h,o,y]);const j=_=>l&&l.keys.includes(_.key)?{..._.box,x:_.box.x+l.dx,y:_.box.y+l.dy}:_.box,O=v.length===1?v[0]:null,$=O?Ye(t,O.path):void 0,A=!!(O&&$&&k&&!o&&!r&&!l),N=v.length>1?b8(v.map(j)):null;return p.jsxs("div",{className:"pointer-events-none absolute inset-0 overflow-visible","data-open-artifact-overlay":!0,children:[S&&!g&&!y?p.jsx(Ag,{box:S.box,scale:M,className:"border border-accent/60"}):null,S&&y&&!b?p.jsx(Ag,{box:S.box,scale:M,className:"rounded-[2px] border-2 border-warning/80"}):null,v.map(_=>p.jsxs(Ag,{box:j(_),scale:M,className:Ie("border-accent",v.length>1?"border":"border-[1.5px]",o&&"border-dashed"),children:[A&&O===_&&$&&$.kind!=="connector"?p.jsx(Hge,{ctx:e,path:_.path}):null,A&&O===_&&$?.kind==="table"?p.jsx(Fge,{table:$,path:_.path}):null]},_.key)),A&&O&&$?.kind==="connector"&&$.points?p.jsx(Uge,{ctx:e,slide:t,path:O.path}):null,N?p.jsx("div",{className:"absolute border border-dashed border-accent/70",style:{left:N.x*M-4,top:N.y*M-4,width:N.w*M+8,height:N.h*M+8}}):null,p.jsx(qge,{ctx:e,slide:t}),u?p.jsxs(p.Fragment,{children:[u.x.map(_=>p.jsx("div",{className:"absolute top-0 h-full w-px bg-danger",style:{left:_*M}},`x${_}`)),u.y.map(_=>p.jsx("div",{className:"absolute left-0 h-px w-full bg-danger",style:{top:_*M}},`y${_}`))]}):null,d?p.jsx("div",{className:"absolute border border-accent bg-accent/10",style:{left:d.x*M,top:d.y*M,width:d.w*M,height:d.h*M}}):null,f?p.jsx(Vge,{scale:M}):null,r&&k?p.jsx(Wge,{ctx:e,slide:t,path:r}):null,n]})}function Ag({box:e,scale:t,className:n,children:s}){return p.jsx("div",{className:Ie("absolute",n),style:{left:e.x*t,top:e.y*t,width:e.w*t,height:e.h*t,transform:e.rotation?`rotate(${e.rotation}deg)`:void 0},children:s})}function Hge({ctx:e,path:t}){return p.jsxs(p.Fragment,{children:[Oie.map(n=>p.jsx("div",{role:"presentation",className:"pointer-events-auto absolute size-2.5 rounded-[2px] border border-accent bg-surface shadow-sm",style:{left:`calc(${(n.hx+1)/2*100}% - 5px)`,top:`calc(${(n.hy+1)/2*100}% - 5px)`,cursor:n.cursor},onPointerDown:s=>{s.button===0&&(s.stopPropagation(),s.preventDefault(),qie(e,s,t,n))}},n.id)),p.jsx("div",{className:"absolute left-1/2 top-0 h-5 w-px -translate-y-full bg-accent"}),p.jsx("div",{role:"presentation",title:"Rotate (Shift snaps to 15°)",className:"pointer-events-auto absolute left-1/2 top-0 flex size-4 -translate-x-1/2 -translate-y-[calc(100%+18px)] cursor-grab items-center justify-center rounded-full border border-accent bg-surface text-accent shadow-sm",onPointerDown:n=>{n.button===0&&(n.stopPropagation(),n.preventDefault(),Gie(e,n,t))},children:p.jsx(DD,{className:"size-2.5"})})]})}function Fge({table:e,path:t}){const n=[{what:"column",label:"Add a column",style:{left:"calc(100% + 14px)",top:"50%",transform:"translateY(-50%)"}},{what:"row",label:"Add a row",style:{top:"calc(100% + 14px)",left:"50%",transform:"translateX(-50%)"}}];return p.jsx(p.Fragment,{children:n.map(({what:s,label:o,style:r})=>{const i=m0(e,s);return p.jsx(h3,{label:i??o,children:p.jsx("button",{type:"button",tabIndex:-1,"data-open-artifact-table-add":s,"aria-label":o,"aria-disabled":i!==null,className:Ie("pointer-events-auto absolute flex size-5 items-center justify-center rounded-full border border-accent bg-surface text-accent shadow-sm",i?"cursor-not-allowed opacity-50":"hover:bg-accent hover:text-accent-fg"),style:r,onPointerDown:l=>l.stopPropagation(),onMouseDown:l=>l.preventDefault(),onDoubleClick:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),i||er(t,s==="row"?"addRow":"addColumn")},children:p.jsx(ds,{className:"size-3",strokeWidth:2})})},s)})})}function Uge({ctx:e,slide:t,path:n}){const s=Ye(t,n);if(s?.kind!=="connector")return null;const o=Vu(e.root,t,n,e.scale),r=GE(s,o.w,o.h);return r?p.jsx(p.Fragment,{children:r.map((i,l)=>p.jsx("div",{role:"presentation",title:l===0?"Start":"End",className:"pointer-events-auto absolute size-3 cursor-move rounded-full border-2 border-accent bg-surface shadow-sm",style:{left:(o.x+i.x)*e.scale-6,top:(o.y+i.y)*e.scale-6},onPointerDown:u=>{u.button===0&&(u.stopPropagation(),u.preventDefault(),Wie(e,u,n,l))}},l))}):null}function Vge({scale:e}){const t=gt(s=>s.draw);if(!t)return null;if(t.tool==="line"||t.tool==="connector")return p.jsx("svg",{className:"absolute inset-0 size-full overflow-visible",children:p.jsx("line",{x1:t.from.x*e,y1:t.from.y*e,x2:t.to.x*e,y2:t.to.y*e,stroke:"var(--color-accent)",strokeWidth:2,strokeDasharray:"6 4"})});const n=v0(t.from,t.to);return p.jsx("div",{className:Ie("absolute border-2 border-dashed border-accent bg-accent/5",t.tool==="ellipse"&&"rounded-full",t.tool==="rounded"&&"rounded-xl"),style:{left:n.x*e,top:n.y*e,width:n.w*e,height:n.h*e}})}function qge({ctx:e,slide:t}){const n=Hh().get(e.slideId),s=gt(l=>l.layoutTick),[o,r]=T.useState([]),i=T.useMemo(()=>(n??[]).flatMap(l=>(l.state?.selected??[]).flatMap(u=>{const d=pI(t,u);return d?[{peer:l,path:d.path}]:[]})),[n,t]);return T.useLayoutEffect(()=>{r(i.flatMap(({peer:l,path:u})=>{const d=Ye(t,u),f=Bs(e.root,u);return!d||!f?[]:[{id:`${l.id}:${rs(u)}`,name:l.name,agent:l.kind==="agent",box:YE(e.root,f,e.scale,ki(d))}]}))},[e,t,i,s]),p.jsx(p.Fragment,{children:o.map(l=>p.jsx(Ag,{box:l.box,scale:e.scale,className:Ie("border-2",l.agent?"border-accent/70":"border-success/80"),children:p.jsx("span",{className:Ie("absolute -top-5 left-0 rounded px-1 text-[10px] font-medium leading-4 text-white",l.agent?"bg-accent":"bg-success"),children:l.name})},l.id))})}const Gge={n:"ns-resize",s:"ns-resize",e:"ew-resize",w:"ew-resize",ne:"nesw-resize",sw:"nesw-resize",nw:"nwse-resize",se:"nwse-resize"},G5={n:"top edge",s:"bottom edge",e:"right edge",w:"left edge",ne:"top right",nw:"top left",se:"bottom right",sw:"bottom left"};function Wge({ctx:e,slide:t,path:n}){const s=Ye(t,n),o=gt(w=>w.layoutTick),r=gt(w=>w.relayout),[i,l]=T.useState(null),[u,d]=T.useState(null);if(T.useLayoutEffect(()=>{if(s?.kind!=="image")return;const w=k8(e,n,s);if(l(w),!w){const S=Bs(e.root,n)?.querySelector("img");S&&!S.complete&&S.addEventListener("load",r,{once:!0})}},[e,s,n,o,r]),s?.kind!=="image"||!s.src)return null;const f=e.scale,h=()=>se.getState().setCropping(null);if(!i)return null;const{frame:g,picture:y}=i,b=u??Gh(s).zoom,v=E8(s);return p.jsxs(p.Fragment,{children:[p.jsx("img",{src:wo(s.src),alt:"",draggable:!1,className:"absolute max-w-none opacity-35",style:{left:y.x*f,top:y.y*f,width:y.w*f,height:y.h*f}}),p.jsx("div",{role:"presentation",title:"Drag to move the picture; drag a side to crop",className:"pointer-events-auto absolute cursor-move outline outline-2 outline-accent",style:{left:g.x*f,top:g.y*f,width:g.w*f,height:g.h*f},onPointerDown:w=>{w.button===0&&(w.stopPropagation(),w.preventDefault(),Qie(e,w,n))},onDoubleClick:w=>{w.stopPropagation(),h()},onWheel:w=>{w.stopPropagation();const S=Math.min(Math.max(5,b),Math.max(1,b*Math.exp(-w.deltaY*.002)));N$(e.slideId,n,S)}}),v?_ie.map(w=>{const S=v[w],C=w.includes("w")?0:w.includes("e")?1:.5,k=w.includes("n")?0:w.includes("s")?1:.5,M=w.length===2;return p.jsx("div",{role:"presentation","aria-label":`Crop handle, ${G5[w]}`,title:S??`Crop from the ${G5[w]}`,className:Ie("pointer-events-auto absolute -translate-x-1/2 -translate-y-1/2 border border-accent bg-surface shadow-sm",M?"size-3":w==="n"||w==="s"?"h-1.5 w-6 rounded-full":"h-6 w-1.5 rounded-full",S&&"opacity-40"),style:{left:(g.x+g.w*C)*f,top:(g.y+g.h*k)*f,cursor:S?"not-allowed":Gge[w]},onPointerDown:j=>{j.button===0&&(j.stopPropagation(),j.preventDefault(),S||eae(e,j,n,w))}},w)}):null,p.jsxs("div",{className:"pointer-events-auto absolute flex w-72 items-center gap-2 rounded-control border border-line bg-surface px-2 py-1 shadow-popup",style:{left:g.x*f+g.w*f/2-144,top:(g.y+g.h)*f+12},onPointerDown:w=>w.stopPropagation(),children:[p.jsx("span",{className:"text-xs text-fg-muted",children:"Zoom"}),p.jsx("div",{className:"min-w-0 flex-1",children:p.jsx(qX,{"aria-label":"Crop zoom",value:b,min:1,max:Math.max(5,b),step:.05,onChange:w=>{d(w),N$(e.slideId,n,w)},onCommit:()=>d(null)})}),p.jsx(Ot,{size:"sm",variant:"ghost",icon:p.jsx(_u,{className:"size-3.5"}),onClick:()=>nae(e.slideId,n),"aria-label":"Reset crop"}),p.jsx(Ot,{size:"sm",variant:"primary",icon:p.jsx(Ni,{className:"size-3.5"}),onClick:h,children:"Done"})]})]})}const W5=nt==="⌘"?"⌥":"Alt+",Yge=nt==="⌘"?"⇧":"Shift+";function Y5(e){document.execCommand(e)||tt.add({title:`Use ${nt}${e==="copy"?"C":"X"} to ${e}`})}function Kge(){const e=se.getState(),t=fs(),n=Ar(e.current)!==null,s=Go();if(!t||!e.current)return null;if(s.length===0)return p.jsxs(p.Fragment,{children:[n?p.jsx(ft,{icon:p.jsx(yS,{className:"size-4"}),shortcut:`${nt}V`,disabled:!qS(),onSelect:()=>VS(),children:"Paste"}):null,p.jsx(ft,{shortcut:`${nt}A`,onSelect:B6,children:"Select all"}),f0()?p.jsx(ft,{icon:p.jsx(Rr,{className:"size-4"}),onSelect:()=>Cn.getState().setDraft(Hu(t,null)),children:"Comment on slide"}):null,p.jsx(Rl,{}),p.jsx(vb,{ids:[e.current]})]});const o=s.length===1?s[0]:null,r=o?Ye(t,o):void 0,i=r?.kind==="box"&&r.group;return p.jsxs(p.Fragment,{children:[n?p.jsx(ft,{icon:p.jsx(PD,{className:"size-4"}),shortcut:`${nt}X`,onSelect:()=>Y5("cut"),children:"Cut"}):null,p.jsx(ft,{icon:p.jsx(DL,{className:"size-4"}),shortcut:`${nt}C`,onSelect:()=>Y5("copy"),children:"Copy"}),n?p.jsxs(p.Fragment,{children:[p.jsx(ft,{icon:p.jsx(yS,{className:"size-4"}),shortcut:`${nt}V`,disabled:!qS(),onSelect:()=>VS(),children:"Paste"}),p.jsx(ft,{shortcut:`${nt}D`,onSelect:F6,children:"Duplicate"}),p.jsx(ft,{icon:p.jsx(wy,{className:"size-4"}),shortcut:"⌫",danger:!0,onSelect:PE,children:"Delete"}),p.jsx(Rl,{}),r&&Ba(r)?p.jsx(ft,{icon:p.jsx(uz,{className:"size-4"}),shortcut:"↵",onSelect:H6,children:"Edit text"}):null,r?.kind==="image"&&r.src?p.jsx(ft,{icon:p.jsx(kW,{className:"size-4"}),onSelect:()=>{ki(r)?tt.add({title:"Straighten the picture to crop it"}):se.getState().setCropping(o)},children:"Crop"}):null,r?.kind==="image"&&o?p.jsx(ft,{icon:p.jsx(_W,{className:"size-4"}),onSelect:()=>{dd("image/png,image/jpeg,image/gif,image/webp,image/svg+xml",!1).then(l=>{l[0]&&y0(o,l[0])})},children:"Replace picture…"}):null,r?.kind==="table"&&o?p.jsx(Xge,{table:r,path:o}):null,p.jsx(ft,{icon:p.jsx(hW,{className:"size-4"}),shortcut:"]",onSelect:()=>au("front"),children:"Bring to front"}),p.jsx(ft,{shortcut:`${nt}]`,onSelect:()=>au("forward"),children:"Bring forward"}),p.jsx(ft,{shortcut:`${nt}[`,onSelect:()=>au("backward"),children:"Send backward"}),p.jsx(ft,{icon:p.jsx(KW,{className:"size-4"}),shortcut:"[",onSelect:()=>au("back"),children:"Send to back"}),p.jsx(Rl,{}),s.length>1?p.jsx(ft,{icon:p.jsx(AW,{className:"size-4"}),shortcut:`${nt}G`,onSelect:V6,children:"Group"}):null,i?p.jsx(ft,{icon:p.jsx(aY,{className:"size-4"}),shortcut:`${Yge}${nt}G`,onSelect:q6,children:"Ungroup"}):null,p.jsx(ft,{icon:p.jsx(ED,{className:"size-4"}),shortcut:`${W5}${nt}C`,onSelect:G6,children:"Copy style"}),p.jsx(ft,{shortcut:`${W5}${nt}V`,disabled:!e.styleClipboard,onSelect:W6,children:"Paste style"})]}):null,f0()&&o?p.jsxs(p.Fragment,{children:[p.jsx(Rl,{}),p.jsx(ft,{icon:p.jsx(Rr,{className:"size-4"}),onSelect:()=>Cn.getState().setDraft(Hu(t,o)),children:"Comment"})]}):null]})}function Xge({table:e,path:t}){const n=se.getState().textEdit,s=n?.cell&&js(n.path,t)?n.cell:null,o=m0(e,"row"),r=m0(e,"column"),i=HS(e,"row"),l=HS(e,"column");return p.jsxs(p.Fragment,{children:[s?p.jsxs(p.Fragment,{children:[p.jsx(ft,{disabled:o!==null,onSelect:()=>er(t,"addRow",s[0]),children:"Insert row above"}),p.jsx(ft,{disabled:o!==null,onSelect:()=>er(t,"addRow",s[0]+1),children:"Insert row below"}),p.jsx(ft,{disabled:r!==null,onSelect:()=>er(t,"addColumn",s[1]),children:"Insert column left"}),p.jsx(ft,{disabled:r!==null,onSelect:()=>er(t,"addColumn",s[1]+1),children:"Insert column right"}),p.jsx(ft,{disabled:i!==null,onSelect:()=>er(t,"removeRow",s[0]),children:"Delete row"}),p.jsx(ft,{disabled:l!==null,onSelect:()=>er(t,"removeColumn",s[1]),children:"Delete column"})]}):p.jsxs(p.Fragment,{children:[p.jsx(ft,{disabled:o!==null,onSelect:()=>er(t,"addRow"),children:"Add a row"}),p.jsx(ft,{disabled:r!==null,onSelect:()=>er(t,"addColumn"),children:"Add a column"}),p.jsx(ft,{disabled:i!==null,onSelect:()=>er(t,"removeRow"),children:"Remove the last row"}),p.jsx(ft,{disabled:l!==null,onSelect:()=>er(t,"removeColumn"),children:"Remove the last column"})]}),p.jsx(Rl,{})]})}const z1=24,K5=_ge,X5=Lge+24,Z5=72;function Zge(e){return Ba(e)||e.kind==="table"}function yH(){const e=se(D=>D.current),t=ae(D=>e?D.slides[e]:void 0),n=gt(D=>D.draft),s=se(u0),o=se(D=>D.textEdit),r=se(D=>D.tool),i=Cn(D=>D.on),l=se(D=>D.showNotes),u=T.useRef(null),d=T.useRef(null),[f,h]=T.useState(null),g=Vh(u),y=T.useRef(0),b=ae(D=>D.index.size);T.useEffect(()=>{if(!g||g.w<=0||g.h<=0)return;const D=g.h-K5-X5-(l?Z5:0);se.getState().setFitScale(Math.max(.05,Math.min((g.w-z1*2)/ot,D/vt)))},[g,l,b]),T.useLayoutEffect(()=>{h(d.current)}),T.useEffect(()=>()=>gt.getState().set({draft:null,move:null,guides:null,marquee:null,draw:null,hover:null}),[e]),T.useEffect(()=>{const D=u.current;if(!D)return;const P=L=>{if(!(L.ctrlKey||L.metaKey))return;L.preventDefault();const F=se.getState();F.setZoom(u0(F)*Math.exp(-L.deltaY*.01))};return D.addEventListener("wheel",P,{passive:!1}),()=>D.removeEventListener("wheel",P)},[]);const v=n&&n.slideId===e?n.slide:t?.slide,w=T.useMemo(()=>f&&e?{root:f,scale:s,slideId:e}:null,[f,s,e]),S=T.useMemo(()=>{const D=o&&o.slideId===e?o:null;return{mode:"edit",resolveSrc:wo,override:D?(P,L)=>js(L,D.path)&&Zge(P)?p.jsx(Wpe,{node:P,path:L,slideId:D.slideId,cell:D.cell},rs(L)):void 0:void 0}},[o,e]);if(Qge(f,e,v),!e||!t||!v)return p.jsx("div",{className:"absolute inset-0 bg-stage"});const C=D=>{if(!w)return;const P=D.target;if(P.closest("[data-open-artifact-overlay] .pointer-events-auto, [data-open-artifact-comment-ui], [data-open-artifact-notes]"))return;s8("stage");const L=se.getState(),F=ae.getState().slides[w.slideId]?.slide;if(!F)return;if(D.button===2){const q=eu(w,F,D.clientX,D.clientY,L.selection);q&&!L.selection.some(G=>js(G,q)||Er(G,q))&&L.select([q]),!q&&L.selection.length&&L.select([]);return}if(D.button!==0||P.closest("[data-open-artifact-editing]"))return;const U=document.activeElement;if(U&&U!==document.body&&!w.root.contains(U)&&U.blur?.(),D.preventDefault(),L.textEdit&&L.endTextEdit(),L.cropping&&L.setCropping(null),Cn.getState().on){if(!f0())return;const q=eu(w,F,D.clientX,D.clientY,[]),G=La(w.root,D.clientX,D.clientY,w.scale);Cn.getState().setDraft(Hu(F,q,G));return}if(L.tool!=="select"){Xie(w,D,L.tool);return}const I=eu(w,F,D.clientX,D.clientY,L.selection);if(!I){Yie(w,D,D.shiftKey);return}const H=L.selection.some(q=>js(q,I));if(D.shiftKey||D.metaKey||D.ctrlKey){if(H){L.select(L.selection.filter(q=>!js(q,I)));return}L.select([...L.selection,I])}else H||L.select([I]);Bie(w,D,se.getState().selection)},k=D=>{if(!w||Cn.getState().on)return;const P=D.target;if(P.closest("[data-open-artifact-editing], [data-open-artifact-overlay] .pointer-events-auto, [data-open-artifact-comment-ui], [data-open-artifact-notes]"))return;const L=se.getState(),F=ae.getState().slides[w.slideId]?.slide;if(!F||L.tool!=="select")return;const U=L.selection[0],I=Pie(w,F,D.clientX,D.clientY);if(!I)return;const H=U?Ye(F,U):void 0;if(U&&H?.kind==="box"&&Er(U,I)){L.select([I]);return}const q=U&&(js(U,I)||Er(U,I))?U:I,G=Ye(F,q);if(!(!G||!Ar(w.slideId)))if(Ba(G))L5({x:D.clientX,y:D.clientY}),L.startTextEdit({slideId:w.slideId,path:q});else if(G.kind==="table"){const Y=P.closest("[data-open-artifact-cell]")?.getAttribute("data-open-artifact-cell")?.split(":").map(Number);L5({x:D.clientX,y:D.clientY}),L.startTextEdit({slideId:w.slideId,path:q,cell:Y&&Y.length===2?[Y[0],Y[1]]:[0,0]})}else G.kind==="image"?G.src?ki(G)?tt.add({title:"Straighten the picture to crop it"}):(L.select([q]),L.setCropping(q)):dd("image/png,image/jpeg,image/gif,image/webp,image/svg+xml",!1).then(Y=>{Y[0]&&y0(q,Y[0])}):G.kind==="box"&&G.children.length&&L.select([I])},M=D=>{const P=Cn.getState().on;if(!w||D.buttons||!P&&se.getState().tool!=="select")return;const L=D.clientX,F=D.clientY;cancelAnimationFrame(y.current),y.current=requestAnimationFrame(()=>{const U=ae.getState().slides[w.slideId]?.slide,I=U?eu(w,U,L,F,P?[]:se.getState().selection):null,H=gt.getState().hover;!(H&&I&&js(H,I))&&H!==I&>.getState().set({hover:I})})},j=D=>{!D.dataTransfer.types.includes("Files")||!hn()||!Ar(e)||(D.preventDefault(),D.dataTransfer.dropEffect="copy")},O=D=>{if(!w||!D.dataTransfer.files.length)return;D.preventDefault();const P=Array.from(D.dataTransfer.files).filter(Z6);if(P.length===0){tt.add({title:"Only pictures and video clips can be dropped here"});return}const L=ae.getState().slides[w.slideId]?.slide,F=L?eu(w,L,D.clientX,D.clientY,[]):null,U=L&&F?Ye(L,F):void 0;if(F&&U?.kind==="image"&&P.length===1&&P[0].type.startsWith("image/")){y0(F,P[0]);return}const I=La(w.root,D.clientX,D.clientY,w.scale);HE(P,{x:Math.min(ot,Math.max(0,I.x)),y:Math.min(vt,Math.max(0,I.y))})},$=ot*s,A=vt*s,N=Math.min(320,(g?.w??0)-24),_=i?qhe:r!=="select"?"crosshair":void 0;return p.jsx(xb,{menu:i?null:p.jsx(Kge,{}),className:"absolute inset-0",children:p.jsx("div",{ref:u,"data-open-artifact-stage":!0,className:"absolute inset-0 overflow-auto bg-stage outline-none",style:{cursor:_},onPointerDown:C,onPointerMove:M,onPointerLeave:()=>gt.getState().set({hover:null}),onDoubleClick:k,onDragOver:j,onDrop:O,children:p.jsx("div",{className:"flex min-h-full min-w-full flex-col items-center justify-center",style:{paddingTop:K5,paddingBottom:X5+(l?Z5:0),paddingLeft:z1,paddingRight:z1,width:"max-content",height:"max-content"},children:p.jsxs("div",{className:"relative shrink-0 shadow-[0_0_0_1px_rgb(0_0_0/0.06),0_1px_3px_rgb(0_0_0/0.08)]",style:{width:$,height:A},children:[p.jsx("div",{className:"absolute left-0 top-0 origin-top-left",style:{width:ot,height:vt,transform:`scale(${s})`},children:p.jsx(fd,{slide:v,options:S,rootRef:d})}),w?p.jsx(Bge,{ctx:w,slide:v,children:p.jsx(Pge,{ctx:w,slide:v})}):null,v.hidden?p.jsxs("div",{className:"pointer-events-none absolute left-2 top-2 flex items-center gap-1 rounded-full bg-chrome/90 px-2 py-0.5 text-[11px] text-chrome-secondary shadow-chrome",children:[p.jsx(Mh,{className:"size-3"})," Skipped when presenting"]}):null,l?p.jsx("div",{"data-open-artifact-notes":!0,className:"absolute left-0 top-full",style:{width:$},onContextMenu:D=>D.stopPropagation(),children:p.jsx("div",{className:"mt-2",style:{width:Math.min(720,Math.max($,N)),marginLeft:Math.min(0,($-N)/2)},children:p.jsx($C,{slideId:e,autoGrow:!0,className:"-mx-1.5 -my-0.5 block w-[calc(100%+12px)] resize-none overflow-hidden rounded-[6px] bg-transparent px-1.5 py-0.5 text-[13px] leading-[18px] text-chrome-secondary outline-none placeholder:text-chrome-muted hover:bg-chrome-hover focus:bg-chrome focus:text-chrome-fg focus:shadow-[0_0_0_1px_var(--color-chrome-accent)]"},e)})}):null]})})})})}function Qge(e,t,n){const s=se(i=>i.findOpen),o=ba(i=>i.query),r=ba(i=>i.matches[i.index]);T.useEffect(()=>{if(!e||!s||!o.trim())return;const i=r&&r.slideId===t?{pathKey:rs(r.path),occurrence:r.occurrence}:void 0,l=requestAnimationFrame(()=>kre(e,o,i));return()=>cancelAnimationFrame(l)},[e,s,o,r,t,n])}const Jge=64;function e0e(){const e=Rt(t=>t.status);return p.jsx(zhe,{comments:sc,agent:{available:e.available,name:e.name,wakesIdle:e.wakesIdle},top:Jge,hint:"Press C, then click the slide where you want to comment."})}const bH="#ffffff",t0e=/#[0-9a-fA-F]{3,8}\b|(?:rgba?|hsla?)\([^()]*\)|\b[a-zA-Z]+\b/g;function Mu(e,t){const n=e.split(/(url\([^)]*\))/i);let s=!1;const o=n.map((r,i)=>i%2===1?r:r.replace(t0e,l=>{if(/^[a-z]+$/i.test(l)&&!Object.hasOwn(Ly,l.toLowerCase()))return l;const u=eC(l);if(!u)return l;const d=t(u,l);return d===void 0||d===l?l:(s=!0,d)}));return s?o.join(""):e}function n0e(e){if(!e)return null;let t=null;return Mu(e,n=>{t??=n}),t}const xH=["border","border-top","border-right","border-bottom","border-left","text-decoration","-webkit-text-stroke"],s0e=/((?:fill|stroke|stop-color|flood-color|lighting-color|color)\s*(?:=\s*["']?|:\s*))(#[0-9a-fA-F]{3,8}\b|(?:rgba?|hsla?)\([^()]*\)|[a-zA-Z]+)/g;function o0e(e,t,n){let s=!1;const o=e.replace(s0e,(r,i,l)=>{if(/^[a-z]+$/i.test(l)&&!Object.hasOwn(Ly,l.toLowerCase()))return r;const u=eC(l);if(!u)return r;const d=n({prop:"fill",value:u,on:t},l);return d===void 0||d===l?r:(s=!0,i+d)});return s?o:e}function ch(e,t,n,s){let o=e;const r=(u,d)=>{d!==e[u]&&(o===e&&(o={...e}),o[u]=d)};let i=t;const l=e.background;if(l){const u=e["background-clip"]==="text",d=n0e(l);r("background",Mu(l,(f,h)=>s.visit({prop:u?"text":n,value:f,on:t},h))),!u&&d&&/^(#|rgb|hsl|[a-z])/i.test(l.trim())&&(i=d)}e.color&&r("color",Mu(e.color,(u,d)=>s.visit({prop:"text",value:u,on:i},d)));for(const u of xH){const d=e[u];d&&r(u,Mu(d,(f,h)=>s.visit({prop:"line",value:f,on:i},h)))}return{style:o,ground:i}}function kk(e,t,n){let s=e;return e.forEach((o,r)=>{const i=o.marks?.color;if(!i)return;const l=Mu(i,(u,d)=>n.visit({prop:"text",value:u,on:t},d));l!==i&&(s===e&&(s=[...e]),s[r]={...o,marks:{...o.marks,color:l}})}),s}function r0e(e,t,n){let s=e;return e.forEach((o,r)=>{const i=ch(o.style,t,"fill",n);let l=o.cells;o.cells.forEach((u,d)=>{const f=ch(u.style,i.ground,"fill",n),h=kk(u.runs,f.ground,n);f.style===u.style&&h===u.runs||(l===o.cells&&(l=[...o.cells]),l[d]={...u,style:f.style,runs:h})}),!(i.style===o.style&&l===o.cells)&&(s===e&&(s=[...e]),s[r]={...o,style:i.style,cells:l})}),s}function Ek(e,t,n){const{style:s,ground:o}=e.kind==="connector"?i0e(e.style,t,n):ch(e.style,t,"fill",n);let r=s===e.style?e:{...e,style:s};const i=l=>{r={...r,...l}};switch(e.kind){case"text":{const l=kk(e.runs,o,n);l!==e.runs&&i({runs:l});break}case"list":{let l=e.items;e.items.forEach((u,d)=>{const f=kk(u.runs,o,n);f!==u.runs&&(l===e.items&&(l=[...e.items]),l[d]={...u,runs:f})}),l!==e.items&&i({items:l});break}case"textbox":{let l=e.blocks;e.blocks.forEach((u,d)=>{const f=Ek(u,o,n);f!==u&&(l===e.blocks&&(l=[...e.blocks]),l[d]=f)}),l!==e.blocks&&i({blocks:l});break}case"box":{let l=e.children;e.children.forEach((u,d)=>{const f=Ek(u,o,n);f!==u&&(l===e.children&&(l=[...e.children]),l[d]=f)}),l!==e.children&&i({children:l});break}case"table":{const l=r0e(e.rows,o,n);l!==e.rows&&i({rows:l});break}case"svg":{const l=o0e(e.markup,o,n.visit);l!==e.markup&&i({markup:l});break}}return r}function i0e(e,t,n){const s=e.color,o=ch({...e,color:void 0},t,"fill",n),r=s?Mu(s,(u,d)=>n.visit({prop:"line",value:u,on:t},d)):void 0;if(!(o.style.background!==e.background||r!==s||xH.some(u=>o.style[u]!==e[u])))return{style:e,ground:o.ground};const l={...o.style};return r!==void 0?l.color=r:delete l.color,{style:l,ground:o.ground}}function BC(e,t){const n={visit:t},{style:s,ground:o}=ch(e.style,bH,"ground",n);let r=e.children;return e.children.forEach((i,l)=>{const u=Ek(i,o,n);u!==i&&(r===e.children&&(r=[...e.children]),r[l]=u)}),s===e.style&&r===e.children?e:{...e,style:s,children:r}}function a0e(e){const t=[];return BC(e,n=>{t.push(n)}),t}const L0=512;function vH(e){return`${e.prop}|${e.value}|${e.on}`}const Ru=e=>e==="ground"||e==="fill";function l0e(e){const t=new Map;for(const n of e){const s=vH(n),o=t.get(s);o?o.count++:t.set(s,{...n,key:s,count:1})}return[...t.values()]}function c0e(e){const t=new Map;for(const o of e){const r=o.prop==="ground"?o.value:o.on;t.set(r,(t.get(r)??0)+o.count)}const n=[...new Set(e.filter(o=>o.prop==="ground").map(o=>o.value))];if(!n.length)return bH;const s=o=>(t.get(o)??0)*(kr(o)?.5:1);return n.sort((o,r)=>s(r)-s(o)||(o<r?-1:1))[0]}function Q5(e){const t=new Map;for(const n of e)t.set(n.value,(t.get(n.value)??0)+n.count);return[...t].sort((n,s)=>s[1]-n[1]||(n[0]<s[0]?-1:1)).map(([n])=>n)}function u0e(e,t,n){const s=k0(t),o=n?.themes.find(A=>A.dark===s)??n?.themes[0],r=nC(o,"accent"),i=new Map,l=new Map,u=new Map;for(const A of e)kr(A.value)&&!P$(A.value)&&u.set(A.value,(u.get(A.value)??0)+A.count*(Ru(A.prop)?3:1));const d=[...u].sort((A,N)=>N[1]-A[1]).map(([A])=>A),f=d.find(A=>A===r)??d[0],h=(A,N)=>N!==void 0&&Eae(A,N)<24,g=d.filter(A=>!h(A,f)&&!Df(A)),y=new Set(g.map(A=>Math.round(E0(A)/30)%12)).size<=1,b=A=>h(A,f)||y&&g.some(N=>A===N||h(A,N)),v=A=>{const N=A.value;return N===t?"background":kr(N)?b(N)?xs(N,t)<1.3&&tC(N)<.09?"accent-soft":"accent":Df(N)??"other":k0(N)!==s&&xs(N,t)>=4.5?"inverse":A.prop==="ground"||xs(N,A.on)<1.25?"surface":"border"},w=e.filter(A=>Ru(A.prop)).sort((A,N)=>A.prop===N.prop?0:A.prop==="ground"?-1:1);for(const A of w){const N=v(A);i.set(A.key,N),(!l.has(A.value)||A.prop==="ground")&&l.set(A.value,N)}const S=A=>l.get(A.on)??(A.on===t?"background":"surface"),C=e.filter(A=>A.prop==="text"&&!kr(A.value)),k=A=>{const N=C.filter(_=>A(S(_)));return Q5(N.filter(_=>xs(_.value,_.on)>=7))[0]??Q5(N)[0]},M=k(A=>A!=="accent"&&A!=="inverse"&&A!=="other"&&!J5(A)),j=k(A=>A==="inverse"),O=(A,N)=>N===void 0||xs(A.value,A.on)>=.8*xs(N,A.on),$=A=>{const N=A.value,_=S(A);return A.prop==="text"&&xs(N,A.on)<1.5?"other":_==="accent"?"on-accent":_==="other"||J5(_)?"other":kr(N)&&!P$(N)?b(N)?_==="inverse"?"inverse-accent":"accent":Df(N)??"other":_==="inverse"?O(A,j)?"on-inverse":"on-inverse-muted":A.prop==="line"?xs(N,A.on)>=7?"text":"border":O(A,M)?"text":"muted"};for(const A of e)Ru(A.prop)||i.set(A.key,$(A));return i}const J5=e=>e==="success"||e==="warning"||e==="danger"||e==="info";function Ck(e){const t=e.replace(/-\d+$/,"");return sk.includes(t)?t:"other"}function d0e(e,t){const n=new Map;for(const d of e){const f=`${t.get(d.key)??"other"} ${d.value}`;n.set(f,[...n.get(f)??[],d])}const s=(d,f)=>f.reduce((h,g)=>h+g.count*(d==="accent"&&Ru(g.prop)?3:1),0),o=new Map,r=new Map,i=[],l=[...n].sort((d,f)=>{const h=d[0].split(" ")[0],g=f[0].split(" ")[0];return s(g,f[1])-s(h,d[1])||(d[0]<f[0]?-1:1)});for(const[d,f]of l){const h=d.split(" ")[0],g=(o.get(h)??0)+1;o.set(h,g);const y=g===1?h:`${h}-${g}`;i.push({id:y,role:h,value:f[0].value,count:f.reduce((b,v)=>b+v.count,0)});for(const b of f)r.set(b.key,y)}const u=new Map;for(const d of e)Ru(d.prop)&&!u.has(d.value)&&u.set(d.value,r.get(d.key));for(const d of i){const f=new Map;for(const g of e){if(r.get(g.key)!==d.id||Ru(g.prop))continue;const y=u.get(g.on);y&&f.set(y,(f.get(y)??0)+g.count)}const h=[...f].sort((g,y)=>y[1]-g[1])[0];h&&(d.on=h[0])}return i.sort((d,f)=>sk.indexOf(d.role)-sk.indexOf(f.role)||d.id.length-f.id.length||(d.id<f.id?-1:1)),{slots:i,assign:r}}function wH(e){return e.kind==="text"?e.tag!=="p"||parseFloat(e.style["font-size"]??"")>=56:e.kind==="textbox"?e.blocks[0]?.kind==="text"&&e.blocks[0].tag!=="p":!1}function ui(e){return e?(Ha(e)[0]??"").toLowerCase():""}function f0e(e,t){const n=(s,o)=>{for(const r of s){const i=r.style["font-family"],l=i?ui(i):o;r.kind==="box"?n(r.children,l):(r.kind==="text"||r.kind==="textbox"||r.kind==="list"||r.kind==="table")&&t(r,l,wH(r))}};n(e.children,ui(e.style["font-family"]))}function h0e(e){const t=new Map,n=new Map;for(const r of e)f0e(r,(i,l,u)=>{const d=u?t:n;d.set(l,(d.get(l)??0)+1)});const s=r=>[...r].sort((i,l)=>l[1]-i[1])[0]?.[0],o=s(n)??s(t)??"";return{heading:s(t)??o,body:o}}function SH(e,t){const n=l0e(e.flatMap(l=>a0e(l))),s=c0e(n),o=new Set(n.map(l=>l.value)).size,{slots:r,assign:i}=o>L0?{slots:[],assign:new Map}:d0e(n,u0e(n,s,t));return{ground:s,dark:k0(s),slots:r,assign:i,uses:n,distinct:o,over:o>L0,...h0e(e)}}const Ta="",kH=2,ju=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function e_(e){if(!ju(e)||typeof e.look!="string"||!ju(e.colors))return null;const t={};for(const[s,o]of Object.entries(e.colors))typeof o=="string"&&/^#[0-9a-f]{6}$/.test(o)&&(t[s]=o);const n={look:e.look,colors:t};return typeof e.title=="string"&&(n.title=e.title),typeof e.heading=="string"&&(n.heading=e.heading),typeof e.body=="string"&&(n.body=e.body),ju(e.on)&&(n.on=Object.fromEntries(Object.entries(e.on).filter(s=>typeof s[1]=="string"))),n}function HC(e){const t=e.style;if(!ju(t)||!ju(t.theme))return null;const n=e_(t.theme.original);if(!n)return null;const s=Array.isArray(t.theme.recent)?t.theme.recent.map(e_).filter(o=>o!==null).slice(0,kH):[];return{original:n,recent:s}}function p0e(e,t){const n=ju(e.style)?e.style:{};return{...e,style:{...n,theme:t}}}function t_(e){return e?.recent[0]?.look??Ta}function m0e(e,t,n){const s=e?.recent??[],o=[n,...s.filter(r=>r.look!==n.look)].slice(0,kH);return{original:e?.original??t,recent:o}}function g0e(e,t){const n=new Set([e.original,...e.recent].flatMap(r=>Object.values(r.colors)));let s=0,o=0;for(const r of t)o+=r.count,n.has(r.value)&&(s+=r.count);return o?s/o:1}function y0e(e,t,n){const s={},o={};for(const r of e)s[r.id]=r.value,r.on&&(o[r.id]=r.on);return{look:Ta,title:"Original look",colors:s,on:o,...t!==void 0?{heading:t}:{},...n!==void 0?{body:n}:{}}}function b0e(e){return Object.entries(e.colors).map(([t,n])=>({id:t,value:n,...e.on?.[t]?{on:e.on[t]}:{}}))}const x0e={text:4.5,"on-accent":4.5,"on-inverse":4.5,muted:3,"on-inverse-muted":3,"inverse-accent":3,accent:3,success:3,warning:3,danger:3,info:3},v0e=(e,t)=>[...t].sort((n,s)=>xs(s,e)-xs(n,e))[0];function w0e(e,t){const n=(h,g=0)=>nC(t,h,g),s=n("background")??(t.dark?"#121212":"#ffffff"),o=n("text")??I$(t.dark?"#f2f2f2":"#1a1a1a",s,7),r=t.colors.filter(h=>h.role==="other"&&kr(h.value)).map(h=>h.value),i=[...t.colors.filter(h=>h.role==="accent").sort((h,g)=>h.rank-g.rank).map(h=>h.value),...r],l=i[0]??o,u=n("inverse")??o,d=n("on-inverse")??s,f={};for(const h of e){const g=Ck(h.id),y=Number(/-(\d+)$/.exec(h.id)?.[1]??1);let b;switch(g){case"background":b=y===1?s:n("surface",y-2)??Kc(s,o,.04*(y-1));break;case"surface":b=n("surface",y-1)??Kc(s,o,.05*y);break;case"text":b=n("text",y-1)??o;break;case"muted":b=n("muted",y-1)??n("muted")??Kc(o,s,.4);break;case"border":b=n("border",y-1)??n("border")??Kc(s,o,.18);break;case"accent":b=i[y-1]??(y===1?l:kr(h.value)?h.value:l);break;case"accent-soft":b=n("accent-soft",y-1)??Kc(s,l,.14);break;case"on-accent":b=n("on-accent")??v0e(l,[s,o,"#ffffff","#000000"]);break;case"inverse":b=u;break;case"on-inverse":b=d;break;case"on-inverse-muted":b=Kc(d,u,.35);break;case"inverse-accent":b=xs(l,u)>=3?l:d;break;case"success":case"warning":case"danger":case"info":b=n(g)??h.value;break;default:b=h.value}f[h.id]=b}for(const h of e){const g=x0e[Ck(h.id)],y=h.on?f[h.on]:void 0;g&&y&&f[h.id]&&(f[h.id]=I$(f[h.id],y,g))}return f}const S0e=new Set(["background","surface","accent","accent-soft","inverse","border","success","warning","danger","info","other"]),k0e=new Set(["text","muted","border","accent","on-accent","on-inverse","on-inverse-muted","inverse-accent","success","warning","danger","info","other"]),E0e=(e,t)=>(e==="ground"||e==="fill"?S0e:k0e).has(t);function EH(e,t,n){for(let s=0;s<t.length;s++){const o=t[s],r=Object.entries(o.colors).filter(([i,l])=>l===e.value&&E0e(e.prop,Ck(i)));if(r.length){if(r.length>1&&n){const i=new Set(Object.entries(o.colors).filter(([,u])=>u===e.on).map(([u])=>u)),l=r.find(([u])=>n[u]!==void 0&&i.has(n[u]));if(l)return{slot:l[0],look:s}}return{slot:r[0][0],look:s}}}return null}function C0e(e,t){return BC(e,(n,s)=>{const o=t.assign?.get(vH(n))??EH(n,t.from,t.on)?.slot;if(!o)return;const r=t.to[o];if(!(!r||r===n.value))return Cae(r,s)})}function T0e(e,t,n){let s=0;const o=t[0];return o?(BC(e,r=>{const i=EH(r,t,n);i&&i.look>0&&o.colors[i.slot]&&o.colors[i.slot]!==r.value&&s++}),s):0}const n_=e=>e.kind==="text"||e.kind==="textbox"||e.kind==="list"||e.kind==="table";function s_(e,t){if((e["font-family"]??void 0)===(t||void 0))return e;const n={...e};return t?n["font-family"]=t:delete n["font-family"],n}function M0e(e,t){const{heading:n,body:s}=t;if(!n&&!s)return e;const o=d=>s&&ui(d)===s.from&&(d||s.from==="")?s.to||void 0:d,r=(d,f,h)=>{let g=null;return d.forEach((y,b)=>{const v=y.style["font-family"],w=v??f,S=n_(y)&&wH(y);let C=v;v&&!S&&(C=o(v));const k=C??h;if(n_(y)){const j=S?n&&ui(w)===n.from?n.to||void 0:w:s&&ui(w)===s.from?s.to||void 0:w;ui(k)!==ui(j)&&(j||!h)&&(C=j)}let M=y;if(C!==v&&(M={...y,style:s_(y.style,C)}),y.kind==="box"){const j=r(y.children,w,C??h);j!==y.children&&(M={...M,children:j})}M!==y&&(g??=[...d],g[b]=M)}),g??d},i=e.style["font-family"],l=s&&ui(i)===s.from?s.to||void 0:i,u=r(e.children,i,l);return l===i&&u===e.children?e:{...e,style:l===i?e.style:s_(e.style,l),children:u}}function o_(e,t){if(!t)return"";let n="";const s=r=>{!n&&ui(r["font-family"])===t&&(n=r["font-family"])},o=r=>{for(const i of r)s(i.style),i.kind==="box"&&o(i.children)};for(const r of e)if(s(r.style),o(r.children),n)break;return n||Dh([t])}function r_(e){const t=new Set,n=o=>{for(const r of Ha(o??""))t.add(r.toLowerCase())},s=o=>{for(const r of o)if(n(r.style["font-family"]),r.kind==="box"&&s(r.children),r.kind==="table")for(const i of r.rows)for(const l of i.cells)n(l.style["font-family"])};for(const o of e)n(o.style["font-family"]),s(o.children);return t}function i_(e,t,n,s){const o={},r=new Set;for(const[i,l]of Object.entries(e))n.has(l.family.toLowerCase())&&(o[i]=l,r.add(l.family.toLowerCase()));for(const[i,l]of t)r.has(l.family.toLowerCase())||(o[i]=l,r.add(l.family.toLowerCase()));return Object.keys(o).length>s?null:o}function R0e(e,t){if(!e)return"";const n=Iy(e,t);return n.ok?n.value:e}const D0=[{family:"Arial",generic:"sans-serif"},{family:"Georgia",generic:"serif"},{family:"Times New Roman",generic:"serif"},{family:"Courier New",generic:"monospace"},{family:"Verdana",generic:"sans-serif"},{family:"Tahoma",generic:"sans-serif"},{family:"Trebuchet MS",generic:"sans-serif"}],Cb=[{family:"Inter",generic:"sans-serif",wght:[100,900],italic:!0},{family:"Roboto",generic:"sans-serif",weights:[400,500,700],wght:[100,900],italic:!0},{family:"Open Sans",generic:"sans-serif",wght:[300,800],italic:!0},{family:"Lato",generic:"sans-serif",weights:[400,700],statics:[100,300,400,700,900],italic:!0},{family:"Montserrat",generic:"sans-serif",wght:[100,900],italic:!0},{family:"Poppins",generic:"sans-serif",statics:[100,200,300,400,500,600,700,800,900],italic:!0},{family:"Raleway",generic:"sans-serif",wght:[100,900],italic:!0},{family:"Nunito",generic:"sans-serif",wght:[200,1e3],italic:!0},{family:"Playfair Display",generic:"serif",wght:[400,900],italic:!0},{family:"Merriweather",generic:"serif",weights:[400,700],wght:[300,900],italic:!0},{family:"Work Sans",generic:"sans-serif",wght:[100,900],italic:!0},{family:"DM Sans",generic:"sans-serif",wght:[100,1e3],italic:!0},{family:"Manrope",generic:"sans-serif",wght:[200,800],italic:!1},{family:"Space Grotesk",generic:"sans-serif",wght:[300,700],italic:!1},{family:"Lora",generic:"serif",wght:[400,700],italic:!0},{family:"Bebas Neue",generic:"sans-serif",statics:[400],italic:!1},{family:"Caveat",generic:"sans-serif",wght:[400,700],italic:!1}],Tk=[{key:"sans-serif",label:"Sans-serif",css:"sans-serif"},{key:"serif",label:"Serif",css:"serif"},{key:"monospace",label:"Monospace",css:"monospace"},{key:"helvetica",label:"Helvetica",css:Dh(["Helvetica","Arial","sans-serif"])}],uh=e=>e.trim().toLowerCase();function Gu(e){return Cb.find(t=>uh(t.family)===uh(e))}function Tb(e){return D0.find(t=>uh(t.family)===uh(e))}function CH(e){return`https://fonts.googleapis.com/css2?family=${e.family.replace(/ +/g,"+")}:wght@${(e.weights??[400,500,600,700]).join(";")}&display=swap`}function TH(e){return{family:e.family,href:CH(e)}}function og(e,t=Tb(e)?.generic??Gu(e)?.generic??"sans-serif"){return Dh([e,t])}function dh(e){return e?Ha(e)[0]??null:null}function j0e(e=document){for(const t of Cb){const n=CH(t);if(e.head.querySelector(`link[href="${CSS.escape(n)}"]`))continue;const s=e.createElement("link");s.rel="stylesheet",s.href=n,e.head.appendChild(s)}}const a_=[100,200,300,400,500,600,700,800,900],A0e={100:"Thin",200:"Extra light",300:"Light",400:"Regular",500:"Medium",600:"Semibold",700:"Bold",800:"Extra bold",900:"Black"};function Wu(e){return Math.min(900,Math.max(100,Math.round(e/100)*100))}function l_({weight:e,italic:t}){const n=A0e[Wu(e)]??String(e);return t?Wu(e)===400?"Italic":`${n} italic`:n}function c_({weight:e,italic:t}){return`${Wu(e)}${t?"i":""}`}function O0e(e){const t=/^(\d{3})(i?)$/.exec(e);return t?{weight:Number(t[1]),italic:t[2]==="i"}:null}const P1=(e,t)=>e.flatMap(n=>t?[{weight:n,italic:!1},{weight:n,italic:!0}]:[{weight:n,italic:!1}]);function N0e(e){const t=e?Gu(e):void 0;if(t){const s=t.wght?a_.filter(o=>o>=t.wght[0]&&o<=t.wght[1]):[...t.statics??[400]];return P1(s,t.italic)}const n=e?uh(e):"";return Tb(n)||n==="helvetica"||n==="helvetica neue"?P1([400,700],!0):P1(a_,!0)}function $0e(e,t){const n=N0e(e);return t&&!n.some(s=>s.weight===Wu(t.weight)&&s.italic===t.italic)&&n.push({weight:Wu(t.weight),italic:t.italic}),n.sort((s,o)=>s.weight-o.weight||Number(s.italic)-Number(o.italic))}const _0e=(e,t)=>`${e}/${t}`;function MH(e){const t=e.indexOf("/");return t<0?{namespace:e,theme:""}:{namespace:e.slice(0,t),theme:e.slice(t+1)}}function L0e(e){const t=n=>nC(e,n);return[t("background")??"#ffffff",t("text")??"#1a1a1a",t("accent")??t("text")??"#1a1a1a",t("surface")??t("background")??"#ffffff",t("muted")??"#777777"]}function D0e(e,t){const n=[t];for(const s of e){const o=s.look.themes;for(const r of o)n.push({id:_0e(s.namespace,r.id),title:s.title,...o.length>1?{subtitle:r.name}:{},swatches:L0e(r),...s.look.heading?{heading:s.look.heading.family}:{},...s.look.body?{body:s.look.body.family}:{}})}return n}function RH(e){return e.subtitle?`${e.title} · ${e.subtitle}`:e.title}function FC(){const e=ae.getState();return fn(e).map(t=>({id:t,entry:e.slides[t]})).filter(t=>!!(t.entry&&!t.entry.held)).map(({id:t,entry:n})=>({id:t,slide:n.slide}))}function jH(e,t,n){let s=t;const o=t_(s),r=o?n.find(u=>u.namespace===MH(o).namespace):void 0,i=SH(e.map(u=>u.slide),r?.look);s&&g0e(s,i.uses)<.5&&(s=null);const l=[];if(s?.recent[0]){const u=[s.recent[0],...s.recent.slice(1),s.original];for(const{id:d,slide:f}of e)T0e(f,u,s.original.on)>0&&l.push(d)}return{analysis:i,memory:s,current:s?t_(s):Ta,strays:l}}const AH=/^(sans-serif|serif|monospace|system-ui|cursive|fantasy|ui-sans-serif|ui-serif|ui-monospace)$/i;function z0e(e,t,n){if(!e||AH.test(e)||Tb(e))return"builtin";const s=e.toLowerCase(),o=Object.values(t).find(i=>i.family.toLowerCase()===s);if(o)return o;for(const i of n)for(const l of[i.look.heading,i.look.body]){if(!l?.files?.length||l.family.toLowerCase()!==s)continue;const u=l.files.find(d=>d.weight==="400"&&d.style==="normal")??l.files.find(d=>d.style==="normal")??l.files[0];return{family:l.family,src:`${jte}${i.namespace}/${u.file}`}}const r=Gu(e);return r?TH(r):null}function P0e(e,t){const n=t?Ha(t).at(-1)?.toLowerCase():void 0;return n==="serif"||n==="monospace"||n==="sans-serif"?n:Tb(e)?.generic??Gu(e)?.generic??"sans-serif"}function OH(e,t){return e?AH.test(e)?e.toLowerCase():Dh([e,P0e(e,t)]):""}function I0e(e,t){const n=[],s=new Set,o=(r,i)=>{!r||s.has(r.toLowerCase())||(s.add(r.toLowerCase()),n.push({family:r,group:i}))};for(const r of Object.values(e))o(r.family,"In this deck");for(const r of t)o(r.look.heading?.family,r.title),o(r.look.body?.family,r.title);for(const r of[...D0,...Cb].sort((i,l)=>i.family.localeCompare(l.family)))o(r.family,"More fonts");return n}function NH(e,t,n,s){const o={wanted:[],missing:[]};for(const r of["heading","body"]){const i=t[r];if(i===void 0)continue;const l=Ha(i)[0]??"";if((l.toLowerCase()||"")===e[r])continue;const u=z0e(l,n,s);if(u===null){o.missing.push(l);continue}u!=="builtin"&&o.wanted.push([OI(u.family),u]),o[r]={from:e[r],to:i}}return o}function UC(e,t,n){const s=ae.getState(),o=u=>{const d={},f=[],h=new Set([...Object.values(s.index.faces),...n.wanted.map(([,v])=>v)].map(v=>v.family.toLowerCase())),g=v=>v?{...v,to:R0e(v.to,h)}:void 0,y=u?g(n.heading):void 0,b=u?g(n.body):void 0;for(const{id:v,slide:w}of e){let S=t?C0e(w,t):w;S=M0e(S,{heading:y,body:b}),S!==w&&(d[v]=S),f.push(S)}for(const v of Object.values(s.slides))v.held&&f.push(v.slide);return{slides:d,all:f}};let r=o(!0),i=i_(s.index.faces,n.wanted,r_(r.all),ve.faces),l=!1;return i||(l=!0,r=o(!1),i=i_(s.index.faces,[],r_(r.all),ve.faces)??s.index.faces),{slides:r.slides,faces:i,fontsDropped:l}}function Mk(e,t){t?tt.add({title:"Fonts unchanged",description:`A presentation carries up to ${ve.faces} typefaces, and the new ones would not fit.`}):e.missing.length&&tt.add({title:"Some fonts were kept",description:`${e.missing.join(", ")} can't be carried by this deck, so the current fonts stay.`})}function B0e(e,t){const{namespace:n,theme:s}=MH(e),o=t.find(i=>i.namespace===n),r=o?.look.themes.find(i=>i.id===s)??(s===""?o?.look.themes[0]:void 0);return o&&r?{system:o,theme:r}:null}const u_=e=>e?OH(e.family,e.stack):void 0;function H0e(e){const t=ae.getState();if(t.readOnly||t.status!=="ready")return!1;const n=ac.getState().systems,s=FC(),o=jH(s,HC(t.index),n),{analysis:r}=o;let i=o.memory;if(!i&&r.over)return tt.add({title:"This deck can't be restyled automatically",description:`It uses ${r.distinct} colors (at most ${L0}). Ask the agent to redo its look instead.`}),!1;const l=s.map(M=>M.slide),u=i?.original??y0e(r.slots,o_(l,r.heading),o_(l,r.body)),d=i?[...i.recent,i.original]:[u];let f,h,g;if(e===Ta){if(!i)return!1;f=u.colors,h={heading:u.heading,body:u.body},g="Original look"}else{const M=B0e(e,n);if(!M)return!1;f=w0e(i?b0e(u):r.slots,M.theme),h={heading:u_(M.system.look.heading),body:u_(M.system.look.body)},g=RH({title:M.system.title,...M.system.look.themes.length>1?{subtitle:M.theme.name}:{}})}const y=NH(r,h,t.index.faces,n),b={from:d,to:f,...u.on?{on:u.on}:{},...i?{}:{assign:r.assign}},v=UC(s,b,y),w={look:e,title:g,colors:f,...h.heading!==void 0?{heading:h.heading}:{},...h.body!==void 0?{body:h.body}:{}},{on:S,...C}=u;i=m0e(i,u,e===Ta?C:w);const k=p0e({...t.index,faces:v.faces??t.index.faces},i);return t.apply(`Theme: ${g}`,{slides:v.slides,index:k}),Mk(y,v.fontsDropped),!0}function F0e(){const e=ae.getState();if(e.readOnly)return;const t=HC(e.index),n=t?.recent[0];if(!t||!n)return;const s=[n,...t.recent.slice(1),t.original],o=UC(FC(),{from:s,to:n.colors,...t.original.on?{on:t.original.on}:{}},{wanted:[]});Object.keys(o.slides).length&&e.apply(`Theme: ${n.title??"look"} on all slides`,{slides:o.slides})}function d_(e,t){const n=ae.getState();if(n.readOnly)return;const s=ac.getState().systems,o=FC(),r=SH(o.map(f=>f.slide)),i=OH(t),l=NH(r,{[e]:i},n.index.faces,s);if(!l.heading&&!l.body){Mk(l,!1);return}const u=UC(o,null,l),d=u.faces&&u.faces!==n.index.faces?{...n.index,faces:u.faces}:void 0;n.apply(e==="heading"?"Heading font":"Body font",{slides:u.slides,...d?{index:d}:{}}),Mk(l,u.fontsDropped)}function U0e({colors:e,className:t}){return p.jsx("span",{className:Ie("flex shrink-0 overflow-hidden rounded-[4px] shadow-[0_0_0_1px_var(--chrome-line)]",t),"aria-hidden":!0,children:e.map((n,s)=>p.jsx("span",{className:"h-full w-3",style:{background:n}},s))})}function V0e({option:e,current:t,onPick:n,tabStop:s}){const[o,r,i]=e.swatches,l=[e.heading,e.body].filter((u,d,f)=>!!u&&f.indexOf(u)===d).join(" · ");return p.jsxs("button",{type:"button",role:"option","aria-selected":t,"data-look":e.id,tabIndex:s?0:-1,onClick:n,className:Ie("flex w-full min-w-0 items-center gap-2.5 rounded-[8px] p-1.5 text-left outline-none hover:bg-chrome-hover focus-visible:shadow-[inset_0_0_0_1px_var(--color-chrome-accent)]",t&&"bg-chrome-hover"),children:[p.jsxs("span",{className:"relative flex h-9 w-16 shrink-0 flex-col justify-center gap-1 overflow-hidden rounded-[4px] px-1.5 shadow-[0_0_0_1px_var(--chrome-line)]",style:{background:o},"aria-hidden":!0,children:[p.jsx("span",{className:"h-1.5 w-8 rounded-full",style:{background:r}}),p.jsx("span",{className:"h-1 w-10 rounded-full opacity-60",style:{background:r}}),p.jsx("span",{className:"absolute bottom-1 right-1.5 size-2.5 rounded-full",style:{background:i}})]}),p.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[p.jsx("span",{className:"truncate text-[13px] text-chrome-fg",children:e.title}),e.subtitle||l?p.jsx("span",{className:"truncate text-[11px] text-chrome-muted",children:[e.subtitle,l].filter(Boolean).join(" — ")}):null]}),t?p.jsx(Ni,{className:"size-4 shrink-0 text-chrome-accent",strokeWidth:2}):null]})}const I1="\0default";function q0e(){const e=ae(N=>N.slides),t=ae(N=>N.index),n=ae(N=>N.readOnly),s=ac(N=>N.systems),o=Rt(N=>N.status),r=T.useRef(null),i=T.useMemo(()=>fn({index:t,slides:e}).map(N=>({id:N,entry:e[N]})).filter(N=>!!(N.entry&&!N.entry.held)).map(({id:N,entry:_})=>({id:N,slide:_.slide})),[t,e]),l=T.useMemo(()=>HC(t),[t]),u=T.useMemo(()=>jH(i,l,s),[i,l,s]),{analysis:d,memory:f,current:h,strays:g}=u,y=T.useMemo(()=>{const N=f?.original.colors??Object.fromEntries(d.slots.map(D=>[D.id,D.value])),_=(...D)=>D.map(P=>N[P]).find(Boolean)??"#ffffff";return{id:Ta,title:"Original look",subtitle:"How the deck looked before",swatches:[_("background","surface"),_("text","muted","on-inverse"),_("accent","text"),_("surface","background"),_("muted","text")]}},[f,d]),b=T.useMemo(()=>D0e(s,y),[s,y]),v=N=>{const _=b.find(D=>D.id===N);return _?RH(_):f?.recent.find(D=>D.look===N)?.title??"an earlier look"},w=N=>{n||N!==h&&(N===Ta&&!f||H0e(N))},S=N=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(N.key))return;const _=[...r.current?.querySelectorAll("[data-look]")??[]],D=_.indexOf(document.activeElement),P=N.key==="Home"?0:N.key==="End"?_.length-1:Math.max(0,Math.min(_.length-1,(D<0?0:D)+(N.key==="ArrowDown"?1:-1))),L=_[P];L&&(N.preventDefault(),L.focus(),w(L.dataset.look??""))},C=T.useMemo(()=>I0e(t.faces,s),[t.faces,s]),k=T.useMemo(()=>[{value:I1,label:"Default (system font)",group:"Default"},...C.map(N=>({value:N.family.toLowerCase(),label:N.family,group:N.group,style:{fontFamily:`"${N.family}"`}}))],[C]),M=N=>N===""?I1:N,j=N=>N&&!k.some(_=>_.value===N)?[{value:N,label:N,group:"In this deck",style:{fontFamily:`"${N}"`}},...k]:k,O=N=>N===I1?"":C.find(_=>_.family.toLowerCase()===N)?.family??N,$=f?.recent.slice(1).filter(N=>N.look!==h)??[],A=n;return p.jsxs("div",{className:"flex min-w-0 flex-col",children:[p.jsxs(ss,{title:"Look",children:[s.length===0?p.jsxs(p.Fragment,{children:[p.jsx(di,{children:"Install a design system in this deck to restyle every slide from its colors and fonts."}),o.available&&!n?p.jsx("div",{className:"px-4 py-1",children:p.jsxs(Pl,{variant:"secondary",icon:p.jsx(mL,{}),onClick:()=>{t6("Install a design system in this deck (copy it under project/ds/ and list it in deck.json designSystems) so I can restyle the slides from the Theme panel.")},children:["Ask ",o.name," to add one"]})}):null]}):null,!f&&d.over?p.jsxs(di,{children:["This deck uses ",d.distinct," colors (at most ",L0," can be restyled automatically). Ask ",o.name," to redo its look instead."]}):null,p.jsxs("div",{ref:r,role:"listbox","aria-label":"Looks","aria-disabled":A||void 0,onKeyDown:S,className:Ie("flex flex-col gap-0.5 px-2.5",A&&"pointer-events-none opacity-50"),children:[b.filter(N=>N.id!==Ta||f).map(N=>p.jsx(V0e,{option:N,current:N.id===h,tabStop:N.id===h||!f&&N===b[1],onPick:()=>w(N.id)},N.id||"original")),!f&&s.length>0?p.jsx(di,{className:"px-1.5",children:"The deck wears its own look. Pick one to restyle every slide; Original look brings it back."}):null]}),$.length?p.jsx(Be,{label:"Recent",children:$.map(N=>p.jsxs(Pl,{variant:"ghost",className:"min-w-0 truncate px-1.5",disabled:A,onClick:()=>w(N.look),title:`Switch back to ${v(N.look)}`,children:[p.jsx(U0e,{className:"h-3",colors:[N.colors.background,N.colors.text,N.colors.accent].filter(_=>!!_)}),p.jsx("span",{className:"truncate",children:v(N.look)})]},N.look||"original"))}):null,g.length&&f?.recent[0]?p.jsxs("div",{className:"mx-4 mt-1 flex flex-col gap-1.5 rounded-[8px] bg-chrome-field p-2.5",children:[p.jsxs("span",{className:"text-[12px] leading-[1.45] text-chrome-fg",children:[g.length===1?"1 slide still uses":`${g.length} slides still use`," colors from an earlier look. Make ",g.length===1?"it":"them"," ",v(h)," too?"]}),p.jsx(Pl,{variant:"secondary",icon:p.jsx(ED,{}),disabled:A,onClick:F0e,className:"self-start",children:"Apply to all slides"})]}):null]}),p.jsxs(ss,{title:"Fonts",children:[p.jsx(Be,{label:"Headings",tip:"The typeface of every heading in the deck",children:p.jsx(Ss,{"aria-label":"Heading font",value:M(d.heading),options:j(d.heading),disabled:A,onChange:N=>d_("heading",O(N))})}),p.jsx(Be,{label:"Body",tip:"The typeface of body text across the deck",children:p.jsx(Ss,{"aria-label":"Body font",value:M(d.body),options:j(d.body),disabled:A,onChange:N=>d_("body",O(N))})}),p.jsx(di,{children:"A presentation carries up to four typefaces; changing a font is one undo step."})]}),d.slots.length?p.jsxs(ss,{title:"Palette",collapsible:!0,children:[p.jsx("div",{className:"flex flex-col gap-0.5 px-4",children:d.slots.slice(0,24).map(N=>p.jsxs("div",{className:"flex min-h-6 items-center gap-2 text-[12px]",children:[p.jsx("span",{className:"size-4 shrink-0 rounded-[4px] shadow-[0_0_0_1px_var(--chrome-line)]",style:{background:N.value},"aria-hidden":!0}),p.jsxs("span",{className:"min-w-0 flex-1 truncate text-chrome-fg",children:[Tae[N.role],/-\d+$/.test(N.id)?` ${N.id.split("-").at(-1)}`:""]}),p.jsx("span",{className:"font-mono text-[11px] text-chrome-muted",children:N.value})]},N.id))}),p.jsx(di,{children:"How the deck’s colors were read. A look maps each role to the design system’s matching color."})]}):null]})}function VC({title:e,children:t}){return p.jsxs("div",{className:"flex min-w-0 flex-col",children:[p.jsx("div",{className:"px-4 pb-1 pt-2 text-[12px] font-[520] text-chrome-secondary",children:e}),t]})}function G0e({target:e}){return p.jsxs(ss,{title:"Advanced",collapsible:!0,children:[p.jsx(W0e,{target:e}),p.jsx(Z0e,{target:e}),p.jsx(eye,{target:e})]})}const f_=[{value:"auto",label:"Auto"},{value:"start",label:"Start"},{value:"center",label:"Center"},{value:"end",label:"End"},{value:"stretch",label:"Stretch"}];function $H(e){const t=e.style.flex?.trim();if(t==="none")return{grow:0,shrink:0,basis:"auto"};if(t==="auto")return{grow:1,shrink:1,basis:"auto"};if(t){const[n,s,o]=t.split(/\s+/),r=s!==void 0&&/^[\d.]+$/.test(s);return{grow:Number(n)||0,shrink:r?Number(s):1,basis:(r?o:s)??"0%"}}return{grow:Number(e.style["flex-grow"]??0),shrink:Number(e.style["flex-shrink"]??1),basis:e.style["flex-basis"]??"auto"}}function B1(e,t,n){yo(e,t,s=>{if(!s)return{};const o=n($H(s));return{flex:o.grow===0&&o.shrink===1&&o.basis==="auto"?void 0:`${o.grow} ${o.shrink} ${o.basis}`,"flex-grow":void 0,"flex-shrink":void 0,"flex-basis":void 0}})}function W0e({target:e}){if(e.nodes.length===0||e.nodes.some(f=>Kt(f)||f.kind==="connector"))return null;const t=e.nodes[0],n=e.paths[0],o=((n.length>1?Uy(e.slide,n)?.style:e.slide.style)??{}).display==="grid",r=Ht(e,"align-self"),i=Ht(e,"justify-self"),l=$H(t),u=/^([\d.]+)px$/.exec(l.basis),d=f=>f.mixed?null:f.value?.replace(/^flex-/,"")??"auto";return p.jsxs(VC,{title:"Sizing",children:[p.jsx(Be,{label:"Align self",children:p.jsx(Ss,{"aria-label":"Align self",value:d(r),placeholder:"Mixed",options:f_.map(f=>({...f})),onChange:f=>ht(e,"align-self",f==="auto"?"":f,"Align self")})}),o?p.jsx(Be,{label:"Justify self",children:p.jsx(Ss,{"aria-label":"Justify self",value:d(i),placeholder:"Mixed",options:f_.map(f=>({...f})),onChange:f=>ht(e,"justify-self",f==="auto"?"":f,"Justify self")})}):p.jsxs(p.Fragment,{children:[p.jsx(Be,{label:"Grow",tip:"How much of the group's spare room this child takes",children:p.jsx(St,{"aria-label":"Grow",value:l.grow,min:0,max:1e3,onCommit:f=>B1(e,"Grow",h=>({...h,grow:f??0}))})}),p.jsx(Be,{label:"Shrink",tip:"How much this child gives up when the group runs out of room",children:p.jsx(St,{"aria-label":"Shrink",value:l.shrink,min:0,max:1e3,onCommit:f=>B1(e,"Shrink",h=>({...h,shrink:f??1}))})}),p.jsx(Be,{label:"Basis",tip:"The size this child starts from before growing or shrinking",children:p.jsx(St,{"aria-label":"Basis",value:u?Number(u[1]):null,placeholder:l.basis==="0%"?"0":"Auto",unit:"px",min:0,max:4096,step:8,onCommit:f=>B1(e,"Basis",h=>({...h,basis:f===null?"auto":`${f}px`}))})})]}),p.jsx(Be,{label:"Aspect",children:p.jsx(zC,{target:e,property:"aspect-ratio",label:"Aspect ratio",placeholder:"Auto"})})]})}const Rk={blur:"Blur",brightness:"Brightness",contrast:"Contrast",saturate:"Saturate",grayscale:"Grayscale",sepia:"Sepia",invert:"Invert","hue-rotate":"Hue"},h_={blur:0,brightness:1,contrast:1,saturate:1,grayscale:0,sepia:0,invert:0,"hue-rotate":0},_H=Object.keys(ql);function jk(e,t){return ql[e].unit===""?Math.round(t*100):t}function LH(e){const t=ql[e].unit;return t===""?"%":t==="deg"?"°":t}function Y0e(e){const t=_H.filter(n=>e[n]!==void 0).map(n=>`${Rk[n]} ${jk(n,e[n])}${LH(n)}`);return t.length?t.join(" · "):"None"}const K0e=[{value:"default",label:"Default"},{value:"normal",label:"Normal"},{value:"multiply",label:"Multiply"},{value:"screen",label:"Screen"},{value:"overlay",label:"Overlay"},{value:"darken",label:"Darken"},{value:"lighten",label:"Lighten"}],X0e=new Set(["box","text","list","textbox","image","shape"]);function Z0e({target:e}){if(e.nodes.length===0)return null;const t=e.nodes.every(o=>X0e.has(o.kind)&&o.kind!=="rule"),n=e.nodes.every(o=>o.kind!=="connector"&&o.kind!=="shape");if(!t&&!n)return null;const s=Ht(e,"mix-blend-mode");return p.jsxs(VC,{title:"Effects",children:[t?p.jsx(p_,{target:e,property:"filter",label:"Filter"}):null,t?p.jsx(p_,{target:e,property:"backdrop-filter",label:"Backdrop"}):null,n?p.jsx(J0e,{target:e}):null,t?p.jsx(Be,{label:"Blend",children:p.jsx(Ss,{"aria-label":"Blend mode",value:s.mixed?null:s.value??"default",placeholder:"Mixed",options:K0e.map(o=>({...o})),onChange:o=>ht(e,"mix-blend-mode",o==="default"?"":o,"Blend mode")})}):null]})}function p_({target:e,property:t,label:n}){const s=Ht(e,t),o=s.value&&!s.mixed?sE(s.value):null,r=o?.ok?o.value:{},i=t==="filter"?"Filter":"Background filter",l=(u,d)=>{const f={...r},h=d===null?null:ql[u].unit===""?d/100:d;h===null||h===h_[u]?delete f[u]:f[u]=h,ht(e,t,oE(f),i,`${t}-${u}`)};return p.jsx(Be,{label:n,onReset:s.value?()=>ht(e,t,"",i):void 0,resetLabel:`Remove ${i.toLowerCase()}`,children:p.jsx(DC,{title:i,text:s.mixed?"Mixed":Y0e(r),children:_H.map(u=>{const d=ql[u],f=d.unit===""?100:1;return p.jsx(Be,{label:Rk[u],children:p.jsx(St,{"aria-label":`${i} ${Rk[u].toLowerCase()}`,value:r[u]===void 0?null:jk(u,r[u]),placeholder:String(jk(u,h_[u])),unit:LH(u),min:d.min*f,max:d.max*f,step:u==="blur"?.5:1,onCommit:h=>l(u,h)})},u)})})})}function Q0e(e){const t=[];return(e.translateX!==void 0||e.translateY!==void 0)&&t.push(`Move ${e.translateX??0}, ${e.translateY??0}`),e.scale!==void 0&&t.push(`Scale ${Math.round(e.scale*100)}%`),e.rotate!==void 0&&t.push(`Rotate ${e.rotate}°`),(e.skewX!==void 0||e.skewY!==void 0)&&t.push(`Skew ${e.skewX??0}°, ${e.skewY??0}°`),t.length?t.join(" · "):"None"}function J0e({target:e}){const t=Ht(e,"transform"),n=t.value&&!t.mixed?oI(t.value):null,s=n?.ok?n.value:{},o=i=>{const l={...s,...i};for(const u of Object.keys(l)){const d=u==="scale"?1:0;(l[u]===void 0||l[u]===d)&&delete l[u]}ht(e,"transform",RS(l),"Transform","transform")},r=i=>typeof i=="number"?i:null;return p.jsx(Be,{label:"Transform",onReset:t.value?()=>ht(e,"transform","","Transform"):void 0,resetLabel:"Remove transform",children:p.jsxs(DC,{title:"Transform",text:t.mixed?"Mixed":Q0e(s),children:[p.jsxs(Be,{label:"Move",children:[p.jsx(St,{"aria-label":"Move x",label:"X",value:r(s.translateX),placeholder:s.translateX==="-50%"?"−50%":"0",steppers:!1,min:-4e3,max:4e3,onCommit:i=>o({translateX:i??0})}),p.jsx(St,{"aria-label":"Move y",label:"Y",value:r(s.translateY),placeholder:s.translateY==="-50%"?"−50%":"0",steppers:!1,min:-4e3,max:4e3,onCommit:i=>o({translateY:i??0})})]}),p.jsx(Be,{label:"Scale",children:p.jsx(St,{"aria-label":"Scale",value:s.scale===void 0?null:Math.round(s.scale*100),placeholder:"100",unit:"%",min:50,max:200,onCommit:i=>o({scale:(i??100)/100})})}),p.jsx(Be,{label:"Rotate",children:p.jsx(St,{"aria-label":"Rotate",value:s.rotate??null,placeholder:"0",unit:"°",min:-360,max:360,onCommit:i=>o({rotate:i??0})})}),p.jsxs(Be,{label:"Skew",children:[p.jsx(St,{"aria-label":"Skew x",label:"X",value:s.skewX??null,placeholder:"0",unit:"°",steppers:!1,min:-60,max:60,onCommit:i=>o({skewX:i??0})}),p.jsx(St,{"aria-label":"Skew y",label:"Y",value:s.skewY??null,placeholder:"0",unit:"°",steppers:!1,min:-60,max:60,onCommit:i=>o({skewY:i??0})})]})]})})}function eye({target:e}){const[t,n]=T.useState(null),s=T.useMemo(()=>{const r=e.nodes.length?e.nodes.map(l=>l.style):[e.slide.style],i=new Set;for(const l of r)for(const u of Object.keys(l))i.add(u);return n0.filter(l=>i.has(l))},[e]),o=n0.filter(r=>!s.includes(r));return p.jsxs(VC,{title:"CSS",children:[s.length===0?p.jsx("p",{className:"px-4 text-[12px] text-chrome-muted",children:"No declarations."}):null,p.jsx("div",{className:"flex flex-col gap-1 px-4",children:s.map(r=>p.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[p.jsx("span",{className:"w-28 shrink-0 truncate font-mono text-[11px] text-chrome-muted",title:r,children:r}),p.jsx(zC,{target:e,property:r}),p.jsx(Os,{label:`Remove ${r}`,icon:p.jsx(_i,{className:"size-3"}),onClick:()=>ht(e,r,"",`Remove ${r}`)})]},r))}),p.jsxs("div",{className:"flex min-w-0 items-center gap-1 px-4 pt-2",children:[p.jsx("div",{className:"w-28 shrink-0",children:p.jsx(Ss,{"aria-label":"Property to add",value:t,placeholder:"Add…",options:o.map(r=>({value:r,label:r})),onChange:n})}),t?p.jsx(_C,{autoFocus:!0,"aria-label":`${t} value`,className:"min-w-0 flex-1 font-mono text-xs",value:"",placeholder:"value",onCommit:r=>{r.trim()&&ht(e,t,r,t)&&n(null)}}):p.jsx(ds,{className:"size-3.5 text-chrome-muted"})]})]})}function tye({target:e}){const t=e.nodes.length===1?e.nodes[0]:null,n=e.paths[0],s=t?vo(t):null,o=i=>{s&&jn("Move",l=>th(l,n,{...s,...i}))},r=[["left","Align left",Wg],["center","Align centers",P3],["right","Align right",F3],["top","Align top",Y3],["middle","Align middles",D3],["bottom","Align bottom",B3]].map(([i,l,u])=>p.jsx(Os,{size:"sm",label:`${e.nodes.length>1?l:`${l} to slide`} (${IP}${p0[i]})`,icon:p.jsx(u,{className:"size-3.5"}),onClick:()=>IE(i)},i));return p.jsxs(ss,{title:"Size",children:[s&&t?p.jsxs(p.Fragment,{children:[p.jsx(Be,{label:"Width",children:p.jsx(St,{"aria-label":"Width",value:s.w,min:1,unit:"px",onCommit:i=>i!==null&&o({w:i})})}),p.jsx(Be,{label:"Height",children:p.jsx(St,{"aria-label":"Height",value:s.h,min:1,unit:"px",onCommit:i=>i!==null&&o({h:i})})}),p.jsxs(Be,{label:"Position",children:[p.jsx(St,{"aria-label":"X",label:"X",value:s.x,onCommit:i=>i!==null&&o({x:i})}),p.jsx(St,{"aria-label":"Y",label:"Y",value:s.y,onCommit:i=>i!==null&&o({y:i})})]}),p.jsx(Be,{label:"Rotation",children:p.jsx(St,{"aria-label":"Rotation",value:ki(t),unit:"°",min:-180,max:180,onCommit:i=>jn("Rotate",l=>SI(l,n,i??0))})})]}):null,p.jsx(Be,{label:"Align",children:p.jsx("div",{className:"flex flex-wrap items-center gap-0.5",children:r})})]})}function H1(e,t){const n=(t.length>1?Uy(e,t)?.style:e.style)??{};return{kind:n.display==="grid"?"grid":"stack",row:n["flex-direction"]==="row"||n["flex-direction"]==="row-reverse",alignItems:n["align-items"]??"stretch"}}function DH(e,t){return e.kind==="stack"&&e.row===(t==="w")}function zH(e,t){return e.kind==="grid"&&t==="w"?"justify-self":"align-self"}function m_(e,t,n){const s=e.style[n==="w"?"width":"height"];if(s&&s!=="auto"&&s!=="100%")return"fixed";if(s==="100%")return"fill";if(DH(t,n)){const r=e.style.flex??"";return/^[1-9]/.test(r)||Number(e.style["flex-grow"]??0)>0?"fill":"hug"}const o=e.style[zH(t,n)];return o?o==="stretch"?"fill":"hug":t.alignItems==="stretch"||t.alignItems==="normal"?"fill":"hug"}function nye(e,t,n,s,o){const r=n==="w"?"width":"height";if(DH(t,n))return s==="fill"?{[r]:void 0,flex:"1","flex-grow":void 0,"flex-basis":void 0}:s==="fixed"?{[r]:`${Math.round(o)}px`,flex:"none","flex-grow":void 0}:{[r]:void 0,flex:void 0,"flex-grow":void 0,"flex-basis":void 0};const i=zH(t,n);return s==="fill"?{[r]:void 0,[i]:"stretch"}:s==="fixed"?{[r]:`${Math.round(o)}px`,[i]:e.style[i]==="stretch"?void 0:e.style[i]}:{[r]:void 0,[i]:"start"}}function g_(e){const t=e?/span\s+(\d+)/.exec(e):null;return t?Number(t[1]):1}function PH(e){return document.querySelector(`[data-open-artifact-stage] [data-open-artifact-path="${e.join(".")}"]`)}function IH(e){if(e instanceof HTMLElement)return{w:e.offsetWidth,h:e.offsetHeight};const t=e.getBoundingClientRect();let n=e.parentElement;for(;n&&n.offsetWidth===0;)n=n.parentElement;const s=n&&n.getBoundingClientRect().width/n.offsetWidth||1;return{w:Math.round(t.width/s),h:Math.round(t.height/s)}}function sye(e){const t=PH(e);return t?IH(t):{w:240,h:120}}function oye(e){const t=e?e.join("."):null,n=ae(i=>i.revision),s=se(i=>i.textEdit!==null),[o,r]=T.useState(null);return T.useEffect(()=>{if(t===null)return;let i=null;const l=requestAnimationFrame(()=>{const u=PH(t.split(".").map(Number));if(!u)return r(null);const d=()=>{const{w:f,h}=IH(u);f===0&&h===0||r(g=>g&&g.w===f&&g.h===h?g:{w:f,h})};d(),i=new ResizeObserver(d),i.observe(u)});return()=>{cancelAnimationFrame(l),i?.disconnect()}},[t,n,s]),o}const rye=e=>`${e}: Hug sizes to the content, Fixed is an exact size, Fill takes the space the group gives it.`,y_=[{key:"min-width",label:"Min width"},{key:"max-width",label:"Max width"},{key:"min-height",label:"Min height"},{key:"max-height",label:"Max height"}];function iye({target:e}){const t=e.paths.map(y=>y.join(".")).join("|"),[n,s]=T.useState(new Set);T.useEffect(()=>s(new Set),[t]);const o=oye(e.nodes.length===1?e.paths[0]:null);if(e.nodes.length===0)return null;if(e.nodes.every(y=>Kt(y)&&y.kind!=="connector"))return p.jsx(tye,{target:e});if(e.nodes.some(y=>Kt(y)))return null;const r=e.paths[0],i=e.nodes[0],l=H1(e.slide,r),u=y=>n.has(y)||e.nodes.some(b=>b.style[y]!==void 0),d=(y,b,v)=>{jn("Size",w=>{let S=w;for(const C of e.paths){const k=Ye(S,C);if(!k)continue;const M=sye(C),j=nye(k,H1(S,C),y,b,v??(y==="w"?M.w:M.h));S=Bn(S,C,O=>({...O,style:lye(O.style,j)}))}return S})},f=y=>{const b=m_(i,l,y),v=y==="w"?"width":"height",w=y==="w"?"Width":"Height",C=(b==="fixed"?qu(i.style[v]):null)??(o?Math.round(y==="w"?o.w:o.h):null);return p.jsxs(Be,{label:w,tip:rye(w),children:[p.jsx(St,{"aria-label":w,value:e.nodes.length===1?C:null,placeholder:e.nodes.length===1?"Auto":"Mixed",min:1,max:4096,step:8,onCommit:k=>k!==null&&d(y,"fixed",k)}),p.jsx(Ss,{"aria-label":`${w} sizing`,className:"w-[76px] shrink-0",value:e.nodes.every((k,M)=>m_(k,H1(e.slide,e.paths[M]),y)===b)?b:null,placeholder:"Mixed",options:[{value:"hug",label:"Hug"},{value:"fixed",label:"Fixed"},{value:"fill",label:"Fill"}],onChange:k=>d(y,k)})]})},h=p.jsx(Js,{align:"end",tip:{label:"Add to Size"},trigger:p.jsx("button",{type:"button","aria-label":"Add to Size",className:"flex size-6 items-center justify-center rounded-[6px] text-chrome-secondary outline-none hover:bg-chrome-hover hover:text-chrome-fg focus-visible:ring-2 focus-visible:ring-chrome-accent",children:p.jsx(ds,{className:"size-4",strokeWidth:1.5})}),children:y_.map(({key:y,label:b})=>p.jsx(Et,{disabled:u(y),onSelect:()=>s(new Set([...n,y])),children:b},y))}),g=l.kind==="grid"?aye(e.slide,r):0;return p.jsxs(ss,{title:"Size",actions:h,children:[f("w"),f("h"),y_.filter(({key:y})=>u(y)).map(({key:y,label:b})=>{const v=Ht(e,y);return p.jsx(Be,{label:b,onReset:()=>{ht(e,y,"",b);const w=new Set(n);w.delete(y),s(w)},resetLabel:`Remove ${b.toLowerCase()}`,children:p.jsx(St,{"aria-label":b,value:v.mixed?null:qu(v.value),placeholder:v.mixed?"Mixed":y.startsWith("min")?"0":"—",unit:"px",min:y.startsWith("min")?0:1,max:4096,step:8,onCommit:w=>ht(e,y,w===null?"":`${w}px`,b)})},y)}),l.kind==="grid"?p.jsxs(p.Fragment,{children:[p.jsx(Be,{label:"Column span",tip:"Grid cells this child spans across (row-major auto-flow).",children:p.jsx(St,{"aria-label":"Column span",value:g_(i.style["grid-column"]),placeholder:"1",min:1,max:Math.max(1,g),onCommit:y=>ht(e,"grid-column",!y||y<=1?"":`span ${Math.round(y)}`,"Column span")})}),p.jsx(Be,{label:"Row span",children:p.jsx(St,{"aria-label":"Row span",value:g_(i.style["grid-row"]),placeholder:"1",min:1,max:12,onCommit:y=>ht(e,"grid-row",!y||y<=1?"":`span ${Math.round(y)}`,"Row span")})})]}):null]})}function aye(e,t){const n=(t.length>1?Uy(e,t)?.style:e.style)??{},s=n["grid-template-columns"]?rE(n["grid-template-columns"]):null;return s?.ok?s.value.length:12}function lye(e,t){const n={...e};for(const[s,o]of Object.entries(t))o===void 0?delete n[s]:n[s]=o;return n}const b_=[{value:"stretch",label:"Stretch"},{value:"start",label:"Start"},{value:"center",label:"Center"},{value:"end",label:"End"}];function Ak(e){switch(e){case"start":case"flex-start":return"start";case"center":return"center";case"end":case"flex-end":return"end";default:return null}}function cye(e){return e.unit==="fr"?{unit:"px",value:240}:e.unit==="px"?{unit:"auto"}:{unit:"fr",value:1}}function uye(e){return e.unit==="auto"?"Auto":`${e.value}${e.unit}`}const Ok={justify:{start:QG,center:XG,end:ZG},align:{start:nW,center:eW,end:tW}},dye={justify:Ok.align,align:Ok.justify};function fye({target:e}){const t=e.nodes.length===1?e.nodes[0]:null,n=e.nodes.length===0;if(!n&&e.nodes.every(r=>r.kind==="text"||r.kind==="list"||r.kind==="textbox"))return p.jsx(ss,{title:"Layout",children:p.jsx(x_,{target:e})});if(!n&&t?.kind!=="box"||t?.kind==="box"&&t.group)return null;const s=n?e.slide.style:t.style,o=s.display==="grid"?"grid":s.position==="relative"?"layered":"stack";return p.jsxs(ss,{title:"Layout",children:[p.jsx(Be,{children:p.jsx(As,{"aria-label":"Layout",value:o,options:[{value:"stack",label:"Stack",title:"Children follow one another"},{value:"grid",label:"Grid",title:"Children fill a grid of columns"},...n?[]:[{value:"layered",label:"Layered",title:"Children are placed freely on top of each other"}]],onChange:r=>hye(e,s,o,r,n)})}),o==="stack"?p.jsx(pye,{target:e,style:s}):null,o==="grid"?p.jsx(mye,{target:e,style:s}):null,o==="layered"?p.jsx(di,{children:"Children are placed freely. Drag them on the slide to arrange them."}):null,o!=="layered"?p.jsx(Be,{label:"Gap",children:p.jsx(St,{"aria-label":"Gap",value:Ht(e,"gap").mixed?null:qu(s.gap?.split(/\s+/)[0])??0,placeholder:"Mixed",min:0,max:512,onCommit:r=>ht(e,"gap",r?`${r}px`:"","Gap","gap")})}):null,p.jsx(x_,{target:e})]})}function hye(e,t,n,s,o){s!==n&&(s==="grid"?yo(e,"Grid layout",{display:"grid","grid-template-columns":iE([{unit:"fr",value:1},{unit:"fr",value:1}]),"flex-direction":void 0,"flex-wrap":void 0,"justify-content":void 0,position:o||t.position==="relative"?void 0:t.position}):s==="stack"?yo(e,"Stack layout",{display:void 0,"grid-template-columns":void 0,"grid-template-rows":void 0,"justify-items":void 0,position:t.position==="relative"?void 0:t.position}):yo(e,"Layered layout",{position:"relative",display:void 0,"grid-template-columns":void 0,"grid-template-rows":void 0}))}function pye({target:e,style:t}){const n=t["flex-direction"]==="row"||t["flex-direction"]==="row-reverse",s=t["flex-wrap"]==="wrap",o=t["justify-content"]==="space-between",r=t["justify-content"]?Ak(t["justify-content"]):"start",i=Ak(t["align-items"]),l=n?Ok:dye,u=(f,h)=>["start","center","end"].map(g=>{const y=l[f][g];return{value:g,label:`${h} ${g}`,title:`${h} ${g}`,icon:p.jsx(y,{strokeWidth:1.5}),disabled:f==="justify"&&o,reason:"Distribute decides this axis"}}),d=n?JG:sW;return p.jsxs(p.Fragment,{children:[p.jsxs(Be,{label:"Direction",children:[p.jsx(As,{"aria-label":"Direction",value:n?"h":"v",options:[{value:"h",label:"Horizontal",title:"Horizontal",icon:p.jsx(aW,{strokeWidth:1.5})},{value:"v",label:"Vertical",title:"Vertical",icon:p.jsx(sL,{strokeWidth:1.5})}],onChange:f=>yo(e,"Direction",f==="h"?{"flex-direction":"row"}:{"flex-direction":void 0,"flex-wrap":void 0})}),p.jsx(Os,{label:s?"Children wrap onto more rows — click for one row":"Wrap children onto more rows",icon:p.jsx(SW,{strokeWidth:1.5}),active:s,disabled:!n,reason:n?void 0:"Wrap applies to a horizontal stack",onClick:()=>ht(e,"flex-wrap",s?"":"wrap","Wrap")})]}),p.jsxs(Be,{label:"Align",onReset:t["justify-content"]||t["align-items"]?()=>yo(e,"Align",{"justify-content":void 0,"align-items":void 0}):void 0,children:[p.jsxs("div",{className:Ie("flex min-w-0 flex-1 gap-2",n?"items-center":"items-start"),children:[p.jsx(As,{"aria-label":"Justify",vertical:!n,className:n?"min-w-0 flex-1":void 0,value:r,options:u("justify","Justify"),onChange:f=>ht(e,"justify-content",f==="start"?"":f,"Justify")}),p.jsx(As,{"aria-label":"Align",vertical:!n,className:n?"min-w-0 flex-1":void 0,value:i,options:u("align","Align"),onChange:f=>ht(e,"align-items",f,"Align")})]}),p.jsx(Os,{label:o?"Distribute: space between — click to pack":"Distribute (space between); needs main-axis room to show",icon:p.jsx(d,{strokeWidth:1.5}),active:o,onClick:()=>ht(e,"justify-content",o?"":"space-between","Distribute")})]})]})}function mye({target:e,style:t}){const n=t["grid-template-columns"]?rE(t["grid-template-columns"]):null,s=n?.ok?n.value:[],o=r=>{r.length>0&&ht(e,"grid-template-columns",iE(r),"Grid columns")};return p.jsxs(p.Fragment,{children:[p.jsx(Be,{label:"Columns",children:p.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:[s.map((r,i)=>p.jsx("button",{type:"button",title:"Click to switch between a share, a fixed 240px and the content's size",className:"h-6 rounded-[6px] bg-chrome-field px-1.5 text-[12px] tabular-nums text-chrome-fg shadow-[inset_0_0_0_1px_var(--chrome-field-ring)] hover:shadow-[inset_0_0_0_1px_var(--chrome-field-ring-strong)]",onClick:()=>o(s.map((l,u)=>u===i?cye(l):l)),children:uye(r)},i)),p.jsx(Os,{label:"Add column",icon:p.jsx(ds,{strokeWidth:1.5}),disabled:s.length>=12,reason:s.length>=12?"12 columns at most":void 0,onClick:()=>o([...s,{unit:"fr",value:1}])}),p.jsx(Os,{label:"Remove column",icon:p.jsx($i,{strokeWidth:1.5}),disabled:s.length<=1,reason:s.length<=1?"A grid keeps one column":void 0,onClick:()=>o(s.slice(0,-1))})]})}),p.jsx(Be,{label:"Rows",children:p.jsx(zC,{target:e,property:"grid-template-rows",label:"Grid rows",placeholder:"auto"})}),p.jsxs(Be,{label:"Align",children:[p.jsx(Ss,{"aria-label":"Justify items",value:t["justify-items"]??"stretch",options:b_.map(r=>({...r})),onChange:r=>ht(e,"justify-items",r==="stretch"?"":r,"Align columns")}),p.jsx(Ss,{"aria-label":"Align items",value:Ak(t["align-items"])??"stretch",options:b_.map(r=>({...r})),onChange:r=>ht(e,"align-items",r==="stretch"?"":r,"Align rows")})]})]})}function x_({target:e}){const t=Ht(e,"padding"),n=s=>{const o=s.every(r=>r===s[0]);ht(e,"padding",o?s[0]?`${s[0]}px`:"":s.map(r=>`${r}px`).join(" "),"Padding","padding")};return p.jsx(LC,{label:"Padding",kind:"sides",values:t.mixed?null:mee(t.value),unit:"px",min:0,max:256,onCommit:n,onReset:t.value&&!t.mixed?()=>ht(e,"padding","","Padding"):void 0})}function BH(e){const t={color:"Color",gradient:"Gradient",image:"Image"};return e.map(n=>({value:n,label:t[n]}))}function HH(e){return e?.image?"image":e?.gradient?"gradient":"color"}function Nk(e){return e?e.image?{swatch:`url("${e.image.url}") center / cover`,label:"Image"}:e.gradient?{swatch:Lh({gradient:e.gradient}),label:e.gradient.type==="radial"?"Radial":"Linear"}:null:null}function gye(e,t,n){const s=qn(e)??{r:20,g:20,b:19},o=qn(t)??s;return Ol({r:Math.round(s.r+(o.r-s.r)*n),g:Math.round(s.g+(o.g-s.g)*n),b:Math.round(s.b+(o.b-s.b)*n),a:1})}function FH(e){const t=e&&qn(e)?Ol({...qn(e),a:1}):"#141413";return{type:"linear",angle:90,stops:[{color:t,positions:[]},{color:gye(t,"#d97757",.6),positions:[]}]}}function yye({image:e,onImage:t}){const[n,s]=T.useState(!1),o=()=>{dd("image/png,image/jpeg,image/webp,image/gif",!1).then(async r=>{const i=r[0];if(i){s(!0);try{const l=await Uh(i);t({url:l.src,size:e?.size??"cover"})}catch(l){tt.add({title:"Couldn't add the image",description:l instanceof Error?l.message:String(l)})}finally{s(!1)}}})};return p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsxs("div",{className:"flex min-h-7 items-center gap-2",children:[p.jsx("span",{className:"w-12 shrink-0 text-[12px] text-chrome-muted",children:"Image"}),e?p.jsx("span",{className:"size-6 shrink-0 rounded-[4px] bg-cover bg-center shadow-[inset_0_0_0_1px_rgb(0_0_0/0.1)]",style:{backgroundImage:`url("${e.url}")`}}):null,p.jsx(Pl,{size:"sm",className:"min-w-0 flex-1",disabled:n,onClick:o,children:n?"Uploading…":e?"Replace…":"Choose image…"})]}),p.jsxs("div",{className:"flex min-h-7 items-center gap-2",children:[p.jsx("span",{className:"w-12 shrink-0 text-[12px] text-chrome-muted",children:"Size"}),p.jsx(As,{"aria-label":"Image size",value:e?.size??"cover",options:[{value:"cover",label:"Cover"},{value:"contain",label:"Contain"}],onChange:r=>e&&t({...e,size:r})})]})]})}const F1=8,U1=2,bye="repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0 / 8px 8px";function UH(e,t){const n=e.stops[t]?.positions[0],s=n?/^(-?[\d.]+)%$/.exec(n):null;return s?Number(s[1]):Math.round(t/Math.max(1,e.stops.length-1)*100)}function VH(e){return{...e,stops:e.stops.map((t,n)=>({...t,positions:[`${UH(e,n)}%`]}))}}function V1(e,t,n){const s=VH(e);return{...s,stops:s.stops.map((o,r)=>r===t?{...o,positions:[`${Math.round(Math.max(0,Math.min(100,n)))}%`]}:o)}}function v_({label:e,children:t}){return p.jsxs("div",{className:"flex min-h-7 items-center gap-2",children:[p.jsx("span",{className:"w-12 shrink-0 text-[12px] text-chrome-muted",children:e}),p.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:t})]})}function qH({gradient:e,onChange:t,linearOnly:n=!1}){const s=zi(),[o,r]=T.useState(0),i=T.useRef(null),l=e.type==="radial",u=e.stops.map((v,w)=>UH(e,w)),d=[...e.stops.map((v,w)=>({stop:v,at:u[w]}))].sort((v,w)=>v.at-w.at),f=Lh({gradient:{type:"linear",angle:90,stops:d.map(({stop:v,at:w})=>({...v,positions:[`${w}%`]}))}}),h=v=>{const w=i.current?.getBoundingClientRect();return w?(v.clientX-w.left-12)/Math.max(1,w.width-24)*100:0},g=v=>w=>{const S=w.shiftKey?10:1,C=w.key==="ArrowLeft"||w.key==="ArrowDown"?-S:w.key==="ArrowRight"||w.key==="ArrowUp"?S:0;C&&(w.preventDefault(),t(V1(e,v,u[v]+C)))},y=()=>{const v=u[o]??50,w=u.filter(C=>C>v).sort((C,k)=>C-k)[0]??Math.min(100,v+20),S=VH(e);S.stops.push({color:e.stops[o]?.color??"#ffffff",positions:[`${Math.round((v+w)/2)}%`]}),t(S),r(S.stops.length-1)},b=v=>{t({...e,stops:e.stops.filter((w,S)=>S!==v)}),r(Math.max(0,Math.min(o,e.stops.length-2)))};return p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsxs(v_,{label:"Style",children:[p.jsx(Ss,{"aria-label":"Gradient style",value:l?"radial":"linear",options:[{value:"linear",label:"Linear"},{value:"radial",label:"Radial",disabled:n,reason:"Linear gradients only here."}],onChange:v=>t(v==="radial"?{type:v,shape:"ellipse",stops:e.stops}:{type:v,angle:e.angle??180,stops:e.stops})}),p.jsx(St,{"aria-label":"Angle",className:"w-[76px] shrink-0",label:p.jsx(DD,{}),value:l?null:e.angle??180,placeholder:l?"–":"180",unit:"°",min:0,max:360,steppers:!1,disabled:l,title:l?"A radial gradient has no angle.":void 0,onCommit:v=>t({...e,angle:v??180})})]}),p.jsxs("div",{ref:i,className:"relative my-1 h-8 rounded-[6px] shadow-[inset_0_0_0_1px_rgb(0_0_0/0.08)]",style:{background:bye},children:[p.jsx("div",{className:"absolute inset-0 rounded-[6px]",style:{background:f}}),p.jsx("div",{className:"absolute inset-y-0 left-3 right-3",children:e.stops.map((v,w)=>p.jsx("button",{type:"button",role:"slider","aria-label":`Stop ${w+1} position`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(u[w]),className:Ie("absolute top-1/2 size-4 -translate-x-1/2 -translate-y-1/2 cursor-default touch-none rounded-full border-2 border-white shadow-[0_0_0_1px_rgb(0_0_0/0.25)] outline-none focus-visible:ring-2 focus-visible:ring-chrome-accent",w===o&&"z-[1] outline-2 outline-offset-1 outline-chrome-fg"),style:{left:`${u[w]}%`,background:v.color},onPointerDown:S=>{S.currentTarget.setPointerCapture(S.pointerId),r(w)},onPointerMove:S=>{S.currentTarget.hasPointerCapture(S.pointerId)&&t(V1(e,w,h(S)))},onKeyDown:g(w)},w))})]}),p.jsxs(v_,{label:"Stops",children:[p.jsx("span",{className:"flex-1"}),p.jsx(Os,{size:"sm",label:"Add stop",icon:p.jsx(ds,{className:"size-4",strokeWidth:1.5}),disabled:e.stops.length>=F1,title:e.stops.length>=F1?`${F1} stops at most.`:void 0,onClick:y})]}),p.jsx("div",{role:"list","aria-label":"Stops",className:"flex flex-col gap-1.5",children:e.stops.map((v,w)=>p.jsxs("div",{role:"listitem",className:Ie("flex min-w-0 items-center gap-1.5 rounded-[8px]",w===o&&"bg-chrome-hover"),onFocus:()=>r(w),children:[p.jsx(St,{"aria-label":`Stop ${w+1} position`,className:"w-[60px] shrink-0",value:Math.round(u[w]),unit:"%",min:0,max:100,steppers:!1,onCommit:S=>t(V1(e,w,S??u[w]))}),p.jsx("div",{className:"min-w-0 flex-1",children:p.jsx(lh,{"aria-label":`Stop ${w+1} color`,value:v.color,groups:s,onCommit:S=>S&&t({...e,stops:e.stops.map((C,k)=>k===w?{...C,color:S}:C)})})}),p.jsx(Os,{size:"sm",label:`Remove stop ${w+1}`,icon:p.jsx($i,{className:"size-4",strokeWidth:1.5}),disabled:e.stops.length<=U1,title:e.stops.length<=U1?`A gradient needs ${U1} color stops.`:void 0,onClick:()=>b(w)})]},w))})]})}const xye="A selected object’s opacity is set by an animation. Ask the agent to change the animation.",vye="Add a border first",wye="A shape draws one stroke all round",w_="A line is solid (a connector can dash)",S_="Not on diamond or arrow shapes",Sye="Inner shadow needs a fill or border on this text",q1=`At most ${ve.shadows} per element`,Mf="#141413",$k=e=>e.kind==="rule"||e.kind==="shape"&&e.shape==="line",k_=e=>e.kind==="shape"||e.kind==="rule",kye=e=>e.kind==="shape"&&(e.shape==="diamond"||e.shape.startsWith("arrow-"));function Eye({target:e,label:t="Fill",gradients:n=!1,removable:s=!0}){const o=zi(),r=Ht(e,"background"),i=r.value?_h(r.value):null,l=i?.ok?i.value:null,u=Ht(e,"background-clip").value==="text",d=HH(l),f=l?.color&&l.color!=="transparent"?l.color:null,h=!r.mixed&&!!(f||l?.gradient||l?.image),g=e.nodes.length>0&&e.nodes.every(w=>w.kind==="shape"&&!w.style.border),y=(w,S=t)=>{ht(e,"background",w?Lh(w):"",S,"fill")};if(u)return p.jsx(Be,{label:t,children:p.jsx(lh,{"aria-label":t,value:null,groups:o,preview:Nk(l)??{swatch:f??"transparent",label:"Text fill"},disabled:!0,title:"This fill paints the letters — change it under Text › Color",onCommit:()=>{}})});const v=n||d==="gradient"?["color","gradient"]:[];return p.jsxs(Be,{label:t,children:[p.jsx(lh,{"aria-label":t,value:r.mixed?null:f,mixed:r.mixed,allowNone:!g,groups:o,preview:Nk(l),onCommit:w=>y(w?{color:w}:null),kinds:v.length>1&&!r.mixed?{value:d,options:BH(v),onChange:w=>{w==="gradient"&&d!=="gradient"?y({gradient:FH(f)},"Gradient"):w==="color"&&d==="gradient"&&y({color:l?.gradient?.stops[0]?.color??Mf})},content:l?.gradient?p.jsx(qH,{gradient:l.gradient,onChange:w=>y({gradient:w},"Gradient")}):null}:void 0}),s&&h?p.jsx(Os,{label:t==="Background"?"Remove background":`Remove ${t.toLowerCase()}`,icon:p.jsx($i,{}),disabled:g,reason:g?vye:void 0,onClick:()=>y(null)}):null]})}function Cye({target:e,lockedReason:t}){const n=Ht(e,"opacity"),[s,o]=T.useState(null),r=s??Math.round((n.value===void 0?1:Number(n.value))*100),i=l=>{ht(e,"opacity",l>=100?"":String(Math.max(0,l)/100),"Opacity","opacity")};return p.jsxs(Be,{label:"Opacity",tip:t,children:[p.jsx(St,{"aria-label":"Opacity",className:"w-[72px] shrink-0",value:n.mixed?null:r,placeholder:"Mixed",unit:"%",min:0,max:100,disabled:!!t,title:t,onCommit:l=>l!==null&&i(l)}),p.jsx(ume,{"aria-label":"Opacity slider",value:r,min:0,max:100,disabled:!!t,onChange:l=>{o(l),i(l)},onCommit:l=>{o(null),i(l)}})]})}function Tye(e){const t=(e??"0").trim().split(/\s+/).map(i=>Number.parseFloat(i)||0),[n=0,s=n,o=n,r=s]=t;return[n,s,o,r]}function Mye({target:e}){const t=Ht(e,"border-radius"),n=(t.value??"").includes("%"),s=n?"%":"px",o=r=>{const i=r.every(l=>l===r[0])?r[0]?`${r[0]}${s}`:"":r.map(l=>`${l}${s}`).join(" ");ht(e,"border-radius",i,"Corner radius","radius")};return p.jsx(LC,{label:"Radius",kind:"corners",values:t.mixed?null:Tye(t.value),unit:s,min:0,max:n?50:256,onCommit:o,onReset:t.value&&!t.mixed?()=>ht(e,"border-radius","","Corner radius"):void 0})}const GH=["border-top","border-right","border-bottom","border-left"];function E_(e){const t=l=>{const u=l?Nf(l,32):null;return u?.ok?u.value:null},n=t(e.border),s=GH.map(l=>t(e[l])??n),o=s.map(l=>l&&l.style!=="none"?l.width:0),r=s.find(l=>l&&l.style!=="none"&&l.width>0);if(!r)return null;const i=r.style==="dashed"||r.style==="dotted"?r.style:"solid";return{widths:o,style:i,color:r.color}}function Rye(e,t){const n={border:void 0,"border-top":void 0,"border-right":void 0,"border-bottom":void 0,"border-left":void 0};if(!e||e.widths.every(o=>o<=0))return n;const s=o=>$f({width:o,style:e.style,color:e.color});return t||e.widths.every(o=>o===e.widths[0])?(n.border=s(Math.max(...e.widths)),n):(GH.forEach((o,r)=>{e.widths[r]>0&&(n[o]=s(e.widths[r]))}),n)}function G1(e){const t=e[0];return e.every(n=>JSON.stringify(n)===JSON.stringify(t))?t??null:null}function jye({target:e}){const t=zi(),s=(e.nodes.length?e.nodes.map(b=>b.style):[e.slide.style]).map(E_),o=e.nodes.length>0&&e.nodes.some(k_),r=e.nodes.length>0&&e.nodes.every($k),i=b=>b?.style??"none",l=G1(s.map(i)),u=G1(s.map(b=>b?.color??null)),d=G1(s.map(b=>b?.widths??null)),f=s.some(Boolean),h=(b,v,w)=>{yo(e,b,S=>Rye(v(E_(S?.style??e.slide.style)),S?k_(S):!1),w)},g=b=>{b==="none"?h("Remove border",()=>null):h("Border style",v=>({widths:v?.widths??[1,1,1,1],style:b,color:v?.color??Mf}))},y=o?32:16;return p.jsxs(p.Fragment,{children:[p.jsx(Be,{label:"Border",onReset:f?()=>g("none"):void 0,resetLabel:"Remove border",children:p.jsx(As,{"aria-label":"Border",value:l,options:[{value:"none",label:"None",title:"No border",icon:p.jsx(dL,{strokeWidth:1.5})},{value:"solid",label:"Solid",title:"Solid",icon:p.jsx(qB,{})},{value:"dashed",label:"Dashed",title:"Dashed",icon:p.jsx(GB,{}),disabled:r,reason:w_},{value:"dotted",label:"Dotted",title:"Dotted",icon:p.jsx(WB,{}),disabled:r,reason:w_}],onChange:g})}),f?p.jsxs(p.Fragment,{children:[p.jsx(Xh,{label:"Color","aria-label":"Border color",value:u,mixed:u===null,groups:t,onCommit:b=>b&&h("Border color",v=>v&&{...v,color:b},"border-color"),onReset:u&&u.toLowerCase()!==Mf?()=>h("Border color",b=>b&&{...b,color:Mf}):void 0}),p.jsx(LC,{label:"Width",kind:"sides",values:d,unit:"px",min:0,max:y,toggleDisabledReason:o?wye:void 0,onCommit:b=>h("Border width",v=>v?b.every(w=>w<=0)?{...v,widths:[1,1,1,1]}:{...v,widths:b}:{widths:b,style:"solid",color:Mf},"border-width")})]}):null]})}function WH({target:e,fill:t=!0,fillLabel:n="Fill",gradients:s=!1,opacity:o=!0,radius:r=!0,border:i=!0,buildControlled:l=!1}){return!t&&!o&&!r&&!i?null:p.jsxs(ss,{title:"Appearance",children:[t?p.jsx(Eye,{target:e,label:n,gradients:s,removable:e.nodes.length>0}):null,o?p.jsx(Cye,{target:e,lockedReason:l?xye:void 0}):null,r?p.jsx(Mye,{target:e}):null,i?p.jsx(jye,{target:e}):null]})}const Aye={inset:!1,x:0,y:2,blur:8,spread:0,color:"#00000033"},Oye={inset:!0,x:0,y:1,blur:2,spread:0,color:"#00000033"},Nye={inset:!1,x:0,y:1,blur:3,spread:0,color:"#00000033"},C_=4,W1=e=>String(Math.round(e*100)/100);function $ye(e){return`${W1(e.x)}, ${W1(e.y)} · ${W1(e.blur)}px`}function T_(e,t){const n=Ht(e,t),s=n.value&&!n.mixed?TS(n.value,t==="text-shadow"):null;return s?.ok?s.value:[]}function M_(e,t){const n=Ht(e,t),s=n.value&&!n.mixed?sE(n.value):null;return s?.ok?s.value:{}}function _ye(e){if(e.length===0)return null;const t=new Set(["box","text","list","textbox","image","table","icon","shape"]),n=new Set(["box","text","list","textbox","image","shape"]),s=e.every(i=>t.has(i.kind)&&!$k(i)),o=e.every(i=>n.has(i.kind)&&!$k(i));if(!s&&!o)return null;const r=e.some(kye);return{box:s?r?S_:"":null,text:e.every(Ba),filter:o,backdrop:r?S_:""}}function Lye({target:e}){const t=_ye(e.nodes);return t?p.jsx(Dye,{target:e,support:t}):null}function Dye({target:e,support:t}){const n=t.box!==null?T_(e,"box-shadow"):[],s=t.text?T_(e,"text-shadow"):[],o=t.filter?M_(e,"filter"):{},r=t.filter?M_(e,"backdrop-filter"):{},[i,l]=T.useState(null),u=(S,C,k)=>{ht(e,S,C.length?MS(C,S==="text-shadow"):"",k,S)},d=(S,C,k)=>{const j={...S==="filter"?o:r};C===null?delete j.blur:j.blur=C,ht(e,S,oE(j),k,S)},f=t.text&&e.nodes.every(S=>S.style.background||S.style.border),h=S=>S.length>=ve.shadows,g=t.text?s:n,y=t.text?h(s)?q1:"":t.box===null?null:t.box||(h(n)?q1:""),b=t.box===null?null:t.box||(t.text&&!f?Sye:h(n)?q1:""),v=p.jsxs(Js,{align:"end",tip:{label:"Add to Effects"},trigger:p.jsx("button",{type:"button","aria-label":"Add to Effects",className:"flex size-6 items-center justify-center rounded-[6px] text-chrome-secondary outline-none hover:bg-chrome-hover hover:text-chrome-fg focus-visible:ring-2 focus-visible:ring-chrome-accent",children:p.jsx(ds,{className:"size-4",strokeWidth:1.5})}),children:[y!==null?p.jsx(Et,{disabled:y!=="",title:y||void 0,onSelect:()=>{t.text?u("text-shadow",[...s,Nye],"Drop shadow"):u("box-shadow",[...n,Aye],"Drop shadow"),l(`${t.text?"text":"box"}-${g.length}`)},children:"Drop shadow"}):null,b!==null?p.jsx(Et,{disabled:b!=="",title:b||void 0,onSelect:()=>{u("box-shadow",[...n,Oye],"Inner shadow"),l(`box-${n.length}`)},children:"Inner shadow"}):null,t.filter?p.jsxs(p.Fragment,{children:[p.jsx(Et,{disabled:o.blur!==void 0,onSelect:()=>d("filter",C_,"Layer blur"),children:"Layer blur"}),p.jsx(Et,{disabled:r.blur!==void 0||t.backdrop!=="",title:t.backdrop||void 0,onSelect:()=>d("backdrop-filter",C_,"Background blur"),children:"Background blur"})]}):null]}),w=(S,C)=>C.map((k,M)=>{const j=`${S==="text-shadow"?"text":"box"}-${M}`,O=S==="text-shadow"?"Drop shadow":k.inset?"Inner shadow":t.text?"Box shadow":"Drop shadow",$=A=>A?C.map((N,_)=>_===M?A:N):C.filter((N,_)=>_!==M);return p.jsxs(Be,{label:O,children:[p.jsx(zye,{title:O,shadow:k,spread:S==="box-shadow",open:i===j,onOpenChange:A=>l(A?j:null),onChange:A=>u(S,$(A),O)}),p.jsx(Os,{label:`Remove ${O.toLowerCase()}`,icon:p.jsx($i,{}),onClick:()=>u(S,$(null),`Remove ${O.toLowerCase()}`)})]},j)});return p.jsxs(ss,{title:"Effects",actions:v,children:[t.text?w("text-shadow",s):null,t.box!==null?w("box-shadow",n):null,o.blur!==void 0?p.jsx(R_,{label:"Layer blur",value:o.blur,onCommit:S=>d("filter",S,"Layer blur")}):null,r.blur!==void 0?p.jsx(R_,{label:"Background blur",value:r.blur,onCommit:S=>d("backdrop-filter",S,"Background blur")}):null]})}function R_({label:e,value:t,onCommit:n}){return p.jsxs(Be,{label:e,children:[p.jsx(St,{"aria-label":e,value:t,placeholder:"0",unit:"px",min:0,max:20,step:.5,onCommit:s=>s!==null&&n(s)}),p.jsx(Os,{label:`Remove ${e.toLowerCase()}`,icon:p.jsx($i,{}),onClick:()=>n(null)})]})}function zye({title:e,shadow:t,spread:n,open:s,onOpenChange:o,onChange:r}){const i=zi(),l=u=>r({...t,...u});return p.jsxs(DC,{title:e,text:$ye(t),swatch:t.color,open:s,onOpenChange:o,children:[p.jsxs(Be,{label:"Offset",children:[p.jsx(St,{"aria-label":"Horizontal offset",label:"X",value:t.x,min:-64,max:64,steppers:!1,onCommit:u=>u!==null&&l({x:u})}),p.jsx(St,{"aria-label":"Vertical offset",label:"Y",value:t.y,min:-64,max:64,steppers:!1,onCommit:u=>u!==null&&l({y:u})})]}),p.jsx(Be,{label:"Blur",children:p.jsx(St,{"aria-label":"Blur",value:t.blur,unit:"px",min:0,max:n?160:64,onCommit:u=>u!==null&&l({blur:u})})}),n?p.jsx(Be,{label:"Spread",children:p.jsx(St,{"aria-label":"Spread",value:t.spread,unit:"px",min:-32,max:32,onCommit:u=>u!==null&&l({spread:u})})}):null,p.jsx(Be,{label:"Color",children:p.jsx(lh,{"aria-label":"Shadow color",value:t.color,groups:i,onCommit:u=>u&&l({color:u})})})]})}function Pye(e){return document.querySelector(`[data-open-artifact-stage] [data-open-artifact-path="${rs(e)}"]`)}const Y1=(e,t)=>Math.round(e*10**t)/10**t;function Iye(e){const t=getComputedStyle(e),n=Number.parseFloat(t.fontSize)||16,s=Number.parseFloat(t.lineHeight),o=Number.parseFloat(t.letterSpacing),r=t.textAlign==="start"?"left":t.textAlign==="end"?"right":t.textAlign;return{family:dh(t.fontFamily),weight:Wu(Number(t.fontWeight)||400),italic:t.fontStyle==="italic"||t.fontStyle.startsWith("oblique"),size:Y1(n,1),lineHeight:Number.isFinite(s)?Y1(s/n,2):null,letterSpacing:Number.isFinite(o)?Y1(o,1):0,color:t.color,align:r}}const j_=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function Bye(e){const t=ae(i=>i.revision),n=se(i=>i.textEdit!==null),s=e.map(rs).join("|"),[o,r]=T.useState(null);return T.useLayoutEffect(()=>{const i=()=>{const d=e.map(Pye).map(g=>g?Iye(g):null),f=d[0],h=f&&d.every(g=>g&&j_(g,f))?f:null;r(g=>g&&h&&j_(g,h)?g:h)};i();const l=requestAnimationFrame(i),u=window.setTimeout(i,250);return()=>{cancelAnimationFrame(l),window.clearTimeout(u)}},[s,t,n]),o}const Hye=[["left","Left",B2],["center","Center",ez],["right","Right",nz],["justify","Justify",oz]],Fye=[{value:"none",label:"None"},{value:"uppercase",label:"Uppercase"},{value:"lowercase",label:"Lowercase"},{value:"capitalize",label:"Capitalize"}],Uye=[{value:"shrink",label:"Shrink text to fit"},{value:"none",label:"Don’t resize text"},{value:"grow",label:"Grow box to fit text"}],A_="What happens when the text outgrows its box: shrink the text, leave it as it is, or grow the box.";function Vye(e){return Ba(e)||e.kind==="table"}function qye(e){return e?e==="bold"?700:e==="normal"?400:/^\d{3}$/.test(e)?Number(e):null:null}function Gye({target:e}){const t=e.nodes.length===0,n=!t&&e.nodes.every(L=>L.kind==="text"),s=lH(n?e.nodes:null),o=Bye(t?[]:e.paths),r=e.paths.map(L=>L.join(".")).join("|"),[i,l]=T.useState(new Set);if(T.useEffect(()=>l(new Set),[r]),!t&&!e.nodes.every(Vye))return null;const u=Ht(e,"font-size"),d=Ht(e,"line-height"),f=Ht(e,"letter-spacing"),h=Ht(e,"text-transform"),g=Ht(e,"text-decoration"),y=Ht(e,"text-align"),b=g.mixed?null:/line-through/.test(g.value??"")?"line-through":/underline/.test(g.value??"")?"underline":null,v=!t&&e.nodes.every(L=>L.kind==="text"||L.kind==="list"),w=v?e.nodes.every(L=>L.kind==="list"&&L.tag==="ul")?"ul":e.nodes.every(L=>L.kind==="list"&&L.tag==="ol")?"ol":e.nodes.every(L=>L.kind==="text")?"none":null:null,S=!t,C=e.nodes.map(L=>L.fit??"shrink"),k=C.every(L=>L===C[0])?C[0]??"shrink":null,M=!t&&(i.has("emphasis")||g.mixed||b!==null),j=v&&(i.has("list")||e.nodes.some(L=>L.kind==="list")),O=i.has("case")||h.mixed||!!(h.value&&h.value!=="none"),$=L=>l(new Set([...i,L])),A=e.nodes.length,N=A>1?`${A} Text`:"Text",_=p.jsxs(Js,{align:"end",tip:{label:"Add to Text"},trigger:p.jsx("button",{type:"button","aria-label":"Add to Text",className:"flex size-6 items-center justify-center rounded-[6px] text-chrome-secondary outline-none hover:bg-chrome-hover hover:text-chrome-fg focus-visible:ring-2 focus-visible:ring-chrome-accent",children:p.jsx(ds,{className:"size-4",strokeWidth:1.5})}),children:[t?null:p.jsx(Et,{disabled:M,onSelect:()=>$("emphasis"),children:"Emphasis"}),v?p.jsx(Et,{disabled:j,onSelect:()=>$("list"),children:"List"}):null,p.jsx(Et,{disabled:O,onSelect:()=>$("case"),children:"Case"})]}),D=!!(d.value||f.value),P=f.mixed||!f.value?null:f.value.endsWith("em")?Math.round(Number.parseFloat(f.value)*(o?.size??16)*10)/10:qu(f.value);return p.jsxs(ss,{title:N,actions:_,children:[n?p.jsx(Be,{label:"Text style",children:p.jsx(Ss,{"aria-label":"Text style",icon:p.jsx(VB,{}),value:s.value,placeholder:s.mixed?"Mixed":"Custom",options:s.options.map(L=>({value:L.value,label:L.label,hint:L.hint,group:L.group,style:L.style})),valueStyle:{},onChange:s.apply})}):null,p.jsx(Yye,{target:e,resolved:o,isSlide:t}),p.jsx(Kye,{target:e,resolved:o}),p.jsx(Be,{label:"Size",onReset:u.value&&!u.mixed?()=>ht(e,"font-size","","Font size"):void 0,children:p.jsx(St,{"aria-label":"Font size",value:u.mixed?null:qu(u.value),unit:"px",min:8,max:400,placeholder:u.mixed?"Mixed":o?String(o.size):"Auto",inherited:!u.mixed,onCommit:L=>ht(e,"font-size",L===null?"":`${L}px`,"Font size")})}),p.jsx(Be,{label:"Spacing",tip:"Line height · Letter spacing",resetLabel:"Reset Spacing",onReset:D?()=>yo(e,"Spacing",{"line-height":void 0,"letter-spacing":void 0}):void 0,children:p.jsxs("div",{className:"grid min-w-0 flex-1 grid-cols-2 gap-1.5",children:[p.jsx(St,{"aria-label":"Line height",title:"Line height",label:p.jsx(Ype,{}),value:d.mixed||!d.value?null:Number.parseFloat(d.value),step:.05,min:.5,max:4,steppers:!1,placeholder:d.mixed?"Mixed":o?.lineHeight!=null?String(o.lineHeight):"Auto",inherited:!d.mixed,onCommit:L=>ht(e,"line-height",L===null?"":String(L),"Line height")}),p.jsx(St,{"aria-label":"Letter spacing",title:"Letter spacing (px)",label:p.jsx(Kpe,{}),value:P,step:.5,min:-24,max:32,steppers:!1,placeholder:f.mixed?"Mixed":String(o?.letterSpacing??0),inherited:!f.mixed,onCommit:L=>ht(e,"letter-spacing",L===null||L===0?"":`${L}px`,"Letter spacing")})]})}),p.jsx(Qye,{target:e,resolved:o}),M?p.jsxs(Be,{label:"Emphasis",onReset:b?()=>ht(e,"text-decoration","","Emphasis"):void 0,children:[p.jsx(Os,{label:"Underline",icon:p.jsx(fz,{}),active:b==="underline",onClick:()=>ht(e,"text-decoration",b==="underline"?"":"underline","Underline")}),p.jsx(Os,{label:"Strikethrough",icon:p.jsx(oY,{}),active:b==="line-through",onClick:()=>ht(e,"text-decoration",b==="line-through"?"":"line-through","Strikethrough")})]}):null,j?p.jsx(Be,{label:"List",children:p.jsx(As,{"aria-label":"List",value:w,options:[{value:"none",label:"None"},{value:"ul",label:"Bulleted"},{value:"ol",label:"Numbered"}],onChange:L=>eo("List",F=>F.kind==="text"||F.kind==="list"?CI(F,L==="none"?null:L):F)})}):null,p.jsx(Be,{label:"Align",onReset:y.value&&!y.mixed?()=>ht(e,"text-align","","Align"):void 0,children:p.jsx(As,{"aria-label":"Text alignment",value:y.mixed?null:y.value??o?.align??"left",options:Hye.map(([L,F,U])=>({value:L,title:F,label:p.jsx(U,{className:"size-4",strokeWidth:1.5})})),onChange:L=>ht(e,"text-align",L,"Align")})}),O?p.jsx(Be,{label:"Case",onReset:h.value&&!h.mixed?()=>ht(e,"text-transform","","Text case"):void 0,children:p.jsx(Ss,{"aria-label":"Text case",value:h.mixed?null:h.value??"none",placeholder:"Mixed",options:Fye,onChange:L=>ht(e,"text-transform",L==="none"?"":L,"Text case")})}):null,S?p.jsx(Be,{label:"Resize",tip:A_,children:p.jsx(Ss,{"aria-label":"Resize",title:A_,value:k,placeholder:"Mixed",options:Uye,onChange:L=>eo("Resize",F=>{const{fit:U,...I}=F;return L==="shrink"?I:{...I,fit:L}})})}):null]})}function Wye(e){if(!e)return"";const t=dh(e);if(!t)return"";const n=t.toLowerCase(),s=Tk.find(o=>o.key===n);return s?s.key:`face:${n}`}function Yye({target:e,resolved:t,isSlide:n}){const s=ae(C=>C.index.faces),[o,r]=T.useState(!1),[i,l]=T.useState(""),u=Ht(e,"font-family"),d=u.mixed?null:Wye(u.value),f=T.useMemo(()=>$me(),[s,o]),h=T.useMemo(()=>{const C=Object.values(s).map(A=>A.family),k=new Set(C.map(A=>A.toLowerCase())),M=[{key:"",label:n?"System font":"Style default",css:""}];for(const A of C)M.push({key:`face:${A.toLowerCase()}`,label:A,css:og(A),preview:og(A)});const j=u.mixed?null:dh(u.value);j&&!(A=>k.has(A.toLowerCase())||Tk.some(N=>N.key===A.toLowerCase())||!!Gu(A)||D0.some(N=>N.family.toLowerCase()===A.toLowerCase()))(j)&&M.push({key:`face:${j.toLowerCase()}`,label:j,css:u.value,preview:u.value});for(const A of Tk)M.push({key:A.key,label:A.label,css:A.css,preview:A.css});const $=[...D0.map(A=>({family:A.family,google:!1})),...Cb.map(A=>({family:A.family,google:!0}))].filter(A=>!k.has(A.family.toLowerCase())).sort((A,N)=>A.family.localeCompare(N.family));for(const A of $)M.push({key:`face:${A.family.toLowerCase()}`,label:A.family,css:og(A.family),preview:og(A.family),google:A.google,disabled:A.google&&!f});return M},[s,u.value,u.mixed,n,f]),g=i.trim().toLowerCase(),y=g?h.filter(C=>C.label.toLowerCase().includes(g)):h,b=h.find(C=>C.key===d),v=t?.family&&!/^(?:system-ui|-apple-system|blinkmacsystemfont)$/i.test(t.family)?t.family:"System font",w=u.mixed?"Mixed":d?b?.label??dh(u.value)??"":t?v:n?"System font":"Style default",S=C=>{if(r(!1),l(""),C.google){const k=Gu(C.label);I5(e,C.css,TH(k))}else I5(e,C.css,null)};return p.jsx(Be,{label:"Font",onReset:u.value&&!u.mixed?()=>ht(e,"font-family","","Font"):void 0,children:p.jsxs(Sy,{open:o,onOpenChange:C=>{r(C),C?j0e():l("")},children:[p.jsxs(ky,{"aria-label":`Font: ${w}`,className:Ie(hd,"flex w-full min-w-0 cursor-default items-center gap-1.5 pl-2 pr-[5px] text-left data-[popup-open]:shadow-[inset_0_0_0_1px_var(--color-chrome-accent)]"),children:[p.jsx("span",{className:Ie("min-w-0 flex-1 truncate",u.mixed?"text-chrome-muted":!d&&"text-chrome-secondary"),children:w}),p.jsx(Fo,{className:"size-4 shrink-0 text-chrome-muted",strokeWidth:1.5})]}),p.jsx(Ey,{children:p.jsx(Cy,{side:"bottom",align:"end",sideOffset:4,collisionPadding:8,className:"z-[1000]",children:p.jsxs(Ty,{className:"flex w-64 flex-col overflow-hidden rounded-[14px] bg-chrome text-chrome-fg shadow-chrome-popup outline-none",children:[p.jsx("div",{className:"p-2 pb-1",children:p.jsx(Eb,{autoFocus:!0,"aria-label":"Search fonts",placeholder:"Search fonts",value:i,onChange:C=>l(C.target.value)})}),p.jsxs("div",{role:"listbox","aria-label":"Fonts",className:"max-h-80 overflow-y-auto p-1.5 pt-1",children:[y.map(C=>p.jsxs("button",{type:"button",role:"option","aria-selected":C.key===d,disabled:C.disabled,title:C.disabled?iH:void 0,onClick:()=>S(C),className:"flex h-7 w-full cursor-default items-center gap-2 rounded-[8px] pl-2 pr-2.5 text-left text-[13px] outline-none hover:bg-chrome-hover focus-visible:bg-chrome-hover disabled:opacity-40",children:[p.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:C.key===d?p.jsx(Ni,{className:"size-4 text-chrome-accent",strokeWidth:2.25}):null}),p.jsx("span",{className:"min-w-0 flex-1 truncate",style:C.preview?{fontFamily:C.preview}:void 0,children:C.label})]},C.key||"default")),y.length===0?p.jsx("p",{className:"px-2 py-2 text-[12px] text-chrome-muted",children:"No matches"}):null]})]})})})]})})}function Kye({target:e,resolved:t}){const n=Ht(e,"font-family"),s=Ht(e,"font-weight"),o=Ht(e,"font-style"),r=s.mixed||o.mixed,i=s.value!==void 0||o.value!==void 0,l=t?{weight:t.weight,italic:t.italic}:null,u=i?{weight:qye(s.value)??l?.weight??400,italic:o.value==="italic"}:null,d=(n.mixed?null:dh(n.value))??t?.family??null,f=$0e(d,u??l).map(h=>({value:c_(h),label:l_(h)}));return p.jsx(Be,{label:"Weight",onReset:i&&!r?()=>yo(e,"Font weight",{"font-weight":void 0,"font-style":void 0}):void 0,children:p.jsx(Ss,{"aria-label":"Weight",value:r||!u?null:c_(u),placeholder:r?"Mixed":l?l_(l):"Regular",inherited:!r,options:f,onChange:h=>{const g=O0e(h);g&&yo(e,"Font weight",{"font-weight":String(g.weight),"font-style":g.italic?"italic":void 0})}})})}const Xye={"background-clip":"text","-webkit-text-fill-color":"transparent"},O_={background:void 0,"background-clip":void 0,"-webkit-text-fill-color":void 0},Zye="repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0 / 8px 8px";function Qye({target:e,resolved:t}){const n=zi(),s=Ht(e,"color"),o=Ht(e,"background"),r=Ht(e,"background-clip"),i=e.nodes.length>0&&e.nodes.every(M=>Ba(M)),l=!r.mixed&&r.value==="text",u=l&&!o.mixed&&o.value?_h(o.value):null,d=u?.ok?u.value:null,f=l?HH(d):"color",[h,g]=T.useState(null),y=h??f;T.useEffect(()=>g(null),[f]);const b=(M,j,O)=>{yo(e,j,{background:Lh(M),...Xye},O)},v=M=>{M==="color"?(g(null),l&&yo(e,"Text fill",O_)):M==="gradient"?(g(null),b({gradient:d?.gradient??FH(s.value??t?.color)},"Gradient text")):g("image")},w=y==="gradient"&&d?.gradient?p.jsx(qH,{gradient:d.gradient,onChange:M=>b({gradient:M},"Text gradient","text-gradient")}):y==="image"?p.jsx(yye,{image:d?.image??null,onImage:M=>b({image:M},"Picture text")}):null,S=y==="color"?null:Nk(d)??{swatch:Zye,label:y==="image"?"Image":"Linear"},C=s.mixed?null:s.value??null,k=y==="color"&&!s.mixed?dH(e,{kind:"text",color:C??t?.color??null,...t?{size:t.size,weight:t.weight}:{}}):null;return p.jsx(Xh,{label:"Color","aria-label":"Text color",value:C,mixed:s.mixed,effective:t?.color??null,emptyLabel:"Theme default",groups:n,preview:S,contrast:k,onReset:C?()=>ht(e,"color","","Text color"):void 0,onCommit:M=>{g(null),yo(e,"Text color",{color:M??void 0,...l?O_:{}},"text-color")},...i?{kinds:{value:y,options:BH(["color","gradient","image"]),onChange:M=>v(M),content:w}}:{}})}const _k="open-artifact-slides:properties-width",z0=304,YH=285;function KH(){return Math.min(560,window.innerWidth-120)}function Og(e){return Math.round(Math.max(YH,Math.min(KH(),e)))}function Jye(){try{const e=Number(localStorage.getItem(_k));return e?Og(e):z0}catch{return z0}}function ebe(e){try{e===z0?localStorage.removeItem(_k):localStorage.setItem(_k,String(e))}catch{}}function tbe(){const[e,t]=T.useState(Jye),n=T.useRef(null);T.useEffect(()=>{const d=()=>t(f=>Og(f));return window.addEventListener("resize",d),()=>window.removeEventListener("resize",d)},[]);const s=d=>{const f=Og(d);t(f),ebe(f)},o=d=>{d.button===0&&(d.preventDefault(),d.currentTarget.setPointerCapture(d.pointerId),n.current={x:d.clientX,width:e})},r=d=>{n.current&&t(Og(n.current.width+n.current.x-d.clientX))},i=d=>{n.current&&(s(n.current.width+n.current.x-d.clientX),n.current=null)},l=d=>{const f=d.shiftKey?48:16;if(d.key==="ArrowLeft")s(e+f);else if(d.key==="ArrowRight")s(e-f);else return;d.preventDefault()},u=p.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize the properties panel","aria-valuenow":e,"aria-valuemin":YH,"aria-valuemax":KH(),tabIndex:0,title:"Drag to resize. Double-click to reset.",onPointerDown:o,onPointerMove:r,onPointerUp:i,onPointerCancel:i,onDoubleClick:()=>s(z0),onKeyDown:l,className:"group absolute inset-y-0 -left-1 z-10 flex w-2 cursor-col-resize justify-center outline-none",children:p.jsx("span",{className:"h-full w-px bg-transparent transition-colors group-hover:bg-chrome-accent group-focus-visible:bg-chrome-accent group-active:bg-chrome-accent"})});return{width:e,handle:u}}const nbe={none:"None",fade:"Fade",push:"Push",magic:"Magic move"},N_="How this slide leaves for the next one in Present",sbe="Magic move animates elements this slide shares with the next one into their new place. Duplicate the slide, then move or resize — duplicates keep the element identity that pairs them up.",XH="open-artifact-slides:properties-tab";function obe(){try{return localStorage.getItem(XH)==="theme"?"theme":"properties"}catch{return"properties"}}function rbe(){const[e,t]=T.useState(obe);return[e,s=>{t(s);try{localStorage.setItem(XH,s)}catch{}}]}function ibe(){const{slide:e,slideId:t,readOnly:n,paths:s,nodes:o}=yb(),{width:r,handle:i}=tbe(),[l,u]=rbe(),d=T.useMemo(()=>e?{slide:e,paths:o.length?s:[[]],nodes:o}:null,[e,s,o]);let f=null;return n?f=p.jsx(di,{className:"py-4",children:"This presentation is read-only here, so its properties can’t be edited."}):e&&d&&t&&(f=o.length===0?p.jsx(abe,{target:d}):p.jsxs(p.Fragment,{children:[p.jsx(lbe,{target:d,nodes:o}),p.jsx(G0e,{target:d})]})),p.jsxs("aside",{"data-open-artifact-properties":!0,"aria-label":"Properties",style:{width:r},className:"relative flex h-full shrink-0 flex-col border-l border-chrome-sep bg-chrome text-chrome-fg",children:[i,p.jsx("div",{className:"shrink-0 border-b border-chrome-sep px-3 py-2",children:p.jsx(As,{"aria-label":"Panel",value:l,options:[{value:"properties",label:"Properties"},{value:"theme",label:"Theme"}],onChange:u})}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden overscroll-contain pb-1",children:l==="theme"?p.jsx(q0e,{}):f})]})}function abe({target:e}){const{slide:t}=e;return p.jsxs(p.Fragment,{children:[p.jsx(ss,{title:"Slide",children:p.jsx(Be,{label:"Transition",tip:N_,children:p.jsx(Ss,{"aria-label":"Transition",title:N_,value:t.transition??"none",options:["none",...Q2].map(n=>({value:n,label:nbe[n]})),onChange:n=>jn("Transition",s=>bte(s,n==="none"?void 0:n))})})}),p.jsx(WH,{target:e,fillLabel:"Background",opacity:!1,radius:!1,border:!1}),p.jsx(di,{className:"pt-3",children:sbe})]})}function lbe({target:e,nodes:t}){const n=new Set(t.map(u=>u.kind)),s=n.size===1?[...n][0]:null,o=t.every(u=>u.kind==="rule"||u.kind==="shape"&&u.shape==="line"),r=t.every(Ba),i=t.some(u=>u.kind==="shape"),l=s==="connector"?null:p.jsx(WH,{target:e,fill:!o,gradients:!i&&s!=="icon",radius:!o&&s!=="icon"&&s!=="svg"&&!t.some(u=>u.kind==="shape"&&u.shape!=="rect"&&u.shape!=="rounded"),border:!o&&s!=="svg"&&s!=="embed",buildControlled:t.some(u=>u.buildIn||u.buildOut)});return p.jsxs(p.Fragment,{children:[p.jsx(iye,{target:e}),p.jsx(fye,{target:e}),p.jsx(Vme,{target:e}),p.jsx(tge,{target:e}),p.jsx(Qme,{target:e}),p.jsx(Jme,{target:e}),p.jsx(Yme,{target:e}),p.jsx(Kme,{target:e}),r?null:l,p.jsx(Gye,{target:e}),r?l:null,p.jsx(Lye,{target:e})]})}const cbe="open-artifact-slides-speaker",ZH="open-artifact-speaker-root",QH='style, link[rel="stylesheet"]';function ube(){const e=window.open("",cbe,"popup,width=1100,height=720");if(!e)return null;const t=e.document;t.title="Speaker notes",t.head.replaceChildren(),t.body.replaceChildren();const n=t.createElement("meta");n.setAttribute("charset","utf-8"),t.head.appendChild(n);for(const r of document.head.querySelectorAll(QH))t.head.appendChild(t.importNode(r,!0));rb(t);const s=document.documentElement.getAttribute("data-theme");s?t.documentElement.setAttribute("data-theme",s):t.documentElement.removeAttribute("data-theme"),t.body.className="m-0 bg-canvas text-fg antialiased";const o=t.createElement("div");return o.id=ZH,o.className="h-screen",t.body.appendChild(o),e}function dbe(e){const t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/3600),s=Math.floor(t%3600/60),o=String(t%60).padStart(2,"0");return n?`${n}:${String(s).padStart(2,"0")}:${o}`:`${s}:${o}`}function K1({slide:e,done:t,width:n}){const s=T.useMemo(()=>sh(e),[e]),o=T.useMemo(()=>l8(e,s,t,!1),[e,s,t]),r=T.useMemo(()=>({mode:"thumb",resolveSrc:wo,builds:o}),[o]),i=n/ot;return p.jsx("div",{className:"relative overflow-hidden rounded-md bg-white ring-1 ring-line",style:{width:n,height:vt*i},children:p.jsx("div",{className:"pointer-events-none absolute left-0 top-0 origin-top-left",style:{width:ot,height:vt,transform:`scale(${i})`},children:p.jsx(fd,{slide:e,options:r})})})}function fbe({popup:e,onClosed:t,...n}){const s=e.document.getElementById(ZH),o=ae(r=>r.index.faces);return T.useEffect(()=>{fb(o,wo,e.document)},[o,e]),T.useEffect(()=>{const r=new MutationObserver(i=>{for(const l of i)for(const u of l.addedNodes)u instanceof Element&&u.matches(QH)&&!u.hasAttribute("data-open-artifact-face")&&e.document.head.appendChild(e.document.importNode(u,!0))});return r.observe(document.head,{childList:!0}),()=>r.disconnect()},[e]),T.useEffect(()=>{const r=setInterval(()=>{e.closed&&t()},500);return()=>clearInterval(r)},[e,t]),s?Jn.createPortal(p.jsx(hbe,{popup:e,...n}),s):null}function hbe({popup:e,position:t,index:n,count:s,steps:o,nextId:r,clock:i,onClock:l,onNext:u,onPrevious:d}){const f=ae(A=>A.slides[t.id]?.slide),h=ae(A=>r?A.slides[r]?.slide:void 0),[g,y]=T.useState(Date.now()),[b,v]=T.useState(e.innerWidth),[w,S]=T.useState(20);if(T.useEffect(()=>{const A=setInterval(()=>y(Date.now()),500),N=()=>v(e.innerWidth);return e.addEventListener("resize",N),()=>{clearInterval(A),e.removeEventListener("resize",N)}},[e]),!f)return null;const C=i.pausedAt!==null,k=(i.pausedAt??g)-i.startedAt,M=t.done<o,j=M?`Next: build ${t.done+1} of ${o}`:h?`Next: slide ${n+2}`:"End of presentation",O=Math.max(240,Math.floor(b*.56)-32),$=Math.max(160,b-O-72);return p.jsxs("div",{className:"flex h-full flex-col gap-3 p-4",children:[p.jsxs("header",{className:"flex items-center gap-3",children:[p.jsxs("span",{className:"text-sm font-medium tabular-nums",children:["Slide ",n+1," of ",s]}),p.jsx("span",{className:"flex-1"}),p.jsx("span",{className:Ie("font-mono text-2xl tabular-nums",C&&"text-fg-muted"),"aria-label":"Elapsed time",children:dbe(k)}),p.jsx(da,{noTooltip:!0,label:C?"Resume timer":"Pause timer",icon:C?p.jsx(Zf,{className:"size-4"}):p.jsx(VW,{className:"size-4"}),onClick:()=>l(C?{startedAt:i.startedAt+(Date.now()-i.pausedAt),pausedAt:null}:{startedAt:i.startedAt,pausedAt:Date.now()})}),p.jsx(da,{noTooltip:!0,label:"Reset timer",icon:p.jsx(_u,{className:"size-4"}),onClick:()=>l({startedAt:Date.now(),pausedAt:C?Date.now():null})})]}),p.jsxs("div",{className:"flex min-h-0 flex-1 gap-6",children:[p.jsxs("div",{className:"flex min-w-0 flex-col gap-3",style:{width:O},children:[p.jsx(K1,{slide:f,done:t.done,width:O}),p.jsxs("div",{className:"flex min-h-0 flex-1 flex-col rounded-md border border-line bg-surface",children:[p.jsxs("div",{className:"flex items-center gap-1 border-b border-line px-3 py-1 text-xs text-fg-muted",children:[p.jsx("span",{className:"flex-1",children:"Speaker notes"}),p.jsx(Ot,{size:"sm",variant:"ghost","aria-label":"Smaller notes",onClick:()=>S(A=>Math.max(12,A-2)),children:"A−"}),p.jsx(Ot,{size:"sm",variant:"ghost","aria-label":"Larger notes",onClick:()=>S(A=>Math.min(48,A+2)),children:"A+"})]}),p.jsx("div",{className:"min-h-0 flex-1",style:{fontSize:w},children:p.jsx($C,{slideId:t.id,className:"h-full w-full resize-none bg-transparent px-3 py-2 leading-relaxed text-fg outline-none placeholder:text-fg-subtle [font-size:inherit]"},t.id)})]})]}),p.jsxs("div",{className:"flex min-w-0 flex-col gap-2",style:{width:$},children:[p.jsx("div",{className:"text-xs font-medium text-fg-muted",children:j}),M?p.jsx(K1,{slide:f,done:t.done+1,width:$}):h?p.jsx(K1,{slide:h,done:0,width:$}):p.jsx("div",{className:"flex items-center justify-center rounded-md border border-dashed border-line text-xs text-fg-subtle",style:{width:$,height:$*9/16},children:"End of presentation"}),p.jsxs("div",{className:"mt-2 flex gap-2",children:[p.jsx(Ot,{icon:p.jsx(wL,{className:"size-4"}),disabled:n===0&&t.done===0,onClick:d,children:"Previous"}),p.jsxs(Ot,{variant:"primary",disabled:!M&&!h,onClick:u,children:["Next",p.jsx(z2,{className:"size-4"})]})]})]})]})]})}const rg="cubic-bezier(0.33, 0.01, 0.2, 1)";function Lk(){return typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function pbe(e,t,n){const s=n>0?e.transition:t.transition;return s&&Q2.includes(s)?s:null}function $_(e){const t=new Map;return e.slide.children.forEach((n,s)=>{if(!n.id)return;const o=e.root.querySelector(`[data-open-artifact-path="${s}"]`);o&&t.set(n.id,o)}),t}const __=e=>({x:e.left+e.width/2,y:e.top+e.height/2});function mbe(e,t,n,s,o){const r=a8[e],i=[];if(e==="push")i.push(t.root.animate([{transform:"translateX(0)"},{transform:`translateX(${-s*ot}px)`}],{duration:r,easing:rg,fill:"forwards"}),n.root.animate([{transform:`translateX(${s*ot}px)`},{transform:"translateX(0)"}],{duration:r,easing:rg}));else if(e==="magic"){const d=$_(t);for(const[f,h]of $_(n)){const g=d.get(f);if(!g)continue;const y=g.getBoundingClientRect(),b=h.getBoundingClientRect();if(!y.width||!y.height||!b.width||!b.height)continue;const v=__(y),w=__(b),S=(v.x-w.x)/o,C=(v.y-w.y)/o,k=y.width/b.width,M=y.height/b.height;i.push(h.animate([{translate:`${S}px ${C}px`,scale:`${k} ${M}`},{translate:"0px 0px",scale:"1 1"}],{duration:r,easing:rg}),g.animate([{translate:"0px 0px",scale:"1 1"},{translate:`${-S}px ${-C}px`,scale:`${1/k} ${1/M}`}],{duration:r,easing:rg,fill:"forwards"}))}i.push(n.root.animate([{opacity:0},{opacity:1}],{duration:r,easing:"ease"}))}else i.push(n.root.animate([{opacity:0},{opacity:1}],{duration:r,easing:"ease"}));const l=()=>{for(const d of i)try{d.finish()}catch{}};return{done:Promise.all(i.map(d=>d.finished.catch(()=>{}))).then(()=>{for(const d of i)d.cancel()}),finish:l}}const L_="open-artifact-deck-motion";let X1;function gbe(){const e=Ine()?.sheet.motion??[];if(X1?.rules!==e){X1={rules:e,read:Ire(e)};let t=document.getElementById(L_);t||(t=document.createElement("style"),t.id=L_,document.head.append(t)),t.textContent=e.join(`
|
|
569
|
-
`)}return X1.read}function D_(e,t){const n=new Map,s=e.querySelector("[data-open-artifact-slide]");s&&n.set(0,{element:s});const o=(r,i)=>{r.forEach((l,u)=>{const d=[...i,u];if(l.origin!==void 0){const h=e.querySelector(`[data-open-artifact-path="${d.join(".")}"]`);h&&n.set(l.origin,{element:h,node:l})}const f=l.children;Array.isArray(f)&&o(f,d)})};return o(t.children,[]),n}function ybe(e,t){const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let s=null;for(let f=n.nextNode();f;f=n.nextNode())if(GS(f.data)){s=f;break}if(!s)return()=>{};const o=s,r=o.data,i=GS(r).value,l=performance.now()+t.delay;let u=0;const d=f=>{const h=t.duration>0?(f-l)/t.duration:1;o.data=h>=1?r:T$(r,t.from+(i-t.from)*Ure(h)),h<1&&(u=requestAnimationFrame(d))};return o.data=T$(r,t.from),u=requestAnimationFrame(d),()=>{cancelAnimationFrame(u),o.data=r}}function bbe(e,t,n,s){const o=t.motion;T.useLayoutEffect(()=>{const i=e.current;if(!s||!o||!i||Lk())return;const{keyframes:l,properties:u}=gbe(),d=D_(i,t),f=[];let h="";const g=`open-artifact-start-${Math.random().toString(36).slice(2,8)}`,y=new Set([...Object.keys(o.elements),...Object.keys(o.starting)].map(Number));for(const v of y){const w=d.get(v);if(!w||w.node?.buildIn||w.node?.buildOut)continue;const S=o.elements[v]??{},C=Bre(Dre(S),l),k=o.starting[v],M=k?Gre(`${g}-${v}`,k,S):null;M&&(h+=M.keyframes);const j=[...C,...M?.animations??[]];if(j.length===0)continue;const O=w.element;O.style.animation=j.map(zre).join(", ");const $=Fre(C,l,u),A=$?ybe(O,$):void 0;f.push(()=>{O.style.animation="",A?.()})}let b;return h&&(b=document.createElement("style"),b.textContent=h,document.head.append(b)),()=>{for(const v of f)v();b?.remove()}},[e,t,o,s]);const r=T.useMemo(()=>[...n].sort((i,l)=>i-l).join(","),[n]);T.useLayoutEffect(()=>{const i=e.current;if(!i||!o?.fragments.length)return;const l=D_(i,t),u=Lk()?"":`opacity ${oh}ms ease`;for(const d of o.fragments){const f=l.get(d.origin)?.element;f&&(f.style.transition=u,f.style.opacity=n.has(d.origin)?"0":"")}},[e,t,o,r])}const xbe=3e3;function z_({slide:e,done:t,animate:n,scale:s,rootRef:o,startedClips:r,onStartClip:i,className:l,motion:u=!1}){const d=T.useMemo(()=>sh(e),[e]),f=T.useMemo(()=>l8(e,d,t,n),[e,d,t,n]),h=T.useMemo(()=>Ere(e,d,t),[e,d,t]),g=T.useMemo(()=>({mode:"present",resolveSrc:wo,builds:f,startedClips:r,onStartClip:i}),[f,r,i]),y=T.useRef(null);return bbe(y,e,h,u),p.jsx("div",{ref:y,className:Ie("absolute left-1/2 top-1/2",l),style:{width:ot*s,height:vt*s,translate:"-50% -50%"},children:p.jsx("div",{className:"origin-top-left overflow-hidden",style:{width:ot,height:vt,transform:`scale(${s})`},children:p.jsx(fd,{slide:e,options:g,rootRef:o})})})}function vbe(){const e=se(t=>t.presenting);return e?p.jsx(wbe,{start:e.start,speaker:e.speaker},e.start):null}function wbe({start:e,speaker:t}){const n=ae(wE(()=>Sr())),[s,o]=T.useState({id:e,done:0,animate:!1}),r=Math.max(0,n.indexOf(s.id)),i=ae(X=>X.slides[s.id]?.slide),l=T.useMemo(()=>i?sh(i):[],[i]),[u,d]=T.useState(null),[f,h]=T.useState(()=>new Set),[g,y]=T.useState(!0),[b,v]=T.useState(!1),[w,S]=T.useState(!1),[C,k]=T.useState(null),[M,j]=T.useState(()=>({startedAt:Date.now(),pausedAt:null})),O=T.useRef(null),$=T.useRef(null),A=T.useRef(null),N=T.useRef(null),_=T.useRef(null),[D,P]=T.useState({w:window.innerWidth,h:window.innerHeight}),L=t&&w,F=L?D.h*.72:D.h,U=Math.min(D.w/ot,F/vt);T.useEffect(()=>{if(n.length===0){se.getState().present(null);return}n.includes(s.id)||o({id:n[Math.min(r,n.length-1)],done:0,animate:!1})},[n,s.id,r]);const I=T.useCallback((X,Z,ne={})=>{const me=Sr()[X];if(!me||me===s.id)return;N.current?.();const ie=ae.getState(),he=ie.slides[s.id]?.slide,ke=ie.slides[me]?.slide;if(!ke)return;const Ne=ne.allDone?sh(ke).length:0,Pe=!ne.cut&&he&&!Lk()?pbe(he,ke,Z):null;d(Pe&&he?{slide:he,done:s.done,direction:Z,kind:Pe}:null),h(new Set),o({id:me,done:Ne,animate:!1})},[s]),H=T.useCallback(()=>{if(u){N.current?.();return}if(s.done<l.length){o(X=>({...X,done:X.done+1,animate:!0}));return}r<n.length-1&&I(r+1,1)},[u,s.done,l.length,r,n.length,I]),q=T.useCallback(()=>{if(u&&N.current?.(),s.done>0){o(X=>({...X,done:X.done-1,animate:!1}));return}r>0&&I(r-1,-1,{allDone:!0})},[u,s.done,r,I]),G=T.useCallback(()=>{const X=s.id;document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),se.getState().present(null),se.getState().showSlide(X)},[s.id]);T.useEffect(()=>{if(u||!l[s.done]?.auto)return;const Z=setTimeout(()=>o(ne=>ne.id===s.id?{...ne,done:ne.done+1,animate:!0}:ne),s.done===0?0:oh);return()=>clearTimeout(Z)},[u,l,s.id,s.done]),T.useLayoutEffect(()=>{if(!u||!A.current||!$.current||!i)return;const X=mbe(u.kind,{slide:u.slide,root:A.current},{slide:i,root:$.current},u.direction,U);let Z=!0;return N.current=X.finish,X.done.then(()=>{Z&&(N.current=null,d(null))}),()=>{Z=!1}},[u]);const Y=T.useRef({text:"",timer:null}),B=T.useCallback(X=>{if(X.target?.closest('textarea, input, [contenteditable="true"]')||X.metaKey||X.ctrlKey||X.altKey)return;const ne=X.key;if(/^[0-9]$/.test(ne)){const ce=Y.current;ce.text=(ce.text+ne).slice(-3),ce.timer&&clearTimeout(ce.timer),ce.timer=setTimeout(()=>{const me=Number(ce.text);ce.text="",me>=1&&me<=Sr().length&&I(me-1,me-1>=r?1:-1,{cut:!0})},500);return}switch(ne){case"ArrowRight":case"ArrowDown":case"PageDown":case" ":case"Enter":case"n":X.preventDefault(),H();return;case"ArrowLeft":case"ArrowUp":case"PageUp":case"Backspace":case"p":X.preventDefault(),q();return;case"Home":X.preventDefault(),I(0,-1,{cut:!0});return;case"End":X.preventDefault(),I(Sr().length-1,1,{cut:!0,allDone:!0});return;case"f":case"F":X.preventDefault(),P_(O.current);return;case"Escape":X.preventDefault(),G();return}},[H,q,I,G,r]);T.useEffect(()=>(window.addEventListener("keydown",B),C?.addEventListener("keydown",B),()=>{window.removeEventListener("keydown",B),C?.removeEventListener("keydown",B)}),[B,C]),T.useEffect(()=>{const X=()=>P({w:window.innerWidth,h:window.innerHeight}),Z=()=>v(!!document.fullscreenElement);return window.addEventListener("resize",X),document.addEventListener("fullscreenchange",Z),O.current?.requestFullscreen&&!document.fullscreenElement&&O.current.requestFullscreen().catch(()=>{}),()=>{window.removeEventListener("resize",X),document.removeEventListener("fullscreenchange",Z)}},[]);const W=T.useRef(null),K=T.useCallback(()=>{y(!0),W.current&&clearTimeout(W.current),W.current=setTimeout(()=>y(!1),xbe)},[]);T.useEffect(()=>(K(),()=>{W.current&&clearTimeout(W.current)}),[K]);const Q=T.useCallback(()=>{if(C&&!C.closed){C.focus();return}const X=ube();if(!X){S(!0),tt.add({title:"The speaker window was blocked",description:"Speaker notes show under the slide instead. Allow pop-ups for this site to open them in their own window."});return}S(!1),k(X)},[C]);T.useEffect(()=>{t&&Q()},[]),T.useEffect(()=>()=>C?.close(),[C]);const J=T.useCallback(X=>h(Z=>new Set([...Z,X])),[]);if(!i)return null;const te=n[r+1]??null;return p.jsxs("div",{ref:O,role:"dialog","aria-modal":!0,"aria-label":"Presentation",className:Ie("fixed inset-0 z-[2000] select-none overflow-hidden bg-black",!g&&"cursor-none"),onPointerMove:K,onPointerDown:X=>{_.current={x:X.clientX,y:X.clientY}},onPointerUp:X=>{const Z=_.current;if(_.current=null,!Z)return;const ne=X.clientX-Z.x;X.pointerType!=="mouse"&&Math.abs(ne)>50&&Math.abs(ne)>Math.abs(X.clientY-Z.y)&&(ne<0?H():q())},onClick:X=>{X.target.closest("a, button, video, iframe, [data-presenter-controls], [data-presenter-notes]")||X.detail>1||H()},onContextMenu:X=>{X.preventDefault(),q()},children:[p.jsxs("div",{className:"absolute inset-x-0 top-0",style:{height:F},children:[u?p.jsx(z_,{slide:u.slide,done:u.done,animate:!1,scale:U,rootRef:A,className:"z-[1]"}):null,p.jsx(z_,{slide:i,done:s.done,animate:s.animate,scale:U,rootRef:$,startedClips:f,onStartClip:J,className:"z-[2]",motion:!0},s.id)]}),L?p.jsxs("div",{"data-presenter-notes":!0,className:"absolute inset-x-0 bottom-0 flex flex-col border-t border-white/15 bg-neutral-950 text-white",style:{height:D.h-F},children:[p.jsxs("div",{className:"px-4 pt-2 text-[11px] uppercase tracking-wide text-white/50",children:["Speaker notes · Slide ",r+1," of ",n.length]}),p.jsx($C,{slideId:s.id,className:"h-full w-full resize-none bg-transparent px-4 py-2 text-lg leading-relaxed text-white outline-none placeholder:text-white/40"},s.id)]}):null,p.jsxs("div",{"data-presenter-controls":!0,className:Ie("absolute bottom-4 left-1/2 flex -translate-x-1/2 items-center gap-1 rounded-full bg-neutral-900/85 px-2 py-1 text-white shadow-lg backdrop-blur transition-opacity duration-300",g?"opacity-100":"pointer-events-none opacity-0"),style:L?{bottom:D.h-F+16}:void 0,children:[p.jsx(da,{label:"Previous",shortcut:"←",icon:p.jsx(wL,{className:"size-4"}),className:"text-white hover:bg-white/15 hover:text-white",disabled:r===0&&s.done===0,onClick:q}),p.jsxs("span",{className:"min-w-16 text-center text-xs tabular-nums text-white/80",children:[r+1," / ",n.length]}),p.jsx(da,{label:"Next",shortcut:"→",icon:p.jsx(z2,{className:"size-4"}),className:"text-white hover:bg-white/15 hover:text-white",disabled:r===n.length-1&&s.done>=l.length,onClick:H}),p.jsx("span",{className:"mx-1 h-4 w-px bg-white/20"}),p.jsx(da,{label:"Speaker notes",icon:p.jsx(sY,{className:"size-4"}),className:"text-white hover:bg-white/15 hover:text-white",onClick:Q}),p.jsx(da,{label:b?"Exit full screen":"Full screen",shortcut:"F",icon:b?p.jsx(FW,{className:"size-4"}):p.jsx(I2,{className:"size-4"}),className:"text-white hover:bg-white/15 hover:text-white",onClick:()=>P_(O.current)}),p.jsx(da,{label:"Stop presenting",shortcut:"Esc",icon:p.jsx(_i,{className:"size-4"}),className:"text-white hover:bg-white/15 hover:text-white",onClick:G})]}),C?p.jsx(fbe,{popup:C,position:s,index:r,count:n.length,steps:l.length,nextId:te,clock:M,onClock:j,onNext:H,onPrevious:q,onClosed:()=>k(null)}):null]})}function P_(e){document.fullscreenElement?document.exitFullscreen().catch(()=>{}):e?.requestFullscreen?.().catch(()=>{})}const yi=Ns()(()=>({drag:null})),Sbe=5;function kbe(e,t){const n=[...e.querySelectorAll("[data-section-row]")];let s=n.length;for(const o of n){const r=o.getBoundingClientRect();if(t<r.top+r.height/2){s=Number(o.dataset.sectionRow);break}}return s}function Ebe(e,t){if(e.button!==0||!hn())return;const n=e.currentTarget.closest("[data-section-rows]");if(!n)return;const s=[...n.querySelectorAll("[data-section-row]")].map(y=>y.dataset.sectionKey||null),o=e.clientX,r=e.clientY;let i=!1;const l=()=>{const y=se.getState().sectionSelection,b=y.includes(t)?y:[t];return s.filter(v=>v!==null&&b.includes(v))},u=y=>{if(!i){if(Math.hypot(y.clientX-o,y.clientY-r)<Sbe)return;i=!0,document.body.style.cursor="grabbing"}yi.setState({drag:{keys:l(),gap:kbe(n,y.clientY)}});const b=n.closest("[data-section-scroll]");if(b){const v=b.getBoundingClientRect();y.clientY<v.top+32?b.scrollBy(0,-12):y.clientY>v.bottom-32&&b.scrollBy(0,12)}},d=y=>{window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",h),window.removeEventListener("keydown",g,!0),document.body.style.cursor="";const b=yi.getState().drag;if(yi.setState({drag:null}),!i){y&&se.getState().sectionSelection.length>1&&se.getState().selectSections([t]);return}y&&b&&b.gap!==null&&b.keys.length&&Yoe(b.keys,b.gap)},f=()=>d(!0),h=()=>d(!1),g=y=>{y.key!=="Escape"||!i||(y.preventDefault(),y.stopPropagation(),d(!1))};window.addEventListener("pointermove",u),window.addEventListener("pointerup",f),window.addEventListener("pointercancel",h),window.addEventListener("keydown",g,!0)}const JH=T.memo(function({id:t,index:n,comments:s,peers:o,dragging:r,dropBefore:i,dropAfter:l,onPointerDown:u,onOpen:d,width:f}){const h=ae(S=>S.slides[t]),g=se(S=>S.current===t),y=se(S=>S.slideSelection.includes(t)),b=uB(t);if(!h)return null;const v=h.held??(h.conflict?"Changed elsewhere at the same time":null),w=Gl(h.slide);return p.jsxs(xb,{menu:p.jsx(vb,{ids:se.getState().slideSelection.includes(t)?qo():[t]}),onOpen:()=>{se.getState().slideSelection.includes(t)||se.getState().showSlide(t)},className:"relative shrink-0 outline-none",style:f?{width:f}:void 0,children:[i?p.jsx("span",{"aria-hidden":!0,className:"absolute -left-[13px] inset-y-0 w-1 rounded bg-accent"}):null,l?p.jsx("span",{"aria-hidden":!0,className:"absolute -right-[13px] inset-y-0 w-1 rounded bg-accent"}):null,p.jsxs("div",{"data-slide-index":n,"data-slide-id":t,role:"option","aria-selected":y||g,"aria-label":`Slide ${n+1}${w?`: ${w}`:""}`,onPointerDown:S=>u(S,t),onDoubleClick:()=>d(t),className:Ie("group cursor-default",r&&"opacity-40",b&&"oa-arrive"),children:[p.jsxs("div",{className:Ie("relative overflow-hidden rounded-md ring-1 ring-line transition-shadow",y||g?"ring-2 ring-accent":"group-hover:ring-line-strong",h.slide.hidden&&"opacity-50"),children:[p.jsx(Xl,{slide:h.slide,virtual:!0}),p.jsxs("div",{className:"pointer-events-none absolute bottom-1.5 right-1.5 flex items-center gap-1",children:[p.jsx(NC,{peers:o}),s?p.jsxs("span",{className:"flex items-center gap-0.5 rounded-full bg-surface px-1.5 text-[10px] text-fg shadow-popup",children:[p.jsx(Rr,{className:"size-2.5"}),s]}):null]})]}),p.jsxs("div",{className:"flex items-center gap-1.5 pt-1.5 text-[11px] text-fg-muted",children:[p.jsx("span",{className:Ie("tabular-nums",(y||g)&&"font-semibold text-fg"),children:n+1}),p.jsx("span",{className:"min-w-0 flex-1 truncate",children:w}),h.slide.hidden?p.jsx(Mh,{className:"size-3 shrink-0","aria-label":"Skipped"}):null,v?p.jsx(Sa,{className:"size-3 shrink-0 text-warning","aria-label":v}):null]})]})]})});function qC({section:e,n:t,ids:n,previousGap:s,nextGap:o,className:r}){const i=e?.key??"-",l=se(b=>b.editingSection===i),u=se(b=>b.sectionSelection.includes(i)),d=ae(b=>!b.readOnly&&!b.indexError)&&hn(),f=e?.description??"",h=`Section ${t+1}`,g=d&&(e!==null||n.length>0),y=b=>{se.getState().setEditingSection(null);const v=hE(b);v!==f&&(e?Goe(e.key,v):n[0]&&Woe(n[0],v))};return p.jsxs("div",{"data-section-label":i,className:Ie("group/label flex min-w-0 items-start gap-2 rounded-md px-1.5 py-1",u&&"bg-accent-soft",e&&d&&"cursor-grab",r),onPointerDown:b=>{const v=b.target;if(b.button!==0||v.closest("textarea")||v.closest("button")&&!v.closest("[data-section-describe]"))return;const w=se.getState(),S=b.metaKey||b.ctrlKey||b.shiftKey;S?w.selectSections(u?w.sectionSelection.filter(C=>C!==i):[...w.sectionSelection,i]):(!u||!e||!d)&&w.selectSections([i]),w.selectSlides([...n]),e&&d&&!S&&Ebe(b,e.key)},children:[p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-fg-muted",children:h}),l?p.jsx(Cbe,{initial:f,onCommit:y,onCancel:()=>se.getState().setEditingSection(null)}):p.jsx("button",{type:"button","data-section-describe":!0,disabled:!g,"aria-label":f||(g?`${h}, Describe this section`:h),className:Ie("block max-w-full truncate text-left text-sm",f?"text-fg":"text-fg-subtle",g&&"hover:text-fg"),onClick:()=>g&&se.getState().setEditingSection(i),children:f||(g?"Describe this section":"")})]}),d&&e?p.jsxs(kz,{trigger:p.jsx(da,{size:"sm",noTooltip:!0,label:`Actions for ${h}`,icon:p.jsx(P2,{className:"size-3.5"}),className:"opacity-0 group-hover/label:opacity-100 focus-visible:opacity-100 pointer-coarse:opacity-100"}),align:"end",children:[p.jsxs(ft,{onSelect:()=>se.getState().setEditingSection(i),children:["Describe ",h]}),p.jsx(ft,{disabled:s===null,onSelect:()=>s!==null&&h$(e.key,s),children:"Move section earlier"}),p.jsx(ft,{disabled:o===null,onSelect:()=>o!==null&&h$(e.key,o),children:"Move section later"}),p.jsx(ft,{icon:p.jsx(ds,{className:"size-4"}),disabled:n.length===0,onSelect:()=>{_a("blank",n.at(-1)??null)},children:"Add a slide to this section"}),p.jsx(ft,{icon:p.jsx(wy,{className:"size-4"}),danger:!0,onSelect:()=>qoe(e.key),children:"Remove section"})]}):null]})}function Cbe({initial:e,onCommit:t,onCancel:n}){const[s,o]=T.useState(e),r=T.useRef(null),i=T.useRef(!1);return T.useEffect(()=>{r.current?.focus(),r.current?.select()},[]),p.jsx("textarea",{ref:r,rows:2,value:s,maxLength:ve.sectionDescription,placeholder:"Describe this section","aria-label":"Section description",className:"mt-0.5 block w-full resize-none rounded border border-accent bg-canvas px-1.5 py-1 text-sm text-fg outline-none",onChange:l=>o(l.target.value.replace(/\n/g," ")),onBlur:()=>{i.current||(i.current=!0,t(s))},onKeyDown:l=>{l.stopPropagation(),l.key==="Enter"?(l.preventDefault(),i.current=!0,t(s)):l.key==="Escape"&&(l.preventDefault(),i.current=!0,n())}})}function GC({gap:e,after:t,className:n}){return hn()?p.jsxs(kz,{trigger:p.jsx("button",{type:"button","aria-label":"Add a slide or section here",className:Ie("flex size-6 items-center justify-center rounded-full border border-line bg-surface text-fg-muted opacity-0 shadow-popup transition-opacity hover:text-fg focus-visible:opacity-100 group-hover/gap:opacity-100 pointer-coarse:opacity-100",n),children:p.jsx(ds,{className:"size-3.5"})}),align:"center",children:[p.jsx(ft,{icon:p.jsx(ds,{className:"size-4"}),onSelect:()=>{_a("blank",t)},children:"New slide here"}),p.jsx(ft,{icon:p.jsx(bS,{className:"size-4"}),onSelect:()=>Voe(e),children:"New section here"})]}):null}const vs=480,Yu=28,ho=48,ir=96,sr=320;function Tbe(e,t,n){const s=vs*n/t,o=s+Yu,r=[],i=new Map,l=[];let u=0;e.forEach((f,h)=>{const g=h*(o+ir);l.push({row:h,section:f.section,key:f.section?.key??null,top:g,first:u,ids:f.ids,empty:f.ids.length===0?{x:sr,y:g,w:vs,h:s}:null}),f.ids.forEach((y,b)=>{const v={id:y,index:u++,row:h,x:sr+b*(vs+ho),y:g,w:vs,h:s};r.push(v),i.set(y,v)})});const d=Math.max(1,...e.map(f=>f.ids.length));return{tiles:r,byId:i,rows:l,slideH:s,tileH:o,width:sr+d*vs+(d-1)*ho,height:Math.max(1,e.length)*(o+ir)-ir}}const Dk=(e,t,n)=>t>=e.x&&t<e.x+e.w&&n>=e.y&&n<e.y+e.h;function Mbe(e,t){const n=e.tileH+ir,s=Math.floor((t+ir/2)/n);return e.rows[Math.min(e.rows.length-1,Math.max(0,s))]}function I_(e,t,n){const s=Mbe(e,n);if(!s||!s.ids.length)return null;const o=Math.floor((t-sr)/(vs+ho)),r=s.ids[o],i=r===void 0?void 0:e.byId.get(r);return i?Dk(i,t,n)?{tile:i,caption:!1}:Dk({x:i.x,y:i.y+i.h,w:i.w,h:Yu},t,n)?{tile:i,caption:!0}:null:null}function Rbe(e,t,n){for(const s of e.rows)if(s.empty&&s.key&&Dk(s.empty,t,n))return s.key;return null}function jbe(e,t,n){let s=null,o=1/0;for(const r of e.tiles){const i=r.y+e.tileH,l=t<r.x?r.x-t:t>r.x+r.w?t-r.x-r.w:0,d=(n<r.y?r.y-n:n>i?n-i:0)*4+l;d<o&&(s=r,o=d)}return s?s.index+(t>s.x+s.w/2?1:0):0}function Abe(e,t){const n=[],s=e.tiles[t],o=e.tiles[t-1];return s&&n.push({x:s.x-ho/2-2,y:s.y,w:4,h:e.tileH}),o&&(!s||s.row!==o.row)&&n.push({x:o.x+o.w+ho/2-2,y:o.y,w:4,h:e.tileH}),n}function zk(e,t){const n=[];for(const s of e.tiles)s.x<t.x+t.w&&s.x+s.w>t.x&&s.y<t.y+t.h&&s.y+e.tileH>t.y&&n.push(s);return n}function Obe(e,t){return{x:e.x-e.w*t,y:e.y-e.h*t,w:e.w*(1+t*2),h:e.h*(1+t*2)}}const yf=32,Nbe=1,$be=2,_be=3,Lbe=0,Dbe=1,zbe=2,Pbe=1,Ibe=2,Bbe=4,Hbe=8,Fbe=16,Ube=32,Vbe=64,qbe=128,Gbe=256,Wbe=512,Ybe=1024,Kbe=2048,Xbe=4096,Zbe=8192,Qbe=2,e9=0,Vf=1,B_=2,Pk=3,t9=4,eve={minZoom:1,maxZoom:2,snap:3,snapDistance:4,dragThreshold:5,hitTolerance:6,handleSize:7,settleMs:8,cameraEventMs:9,wheelZoom:10,selection:11,marquee:12,fadeMs:13,dragEvents:14,grid:15,gridSpacing:16,textureBudget:17,zoomSpeed:18,wheelZoomMax:19,gridMajor:20,gridFadeStart:21,gridFadeEnd:22},tve={background:30,grid:31,selection:32,handle:33,guide:34,marquee:35,hover:36},nve=1,sve=2,ove=4,rve=8,ive=1,ave=2,lve=3,cve={select:0,pan:1,none:2},uve={mouse:0,pen:1,touch:2},dve=["default","grab","grabbing","move","ns-resize","ew-resize","nwse-resize","nesw-resize","crosshair"],fve=1,hve=2,pve=4,Jbe={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},exe=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/;function Mb(e){const t=exe.exec(e);if(!t)return null;const n=e.slice(t[0].length);return/^(%|deg|rad|grad|turn)?$/.test(n)?{v:parseFloat(t[0]),unit:n}:null}function txe(e){const t=e.includes(","),[n,s,o]=t?[e,void 0,void 0]:e.split("/");if(o!==void 0)return null;const r=n.split(t?",":/\s+/).map(u=>u.trim()).filter(Boolean);if(t?r.length!==3&&r.length!==4:r.length!==3)return null;const i=t?r[3]:s?.trim();if(i==="")return null;const l=u=>u==="none"?"0":u;return[l(r[0]),l(r[1]),l(r[2]),i===void 0?void 0:l(i)]}function nxe(e){if(e===void 0)return 1;const t=Mb(e);return!t||t.unit&&t.unit!=="%"?NaN:t.unit==="%"?t.v/100:t.v}function sxe(e){const t=Mb(e);if(!t)return NaN;switch(t.unit){case"":case"deg":return t.v;case"rad":return t.v*180/Math.PI;case"grad":return t.v*.9;case"turn":return t.v*360;default:return NaN}}function H_(e){const t=Mb(e);return t?t.unit==="%"||t.unit===""?t.v/100:NaN:NaN}function F_(e,t,n,s){const o=(r,i)=>Math.round(Math.min(Math.max(r,0),i));return(o(e,255)<<24|o(t,255)<<16|o(n,255)<<8|o(s*255,255))>>>0}function oxe(e,t,n){const s=(e%360+360)%360,o=l=>(l+s/30)%12,r=t*Math.min(n,1-n),i=l=>n-r*Math.max(-1,Math.min(o(l)-3,9-o(l),1));return[i(0)*255,i(8)*255,i(4)*255]}function nu(e,t=0){if(e==null)return t;if(typeof e=="number")return e>>>0;const n=e.trim().toLowerCase();if(n==="transparent"||n==="none")return 0;const s=Jbe[n];if(s!==void 0)return(s<<8|255)>>>0;if(n.startsWith("#")){const l=n.slice(1);if(/^[0-9a-f]+$/.test(l)){if(l.length===3||l.length===4){const u=[...l].map(d=>d+d).join("");return parseInt(l.length===3?u+"ff":u,16)>>>0}if(l.length===6)return parseInt(l+"ff",16)>>>0;if(l.length===8)return parseInt(l,16)>>>0}}const o=/^(rgba?|hsla?)\(\s*([^()]*)\)$/.exec(n),r=o?txe(o[2]):null;if(o&&r){const[l,u,d,f]=r,h=nxe(f);if(o[1].startsWith("rgb")){const g=b=>{const v=Mb(b);return v?v.unit==="%"?v.v/100*255:v.unit===""?v.v:NaN:NaN},y=[g(l),g(u),g(d)];if([...y,h].every(Number.isFinite))return F_(y[0],y[1],y[2],h)}else{const g=sxe(l),y=Math.min(Math.max(H_(u),0),1),b=Math.min(Math.max(H_(d),0),1);if([g,y,b,h].every(Number.isFinite)){const[v,w,S]=oxe(g,y,b);return F_(v,w,S,h)}}}const i=rxe(n);if(i!==null)return i;throw new TypeError(`canvas-engine: unsupported colour ${JSON.stringify(e)}`)}let _o;const ig=new Map;function rxe(e){const t=ig.get(e);if(t!==void 0)return t;_o===void 0&&(_o=typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1).getContext("2d",{willReadFrequently:!0}):typeof document<"u"?document.createElement("canvas").getContext("2d",{willReadFrequently:!0}):null);let n=null;if(_o){_o.fillStyle="#000",_o.fillStyle=e;const s=_o.fillStyle;if(_o.fillStyle="#fff",_o.fillStyle=e,s===_o.fillStyle){_o.clearRect(0,0,1,1),_o.fillRect(0,0,1,1);const[o,r,i,l]=_o.getImageData(0,0,1,1).data;n=l===0?0:(o<<24|r<<16|i<<8|l)>>>0}}return ig.size>512&&ig.clear(),ig.set(e,n),n}function ixe(e){let t=0;return e.visible!==!1&&(t|=Pbe),e.hittable!==!1&&(t|=Ibe),e.selectable!==!1&&(t|=Bbe),e.movable!==!1&&(t|=Hbe),e.resizable!==!1&&(t|=Fbe),e.snap!==!1&&(t|=Ube),e.lockAspect&&(t|=Vbe),e.hitStrokeOnly&&(t|=qbe),e.screenStroke&&(t|=Gbe),e.hover===!1&&(t|=Wbe),e.selectionOutline===!1&&(t|=Ybe),e.handles==="corners"?t|=Kbe:e.handles==="width"&&(t|=Xbe),e.blend==="multiply"&&(t|=Zbe),t}function axe(e){const t=/([MmLlHhVvCcSsQqTtAaZz])|([-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?)/g,n=[];let s;for(;s=t.exec(e);)n.push(s[1]?{cmd:!0,raw:s[1]}:{cmd:!1,raw:s[2]});return n}function lxe(e,t,n,s,o,r,i,l,u,d){if(s===0||o===0){e.push(Vf,u,d);return}if(t===u&&n===d)return;s=Math.abs(s),o=Math.abs(o);const f=r*Math.PI/180,h=Math.cos(f),g=Math.sin(f),y=(t-u)/2,b=(n-d)/2,v=h*y+g*b,w=-g*y+h*b,S=v*v/(s*s)+w*w/(o*o);if(S>1){const q=Math.sqrt(S);s*=q,o*=q}const C=s*s*o*o-s*s*w*w-o*o*v*v,k=s*s*w*w+o*o*v*v;let M=Math.sqrt(Math.max(0,C/k));i===l&&(M=-M);const j=M*s*w/o,O=-M*o*v/s,$=h*j-g*O+(t+u)/2,A=g*j+h*O+(n+d)/2,N=(q,G,Y,B)=>Math.atan2(q*B-G*Y,q*Y+G*B),_=N(1,0,(v-j)/s,(w-O)/o);let D=N((v-j)/s,(w-O)/o,(-v-j)/s,(-w-O)/o);!l&&D>0&&(D-=2*Math.PI),l&&D<0&&(D+=2*Math.PI);const P=Math.max(1,Math.ceil(Math.abs(D)/(Math.PI/2))),L=D/P,F=4/3*Math.tan(L/4);let U=_;const I=q=>{const G=s*Math.cos(q),Y=o*Math.sin(q);return[$+h*G-g*Y,A+g*G+h*Y]},H=q=>{const G=-s*Math.sin(q),Y=o*Math.cos(q);return[h*G-g*Y,g*G+h*Y]};for(let q=0;q<P;q++){const G=U+L,[Y,B]=I(U),[W,K]=I(G),[Q,J]=H(U),[te,X]=H(G);e.push(Pk,Y+F*Q,B+F*J,W-F*te,K-F*X,q===P-1?u:W,q===P-1?d:K),U=G}}function cxe(e){const t=[],n=axe(e);let s=0,o="",r=0,i=0,l=0,u=0,d=0,f=0,h="";const g=()=>{const b=n[s];if(!b||b.cmd)throw new SyntaxError(`canvas-engine: bad path data near token ${s} in ${JSON.stringify(e.slice(0,80))}`);return s++,parseFloat(b.raw)},y=()=>{const b=n[s];if(!b||b.cmd||b.raw[0]!=="0"&&b.raw[0]!=="1")throw new SyntaxError(`canvas-engine: bad arc flag near token ${s}`);return b.raw.length>1?n[s]={cmd:!1,raw:b.raw.slice(1)}:s++,b.raw[0]==="1"};for(;s<n.length;){const b=n[s];if(b.cmd)o=b.raw,s++;else if(!o)throw new SyntaxError("canvas-engine: path data must start with a command");const v=o===o.toLowerCase(),w=v?r:0,S=v?i:0;switch(o.toUpperCase()){case"M":{r=w+g(),i=S+g(),l=r,u=i,t.push(e9,r,i),o=v?"l":"L",h="M";break}case"L":r=w+g(),i=S+g(),t.push(Vf,r,i),h="L";break;case"H":r=w+g(),t.push(Vf,r,i),h="L";break;case"V":i=S+g(),t.push(Vf,r,i),h="L";break;case"C":{const C=w+g(),k=S+g();d=w+g(),f=S+g(),r=w+g(),i=S+g(),t.push(Pk,C,k,d,f,r,i),h="C";break}case"S":{const C=h==="C"?2*r-d:r,k=h==="C"?2*i-f:i;d=w+g(),f=S+g(),r=w+g(),i=S+g(),t.push(Pk,C,k,d,f,r,i),h="C";break}case"Q":d=w+g(),f=S+g(),r=w+g(),i=S+g(),t.push(B_,d,f,r,i),h="Q";break;case"T":d=h==="Q"?2*r-d:r,f=h==="Q"?2*i-f:i,r=w+g(),i=S+g(),t.push(B_,d,f,r,i),h="Q";break;case"A":{const C=g(),k=g(),M=g(),j=y(),O=y(),$=w+g(),A=S+g();lxe(t,r,i,C,k,M,j,O,$,A),r=$,i=A,h="A";break}case"Z":if(t.push(t9),r=l,i=u,h="Z",n[s]&&!n[s].cmd)throw new SyntaxError("canvas-engine: numbers after Z in path data");break;default:throw new SyntaxError(`canvas-engine: unknown path command ${o}`)}}return t}function uxe(e,t=!1){const n=[];for(let s=0;s+1<e.length;s+=2)n.push(s===0?e9:Vf,e[s],e[s+1]);return t&&n.length&&n.push(t9),n}class U_{#e=new Map;#t=[];#i=[];#o=[];get size(){return this.#e.size}get(t){return this.#e.get(t)}ensure(t){let n=this.#e.get(t);return n===void 0&&(n=this.#i.pop()??this.#t.length,this.#e.set(t,n),this.#t[n]=t),n}id(t){return this.#t[t]}ids(t){const n=[];for(let s=0;s<t.length;s++){const o=this.#t[t[s]];o!==void 0&&n.push(o)}return n}release(t){const n=this.#e.get(t);if(n!==void 0)return this.#e.delete(t),this.#t[n]=void 0,this.#o.push(n),n}clear(){for(const t of this.#e.values())this.#o.push(t);this.#e.clear(),this.#t.fill(void 0)}flush(){this.#i.push(...this.#o),this.#o.length=0}}const dxe={butt:0,round:1,square:2},fxe={miter:0,round:1,bevel:2};class mve{items=new U_;textures=new U_;#e=new Map;#t(t){const n=this.#e.get(t.id),s=t.closed??!1;if(n&&n.d===t.d&&n.points===t.points&&n.closed===s)return n.cmds;const o=t.d!==void 0?cxe(t.d):t.points?uxe(t.points,s):[];return this.#e.set(t.id,{d:t.d,points:t.points,closed:s,cmds:o}),o}encode(t){const n=t.upsert??[],s=t.remove??[],o=(t.clear?1:0)+s.length+n.length,r=new Float64Array(o*yf),i=[];let l=0,u=0;t.clear&&(r[0]=_be,this.items.clear(),this.#e.clear(),u=1);for(const h of s){const g=this.items.release(h);if(this.#e.delete(h),g===void 0)continue;const y=u*yf;r[y]=$be,r[y+1]=g,u++}for(const h of n){const g=u*yf;switch(u++,r[g]=Nbe,r[g+1]=this.items.ensure(h.id),r[g+3]=h.layer??0,r[g+4]=h.z??0,r[g+5]=h.x,r[g+6]=h.y,r[g+7]=h.w,r[g+8]=h.h,r[g+9]=h.rotation??0,r[g+10]=ixe(h),r[g+11]=h.opacity??1,r[g+22]=-1,h.kind){case"hole":r[g+2]=Dbe,r[g+15]=h.radius??0;break;case"path":{r[g+2]=zbe,r[g+12]=nu(h.fill),r[g+13]=nu(h.stroke),r[g+14]=h.strokeWidth??1,r[g+16]=h.dash?.[0]??0,r[g+17]=h.dash?.[1]??0;const y=this.#t(h);r[g+23]=l,r[g+24]=y.length,i.push(y),l+=y.length;const b=h.cuts?.slice(0,Qbe)??[];if(b.length){const v=b.flatMap(w=>[w.x,w.y,w.w,w.h]);i.push(v),l+=v.length,r[g+31]=b.length}r[g+25]=h.viewBox?.[0]??0,r[g+26]=h.viewBox?.[1]??0,r[g+27]=dxe[h.cap??"butt"],r[g+28]=fxe[h.join??"miter"],r[g+29]=h.miterLimit??4,r[g+30]=h.fillRule==="evenodd"?1:0;break}default:r[g+2]=Lbe,r[g+12]=nu(h.fill),r[g+13]=nu(h.stroke),r[g+14]=h.strokeWidth??(h.stroke!==void 0?1:0),r[g+15]=h.radius??0,r[g+16]=h.dash?.[0]??0,r[g+17]=h.dash?.[1]??0,h.shadow&&(r[g+18]=nu(h.shadow.color),r[g+19]=h.shadow.blur,r[g+20]=h.shadow.dx??0,r[g+21]=h.shadow.dy??0),h.texture!==void 0&&(r[g+22]=this.textures.ensure(h.texture))}}const d=new Float32Array(l);let f=0;for(const h of i)d.set(h,f),f+=h.length;return this.items.flush(),{ops:u*yf===r.length?r:r.subarray(0,u*yf),paths:d,records:u}}}const hxe=(()=>{try{return new URLSearchParams(location.search).get("open_artifact_engine")==="off"}catch{return!1}})(),pxe=.05,mxe=2,gxe=48,yxe=12,bxe=48,xxe=1.25,Z1=160,vxe=6,wxe=6,Sxe=500;let Q1=null;function V_(){const e=ae.getState(),t=fn(e),n=us(_n(Bh({sections:e.index.sections}),t),t),s=`${ot}:${JSON.stringify(n)}`;return{layout:Tbe(n,ot,vt),key:s}}function n9(e){try{return nu(e),e}catch{return null}}function q_(){const e=getComputedStyle(document.documentElement),t=(n,s)=>n9(e.getPropertyValue(n).trim())??s;return{accent:t("--open-artifact-accent","#2563eb"),accentSoft:t("--open-artifact-accent-soft","rgba(37, 99, 235, 0.12)"),line:t("--open-artifact-line","rgba(0, 0, 0, 0.1)"),lineStrong:t("--open-artifact-line-strong","rgba(0, 0, 0, 0.2)")}}async function kxe(e,t){const n=Array.from(e.querySelectorAll("img"),s=>s.decode().catch(()=>{}));await Promise.race([Promise.all(n),new Promise(s=>setTimeout(s,t))])}const G_=()=>new Promise(e=>requestAnimationFrame(()=>e())),J1=(e,t)=>`${e}|${t.key}`;class Exe{store;#e=null;#t=null;#i=!1;#o=[];#x;#r={x:0,y:0,zoom:1};#m=!1;#c=new Set;#T=new Set;#a=new Map;#f=new Set;#l=new Map;#u=new Map;#d=new Map;#g=[];#y=new Set;#h=new Map;#v=new Set;#w=new Set;#S=new Set;#b={accent:"#2563eb",accentSoft:"rgba(37, 99, 235, 0.12)",line:"rgba(0, 0, 0, 0.1)",lineStrong:"rgba(0, 0, 0, 0.2)"};#k=new Map;#p=null;#M=!1;#n=null;constructor(){const{layout:t,key:n}=V_();this.#x=n,this.store=_P()(()=>({layout:t,view:null,zoom:1,hover:null,live:[],drag:null,menu:null}))}async start(t,n){const{CanvasEngine:s}=await $P(async()=>{const{CanvasEngine:i}=await import("./src-C48N4IXt.js");return{CanvasEngine:i}},[],import.meta.url);if(this.#i)return;this.#b=q_();const o=await s.create(n,{selection:"controlled",snap:!1,grid:"none",minZoom:pxe,maxZoom:mxe,cameraEventMs:0,dragEvents:!0,dragThreshold:5,zoomSpeed:.01,wheelZoomMax:1/0,theme:this.#j()});if(this.#i){o.destroy();return}this.#e=o,this.#t=n;const r=(i,l)=>{this.#o.push(o.on(i,l))};r("camera",i=>this.#B(i)),r("moving",({moving:i})=>{i&&(this.#m=!0,this.#s())}),r("holes",({holes:i})=>this.#G(i)),r("textureNeeded",({keys:i})=>this.#q(i)),r("hover",({id:i})=>this.store.setState({hover:i})),r("gesture",i=>this.#X(i)),r("dragging",i=>this.#Z(i)),r("dblclick",({id:i,world:l})=>{const u=this.#I(i,l);u&&se.getState().editOnCanvas(u)}),r("contextmenu",({id:i,world:l,event:u})=>{const d=this.#I(i,l);if(!d){u?.stopPropagation();return}se.getState().slideSelection.includes(d)||se.getState().showSlide(d),this.store.setState({menu:d})}),r("commit",i=>{i.op==="select"?this.#M&&this.#J(i.ids):i.op==="move"&&this.#Q()}),this.#W(t,n),this.#V(),this.#N(),this.#s(),Q1?o.setCamera(Q1):this.fit(0),globalThis.__openArtifactCanvasEngine=()=>this.#ee()}destroy(){if(this.#i)return;this.#i=!0;for(const n of this.#o)n();this.#o.length=0,this.#e?.destroy(),this.#e=null,this.#n&&(se.getState().setDropGap(null),If([]));const t=globalThis;delete t.__openArtifactCanvasEngine}fit(t=300){const{layout:n}=this.store.getState();this.#e?.glideTo({x:0,y:0,w:n.width,h:n.height},{duration:t,padding:gxe,maxZoom:1})}zoomBy(t){this.#e?.zoomAt(t)}attachWorld(t){return this.#w.add(t),t.style.transform=this.#R(),()=>this.#w.delete(t)}attachZoomReadout(t){return this.#S.add(t),t.textContent=`${Math.round(this.#r.zoom*100)}%`,()=>this.#S.delete(t)}#R(){const{x:t,y:n,zoom:s}=this.#r;return`translate(${-t*s}px, ${-n*s}px) scale(${s})`}#B(t){this.#r={x:t.x,y:t.y,zoom:t.zoom},Q1=this.#r;const n=this.#R();for(const o of this.#w)o.style.transform=n;const s=`${Math.round(t.zoom*100)}%`;for(const o of this.#S)o.textContent=s;aB(),t.settled&&(this.#m=!1,this.#E())}#E(){const t=this.#e;if(!t)return;const{layout:n}=this.store.getState(),s=t.viewport();this.#c=new Set(zk(n,s).map(i=>i.id));const o=this.#H(s),r=this.store.getState().live;this.#T=new Set(o),this.store.setState({view:s,zoom:this.#r.zoom,live:o.length===r.length&&o.every((i,l)=>r[l]===i)?r:o});for(const[i,l]of this.#h)this.#f.has(i)||this.#P(i,l);for(const i of this.#c){const l=this.#l.get(i);l&&this.#d.get(l)===1&&this.#O()&&this.#L(l)}this.#s()}#H(t){const{layout:n}=this.store.getState(),s=vs*this.#r.zoom,o=s*(devicePixelRatio||1),r=ot*rB*xxe,i=t.x+t.w/2,l=t.y+t.h/2,u=s<bxe?[]:zk(n,t).filter(f=>!this.#C(f.id)||o>r).map(f=>({id:f.id,d:Math.hypot(f.x+f.w/2-i,f.y+f.h/2-l)})).sort((f,h)=>f.d-h.d).slice(0,yxe).map(f=>f.id),d=se.getState().current;return d&&this.#c.has(d)&&!u.includes(d)&&u.push(d),u}#s(){const t=this.#e;if(!t||this.#n)return;const{layout:n}=this.store.getState(),s=ae.getState(),o=hn(),r=new Set(yi.getState().drag?.keys??[]),i=[],l=new Set;let u=!1;for(const f of n.tiles){const h=s.slides[f.id]?.slide;if(!h)continue;const g=n.rows[f.row]?.key,y=this.#v.has(f.id)&&this.#T.has(f.id)&&!(this.#m&&this.#C(f.id)),b={id:f.id,x:f.x,y:f.y,w:f.w,h:f.h,radius:wxe,movable:o,resizable:!1,snap:!1},v=y?{...b,kind:"hole"}:{...b,kind:"image",fill:this.#F(h),stroke:this.#b.line,strokeWidth:1,screenStroke:!0,texture:this.#l.get(f.id),opacity:(h.hidden?.5:1)*(g&&r.has(g)?.4:1)};l.add(f.id),y?this.#f.add(f.id):this.#f.delete(f.id);const w=JSON.stringify(v);this.#a.get(f.id)!==w&&(this.#a.has(f.id)||(u=!0),this.#a.set(f.id,w),i.push(v))}const d=[...this.#a.keys()].filter(f=>!l.has(f));for(const f of d)this.#a.delete(f),this.#f.delete(f);(i.length||d.length)&&t.applyPatch({upsert:i,remove:d}),u&&this.#A()}#F(t){const n=t.style.background;if(!n||/url\(|gradient/i.test(n))return"#ffffff";let s=this.#k.get(n);return s===void 0&&(s=n9(n)??"#ffffff",this.#k.set(n,s)),s}#j(){const t=this.#b;return{background:"transparent",grid:"transparent",selection:t.accent,handle:t.accent,guide:t.accent,marquee:t.accentSoft,hover:t.lineStrong}}#A(){const t=se.getState(),n=new Set(t.slideSelection);t.current&&n.add(t.current),this.#e?.setSelection([...n].filter(s=>this.#a.has(s)))}#U(){const{layout:t,key:n}=V_();n!==this.#x?(this.#x=n,this.store.setState({layout:t}),this.#E()):this.#s()}#V(){const t=r=>{this.#o.push(r)};t(ae.subscribe((r,i)=>{(r.index!==i.index||r.slides!==i.slides||r.status!==i.status||r.readOnly!==i.readOnly)&&this.#U()})),t(se.subscribe((r,i)=>{(r.slideSelection!==i.slideSelection||r.current!==i.current)&&this.#A(),r.current!==i.current&&!this.#m&&this.#E()})),t(yi.subscribe(()=>this.#s())),t(zs.subscribe((r,i)=>{r.snapshots!==i.snapshots&&this.#N()})),t(Jue({ids:()=>this.store.getState().layout.byId.keys(),visible:()=>this.#c}));const n=()=>{this.#b=q_(),this.#k.clear(),this.#e?.setOptions({theme:this.#j()}),this.#a.clear(),this.#s()},s=matchMedia("(prefers-color-scheme: dark)");s.addEventListener("change",n),t(()=>s.removeEventListener("change",n));const o=new MutationObserver(n);o.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),t(()=>o.disconnect())}#C(t){const n=this.#l.get(t);return n!==void 0&&this.#d.has(n)}#O(){return vs*this.#r.zoom*(devicePixelRatio||1)>Z1}#N(){const{snapshots:t}=zs.getState(),n=new Set([...this.#l.keys(),...Object.keys(t)]);let s=!1;for(const o of n){const r=t[o],i=r?J1(o,r):void 0,l=this.#l.get(o);i===l||i&&this.#u.has(i)||(i&&l&&this.#c.has(o)?(this.#u.set(i,o),this.#z(i).finally(()=>{this.#$(o,i)&&this.#s()})):s=this.#$(o,i)||s)}s&&this.#s()}#$(t,n){if(this.#i)return!1;const s=zs.getState().snapshots[t];if(n&&(!s||J1(t,s)!==n))return this.#_(n),!1;const o=this.#l.get(t);return n?(this.#l.set(t,n),this.#u.set(n,t)):this.#l.delete(t),o&&o!==n&&this.#_(o),!0}#_(t){this.#u.delete(t),this.#d.delete(t),this.#e?.removeTexture(t)}#q(t){for(const n of t)this.#d.delete(n),this.#u.has(n)&&this.#L(n)}#L(t){!this.#y.has(t)&&!this.#g.includes(t)&&this.#g.push(t),this.#D()}#D(){for(;this.#y.size<vxe&&this.#g.length;){const t=this.#g.shift();this.#y.add(t),this.#z(t).finally(()=>{this.#y.delete(t),this.#D()})}}async#z(t){const n=this.#u.get(t),s=n?zs.getState().snapshots[n]:void 0;if(!n||!s||J1(n,s)!==t)return;const o=this.#O(),{layout:r}=this.store.getState(),i=[];try{const l={premultiplyAlpha:"premultiply"};if(i.push(await createImageBitmap(s.blob,{...l,resizeWidth:Z1,resizeHeight:Math.round(Z1*r.slideH/vs),resizeQuality:"medium"})),o&&i.push(await createImageBitmap(s.blob,l)),!this.#e||this.#u.get(t)!==n)return;this.#e.setTexture(t,i)&&this.#d.set(t,o?2:1)}catch{}finally{for(const l of i)l.close()}}attachLive(t,n){this.#h.set(t,n),this.#P(t,n);let s=!0;return(async()=>(await G_(),await G_(),await kxe(n,Sxe),!(!s||this.#h.get(t)!==n)&&(this.#v.add(t),this.#s())))(),()=>{s=!1,this.#h.get(t)===n&&(this.#h.delete(t),this.#v.delete(t),this.#s())}}#P(t,n){const s=this.store.getState().layout.byId.get(t);if(!s)return;const{x:o,y:r,zoom:i}=this.#r;n.style.transform=`matrix(${i}, 0, 0, ${i}, ${(s.x-o)*i}, ${(s.y-r)*i})`,n.style.visibility="hidden"}#G(t){const n=new Map(t.map(s=>[s.id,s]));for(const[s,o]of this.#h){const r=n.get(s);r?(o.style.transform=r.transform,o.style.visibility="visible"):o.style.visibility="hidden"}}hitAt(t,n){if(!this.#e||!this.#t)return null;const s=this.#t.getBoundingClientRect(),o=this.#e.screenToWorld({x:t-s.left,y:n-s.top});return I_(this.store.getState().layout,o.x,o.y)}#W(t,n){const s=(o,r,i=!1)=>{t.addEventListener(o,r,i),this.#o.push(()=>t.removeEventListener(o,r,i))};s("pointerdown",o=>this.#Y(o,n),!0),s("wheel",o=>{o.target===n||o.target instanceof Element&&o.target.closest("textarea")||(o.preventDefault(),n.dispatchEvent(new WheelEvent("wheel",o)))},!1),s("contextmenu",o=>{o.target!==n&&o.stopPropagation()},!0)}#I(t,n){return t??I_(this.store.getState().layout,n.x,n.y)?.tile.id??null}#Y(t,n){const s=this.#e;if(t.button!==0||!s||t.target!==n)return;const o=this.hitAt(t.clientX,t.clientY);if(!o){!t.shiftKey&&!t.metaKey&&!t.ctrlKey&&this.#K(t,s);return}const r=o.tile.id,i=se.getState().slideSelection.includes(r),l=PB(r,t);(!l||o.caption)&&t.stopPropagation();const u=n.getBoundingClientRect(),d={id:r,world:s.screenToWorld({x:t.clientX-u.left,y:t.clientY-u.top}),moved:!1};this.#p=d;const f=h=>{window.removeEventListener("pointerup",f,!0),window.removeEventListener("pointercancel",f,!0),this.#p===d&&(this.#p=null),h.type==="pointerup"&&l&&!d.moved&&i&&se.getState().slideSelection.length>1&&se.getState().selectSlides([r])};window.addEventListener("pointerup",f,!0),window.addEventListener("pointercancel",f,!0)}#K(t,n){n.setTool("pan");const s=t.clientX,o=t.clientY;let r=!1;const i=u=>{Math.hypot(u.clientX-s,u.clientY-o)>=3&&(r=!0)},l=u=>{if(window.removeEventListener("pointermove",i),window.removeEventListener("pointerup",l),window.removeEventListener("pointercancel",l),this.#e?.setTool("select"),r||u.type!=="pointerup")return;const d=se.getState();d.selectSections([]),d.selectSlides(d.current?[d.current]:[])};window.addEventListener("pointermove",i),window.addEventListener("pointerup",l),window.addEventListener("pointercancel",l)}#X(t){if(t.kind==="marquee"&&(this.#M=t.phase==="start"),t.kind!=="move")return;if(t.phase==="start"){this.#p&&(this.#p.moved=!0);return}const n=this.#n;if(this.#n=null,se.getState().setDropGap(null),If([]),this.store.setState({drag:null}),n)for(const s of n.ids)this.#a.delete(s);this.#s()}#Z({ids:t,dx:n,dy:s}){const{layout:o}=this.store.getState();if(!this.#n){const d=fn(ae.getState()),f=this.#p,h=o.byId.get(t[0]??"");this.#n={ids:d.filter(g=>t.includes(g)),origin:f?f.world:{x:h?.x??0,y:h?.y??0}},If(this.#n.ids)}const r=this.#n.origin.x+n,i=this.#n.origin.y+s,l=Rbe(o,r,i);se.getState().setDropGap(l?null:jbe(o,r,i));const u=this.store.getState().drag;(!u||u.section!==l)&&this.store.setState({drag:{ids:this.#n.ids,section:l}})}#Q(){const t=this.#n;if(!t)return;const n=this.store.getState().drag?.section??null,s=se.getState().dropGap;n?P6(t.ids,n,0):s!==null&&DE(t.ids,s)}#J(t){const n=se.getState(),s=fn(ae.getState()).filter(o=>t.includes(o));if(n.selectSections([]),!s.length){n.selectSlides(n.current?[n.current]:[]);return}(!n.current||!s.includes(n.current))&&n.showSlide(s[0],{keepSelection:!0}),se.getState().selectSlides(s)}#ee(){let t=0;for(const o of this.#c)(this.#C(o)||this.#f.has(o))&&t++;const{layout:n,live:s}=this.store.getState();return{tiles:n.tiles.length,visible:this.#c.size,visibleShown:t,live:s.length,holes:this.#f.size,textures:this.#d.size,large:[...this.#d.values()].filter(o=>o===2).length,camera:this.#r,moving:this.#m,engine:this.#e?.stats()??null}}}const Cxe=.25,Txe=.5;function Mxe({onFail:e}){const t=T.useRef(null),n=T.useRef(null),[s,o]=T.useState(null),r=T.useRef(e);return r.current=e,T.useEffect(()=>{const i=new Exe;return o(i),i.start(t.current,n.current).catch(l=>{i.destroy(),r.current(l)}),()=>i.destroy()},[]),p.jsx(xb,{menu:s?p.jsx(Rxe,{board:s}):p.jsx(p.Fragment,{}),className:"relative flex min-h-0 flex-1 bg-stage outline-none",children:p.jsxs("div",{ref:t,role:"listbox","aria-label":"Canvas","aria-multiselectable":!0,"data-open-artifact-canvas-engine":!0,className:"relative min-h-0 flex-1 touch-none overflow-hidden",children:[s?p.jsx(jxe,{board:s}):null,p.jsx("canvas",{ref:n,className:"absolute inset-0 size-full"}),s?p.jsx(Oxe,{board:s}):null,s?p.jsx(Lxe,{board:s}):null]})})}function Rxe({board:e}){const t=or(e.store,n=>n.menu);return t?p.jsx(vb,{ids:se.getState().slideSelection.includes(t)?qo():[t]}):null}function jxe({board:e}){const t=or(e.store,n=>n.live);return p.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 overflow-hidden",children:t.map(n=>p.jsx(Axe,{board:e,id:n},n))})}const Axe=T.memo(function({board:t,id:n}){const s=T.useRef(null),o=ae(u=>u.slides[n]?.slide),r=or(t.store,u=>u.layout.slideH),i=or(t.store,u=>u.layout.rows[u.layout.byId.get(n)?.row??-1]?.key??null),l=yi(u=>i!==null&&(u.drag?.keys.includes(i)??!1));return T.useLayoutEffect(()=>t.attachLive(n,s.current),[t,n]),p.jsx("div",{ref:s,className:"absolute left-0 top-0 origin-top-left overflow-hidden rounded-md",style:{width:vs,height:r,visibility:"hidden",opacity:(o?.hidden?.5:1)*(l?.4:1)},children:o?p.jsx(Xl,{slide:o}):null})});function Oxe({board:e}){const t=T.useRef(null),n=or(e.store,y=>y.layout),s=or(e.store,y=>y.view),o=or(e.store,y=>y.zoom),r=or(e.store,y=>y.drag),i=se(y=>y.dropGap),l=yi(y=>y.drag),u=ae(y=>!y.readOnly)&&hn();T.useLayoutEffect(()=>e.attachWorld(t.current),[e]);const d=s?Obe(s,Txe):null,f=d?n.rows.filter(y=>y.top<d.y+d.h&&y.top+n.tileH>d.y):[],h=d&&o>=Cxe?zk(n,d):[],g=Math.min(4,Math.max(1,.6/o));return p.jsx("div",{className:"pointer-events-none absolute inset-0 overflow-hidden",children:p.jsxs("div",{ref:t,"data-section-rows":!0,className:"absolute left-0 top-0 origin-top-left",style:{width:n.width,height:n.height},children:[n.rows.map(y=>p.jsx("div",{"data-section-row":y.row,"data-section-key":y.key??"","aria-hidden":!0,className:"absolute left-0",style:{top:y.top,width:1,height:n.tileH}},y.key??"-")),l&&l.gap!==null?p.jsx("div",{"aria-hidden":!0,className:"absolute left-0 h-1 rounded bg-accent",style:{top:l.gap*(n.tileH+ir)-ir/2,width:n.width}}):null,f.map(y=>p.jsx("div",{className:Ie("pointer-events-auto absolute",y.key&&l?.keys.includes(y.key)&&"opacity-40"),style:{left:0,top:y.top,width:sr-ho},children:p.jsx("div",{className:"origin-top-left",style:{transform:`scale(${g})`,width:(sr-ho)/g},children:p.jsx(qC,{section:y.section,n:y.row,ids:y.ids,previousGap:y.row>0?y.row-1:null,nextGap:y.row<n.rows.length-1?y.row+2:null})})},y.key??"-")),n.rows.map(y=>y.empty&&y.key?p.jsx("div",{"data-empty-section":y.key,className:Ie("absolute flex items-center justify-center rounded-lg border-2 border-dashed border-line text-lg text-fg-subtle",r?.section===y.key&&"border-accent bg-accent-soft text-accent"),style:{left:y.empty.x,top:y.empty.y,width:y.empty.w,height:y.empty.h},children:"An empty section. Drop slides here."},y.key):null),r&&!r.section&&i!==null?Abe(n,i).map((y,b)=>p.jsx("span",{"aria-hidden":!0,className:"absolute rounded bg-accent",style:{left:y.x,top:y.y,width:y.w,height:y.h}},b)):null,h.length?p.jsx(Nxe,{tiles:h,slideH:n.slideH,dragging:r?.ids??null}):null,u&&!r?p.jsx(_xe,{board:e}):null]})})}function Nxe({tiles:e,slideH:t,dragging:n}){const s=Yy(),o=Hh();return e.map(r=>p.jsx($xe,{tile:r,slideH:t,comments:s.get(r.id)??0,peers:o.get(r.id),dragging:n?.includes(r.id)??!1},r.id))}const $xe=T.memo(function({tile:t,slideH:n,comments:s,peers:o,dragging:r}){const i=ae(h=>h.slides[t.id]),l=se(h=>h.current===t.id),u=se(h=>h.slideSelection.includes(t.id));if(!i)return null;const d=i.held??(i.conflict?"Changed elsewhere at the same time":null),f=Gl(i.slide);return p.jsxs("div",{"data-slide-index":t.index,"data-slide-id":t.id,role:"option","aria-selected":u||l,"aria-label":`Slide ${t.index+1}${f?`: ${f}`:""}`,className:Ie("absolute",r&&"opacity-40"),style:{left:t.x,top:t.y,width:t.w,height:n+Yu},children:[p.jsxs("div",{className:"absolute right-1.5 flex items-center gap-1",style:{top:n-6,transform:"translateY(-100%)"},children:[p.jsx(NC,{peers:o}),s?p.jsxs("span",{className:"flex items-center gap-0.5 rounded-full bg-surface px-1.5 text-[10px] text-fg shadow-popup",children:[p.jsx(Rr,{className:"size-2.5"}),s]}):null]}),p.jsxs("div",{className:"absolute inset-x-0 flex items-center gap-1.5 pt-1.5 text-[11px] text-fg-muted",style:{top:n},children:[p.jsx("span",{className:Ie("tabular-nums",(u||l)&&"font-semibold text-fg"),children:t.index+1}),p.jsx("span",{className:"min-w-0 flex-1 truncate",children:f}),i.slide.hidden?p.jsx(Mh,{className:"size-3 shrink-0","aria-label":"Skipped"}):null,d?p.jsx(Sa,{className:"size-3 shrink-0 text-warning","aria-label":d}):null]})]})});function _xe({board:e}){const t=or(e.store,r=>r.hover),n=or(e.store,r=>r.layout),s=T.useRef(null);t&&n.byId.has(t)&&(s.current=t);const o=s.current?n.byId.get(s.current):void 0;return o?p.jsx("div",{className:Ie("group/gap pointer-events-none absolute flex items-center justify-center [&_button]:pointer-events-auto",t===o.id&&"[&_button]:opacity-100"),style:{left:o.x+o.w,top:o.y,width:ho,height:o.h},children:p.jsx(GC,{gap:o.index+1,after:o.id})}):null}function Lxe({board:e}){const t=T.useRef(null);return T.useLayoutEffect(()=>e.attachZoomReadout(t.current),[e]),p.jsxs(Lr,{"data-canvas-controls":!0,className:"absolute bottom-3 right-3 h-9 px-1 py-px",onPointerDown:n=>n.stopPropagation(),children:[p.jsx(Rn,{label:"Zoom out",children:p.jsx(Pt,{square:!0,"aria-label":"Zoom out",onClick:()=>e.zoomBy(1/1.25),children:p.jsx($i,{className:"size-4",strokeWidth:1.5})})}),p.jsx("span",{ref:t,className:"min-w-11 text-center text-[13px] tabular-nums text-chrome-secondary"}),p.jsx(Rn,{label:"Zoom in",children:p.jsx(Pt,{square:!0,"aria-label":"Zoom in",onClick:()=>e.zoomBy(1.25),children:p.jsx(ds,{className:"size-4",strokeWidth:1.5})})}),p.jsx(Mr,{}),p.jsxs(Pt,{className:"pl-1.5 pr-2",onClick:()=>e.fit(),children:[p.jsx(I2,{className:"size-4",strokeWidth:1.5}),"Fit all slides"]})]})}const Dxe=()=>vs*vt/ot+Yu,eS=48,zxe=.05,Pxe=2;let W_=null;const s9=e=>Math.min(Pxe,Math.max(zxe,e));function Ixe(e,t,n,s){const o=s9(Math.min((n-eS*2)/e,(s-eS*2)/t,1));return{scale:o,x:(n-e*o)/2,y:Math.max(eS,(s-t*o)/2)}}function Bxe(e){se.getState().editOnCanvas(e)}function Hxe(){return se(t=>t.canvasEdit)?p.jsx(qxe,{}):p.jsx(Fxe,{})}let tS=!1;function Fxe(){const e=ld().length===0,[,t]=T.useState(tS);return hxe||tS||e?p.jsx(Uxe,{}):p.jsx(Mxe,{onFail:n=>{console.warn("Canvas engine unavailable; drawing the canvas with the DOM.",n),tS=!0,t(!0)}})}function Uxe(){const{order:e,groups:t}=r6(),n=Yy(),s=Hh(),o=se(_=>_.dropGap),r=ae(_=>!_.readOnly)&&hn(),i=T.useRef(null),l=Vh(i),{drag:u,onPointerDown:d}=OC(i,"grid"),f=yi(_=>_.drag),h=new Set(u?.ids??[]);ae(_=>_.index.size);const g=Dxe(),y=Math.max(1,...t.map(_=>_.ids.length)),b=sr+y*vs+(y-1)*ho,v=Math.max(1,t.length)*(g+ir)-ir,[w,S]=T.useState(W_),C=T.useRef(w);C.current=w;const k=T.useCallback(_=>{C.current=_,W_=_,S(_),aB()},[]),M=T.useCallback(()=>{l&&k(Ixe(b,v,l.w,l.h))},[l,b,v,k]);T.useLayoutEffect(()=>{!C.current&&l&&M()},[l,M]);const j=T.useCallback((_,D,P)=>{const L=C.current;if(!L)return;const F=s9(L.scale*_),U=F/L.scale;k({scale:F,x:D-(D-L.x)*U,y:P-(P-L.y)*U})},[k]);T.useEffect(()=>{const _=i.current;if(!_)return;const D=P=>{P.preventDefault();const L=C.current;if(!L)return;const F=_.getBoundingClientRect();if(P.ctrlKey||P.metaKey)j(Math.exp(-P.deltaY*.01),P.clientX-F.left,P.clientY-F.top);else{const U=P.shiftKey&&P.deltaX===0?P.deltaY:P.deltaX,I=P.shiftKey&&P.deltaX===0?0:P.deltaY;k({...L,x:L.x-U,y:L.y-I})}};return _.addEventListener("wheel",D,{passive:!1}),()=>_.removeEventListener("wheel",D)},[j,k]);const O=()=>({x:(l?.w??0)/2,y:(l?.h??0)/2}),$=_=>{if(_.button!==0&&_.button!==1||_.target.closest("[data-slide-index], [data-section-label], [data-empty-section], button, textarea, [data-canvas-controls]"))return;const P=C.current;if(!P)return;_.preventDefault();const L=_.clientX,F=_.clientY;let U=!1;const I=q=>{!U&&Math.hypot(q.clientX-L,q.clientY-F)<3||(U=!0,k({...P,x:P.x+q.clientX-L,y:P.y+q.clientY-F}))},H=()=>{if(window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",H),!U){const q=se.getState();q.selectSections([]),q.selectSlides(q.current?[q.current]:[])}};window.addEventListener("pointermove",I),window.addEventListener("pointerup",H)};let A=0;const N=t.map(_=>{const D=A;return A+=_.ids.length,D});return p.jsxs("div",{ref:i,role:"listbox","aria-label":"Canvas","aria-multiselectable":!0,"data-open-artifact-thumbs":!0,className:Ie("relative min-h-0 flex-1 touch-none overflow-hidden bg-stage",!u&&"cursor-grab active:cursor-grabbing"),onPointerDown:$,children:[e.length===0?p.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-3 text-sm text-chrome-muted",children:[p.jsx("p",{children:"No slides yet."}),r?p.jsx(Ot,{variant:"primary",icon:p.jsx(ds,{className:"size-4"}),onClick:()=>_a("blank",null),children:"Add slide"}):null]}):w?p.jsx("div",{"data-section-rows":!0,className:"absolute left-0 top-0 origin-top-left",style:{width:b,height:v,transform:`translate(${w.x}px, ${w.y}px) scale(${w.scale})`},children:t.map((_,D)=>{const P=D*(g+ir),L=N[D];return p.jsxs("section",{"aria-label":_.section?.description||`Section ${D+1}`,className:Ie(_.section&&f?.keys.includes(_.section.key)&&"opacity-40"),children:[p.jsx("div",{"data-section-row":D,"data-section-key":_.section?.key??"","aria-hidden":!0,className:"pointer-events-none absolute left-0",style:{top:P,width:1,height:g}}),f?.gap===D?p.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute left-0 h-1 rounded bg-accent",style:{top:P-ir/2,width:b}}):null,p.jsx("div",{className:"absolute",style:{left:0,top:P,width:sr-ho},children:p.jsx("div",{className:"origin-top-left",style:{transform:`scale(${Math.min(4,Math.max(1,.6/w.scale))})`,width:(sr-ho)/Math.min(4,Math.max(1,.6/w.scale))},children:p.jsx(qC,{section:_.section,n:D,ids:_.ids,previousGap:D>0?D-1:null,nextGap:D<t.length-1?D+2:null})})}),_.ids.length===0?p.jsx("div",{"data-empty-section":_.section?.key,className:Ie("absolute flex items-center justify-center rounded-lg border-2 border-dashed border-line text-lg text-fg-subtle",u?.section===_.section?.key&&"border-accent bg-accent-soft text-accent"),style:{left:sr,top:P,width:vs,height:g-Yu},children:"An empty section. Drop slides here."}):_.ids.map((F,U)=>{const I=L+U;return p.jsxs("div",{className:"group/gap absolute",style:{left:sr+U*(vs+ho),top:P,width:vs},children:[p.jsx(JH,{id:F,index:I,width:vs,comments:n.get(F)??0,peers:s.get(F),dragging:h.has(F),dropBefore:u!==null&&o===I,dropAfter:u!==null&&U===_.ids.length-1&&o===I+1,onPointerDown:d,onOpen:Bxe}),r&&!u?p.jsx("div",{className:"absolute top-0 z-10 flex items-center justify-center",style:{left:vs,width:ho,height:g-Yu},children:p.jsx(GC,{gap:I+1,after:F})}):null]},F)})]},_.section?.key??"-")})}):null,p.jsxs(Lr,{"data-canvas-controls":!0,className:"absolute bottom-3 right-3 h-9 px-1 py-px",onPointerDown:_=>_.stopPropagation(),children:[p.jsx(Rn,{label:"Zoom out",children:p.jsx(Pt,{square:!0,"aria-label":"Zoom out",onClick:()=>j(1/1.25,O().x,O().y),children:p.jsx($i,{className:"size-4",strokeWidth:1.5})})}),p.jsx("span",{className:"min-w-11 text-center text-[13px] tabular-nums text-chrome-secondary",children:w?`${Math.round(w.scale*100)}%`:""}),p.jsx(Rn,{label:"Zoom in",children:p.jsx(Pt,{square:!0,"aria-label":"Zoom in",onClick:()=>j(1.25,O().x,O().y),children:p.jsx(ds,{className:"size-4",strokeWidth:1.5})})}),p.jsx(Mr,{}),p.jsxs(Pt,{className:"pl-1.5 pr-2",onClick:M,children:[p.jsx(I2,{className:"size-4",strokeWidth:1.5}),"Fit all slides"]})]})]})}const Y_=2;function Vxe({id:e,n:t}){const n=ae(s=>s.slides[e]?.slide);return n?p.jsxs("button",{type:"button","aria-label":`Edit slide ${t}`,className:"group w-full text-left",onClick:()=>se.getState().showSlide(e),children:[p.jsx("div",{className:"overflow-hidden rounded-[6px] opacity-60 shadow-[0_0_0_1px_var(--chrome-line)] transition group-hover:opacity-100",children:p.jsx(Xl,{slide:n})}),p.jsxs("div",{className:"truncate pt-1 text-[11px] text-chrome-muted",children:[p.jsx("span",{className:"tabular-nums",children:t})," ",Gl(n)]})]}):null}function qxe(){const e=ld(),t=se(i=>i.current),n=t?e.indexOf(t):-1;if(T.useEffect(()=>{n<0&&se.getState().editOnCanvas(null)},[n]),n<0)return null;const s=e.slice(Math.max(0,n-Y_),n),o=e.slice(n+1,n+1+Y_),r=(i,l)=>p.jsx("div",{className:"flex w-40 shrink-0 flex-col justify-center gap-4 overflow-hidden px-3 pb-14 pt-14 max-md:hidden",children:i.map((u,d)=>p.jsx(Vxe,{id:u,n:l+d+1},u))});return p.jsxs("div",{className:"relative flex min-h-0 flex-1 bg-stage",children:[r(s,n-s.length),p.jsxs("div",{className:"relative min-w-0 flex-1",children:[p.jsx(yH,{}),p.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-3 z-10 flex justify-center",children:p.jsxs(Lr,{className:"h-9 px-1 py-px",children:[p.jsx(Rn,{label:"Back to canvas",shortcut:"Esc",children:p.jsxs(Pt,{className:"pl-1.5 pr-2",onClick:()=>se.getState().editOnCanvas(null),children:[p.jsx(iW,{className:"size-4",strokeWidth:1.5}),"Canvas"]})}),p.jsx(Mr,{}),p.jsxs("span",{className:"px-2 text-[13px] tabular-nums text-chrome-secondary",children:["Slide ",n+1," of ",e.length]})]})})]}),r(o,n+1)]})}const K_=220,Xc=24,nS=32;function Gxe(e){const t=se.getState();t.setMode("edit"),t.showSlide(e)}function Wxe(){const{order:e,groups:t}=r6(),n=Yy(),s=Hh(),o=se(M=>M.dropGap),r=se(M=>M.current),i=ae(M=>!M.readOnly)&&hn(),l=$n(M=>M.writing),u=T.useRef(null),d=Vh(u),{drag:f,onPointerDown:h}=OC(u,"grid"),g=yi(M=>M.drag),y=new Set(f?.ids??[]),b=d?Math.max(1,Math.floor((d.w-nS*2+Xc)/(K_+Xc))):4,v=d?Math.floor((d.w-nS*2-Xc*(b-1))/b):K_,[w,S]=T.useState(!1);if(T.useLayoutEffect(()=>{w||!d||!r||(u.current?.querySelector(`[data-slide-id="${CSS.escape(r)}"]`)?.scrollIntoView({block:"center"}),S(!0))},[w,d,r]),e.length===0)return l?p.jsx(cB,{}):p.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 bg-stage text-sm text-chrome-muted",children:[p.jsx("p",{children:"No slides yet."}),i?p.jsx(Ot,{variant:"primary",icon:p.jsx(ds,{className:"size-4"}),onClick:()=>_a("blank",null),children:"Add slide"}):null]});let C=0;const k=t.map(M=>{const j=C;return C+=M.ids.length,j});return p.jsxs("div",{ref:u,role:"listbox","aria-label":"Slides","aria-multiselectable":!0,"data-open-artifact-grid-columns":b,"data-section-rows":!0,"data-section-scroll":!0,"data-open-artifact-thumbs":!0,className:"min-h-0 flex-1 overflow-y-auto bg-stage pb-6 pt-[60px]",style:{paddingInline:nS},onPointerMove:M=>{const j=M.target instanceof Element?M.target.closest("[data-slide-id]"):null,O=j?.dataset.slideId;if(!j||!O)return f1(null);const $=j.getBoundingClientRect();f1({slideId:O,x:(M.clientX-$.left)/Math.max(1,$.width),y:(M.clientY-$.top)/Math.max(1,$.height)})},onPointerLeave:()=>f1(null),onPointerDown:M=>{if(M.target===M.currentTarget){const j=se.getState();j.selectSections([]),j.selectSlides(j.current?[j.current]:[])}},children:[t.map((M,j)=>{const O=k[j],$=j>0?j-1:null,A=j<t.length-1?j+2:null,N=M.section!==null||t.length>1||i,_=!!(M.section&&g?.keys.includes(M.section.key));return p.jsxs("section",{"data-section-row":j,"data-section-key":M.section?.key??"",className:Ie("relative mb-8",_&&"opacity-40"),"aria-label":M.section?.description||`Section ${j+1}`,children:[g?.gap===j?p.jsx(X_,{}):null,N?p.jsx(qC,{section:M.section,n:j,ids:M.ids,previousGap:$,nextGap:A,className:"mb-3 max-w-2xl"}):null,M.ids.length===0?p.jsx("div",{"data-empty-section":M.section?.key,className:Ie("flex h-24 items-center justify-center rounded-md border border-dashed border-line text-xs text-fg-subtle",f?.section===M.section?.key&&"border-accent bg-accent-soft text-accent"),children:"An empty section. Drop slides here."}):p.jsx("div",{className:"grid",style:{gridTemplateColumns:`repeat(${b}, ${v}px)`,columnGap:Xc,rowGap:Xc},children:M.ids.map((D,P)=>{const L=O+P,F=L===e.length-1;return p.jsxs("div",{className:"group/gap relative",children:[p.jsx(JH,{id:D,index:L,comments:n.get(D)??0,peers:s.get(D),dragging:y.has(D),dropBefore:f!==null&&o===L,dropAfter:f!==null&&F&&o===e.length,onPointerDown:h,onOpen:Gxe}),p.jsx($ge,{id:D}),i&&!f?p.jsx("div",{className:"absolute -right-[18px] top-0 z-10 flex w-3 items-center justify-center",style:{height:v*9/16},children:p.jsx(GC,{gap:L+1,after:D})}):null]},D)})})]},M.section?.key??"-")}),p.jsx(hde,{first:e.length,columns:b,tile:v,gap:Xc}),g?.gap===t.length?p.jsx("div",{className:"relative h-0",children:p.jsx(X_,{})}):null,i?p.jsx(Ot,{variant:"ghost",icon:p.jsx(ds,{className:"size-4"}),onClick:()=>_a("blank",e.at(-1)??null),children:"Add slide"}):null]})}function X_(){return p.jsx("div",{className:"pointer-events-none absolute -top-4 left-0 right-0 h-0.5 rounded bg-accent","aria-hidden":!0})}async function Yxe(){try{await Gne()}catch(n){ae.getState().fail(n instanceof Error?n.message:String(n));return}await bue();const e=ae.getState();if(e.status!=="ready")return;se.getState().showSlide(R8()??fn(e)[0]??null),Hae(),tse(),yae();const t=ad()?.room;t&&wae(t,{ids:()=>Ci.getState().peers.map(n=>n.id),subscribe:n=>Ci.subscribe((s,o)=>{s.peers!==o.peers&&n()})}),Tue(),nse(),Iae(),e.readOnly||Tg.getState().set(Vae()),document.title=e.title||"Slides"}let Z_=!1;function Kxe(){const e=ae(s=>!s.readOnly)&&hn(),t=Rt(s=>s.status);return $n(s=>s.writing)?p.jsx(cB,{}):p.jsxs(NP,{icon:p.jsx(dg,{className:"size-6"}),title:"This presentation has no slides yet",children:[p.jsx("p",{children:e?t.available?`Add one, or ask ${t.name} to add some.`:"Add one to get started.":"Slides will show here once they are added."}),e?p.jsx(Ot,{className:"mt-2",variant:"primary",icon:p.jsx(ds,{className:"size-4"}),onClick:()=>_a("blank",null),children:"Add slide"}):null]})}function Xxe(){const e=ae(b=>b.status),t=ae(b=>b.error),n=ae(b=>b.title),s=ae(b=>b.index.faces),o=ld(),r=se(b=>b.mode),i=se(b=>b.canvasEdit),l=se(b=>b.current),u=se(b=>b.showRail),d=se(b=>b.showProperties);T.useEffect(()=>{Z_||(Z_=!0,Yxe());const b=iae(),v=yre();return()=>{b(),v()}},[]),T.useEffect(()=>{n&&(document.title=n)},[n]),T.useEffect(()=>{e==="ready"&&fb(s,wo)},[e,s]);const f=T.useRef(0);if(T.useEffect(()=>{if(e!=="ready")return;const b=l?o.indexOf(l):-1;if(b>=0){f.current=b;return}const v=o[Math.min(f.current,o.length-1)]??null;v!==l&&se.getState().showSlide(v)},[e,o,l]),e==="loading")return p.jsx("div",{className:"flex h-full items-center justify-center bg-canvas",children:p.jsx(Yg,{className:"size-5 animate-spin text-fg-subtle","aria-label":"Loading"})});if(e==="error")return p.jsx("div",{className:"h-full bg-canvas",children:p.jsx(NP,{icon:p.jsx(Sa,{className:"size-6"}),title:"This presentation could not be opened",children:t})});const h=r==="edit"||i,g=o.length===0,y=r==="edit"&&u&&!g;return p.jsx(ipe,{children:p.jsxs("div",{className:"flex h-full bg-stage text-fg",children:[y?p.jsx(kpe,{}):null,p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[p.jsx(ude,{}),p.jsxs("main",{className:"relative flex min-h-0 min-w-0 flex-1",children:[r==="edit"?g?p.jsx(Kxe,{}):p.jsx(yH,{}):r==="grid"?p.jsx(Wxe,{}):p.jsx(Hxe,{}),p.jsx(Dge,{onStage:h&&!g,startCard:!y}),p.jsx(fpe,{}),p.jsx(pde,{}),p.jsx(mde,{})]})]}),h&&d&&!g?p.jsx(ibe,{}):null,p.jsx(e0e,{}),p.jsx(gde,{}),p.jsx(vbe,{})]})})}Bk.createRoot(document.getElementById("root")).render(p.jsx(T.StrictMode,{children:p.jsxs(Gq,{children:[p.jsx(Xxe,{}),p.jsx(VZ,{})]})}));export{dve as C,pve as F,U_ as I,ive as K,rve as M,eve as O,mve as P,cve as T,fve as a,hve as b,ave as c,lve as d,uve as e,tve as f,ove as g,sve as h,nve as i,Qbe as j,cxe as k,uxe as l,nu as p,Qxe as s,Jxe as v,Zxe as w};
|
|
569
|
+
`)}return X1.read}function D_(e,t){const n=new Map,s=e.querySelector("[data-open-artifact-slide]");s&&n.set(0,{element:s});const o=(r,i)=>{r.forEach((l,u)=>{const d=[...i,u];if(l.origin!==void 0){const h=e.querySelector(`[data-open-artifact-path="${d.join(".")}"]`);h&&n.set(l.origin,{element:h,node:l})}const f=l.children;Array.isArray(f)&&o(f,d)})};return o(t.children,[]),n}function ybe(e,t){const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let s=null;for(let f=n.nextNode();f;f=n.nextNode())if(GS(f.data)){s=f;break}if(!s)return()=>{};const o=s,r=o.data,i=GS(r).value,l=performance.now()+t.delay;let u=0;const d=f=>{const h=t.duration>0?(f-l)/t.duration:1;o.data=h>=1?r:T$(r,t.from+(i-t.from)*Ure(h)),h<1&&(u=requestAnimationFrame(d))};return o.data=T$(r,t.from),u=requestAnimationFrame(d),()=>{cancelAnimationFrame(u),o.data=r}}function bbe(e,t,n,s){const o=t.motion;T.useLayoutEffect(()=>{const i=e.current;if(!s||!o||!i||Lk())return;const{keyframes:l,properties:u}=gbe(),d=D_(i,t),f=[];let h="";const g=`open-artifact-start-${Math.random().toString(36).slice(2,8)}`,y=new Set([...Object.keys(o.elements),...Object.keys(o.starting)].map(Number));for(const v of y){const w=d.get(v);if(!w||w.node?.buildIn||w.node?.buildOut)continue;const S=o.elements[v]??{},C=Bre(Dre(S),l),k=o.starting[v],M=k?Gre(`${g}-${v}`,k,S):null;M&&(h+=M.keyframes);const j=[...C,...M?.animations??[]];if(j.length===0)continue;const O=w.element;O.style.animation=j.map(zre).join(", ");const $=Fre(C,l,u),A=$?ybe(O,$):void 0;f.push(()=>{O.style.animation="",A?.()})}let b;return h&&(b=document.createElement("style"),b.textContent=h,document.head.append(b)),()=>{for(const v of f)v();b?.remove()}},[e,t,o,s]);const r=T.useMemo(()=>[...n].sort((i,l)=>i-l).join(","),[n]);T.useLayoutEffect(()=>{const i=e.current;if(!i||!o?.fragments.length)return;const l=D_(i,t),u=Lk()?"":`opacity ${oh}ms ease`;for(const d of o.fragments){const f=l.get(d.origin)?.element;f&&(f.style.transition=u,f.style.opacity=n.has(d.origin)?"0":"")}},[e,t,o,r])}const xbe=3e3;function z_({slide:e,done:t,animate:n,scale:s,rootRef:o,startedClips:r,onStartClip:i,className:l,motion:u=!1}){const d=T.useMemo(()=>sh(e),[e]),f=T.useMemo(()=>l8(e,d,t,n),[e,d,t,n]),h=T.useMemo(()=>Ere(e,d,t),[e,d,t]),g=T.useMemo(()=>({mode:"present",resolveSrc:wo,builds:f,startedClips:r,onStartClip:i}),[f,r,i]),y=T.useRef(null);return bbe(y,e,h,u),p.jsx("div",{ref:y,className:Ie("absolute left-1/2 top-1/2",l),style:{width:ot*s,height:vt*s,translate:"-50% -50%"},children:p.jsx("div",{className:"origin-top-left overflow-hidden",style:{width:ot,height:vt,transform:`scale(${s})`},children:p.jsx(fd,{slide:e,options:g,rootRef:o})})})}function vbe(){const e=se(t=>t.presenting);return e?p.jsx(wbe,{start:e.start,speaker:e.speaker},e.start):null}function wbe({start:e,speaker:t}){const n=ae(wE(()=>Sr())),[s,o]=T.useState({id:e,done:0,animate:!1}),r=Math.max(0,n.indexOf(s.id)),i=ae(X=>X.slides[s.id]?.slide),l=T.useMemo(()=>i?sh(i):[],[i]),[u,d]=T.useState(null),[f,h]=T.useState(()=>new Set),[g,y]=T.useState(!0),[b,v]=T.useState(!1),[w,S]=T.useState(!1),[C,k]=T.useState(null),[M,j]=T.useState(()=>({startedAt:Date.now(),pausedAt:null})),O=T.useRef(null),$=T.useRef(null),A=T.useRef(null),N=T.useRef(null),_=T.useRef(null),[D,P]=T.useState({w:window.innerWidth,h:window.innerHeight}),L=t&&w,F=L?D.h*.72:D.h,U=Math.min(D.w/ot,F/vt);T.useEffect(()=>{if(n.length===0){se.getState().present(null);return}n.includes(s.id)||o({id:n[Math.min(r,n.length-1)],done:0,animate:!1})},[n,s.id,r]);const I=T.useCallback((X,Z,ne={})=>{const me=Sr()[X];if(!me||me===s.id)return;N.current?.();const ie=ae.getState(),he=ie.slides[s.id]?.slide,ke=ie.slides[me]?.slide;if(!ke)return;const Ne=ne.allDone?sh(ke).length:0,Pe=!ne.cut&&he&&!Lk()?pbe(he,ke,Z):null;d(Pe&&he?{slide:he,done:s.done,direction:Z,kind:Pe}:null),h(new Set),o({id:me,done:Ne,animate:!1})},[s]),H=T.useCallback(()=>{if(u){N.current?.();return}if(s.done<l.length){o(X=>({...X,done:X.done+1,animate:!0}));return}r<n.length-1&&I(r+1,1)},[u,s.done,l.length,r,n.length,I]),q=T.useCallback(()=>{if(u&&N.current?.(),s.done>0){o(X=>({...X,done:X.done-1,animate:!1}));return}r>0&&I(r-1,-1,{allDone:!0})},[u,s.done,r,I]),G=T.useCallback(()=>{const X=s.id;document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),se.getState().present(null),se.getState().showSlide(X)},[s.id]);T.useEffect(()=>{if(u||!l[s.done]?.auto)return;const Z=setTimeout(()=>o(ne=>ne.id===s.id?{...ne,done:ne.done+1,animate:!0}:ne),s.done===0?0:oh);return()=>clearTimeout(Z)},[u,l,s.id,s.done]),T.useLayoutEffect(()=>{if(!u||!A.current||!$.current||!i)return;const X=mbe(u.kind,{slide:u.slide,root:A.current},{slide:i,root:$.current},u.direction,U);let Z=!0;return N.current=X.finish,X.done.then(()=>{Z&&(N.current=null,d(null))}),()=>{Z=!1}},[u]);const Y=T.useRef({text:"",timer:null}),B=T.useCallback(X=>{if(X.target?.closest('textarea, input, [contenteditable="true"]')||X.metaKey||X.ctrlKey||X.altKey)return;const ne=X.key;if(/^[0-9]$/.test(ne)){const ce=Y.current;ce.text=(ce.text+ne).slice(-3),ce.timer&&clearTimeout(ce.timer),ce.timer=setTimeout(()=>{const me=Number(ce.text);ce.text="",me>=1&&me<=Sr().length&&I(me-1,me-1>=r?1:-1,{cut:!0})},500);return}switch(ne){case"ArrowRight":case"ArrowDown":case"PageDown":case" ":case"Enter":case"n":X.preventDefault(),H();return;case"ArrowLeft":case"ArrowUp":case"PageUp":case"Backspace":case"p":X.preventDefault(),q();return;case"Home":X.preventDefault(),I(0,-1,{cut:!0});return;case"End":X.preventDefault(),I(Sr().length-1,1,{cut:!0,allDone:!0});return;case"f":case"F":X.preventDefault(),P_(O.current);return;case"Escape":X.preventDefault(),G();return}},[H,q,I,G,r]);T.useEffect(()=>(window.addEventListener("keydown",B),C?.addEventListener("keydown",B),()=>{window.removeEventListener("keydown",B),C?.removeEventListener("keydown",B)}),[B,C]),T.useEffect(()=>{const X=()=>P({w:window.innerWidth,h:window.innerHeight}),Z=()=>v(!!document.fullscreenElement);return window.addEventListener("resize",X),document.addEventListener("fullscreenchange",Z),O.current?.requestFullscreen&&!document.fullscreenElement&&O.current.requestFullscreen().catch(()=>{}),()=>{window.removeEventListener("resize",X),document.removeEventListener("fullscreenchange",Z)}},[]);const W=T.useRef(null),K=T.useCallback(()=>{y(!0),W.current&&clearTimeout(W.current),W.current=setTimeout(()=>y(!1),xbe)},[]);T.useEffect(()=>(K(),()=>{W.current&&clearTimeout(W.current)}),[K]);const Q=T.useCallback(()=>{if(C&&!C.closed){C.focus();return}const X=ube();if(!X){S(!0),tt.add({title:"The speaker window was blocked",description:"Speaker notes show under the slide instead. Allow pop-ups for this site to open them in their own window."});return}S(!1),k(X)},[C]);T.useEffect(()=>{t&&Q()},[]),T.useEffect(()=>()=>C?.close(),[C]);const J=T.useCallback(X=>h(Z=>new Set([...Z,X])),[]);if(!i)return null;const te=n[r+1]??null;return p.jsxs("div",{ref:O,role:"dialog","aria-modal":!0,"aria-label":"Presentation",className:Ie("fixed inset-0 z-[2000] select-none overflow-hidden bg-black",!g&&"cursor-none"),onPointerMove:K,onPointerDown:X=>{_.current={x:X.clientX,y:X.clientY}},onPointerUp:X=>{const Z=_.current;if(_.current=null,!Z)return;const ne=X.clientX-Z.x;X.pointerType!=="mouse"&&Math.abs(ne)>50&&Math.abs(ne)>Math.abs(X.clientY-Z.y)&&(ne<0?H():q())},onClick:X=>{X.target.closest("a, button, video, iframe, [data-presenter-controls], [data-presenter-notes]")||X.detail>1||H()},onContextMenu:X=>{X.preventDefault(),q()},children:[p.jsxs("div",{className:"absolute inset-x-0 top-0",style:{height:F},children:[u?p.jsx(z_,{slide:u.slide,done:u.done,animate:!1,scale:U,rootRef:A,className:"z-[1]"}):null,p.jsx(z_,{slide:i,done:s.done,animate:s.animate,scale:U,rootRef:$,startedClips:f,onStartClip:J,className:"z-[2]",motion:!0},s.id)]}),L?p.jsxs("div",{"data-presenter-notes":!0,className:"absolute inset-x-0 bottom-0 flex flex-col border-t border-white/15 bg-neutral-950 text-white",style:{height:D.h-F},children:[p.jsxs("div",{className:"px-4 pt-2 text-[11px] uppercase tracking-wide text-white/50",children:["Speaker notes · Slide ",r+1," of ",n.length]}),p.jsx($C,{slideId:s.id,className:"h-full w-full resize-none bg-transparent px-4 py-2 text-lg leading-relaxed text-white outline-none placeholder:text-white/40"},s.id)]}):null,p.jsxs("div",{"data-presenter-controls":!0,className:Ie("absolute bottom-4 left-1/2 flex -translate-x-1/2 items-center gap-1 rounded-full bg-neutral-900/85 px-2 py-1 text-white shadow-lg backdrop-blur transition-opacity duration-300",g?"opacity-100":"pointer-events-none opacity-0"),style:L?{bottom:D.h-F+16}:void 0,children:[p.jsx(da,{label:"Previous",shortcut:"←",icon:p.jsx(wL,{className:"size-4"}),className:"text-white hover:bg-white/15 hover:text-white",disabled:r===0&&s.done===0,onClick:q}),p.jsxs("span",{className:"min-w-16 text-center text-xs tabular-nums text-white/80",children:[r+1," / ",n.length]}),p.jsx(da,{label:"Next",shortcut:"→",icon:p.jsx(z2,{className:"size-4"}),className:"text-white hover:bg-white/15 hover:text-white",disabled:r===n.length-1&&s.done>=l.length,onClick:H}),p.jsx("span",{className:"mx-1 h-4 w-px bg-white/20"}),p.jsx(da,{label:"Speaker notes",icon:p.jsx(sY,{className:"size-4"}),className:"text-white hover:bg-white/15 hover:text-white",onClick:Q}),p.jsx(da,{label:b?"Exit full screen":"Full screen",shortcut:"F",icon:b?p.jsx(FW,{className:"size-4"}):p.jsx(I2,{className:"size-4"}),className:"text-white hover:bg-white/15 hover:text-white",onClick:()=>P_(O.current)}),p.jsx(da,{label:"Stop presenting",shortcut:"Esc",icon:p.jsx(_i,{className:"size-4"}),className:"text-white hover:bg-white/15 hover:text-white",onClick:G})]}),C?p.jsx(fbe,{popup:C,position:s,index:r,count:n.length,steps:l.length,nextId:te,clock:M,onClock:j,onNext:H,onPrevious:q,onClosed:()=>k(null)}):null]})}function P_(e){document.fullscreenElement?document.exitFullscreen().catch(()=>{}):e?.requestFullscreen?.().catch(()=>{})}const yi=Ns()(()=>({drag:null})),Sbe=5;function kbe(e,t){const n=[...e.querySelectorAll("[data-section-row]")];let s=n.length;for(const o of n){const r=o.getBoundingClientRect();if(t<r.top+r.height/2){s=Number(o.dataset.sectionRow);break}}return s}function Ebe(e,t){if(e.button!==0||!hn())return;const n=e.currentTarget.closest("[data-section-rows]");if(!n)return;const s=[...n.querySelectorAll("[data-section-row]")].map(y=>y.dataset.sectionKey||null),o=e.clientX,r=e.clientY;let i=!1;const l=()=>{const y=se.getState().sectionSelection,b=y.includes(t)?y:[t];return s.filter(v=>v!==null&&b.includes(v))},u=y=>{if(!i){if(Math.hypot(y.clientX-o,y.clientY-r)<Sbe)return;i=!0,document.body.style.cursor="grabbing"}yi.setState({drag:{keys:l(),gap:kbe(n,y.clientY)}});const b=n.closest("[data-section-scroll]");if(b){const v=b.getBoundingClientRect();y.clientY<v.top+32?b.scrollBy(0,-12):y.clientY>v.bottom-32&&b.scrollBy(0,12)}},d=y=>{window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",h),window.removeEventListener("keydown",g,!0),document.body.style.cursor="";const b=yi.getState().drag;if(yi.setState({drag:null}),!i){y&&se.getState().sectionSelection.length>1&&se.getState().selectSections([t]);return}y&&b&&b.gap!==null&&b.keys.length&&Yoe(b.keys,b.gap)},f=()=>d(!0),h=()=>d(!1),g=y=>{y.key!=="Escape"||!i||(y.preventDefault(),y.stopPropagation(),d(!1))};window.addEventListener("pointermove",u),window.addEventListener("pointerup",f),window.addEventListener("pointercancel",h),window.addEventListener("keydown",g,!0)}const JH=T.memo(function({id:t,index:n,comments:s,peers:o,dragging:r,dropBefore:i,dropAfter:l,onPointerDown:u,onOpen:d,width:f}){const h=ae(S=>S.slides[t]),g=se(S=>S.current===t),y=se(S=>S.slideSelection.includes(t)),b=uB(t);if(!h)return null;const v=h.held??(h.conflict?"Changed elsewhere at the same time":null),w=Gl(h.slide);return p.jsxs(xb,{menu:p.jsx(vb,{ids:se.getState().slideSelection.includes(t)?qo():[t]}),onOpen:()=>{se.getState().slideSelection.includes(t)||se.getState().showSlide(t)},className:"relative shrink-0 outline-none",style:f?{width:f}:void 0,children:[i?p.jsx("span",{"aria-hidden":!0,className:"absolute -left-[13px] inset-y-0 w-1 rounded bg-accent"}):null,l?p.jsx("span",{"aria-hidden":!0,className:"absolute -right-[13px] inset-y-0 w-1 rounded bg-accent"}):null,p.jsxs("div",{"data-slide-index":n,"data-slide-id":t,role:"option","aria-selected":y||g,"aria-label":`Slide ${n+1}${w?`: ${w}`:""}`,onPointerDown:S=>u(S,t),onDoubleClick:()=>d(t),className:Ie("group cursor-default",r&&"opacity-40",b&&"oa-arrive"),children:[p.jsxs("div",{className:Ie("relative overflow-hidden rounded-md ring-1 ring-line transition-shadow",y||g?"ring-2 ring-accent":"group-hover:ring-line-strong",h.slide.hidden&&"opacity-50"),children:[p.jsx(Xl,{slide:h.slide,virtual:!0}),p.jsxs("div",{className:"pointer-events-none absolute bottom-1.5 right-1.5 flex items-center gap-1",children:[p.jsx(NC,{peers:o}),s?p.jsxs("span",{className:"flex items-center gap-0.5 rounded-full bg-surface px-1.5 text-[10px] text-fg shadow-popup",children:[p.jsx(Rr,{className:"size-2.5"}),s]}):null]})]}),p.jsxs("div",{className:"flex items-center gap-1.5 pt-1.5 text-[11px] text-fg-muted",children:[p.jsx("span",{className:Ie("tabular-nums",(y||g)&&"font-semibold text-fg"),children:n+1}),p.jsx("span",{className:"min-w-0 flex-1 truncate",children:w}),h.slide.hidden?p.jsx(Mh,{className:"size-3 shrink-0","aria-label":"Skipped"}):null,v?p.jsx(Sa,{className:"size-3 shrink-0 text-warning","aria-label":v}):null]})]})]})});function qC({section:e,n:t,ids:n,previousGap:s,nextGap:o,className:r}){const i=e?.key??"-",l=se(b=>b.editingSection===i),u=se(b=>b.sectionSelection.includes(i)),d=ae(b=>!b.readOnly&&!b.indexError)&&hn(),f=e?.description??"",h=`Section ${t+1}`,g=d&&(e!==null||n.length>0),y=b=>{se.getState().setEditingSection(null);const v=hE(b);v!==f&&(e?Goe(e.key,v):n[0]&&Woe(n[0],v))};return p.jsxs("div",{"data-section-label":i,className:Ie("group/label flex min-w-0 items-start gap-2 rounded-md px-1.5 py-1",u&&"bg-accent-soft",e&&d&&"cursor-grab",r),onPointerDown:b=>{const v=b.target;if(b.button!==0||v.closest("textarea")||v.closest("button")&&!v.closest("[data-section-describe]"))return;const w=se.getState(),S=b.metaKey||b.ctrlKey||b.shiftKey;S?w.selectSections(u?w.sectionSelection.filter(C=>C!==i):[...w.sectionSelection,i]):(!u||!e||!d)&&w.selectSections([i]),w.selectSlides([...n]),e&&d&&!S&&Ebe(b,e.key)},children:[p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-fg-muted",children:h}),l?p.jsx(Cbe,{initial:f,onCommit:y,onCancel:()=>se.getState().setEditingSection(null)}):p.jsx("button",{type:"button","data-section-describe":!0,disabled:!g,"aria-label":f||(g?`${h}, Describe this section`:h),className:Ie("block max-w-full truncate text-left text-sm",f?"text-fg":"text-fg-subtle",g&&"hover:text-fg"),onClick:()=>g&&se.getState().setEditingSection(i),children:f||(g?"Describe this section":"")})]}),d&&e?p.jsxs(kz,{trigger:p.jsx(da,{size:"sm",noTooltip:!0,label:`Actions for ${h}`,icon:p.jsx(P2,{className:"size-3.5"}),className:"opacity-0 group-hover/label:opacity-100 focus-visible:opacity-100 pointer-coarse:opacity-100"}),align:"end",children:[p.jsxs(ft,{onSelect:()=>se.getState().setEditingSection(i),children:["Describe ",h]}),p.jsx(ft,{disabled:s===null,onSelect:()=>s!==null&&h$(e.key,s),children:"Move section earlier"}),p.jsx(ft,{disabled:o===null,onSelect:()=>o!==null&&h$(e.key,o),children:"Move section later"}),p.jsx(ft,{icon:p.jsx(ds,{className:"size-4"}),disabled:n.length===0,onSelect:()=>{_a("blank",n.at(-1)??null)},children:"Add a slide to this section"}),p.jsx(ft,{icon:p.jsx(wy,{className:"size-4"}),danger:!0,onSelect:()=>qoe(e.key),children:"Remove section"})]}):null]})}function Cbe({initial:e,onCommit:t,onCancel:n}){const[s,o]=T.useState(e),r=T.useRef(null),i=T.useRef(!1);return T.useEffect(()=>{r.current?.focus(),r.current?.select()},[]),p.jsx("textarea",{ref:r,rows:2,value:s,maxLength:ve.sectionDescription,placeholder:"Describe this section","aria-label":"Section description",className:"mt-0.5 block w-full resize-none rounded border border-accent bg-canvas px-1.5 py-1 text-sm text-fg outline-none",onChange:l=>o(l.target.value.replace(/\n/g," ")),onBlur:()=>{i.current||(i.current=!0,t(s))},onKeyDown:l=>{l.stopPropagation(),l.key==="Enter"?(l.preventDefault(),i.current=!0,t(s)):l.key==="Escape"&&(l.preventDefault(),i.current=!0,n())}})}function GC({gap:e,after:t,className:n}){return hn()?p.jsxs(kz,{trigger:p.jsx("button",{type:"button","aria-label":"Add a slide or section here",className:Ie("flex size-6 items-center justify-center rounded-full border border-line bg-surface text-fg-muted opacity-0 shadow-popup transition-opacity hover:text-fg focus-visible:opacity-100 group-hover/gap:opacity-100 pointer-coarse:opacity-100",n),children:p.jsx(ds,{className:"size-3.5"})}),align:"center",children:[p.jsx(ft,{icon:p.jsx(ds,{className:"size-4"}),onSelect:()=>{_a("blank",t)},children:"New slide here"}),p.jsx(ft,{icon:p.jsx(bS,{className:"size-4"}),onSelect:()=>Voe(e),children:"New section here"})]}):null}const vs=480,Yu=28,ho=48,ir=96,sr=320;function Tbe(e,t,n){const s=vs*n/t,o=s+Yu,r=[],i=new Map,l=[];let u=0;e.forEach((f,h)=>{const g=h*(o+ir);l.push({row:h,section:f.section,key:f.section?.key??null,top:g,first:u,ids:f.ids,empty:f.ids.length===0?{x:sr,y:g,w:vs,h:s}:null}),f.ids.forEach((y,b)=>{const v={id:y,index:u++,row:h,x:sr+b*(vs+ho),y:g,w:vs,h:s};r.push(v),i.set(y,v)})});const d=Math.max(1,...e.map(f=>f.ids.length));return{tiles:r,byId:i,rows:l,slideH:s,tileH:o,width:sr+d*vs+(d-1)*ho,height:Math.max(1,e.length)*(o+ir)-ir}}const Dk=(e,t,n)=>t>=e.x&&t<e.x+e.w&&n>=e.y&&n<e.y+e.h;function Mbe(e,t){const n=e.tileH+ir,s=Math.floor((t+ir/2)/n);return e.rows[Math.min(e.rows.length-1,Math.max(0,s))]}function I_(e,t,n){const s=Mbe(e,n);if(!s||!s.ids.length)return null;const o=Math.floor((t-sr)/(vs+ho)),r=s.ids[o],i=r===void 0?void 0:e.byId.get(r);return i?Dk(i,t,n)?{tile:i,caption:!1}:Dk({x:i.x,y:i.y+i.h,w:i.w,h:Yu},t,n)?{tile:i,caption:!0}:null:null}function Rbe(e,t,n){for(const s of e.rows)if(s.empty&&s.key&&Dk(s.empty,t,n))return s.key;return null}function jbe(e,t,n){let s=null,o=1/0;for(const r of e.tiles){const i=r.y+e.tileH,l=t<r.x?r.x-t:t>r.x+r.w?t-r.x-r.w:0,d=(n<r.y?r.y-n:n>i?n-i:0)*4+l;d<o&&(s=r,o=d)}return s?s.index+(t>s.x+s.w/2?1:0):0}function Abe(e,t){const n=[],s=e.tiles[t],o=e.tiles[t-1];return s&&n.push({x:s.x-ho/2-2,y:s.y,w:4,h:e.tileH}),o&&(!s||s.row!==o.row)&&n.push({x:o.x+o.w+ho/2-2,y:o.y,w:4,h:e.tileH}),n}function zk(e,t){const n=[];for(const s of e.tiles)s.x<t.x+t.w&&s.x+s.w>t.x&&s.y<t.y+t.h&&s.y+e.tileH>t.y&&n.push(s);return n}function Obe(e,t){return{x:e.x-e.w*t,y:e.y-e.h*t,w:e.w*(1+t*2),h:e.h*(1+t*2)}}const yf=32,Nbe=1,$be=2,_be=3,Lbe=0,Dbe=1,zbe=2,Pbe=1,Ibe=2,Bbe=4,Hbe=8,Fbe=16,Ube=32,Vbe=64,qbe=128,Gbe=256,Wbe=512,Ybe=1024,Kbe=2048,Xbe=4096,Zbe=8192,Qbe=2,e9=0,Vf=1,B_=2,Pk=3,t9=4,eve={minZoom:1,maxZoom:2,snap:3,snapDistance:4,dragThreshold:5,hitTolerance:6,handleSize:7,settleMs:8,cameraEventMs:9,wheelZoom:10,selection:11,marquee:12,fadeMs:13,dragEvents:14,grid:15,gridSpacing:16,textureBudget:17,zoomSpeed:18,wheelZoomMax:19,gridMajor:20,gridFadeStart:21,gridFadeEnd:22},tve={background:30,grid:31,selection:32,handle:33,guide:34,marquee:35,hover:36},nve=1,sve=2,ove=4,rve=8,ive=1,ave=2,lve=3,cve={select:0,pan:1,none:2},uve={mouse:0,pen:1,touch:2},dve=["default","grab","grabbing","move","ns-resize","ew-resize","nwse-resize","nesw-resize","crosshair"],fve=1,hve=2,pve=4,Jbe={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},exe=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/;function Mb(e){const t=exe.exec(e);if(!t)return null;const n=e.slice(t[0].length);return/^(%|deg|rad|grad|turn)?$/.test(n)?{v:parseFloat(t[0]),unit:n}:null}function txe(e){const t=e.includes(","),[n,s,o]=t?[e,void 0,void 0]:e.split("/");if(o!==void 0)return null;const r=n.split(t?",":/\s+/).map(u=>u.trim()).filter(Boolean);if(t?r.length!==3&&r.length!==4:r.length!==3)return null;const i=t?r[3]:s?.trim();if(i==="")return null;const l=u=>u==="none"?"0":u;return[l(r[0]),l(r[1]),l(r[2]),i===void 0?void 0:l(i)]}function nxe(e){if(e===void 0)return 1;const t=Mb(e);return!t||t.unit&&t.unit!=="%"?NaN:t.unit==="%"?t.v/100:t.v}function sxe(e){const t=Mb(e);if(!t)return NaN;switch(t.unit){case"":case"deg":return t.v;case"rad":return t.v*180/Math.PI;case"grad":return t.v*.9;case"turn":return t.v*360;default:return NaN}}function H_(e){const t=Mb(e);return t?t.unit==="%"||t.unit===""?t.v/100:NaN:NaN}function F_(e,t,n,s){const o=(r,i)=>Math.round(Math.min(Math.max(r,0),i));return(o(e,255)<<24|o(t,255)<<16|o(n,255)<<8|o(s*255,255))>>>0}function oxe(e,t,n){const s=(e%360+360)%360,o=l=>(l+s/30)%12,r=t*Math.min(n,1-n),i=l=>n-r*Math.max(-1,Math.min(o(l)-3,9-o(l),1));return[i(0)*255,i(8)*255,i(4)*255]}function nu(e,t=0){if(e==null)return t;if(typeof e=="number")return e>>>0;const n=e.trim().toLowerCase();if(n==="transparent"||n==="none")return 0;const s=Jbe[n];if(s!==void 0)return(s<<8|255)>>>0;if(n.startsWith("#")){const l=n.slice(1);if(/^[0-9a-f]+$/.test(l)){if(l.length===3||l.length===4){const u=[...l].map(d=>d+d).join("");return parseInt(l.length===3?u+"ff":u,16)>>>0}if(l.length===6)return parseInt(l+"ff",16)>>>0;if(l.length===8)return parseInt(l,16)>>>0}}const o=/^(rgba?|hsla?)\(\s*([^()]*)\)$/.exec(n),r=o?txe(o[2]):null;if(o&&r){const[l,u,d,f]=r,h=nxe(f);if(o[1].startsWith("rgb")){const g=b=>{const v=Mb(b);return v?v.unit==="%"?v.v/100*255:v.unit===""?v.v:NaN:NaN},y=[g(l),g(u),g(d)];if([...y,h].every(Number.isFinite))return F_(y[0],y[1],y[2],h)}else{const g=sxe(l),y=Math.min(Math.max(H_(u),0),1),b=Math.min(Math.max(H_(d),0),1);if([g,y,b,h].every(Number.isFinite)){const[v,w,S]=oxe(g,y,b);return F_(v,w,S,h)}}}const i=rxe(n);if(i!==null)return i;throw new TypeError(`canvas-engine: unsupported colour ${JSON.stringify(e)}`)}let _o;const ig=new Map;function rxe(e){const t=ig.get(e);if(t!==void 0)return t;_o===void 0&&(_o=typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1).getContext("2d",{willReadFrequently:!0}):typeof document<"u"?document.createElement("canvas").getContext("2d",{willReadFrequently:!0}):null);let n=null;if(_o){_o.fillStyle="#000",_o.fillStyle=e;const s=_o.fillStyle;if(_o.fillStyle="#fff",_o.fillStyle=e,s===_o.fillStyle){_o.clearRect(0,0,1,1),_o.fillRect(0,0,1,1);const[o,r,i,l]=_o.getImageData(0,0,1,1).data;n=l===0?0:(o<<24|r<<16|i<<8|l)>>>0}}return ig.size>512&&ig.clear(),ig.set(e,n),n}function ixe(e){let t=0;return e.visible!==!1&&(t|=Pbe),e.hittable!==!1&&(t|=Ibe),e.selectable!==!1&&(t|=Bbe),e.movable!==!1&&(t|=Hbe),e.resizable!==!1&&(t|=Fbe),e.snap!==!1&&(t|=Ube),e.lockAspect&&(t|=Vbe),e.hitStrokeOnly&&(t|=qbe),e.screenStroke&&(t|=Gbe),e.hover===!1&&(t|=Wbe),e.selectionOutline===!1&&(t|=Ybe),e.handles==="corners"?t|=Kbe:e.handles==="width"&&(t|=Xbe),e.blend==="multiply"&&(t|=Zbe),t}function axe(e){const t=/([MmLlHhVvCcSsQqTtAaZz])|([-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?)/g,n=[];let s;for(;s=t.exec(e);)n.push(s[1]?{cmd:!0,raw:s[1]}:{cmd:!1,raw:s[2]});return n}function lxe(e,t,n,s,o,r,i,l,u,d){if(s===0||o===0){e.push(Vf,u,d);return}if(t===u&&n===d)return;s=Math.abs(s),o=Math.abs(o);const f=r*Math.PI/180,h=Math.cos(f),g=Math.sin(f),y=(t-u)/2,b=(n-d)/2,v=h*y+g*b,w=-g*y+h*b,S=v*v/(s*s)+w*w/(o*o);if(S>1){const q=Math.sqrt(S);s*=q,o*=q}const C=s*s*o*o-s*s*w*w-o*o*v*v,k=s*s*w*w+o*o*v*v;let M=Math.sqrt(Math.max(0,C/k));i===l&&(M=-M);const j=M*s*w/o,O=-M*o*v/s,$=h*j-g*O+(t+u)/2,A=g*j+h*O+(n+d)/2,N=(q,G,Y,B)=>Math.atan2(q*B-G*Y,q*Y+G*B),_=N(1,0,(v-j)/s,(w-O)/o);let D=N((v-j)/s,(w-O)/o,(-v-j)/s,(-w-O)/o);!l&&D>0&&(D-=2*Math.PI),l&&D<0&&(D+=2*Math.PI);const P=Math.max(1,Math.ceil(Math.abs(D)/(Math.PI/2))),L=D/P,F=4/3*Math.tan(L/4);let U=_;const I=q=>{const G=s*Math.cos(q),Y=o*Math.sin(q);return[$+h*G-g*Y,A+g*G+h*Y]},H=q=>{const G=-s*Math.sin(q),Y=o*Math.cos(q);return[h*G-g*Y,g*G+h*Y]};for(let q=0;q<P;q++){const G=U+L,[Y,B]=I(U),[W,K]=I(G),[Q,J]=H(U),[te,X]=H(G);e.push(Pk,Y+F*Q,B+F*J,W-F*te,K-F*X,q===P-1?u:W,q===P-1?d:K),U=G}}function cxe(e){const t=[],n=axe(e);let s=0,o="",r=0,i=0,l=0,u=0,d=0,f=0,h="";const g=()=>{const b=n[s];if(!b||b.cmd)throw new SyntaxError(`canvas-engine: bad path data near token ${s} in ${JSON.stringify(e.slice(0,80))}`);return s++,parseFloat(b.raw)},y=()=>{const b=n[s];if(!b||b.cmd||b.raw[0]!=="0"&&b.raw[0]!=="1")throw new SyntaxError(`canvas-engine: bad arc flag near token ${s}`);return b.raw.length>1?n[s]={cmd:!1,raw:b.raw.slice(1)}:s++,b.raw[0]==="1"};for(;s<n.length;){const b=n[s];if(b.cmd)o=b.raw,s++;else if(!o)throw new SyntaxError("canvas-engine: path data must start with a command");const v=o===o.toLowerCase(),w=v?r:0,S=v?i:0;switch(o.toUpperCase()){case"M":{r=w+g(),i=S+g(),l=r,u=i,t.push(e9,r,i),o=v?"l":"L",h="M";break}case"L":r=w+g(),i=S+g(),t.push(Vf,r,i),h="L";break;case"H":r=w+g(),t.push(Vf,r,i),h="L";break;case"V":i=S+g(),t.push(Vf,r,i),h="L";break;case"C":{const C=w+g(),k=S+g();d=w+g(),f=S+g(),r=w+g(),i=S+g(),t.push(Pk,C,k,d,f,r,i),h="C";break}case"S":{const C=h==="C"?2*r-d:r,k=h==="C"?2*i-f:i;d=w+g(),f=S+g(),r=w+g(),i=S+g(),t.push(Pk,C,k,d,f,r,i),h="C";break}case"Q":d=w+g(),f=S+g(),r=w+g(),i=S+g(),t.push(B_,d,f,r,i),h="Q";break;case"T":d=h==="Q"?2*r-d:r,f=h==="Q"?2*i-f:i,r=w+g(),i=S+g(),t.push(B_,d,f,r,i),h="Q";break;case"A":{const C=g(),k=g(),M=g(),j=y(),O=y(),$=w+g(),A=S+g();lxe(t,r,i,C,k,M,j,O,$,A),r=$,i=A,h="A";break}case"Z":if(t.push(t9),r=l,i=u,h="Z",n[s]&&!n[s].cmd)throw new SyntaxError("canvas-engine: numbers after Z in path data");break;default:throw new SyntaxError(`canvas-engine: unknown path command ${o}`)}}return t}function uxe(e,t=!1){const n=[];for(let s=0;s+1<e.length;s+=2)n.push(s===0?e9:Vf,e[s],e[s+1]);return t&&n.length&&n.push(t9),n}class U_{#e=new Map;#t=[];#i=[];#o=[];get size(){return this.#e.size}get(t){return this.#e.get(t)}ensure(t){let n=this.#e.get(t);return n===void 0&&(n=this.#i.pop()??this.#t.length,this.#e.set(t,n),this.#t[n]=t),n}id(t){return this.#t[t]}ids(t){const n=[];for(let s=0;s<t.length;s++){const o=this.#t[t[s]];o!==void 0&&n.push(o)}return n}release(t){const n=this.#e.get(t);if(n!==void 0)return this.#e.delete(t),this.#t[n]=void 0,this.#o.push(n),n}clear(){for(const t of this.#e.values())this.#o.push(t);this.#e.clear(),this.#t.fill(void 0)}flush(){this.#i.push(...this.#o),this.#o.length=0}}const dxe={butt:0,round:1,square:2},fxe={miter:0,round:1,bevel:2};class mve{items=new U_;textures=new U_;#e=new Map;#t(t){const n=this.#e.get(t.id),s=t.closed??!1;if(n&&n.d===t.d&&n.points===t.points&&n.closed===s)return n.cmds;const o=t.d!==void 0?cxe(t.d):t.points?uxe(t.points,s):[];return this.#e.set(t.id,{d:t.d,points:t.points,closed:s,cmds:o}),o}encode(t){const n=t.upsert??[],s=t.remove??[],o=(t.clear?1:0)+s.length+n.length,r=new Float64Array(o*yf),i=[];let l=0,u=0;t.clear&&(r[0]=_be,this.items.clear(),this.#e.clear(),u=1);for(const h of s){const g=this.items.release(h);if(this.#e.delete(h),g===void 0)continue;const y=u*yf;r[y]=$be,r[y+1]=g,u++}for(const h of n){const g=u*yf;switch(u++,r[g]=Nbe,r[g+1]=this.items.ensure(h.id),r[g+3]=h.layer??0,r[g+4]=h.z??0,r[g+5]=h.x,r[g+6]=h.y,r[g+7]=h.w,r[g+8]=h.h,r[g+9]=h.rotation??0,r[g+10]=ixe(h),r[g+11]=h.opacity??1,r[g+22]=-1,h.kind){case"hole":r[g+2]=Dbe,r[g+15]=h.radius??0;break;case"path":{r[g+2]=zbe,r[g+12]=nu(h.fill),r[g+13]=nu(h.stroke),r[g+14]=h.strokeWidth??1,r[g+16]=h.dash?.[0]??0,r[g+17]=h.dash?.[1]??0;const y=this.#t(h);r[g+23]=l,r[g+24]=y.length,i.push(y),l+=y.length;const b=h.cuts?.slice(0,Qbe)??[];if(b.length){const v=b.flatMap(w=>[w.x,w.y,w.w,w.h]);i.push(v),l+=v.length,r[g+31]=b.length}r[g+25]=h.viewBox?.[0]??0,r[g+26]=h.viewBox?.[1]??0,r[g+27]=dxe[h.cap??"butt"],r[g+28]=fxe[h.join??"miter"],r[g+29]=h.miterLimit??4,r[g+30]=h.fillRule==="evenodd"?1:0;break}default:r[g+2]=Lbe,r[g+12]=nu(h.fill),r[g+13]=nu(h.stroke),r[g+14]=h.strokeWidth??(h.stroke!==void 0?1:0),r[g+15]=h.radius??0,r[g+16]=h.dash?.[0]??0,r[g+17]=h.dash?.[1]??0,h.shadow&&(r[g+18]=nu(h.shadow.color),r[g+19]=h.shadow.blur,r[g+20]=h.shadow.dx??0,r[g+21]=h.shadow.dy??0),h.texture!==void 0&&(r[g+22]=this.textures.ensure(h.texture))}}const d=new Float32Array(l);let f=0;for(const h of i)d.set(h,f),f+=h.length;return this.items.flush(),{ops:u*yf===r.length?r:r.subarray(0,u*yf),paths:d,records:u}}}const hxe=(()=>{try{return new URLSearchParams(location.search).get("open_artifact_engine")==="off"}catch{return!1}})(),pxe=.05,mxe=2,gxe=48,yxe=12,bxe=48,xxe=1.25,Z1=160,vxe=6,wxe=6,Sxe=500;let Q1=null;function V_(){const e=ae.getState(),t=fn(e),n=us(_n(Bh({sections:e.index.sections}),t),t),s=`${ot}:${JSON.stringify(n)}`;return{layout:Tbe(n,ot,vt),key:s}}function n9(e){try{return nu(e),e}catch{return null}}function q_(){const e=getComputedStyle(document.documentElement),t=(n,s)=>n9(e.getPropertyValue(n).trim())??s;return{accent:t("--open-artifact-accent","#2563eb"),accentSoft:t("--open-artifact-accent-soft","rgba(37, 99, 235, 0.12)"),line:t("--open-artifact-line","rgba(0, 0, 0, 0.1)"),lineStrong:t("--open-artifact-line-strong","rgba(0, 0, 0, 0.2)")}}async function kxe(e,t){const n=Array.from(e.querySelectorAll("img"),s=>s.decode().catch(()=>{}));await Promise.race([Promise.all(n),new Promise(s=>setTimeout(s,t))])}const G_=()=>new Promise(e=>requestAnimationFrame(()=>e())),J1=(e,t)=>`${e}|${t.key}`;class Exe{store;#e=null;#t=null;#i=!1;#o=[];#x;#r={x:0,y:0,zoom:1};#m=!1;#c=new Set;#T=new Set;#a=new Map;#f=new Set;#l=new Map;#u=new Map;#d=new Map;#g=[];#y=new Set;#h=new Map;#v=new Set;#w=new Set;#S=new Set;#b={accent:"#2563eb",accentSoft:"rgba(37, 99, 235, 0.12)",line:"rgba(0, 0, 0, 0.1)",lineStrong:"rgba(0, 0, 0, 0.2)"};#k=new Map;#p=null;#M=!1;#n=null;constructor(){const{layout:t,key:n}=V_();this.#x=n,this.store=_P()(()=>({layout:t,view:null,zoom:1,hover:null,live:[],drag:null,menu:null}))}async start(t,n){const{CanvasEngine:s}=await $P(async()=>{const{CanvasEngine:i}=await import("./src-CxNLgI5_.js");return{CanvasEngine:i}},[],import.meta.url);if(this.#i)return;this.#b=q_();const o=await s.create(n,{selection:"controlled",snap:!1,grid:"none",minZoom:pxe,maxZoom:mxe,cameraEventMs:0,dragEvents:!0,dragThreshold:5,zoomSpeed:.01,wheelZoomMax:1/0,theme:this.#j()});if(this.#i){o.destroy();return}this.#e=o,this.#t=n;const r=(i,l)=>{this.#o.push(o.on(i,l))};r("camera",i=>this.#B(i)),r("moving",({moving:i})=>{i&&(this.#m=!0,this.#s())}),r("holes",({holes:i})=>this.#G(i)),r("textureNeeded",({keys:i})=>this.#q(i)),r("hover",({id:i})=>this.store.setState({hover:i})),r("gesture",i=>this.#X(i)),r("dragging",i=>this.#Z(i)),r("dblclick",({id:i,world:l})=>{const u=this.#I(i,l);u&&se.getState().editOnCanvas(u)}),r("contextmenu",({id:i,world:l,event:u})=>{const d=this.#I(i,l);if(!d){u?.stopPropagation();return}se.getState().slideSelection.includes(d)||se.getState().showSlide(d),this.store.setState({menu:d})}),r("commit",i=>{i.op==="select"?this.#M&&this.#J(i.ids):i.op==="move"&&this.#Q()}),this.#W(t,n),this.#V(),this.#N(),this.#s(),Q1?o.setCamera(Q1):this.fit(0),globalThis.__openArtifactCanvasEngine=()=>this.#ee()}destroy(){if(this.#i)return;this.#i=!0;for(const n of this.#o)n();this.#o.length=0,this.#e?.destroy(),this.#e=null,this.#n&&(se.getState().setDropGap(null),If([]));const t=globalThis;delete t.__openArtifactCanvasEngine}fit(t=300){const{layout:n}=this.store.getState();this.#e?.glideTo({x:0,y:0,w:n.width,h:n.height},{duration:t,padding:gxe,maxZoom:1})}zoomBy(t){this.#e?.zoomAt(t)}attachWorld(t){return this.#w.add(t),t.style.transform=this.#R(),()=>this.#w.delete(t)}attachZoomReadout(t){return this.#S.add(t),t.textContent=`${Math.round(this.#r.zoom*100)}%`,()=>this.#S.delete(t)}#R(){const{x:t,y:n,zoom:s}=this.#r;return`translate(${-t*s}px, ${-n*s}px) scale(${s})`}#B(t){this.#r={x:t.x,y:t.y,zoom:t.zoom},Q1=this.#r;const n=this.#R();for(const o of this.#w)o.style.transform=n;const s=`${Math.round(t.zoom*100)}%`;for(const o of this.#S)o.textContent=s;aB(),t.settled&&(this.#m=!1,this.#E())}#E(){const t=this.#e;if(!t)return;const{layout:n}=this.store.getState(),s=t.viewport();this.#c=new Set(zk(n,s).map(i=>i.id));const o=this.#H(s),r=this.store.getState().live;this.#T=new Set(o),this.store.setState({view:s,zoom:this.#r.zoom,live:o.length===r.length&&o.every((i,l)=>r[l]===i)?r:o});for(const[i,l]of this.#h)this.#f.has(i)||this.#P(i,l);for(const i of this.#c){const l=this.#l.get(i);l&&this.#d.get(l)===1&&this.#O()&&this.#L(l)}this.#s()}#H(t){const{layout:n}=this.store.getState(),s=vs*this.#r.zoom,o=s*(devicePixelRatio||1),r=ot*rB*xxe,i=t.x+t.w/2,l=t.y+t.h/2,u=s<bxe?[]:zk(n,t).filter(f=>!this.#C(f.id)||o>r).map(f=>({id:f.id,d:Math.hypot(f.x+f.w/2-i,f.y+f.h/2-l)})).sort((f,h)=>f.d-h.d).slice(0,yxe).map(f=>f.id),d=se.getState().current;return d&&this.#c.has(d)&&!u.includes(d)&&u.push(d),u}#s(){const t=this.#e;if(!t||this.#n)return;const{layout:n}=this.store.getState(),s=ae.getState(),o=hn(),r=new Set(yi.getState().drag?.keys??[]),i=[],l=new Set;let u=!1;for(const f of n.tiles){const h=s.slides[f.id]?.slide;if(!h)continue;const g=n.rows[f.row]?.key,y=this.#v.has(f.id)&&this.#T.has(f.id)&&!(this.#m&&this.#C(f.id)),b={id:f.id,x:f.x,y:f.y,w:f.w,h:f.h,radius:wxe,movable:o,resizable:!1,snap:!1},v=y?{...b,kind:"hole"}:{...b,kind:"image",fill:this.#F(h),stroke:this.#b.line,strokeWidth:1,screenStroke:!0,texture:this.#l.get(f.id),opacity:(h.hidden?.5:1)*(g&&r.has(g)?.4:1)};l.add(f.id),y?this.#f.add(f.id):this.#f.delete(f.id);const w=JSON.stringify(v);this.#a.get(f.id)!==w&&(this.#a.has(f.id)||(u=!0),this.#a.set(f.id,w),i.push(v))}const d=[...this.#a.keys()].filter(f=>!l.has(f));for(const f of d)this.#a.delete(f),this.#f.delete(f);(i.length||d.length)&&t.applyPatch({upsert:i,remove:d}),u&&this.#A()}#F(t){const n=t.style.background;if(!n||/url\(|gradient/i.test(n))return"#ffffff";let s=this.#k.get(n);return s===void 0&&(s=n9(n)??"#ffffff",this.#k.set(n,s)),s}#j(){const t=this.#b;return{background:"transparent",grid:"transparent",selection:t.accent,handle:t.accent,guide:t.accent,marquee:t.accentSoft,hover:t.lineStrong}}#A(){const t=se.getState(),n=new Set(t.slideSelection);t.current&&n.add(t.current),this.#e?.setSelection([...n].filter(s=>this.#a.has(s)))}#U(){const{layout:t,key:n}=V_();n!==this.#x?(this.#x=n,this.store.setState({layout:t}),this.#E()):this.#s()}#V(){const t=r=>{this.#o.push(r)};t(ae.subscribe((r,i)=>{(r.index!==i.index||r.slides!==i.slides||r.status!==i.status||r.readOnly!==i.readOnly)&&this.#U()})),t(se.subscribe((r,i)=>{(r.slideSelection!==i.slideSelection||r.current!==i.current)&&this.#A(),r.current!==i.current&&!this.#m&&this.#E()})),t(yi.subscribe(()=>this.#s())),t(zs.subscribe((r,i)=>{r.snapshots!==i.snapshots&&this.#N()})),t(Jue({ids:()=>this.store.getState().layout.byId.keys(),visible:()=>this.#c}));const n=()=>{this.#b=q_(),this.#k.clear(),this.#e?.setOptions({theme:this.#j()}),this.#a.clear(),this.#s()},s=matchMedia("(prefers-color-scheme: dark)");s.addEventListener("change",n),t(()=>s.removeEventListener("change",n));const o=new MutationObserver(n);o.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),t(()=>o.disconnect())}#C(t){const n=this.#l.get(t);return n!==void 0&&this.#d.has(n)}#O(){return vs*this.#r.zoom*(devicePixelRatio||1)>Z1}#N(){const{snapshots:t}=zs.getState(),n=new Set([...this.#l.keys(),...Object.keys(t)]);let s=!1;for(const o of n){const r=t[o],i=r?J1(o,r):void 0,l=this.#l.get(o);i===l||i&&this.#u.has(i)||(i&&l&&this.#c.has(o)?(this.#u.set(i,o),this.#z(i).finally(()=>{this.#$(o,i)&&this.#s()})):s=this.#$(o,i)||s)}s&&this.#s()}#$(t,n){if(this.#i)return!1;const s=zs.getState().snapshots[t];if(n&&(!s||J1(t,s)!==n))return this.#_(n),!1;const o=this.#l.get(t);return n?(this.#l.set(t,n),this.#u.set(n,t)):this.#l.delete(t),o&&o!==n&&this.#_(o),!0}#_(t){this.#u.delete(t),this.#d.delete(t),this.#e?.removeTexture(t)}#q(t){for(const n of t)this.#d.delete(n),this.#u.has(n)&&this.#L(n)}#L(t){!this.#y.has(t)&&!this.#g.includes(t)&&this.#g.push(t),this.#D()}#D(){for(;this.#y.size<vxe&&this.#g.length;){const t=this.#g.shift();this.#y.add(t),this.#z(t).finally(()=>{this.#y.delete(t),this.#D()})}}async#z(t){const n=this.#u.get(t),s=n?zs.getState().snapshots[n]:void 0;if(!n||!s||J1(n,s)!==t)return;const o=this.#O(),{layout:r}=this.store.getState(),i=[];try{const l={premultiplyAlpha:"premultiply"};if(i.push(await createImageBitmap(s.blob,{...l,resizeWidth:Z1,resizeHeight:Math.round(Z1*r.slideH/vs),resizeQuality:"medium"})),o&&i.push(await createImageBitmap(s.blob,l)),!this.#e||this.#u.get(t)!==n)return;this.#e.setTexture(t,i)&&this.#d.set(t,o?2:1)}catch{}finally{for(const l of i)l.close()}}attachLive(t,n){this.#h.set(t,n),this.#P(t,n);let s=!0;return(async()=>(await G_(),await G_(),await kxe(n,Sxe),!(!s||this.#h.get(t)!==n)&&(this.#v.add(t),this.#s())))(),()=>{s=!1,this.#h.get(t)===n&&(this.#h.delete(t),this.#v.delete(t),this.#s())}}#P(t,n){const s=this.store.getState().layout.byId.get(t);if(!s)return;const{x:o,y:r,zoom:i}=this.#r;n.style.transform=`matrix(${i}, 0, 0, ${i}, ${(s.x-o)*i}, ${(s.y-r)*i})`,n.style.visibility="hidden"}#G(t){const n=new Map(t.map(s=>[s.id,s]));for(const[s,o]of this.#h){const r=n.get(s);r?(o.style.transform=r.transform,o.style.visibility="visible"):o.style.visibility="hidden"}}hitAt(t,n){if(!this.#e||!this.#t)return null;const s=this.#t.getBoundingClientRect(),o=this.#e.screenToWorld({x:t-s.left,y:n-s.top});return I_(this.store.getState().layout,o.x,o.y)}#W(t,n){const s=(o,r,i=!1)=>{t.addEventListener(o,r,i),this.#o.push(()=>t.removeEventListener(o,r,i))};s("pointerdown",o=>this.#Y(o,n),!0),s("wheel",o=>{o.target===n||o.target instanceof Element&&o.target.closest("textarea")||(o.preventDefault(),n.dispatchEvent(new WheelEvent("wheel",o)))},!1),s("contextmenu",o=>{o.target!==n&&o.stopPropagation()},!0)}#I(t,n){return t??I_(this.store.getState().layout,n.x,n.y)?.tile.id??null}#Y(t,n){const s=this.#e;if(t.button!==0||!s||t.target!==n)return;const o=this.hitAt(t.clientX,t.clientY);if(!o){!t.shiftKey&&!t.metaKey&&!t.ctrlKey&&this.#K(t,s);return}const r=o.tile.id,i=se.getState().slideSelection.includes(r),l=PB(r,t);(!l||o.caption)&&t.stopPropagation();const u=n.getBoundingClientRect(),d={id:r,world:s.screenToWorld({x:t.clientX-u.left,y:t.clientY-u.top}),moved:!1};this.#p=d;const f=h=>{window.removeEventListener("pointerup",f,!0),window.removeEventListener("pointercancel",f,!0),this.#p===d&&(this.#p=null),h.type==="pointerup"&&l&&!d.moved&&i&&se.getState().slideSelection.length>1&&se.getState().selectSlides([r])};window.addEventListener("pointerup",f,!0),window.addEventListener("pointercancel",f,!0)}#K(t,n){n.setTool("pan");const s=t.clientX,o=t.clientY;let r=!1;const i=u=>{Math.hypot(u.clientX-s,u.clientY-o)>=3&&(r=!0)},l=u=>{if(window.removeEventListener("pointermove",i),window.removeEventListener("pointerup",l),window.removeEventListener("pointercancel",l),this.#e?.setTool("select"),r||u.type!=="pointerup")return;const d=se.getState();d.selectSections([]),d.selectSlides(d.current?[d.current]:[])};window.addEventListener("pointermove",i),window.addEventListener("pointerup",l),window.addEventListener("pointercancel",l)}#X(t){if(t.kind==="marquee"&&(this.#M=t.phase==="start"),t.kind!=="move")return;if(t.phase==="start"){this.#p&&(this.#p.moved=!0);return}const n=this.#n;if(this.#n=null,se.getState().setDropGap(null),If([]),this.store.setState({drag:null}),n)for(const s of n.ids)this.#a.delete(s);this.#s()}#Z({ids:t,dx:n,dy:s}){const{layout:o}=this.store.getState();if(!this.#n){const d=fn(ae.getState()),f=this.#p,h=o.byId.get(t[0]??"");this.#n={ids:d.filter(g=>t.includes(g)),origin:f?f.world:{x:h?.x??0,y:h?.y??0}},If(this.#n.ids)}const r=this.#n.origin.x+n,i=this.#n.origin.y+s,l=Rbe(o,r,i);se.getState().setDropGap(l?null:jbe(o,r,i));const u=this.store.getState().drag;(!u||u.section!==l)&&this.store.setState({drag:{ids:this.#n.ids,section:l}})}#Q(){const t=this.#n;if(!t)return;const n=this.store.getState().drag?.section??null,s=se.getState().dropGap;n?P6(t.ids,n,0):s!==null&&DE(t.ids,s)}#J(t){const n=se.getState(),s=fn(ae.getState()).filter(o=>t.includes(o));if(n.selectSections([]),!s.length){n.selectSlides(n.current?[n.current]:[]);return}(!n.current||!s.includes(n.current))&&n.showSlide(s[0],{keepSelection:!0}),se.getState().selectSlides(s)}#ee(){let t=0;for(const o of this.#c)(this.#C(o)||this.#f.has(o))&&t++;const{layout:n,live:s}=this.store.getState();return{tiles:n.tiles.length,visible:this.#c.size,visibleShown:t,live:s.length,holes:this.#f.size,textures:this.#d.size,large:[...this.#d.values()].filter(o=>o===2).length,camera:this.#r,moving:this.#m,engine:this.#e?.stats()??null}}}const Cxe=.25,Txe=.5;function Mxe({onFail:e}){const t=T.useRef(null),n=T.useRef(null),[s,o]=T.useState(null),r=T.useRef(e);return r.current=e,T.useEffect(()=>{const i=new Exe;return o(i),i.start(t.current,n.current).catch(l=>{i.destroy(),r.current(l)}),()=>i.destroy()},[]),p.jsx(xb,{menu:s?p.jsx(Rxe,{board:s}):p.jsx(p.Fragment,{}),className:"relative flex min-h-0 flex-1 bg-stage outline-none",children:p.jsxs("div",{ref:t,role:"listbox","aria-label":"Canvas","aria-multiselectable":!0,"data-open-artifact-canvas-engine":!0,className:"relative min-h-0 flex-1 touch-none overflow-hidden",children:[s?p.jsx(jxe,{board:s}):null,p.jsx("canvas",{ref:n,className:"absolute inset-0 size-full"}),s?p.jsx(Oxe,{board:s}):null,s?p.jsx(Lxe,{board:s}):null]})})}function Rxe({board:e}){const t=or(e.store,n=>n.menu);return t?p.jsx(vb,{ids:se.getState().slideSelection.includes(t)?qo():[t]}):null}function jxe({board:e}){const t=or(e.store,n=>n.live);return p.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 overflow-hidden",children:t.map(n=>p.jsx(Axe,{board:e,id:n},n))})}const Axe=T.memo(function({board:t,id:n}){const s=T.useRef(null),o=ae(u=>u.slides[n]?.slide),r=or(t.store,u=>u.layout.slideH),i=or(t.store,u=>u.layout.rows[u.layout.byId.get(n)?.row??-1]?.key??null),l=yi(u=>i!==null&&(u.drag?.keys.includes(i)??!1));return T.useLayoutEffect(()=>t.attachLive(n,s.current),[t,n]),p.jsx("div",{ref:s,className:"absolute left-0 top-0 origin-top-left overflow-hidden rounded-md",style:{width:vs,height:r,visibility:"hidden",opacity:(o?.hidden?.5:1)*(l?.4:1)},children:o?p.jsx(Xl,{slide:o}):null})});function Oxe({board:e}){const t=T.useRef(null),n=or(e.store,y=>y.layout),s=or(e.store,y=>y.view),o=or(e.store,y=>y.zoom),r=or(e.store,y=>y.drag),i=se(y=>y.dropGap),l=yi(y=>y.drag),u=ae(y=>!y.readOnly)&&hn();T.useLayoutEffect(()=>e.attachWorld(t.current),[e]);const d=s?Obe(s,Txe):null,f=d?n.rows.filter(y=>y.top<d.y+d.h&&y.top+n.tileH>d.y):[],h=d&&o>=Cxe?zk(n,d):[],g=Math.min(4,Math.max(1,.6/o));return p.jsx("div",{className:"pointer-events-none absolute inset-0 overflow-hidden",children:p.jsxs("div",{ref:t,"data-section-rows":!0,className:"absolute left-0 top-0 origin-top-left",style:{width:n.width,height:n.height},children:[n.rows.map(y=>p.jsx("div",{"data-section-row":y.row,"data-section-key":y.key??"","aria-hidden":!0,className:"absolute left-0",style:{top:y.top,width:1,height:n.tileH}},y.key??"-")),l&&l.gap!==null?p.jsx("div",{"aria-hidden":!0,className:"absolute left-0 h-1 rounded bg-accent",style:{top:l.gap*(n.tileH+ir)-ir/2,width:n.width}}):null,f.map(y=>p.jsx("div",{className:Ie("pointer-events-auto absolute",y.key&&l?.keys.includes(y.key)&&"opacity-40"),style:{left:0,top:y.top,width:sr-ho},children:p.jsx("div",{className:"origin-top-left",style:{transform:`scale(${g})`,width:(sr-ho)/g},children:p.jsx(qC,{section:y.section,n:y.row,ids:y.ids,previousGap:y.row>0?y.row-1:null,nextGap:y.row<n.rows.length-1?y.row+2:null})})},y.key??"-")),n.rows.map(y=>y.empty&&y.key?p.jsx("div",{"data-empty-section":y.key,className:Ie("absolute flex items-center justify-center rounded-lg border-2 border-dashed border-line text-lg text-fg-subtle",r?.section===y.key&&"border-accent bg-accent-soft text-accent"),style:{left:y.empty.x,top:y.empty.y,width:y.empty.w,height:y.empty.h},children:"An empty section. Drop slides here."},y.key):null),r&&!r.section&&i!==null?Abe(n,i).map((y,b)=>p.jsx("span",{"aria-hidden":!0,className:"absolute rounded bg-accent",style:{left:y.x,top:y.y,width:y.w,height:y.h}},b)):null,h.length?p.jsx(Nxe,{tiles:h,slideH:n.slideH,dragging:r?.ids??null}):null,u&&!r?p.jsx(_xe,{board:e}):null]})})}function Nxe({tiles:e,slideH:t,dragging:n}){const s=Yy(),o=Hh();return e.map(r=>p.jsx($xe,{tile:r,slideH:t,comments:s.get(r.id)??0,peers:o.get(r.id),dragging:n?.includes(r.id)??!1},r.id))}const $xe=T.memo(function({tile:t,slideH:n,comments:s,peers:o,dragging:r}){const i=ae(h=>h.slides[t.id]),l=se(h=>h.current===t.id),u=se(h=>h.slideSelection.includes(t.id));if(!i)return null;const d=i.held??(i.conflict?"Changed elsewhere at the same time":null),f=Gl(i.slide);return p.jsxs("div",{"data-slide-index":t.index,"data-slide-id":t.id,role:"option","aria-selected":u||l,"aria-label":`Slide ${t.index+1}${f?`: ${f}`:""}`,className:Ie("absolute",r&&"opacity-40"),style:{left:t.x,top:t.y,width:t.w,height:n+Yu},children:[p.jsxs("div",{className:"absolute right-1.5 flex items-center gap-1",style:{top:n-6,transform:"translateY(-100%)"},children:[p.jsx(NC,{peers:o}),s?p.jsxs("span",{className:"flex items-center gap-0.5 rounded-full bg-surface px-1.5 text-[10px] text-fg shadow-popup",children:[p.jsx(Rr,{className:"size-2.5"}),s]}):null]}),p.jsxs("div",{className:"absolute inset-x-0 flex items-center gap-1.5 pt-1.5 text-[11px] text-fg-muted",style:{top:n},children:[p.jsx("span",{className:Ie("tabular-nums",(u||l)&&"font-semibold text-fg"),children:t.index+1}),p.jsx("span",{className:"min-w-0 flex-1 truncate",children:f}),i.slide.hidden?p.jsx(Mh,{className:"size-3 shrink-0","aria-label":"Skipped"}):null,d?p.jsx(Sa,{className:"size-3 shrink-0 text-warning","aria-label":d}):null]})]})});function _xe({board:e}){const t=or(e.store,r=>r.hover),n=or(e.store,r=>r.layout),s=T.useRef(null);t&&n.byId.has(t)&&(s.current=t);const o=s.current?n.byId.get(s.current):void 0;return o?p.jsx("div",{className:Ie("group/gap pointer-events-none absolute flex items-center justify-center [&_button]:pointer-events-auto",t===o.id&&"[&_button]:opacity-100"),style:{left:o.x+o.w,top:o.y,width:ho,height:o.h},children:p.jsx(GC,{gap:o.index+1,after:o.id})}):null}function Lxe({board:e}){const t=T.useRef(null);return T.useLayoutEffect(()=>e.attachZoomReadout(t.current),[e]),p.jsxs(Lr,{"data-canvas-controls":!0,className:"absolute bottom-3 right-3 h-9 px-1 py-px",onPointerDown:n=>n.stopPropagation(),children:[p.jsx(Rn,{label:"Zoom out",children:p.jsx(Pt,{square:!0,"aria-label":"Zoom out",onClick:()=>e.zoomBy(1/1.25),children:p.jsx($i,{className:"size-4",strokeWidth:1.5})})}),p.jsx("span",{ref:t,className:"min-w-11 text-center text-[13px] tabular-nums text-chrome-secondary"}),p.jsx(Rn,{label:"Zoom in",children:p.jsx(Pt,{square:!0,"aria-label":"Zoom in",onClick:()=>e.zoomBy(1.25),children:p.jsx(ds,{className:"size-4",strokeWidth:1.5})})}),p.jsx(Mr,{}),p.jsxs(Pt,{className:"pl-1.5 pr-2",onClick:()=>e.fit(),children:[p.jsx(I2,{className:"size-4",strokeWidth:1.5}),"Fit all slides"]})]})}const Dxe=()=>vs*vt/ot+Yu,eS=48,zxe=.05,Pxe=2;let W_=null;const s9=e=>Math.min(Pxe,Math.max(zxe,e));function Ixe(e,t,n,s){const o=s9(Math.min((n-eS*2)/e,(s-eS*2)/t,1));return{scale:o,x:(n-e*o)/2,y:Math.max(eS,(s-t*o)/2)}}function Bxe(e){se.getState().editOnCanvas(e)}function Hxe(){return se(t=>t.canvasEdit)?p.jsx(qxe,{}):p.jsx(Fxe,{})}let tS=!1;function Fxe(){const e=ld().length===0,[,t]=T.useState(tS);return hxe||tS||e?p.jsx(Uxe,{}):p.jsx(Mxe,{onFail:n=>{console.warn("Canvas engine unavailable; drawing the canvas with the DOM.",n),tS=!0,t(!0)}})}function Uxe(){const{order:e,groups:t}=r6(),n=Yy(),s=Hh(),o=se(_=>_.dropGap),r=ae(_=>!_.readOnly)&&hn(),i=T.useRef(null),l=Vh(i),{drag:u,onPointerDown:d}=OC(i,"grid"),f=yi(_=>_.drag),h=new Set(u?.ids??[]);ae(_=>_.index.size);const g=Dxe(),y=Math.max(1,...t.map(_=>_.ids.length)),b=sr+y*vs+(y-1)*ho,v=Math.max(1,t.length)*(g+ir)-ir,[w,S]=T.useState(W_),C=T.useRef(w);C.current=w;const k=T.useCallback(_=>{C.current=_,W_=_,S(_),aB()},[]),M=T.useCallback(()=>{l&&k(Ixe(b,v,l.w,l.h))},[l,b,v,k]);T.useLayoutEffect(()=>{!C.current&&l&&M()},[l,M]);const j=T.useCallback((_,D,P)=>{const L=C.current;if(!L)return;const F=s9(L.scale*_),U=F/L.scale;k({scale:F,x:D-(D-L.x)*U,y:P-(P-L.y)*U})},[k]);T.useEffect(()=>{const _=i.current;if(!_)return;const D=P=>{P.preventDefault();const L=C.current;if(!L)return;const F=_.getBoundingClientRect();if(P.ctrlKey||P.metaKey)j(Math.exp(-P.deltaY*.01),P.clientX-F.left,P.clientY-F.top);else{const U=P.shiftKey&&P.deltaX===0?P.deltaY:P.deltaX,I=P.shiftKey&&P.deltaX===0?0:P.deltaY;k({...L,x:L.x-U,y:L.y-I})}};return _.addEventListener("wheel",D,{passive:!1}),()=>_.removeEventListener("wheel",D)},[j,k]);const O=()=>({x:(l?.w??0)/2,y:(l?.h??0)/2}),$=_=>{if(_.button!==0&&_.button!==1||_.target.closest("[data-slide-index], [data-section-label], [data-empty-section], button, textarea, [data-canvas-controls]"))return;const P=C.current;if(!P)return;_.preventDefault();const L=_.clientX,F=_.clientY;let U=!1;const I=q=>{!U&&Math.hypot(q.clientX-L,q.clientY-F)<3||(U=!0,k({...P,x:P.x+q.clientX-L,y:P.y+q.clientY-F}))},H=()=>{if(window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",H),!U){const q=se.getState();q.selectSections([]),q.selectSlides(q.current?[q.current]:[])}};window.addEventListener("pointermove",I),window.addEventListener("pointerup",H)};let A=0;const N=t.map(_=>{const D=A;return A+=_.ids.length,D});return p.jsxs("div",{ref:i,role:"listbox","aria-label":"Canvas","aria-multiselectable":!0,"data-open-artifact-thumbs":!0,className:Ie("relative min-h-0 flex-1 touch-none overflow-hidden bg-stage",!u&&"cursor-grab active:cursor-grabbing"),onPointerDown:$,children:[e.length===0?p.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-3 text-sm text-chrome-muted",children:[p.jsx("p",{children:"No slides yet."}),r?p.jsx(Ot,{variant:"primary",icon:p.jsx(ds,{className:"size-4"}),onClick:()=>_a("blank",null),children:"Add slide"}):null]}):w?p.jsx("div",{"data-section-rows":!0,className:"absolute left-0 top-0 origin-top-left",style:{width:b,height:v,transform:`translate(${w.x}px, ${w.y}px) scale(${w.scale})`},children:t.map((_,D)=>{const P=D*(g+ir),L=N[D];return p.jsxs("section",{"aria-label":_.section?.description||`Section ${D+1}`,className:Ie(_.section&&f?.keys.includes(_.section.key)&&"opacity-40"),children:[p.jsx("div",{"data-section-row":D,"data-section-key":_.section?.key??"","aria-hidden":!0,className:"pointer-events-none absolute left-0",style:{top:P,width:1,height:g}}),f?.gap===D?p.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute left-0 h-1 rounded bg-accent",style:{top:P-ir/2,width:b}}):null,p.jsx("div",{className:"absolute",style:{left:0,top:P,width:sr-ho},children:p.jsx("div",{className:"origin-top-left",style:{transform:`scale(${Math.min(4,Math.max(1,.6/w.scale))})`,width:(sr-ho)/Math.min(4,Math.max(1,.6/w.scale))},children:p.jsx(qC,{section:_.section,n:D,ids:_.ids,previousGap:D>0?D-1:null,nextGap:D<t.length-1?D+2:null})})}),_.ids.length===0?p.jsx("div",{"data-empty-section":_.section?.key,className:Ie("absolute flex items-center justify-center rounded-lg border-2 border-dashed border-line text-lg text-fg-subtle",u?.section===_.section?.key&&"border-accent bg-accent-soft text-accent"),style:{left:sr,top:P,width:vs,height:g-Yu},children:"An empty section. Drop slides here."}):_.ids.map((F,U)=>{const I=L+U;return p.jsxs("div",{className:"group/gap absolute",style:{left:sr+U*(vs+ho),top:P,width:vs},children:[p.jsx(JH,{id:F,index:I,width:vs,comments:n.get(F)??0,peers:s.get(F),dragging:h.has(F),dropBefore:u!==null&&o===I,dropAfter:u!==null&&U===_.ids.length-1&&o===I+1,onPointerDown:d,onOpen:Bxe}),r&&!u?p.jsx("div",{className:"absolute top-0 z-10 flex items-center justify-center",style:{left:vs,width:ho,height:g-Yu},children:p.jsx(GC,{gap:I+1,after:F})}):null]},F)})]},_.section?.key??"-")})}):null,p.jsxs(Lr,{"data-canvas-controls":!0,className:"absolute bottom-3 right-3 h-9 px-1 py-px",onPointerDown:_=>_.stopPropagation(),children:[p.jsx(Rn,{label:"Zoom out",children:p.jsx(Pt,{square:!0,"aria-label":"Zoom out",onClick:()=>j(1/1.25,O().x,O().y),children:p.jsx($i,{className:"size-4",strokeWidth:1.5})})}),p.jsx("span",{className:"min-w-11 text-center text-[13px] tabular-nums text-chrome-secondary",children:w?`${Math.round(w.scale*100)}%`:""}),p.jsx(Rn,{label:"Zoom in",children:p.jsx(Pt,{square:!0,"aria-label":"Zoom in",onClick:()=>j(1.25,O().x,O().y),children:p.jsx(ds,{className:"size-4",strokeWidth:1.5})})}),p.jsx(Mr,{}),p.jsxs(Pt,{className:"pl-1.5 pr-2",onClick:M,children:[p.jsx(I2,{className:"size-4",strokeWidth:1.5}),"Fit all slides"]})]})]})}const Y_=2;function Vxe({id:e,n:t}){const n=ae(s=>s.slides[e]?.slide);return n?p.jsxs("button",{type:"button","aria-label":`Edit slide ${t}`,className:"group w-full text-left",onClick:()=>se.getState().showSlide(e),children:[p.jsx("div",{className:"overflow-hidden rounded-[6px] opacity-60 shadow-[0_0_0_1px_var(--chrome-line)] transition group-hover:opacity-100",children:p.jsx(Xl,{slide:n})}),p.jsxs("div",{className:"truncate pt-1 text-[11px] text-chrome-muted",children:[p.jsx("span",{className:"tabular-nums",children:t})," ",Gl(n)]})]}):null}function qxe(){const e=ld(),t=se(i=>i.current),n=t?e.indexOf(t):-1;if(T.useEffect(()=>{n<0&&se.getState().editOnCanvas(null)},[n]),n<0)return null;const s=e.slice(Math.max(0,n-Y_),n),o=e.slice(n+1,n+1+Y_),r=(i,l)=>p.jsx("div",{className:"flex w-40 shrink-0 flex-col justify-center gap-4 overflow-hidden px-3 pb-14 pt-14 max-md:hidden",children:i.map((u,d)=>p.jsx(Vxe,{id:u,n:l+d+1},u))});return p.jsxs("div",{className:"relative flex min-h-0 flex-1 bg-stage",children:[r(s,n-s.length),p.jsxs("div",{className:"relative min-w-0 flex-1",children:[p.jsx(yH,{}),p.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-3 z-10 flex justify-center",children:p.jsxs(Lr,{className:"h-9 px-1 py-px",children:[p.jsx(Rn,{label:"Back to canvas",shortcut:"Esc",children:p.jsxs(Pt,{className:"pl-1.5 pr-2",onClick:()=>se.getState().editOnCanvas(null),children:[p.jsx(iW,{className:"size-4",strokeWidth:1.5}),"Canvas"]})}),p.jsx(Mr,{}),p.jsxs("span",{className:"px-2 text-[13px] tabular-nums text-chrome-secondary",children:["Slide ",n+1," of ",e.length]})]})})]}),r(o,n+1)]})}const K_=220,Xc=24,nS=32;function Gxe(e){const t=se.getState();t.setMode("edit"),t.showSlide(e)}function Wxe(){const{order:e,groups:t}=r6(),n=Yy(),s=Hh(),o=se(M=>M.dropGap),r=se(M=>M.current),i=ae(M=>!M.readOnly)&&hn(),l=$n(M=>M.writing),u=T.useRef(null),d=Vh(u),{drag:f,onPointerDown:h}=OC(u,"grid"),g=yi(M=>M.drag),y=new Set(f?.ids??[]),b=d?Math.max(1,Math.floor((d.w-nS*2+Xc)/(K_+Xc))):4,v=d?Math.floor((d.w-nS*2-Xc*(b-1))/b):K_,[w,S]=T.useState(!1);if(T.useLayoutEffect(()=>{w||!d||!r||(u.current?.querySelector(`[data-slide-id="${CSS.escape(r)}"]`)?.scrollIntoView({block:"center"}),S(!0))},[w,d,r]),e.length===0)return l?p.jsx(cB,{}):p.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 bg-stage text-sm text-chrome-muted",children:[p.jsx("p",{children:"No slides yet."}),i?p.jsx(Ot,{variant:"primary",icon:p.jsx(ds,{className:"size-4"}),onClick:()=>_a("blank",null),children:"Add slide"}):null]});let C=0;const k=t.map(M=>{const j=C;return C+=M.ids.length,j});return p.jsxs("div",{ref:u,role:"listbox","aria-label":"Slides","aria-multiselectable":!0,"data-open-artifact-grid-columns":b,"data-section-rows":!0,"data-section-scroll":!0,"data-open-artifact-thumbs":!0,className:"min-h-0 flex-1 overflow-y-auto bg-stage pb-6 pt-[60px]",style:{paddingInline:nS},onPointerMove:M=>{const j=M.target instanceof Element?M.target.closest("[data-slide-id]"):null,O=j?.dataset.slideId;if(!j||!O)return f1(null);const $=j.getBoundingClientRect();f1({slideId:O,x:(M.clientX-$.left)/Math.max(1,$.width),y:(M.clientY-$.top)/Math.max(1,$.height)})},onPointerLeave:()=>f1(null),onPointerDown:M=>{if(M.target===M.currentTarget){const j=se.getState();j.selectSections([]),j.selectSlides(j.current?[j.current]:[])}},children:[t.map((M,j)=>{const O=k[j],$=j>0?j-1:null,A=j<t.length-1?j+2:null,N=M.section!==null||t.length>1||i,_=!!(M.section&&g?.keys.includes(M.section.key));return p.jsxs("section",{"data-section-row":j,"data-section-key":M.section?.key??"",className:Ie("relative mb-8",_&&"opacity-40"),"aria-label":M.section?.description||`Section ${j+1}`,children:[g?.gap===j?p.jsx(X_,{}):null,N?p.jsx(qC,{section:M.section,n:j,ids:M.ids,previousGap:$,nextGap:A,className:"mb-3 max-w-2xl"}):null,M.ids.length===0?p.jsx("div",{"data-empty-section":M.section?.key,className:Ie("flex h-24 items-center justify-center rounded-md border border-dashed border-line text-xs text-fg-subtle",f?.section===M.section?.key&&"border-accent bg-accent-soft text-accent"),children:"An empty section. Drop slides here."}):p.jsx("div",{className:"grid",style:{gridTemplateColumns:`repeat(${b}, ${v}px)`,columnGap:Xc,rowGap:Xc},children:M.ids.map((D,P)=>{const L=O+P,F=L===e.length-1;return p.jsxs("div",{className:"group/gap relative",children:[p.jsx(JH,{id:D,index:L,comments:n.get(D)??0,peers:s.get(D),dragging:y.has(D),dropBefore:f!==null&&o===L,dropAfter:f!==null&&F&&o===e.length,onPointerDown:h,onOpen:Gxe}),p.jsx($ge,{id:D}),i&&!f?p.jsx("div",{className:"absolute -right-[18px] top-0 z-10 flex w-3 items-center justify-center",style:{height:v*9/16},children:p.jsx(GC,{gap:L+1,after:D})}):null]},D)})})]},M.section?.key??"-")}),p.jsx(hde,{first:e.length,columns:b,tile:v,gap:Xc}),g?.gap===t.length?p.jsx("div",{className:"relative h-0",children:p.jsx(X_,{})}):null,i?p.jsx(Ot,{variant:"ghost",icon:p.jsx(ds,{className:"size-4"}),onClick:()=>_a("blank",e.at(-1)??null),children:"Add slide"}):null]})}function X_(){return p.jsx("div",{className:"pointer-events-none absolute -top-4 left-0 right-0 h-0.5 rounded bg-accent","aria-hidden":!0})}async function Yxe(){try{await Gne()}catch(n){ae.getState().fail(n instanceof Error?n.message:String(n));return}await bue();const e=ae.getState();if(e.status!=="ready")return;se.getState().showSlide(R8()??fn(e)[0]??null),Hae(),tse(),yae();const t=ad()?.room;t&&wae(t,{ids:()=>Ci.getState().peers.map(n=>n.id),subscribe:n=>Ci.subscribe((s,o)=>{s.peers!==o.peers&&n()})}),Tue(),nse(),Iae(),e.readOnly||Tg.getState().set(Vae()),document.title=e.title||"Slides"}let Z_=!1;function Kxe(){const e=ae(s=>!s.readOnly)&&hn(),t=Rt(s=>s.status);return $n(s=>s.writing)?p.jsx(cB,{}):p.jsxs(NP,{icon:p.jsx(dg,{className:"size-6"}),title:"This presentation has no slides yet",children:[p.jsx("p",{children:e?t.available?`Add one, or ask ${t.name} to add some.`:"Add one to get started.":"Slides will show here once they are added."}),e?p.jsx(Ot,{className:"mt-2",variant:"primary",icon:p.jsx(ds,{className:"size-4"}),onClick:()=>_a("blank",null),children:"Add slide"}):null]})}function Xxe(){const e=ae(b=>b.status),t=ae(b=>b.error),n=ae(b=>b.title),s=ae(b=>b.index.faces),o=ld(),r=se(b=>b.mode),i=se(b=>b.canvasEdit),l=se(b=>b.current),u=se(b=>b.showRail),d=se(b=>b.showProperties);T.useEffect(()=>{Z_||(Z_=!0,Yxe());const b=iae(),v=yre();return()=>{b(),v()}},[]),T.useEffect(()=>{n&&(document.title=n)},[n]),T.useEffect(()=>{e==="ready"&&fb(s,wo)},[e,s]);const f=T.useRef(0);if(T.useEffect(()=>{if(e!=="ready")return;const b=l?o.indexOf(l):-1;if(b>=0){f.current=b;return}const v=o[Math.min(f.current,o.length-1)]??null;v!==l&&se.getState().showSlide(v)},[e,o,l]),e==="loading")return p.jsx("div",{className:"flex h-full items-center justify-center bg-canvas",children:p.jsx(Yg,{className:"size-5 animate-spin text-fg-subtle","aria-label":"Loading"})});if(e==="error")return p.jsx("div",{className:"h-full bg-canvas",children:p.jsx(NP,{icon:p.jsx(Sa,{className:"size-6"}),title:"This presentation could not be opened",children:t})});const h=r==="edit"||i,g=o.length===0,y=r==="edit"&&u&&!g;return p.jsx(ipe,{children:p.jsxs("div",{className:"flex h-full bg-stage text-fg",children:[y?p.jsx(kpe,{}):null,p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[p.jsx(ude,{}),p.jsxs("main",{className:"relative flex min-h-0 min-w-0 flex-1",children:[r==="edit"?g?p.jsx(Kxe,{}):p.jsx(yH,{}):r==="grid"?p.jsx(Wxe,{}):p.jsx(Hxe,{}),p.jsx(Dge,{onStage:h&&!g,startCard:!y}),p.jsx(fpe,{}),p.jsx(pde,{}),p.jsx(mde,{})]})]}),h&&d&&!g?p.jsx(ibe,{}):null,p.jsx(e0e,{}),p.jsx(gde,{}),p.jsx(vbe,{})]})})}Bk.createRoot(document.getElementById("root")).render(p.jsx(T.StrictMode,{children:p.jsxs(Gq,{children:[p.jsx(Xxe,{}),p.jsx(VZ,{})]})}));export{dve as C,pve as F,U_ as I,ive as K,rve as M,eve as O,mve as P,cve as T,fve as a,hve as b,ave as c,lve as d,uve as e,tve as f,ove as g,sve as h,nve as i,Qbe as j,cxe as k,uxe as l,nu as p,Qxe as s,Jxe as v,Zxe as w};
|