@tatamicks/core 1.0.2 → 1.0.4

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 (36) hide show
  1. package/dist/PalettePanel-BTB1LkgU.cjs +9 -0
  2. package/dist/PalettePanel-BTB1LkgU.cjs.map +1 -0
  3. package/dist/{PalettePanel-Cigl9i1N.js → PalettePanel-CrA2BGLq.js} +961 -959
  4. package/dist/PalettePanel-CrA2BGLq.js.map +1 -0
  5. package/dist/PalettePanel.css +1 -1
  6. package/dist/canvas.cjs +1 -1
  7. package/dist/canvas.mjs +4 -4
  8. package/dist/index.cjs +2 -2
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.css +1 -1
  11. package/dist/index.mjs +352 -343
  12. package/dist/index.mjs.map +1 -1
  13. package/dist/{paperSettingsWidget-DvtghSA5.js → paperSettingsWidget-CAIw_Ofm.js} +1582 -1535
  14. package/dist/paperSettingsWidget-CAIw_Ofm.js.map +1 -0
  15. package/dist/paperSettingsWidget-CIRKgnz4.cjs +2 -0
  16. package/dist/paperSettingsWidget-CIRKgnz4.cjs.map +1 -0
  17. package/dist/shell.cjs +1 -1
  18. package/dist/shell.mjs +2 -2
  19. package/dist/sidebarPortal-Bigm11qq.js +880 -0
  20. package/dist/sidebarPortal-Bigm11qq.js.map +1 -0
  21. package/dist/sidebarPortal-Dit8f3sD.cjs +3 -0
  22. package/dist/sidebarPortal-Dit8f3sD.cjs.map +1 -0
  23. package/dist/src/canvas.d.ts +4 -0
  24. package/dist/src/index.d.ts +5 -3
  25. package/dist/src/shell.d.ts +3 -1
  26. package/package.json +1 -1
  27. package/dist/PalettePanel-BMZ6dfI3.cjs +0 -9
  28. package/dist/PalettePanel-BMZ6dfI3.cjs.map +0 -1
  29. package/dist/PalettePanel-Cigl9i1N.js.map +0 -1
  30. package/dist/paperSettingsWidget-7766a5Fe.cjs +0 -2
  31. package/dist/paperSettingsWidget-7766a5Fe.cjs.map +0 -1
  32. package/dist/paperSettingsWidget-DvtghSA5.js.map +0 -1
  33. package/dist/sidebarPortal-BN6FVwaF.js +0 -870
  34. package/dist/sidebarPortal-BN6FVwaF.js.map +0 -1
  35. package/dist/sidebarPortal-Cr-dLvA_.cjs +0 -3
  36. package/dist/sidebarPortal-Cr-dLvA_.cjs.map +0 -1
