@tatamicks/core 0.3.2 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +518 -81
- package/dist/PalettePanel-CtXsH6Cb.js +5137 -0
- package/dist/PalettePanel-CtXsH6Cb.js.map +1 -0
- package/dist/PalettePanel-Dipvtj7D.cjs +9 -0
- package/dist/PalettePanel-Dipvtj7D.cjs.map +1 -0
- package/dist/PalettePanel.css +1 -0
- package/dist/canvas.cjs +1 -0
- package/dist/canvas.cjs.map +1 -0
- package/dist/canvas.mjs +354 -0
- package/dist/canvas.mjs.map +1 -0
- package/dist/index.cjs +5 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +3 -1
- package/dist/index.css.d.ts +2 -0
- package/dist/index.mjs +1424 -6891
- package/dist/index.mjs.map +1 -1
- package/dist/paperSettingsWidget-DgDoBA0P.js +5137 -0
- package/dist/paperSettingsWidget-DgDoBA0P.js.map +1 -0
- package/dist/paperSettingsWidget-sLJsIUxS.cjs +2 -0
- package/dist/paperSettingsWidget-sLJsIUxS.cjs.map +1 -0
- package/dist/paperSettingsWidget.css +1 -0
- package/dist/shell.cjs +1 -0
- package/dist/shell.cjs.map +1 -0
- package/dist/shell.mjs +65 -0
- package/dist/shell.mjs.map +1 -0
- package/dist/sidebarPortal-C06y4JSP.js +723 -0
- package/dist/sidebarPortal-C06y4JSP.js.map +1 -0
- package/dist/sidebarPortal-C3HszQyp.cjs +1 -0
- package/dist/sidebarPortal-C3HszQyp.cjs.map +1 -0
- package/dist/src/canvas.d.ts +2523 -0
- package/dist/src/index.d.ts +1801 -2880
- package/dist/src/shell.d.ts +1982 -0
- package/package.json +21 -8
- package/dist/index.js +0 -70
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";require('./paperSettingsWidget.css');const i=require("./sidebarPortal-C3HszQyp.cjs"),l=require("react"),h=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 Ve={grid:i.DEFAULT_GRID,blocks:[]},ht={paper:i.DEFAULT_PAPER,pages:[Ve]};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,s=qt();for(const[c,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>s&&t.push({message:`ページ ${c+1} のブロック数 (${d.blocks.length}) が上限 (${s}) を超えています`,code:"BLOCK_COUNT_EXCEEDED",field:d.id??`page-${c}`,severity:re.ERROR})}for(const c of r)t.push({message:`blockId "${c}" が複数ページに重複して存在します`,code:"DUPLICATE_BLOCK_ID",field:c,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={...Ve,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,s)=>s!==t);return{...e,pages:le(n)}}function nn(e,t,n){if(t===n)return e;const r=[...e.pages],s=r.splice(t,1)[0];return s?(r.splice(n,0,s),{...e,pages:le(r)}):e}function gt(e,t,n){return{...e,pages:le(e.pages.map((r,s)=>s===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(s=>s.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),s=i.toMm.fromDim(n.height);return t?{width:s,height:r}:{width:r,height:s}}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)),s=Math.round(i.toMm.fromDim(n?e.size.width:e.size.height)),c=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 ${s}mm; ${c} }`}const cn={[i.HorizontalAlign.left]:"flex-start",[i.HorizontalAlign.center]:"center",[i.HorizontalAlign.right]:"flex-end"},un={[i.VerticalAlign.top]:"flex-start",[i.VerticalAlign.center]:"center",[i.VerticalAlign.bottom]:"flex-end"},We=l.forwardRef(({id:e,props:t,value:n,onChange:r,readOnly:s,ariaLabel:c},d)=>{var y;const o=l.useRef(null);l.useImperativeHandle(d,()=>({focus:()=>{var w;return(w=o.current)==null?void 0:w.focus()}}),[]);const f=n??!1,g=l.useMemo(()=>{const w={width:"100%",height:"100%",display:"flex",boxSizing:"border-box",overflow:"hidden",cursor:s?"default":"pointer"};w.justifyContent=cn[t.horizontal??i.HorizontalAlign.center],w.alignItems=un[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,s]),a=(y=t.styleConfig)!=null&&y.checkboxSize?i.toPx.fromDim(t.styleConfig.checkboxSize):16,u=()=>{s||r(!f)};return h.jsxs("div",{ref:o,style:g,role:"switch","aria-checked":f,"aria-label":c,tabIndex:s?-1:0,onClick:u,onKeyDown:w=>{(w.key===" "||w.key==="Enter")&&(w.preventDefault(),u())},children:[h.jsx("input",{id:e,type:"checkbox",checked:f,onChange:()=>{},style:{display:"none"},tabIndex:-1,readOnly:!0}),h.jsx("div",{style:{width:a,height:a,flexShrink:0,pointerEvents:"none"},children:h.jsx(i.ClassicCheckboxVisual,{checked:f,styleConfig:t.styleConfig})})]})});We.displayName="CheckboxRenderer";const dn={...i.alignmentProp,defaultProps:{...i.alignmentProp.defaultProps,horizontal:i.HorizontalAlign.center}},Ke={kind:"checkbox",meta:{displayName:"チェックボックス",description:"チェック/非チェックを選択する入力ブロック",defaultSize:{w:2,h:2}},Renderer:We,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=l.forwardRef(({id:e,props:t,value:n,onChange:r,readOnly:s,mode:c,ariaLabel:d},o)=>{var O,S,L;const f=l.useRef(null);l.useImperativeHandle(o,()=>({focus:()=>{var N;return(N=f.current)==null?void 0:N.focus()}}),[]);const g=s||c===i.NoteMode.VIEW,a=l.useMemo(()=>{const N={width:"100%",height:"100%",position:"relative",display:"flex",alignItems:hn[t.vertical??i.VerticalAlign.center],boxSizing:"border-box",overflow:"hidden"},I=t.bulk?t.all:void 0,M=I??t.top,C=I??t.right,H=I??t.bottom,q=I??t.left;return M&&(N.paddingTop=i.dimensionToString(M)),C&&(N.paddingRight=i.dimensionToString(C)),H&&(N.paddingBottom=i.dimensionToString(H)),q&&(N.paddingLeft=i.dimensionToString(q)),N},[t]),u=(((O=t.selectConfig)==null?void 0:O.options)??[]).find(N=>N.value===n),y=u==null?void 0:u.color,w=y&&rt(y)?y:void 0,b=l.useMemo(()=>{const N={appearance:"none",WebkitAppearance:"none",background:w??"transparent",border:"none",outline:"none",width:"100%",height:"auto",padding:"0 20px 0 4px",boxSizing:"border-box",cursor:g?"default":"pointer",textAlign:fn[t.horizontal??i.HorizontalAlign.left]};t.fontFamily&&(N.fontFamily=t.fontFamily),t.fontSize&&(N.fontSize=`${i.toPx.fromDim(t.fontSize)}px`),t.color&&(N.color=t.color),N.fontWeight=t.fontWeight?"bold":"normal",N.fontStyle=t.italic?"italic":"normal";const I=[];return t.underline&&I.push("underline"),t.lineThrough&&I.push("line-through"),I.length>0&&(N.textDecoration=I.join(" ")),N},[t,w,g]),x={position:"absolute",right:6,top:"50%",transform:"translateY(-50%)",width:0,height:0,borderLeft:"5px solid transparent",borderRight:"5px solid transparent",borderTop:`5px solid ${g?"#aaa":"#555"}`,pointerEvents:"none"},R=N=>{const I=N.target.value===""?null:N.target.value;r(I)},m=N=>{var I,M;!g&&N.target!==f.current&&((M=(I=f.current)==null?void 0:I.showPicker)==null||M.call(I))},v=N=>{var I,M;!g&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),(M=(I=f.current)==null?void 0:I.showPicker)==null||M.call(I))};if(c===i.NoteMode.VIEW){const N=(u==null?void 0:u.label)??(n!=null?String(n):t.placeholder??""),I={...b,height:"auto",padding:"0 4px"};return h.jsx("div",{style:a,children:h.jsx("div",{style:I,children:N})})}const P=h.jsxs(h.Fragment,{children:[h.jsxs("select",{ref:f,id:e,value:n??"",onChange:R,disabled:g,style:b,"aria-label":d,children:[t.placeholder!==void 0&&!t.required&&((S=t.selectConfig)==null?void 0:S.allowEmpty)!==!1&&h.jsx("option",{value:"",children:t.placeholder}),(((L=t.selectConfig)==null?void 0:L.options)??[]).map(N=>{const I=N.color&&rt(N.color)?N.color:void 0;return h.jsx("option",{value:N.value,style:I?{backgroundColor:I}:void 0,children:N.label},N.value)})]}),h.jsx("div",{style:x,"aria-hidden":"true"})]});return g?h.jsx("div",{style:a,children:P}):h.jsx("div",{style:a,role:"none",onClick:m,onKeyDown:v,children:P})});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:s,...c}=t;return{...c,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=l.forwardRef(({props:e,value:t,onChange:n,onBlur:r,readOnly:s,mode:c,onMeasureHeight:d,onMeasureWidth:o,ariaLabel:f},g)=>{const a=l.useRef(null),u=l.useRef(null),y=l.useRef(null),w=l.useRef(null),[b,x]=l.useState(null),R=l.useRef(null),m=l.useRef(null),v=t!=null?String(t):"";l.useLayoutEffect(()=>{if(!e.multiline)return;const E=y.current,T=u.current;if(!E||!T)return;const F=v+(v.endsWith(`
|
|
2
|
+
`)?" ":"");E.textContent=F||" ";const p=window.getComputedStyle(T),_=Number.parseFloat(p.paddingTop),$=Number.parseFloat(p.paddingBottom),z=Number.parseFloat(p.paddingLeft),j=Number.parseFloat(p.paddingRight),k=T.clientWidth-z-j;E.style.width=`${k}px`,E.style.paddingTop="0px",E.style.paddingBottom="0px";const D=E.scrollHeight;if(x(D),d){const B=D+_+$;B!==R.current&&(R.current=B,d(B))}},[e,v,d]),l.useLayoutEffect(()=>{if(!o)return;const E=w.current;if(!E)return;E.textContent=v;const T=E.offsetWidth+2;T!==m.current&&(m.current=T,o(T))},[v,o]),l.useImperativeHandle(g,()=>({focus:()=>{var E;return(E=a.current)==null?void 0:E.focus()}}),[]);const P=!s,O=l.useMemo(()=>{const E={position:"relative",width:"100%",height:"100%",display:"flex",boxSizing:"border-box",overflow:"hidden",cursor:P?"text":"default"};E.justifyContent=gn[e.horizontal??i.HorizontalAlign.left],E.alignItems=pn[e.vertical??i.VerticalAlign.center];const T=e.bulk?e.all:void 0,F=T??e.top,p=T??e.right,_=T??e.bottom,$=T??e.left;return F&&(E.paddingTop=i.dimensionToString(F)),p&&(E.paddingRight=i.dimensionToString(p)),_&&(E.paddingBottom=i.dimensionToString(_)),$&&(E.paddingLeft=i.dimensionToString($)),E},[e,P]),S=l.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 T=[];switch(e.underline&&T.push("underline"),e.lineThrough&&T.push("line-through"),E.textDecoration=T.length>0?T.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]),L=l.useMemo(()=>({...S,position:"absolute",top:0,left:0,visibility:"hidden",pointerEvents:"none",whiteSpace:"pre",width:"auto",height:"auto",overflow:"visible"}),[S]),N=l.useMemo(()=>{const E=!!o;return{...S,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"}},[S,o]),I=E=>{n(E.target.value)},M=()=>{r==null||r(t)},C=l.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]),H=l.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=l.useCallback(E=>{if(!C)return;const T=E.nativeEvent;if(T.data){for(const F of T.data)if(!C.test(F)){E.preventDefault();return}}},[C]),J=l.useCallback(E=>{if(!C)return;const T=E.currentTarget,F=[...T.value].filter(p=>C.test(p)).join("");F!==T.value&&n(F)},[C,n]),W=c===i.NoteMode.EDIT||c===i.NoteMode.FORM?e.placeholder:void 0,A=E=>{var T;P&&E.target===E.currentTarget&&((T=a.current)==null||T.focus())};if(e.multiline){const E={...S,resize:"none",overflow:o||c===i.NoteMode.VIEW?"hidden":"auto",height:b!==null?`${b}px`:"auto"},T=F=>{a.current=F};return h.jsxs("div",{ref:u,style:O,role:"none",onClick:A,onKeyDown:F=>{var p;P&&(F.key==="Enter"||F.key===" ")&&((p=a.current)==null||p.focus())},children:[h.jsx("div",{ref:y,style:N,"aria-hidden":"true"}),h.jsx("textarea",{ref:T,value:v,onChange:I,onBlur:M,onBeforeInput:q,onCompositionEnd:J,inputMode:H,style:E,placeholder:W,readOnly:!P,tabIndex:P?0:-1,"aria-label":f}),o&&h.jsx("span",{ref:w,"aria-hidden":"true",style:L})]})}return h.jsxs("div",{style:O,role:"none",onClick:A,onKeyDown:E=>{var T;P&&(E.key==="Enter"||E.key===" ")&&((T=a.current)==null||T.focus())},children:[h.jsx("input",{ref:a,type:e.inputType??"text",value:v,onChange:I,onBlur:M,onBeforeInput:q,onCompositionEnd:J,inputMode:H,style:S,placeholder:W,readOnly:!P,tabIndex:P?0:-1,"aria-label":f,min:e.min,max:e.max,step:e.step}),o&&h.jsx("span",{ref:w,"aria-hidden":"true",style:L})]})});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 s of["min","max","step"])s in n&&typeof n[s]!="number"&&(n[s]=void 0);return n},validateValue:e=>{if(typeof e=="string")return e;if(typeof e=="number")return String(e)}};function mn(e){const t=l.useRef(e);t.current=e;const n=l.useCallback((s,c)=>{const d=t.current[s];d&&(c!==void 0&&d.validatePayload!==void 0&&!d.validatePayload(c)||d.execute(c))},[]),r=l.useCallback(s=>{var c;return((c=t.current[s])==null?void 0:c.isEnabled())??!1},[]);return l.useMemo(()=>({execute:n,isEnabled:r}),[n,r])}function Re(e,t,n){if(t.length===0)return n;const[r,...s]=t,c=typeof e=="object"&&e!==null?e:{};return{...c,[r]:Re(c[r],s,n)}}function yn(e,t,n){const r=t.split(".");return Re(e,r,n)}function Be(e,t){const n=t.split(".");let r=e;for(const s of n){if(r===null||typeof r!="object")return null;r=r[s]}return r??null}function xn(e,t,n){const r=l.useRef(e);r.current=e;const s=l.useRef((n==null?void 0:n.pageIdx)??0);s.current=(n==null?void 0:n.pageIdx)??0;const c=l.useRef(n==null?void 0:n.extra);c.current=n==null?void 0:n.extra;const d=l.useCallback(f=>{var u;const g=c.current;if(g){const y=g.get(f);if(y!==void 0)return y}const a=r.current;return f.startsWith("margin.")?Be(a.paper.margin,f.slice(7)):f.startsWith("grid.")?Be((u=a.pages[s.current])==null?void 0:u.grid,f.slice(5)):Be(a,f)},[]),o=l.useCallback((f,g)=>{var y;const a=c.current;if(a&&a.get(f)!==void 0){a.set(f,g);return}const u=r.current;if(f.startsWith("margin.")){if(f==="margin.bulk"&&g===!0){const x=u.paper.margin,R=(y=x.all)!=null&&y.unit?x.all:x.top;t({...u,paper:{...u.paper,margin:{...x,bulk:!0,all:R}}},{mergeKey:i.bindingKey(f)});return}const w=f.slice(7),b=Re(u.paper.margin,w.split("."),g);t({...u,paper:{...u.paper,margin:b}},{mergeKey:i.bindingKey(f)});return}if(f.startsWith("grid.")){const w=s.current,b=u.pages[w];if(!b)return;const x=Re(b.grid,f.slice(5).split("."),g),R=u.pages.map((m,v)=>v===w?{...m,grid:x}:m);t({...u,pages:R},{mergeKey:i.bindingKey(f)});return}t(yn(u,f,g),{mergeKey:i.bindingKey(f)})},[t]);return l.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 s=[...e.entries.slice(0,e.idx+1),{book:t.book,mergeKey:t.mergeKey,timestamp:t.timestamp}],c=s.length>t.maxHistory?s.slice(s.length-t.maxHistory):s;return{entries:c,idx:c.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 g;const n=t??ot,[r,s]=l.useReducer(wn,void 0,()=>({entries:[{book:e,timestamp:Date.now()}],idx:0})),c=((g=r.entries[r.idx])==null?void 0:g.book)??e,d=l.useCallback((a,u)=>{s({type:"push",book:a,mergeKey:u==null?void 0:u.mergeKey,noTimeWindow:u==null?void 0:u.noTimeWindow,timestamp:Date.now(),maxHistory:n})},[n]),o=l.useCallback(()=>s({type:"undo"}),[]),f=l.useCallback(()=>s({type:"redo"}),[]);return{book:c,handleBookChange:d,canUndo:r.idx>0,canRedo:r.idx<r.entries.length-1,undo:o,redo:f,historyActionHandlers:{undo:{execute:o,isEnabled:()=>r.idx>0},redo:{execute:f,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 ce=l.memo(({blockSizePx:e,borderStyle:t,blockZIndex:n,subZIndex:r=i.BLOCK_SUB_INDEX.BORDER,visible:s=!0,dpi:c=i.DEFAULT_DPI})=>{if(!s||!t)return null;const{top:d,right:o,bottom:f,left:g}=t;if(!d&&!o&&!f&&!g)return null;const{width:a,height:u}=e,y=me(n,r);return h.jsxs("svg",{role:"presentation","aria-hidden":"true",style:{position:"absolute",inset:0,width:`${a}px`,height:`${u}px`,pointerEvents:"none",overflow:"visible",zIndex:y},width:a,height:u,"data-testid":"block-border",children:[d&&h.jsx("line",{x1:0,y1:0,x2:a,y2:0,...we(d,c)}),o&&h.jsx("line",{x1:a,y1:0,x2:a,y2:u,...we(o,c)}),f&&h.jsx("line",{x1:0,y1:u,x2:a,y2:u,...we(f,c)}),g&&h.jsx("line",{x1:0,y1:0,x2:0,y2:u,...we(g,c)})]})});ce.displayName="BlockBorder";const ye=l.memo(({blockSizePx:e,blockZIndex:t,subZIndex:n=i.BLOCK_SUB_INDEX.BG,backgroundColor:r="transparent"})=>{const s=me(t,n),c={position:"absolute",inset:0,width:`${e.width}px`,height:`${e.height}px`,backgroundColor:r,pointerEvents:"none",zIndex:s};return h.jsx("div",{style:c,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 Ne={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}},Te=l.memo(({blockSizePx:e,blockZIndex:t,subZIndex:n=i.BLOCK_SUB_INDEX.GUIDE,borderStyle:r=Ne,visible:s=!0})=>{if(!s||!r)return null;const{top:c,right:d,bottom:o,left:f}=r;if(!c&&!d&&!o&&!f)return null;const{width:g,height:a}=e,u=me(t,n);return h.jsxs("svg",{role:"presentation","aria-hidden":"true",style:{position:"absolute",inset:0,width:`${g}px`,height:`${a}px`,pointerEvents:"none",overflow:"visible",zIndex:u},width:g,height:a,"data-testid":"block-guide-border",children:[c&&h.jsx("line",{x1:0,y1:0,x2:g,y2:0,stroke:c.color,strokeWidth:c.width.value,strokeDasharray:be(c.type,c.width.value)}),d&&h.jsx("line",{x1:g,y1:0,x2:g,y2:a,stroke:d.color,strokeWidth:d.width.value,strokeDasharray:be(d.type,d.width.value)}),o&&h.jsx("line",{x1:0,y1:a,x2:g,y2:a,stroke:o.color,strokeWidth:o.width.value,strokeDasharray:be(o.type,o.width.value)}),f&&h.jsx("line",{x1:0,y1:0,x2:0,y2:a,stroke:f.color,strokeWidth:f.width.value,strokeDasharray:be(f.type,f.width.value)})]})});Te.displayName="BlockGuideBorder";const kn=({id:e,resolvedPlugin:t,props:n,value:r,onChange:s,onBlur:c,readOnly:d,mode:o,blockSizePx:f,blockZIndex:g,subZIndex:a=i.BLOCK_SUB_INDEX.CONTENT,onMeasureHeight:u,onMeasureWidth:y,bindingContext:w,actionContext:b},x)=>{const R=l.useRef(null);l.useImperativeHandle(x,()=>({focus:()=>{var S;return(S=R.current)==null?void 0:S.focus()}}),[]);const m=me(g,a),v={position:"absolute",inset:0,width:`${f.width}px`,height:`${f.height}px`,zIndex:m,pointerEvents:"auto"},P={id:e,props:n,value:r,onChange:s??(()=>{}),onBlur:c,readOnly:d,mode:o,dimensions:{widthPx:f.width,heightPx:f.height},onMeasureHeight:u,onMeasureWidth:y,ariaLabel:t.meta.displayName,bindingContext:w,actionContext:b},{Renderer:O}=t;return h.jsx("div",{style:v,"data-testid":"block-renderer","data-block-id":e,"data-plugin-kind":t.kind,children:h.jsx(O,{ref:R,...P})})},xe=l.memo(l.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=l.memo(({blockSizePx:e,blockZIndex:t,errors:n})=>{const[r,s]=l.useState(!1);if(n.length===0)return null;const c=me(t,i.BLOCK_SUB_INDEX.VALIDATION),d=3,o="repeating-linear-gradient(45deg, #1a1a1a 0px, #1a1a1a 4px, #FFD700 4px, #FFD700 8px)",f={position:"absolute",top:-d,left:-d,width:`${e.width+d*2}px`,height:`${e.height+d*2}px`,zIndex:c,pointerEvents:"none"},g=a=>({position:"absolute",background:o,...a});return h.jsxs("div",{style:f,"data-testid":"validation-overlay",children:[h.jsx("div",{style:g({top:0,left:0,width:"100%",height:d})}),h.jsx("div",{style:g({bottom:0,left:0,width:"100%",height:d})}),h.jsx("div",{style:g({top:0,left:0,width:d,height:"100%"})}),h.jsx("div",{style:g({top:0,right:0,width:d,height:"100%"})}),h.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:()=>s(!0),onMouseLeave:()=>s(!1),"aria-label":n.map(a=>a.message).join(" / "),children:["⚠",r&&h.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:c+1},children:n.map(a=>h.jsx("div",{children:a.message},a.code))})]}),h.jsx("style",{children:'@media print { [data-testid="validation-overlay"] { display: none !important; } }'})]})});Ze.displayName="ValidationOverlay";const Ye=l.memo(l.forwardRef(({block:e,resolvedPlugin:t,blockRectPx:n,blockZIndex:r,mode:s,value:c,blockDefaults:d,onValueChange:o,onBlur:f,showGuides:g=!0,showBorder:a=!0,defaultGuideBorder:u=Ne,dpi:y=i.DEFAULT_DPI,pointerEvents:w="none",showValidation:b=!1,validationErrors:x,onMeasureHeight:R,onMeasureWidth:m,focusedBlockId:v,bindingContext:P,actionContext:O},S)=>{var $,z,j,k;const[L,N]=l.useState(null),[I,M]=l.useState(null),C=l.useCallback(D=>{N(D),R==null||R(e.id,D)},[e.id,R]),H=l.useCallback(D=>{M(D),m==null||m(e.id,D)},[e.id,m]),q=R?Math.max(n.height,L??0):n.height,J=m?Math.max(n.width,I??0):n.width,te={position:"absolute",left:`${n.left}px`,top:`${n.top}px`,width:`${J}px`,height:`${q}px`,zIndex:r,pointerEvents:w,boxSizing:"border-box"},W=l.useMemo(()=>({width:J,height:q}),[J,q]),A=Xe(e,t,d),E=t.validateProps?t.validateProps(A):A,T=t.validateValue?t.validateValue(c,E)??e.initValue??c:c,F=x&&x.length>0,p=F?`error-${e.id}`:void 0,_=v===e.id;return h.jsxs("section",{"aria-label":t.meta.displayName,"aria-invalid":F||void 0,"aria-describedby":p,style:te,"data-testid":`block-${e.id}`,"data-block-id":e.id,children:[h.jsx(ye,{blockSizePx:W,blockZIndex:r,backgroundColor:($=e.style)==null?void 0:$.backgroundColor,subZIndex:i.BLOCK_SUB_INDEX.BG}),g&&!((z=e.style)!=null&&z.border)&&h.jsx(Te,{blockSizePx:W,blockZIndex:r,subZIndex:i.BLOCK_SUB_INDEX.GUIDE,borderStyle:u}),h.jsx(xe,{ref:S,id:e.id,resolvedPlugin:t,props:E,value:T,onChange:o,onBlur:f,readOnly:s===i.NoteMode.EDIT?((j=e.behavior)==null?void 0:j.readOnly)??!1:!0,mode:s,blockSizePx:W,blockZIndex:r,subZIndex:i.BLOCK_SUB_INDEX.CONTENT,onMeasureHeight:R?C:void 0,onMeasureWidth:m?H:void 0,bindingContext:P,actionContext:O}),h.jsx(ce,{blockSizePx:W,blockZIndex:r,borderStyle:(k=e.style)==null?void 0:k.border,subZIndex:i.BLOCK_SUB_INDEX.BORDER,visible:a,dpi:y}),b&&F&&h.jsx(Ze,{blockSizePx:W,blockZIndex:r,errors:x}),F&&h.jsx("span",{id:p,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(D=>D.message).join(", ")}),_&&h.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 Dn=(e,t)=>{},In=(e,t)=>{},ve=l.memo(({blocks:e,pluginRegistry:t,mode:n,values:r,blockDefaults:s,selectedBlockIds:c=[],getBlockRectPx:d,onValueChange:o,onBlur:f,showGuides:g=!0,showBorder:a=!0,defaultGuideBorder:u=Ne,dpi:y=i.DEFAULT_DPI,showValidation:w=!1,validationErrors:b,onMeasureHeight:x,onMeasureWidth:R,focusedBlockId:m,bindingContext:v,actionContext:P})=>{const O=l.useRef(new Map),S={position:"absolute",inset:0,pointerEvents:"none"};return h.jsx("div",{style:S,"data-testid":"block-layer",children:e.map((L,N)=>{var T,F;const I=t[L.kind];if(!I)return console.warn(`[tatamicks] Block kind "${L.kind}" is not registered. Add the plugin to createPluginRegistry.`),null;if(he(L.hiddenBinding,v))return null;const C=d(L),q=c.includes(L.id)?i.Z_INDEX.SELECT_BLOCK:Yt(N),J=L.props!==null&&typeof L.props=="object"&&"binding"in L.props?L.props.binding:void 0,te=J&&v?v.get(J)??null:L.id in r?r[L.id]:L.initValue??null,W=J&&v?p=>v.set(J,p):o?p=>o(L.id,p):void 0,A=(T=L.behavior)!=null&&T.heightFit?x??Dn:void 0,E=(F=L.behavior)!=null&&F.widthFit?R??In:void 0;return h.jsx(l.Fragment,{children:h.jsx(Ye,{ref:p=>{p?O.current.set(L.id,p):O.current.delete(L.id)},block:L,resolvedPlugin:I,blockRectPx:C,blockZIndex:q,mode:n,value:te??null,blockDefaults:s,onValueChange:W,onBlur:f?p=>f(L.id,p):void 0,showGuides:g,showBorder:a,defaultGuideBorder:u,dpi:y,pointerEvents:"none",showValidation:w,validationErrors:b==null?void 0:b[L.id],onMeasureHeight:A,onMeasureWidth:E,focusedBlockId:m,bindingContext:v,actionContext:P})},L.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=l.memo(({contentPx:e,marginLeftPx:t,marginTopPx:n,borderStyle:r,dpi:s=i.DEFAULT_DPI,zIndex:c=i.Z_INDEX.BORDER_OVERLAY})=>{if(!r)return null;const{top:d,right:o,bottom:f,left:g}=r;if(!d&&!o&&!f&&!g)return null;const a=e.width,u=e.height;return h.jsxs("svg",{role:"presentation","aria-hidden":"true",style:{position:"absolute",left:`${t}px`,top:`${n}px`,pointerEvents:"none",overflow:"visible",zIndex:c},width:a,height:u,"data-testid":"border-overlay",children:[d&&h.jsx("line",{x1:0,y1:0,x2:a,y2:0,...Ee(d,s)}),o&&h.jsx("line",{x1:a,y1:0,x2:a,y2:u,...Ee(o,s)}),f&&h.jsx("line",{x1:0,y1:u,x2:a,y2:u,...Ee(f,s)}),g&&h.jsx("line",{x1:0,y1:0,x2:0,y2:u,...Ee(g,s)})]})});yt.displayName="BorderOverlay";const xt=l.memo(({canvasPx:e,backgroundColor:t="#ffffff",boxShadow:n="0 2px 8px rgba(0, 0, 0, 0.1)",zIndex:r=i.Z_INDEX.GRID_CANVAS})=>h.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 Rn="_label_er4b8_1",Sn={label:Rn},Cn="_editor_1xj3w_1",Pn="_input_1xj3w_14",Nn="_select_1xj3w_29",Tn="_button_1xj3w_45",ke={editor:Cn,input:Pn,select:Nn,button:Tn},Mn=["fr","px","mm","cm","pt","inch"];function Ln(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=l.memo(({direction:e,dimension:t,currentPxSize:n,position:r,marginLeftPx:s,marginTopPx:c,onChange:d,onCancel:o})=>{const[f,g]=l.useState(t.value.toString()),[a,u]=l.useState(t.unit),y=l.useRef(null),w=l.useRef(null),b=e==="column"?{left:`${s+r}px`,top:`${c+24}px`,transform:"translateX(-50%)"}:{left:`${s+24}px`,top:`${c+r}px`,transform:"translateY(-50%)"};l.useEffect(()=>{var v,P;(v=y.current)==null||v.focus(),(P=y.current)==null||P.select()},[]),l.useEffect(()=>{const v=P=>{w.current&&!w.current.contains(P.target)&&o()};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[o]);const x=()=>{const v=Number.parseFloat(f);!Number.isNaN(v)&&v>=.1?d({unit:a,value:v}):o()},R=v=>{v.key==="Enter"?(v.preventDefault(),x()):v.key==="Escape"&&(v.preventDefault(),o())},m=v=>{const P=v.target.value;u(P),g(Ln(n,P).toString())};return h.jsxs("div",{ref:w,className:ke.editor,style:b,"data-testid":`grid-unit-editor-${e}`,children:[h.jsx("input",{ref:y,type:"number",className:ke.input,value:f,onChange:v=>g(v.target.value),onKeyDown:R,min:"0.1",step:a==="fr"?"0.1":"1"}),h.jsx("select",{className:ke.select,value:a,onChange:m,children:Mn.map(v=>h.jsx("option",{value:v,children:v},v))}),h.jsx("button",{type:"button",className:ke.button,onClick:x,title:"確定",children:"✓"})]})});vt.displayName="GridUnitEditor";function Bn(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 s=t;throw new Error(`Unsupported unit: ${s}`)}}}const Oe=l.memo(({direction:e,index:t,dimension:n,position:r,currentPxSize:s,marginLeftPx:c,marginTopPx:d,isNearCursor:o,resizingPxSize:f,onDimensionChange:g})=>{const[a,u]=l.useState(!1);if(!o&&!a)return null;const y=e==="column"?{left:`${c+r}px`,top:`${d-20}px`,transform:"translateX(-50%)"}:{left:`${c-20}px`,top:`${d+r}px`,transform:"translateY(-50%)",writingMode:"vertical-rl"},b=f?(()=>{const x=Bn(f,n.unit,n.value,s);return n.unit==="fr"?`${x}fr`:`${x}${n.unit}`})():(x=>x.unit==="fr"?`${x.value}fr`:`${x.value}${x.unit}`)(n);return h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button",className:Sn.label,style:y,onDoubleClick:()=>u(!0),"data-testid":`grid-dimension-${e}-${t}`,"aria-label":`グリッド寸法: ${b}`,children:b}),a&&h.jsx(vt,{direction:e,dimension:n,currentPxSize:s,position:r,marginLeftPx:c,marginTopPx:d,onChange:x=>{g==null||g(e,t,x),u(!1)},onCancel:()=>u(!1)})]})});Oe.displayName="GridDimensionLabel";function An(e,t,n,r){let s="";for(const c of e)s+=`M ${c} 0 L ${c} ${r} `;for(const c of t)s+=`M 0 ${c} L ${n} ${c} `;return s}const wt=l.memo(({gridPosPx:e,contentPx:t,marginLeftPx:n,marginTopPx:r,lineStyle:s,zIndex:c=i.Z_INDEX.GRID_OVERLAY,dpi:d=i.DEFAULT_DPI})=>{const o=l.useMemo(()=>An(e.cols.slice(1,-1),e.rows.slice(1,-1),t.width,t.height),[e,t]);return s?h.jsx("svg",{style:{position:"absolute",left:`${n}px`,top:`${r}px`,pointerEvents:"none",zIndex:c},width:t.width,height:t.height,role:"img","aria-label":"Grid overlay lines",children:h.jsx("path",{d:o,stroke:s.color,strokeWidth:i.toPx.fromDim(s.width,d),strokeDasharray:mt(s),fill:"none"})}):null});wt.displayName="GridOverlay";const _n="_handle_i8g0e_1",On="_dragging_i8g0e_19",st={handle:_n,dragging:On},ze=l.memo(({direction:e,index:t,position:n,marginLeftPx:r,marginTopPx:s,onResizeStart:c,onResize:d,onResizeEnd:o})=>{const[f,g]=l.useState(!1),a=12,u=a/2,y=e==="column"?{left:`${r+n-u}px`,top:`${s-u}px`,width:`${a}px`,height:`${a}px`,cursor:"col-resize"}:{left:`${r-u}px`,top:`${s+n-u}px`,width:`${a}px`,height:`${a}px`,cursor:"row-resize"},w=l.useCallback(b=>{b.stopPropagation(),b.preventDefault();const x=e==="column"?b.clientX:b.clientY;g(!0),c==null||c(e,t);const R=v=>{const P=e==="column"?v.clientX:v.clientY;d==null||d(e,t,P-x)},m=v=>{const P=e==="column"?v.clientX:v.clientY;g(!1),o==null||o(e,t,P-x),window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",m)};window.addEventListener("pointermove",R),window.addEventListener("pointerup",m)},[e,t,c,d,o]);return h.jsx("div",{className:`${st.handle} ${f?st.dragging:""}`,style:y,onPointerDown:w,"data-testid":`grid-resize-handle-${e}-${t}`})});ze.displayName="GridResizeHandle";const bt=l.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 h.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&&h.jsx("div",{"data-testid":"margin-top",style:{...r,top:0,left:0,width:"100%",height:`${e.margin.top}px`}}),e.margin.bottom>0&&h.jsx("div",{"data-testid":"margin-bottom",style:{...r,bottom:0,left:0,width:"100%",height:`${e.margin.bottom}px`}}),e.margin.left>0&&h.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&&h.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 Me=l.memo(({paperPx:e,gridPosPx:t,gridDimensions:n,gridLineStyle:r,borderStyle:s,backgroundColor:c="#ffffff",boxShadow:d="0 2px 8px rgba(0, 0, 0, 0.1)",marginFillColor:o,showGridLines:f=!0,showMargins:g=!0,showBorder:a=!0,showResizeHandles:u=!1,showDimensionLabels:y=!1,dpi:w=i.DEFAULT_DPI,onGridResize:b,onDimensionChange:x,className:R="",zIndex:m={}})=>{const[v,P]=l.useState(null),[O,S]=l.useState(null),[L,N]=l.useState(null),I=l.useRef(null);l.useEffect(()=>{const W=E=>{if(!I.current)return;const T=I.current.getBoundingClientRect();N({x:E.clientX-T.left,y:E.clientY-T.top})},A=E=>{if(!I.current)return;const T=I.current.getBoundingClientRect();(E.clientX<T.left||E.clientX>T.right||E.clientY<T.top||E.clientY>T.bottom)&&N(null)};return window.addEventListener("mousemove",W),window.addEventListener("mouseleave",A),()=>{window.removeEventListener("mousemove",W),window.removeEventListener("mouseleave",A)}},[]);const M=l.useMemo(()=>L?!(L.x>=e.margin.left&&L.x<=e.margin.left+e.content.width&&L.y>=e.margin.top&&L.y<=e.margin.top+e.content.height):!1,[L,e]),C=l.useMemo(()=>{if(!v||!O)return null;const W=O.direction==="column"?t.cols:t.rows,A=O.index,E=W[A-1],T=W[A+1];return{direction:O.direction,prevIndex:A-1,prevSize:E!==void 0?v.position-E:0,nextIndex:A,nextSize:T!==void 0?T-v.position:0}},[v,O,t]),H=l.useCallback((W,A,E)=>{const F=W==="column"?t.cols:t.rows,p=F[A];if(p===void 0)return E;const _=F[A-1],$=F[A+1];let z=E;return _!==void 0&&(z=Math.max(z,_+10-p)),$!==void 0&&(z=Math.min(z,$-10-p)),z},[t]),q=l.useCallback((W,A)=>{S({direction:W,index:A})},[]),J=l.useCallback((W,A,E)=>{const F=(W==="column"?t.cols:t.rows)[A];F!==void 0&&P({direction:W,position:F+H(W,A,E)})},[t,H]),te=l.useCallback((W,A,E)=>{P(null),S(null),b==null||b(W,A,H(W,A,E))},[H,b]);return h.jsxs("div",{ref:I,className:R,style:{position:"relative",width:"100%",height:"100%"},children:[h.jsx(xt,{canvasPx:e.canvas,backgroundColor:c,boxShadow:d,zIndex:m.canvas??i.Z_INDEX.GRID_CANVAS}),g&&h.jsx(bt,{paperPx:e,marginColor:o,zIndex:m.margin??i.Z_INDEX.MARGIN_OVERLAY}),f&&h.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}),a&&h.jsx(yt,{contentPx:e.content,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,borderStyle:s,dpi:w,zIndex:m.border??i.Z_INDEX.BORDER_OVERLAY}),u&&b&&h.jsxs(h.Fragment,{children:[t.cols.map((W,A)=>A===0||A===t.cols.length-1?null:h.jsx(ze,{direction:"column",index:A,position:W,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,onResizeStart:q,onResize:J,onResizeEnd:te},`col-${W}`)),t.rows.map((W,A)=>A===0||A===t.rows.length-1?null:h.jsx(ze,{direction:"row",index:A,position:W,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,onResizeStart:q,onResize:J,onResizeEnd:te},`row-${W}`))]}),y&&n&&h.jsxs(h.Fragment,{children:[n.cols.map((W,A)=>{const E=t.cols[A],T=t.cols[A+1];if(E===void 0||T===void 0)return null;const F=(O==null?void 0:O.direction)==="column"&&(O.index===A||O.index===A+1);let p;return(C==null?void 0:C.direction)==="column"&&(C.prevIndex===A?p=C.prevSize:C.nextIndex===A&&(p=C.nextSize)),h.jsx(Oe,{direction:"column",index:A,dimension:W,position:(E+T)/2,currentPxSize:T-E,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,isNearCursor:M||F,resizingPxSize:p,onDimensionChange:x},`col-dim-${E}`)}),n.rows.map((W,A)=>{const E=t.rows[A],T=t.rows[A+1];if(E===void 0||T===void 0)return null;const F=(O==null?void 0:O.direction)==="row"&&(O.index===A||O.index===A+1);let p;return(C==null?void 0:C.direction)==="row"&&(C.prevIndex===A?p=C.prevSize:C.nextIndex===A&&(p=C.nextSize)),h.jsx(Oe,{direction:"row",index:A,dimension:W,position:(E+T)/2,currentPxSize:T-E,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,isNearCursor:M||F,resizingPxSize:p,onDimensionChange:x},`row-dim-${E}`)})]}),v&&h.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}})]})});Me.displayName="GridLayer";function Et(e){return l.useState({editingBlockId:null,...e})}var ee=(e=>(e.IDLE="idle",e.PRESSING="pressing",e.DRAGGING="dragging",e.INSERT="insert",e.EDITING="editing",e))(ee||{}),K=(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))(K||{}),Q=(e=>(e.MOVE="move",e.RESIZE="resize",e.INSERT="insert",e))(Q||{});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 Dt({layout:e,handle:t,deltaCol:n,deltaRow:r,gridCols:s,gridRows:c}){const d={...e};if(t===K.E||t===K.NE||t===K.SE){const o=s-e.x;d.w=Math.max(1,Math.min(e.w+n,o))}else if(t===K.W||t===K.NW||t===K.SW){const o=e.w-1,f=n>0?Math.min(n,o):n;e.x+f>=0?(d.x=e.x+f,d.w=e.w-f):(d.x=0,d.w=e.w+e.x)}if(t===K.S||t===K.SE||t===K.SW){const o=c-e.y;d.h=Math.max(1,Math.min(e.h+r,o))}else if(t===K.N||t===K.NE||t===K.NW){const o=e.h-1,f=r>0?Math.min(r,o):r;e.y+f>=0?(d.y=e.y+f,d.h=e.h-f):(d.y=0,d.h=e.h+e.y)}return d}function It(e,t,n,r,s){if(e.length===0)return[];if(e.length===1){const x=e[0];if(!x)return[];const R=r-x.layout.w,m=s-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 c=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)),f=Math.max(...e.map(x=>x.layout.y+x.layout.h)),g=o-c,a=f-d,u=Math.max(0,Math.min(c+t,r-g)),y=Math.max(0,Math.min(d+n,s-a)),w=u-c,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}},Ie=l.memo(({block:e,resolvedPlugin:t,blockDefaults:n,rect:r,opacity:s,ghostZIndex:c})=>{var f,g,a;const d=Xe(e,t,n),o={width:r.width,height:r.height};return h.jsxs("div",{style:{position:"absolute",left:`${r.left}px`,top:`${r.top}px`,width:`${r.width}px`,height:`${r.height}px`,opacity:s,zIndex:c,pointerEvents:"none"},children:[h.jsx(ye,{blockSizePx:o,blockZIndex:0,subZIndex:i.BLOCK_SUB_INDEX.BG,backgroundColor:(f=e.style)==null?void 0:f.backgroundColor}),h.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}),!((g=e.style)!=null&&g.border)&&h.jsx(Te,{blockSizePx:o,blockZIndex:0,subZIndex:i.BLOCK_SUB_INDEX.GUIDE,borderStyle:zn}),h.jsx(ce,{blockSizePx:o,borderStyle:(a=e.style)==null?void 0:a.border,blockZIndex:0,subZIndex:i.BLOCK_SUB_INDEX.BORDER,dpi:i.DEFAULT_DPI})]})});Ie.displayName="GhostBlock";const Rt=l.memo(({blocks:e,pluginRegistry:t,gridLength:n,draggingState:r,getBlockRectPx:s,blockDefaults:c,ghostZIndex:d=i.Z_INDEX.BLOCK_GHOST})=>{if(!r)return null;const o=r.currentGrid.col-r.startGrid.col,f=r.currentGrid.row-r.startGrid.row,g={position:"absolute",inset:0,pointerEvents:"none"};if(r.type===Q.MOVE){const a=r.blockIds.map(y=>e.find(w=>w.id===y)).filter(Boolean),u=It(a,o,f,n.cols,n.rows);return h.jsx("div",{style:g,"data-testid":"drag-layer-move",children:a.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=s(y);b={left:R.x-m.width/2,top:R.y-m.height/2,width:m.width,height:m.height}}else{const m=u.find(P=>P.blockId===y.id);if(!m)return null;const v={...y,layout:{...y.layout,x:m.x,y:m.y}};b=s(v)}return h.jsx(Ie,{block:y,resolvedPlugin:w,blockDefaults:c,rect:b,opacity:x?.3:.5,ghostZIndex:d},y.id)})})}if(r.type===Q.RESIZE){const a=r.blockIds[0],u=r.handle;if(!a||!u)return null;const y=e.find(m=>m.id===a),w=y?t[y.kind]:void 0;if(!y||!w)return null;const b=Dt({layout:y.layout,handle:u,deltaCol:o,deltaRow:f,gridCols:n.cols,gridRows:n.rows}),x={...y,layout:b},R=s(x);return h.jsx("div",{style:g,"data-testid":"drag-layer-resize",children:h.jsx(Ie,{block:y,resolvedPlugin:w,blockDefaults:c,rect:R,opacity:r.isOutside?.3:.5,ghostZIndex:d})})}if(r.type===Q.INSERT){const{pluginKind:a,defaultSize:u,currentGrid:y,currentMousePx:w}=r;if(!a||!u)return null;const b=t[a];if(!b)return null;const x=r.isOutside??!1;let R;if(x&&w){const v=fe(b,{x:0,y:0}),P=s({...v,layout:{...v.layout,w:u.w,h:u.h}});R={left:w.x-P.width/2,top:w.y-P.height/2,width:P.width,height:P.height}}else{const v=n.cols-u.w,P=n.rows-u.h,O=Math.max(0,Math.min(y.col,v)),S=Math.max(0,Math.min(y.row,P)),L=fe(b,{x:O,y:S}),N={...L,layout:{...L.layout,w:u.w,h:u.h}};R=s(N)}const m={...fe(b,{x:0,y:0}),layout:{x:0,y:0,w:u.w,h:u.h}};return h.jsx("div",{style:g,"data-testid":"drag-layer-insert",children:h.jsx(Ie,{block:m,resolvedPlugin:b,blockDefaults:c,rect:R,opacity:x?.3:.5,ghostZIndex:d})})}return null});Rt.displayName="DragLayer";const jn=({id:e,resolvedPlugin:t,props:n,value:r,onChange:s,blockRectPx:c,block:d,zIndex:o=i.Z_INDEX.EDIT_BLOCK,bindingContext:f,actionContext:g},a)=>{var w,b;const u=l.useRef(null);l.useImperativeHandle(a,()=>({focus:()=>{var x;return(x=u.current)==null?void 0:x.focus()}}),[]);const y={width:c.width,height:c.height};return h.jsxs("div",{style:{position:"absolute",left:`${c.left}px`,top:`${c.top}px`,width:`${y.width}px`,height:`${y.height}px`,zIndex:o,pointerEvents:"auto"},"data-testid":"editing-block",children:[h.jsx(ye,{blockSizePx:y,blockZIndex:0,subZIndex:i.BLOCK_SUB_INDEX.BG,backgroundColor:(w=d.style)==null?void 0:w.backgroundColor}),h.jsx(xe,{ref:u,id:e,resolvedPlugin:t,props:n,value:r,onChange:s,readOnly:!1,mode:i.NoteMode.EDIT,blockSizePx:y,blockZIndex:0,subZIndex:i.BLOCK_SUB_INDEX.CONTENT,bindingContext:f,actionContext:g}),h.jsx(ce,{blockSizePx:y,borderStyle:(b=d.style)==null?void 0:b.border,blockZIndex:0,subZIndex:i.BLOCK_SUB_INDEX.BORDER,dpi:i.DEFAULT_DPI})]})},St=l.memo(l.forwardRef(jn));St.displayName="EditingBlock";const De={color:"#3b82f688",width:{value:4,unit:"px"},type:i.LineType.SOLID},Ct={top:De,right:De,bottom:De,left:De},je=12,se=je/2,$n=[{id:K.NW,cursor:"nwse-resize",x:0,y:0},{id:K.N,cursor:"ns-resize",x:50,y:0},{id:K.NE,cursor:"nesw-resize",x:100,y:0},{id:K.W,cursor:"ew-resize",x:0,y:50},{id:K.E,cursor:"ew-resize",x:100,y:50},{id:K.SW,cursor:"nesw-resize",x:0,y:100},{id:K.S,cursor:"ns-resize",x:50,y:100},{id:K.SE,cursor:"nwse-resize",x:100,y:100}],Pt=l.memo(({block:e,rect:t,showHandles:n=!1,onResizeStart:r,activeHandle:s,selectionStyle:c=Ct,selectBorderZIndex:d=i.Z_INDEX.BLOCK_SELECT_BORDER,blockHandlesZIndex:o=i.Z_INDEX.BLOCK_HANDLES})=>{const f={position:"absolute",left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,pointerEvents:"none"};return h.jsxs("div",{style:f,"data-testid":"interaction-block","data-block-id":e.id,children:[h.jsx(ce,{blockSizePx:{width:t.width,height:t.height},borderStyle:c,blockZIndex:d,subZIndex:0,dpi:i.DEFAULT_DPI}),n&&r&&$n.map(({id:g,cursor:a,x:u,y})=>{const w=u===50?`calc(50% - ${se}px)`:u===100?`calc(100% - ${se}px)`:`-${se}px`,b=y===50?`calc(50% - ${se}px)`:y===100?`calc(100% - ${se}px)`:`-${se}px`,x=s===g;return h.jsx("div",{onPointerDown:R=>{R.stopPropagation(),r(R,g)},style:{position:"absolute",left:w,top:b,width:`${je}px`,height:`${je}px`,backgroundColor:x?"#3b82f6":"#ffffff",border:"1px solid #3b82f6",borderRadius:"50%",cursor:a,zIndex:o,pointerEvents:"auto",boxSizing:"border-box",transform:x?"scale(1.2)":void 0},"data-testid":`resize-handle-${g}`},g)})]})});Pt.displayName="InteractionBlock";const Nt=l.memo(({blocks:e,selectedBlockIds:t,isDragging:n,draggingState:r,getBlockRectPx:s,onResizeStart:c,selectionStyle:d=Ct,selectBorderZIndex:o,blockHandlesZIndex:f})=>{if(n&&(r==null?void 0:r.type)!==Q.RESIZE)return null;const a=Array.from(new Set(t));return h.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:a.map(u=>{const y=e.find(x=>x.id===u);if(!y)return null;const b=(r==null?void 0:r.type)===Q.RESIZE&&r.blockIds.includes(u)?r==null?void 0:r.handle:null;return h.jsx(Pt,{block:y,rect:s(y),showHandles:!0,onResizeStart:(x,R)=>c(x,R,u),activeHandle:b??null,selectionStyle:d,selectBorderZIndex:o,blockHandlesZIndex:f},y.id)})})});Nt.displayName="SelectionLayer";function Tt(e,t,n,r){const s=n-t.w,c=r-t.h;return{x:Math.max(0,Math.min(e.x,s)),y:Math.max(0,Math.min(e.y,c))}}function Gn(e,t,n){const r=e.x+e.w<t?e.x+1:Math.max(0,e.x-1),s=e.y+e.h<n?e.y+1:Math.max(0,e.y-1);return{x:r,y:s}}function lt(e,t,n){const{x:r,y:s}=e;for(let c=t.length-1;c>=0;c--){const d=t[c];if(!d)continue;const o=n(d);if(r>=o.left&&r<=o.left+o.width&&s>=o.top&&s<=o.top+o.height)return d.id}return null}const qe=l.memo(({page:e,pluginRegistry:t,gridLength:n,blockDefaults:r,getBlockRectPx:s,getColIndex:c,getRowIndex:d,state:o,onStateChange:f,selectedBlockIds:g,onSelectionChange:a,onPageChange:u,actionContext:y,bindingContext:w,scale:b=1,className:x="",selectionStyle:R})=>{const m=e.blocks,v=l.useRef(null),P=l.useRef(null),O=l.useRef(null);l.useEffect(()=>()=>{O.current!==null&&clearTimeout(O.current)},[]);const S=kt(o),L=l.useRef(null),N=l.useRef(0),I=l.useRef(null),M=l.useRef(0),C=l.useRef(o);C.current=o;const H=l.useRef(f);H.current=f,l.useEffect(()=>{if(S!==ee.INSERT)return;const p=_=>{const $=v.current;$&&(_.target===$||$.contains(_.target))||H.current({...C.current,dragging:void 0})};return window.addEventListener("pointerup",p),()=>window.removeEventListener("pointerup",p)},[S]),l.useEffect(()=>{if(S===ee.EDITING&&o.editingBlockId){const p=setTimeout(()=>{var _;(_=P.current)==null||_.focus()},0);return()=>clearTimeout(p)}},[S,o.editingBlockId]),l.useEffect(()=>{const p=new Set(m.map($=>$.id)),_=g.filter($=>p.has($));_.length!==g.length&&a(_)},[m,g,a]);const q=l.useCallback(p=>{var B;if(p.button!==0)return;const _=(B=v.current)==null?void 0:B.getBoundingClientRect();if(!_)return;const $=b,z={x:(p.clientX-_.left)/$,y:(p.clientY-_.top)/$},j=lt(z,m,s);if(S===ee.EDITING){j!==o.editingBlockId&&(f({...o,editingBlockId:null}),j||a([]));return}const k=c(z.x),D=d(z.y);if(j){p.stopPropagation();const V=g.includes(j);if(V&&p.shiftKey){a(g.filter(Y=>Y!==j));return}p.currentTarget.setPointerCapture(p.pointerId),V?f({...o,dragging:{type:Q.MOVE,blockIds:g,startGrid:{col:k,row:D},currentGrid:{col:k,row:D},isOutside:!1}}):p.shiftKey?a([...g,j]):(a([j]),f({...o,dragging:{type:Q.MOVE,blockIds:[j],startGrid:{col:k,row:D},currentGrid:{col:k,row:D},isOutside:!1}}))}else p.stopPropagation(),a([])},[m,s,c,d,S,g,a,f,b,o]),J=l.useCallback(p=>{var X;if(S!==ee.PRESSING&&S!==ee.DRAGGING&&S!==ee.INSERT||!o.dragging)return;const _=(X=v.current)==null?void 0:X.getBoundingClientRect();if(!_)return;const $=b,z=_.width/$,j=_.height/$,k=(p.clientX-_.left)/$,D=(p.clientY-_.top)/$,B=o.dragging.type!==Q.RESIZE&&(k<0||k>z||D<0||D>j),V=Math.max(0,Math.min(k,z)),Y=Math.max(0,Math.min(D,j));let G=c(V),Z=d(Y);if(o.dragging.type===Q.RESIZE&&o.dragging.handle){const U=o.dragging.handle;(U===K.E||U===K.NE||U===K.SE)&&(G=c(V)+1),(U===K.S||U===K.SE||U===K.SW)&&(Z=d(Y)+1)}f({...o,dragging:{...o.dragging,currentGrid:{col:G,row:Z},currentMousePx:{x:k,y:D},isOutside:B}})},[S,o,c,d,f,b]),te=l.useCallback(p=>{if((S===ee.DRAGGING||S===ee.INSERT)&&o.dragging){if(o.dragging.isOutside){if(o.dragging.type===Q.MOVE){const z=new Set(o.dragging.blockIds);u({...e,blocks:m.filter(j=>!z.has(j.id))}),a([])}f({...o,dragging:void 0}),p.currentTarget.releasePointerCapture(p.pointerId);return}const _=o.dragging.currentGrid.col-o.dragging.startGrid.col,$=o.dragging.currentGrid.row-o.dragging.startGrid.row;if(o.dragging.type===Q.MOVE&&(_!==0||$!==0)){const z=o.dragging.blockIds.map(j=>m.find(k=>k.id===j)).filter(Boolean);if(z.length>0){const j=It(z,_,$,n.cols,n.rows);u({...e,blocks:m.map(k=>{const D=j.find(B=>B.blockId===k.id);return D?{...k,layout:{...k.layout,x:D.x,y:D.y}}:k})})}}else if(o.dragging.type===Q.INSERT){const{pluginKind:z,currentGrid:j,defaultSize:k}=o.dragging;if(z&&k){const D=t[z];if(D){const{x:B,y:V}=Tt({x:j.col,y:j.row},{w:k.w,h:k.h},n.cols,n.rows),Y={...fe(D,{x:B,y:V}),layout:{x:B,y:V,w:k.w,h:k.h}};u({...e,blocks:[...m,Y]}),a([Y.id])}}}else if(o.dragging.type===Q.RESIZE){const z=o.dragging.blockIds[0],j=m.find(D=>D.id===z),k=o.dragging.handle;if(j&&k&&(_!==0||$!==0)){const D=Dt({layout:j.layout,handle:k,deltaCol:_,deltaRow:$,gridCols:n.cols,gridRows:n.rows});(D.x!==j.layout.x||D.y!==j.layout.y||D.w!==j.layout.w||D.h!==j.layout.h)&&u({...e,blocks:m.map(B=>B.id===j.id?{...B,layout:D}:B)})}}f({...o,dragging:void 0})}else if(S===ee.PRESSING&&o.dragging){if(o.dragging.isOutside&&o.dragging.type===Q.MOVE){const _=new Set(o.dragging.blockIds);u({...e,blocks:m.filter($=>!_.has($.id))}),a([])}f({...o,dragging:void 0})}p.currentTarget.releasePointerCapture(p.pointerId)},[S,o,m,e,n,t,u,f,a]),W=l.useCallback(p=>{var k;const _=(k=v.current)==null?void 0:k.getBoundingClientRect();if(!_)return;const $=b,z={x:(p.clientX-_.left)/$,y:(p.clientY-_.top)/$},j=lt(z,m,s);j&&(g.includes(j)||a([j]),f({...o,editingBlockId:j}))},[m,s,a,f,b,g,o]),A=l.useCallback(p=>{var _;if((S===ee.PRESSING||S===ee.DRAGGING||S===ee.INSERT)&&o.dragging){const $=(_=v.current)==null?void 0:_.getBoundingClientRect();if(!$)return;const z=b,j=(p.clientX-$.left)/z,k=(p.clientY-$.top)/z,D=$.width/z,B=$.height/z,V=Math.max(0,Math.min(j,D)),Y=Math.max(0,Math.min(k,B));f({...o,dragging:{...o.dragging,currentGrid:{col:c(V),row:d(Y)},currentMousePx:{x:j,y:k},isOutside:!0}})}},[S,o,b,c,d,f]),E=l.useCallback(p=>{const _=S===ee.EDITING;if(p.key==="Escape"){_?(p.preventDefault(),f({...o,editingBlockId:null}),O.current=setTimeout(()=>{var G;return(G=v.current)==null?void 0:G.focus()},0)):g.length>0&&(p.preventDefault(),a([]));return}if(_)return;if(p.key.toLowerCase()==="z"&&(p.ctrlKey||p.metaKey)&&!p.shiftKey){p.preventDefault(),y==null||y.execute("undo");return}if(p.key.toLowerCase()==="y"&&(p.ctrlKey||p.metaKey)||p.key.toLowerCase()==="z"&&(p.ctrlKey||p.metaKey)&&p.shiftKey){p.preventDefault(),y==null||y.execute("redo");return}if(p.key==="c"&&(p.ctrlKey||p.metaKey)&&g.length>0){p.preventDefault(),y.execute("copy");return}if(p.key==="x"&&(p.ctrlKey||p.metaKey)&&g.length>0){p.preventDefault(),y.execute("copy");const G=new Set(g);u({...e,blocks:m.filter(Z=>!G.has(Z.id))}),a([]);return}if(p.key==="v"&&(p.ctrlKey||p.metaKey)){y.isEnabled("paste")&&(p.preventDefault(),y.execute("paste"));return}if(p.key==="d"&&(p.ctrlKey||p.metaKey)&&g.length>0){p.preventDefault();const Z=m.filter(X=>g.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}}});u({...e,blocks:[...m,...Z]}),a(Z.map(X=>X.id));return}if((p.key==="Delete"||p.key==="Backspace")&&g.length>0){p.preventDefault();const G=new Set(g);u({...e,blocks:m.filter(Z=>!G.has(Z.id))}),a([]);return}if(p.key==="a"&&(p.ctrlKey||p.metaKey)){if(m.length===0)return;p.preventDefault(),a(m.map(G=>G.id));return}if(p.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=g.length===1?g[0]:null,X=Z!==null?G.findIndex(U=>U.id===Z):-1;if(p.shiftKey){if(X<=0){a([]);return}const U=G[X-1];if(!U)return;p.preventDefault(),a([U.id])}else if(X===-1){const U=G[0];if(!U)return;p.preventDefault(),a([U.id])}else if(X>=G.length-1){a([]);return}else{const U=G[X+1];if(!U)return;p.preventDefault(),a([U.id])}return}if(g.length===0)return;if(p.shiftKey){const Z={ArrowRight:{dw:1,dh:0},ArrowLeft:{dw:-1,dh:0},ArrowDown:{dw:0,dh:1},ArrowUp:{dw:0,dh:-1}}[p.key];if(!Z)return;p.preventDefault();const X=[...g].sort().join(","),U=I.current;(U===null||U.direction!==p.key||U.blockIds!==X)&&(M.current+=1,I.current={direction:p.key,blockIds:X,id:M.current});const ne=I.current;if(!ne)return;u({...e,blocks:m.map(ie=>{if(!g.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 z={ArrowLeft:{deltaCol:-1,deltaRow:0},ArrowRight:{deltaCol:1,deltaRow:0},ArrowUp:{deltaCol:0,deltaRow:-1},ArrowDown:{deltaCol:0,deltaRow:1}}[p.key];if(!z||(p.preventDefault(),!m.filter(G=>g.includes(G.id)).every(G=>{const Z=G.layout.x+z.deltaCol,X=G.layout.y+z.deltaRow;return Z>=0&&Z+G.layout.w<=n.cols&&X>=0&&X+G.layout.h<=n.rows})))return;const D=[...g].sort().join(","),B=L.current;(B===null||B.direction!==p.key||B.blockIds!==D)&&(N.current+=1,L.current={direction:p.key,blockIds:D,id:N.current});const V=L.current;if(!V)return;const Y=String(V.id);u({...e,blocks:m.map(G=>g.includes(G.id)?{...G,layout:{...G.layout,x:G.layout.x+z.deltaCol,y:G.layout.y+z.deltaRow}}:G)},{mergeKey:i.arrowMoveKey(Y),noTimeWindow:!0})},[S,g,m,e,n,o,f,a,u,y]),T=l.useCallback((p,_,$)=>{S===ee.EDITING&&f({...o,editingBlockId:null}),p.currentTarget.setPointerCapture(p.pointerId);const z=m.find(D=>D.id===$);if(!z)return;const j=(()=>{switch(_){case K.E:case K.NE:case K.SE:return z.layout.x+z.layout.w;case K.W:case K.NW:case K.SW:return z.layout.x;default:return 0}})(),k=(()=>{switch(_){case K.S:case K.SE:case K.SW:return z.layout.y+z.layout.h;case K.N:case K.NE:case K.NW:return z.layout.y;default:return 0}})();f({...o,dragging:{type:Q.RESIZE,blockIds:[$],startGrid:{col:j,row:k},currentGrid:{col:j,row:k},handle:_,isOutside:!1}})},[S,o,m,f]),F=(()=>{if(!o.editingBlockId)return null;const p=m.find(z=>z.id===o.editingBlockId),_=p?t[p.kind]:null;if(!p||!_)return null;const $=Xe(p,_,r);return h.jsx(St,{ref:P,id:p.id,resolvedPlugin:_,props:$,value:p.initValue??null,onChange:z=>{u({...e,blocks:m.map(j=>j.id===p.id?{...j,initValue:z}:j)},{mergeKey:i.initValueKey(p.id)})},blockRectPx:s(p),block:p,bindingContext:w,actionContext:y})})();return h.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:J,onPointerUp:te,onPointerLeave:A,onDoubleClick:W,onKeyDown:E,"data-testid":"interaction-layer",children:[F,h.jsx(Nt,{blocks:m,selectedBlockIds:g,isDragging:S===ee.DRAGGING,draggingState:o.dragging,getBlockRectPx:s,onResizeStart:T,selectionStyle:R}),h.jsx(Rt,{blocks:m,pluginRegistry:t,gridLength:n,draggingState:o.dragging,getBlockRectPx:s,blockDefaults:r,selectionStyle:R})]})});qe.displayName="InteractionLayer";const Le=l.createContext(null);function Se(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,s){const c=e[t],d=e[t+1];if(!c||!d)return e;let o=0,f=0;for(const u of e)u.unit==="fr"?o+=u.value:f+=i.toPx.fromDim(u);const g=s-f,a=o>0?g/o:0;if(r==="next"){const u=i.toPx.fromDim(d),y=Math.max(10,u-n);e[t+1]={...d,value:Se(y,d.unit)};const w=g-(y-u),b=Math.max(10,c.value*a+n),x=o>0?b/w*o:1;e[t]={...c,value:Math.round(x*100)/100}}else{const u=i.toPx.fromDim(c),y=Math.max(10,u+n);e[t]={...c,value:Se(y,c.unit)};const w=g-(y-u),b=Math.max(10,d.value*a-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],s=e[t+1];if(!r||!s)return e;const c=Math.max(10,i.toPx.fromDim(r)+n),d=Math.max(10,i.toPx.fromDim(s)-n);return e[t]={...r,value:Se(c,r.unit)},e[t+1]={...s,value:Se(d,s.unit)},e}function Vn(e,t,n,r){const s=e[t],c=e[t+1];if(!s||!c)return e;const d=e.reduce((a,u)=>u.unit==="fr"?a+u.value:a,0),o=r/d,f=Math.max(10,s.value*o+n)/o,g=Math.max(10,c.value*o-n)/o;return e[t]={...s,value:Math.round(f*100)/100},e[t+1]={...c,value:Math.round(g*100)/100},e}function ct(e,t,n,r){if(t<0||t>=e.length)return e;const s=[...e],c=s[t],d=s[t+1];return!c||!d?e:c.unit==="fr"&&d.unit==="fr"?Vn(s,t,n,r):c.unit!=="fr"&&d.unit!=="fr"?Hn(s,t,n):c.unit==="fr"&&d.unit!=="fr"?at(s,t,n,"next",r):at(s,t,n,"current",r)}function Mt({book:e,pageIdx:t,showValidation:n,values:r,bindingContext:s}){const c=e.pages[t]??e.pages[0],d=e.paper,{paperPx:o,gridPosPx:f,getBlockRectPx:g}=i.useGridCalc(d,c.grid,i.DEFAULT_DPI),a=d.autoHeight===!0,u=d.autoWidth===!0,[y,w]=l.useState(new Map),[b,x]=l.useState(new Map),R=l.useCallback((I,M)=>{w(C=>{if(C.get(I)===M)return C;const H=new Map(C);return H.set(I,M),H})},[]),m=l.useCallback((I,M)=>{x(C=>{if(C.get(I)===M)return C;const H=new Map(C);return H.set(I,M),H})},[]),v=l.useMemo(()=>{if(!a||y.size===0)return 0;let I=0;for(const M of c.blocks){if(he(M.hiddenBinding,s))continue;const H=g(M),q=y.get(M.id)??H.height;I=Math.max(I,H.top-o.margin.top+q)}return I},[a,y,c.blocks,g,o.margin.top,s]),P=l.useMemo(()=>{if(!u||b.size===0)return 0;let I=0;for(const M of c.blocks){if(he(M.hiddenBinding,s))continue;const H=g(M),q=b.get(M.id)??H.width;I=Math.max(I,H.left-o.margin.left+q)}return I},[u,b,c.blocks,g,o.margin.left,s]),O=l.useMemo(()=>!a||v===0&&y.size===0?o.canvas.height:o.margin.top+Math.max(0,v)+o.margin.bottom,[a,o,v,y.size]),S=l.useMemo(()=>{const I=(f.cols[f.cols.length-1]??0)+o.margin.left+o.margin.right;if(!u||P===0&&b.size===0)return I;const M=o.margin.left+Math.max(0,P)+o.margin.right;return Math.max(I,M)},[u,o,f.cols,P,b.size]),L=l.useMemo(()=>({...o,canvas:{...o.canvas,height:O,width:S}}),[o,O,S]),N=l.useMemo(()=>{if(!n)return;const I={};for(const M of c.blocks){if(!dt(M.props))continue;const C=r[M.id],H=C==null?void 0:String(C),q=ft(M.props,H);q.length>0&&(I[M.id]=q)}return I},[n,c.blocks,r]);return{page:c,isFit:a,isWidthFit:u,paperPx:o,gridPosPx:f,getBlockRectPx:g,measuredHeights:y,measuredWidths:b,handleMeasureHeight:R,handleMeasureWidth:m,canvasHeightPx:O,canvasWidthPx:S,effectivePaperPx:L,validationErrors:N}}const Lt=l.memo(function({context:t,showValidation:n=!1,scale:r=1,className:s}){const{book:c,pluginRegistry:d}=t,o=t.values,f=t.onValuesChange,g=l.useCallback((C,H)=>f==null?void 0:f([{id:C,value:H}]),[f]),{page:a,isFit:u,isWidthFit:y,gridPosPx:w,getBlockRectPx:b,handleMeasureHeight:x,handleMeasureWidth:R,canvasHeightPx:m,canvasWidthPx:v,effectivePaperPx:P,validationErrors:O}=Mt({book:c,pageIdx:t.editorState.pageIdx,showValidation:n,values:o,bindingContext:t.bindingContext}),[S,L]=l.useState(null),N=l.useMemo(()=>[...a.blocks].sort((C,H)=>C.layout.y!==H.layout.y?C.layout.y-H.layout.y:C.layout.x-H.layout.x),[a.blocks]),I=l.useCallback(C=>{const H=C.target.closest("[data-block-id]");L((H==null?void 0:H.getAttribute("data-block-id"))??null)},[]),M=l.useCallback(C=>{C.currentTarget.contains(C.relatedTarget)||L(null)},[]);return h.jsx(Le.Provider,{value:d,children:h.jsxs("form",{"data-testid":"note-container","aria-label":"フォーム",className:s,onSubmit:C=>C.preventDefault(),onFocusCapture:I,onBlurCapture:M,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"},children:[h.jsx(Me,{paperPx:P,gridPosPx:w,showGridLines:!1,showMargins:!1,showBorder:!1}),h.jsx(ve,{blocks:N,pluginRegistry:d,mode:i.NoteMode.EDIT,values:o,blockDefaults:a.blockDefaults,getBlockRectPx:b,onMeasureHeight:u?x:void 0,onMeasureWidth:y?R:void 0,onValueChange:f?g:void 0,showGuides:!0,showBorder:!0,showValidation:n,validationErrors:O,focusedBlockId:S??void 0,bindingContext:t.bindingContext,actionContext:t.actionContext})]})})}),Bt=l.memo(function({context:t,scale:n=1,className:r}){const{book:s,onBookChange:c,pluginRegistry:d}=t,o=t.editorState.pageIdx,f=t.editorState.selectedBlockIds,g=t.actionContext,a=s.pages[o]??s.pages[0],u=l.useRef(s);u.current=s;const y=l.useRef(o);y.current=o;const w=l.useCallback((k,D)=>{c&&c(gt(u.current,y.current,k),D)},[c]),[b,x]=Et(),R=l.useRef(x);R.current=x;const m=l.useCallback(k=>g.execute("selectBlocks",k),[g]),v=l.useRef(null),{expandedCols:P,expandedRows:O}=i.useExpandedGrid(a.grid),{paperPx:S,gridPosPx:L,getBlockRectPx:N,getColIndex:I,getRowIndex:M}=i.useGridCalc(s.paper,a.grid,i.DEFAULT_DPI),C=l.useCallback(k=>{var X;const D=i.getBlockDragKind(k);if(!D)return;k.preventDefault();const B=d[D],V=(B==null?void 0:B.meta.defaultSize)??{w:1,h:1},Y=(X=v.current)==null?void 0:X.getBoundingClientRect(),G=Y?I(k.clientX-Y.left):0,Z=Y?M(k.clientY-Y.top):0;R.current({editingBlockId:null,dragging:{type:Q.INSERT,blockIds:[],pluginKind:D,defaultSize:V,startGrid:{col:G,row:Z},currentGrid:{col:G,row:Z},currentMousePx:{x:k.clientX,y:k.clientY}}})},[d,I,M]),H=l.useCallback(k=>{var Y;if(!k.dataTransfer.types.includes(i.BLOCK_DRAG_MIME))return;k.preventDefault(),k.dataTransfer.dropEffect="copy";const D=(Y=v.current)==null?void 0:Y.getBoundingClientRect();if(!D)return;const B=I(k.clientX-D.left),V=M(k.clientY-D.top);R.current(G=>{var Z;return((Z=G.dragging)==null?void 0:Z.type)!==Q.INSERT?G:{...G,dragging:{...G.dragging,currentGrid:{col:B,row:V},currentMousePx:{x:k.clientX,y:k.clientY}}}})},[I,M]),q=l.useCallback(k=>{var D;k.dataTransfer.types.includes(i.BLOCK_DRAG_MIME)&&((D=v.current)!=null&&D.contains(k.relatedTarget)||R.current({editingBlockId:null,dragging:void 0}))},[]),J=l.useCallback(k=>{var ie;k.preventDefault();const D=i.getBlockDragData(k);if(!D)return;const B=(ie=v.current)==null?void 0:ie.getBoundingClientRect();if(!B)return;const V=I(k.clientX-B.left),Y=M(k.clientY-B.top),G=D.defaultSize??{w:1,h:1},Z=d[D.kind];if(!Z)return;const{x:X,y:U}=Tt({x:V,y:Y},G,a.grid.colCount,a.grid.rowCount),ne={...fe(Z,{x:X,y:U}),layout:{x:X,y:U,w:G.w,h:G.h}};w({...a,blocks:[...a.blocks,ne]}),m([ne.id]),R.current({editingBlockId:null,dragging:void 0})},[a,d,I,M,w,m]),[te,W]=l.useState(new Map),[A,E]=l.useState(new Map),T=l.useCallback((k,D)=>{W(B=>{if(B.get(k)===D)return B;const V=new Map(B);return V.set(k,D),V})},[]),F=l.useCallback((k,D)=>{E(B=>{if(B.get(k)===D)return B;const V=new Map(B);return V.set(k,D),V})},[]),p=l.useCallback(k=>{const D=N(k),B=te.get(k.id),V=A.get(k.id);return{...D,height:B!==void 0?Math.max(D.height,B):D.height,width:V!==void 0?Math.max(D.width,V):D.width}},[N,te,A]),_=l.useCallback((k,D)=>{const B=a.blocks.map(V=>V.id===k?{...V,initValue:D}:V);w({...a,blocks:B},{mergeKey:i.initValueKey(k)})},[a,w]);l.useEffect(()=>{const k=D=>{if(f.length===0)return;const B=D.target;if(B instanceof Element){const V=B.closest(i.SIDEBAR_PORTAL_SELECTOR),Y=B.closest('[data-selection-action-bar="true"]');if(V||Y)return}v.current&&!v.current.contains(B)&&m([])};return document.addEventListener("mousedown",k),()=>{document.removeEventListener("mousedown",k)}},[f,m]);const $=l.useCallback((k,D,B)=>{const V=D-1;if(k==="column"){const Y=ct(P,V,B,S.content.width);w({...a,grid:{...a.grid,...i.colsToSparse(Y)}})}else{const Y=ct(O,V,B,S.content.height);w({...a,grid:{...a.grid,...i.rowsToSparse(Y)}})}},[a,S,P,O,w]),z=l.useCallback((k,D,B)=>{if(k==="column"){const V=[...P];V[D]=B,w({...a,grid:{...a.grid,...i.colsToSparse(V)}})}else{const V=[...O];V[D]=B,w({...a,grid:{...a.grid,...i.rowsToSparse(V)}})}},[w,a,P,O]),j=l.useMemo(()=>{const k={};for(const D of a.blocks)!he(D.hiddenBinding,void 0)&&D.initValue!==void 0&&(k[D.id]=D.initValue);return k},[a.blocks]);return h.jsx(Le.Provider,{value:d,children:h.jsxs("section",{ref:v,"data-testid":"note-container",className:r,"aria-label":"用紙",onDragEnter:C,onDragOver:H,onDragLeave:q,onDrop:J,style:{position:"relative",width:`${S.canvas.width}px`,height:`${S.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"},children:[h.jsx(Me,{paperPx:S,gridPosPx:L,gridDimensions:{cols:P,rows:O},showGridLines:!0,showMargins:!0,showBorder:!0,showResizeHandles:!0,showDimensionLabels:!0,onGridResize:$,onDimensionChange:z,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}}}),h.jsx(ve,{blocks:a.blocks,pluginRegistry:d,mode:i.NoteMode.FORM,values:j,selectedBlockIds:f,blockDefaults:a.blockDefaults,getBlockRectPx:N,onValueChange:_,onMeasureHeight:T,onMeasureWidth:F,showGuides:!0,showBorder:!0}),h.jsx(qe,{page:a,gridLength:{cols:a.grid.colCount,rows:a.grid.rowCount},pluginRegistry:d,blockDefaults:a.blockDefaults,getBlockRectPx:p,getColIndex:I,getRowIndex:M,selectedBlockIds:f,onSelectionChange:m,state:b,onStateChange:x,onPageChange:w,actionContext:g,scale:n})]})})}),At=l.memo(function(t){var S,L,N;const n=t.context!==void 0?t.context.book:t.book,r=t.context!==void 0?t.context.pluginRegistry:t.pluginRegistry,s=((S=t.context)==null?void 0:S.values)??t.values??{},c=t.showValidation??!1,d=t.scale??1,{className:o}=t,f=(L=t.context)==null?void 0:L.bindingContext,g=(N=t.context)==null?void 0:N.actionContext,{page:a,isFit:u,isWidthFit:y,gridPosPx:w,getBlockRectPx:b,handleMeasureHeight:x,handleMeasureWidth:R,canvasHeightPx:m,canvasWidthPx:v,effectivePaperPx:P,validationErrors:O}=Mt({book:n,pageIdx:t.context!==void 0?t.context.editorState.pageIdx:t.pageIdx??0,showValidation:c,values:s,bindingContext:f});return h.jsx(Le.Provider,{value:r,children:h.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"},children:[h.jsx(Me,{paperPx:P,gridPosPx:w,showGridLines:!1,showMargins:!1,showBorder:!1}),h.jsx(ve,{blocks:a.blocks,pluginRegistry:r,mode:i.NoteMode.VIEW,values:s,blockDefaults:a.blockDefaults,getBlockRectPx:b,onMeasureHeight:u?x:void 0,onMeasureWidth:y?R:void 0,showGuides:!1,showBorder:!0,showValidation:c,validationErrors:O,bindingContext:f,actionContext:g})]})})});function _t({context:e,mode:t,className:n,style:r,showValidation:s,scale:c}){return t===i.NoteMode.FORM?h.jsx("div",{style:r,className:n,children:h.jsx(Bt,{scale:c,context:e})}):t===i.NoteMode.VIEW?h.jsx("div",{style:r,className:n,children:h.jsx(At,{showValidation:s,scale:c,context:e})}):h.jsx("div",{style:r,className:n,children:h.jsx(Lt,{showValidation:s,scale:c,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:""}},Ae={[i.HorizontalAlign.left]:"flex-start",[i.HorizontalAlign.center]:"center",[i.HorizontalAlign.right]:"flex-end"},_e={[i.VerticalAlign.top]:"flex-start",[i.VerticalAlign.center]:"center",[i.VerticalAlign.bottom]:"flex-end"},Qe=l.forwardRef(({props:e,readOnly:t,onChange:n,ariaLabel:r,actionContext:s,bindingContext:c},d)=>{const o=l.useRef(null),[f,g]=l.useState(!1);l.useImperativeHandle(d,()=>({focus:()=>{var m;return(m=o.current)==null?void 0:m.focus()}}),[]);const a=zt(e.action,s),u=t||!a,y=jt(e.action,c),w=l.useCallback(()=>{u||Ot(e.action,{actionContext:s,bindingContext:c,onChange:n})},[u,e.action,s,c,n]),b=l.useCallback(()=>{u||g(!0)},[u]),x=l.useCallback(()=>g(!1),[]),R=l.useMemo(()=>{const m={width:"100%",height:"100%",boxSizing:"border-box",overflow:"hidden",cursor:u?"default":"pointer",userSelect:"none",outline:"none",appearance:"none",border:"none",background:"none",opacity:u?.4:f?.7:y?.85:1,transform:f?"scale(0.97)":"scale(1)",transition:f?"none":"opacity 150ms ease, transform 150ms ease"};e.iconPath?(m.display="flex",m.alignItems=_e[e.vertical??i.VerticalAlign.center],m.justifyContent=Ae[e.horizontal??i.HorizontalAlign.center],m.containerType="size",m.color="inherit"):e.icon&&!e.label?(m.display="flex",m.alignItems=_e[e.vertical??i.VerticalAlign.center],m.justifyContent=Ae[e.horizontal??i.HorizontalAlign.center],m.containerType="size",m.fontFamily="inherit",m.color="inherit"):(m.display="flex",m.alignItems=_e[e.vertical??i.VerticalAlign.center],m.justifyContent=Ae[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,P=v??e.top,O=v??e.right,S=v??e.bottom,L=v??e.left;return P&&(m.paddingTop=i.dimensionToString(P)),O&&(m.paddingRight=i.dimensionToString(O)),S&&(m.paddingBottom=i.dimensionToString(S)),L&&(m.paddingLeft=i.dimensionToString(L)),m},[e,u,f,y]);return h.jsxs("button",{ref:o,type:"button",disabled:u,"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?h.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",style:{display:"block",margin:"auto",width:"min(55cqi, 55cqb)",height:"min(55cqi, 55cqb)"},children:h.jsx("path",{d:e.iconPath,fill:"currentColor"})}):e.icon?h.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)&&h.jsx("span",{children:e.label??"ボタン"})]})});Qe.displayName="ButtonRenderer";const Wn={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 Kn=[{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:Kn,allowEmpty:!1,defaultValue:"mm"},horizontal:"left",left:{value:2,unit:"px"}}}}const Ht={kind:"stepperBehavior",defaultProps:{step:1}},Vt={kind:"stepperStyle",defaultProps:{styleConfig:{arrowWidth:50,arrowHeight:25,arrowColor:"currentColor",arrowGap:20}}};function Fn(e,t,n,r){let s=e+t;return r!==void 0&&(s=Math.min(r,s)),n!==void 0&&(s=Math.max(n,s)),s}const Un="M 10,0 L 20,10 L 0,10 Z",Xn="M 0,0 L 20,0 L 10,10 Z",ut=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=l.forwardRef(({props:e,value:t,onChange:n,readOnly:r},s)=>{var S,L,N,I;const c=l.useRef(null),[d,o]=l.useState(!1),[f,g]=l.useState(!1),a=r,u=e.step??1,y=((S=e.styleConfig)==null?void 0:S.arrowColor)??"currentColor",w=((L=e.styleConfig)==null?void 0:L.arrowWidth)??50,b=((N=e.styleConfig)==null?void 0:N.arrowHeight)??25,x=((I=e.styleConfig)==null?void 0:I.arrowGap)??20,R=(100-w)/2;l.useImperativeHandle(s,()=>({focus:()=>{var M,C;return(C=(M=c.current)==null?void 0:M.querySelector("button"))==null?void 0:C.focus()}}),[]);const m=l.useCallback(M=>{if(a)return;const C=Number(t??0),H=Fn(C,M,e.min,e.max);n(H)},[a,t,n,e.min,e.max]),v=l.useCallback(()=>m(u),[m,u]),P=l.useCallback(()=>m(-u),[m,u]),O=M=>({opacity:a?.4:M?.6:1,transform:M?"scale(0.9)":"scale(1)",transition:M?"none":"opacity 150ms ease, transform 150ms ease"});return h.jsxs("div",{ref:c,style:{position:"relative",width:"100%",height:"100%",overflow:"visible",color:y},children:[h.jsx("button",{type:"button",disabled:a,"aria-label":"増やす",style:{...ut(a),top:0},onClick:v,onPointerDown:()=>{a||o(!0)},onPointerUp:()=>o(!1),onPointerLeave:()=>o(!1)}),h.jsx("button",{type:"button",disabled:a,"aria-label":"減らす",style:{...ut(a),bottom:0},onClick:P,onPointerDown:()=>{a||g(!0)},onPointerUp:()=>g(!1),onPointerLeave:()=>g(!1)}),h.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:h.jsx("path",{d:Un,fill:"currentColor"})}),h.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(f)},children:h.jsx("path",{d:Xn,fill:"currentColor"})})]})});Je.displayName="StepperRenderer";const ue={kind:"stepper",meta:{displayName:"ステッパー",description:"数値を増減するステッパーブロック",defaultSize:{w:1,h:1}},Renderer:Je,properties:[i.alignmentProp,Ht,Vt],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},Wt={colCount:3,rowCount:1,cols:{2:{value:8,unit:"mm"}}},Zn={props:{book:{paper:et,pages:[{grid:Wt,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,ue]},Yn={props:{book:{paper:et,pages:[{grid:Wt,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,ue]},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,ue]},Qn={get:()=>null,set:()=>{}},Jn={execute:()=>{},isEnabled:()=>!1},ei={selectedBlockIds:[],pageIdx:0},tt=l.forwardRef(({props:e,dimensions:t,bindingContext:n,actionContext:r,onMeasureHeight:s,onMeasureWidth:c},d)=>{const o=l.useContext(Le);l.useImperativeHandle(d,()=>({focus:()=>{}}),[]);const f=l.useRef(null),{naturalWidth:g,naturalHeight:a,scale:u}=l.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]);l.useEffect(()=>{s==null||s(a*u)},[s,a,u]),l.useEffect(()=>{c==null||c(g*u)},[c,g,u]);const y=l.useMemo(()=>o?{book:e.book,onBookChange:()=>{},pluginRegistry:o,containerRef:f,bindingContext:n??Qn,actionContext:r??Jn,editorState:ei,values:{}}:null,[e.book,o,n,r]);return y?h.jsx("div",{style:{width:"100%",height:"100%",overflow:"hidden"},children:h.jsx(_t,{mode:i.NoteMode.EDIT,context:y,style:{width:g,height:a,transform:`scale(${u})`,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:[Ke,nt,Pe,ue,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:[Ke]},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]},Kt=[{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:Kt}]}},plugins:[nt,Pe,ue,ae]};exports.BlockBorder=ce;exports.BlockCanvas=ye;exports.BlockContainer=Ye;exports.BlockGuideBorder=Te;exports.BlockLayer=ve;exports.BlockRenderer=xe;exports.ButtonPlugin=Wn;exports.ButtonRenderer=Qe;exports.CheckboxPlugin=Ke;exports.CheckboxRenderer=We;exports.DEFAULT_BOOK=ht;exports.DEFAULT_GUIDE_BORDER=Ne;exports.DEFAULT_PAGE=Ve;exports.DragType=Q;exports.InteractionLayer=qe;exports.InteractionMode=ee;exports.Note=_t;exports.NoteBlockPlugin=nt;exports.NoteBlockRenderer=tt;exports.NoteEdit=Lt;exports.NoteForm=Bt;exports.NoteView=At;exports.PAPER_SIZE_BLOCKS=Kt;exports.ResizeHandle=K;exports.SelectPlugin=Pe;exports.SelectRenderer=Fe;exports.StepperPlugin=ue;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=Vt;exports.unitSelectBlock=ge;exports.useBookActionContext=mn;exports.useBookBindingContext=xn;exports.useBookHistory=bn;exports.useInteractionState=Et;exports.validateBook=Qt;
|