dev-process-kit 0.0.10 → 0.0.11

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.
Files changed (27) hide show
  1. package/dist/chunks/{shared-Bd9pmv5a.js → shared-B4ewpBuM.js} +1 -1
  2. package/dist/chunks/{shared-Ds5vLeFk.js → shared-B9OVJ7XA.js} +1 -1
  3. package/dist/chunks/{shared-FtbePk3S.js → shared-BHRhwgui.js} +1 -1
  4. package/dist/chunks/{shared-COrrbgIn.js → shared-BSFZSMH5.js} +1 -1
  5. package/dist/chunks/{shared-BQFDKhM1.js → shared-B_MMP97h.js} +1 -1
  6. package/dist/chunks/{shared-CDUEK_Mh.js → shared-BgCDocVX.js} +1 -1
  7. package/dist/chunks/{shared-BdUyaZo-.js → shared-CHaHI5X3.js} +1 -1
  8. package/dist/chunks/{shared-CQXKAPdi.js → shared-CrE-y5oF.js} +1 -1
  9. package/dist/chunks/{shared-C2ytkQtn.js → shared-CxFItadP.js} +1 -1
  10. package/dist/chunks/{shared-DkFF4haI.js → shared-DGI_sFo5.js} +1 -1
  11. package/dist/chunks/{shared-Dmq-C6h3.js → shared-DIJgMVpY.js} +57 -57
  12. package/dist/chunks/{shared-CmNWTIOz.js → shared-DZfXwU7f.js} +1 -1
  13. package/dist/chunks/{shared-qb0tjbw2.js → shared-OGH3pSVq.js} +1 -1
  14. package/dist/chunks/{shared-CNbKTeSv.js → shared-TW6kWbUL.js} +1 -1
  15. package/dist/components.js +1 -1
  16. package/dist/index.js +1 -1
  17. package/dist/templates/delegation-poker.js +1 -1
  18. package/dist/templates/event-storming.js +1 -1
  19. package/dist/templates/example-mapping.js +1 -1
  20. package/dist/templates/grill.js +1 -1
  21. package/dist/templates/plain.js +1 -1
  22. package/dist/templates/prototype.js +1 -1
  23. package/dist/templates/slides.js +1 -1
  24. package/dist/templates/task-board.js +1 -1
  25. package/dist/templates/usm.js +1 -1
  26. package/dist/templates/whiteboard.js +1 -1
  27. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import{ab as Ro,ac as b,ad as i,ae as f,af as c,ag as w,aw as h,an as X,ah as J,ai as V,p as $,v as Uo,av as qo,as as Io,ak as Qo,am as B,P as Ho,e as Mo,a0 as Ko,V as Fo,R as S,a3 as s,a4 as n,A as jo,a5 as y,aT as Z,aU as Yo,aF as P,K as Xo,aC as Jo,a2 as Vo,T as oo,l as Zo,aH as oe}from"./shared-BQFDKhM1.js";const eo=["working","waiting","blocked","done"],D=["todo","doing","blocked","done"],ao=["agent","human"],E=["why","what","goals","nonGoals"],T=J(c(),V(1)),ee=b({id:h,name:T,kind:i(w(ao),"agent")}),ae=b({id:h,title:T,status:i(w(D),"todo"),assignee:i(h),note:i(c()),proposed:i(X(),!1),reason:i(c())}),te=b({id:h,label:i(c()),href:T,kind:i(c()),description:i(c())}),re=b({why:i(c()),what:i(c()),goals:i(f(c()),[]),nonGoals:i(f(c()),[])}),ne=b({id:h,from:i(h),at:i(c()),title:i(c()),body:i(c()),points:i(f(c()),[])}),de=b({id:h,ref:i(T),title:T,description:i(c()),blocking:i(X(),!1),assumption:i(c())}),to=b({title:i(c(),""),status:i(w(eo)),updatedAt:i(c()),context:i(re,{}),members:i(f(ee),[]),todos:i(f(ae),[]),outputs:i(f(te),[]),log:i(f(ne),[]),questions:i(f(de),[])}),A=(e,o)=>{const a=new Set;for(const t of o){if(a.has(t))throw new Error(`duplicate ${e} id: ${t}`);a.add(t)}},u=e=>e===void 0||e.trim()===""?null:e,W=e=>e.filter(o=>o.trim()!==""),ro=e=>{const o=Ro(to,e);A("member",o.members.map(t=>t.id)),A("todo",o.todos.map(t=>t.id)),A("output",o.outputs.map(t=>t.id)),A("log",o.log.map(t=>t.id)),A("question",o.questions.map(t=>t.id));const a=new Set(o.members.map(t=>t.id));for(const t of o.todos)if(t.assignee!==void 0&&!a.has(t.assignee))throw new Error(`todo ${t.id} is assigned to ${t.assignee}, which is not in members`);for(const t of o.log){if(t.from!==void 0&&!a.has(t.from))throw new Error(`log entry ${t.id} is from ${t.from}, which is not in members`);if(u(t.title)===null&&u(t.body)===null)throw new Error(`log entry ${t.id} needs a title or a body`)}for(const t of o.questions)if(!t.blocking&&u(t.assumption)===null)throw new Error(`question ${t.id} does not block, so it needs the assumption the agent works on`);return{title:o.title,status:o.status??null,updatedAt:u(o.updatedAt),context:{why:u(o.context.why),what:u(o.context.what),goals:W(o.context.goals),nonGoals:W(o.context.nonGoals)},members:o.members,todos:o.todos.map(t=>({id:t.id,title:t.title,status:t.status,assignee:t.assignee??null,note:u(t.note),proposed:t.proposed,reason:u(t.reason),added:!1})),outputs:o.outputs.map(t=>({id:t.id,label:u(t.label),href:t.href,kind:u(t.kind),description:u(t.description)})),log:o.log.map(t=>({id:t.id,from:t.from??null,at:u(t.at),title:u(t.title),body:u(t.body),points:W(t.points)})),questions:o.questions.map((t,r)=>({id:t.id,ref:t.ref??`Q${r+1}`,title:t.title,description:u(t.description),blocking:t.blocking,assumption:u(t.assumption)})),answers:{},decisions:{}}},no=()=>({title:"",status:null,updatedAt:null,context:{why:null,what:null,goals:[],nonGoals:[]},members:[],todos:[],outputs:[],log:[],questions:[],answers:{},decisions:{}}),O=(e,o)=>o===null?void 0:e.members.find(a=>a.id===o),k=(e,o)=>e.todos.find(a=>a.id===o),so=(e,o)=>e.log.find(a=>a.id===o),io=e=>E.includes(e),N=(e,o)=>{const a=e.context[o];return typeof a=="string"||a!==null&&a.length>0},C=(e,o)=>e.questions.find(a=>a.id===o),lo=(e,o)=>{const a=e.answers[o.id];return a===void 0?!1:a.kind==="approve"||a.text.trim()!==""},R=(e,o)=>!o.proposed||e.decisions[o.id]==="accept",U=(e,o)=>R(e,o)&&O(e,o.assignee)?.kind==="human",po=(e,o,a)=>{const t={...e};return a===null?delete t[o]:t[o]=a,t},q=(e,o,a)=>({...e,answers:po(e.answers,o,a)}),se=(e,o,a)=>({...e,decisions:po(e.decisions,o,a)}),ie=(e,o,a)=>({...e,todos:e.todos.map(t=>t.id===o?a(t):t)}),m={ANSWER_QUESTION:$("ANSWER_QUESTION","question",Qo("kind",[b({kind:B("approve")}),b({kind:B("answer"),text:c()}),b({kind:B("clear")})])),DECIDE_PROPOSAL:$("DECIDE_PROPOSAL","todo",b({decision:w(["accept","decline","clear"])})),SET_TODO_STATUS:$("SET_TODO_STATUS","todo",b({status:w(D)})),ADD_TODO:$("ADD_TODO","page",b({id:h,title:J(c(),Io(),V(1)),assignee:qo(h)}),{dedupeKey:Uo}),DELETE_TODO:$("DELETE_TODO","todo",b({}))},co={type:"page",id:"task-board"},I=(e,o)=>({type:"ANSWER_QUESTION",target:{type:"question",id:e},payload:o}),uo=(e,o)=>({type:"DECIDE_PROPOSAL",target:{type:"todo",id:e},payload:{decision:o}}),bo=(e,o)=>({type:"SET_TODO_STATUS",target:{type:"todo",id:e},payload:{status:o}}),go=(e,o,a)=>({type:"ADD_TODO",target:co,payload:{id:e,title:o,assignee:a}}),ho=e=>({type:"DELETE_TODO",target:{type:"todo",id:e},payload:{}}),ko=(e,o)=>{const a=Ho(m,o);if(a===null)return null;const t=a.target.id;switch(a.type){case"ANSWER_QUESTION":{const r=C(e,t);if(r===void 0)return null;const d=a.payload;return d.kind==="clear"?q(e,t,null):d.kind==="approve"?r.assumption===null?null:q(e,t,{kind:"approve"}):q(e,t,{kind:"answer",text:d.text})}case"DECIDE_PROPOSAL":{if(k(e,t)?.proposed!==!0)return null;const{decision:r}=a.payload;return se(e,t,r==="clear"?null:r)}case"SET_TODO_STATUS":{const r=k(e,t);if(r===void 0||!U(e,r))return null;const{status:d}=a.payload;return ie(e,t,l=>({...l,status:d}))}case"ADD_TODO":{const{payload:r}=a;return k(e,r.id)!==void 0||r.assignee!==null&&O(e,r.assignee)===void 0?null:{...e,todos:[...e.todos,{id:r.id,title:r.title,status:"todo",assignee:r.assignee,note:null,proposed:!1,reason:null,added:!0}]}}case"DELETE_TODO":return k(e,t)?.added!==!0?null:{...e,todos:e.todos.filter(r=>r.id!==t)};default:return Mo(a)}},Q=Ko({en:{wholeBoard:"Whole board",statusWorking:"Working",statusWaiting:"Waiting on you",statusBlocked:"Blocked",statusDone:"Done",todoTodo:"To do",todoDoing:"In progress",todoBlocked:"Blocked",todoDone:"Done",kindAgent:"Agent",kindHuman:"Human",updatedAt:e=>`Updated ${e}`,context:"What this task is about",contextWhy:"Why",contextWhat:"What",contextGoals:"Goals",contextNonGoals:"Non-goals",noContext:"The agent has not written down why and what yet.",tabs:"Board sections",tabContext:"Context",tabLog:"Work log",tabQuestions:"Questions",openCount:e=>`${e} open`,noQuestions:"The agent has nothing to ask right now.",questions:"Questions from the agent",questionsProgress:(e,o)=>`${e} of ${o} replied`,blockingGroup:"Blocking \u2014 the agent waits for your decision",provisionalGroup:"Going ahead on an assumption \u2014 the agent adjusts if you answer otherwise",blockingTag:"Blocking",assumption:"Assumption",recommendation:"Agent recommends",approveAssumption:"OK, go with this",approveRecommendation:"OK, go with the recommendation",answerOther:"Answer differently",answerOf:e=>`Your answer to ${e}`,answerPlaceholder:"What you expect instead\u2026",blockingPlaceholder:"Your decision\u2026",approvedTag:"Approved",answeredTag:"Answered",todos:"Todo",progress:(e,o)=>`${e} of ${o} done`,noTodosYet:"No todos yet",assignee:"Assignee",unassigned:"Unassigned",memberOption:(e,o)=>`${e} (${o})`,statusOf:e=>`Status of \u201C${e}\u201D`,filterTodos:"Show todos",filterAll:"All",filterHuman:"People",doneGroup:e=>`Done (${e})`,noHumanTodos:"Nobody but the agent has a todo.",addedTag:"Added by you",changedTag:"Changed",removeAdded:"Remove this todo you added",noTodos:"There are no todos yet.",newTodo:"New todo",newTodoPlaceholder:"Add a todo for the agent\u2026",newTodoAssignee:"Assignee of the new todo",addTodo:"Add",proposedMark:"Proposed by the agent",reason:"Why",accept:"Accept",decline:"Decline",decisionOf:e=>`Decision on \u201C${e}\u201D`,acceptedTag:"Accepted",declinedTag:"Declined",undoDecision:"Undo",outputs:"Outputs",noOutputs:"Nothing has been produced yet.",copy:e=>`Copy ${e}`,copied:"Copied",log:"Conversation with the agent",logLede:"Newest first",noLog:"Nothing has been exchanged yet.",fromAgent:"Agent",latestTag:"Latest",commentOn:e=>`Comment on ${e}`,todoGroup:"Todo",logGroup:"Log",contextGroup:"Context",proposalGroup:"Proposal",questionGroup:"Question",approved:"Approve the assumption",answered:"Answer",answerCleared:"Clear the reply",accepted:"Accept the proposal",declined:"Decline the proposal",decisionCleared:"Clear the decision",statusChanged:"Change the status",todoAdded:"Add a todo",todoRemoved:"Remove the added todo",quoted:e=>`\u2192 \u201C${e}\u201D`,change:(e,o)=>`${e} \u2192 ${o}`},ja:{wholeBoard:"\u30DC\u30FC\u30C9\u5168\u4F53",statusWorking:"\u4F5C\u696D\u4E2D",statusWaiting:"\u3042\u306A\u305F\u306E\u8FD4\u7B54\u5F85\u3061",statusBlocked:"\u30D6\u30ED\u30C3\u30AF\u4E2D",statusDone:"\u5B8C\u4E86",todoTodo:"\u672A\u7740\u624B",todoDoing:"\u9032\u884C\u4E2D",todoBlocked:"\u30D6\u30ED\u30C3\u30AF",todoDone:"\u5B8C\u4E86",kindAgent:"Agent",kindHuman:"\u4EBA\u9593",updatedAt:e=>`\u66F4\u65B0 ${e}`,context:"\u3053\u306E\u30BF\u30B9\u30AF\u306E\u524D\u63D0",contextWhy:"Why \u2014 \u306A\u305C\u3084\u308B\u304B",contextWhat:"What \u2014 \u4F55\u3092\u3084\u308B\u304B",contextGoals:"\u30B4\u30FC\u30EB",contextNonGoals:"\u3084\u3089\u306A\u3044\u3053\u3068",noContext:"Agent \u306F\u307E\u3060 Why / What \u3092\u66F8\u3044\u3066\u3044\u307E\u305B\u3093\u3002",tabs:"\u30DC\u30FC\u30C9\u306E\u533A\u5206",tabContext:"Context",tabLog:"\u4F5C\u696D\u30ED\u30B0",tabQuestions:"\u8CEA\u554F",openCount:e=>`\u672A\u56DE\u7B54 ${e} \u4EF6`,noQuestions:"\u4ECA Agent \u304B\u3089\u805E\u304D\u305F\u3044\u3053\u3068\u306F\u3042\u308A\u307E\u305B\u3093\u3002",questions:"Agent \u304B\u3089\u306E\u8CEA\u554F",questionsProgress:(e,o)=>`\u8FD4\u7B54\u6E08\u307F ${e} / ${o}`,blockingGroup:"\u30D6\u30ED\u30C3\u30AB\u30FC \u2014 \u6C7A\u3081\u3066\u3082\u3089\u3046\u307E\u3067\u5148\u306B\u9032\u3081\u306A\u3044",provisionalGroup:"\u4EEE\u306E\u524D\u63D0\u3067\u9032\u884C\u4E2D \u2014 \u9055\u3048\u3070\u65B9\u91DD\u3092\u76F4\u3059",blockingTag:"\u30D6\u30ED\u30C3\u30AB\u30FC",assumption:"\u4EEE\u56DE\u7B54",recommendation:"Agent \u306E\u63A8\u5968",approveAssumption:"\u3053\u306E\u524D\u63D0\u3067 OK",approveRecommendation:"\u63A8\u5968\u3069\u304A\u308A\u3067 OK",answerOther:"\u5225\u306E\u56DE\u7B54\u3092\u3059\u308B",answerOf:e=>`${e} \u3078\u306E\u56DE\u7B54`,answerPlaceholder:"\u671F\u5F85\u3059\u308B\u56DE\u7B54\u3092\u5165\u529B\u2026",blockingPlaceholder:"\u3069\u3046\u3059\u308B\u304B\u3092\u5165\u529B\u2026",approvedTag:"\u627F\u8A8D\u6E08\u307F",answeredTag:"\u56DE\u7B54\u6E08\u307F",todos:"Todo",progress:(e,o)=>`${o} \u4EF6\u4E2D ${e} \u4EF6\u5B8C\u4E86`,noTodosYet:"Todo \u306F\u307E\u3060\u3042\u308A\u307E\u305B\u3093",assignee:"\u62C5\u5F53",unassigned:"\u672A\u5272\u308A\u5F53\u3066",memberOption:(e,o)=>`${e}\uFF08${o}\uFF09`,statusOf:e=>`\u300C${e}\u300D\u306E\u72B6\u614B`,filterTodos:"\u8868\u793A\u3059\u308B Todo",filterAll:"\u3059\u3079\u3066",filterHuman:"\u4EBA\u9593\u306E\u62C5\u5F53",doneGroup:e=>`\u5B8C\u4E86 ${e} \u4EF6`,noHumanTodos:"\u4EBA\u9593\u304C\u62C5\u5F53\u3059\u308B Todo \u306F\u3042\u308A\u307E\u305B\u3093\u3002",addedTag:"\u3042\u306A\u305F\u304C\u8FFD\u52A0",changedTag:"\u5909\u66F4\u3042\u308A",removeAdded:"\u8FFD\u52A0\u3057\u305F Todo \u3092\u53D6\u308A\u6D88\u3059",noTodos:"Todo \u306F\u307E\u3060\u3042\u308A\u307E\u305B\u3093\u3002",newTodo:"\u65B0\u3057\u3044 Todo",newTodoPlaceholder:"Agent \u306B\u983C\u3080 Todo \u3092\u8FFD\u52A0\u2026",newTodoAssignee:"\u65B0\u3057\u3044 Todo \u306E\u62C5\u5F53",addTodo:"\u8FFD\u52A0",proposedMark:"Agent \u304B\u3089\u306E\u63D0\u6848",reason:"\u306A\u305C",accept:"\u627F\u8A8D",decline:"\u898B\u9001\u308A",decisionOf:e=>`\u300C${e}\u300D\u306E\u5224\u65AD`,acceptedTag:"\u627F\u8A8D\u6E08\u307F",declinedTag:"\u898B\u9001\u308A",undoDecision:"\u53D6\u308A\u6D88\u3059",outputs:"\u6210\u679C\u7269",noOutputs:"\u307E\u3060\u6210\u679C\u7269\u306F\u3042\u308A\u307E\u305B\u3093\u3002",copy:e=>`${e} \u3092\u30B3\u30D4\u30FC`,copied:"\u30B3\u30D4\u30FC\u3057\u307E\u3057\u305F",log:"Agent \u3068\u306E\u3084\u308A\u3068\u308A",logLede:"\u65B0\u3057\u3044\u9806",noLog:"\u307E\u3060\u3084\u308A\u3068\u308A\u306F\u3042\u308A\u307E\u305B\u3093\u3002",fromAgent:"Agent",latestTag:"\u6700\u65B0",commentOn:e=>`${e} \u306B\u30B3\u30E1\u30F3\u30C8`,todoGroup:"Todo",logGroup:"\u4F5C\u696D\u30ED\u30B0",contextGroup:"Context",proposalGroup:"\u63D0\u6848",questionGroup:"\u8CEA\u554F",approved:"\u524D\u63D0\u3092\u627F\u8A8D",answered:"\u56DE\u7B54",answerCleared:"\u8FD4\u7B54\u3092\u30AF\u30EA\u30A2",accepted:"\u63D0\u6848\u3092\u627F\u8A8D",declined:"\u63D0\u6848\u3092\u898B\u9001\u308A",decisionCleared:"\u63D0\u6848\u306E\u5224\u65AD\u3092\u30AF\u30EA\u30A2",statusChanged:"\u72B6\u614B\u3092\u5909\u66F4",todoAdded:"Todo \u3092\u8FFD\u52A0",todoRemoved:"\u8FFD\u52A0\u3057\u305F Todo \u3092\u53D6\u308A\u6D88\u3057",quoted:e=>`\u2192 \u300C${e}\u300D`,change:(e,o)=>`${e} \u2192 ${o}`}}),xo=(e,o)=>{switch(o){case"working":return e.statusWorking;case"waiting":return e.statusWaiting;case"blocked":return e.statusBlocked;case"done":return e.statusDone}},z=(e,o)=>{switch(o){case"todo":return e.todoTodo;case"doing":return e.todoDoing;case"blocked":return e.todoBlocked;case"done":return e.todoDone}},le=(e,o)=>o==="agent"?e.kindAgent:e.kindHuman,L=(e,o)=>{switch(o){case"why":return e.contextWhy;case"what":return e.contextWhat;case"goals":return e.contextGoals;case"nonGoals":return e.contextNonGoals}},fo=48,H=e=>{const o=e.title??e.body??e.id;return o.length<=fo?o:`${o.slice(0,fo-1)}\u2026`},pe=(e,o,a)=>a===null?e.unassigned:O(o,a)?.name??a,mo=e=>e.title===""?"Task Context Board":e.title,vo=(e,o,a)=>{switch(a.type){case"todo":{const t=k(o,a.id);return`${t?.proposed===!0?e.proposalGroup:e.todoGroup} \xB7 ${t?.title??a.id}`}case"log":{const t=so(o,a.id);return`${e.logGroup} \xB7 ${t===void 0?a.id:H(t)}`}case"context":return`${e.contextGroup} \xB7 ${io(a.id)?L(e,a.id):a.id}`;case"question":{const t=C(o,a.id);return t===void 0?a.id:`${t.ref} \xB7 ${t.title}`}case"page":return e.wholeBoard;default:return a.id}},ce=(e,o)=>{switch(o){case"accept":return{title:e.accepted,tone:"update"};case"decline":return{title:e.declined,tone:"update"};case"clear":return{title:e.decisionCleared,tone:"delete"}}},ue=(e,o,a)=>{switch(a.type){case"ANSWER_QUESTION":{const t=S(m.ANSWER_QUESTION,a);if(t.kind==="clear")return{title:e.answerCleared,tone:"delete"};if(t.kind==="approve"){const r=C(o,a.target.id)?.assumption??null;return{title:e.approved,tone:"update",...r===null?{}:{body:e.quoted(r)}}}return{title:e.answered,tone:"update",body:e.quoted(t.text.slice(0,120))}}case"DECIDE_PROPOSAL":return ce(e,S(m.DECIDE_PROPOSAL,a).decision);case"SET_TODO_STATUS":{const{status:t}=S(m.SET_TODO_STATUS,a),r=k(o,a.target.id)?.status,d=z(e,t);return{title:e.statusChanged,tone:"update",body:r===void 0?d:e.change(z(e,r),d)}}case"ADD_TODO":{const t=S(m.ADD_TODO,a);return{title:e.todoAdded,tone:"create",targetLabel:`${e.todoGroup} \xB7 ${t.title}`,...t.assignee===null?{}:{body:`${e.assignee}: ${pe(e,o,t.assignee)}`}}}case"DELETE_TODO":return{title:e.todoRemoved,tone:"delete"};default:return{title:a.type,tone:"meta"}}},wo=(e,o,a,t)=>{let r;try{r=ue(e,t??a,o)}catch{r={title:o.type,tone:"meta"}}return{title:r.title,targetLabel:r.targetLabel??vo(e,a,o.target),tone:r.tone,...r.body===void 0?{}:{summary:r.body}}},$o=e=>`${e.type} ${Fo(e.target)} ${JSON.stringify(e.payload)}`,yo=(e,o)=>[...o.questions.map(a=>({value:`question:${a.id}`,label:`${a.ref} \xB7 ${a.title}`,group:e.questionGroup})),...o.todos.map(a=>({value:`todo:${a.id}`,label:a.title,group:a.proposed?e.proposalGroup:e.todoGroup})),...o.log.map(a=>({value:`log:${a.id}`,label:H(a),group:e.logGroup})),...E.filter(a=>N(o,a)).map(a=>({value:`context:${a}`,label:L(e,a),group:e.contextGroup}))],To=(e,o)=>o,Ao=(e,o,a)=>({parts:E.filter(t=>N(o,t)).map(t=>{const r=o.context[t];return{id:t,title:L(e,t),text:typeof r=="string"?r:null,items:typeof r=="string"||r===null?[]:r,comments:a(`context:${t}`)}})}),be=(e,o,a)=>{const t=e.answers[o.id];return{id:o.id,ref:o.ref,title:o.title,description:o.description,blocking:o.blocking,assumption:o.assumption,reply:t?.kind??"none",resolved:lo(e,o),draft:t?.kind==="answer"?t.text:"",comments:a(`question:${o.id}`)}},Oo=(e,o)=>{const a=e.questions.map(r=>be(e,r,o)),t=a.filter(r=>r.resolved).length;return{blocking:a.filter(r=>r.blocking),provisional:a.filter(r=>!r.blocking),resolved:t,total:a.length,open:a.length-t,blockingOpen:a.filter(r=>r.blocking&&!r.resolved).length}},ge=(e,o,a,t,r)=>{const d=k(a,t.id),l=O(o,t.assignee);return{id:t.id,title:t.title,note:t.note,reason:t.reason,status:t.status,statusLabel:z(e,t.status),assignee:t.assignee,assigneeName:l?.name??null,assigneeKind:l?.kind??null,editable:U(o,t),proposal:t.proposed?o.decisions[t.id]??"pending":null,added:t.added,changed:d!==void 0&&d.status!==t.status,comments:r(`todo:${t.id}`)}},So=(e,o,a,t,r="all")=>{const d=o.todos.filter(p=>R(o,p)),l=d.filter(p=>p.status==="done").length,g=o.members.some(p=>p.kind==="human"),x=g?r:"all",F=p=>p.assigneeKind==="human",G=o.todos.map(p=>ge(e,o,a,p,t)),j=x==="human"?G.filter(F):G,Y=p=>p.status==="done"&&k(a,p.id)?.status==="done";return{todos:j.filter(p=>!Y(p)),done:j.filter(Y),filter:x,canFilter:g,humanCount:G.filter(F).length,progress:{done:l,total:d.length,label:d.length===0?e.noTodosYet:e.progress(l,d.length)},statuses:D.map(p=>({value:p,label:z(e,p)})),members:o.members.map(p=>({id:p.id,label:e.memberOption(p.name,le(e,p.kind))}))}},Do=e=>{if(!/^[a-z][a-z\d+.-]*:\/\//i.test(e))return{kind:"path"};try{return{kind:"url",host:new URL(e).host}}catch{return{kind:"path"}}},Eo=e=>e.outputs.map(o=>({id:o.id,title:o.label??o.href,labelled:o.label!==null,href:o.href,kind:o.kind,description:o.description,place:Do(o.href)})),Co=(e,o,a)=>({entries:o.log.map((t,r)=>{const d=O(o,t.from);return{id:t.id,author:d===void 0?null:{name:d.name,kind:d.kind},at:t.at,title:t.title,body:t.body,points:t.points,label:H(t),latest:r===o.log.length-1,comments:a(`log:${t.id}`)}}).reverse(),status:o.status===null&&o.updatedAt===null?null:{status:o.status,label:o.status===null?null:xo(e,o.status),updatedAt:o.updatedAt}}),zo=(e,o)=>{switch(o.type){case"todo":return k(e,o.id)!==void 0;case"log":return so(e,o.id)!==void 0;case"context":return io(o.id)&&N(e,o.id);case"question":return C(e,o.id)!==void 0;case"page":return!0;default:return!1}},Lo=e=>{const o=Q(e);return{name:"task-board",label:"Task Context Board",parseBase:ro,emptyBase:no,actions:m,apply:ko,hasTarget:zo,describe:(a,t,r)=>wo(o,a,t,r),serialize:$o,resolveNavigation:To,commentTargets:a=>yo(o,a),title:mo}},_=(e,o,a,t)=>n`
1
+ import{ab as Ro,ac as b,ad as i,ae as f,af as c,ag as w,aw as h,an as X,ah as J,ai as V,p as $,v as Uo,av as qo,as as Io,ak as Qo,am as B,P as Ho,e as Mo,a0 as Ko,V as Fo,R as S,a3 as s,a4 as n,A as jo,a5 as y,aT as Z,aU as Yo,aF as P,K as Xo,aC as Jo,a2 as Vo,T as oo,l as Zo,aH as oe}from"./shared-B_MMP97h.js";const eo=["working","waiting","blocked","done"],D=["todo","doing","blocked","done"],ao=["agent","human"],E=["why","what","goals","nonGoals"],T=J(c(),V(1)),ee=b({id:h,name:T,kind:i(w(ao),"agent")}),ae=b({id:h,title:T,status:i(w(D),"todo"),assignee:i(h),note:i(c()),proposed:i(X(),!1),reason:i(c())}),te=b({id:h,label:i(c()),href:T,kind:i(c()),description:i(c())}),re=b({why:i(c()),what:i(c()),goals:i(f(c()),[]),nonGoals:i(f(c()),[])}),ne=b({id:h,from:i(h),at:i(c()),title:i(c()),body:i(c()),points:i(f(c()),[])}),de=b({id:h,ref:i(T),title:T,description:i(c()),blocking:i(X(),!1),assumption:i(c())}),to=b({title:i(c(),""),status:i(w(eo)),updatedAt:i(c()),context:i(re,{}),members:i(f(ee),[]),todos:i(f(ae),[]),outputs:i(f(te),[]),log:i(f(ne),[]),questions:i(f(de),[])}),A=(e,o)=>{const a=new Set;for(const t of o){if(a.has(t))throw new Error(`duplicate ${e} id: ${t}`);a.add(t)}},u=e=>e===void 0||e.trim()===""?null:e,W=e=>e.filter(o=>o.trim()!==""),ro=e=>{const o=Ro(to,e);A("member",o.members.map(t=>t.id)),A("todo",o.todos.map(t=>t.id)),A("output",o.outputs.map(t=>t.id)),A("log",o.log.map(t=>t.id)),A("question",o.questions.map(t=>t.id));const a=new Set(o.members.map(t=>t.id));for(const t of o.todos)if(t.assignee!==void 0&&!a.has(t.assignee))throw new Error(`todo ${t.id} is assigned to ${t.assignee}, which is not in members`);for(const t of o.log){if(t.from!==void 0&&!a.has(t.from))throw new Error(`log entry ${t.id} is from ${t.from}, which is not in members`);if(u(t.title)===null&&u(t.body)===null)throw new Error(`log entry ${t.id} needs a title or a body`)}for(const t of o.questions)if(!t.blocking&&u(t.assumption)===null)throw new Error(`question ${t.id} does not block, so it needs the assumption the agent works on`);return{title:o.title,status:o.status??null,updatedAt:u(o.updatedAt),context:{why:u(o.context.why),what:u(o.context.what),goals:W(o.context.goals),nonGoals:W(o.context.nonGoals)},members:o.members,todos:o.todos.map(t=>({id:t.id,title:t.title,status:t.status,assignee:t.assignee??null,note:u(t.note),proposed:t.proposed,reason:u(t.reason),added:!1})),outputs:o.outputs.map(t=>({id:t.id,label:u(t.label),href:t.href,kind:u(t.kind),description:u(t.description)})),log:o.log.map(t=>({id:t.id,from:t.from??null,at:u(t.at),title:u(t.title),body:u(t.body),points:W(t.points)})),questions:o.questions.map((t,r)=>({id:t.id,ref:t.ref??`Q${r+1}`,title:t.title,description:u(t.description),blocking:t.blocking,assumption:u(t.assumption)})),answers:{},decisions:{}}},no=()=>({title:"",status:null,updatedAt:null,context:{why:null,what:null,goals:[],nonGoals:[]},members:[],todos:[],outputs:[],log:[],questions:[],answers:{},decisions:{}}),O=(e,o)=>o===null?void 0:e.members.find(a=>a.id===o),k=(e,o)=>e.todos.find(a=>a.id===o),so=(e,o)=>e.log.find(a=>a.id===o),io=e=>E.includes(e),N=(e,o)=>{const a=e.context[o];return typeof a=="string"||a!==null&&a.length>0},C=(e,o)=>e.questions.find(a=>a.id===o),lo=(e,o)=>{const a=e.answers[o.id];return a===void 0?!1:a.kind==="approve"||a.text.trim()!==""},R=(e,o)=>!o.proposed||e.decisions[o.id]==="accept",U=(e,o)=>R(e,o)&&O(e,o.assignee)?.kind==="human",po=(e,o,a)=>{const t={...e};return a===null?delete t[o]:t[o]=a,t},q=(e,o,a)=>({...e,answers:po(e.answers,o,a)}),se=(e,o,a)=>({...e,decisions:po(e.decisions,o,a)}),ie=(e,o,a)=>({...e,todos:e.todos.map(t=>t.id===o?a(t):t)}),m={ANSWER_QUESTION:$("ANSWER_QUESTION","question",Qo("kind",[b({kind:B("approve")}),b({kind:B("answer"),text:c()}),b({kind:B("clear")})])),DECIDE_PROPOSAL:$("DECIDE_PROPOSAL","todo",b({decision:w(["accept","decline","clear"])})),SET_TODO_STATUS:$("SET_TODO_STATUS","todo",b({status:w(D)})),ADD_TODO:$("ADD_TODO","page",b({id:h,title:J(c(),Io(),V(1)),assignee:qo(h)}),{dedupeKey:Uo}),DELETE_TODO:$("DELETE_TODO","todo",b({}))},co={type:"page",id:"task-board"},I=(e,o)=>({type:"ANSWER_QUESTION",target:{type:"question",id:e},payload:o}),uo=(e,o)=>({type:"DECIDE_PROPOSAL",target:{type:"todo",id:e},payload:{decision:o}}),bo=(e,o)=>({type:"SET_TODO_STATUS",target:{type:"todo",id:e},payload:{status:o}}),go=(e,o,a)=>({type:"ADD_TODO",target:co,payload:{id:e,title:o,assignee:a}}),ho=e=>({type:"DELETE_TODO",target:{type:"todo",id:e},payload:{}}),ko=(e,o)=>{const a=Ho(m,o);if(a===null)return null;const t=a.target.id;switch(a.type){case"ANSWER_QUESTION":{const r=C(e,t);if(r===void 0)return null;const d=a.payload;return d.kind==="clear"?q(e,t,null):d.kind==="approve"?r.assumption===null?null:q(e,t,{kind:"approve"}):q(e,t,{kind:"answer",text:d.text})}case"DECIDE_PROPOSAL":{if(k(e,t)?.proposed!==!0)return null;const{decision:r}=a.payload;return se(e,t,r==="clear"?null:r)}case"SET_TODO_STATUS":{const r=k(e,t);if(r===void 0||!U(e,r))return null;const{status:d}=a.payload;return ie(e,t,l=>({...l,status:d}))}case"ADD_TODO":{const{payload:r}=a;return k(e,r.id)!==void 0||r.assignee!==null&&O(e,r.assignee)===void 0?null:{...e,todos:[...e.todos,{id:r.id,title:r.title,status:"todo",assignee:r.assignee,note:null,proposed:!1,reason:null,added:!0}]}}case"DELETE_TODO":return k(e,t)?.added!==!0?null:{...e,todos:e.todos.filter(r=>r.id!==t)};default:return Mo(a)}},Q=Ko({en:{wholeBoard:"Whole board",statusWorking:"Working",statusWaiting:"Waiting on you",statusBlocked:"Blocked",statusDone:"Done",todoTodo:"To do",todoDoing:"In progress",todoBlocked:"Blocked",todoDone:"Done",kindAgent:"Agent",kindHuman:"Human",updatedAt:e=>`Updated ${e}`,context:"What this task is about",contextWhy:"Why",contextWhat:"What",contextGoals:"Goals",contextNonGoals:"Non-goals",noContext:"The agent has not written down why and what yet.",tabs:"Board sections",tabContext:"Context",tabLog:"Work log",tabQuestions:"Questions",openCount:e=>`${e} open`,noQuestions:"The agent has nothing to ask right now.",questions:"Questions from the agent",questionsProgress:(e,o)=>`${e} of ${o} replied`,blockingGroup:"Blocking \u2014 the agent waits for your decision",provisionalGroup:"Going ahead on an assumption \u2014 the agent adjusts if you answer otherwise",blockingTag:"Blocking",assumption:"Assumption",recommendation:"Agent recommends",approveAssumption:"OK, go with this",approveRecommendation:"OK, go with the recommendation",answerOther:"Answer differently",answerOf:e=>`Your answer to ${e}`,answerPlaceholder:"What you expect instead\u2026",blockingPlaceholder:"Your decision\u2026",approvedTag:"Approved",answeredTag:"Answered",todos:"Todo",progress:(e,o)=>`${e} of ${o} done`,noTodosYet:"No todos yet",assignee:"Assignee",unassigned:"Unassigned",memberOption:(e,o)=>`${e} (${o})`,statusOf:e=>`Status of \u201C${e}\u201D`,filterTodos:"Show todos",filterAll:"All",filterHuman:"People",doneGroup:e=>`Done (${e})`,noHumanTodos:"Nobody but the agent has a todo.",addedTag:"Added by you",changedTag:"Changed",removeAdded:"Remove this todo you added",noTodos:"There are no todos yet.",newTodo:"New todo",newTodoPlaceholder:"Add a todo for the agent\u2026",newTodoAssignee:"Assignee of the new todo",addTodo:"Add",proposedMark:"Proposed by the agent",reason:"Why",accept:"Accept",decline:"Decline",decisionOf:e=>`Decision on \u201C${e}\u201D`,acceptedTag:"Accepted",declinedTag:"Declined",undoDecision:"Undo",outputs:"Outputs",noOutputs:"Nothing has been produced yet.",copy:e=>`Copy ${e}`,copied:"Copied",log:"Conversation with the agent",logLede:"Newest first",noLog:"Nothing has been exchanged yet.",fromAgent:"Agent",latestTag:"Latest",commentOn:e=>`Comment on ${e}`,todoGroup:"Todo",logGroup:"Log",contextGroup:"Context",proposalGroup:"Proposal",questionGroup:"Question",approved:"Approve the assumption",answered:"Answer",answerCleared:"Clear the reply",accepted:"Accept the proposal",declined:"Decline the proposal",decisionCleared:"Clear the decision",statusChanged:"Change the status",todoAdded:"Add a todo",todoRemoved:"Remove the added todo",quoted:e=>`\u2192 \u201C${e}\u201D`,change:(e,o)=>`${e} \u2192 ${o}`},ja:{wholeBoard:"\u30DC\u30FC\u30C9\u5168\u4F53",statusWorking:"\u4F5C\u696D\u4E2D",statusWaiting:"\u3042\u306A\u305F\u306E\u8FD4\u7B54\u5F85\u3061",statusBlocked:"\u30D6\u30ED\u30C3\u30AF\u4E2D",statusDone:"\u5B8C\u4E86",todoTodo:"\u672A\u7740\u624B",todoDoing:"\u9032\u884C\u4E2D",todoBlocked:"\u30D6\u30ED\u30C3\u30AF",todoDone:"\u5B8C\u4E86",kindAgent:"Agent",kindHuman:"\u4EBA\u9593",updatedAt:e=>`\u66F4\u65B0 ${e}`,context:"\u3053\u306E\u30BF\u30B9\u30AF\u306E\u524D\u63D0",contextWhy:"Why \u2014 \u306A\u305C\u3084\u308B\u304B",contextWhat:"What \u2014 \u4F55\u3092\u3084\u308B\u304B",contextGoals:"\u30B4\u30FC\u30EB",contextNonGoals:"\u3084\u3089\u306A\u3044\u3053\u3068",noContext:"Agent \u306F\u307E\u3060 Why / What \u3092\u66F8\u3044\u3066\u3044\u307E\u305B\u3093\u3002",tabs:"\u30DC\u30FC\u30C9\u306E\u533A\u5206",tabContext:"Context",tabLog:"\u4F5C\u696D\u30ED\u30B0",tabQuestions:"\u8CEA\u554F",openCount:e=>`\u672A\u56DE\u7B54 ${e} \u4EF6`,noQuestions:"\u4ECA Agent \u304B\u3089\u805E\u304D\u305F\u3044\u3053\u3068\u306F\u3042\u308A\u307E\u305B\u3093\u3002",questions:"Agent \u304B\u3089\u306E\u8CEA\u554F",questionsProgress:(e,o)=>`\u8FD4\u7B54\u6E08\u307F ${e} / ${o}`,blockingGroup:"\u30D6\u30ED\u30C3\u30AB\u30FC \u2014 \u6C7A\u3081\u3066\u3082\u3089\u3046\u307E\u3067\u5148\u306B\u9032\u3081\u306A\u3044",provisionalGroup:"\u4EEE\u306E\u524D\u63D0\u3067\u9032\u884C\u4E2D \u2014 \u9055\u3048\u3070\u65B9\u91DD\u3092\u76F4\u3059",blockingTag:"\u30D6\u30ED\u30C3\u30AB\u30FC",assumption:"\u4EEE\u56DE\u7B54",recommendation:"Agent \u306E\u63A8\u5968",approveAssumption:"\u3053\u306E\u524D\u63D0\u3067 OK",approveRecommendation:"\u63A8\u5968\u3069\u304A\u308A\u3067 OK",answerOther:"\u5225\u306E\u56DE\u7B54\u3092\u3059\u308B",answerOf:e=>`${e} \u3078\u306E\u56DE\u7B54`,answerPlaceholder:"\u671F\u5F85\u3059\u308B\u56DE\u7B54\u3092\u5165\u529B\u2026",blockingPlaceholder:"\u3069\u3046\u3059\u308B\u304B\u3092\u5165\u529B\u2026",approvedTag:"\u627F\u8A8D\u6E08\u307F",answeredTag:"\u56DE\u7B54\u6E08\u307F",todos:"Todo",progress:(e,o)=>`${o} \u4EF6\u4E2D ${e} \u4EF6\u5B8C\u4E86`,noTodosYet:"Todo \u306F\u307E\u3060\u3042\u308A\u307E\u305B\u3093",assignee:"\u62C5\u5F53",unassigned:"\u672A\u5272\u308A\u5F53\u3066",memberOption:(e,o)=>`${e}\uFF08${o}\uFF09`,statusOf:e=>`\u300C${e}\u300D\u306E\u72B6\u614B`,filterTodos:"\u8868\u793A\u3059\u308B Todo",filterAll:"\u3059\u3079\u3066",filterHuman:"\u4EBA\u9593\u306E\u62C5\u5F53",doneGroup:e=>`\u5B8C\u4E86 ${e} \u4EF6`,noHumanTodos:"\u4EBA\u9593\u304C\u62C5\u5F53\u3059\u308B Todo \u306F\u3042\u308A\u307E\u305B\u3093\u3002",addedTag:"\u3042\u306A\u305F\u304C\u8FFD\u52A0",changedTag:"\u5909\u66F4\u3042\u308A",removeAdded:"\u8FFD\u52A0\u3057\u305F Todo \u3092\u53D6\u308A\u6D88\u3059",noTodos:"Todo \u306F\u307E\u3060\u3042\u308A\u307E\u305B\u3093\u3002",newTodo:"\u65B0\u3057\u3044 Todo",newTodoPlaceholder:"Agent \u306B\u983C\u3080 Todo \u3092\u8FFD\u52A0\u2026",newTodoAssignee:"\u65B0\u3057\u3044 Todo \u306E\u62C5\u5F53",addTodo:"\u8FFD\u52A0",proposedMark:"Agent \u304B\u3089\u306E\u63D0\u6848",reason:"\u306A\u305C",accept:"\u627F\u8A8D",decline:"\u898B\u9001\u308A",decisionOf:e=>`\u300C${e}\u300D\u306E\u5224\u65AD`,acceptedTag:"\u627F\u8A8D\u6E08\u307F",declinedTag:"\u898B\u9001\u308A",undoDecision:"\u53D6\u308A\u6D88\u3059",outputs:"\u6210\u679C\u7269",noOutputs:"\u307E\u3060\u6210\u679C\u7269\u306F\u3042\u308A\u307E\u305B\u3093\u3002",copy:e=>`${e} \u3092\u30B3\u30D4\u30FC`,copied:"\u30B3\u30D4\u30FC\u3057\u307E\u3057\u305F",log:"Agent \u3068\u306E\u3084\u308A\u3068\u308A",logLede:"\u65B0\u3057\u3044\u9806",noLog:"\u307E\u3060\u3084\u308A\u3068\u308A\u306F\u3042\u308A\u307E\u305B\u3093\u3002",fromAgent:"Agent",latestTag:"\u6700\u65B0",commentOn:e=>`${e} \u306B\u30B3\u30E1\u30F3\u30C8`,todoGroup:"Todo",logGroup:"\u4F5C\u696D\u30ED\u30B0",contextGroup:"Context",proposalGroup:"\u63D0\u6848",questionGroup:"\u8CEA\u554F",approved:"\u524D\u63D0\u3092\u627F\u8A8D",answered:"\u56DE\u7B54",answerCleared:"\u8FD4\u7B54\u3092\u30AF\u30EA\u30A2",accepted:"\u63D0\u6848\u3092\u627F\u8A8D",declined:"\u63D0\u6848\u3092\u898B\u9001\u308A",decisionCleared:"\u63D0\u6848\u306E\u5224\u65AD\u3092\u30AF\u30EA\u30A2",statusChanged:"\u72B6\u614B\u3092\u5909\u66F4",todoAdded:"Todo \u3092\u8FFD\u52A0",todoRemoved:"\u8FFD\u52A0\u3057\u305F Todo \u3092\u53D6\u308A\u6D88\u3057",quoted:e=>`\u2192 \u300C${e}\u300D`,change:(e,o)=>`${e} \u2192 ${o}`}}),xo=(e,o)=>{switch(o){case"working":return e.statusWorking;case"waiting":return e.statusWaiting;case"blocked":return e.statusBlocked;case"done":return e.statusDone}},z=(e,o)=>{switch(o){case"todo":return e.todoTodo;case"doing":return e.todoDoing;case"blocked":return e.todoBlocked;case"done":return e.todoDone}},le=(e,o)=>o==="agent"?e.kindAgent:e.kindHuman,L=(e,o)=>{switch(o){case"why":return e.contextWhy;case"what":return e.contextWhat;case"goals":return e.contextGoals;case"nonGoals":return e.contextNonGoals}},fo=48,H=e=>{const o=e.title??e.body??e.id;return o.length<=fo?o:`${o.slice(0,fo-1)}\u2026`},pe=(e,o,a)=>a===null?e.unassigned:O(o,a)?.name??a,mo=e=>e.title===""?"Task Context Board":e.title,vo=(e,o,a)=>{switch(a.type){case"todo":{const t=k(o,a.id);return`${t?.proposed===!0?e.proposalGroup:e.todoGroup} \xB7 ${t?.title??a.id}`}case"log":{const t=so(o,a.id);return`${e.logGroup} \xB7 ${t===void 0?a.id:H(t)}`}case"context":return`${e.contextGroup} \xB7 ${io(a.id)?L(e,a.id):a.id}`;case"question":{const t=C(o,a.id);return t===void 0?a.id:`${t.ref} \xB7 ${t.title}`}case"page":return e.wholeBoard;default:return a.id}},ce=(e,o)=>{switch(o){case"accept":return{title:e.accepted,tone:"update"};case"decline":return{title:e.declined,tone:"update"};case"clear":return{title:e.decisionCleared,tone:"delete"}}},ue=(e,o,a)=>{switch(a.type){case"ANSWER_QUESTION":{const t=S(m.ANSWER_QUESTION,a);if(t.kind==="clear")return{title:e.answerCleared,tone:"delete"};if(t.kind==="approve"){const r=C(o,a.target.id)?.assumption??null;return{title:e.approved,tone:"update",...r===null?{}:{body:e.quoted(r)}}}return{title:e.answered,tone:"update",body:e.quoted(t.text.slice(0,120))}}case"DECIDE_PROPOSAL":return ce(e,S(m.DECIDE_PROPOSAL,a).decision);case"SET_TODO_STATUS":{const{status:t}=S(m.SET_TODO_STATUS,a),r=k(o,a.target.id)?.status,d=z(e,t);return{title:e.statusChanged,tone:"update",body:r===void 0?d:e.change(z(e,r),d)}}case"ADD_TODO":{const t=S(m.ADD_TODO,a);return{title:e.todoAdded,tone:"create",targetLabel:`${e.todoGroup} \xB7 ${t.title}`,...t.assignee===null?{}:{body:`${e.assignee}: ${pe(e,o,t.assignee)}`}}}case"DELETE_TODO":return{title:e.todoRemoved,tone:"delete"};default:return{title:a.type,tone:"meta"}}},wo=(e,o,a,t)=>{let r;try{r=ue(e,t??a,o)}catch{r={title:o.type,tone:"meta"}}return{title:r.title,targetLabel:r.targetLabel??vo(e,a,o.target),tone:r.tone,...r.body===void 0?{}:{summary:r.body}}},$o=e=>`${e.type} ${Fo(e.target)} ${JSON.stringify(e.payload)}`,yo=(e,o)=>[...o.questions.map(a=>({value:`question:${a.id}`,label:`${a.ref} \xB7 ${a.title}`,group:e.questionGroup})),...o.todos.map(a=>({value:`todo:${a.id}`,label:a.title,group:a.proposed?e.proposalGroup:e.todoGroup})),...o.log.map(a=>({value:`log:${a.id}`,label:H(a),group:e.logGroup})),...E.filter(a=>N(o,a)).map(a=>({value:`context:${a}`,label:L(e,a),group:e.contextGroup}))],To=(e,o)=>o,Ao=(e,o,a)=>({parts:E.filter(t=>N(o,t)).map(t=>{const r=o.context[t];return{id:t,title:L(e,t),text:typeof r=="string"?r:null,items:typeof r=="string"||r===null?[]:r,comments:a(`context:${t}`)}})}),be=(e,o,a)=>{const t=e.answers[o.id];return{id:o.id,ref:o.ref,title:o.title,description:o.description,blocking:o.blocking,assumption:o.assumption,reply:t?.kind??"none",resolved:lo(e,o),draft:t?.kind==="answer"?t.text:"",comments:a(`question:${o.id}`)}},Oo=(e,o)=>{const a=e.questions.map(r=>be(e,r,o)),t=a.filter(r=>r.resolved).length;return{blocking:a.filter(r=>r.blocking),provisional:a.filter(r=>!r.blocking),resolved:t,total:a.length,open:a.length-t,blockingOpen:a.filter(r=>r.blocking&&!r.resolved).length}},ge=(e,o,a,t,r)=>{const d=k(a,t.id),l=O(o,t.assignee);return{id:t.id,title:t.title,note:t.note,reason:t.reason,status:t.status,statusLabel:z(e,t.status),assignee:t.assignee,assigneeName:l?.name??null,assigneeKind:l?.kind??null,editable:U(o,t),proposal:t.proposed?o.decisions[t.id]??"pending":null,added:t.added,changed:d!==void 0&&d.status!==t.status,comments:r(`todo:${t.id}`)}},So=(e,o,a,t,r="all")=>{const d=o.todos.filter(p=>R(o,p)),l=d.filter(p=>p.status==="done").length,g=o.members.some(p=>p.kind==="human"),x=g?r:"all",F=p=>p.assigneeKind==="human",G=o.todos.map(p=>ge(e,o,a,p,t)),j=x==="human"?G.filter(F):G,Y=p=>p.status==="done"&&k(a,p.id)?.status==="done";return{todos:j.filter(p=>!Y(p)),done:j.filter(Y),filter:x,canFilter:g,humanCount:G.filter(F).length,progress:{done:l,total:d.length,label:d.length===0?e.noTodosYet:e.progress(l,d.length)},statuses:D.map(p=>({value:p,label:z(e,p)})),members:o.members.map(p=>({id:p.id,label:e.memberOption(p.name,le(e,p.kind))}))}},Do=e=>{if(!/^[a-z][a-z\d+.-]*:\/\//i.test(e))return{kind:"path"};try{return{kind:"url",host:new URL(e).host}}catch{return{kind:"path"}}},Eo=e=>e.outputs.map(o=>({id:o.id,title:o.label??o.href,labelled:o.label!==null,href:o.href,kind:o.kind,description:o.description,place:Do(o.href)})),Co=(e,o,a)=>({entries:o.log.map((t,r)=>{const d=O(o,t.from);return{id:t.id,author:d===void 0?null:{name:d.name,kind:d.kind},at:t.at,title:t.title,body:t.body,points:t.points,label:H(t),latest:r===o.log.length-1,comments:a(`log:${t.id}`)}}).reverse(),status:o.status===null&&o.updatedAt===null?null:{status:o.status,label:o.status===null?null:xo(e,o.status),updatedAt:o.updatedAt}}),zo=(e,o)=>{switch(o.type){case"todo":return k(e,o.id)!==void 0;case"log":return so(e,o.id)!==void 0;case"context":return io(o.id)&&N(e,o.id);case"question":return C(e,o.id)!==void 0;case"page":return!0;default:return!1}},Lo=e=>{const o=Q(e);return{name:"task-board",label:"Task Context Board",parseBase:ro,emptyBase:no,actions:m,apply:ko,hasTarget:zo,describe:(a,t,r)=>wo(o,a,t,r),serialize:$o,resolveNavigation:To,commentTargets:a=>yo(o,a),title:mo}},_=(e,o,a,t)=>n`
2
2
  <button
3
3
  class="dpk-icon-btn board-comment"
4
4
  type="button"
@@ -1,4 +1,4 @@
1
- import{a0 as _,Z as _e,j as Be,a1 as Ge,a2 as B,a3 as b,a4 as h,a5 as J,a6 as O,a7 as Ye,a8 as Ve,A as We,a9 as Es,aa as qs,ab as G,ac as q,ad as f,ae as z,af as u,ag as H,ah as S,ai as M,aj as ae,ak as Ke,al as Xe,am as Z,an as we,ao as zs,ap as $e,aq as Se,ar as Ds,as as Me,l as Je,at as Ts,au as As,av as Ls,aw as ne,ax as Rs,q as Os,r as Is}from"./shared-BQFDKhM1.js";import{i as Ze}from"./shared-COrrbgIn.js";import{P as Qe,p as et,r as tt,c as st}from"./shared-Bd9pmv5a.js";import{c as me}from"./shared-ml5h7U5L.js";const Ps='script[type="application/json"]',at=(a,e)=>{const t=a.querySelector(Ps);if(!t)return null;const s=t.textContent??"";if(s.trim()==="")return{ok:!1,error:"JSON block is empty"};try{return{ok:!0,value:e(JSON.parse(s))}}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},nt=(a,e,t)=>{const s=at(a,e);if(s)return t(s),()=>{};const n=new MutationObserver(()=>{const r=at(a,e);r&&(n.disconnect(),t(r))});return n.observe(a,{childList:!0,subtree:!0}),()=>n.disconnect()},rt={nodeSpacing:34,layerSpacing:84,padding:28,sweeps:4,coordinatePasses:6},ge=a=>{const e=[...a].sort((s,n)=>s-n);if(e.length===0)return 0;const t=Math.floor(e.length/2);return e.length%2===1?e[t]??0:((e[t-1]??0)+(e[t]??0))/2},js=(a,e)=>{const t=new Map;for(const i of a)t.set(i.id,[]);for(const i of e)t.get(i.from)?.push(i);const s=new Map,n=new Set,r=i=>{s.set(i,"open");for(const o of t.get(i)??[]){const d=s.get(o.to)??"new";d==="open"?n.add(o.id):d==="new"&&r(o.to)}s.set(i,"done")};for(const i of a)(s.get(i.id)??"new")==="new"&&r(i.id);return{reversed:n,forward:e.filter(i=>!n.has(i.id))}},Fs=(a,e)=>{const t=new Map,s=new Map;for(const o of a)t.set(o.id,[]),s.set(o.id,[]);for(const o of e)s.get(o.from)?.push(o),t.get(o.to)?.push(o);const n=new Map(a.map(o=>[o.id,0])),r=new Map(a.map(o=>[o.id,(t.get(o.id)??[]).length])),i=a.filter(o=>(r.get(o.id)??0)===0).map(o=>o.id);for(const o of i)for(const d of s.get(o)??[]){const l=n.get(d.to)??0;n.set(d.to,Math.max(l,(n.get(o)??0)+1));const c=(r.get(d.to)??0)-1;r.set(d.to,c),c===0&&i.push(d.to)}return n},Ns=(a,e,t,s)=>{const n=[...a.keys()].sort((r,i)=>r-i);for(let r=0;r<s;r++){const i=r%2===0;for(const o of i?n:[...n].reverse()){const d=a.get(o)??[],l=new Map(d.map((p,k)=>[p,k])),c=p=>{const k=l.get(p);return k===void 0?null:k},m=d.map(p=>{const k=(e.get(p)??[]).filter(x=>(t.get(x)??o)===o+(i?-1:1)).map(c).filter(x=>x!==null);return{id:p,want:k.length>0?ge(k):l.get(p)??0}});m.sort((p,k)=>p.want-k.want||(l.get(p.id)??0)-(l.get(k.id)??0)),a.set(o,m.map(p=>p.id))}}},it=(a,e,t,s)=>{const n=a.map((i,o)=>({id:i,want:t.get(i)??o*100,index:o}));n.sort((i,o)=>i.want-o.want||i.index-o.index);let r=0;for(const i of n){const o=e.get(i.id);o&&(o.y=r,r+=o.spec.height+s)}return{height:Math.max(0,r-s)}},Us=(a,e,t,s,n)=>{const r=[...a.keys()].sort((l,c)=>l-c),i=new Map;for(const l of r)i.set(l,it(a.get(l)??[],e,new Map,n.nodeSpacing).height);const o=Math.max(0,...i.values());for(const l of r){const c=(o-(i.get(l)??0))/2;for(const m of a.get(l)??[]){const p=e.get(m);p&&(p.y+=c)}}const d=(l,c)=>{const m=(t.get(l)??[]).filter(p=>s.get(p)===c).flatMap(p=>{const k=e.get(p);return k?[k.y+k.spec.height/2]:[]});return m.length>0?ge(m):null};for(let l=0;l<n.coordinatePasses;l++){const c=l%2===0;for(const m of c?r:[...r].reverse()){const p=a.get(m)??[],k=new Map;for(const w of p){const D=d(w,m+(c?-1:1)),I=e.get(w);I!==void 0&&k.set(w,D===null?I.y+I.spec.height/2:D)}const x=p.map(w=>e.get(w)?.y??0);it(p,e,k,n.nodeSpacing);const v=p.map(w=>e.get(w)?.y??0),y=ge(x)-ge(v);for(const w of p){const D=e.get(w);D&&(D.y+=y)}}}},ot=(a,e,t)=>{const s=e===void 0?void 0:a.spec.ports?.[e];return s?{x:a.x+s.x,y:a.y+s.y}:t==="out"?{x:a.x+a.spec.width,y:a.y+a.spec.height/2}:{x:a.x,y:a.y+a.spec.height/2}},dt=(a,e,t)=>{let s=0;const n=[];for(const r of a){const i=t.byId.get(r.from),o=t.byId.get(r.to);if(!i||!o)continue;const d=ot(i,r.fromPort,"out"),l=ot(o,r.toPort,"in");if(r.from===r.to){const x=i.x+i.spec.width,v=i.y+i.spec.height,y=Math.max(t.padding/2,v+18);n.push({id:r.id,points:[d,{x:x+20,y:d.y},{x:x+20,y},{x:i.x-20,y},{x:i.x-20,y:l.y},l]});continue}if(!e.has(r.id)&&(i.layer<o.layer||i.layer===o.layer&&l.x>d.x+12)){if(Math.abs(d.y-l.y)<.5){n.push({id:r.id,points:[d,l]});continue}const v=i.layer<o.layer?Math.max(d.x+14,o.x-Math.max(12,t.layerSpacing/2)):(d.x+l.x)/2;n.push({id:r.id,points:[d,{x:v,y:d.y},{x:v,y:l.y},l]});continue}const c=r.fromPort===void 0?{x:i.x+i.spec.width/2,y:i.y+i.spec.height}:d,m=r.toPort===void 0?{x:o.x+o.spec.width/2,y:o.y+o.spec.height}:l,p=Math.max(c.y,m.y)+18+s*14;s+=1;const k=[d,c,{x:c.x,y:p},{x:m.x,y:p},m,l].filter((x,v,y)=>v===0||x.x!==y[v-1]?.x||x.y!==y[v-1]?.y);n.push({id:r.id,points:k})}return n},lt=(a,e,t)=>{const s=e.flatMap(p=>[...p.points]),n=[...a.map(p=>p.x),...a.map(p=>p.x+p.spec.width),...s.map(p=>p.x)],r=[...a.map(p=>p.y),...a.map(p=>p.y+p.spec.height),...s.map(p=>p.y)],i=Math.min(0,...n),o=Math.min(0,...r),d=Math.max(0,...n),l=Math.max(0,...r),c=t-i,m=t-o;return{width:d-i+t*2,height:l-o+t*2,nodes:a.map(p=>({id:p.spec.id,x:p.x+c,y:p.y+m,width:p.spec.width,height:p.spec.height,layer:p.layer,order:p.order})),routes:e.map(p=>({id:p.id,points:p.points.map(k=>({x:k.x+c,y:k.y+m}))}))}},ct=(a,e)=>{const t=new Map(a.map(s=>[s.id,[]]));for(const s of e)s.from!==s.to&&(t.get(s.from)?.push(s.to),t.get(s.to)?.push(s.from));return t},pt=(a,e,t,s)=>a.map(n=>({spec:n,layer:e.get(n.id)??0,order:t.get(n.id)??0,...s(n)})),Hs=(a,e)=>{const t=new Map;for(const s of a){const n=e.get(s.id)??0,r=t.get(n);r?r.push(s.id):t.set(n,[s.id])}return t},_s=(a,e,t={})=>{const s={...rt,...t};if(a.length===0)return{width:0,height:0,nodes:[],routes:[]};const n=new Set(a.map(v=>v.id)),r=e.filter(v=>n.has(v.from)&&n.has(v.to)),{forward:i,reversed:o}=js(a,r),d=Fs(a,i),l=Hs(a,d);Ns(l,ct(a,r),d,s.sweeps);const c=new Map;for(const v of l.values())v.forEach((y,w)=>c.set(y,w));const m=pt(a,d,c,()=>({x:0,y:0})),p=new Map(m.map(v=>[v.spec.id,v]));Us(l,p,ct(a,r),d,s);const k=[...l.keys()].sort((v,y)=>v-y);let x=0;for(const v of k){const y=Math.max(...(l.get(v)??[]).map(w=>p.get(w)?.spec.width??0));for(const w of l.get(v)??[]){const D=p.get(w);D&&(D.x=x)}x+=y+s.layerSpacing}return lt(m,dt(r,o,{byId:p,layerSpacing:s.layerSpacing,padding:s.padding}),s.padding)},Bs=(a,e,t={})=>{const s={...rt,...t};if(a.length===0)return{width:0,height:0,nodes:[],routes:[]};const n=new Set(a.map(d=>d.id)),r=e.filter(d=>n.has(d.from)&&n.has(d.to)),i=pt(a,new Map,new Map,d=>d.position??{x:0,y:0}),o=new Map(i.map(d=>[d.spec.id,d]));return lt(i,dt(r,new Set,{byId:o,layerSpacing:s.layerSpacing,padding:s.padding}),s.padding)},Gs=_({en:{tagFilter:"Filter by tag",tagMatch:"Tag matching",clearTags:"Clear",zoomOut:"Zoom out",fit:"Fit to view",zoomIn:"Zoom in",sendFailed:"Could not send. Please try again.",commentOn:a=>`Comment on ${a}`,noMatches:"No matching elements.",maximize:"Maximize",restore:"Restore size",canvas:"Diagram. Arrow keys pan, plus and minus zoom, 0 fits the view.",dataError:"Could not load the diagram data.",nodes:"elements",edges:"relations",change:(a,e)=>`\u201C${a}\u201D \u2192 \u201C${e}\u201D`},ja:{tagFilter:"\u30BF\u30B0\u306E\u7D5E\u308A\u8FBC\u307F",tagMatch:"\u30BF\u30B0\u306E\u4E00\u81F4\u6761\u4EF6",clearTags:"\u89E3\u9664",zoomOut:"\u7E2E\u5C0F",fit:"\u5168\u4F53\u3092\u8868\u793A",zoomIn:"\u62E1\u5927",sendFailed:"\u9001\u4FE1\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002\u3082\u3046\u4E00\u5EA6\u304A\u8A66\u3057\u304F\u3060\u3055\u3044\u3002",commentOn:a=>`${a}\u306B\u30B3\u30E1\u30F3\u30C8`,noMatches:"\u8A72\u5F53\u3059\u308B\u8981\u7D20\u306F\u3042\u308A\u307E\u305B\u3093\u3002",maximize:"\u6700\u5927\u5316",restore:"\u5143\u306E\u30B5\u30A4\u30BA\u306B\u623B\u3059",canvas:"\u56F3\u3002\u77E2\u5370\u30AD\u30FC\u3067\u30D1\u30F3\u3001\u30D7\u30E9\u30B9\u30FB\u30DE\u30A4\u30CA\u30B9\u3067\u30BA\u30FC\u30E0\u30010\u3067\u5168\u4F53\u8868\u793A\u3002",dataError:"\u56F3\u306E\u30C7\u30FC\u30BF\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F\u3002",nodes:"\u8981\u7D20",edges:"\u95A2\u9023",change:(a,e)=>`\u300C${a}\u300D\u2192\u300C${e}\u300D`}}),Ys={active:[],match:"single"},Q=(a,e)=>e.active.length===0?!0:e.match==="all"?e.active.every(t=>a.includes(t)):e.active.some(t=>a.includes(t)),Vs=(a,e)=>a.active.includes(e)?{...a,active:a.active.filter(t=>t!==e)}:a.match==="single"?{...a,active:[e]}:{...a,active:[...a.active,e]},Ws=(a,e)=>({match:e,active:e==="single"&&a.active.length>1?a.active.slice(-1):a.active}),Ks=a=>({...a,active:[]}),Xs=a=>{const e=new Map;for(const t of a)for(const s of new Set(t))e.set(s,(e.get(s)??0)+1);return[...e].map(([t,s])=>({tag:t,count:s}))},Y={nodes:new Map,edges:new Set},N=(a,e,t,s)=>{const n=new Map,r=new Set,i=[{id:e,depth:0}],o=new Set([e]);for(const d of i)if(!(!s&&d.depth>=1))for(const l of a){const c=t==="outgoing"?l.from:l.to,m=t==="outgoing"?l.to:l.from;c===d.id&&(r.add(l.id),!o.has(m)&&(o.add(m),n.set(m,d.depth+1),i.push({id:m,depth:d.depth+1})))}return{nodes:n,edges:r}},Js=(a,e)=>{const t=new Map(a.map(r=>[r,N(e,r,"outgoing",!0).nodes])),s=new Set,n=[];for(const r of a){if(s.has(r))continue;const i=a.filter(o=>o===r||t.get(r)?.has(o)===!0&&t.get(o)?.has(r)===!0);for(const o of i)s.add(o);(i.length>1||e.some(o=>o.from===r&&o.to===r))&&n.push(i)}return n},Ce=a=>new Map(a.flatMap((e,t)=>e.map(s=>[s,t]))),ht=(a,e)=>e.get(a.from)===e.get(a.to)&&e.has(a.from),ut=a=>{try{return a.split("/").map(e=>decodeURIComponent(e))}catch{return null}},mt=(a,e,t,s)=>{const n=e!==null&&e.kind===t&&e.id===a,r=t==="node"?s.nodes.has(a):s.edges.has(a),i=t==="node"?s.nodes.get(a)??null:null;return{selected:n,related:r&&!n,dimmed:e!==null&&!n&&!r,depth:i}},ee=(...a)=>a.filter(e=>typeof e=="string"&&e!=="").join(" "),Zs=a=>{const e=a[0]??{x:0,y:0},t=a.at(-1)??e;if(a.length<=2)return{x:(e.x+t.x)/2,y:(e.y+t.y)/2};if(a.length===4){const r=a[1]??e,i=a[2]??t;return{x:r.x,y:(r.y+i.y)/2}}const s=a[2]??e,n=a[3]??t;return{x:(s.x+n.x)/2,y:s.y}},Qs=(a,e)=>Xs(a).map(t=>({tag:t.tag,count:t.count,selected:e.active.includes(t.tag)})),ea=(a,e,t)=>`${a} ${t.node} \xB7 ${e} ${t.edge}`,W=[_e,Be,Ge,B`
1
+ import{a0 as _,Z as _e,j as Be,a1 as Ge,a2 as B,a3 as b,a4 as h,a5 as J,a6 as O,a7 as Ye,a8 as Ve,A as We,a9 as Es,aa as qs,ab as G,ac as q,ad as f,ae as z,af as u,ag as H,ah as S,ai as M,aj as ae,ak as Ke,al as Xe,am as Z,an as we,ao as zs,ap as $e,aq as Se,ar as Ds,as as Me,l as Je,at as Ts,au as As,av as Ls,aw as ne,ax as Rs,q as Os,r as Is}from"./shared-B_MMP97h.js";import{i as Ze}from"./shared-BSFZSMH5.js";import{P as Qe,p as et,r as tt,c as st}from"./shared-B4ewpBuM.js";import{c as me}from"./shared-ml5h7U5L.js";const Ps='script[type="application/json"]',at=(a,e)=>{const t=a.querySelector(Ps);if(!t)return null;const s=t.textContent??"";if(s.trim()==="")return{ok:!1,error:"JSON block is empty"};try{return{ok:!0,value:e(JSON.parse(s))}}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},nt=(a,e,t)=>{const s=at(a,e);if(s)return t(s),()=>{};const n=new MutationObserver(()=>{const r=at(a,e);r&&(n.disconnect(),t(r))});return n.observe(a,{childList:!0,subtree:!0}),()=>n.disconnect()},rt={nodeSpacing:34,layerSpacing:84,padding:28,sweeps:4,coordinatePasses:6},ge=a=>{const e=[...a].sort((s,n)=>s-n);if(e.length===0)return 0;const t=Math.floor(e.length/2);return e.length%2===1?e[t]??0:((e[t-1]??0)+(e[t]??0))/2},js=(a,e)=>{const t=new Map;for(const i of a)t.set(i.id,[]);for(const i of e)t.get(i.from)?.push(i);const s=new Map,n=new Set,r=i=>{s.set(i,"open");for(const o of t.get(i)??[]){const d=s.get(o.to)??"new";d==="open"?n.add(o.id):d==="new"&&r(o.to)}s.set(i,"done")};for(const i of a)(s.get(i.id)??"new")==="new"&&r(i.id);return{reversed:n,forward:e.filter(i=>!n.has(i.id))}},Fs=(a,e)=>{const t=new Map,s=new Map;for(const o of a)t.set(o.id,[]),s.set(o.id,[]);for(const o of e)s.get(o.from)?.push(o),t.get(o.to)?.push(o);const n=new Map(a.map(o=>[o.id,0])),r=new Map(a.map(o=>[o.id,(t.get(o.id)??[]).length])),i=a.filter(o=>(r.get(o.id)??0)===0).map(o=>o.id);for(const o of i)for(const d of s.get(o)??[]){const l=n.get(d.to)??0;n.set(d.to,Math.max(l,(n.get(o)??0)+1));const c=(r.get(d.to)??0)-1;r.set(d.to,c),c===0&&i.push(d.to)}return n},Ns=(a,e,t,s)=>{const n=[...a.keys()].sort((r,i)=>r-i);for(let r=0;r<s;r++){const i=r%2===0;for(const o of i?n:[...n].reverse()){const d=a.get(o)??[],l=new Map(d.map((p,k)=>[p,k])),c=p=>{const k=l.get(p);return k===void 0?null:k},m=d.map(p=>{const k=(e.get(p)??[]).filter(x=>(t.get(x)??o)===o+(i?-1:1)).map(c).filter(x=>x!==null);return{id:p,want:k.length>0?ge(k):l.get(p)??0}});m.sort((p,k)=>p.want-k.want||(l.get(p.id)??0)-(l.get(k.id)??0)),a.set(o,m.map(p=>p.id))}}},it=(a,e,t,s)=>{const n=a.map((i,o)=>({id:i,want:t.get(i)??o*100,index:o}));n.sort((i,o)=>i.want-o.want||i.index-o.index);let r=0;for(const i of n){const o=e.get(i.id);o&&(o.y=r,r+=o.spec.height+s)}return{height:Math.max(0,r-s)}},Us=(a,e,t,s,n)=>{const r=[...a.keys()].sort((l,c)=>l-c),i=new Map;for(const l of r)i.set(l,it(a.get(l)??[],e,new Map,n.nodeSpacing).height);const o=Math.max(0,...i.values());for(const l of r){const c=(o-(i.get(l)??0))/2;for(const m of a.get(l)??[]){const p=e.get(m);p&&(p.y+=c)}}const d=(l,c)=>{const m=(t.get(l)??[]).filter(p=>s.get(p)===c).flatMap(p=>{const k=e.get(p);return k?[k.y+k.spec.height/2]:[]});return m.length>0?ge(m):null};for(let l=0;l<n.coordinatePasses;l++){const c=l%2===0;for(const m of c?r:[...r].reverse()){const p=a.get(m)??[],k=new Map;for(const w of p){const D=d(w,m+(c?-1:1)),I=e.get(w);I!==void 0&&k.set(w,D===null?I.y+I.spec.height/2:D)}const x=p.map(w=>e.get(w)?.y??0);it(p,e,k,n.nodeSpacing);const v=p.map(w=>e.get(w)?.y??0),y=ge(x)-ge(v);for(const w of p){const D=e.get(w);D&&(D.y+=y)}}}},ot=(a,e,t)=>{const s=e===void 0?void 0:a.spec.ports?.[e];return s?{x:a.x+s.x,y:a.y+s.y}:t==="out"?{x:a.x+a.spec.width,y:a.y+a.spec.height/2}:{x:a.x,y:a.y+a.spec.height/2}},dt=(a,e,t)=>{let s=0;const n=[];for(const r of a){const i=t.byId.get(r.from),o=t.byId.get(r.to);if(!i||!o)continue;const d=ot(i,r.fromPort,"out"),l=ot(o,r.toPort,"in");if(r.from===r.to){const x=i.x+i.spec.width,v=i.y+i.spec.height,y=Math.max(t.padding/2,v+18);n.push({id:r.id,points:[d,{x:x+20,y:d.y},{x:x+20,y},{x:i.x-20,y},{x:i.x-20,y:l.y},l]});continue}if(!e.has(r.id)&&(i.layer<o.layer||i.layer===o.layer&&l.x>d.x+12)){if(Math.abs(d.y-l.y)<.5){n.push({id:r.id,points:[d,l]});continue}const v=i.layer<o.layer?Math.max(d.x+14,o.x-Math.max(12,t.layerSpacing/2)):(d.x+l.x)/2;n.push({id:r.id,points:[d,{x:v,y:d.y},{x:v,y:l.y},l]});continue}const c=r.fromPort===void 0?{x:i.x+i.spec.width/2,y:i.y+i.spec.height}:d,m=r.toPort===void 0?{x:o.x+o.spec.width/2,y:o.y+o.spec.height}:l,p=Math.max(c.y,m.y)+18+s*14;s+=1;const k=[d,c,{x:c.x,y:p},{x:m.x,y:p},m,l].filter((x,v,y)=>v===0||x.x!==y[v-1]?.x||x.y!==y[v-1]?.y);n.push({id:r.id,points:k})}return n},lt=(a,e,t)=>{const s=e.flatMap(p=>[...p.points]),n=[...a.map(p=>p.x),...a.map(p=>p.x+p.spec.width),...s.map(p=>p.x)],r=[...a.map(p=>p.y),...a.map(p=>p.y+p.spec.height),...s.map(p=>p.y)],i=Math.min(0,...n),o=Math.min(0,...r),d=Math.max(0,...n),l=Math.max(0,...r),c=t-i,m=t-o;return{width:d-i+t*2,height:l-o+t*2,nodes:a.map(p=>({id:p.spec.id,x:p.x+c,y:p.y+m,width:p.spec.width,height:p.spec.height,layer:p.layer,order:p.order})),routes:e.map(p=>({id:p.id,points:p.points.map(k=>({x:k.x+c,y:k.y+m}))}))}},ct=(a,e)=>{const t=new Map(a.map(s=>[s.id,[]]));for(const s of e)s.from!==s.to&&(t.get(s.from)?.push(s.to),t.get(s.to)?.push(s.from));return t},pt=(a,e,t,s)=>a.map(n=>({spec:n,layer:e.get(n.id)??0,order:t.get(n.id)??0,...s(n)})),Hs=(a,e)=>{const t=new Map;for(const s of a){const n=e.get(s.id)??0,r=t.get(n);r?r.push(s.id):t.set(n,[s.id])}return t},_s=(a,e,t={})=>{const s={...rt,...t};if(a.length===0)return{width:0,height:0,nodes:[],routes:[]};const n=new Set(a.map(v=>v.id)),r=e.filter(v=>n.has(v.from)&&n.has(v.to)),{forward:i,reversed:o}=js(a,r),d=Fs(a,i),l=Hs(a,d);Ns(l,ct(a,r),d,s.sweeps);const c=new Map;for(const v of l.values())v.forEach((y,w)=>c.set(y,w));const m=pt(a,d,c,()=>({x:0,y:0})),p=new Map(m.map(v=>[v.spec.id,v]));Us(l,p,ct(a,r),d,s);const k=[...l.keys()].sort((v,y)=>v-y);let x=0;for(const v of k){const y=Math.max(...(l.get(v)??[]).map(w=>p.get(w)?.spec.width??0));for(const w of l.get(v)??[]){const D=p.get(w);D&&(D.x=x)}x+=y+s.layerSpacing}return lt(m,dt(r,o,{byId:p,layerSpacing:s.layerSpacing,padding:s.padding}),s.padding)},Bs=(a,e,t={})=>{const s={...rt,...t};if(a.length===0)return{width:0,height:0,nodes:[],routes:[]};const n=new Set(a.map(d=>d.id)),r=e.filter(d=>n.has(d.from)&&n.has(d.to)),i=pt(a,new Map,new Map,d=>d.position??{x:0,y:0}),o=new Map(i.map(d=>[d.spec.id,d]));return lt(i,dt(r,new Set,{byId:o,layerSpacing:s.layerSpacing,padding:s.padding}),s.padding)},Gs=_({en:{tagFilter:"Filter by tag",tagMatch:"Tag matching",clearTags:"Clear",zoomOut:"Zoom out",fit:"Fit to view",zoomIn:"Zoom in",sendFailed:"Could not send. Please try again.",commentOn:a=>`Comment on ${a}`,noMatches:"No matching elements.",maximize:"Maximize",restore:"Restore size",canvas:"Diagram. Arrow keys pan, plus and minus zoom, 0 fits the view.",dataError:"Could not load the diagram data.",nodes:"elements",edges:"relations",change:(a,e)=>`\u201C${a}\u201D \u2192 \u201C${e}\u201D`},ja:{tagFilter:"\u30BF\u30B0\u306E\u7D5E\u308A\u8FBC\u307F",tagMatch:"\u30BF\u30B0\u306E\u4E00\u81F4\u6761\u4EF6",clearTags:"\u89E3\u9664",zoomOut:"\u7E2E\u5C0F",fit:"\u5168\u4F53\u3092\u8868\u793A",zoomIn:"\u62E1\u5927",sendFailed:"\u9001\u4FE1\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002\u3082\u3046\u4E00\u5EA6\u304A\u8A66\u3057\u304F\u3060\u3055\u3044\u3002",commentOn:a=>`${a}\u306B\u30B3\u30E1\u30F3\u30C8`,noMatches:"\u8A72\u5F53\u3059\u308B\u8981\u7D20\u306F\u3042\u308A\u307E\u305B\u3093\u3002",maximize:"\u6700\u5927\u5316",restore:"\u5143\u306E\u30B5\u30A4\u30BA\u306B\u623B\u3059",canvas:"\u56F3\u3002\u77E2\u5370\u30AD\u30FC\u3067\u30D1\u30F3\u3001\u30D7\u30E9\u30B9\u30FB\u30DE\u30A4\u30CA\u30B9\u3067\u30BA\u30FC\u30E0\u30010\u3067\u5168\u4F53\u8868\u793A\u3002",dataError:"\u56F3\u306E\u30C7\u30FC\u30BF\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F\u3002",nodes:"\u8981\u7D20",edges:"\u95A2\u9023",change:(a,e)=>`\u300C${a}\u300D\u2192\u300C${e}\u300D`}}),Ys={active:[],match:"single"},Q=(a,e)=>e.active.length===0?!0:e.match==="all"?e.active.every(t=>a.includes(t)):e.active.some(t=>a.includes(t)),Vs=(a,e)=>a.active.includes(e)?{...a,active:a.active.filter(t=>t!==e)}:a.match==="single"?{...a,active:[e]}:{...a,active:[...a.active,e]},Ws=(a,e)=>({match:e,active:e==="single"&&a.active.length>1?a.active.slice(-1):a.active}),Ks=a=>({...a,active:[]}),Xs=a=>{const e=new Map;for(const t of a)for(const s of new Set(t))e.set(s,(e.get(s)??0)+1);return[...e].map(([t,s])=>({tag:t,count:s}))},Y={nodes:new Map,edges:new Set},N=(a,e,t,s)=>{const n=new Map,r=new Set,i=[{id:e,depth:0}],o=new Set([e]);for(const d of i)if(!(!s&&d.depth>=1))for(const l of a){const c=t==="outgoing"?l.from:l.to,m=t==="outgoing"?l.to:l.from;c===d.id&&(r.add(l.id),!o.has(m)&&(o.add(m),n.set(m,d.depth+1),i.push({id:m,depth:d.depth+1})))}return{nodes:n,edges:r}},Js=(a,e)=>{const t=new Map(a.map(r=>[r,N(e,r,"outgoing",!0).nodes])),s=new Set,n=[];for(const r of a){if(s.has(r))continue;const i=a.filter(o=>o===r||t.get(r)?.has(o)===!0&&t.get(o)?.has(r)===!0);for(const o of i)s.add(o);(i.length>1||e.some(o=>o.from===r&&o.to===r))&&n.push(i)}return n},Ce=a=>new Map(a.flatMap((e,t)=>e.map(s=>[s,t]))),ht=(a,e)=>e.get(a.from)===e.get(a.to)&&e.has(a.from),ut=a=>{try{return a.split("/").map(e=>decodeURIComponent(e))}catch{return null}},mt=(a,e,t,s)=>{const n=e!==null&&e.kind===t&&e.id===a,r=t==="node"?s.nodes.has(a):s.edges.has(a),i=t==="node"?s.nodes.get(a)??null:null;return{selected:n,related:r&&!n,dimmed:e!==null&&!n&&!r,depth:i}},ee=(...a)=>a.filter(e=>typeof e=="string"&&e!=="").join(" "),Zs=a=>{const e=a[0]??{x:0,y:0},t=a.at(-1)??e;if(a.length<=2)return{x:(e.x+t.x)/2,y:(e.y+t.y)/2};if(a.length===4){const r=a[1]??e,i=a[2]??t;return{x:r.x,y:(r.y+i.y)/2}}const s=a[2]??e,n=a[3]??t;return{x:(s.x+n.x)/2,y:s.y}},Qs=(a,e)=>Xs(a).map(t=>({tag:t.tag,count:t.count,selected:e.active.includes(t.tag)})),ea=(a,e,t)=>`${a} ${t.node} \xB7 ${e} ${t.edge}`,W=[_e,Be,Ge,B`
2
2
  :host {
3
3
  display: block;
4
4
  container-type: inline-size;
@@ -1,4 +1,4 @@
1
- import{ak as Ft,ac as F,aw as xe,ad as f,af as m,am as ee,ag as S,ah as z,ai as B,aV as te,aj as oe,at as Ae,ab as Bt,ae as Fe,ay as q,p as g,aq as E,v as Be,av as Ht,P as He,e as Wt,a0 as Kt,V as I,l as We,a3 as b,a5 as qt,a4 as h,a6 as v,A as Ut,K as Zt,aB as Vt,a2 as Xt,T as Ke,a1 as Gt,h as Yt}from"./shared-BQFDKhM1.js";import{P as jt,r as Jt,p as Qt,c as eo}from"./shared-Bd9pmv5a.js";import{c as ye}from"./shared-ml5h7U5L.js";const ne=["yellow","orange","pink","purple","blue","green","gray"],qe=["rect","ellipse"],to=["sticky","text","shape","frame"],ie=["small","medium","large","xlarge"],re="medium",Ue=["arrow","line"],U=["straight","elbow","curve"],Z=24,C={sticky:{w:160,h:160},text:{w:240,h:48},shape:{w:180,h:110},frame:{w:640,h:420}},H={sticky:"yellow",shape:"blue",frame:"gray"},Ze=z(oe(),te()),R=z(oe(),te(),Ae(Z)),ke=S(ne),ge=f(S(ie),re),ae={id:xe,x:Ze,y:Ze},oo=F({...ae,kind:ee("sticky"),w:f(R,C.sticky.w),h:f(R,C.sticky.h),text:f(m(),""),color:f(ke,H.sticky),fontSize:ge}),no=F({...ae,kind:ee("text"),w:f(R,C.text.w),h:f(R,C.text.h),text:f(m(),""),fontSize:ge}),io=F({...ae,kind:ee("shape"),shape:f(S(qe),"rect"),w:f(R,C.shape.w),h:f(R,C.shape.h),text:f(m(),""),color:f(ke,H.shape),fontSize:ge}),ro=F({...ae,kind:ee("frame"),w:R,h:R,title:z(m(),B(1)),color:f(ke,H.frame)}),Ve=Ft("kind",[oo,no,io,ro]),ao=F({id:xe,from:z(m(),B(1)),to:z(m(),B(1)),label:q(m()),style:f(S(Ue),"arrow"),route:f(S(U),"straight")}),Xe=F({title:q(m()),items:f(Fe(Ve),[]),connectors:f(Fe(ao),[])}),Ge=t=>{const e=Bt(Xe,t),o=new Set;for(const{id:i}of[...e.items,...e.connectors]){if(o.has(i))throw new Error(`duplicate id "${i}" (items and connectors share one id space)`);o.add(i)}const n=new Set(e.items.map(i=>i.id));for(const i of e.connectors){if(!n.has(i.from))throw new Error(`unknown item "${i.from}" in connector "${i.id}"`);if(!n.has(i.to))throw new Error(`unknown item "${i.to}" in connector "${i.id}"`);if(i.from===i.to)throw new Error(`connector "${i.id}" connects an item to itself`)}return e},Ye=()=>({items:[],connectors:[]}),p=(t,e)=>{if(e!==void 0)return t.items.find(o=>o.id===e)},k=(t,e)=>{if(e!==void 0)return t.connectors.find(o=>o.id===e)},je=t=>[...t.items.map(e=>e.id),...t.connectors.map(e=>e.id)],L=t=>t.kind==="frame"?t.title:t.text,ve=t=>t.kind!=="text",V=t=>t.kind!=="frame",se=t=>t.w*t.h,so=(t,e,o)=>e>=t.x&&e<=t.x+t.w&&o>=t.y&&o<=t.y+t.h,P=(t,e)=>{const o=e.x+e.w/2,n=e.y+e.h/2;let i;for(const r of t.items)r.kind!=="frame"||r.id===e.id||e.kind==="frame"&&se(r)<=se(e)||so(r,o,n)&&(i===void 0||se(r)<se(i))&&(i=r);return i},$e=(t,e)=>{const o=[],n=i=>{let r=P(t,i);for(;r!==void 0;){if(r.id===e.id)return!0;r=P(t,r)}return!1};for(const i of t.items)i.id!==e.id&&n(i)&&o.push(i);return o},Je=z(oe(),te()),Qe=z(oe(),te(),Ae(Z)),Ee={type:"page",id:"whiteboard"},de={ADD_ITEM:g("ADD_ITEM","page",Ve,{dedupeKey:Be}),SET_ITEM_TEXT:g("SET_ITEM_TEXT","item",E({text:m()})),MOVE_ITEM:g("MOVE_ITEM","item",E({x:Je,y:Je})),RESIZE_ITEM:g("RESIZE_ITEM","item",E({w:Qe,h:Qe})),SET_ITEM_COLOR:g("SET_ITEM_COLOR","item",E({color:S(ne)})),SET_ITEM_FONT_SIZE:g("SET_ITEM_FONT_SIZE","item",E({fontSize:S(ie)})),REORDER_ITEM:g("REORDER_ITEM","item",E({after:Ht(z(m(),B(1)))})),DELETE_ITEM:g("DELETE_ITEM","item",E({})),CONNECT_ITEMS:g("CONNECT_ITEMS","page",E({id:xe,from:z(m(),B(1)),to:z(m(),B(1)),label:q(m()),style:q(S(Ue)),route:q(S(U))}),{dedupeKey:Be}),SET_CONNECTOR_LABEL:g("SET_CONNECTOR_LABEL","connector",E({label:m()})),SET_CONNECTOR_ROUTE:g("SET_CONNECTOR_ROUTE","connector",E({route:S(U)})),DELETE_CONNECTOR:g("DELETE_CONNECTOR","connector",E({}))},A=t=>({type:"item",id:t}),w={addItem:t=>({type:"ADD_ITEM",target:Ee,payload:t}),setText:(t,e)=>({type:"SET_ITEM_TEXT",target:A(t),payload:{text:e}}),move:(t,e,o)=>({type:"MOVE_ITEM",target:A(t),payload:{x:e,y:o}}),resize:(t,e,o)=>({type:"RESIZE_ITEM",target:A(t),payload:{w:e,h:o}}),setColor:(t,e)=>({type:"SET_ITEM_COLOR",target:A(t),payload:{color:e}}),setFontSize:(t,e)=>({type:"SET_ITEM_FONT_SIZE",target:A(t),payload:{fontSize:e}}),reorder:(t,e)=>({type:"REORDER_ITEM",target:A(t),payload:{after:e}}),deleteItem:t=>({type:"DELETE_ITEM",target:A(t),payload:{}}),connect:(t,e,o,n)=>({type:"CONNECT_ITEMS",target:Ee,payload:{id:t,from:e,to:o,...n===void 0?{}:{label:n}}}),setConnectorLabel:(t,e)=>({type:"SET_CONNECTOR_LABEL",target:{type:"connector",id:t},payload:{label:e}}),setConnectorRoute:(t,e)=>({type:"SET_CONNECTOR_ROUTE",target:{type:"connector",id:t},payload:{route:e}}),deleteConnector:t=>({type:"DELETE_CONNECTOR",target:{type:"connector",id:t},payload:{}})},et=(t,e)=>{const o=He(de,e);if(o===null)return null;const n=o.target.id;switch(o.type){case"ADD_ITEM":{const i=o.payload,r=t.items.find(a=>a.id===i.id);return r!==void 0?r.kind===i.kind?t:null:t.connectors.some(a=>a.id===i.id)?null:{...t,items:[...t.items,i]}}case"SET_ITEM_TEXT":return X(t,n,i=>i.kind==="frame"?o.payload.text.trim()===""?null:{...i,title:o.payload.text}:{...i,text:o.payload.text});case"MOVE_ITEM":return X(t,n,i=>({...i,x:o.payload.x,y:o.payload.y}));case"RESIZE_ITEM":return X(t,n,i=>({...i,w:o.payload.w,h:o.payload.h}));case"SET_ITEM_COLOR":return X(t,n,i=>i.kind==="text"?null:{...i,color:o.payload.color});case"SET_ITEM_FONT_SIZE":return X(t,n,i=>i.kind==="frame"?null:{...i,fontSize:o.payload.fontSize});case"REORDER_ITEM":return co(t,n,o.payload.after);case"DELETE_ITEM":return t.items.some(i=>i.id===n)?{...t,items:t.items.filter(i=>i.id!==n),connectors:t.connectors.filter(i=>i.from!==n&&i.to!==n)}:null;case"CONNECT_ITEMS":{const i=o.payload;if(t.connectors.some(a=>a.id===i.id))return t;if(t.items.some(a=>a.id===i.id)||i.from===i.to||!t.items.some(a=>a.id===i.from)||!t.items.some(a=>a.id===i.to))return null;const r={id:i.id,from:i.from,to:i.to,style:i.style??"arrow",route:i.route??"straight",...i.label===void 0||i.label===""?{}:{label:i.label}};return{...t,connectors:[...t.connectors,r]}}case"SET_CONNECTOR_LABEL":return tt(t,n,i=>{const{label:r,...a}=i;return o.payload.label===""?a:{...a,label:o.payload.label}});case"SET_CONNECTOR_ROUTE":return tt(t,n,i=>({...i,route:o.payload.route}));case"DELETE_CONNECTOR":return t.connectors.some(i=>i.id===n)?{...t,connectors:t.connectors.filter(i=>i.id!==n)}:null;default:return Wt(o)}},X=(t,e,o)=>{const n=t.items.find(r=>r.id===e);if(n===void 0)return null;const i=o(n);return i===null?null:{...t,items:t.items.map(r=>r.id===e?i:r)}},co=(t,e,o)=>{const n=t.items.find(a=>a.id===e);if(n===void 0||o===e)return null;const i=t.items.filter(a=>a.id!==e),r=o===null?0:i.findIndex(a=>a.id===o)+1;return r===0&&o!==null?null:{...t,items:[...i.slice(0,r),n,...i.slice(r)]}},tt=(t,e,o)=>{const n=t.connectors.find(r=>r.id===e);if(n===void 0)return null;const i=o(n);return{...t,connectors:t.connectors.map(r=>r.id===e?i:r)}},G=t=>{if(t.length===0)return null;const e=Math.min(...t.map(r=>r.x)),o=Math.min(...t.map(r=>r.y)),n=Math.max(...t.map(r=>r.x+r.w)),i=Math.max(...t.map(r=>r.y+r.h));return{x:e,y:o,w:n-e,h:i-o}},Te=t=>[...t.items.filter(e=>e.kind==="frame"),...t.items.filter(e=>e.kind!=="frame")],lo=t=>t.kind==="shape"&&t.shape==="ellipse",Y=(t,e)=>{const o=t.x+t.w/2,n=t.y+t.h/2,i=e.x-o,r=e.y-n;if(i===0&&r===0)return{x:o,y:n};const a=t.w/2,d=t.h/2,s=lo(t)?1/Math.sqrt((i/a)**2+(r/d)**2):Math.min(i===0?1/0:a/Math.abs(i),r===0?1/0:d/Math.abs(r));return{x:o+i*s,y:n+r*s}},W=t=>({x:t.x+t.w/2,y:t.y+t.h/2}),ot=(t,e)=>{const o=Y(t,W(e)),n=Y(e,W(t));return{start:o,end:n,mid:{x:(o.x+n.x)/2,y:(o.y+n.y)/2}}},M=t=>`${t.x} ${t.y}`,ce=(t,e,o)=>{if(o==="straight"){const{start:_,end:J,mid:Q}=ot(t,e);return{d:`M ${M(_)} L ${M(J)}`,mid:Q}}const n=W(t),i=W(e),r=Math.abs(i.x-n.x)>=Math.abs(i.y-n.y),a=r?i.x>=n.x:i.y>=n.y,d=(_,J)=>{const Q=W(_);return r?{x:J?_.x+_.w:_.x,y:Q.y}:{x:Q.x,y:J?_.y+_.h:_.y}},s=d(t,a),c=d(e,!a),l={x:(s.x+c.x)/2,y:(s.y+c.y)/2},x=r?{x:l.x,y:s.y}:{x:s.x,y:l.y},u=r?{x:l.x,y:c.y}:{x:c.x,y:l.y};return{d:o==="elbow"?`M ${M(s)} L ${M(x)} L ${M(u)} L ${M(c)}`:`M ${M(s)} C ${M(x)} ${M(u)} ${M(c)}`,mid:l}},Se=(t,e)=>e.x>=t.x&&e.x<=t.x+t.w&&e.y>=t.y&&e.y<=t.y+t.h,ho=(t,e)=>e>.5?{w:t.w,h:Math.ceil(t.h+e)}:void 0,po=(t,e)=>t.items.filter(o=>o.kind==="frame"&&Se(o,e)).sort((o,n)=>o.w*o.h-n.w*n.h),ze=(t,e,o)=>{const n=Te(t);for(let r=n.length-1;r>=0;r-=1){const a=n[r];if(!(a===void 0||a.id===o||a.kind==="frame")&&Se(a,e))return a}let i;for(const r of n)r.kind!=="frame"||r.id===o||!Se(r,e)||(i===void 0||r.w*r.h<i.w*i.h)&&(i=r);return i},uo=(t,e)=>({x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),w:Math.abs(t.x-e.x),h:Math.abs(t.y-e.y)}),bo=(t,e)=>e.x>=t.x&&e.y>=t.y&&e.x+e.w<=t.x+t.w&&e.y+e.h<=t.y+t.h,fo=(t,e)=>t.items.filter(o=>o.kind==="frame"?bo(e,o):le(e,o,0)),le=(t,e,o)=>t.x<e.x+e.w+o&&e.x<t.x+t.w+o&&t.y<e.y+e.h+o&&e.y<t.y+t.h+o,mo=(t,e,o=!1,n=16,i=6)=>{const r=o?t.items:t.items.filter(c=>c.kind!=="frame"),a=c=>!r.some(l=>le(c,l,n));if(a(e))return{x:e.x,y:e.y};const d=e.w+n,s=e.h+n;for(let c=1;c<=i;c+=1){const l=[];for(let u=-c;u<=c;u+=1)for(let y=-c;y<=c;y+=1)Math.max(Math.abs(y),Math.abs(u))===c&&l.push({x:e.x+y*d,y:e.y+u*s});l.sort((u,y)=>Math.hypot(u.x-e.x,u.y-e.y)-Math.hypot(y.x-e.x,y.y-e.y));const x=l.find(u=>a({...e,...u}));if(x!==void 0)return x}return{x:e.x,y:e.y}},wo={sticky:"Sticky note",text:"Text",shape:"Shape",frame:"Frame"},O={sticky:"\u4ED8\u7B8B",text:"\u30C6\u30AD\u30B9\u30C8",shape:"\u56F3\u5F62",frame:"\u30D5\u30EC\u30FC\u30E0"},N={sticky:"sticky note",text:"text box",shape:"shape",frame:"frame"},xo={rect:"Rectangle",ellipse:"Ellipse"},yo={rect:"\u56DB\u89D2\u5F62",ellipse:"\u6955\u5186"},ko={yellow:"Yellow",orange:"Orange",pink:"Pink",purple:"Purple",blue:"Blue",green:"Green",gray:"Gray"},go={yellow:"\u9EC4",orange:"\u30AA\u30EC\u30F3\u30B8",pink:"\u30D4\u30F3\u30AF",purple:"\u7D2B",blue:"\u9752",green:"\u7DD1",gray:"\u30B0\u30EC\u30FC"},vo={small:"Small",medium:"Medium",large:"Large",xlarge:"Extra large"},$o={small:"\u5C0F",medium:"\u4E2D",large:"\u5927",xlarge:"\u7279\u5927"},Eo={straight:"Straight",elbow:"Elbow",curve:"Curved"},To={straight:"\u76F4\u7DDA",elbow:"\u30AB\u30AE\u7DDA",curve:"\u66F2\u7DDA"},nt={small:"S",medium:"M",large:"L",xlarge:"XL"},he=Kt({en:{kindLabel:t=>wo[t],shapeLabel:t=>xo[t],colorLabel:t=>ko[t],fontSizeLabel:t=>vo[t],fontSizeShort:t=>nt[t],routeLabel:t=>Eo[t],connector:"Connector",board:"Board",wholeBoard:"Whole board",canvasLabel:"Whiteboard canvas",emptyHint:"Double-click anywhere to add a sticky note, or pick something from the toolbar.",toolsLabel:"Add to the board",addSticky:"Sticky note",addText:"Text",addRect:"Rectangle",addEllipse:"Ellipse",addFrame:"Frame",newFrameTitle:"New frame",textPlaceholder:"Type something",selectionLabel:"Selected item",selectionCount:t=>`${t} items selected`,editText:"Edit text",renameFrame:"Rename frame",comment:"Comment",delete:"Delete",colorLabelPrefix:"Color",fontSizeLabelPrefix:"Text size",arrangeLabel:"Stacking order",bringToFront:"Bring to front",bringForward:"Bring forward",sendBackward:"Send backward",sendToBack:"Send to back",routeLabelPrefix:"Line",labelField:"Connector label",labelPlaceholder:"Add a label",resizeHandle:"Resize",connectHandle:"Drag to connect",commentCount:t=>`${t} comment${t===1?"":"s"}`,zoomIn:"Zoom in",zoomOut:"Zoom out",zoomFit:"Fit the board",zoomReset:"Reset to 100%",framesHeading:"Frames",framesHint:"Pick a frame to bring it into view.",memberCount:t=>`${t} item${t===1?"":"s"}`,addedTitle:t=>`Added a ${N[t]}`,textEditedTitle:t=>t==="frame"?"Renamed the frame":`Edited the ${N[t]}`,movedTitle:t=>`Moved the ${N[t]}`,resizedTitle:t=>`Resized the ${N[t]}`,recoloredTitle:t=>`Changed the color of the ${N[t]}`,resizedTextTitle:t=>`Changed the text size of the ${N[t]}`,restackedTitle:t=>`Changed the stacking order of the ${N[t]}`,deletedTitle:t=>`Deleted the ${N[t]}`,connectedTitle:"Connected two items",relabeledTitle:"Relabeled the connector",reroutedTitle:"Changed the connector line",disconnectedTitle:"Removed the connector",arrowTo:t=>`\u2192 \u201C${t}\u201D`,arrowFrom:(t,e)=>`\u201C${t}\u201D \u2192 \u201C${e}\u201D`,plain:(t,e)=>`${t} \u2192 ${e}`,added:t=>`+ \u201C${t}\u201D`,deleted:t=>`\u2212 \u201C${t}\u201D`,inFrame:t=>`in frame \u201C${t}\u201D`,intoFrame:t=>`into frame \u201C${t}\u201D`,outOfFrame:t=>`out of frame \u201C${t}\u201D`,betweenFrames:(t,e)=>`frame \u201C${t}\u201D \u2192 frame \u201C${e}\u201D`,position:(t,e)=>`(${t}, ${e})`,size:(t,e)=>`${t}\xD7${e}`,connection:(t,e)=>`\u201C${t}\u201D \u2192 \u201C${e}\u201D`,labeled:t=>`labeled \u201C${t}\u201D`,inFrontOf:t=>`in front of \u201C${t}\u201D`,toBack:"to the very back",empty:"(empty)",noLabel:"(no label)"},ja:{kindLabel:t=>O[t],shapeLabel:t=>yo[t],colorLabel:t=>go[t],fontSizeLabel:t=>$o[t],fontSizeShort:t=>nt[t],routeLabel:t=>To[t],connector:"\u30B3\u30CD\u30AF\u30BF",board:"\u30DC\u30FC\u30C9",wholeBoard:"\u30DC\u30FC\u30C9\u5168\u4F53",canvasLabel:"\u30DB\u30EF\u30A4\u30C8\u30DC\u30FC\u30C9",emptyHint:"\u30C0\u30D6\u30EB\u30AF\u30EA\u30C3\u30AF\u3067\u4ED8\u7B8B\u3092\u7F6E\u304F\u304B\u3001\u30C4\u30FC\u30EB\u30D0\u30FC\u304B\u3089\u8FFD\u52A0\u3057\u307E\u3059\u3002",toolsLabel:"\u30DC\u30FC\u30C9\u306B\u8FFD\u52A0",addSticky:"\u4ED8\u7B8B",addText:"\u30C6\u30AD\u30B9\u30C8",addRect:"\u56DB\u89D2\u5F62",addEllipse:"\u6955\u5186",addFrame:"\u30D5\u30EC\u30FC\u30E0",newFrameTitle:"\u65B0\u3057\u3044\u30D5\u30EC\u30FC\u30E0",textPlaceholder:"\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",selectionLabel:"\u9078\u629E\u4E2D\u306E\u8981\u7D20",selectionCount:t=>`${t} \u4EF6\u3092\u9078\u629E\u4E2D`,editText:"\u30C6\u30AD\u30B9\u30C8\u3092\u7DE8\u96C6",renameFrame:"\u30D5\u30EC\u30FC\u30E0\u540D\u3092\u5909\u66F4",comment:"\u30B3\u30E1\u30F3\u30C8",delete:"\u524A\u9664",colorLabelPrefix:"\u8272",fontSizeLabelPrefix:"\u6587\u5B57\u30B5\u30A4\u30BA",arrangeLabel:"\u91CD\u306A\u308A\u9806",bringToFront:"\u6700\u524D\u9762\u3078",bringForward:"\u524D\u9762\u3078",sendBackward:"\u80CC\u9762\u3078",sendToBack:"\u6700\u80CC\u9762\u3078",routeLabelPrefix:"\u7DDA\u306E\u5F62",labelField:"\u30B3\u30CD\u30AF\u30BF\u306E\u30E9\u30D9\u30EB",labelPlaceholder:"\u30E9\u30D9\u30EB\u3092\u8FFD\u52A0",resizeHandle:"\u30B5\u30A4\u30BA\u3092\u5909\u66F4",connectHandle:"\u30C9\u30E9\u30C3\u30B0\u3057\u3066\u3064\u306A\u3050",commentCount:t=>`\u30B3\u30E1\u30F3\u30C8 ${t} \u4EF6`,zoomIn:"\u62E1\u5927",zoomOut:"\u7E2E\u5C0F",zoomFit:"\u30DC\u30FC\u30C9\u5168\u4F53\u3092\u8868\u793A",zoomReset:"100% \u306B\u623B\u3059",framesHeading:"\u30D5\u30EC\u30FC\u30E0",framesHint:"\u30D5\u30EC\u30FC\u30E0\u3092\u9078\u3076\u3068\u305D\u3053\u3078\u79FB\u52D5\u3057\u307E\u3059\u3002",memberCount:t=>`${t} \u4EF6`,addedTitle:t=>`${O[t]}\u3092\u8FFD\u52A0`,textEditedTitle:t=>t==="frame"?"\u30D5\u30EC\u30FC\u30E0\u540D\u3092\u5909\u66F4":`${O[t]}\u306E\u30C6\u30AD\u30B9\u30C8\u3092\u5909\u66F4`,movedTitle:t=>`${O[t]}\u3092\u79FB\u52D5`,resizedTitle:t=>`${O[t]}\u306E\u30B5\u30A4\u30BA\u3092\u5909\u66F4`,recoloredTitle:t=>`${O[t]}\u306E\u8272\u3092\u5909\u66F4`,resizedTextTitle:t=>`${O[t]}\u306E\u6587\u5B57\u30B5\u30A4\u30BA\u3092\u5909\u66F4`,restackedTitle:t=>`${O[t]}\u306E\u91CD\u306A\u308A\u9806\u3092\u5909\u66F4`,deletedTitle:t=>`${O[t]}\u3092\u524A\u9664`,connectedTitle:"\u8981\u7D20\u3092\u3064\u306A\u3044\u3060",relabeledTitle:"\u30B3\u30CD\u30AF\u30BF\u306E\u30E9\u30D9\u30EB\u3092\u5909\u66F4",reroutedTitle:"\u30B3\u30CD\u30AF\u30BF\u306E\u7DDA\u306E\u5F62\u3092\u5909\u66F4",disconnectedTitle:"\u30B3\u30CD\u30AF\u30BF\u3092\u524A\u9664",arrowTo:t=>`\u2192 \u300C${t}\u300D`,arrowFrom:(t,e)=>`\u300C${t}\u300D\u2192\u300C${e}\u300D`,plain:(t,e)=>`${t} \u2192 ${e}`,added:t=>`+ \u300C${t}\u300D`,deleted:t=>`\u2212 \u300C${t}\u300D`,inFrame:t=>`\u30D5\u30EC\u30FC\u30E0\u300C${t}\u300D\u5185`,intoFrame:t=>`\u30D5\u30EC\u30FC\u30E0\u300C${t}\u300D\u3078`,outOfFrame:t=>`\u30D5\u30EC\u30FC\u30E0\u300C${t}\u300D\u306E\u5916\u3078`,betweenFrames:(t,e)=>`\u30D5\u30EC\u30FC\u30E0\u300C${t}\u300D\u2192\u300C${e}\u300D`,position:(t,e)=>`(${t}, ${e})`,size:(t,e)=>`${t}\xD7${e}`,connection:(t,e)=>`\u300C${t}\u300D\u2192\u300C${e}\u300D`,labeled:t=>`\u30E9\u30D9\u30EB\u300C${t}\u300D`,inFrontOf:t=>`\u300C${t}\u300D\u306E\u524D\u9762\u3078`,toBack:"\u6700\u80CC\u9762\u3078",empty:"\uFF08\u7A7A\uFF09",noLabel:"\uFF08\u30E9\u30D9\u30EB\u306A\u3057\uFF09"}}),pe=t=>t===void 0?[]:[...new Set(t.split(",").filter(e=>e!==""))],it=t=>t.length===0?void 0:t.join(","),rt=(t,e)=>t.includes(e)?t.filter(o=>o!==e):[...t,e],at=40,D=(t,e)=>{const o=e.replace(/\s+/g," ").trim();return o===""?t.empty:o.length>at?`${o.slice(0,at-1)}\u2026`:o},So=(t,e)=>`${e.kind==="shape"?t.shapeLabel(e.shape):t.kindLabel(e.kind)} \xB7 ${D(t,L(e))}`,T=(t,e,o,n)=>{const i=p(e,n)??p(o,n);return i===void 0?n:D(t,L(i))},zo=(t,e,o,n=e)=>`${t.connector} \xB7 ${t.connection(T(t,e,n,o.from),T(t,e,n,o.to))}`,Mo=(t,e,o,n,i)=>{const r=o===void 0?void 0:P(i,o),a=P(e,n),d=t.position(Math.round(n.x),Math.round(n.y));if(r?.id!==a?.id){if(r!==void 0&&a!==void 0)return`${t.betweenFrames(r.title,a.title)} ${d}`;if(a!==void 0)return`${t.intoFrame(a.title)} ${d}`;if(r!==void 0)return`${t.outOfFrame(r.title)} ${d}`}return o===void 0?`\u2192 ${d}`:t.plain(t.position(Math.round(o.x),Math.round(o.y)),d)},_o=(t,e,o,n)=>{const i=e.target.id,r=p(n,i),a=p(o,i)??r,d=a?.kind??"sticky";switch(e.type){case"ADD_ITEM":{const s=p(o,e.payload.id)??e.payload,c=P(o,s),l=t.added(D(t,L(s)));return{title:t.addedTitle(s.kind),tone:"create",body:c===void 0?l:`${l} ${t.inFrame(c.title)}`}}case"SET_ITEM_TEXT":{const s=D(t,e.payload.text);return{title:t.textEditedTitle(d),tone:"update",body:r===void 0?t.arrowTo(s):t.arrowFrom(D(t,L(r)),s)}}case"MOVE_ITEM":{if(a===void 0)return{title:t.movedTitle(d),tone:"move"};const s={...a,x:e.payload.x,y:e.payload.y};return{title:t.movedTitle(d),tone:"move",body:Mo(t,o,r,s,n)}}case"RESIZE_ITEM":{const s=t.size(Math.round(e.payload.w),Math.round(e.payload.h));return{title:t.resizedTitle(d),tone:"update",body:r===void 0?`\u2192 ${s}`:t.plain(t.size(Math.round(r.w),Math.round(r.h)),s)}}case"SET_ITEM_COLOR":{const s=t.colorLabel(e.payload.color);return{title:t.recoloredTitle(d),tone:"update",body:r!==void 0&&ve(r)?t.plain(t.colorLabel(r.color),s):`\u2192 ${s}`}}case"SET_ITEM_FONT_SIZE":{const s=t.fontSizeLabel(e.payload.fontSize);return{title:t.resizedTextTitle(d),tone:"update",body:r!==void 0&&V(r)?t.plain(t.fontSizeLabel(r.fontSize),s):`\u2192 ${s}`}}case"REORDER_ITEM":{const s=e.payload.after;return{title:t.restackedTitle(d),tone:"move",body:s===null?t.toBack:t.inFrontOf(T(t,o,n,s))}}case"DELETE_ITEM":return{title:t.deletedTitle(d),tone:"delete",body:t.deleted(a===void 0?i:D(t,L(a)))};case"CONNECT_ITEMS":{const s=e.payload,c=t.connection(T(t,o,n,s.from),T(t,o,n,s.to));return{title:t.connectedTitle,tone:"create",body:s.label===void 0||s.label===""?c:`${c} \xB7 ${t.labeled(s.label)}`}}case"SET_CONNECTOR_LABEL":{const s=k(n,i)?.label,c=e.payload.label===""?t.noLabel:e.payload.label;return{title:t.relabeledTitle,tone:"update",body:s===void 0?t.arrowTo(c):t.arrowFrom(s,c)}}case"SET_CONNECTOR_ROUTE":{const s=k(n,i)?.route,c=t.routeLabel(e.payload.route);return{title:t.reroutedTitle,tone:"update",body:s===void 0?`\u2192 ${c}`:t.plain(t.routeLabel(s),c)}}case"DELETE_CONNECTOR":{const s=k(n,i)??k(o,i);return{title:t.disconnectedTitle,tone:"delete",...s===void 0?{}:{body:t.connection(T(t,o,n,s.from),T(t,o,n,s.to))}}}}},st=(t,e,o,n=o)=>{let i;try{const r=He(de,e);i=r===null?{title:e.type,tone:"meta"}:_o(t,r,o,n)}catch{i={title:e.type,tone:"meta"}}return{title:i.title,targetLabel:ct(t,o,e.target,n),tone:i.tone,...i.body===void 0?{}:{summary:i.body}}},dt=t=>`${t.type} ${I(t.target)} ${JSON.stringify(t.payload)}`,ct=(t,e,o,n=e)=>{switch(o.type){case"item":{const i=p(e,o.id)??p(n,o.id);return i===void 0?`${o.type} \xB7 ${o.id} (missing)`:So(t,i)}case"connector":{const i=k(e,o.id)??k(n,o.id);return i===void 0?`${t.connector} \xB7 ${o.id} (missing)`:zo(t,e,i,n)}case"page":return`${t.board} \xB7 ${Me(e)}`;default:return`${o.type} \xB7 ${o.id}`}},lt=(t,e)=>{const o=[{value:"page:whiteboard",label:t.wholeBoard,group:t.board}],n=e.items.filter(r=>r.kind==="frame"),i=e.items.filter(r=>r.kind!=="frame");for(const r of[...n,...i]){const a=P(e,r),d=D(t,L(r));o.push({value:I({type:"item",id:r.id}),label:a===void 0?d:`${a.title} \u203A ${d}`,group:t.kindLabel(r.kind)})}for(const r of e.connectors)o.push({value:I({type:"connector",id:r.id}),label:t.connection(T(t,e,e,r.from),T(t,e,e,r.to)),group:t.connector});return o},ht=(t,e,o)=>{const n=pe(o.item),i=n.length===1?n[0]:void 0,r=p(e,i)??p(e,o.frame);if(r!==void 0)return{value:I({type:"item",id:r.id}),label:D(t,L(r)),group:t.kindLabel(r.kind)};const a=k(e,i);return a===void 0?null:{value:I({type:"connector",id:a.id}),label:t.connection(T(t,e,e,a.from),T(t,e,e,a.to)),group:t.connector}},Me=t=>t.title??"Whiteboard",pt=(t,e)=>{const o={...e};p(t,e.frame)?.kind!=="frame"&&delete o.frame;const n=pe(e.item),i=n.filter(d=>p(t,d)!==void 0),r=n.length===1?k(t,n[0]):void 0,a=it(r===void 0?i:[r.id]);return a===void 0?delete o.item:o.item=a,o},ut=(t,e)=>{switch(e.type){case"item":return p(t,e.id)!==void 0;case"connector":return k(t,e.id)!==void 0;case"page":return!0;default:return!1}},bt=t=>{const e=he(t);return{name:"whiteboard",label:"Whiteboard",parseBase:Ge,emptyBase:Ye,actions:de,apply:et,canonicalState:o=>({...o,items:Te(o)}),hasTarget:ut,describe:(o,n,i)=>st(e,o,n,i),serialize:dt,resolveNavigation:pt,navigationHierarchy:["frame","item"],commentTargets:o=>lt(e,o),currentTarget:(o,n)=>ht(e,o,n),title:Me}},ft=["front","forward","backward","back"],mt=t=>t.items.filter(e=>e.kind!=="frame"),wt=(t,e,o,n)=>{const i=t.indexOf(e),r=(n?t.slice(i+1):t.slice(0,i).reverse()).filter(c=>!o.has(c.id)),a=r.find(c=>le(e,c,0))??r[0];if(a===void 0)return t;const d=t.filter(c=>c!==e),s=d.indexOf(a)+(n?1:0);return[...d.slice(0,s),e,...d.slice(s)]},xt=(t,e,o)=>{const n=t.filter(r=>e.has(r.id)),i=t.filter(r=>!e.has(r.id));switch(o){case"front":return[...i,...n];case"back":return[...n,...i];case"forward":return[...n].reverse().reduce((r,a)=>wt(r,a,e,!0),[...t]);case"backward":return n.reduce((r,a)=>wt(r,a,e,!1),[...t])}},Lo=(t,e,o)=>{let n=t.map(r=>r.id);const i=[];return e.forEach((r,a)=>{if(!o.has(r.id))return;const d=e[a-1]?.id??null,s=n.indexOf(r.id);(n[s-1]??null)!==d&&(n=n.filter(c=>c!==r.id),n.splice(d===null?0:n.indexOf(d)+1,0,r.id),i.push(w.reorder(r.id,d)))}),i},Oo=(t,e,o)=>{const n=mt(t),i=new Set(e.filter(r=>n.some(a=>a.id===r)));return i.size===0?[]:Lo(n,xt(n,i,o),i)},Io=(t,e)=>{const o=mt(t),n=new Set(e.filter(a=>o.some(d=>d.id===a))),i=o.flatMap(a=>n.has(a.id)?o.filter(d=>!n.has(d.id)&&le(a,d,0)).map(d=>[a,d]):[]),r=(a,[d,s])=>a.indexOf(d)>a.indexOf(s);return new Set(ft.filter(a=>{const d=xt(o,n,a);return i.some(s=>r(o,s)!==r(d,s))}))},yt=(t,e,o)=>{if(!t.contains(e)||e.nodeType!==Node.TEXT_NODE)return;let n=0;const i=t.ownerDocument.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(let r=i.nextNode();r!==null;r=i.nextNode()){if(r===e)return n+o;n+=r.textContent?.length??0}},Co=(t,e,o)=>{const n=t.getRootNode(),i=t.ownerDocument;if(typeof i.caretPositionFromPoint=="function"){const r=n instanceof ShadowRoot?[n]:[],a=i.caretPositionFromPoint(e,o,{shadowRoots:r});if(a!==null)return yt(t,a.offsetNode,a.offset)}if(typeof i.caretRangeFromPoint=="function"){const r=i.caretRangeFromPoint(e,o);if(r!==null)return yt(t,r.startContainer,r.startOffset)}},Ro=["sticky","text","rect","ellipse","frame"],No=t=>t==="rect"||t==="ellipse"?C.shape:C[t],Do=(t,e,o,n)=>{const{w:i,h:r}=No(o),a={x:Math.round(n.x-i/2),y:Math.round(n.y-r/2)},d=mo(t,{...a,w:i,h:r},o==="frame"),l={id:We(`new-${o==="rect"||o==="ellipse"?"shape":o}`,je(t)),x:d.x,y:d.y,w:i,h:r};switch(o){case"sticky":return{...l,kind:"sticky",text:"",color:H.sticky,fontSize:re};case"text":return{...l,kind:"text",text:"",fontSize:re};case"rect":case"ellipse":return{...l,kind:"shape",shape:o,text:"",color:H.shape,fontSize:re};case"frame":return{...l,kind:"frame",title:e.newFrameTitle,color:H.frame}}},Po=(t,e,o)=>We(`${e}-to-${o}`,je(t)),Ao=(t,e)=>{const o=(t.kind==="frame"?e.replace(/\r?\n/g," "):e).trim();if(!(t.kind==="frame"&&o===""))return o===L(t)?void 0:o},ue=4,_e=(t,e,o,n,i=[e])=>{if(p(t,e)===void 0)return;const r=new Map;for(const a of i.includes(e)?i:[e,...i]){const d=p(t,a);if(d!==void 0)for(const s of d.kind==="frame"?[d,...$e(t,d)]:[d])r.set(s.id,s)}return{kind:"move",pointerId:o,itemId:e,origins:[...r.values()].map(({id:a,x:d,y:s})=>({id:a,x:d,y:s})),start:n,current:n,moved:!1}},Fo=(t,e,o,n)=>{const i=p(t,e);if(i!==void 0)return{kind:"resize",pointerId:o,itemId:e,origin:{w:i.w,h:i.h},start:n,current:n,moved:!1,keepRatio:!1}},Bo=(t,e)=>({kind:"pan",pointerId:t,start:e,last:e,moved:!1}),Ho=(t,e)=>({gesture:{...t,last:e,moved:t.moved||Math.hypot(e.x-t.start.x,e.y-t.start.y)>ue},dx:e.x-t.last.x,dy:e.y-t.last.y}),kt=(t,e,o)=>({kind:"marquee",pointerId:t,base:o,start:e,current:e,moved:!1}),Wo=(t,e,o,n,i)=>{const r=po(t,n).find(d=>e.includes(d.id));return(r===void 0?void 0:_e(t,r.id,o,n,e))??kt(o,n,i)},gt=t=>t?.kind==="marquee"&&t.moved?uo(t.start,t.current):void 0,vt=(t,e)=>{const o=gt(e);if(e.kind!=="marquee"||o===void 0)return[];const n=fo(t,o).map(i=>i.id);return[...new Set([...e.base,...n])]},Ko=(t,e,o)=>({kind:"connect",pointerId:e,fromId:t,start:o,current:o,moved:!1}),Le=(t,e,o,n,i,r=!1)=>{if(e.pointerId!==o)return e;switch(e.kind){case"pan":return e;case"marquee":case"move":{const a=e.moved||Math.hypot(n.x-e.start.x,n.y-e.start.y)*i>ue;return{...e,current:n,moved:a}}case"resize":{const a=e.moved||Math.hypot(n.x-e.start.x,n.y-e.start.y)*i>ue;return{...e,current:n,moved:a,keepRatio:r}}case"connect":{const a=e.moved||Math.hypot(n.x-e.start.x,n.y-e.start.y)*i>ue,d=ze(t,n,e.fromId),{targetId:s,...c}=e;return d===void 0?{...c,current:n,moved:a}:{...c,current:n,moved:a,targetId:d.id}}}},K=t=>Math.round(t),$t=(t,e)=>{if(e===void 0||!e.moved)return t;if(e.kind==="move"){const o=e.current.x-e.start.x,n=e.current.y-e.start.y,i=new Map(e.origins.map(r=>[r.id,r]));return{...t,items:t.items.map(r=>{const a=i.get(r.id);return a===void 0?r:{...r,x:K(a.x+o),y:K(a.y+n)}})}}if(e.kind==="resize"){const o=Et(e);return{...t,items:t.items.map(n=>n.id===e.itemId?{...n,...o}:n)}}return t},Et=t=>{const{origin:e}=t,o=e.w+t.current.x-t.start.x,n=e.h+t.current.y-t.start.y;if(!t.keepRatio)return{w:Math.max(Z,K(o)),h:Math.max(Z,K(n))};const i=Math.max(o/e.w,n/e.h,Z/Math.min(e.w,e.h));return{w:K(e.w*i),h:K(e.h*i)}},qo=(t,e,o,n)=>{const[i]=e;if(i===void 0)return[];const r=_e(t,i,0,{x:0,y:0},e);if(r?.kind!=="move")return[];const a=Tt(t,{...r,current:{x:o,y:n},moved:!0});return a.kind==="dispatch"?a.inputs:[]},Tt=(t,e)=>{switch(e.kind){case"pan":return e.moved?{kind:"none"}:{kind:"click"};case"marquee":{if(e.moved)return{kind:"select",ids:vt(t,e)};const o=ze(t,e.start);return o===void 0?{kind:"click"}:{kind:"click",itemId:o.id}}case"move":{if(!e.moved)return{kind:"click",itemId:e.itemId};const o=$t(t,e),n=e.origins.flatMap(i=>{const r=p(o,i.id);return r===void 0||r.x===i.x&&r.y===i.y?[]:[w.move(i.id,r.x,r.y)]});return n.length===0?{kind:"none"}:{kind:"dispatch",inputs:n}}case"resize":{if(!e.moved)return{kind:"click",itemId:e.itemId};const o=Et(e);return o.w===e.origin.w&&o.h===e.origin.h?{kind:"none"}:{kind:"dispatch",inputs:[w.resize(e.itemId,o.w,o.h)]}}case"connect":return e.moved?e.targetId===void 0?{kind:"none"}:{kind:"connect",from:e.fromId,to:e.targetId}:{kind:"click",itemId:e.fromId}}},Oe=.1,St=2.5,Uo={x:0,y:0,zoom:1},Zo=96,Ie=(t,e)=>({x:(e.x-t.x)/t.zoom,y:(e.y-t.y)/t.zoom}),Ce=(t,e)=>({x:e.x*t.zoom+t.x,y:e.y*t.zoom+t.y}),be=(t,e,o)=>({...t,x:t.x+e,y:t.y+o}),Re=(t,e,o)=>{const n=ye(t.zoom*o,Oe,St),i=Ie(t,e);return{zoom:n,x:e.x-i.x*n,y:e.y-i.y*n}},zt=(t,e,o=48,n=1)=>{const i=Math.max(1,e.width-o*2),r=Math.max(1,e.height-o*2),a=ye(Math.min(i/Math.max(1,t.w),r/Math.max(1,t.h)),Oe,n);return{zoom:a,x:e.width/2-(t.x+t.w/2)*a,y:e.height/2-(t.y+t.h/2)*a}},Mt=(t,e,o)=>{if(e===null||o.width<=0||o.height<=0)return t;const n=(i,r,a,d)=>{const s=Math.min(Zo,d/2),c=s-(r+a)*t.zoom,l=d-s-r*t.zoom;return ye(i,Math.min(c,l),Math.max(c,l))};return{zoom:t.zoom,x:n(t.x,e.x,e.w,o.width),y:n(t.y,e.y,e.h,o.height)}},Vo=(t,e,o,n=24)=>{const i=e.x*t.zoom+t.x,r=e.y*t.zoom+t.y,a=i+e.w*t.zoom,d=r+e.h*t.zoom;return i>=n&&r>=n&&a<=o.width-n&&d<=o.height-n?t:{zoom:t.zoom,x:o.width/2-(e.x+e.w/2)*t.zoom,y:o.height/2-(e.y+e.h/2)*t.zoom}},_t=(t,e,o,n)=>{const i=t+e-(o-n),r=i>0?-i:0;return t+r<n?n-t:r},Xo=(t,e)=>t.x===e.x&&t.y===e.y&&t.zoom===e.zoom,$={kind:"idle"},j=(t,e)=>t.kind==="editing"&&t.itemId===e,Go={yellow:{paper:"#fff0a3",ink:"#4a3a06",stroke:"#d9a900"},orange:{paper:"#ffd1a0",ink:"#4a2503",stroke:"#ec7f1d"},pink:{paper:"#ffc9dd",ink:"#4b1029",stroke:"#de4479"},purple:{paper:"#ddcbf8",ink:"#32195c",stroke:"#8a5bd6"},blue:{paper:"#c0ddf7",ink:"#0e2c4b",stroke:"#3a80d4"},green:{paper:"#cdeba5",ink:"#22380a",stroke:"#55a42c"},gray:{paper:"#e3e6eb",ink:"#2a2f38",stroke:"#868d99"}},Ne=t=>{const{paper:e,ink:o,stroke:n}=Go[t];return`--wb-paper:${e};--wb-ink:${o};--wb-stroke:${n}`},Lt={sticky:"addSticky",text:"addText",rect:"addRect",ellipse:"addEllipse",frame:"addFrame"},Ot={small:.8,medium:1,large:1.4,xlarge:2},Yo=t=>{const e=24*t.zoom;return`background-size:${e}px ${e}px;background-position:${t.x}px ${t.y}px`},jo=t=>{const{m:e,state:o,viewport:n,gesture:i,handlers:r}=t,a=["wb-canvas"];i?.moved===!0&&a.push("wb-canvas--gesturing"),i?.kind==="pan"&&i.moved&&a.push("wb-canvas--panning"),i?.kind==="connect"&&a.push("wb-canvas--connecting"),(t.panReady||i?.kind==="pan")&&a.push("wb-canvas--pan-ready");const d=Te(o);return h`<div
1
+ import{ak as Ft,ac as F,aw as xe,ad as f,af as m,am as ee,ag as S,ah as z,ai as B,aV as te,aj as oe,at as Ae,ab as Bt,ae as Fe,ay as q,p as g,aq as E,v as Be,av as Ht,P as He,e as Wt,a0 as Kt,V as I,l as We,a3 as b,a5 as qt,a4 as h,a6 as v,A as Ut,K as Zt,aB as Vt,a2 as Xt,T as Ke,a1 as Gt,h as Yt}from"./shared-B_MMP97h.js";import{P as jt,r as Jt,p as Qt,c as eo}from"./shared-B4ewpBuM.js";import{c as ye}from"./shared-ml5h7U5L.js";const ne=["yellow","orange","pink","purple","blue","green","gray"],qe=["rect","ellipse"],to=["sticky","text","shape","frame"],ie=["small","medium","large","xlarge"],re="medium",Ue=["arrow","line"],U=["straight","elbow","curve"],Z=24,C={sticky:{w:160,h:160},text:{w:240,h:48},shape:{w:180,h:110},frame:{w:640,h:420}},H={sticky:"yellow",shape:"blue",frame:"gray"},Ze=z(oe(),te()),R=z(oe(),te(),Ae(Z)),ke=S(ne),ge=f(S(ie),re),ae={id:xe,x:Ze,y:Ze},oo=F({...ae,kind:ee("sticky"),w:f(R,C.sticky.w),h:f(R,C.sticky.h),text:f(m(),""),color:f(ke,H.sticky),fontSize:ge}),no=F({...ae,kind:ee("text"),w:f(R,C.text.w),h:f(R,C.text.h),text:f(m(),""),fontSize:ge}),io=F({...ae,kind:ee("shape"),shape:f(S(qe),"rect"),w:f(R,C.shape.w),h:f(R,C.shape.h),text:f(m(),""),color:f(ke,H.shape),fontSize:ge}),ro=F({...ae,kind:ee("frame"),w:R,h:R,title:z(m(),B(1)),color:f(ke,H.frame)}),Ve=Ft("kind",[oo,no,io,ro]),ao=F({id:xe,from:z(m(),B(1)),to:z(m(),B(1)),label:q(m()),style:f(S(Ue),"arrow"),route:f(S(U),"straight")}),Xe=F({title:q(m()),items:f(Fe(Ve),[]),connectors:f(Fe(ao),[])}),Ge=t=>{const e=Bt(Xe,t),o=new Set;for(const{id:i}of[...e.items,...e.connectors]){if(o.has(i))throw new Error(`duplicate id "${i}" (items and connectors share one id space)`);o.add(i)}const n=new Set(e.items.map(i=>i.id));for(const i of e.connectors){if(!n.has(i.from))throw new Error(`unknown item "${i.from}" in connector "${i.id}"`);if(!n.has(i.to))throw new Error(`unknown item "${i.to}" in connector "${i.id}"`);if(i.from===i.to)throw new Error(`connector "${i.id}" connects an item to itself`)}return e},Ye=()=>({items:[],connectors:[]}),p=(t,e)=>{if(e!==void 0)return t.items.find(o=>o.id===e)},k=(t,e)=>{if(e!==void 0)return t.connectors.find(o=>o.id===e)},je=t=>[...t.items.map(e=>e.id),...t.connectors.map(e=>e.id)],L=t=>t.kind==="frame"?t.title:t.text,ve=t=>t.kind!=="text",V=t=>t.kind!=="frame",se=t=>t.w*t.h,so=(t,e,o)=>e>=t.x&&e<=t.x+t.w&&o>=t.y&&o<=t.y+t.h,P=(t,e)=>{const o=e.x+e.w/2,n=e.y+e.h/2;let i;for(const r of t.items)r.kind!=="frame"||r.id===e.id||e.kind==="frame"&&se(r)<=se(e)||so(r,o,n)&&(i===void 0||se(r)<se(i))&&(i=r);return i},$e=(t,e)=>{const o=[],n=i=>{let r=P(t,i);for(;r!==void 0;){if(r.id===e.id)return!0;r=P(t,r)}return!1};for(const i of t.items)i.id!==e.id&&n(i)&&o.push(i);return o},Je=z(oe(),te()),Qe=z(oe(),te(),Ae(Z)),Ee={type:"page",id:"whiteboard"},de={ADD_ITEM:g("ADD_ITEM","page",Ve,{dedupeKey:Be}),SET_ITEM_TEXT:g("SET_ITEM_TEXT","item",E({text:m()})),MOVE_ITEM:g("MOVE_ITEM","item",E({x:Je,y:Je})),RESIZE_ITEM:g("RESIZE_ITEM","item",E({w:Qe,h:Qe})),SET_ITEM_COLOR:g("SET_ITEM_COLOR","item",E({color:S(ne)})),SET_ITEM_FONT_SIZE:g("SET_ITEM_FONT_SIZE","item",E({fontSize:S(ie)})),REORDER_ITEM:g("REORDER_ITEM","item",E({after:Ht(z(m(),B(1)))})),DELETE_ITEM:g("DELETE_ITEM","item",E({})),CONNECT_ITEMS:g("CONNECT_ITEMS","page",E({id:xe,from:z(m(),B(1)),to:z(m(),B(1)),label:q(m()),style:q(S(Ue)),route:q(S(U))}),{dedupeKey:Be}),SET_CONNECTOR_LABEL:g("SET_CONNECTOR_LABEL","connector",E({label:m()})),SET_CONNECTOR_ROUTE:g("SET_CONNECTOR_ROUTE","connector",E({route:S(U)})),DELETE_CONNECTOR:g("DELETE_CONNECTOR","connector",E({}))},A=t=>({type:"item",id:t}),w={addItem:t=>({type:"ADD_ITEM",target:Ee,payload:t}),setText:(t,e)=>({type:"SET_ITEM_TEXT",target:A(t),payload:{text:e}}),move:(t,e,o)=>({type:"MOVE_ITEM",target:A(t),payload:{x:e,y:o}}),resize:(t,e,o)=>({type:"RESIZE_ITEM",target:A(t),payload:{w:e,h:o}}),setColor:(t,e)=>({type:"SET_ITEM_COLOR",target:A(t),payload:{color:e}}),setFontSize:(t,e)=>({type:"SET_ITEM_FONT_SIZE",target:A(t),payload:{fontSize:e}}),reorder:(t,e)=>({type:"REORDER_ITEM",target:A(t),payload:{after:e}}),deleteItem:t=>({type:"DELETE_ITEM",target:A(t),payload:{}}),connect:(t,e,o,n)=>({type:"CONNECT_ITEMS",target:Ee,payload:{id:t,from:e,to:o,...n===void 0?{}:{label:n}}}),setConnectorLabel:(t,e)=>({type:"SET_CONNECTOR_LABEL",target:{type:"connector",id:t},payload:{label:e}}),setConnectorRoute:(t,e)=>({type:"SET_CONNECTOR_ROUTE",target:{type:"connector",id:t},payload:{route:e}}),deleteConnector:t=>({type:"DELETE_CONNECTOR",target:{type:"connector",id:t},payload:{}})},et=(t,e)=>{const o=He(de,e);if(o===null)return null;const n=o.target.id;switch(o.type){case"ADD_ITEM":{const i=o.payload,r=t.items.find(a=>a.id===i.id);return r!==void 0?r.kind===i.kind?t:null:t.connectors.some(a=>a.id===i.id)?null:{...t,items:[...t.items,i]}}case"SET_ITEM_TEXT":return X(t,n,i=>i.kind==="frame"?o.payload.text.trim()===""?null:{...i,title:o.payload.text}:{...i,text:o.payload.text});case"MOVE_ITEM":return X(t,n,i=>({...i,x:o.payload.x,y:o.payload.y}));case"RESIZE_ITEM":return X(t,n,i=>({...i,w:o.payload.w,h:o.payload.h}));case"SET_ITEM_COLOR":return X(t,n,i=>i.kind==="text"?null:{...i,color:o.payload.color});case"SET_ITEM_FONT_SIZE":return X(t,n,i=>i.kind==="frame"?null:{...i,fontSize:o.payload.fontSize});case"REORDER_ITEM":return co(t,n,o.payload.after);case"DELETE_ITEM":return t.items.some(i=>i.id===n)?{...t,items:t.items.filter(i=>i.id!==n),connectors:t.connectors.filter(i=>i.from!==n&&i.to!==n)}:null;case"CONNECT_ITEMS":{const i=o.payload;if(t.connectors.some(a=>a.id===i.id))return t;if(t.items.some(a=>a.id===i.id)||i.from===i.to||!t.items.some(a=>a.id===i.from)||!t.items.some(a=>a.id===i.to))return null;const r={id:i.id,from:i.from,to:i.to,style:i.style??"arrow",route:i.route??"straight",...i.label===void 0||i.label===""?{}:{label:i.label}};return{...t,connectors:[...t.connectors,r]}}case"SET_CONNECTOR_LABEL":return tt(t,n,i=>{const{label:r,...a}=i;return o.payload.label===""?a:{...a,label:o.payload.label}});case"SET_CONNECTOR_ROUTE":return tt(t,n,i=>({...i,route:o.payload.route}));case"DELETE_CONNECTOR":return t.connectors.some(i=>i.id===n)?{...t,connectors:t.connectors.filter(i=>i.id!==n)}:null;default:return Wt(o)}},X=(t,e,o)=>{const n=t.items.find(r=>r.id===e);if(n===void 0)return null;const i=o(n);return i===null?null:{...t,items:t.items.map(r=>r.id===e?i:r)}},co=(t,e,o)=>{const n=t.items.find(a=>a.id===e);if(n===void 0||o===e)return null;const i=t.items.filter(a=>a.id!==e),r=o===null?0:i.findIndex(a=>a.id===o)+1;return r===0&&o!==null?null:{...t,items:[...i.slice(0,r),n,...i.slice(r)]}},tt=(t,e,o)=>{const n=t.connectors.find(r=>r.id===e);if(n===void 0)return null;const i=o(n);return{...t,connectors:t.connectors.map(r=>r.id===e?i:r)}},G=t=>{if(t.length===0)return null;const e=Math.min(...t.map(r=>r.x)),o=Math.min(...t.map(r=>r.y)),n=Math.max(...t.map(r=>r.x+r.w)),i=Math.max(...t.map(r=>r.y+r.h));return{x:e,y:o,w:n-e,h:i-o}},Te=t=>[...t.items.filter(e=>e.kind==="frame"),...t.items.filter(e=>e.kind!=="frame")],lo=t=>t.kind==="shape"&&t.shape==="ellipse",Y=(t,e)=>{const o=t.x+t.w/2,n=t.y+t.h/2,i=e.x-o,r=e.y-n;if(i===0&&r===0)return{x:o,y:n};const a=t.w/2,d=t.h/2,s=lo(t)?1/Math.sqrt((i/a)**2+(r/d)**2):Math.min(i===0?1/0:a/Math.abs(i),r===0?1/0:d/Math.abs(r));return{x:o+i*s,y:n+r*s}},W=t=>({x:t.x+t.w/2,y:t.y+t.h/2}),ot=(t,e)=>{const o=Y(t,W(e)),n=Y(e,W(t));return{start:o,end:n,mid:{x:(o.x+n.x)/2,y:(o.y+n.y)/2}}},M=t=>`${t.x} ${t.y}`,ce=(t,e,o)=>{if(o==="straight"){const{start:_,end:J,mid:Q}=ot(t,e);return{d:`M ${M(_)} L ${M(J)}`,mid:Q}}const n=W(t),i=W(e),r=Math.abs(i.x-n.x)>=Math.abs(i.y-n.y),a=r?i.x>=n.x:i.y>=n.y,d=(_,J)=>{const Q=W(_);return r?{x:J?_.x+_.w:_.x,y:Q.y}:{x:Q.x,y:J?_.y+_.h:_.y}},s=d(t,a),c=d(e,!a),l={x:(s.x+c.x)/2,y:(s.y+c.y)/2},x=r?{x:l.x,y:s.y}:{x:s.x,y:l.y},u=r?{x:l.x,y:c.y}:{x:c.x,y:l.y};return{d:o==="elbow"?`M ${M(s)} L ${M(x)} L ${M(u)} L ${M(c)}`:`M ${M(s)} C ${M(x)} ${M(u)} ${M(c)}`,mid:l}},Se=(t,e)=>e.x>=t.x&&e.x<=t.x+t.w&&e.y>=t.y&&e.y<=t.y+t.h,ho=(t,e)=>e>.5?{w:t.w,h:Math.ceil(t.h+e)}:void 0,po=(t,e)=>t.items.filter(o=>o.kind==="frame"&&Se(o,e)).sort((o,n)=>o.w*o.h-n.w*n.h),ze=(t,e,o)=>{const n=Te(t);for(let r=n.length-1;r>=0;r-=1){const a=n[r];if(!(a===void 0||a.id===o||a.kind==="frame")&&Se(a,e))return a}let i;for(const r of n)r.kind!=="frame"||r.id===o||!Se(r,e)||(i===void 0||r.w*r.h<i.w*i.h)&&(i=r);return i},uo=(t,e)=>({x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),w:Math.abs(t.x-e.x),h:Math.abs(t.y-e.y)}),bo=(t,e)=>e.x>=t.x&&e.y>=t.y&&e.x+e.w<=t.x+t.w&&e.y+e.h<=t.y+t.h,fo=(t,e)=>t.items.filter(o=>o.kind==="frame"?bo(e,o):le(e,o,0)),le=(t,e,o)=>t.x<e.x+e.w+o&&e.x<t.x+t.w+o&&t.y<e.y+e.h+o&&e.y<t.y+t.h+o,mo=(t,e,o=!1,n=16,i=6)=>{const r=o?t.items:t.items.filter(c=>c.kind!=="frame"),a=c=>!r.some(l=>le(c,l,n));if(a(e))return{x:e.x,y:e.y};const d=e.w+n,s=e.h+n;for(let c=1;c<=i;c+=1){const l=[];for(let u=-c;u<=c;u+=1)for(let y=-c;y<=c;y+=1)Math.max(Math.abs(y),Math.abs(u))===c&&l.push({x:e.x+y*d,y:e.y+u*s});l.sort((u,y)=>Math.hypot(u.x-e.x,u.y-e.y)-Math.hypot(y.x-e.x,y.y-e.y));const x=l.find(u=>a({...e,...u}));if(x!==void 0)return x}return{x:e.x,y:e.y}},wo={sticky:"Sticky note",text:"Text",shape:"Shape",frame:"Frame"},O={sticky:"\u4ED8\u7B8B",text:"\u30C6\u30AD\u30B9\u30C8",shape:"\u56F3\u5F62",frame:"\u30D5\u30EC\u30FC\u30E0"},N={sticky:"sticky note",text:"text box",shape:"shape",frame:"frame"},xo={rect:"Rectangle",ellipse:"Ellipse"},yo={rect:"\u56DB\u89D2\u5F62",ellipse:"\u6955\u5186"},ko={yellow:"Yellow",orange:"Orange",pink:"Pink",purple:"Purple",blue:"Blue",green:"Green",gray:"Gray"},go={yellow:"\u9EC4",orange:"\u30AA\u30EC\u30F3\u30B8",pink:"\u30D4\u30F3\u30AF",purple:"\u7D2B",blue:"\u9752",green:"\u7DD1",gray:"\u30B0\u30EC\u30FC"},vo={small:"Small",medium:"Medium",large:"Large",xlarge:"Extra large"},$o={small:"\u5C0F",medium:"\u4E2D",large:"\u5927",xlarge:"\u7279\u5927"},Eo={straight:"Straight",elbow:"Elbow",curve:"Curved"},To={straight:"\u76F4\u7DDA",elbow:"\u30AB\u30AE\u7DDA",curve:"\u66F2\u7DDA"},nt={small:"S",medium:"M",large:"L",xlarge:"XL"},he=Kt({en:{kindLabel:t=>wo[t],shapeLabel:t=>xo[t],colorLabel:t=>ko[t],fontSizeLabel:t=>vo[t],fontSizeShort:t=>nt[t],routeLabel:t=>Eo[t],connector:"Connector",board:"Board",wholeBoard:"Whole board",canvasLabel:"Whiteboard canvas",emptyHint:"Double-click anywhere to add a sticky note, or pick something from the toolbar.",toolsLabel:"Add to the board",addSticky:"Sticky note",addText:"Text",addRect:"Rectangle",addEllipse:"Ellipse",addFrame:"Frame",newFrameTitle:"New frame",textPlaceholder:"Type something",selectionLabel:"Selected item",selectionCount:t=>`${t} items selected`,editText:"Edit text",renameFrame:"Rename frame",comment:"Comment",delete:"Delete",colorLabelPrefix:"Color",fontSizeLabelPrefix:"Text size",arrangeLabel:"Stacking order",bringToFront:"Bring to front",bringForward:"Bring forward",sendBackward:"Send backward",sendToBack:"Send to back",routeLabelPrefix:"Line",labelField:"Connector label",labelPlaceholder:"Add a label",resizeHandle:"Resize",connectHandle:"Drag to connect",commentCount:t=>`${t} comment${t===1?"":"s"}`,zoomIn:"Zoom in",zoomOut:"Zoom out",zoomFit:"Fit the board",zoomReset:"Reset to 100%",framesHeading:"Frames",framesHint:"Pick a frame to bring it into view.",memberCount:t=>`${t} item${t===1?"":"s"}`,addedTitle:t=>`Added a ${N[t]}`,textEditedTitle:t=>t==="frame"?"Renamed the frame":`Edited the ${N[t]}`,movedTitle:t=>`Moved the ${N[t]}`,resizedTitle:t=>`Resized the ${N[t]}`,recoloredTitle:t=>`Changed the color of the ${N[t]}`,resizedTextTitle:t=>`Changed the text size of the ${N[t]}`,restackedTitle:t=>`Changed the stacking order of the ${N[t]}`,deletedTitle:t=>`Deleted the ${N[t]}`,connectedTitle:"Connected two items",relabeledTitle:"Relabeled the connector",reroutedTitle:"Changed the connector line",disconnectedTitle:"Removed the connector",arrowTo:t=>`\u2192 \u201C${t}\u201D`,arrowFrom:(t,e)=>`\u201C${t}\u201D \u2192 \u201C${e}\u201D`,plain:(t,e)=>`${t} \u2192 ${e}`,added:t=>`+ \u201C${t}\u201D`,deleted:t=>`\u2212 \u201C${t}\u201D`,inFrame:t=>`in frame \u201C${t}\u201D`,intoFrame:t=>`into frame \u201C${t}\u201D`,outOfFrame:t=>`out of frame \u201C${t}\u201D`,betweenFrames:(t,e)=>`frame \u201C${t}\u201D \u2192 frame \u201C${e}\u201D`,position:(t,e)=>`(${t}, ${e})`,size:(t,e)=>`${t}\xD7${e}`,connection:(t,e)=>`\u201C${t}\u201D \u2192 \u201C${e}\u201D`,labeled:t=>`labeled \u201C${t}\u201D`,inFrontOf:t=>`in front of \u201C${t}\u201D`,toBack:"to the very back",empty:"(empty)",noLabel:"(no label)"},ja:{kindLabel:t=>O[t],shapeLabel:t=>yo[t],colorLabel:t=>go[t],fontSizeLabel:t=>$o[t],fontSizeShort:t=>nt[t],routeLabel:t=>To[t],connector:"\u30B3\u30CD\u30AF\u30BF",board:"\u30DC\u30FC\u30C9",wholeBoard:"\u30DC\u30FC\u30C9\u5168\u4F53",canvasLabel:"\u30DB\u30EF\u30A4\u30C8\u30DC\u30FC\u30C9",emptyHint:"\u30C0\u30D6\u30EB\u30AF\u30EA\u30C3\u30AF\u3067\u4ED8\u7B8B\u3092\u7F6E\u304F\u304B\u3001\u30C4\u30FC\u30EB\u30D0\u30FC\u304B\u3089\u8FFD\u52A0\u3057\u307E\u3059\u3002",toolsLabel:"\u30DC\u30FC\u30C9\u306B\u8FFD\u52A0",addSticky:"\u4ED8\u7B8B",addText:"\u30C6\u30AD\u30B9\u30C8",addRect:"\u56DB\u89D2\u5F62",addEllipse:"\u6955\u5186",addFrame:"\u30D5\u30EC\u30FC\u30E0",newFrameTitle:"\u65B0\u3057\u3044\u30D5\u30EC\u30FC\u30E0",textPlaceholder:"\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",selectionLabel:"\u9078\u629E\u4E2D\u306E\u8981\u7D20",selectionCount:t=>`${t} \u4EF6\u3092\u9078\u629E\u4E2D`,editText:"\u30C6\u30AD\u30B9\u30C8\u3092\u7DE8\u96C6",renameFrame:"\u30D5\u30EC\u30FC\u30E0\u540D\u3092\u5909\u66F4",comment:"\u30B3\u30E1\u30F3\u30C8",delete:"\u524A\u9664",colorLabelPrefix:"\u8272",fontSizeLabelPrefix:"\u6587\u5B57\u30B5\u30A4\u30BA",arrangeLabel:"\u91CD\u306A\u308A\u9806",bringToFront:"\u6700\u524D\u9762\u3078",bringForward:"\u524D\u9762\u3078",sendBackward:"\u80CC\u9762\u3078",sendToBack:"\u6700\u80CC\u9762\u3078",routeLabelPrefix:"\u7DDA\u306E\u5F62",labelField:"\u30B3\u30CD\u30AF\u30BF\u306E\u30E9\u30D9\u30EB",labelPlaceholder:"\u30E9\u30D9\u30EB\u3092\u8FFD\u52A0",resizeHandle:"\u30B5\u30A4\u30BA\u3092\u5909\u66F4",connectHandle:"\u30C9\u30E9\u30C3\u30B0\u3057\u3066\u3064\u306A\u3050",commentCount:t=>`\u30B3\u30E1\u30F3\u30C8 ${t} \u4EF6`,zoomIn:"\u62E1\u5927",zoomOut:"\u7E2E\u5C0F",zoomFit:"\u30DC\u30FC\u30C9\u5168\u4F53\u3092\u8868\u793A",zoomReset:"100% \u306B\u623B\u3059",framesHeading:"\u30D5\u30EC\u30FC\u30E0",framesHint:"\u30D5\u30EC\u30FC\u30E0\u3092\u9078\u3076\u3068\u305D\u3053\u3078\u79FB\u52D5\u3057\u307E\u3059\u3002",memberCount:t=>`${t} \u4EF6`,addedTitle:t=>`${O[t]}\u3092\u8FFD\u52A0`,textEditedTitle:t=>t==="frame"?"\u30D5\u30EC\u30FC\u30E0\u540D\u3092\u5909\u66F4":`${O[t]}\u306E\u30C6\u30AD\u30B9\u30C8\u3092\u5909\u66F4`,movedTitle:t=>`${O[t]}\u3092\u79FB\u52D5`,resizedTitle:t=>`${O[t]}\u306E\u30B5\u30A4\u30BA\u3092\u5909\u66F4`,recoloredTitle:t=>`${O[t]}\u306E\u8272\u3092\u5909\u66F4`,resizedTextTitle:t=>`${O[t]}\u306E\u6587\u5B57\u30B5\u30A4\u30BA\u3092\u5909\u66F4`,restackedTitle:t=>`${O[t]}\u306E\u91CD\u306A\u308A\u9806\u3092\u5909\u66F4`,deletedTitle:t=>`${O[t]}\u3092\u524A\u9664`,connectedTitle:"\u8981\u7D20\u3092\u3064\u306A\u3044\u3060",relabeledTitle:"\u30B3\u30CD\u30AF\u30BF\u306E\u30E9\u30D9\u30EB\u3092\u5909\u66F4",reroutedTitle:"\u30B3\u30CD\u30AF\u30BF\u306E\u7DDA\u306E\u5F62\u3092\u5909\u66F4",disconnectedTitle:"\u30B3\u30CD\u30AF\u30BF\u3092\u524A\u9664",arrowTo:t=>`\u2192 \u300C${t}\u300D`,arrowFrom:(t,e)=>`\u300C${t}\u300D\u2192\u300C${e}\u300D`,plain:(t,e)=>`${t} \u2192 ${e}`,added:t=>`+ \u300C${t}\u300D`,deleted:t=>`\u2212 \u300C${t}\u300D`,inFrame:t=>`\u30D5\u30EC\u30FC\u30E0\u300C${t}\u300D\u5185`,intoFrame:t=>`\u30D5\u30EC\u30FC\u30E0\u300C${t}\u300D\u3078`,outOfFrame:t=>`\u30D5\u30EC\u30FC\u30E0\u300C${t}\u300D\u306E\u5916\u3078`,betweenFrames:(t,e)=>`\u30D5\u30EC\u30FC\u30E0\u300C${t}\u300D\u2192\u300C${e}\u300D`,position:(t,e)=>`(${t}, ${e})`,size:(t,e)=>`${t}\xD7${e}`,connection:(t,e)=>`\u300C${t}\u300D\u2192\u300C${e}\u300D`,labeled:t=>`\u30E9\u30D9\u30EB\u300C${t}\u300D`,inFrontOf:t=>`\u300C${t}\u300D\u306E\u524D\u9762\u3078`,toBack:"\u6700\u80CC\u9762\u3078",empty:"\uFF08\u7A7A\uFF09",noLabel:"\uFF08\u30E9\u30D9\u30EB\u306A\u3057\uFF09"}}),pe=t=>t===void 0?[]:[...new Set(t.split(",").filter(e=>e!==""))],it=t=>t.length===0?void 0:t.join(","),rt=(t,e)=>t.includes(e)?t.filter(o=>o!==e):[...t,e],at=40,D=(t,e)=>{const o=e.replace(/\s+/g," ").trim();return o===""?t.empty:o.length>at?`${o.slice(0,at-1)}\u2026`:o},So=(t,e)=>`${e.kind==="shape"?t.shapeLabel(e.shape):t.kindLabel(e.kind)} \xB7 ${D(t,L(e))}`,T=(t,e,o,n)=>{const i=p(e,n)??p(o,n);return i===void 0?n:D(t,L(i))},zo=(t,e,o,n=e)=>`${t.connector} \xB7 ${t.connection(T(t,e,n,o.from),T(t,e,n,o.to))}`,Mo=(t,e,o,n,i)=>{const r=o===void 0?void 0:P(i,o),a=P(e,n),d=t.position(Math.round(n.x),Math.round(n.y));if(r?.id!==a?.id){if(r!==void 0&&a!==void 0)return`${t.betweenFrames(r.title,a.title)} ${d}`;if(a!==void 0)return`${t.intoFrame(a.title)} ${d}`;if(r!==void 0)return`${t.outOfFrame(r.title)} ${d}`}return o===void 0?`\u2192 ${d}`:t.plain(t.position(Math.round(o.x),Math.round(o.y)),d)},_o=(t,e,o,n)=>{const i=e.target.id,r=p(n,i),a=p(o,i)??r,d=a?.kind??"sticky";switch(e.type){case"ADD_ITEM":{const s=p(o,e.payload.id)??e.payload,c=P(o,s),l=t.added(D(t,L(s)));return{title:t.addedTitle(s.kind),tone:"create",body:c===void 0?l:`${l} ${t.inFrame(c.title)}`}}case"SET_ITEM_TEXT":{const s=D(t,e.payload.text);return{title:t.textEditedTitle(d),tone:"update",body:r===void 0?t.arrowTo(s):t.arrowFrom(D(t,L(r)),s)}}case"MOVE_ITEM":{if(a===void 0)return{title:t.movedTitle(d),tone:"move"};const s={...a,x:e.payload.x,y:e.payload.y};return{title:t.movedTitle(d),tone:"move",body:Mo(t,o,r,s,n)}}case"RESIZE_ITEM":{const s=t.size(Math.round(e.payload.w),Math.round(e.payload.h));return{title:t.resizedTitle(d),tone:"update",body:r===void 0?`\u2192 ${s}`:t.plain(t.size(Math.round(r.w),Math.round(r.h)),s)}}case"SET_ITEM_COLOR":{const s=t.colorLabel(e.payload.color);return{title:t.recoloredTitle(d),tone:"update",body:r!==void 0&&ve(r)?t.plain(t.colorLabel(r.color),s):`\u2192 ${s}`}}case"SET_ITEM_FONT_SIZE":{const s=t.fontSizeLabel(e.payload.fontSize);return{title:t.resizedTextTitle(d),tone:"update",body:r!==void 0&&V(r)?t.plain(t.fontSizeLabel(r.fontSize),s):`\u2192 ${s}`}}case"REORDER_ITEM":{const s=e.payload.after;return{title:t.restackedTitle(d),tone:"move",body:s===null?t.toBack:t.inFrontOf(T(t,o,n,s))}}case"DELETE_ITEM":return{title:t.deletedTitle(d),tone:"delete",body:t.deleted(a===void 0?i:D(t,L(a)))};case"CONNECT_ITEMS":{const s=e.payload,c=t.connection(T(t,o,n,s.from),T(t,o,n,s.to));return{title:t.connectedTitle,tone:"create",body:s.label===void 0||s.label===""?c:`${c} \xB7 ${t.labeled(s.label)}`}}case"SET_CONNECTOR_LABEL":{const s=k(n,i)?.label,c=e.payload.label===""?t.noLabel:e.payload.label;return{title:t.relabeledTitle,tone:"update",body:s===void 0?t.arrowTo(c):t.arrowFrom(s,c)}}case"SET_CONNECTOR_ROUTE":{const s=k(n,i)?.route,c=t.routeLabel(e.payload.route);return{title:t.reroutedTitle,tone:"update",body:s===void 0?`\u2192 ${c}`:t.plain(t.routeLabel(s),c)}}case"DELETE_CONNECTOR":{const s=k(n,i)??k(o,i);return{title:t.disconnectedTitle,tone:"delete",...s===void 0?{}:{body:t.connection(T(t,o,n,s.from),T(t,o,n,s.to))}}}}},st=(t,e,o,n=o)=>{let i;try{const r=He(de,e);i=r===null?{title:e.type,tone:"meta"}:_o(t,r,o,n)}catch{i={title:e.type,tone:"meta"}}return{title:i.title,targetLabel:ct(t,o,e.target,n),tone:i.tone,...i.body===void 0?{}:{summary:i.body}}},dt=t=>`${t.type} ${I(t.target)} ${JSON.stringify(t.payload)}`,ct=(t,e,o,n=e)=>{switch(o.type){case"item":{const i=p(e,o.id)??p(n,o.id);return i===void 0?`${o.type} \xB7 ${o.id} (missing)`:So(t,i)}case"connector":{const i=k(e,o.id)??k(n,o.id);return i===void 0?`${t.connector} \xB7 ${o.id} (missing)`:zo(t,e,i,n)}case"page":return`${t.board} \xB7 ${Me(e)}`;default:return`${o.type} \xB7 ${o.id}`}},lt=(t,e)=>{const o=[{value:"page:whiteboard",label:t.wholeBoard,group:t.board}],n=e.items.filter(r=>r.kind==="frame"),i=e.items.filter(r=>r.kind!=="frame");for(const r of[...n,...i]){const a=P(e,r),d=D(t,L(r));o.push({value:I({type:"item",id:r.id}),label:a===void 0?d:`${a.title} \u203A ${d}`,group:t.kindLabel(r.kind)})}for(const r of e.connectors)o.push({value:I({type:"connector",id:r.id}),label:t.connection(T(t,e,e,r.from),T(t,e,e,r.to)),group:t.connector});return o},ht=(t,e,o)=>{const n=pe(o.item),i=n.length===1?n[0]:void 0,r=p(e,i)??p(e,o.frame);if(r!==void 0)return{value:I({type:"item",id:r.id}),label:D(t,L(r)),group:t.kindLabel(r.kind)};const a=k(e,i);return a===void 0?null:{value:I({type:"connector",id:a.id}),label:t.connection(T(t,e,e,a.from),T(t,e,e,a.to)),group:t.connector}},Me=t=>t.title??"Whiteboard",pt=(t,e)=>{const o={...e};p(t,e.frame)?.kind!=="frame"&&delete o.frame;const n=pe(e.item),i=n.filter(d=>p(t,d)!==void 0),r=n.length===1?k(t,n[0]):void 0,a=it(r===void 0?i:[r.id]);return a===void 0?delete o.item:o.item=a,o},ut=(t,e)=>{switch(e.type){case"item":return p(t,e.id)!==void 0;case"connector":return k(t,e.id)!==void 0;case"page":return!0;default:return!1}},bt=t=>{const e=he(t);return{name:"whiteboard",label:"Whiteboard",parseBase:Ge,emptyBase:Ye,actions:de,apply:et,canonicalState:o=>({...o,items:Te(o)}),hasTarget:ut,describe:(o,n,i)=>st(e,o,n,i),serialize:dt,resolveNavigation:pt,navigationHierarchy:["frame","item"],commentTargets:o=>lt(e,o),currentTarget:(o,n)=>ht(e,o,n),title:Me}},ft=["front","forward","backward","back"],mt=t=>t.items.filter(e=>e.kind!=="frame"),wt=(t,e,o,n)=>{const i=t.indexOf(e),r=(n?t.slice(i+1):t.slice(0,i).reverse()).filter(c=>!o.has(c.id)),a=r.find(c=>le(e,c,0))??r[0];if(a===void 0)return t;const d=t.filter(c=>c!==e),s=d.indexOf(a)+(n?1:0);return[...d.slice(0,s),e,...d.slice(s)]},xt=(t,e,o)=>{const n=t.filter(r=>e.has(r.id)),i=t.filter(r=>!e.has(r.id));switch(o){case"front":return[...i,...n];case"back":return[...n,...i];case"forward":return[...n].reverse().reduce((r,a)=>wt(r,a,e,!0),[...t]);case"backward":return n.reduce((r,a)=>wt(r,a,e,!1),[...t])}},Lo=(t,e,o)=>{let n=t.map(r=>r.id);const i=[];return e.forEach((r,a)=>{if(!o.has(r.id))return;const d=e[a-1]?.id??null,s=n.indexOf(r.id);(n[s-1]??null)!==d&&(n=n.filter(c=>c!==r.id),n.splice(d===null?0:n.indexOf(d)+1,0,r.id),i.push(w.reorder(r.id,d)))}),i},Oo=(t,e,o)=>{const n=mt(t),i=new Set(e.filter(r=>n.some(a=>a.id===r)));return i.size===0?[]:Lo(n,xt(n,i,o),i)},Io=(t,e)=>{const o=mt(t),n=new Set(e.filter(a=>o.some(d=>d.id===a))),i=o.flatMap(a=>n.has(a.id)?o.filter(d=>!n.has(d.id)&&le(a,d,0)).map(d=>[a,d]):[]),r=(a,[d,s])=>a.indexOf(d)>a.indexOf(s);return new Set(ft.filter(a=>{const d=xt(o,n,a);return i.some(s=>r(o,s)!==r(d,s))}))},yt=(t,e,o)=>{if(!t.contains(e)||e.nodeType!==Node.TEXT_NODE)return;let n=0;const i=t.ownerDocument.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(let r=i.nextNode();r!==null;r=i.nextNode()){if(r===e)return n+o;n+=r.textContent?.length??0}},Co=(t,e,o)=>{const n=t.getRootNode(),i=t.ownerDocument;if(typeof i.caretPositionFromPoint=="function"){const r=n instanceof ShadowRoot?[n]:[],a=i.caretPositionFromPoint(e,o,{shadowRoots:r});if(a!==null)return yt(t,a.offsetNode,a.offset)}if(typeof i.caretRangeFromPoint=="function"){const r=i.caretRangeFromPoint(e,o);if(r!==null)return yt(t,r.startContainer,r.startOffset)}},Ro=["sticky","text","rect","ellipse","frame"],No=t=>t==="rect"||t==="ellipse"?C.shape:C[t],Do=(t,e,o,n)=>{const{w:i,h:r}=No(o),a={x:Math.round(n.x-i/2),y:Math.round(n.y-r/2)},d=mo(t,{...a,w:i,h:r},o==="frame"),l={id:We(`new-${o==="rect"||o==="ellipse"?"shape":o}`,je(t)),x:d.x,y:d.y,w:i,h:r};switch(o){case"sticky":return{...l,kind:"sticky",text:"",color:H.sticky,fontSize:re};case"text":return{...l,kind:"text",text:"",fontSize:re};case"rect":case"ellipse":return{...l,kind:"shape",shape:o,text:"",color:H.shape,fontSize:re};case"frame":return{...l,kind:"frame",title:e.newFrameTitle,color:H.frame}}},Po=(t,e,o)=>We(`${e}-to-${o}`,je(t)),Ao=(t,e)=>{const o=(t.kind==="frame"?e.replace(/\r?\n/g," "):e).trim();if(!(t.kind==="frame"&&o===""))return o===L(t)?void 0:o},ue=4,_e=(t,e,o,n,i=[e])=>{if(p(t,e)===void 0)return;const r=new Map;for(const a of i.includes(e)?i:[e,...i]){const d=p(t,a);if(d!==void 0)for(const s of d.kind==="frame"?[d,...$e(t,d)]:[d])r.set(s.id,s)}return{kind:"move",pointerId:o,itemId:e,origins:[...r.values()].map(({id:a,x:d,y:s})=>({id:a,x:d,y:s})),start:n,current:n,moved:!1}},Fo=(t,e,o,n)=>{const i=p(t,e);if(i!==void 0)return{kind:"resize",pointerId:o,itemId:e,origin:{w:i.w,h:i.h},start:n,current:n,moved:!1,keepRatio:!1}},Bo=(t,e)=>({kind:"pan",pointerId:t,start:e,last:e,moved:!1}),Ho=(t,e)=>({gesture:{...t,last:e,moved:t.moved||Math.hypot(e.x-t.start.x,e.y-t.start.y)>ue},dx:e.x-t.last.x,dy:e.y-t.last.y}),kt=(t,e,o)=>({kind:"marquee",pointerId:t,base:o,start:e,current:e,moved:!1}),Wo=(t,e,o,n,i)=>{const r=po(t,n).find(d=>e.includes(d.id));return(r===void 0?void 0:_e(t,r.id,o,n,e))??kt(o,n,i)},gt=t=>t?.kind==="marquee"&&t.moved?uo(t.start,t.current):void 0,vt=(t,e)=>{const o=gt(e);if(e.kind!=="marquee"||o===void 0)return[];const n=fo(t,o).map(i=>i.id);return[...new Set([...e.base,...n])]},Ko=(t,e,o)=>({kind:"connect",pointerId:e,fromId:t,start:o,current:o,moved:!1}),Le=(t,e,o,n,i,r=!1)=>{if(e.pointerId!==o)return e;switch(e.kind){case"pan":return e;case"marquee":case"move":{const a=e.moved||Math.hypot(n.x-e.start.x,n.y-e.start.y)*i>ue;return{...e,current:n,moved:a}}case"resize":{const a=e.moved||Math.hypot(n.x-e.start.x,n.y-e.start.y)*i>ue;return{...e,current:n,moved:a,keepRatio:r}}case"connect":{const a=e.moved||Math.hypot(n.x-e.start.x,n.y-e.start.y)*i>ue,d=ze(t,n,e.fromId),{targetId:s,...c}=e;return d===void 0?{...c,current:n,moved:a}:{...c,current:n,moved:a,targetId:d.id}}}},K=t=>Math.round(t),$t=(t,e)=>{if(e===void 0||!e.moved)return t;if(e.kind==="move"){const o=e.current.x-e.start.x,n=e.current.y-e.start.y,i=new Map(e.origins.map(r=>[r.id,r]));return{...t,items:t.items.map(r=>{const a=i.get(r.id);return a===void 0?r:{...r,x:K(a.x+o),y:K(a.y+n)}})}}if(e.kind==="resize"){const o=Et(e);return{...t,items:t.items.map(n=>n.id===e.itemId?{...n,...o}:n)}}return t},Et=t=>{const{origin:e}=t,o=e.w+t.current.x-t.start.x,n=e.h+t.current.y-t.start.y;if(!t.keepRatio)return{w:Math.max(Z,K(o)),h:Math.max(Z,K(n))};const i=Math.max(o/e.w,n/e.h,Z/Math.min(e.w,e.h));return{w:K(e.w*i),h:K(e.h*i)}},qo=(t,e,o,n)=>{const[i]=e;if(i===void 0)return[];const r=_e(t,i,0,{x:0,y:0},e);if(r?.kind!=="move")return[];const a=Tt(t,{...r,current:{x:o,y:n},moved:!0});return a.kind==="dispatch"?a.inputs:[]},Tt=(t,e)=>{switch(e.kind){case"pan":return e.moved?{kind:"none"}:{kind:"click"};case"marquee":{if(e.moved)return{kind:"select",ids:vt(t,e)};const o=ze(t,e.start);return o===void 0?{kind:"click"}:{kind:"click",itemId:o.id}}case"move":{if(!e.moved)return{kind:"click",itemId:e.itemId};const o=$t(t,e),n=e.origins.flatMap(i=>{const r=p(o,i.id);return r===void 0||r.x===i.x&&r.y===i.y?[]:[w.move(i.id,r.x,r.y)]});return n.length===0?{kind:"none"}:{kind:"dispatch",inputs:n}}case"resize":{if(!e.moved)return{kind:"click",itemId:e.itemId};const o=Et(e);return o.w===e.origin.w&&o.h===e.origin.h?{kind:"none"}:{kind:"dispatch",inputs:[w.resize(e.itemId,o.w,o.h)]}}case"connect":return e.moved?e.targetId===void 0?{kind:"none"}:{kind:"connect",from:e.fromId,to:e.targetId}:{kind:"click",itemId:e.fromId}}},Oe=.1,St=2.5,Uo={x:0,y:0,zoom:1},Zo=96,Ie=(t,e)=>({x:(e.x-t.x)/t.zoom,y:(e.y-t.y)/t.zoom}),Ce=(t,e)=>({x:e.x*t.zoom+t.x,y:e.y*t.zoom+t.y}),be=(t,e,o)=>({...t,x:t.x+e,y:t.y+o}),Re=(t,e,o)=>{const n=ye(t.zoom*o,Oe,St),i=Ie(t,e);return{zoom:n,x:e.x-i.x*n,y:e.y-i.y*n}},zt=(t,e,o=48,n=1)=>{const i=Math.max(1,e.width-o*2),r=Math.max(1,e.height-o*2),a=ye(Math.min(i/Math.max(1,t.w),r/Math.max(1,t.h)),Oe,n);return{zoom:a,x:e.width/2-(t.x+t.w/2)*a,y:e.height/2-(t.y+t.h/2)*a}},Mt=(t,e,o)=>{if(e===null||o.width<=0||o.height<=0)return t;const n=(i,r,a,d)=>{const s=Math.min(Zo,d/2),c=s-(r+a)*t.zoom,l=d-s-r*t.zoom;return ye(i,Math.min(c,l),Math.max(c,l))};return{zoom:t.zoom,x:n(t.x,e.x,e.w,o.width),y:n(t.y,e.y,e.h,o.height)}},Vo=(t,e,o,n=24)=>{const i=e.x*t.zoom+t.x,r=e.y*t.zoom+t.y,a=i+e.w*t.zoom,d=r+e.h*t.zoom;return i>=n&&r>=n&&a<=o.width-n&&d<=o.height-n?t:{zoom:t.zoom,x:o.width/2-(e.x+e.w/2)*t.zoom,y:o.height/2-(e.y+e.h/2)*t.zoom}},_t=(t,e,o,n)=>{const i=t+e-(o-n),r=i>0?-i:0;return t+r<n?n-t:r},Xo=(t,e)=>t.x===e.x&&t.y===e.y&&t.zoom===e.zoom,$={kind:"idle"},j=(t,e)=>t.kind==="editing"&&t.itemId===e,Go={yellow:{paper:"#fff0a3",ink:"#4a3a06",stroke:"#d9a900"},orange:{paper:"#ffd1a0",ink:"#4a2503",stroke:"#ec7f1d"},pink:{paper:"#ffc9dd",ink:"#4b1029",stroke:"#de4479"},purple:{paper:"#ddcbf8",ink:"#32195c",stroke:"#8a5bd6"},blue:{paper:"#c0ddf7",ink:"#0e2c4b",stroke:"#3a80d4"},green:{paper:"#cdeba5",ink:"#22380a",stroke:"#55a42c"},gray:{paper:"#e3e6eb",ink:"#2a2f38",stroke:"#868d99"}},Ne=t=>{const{paper:e,ink:o,stroke:n}=Go[t];return`--wb-paper:${e};--wb-ink:${o};--wb-stroke:${n}`},Lt={sticky:"addSticky",text:"addText",rect:"addRect",ellipse:"addEllipse",frame:"addFrame"},Ot={small:.8,medium:1,large:1.4,xlarge:2},Yo=t=>{const e=24*t.zoom;return`background-size:${e}px ${e}px;background-position:${t.x}px ${t.y}px`},jo=t=>{const{m:e,state:o,viewport:n,gesture:i,handlers:r}=t,a=["wb-canvas"];i?.moved===!0&&a.push("wb-canvas--gesturing"),i?.kind==="pan"&&i.moved&&a.push("wb-canvas--panning"),i?.kind==="connect"&&a.push("wb-canvas--connecting"),(t.panReady||i?.kind==="pan")&&a.push("wb-canvas--pan-ready");const d=Te(o);return h`<div
2
2
  class=${a.join(" ")}
3
3
  data-testid="wb-canvas"
4
4
  tabindex="0"
@@ -1,4 +1,4 @@
1
- import{p as be,ak as L,ac as g,ah as h,ai as b,af as p,am as v,ad as u,an as fe,ae as $,ab as ke,R as z,a0 as ve,V as xe,a4 as s,a5 as F,a3 as d,ax as O,a2 as me,T as P,aG as we,aH as ye}from"./shared-BQFDKhM1.js";import{c as N}from"./shared-ml5h7U5L.js";const $e=(t,e,r)=>r.top<e.top?t+r.top-e.top:r.bottom<=e.bottom?t:t+Math.min(r.bottom-e.bottom,r.top-e.top),Te=(t,e)=>{const i=t.getBoundingClientRect().top+t.clientTop;t.scrollTop=$e(t.scrollTop,{top:i,bottom:i+t.clientHeight},e.getBoundingClientRect())},Se=L("kind",[g({kind:v("option"),optionId:h(p(),b(1))}),g({kind:v("free"),text:p()}),g({kind:v("clear")})]),T={ANSWER_QUESTION:be("ANSWER_QUESTION","question",Se)},G=(t,e)=>({type:"ANSWER_QUESTION",target:{type:"question",id:t},payload:e}),Re=g({id:h(p(),b(1)),label:h(p(),b(1))}),B=g({id:h(p(),b(1)),ref:u(h(p(),b(1))),title:h(p(),b(1)),description:u(p()),note:u(p()),options:u($(Re),[]),freeText:u(fe(),!0)}),Ce=L("kind",[g({kind:v("option"),optionId:h(p(),b(1))}),g({kind:v("free"),text:p()})]),Ae=g({...B.entries,answer:u(Ce)}),qe=g({label:u(h(p(),b(1))),questions:$(Ae)}),_=g({title:u(p(),""),questions:$(B),history:u($(qe),[])}),H=t=>{const e=new Set;return t.map((r,i)=>{if(e.has(r.id))throw new Error(`duplicate question id: ${r.id}`);e.add(r.id);const n=new Set;for(const a of r.options){if(n.has(a.id))throw new Error(`duplicate option id: ${a.id} in question ${r.id}`);n.add(a.id)}return{...r,ref:r.ref??`Q${i+1}`,description:r.description??null,note:r.note??null}})},M=t=>({id:t.id,ref:t.ref,title:t.title,description:t.description,note:t.note,options:t.options,freeText:t.freeText}),Ee=t=>{const e=t.answer??null;if(e?.kind==="option"&&!t.options.some(r=>r.id===e.optionId))throw new Error(`unknown option id: ${e.optionId} in question ${t.id}`);return{...M(t),answer:e}},U=t=>{const e=ke(_,t);return{title:e.title,questions:H(e.questions).map(M),answers:{},pastRounds:e.history.map((r,i)=>({label:r.label??`v${i+1}`,questions:H(r.questions).map(Ee)}))}},W=()=>({title:"",questions:[],answers:{},pastRounds:[]}),f=(t,e)=>t.questions.find(r=>r.id===e),Qe=(t,e)=>f(t,e)?.ref??e,q=(t,e)=>{const r=f(t,e);return r?`${r.ref} \xB7 ${r.title}`:e},x=(t,e)=>e?e.kind==="option"?t.options.find(r=>r.id===e.optionId)?.label??"":e.text.trim():"",S=(t,e)=>x(t,e)!=="",j=t=>{let e="";for(let r=t+1;r>0;r=Math.floor((r-1)/26))e=String.fromCharCode(97+(r-1)%26)+e;return e},D=t=>({total:t.questions.length,answered:t.questions.filter(e=>S(e,t.answers[e.id])).length}),R=(t,e,r)=>{const i=t.answers[e];if(r===null){if(i===void 0)return t;const n={...t.answers};return delete n[e],{...t,answers:n}}return i?.kind===r.kind&&(i.kind==="option"&&r.kind==="option"&&i.optionId===r.optionId||i.kind==="free"&&r.kind==="free"&&i.text===r.text)?t:{...t,answers:{...t.answers,[e]:r}}},Y=(t,e)=>{if(e.type!=="ANSWER_QUESTION")return null;const r=f(t,e.target.id);if(!r)return null;const i=z(T.ANSWER_QUESTION,e);return i.kind==="clear"?R(t,r.id,null):i.kind==="option"?r.options.some(n=>n.id===i.optionId)?R(t,r.id,{kind:"option",optionId:i.optionId}):null:R(t,r.id,{kind:"free",text:i.text})},m=ve({en:{wholePage:"Whole page",questionGroup:"Question",answerCleared:"Clear answer",answered:"Answer",answeredFreely:"Answer in your own words",quoted:t=>`\u2192 \u201C${t}\u201D`,progress:(t,e)=>`${t} of ${e} answered`,openPanel:"Show questions / review",closePanel:"Hide questions / review",toggleLabel:(t,e)=>`${t} (${e})`,tabs:"Questions / review",questionsTab:"Questions",reviewTab:"Review",copied:"Copied",copyFailed:"Could not copy",copyAll:"Copy answers and review",sending:"Sending\u2026",sent:"Sent to Claude",sendFailed:"Could not send",sendAll:"Send answers and review to Claude",copyDone:"Copied",copy:"Copy",noQuestions:"No matching questions.",freeText:"Your own answer",freeTextOf:t=>`Your own answer to ${t}`,freeTextPlaceholder:"Type an answer\u2026 (\u2318/Ctrl+Enter for next)",clearAnswer:"Clear answer",roundSelect:"Question round",currentRound:"Current questions",roundOption:(t,e)=>`${t} (${e})`,pastRound:t=>`${t}: earlier questions, read-only`,unanswered:"Not answered"},ja:{wholePage:"\u30DA\u30FC\u30B8\u5168\u4F53",questionGroup:"\u8CEA\u554F",answerCleared:"\u56DE\u7B54\u3092\u30AF\u30EA\u30A2",answered:"\u56DE\u7B54",answeredFreely:"\u81EA\u7531\u8A18\u8FF0\u3067\u56DE\u7B54",quoted:t=>`\u2192 \u300C${t}\u300D`,progress:(t,e)=>`\u56DE\u7B54\u6E08\u307F ${t} / ${e}`,openPanel:"\u8CEA\u554F / Review \u3092\u3072\u3089\u304F",closePanel:"\u8CEA\u554F / Review \u3092\u305F\u305F\u3080",toggleLabel:(t,e)=>`${t}\uFF08${e}\uFF09`,tabs:"\u8CEA\u554F / Review",questionsTab:"\u8CEA\u554F",reviewTab:"Review",copied:"\u30B3\u30D4\u30FC\u3057\u307E\u3057\u305F",copyFailed:"\u30B3\u30D4\u30FC\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F",copyAll:"\u56DE\u7B54\u30FBReview \u3092\u307E\u3068\u3081\u3066\u30B3\u30D4\u30FC",sending:"\u9001\u4FE1\u4E2D\u2026",sent:"Claude \u306B\u9001\u308A\u307E\u3057\u305F",sendFailed:"\u9001\u308C\u307E\u305B\u3093\u3067\u3057\u305F",sendAll:"\u56DE\u7B54\u30FBReview \u3092 Claude \u306B\u9001\u308B",copyDone:"\u30B3\u30D4\u30FC\u6E08\u307F",copy:"\u30B3\u30D4\u30FC",noQuestions:"\u8A72\u5F53\u3059\u308B\u8CEA\u554F\u306F\u3042\u308A\u307E\u305B\u3093\u3002",freeText:"\u81EA\u7531\u8A18\u8FF0",freeTextOf:t=>`${t} \u306E\u81EA\u7531\u8A18\u8FF0`,freeTextPlaceholder:"\u56DE\u7B54\u3092\u5165\u529B\u2026\uFF08\u2318/Ctrl+Enter \u3067\u6B21\u3078\uFF09",clearAnswer:"\u56DE\u7B54\u3092\u30AF\u30EA\u30A2",roundSelect:"\u8CEA\u554F\u306E\u30E9\u30A6\u30F3\u30C9",currentRound:"\u73FE\u5728\u306E\u8CEA\u554F",roundOption:(t,e)=>`${t}\uFF08${e} \u554F\uFF09`,pastRound:t=>`${t}: \u904E\u53BB\u306E\u8CEA\u554F\uFF08\u95B2\u89A7\u306E\u307F\uFF09`,unanswered:"\u672A\u56DE\u7B54"}}),V=t=>t.title===""?"Visually Grill":t.title,K=(t,e,r)=>{switch(r.type){case"question":return q(e,r.id);case"page":return t.wholePage;default:return r.id}},Ie=(t,e,r)=>{const i=z(T.ANSWER_QUESTION,r);if(i.kind==="clear")return{title:t.answerCleared,tone:"delete"};if(i.kind==="option"){const n=f(e,r.target.id)?.options.find(a=>a.id===i.optionId);return{title:t.answered,tone:"update",body:t.quoted(n?.label??i.optionId)}}return{title:t.answeredFreely,tone:"update",body:t.quoted(i.text.slice(0,120))}},J=(t,e,r,i)=>{let n;try{n=Ie(t,i??r,e)}catch{n={title:e.type,tone:"meta"}}return{title:n.title,targetLabel:K(t,r,e.target),tone:n.tone,...n.body===void 0?{}:{summary:n.body}}},X=t=>`${t.type} ${xe(t.target)} ${JSON.stringify(t.payload)}`,Z=(t,e)=>e.questions.map(r=>({value:`question:${r.id}`,label:q(e,r.id),group:t.questionGroup})),ee=(t,e)=>{const r=e.question;if(r!==void 0&&f(t,r))return e;const i=t.questions[0];return i===void 0?e:{...e,question:i.id}},te=(t,e)=>{const r=e.question;return r!==void 0&&f(t,r)?r:t.questions[0]?.id??null},Le=(t,e)=>{const r=t.questions,i=r.findIndex(a=>a.id===e);return(i===-1?r:[...r.slice(i+1),...r.slice(0,i)]).find(a=>!S(a,t.answers[a.id]))?.id??null},re=(t,e)=>t.options.map((r,i)=>({id:r.id,letter:j(i),label:r.label,checked:e?.kind==="option"&&e.optionId===r.id})),ze=(t,e,r)=>{const i=e.answers[t.id];return{id:t.id,ref:t.ref,title:t.title,description:t.description,note:t.note,open:t.id===r,answered:x(t,i)!=="",summary:x(t,i),choices:re(t,i),draft:i?.kind==="free"?i.text:"",freeSelected:i?.kind==="free",allowFreeText:t.freeText}},ie=(t,e)=>{const r=te(t,e);return{questions:t.questions.map(i=>ze(i,t,r))}},ne=(t,e)=>{const r=D(e);return{progress:t.progress(r.answered,r.total),answered:r.answered,total:r.total}},ae=(t,e)=>e!=="current"&&t.pastRounds[e]!==void 0?e:"current",Fe=(t,e,r)=>{if(e.pastRounds.length===0)return[];const i=ae(e,r),n=e.pastRounds.map((a,o)=>({value:String(o),label:t.roundOption(a.label,a.questions.length),selected:i===o}));return[{value:"current",label:t.roundOption(t.currentRound,e.questions.length),selected:i==="current"},...[...n].reverse()]},Oe=(t,e,r)=>{const i=e.pastRounds[r];return i===void 0?null:{label:i.label,questions:i.questions.map(n=>{const a=n.answer??void 0,o=x(n,a);return{id:n.id,ref:n.ref,title:n.title,description:n.description,note:n.note,answered:o!=="",summary:o===""?t.unanswered:o,choices:re(n,a),freeText:a?.kind==="free"?a.text:null}})}},oe=(t,e)=>{switch(e.type){case"question":return f(t,e.id)!==void 0;case"page":return!0;default:return!1}},se=t=>{const e=m(t);return{name:"grill",label:"Visually Grill",parseBase:U,emptyBase:W,actions:T,apply:Y,hasTarget:oe,describe:(r,i,n)=>J(e,r,i,n),serialize:X,resolveNavigation:ee,commentTargets:r=>Z(e,r),title:V}},w="data-grill-questions",Pe=t=>{const e=[t];for(const r of t.querySelectorAll("*"))r.shadowRoot&&e.push(r.shadowRoot);return e},le=(t,e,r)=>{const i=r.question??e.questions[0]?.id??null,n=new Map(e.questions.map(o=>[o.ref,o])),a=[];for(const o of Pe(t))for(const l of o.querySelectorAll(`[${w}]`)){const k=l.getAttribute(w)??"";for(const C of k.split(/\s+/)){if(C==="")continue;const c=n.get(C);c&&a.push({index:a.length,target:l,questionId:c.id,ref:c.ref,title:c.title,answered:S(c,e.answers[c.id]),open:c.id===i})}}return a},de=(t,e)=>{const r=t.getBoundingClientRect(),i=new Map;e.forEach((a,o)=>{const l=t.querySelector(`[data-label="${o}"]`);if(!l)return;const k=i.get(a.target)??[];k.push(l),i.set(a.target,k)});const n=new Map;for(const[a,o]of i){const l=a.getBoundingClientRect(),k=l.width>0||l.height>0,c=n.get(a)??Ne(a,t);n.set(a,c);const E=l.bottom>r.top&&l.top<r.bottom&&l.right>r.left&&l.left<r.right,Q=l.bottom>c.top&&l.top<c.bottom;o.forEach((y,ge)=>{if(y.dataset.visible=String(k&&E&&Q),!k||!E||!Q)return;const A=y.offsetWidth,I=y.offsetHeight,ue=l.right-r.left-A+8-(o.length-1-ge)*(A+5),he=l.top-r.top-I/2;y.style.transform=`translate(${N(ue,0,Math.max(0,t.clientWidth-A))}px, ${N(he,0,Math.max(0,t.clientHeight-I))}px)`})}},Ne=(t,e)=>{const r=t.getRootNode(),i=r instanceof ShadowRoot?r.host:null,n=i?.shadowRoot?.querySelector(".diagram-canvas")??null;return n instanceof Element?n.getBoundingClientRect():i instanceof Element?i.getBoundingClientRect():e.getBoundingClientRect()},Ge=(t,e,r)=>s`
1
+ import{p as be,ak as L,ac as g,ah as h,ai as b,af as p,am as v,ad as u,an as fe,ae as $,ab as ke,R as z,a0 as ve,V as xe,a4 as s,a5 as F,a3 as d,ax as O,a2 as me,T as P,aG as we,aH as ye}from"./shared-B_MMP97h.js";import{c as N}from"./shared-ml5h7U5L.js";const $e=(t,e,r)=>r.top<e.top?t+r.top-e.top:r.bottom<=e.bottom?t:t+Math.min(r.bottom-e.bottom,r.top-e.top),Te=(t,e)=>{const i=t.getBoundingClientRect().top+t.clientTop;t.scrollTop=$e(t.scrollTop,{top:i,bottom:i+t.clientHeight},e.getBoundingClientRect())},Se=L("kind",[g({kind:v("option"),optionId:h(p(),b(1))}),g({kind:v("free"),text:p()}),g({kind:v("clear")})]),T={ANSWER_QUESTION:be("ANSWER_QUESTION","question",Se)},G=(t,e)=>({type:"ANSWER_QUESTION",target:{type:"question",id:t},payload:e}),Re=g({id:h(p(),b(1)),label:h(p(),b(1))}),B=g({id:h(p(),b(1)),ref:u(h(p(),b(1))),title:h(p(),b(1)),description:u(p()),note:u(p()),options:u($(Re),[]),freeText:u(fe(),!0)}),Ce=L("kind",[g({kind:v("option"),optionId:h(p(),b(1))}),g({kind:v("free"),text:p()})]),Ae=g({...B.entries,answer:u(Ce)}),qe=g({label:u(h(p(),b(1))),questions:$(Ae)}),_=g({title:u(p(),""),questions:$(B),history:u($(qe),[])}),H=t=>{const e=new Set;return t.map((r,i)=>{if(e.has(r.id))throw new Error(`duplicate question id: ${r.id}`);e.add(r.id);const n=new Set;for(const a of r.options){if(n.has(a.id))throw new Error(`duplicate option id: ${a.id} in question ${r.id}`);n.add(a.id)}return{...r,ref:r.ref??`Q${i+1}`,description:r.description??null,note:r.note??null}})},M=t=>({id:t.id,ref:t.ref,title:t.title,description:t.description,note:t.note,options:t.options,freeText:t.freeText}),Ee=t=>{const e=t.answer??null;if(e?.kind==="option"&&!t.options.some(r=>r.id===e.optionId))throw new Error(`unknown option id: ${e.optionId} in question ${t.id}`);return{...M(t),answer:e}},U=t=>{const e=ke(_,t);return{title:e.title,questions:H(e.questions).map(M),answers:{},pastRounds:e.history.map((r,i)=>({label:r.label??`v${i+1}`,questions:H(r.questions).map(Ee)}))}},W=()=>({title:"",questions:[],answers:{},pastRounds:[]}),f=(t,e)=>t.questions.find(r=>r.id===e),Qe=(t,e)=>f(t,e)?.ref??e,q=(t,e)=>{const r=f(t,e);return r?`${r.ref} \xB7 ${r.title}`:e},x=(t,e)=>e?e.kind==="option"?t.options.find(r=>r.id===e.optionId)?.label??"":e.text.trim():"",S=(t,e)=>x(t,e)!=="",j=t=>{let e="";for(let r=t+1;r>0;r=Math.floor((r-1)/26))e=String.fromCharCode(97+(r-1)%26)+e;return e},D=t=>({total:t.questions.length,answered:t.questions.filter(e=>S(e,t.answers[e.id])).length}),R=(t,e,r)=>{const i=t.answers[e];if(r===null){if(i===void 0)return t;const n={...t.answers};return delete n[e],{...t,answers:n}}return i?.kind===r.kind&&(i.kind==="option"&&r.kind==="option"&&i.optionId===r.optionId||i.kind==="free"&&r.kind==="free"&&i.text===r.text)?t:{...t,answers:{...t.answers,[e]:r}}},Y=(t,e)=>{if(e.type!=="ANSWER_QUESTION")return null;const r=f(t,e.target.id);if(!r)return null;const i=z(T.ANSWER_QUESTION,e);return i.kind==="clear"?R(t,r.id,null):i.kind==="option"?r.options.some(n=>n.id===i.optionId)?R(t,r.id,{kind:"option",optionId:i.optionId}):null:R(t,r.id,{kind:"free",text:i.text})},m=ve({en:{wholePage:"Whole page",questionGroup:"Question",answerCleared:"Clear answer",answered:"Answer",answeredFreely:"Answer in your own words",quoted:t=>`\u2192 \u201C${t}\u201D`,progress:(t,e)=>`${t} of ${e} answered`,openPanel:"Show questions / review",closePanel:"Hide questions / review",toggleLabel:(t,e)=>`${t} (${e})`,tabs:"Questions / review",questionsTab:"Questions",reviewTab:"Review",copied:"Copied",copyFailed:"Could not copy",copyAll:"Copy answers and review",sending:"Sending\u2026",sent:"Sent to Claude",sendFailed:"Could not send",sendAll:"Send answers and review to Claude",copyDone:"Copied",copy:"Copy",noQuestions:"No matching questions.",freeText:"Your own answer",freeTextOf:t=>`Your own answer to ${t}`,freeTextPlaceholder:"Type an answer\u2026 (\u2318/Ctrl+Enter for next)",clearAnswer:"Clear answer",roundSelect:"Question round",currentRound:"Current questions",roundOption:(t,e)=>`${t} (${e})`,pastRound:t=>`${t}: earlier questions, read-only`,unanswered:"Not answered"},ja:{wholePage:"\u30DA\u30FC\u30B8\u5168\u4F53",questionGroup:"\u8CEA\u554F",answerCleared:"\u56DE\u7B54\u3092\u30AF\u30EA\u30A2",answered:"\u56DE\u7B54",answeredFreely:"\u81EA\u7531\u8A18\u8FF0\u3067\u56DE\u7B54",quoted:t=>`\u2192 \u300C${t}\u300D`,progress:(t,e)=>`\u56DE\u7B54\u6E08\u307F ${t} / ${e}`,openPanel:"\u8CEA\u554F / Review \u3092\u3072\u3089\u304F",closePanel:"\u8CEA\u554F / Review \u3092\u305F\u305F\u3080",toggleLabel:(t,e)=>`${t}\uFF08${e}\uFF09`,tabs:"\u8CEA\u554F / Review",questionsTab:"\u8CEA\u554F",reviewTab:"Review",copied:"\u30B3\u30D4\u30FC\u3057\u307E\u3057\u305F",copyFailed:"\u30B3\u30D4\u30FC\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F",copyAll:"\u56DE\u7B54\u30FBReview \u3092\u307E\u3068\u3081\u3066\u30B3\u30D4\u30FC",sending:"\u9001\u4FE1\u4E2D\u2026",sent:"Claude \u306B\u9001\u308A\u307E\u3057\u305F",sendFailed:"\u9001\u308C\u307E\u305B\u3093\u3067\u3057\u305F",sendAll:"\u56DE\u7B54\u30FBReview \u3092 Claude \u306B\u9001\u308B",copyDone:"\u30B3\u30D4\u30FC\u6E08\u307F",copy:"\u30B3\u30D4\u30FC",noQuestions:"\u8A72\u5F53\u3059\u308B\u8CEA\u554F\u306F\u3042\u308A\u307E\u305B\u3093\u3002",freeText:"\u81EA\u7531\u8A18\u8FF0",freeTextOf:t=>`${t} \u306E\u81EA\u7531\u8A18\u8FF0`,freeTextPlaceholder:"\u56DE\u7B54\u3092\u5165\u529B\u2026\uFF08\u2318/Ctrl+Enter \u3067\u6B21\u3078\uFF09",clearAnswer:"\u56DE\u7B54\u3092\u30AF\u30EA\u30A2",roundSelect:"\u8CEA\u554F\u306E\u30E9\u30A6\u30F3\u30C9",currentRound:"\u73FE\u5728\u306E\u8CEA\u554F",roundOption:(t,e)=>`${t}\uFF08${e} \u554F\uFF09`,pastRound:t=>`${t}: \u904E\u53BB\u306E\u8CEA\u554F\uFF08\u95B2\u89A7\u306E\u307F\uFF09`,unanswered:"\u672A\u56DE\u7B54"}}),V=t=>t.title===""?"Visually Grill":t.title,K=(t,e,r)=>{switch(r.type){case"question":return q(e,r.id);case"page":return t.wholePage;default:return r.id}},Ie=(t,e,r)=>{const i=z(T.ANSWER_QUESTION,r);if(i.kind==="clear")return{title:t.answerCleared,tone:"delete"};if(i.kind==="option"){const n=f(e,r.target.id)?.options.find(a=>a.id===i.optionId);return{title:t.answered,tone:"update",body:t.quoted(n?.label??i.optionId)}}return{title:t.answeredFreely,tone:"update",body:t.quoted(i.text.slice(0,120))}},J=(t,e,r,i)=>{let n;try{n=Ie(t,i??r,e)}catch{n={title:e.type,tone:"meta"}}return{title:n.title,targetLabel:K(t,r,e.target),tone:n.tone,...n.body===void 0?{}:{summary:n.body}}},X=t=>`${t.type} ${xe(t.target)} ${JSON.stringify(t.payload)}`,Z=(t,e)=>e.questions.map(r=>({value:`question:${r.id}`,label:q(e,r.id),group:t.questionGroup})),ee=(t,e)=>{const r=e.question;if(r!==void 0&&f(t,r))return e;const i=t.questions[0];return i===void 0?e:{...e,question:i.id}},te=(t,e)=>{const r=e.question;return r!==void 0&&f(t,r)?r:t.questions[0]?.id??null},Le=(t,e)=>{const r=t.questions,i=r.findIndex(a=>a.id===e);return(i===-1?r:[...r.slice(i+1),...r.slice(0,i)]).find(a=>!S(a,t.answers[a.id]))?.id??null},re=(t,e)=>t.options.map((r,i)=>({id:r.id,letter:j(i),label:r.label,checked:e?.kind==="option"&&e.optionId===r.id})),ze=(t,e,r)=>{const i=e.answers[t.id];return{id:t.id,ref:t.ref,title:t.title,description:t.description,note:t.note,open:t.id===r,answered:x(t,i)!=="",summary:x(t,i),choices:re(t,i),draft:i?.kind==="free"?i.text:"",freeSelected:i?.kind==="free",allowFreeText:t.freeText}},ie=(t,e)=>{const r=te(t,e);return{questions:t.questions.map(i=>ze(i,t,r))}},ne=(t,e)=>{const r=D(e);return{progress:t.progress(r.answered,r.total),answered:r.answered,total:r.total}},ae=(t,e)=>e!=="current"&&t.pastRounds[e]!==void 0?e:"current",Fe=(t,e,r)=>{if(e.pastRounds.length===0)return[];const i=ae(e,r),n=e.pastRounds.map((a,o)=>({value:String(o),label:t.roundOption(a.label,a.questions.length),selected:i===o}));return[{value:"current",label:t.roundOption(t.currentRound,e.questions.length),selected:i==="current"},...[...n].reverse()]},Oe=(t,e,r)=>{const i=e.pastRounds[r];return i===void 0?null:{label:i.label,questions:i.questions.map(n=>{const a=n.answer??void 0,o=x(n,a);return{id:n.id,ref:n.ref,title:n.title,description:n.description,note:n.note,answered:o!=="",summary:o===""?t.unanswered:o,choices:re(n,a),freeText:a?.kind==="free"?a.text:null}})}},oe=(t,e)=>{switch(e.type){case"question":return f(t,e.id)!==void 0;case"page":return!0;default:return!1}},se=t=>{const e=m(t);return{name:"grill",label:"Visually Grill",parseBase:U,emptyBase:W,actions:T,apply:Y,hasTarget:oe,describe:(r,i,n)=>J(e,r,i,n),serialize:X,resolveNavigation:ee,commentTargets:r=>Z(e,r),title:V}},w="data-grill-questions",Pe=t=>{const e=[t];for(const r of t.querySelectorAll("*"))r.shadowRoot&&e.push(r.shadowRoot);return e},le=(t,e,r)=>{const i=r.question??e.questions[0]?.id??null,n=new Map(e.questions.map(o=>[o.ref,o])),a=[];for(const o of Pe(t))for(const l of o.querySelectorAll(`[${w}]`)){const k=l.getAttribute(w)??"";for(const C of k.split(/\s+/)){if(C==="")continue;const c=n.get(C);c&&a.push({index:a.length,target:l,questionId:c.id,ref:c.ref,title:c.title,answered:S(c,e.answers[c.id]),open:c.id===i})}}return a},de=(t,e)=>{const r=t.getBoundingClientRect(),i=new Map;e.forEach((a,o)=>{const l=t.querySelector(`[data-label="${o}"]`);if(!l)return;const k=i.get(a.target)??[];k.push(l),i.set(a.target,k)});const n=new Map;for(const[a,o]of i){const l=a.getBoundingClientRect(),k=l.width>0||l.height>0,c=n.get(a)??Ne(a,t);n.set(a,c);const E=l.bottom>r.top&&l.top<r.bottom&&l.right>r.left&&l.left<r.right,Q=l.bottom>c.top&&l.top<c.bottom;o.forEach((y,ge)=>{if(y.dataset.visible=String(k&&E&&Q),!k||!E||!Q)return;const A=y.offsetWidth,I=y.offsetHeight,ue=l.right-r.left-A+8-(o.length-1-ge)*(A+5),he=l.top-r.top-I/2;y.style.transform=`translate(${N(ue,0,Math.max(0,t.clientWidth-A))}px, ${N(he,0,Math.max(0,t.clientHeight-I))}px)`})}},Ne=(t,e)=>{const r=t.getRootNode(),i=r instanceof ShadowRoot?r.host:null,n=i?.shadowRoot?.querySelector(".diagram-canvas")??null;return n instanceof Element?n.getBoundingClientRect():i instanceof Element?i.getBoundingClientRect():e.getBoundingClientRect()},Ge=(t,e,r)=>s`
2
2
  <div class="grill-list">
3
3
  ${e.questions.length===0?s`<p class="grill-empty">${t.noQuestions}</p>`:F(e.questions,i=>i.id,i=>Be(t,i,r))}
4
4
  </div>