@@ -0,0 +1,2 @@
1
+ "use strict";require('./paperSettingsWidget.css');const i=require("./sidebarPortal-Dit8f3sD.cjs"),a=require("react"),f=require("react/jsx-runtime"),$e={kind:"fontStyle",defaultProps:{fontFamily:"sans-serif",fontSize:{value:16,unit:"px"},color:"#000000",fontWeight:!1,italic:!1,underline:!1,lineThrough:!1}},pe={kind:"padding",defaultProps:{top:{value:0,unit:"px"},right:{value:0,unit:"px"},bottom:{value:0,unit:"px"},left:{value:0,unit:"px"}}},Ge={kind:"placeholder",defaultProps:{placeholder:"テキストを入力"}},Ce={kind:"required",defaultProps:{required:!1}};var re=(e=>(e.ERROR="error",e.WARNING="warning",e.INFO="info",e))(re||{});function Xt(e){return!(e.length>200||/\((?:[^[\]()*+?\\]|\\.|\[[^\]]*\])[+*][^()]*\)[+*{]/.test(e))}function dt(e){if(typeof e!="object"||e===null)return!1;const t=e;return t.required!==void 0||t.minLength!==void 0||t.maxLength!==void 0||t.pattern!==void 0}function ft(e,t){const n=[],r=t??"";if(e.required&&r.length===0&&n.push({code:"REQUIRED",message:"必須項目です",severity:re.ERROR}),e.minLength!==void 0&&r.length<e.minLength&&n.push({code:"MIN_LENGTH",message:`${e.minLength}文字以上入力してください`,severity:re.ERROR}),e.maxLength!==void 0&&r.length>e.maxLength&&n.push({code:"MAX_LENGTH",message:`${e.maxLength}文字以内で入力してください`,severity:re.ERROR}),e.pattern&&Xt(e.pattern))try{new RegExp(e.pattern).test(r)||n.push({code:"PATTERN",message:"形式が正しくありません",severity:re.ERROR})}catch{}return n}function Zt(e,t){return e.required&&t!==!0?[{code:"REQUIRED",message:"必須項目です",severity:re.ERROR}]:[]}function He(e){return`${e}_${crypto.randomUUID()}`}function he(e,t){if(e==null||t==null)return!1;if(typeof e=="string")return!!t.get(e);const n=t.get(e.path);return"eq"in e?n===e.eq:n!==e.neq}const Ke={grid:i.DEFAULT_GRID,blocks:[]},ht={paper:i.DEFAULT_PAPER,pages:[Ke]};function Yt(e){const t=i.Z_INDEX.BLOCK_LAYER_MIN+e*i.Z_INDEX.BLOCK_LAYER_STEP;return t>=i.Z_INDEX.BLOCK_LAYER_MAX?i.Z_INDEX.BLOCK_LAYER_MAX:t}function me(e,t){const n=Math.min(Math.max(0,t),i.Z_INDEX.BLOCK_LAYER_STEP-1);return e+n}function qt(){return Math.floor((i.Z_INDEX.BLOCK_LAYER_MAX-i.Z_INDEX.BLOCK_LAYER_MIN)/i.Z_INDEX.BLOCK_LAYER_STEP)}function Qt(e){const t=[],n=new Set,r=new Set,l=qt();for(const[u,d]of e.pages.entries()){for(const o of d.blocks)n.has(o.id)?r.add(o.id):n.add(o.id);d.blocks.length>l&&t.push({message:`ページ ${u+1} のブロック数 (${d.blocks.length}) が上限 (${l}) を超えています`,code:"BLOCK_COUNT_EXCEEDED",field:d.id??`page-${u}`,severity:re.ERROR})}for(const u of r)t.push({message:`blockId "${u}" が複数ページに重複して存在します`,code:"DUPLICATE_BLOCK_ID",field:u,severity:re.ERROR});return t}function le(e){if(e.length===0)throw new Error("pages must not be empty");return e}function Jt(e){const t={...Ke,id:crypto.randomUUID()};return{...e,pages:le([...e.pages,t])}}function en(e){const t=le(e.pages.map(n=>n.id!==void 0?n:{...n,id:crypto.randomUUID()}));return{...e,pages:t}}function tn(e,t){if(e.pages.length<=1)return e;const n=e.pages.filter((r,l)=>l!==t);return{...e,pages:le(n)}}function nn(e,t,n){if(t===n)return e;const r=[...e.pages],l=r.splice(t,1)[0];return l?(r.splice(n,0,l),{...e,pages:le(r)}):e}function gt(e,t,n){return{...e,pages:le(e.pages.map((r,l)=>l===t?n:r))}}function rn(e,t,n){const r=[...e.pages.slice(0,t+1),n,...e.pages.slice(t+1)];return{...e,pages:le(r)}}function on(e,t){const n=new Set(e.pages.flatMap(r=>r.blocks.map(l=>l.id)));return Object.fromEntries(Object.entries(t).filter(([r])=>n.has(r)))}function sn(e,t){const n=i.DEFAULT_PAPER_SIZES[e],r=i.toMm.fromDim(n.width),l=i.toMm.fromDim(n.height);return t?{width:l,height:r}:{width:r,height:l}}function ln(e,t){return{...e.paper,size:(t==null?void 0:t.paperSize)!=null?i.DEFAULT_PAPER_SIZES[t.paperSize]??e.paper.size:e.paper.size,orientation:(t==null?void 0:t.orientation)??e.paper.orientation}}function an(e,t){const n=e.orientation===!0,r=Math.round(i.toMm.fromDim(n?e.size.height:e.size.width)),l=Math.round(i.toMm.fromDim(n?e.size.width:e.size.height)),u=t?`margin-top:${t.top??"0"};margin-right:${t.right??"0"};margin-bottom:${t.bottom??"0"};margin-left:${t.left??"0"};`:"margin:0;";return`@page { size: ${r}mm ${l}mm; ${u} }`}const un={[i.HorizontalAlign.left]:"flex-start",[i.HorizontalAlign.center]:"center",[i.HorizontalAlign.right]:"flex-end"},cn={[i.VerticalAlign.top]:"flex-start",[i.VerticalAlign.center]:"center",[i.VerticalAlign.bottom]:"flex-end"},Ve=a.forwardRef(({id:e,props:t,value:n,onChange:r,readOnly:l,ariaLabel:u},d)=>{var y;const o=a.useRef(null);a.useImperativeHandle(d,()=>({focus:()=>{var w;return(w=o.current)==null?void 0:w.focus()}}),[]);const h=n??!1,p=a.useMemo(()=>{const w={width:"100%",height:"100%",display:"flex",boxSizing:"border-box",overflow:"hidden",cursor:l?"default":"pointer"};w.justifyContent=un[t.horizontal??i.HorizontalAlign.center],w.alignItems=cn[t.vertical??i.VerticalAlign.center];const b=t.bulk?t.all:void 0,x=b??t.top,R=b??t.right,m=b??t.bottom,v=b??t.left;return x&&(w.paddingTop=i.dimensionToString(x)),R&&(w.paddingRight=i.dimensionToString(R)),m&&(w.paddingBottom=i.dimensionToString(m)),v&&(w.paddingLeft=i.dimensionToString(v)),w},[t,l]),s=(y=t.styleConfig)!=null&&y.checkboxSize?i.toPx.fromDim(t.styleConfig.checkboxSize):16,c=()=>{l||r(!h)};return f.jsxs("div",{ref:o,style:p,role:"switch","aria-checked":h,"aria-label":u,tabIndex:l?-1:0,onClick:c,onKeyDown:w=>{(w.key===" "||w.key==="Enter")&&(w.preventDefault(),c())},children:[f.jsx("input",{id:e,type:"checkbox",checked:h,onChange:()=>{},style:{display:"none"},tabIndex:-1,readOnly:!0}),f.jsx("div",{style:{width:s,height:s,flexShrink:0,pointerEvents:"none"},children:f.jsx(i.ClassicCheckboxVisual,{checked:h,styleConfig:t.styleConfig})})]})});Ve.displayName="CheckboxRenderer";const dn={...i.alignmentProp,defaultProps:{...i.alignmentProp.defaultProps,horizontal:i.HorizontalAlign.center}},We={kind:"checkbox",meta:{displayName:"チェックボックス",description:"チェック/非チェックを選択する入力ブロック",defaultSize:{w:2,h:2}},Renderer:Ve,properties:[dn,pe,Ce,i.checkboxStyleProp],validateProps:e=>({...typeof e=="object"&&e!==null?e:{}}),validateValue:e=>typeof e=="boolean"?e:!1},pt={kind:"selectConfig",defaultProps:{selectConfig:{options:[{label:"option1",value:"option1"},{label:"option2",value:"option2"}]}}};function rt(e){return/^#[0-9a-fA-F]{3,8}$/.test(e)}const fn={[i.HorizontalAlign.left]:"left",[i.HorizontalAlign.center]:"center",[i.HorizontalAlign.right]:"right"},hn={[i.VerticalAlign.top]:"flex-start",[i.VerticalAlign.center]:"center",[i.VerticalAlign.bottom]:"flex-end"},Fe=a.forwardRef(({id:e,props:t,value:n,onChange:r,readOnly:l,mode:u,ariaLabel:d,blockBackgroundColor:o},h)=>{var N,F,_;const p=a.useRef(null);a.useImperativeHandle(h,()=>({focus:()=>{var k;return(k=p.current)==null?void 0:k.focus()}}),[]);const s=l||u===i.NoteMode.VIEW,c=(((N=t.selectConfig)==null?void 0:N.options)??[]).find(k=>k.value===n),y=c==null?void 0:c.color,w=y&&rt(y)?y:void 0,b=a.useMemo(()=>{const k={width:"100%",height:"100%",position:"relative",display:"flex",alignItems:hn[t.vertical??i.VerticalAlign.center],boxSizing:"border-box",overflow:"hidden"};w&&(k.backgroundColor=w);const D=t.bulk?t.all:void 0,j=D??t.top,q=D??t.right,Q=D??t.bottom,te=D??t.left;return j&&(k.paddingTop=i.dimensionToString(j)),q&&(k.paddingRight=i.dimensionToString(q)),Q&&(k.paddingBottom=i.dimensionToString(Q)),te&&(k.paddingLeft=i.dimensionToString(te)),k},[t,w]),x=a.useMemo(()=>{const k={appearance:"none",WebkitAppearance:"none",background:"transparent",border:"none",outline:"none",width:"100%",height:"auto",padding:"0 20px 0 4px",boxSizing:"border-box",cursor:s?"default":"pointer",textAlign:fn[t.horizontal??i.HorizontalAlign.left]};t.fontFamily&&(k.fontFamily=t.fontFamily),t.fontSize&&(k.fontSize=`${i.toPx.fromDim(t.fontSize)}px`),t.color&&(k.color=t.color),k.fontWeight=t.fontWeight?"bold":"normal",k.fontStyle=t.italic?"italic":"normal";const D=[];return t.underline&&D.push("underline"),t.lineThrough&&D.push("line-through"),D.length>0&&(k.textDecoration=D.join(" ")),k},[t,s]),R={position:"absolute",right:6,top:"50%",transform:"translateY(-50%)",width:0,height:0,borderLeft:"5px solid transparent",borderRight:"5px solid transparent",borderTop:`5px solid ${s?"#aaa":"#555"}`,pointerEvents:"none"},m=k=>{const D=k.target.value===""?null:k.target.value;r(D)},v=k=>{var D,j;!s&&k.target!==p.current&&((j=(D=p.current)==null?void 0:D.showPicker)==null||j.call(D))},T=k=>{var D,j;!s&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),(j=(D=p.current)==null?void 0:D.showPicker)==null||j.call(D))};if(u===i.NoteMode.VIEW){const k=(c==null?void 0:c.label)??(n!=null?String(n):t.placeholder??""),D={...x,height:"auto",padding:"0 4px"};return f.jsx("div",{style:b,children:f.jsx("div",{style:D,children:k})})}const O=k=>k&&rt(k)?k:o,C=f.jsxs(f.Fragment,{children:[f.jsxs("select",{ref:p,id:e,value:n??"",onChange:m,disabled:s,style:x,"aria-label":d,children:[t.placeholder!==void 0&&!t.required&&((F=t.selectConfig)==null?void 0:F.allowEmpty)!==!1&&f.jsx("option",{value:"",style:o?{backgroundColor:o}:void 0,children:t.placeholder}),(((_=t.selectConfig)==null?void 0:_.options)??[]).map(k=>{const D=O(k.color);return f.jsx("option",{value:k.value,style:D?{backgroundColor:D}:void 0,children:k.label},k.value)})]}),f.jsx("div",{style:R,"aria-hidden":"true"})]});return s?f.jsx("div",{style:b,children:C}):f.jsx("div",{style:b,role:"none",onClick:v,onKeyDown:T,children:C})});Fe.displayName="SelectRenderer";const Pe={kind:"select",meta:{displayName:"セレクトボックス",description:"ドロップダウンから選択肢を選ぶ入力ブロック",defaultSize:{w:4,h:2}},Renderer:Fe,properties:[i.alignmentProp,pe,$e,Ge,Ce,pt],validateProps:e=>{if(typeof e!="object"||e===null)return{};const t=e,n=t.selectConfig;if(typeof n=="object"&&n!==null&&Array.isArray(n.options)&&n.options.every(d=>typeof d=="object"&&d!==null&&typeof d.label=="string"&&typeof d.value=="string"))return{...t,selectConfig:n};const{selectConfig:l,...u}=t;return{...u,selectConfig:{options:[]}}},validateValue:e=>typeof e=="string"?e:null},gn={[i.HorizontalAlign.left]:"flex-start",[i.HorizontalAlign.center]:"center",[i.HorizontalAlign.right]:"flex-end"},pn={[i.VerticalAlign.top]:"flex-start",[i.VerticalAlign.center]:"center",[i.VerticalAlign.bottom]:"flex-end"},Ue=a.forwardRef(({props:e,value:t,onChange:n,onBlur:r,readOnly:l,mode:u,onMeasureHeight:d,onMeasureWidth:o,ariaLabel:h},p)=>{const s=a.useRef(null),c=a.useRef(null),y=a.useRef(null),w=a.useRef(null),[b,x]=a.useState(null),R=a.useRef(null),m=a.useRef(null),v=t!=null?String(t):"";a.useLayoutEffect(()=>{if(!e.multiline)return;const E=y.current,L=c.current;if(!E||!L)return;const W=v+(v.endsWith(`
2
+ `)?" ":"");E.textContent=W||" ";const g=window.getComputedStyle(L),A=Number.parseFloat(g.paddingTop),$=Number.parseFloat(g.paddingBottom),B=Number.parseFloat(g.paddingLeft),z=Number.parseFloat(g.paddingRight),I=L.clientWidth-B-z;E.style.width=`${I}px`,E.style.paddingTop="0px",E.style.paddingBottom="0px";const S=E.scrollHeight;if(x(S),d){const P=S+A+$;P!==R.current&&(R.current=P,d(P))}},[e,v,d]),a.useLayoutEffect(()=>{if(!o)return;const E=w.current;if(!E)return;E.textContent=v;const L=E.offsetWidth+2;L!==m.current&&(m.current=L,o(L))},[v,o]),a.useImperativeHandle(p,()=>({focus:()=>{var E;return(E=s.current)==null?void 0:E.focus()}}),[]);const T=!l,O=a.useMemo(()=>{const E={position:"relative",width:"100%",height:"100%",display:"flex",boxSizing:"border-box",overflow:"hidden",cursor:T?"text":"default"};E.justifyContent=gn[e.horizontal??i.HorizontalAlign.left],E.alignItems=pn[e.vertical??i.VerticalAlign.center];const L=e.bulk?e.all:void 0,W=L??e.top,g=L??e.right,A=L??e.bottom,$=L??e.left;return W&&(E.paddingTop=i.dimensionToString(W)),g&&(E.paddingRight=i.dimensionToString(g)),A&&(E.paddingBottom=i.dimensionToString(A)),$&&(E.paddingLeft=i.dimensionToString($)),E},[e,T]),C=a.useMemo(()=>{const E={background:"transparent",border:"none",outline:"none",resize:"none",padding:0,margin:0,width:"100%",whiteSpace:o?e.multiline?"pre":"nowrap":void 0,boxSizing:"border-box",fontFamily:"inherit",color:"inherit"};e.fontSize&&(E.fontSize=`${i.toPx.fromDim(e.fontSize)}px`),e.fontFamily&&(E.fontFamily=e.fontFamily),e.color&&(E.color=e.color),E.fontWeight=e.fontWeight?"bold":"normal",E.fontStyle=e.italic?"italic":"normal";const L=[];switch(e.underline&&L.push("underline"),e.lineThrough&&L.push("line-through"),E.textDecoration=L.length>0?L.join(" "):"none",e.lineHeight&&(E.lineHeight=e.lineHeight),e.horizontal){case i.HorizontalAlign.center:E.textAlign="center";break;case i.HorizontalAlign.right:E.textAlign="right";break;default:E.textAlign="left"}return E},[e,o]),N=a.useMemo(()=>({...C,position:"absolute",top:0,left:0,visibility:"hidden",pointerEvents:"none",whiteSpace:"pre",width:"auto",height:"auto",overflow:"visible"}),[C]),F=a.useMemo(()=>{const E=!!o;return{...C,position:"absolute",top:0,left:0,width:"100%",height:"auto",visibility:"hidden",pointerEvents:"none",overflow:"hidden",whiteSpace:E?"pre":"pre-wrap",wordWrap:E?"normal":"break-word",overflowWrap:E?"normal":"break-word",padding:0,border:"none",boxSizing:"border-box"}},[C,o]),_=E=>{n(E.target.value)},k=()=>{r==null||r(t)},D=a.useMemo(()=>{if(!e.pattern)return null;const E=e.pattern.match(/^(\[.+?\])\+$/);if(!E)return null;try{return new RegExp(`^${E[1]}$`)}catch{return null}},[e.pattern]),j=a.useMemo(()=>e.inputType==="number"?"numeric":e.inputType==="tel"?"tel":e.inputType==="email"?"email":e.inputType==="url"?"url":e.pattern==="[0-9]+"?"numeric":"text",[e.inputType,e.pattern]),q=a.useCallback(E=>{if(!D)return;const L=E.nativeEvent;if(L.data){for(const W of L.data)if(!D.test(W)){E.preventDefault();return}}},[D]),Q=a.useCallback(E=>{if(!D)return;const L=E.currentTarget,W=[...L.value].filter(g=>D.test(g)).join("");W!==L.value&&n(W)},[D,n]),K=u===i.NoteMode.EDIT||u===i.NoteMode.FORM?e.placeholder:void 0,M=E=>{var L;T&&E.target===E.currentTarget&&((L=s.current)==null||L.focus())};if(e.multiline){const E={...C,resize:"none",overflow:o||u===i.NoteMode.VIEW?"hidden":"auto",height:b!==null?`${b}px`:"auto"},L=W=>{s.current=W};return f.jsxs("div",{ref:c,style:O,role:"none",onClick:M,onKeyDown:W=>{var g;T&&(W.key==="Enter"||W.key===" ")&&((g=s.current)==null||g.focus())},children:[f.jsx("div",{ref:y,style:F,"aria-hidden":"true"}),f.jsx("textarea",{ref:L,value:v,onChange:_,onBlur:k,onBeforeInput:q,onCompositionEnd:Q,inputMode:j,style:E,placeholder:K,readOnly:!T,tabIndex:T?0:-1,"aria-label":h}),o&&f.jsx("span",{ref:w,"aria-hidden":"true",style:N})]})}return f.jsxs("div",{style:O,role:"none",onClick:M,onKeyDown:E=>{var L;T&&(E.key==="Enter"||E.key===" ")&&((L=s.current)==null||L.focus())},children:[f.jsx("input",{ref:s,type:e.inputType??"text",value:v,onChange:_,onBlur:k,onBeforeInput:q,onCompositionEnd:Q,inputMode:j,style:C,placeholder:K,readOnly:!T,tabIndex:T?0:-1,"aria-label":h,min:e.min,max:e.max,step:e.step}),o&&f.jsx("span",{ref:w,"aria-hidden":"true",style:N})]})});Ue.displayName="TextRenderer";const ae={kind:"text",meta:{displayName:"テキスト",description:"テキスト入力用ブロック",defaultSize:{w:3,h:1}},Renderer:Ue,properties:[i.alignmentProp,pe,$e,Ge,Ce,i.textBehaviorProp,i.textValidationProp],validateProps:e=>{const n={...typeof e=="object"&&e!==null?e:{}};typeof n.minLength!="number"&&(n.minLength=void 0),typeof n.maxLength!="number"&&(n.maxLength=void 0),typeof n.pattern!="string"&&(n.pattern=void 0),["text","number","email","tel","url","date","password"].includes(n.inputType)||(n.inputType=void 0);for(const l of["min","max","step"])l in n&&typeof n[l]!="number"&&(n[l]=void 0);return n},validateValue:e=>{if(typeof e=="string")return e;if(typeof e=="number")return String(e)}};function mn(e){const t=a.useRef(e);t.current=e;const n=a.useCallback((l,u)=>{const d=t.current[l];d&&(u!==void 0&&d.validatePayload!==void 0&&!d.validatePayload(u)||d.execute(u))},[]),r=a.useCallback(l=>{var u;return((u=t.current[l])==null?void 0:u.isEnabled())??!1},[]);return a.useMemo(()=>({execute:n,isEnabled:r}),[n,r])}function Se(e,t,n){if(t.length===0)return n;const[r,...l]=t,u=typeof e=="object"&&e!==null?e:{};return{...u,[r]:Se(u[r],l,n)}}function yn(e,t,n){const r=t.split(".");return Se(e,r,n)}function Ae(e,t){const n=t.split(".");let r=e;for(const l of n){if(r===null||typeof r!="object")return null;r=r[l]}return r??null}function xn(e,t,n){const r=a.useRef(e);r.current=e;const l=a.useRef((n==null?void 0:n.pageIdx)??0);l.current=(n==null?void 0:n.pageIdx)??0;const u=a.useRef(n==null?void 0:n.extra);u.current=n==null?void 0:n.extra;const d=a.useCallback(h=>{var c;const p=u.current;if(p){const y=p.get(h);if(y!==void 0)return y}const s=r.current;return h.startsWith("margin.")?Ae(s.paper.margin,h.slice(7)):h.startsWith("grid.")?Ae((c=s.pages[l.current])==null?void 0:c.grid,h.slice(5)):Ae(s,h)},[]),o=a.useCallback((h,p)=>{var y;const s=u.current;if(s&&s.get(h)!==void 0){s.set(h,p);return}const c=r.current;if(h.startsWith("margin.")){if(h==="margin.bulk"&&p===!0){const x=c.paper.margin,R=(y=x.all)!=null&&y.unit?x.all:x.top;t({...c,paper:{...c.paper,margin:{...x,bulk:!0,all:R}}},{mergeKey:i.bindingKey(h)});return}const w=h.slice(7),b=Se(c.paper.margin,w.split("."),p);t({...c,paper:{...c.paper,margin:b}},{mergeKey:i.bindingKey(h)});return}if(h.startsWith("grid.")){const w=l.current,b=c.pages[w];if(!b)return;const x=Se(b.grid,h.slice(5).split("."),p),R=c.pages.map((m,v)=>v===w?{...m,grid:x}:m);t({...c,pages:R},{mergeKey:i.bindingKey(h)});return}t(yn(c,h,p),{mergeKey:i.bindingKey(h)})},[t]);return a.useMemo(()=>({get:d,set:o}),[d,o])}const vn=500;function wn(e,t){switch(t.type){case"push":{const n=e.entries[e.idx];if(t.mergeKey!==void 0&&(n==null?void 0:n.mergeKey)===t.mergeKey&&(t.noTimeWindow===!0||t.timestamp-((n==null?void 0:n.timestamp)??0)<vn))return{entries:[...e.entries.slice(0,e.idx),{book:t.book,mergeKey:t.mergeKey,timestamp:t.timestamp}],idx:e.idx};const l=[...e.entries.slice(0,e.idx+1),{book:t.book,mergeKey:t.mergeKey,timestamp:t.timestamp}],u=l.length>t.maxHistory?l.slice(l.length-t.maxHistory):l;return{entries:u,idx:u.length-1}}case"undo":return{...e,idx:Math.max(0,e.idx-1)};case"redo":return{...e,idx:Math.min(e.entries.length-1,e.idx+1)}}}const ot=100;function bn({initialBook:e,maxHistory:t=ot}){var p;const n=t??ot,[r,l]=a.useReducer(wn,void 0,()=>({entries:[{book:e,timestamp:Date.now()}],idx:0})),u=((p=r.entries[r.idx])==null?void 0:p.book)??e,d=a.useCallback((s,c)=>{l({type:"push",book:s,mergeKey:c==null?void 0:c.mergeKey,noTimeWindow:c==null?void 0:c.noTimeWindow,timestamp:Date.now(),maxHistory:n})},[n]),o=a.useCallback(()=>l({type:"undo"}),[]),h=a.useCallback(()=>l({type:"redo"}),[]);return{book:u,handleBookChange:d,canUndo:r.idx>0,canRedo:r.idx<r.entries.length-1,undo:o,redo:h,historyActionHandlers:{undo:{execute:o,isEnabled:()=>r.idx>0},redo:{execute:h,isEnabled:()=>r.idx<r.entries.length-1}}}}function En(e,t){if(e===i.LineType.DASHED)return`${t*4} ${t*2}`;if(e===i.LineType.DOTTED)return`${t*1} ${t*2}`}function we(e,t){return{stroke:e.color,strokeWidth:i.toPx.fromDim(e.width,t),strokeDasharray:En(e.type,e.width.value)}}const ue=a.memo(({blockSizePx:e,borderStyle:t,blockZIndex:n,subZIndex:r=i.BLOCK_SUB_INDEX.BORDER,visible:l=!0,dpi:u=i.DEFAULT_DPI})=>{if(!l||!t)return null;const{top:d,right:o,bottom:h,left:p}=t;if(!d&&!o&&!h&&!p)return null;const{width:s,height:c}=e,y=me(n,r);return f.jsxs("svg",{role:"presentation","aria-hidden":"true",style:{position:"absolute",inset:0,width:`${s}px`,height:`${c}px`,pointerEvents:"none",overflow:"visible",zIndex:y},width:s,height:c,"data-testid":"block-border",children:[d&&f.jsx("line",{x1:0,y1:0,x2:s,y2:0,...we(d,u)}),o&&f.jsx("line",{x1:s,y1:0,x2:s,y2:c,...we(o,u)}),h&&f.jsx("line",{x1:0,y1:c,x2:s,y2:c,...we(h,u)}),p&&f.jsx("line",{x1:0,y1:0,x2:0,y2:c,...we(p,u)})]})});ue.displayName="BlockBorder";const ye=a.memo(({blockSizePx:e,blockZIndex:t,subZIndex:n=i.BLOCK_SUB_INDEX.BG,backgroundColor:r="transparent"})=>{const l=me(t,n),u={position:"absolute",inset:0,width:`${e.width}px`,height:`${e.height}px`,backgroundColor:r,pointerEvents:"none",zIndex:l};return f.jsx("div",{style:u,role:"presentation","aria-hidden":"true","data-testid":"block-canvas"})});ye.displayName="BlockCanvas";function be(e,t){if(e===i.LineType.DASHED)return`${t*3} ${t*2}`;if(e===i.LineType.DOTTED)return`${t} ${t*2}`}const Te={top:{color:"#cccccc",width:{value:1,unit:"px"},type:i.LineType.SOLID},right:{color:"#cccccc",width:{value:1,unit:"px"},type:i.LineType.SOLID},bottom:{color:"#cccccc",width:{value:1,unit:"px"},type:i.LineType.SOLID},left:{color:"#cccccc",width:{value:1,unit:"px"},type:i.LineType.SOLID}},Ne=a.memo(({blockSizePx:e,blockZIndex:t,subZIndex:n=i.BLOCK_SUB_INDEX.GUIDE,borderStyle:r=Te,visible:l=!0})=>{if(!l||!r)return null;const{top:u,right:d,bottom:o,left:h}=r;if(!u&&!d&&!o&&!h)return null;const{width:p,height:s}=e,c=me(t,n);return f.jsxs("svg",{role:"presentation","aria-hidden":"true",style:{position:"absolute",inset:0,width:`${p}px`,height:`${s}px`,pointerEvents:"none",overflow:"visible",zIndex:c},width:p,height:s,"data-testid":"block-guide-border",children:[u&&f.jsx("line",{x1:0,y1:0,x2:p,y2:0,stroke:u.color,strokeWidth:u.width.value,strokeDasharray:be(u.type,u.width.value)}),d&&f.jsx("line",{x1:p,y1:0,x2:p,y2:s,stroke:d.color,strokeWidth:d.width.value,strokeDasharray:be(d.type,d.width.value)}),o&&f.jsx("line",{x1:0,y1:s,x2:p,y2:s,stroke:o.color,strokeWidth:o.width.value,strokeDasharray:be(o.type,o.width.value)}),h&&f.jsx("line",{x1:0,y1:0,x2:0,y2:s,stroke:h.color,strokeWidth:h.width.value,strokeDasharray:be(h.type,h.width.value)})]})});Ne.displayName="BlockGuideBorder";const kn=({id:e,resolvedPlugin:t,props:n,value:r,onChange:l,onBlur:u,readOnly:d,mode:o,blockSizePx:h,blockZIndex:p,subZIndex:s=i.BLOCK_SUB_INDEX.CONTENT,onMeasureHeight:c,onMeasureWidth:y,bindingContext:w,actionContext:b,blockBackgroundColor:x},R)=>{const m=a.useRef(null);a.useImperativeHandle(R,()=>({focus:()=>{var N;return(N=m.current)==null?void 0:N.focus()}}),[]);const v=me(p,s),T={position:"absolute",inset:0,width:`${h.width}px`,height:`${h.height}px`,zIndex:v,pointerEvents:"auto"},O={id:e,props:n,value:r,onChange:l??(()=>{}),onBlur:u,readOnly:d,mode:o,dimensions:{widthPx:h.width,heightPx:h.height},onMeasureHeight:c,onMeasureWidth:y,ariaLabel:t.meta.displayName,bindingContext:w,actionContext:b,blockBackgroundColor:x},{Renderer:C}=t;return f.jsx("div",{style:T,"data-testid":"block-renderer","data-block-id":e,"data-plugin-kind":t.kind,children:f.jsx(C,{ref:m,...O})})},xe=a.memo(a.forwardRef(kn));xe.displayName="BlockRenderer";function Xe(e,t,n){const r=(n==null?void 0:n[e.kind])??{};return{...t.defaultProps,...r,...e.props}}const Ze=a.memo(({blockSizePx:e,blockZIndex:t,errors:n})=>{const[r,l]=a.useState(!1);if(n.length===0)return null;const u=me(t,i.BLOCK_SUB_INDEX.VALIDATION),d=3,o="repeating-linear-gradient(45deg, #1a1a1a 0px, #1a1a1a 4px, #FFD700 4px, #FFD700 8px)",h={position:"absolute",top:-d,left:-d,width:`${e.width+d*2}px`,height:`${e.height+d*2}px`,zIndex:u,pointerEvents:"none"},p=s=>({position:"absolute",background:o,...s});return f.jsxs("div",{style:h,"data-testid":"validation-overlay",children:[f.jsx("div",{style:p({top:0,left:0,width:"100%",height:d})}),f.jsx("div",{style:p({bottom:0,left:0,width:"100%",height:d})}),f.jsx("div",{style:p({top:0,left:0,width:d,height:"100%"})}),f.jsx("div",{style:p({top:0,right:0,width:d,height:"100%"})}),f.jsxs("button",{type:"button",style:{position:"absolute",top:-8,right:-8,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,lineHeight:1,cursor:"default",pointerEvents:"auto",userSelect:"none",background:"none",border:"none",padding:0},onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),"aria-label":n.map(s=>s.message).join(" / "),children:["⚠",r&&f.jsx("div",{style:{position:"absolute",top:"calc(100% + 4px)",right:0,minWidth:160,maxWidth:240,backgroundColor:"rgba(30,30,30,0.92)",color:"#fff",fontSize:11,lineHeight:1.5,padding:"6px 8px",borderRadius:4,boxShadow:"0 2px 6px rgba(0,0,0,0.4)",pointerEvents:"none",whiteSpace:"pre-wrap",wordBreak:"break-all",zIndex:u+1},children:n.map(s=>f.jsx("div",{children:s.message},s.code))})]}),f.jsx("style",{children:'@media print { [data-testid="validation-overlay"] { display: none !important; } }'})]})});Ze.displayName="ValidationOverlay";const Ye=a.memo(a.forwardRef(({block:e,resolvedPlugin:t,blockRectPx:n,blockZIndex:r,mode:l,value:u,blockDefaults:d,onValueChange:o,onBlur:h,showGuides:p=!0,showBorder:s=!0,defaultGuideBorder:c=Te,dpi:y=i.DEFAULT_DPI,pointerEvents:w="none",showValidation:b=!1,validationErrors:x,onMeasureHeight:R,onMeasureWidth:m,focusedBlockId:v,bindingContext:T,actionContext:O},C)=>{var $,B,z,I,S;const[N,F]=a.useState(null),[_,k]=a.useState(null),D=a.useCallback(P=>{F(P),R==null||R(e.id,P)},[e.id,R]),j=a.useCallback(P=>{k(P),m==null||m(e.id,P)},[e.id,m]),q=R?Math.max(n.height,N??0):n.height,Q=m?Math.max(n.width,_??0):n.width,te={position:"absolute",left:`${n.left}px`,top:`${n.top}px`,width:`${Q}px`,height:`${q}px`,zIndex:r,pointerEvents:w,boxSizing:"border-box"},K=a.useMemo(()=>({width:Q,height:q}),[Q,q]),M=Xe(e,t,d),E=t.validateProps?t.validateProps(M):M,L=t.validateValue?t.validateValue(u,E)??e.initValue??u:u,W=x&&x.length>0,g=W?`error-${e.id}`:void 0,A=v===e.id;return f.jsxs("section",{"aria-label":t.meta.displayName,"aria-invalid":W||void 0,"aria-describedby":g,style:te,"data-testid":`block-${e.id}`,"data-block-id":e.id,children:[f.jsx(ye,{blockSizePx:K,blockZIndex:r,backgroundColor:($=e.style)==null?void 0:$.backgroundColor,subZIndex:i.BLOCK_SUB_INDEX.BG}),p&&!((B=e.style)!=null&&B.border)&&f.jsx(Ne,{blockSizePx:K,blockZIndex:r,subZIndex:i.BLOCK_SUB_INDEX.GUIDE,borderStyle:c}),f.jsx(xe,{ref:C,id:e.id,resolvedPlugin:t,props:E,value:L,onChange:o,onBlur:h,readOnly:l===i.NoteMode.EDIT?((z=e.behavior)==null?void 0:z.readOnly)??!1:!0,mode:l,blockSizePx:K,blockZIndex:r,subZIndex:i.BLOCK_SUB_INDEX.CONTENT,onMeasureHeight:R?D:void 0,onMeasureWidth:m?j:void 0,bindingContext:T,actionContext:O,blockBackgroundColor:(I=e.style)==null?void 0:I.backgroundColor}),f.jsx(ue,{blockSizePx:K,blockZIndex:r,borderStyle:(S=e.style)==null?void 0:S.border,subZIndex:i.BLOCK_SUB_INDEX.BORDER,visible:s,dpi:y}),b&&W&&f.jsx(Ze,{blockSizePx:K,blockZIndex:r,errors:x}),W&&f.jsx("span",{id:g,style:{position:"absolute",width:"1px",height:"1px",padding:0,margin:"-1px",overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0},children:x.map(P=>P.message).join(", ")}),A&&f.jsx("div",{"aria-hidden":"true",style:{position:"absolute",inset:0,boxShadow:"0 0 0 2px #3b82f6, 0 0 0 4px rgba(59,130,246,0.15)",pointerEvents:"none",zIndex:i.Z_INDEX.HOVER_OUTLINE,boxSizing:"border-box"}})]})}),(e,t)=>e.block===t.block&&e.resolvedPlugin===t.resolvedPlugin&&e.blockRectPx.left===t.blockRectPx.left&&e.blockRectPx.top===t.blockRectPx.top&&e.blockRectPx.width===t.blockRectPx.width&&e.blockRectPx.height===t.blockRectPx.height&&e.blockZIndex===t.blockZIndex&&e.mode===t.mode&&e.value===t.value&&e.blockDefaults===t.blockDefaults&&e.showGuides===t.showGuides&&e.showBorder===t.showBorder&&e.defaultGuideBorder===t.defaultGuideBorder&&e.dpi===t.dpi&&e.pointerEvents===t.pointerEvents&&e.showValidation===t.showValidation&&e.validationErrors===t.validationErrors&&e.onMeasureHeight===t.onMeasureHeight&&e.onMeasureWidth===t.onMeasureWidth&&e.focusedBlockId===t.focusedBlockId&&e.bindingContext===t.bindingContext&&e.actionContext===t.actionContext);Ye.displayName="BlockContainer";const In=(e,t)=>{},Dn=(e,t)=>{},ve=a.memo(({blocks:e,pluginRegistry:t,mode:n,values:r,blockDefaults:l,selectedBlockIds:u=[],getBlockRectPx:d,onValueChange:o,onBlur:h,showGuides:p=!0,showBorder:s=!0,defaultGuideBorder:c=Te,dpi:y=i.DEFAULT_DPI,showValidation:w=!1,validationErrors:b,onMeasureHeight:x,onMeasureWidth:R,focusedBlockId:m,bindingContext:v,actionContext:T})=>{const O=a.useRef(new Map),C={position:"absolute",inset:0,pointerEvents:"none"};return f.jsx("div",{style:C,"data-testid":"block-layer",children:e.map((N,F)=>{var L,W;const _=t[N.kind];if(!_)return console.warn(`[tatamicks] Block kind "${N.kind}" is not registered. Add the plugin to createPluginRegistry.`),null;if(he(N.hiddenBinding,v))return null;const D=d(N),q=u.includes(N.id)?i.Z_INDEX.SELECT_BLOCK:Yt(F),Q=N.props!==null&&typeof N.props=="object"&&"binding"in N.props?N.props.binding:void 0,te=Q&&v?v.get(Q)??null:N.id in r?r[N.id]:N.initValue??null,K=Q&&v?g=>v.set(Q,g):o?g=>o(N.id,g):void 0,M=(L=N.behavior)!=null&&L.heightFit?x??In:void 0,E=(W=N.behavior)!=null&&W.widthFit?R??Dn:void 0;return f.jsx(a.Fragment,{children:f.jsx(Ye,{ref:g=>{g?O.current.set(N.id,g):O.current.delete(N.id)},block:N,resolvedPlugin:_,blockRectPx:D,blockZIndex:q,mode:n,value:te??null,blockDefaults:l,onValueChange:K,onBlur:h?g=>h(N.id,g):void 0,showGuides:p,showBorder:s,defaultGuideBorder:c,dpi:y,pointerEvents:"none",showValidation:w,validationErrors:b==null?void 0:b[N.id],onMeasureHeight:M,onMeasureWidth:E,focusedBlockId:m,bindingContext:v,actionContext:T})},N.id)})})});ve.displayName="BlockLayer";function mt(e){if(!(e!=null&&e.width)||!(e!=null&&e.type))return;const t=e.width.value;if(t!==0){if(e.type===i.LineType.DASHED)return`${t*4} ${t*2}`;if(e.type===i.LineType.DOTTED)return`${t*1} ${t*2}`}}function Ee(e,t){return{stroke:e.color,strokeWidth:i.toPx.fromDim(e.width,t),strokeDasharray:mt(e)}}const yt=a.memo(({contentPx:e,marginLeftPx:t,marginTopPx:n,borderStyle:r,dpi:l=i.DEFAULT_DPI,zIndex:u=i.Z_INDEX.BORDER_OVERLAY})=>{if(!r)return null;const{top:d,right:o,bottom:h,left:p}=r;if(!d&&!o&&!h&&!p)return null;const s=e.width,c=e.height;return f.jsxs("svg",{role:"presentation","aria-hidden":"true",style:{position:"absolute",left:`${t}px`,top:`${n}px`,pointerEvents:"none",overflow:"visible",zIndex:u},width:s,height:c,"data-testid":"border-overlay",children:[d&&f.jsx("line",{x1:0,y1:0,x2:s,y2:0,...Ee(d,l)}),o&&f.jsx("line",{x1:s,y1:0,x2:s,y2:c,...Ee(o,l)}),h&&f.jsx("line",{x1:0,y1:c,x2:s,y2:c,...Ee(h,l)}),p&&f.jsx("line",{x1:0,y1:0,x2:0,y2:c,...Ee(p,l)})]})});yt.displayName="BorderOverlay";const xt=a.memo(({canvasPx:e,backgroundColor:t="#ffffff",boxShadow:n="0 2px 8px rgba(0, 0, 0, 0.1)",zIndex:r=i.Z_INDEX.GRID_CANVAS})=>f.jsx("div",{role:"presentation","aria-label":"Paper background","data-testid":"grid-canvas",style:{position:"absolute",inset:0,width:`${e.width}px`,height:`${e.height}px`,backgroundColor:t,boxShadow:n,pointerEvents:"none",zIndex:r}}));xt.displayName="GridCanvas";const Sn="_label_er4b8_1",Rn={label:Sn},Cn="_editor_1xj3w_1",Pn="_input_1xj3w_14",Tn="_select_1xj3w_29",Nn="_button_1xj3w_45",ke={editor:Cn,input:Pn,select:Tn,button:Nn},Ln=["fr","px","mm","cm","pt","inch"];function Mn(e,t){if(t==="fr")return 1;switch(t){case"px":return e;case"mm":return Math.round(i.toMm.fromPx(e)*10)/10;case"cm":return Math.round(i.toMm.fromPx(e)/10*100)/100;case"inch":return Math.round(i.toMm.fromPx(e)/25.4*100)/100;case"pt":return Math.round(i.toMm.fromPx(e)/25.4*72*10)/10;default:{const n=t;throw new Error(`Unsupported unit: ${n}`)}}}const vt=a.memo(({direction:e,dimension:t,currentPxSize:n,position:r,marginLeftPx:l,marginTopPx:u,onChange:d,onCancel:o})=>{const[h,p]=a.useState(t.value.toString()),[s,c]=a.useState(t.unit),y=a.useRef(null),w=a.useRef(null),b=e==="column"?{left:`${l+r}px`,top:`${u+24}px`,transform:"translateX(-50%)"}:{left:`${l+24}px`,top:`${u+r}px`,transform:"translateY(-50%)"};a.useEffect(()=>{var v,T;(v=y.current)==null||v.focus(),(T=y.current)==null||T.select()},[]),a.useEffect(()=>{const v=T=>{w.current&&!w.current.contains(T.target)&&o()};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[o]);const x=()=>{const v=Number.parseFloat(h);!Number.isNaN(v)&&v>=.1?d({unit:s,value:v}):o()},R=v=>{v.key==="Enter"?(v.preventDefault(),x()):v.key==="Escape"&&(v.preventDefault(),o())},m=v=>{const T=v.target.value;c(T),p(Mn(n,T).toString())};return f.jsxs("div",{ref:w,className:ke.editor,style:b,"data-testid":`grid-unit-editor-${e}`,children:[f.jsx("input",{ref:y,type:"number",className:ke.input,value:h,onChange:v=>p(v.target.value),onKeyDown:R,min:"0.1",step:s==="fr"?"0.1":"1"}),f.jsx("select",{className:ke.select,value:s,onChange:m,children:Ln.map(v=>f.jsx("option",{value:v,children:v},v))}),f.jsx("button",{type:"button",className:ke.button,onClick:x,title:"確定",children:"✓"})]})});vt.displayName="GridUnitEditor";function An(e,t,n,r){if(t==="fr")return n!==void 0&&r!==void 0&&r>0?Math.round(n*(e/r)*100)/100:1;switch(t){case"px":return Math.round(e);case"mm":return Math.round(i.toMm.fromPx(e)*10)/10;case"cm":return Math.round(i.toMm.fromPx(e)/10*100)/100;case"inch":return Math.round(i.toMm.fromPx(e)/25.4*100)/100;case"pt":return Math.round(i.toMm.fromPx(e)/25.4*72*10)/10;default:{const l=t;throw new Error(`Unsupported unit: ${l}`)}}}const Oe=a.memo(({direction:e,index:t,dimension:n,position:r,currentPxSize:l,marginLeftPx:u,marginTopPx:d,isNearCursor:o,resizingPxSize:h,onDimensionChange:p})=>{const[s,c]=a.useState(!1);if(!o&&!s)return null;const y=e==="column"?{left:`${u+r}px`,top:`${d-20}px`,transform:"translateX(-50%)"}:{left:`${u-20}px`,top:`${d+r}px`,transform:"translateY(-50%)",writingMode:"vertical-rl"},b=h?(()=>{const x=An(h,n.unit,n.value,l);return n.unit==="fr"?`${x}fr`:`${x}${n.unit}`})():(x=>x.unit==="fr"?`${x.value}fr`:`${x.value}${x.unit}`)(n);return f.jsxs(f.Fragment,{children:[f.jsx("button",{type:"button",className:Rn.label,style:y,onDoubleClick:()=>c(!0),"data-testid":`grid-dimension-${e}-${t}`,"aria-label":`グリッド寸法: ${b}`,children:b}),s&&f.jsx(vt,{direction:e,dimension:n,currentPxSize:l,position:r,marginLeftPx:u,marginTopPx:d,onChange:x=>{p==null||p(e,t,x),c(!1)},onCancel:()=>c(!1)})]})});Oe.displayName="GridDimensionLabel";function _n(e,t,n,r){let l="";for(const u of e)l+=`M ${u} 0 L ${u} ${r} `;for(const u of t)l+=`M 0 ${u} L ${n} ${u} `;return l}const wt=a.memo(({gridPosPx:e,contentPx:t,marginLeftPx:n,marginTopPx:r,lineStyle:l,zIndex:u=i.Z_INDEX.GRID_OVERLAY,dpi:d=i.DEFAULT_DPI})=>{const o=a.useMemo(()=>_n(e.cols.slice(1,-1),e.rows.slice(1,-1),t.width,t.height),[e,t]);return l?f.jsx("svg",{style:{position:"absolute",left:`${n}px`,top:`${r}px`,pointerEvents:"none",zIndex:u},width:t.width,height:t.height,role:"img","aria-label":"Grid overlay lines",children:f.jsx("path",{d:o,stroke:l.color,strokeWidth:i.toPx.fromDim(l.width,d),strokeDasharray:mt(l),fill:"none"})}):null});wt.displayName="GridOverlay";const Bn="_handle_i8g0e_1",On="_dragging_i8g0e_19",st={handle:Bn,dragging:On},ze=a.memo(({direction:e,index:t,position:n,marginLeftPx:r,marginTopPx:l,onResizeStart:u,onResize:d,onResizeEnd:o})=>{const[h,p]=a.useState(!1),s=12,c=s/2,y=e==="column"?{left:`${r+n-c}px`,top:`${l-c}px`,width:`${s}px`,height:`${s}px`,cursor:"col-resize"}:{left:`${r-c}px`,top:`${l+n-c}px`,width:`${s}px`,height:`${s}px`,cursor:"row-resize"},w=a.useCallback(b=>{b.stopPropagation(),b.preventDefault();const x=e==="column"?b.clientX:b.clientY;p(!0),u==null||u(e,t);const R=v=>{const T=e==="column"?v.clientX:v.clientY;d==null||d(e,t,T-x)},m=v=>{const T=e==="column"?v.clientX:v.clientY;p(!1),o==null||o(e,t,T-x),window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",m)};window.addEventListener("pointermove",R),window.addEventListener("pointerup",m)},[e,t,u,d,o]);return f.jsx("div",{className:`${st.handle} ${h?st.dragging:""}`,style:y,onPointerDown:w,"data-testid":`grid-resize-handle-${e}-${t}`})});ze.displayName="GridResizeHandle";const bt=a.memo(({paperPx:e,marginColor:t="rgba(0, 0, 0, 0.05)",zIndex:n=i.Z_INDEX.MARGIN_OVERLAY})=>{const r={position:"absolute",backgroundColor:t,pointerEvents:"none"};return f.jsxs("div",{role:"presentation","aria-label":"Printable area margin","data-testid":"margin-overlay",style:{position:"absolute",inset:0,pointerEvents:"none",width:`${e.canvas.width}px`,height:`${e.canvas.height}px`,zIndex:n},children:[e.margin.top>0&&f.jsx("div",{"data-testid":"margin-top",style:{...r,top:0,left:0,width:"100%",height:`${e.margin.top}px`}}),e.margin.bottom>0&&f.jsx("div",{"data-testid":"margin-bottom",style:{...r,bottom:0,left:0,width:"100%",height:`${e.margin.bottom}px`}}),e.margin.left>0&&f.jsx("div",{"data-testid":"margin-left",style:{...r,left:0,top:`${e.margin.top}px`,height:`${e.content.height}px`,width:`${e.margin.left}px`}}),e.margin.right>0&&f.jsx("div",{"data-testid":"margin-right",style:{...r,right:0,top:`${e.margin.top}px`,height:`${e.content.height}px`,width:`${e.margin.right}px`}})]})});bt.displayName="MarginOverlay";const Le=a.memo(({paperPx:e,gridPosPx:t,gridDimensions:n,gridLineStyle:r,borderStyle:l,backgroundColor:u="#ffffff",boxShadow:d="0 2px 8px rgba(0, 0, 0, 0.1)",marginFillColor:o,showGridLines:h=!0,showMargins:p=!0,showBorder:s=!0,showResizeHandles:c=!1,showDimensionLabels:y=!1,dpi:w=i.DEFAULT_DPI,onGridResize:b,onDimensionChange:x,className:R="",zIndex:m={}})=>{const[v,T]=a.useState(null),[O,C]=a.useState(null),[N,F]=a.useState(null),_=a.useRef(null);a.useEffect(()=>{const K=E=>{if(!_.current)return;const L=_.current.getBoundingClientRect();F({x:E.clientX-L.left,y:E.clientY-L.top})},M=E=>{if(!_.current)return;const L=_.current.getBoundingClientRect();(E.clientX<L.left||E.clientX>L.right||E.clientY<L.top||E.clientY>L.bottom)&&F(null)};return window.addEventListener("mousemove",K),window.addEventListener("mouseleave",M),()=>{window.removeEventListener("mousemove",K),window.removeEventListener("mouseleave",M)}},[]);const k=a.useMemo(()=>N?!(N.x>=e.margin.left&&N.x<=e.margin.left+e.content.width&&N.y>=e.margin.top&&N.y<=e.margin.top+e.content.height):!1,[N,e]),D=a.useMemo(()=>{if(!v||!O)return null;const K=O.direction==="column"?t.cols:t.rows,M=O.index,E=K[M-1],L=K[M+1];return{direction:O.direction,prevIndex:M-1,prevSize:E!==void 0?v.position-E:0,nextIndex:M,nextSize:L!==void 0?L-v.position:0}},[v,O,t]),j=a.useCallback((K,M,E)=>{const W=K==="column"?t.cols:t.rows,g=W[M];if(g===void 0)return E;const A=W[M-1],$=W[M+1];let B=E;return A!==void 0&&(B=Math.max(B,A+10-g)),$!==void 0&&(B=Math.min(B,$-10-g)),B},[t]),q=a.useCallback((K,M)=>{C({direction:K,index:M})},[]),Q=a.useCallback((K,M,E)=>{const W=(K==="column"?t.cols:t.rows)[M];W!==void 0&&T({direction:K,position:W+j(K,M,E)})},[t,j]),te=a.useCallback((K,M,E)=>{T(null),C(null),b==null||b(K,M,j(K,M,E))},[j,b]);return f.jsxs("div",{ref:_,className:R,style:{position:"relative",width:"100%",height:"100%"},children:[f.jsx(xt,{canvasPx:e.canvas,backgroundColor:u,boxShadow:d,zIndex:m.canvas??i.Z_INDEX.GRID_CANVAS}),p&&f.jsx(bt,{paperPx:e,marginColor:o,zIndex:m.margin??i.Z_INDEX.MARGIN_OVERLAY}),h&&f.jsx(wt,{gridPosPx:t,contentPx:e.content,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,lineStyle:r,dpi:w,zIndex:m.grid??i.Z_INDEX.GRID_OVERLAY}),s&&f.jsx(yt,{contentPx:e.content,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,borderStyle:l,dpi:w,zIndex:m.border??i.Z_INDEX.BORDER_OVERLAY}),c&&b&&f.jsxs(f.Fragment,{children:[t.cols.map((K,M)=>M===0||M===t.cols.length-1?null:f.jsx(ze,{direction:"column",index:M,position:K,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,onResizeStart:q,onResize:Q,onResizeEnd:te},`col-${K}`)),t.rows.map((K,M)=>M===0||M===t.rows.length-1?null:f.jsx(ze,{direction:"row",index:M,position:K,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,onResizeStart:q,onResize:Q,onResizeEnd:te},`row-${K}`))]}),y&&n&&f.jsxs(f.Fragment,{children:[n.cols.map((K,M)=>{const E=t.cols[M],L=t.cols[M+1];if(E===void 0||L===void 0)return null;const W=(O==null?void 0:O.direction)==="column"&&(O.index===M||O.index===M+1);let g;return(D==null?void 0:D.direction)==="column"&&(D.prevIndex===M?g=D.prevSize:D.nextIndex===M&&(g=D.nextSize)),f.jsx(Oe,{direction:"column",index:M,dimension:K,position:(E+L)/2,currentPxSize:L-E,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,isNearCursor:k||W,resizingPxSize:g,onDimensionChange:x},`col-dim-${E}`)}),n.rows.map((K,M)=>{const E=t.rows[M],L=t.rows[M+1];if(E===void 0||L===void 0)return null;const W=(O==null?void 0:O.direction)==="row"&&(O.index===M||O.index===M+1);let g;return(D==null?void 0:D.direction)==="row"&&(D.prevIndex===M?g=D.prevSize:D.nextIndex===M&&(g=D.nextSize)),f.jsx(Oe,{direction:"row",index:M,dimension:K,position:(E+L)/2,currentPxSize:L-E,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,isNearCursor:k||W,resizingPxSize:g,onDimensionChange:x},`row-dim-${E}`)})]}),v&&f.jsx("div",{style:{position:"absolute",left:v.direction==="column"?e.margin.left+v.position:e.margin.left,top:v.direction==="row"?e.margin.top+v.position:e.margin.top,width:v.direction==="column"?"2px":e.content.width,height:v.direction==="row"?"2px":e.content.height,backgroundColor:"#3b82f6",opacity:.5,pointerEvents:"none",zIndex:i.Z_INDEX.GRID_GHOST}})]})});Le.displayName="GridLayer";function Et(e){return a.useState({editingBlockId:null,...e})}var ee=(e=>(e.IDLE="idle",e.PRESSING="pressing",e.DRAGGING="dragging",e.INSERT="insert",e.EDITING="editing",e))(ee||{}),V=(e=>(e.N="n",e.NE="ne",e.E="e",e.SE="se",e.S="s",e.SW="sw",e.W="w",e.NW="nw",e))(V||{}),J=(e=>(e.MOVE="move",e.RESIZE="resize",e.INSERT="insert",e))(J||{});function kt(e){return e.editingBlockId!==null?"editing":e.dragging?e.dragging.type==="insert"?"insert":e.dragging.type==="resize"||e.dragging.currentGrid.col!==e.dragging.startGrid.col||e.dragging.currentGrid.row!==e.dragging.startGrid.row?"dragging":"pressing":"idle"}function It({layout:e,handle:t,deltaCol:n,deltaRow:r,gridCols:l,gridRows:u}){const d={...e};if(t===V.E||t===V.NE||t===V.SE){const o=l-e.x;d.w=Math.max(1,Math.min(e.w+n,o))}else if(t===V.W||t===V.NW||t===V.SW){const o=e.w-1,h=n>0?Math.min(n,o):n;e.x+h>=0?(d.x=e.x+h,d.w=e.w-h):(d.x=0,d.w=e.w+e.x)}if(t===V.S||t===V.SE||t===V.SW){const o=u-e.y;d.h=Math.max(1,Math.min(e.h+r,o))}else if(t===V.N||t===V.NE||t===V.NW){const o=e.h-1,h=r>0?Math.min(r,o):r;e.y+h>=0?(d.y=e.y+h,d.h=e.h-h):(d.y=0,d.h=e.h+e.y)}return d}function Dt(e,t,n,r,l){if(e.length===0)return[];if(e.length===1){const x=e[0];if(!x)return[];const R=r-x.layout.w,m=l-x.layout.h;return[{blockId:x.id,x:Math.max(0,Math.min(x.layout.x+t,R)),y:Math.max(0,Math.min(x.layout.y+n,m))}]}const u=Math.min(...e.map(x=>x.layout.x)),d=Math.min(...e.map(x=>x.layout.y)),o=Math.max(...e.map(x=>x.layout.x+x.layout.w)),h=Math.max(...e.map(x=>x.layout.y+x.layout.h)),p=o-u,s=h-d,c=Math.max(0,Math.min(u+t,r-p)),y=Math.max(0,Math.min(d+n,l-s)),w=c-u,b=y-d;return e.map(x=>({blockId:x.id,x:x.layout.x+w,y:x.layout.y+b}))}function fe(e,t){var n,r;return{id:He(e.kind),kind:e.kind,layout:{x:t.x,y:t.y,w:((n=e.meta.defaultSize)==null?void 0:n.w)??1,h:((r=e.meta.defaultSize)==null?void 0:r.h)??1},props:{}}}const zn={top:{color:"#888888",width:{value:3,unit:"px"},type:i.LineType.DASHED},right:{color:"#888888",width:{value:3,unit:"px"},type:i.LineType.DASHED},bottom:{color:"#888888",width:{value:3,unit:"px"},type:i.LineType.DASHED},left:{color:"#888888",width:{value:3,unit:"px"},type:i.LineType.DASHED}},De=a.memo(({block:e,resolvedPlugin:t,blockDefaults:n,rect:r,opacity:l,ghostZIndex:u})=>{var h,p,s;const d=Xe(e,t,n),o={width:r.width,height:r.height};return f.jsxs("div",{style:{position:"absolute",left:`${r.left}px`,top:`${r.top}px`,width:`${r.width}px`,height:`${r.height}px`,opacity:l,zIndex:u,pointerEvents:"none"},children:[f.jsx(ye,{blockSizePx:o,blockZIndex:0,subZIndex:i.BLOCK_SUB_INDEX.BG,backgroundColor:(h=e.style)==null?void 0:h.backgroundColor}),f.jsx(xe,{id:e.id,resolvedPlugin:t,props:d,value:e.initValue??null,readOnly:!0,mode:i.NoteMode.FORM,blockSizePx:o,blockZIndex:0,subZIndex:i.BLOCK_SUB_INDEX.CONTENT}),!((p=e.style)!=null&&p.border)&&f.jsx(Ne,{blockSizePx:o,blockZIndex:0,subZIndex:i.BLOCK_SUB_INDEX.GUIDE,borderStyle:zn}),f.jsx(ue,{blockSizePx:o,borderStyle:(s=e.style)==null?void 0:s.border,blockZIndex:0,subZIndex:i.BLOCK_SUB_INDEX.BORDER,dpi:i.DEFAULT_DPI})]})});De.displayName="GhostBlock";const St=a.memo(({blocks:e,pluginRegistry:t,gridLength:n,draggingState:r,getBlockRectPx:l,blockDefaults:u,ghostZIndex:d=i.Z_INDEX.BLOCK_GHOST})=>{if(!r)return null;const o=r.currentGrid.col-r.startGrid.col,h=r.currentGrid.row-r.startGrid.row,p={position:"absolute",inset:0,pointerEvents:"none"};if(r.type===J.MOVE){const s=r.blockIds.map(y=>e.find(w=>w.id===y)).filter(Boolean),c=Dt(s,o,h,n.cols,n.rows);return f.jsx("div",{style:p,"data-testid":"drag-layer-move",children:s.map(y=>{const w=t[y.kind];if(!w)return null;let b;const x=r.isOutside??!1,R=r.currentMousePx;if(x&&R){const m=l(y);b={left:R.x-m.width/2,top:R.y-m.height/2,width:m.width,height:m.height}}else{const m=c.find(T=>T.blockId===y.id);if(!m)return null;const v={...y,layout:{...y.layout,x:m.x,y:m.y}};b=l(v)}return f.jsx(De,{block:y,resolvedPlugin:w,blockDefaults:u,rect:b,opacity:x?.3:.5,ghostZIndex:d},y.id)})})}if(r.type===J.RESIZE){const s=r.blockIds[0],c=r.handle;if(!s||!c)return null;const y=e.find(m=>m.id===s),w=y?t[y.kind]:void 0;if(!y||!w)return null;const b=It({layout:y.layout,handle:c,deltaCol:o,deltaRow:h,gridCols:n.cols,gridRows:n.rows}),x={...y,layout:b},R=l(x);return f.jsx("div",{style:p,"data-testid":"drag-layer-resize",children:f.jsx(De,{block:y,resolvedPlugin:w,blockDefaults:u,rect:R,opacity:r.isOutside?.3:.5,ghostZIndex:d})})}if(r.type===J.INSERT){const{pluginKind:s,defaultSize:c,currentGrid:y,currentMousePx:w}=r;if(!s||!c)return null;const b=t[s];if(!b)return null;const x=r.isOutside??!1;let R;if(x&&w){const v=fe(b,{x:0,y:0}),T=l({...v,layout:{...v.layout,w:c.w,h:c.h}});R={left:w.x-T.width/2,top:w.y-T.height/2,width:T.width,height:T.height}}else{const v=n.cols-c.w,T=n.rows-c.h,O=Math.max(0,Math.min(y.col,v)),C=Math.max(0,Math.min(y.row,T)),N=fe(b,{x:O,y:C}),F={...N,layout:{...N.layout,w:c.w,h:c.h}};R=l(F)}const m={...fe(b,{x:0,y:0}),layout:{x:0,y:0,w:c.w,h:c.h}};return f.jsx("div",{style:p,"data-testid":"drag-layer-insert",children:f.jsx(De,{block:m,resolvedPlugin:b,blockDefaults:u,rect:R,opacity:x?.3:.5,ghostZIndex:d})})}return null});St.displayName="DragLayer";const jn=({id:e,resolvedPlugin:t,props:n,value:r,onChange:l,blockRectPx:u,block:d,zIndex:o=i.Z_INDEX.EDIT_BLOCK,bindingContext:h,actionContext:p},s)=>{var w,b;const c=a.useRef(null);a.useImperativeHandle(s,()=>({focus:()=>{var x;return(x=c.current)==null?void 0:x.focus()}}),[]);const y={width:u.width,height:u.height};return f.jsxs("div",{style:{position:"absolute",left:`${u.left}px`,top:`${u.top}px`,width:`${y.width}px`,height:`${y.height}px`,zIndex:o,pointerEvents:"auto"},"data-testid":"editing-block",children:[f.jsx(ye,{blockSizePx:y,blockZIndex:0,subZIndex:i.BLOCK_SUB_INDEX.BG,backgroundColor:(w=d.style)==null?void 0:w.backgroundColor}),f.jsx(xe,{ref:c,id:e,resolvedPlugin:t,props:n,value:r,onChange:l,readOnly:!1,mode:i.NoteMode.EDIT,blockSizePx:y,blockZIndex:0,subZIndex:i.BLOCK_SUB_INDEX.CONTENT,bindingContext:h,actionContext:p}),f.jsx(ue,{blockSizePx:y,borderStyle:(b=d.style)==null?void 0:b.border,blockZIndex:0,subZIndex:i.BLOCK_SUB_INDEX.BORDER,dpi:i.DEFAULT_DPI})]})},Rt=a.memo(a.forwardRef(jn));Rt.displayName="EditingBlock";const Ie={color:"#3b82f688",width:{value:4,unit:"px"},type:i.LineType.SOLID},Ct={top:Ie,right:Ie,bottom:Ie,left:Ie},je=12,se=je/2,$n=[{id:V.NW,cursor:"nwse-resize",x:0,y:0},{id:V.N,cursor:"ns-resize",x:50,y:0},{id:V.NE,cursor:"nesw-resize",x:100,y:0},{id:V.W,cursor:"ew-resize",x:0,y:50},{id:V.E,cursor:"ew-resize",x:100,y:50},{id:V.SW,cursor:"nesw-resize",x:0,y:100},{id:V.S,cursor:"ns-resize",x:50,y:100},{id:V.SE,cursor:"nwse-resize",x:100,y:100}],Pt=a.memo(({block:e,rect:t,showHandles:n=!1,onResizeStart:r,activeHandle:l,selectionStyle:u=Ct,selectBorderZIndex:d=i.Z_INDEX.BLOCK_SELECT_BORDER,blockHandlesZIndex:o=i.Z_INDEX.BLOCK_HANDLES})=>{const h={position:"absolute",left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,pointerEvents:"none"};return f.jsxs("div",{style:h,"data-testid":"interaction-block","data-block-id":e.id,children:[f.jsx(ue,{blockSizePx:{width:t.width,height:t.height},borderStyle:u,blockZIndex:d,subZIndex:0,dpi:i.DEFAULT_DPI}),n&&r&&$n.map(({id:p,cursor:s,x:c,y})=>{const w=c===50?`calc(50% - ${se}px)`:c===100?`calc(100% - ${se}px)`:`-${se}px`,b=y===50?`calc(50% - ${se}px)`:y===100?`calc(100% - ${se}px)`:`-${se}px`,x=l===p;return f.jsx("div",{onPointerDown:R=>{R.stopPropagation(),r(R,p)},style:{position:"absolute",left:w,top:b,width:`${je}px`,height:`${je}px`,backgroundColor:x?"#3b82f6":"#ffffff",border:"1px solid #3b82f6",borderRadius:"50%",cursor:s,zIndex:o,pointerEvents:"auto",boxSizing:"border-box",transform:x?"scale(1.2)":void 0},"data-testid":`resize-handle-${p}`},p)})]})});Pt.displayName="InteractionBlock";const Tt=a.memo(({blocks:e,selectedBlockIds:t,isDragging:n,draggingState:r,getBlockRectPx:l,onResizeStart:u,selectionStyle:d=Ct,selectBorderZIndex:o,blockHandlesZIndex:h})=>{if(n&&(r==null?void 0:r.type)!==J.RESIZE)return null;const s=Array.from(new Set(t));return f.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:s.map(c=>{const y=e.find(x=>x.id===c);if(!y)return null;const b=(r==null?void 0:r.type)===J.RESIZE&&r.blockIds.includes(c)?r==null?void 0:r.handle:null;return f.jsx(Pt,{block:y,rect:l(y),showHandles:!0,onResizeStart:(x,R)=>u(x,R,c),activeHandle:b??null,selectionStyle:d,selectBorderZIndex:o,blockHandlesZIndex:h},y.id)})})});Tt.displayName="SelectionLayer";function Nt(e,t,n,r){const l=n-t.w,u=r-t.h;return{x:Math.max(0,Math.min(e.x,l)),y:Math.max(0,Math.min(e.y,u))}}function Gn(e,t,n){const r=e.x+e.w<t?e.x+1:Math.max(0,e.x-1),l=e.y+e.h<n?e.y+1:Math.max(0,e.y-1);return{x:r,y:l}}function lt(e,t,n){const{x:r,y:l}=e;for(let u=t.length-1;u>=0;u--){const d=t[u];if(!d)continue;const o=n(d);if(r>=o.left&&r<=o.left+o.width&&l>=o.top&&l<=o.top+o.height)return d.id}return null}const qe=a.memo(({page:e,pluginRegistry:t,gridLength:n,blockDefaults:r,getBlockRectPx:l,getColIndex:u,getRowIndex:d,state:o,onStateChange:h,selectedBlockIds:p,onSelectionChange:s,onPageChange:c,actionContext:y,bindingContext:w,scale:b=1,className:x="",selectionStyle:R})=>{const m=e.blocks,v=a.useRef(null),T=a.useRef(null),O=a.useRef(null);a.useEffect(()=>()=>{O.current!==null&&clearTimeout(O.current)},[]);const C=kt(o),N=a.useRef(null),F=a.useRef(0),_=a.useRef(null),k=a.useRef(0),D=a.useRef(o);D.current=o;const j=a.useRef(h);j.current=h,a.useEffect(()=>{if(C!==ee.INSERT)return;const g=A=>{const $=v.current;$&&(A.target===$||$.contains(A.target))||j.current({...D.current,dragging:void 0})};return window.addEventListener("pointerup",g),()=>window.removeEventListener("pointerup",g)},[C]),a.useEffect(()=>{if(C===ee.EDITING&&o.editingBlockId){const g=setTimeout(()=>{var A;(A=T.current)==null||A.focus()},0);return()=>clearTimeout(g)}},[C,o.editingBlockId]),a.useEffect(()=>{const g=new Set(m.map($=>$.id)),A=p.filter($=>g.has($));A.length!==p.length&&s(A)},[m,p,s]);const q=a.useCallback(g=>{var P;if(g.button!==0)return;const A=(P=v.current)==null?void 0:P.getBoundingClientRect();if(!A)return;const $=b,B={x:(g.clientX-A.left)/$,y:(g.clientY-A.top)/$},z=lt(B,m,l);if(C===ee.EDITING){z!==o.editingBlockId&&(h({...o,editingBlockId:null}),z||s([]));return}const I=u(B.x),S=d(B.y);if(z){g.stopPropagation();const H=p.includes(z);if(H&&g.shiftKey){s(p.filter(Y=>Y!==z));return}g.currentTarget.setPointerCapture(g.pointerId),H?h({...o,dragging:{type:J.MOVE,blockIds:p,startGrid:{col:I,row:S},currentGrid:{col:I,row:S},isOutside:!1}}):g.shiftKey?s([...p,z]):(s([z]),h({...o,dragging:{type:J.MOVE,blockIds:[z],startGrid:{col:I,row:S},currentGrid:{col:I,row:S},isOutside:!1}}))}else g.stopPropagation(),s([])},[m,l,u,d,C,p,s,h,b,o]),Q=a.useCallback(g=>{var X;if(C!==ee.PRESSING&&C!==ee.DRAGGING&&C!==ee.INSERT||!o.dragging)return;const A=(X=v.current)==null?void 0:X.getBoundingClientRect();if(!A)return;const $=b,B=A.width/$,z=A.height/$,I=(g.clientX-A.left)/$,S=(g.clientY-A.top)/$,P=o.dragging.type!==J.RESIZE&&(I<0||I>B||S<0||S>z),H=Math.max(0,Math.min(I,B)),Y=Math.max(0,Math.min(S,z));let G=u(H),Z=d(Y);if(o.dragging.type===J.RESIZE&&o.dragging.handle){const U=o.dragging.handle;(U===V.E||U===V.NE||U===V.SE)&&(G=u(H)+1),(U===V.S||U===V.SE||U===V.SW)&&(Z=d(Y)+1)}h({...o,dragging:{...o.dragging,currentGrid:{col:G,row:Z},currentMousePx:{x:I,y:S},isOutside:P}})},[C,o,u,d,h,b]),te=a.useCallback(g=>{if((C===ee.DRAGGING||C===ee.INSERT)&&o.dragging){if(o.dragging.isOutside){if(o.dragging.type===J.MOVE){const B=new Set(o.dragging.blockIds);c({...e,blocks:m.filter(z=>!B.has(z.id))}),s([])}h({...o,dragging:void 0}),g.currentTarget.releasePointerCapture(g.pointerId);return}const A=o.dragging.currentGrid.col-o.dragging.startGrid.col,$=o.dragging.currentGrid.row-o.dragging.startGrid.row;if(o.dragging.type===J.MOVE&&(A!==0||$!==0)){const B=o.dragging.blockIds.map(z=>m.find(I=>I.id===z)).filter(Boolean);if(B.length>0){const z=Dt(B,A,$,n.cols,n.rows);c({...e,blocks:m.map(I=>{const S=z.find(P=>P.blockId===I.id);return S?{...I,layout:{...I.layout,x:S.x,y:S.y}}:I})})}}else if(o.dragging.type===J.INSERT){const{pluginKind:B,currentGrid:z,defaultSize:I}=o.dragging;if(B&&I){const S=t[B];if(S){const{x:P,y:H}=Nt({x:z.col,y:z.row},{w:I.w,h:I.h},n.cols,n.rows),Y={...fe(S,{x:P,y:H}),layout:{x:P,y:H,w:I.w,h:I.h}};c({...e,blocks:[...m,Y]}),s([Y.id])}}}else if(o.dragging.type===J.RESIZE){const B=o.dragging.blockIds[0],z=m.find(S=>S.id===B),I=o.dragging.handle;if(z&&I&&(A!==0||$!==0)){const S=It({layout:z.layout,handle:I,deltaCol:A,deltaRow:$,gridCols:n.cols,gridRows:n.rows});(S.x!==z.layout.x||S.y!==z.layout.y||S.w!==z.layout.w||S.h!==z.layout.h)&&c({...e,blocks:m.map(P=>P.id===z.id?{...P,layout:S}:P)})}}h({...o,dragging:void 0})}else if(C===ee.PRESSING&&o.dragging){if(o.dragging.isOutside&&o.dragging.type===J.MOVE){const A=new Set(o.dragging.blockIds);c({...e,blocks:m.filter($=>!A.has($.id))}),s([])}h({...o,dragging:void 0})}g.currentTarget.releasePointerCapture(g.pointerId)},[C,o,m,e,n,t,c,h,s]),K=a.useCallback(g=>{var I;const A=(I=v.current)==null?void 0:I.getBoundingClientRect();if(!A)return;const $=b,B={x:(g.clientX-A.left)/$,y:(g.clientY-A.top)/$},z=lt(B,m,l);z&&(p.includes(z)||s([z]),h({...o,editingBlockId:z}))},[m,l,s,h,b,p,o]),M=a.useCallback(g=>{var A;if((C===ee.PRESSING||C===ee.DRAGGING||C===ee.INSERT)&&o.dragging){const $=(A=v.current)==null?void 0:A.getBoundingClientRect();if(!$)return;const B=b,z=(g.clientX-$.left)/B,I=(g.clientY-$.top)/B,S=$.width/B,P=$.height/B,H=Math.max(0,Math.min(z,S)),Y=Math.max(0,Math.min(I,P));h({...o,dragging:{...o.dragging,currentGrid:{col:u(H),row:d(Y)},currentMousePx:{x:z,y:I},isOutside:!0}})}},[C,o,b,u,d,h]),E=a.useCallback(g=>{const A=C===ee.EDITING;if(g.key==="Escape"){A?(g.preventDefault(),h({...o,editingBlockId:null}),O.current=setTimeout(()=>{var G;return(G=v.current)==null?void 0:G.focus()},0)):p.length>0&&(g.preventDefault(),s([]));return}if(A)return;if(g.key.toLowerCase()==="z"&&(g.ctrlKey||g.metaKey)&&!g.shiftKey){g.preventDefault(),y==null||y.execute("undo");return}if(g.key.toLowerCase()==="y"&&(g.ctrlKey||g.metaKey)||g.key.toLowerCase()==="z"&&(g.ctrlKey||g.metaKey)&&g.shiftKey){g.preventDefault(),y==null||y.execute("redo");return}if(g.key==="c"&&(g.ctrlKey||g.metaKey)&&p.length>0){g.preventDefault(),y.execute("copy");return}if(g.key==="x"&&(g.ctrlKey||g.metaKey)&&p.length>0){g.preventDefault(),y.execute("copy");const G=new Set(p);c({...e,blocks:m.filter(Z=>!G.has(Z.id))}),s([]);return}if(g.key==="v"&&(g.ctrlKey||g.metaKey)){y.isEnabled("paste")&&(g.preventDefault(),y.execute("paste"));return}if(g.key==="d"&&(g.ctrlKey||g.metaKey)&&p.length>0){g.preventDefault();const Z=m.filter(X=>p.includes(X.id)).map(X=>{const{x:U,y:ne}=Gn(X.layout,n.cols,n.rows);return{...X,id:He(X.kind),layout:{...X.layout,x:U,y:ne}}});c({...e,blocks:[...m,...Z]}),s(Z.map(X=>X.id));return}if((g.key==="Delete"||g.key==="Backspace")&&p.length>0){g.preventDefault();const G=new Set(p);c({...e,blocks:m.filter(Z=>!G.has(Z.id))}),s([]);return}if(g.key==="a"&&(g.ctrlKey||g.metaKey)){if(m.length===0)return;g.preventDefault(),s(m.map(G=>G.id));return}if(g.key==="Tab"){if(m.length===0)return;const G=[...m].sort((U,ne)=>U.layout.y!==ne.layout.y?U.layout.y-ne.layout.y:U.layout.x-ne.layout.x),Z=p.length===1?p[0]:null,X=Z!==null?G.findIndex(U=>U.id===Z):-1;if(g.shiftKey){if(X<=0){s([]);return}const U=G[X-1];if(!U)return;g.preventDefault(),s([U.id])}else if(X===-1){const U=G[0];if(!U)return;g.preventDefault(),s([U.id])}else if(X>=G.length-1){s([]);return}else{const U=G[X+1];if(!U)return;g.preventDefault(),s([U.id])}return}if(p.length===0)return;if(g.shiftKey){const Z={ArrowRight:{dw:1,dh:0},ArrowLeft:{dw:-1,dh:0},ArrowDown:{dw:0,dh:1},ArrowUp:{dw:0,dh:-1}}[g.key];if(!Z)return;g.preventDefault();const X=[...p].sort().join(","),U=_.current;(U===null||U.direction!==g.key||U.blockIds!==X)&&(k.current+=1,_.current={direction:g.key,blockIds:X,id:k.current});const ne=_.current;if(!ne)return;c({...e,blocks:m.map(ie=>{if(!p.includes(ie.id))return ie;const Ft=Math.max(1,Math.min(ie.layout.w+Z.dw,n.cols-ie.layout.x)),Ut=Math.max(1,Math.min(ie.layout.h+Z.dh,n.rows-ie.layout.y));return{...ie,layout:{...ie.layout,w:Ft,h:Ut}}})},{mergeKey:i.keyboardResizeKey(String(ne.id)),noTimeWindow:!0});return}const B={ArrowLeft:{deltaCol:-1,deltaRow:0},ArrowRight:{deltaCol:1,deltaRow:0},ArrowUp:{deltaCol:0,deltaRow:-1},ArrowDown:{deltaCol:0,deltaRow:1}}[g.key];if(!B||(g.preventDefault(),!m.filter(G=>p.includes(G.id)).every(G=>{const Z=G.layout.x+B.deltaCol,X=G.layout.y+B.deltaRow;return Z>=0&&Z+G.layout.w<=n.cols&&X>=0&&X+G.layout.h<=n.rows})))return;const S=[...p].sort().join(","),P=N.current;(P===null||P.direction!==g.key||P.blockIds!==S)&&(F.current+=1,N.current={direction:g.key,blockIds:S,id:F.current});const H=N.current;if(!H)return;const Y=String(H.id);c({...e,blocks:m.map(G=>p.includes(G.id)?{...G,layout:{...G.layout,x:G.layout.x+B.deltaCol,y:G.layout.y+B.deltaRow}}:G)},{mergeKey:i.arrowMoveKey(Y),noTimeWindow:!0})},[C,p,m,e,n,o,h,s,c,y]),L=a.useCallback((g,A,$)=>{C===ee.EDITING&&h({...o,editingBlockId:null}),g.currentTarget.setPointerCapture(g.pointerId);const B=m.find(S=>S.id===$);if(!B)return;const z=(()=>{switch(A){case V.E:case V.NE:case V.SE:return B.layout.x+B.layout.w;case V.W:case V.NW:case V.SW:return B.layout.x;default:return 0}})(),I=(()=>{switch(A){case V.S:case V.SE:case V.SW:return B.layout.y+B.layout.h;case V.N:case V.NE:case V.NW:return B.layout.y;default:return 0}})();h({...o,dragging:{type:J.RESIZE,blockIds:[$],startGrid:{col:z,row:I},currentGrid:{col:z,row:I},handle:A,isOutside:!1}})},[C,o,m,h]),W=(()=>{if(!o.editingBlockId)return null;const g=m.find(B=>B.id===o.editingBlockId),A=g?t[g.kind]:null;if(!g||!A)return null;const $=Xe(g,A,r);return f.jsx(Rt,{ref:T,id:g.id,resolvedPlugin:A,props:$,value:g.initValue??null,onChange:B=>{c({...e,blocks:m.map(z=>z.id===g.id?{...z,initValue:B}:z)},{mergeKey:i.initValueKey(g.id)})},blockRectPx:l(g),block:g,bindingContext:w,actionContext:y})})();return f.jsxs("div",{ref:v,className:x,style:{position:"absolute",inset:0,zIndex:i.Z_INDEX.INTERACTION_LAYER_BASE,pointerEvents:"auto",touchAction:"none"},role:"application","aria-label":"Interactive canvas layer",tabIndex:-1,onPointerDown:q,onPointerMove:Q,onPointerUp:te,onPointerLeave:M,onDoubleClick:K,onKeyDown:E,"data-testid":"interaction-layer",children:[W,f.jsx(Tt,{blocks:m,selectedBlockIds:p,isDragging:C===ee.DRAGGING,draggingState:o.dragging,getBlockRectPx:l,onResizeStart:L,selectionStyle:R}),f.jsx(St,{blocks:m,pluginRegistry:t,gridLength:n,draggingState:o.dragging,getBlockRectPx:l,blockDefaults:r,selectionStyle:R})]})});qe.displayName="InteractionLayer";const Me=a.createContext(null);function Re(e,t){switch(t){case"px":return Math.round(e);case"mm":return Math.round(i.toMm.fromPx(e)*10)/10;case"cm":return Math.round(i.toMm.fromPx(e)/10*100)/100;case"inch":return Math.round(i.toMm.fromPx(e)/25.4*100)/100;case"pt":return Math.round(i.toMm.fromPx(e)/25.4*72*10)/10;case"fr":return 1;default:{const n=t;throw new Error(`Unsupported unit: ${n}`)}}}function at(e,t,n,r,l){const u=e[t],d=e[t+1];if(!u||!d)return e;let o=0,h=0;for(const c of e)c.unit==="fr"?o+=c.value:h+=i.toPx.fromDim(c);const p=l-h,s=o>0?p/o:0;if(r==="next"){const c=i.toPx.fromDim(d),y=Math.max(10,c-n);e[t+1]={...d,value:Re(y,d.unit)};const w=p-(y-c),b=Math.max(10,u.value*s+n),x=o>0?b/w*o:1;e[t]={...u,value:Math.round(x*100)/100}}else{const c=i.toPx.fromDim(u),y=Math.max(10,c+n);e[t]={...u,value:Re(y,u.unit)};const w=p-(y-c),b=Math.max(10,d.value*s-n),x=o>0?b/w*o:1;e[t+1]={...d,value:Math.round(x*100)/100}}return e}function Hn(e,t,n){const r=e[t],l=e[t+1];if(!r||!l)return e;const u=Math.max(10,i.toPx.fromDim(r)+n),d=Math.max(10,i.toPx.fromDim(l)-n);return e[t]={...r,value:Re(u,r.unit)},e[t+1]={...l,value:Re(d,l.unit)},e}function Kn(e,t,n,r){const l=e[t],u=e[t+1];if(!l||!u)return e;const d=e.reduce((s,c)=>c.unit==="fr"?s+c.value:s,0),o=r/d,h=Math.max(10,l.value*o+n)/o,p=Math.max(10,u.value*o-n)/o;return e[t]={...l,value:Math.round(h*100)/100},e[t+1]={...u,value:Math.round(p*100)/100},e}function ut(e,t,n,r){if(t<0||t>=e.length)return e;const l=[...e],u=l[t],d=l[t+1];return!u||!d?e:u.unit==="fr"&&d.unit==="fr"?Kn(l,t,n,r):u.unit!=="fr"&&d.unit!=="fr"?Hn(l,t,n):u.unit==="fr"&&d.unit!=="fr"?at(l,t,n,"next",r):at(l,t,n,"current",r)}function Lt({book:e,pageIdx:t,showValidation:n,values:r,bindingContext:l}){const u=e.pages[t]??e.pages[0],d=e.paper,{paperPx:o,gridPosPx:h,getBlockRectPx:p}=i.useGridCalc(d,u.grid,i.DEFAULT_DPI),s=d.autoHeight===!0,c=d.autoWidth===!0,[y,w]=a.useState(new Map),[b,x]=a.useState(new Map),R=a.useCallback((_,k)=>{w(D=>{if(D.get(_)===k)return D;const j=new Map(D);return j.set(_,k),j})},[]),m=a.useCallback((_,k)=>{x(D=>{if(D.get(_)===k)return D;const j=new Map(D);return j.set(_,k),j})},[]),v=a.useMemo(()=>{if(!s||y.size===0)return 0;let _=0;for(const k of u.blocks){if(he(k.hiddenBinding,l))continue;const j=p(k),q=y.get(k.id)??j.height;_=Math.max(_,j.top-o.margin.top+q)}return _},[s,y,u.blocks,p,o.margin.top,l]),T=a.useMemo(()=>{if(!c||b.size===0)return 0;let _=0;for(const k of u.blocks){if(he(k.hiddenBinding,l))continue;const j=p(k),q=b.get(k.id)??j.width;_=Math.max(_,j.left-o.margin.left+q)}return _},[c,b,u.blocks,p,o.margin.left,l]),O=a.useMemo(()=>!s||v===0&&y.size===0?o.canvas.height:o.margin.top+Math.max(0,v)+o.margin.bottom,[s,o,v,y.size]),C=a.useMemo(()=>{const _=(h.cols[h.cols.length-1]??0)+o.margin.left+o.margin.right;if(!c||T===0&&b.size===0)return _;const k=o.margin.left+Math.max(0,T)+o.margin.right;return Math.max(_,k)},[c,o,h.cols,T,b.size]),N=a.useMemo(()=>({...o,canvas:{...o.canvas,height:O,width:C}}),[o,O,C]),F=a.useMemo(()=>{if(!n)return;const _={};for(const k of u.blocks){if(!dt(k.props))continue;const D=r[k.id],j=D==null?void 0:String(D),q=ft(k.props,j);q.length>0&&(_[k.id]=q)}return _},[n,u.blocks,r]);return{page:u,isFit:s,isWidthFit:c,paperPx:o,gridPosPx:h,getBlockRectPx:p,measuredHeights:y,measuredWidths:b,handleMeasureHeight:R,handleMeasureWidth:m,canvasHeightPx:O,canvasWidthPx:C,effectivePaperPx:N,validationErrors:F}}const Mt=a.memo(function({context:t,showValidation:n=!1,scale:r=1,className:l}){const{book:u,pluginRegistry:d}=t,o=t.values,h=t.onValuesChange,p=a.useCallback((D,j)=>h==null?void 0:h([{id:D,value:j}]),[h]),{page:s,isFit:c,isWidthFit:y,gridPosPx:w,getBlockRectPx:b,handleMeasureHeight:x,handleMeasureWidth:R,canvasHeightPx:m,canvasWidthPx:v,effectivePaperPx:T,validationErrors:O}=Lt({book:u,pageIdx:t.editorState.pageIdx,showValidation:n,values:o,bindingContext:t.bindingContext}),[C,N]=a.useState(null),F=a.useMemo(()=>[...s.blocks].sort((D,j)=>D.layout.y!==j.layout.y?D.layout.y-j.layout.y:D.layout.x-j.layout.x),[s.blocks]),_=a.useCallback(D=>{const j=D.target.closest("[data-block-id]");N((j==null?void 0:j.getAttribute("data-block-id"))??null)},[]),k=a.useCallback(D=>{D.currentTarget.contains(D.relatedTarget)||N(null)},[]);return f.jsx(Me.Provider,{value:d,children:f.jsxs("form",{"data-testid":"note-container","aria-label":"フォーム",className:l,onSubmit:D=>D.preventDefault(),onFocusCapture:_,onBlurCapture:k,style:{position:"relative",width:`${v}px`,height:`${m}px`,margin:"0 auto",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",backgroundColor:"#fff",transform:r!==1?`scale(${r})`:void 0,transformOrigin:"top center",...i.STACKING_ISOLATION_STYLE},children:[f.jsx(Le,{paperPx:T,gridPosPx:w,showGridLines:!1,showMargins:!1,showBorder:!1}),f.jsx(ve,{blocks:F,pluginRegistry:d,mode:i.NoteMode.EDIT,values:o,blockDefaults:s.blockDefaults,getBlockRectPx:b,onMeasureHeight:c?x:void 0,onMeasureWidth:y?R:void 0,onValueChange:h?p:void 0,showGuides:!0,showBorder:!0,showValidation:n,validationErrors:O,focusedBlockId:C??void 0,bindingContext:t.bindingContext,actionContext:t.actionContext})]})})}),At=a.memo(function({context:t,scale:n=1,className:r}){const{book:l,onBookChange:u,pluginRegistry:d}=t,o=t.editorState.pageIdx,h=t.editorState.selectedBlockIds,p=t.actionContext,s=l.pages[o]??l.pages[0],c=a.useRef(l);c.current=l;const y=a.useRef(o);y.current=o;const w=a.useCallback((I,S)=>{u&&u(gt(c.current,y.current,I),S)},[u]),[b,x]=Et(),R=a.useRef(x);R.current=x;const m=a.useCallback(I=>p.execute("selectBlocks",I),[p]),v=a.useRef(null),{expandedCols:T,expandedRows:O}=i.useExpandedGrid(s.grid),{paperPx:C,gridPosPx:N,getBlockRectPx:F,getColIndex:_,getRowIndex:k}=i.useGridCalc(l.paper,s.grid,i.DEFAULT_DPI),D=a.useCallback(I=>{var X;const S=i.getBlockDragKind(I);if(!S)return;I.preventDefault();const P=d[S],H=(P==null?void 0:P.meta.defaultSize)??{w:1,h:1},Y=(X=v.current)==null?void 0:X.getBoundingClientRect(),G=Y?_(I.clientX-Y.left):0,Z=Y?k(I.clientY-Y.top):0;R.current({editingBlockId:null,dragging:{type:J.INSERT,blockIds:[],pluginKind:S,defaultSize:H,startGrid:{col:G,row:Z},currentGrid:{col:G,row:Z},currentMousePx:{x:I.clientX,y:I.clientY}}})},[d,_,k]),j=a.useCallback(I=>{var Y;if(!I.dataTransfer.types.includes(i.BLOCK_DRAG_MIME))return;I.preventDefault(),I.dataTransfer.dropEffect="copy";const S=(Y=v.current)==null?void 0:Y.getBoundingClientRect();if(!S)return;const P=_(I.clientX-S.left),H=k(I.clientY-S.top);R.current(G=>{var Z;return((Z=G.dragging)==null?void 0:Z.type)!==J.INSERT?G:{...G,dragging:{...G.dragging,currentGrid:{col:P,row:H},currentMousePx:{x:I.clientX,y:I.clientY}}}})},[_,k]),q=a.useCallback(I=>{var S;I.dataTransfer.types.includes(i.BLOCK_DRAG_MIME)&&((S=v.current)!=null&&S.contains(I.relatedTarget)||R.current({editingBlockId:null,dragging:void 0}))},[]),Q=a.useCallback(I=>{var ie;I.preventDefault();const S=i.getBlockDragData(I);if(!S)return;const P=(ie=v.current)==null?void 0:ie.getBoundingClientRect();if(!P)return;const H=_(I.clientX-P.left),Y=k(I.clientY-P.top),G=S.defaultSize??{w:1,h:1},Z=d[S.kind];if(!Z)return;const{x:X,y:U}=Nt({x:H,y:Y},G,s.grid.colCount,s.grid.rowCount),ne={...fe(Z,{x:X,y:U}),layout:{x:X,y:U,w:G.w,h:G.h}};w({...s,blocks:[...s.blocks,ne]}),m([ne.id]),R.current({editingBlockId:null,dragging:void 0})},[s,d,_,k,w,m]),[te,K]=a.useState(new Map),[M,E]=a.useState(new Map),L=a.useCallback((I,S)=>{K(P=>{if(P.get(I)===S)return P;const H=new Map(P);return H.set(I,S),H})},[]),W=a.useCallback((I,S)=>{E(P=>{if(P.get(I)===S)return P;const H=new Map(P);return H.set(I,S),H})},[]),g=a.useCallback(I=>{const S=F(I),P=te.get(I.id),H=M.get(I.id);return{...S,height:P!==void 0?Math.max(S.height,P):S.height,width:H!==void 0?Math.max(S.width,H):S.width}},[F,te,M]),A=a.useCallback((I,S)=>{const P=s.blocks.map(H=>H.id===I?{...H,initValue:S}:H);w({...s,blocks:P},{mergeKey:i.initValueKey(I)})},[s,w]);a.useEffect(()=>{const I=S=>{if(h.length===0)return;const P=S.target;if(P instanceof Element){const H=P.closest(i.SIDEBAR_PORTAL_SELECTOR),Y=P.closest('[data-selection-action-bar="true"]');if(H||Y)return}v.current&&!v.current.contains(P)&&m([])};return document.addEventListener("mousedown",I),()=>{document.removeEventListener("mousedown",I)}},[h,m]);const $=a.useCallback((I,S,P)=>{const H=S-1;if(I==="column"){const Y=ut(T,H,P,C.content.width);w({...s,grid:{...s.grid,...i.colsToSparse(Y)}})}else{const Y=ut(O,H,P,C.content.height);w({...s,grid:{...s.grid,...i.rowsToSparse(Y)}})}},[s,C,T,O,w]),B=a.useCallback((I,S,P)=>{if(I==="column"){const H=[...T];H[S]=P,w({...s,grid:{...s.grid,...i.colsToSparse(H)}})}else{const H=[...O];H[S]=P,w({...s,grid:{...s.grid,...i.rowsToSparse(H)}})}},[w,s,T,O]),z=a.useMemo(()=>{const I={};for(const S of s.blocks)!he(S.hiddenBinding,void 0)&&S.initValue!==void 0&&(I[S.id]=S.initValue);return I},[s.blocks]);return f.jsx(Me.Provider,{value:d,children:f.jsxs("section",{ref:v,"data-testid":"note-container",className:r,"aria-label":"用紙",onDragEnter:D,onDragOver:j,onDragLeave:q,onDrop:Q,style:{position:"relative",width:`${C.canvas.width}px`,height:`${C.canvas.height}px`,margin:"0 auto",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",backgroundColor:"#fff",transform:n!==1?`scale(${n})`:void 0,transformOrigin:"top center",...i.STACKING_ISOLATION_STYLE},children:[f.jsx(Le,{paperPx:C,gridPosPx:N,gridDimensions:{cols:T,rows:O},showGridLines:!0,showMargins:!0,showBorder:!0,showResizeHandles:!0,showDimensionLabels:!0,onGridResize:$,onDimensionChange:B,gridLineStyle:{color:"#e5e7eb",width:{value:1,unit:"px"},type:i.LineType.SOLID},borderStyle:{top:{color:"#000000",width:{value:1,unit:"px"},type:i.LineType.SOLID},right:{color:"#000000",width:{value:1,unit:"px"},type:i.LineType.SOLID},bottom:{color:"#000000",width:{value:1,unit:"px"},type:i.LineType.SOLID},left:{color:"#000000",width:{value:1,unit:"px"},type:i.LineType.SOLID}}}),f.jsx(ve,{blocks:s.blocks,pluginRegistry:d,mode:i.NoteMode.FORM,values:z,selectedBlockIds:h,blockDefaults:s.blockDefaults,getBlockRectPx:F,onValueChange:A,onMeasureHeight:L,onMeasureWidth:W,showGuides:!0,showBorder:!0}),f.jsx(qe,{page:s,gridLength:{cols:s.grid.colCount,rows:s.grid.rowCount},pluginRegistry:d,blockDefaults:s.blockDefaults,getBlockRectPx:g,getColIndex:_,getRowIndex:k,selectedBlockIds:h,onSelectionChange:m,state:b,onStateChange:x,onPageChange:w,actionContext:p,scale:n})]})})}),_t=a.memo(function(t){var C,N,F;const n=t.context!==void 0?t.context.book:t.book,r=t.context!==void 0?t.context.pluginRegistry:t.pluginRegistry,l=((C=t.context)==null?void 0:C.values)??t.values??{},u=t.showValidation??!1,d=t.scale??1,{className:o}=t,h=(N=t.context)==null?void 0:N.bindingContext,p=(F=t.context)==null?void 0:F.actionContext,{page:s,isFit:c,isWidthFit:y,gridPosPx:w,getBlockRectPx:b,handleMeasureHeight:x,handleMeasureWidth:R,canvasHeightPx:m,canvasWidthPx:v,effectivePaperPx:T,validationErrors:O}=Lt({book:n,pageIdx:t.context!==void 0?t.context.editorState.pageIdx:t.pageIdx??0,showValidation:u,values:l,bindingContext:h});return f.jsx(Me.Provider,{value:r,children:f.jsxs("div",{"data-testid":"note-container",className:o,style:{position:"relative",width:`${v}px`,height:`${m}px`,margin:"0 auto",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",backgroundColor:"#fff",transform:d!==1?`scale(${d})`:void 0,transformOrigin:"top center",...i.STACKING_ISOLATION_STYLE},children:[f.jsx(Le,{paperPx:T,gridPosPx:w,showGridLines:!1,showMargins:!1,showBorder:!1}),f.jsx(ve,{blocks:s.blocks,pluginRegistry:r,mode:i.NoteMode.VIEW,values:l,blockDefaults:s.blockDefaults,getBlockRectPx:b,onMeasureHeight:c?x:void 0,onMeasureWidth:y?R:void 0,showGuides:!1,showBorder:!0,showValidation:u,validationErrors:O,bindingContext:h,actionContext:p})]})})});function Bt({context:e,mode:t,className:n,style:r,showValidation:l,scale:u}){return t===i.NoteMode.FORM?f.jsx("div",{style:{...r,...i.STACKING_ISOLATION_STYLE},className:n,children:f.jsx(At,{scale:u,context:e})}):t===i.NoteMode.VIEW?f.jsx("div",{style:{...r,...i.STACKING_ISOLATION_STYLE},className:n,children:f.jsx(_t,{showValidation:l,scale:u,context:e})}):f.jsx("div",{style:{...r,...i.STACKING_ISOLATION_STYLE},className:n,children:f.jsx(Mt,{showValidation:l,scale:u,context:e})})}function Ot(e,{actionContext:t,bindingContext:n,onChange:r}){if(typeof e=="string"){e&&t?t.execute(e):r(null);return}if(e!=null&&n!=null){n.set(e.path,e.value);return}r(null)}function zt(e,t){return typeof e!="string"||!e||!t?!0:t.isEnabled(e)}function jt(e,t){return e==null||typeof e!="object"||t==null?!1:t.get(e.path)===e.value}const $t={kind:"buttonContent",defaultProps:{label:"ボタン",icon:"",iconPath:"",title:""}},Gt={kind:"buttonAction",defaultProps:{action:""}},_e={[i.HorizontalAlign.left]:"flex-start",[i.HorizontalAlign.center]:"center",[i.HorizontalAlign.right]:"flex-end"},Be={[i.VerticalAlign.top]:"flex-start",[i.VerticalAlign.center]:"center",[i.VerticalAlign.bottom]:"flex-end"},Qe=a.forwardRef(({props:e,readOnly:t,onChange:n,ariaLabel:r,actionContext:l,bindingContext:u},d)=>{const o=a.useRef(null),[h,p]=a.useState(!1);a.useImperativeHandle(d,()=>({focus:()=>{var m;return(m=o.current)==null?void 0:m.focus()}}),[]);const s=zt(e.action,l),c=t||!s,y=jt(e.action,u),w=a.useCallback(()=>{c||Ot(e.action,{actionContext:l,bindingContext:u,onChange:n})},[c,e.action,l,u,n]),b=a.useCallback(()=>{c||p(!0)},[c]),x=a.useCallback(()=>p(!1),[]),R=a.useMemo(()=>{const m={width:"100%",height:"100%",boxSizing:"border-box",overflow:"hidden",cursor:c?"default":"pointer",userSelect:"none",outline:"none",appearance:"none",border:"none",background:"none",opacity:c?.4:h?.7:y?.85:1,transform:h?"scale(0.97)":"scale(1)",transition:h?"none":"opacity 150ms ease, transform 150ms ease"};e.iconPath?(m.display="flex",m.alignItems=Be[e.vertical??i.VerticalAlign.center],m.justifyContent=_e[e.horizontal??i.HorizontalAlign.center],m.containerType="size",m.color="inherit"):e.icon&&!e.label?(m.display="flex",m.alignItems=Be[e.vertical??i.VerticalAlign.center],m.justifyContent=_e[e.horizontal??i.HorizontalAlign.center],m.containerType="size",m.fontFamily="inherit",m.color="inherit"):(m.display="flex",m.alignItems=Be[e.vertical??i.VerticalAlign.center],m.justifyContent=_e[e.horizontal??i.HorizontalAlign.center],m.gap="4px",m.fontFamily="inherit",m.fontSize="inherit",m.color="inherit");const v=e.bulk?e.all:void 0,T=v??e.top,O=v??e.right,C=v??e.bottom,N=v??e.left;return T&&(m.paddingTop=i.dimensionToString(T)),O&&(m.paddingRight=i.dimensionToString(O)),C&&(m.paddingBottom=i.dimensionToString(C)),N&&(m.paddingLeft=i.dimensionToString(N)),m},[e,c,h,y]);return f.jsxs("button",{ref:o,type:"button",disabled:c,"aria-pressed":y?!0:void 0,"aria-label":r??e.label??"ボタン",title:e.title,style:R,onClick:w,onPointerDown:b,onPointerUp:x,onPointerLeave:x,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),w())},children:[e.iconPath?f.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",style:{display:"block",margin:"auto",width:"min(55cqi, 55cqb)",height:"min(55cqi, 55cqb)"},children:f.jsx("path",{d:e.iconPath,fill:"currentColor"})}):e.icon?f.jsx("span",{"aria-hidden":"true",style:e.label?void 0:{display:"block",width:"100%",textAlign:"center",fontSize:"min(55cqi, 55cqb)",lineHeight:"1"},children:e.icon}):null,!e.iconPath&&(e.label||!e.icon)&&f.jsx("span",{children:e.label??"ボタン"})]})});Qe.displayName="ButtonRenderer";const Vn={kind:"button",meta:{displayName:"ボタン",description:"クリックでアクションを実行するボタンブロック",defaultSize:{w:2,h:1}},Renderer:Qe,properties:[i.alignmentProp,pe,$t,Gt],validateProps:e=>typeof e!="object"||e===null?{}:e,validateValue:()=>null};function oe(e,t){return{id:e,kind:"text",layout:{x:0,y:0,w:1,h:1},props:{binding:t,placeholder:"0",pattern:"^[0-9]*\\.?[0-9]*$",multiline:!1,horizontal:"right",vertical:"center",top:{value:2,unit:"px"},right:{value:5,unit:"px"}}}}const Wn=[{label:"mm",value:"mm"},{label:"cm",value:"cm"},{label:"inch",value:"inch"}];function ge(e,t){return{id:e,kind:"select",layout:{x:0,y:0,w:1,h:1},props:{binding:t,selectConfig:{options:Wn,allowEmpty:!1,defaultValue:"mm"},horizontal:"left",left:{value:2,unit:"px"}}}}const Ht={kind:"stepperBehavior",defaultProps:{step:1}},Kt={kind:"stepperStyle",defaultProps:{styleConfig:{arrowWidth:50,arrowHeight:25,arrowColor:"currentColor",arrowGap:20}}};function Fn(e,t,n,r){let l=e+t;return r!==void 0&&(l=Math.min(r,l)),n!==void 0&&(l=Math.max(n,l)),l}const Un="M 10,0 L 20,10 L 0,10 Z",Xn="M 0,0 L 20,0 L 10,10 Z",ct=e=>({position:"absolute",left:0,width:"100%",height:"50%",padding:0,border:"none",background:"none",appearance:"none",cursor:e?"default":"pointer",boxSizing:"border-box"}),Je=a.forwardRef(({props:e,value:t,onChange:n,readOnly:r},l)=>{var C,N,F,_;const u=a.useRef(null),[d,o]=a.useState(!1),[h,p]=a.useState(!1),s=r,c=e.step??1,y=((C=e.styleConfig)==null?void 0:C.arrowColor)??"currentColor",w=((N=e.styleConfig)==null?void 0:N.arrowWidth)??50,b=((F=e.styleConfig)==null?void 0:F.arrowHeight)??25,x=((_=e.styleConfig)==null?void 0:_.arrowGap)??20,R=(100-w)/2;a.useImperativeHandle(l,()=>({focus:()=>{var k,D;return(D=(k=u.current)==null?void 0:k.querySelector("button"))==null?void 0:D.focus()}}),[]);const m=a.useCallback(k=>{if(s)return;const D=Number(t??0),j=Fn(D,k,e.min,e.max);n(j)},[s,t,n,e.min,e.max]),v=a.useCallback(()=>m(c),[m,c]),T=a.useCallback(()=>m(-c),[m,c]),O=k=>({opacity:s?.4:k?.6:1,transform:k?"scale(0.9)":"scale(1)",transition:k?"none":"opacity 150ms ease, transform 150ms ease"});return f.jsxs("div",{ref:u,style:{position:"relative",width:"100%",height:"100%",overflow:"visible",color:y},children:[f.jsx("button",{type:"button",disabled:s,"aria-label":"増やす",style:{...ct(s),top:0},onClick:v,onPointerDown:()=>{s||o(!0)},onPointerUp:()=>o(!1),onPointerLeave:()=>o(!1)}),f.jsx("button",{type:"button",disabled:s,"aria-label":"減らす",style:{...ct(s),bottom:0},onClick:T,onPointerDown:()=>{s||p(!0)},onPointerUp:()=>p(!1),onPointerLeave:()=>p(!1)}),f.jsx("svg",{viewBox:"0 0 20 10",preserveAspectRatio:"none","aria-hidden":"true",style:{position:"absolute",left:`${R}%`,bottom:`calc(50% + ${x/2}%)`,width:`${w}%`,height:`${b}%`,pointerEvents:"none",transformOrigin:"center bottom",...O(d)},children:f.jsx("path",{d:Un,fill:"currentColor"})}),f.jsx("svg",{viewBox:"0 0 20 10",preserveAspectRatio:"none","aria-hidden":"true",style:{position:"absolute",left:`${R}%`,top:`calc(50% + ${x/2}%)`,width:`${w}%`,height:`${b}%`,pointerEvents:"none",transformOrigin:"center top",...O(h)},children:f.jsx("path",{d:Xn,fill:"currentColor"})})]})});Je.displayName="StepperRenderer";const ce={kind:"stepper",meta:{displayName:"ステッパー",description:"数値を増減するステッパーブロック",defaultSize:{w:1,h:1}},Renderer:Je,properties:[i.alignmentProp,Ht,Kt],validateProps:e=>{if(typeof e!="object"||e===null)return{};const t=e;return"styleConfig"in t&&(typeof t.styleConfig!="object"||t.styleConfig===null)?{...t,styleConfig:{}}:e},validateValue:e=>typeof e=="number"?e:null},et={size:{preset:i.PaperSizePreset.CUSTOM,width:{value:100,unit:"mm"},height:{value:8,unit:"mm"}},margin:{top:{value:0,unit:"mm"},right:{value:0,unit:"mm"},bottom:{value:0,unit:"mm"},left:{value:0,unit:"mm"}},autoHeight:!0,autoWidth:!0},Vt={colCount:3,rowCount:1,cols:{2:{value:8,unit:"mm"}}},Zn={props:{book:{paper:et,pages:[{grid:Vt,blocks:[{id:"grid-row-count-label",kind:"text",layout:{x:0,y:0,w:1,h:1},initValue:"行数",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"}},{...oe("grid-row-count-value","grid.rowCount"),layout:{x:1,y:0,w:1,h:1}},{id:"grid-row-count-stepper",kind:"stepper",layout:{x:2,y:0,w:1,h:1},props:{binding:"grid.rowCount",step:1,min:1}}]}]}},plugins:[ae,ce]},Yn={props:{book:{paper:et,pages:[{grid:Vt,blocks:[{id:"grid-col-count-label",kind:"text",layout:{x:0,y:0,w:1,h:1},initValue:"列数",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"}},{...oe("grid-col-count-value","grid.colCount"),layout:{x:1,y:0,w:1,h:1}},{id:"grid-col-count-stepper",kind:"stepper",layout:{x:2,y:0,w:1,h:1},props:{binding:"grid.colCount",step:1,min:1}}]}]}},plugins:[ae,ce]},qn={props:{book:{paper:et,pages:[{grid:{colCount:6,rowCount:1,cols:{2:{value:8,unit:"mm"},5:{value:8,unit:"mm"}}},blocks:[{id:"grid-row-count-label",kind:"text",layout:{x:0,y:0,w:1,h:1},initValue:"行数",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"}},{...oe("grid-row-count-value","grid.rowCount"),layout:{x:1,y:0,w:1,h:1}},{id:"grid-row-count-stepper",kind:"stepper",layout:{x:2,y:0,w:1,h:1},props:{binding:"grid.rowCount",step:1,min:1}},{id:"grid-col-count-label",kind:"text",layout:{x:3,y:0,w:1,h:1},initValue:"列数",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"}},{...oe("grid-col-count-value","grid.colCount"),layout:{x:4,y:0,w:1,h:1}},{id:"grid-col-count-stepper",kind:"stepper",layout:{x:5,y:0,w:1,h:1},props:{binding:"grid.colCount",step:1,min:1}}]}]}},plugins:[ae,ce]},Qn={get:()=>null,set:()=>{}},Jn={execute:()=>{},isEnabled:()=>!1},ei={selectedBlockIds:[],pageIdx:0},tt=a.forwardRef(({props:e,dimensions:t,bindingContext:n,actionContext:r,onMeasureHeight:l,onMeasureWidth:u},d)=>{const o=a.useContext(Me);a.useImperativeHandle(d,()=>({focus:()=>{}}),[]);const h=a.useRef(null),{naturalWidth:p,naturalHeight:s,scale:c}=a.useMemo(()=>{const w=i.toPx.fromDim(e.book.paper.size.width,i.DEFAULT_DPI),b=i.toPx.fromDim(e.book.paper.size.height,i.DEFAULT_DPI),x=t&&w>0&&b>0?Math.min(t.widthPx/w,t.heightPx/b<1&&b-t.heightPx<1?1:t.heightPx/b):1;return{naturalWidth:w,naturalHeight:b,scale:x}},[e.book.paper,t]);a.useEffect(()=>{l==null||l(s*c)},[l,s,c]),a.useEffect(()=>{u==null||u(p*c)},[u,p,c]);const y=a.useMemo(()=>o?{book:e.book,onBookChange:()=>{},pluginRegistry:o,containerRef:h,bindingContext:n??Qn,actionContext:r??Jn,editorState:ei,values:{}}:null,[e.book,o,n,r]);return y?f.jsx("div",{style:{width:"100%",height:"100%",overflow:"hidden"},children:f.jsx(Bt,{mode:i.NoteMode.EDIT,context:y,style:{width:p,height:s,transform:`scale(${c})`,transformOrigin:"top left"}})}):null});tt.displayName="NoteBlockRenderer";const nt={kind:"note",meta:{displayName:"ノートブロック",description:"ブロックとして振る舞う Note(入れ子グリッド)",defaultSize:{w:6,h:4}},Renderer:tt,properties:[],validateProps:e=>typeof e=="object"&&e!==null&&"book"in e&&typeof e.book=="object"&&e.book!==null?e:{book:ht},validateValue:()=>null};const de={path:"paper.size.preset",neq:i.PaperSizePreset.CUSTOM},it={size:{preset:i.PaperSizePreset.CUSTOM,width:{value:160,unit:"mm"},height:{value:10,unit:"mm"}},margin:{top:{value:0,unit:"mm"},right:{value:0,unit:"mm"},bottom:{value:0,unit:"mm"},left:{value:0,unit:"mm"}},autoHeight:!0,autoWidth:!0},ti={book:{paper:it,pages:[{grid:{colCount:8,rowCount:1,cols:{7:{value:15,unit:"mm"}}},blocks:[{id:"paper-size-label",kind:"text",layout:{x:0,y:0,w:2,h:1},initValue:"用紙サイズ",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"}},{id:"paper-preset",kind:"select",layout:{x:2,y:0,w:3,h:1},initValue:i.PaperSizePreset.A4,props:{binding:"paper.size.preset",required:!0,left:{value:2,unit:"px"},selectConfig:{options:[{label:"A4 (210×297mm)",value:i.PaperSizePreset.A4},{label:"A3 (297×420mm)",value:i.PaperSizePreset.A3},{label:"B5 (182×257mm)",value:i.PaperSizePreset.B5},{label:"Letter (8.5×11inch)",value:i.PaperSizePreset.LETTER},{label:"Legal (8.5×14inch)",value:i.PaperSizePreset.LEGAL},{label:"カスタム",value:i.PaperSizePreset.CUSTOM}]}}},{id:"paper-orientation-label",kind:"text",layout:{x:5,y:0,w:2,h:1},initValue:"横向き",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"}},{id:"paper-orientation",kind:"checkbox",layout:{x:7,y:0,w:1,h:1},props:{binding:"paper.orientation"}}]}]}},ni={book:{paper:it,pages:[{grid:{colCount:8,rowCount:1,cols:{3:{value:15,unit:"mm"},7:{value:15,unit:"mm"}}},blocks:[{id:"paper-width-auto-label",kind:"text",layout:{x:0,y:0,w:3,h:1},initValue:"幅自動",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"}},{id:"paper-width-auto",kind:"checkbox",layout:{x:3,y:0,w:1,h:1},props:{binding:"paper.autoWidth"}},{id:"paper-height-auto-label",kind:"text",layout:{x:4,y:0,w:3,h:1},initValue:"高さ自動",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"}},{id:"paper-height-auto",kind:"checkbox",layout:{x:7,y:0,w:1,h:1},props:{binding:"paper.autoHeight"}}]}]}},ii={book:{paper:it,pages:[{grid:{colCount:8,rowCount:1,cols:{2:{value:8,unit:"mm"},3:{value:15,unit:"mm"},6:{value:8,unit:"mm"},7:{value:15,unit:"mm"}}},blocks:[{id:"paper-width-label",kind:"text",layout:{x:0,y:0,w:1,h:1},initValue:"幅",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"},hiddenBinding:"paper.autoWidth"},{id:"paper-width-label-min",kind:"text",layout:{x:0,y:0,w:1,h:1},initValue:"最低幅",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"},hiddenBinding:{path:"paper.autoWidth",neq:!0}},{...oe("paper-width-value","paper.size.width.value"),layout:{x:1,y:0,w:1,h:1}},{id:"paper-width-stepper",kind:"stepper",layout:{x:2,y:0,w:1,h:1},props:{binding:"paper.size.width.value",step:1,min:0}},{...ge("paper-width-unit","paper.size.width.unit"),layout:{x:3,y:0,w:1,h:1}},{id:"paper-height-label",kind:"text",layout:{x:4,y:0,w:1,h:1},initValue:"高さ",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"},hiddenBinding:"paper.autoHeight"},{id:"paper-height-label-min",kind:"text",layout:{x:4,y:0,w:1,h:1},initValue:"最低高さ",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"},hiddenBinding:{path:"paper.autoHeight",neq:!0}},{...oe("paper-height-value","paper.size.height.value"),layout:{x:5,y:0,w:1,h:1}},{id:"paper-height-stepper",kind:"stepper",layout:{x:6,y:0,w:1,h:1},props:{binding:"paper.size.height.value",step:1,min:0}},{...ge("paper-height-unit","paper.size.height.unit"),layout:{x:7,y:0,w:1,h:1}}]}]}},ri={props:{book:{paper:{size:{preset:i.PaperSizePreset.CUSTOM,width:{value:160,unit:"mm"},height:{value:30,unit:"mm"}},margin:{top:{value:0,unit:"mm"},right:{value:0,unit:"mm"},bottom:{value:0,unit:"mm"},left:{value:0,unit:"mm"}},autoHeight:!0,autoWidth:!0},pages:[{grid:{colCount:1,rowCount:3,rows:{0:{value:10,unit:"mm"},1:{value:10,unit:"mm"},2:{value:10,unit:"mm"}}},blocks:[{id:"row-preset-orientation",kind:"note",layout:{x:0,y:0,w:1,h:1},behavior:{heightFit:!0},props:ti},{id:"row-auto-resize",kind:"note",layout:{x:0,y:1,w:1,h:1},behavior:{heightFit:!0},props:ni},{id:"row-dimension",kind:"note",layout:{x:0,y:2,w:1,h:1},behavior:{heightFit:!0},props:ii,hiddenBinding:de}]}]}},plugins:[We,nt,Pe,ce,ae]},oi={props:{book:{paper:{size:{preset:i.PaperSizePreset.CUSTOM,width:{value:20,unit:"mm"},height:{value:15,unit:"mm"}},margin:{top:{value:0,unit:"mm"},right:{value:0,unit:"mm"},bottom:{value:0,unit:"mm"},left:{value:0,unit:"mm"}},autoHeight:!0,autoWidth:!0},pages:[{grid:{colCount:1,rowCount:1},blocks:[{id:"paper-orientation",kind:"checkbox",layout:{x:0,y:0,w:1,h:1},props:{binding:"paper.orientation"}}]}]}},plugins:[We]},si={props:{book:{paper:{size:{preset:i.PaperSizePreset.CUSTOM,width:{value:60,unit:"mm"},height:{value:10,unit:"mm"}},margin:{top:{value:0,unit:"mm"},right:{value:0,unit:"mm"},bottom:{value:0,unit:"mm"},left:{value:0,unit:"mm"}},autoHeight:!0,autoWidth:!0},pages:[{grid:{colCount:1,rowCount:1},blocks:[{id:"paper-preset",kind:"select",layout:{x:0,y:0,w:1,h:1},props:{binding:"paper.size.preset",selectConfig:{options:[{label:"A4 (210×297mm)",value:i.PaperSizePreset.A4},{label:"A3 (297×420mm)",value:i.PaperSizePreset.A3},{label:"B5 (182×257mm)",value:i.PaperSizePreset.B5},{label:"Letter (8.5×11inch)",value:i.PaperSizePreset.LETTER},{label:"Legal (8.5×14inch)",value:i.PaperSizePreset.LEGAL},{label:"カスタム",value:i.PaperSizePreset.CUSTOM}]}}}]}]}},plugins:[Pe]},Wt=[{id:"paper-preset",kind:"select",layout:{x:0,y:0,w:4,h:1},props:{binding:"paper.size.preset",selectConfig:{options:[{label:"A4 (210×297mm)",value:i.PaperSizePreset.A4},{label:"A3 (297×420mm)",value:i.PaperSizePreset.A3},{label:"B5 (182×257mm)",value:i.PaperSizePreset.B5},{label:"Letter (8.5×11inch)",value:i.PaperSizePreset.LETTER},{label:"Legal (8.5×14inch)",value:i.PaperSizePreset.LEGAL},{label:"カスタム",value:i.PaperSizePreset.CUSTOM}]}}},{...oe("paper-width-value","paper.size.width.value"),layout:{x:0,y:1,w:1,h:1},hiddenBinding:de},{...ge("paper-width-unit","paper.size.width.unit"),layout:{x:1,y:1,w:1,h:1},hiddenBinding:de},{...oe("paper-height-value","paper.size.height.value"),layout:{x:2,y:1,w:1,h:1},hiddenBinding:de},{...ge("paper-height-unit","paper.size.height.unit"),layout:{x:3,y:1,w:1,h:1},hiddenBinding:de}],li={props:{book:{paper:{size:{preset:i.PaperSizePreset.CUSTOM,width:{value:80,unit:"mm"},height:{value:30,unit:"mm"}},margin:{top:{value:0,unit:"mm"},right:{value:0,unit:"mm"},bottom:{value:0,unit:"mm"},left:{value:0,unit:"mm"}},autoHeight:!0,autoWidth:!0},pages:[{grid:{colCount:4,rowCount:2,cols:{1:{value:15,unit:"mm"},3:{value:15,unit:"mm"}}},blocks:Wt}]}},plugins:[nt,Pe,ce,ae]};exports.BlockBorder=ue;exports.BlockCanvas=ye;exports.BlockContainer=Ye;exports.BlockGuideBorder=Ne;exports.BlockLayer=ve;exports.BlockRenderer=xe;exports.ButtonPlugin=Vn;exports.ButtonRenderer=Qe;exports.CheckboxPlugin=We;exports.CheckboxRenderer=Ve;exports.DEFAULT_BOOK=ht;exports.DEFAULT_GUIDE_BORDER=Te;exports.DEFAULT_PAGE=Ke;exports.DragType=J;exports.InteractionLayer=qe;exports.InteractionMode=ee;exports.Note=Bt;exports.NoteBlockPlugin=nt;exports.NoteBlockRenderer=tt;exports.NoteEdit=Mt;exports.NoteForm=At;exports.NoteView=_t;exports.PAPER_SIZE_BLOCKS=Wt;exports.ResizeHandle=V;exports.SelectPlugin=Pe;exports.SelectRenderer=Fe;exports.StepperPlugin=ce;exports.StepperRenderer=Je;exports.TextPlugin=ae;exports.TextRenderer=Ue;exports.ValidationOverlay=Ze;exports.ValidationSeverity=re;exports.addPage=Jt;exports.buildPageCss=an;exports.buttonActionProp=Gt;exports.buttonContentProp=$t;exports.cleanValues=on;exports.createBlockId=He;exports.ensurePageIds=en;exports.evalHiddenBinding=he;exports.evaluateCheckboxValidation=Zt;exports.evaluateValidation=ft;exports.executeButtonAction=Ot;exports.fontStyleProp=$e;exports.getButtonActionActive=jt;exports.getInteractionMode=kt;exports.getPaperSize=sn;exports.gridColCountWidget=Yn;exports.gridRowCountWidget=Zn;exports.gridSettingsWidget=qn;exports.hasValidationRule=dt;exports.insertPage=rn;exports.isButtonActionEnabled=zt;exports.movePage=nn;exports.numberInputBlock=oe;exports.paddingProp=pe;exports.paperOrientationWidget=oi;exports.paperPresetSelectWidget=si;exports.paperSettingsWidget=ri;exports.paperSizeWidget=li;exports.placeholderProp=Ge;exports.removePage=tn;exports.requiredProp=Ce;exports.resolveEffectivePaper=ln;exports.selectConfigProp=pt;exports.setPage=gt;exports.stepperBehaviorProp=Ht;exports.stepperStyleProp=Kt;exports.unitSelectBlock=ge;exports.useBookActionContext=mn;exports.useBookBindingContext=xn;exports.useBookHistory=bn;exports.useInteractionState=Et;exports.validateBook=Qt;