@tatamicks/core 0.3.0 → 0.3.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/dist/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var cn;function _r(){if(cn)return Gt;cn=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(o,s,i){var a=null;if(i!==void 0&&(a=""+i),s.key!==void 0&&(a=""+s.key),"key"in s){i={};for(var l in s)l!=="key"&&(i[l]=s[l])}else i=s;return s=i.ref,{$$typeof:t,type:o,key:a,ref:s!==void 0?s:null,props:i}}return Gt.Fragment=e,Gt.jsx=n,Gt.jsxs=n,Gt}var Bt={};/**
9
+ */var cn;function _r(){if(cn)return Gt;cn=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,s,i){var a=null;if(i!==void 0&&(a=""+i),s.key!==void 0&&(a=""+s.key),"key"in s){i={};for(var l in s)l!=="key"&&(i[l]=s[l])}else i=s;return s=i.ref,{$$typeof:t,type:r,key:a,ref:s!==void 0?s:null,props:i}}return Gt.Fragment=e,Gt.jsx=n,Gt.jsxs=n,Gt}var Bt={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,12 +14,12 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var un;function yr(){return un||(un=1,process.env.NODE_ENV!=="production"&&(function(){function t(b){if(b==null)return null;if(typeof b=="function")return b.$$typeof===D?null:b.displayName||b.name||null;if(typeof b=="string")return b;switch(b){case p:return"Fragment";case h:return"Profiler";case x:return"StrictMode";case B:return"Suspense";case $:return"SuspenseList";case S:return"Activity"}if(typeof b=="object")switch(typeof b.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),b.$$typeof){case y:return"Portal";case N:return b.displayName||"Context";case w:return(b._context.displayName||"Context")+".Consumer";case I:var M=b.render;return b=b.displayName,b||(b=M.displayName||M.name||"",b=b!==""?"ForwardRef("+b+")":"ForwardRef"),b;case A:return M=b.displayName||null,M!==null?M:t(b.type)||"Memo";case L:M=b._payload,b=b._init;try{return t(b(M))}catch{}}return null}function e(b){return""+b}function n(b){try{e(b);var M=!1}catch{M=!0}if(M){M=console;var P=M.error,z=typeof Symbol=="function"&&Symbol.toStringTag&&b[Symbol.toStringTag]||b.constructor.name||"Object";return P.call(M,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",z),e(b)}}function o(b){if(b===p)return"<>";if(typeof b=="object"&&b!==null&&b.$$typeof===L)return"<...>";try{var M=t(b);return M?"<"+M+">":"<...>"}catch{return"<...>"}}function s(){var b=k.A;return b===null?null:b.getOwner()}function i(){return Error("react-stack-top-frame")}function a(b){if(C.call(b,"key")){var M=Object.getOwnPropertyDescriptor(b,"key").get;if(M&&M.isReactWarning)return!1}return b.key!==void 0}function l(b,M){function P(){R||(R=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",M))}P.isReactWarning=!0,Object.defineProperty(b,"key",{get:P,configurable:!0})}function c(){var b=t(this.type);return T[b]||(T[b]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),b=this.props.ref,b!==void 0?b:null}function m(b,M,P,z,ht,Ot){var q=P.ref;return b={$$typeof:E,type:b,key:M,props:P,_owner:z},(q!==void 0?q:null)!==null?Object.defineProperty(b,"ref",{enumerable:!1,get:c}):Object.defineProperty(b,"ref",{enumerable:!1,value:null}),b._store={},Object.defineProperty(b._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(b,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(b,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:ht}),Object.defineProperty(b,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Ot}),Object.freeze&&(Object.freeze(b.props),Object.freeze(b)),b}function d(b,M,P,z,ht,Ot){var q=M.children;if(q!==void 0)if(z)if(j(q)){for(z=0;z<q.length;z++)f(q[z]);Object.freeze&&Object.freeze(q)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else f(q);if(C.call(M,"key")){q=t(b);var ut=Object.keys(M).filter(function(Kt){return Kt!=="key"});z=0<ut.length?"{key: someKey, "+ut.join(": ..., ")+": ...}":"{key: someKey}",F[q+z]||(ut=0<ut.length?"{"+ut.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
17
+ */var un;function yr(){return un||(un=1,process.env.NODE_ENV!=="production"&&(function(){function t(b){if(b==null)return null;if(typeof b=="function")return b.$$typeof===$?null:b.displayName||b.name||null;if(typeof b=="string")return b;switch(b){case f:return"Fragment";case h:return"Profiler";case x:return"StrictMode";case B:return"Suspense";case D:return"SuspenseList";case L:return"Activity"}if(typeof b=="object")switch(typeof b.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),b.$$typeof){case y:return"Portal";case N:return b.displayName||"Context";case w:return(b._context.displayName||"Context")+".Consumer";case I:var M=b.render;return b=b.displayName,b||(b=M.displayName||M.name||"",b=b!==""?"ForwardRef("+b+")":"ForwardRef"),b;case A:return M=b.displayName||null,M!==null?M:t(b.type)||"Memo";case S:M=b._payload,b=b._init;try{return t(b(M))}catch{}}return null}function e(b){return""+b}function n(b){try{e(b);var M=!1}catch{M=!0}if(M){M=console;var P=M.error,z=typeof Symbol=="function"&&Symbol.toStringTag&&b[Symbol.toStringTag]||b.constructor.name||"Object";return P.call(M,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",z),e(b)}}function r(b){if(b===f)return"<>";if(typeof b=="object"&&b!==null&&b.$$typeof===S)return"<...>";try{var M=t(b);return M?"<"+M+">":"<...>"}catch{return"<...>"}}function s(){var b=k.A;return b===null?null:b.getOwner()}function i(){return Error("react-stack-top-frame")}function a(b){if(C.call(b,"key")){var M=Object.getOwnPropertyDescriptor(b,"key").get;if(M&&M.isReactWarning)return!1}return b.key!==void 0}function l(b,M){function P(){R||(R=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",M))}P.isReactWarning=!0,Object.defineProperty(b,"key",{get:P,configurable:!0})}function c(){var b=t(this.type);return T[b]||(T[b]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),b=this.props.ref,b!==void 0?b:null}function m(b,M,P,z,ht,Ot){var q=P.ref;return b={$$typeof:E,type:b,key:M,props:P,_owner:z},(q!==void 0?q:null)!==null?Object.defineProperty(b,"ref",{enumerable:!1,get:c}):Object.defineProperty(b,"ref",{enumerable:!1,value:null}),b._store={},Object.defineProperty(b._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(b,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(b,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:ht}),Object.defineProperty(b,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Ot}),Object.freeze&&(Object.freeze(b.props),Object.freeze(b)),b}function d(b,M,P,z,ht,Ot){var q=M.children;if(q!==void 0)if(z)if(j(q)){for(z=0;z<q.length;z++)p(q[z]);Object.freeze&&Object.freeze(q)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else p(q);if(C.call(M,"key")){q=t(b);var ut=Object.keys(M).filter(function(Kt){return Kt!=="key"});z=0<ut.length?"{key: someKey, "+ut.join(": ..., ")+": ...}":"{key: someKey}",F[q+z]||(ut=0<ut.length?"{"+ut.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
18
  let props = %s;
19
19
  <%s {...props} />
20
20
  React keys must be passed directly to JSX without using spread:
21
21
  let props = %s;
22
- <%s key={someKey} {...props} />`,z,q,ut,q),F[q+z]=!0)}if(q=null,P!==void 0&&(n(P),q=""+P),a(M)&&(n(M.key),q=""+M.key),"key"in M){P={};for(var bt in M)bt!=="key"&&(P[bt]=M[bt])}else P=M;return q&&l(P,typeof b=="function"?b.displayName||b.name||"Unknown":b),m(b,q,P,s(),ht,Ot)}function f(b){v(b)?b._store&&(b._store.validated=1):typeof b=="object"&&b!==null&&b.$$typeof===L&&(b._payload.status==="fulfilled"?v(b._payload.value)&&b._payload.value._store&&(b._payload.value._store.validated=1):b._store&&(b._store.validated=1))}function v(b){return typeof b=="object"&&b!==null&&b.$$typeof===E}var g=u,E=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),p=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),h=Symbol.for("react.profiler"),w=Symbol.for("react.consumer"),N=Symbol.for("react.context"),I=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),$=Symbol.for("react.suspense_list"),A=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),S=Symbol.for("react.activity"),D=Symbol.for("react.client.reference"),k=g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,C=Object.prototype.hasOwnProperty,j=Array.isArray,_=console.createTask?console.createTask:function(){return null};g={react_stack_bottom_frame:function(b){return b()}};var R,T={},O=g.react_stack_bottom_frame.bind(g,i)(),U=_(o(i)),F={};Bt.Fragment=p,Bt.jsx=function(b,M,P){var z=1e4>k.recentlyCreatedOwnerStacks++;return d(b,M,P,!1,z?Error("react-stack-top-frame"):O,z?_(o(b)):U)},Bt.jsxs=function(b,M,P){var z=1e4>k.recentlyCreatedOwnerStacks++;return d(b,M,P,!0,z?Error("react-stack-top-frame"):O,z?_(o(b)):U)}})()),Bt}var dn;function Er(){return dn||(dn=1,process.env.NODE_ENV==="production"?Zt.exports=_r():Zt.exports=yr()),Zt.exports}var r=Er(),Tt=(t=>(t.left="flex-start",t.center="center",t.right="flex-end",t))(Tt||{}),Rt=(t=>(t.top="flex-start",t.center="center",t.bottom="flex-end",t))(Rt||{});const jr="_container_1mr3i_5",Nr="_select_1mr3i_11",Ir="_placeholderOverlay_1mr3i_44",ve={container:jr,select:Nr,placeholderOverlay:Ir},wt=t=>{const{value:e,onChange:n,readOnly:o=!1,config:s}=t,i=t.options??(s==null?void 0:s.options)??[],a=t.placeholder??(s==null?void 0:s.placeholder)??"選択してください",l=t.width??(s==null?void 0:s.width),c=t.height??(s==null?void 0:s.height),m=u.useCallback(E=>{const y=E.target.value;if(y==="")n(void 0);else{const p=i.find(x=>String(x.value)===y);n(p?p.value:y)}},[n,i]),d=e??"",f=e!==void 0&&e!=="",v={};l!==void 0?v.width=`${l}px`:v.width="100%";const g={width:"100%",height:c?`${c}px`:void 0};return r.jsxs("div",{className:ve.container,style:v,children:[!f&&r.jsx("input",{className:ve.placeholderOverlay,style:g,readOnly:!0,placeholder:a}),r.jsx("select",{className:ve.select,style:g,value:d,onChange:m,disabled:o,children:i.map(E=>r.jsx("option",{value:String(E.value),children:E.label},String(E.value)))})]})};wt.displayName="Select";const pn={justifyContent:{defaultValue:Tt.left,label:"水平方向の配置",group:"配置",description:"ブロック内のコンテンツの水平方向の配置を設定します。",Component:wt,config:{options:[{label:"左揃え",value:Tt.left},{label:"中央揃え",value:Tt.center},{label:"右揃え",value:Tt.right}]}},alignItems:{defaultValue:Rt.center,label:"垂直方向の配置",group:"配置",description:"ブロック内のコンテンツの垂直方向の配置を設定します。",Component:wt,config:{options:[{label:"上揃え",value:Rt.top},{label:"中央揃え",value:Rt.center},{label:"下揃え",value:Rt.bottom}]}}},Dr="_container_1tnp6_5",$r="_input_1tnp6_13",Tr="_label_1tnp6_29",be={container:Dr,input:$r,label:Tr},xt=({value:t,onChange:e,readOnly:n=!1,label:o,config:s})=>{const i=o??(s==null?void 0:s.label),a=u.useCallback(l=>{e(l.target.checked)},[e]);return r.jsxs("label",{className:be.container,children:[r.jsx("input",{type:"checkbox",className:be.input,checked:!!t,onChange:a,disabled:n}),i&&r.jsx("span",{className:be.label,children:i})]})};xt.displayName="Checkbox";const Rr="_container_qbvob_5",Mr="_colorButton_qbvob_13",Cr="_textInputWrapper_qbvob_40",Pr="_textInputPrefix_qbvob_62",Ar="_textInput_qbvob_40",kr="_popover_qbvob_125",Sr="_palette_qbvob_141",Lr="_paletteButton_qbvob_148",Or="_selected_qbvob_171",Gr="_transparentPaletteButton_qbvob_177",Br="_rgbaInputs_qbvob_183",Vr="_rgbaInputGroup_qbvob_190",Ur="_rgbaLabel_qbvob_205",tt={container:Rr,colorButton:Mr,textInputWrapper:Cr,textInputPrefix:Pr,textInput:Ar,popover:kr,palette:Sr,paletteButton:Lr,selected:Or,transparentPaletteButton:Gr,rgbaInputs:Br,rgbaInputGroup:Vr,rgbaLabel:Ur};function Ee(t){if(!t)return null;const e=t.match(/^#([0-9a-f]{6}|[0-9a-f]{8})$/i);if(e&&typeof e[1]=="string"){const o=e[1],s=Number.parseInt(o.slice(0,2),16),i=Number.parseInt(o.slice(2,4),16),a=Number.parseInt(o.slice(4,6),16),l=o.length===8?Number.parseInt(o.slice(6,8),16)/255:1;return{r:s,g:i,b:a,a:l}}const n=t.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/);if(n){const o=Number.parseInt(n[1]??"",10),s=Number.parseInt(n[2]??"",10),i=Number.parseInt(n[3]??"",10),a=n[4]?Number.parseFloat(n[4]):1;return{r:o,g:s,b:i,a}}return null}function xn(t){const{r:e,g:n,b:o,a:s}=t;if(s===0)return;const i=e.toString(16).padStart(2,"0"),a=n.toString(16).padStart(2,"0"),l=o.toString(16).padStart(2,"0");if(s<1){const c=Math.round(s*255).toString(16).padStart(2,"0");return`#${i}${a}${l}${c}`}return`#${i}${a}${l}`}function Fr(t){const{r:e,g:n,b:o,a:s}=t;if(s!==0)return`rgba(${e}, ${n}, ${o}, ${s})`}function zr(t){return/^#([0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)}const vn=[{label:"無色",value:void 0},{label:"白",value:"#ffffff"},{label:"グレー1",value:"#efefef"},{label:"グレー2",value:"#d9d9d9"},{label:"グレー3",value:"#cccccc"},{label:"グレー4",value:"#b7b7b7"},{label:"グレー5",value:"#999999"},{label:"グレー6",value:"#666666"},{label:"グレー7",value:"#434343"},{label:"黒",value:"#000000"},{label:"薄茶",value:"#E6B8AF"},{label:"薄赤",value:"#F4CCCC"},{label:"薄橙",value:"#FCE5CD"},{label:"薄黄",value:"#FFF2CC"},{label:"薄緑",value:"#D9EAD3"},{label:"薄青緑",value:"#D0E0E3"},{label:"薄青",value:"#C9DAF8"},{label:"薄青紫",value:"#CFE2F3"},{label:"薄紫",value:"#D9D2E9"},{label:"薄赤紫",value:"#EAD1DC"},{label:"茶",value:"#DD7E6B"},{label:"赤",value:"#EA9999"},{label:"橙",value:"#F9CB9C"},{label:"黄",value:"#FFE599"},{label:"緑",value:"#B6D7A8"},{label:"青緑",value:"#A2C4C9"},{label:"青",value:"#A4C2F4"},{label:"青紫",value:"#9FC5E8"},{label:"紫",value:"#B4A7D6"},{label:"赤紫",value:"#D5A6BD"}],Ae=({onColorSelect:t,selectedColor:e,readOnly:n=!1})=>r.jsx("div",{className:tt.palette,children:vn.map((o,s)=>{const i=o.value===void 0,a=o.value===e,l=i?{}:{backgroundColor:o.value};return r.jsx("button",{type:"button",className:`${tt.paletteButton} ${i?tt.transparentPaletteButton:""} ${a?tt.selected:""}`,onClick:()=>t(o.value),disabled:n,title:o.label,"aria-label":o.label,style:l},o.value??`undefined-${s}`)})});Ae.displayName="ColorPalette";const Wr="_input_14n56_5",Yr={input:Wr},st=({value:t,onChange:e,readOnly:n=!1,min:o,max:s,step:i,integer:a,placeholder:l,width:c,height:m,config:d,onBlur:f})=>{const v=o??(d==null?void 0:d.min)??1,g=s??(d==null?void 0:d.max),E=i??(d==null?void 0:d.step)??1,y=a??(d==null?void 0:d.integer)??!1,p=l??(d==null?void 0:d.placeholder),x=c??(d==null?void 0:d.width),h=m??(d==null?void 0:d.height),w=u.useCallback(I=>{const B=I.target.value;if(B===""){e(void 0);return}let $=Number.parseFloat(B);Number.isNaN($)||(y&&($=Math.round($)),v!==void 0&&$<v&&($=v),g!==void 0&&$>g&&($=g),e($))},[e,v,g,y]),N={};return x!==void 0&&(N.width=`${x}px`),h!==void 0&&(N.height=`${h}px`,N.paddingTop=0,N.paddingBottom=0),r.jsx("input",{type:"number",className:Yr.input,style:N,value:t??"",onChange:w,onBlur:f,disabled:n,min:v,max:g,step:E,placeholder:p})};st.displayName="NumberInput";const ke=({rgba:t,onChange:e,readOnly:n=!1})=>r.jsxs("div",{className:tt.rgbaInputs,children:[r.jsxs("div",{className:tt.rgbaInputGroup,children:[r.jsx("span",{className:tt.rgbaLabel,children:"R"}),r.jsx(st,{value:t.r,onChange:o=>e("r",o),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),r.jsxs("div",{className:tt.rgbaInputGroup,children:[r.jsx("span",{className:tt.rgbaLabel,children:"G"}),r.jsx(st,{value:t.g,onChange:o=>e("g",o),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),r.jsxs("div",{className:tt.rgbaInputGroup,children:[r.jsx("span",{className:tt.rgbaLabel,children:"B"}),r.jsx(st,{value:t.b,onChange:o=>e("b",o),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),r.jsxs("div",{className:tt.rgbaInputGroup,children:[r.jsx("span",{className:tt.rgbaLabel,children:"A"}),r.jsx(st,{value:Math.round(t.a*100),onChange:o=>e("a",o!==void 0?o/100:void 0),min:0,max:100,step:1,integer:!0,width:48,readOnly:n})]})]});ke.displayName="RGBAInputs";const G={GRID_CANVAS:10,MARGIN_OVERLAY:20,GRID_OVERLAY:30,BORDER_OVERLAY:40,BLOCK_LAYER_MIN:100,BLOCK_LAYER_MAX:999999,BLOCK_LAYER_STEP:100,ERROR_BORDER:11e5,ERROR_TOOLTIP:12e5,ERROR_HIGHLIGHT:13e5,SELECT_BLOCK:2e6,INTERACTION_LAYER_BASE:21e5,BLOCK_GHOST:22e5,HOVER_OUTLINE:23e5,EDIT_BLOCK:24e5,BLOCK_SELECT_BORDER:25e5,BLOCK_HANDLES:26e5,GRID_GHOST:27e5,GRID_HANDLES:28e5,RUBBER_BAND:29e5,PROPERTY_PANEL:31e5,PALETTE:32e5,TOOLTIP:33e5,DROPDOWN:34e5,CONTEXT_MENU:35e5,MODAL:36e5,DEBUG:1e7},mt={BG:10,CONTENT:50,GUIDE:70,BORDER:80},Se=({isOpen:t,onClose:e,rgba:n,onRgbaChange:o,onColorSelect:s,selectedColor:i,readOnly:a=!1})=>{const l=u.useRef(null);return u.useEffect(()=>{if(!t)return;const c=m=>{l.current&&!l.current.contains(m.target)&&e()};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[t,e]),t?r.jsxs("div",{className:tt.popover,ref:l,style:{zIndex:G.DROPDOWN},children:[r.jsx(Ae,{onColorSelect:s,selectedColor:i,readOnly:a}),r.jsx(ke,{rgba:n,onChange:o,readOnly:a})]}):null};Se.displayName="ColorPickerPopover";const Wt=({value:t,onChange:e,readOnly:n=!1,showTextInput:o=!0,allowUndefined:s,placeholder:i,width:a,height:l,config:c})=>{const m=s??(c==null?void 0:c.allowUndefined)??!0,d=i??(m?"未設定":"#000000"),f=a??(c==null?void 0:c.width),v=l??(c==null?void 0:c.height),[g,E]=u.useState(!1),y=u.useRef(null),[p,x]=u.useState(()=>Ee(t)??{r:0,g:0,b:0,a:1});u.useEffect(()=>{const j=Ee(t);j&&x(j)},[t]);const h=u.useCallback(()=>{n||E(j=>!j)},[n]),[w,N]=u.useState(t?t.replace(/^#/,""):"");u.useEffect(()=>{N(t?t.replace(/^#/,""):"")},[t]);const I=u.useCallback(j=>{const _=j.target.value;/^[0-9A-Fa-f]*$/.test(_)&&N(_)},[]),B=u.useCallback(j=>{if(j===""&&m){e(void 0);return}/^[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$/.test(j)?e(`#${j}`):N(t?t.replace(/^#/,""):"")},[e,m,t]),$=u.useCallback(j=>{B(j.target.value)},[B]),A=u.useCallback(j=>{j.key==="Enter"&&(j.preventDefault(),B(j.currentTarget.value),j.currentTarget.blur())},[B]),L=u.useCallback(j=>{e(j)},[e]),S=u.useCallback((j,_)=>{if(_===void 0)return;const R={...p,[j]:_};x(R),e(xn(R))},[p,e]),D=t??"未設定",k={};t&&(k.background=t);const C={};return f!==void 0?C.width=`${f}px`:C.width="100%",v!==void 0&&(C.height=`${v}px`),r.jsxs("div",{className:tt.container,style:C,ref:y,children:[r.jsx("button",{type:"button",className:tt.colorButton,onClick:h,disabled:n,title:D,"aria-label":"カラーピッカーを開く",style:k}),o&&r.jsxs("div",{className:tt.textInputWrapper,children:[r.jsx("span",{className:tt.textInputPrefix,children:"#"}),r.jsx("input",{type:"text",className:tt.textInput,value:w,onChange:I,onKeyDown:A,onBlur:$,disabled:n,placeholder:d,maxLength:8})]}),r.jsx(Se,{isOpen:g,onClose:()=>E(!1),rgba:p,onRgbaChange:S,onColorSelect:L,selectedColor:t,readOnly:n})]})};Wt.displayName="ColorPicker";const Hr="_container_1n9lj_5",Xr="_valueInput_1n9lj_23",qr="_unitSelect_1n9lj_45",ge={container:Hr,valueInput:Xr,unitSelect:qr},rt=t=>{const{value:e,onChange:n,readOnly:o=!1,config:s}=t,i=t.allowedUnits??(s==null?void 0:s.allowedUnits),a=t.min??(s==null?void 0:s.min),l=t.max??(s==null?void 0:s.max),c=t.step??(s==null?void 0:s.step)??1,m=t.placeholder??(s==null?void 0:s.placeholder),d=t.width??(s==null?void 0:s.width),f=t.height??(s==null?void 0:s.height),v=(e==null?void 0:e.unit)??(i==null?void 0:i[0]),g=u.useCallback(w=>{const N=w.target.value;let I=Number.parseFloat(N);if(Number.isNaN(I))return;const B=a??1;I<B&&(I=B),l!==void 0&&I>l&&(I=l),n({value:I,unit:(e==null?void 0:e.unit)??v})},[e,n,v,a,l]),E=u.useCallback(w=>{const N=w.target.value;if(N==="")return;let I=Number.parseFloat(N);if(Number.isNaN(I))return;const B=a??1;I<B&&(I=B,n({value:I,unit:(e==null?void 0:e.unit)??v})),l!==void 0&&I>l&&(I=l,n({value:I,unit:(e==null?void 0:e.unit)??v}))},[e,n,v,a,l]),y=u.useCallback(w=>{const N=w.target.value;n({value:(e==null?void 0:e.value)??1,unit:N})},[e,n]),p=(e==null?void 0:e.value)??"",x=(e==null?void 0:e.unit)??v??"",h={};return d!==void 0?h.width=`${d}px`:h.width="100%",f!==void 0&&(h.height=`${f}px`),r.jsxs("div",{className:ge.container,style:h,children:[r.jsx("input",{type:"number",className:ge.valueInput,value:p,onChange:g,onBlur:E,placeholder:m,min:a??1,max:l,step:c,readOnly:o,disabled:o}),r.jsx("select",{className:ge.unitSelect,value:x,onChange:y,disabled:o||!i||i.length<=1,children:i?i.map(w=>r.jsx("option",{value:w,children:w},w)):r.jsx("option",{value:x,children:x})})]})},Kr="_container_1bfk3_6",Zr="_scrollArea_1bfk3_23",Jr="_emptyState_1bfk3_31",we={container:Kr,scrollArea:Zr,emptyState:Jr},Le=({children:t,emptyMessage:e,className:n})=>r.jsx("div",{className:`${we.container} ${n||""}`,children:t?r.jsx("div",{className:we.scrollArea,children:t}):e&&r.jsx("div",{className:we.emptyState,children:e})}),Qr="_root_qs6t8_3",to="_list_qs6t8_11",eo="_trigger_qs6t8_26",no="_content_qs6t8_71",le={root:Qr,list:to,trigger:eo,content:no},ce=u.createContext(void 0),Oe=({defaultValue:t,value:e,onValueChange:n,children:o,variant:s="default",className:i=""})=>{const[a,l]=u.useState(t),c=e??a,m=d=>{l(d),n==null||n(d)};return r.jsx(ce.Provider,{value:{value:c,onChange:m,variant:s},children:r.jsx("div",{className:`${le.root} ${i}`,"data-variant":s,children:o})})},Ge=({children:t,className:e="",width:n,height:o,style:s})=>{const i=u.useContext(ce);if(!i)throw new Error("TabsList must be used within a Tabs component");const{variant:a}=i,l={...s};return n!==void 0&&(l.width=`${n}px`),o!==void 0&&(l.height=`${o}px`),r.jsx("div",{className:`${le.list} ${e}`,"data-variant":a,style:l,children:t})},yt=({value:t,children:e,className:n="",disabled:o=!1,width:s,height:i,style:a})=>{const l=u.useContext(ce);if(!l)throw new Error("TabsTrigger must be used within a Tabs component");const{value:c,onChange:m,variant:d}=l,f=c===t,v={...a};return s!==void 0&&(v.width=`${s}px`),i!==void 0&&(v.height=`${i}px`),r.jsx("button",{className:`${le.trigger} ${n}`,"data-state":f?"active":"inactive","data-variant":d,onClick:()=>m(t),disabled:o,type:"button",style:v,children:e})},Et=({value:t,children:e,className:n=""})=>{const o=u.useContext(ce);if(!o)throw new Error("TabsContent must be used within a Tabs component");const{value:s}=o;return s!==t?null:r.jsx("div",{className:`${le.content} ${n}`,children:e})},ro="_input_9unrj_5",oo={input:ro},At=({value:t,onChange:e,readOnly:n=!1,placeholder:o,maxLength:s,multiline:i,rows:a,width:l,height:c,config:m,onBlur:d})=>{const f=o??(m==null?void 0:m.placeholder),v=s??(m==null?void 0:m.maxLength),g=i??(m==null?void 0:m.multiline)??!1,E=a??(m==null?void 0:m.rows)??3,y=u.useCallback(h=>{const w=h.target.value;e(w)},[e]),p={};l!==void 0?p.width=`${l}px`:p.width="100%",c!==void 0&&(p.height=`${c}px`);const x={className:oo.input,style:p,value:t??"",onChange:y,disabled:n,placeholder:f,maxLength:v};return g?r.jsx("textarea",{...x,rows:E}):r.jsx("input",{...x,type:"text",onBlur:d})};At.displayName="TextInput";const so=["mm","cm","fr","inch","pt","px","%"],io=["mm","cm","pt","inch","px"],ao=["mm","cm","inch"],lo=["mm","cm","fr","inch","pt","px"],bn=["px","pt","mm"],gn=["px","pt","mm"],$t=["mm","pt","px","%"],je=["mm","cm","inch","pt","px","%"],wn={isIndividual:{defaultValue:!1,label:"個別に設定",group:"余白",Component:xt,description:"上下左右の余白を個別に設定します"},all:{defaultValue:{value:0,unit:"px"},label:"全方向",group:"余白",Component:rt,config:{allowedUnits:$t,min:0},condition:t=>!t.isIndividual},top:{defaultValue:{value:0,unit:"px"},label:"上",group:"余白",Component:rt,config:{allowedUnits:$t,min:0},condition:t=>t.isIndividual===!0},right:{defaultValue:{value:0,unit:"px"},label:"右",group:"余白",Component:rt,config:{allowedUnits:$t,min:0},condition:t=>t.isIndividual===!0},bottom:{defaultValue:{value:0,unit:"px"},label:"下",group:"余白",Component:rt,config:{allowedUnits:$t,min:0},condition:t=>t.isIndividual===!0},left:{defaultValue:{value:0,unit:"px"},label:"左",group:"余白",Component:rt,config:{allowedUnits:$t,min:0},condition:t=>t.isIndividual===!0}},co={...pn,...wn},_n=[{label:"ゴシック体",value:"sans-serif"},{label:"明朝体",value:"serif"},{label:"等幅",value:"monospace"},{label:"Arial",value:"Arial, sans-serif"},{label:"Times New Roman",value:"'Times New Roman', serif"}],uo={fontSize:{defaultValue:{value:14,unit:"pt"},label:"フォントサイズ",group:"フォント",description:"テキストのフォントサイズを設定します",Component:rt,config:{allowedUnits:gn,min:1,step:1}},fontFamily:{defaultValue:"sans-serif",label:"フォント",group:"フォント",Component:wt,config:{placeholder:"フォントを選択",options:_n}},color:{defaultValue:void 0,label:"文字色",group:"フォント",Component:Wt,config:{allowUndefined:!0}},fontWeight:{defaultValue:!1,label:"太字",group:"フォント",description:"テキストを太字にします",Component:xt},italic:{defaultValue:!1,label:"斜体",group:"フォント",description:"テキストを斜体にします",Component:xt},underline:{defaultValue:!1,label:"下線",group:"フォント",description:"テキストに下線を引きます",Component:xt},lineThrough:{defaultValue:!1,label:"取り消し線",group:"フォント",description:"テキストに取り消し線を引きます",Component:xt},lineHeight:{defaultValue:1.2,label:"行の高さ",group:"フォント",description:"行の高さを設定します(1.0〜3.0)",Component:st,config:{min:1,max:3,step:.1}}};function mo(t){return t.reduce((e,n)=>(e[n.kind]=n,e),{})}var jt=(t=>(t.Contain="contain",t.Cover="cover",t.Fill="fill",t.None="none",t.ScaleDown="scale-down",t))(jt||{});const ho={objectFit:{defaultValue:jt.Contain,label:"表示方法",group:"画像",description:"画像のサイズが枠と合わない場合の表示方法を設定します",Component:wt,config:{options:[{label:"全体を表示",value:jt.Contain},{label:"枠を埋める/切り抜き",value:jt.Cover},{label:"引き伸ばす/縮小する",value:jt.Fill},{label:"元のサイズ",value:jt.None},{label:"縮小のみ",value:jt.ScaleDown}]}},alt:{defaultValue:"",label:"代替テキスト",group:"画像",description:"画像が表示できない場合に表示されるテキスト",Component:At,config:{placeholder:"画像の説明"}}};var Mt=(t=>(t.Normal="normal",t.BreakWord="break-word",t.BreakAll="break-all",t))(Mt||{}),Ct=(t=>(t.Normal="normal",t.NoWrap="nowrap",t.Pre="pre",t.PreWrap="pre-wrap",t.PreLine="pre-line",t))(Ct||{});const fo={multiline:{defaultValue:!1,label:"複数行モード",group:"設定",Component:xt,config:{label:"有効にする"}},wordWrap:{defaultValue:Mt.Normal,label:"単語の折り返し",group:"設定",Component:wt,config:{options:[{label:"通常",value:Mt.Normal},{label:"単語で改行",value:Mt.BreakWord},{label:"強制改行",value:Mt.BreakAll}]},condition:t=>t.multiline===!0},whiteSpace:{defaultValue:Ct.Normal,label:"空白文字の扱い",group:"設定",Component:wt,config:{options:[{label:"通常",value:Ct.Normal},{label:"折り返しなし",value:Ct.NoWrap},{label:"そのまま表示",value:Ct.Pre}]},condition:t=>t.multiline===!0}},po={placeholder:{defaultValue:void 0,label:"プレースホルダー",group:"設定",description:"入力欄に表示するプレースホルダーテキストを設定します",Component:At,config:{placeholder:"例: テキストを入力してください"}}},xo={width:{defaultValue:void 0,label:"幅",group:"サイズ",description:"要素の幅を設定します",Component:rt,config:{min:0,allowedUnits:je,placeholder:"auto"}},height:{defaultValue:void 0,label:"高さ",group:"サイズ",description:"要素の高さを設定します",Component:rt,config:{min:0,allowedUnits:je,placeholder:"auto"}}},yn=t=>{const e={};return Object.entries(t.properties).forEach(([n,o])=>{o!==!1&&typeof o=="object"&&o!==null&&"defaultValue"in o&&(e[n]=o.defaultValue)}),e};function En(t){const e=Date.now(),n=Math.random().toString(36).slice(2);return`${t}_${e}_${n}`}function Nt(t,e,n){const o=yn(t);return{id:En(t.kind),kind:t.kind,layout:{x:e.x,y:e.y,w:e.w,h:e.h},style:{},behavior:{},props:{...o,...n}}}const vo={required:{defaultValue:!1,label:"必須項目",group:"バリデーション",description:"この項目を必須入力にします",Component:xt,config:{label:"必須にする"}},minLength:{defaultValue:void 0,label:"最小文字数",group:"バリデーション",description:"入力可能な最小文字数を設定します",Component:st,config:{min:0,integer:!0,placeholder:"制限なし"}},maxLength:{defaultValue:void 0,label:"最大文字数",group:"バリデーション",description:"入力可能な最大文字数を設定します",Component:st,config:{min:0,integer:!0,placeholder:"制限なし"}},pattern:{defaultValue:void 0,label:"入力パターン (正規表現)",group:"バリデーション",description:"入力値を検証する正規表現パターンを設定します",Component:At,config:{placeholder:"例: ^[0-9]+$"},disableInMultiSelection:!0}};var ct=(t=>(t.ADD="add",t.UPDATE="update",t.DELETE="delete",t.MOVE="move",t.RESIZE="resize",t.DUPLICATE="duplicate",t.PASTE="paste",t))(ct||{});const jn={cols:Array.from({length:12}).map(()=>({value:1,unit:"fr"})),rows:Array.from({length:16}).map(()=>({value:1,unit:"fr"}))};var dt=(t=>(t.SOLID="solid",t.DASHED="dashed",t.DOTTED="dotted",t))(dt||{});const W=96;function ue(t,e){if(t<=0){const n=e??"Value";throw new Error(`${n} must be positive (> 0): got ${t}`)}}function et(t,e){if(t<0){const n=e??"Value";throw new Error(`${n} must be non-negative (>= 0): got ${t}`)}}function Nn(t,e,n,o){if(t<e||t>n){const s=o??"Value";throw new Error(`${s} must be between ${e} and ${n}: got ${t}`)}}function de(t,e){if(!Number.isInteger(t)){const n=e??"Value";throw new Error(`${n} must be an integer: got ${t}`)}}function bo(t,e){if(!Number.isFinite(t)){const n=e??"Value";throw new Error(`${n} must be a finite number: got ${t}`)}}const go=25.4,wo=2.54,_o=72,V={_assertDpi(t){ue(t,"DPI"),de(t,"DPI")},fromMm(t,e=W){return V._assertDpi(e),et(t,"Millimeter value"),t*e/go},fromCm(t,e=W){return V._assertDpi(e),et(t,"Centimeter value"),t*e/wo},fromInch(t,e=W){return V._assertDpi(e),et(t,"Inch value"),t*e},fromPt(t,e=W){return V._assertDpi(e),et(t,"Point value"),t*e/_o},fromPx(t,e=W){return V._assertDpi(e),et(t,"Pixel value"),t*e/W},fromDim(t,e=W,n){switch(V._assertDpi(e),et(t.value,"Dimension value"),t.unit){case"mm":return V.fromMm(t.value,e);case"cm":return V.fromCm(t.value,e);case"inch":return V.fromInch(t.value,e);case"pt":return V.fromPt(t.value,e);case"px":return V.fromPx(t.value,e);case"%":if(n===void 0)throw new Error("Base size must be defined for percentage values.");return t.value/100*n;case"fr":throw new Error(`Cannot convert ${t.unit} to px. Use physical units only.`);default:{const o=t.unit;throw new Error(`Unsupported unit: ${o}`)}}}},Pt=t=>{if(!(t!=null&&t.width)||!(t!=null&&t.type))return;const e=t.width.value;if(e!==0){if(t.type===dt.DASHED)return`${e*4} ${e*2}`;if(t.type===dt.DOTTED)return`${e*1} ${e*2}`}};class kt{constructor(e){this.style=e}get top(){return this.style.top?{...this.style.all,...this.style.top}:this.style.all}get right(){return this.style.right?{...this.style.all,...this.style.right}:this.style.all}get bottom(){return this.style.bottom?{...this.style.all,...this.style.bottom}:this.style.all}get left(){return this.style.left?{...this.style.all,...this.style.left}:this.style.all}get hasAnyBorder(){return!!(this.top||this.right||this.bottom||this.left)}getTopSVGProps(e,n=W){const o=this.top;return o?{x1:0,y1:0,x2:e,y2:0,stroke:o.color,strokeWidth:V.fromDim(o.width,n),strokeDasharray:Pt(o),vectorEffect:"non-scaling-stroke","data-edge":"top"}:null}getRightSVGProps(e,n,o=W){const s=this.right;return s?{x1:e,y1:0,x2:e,y2:n,stroke:s.color,strokeWidth:V.fromDim(s.width,o),strokeDasharray:Pt(s),vectorEffect:"non-scaling-stroke","data-edge":"right"}:null}getBottomSVGProps(e,n,o=W){const s=this.bottom;return s?{x1:0,y1:n,x2:e,y2:n,stroke:s.color,strokeWidth:V.fromDim(s.width,o),strokeDasharray:Pt(s),vectorEffect:"non-scaling-stroke","data-edge":"bottom"}:null}getLeftSVGProps(e,n=W){const o=this.left;return o?{x1:0,y1:0,x2:0,y2:e,stroke:o.color,strokeWidth:V.fromDim(o.width,n),strokeDasharray:Pt(o),vectorEffect:"non-scaling-stroke","data-edge":"left"}:null}}var it=(t=>(t.FORM="Form",t.EDIT="Edit",t.VIEW="View",t))(it||{}),pt=(t=>(t.A4="A4",t.B5="B5",t.A3="A3",t.LETTER="Letter",t.LEGAL="Legal",t.CUSTOM="Custom",t))(pt||{});const Be={A4:{preset:"A4",width:{value:210,unit:"mm"},height:{value:297,unit:"mm"}},A3:{preset:"A3",width:{value:297,unit:"mm"},height:{value:420,unit:"mm"}},B5:{preset:"B5",width:{value:182,unit:"mm"},height:{value:257,unit:"mm"}},Letter:{preset:"Letter",width:{value:8.5,unit:"inch"},height:{value:11,unit:"inch"}},Legal:{preset:"Legal",width:{value:8.5,unit:"inch"},height:{value:14,unit:"inch"}},Custom:{preset:"Custom",width:{value:210,unit:"mm"},height:{value:297,unit:"mm"}}},In={top:{value:10,unit:"mm"},right:{value:10,unit:"mm"},bottom:{value:10,unit:"mm"},left:{value:10,unit:"mm"}},Dn={size:Be.A4,margin:In},yo={paper:Dn,grid:jn,blocks:[]};var $n=(t=>(t.ERROR="error",t.WARNING="warning",t.INFO="info",t))($n||{});const It=u.memo(({width:t,height:e,border:n,dpi:o=W,className:s=""})=>n.hasAnyBorder?r.jsxs("svg",{width:t,height:e,xmlns:"http://www.w3.org/2000/svg",className:s,style:{overflow:"visible"},children:[r.jsx("title",{children:"border SVG"}),n.top&&r.jsx("line",{...n.getTopSVGProps(t,o)}),n.right&&r.jsx("line",{...n.getRightSVGProps(t,e,o)}),n.bottom&&r.jsx("line",{...n.getBottomSVGProps(t,e,o)}),n.left&&r.jsx("line",{...n.getLeftSVGProps(e,o)})]}):null);It.displayName="BorderRenderer";function Tn(t){const e=G.BLOCK_LAYER_MIN+t*G.BLOCK_LAYER_STEP;return e>=G.BLOCK_LAYER_MAX?G.BLOCK_LAYER_MAX:e}function Yt(t,e){const n=Math.min(Math.max(0,e),G.BLOCK_LAYER_STEP-1);return t+n}function Eo(){return Math.floor((G.BLOCK_LAYER_MAX-G.BLOCK_LAYER_MIN)/G.BLOCK_LAYER_STEP)}const Rn=u.memo(({blockSizePx:t,borderStyle:e,blockZIndex:n,subZIndex:o=mt.BORDER,visible:s=!0,dpi:i=W,className:a=""})=>{const l=u.useMemo(()=>{if(e)return new kt(e)},[e]);if(!s||!l||!l.hasAnyBorder)return null;const c=Yt(n,o),m={position:"absolute",left:0,top:0,width:`${t.width}px`,height:`${t.height}px`,pointerEvents:"none",overflow:"visible",zIndex:c};return r.jsx("div",{className:a,style:m,"data-testid":"block-border",children:r.jsx(It,{width:t.width,height:t.height,border:l,dpi:i})})}),Mn=u.memo(({blockSizePx:t,blockZIndex:e,subZIndex:n=mt.BG,backgroundColor:o="transparent",className:s=""})=>{const i=Yt(e,n),a={position:"absolute",inset:0,width:`${t.width}px`,height:`${t.height}px`,backgroundColor:o,pointerEvents:"none",zIndex:i};return r.jsx("div",{className:s,style:a,role:"presentation","aria-label":"Block background","data-testid":"block-canvas"})}),Cn={color:"#cccccc",width:{value:1,unit:"pt"},type:dt.SOLID},me={all:Cn},Pn=u.memo(({blockSizePx:t,blockZIndex:e,subZIndex:n=mt.GUIDE,borderStyle:o=me,visible:s=!0,dpi:i=W,className:a=""})=>{const l=u.useMemo(()=>{if(o)return new kt(o)},[o]);if(!s||!l||!l.hasAnyBorder)return null;const c=Yt(e,n),m={position:"absolute",left:0,top:0,width:`${t.width}px`,height:`${t.height}px`,pointerEvents:"none",overflow:"visible",zIndex:c};return r.jsx("div",{className:a,style:m,"data-testid":"block-base-border",children:r.jsx(It,{width:t.width,height:t.height,border:l,dpi:i})})}),jo=({id:t,plugin:e,props:n,value:o,onChange:s,onBlur:i,readOnly:a,mode:l,blockSizePx:c,blockZIndex:m,subZIndex:d=mt.CONTENT,validationState:f,className:v=""},g)=>{const E=u.useRef(null);u.useImperativeHandle(g,()=>({focus:()=>{var w;return(w=E.current)==null?void 0:w.focus()}}),[]);const y=Yt(m,d),p={position:"absolute",inset:0,width:`${c.width}px`,height:`${c.height}px`,zIndex:y,pointerEvents:"auto"},x={id:t,props:n,value:o,onChange:s??(()=>{}),onBlur:i,readOnly:a,mode:l,dimensions:{widthPx:c.width,heightPx:c.height},validationState:f},h=e.Renderer;return r.jsx("div",{className:v,style:p,"data-testid":"block-renderer","data-block-id":t,"data-plugin-kind":e.kind,children:r.jsx(h,{ref:E,...x})})},No=u.forwardRef(jo),Ht=u.memo(No);function Ve(t,e){return{position:"absolute",left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,zIndex:e==null?void 0:e.zIndex,pointerEvents:(e==null?void 0:e.pointerEvents)??"auto"}}const Ue=u.memo(u.forwardRef(({block:t,plugin:e,blockRectPx:n,blockZIndex:o,mode:s,value:i,onValueChange:a,onValueBlur:l,showGuides:c=!0,showBorder:m=!0,blockSubZIndex:d={bg:mt.BG,guide:mt.GUIDE,content:mt.CONTENT,border:mt.BORDER},defaultGuideBorder:f=me,dpi:v=W,className:g="",pointerEvents:E="none"},y)=>{var h,w,N,I;const p=Ve(n,{zIndex:o,pointerEvents:E}),x=u.useMemo(()=>({width:n.width,height:n.height}),[n.width,n.height]);return r.jsxs("div",{style:p,"data-block-id":t.id,className:g,children:[r.jsx(Mn,{blockSizePx:x,blockZIndex:o,backgroundColor:(h=t.style)==null?void 0:h.backgroundColor,subZIndex:d.bg}),c&&!((w=t.style)!=null&&w.border)&&r.jsx(Pn,{blockSizePx:x,blockZIndex:o,subZIndex:d.guide,borderStyle:f,dpi:v}),r.jsx(Ht,{id:t.id,ref:y,plugin:e,props:t.props,value:i,onChange:a,onBlur:l,readOnly:s===it.EDIT?((N=t.behavior)==null?void 0:N.readOnly)??!1:!0,mode:s,blockSizePx:x,blockZIndex:o,subZIndex:d.content}),r.jsx(Rn,{blockSizePx:x,blockZIndex:o,borderStyle:(I=t.style)==null?void 0:I.border,subZIndex:d.border,visible:m,dpi:v})]})}));Ue.displayName="BlockContainer";const St=u.memo(({blocks:t,pluginRegistry:e,mode:n,values:o,selectedBlockIds:s=[],getBlockRectPx:i,onValueChange:a,onValueBlur:l,showGuides:c=!0,showBorder:m=!0,blockSubZIndex:d={bg:mt.BG,guide:mt.GUIDE,content:mt.CONTENT,border:mt.BORDER},defaultGuideBorder:f=me,dpi:v=W,className:g=""})=>{const E=u.useRef(new Map),y={position:"absolute",inset:0,pointerEvents:"none"};return r.jsx("div",{className:g,style:y,"data-testid":"block-layer",children:t.map((p,x)=>{const h=e[p.kind];if(!h)return null;const w=i(p),N=s.includes(p.id);let I=Tn(x);N&&(I=G.SELECT_BLOCK);const B=o[p.id]??p.initValue;return r.jsx(Ue,{ref:$=>{$?E.current.set(p.id,$):E.current.delete(p.id)},block:p,plugin:h,blockRectPx:w,blockZIndex:I,mode:n,value:B,onValueChange:a?$=>a(p.id,$):void 0,onValueBlur:$=>l==null?void 0:l(p.id,$),showGuides:c,showBorder:m,blockSubZIndex:d,defaultGuideBorder:f,dpi:v,pointerEvents:"none"},p.id)})})});St.displayName="BlockLayer";const An=u.memo(({contentPx:t,marginLeftPx:e,marginTopPx:n,borderStyle:o,visible:s=!0,dpi:i=W,zIndex:a=G.BORDER_OVERLAY,className:l=""})=>{const c=u.useMemo(()=>{if(o)return new kt(o)},[o]);if(!s||!c||!c.hasAnyBorder)return null;const m={position:"absolute",left:`${e}px`,top:`${n}px`,width:`${t.width}px`,height:`${t.height}px`,pointerEvents:"none",overflow:"visible",zIndex:a};return r.jsx("div",{className:l,style:m,"data-testid":"border-overlay",children:r.jsx(It,{width:t.width,height:t.height,border:c,dpi:i})})}),kn=u.memo(({canvasPx:t,backgroundColor:e="#ffffff",boxShadow:n="0 2px 8px rgba(0, 0, 0, 0.1)",zIndex:o=G.GRID_CANVAS,className:s})=>{const i={position:"absolute",inset:0,width:`${t.width}px`,height:`${t.height}px`,backgroundColor:e,boxShadow:n,pointerEvents:"none",zIndex:o};return r.jsx("div",{className:s,style:i,role:"presentation","aria-label":"Paper background","data-testid":"grid-canvas"})}),Io="_label_vgaic_1",Do={label:Io},$o="_editor_6szgo_5",To="_input_6szgo_18",Ro="_select_6szgo_38",Mo="_button_6szgo_54",Jt={editor:$o,input:To,select:Ro,button:Mo};function Sn(t,e){const n=t.match(/^(\d+(?:\.\d+)?)([a-zA-Z%]+)$/);if(!n)throw new Error(`Invalid dimension string: ${t}`);const o=Number(n[1]),s=n[2];if(et(o,"Dimension value"),!e.includes(s))throw new Error(`Unit not allowed: ${s}`);return{value:o,unit:s}}function Co(t,e){return t.map(n=>Sn(n,e))}const Po=10,Ao=25.4,ko=.352778,So=.264583,Y={fromCm(t){return et(t,"Centimeter value"),t*Po},fromInch(t){return et(t,"Inch value"),t*Ao},fromPt(t){return et(t,"Point value"),t*ko},fromPx(t){return et(t,"Pixel value"),t*So},fromDim(t){switch(et(t.value,"Dimension value"),t.unit){case"mm":return t.value;case"cm":return Y.fromCm(t.value);case"inch":return Y.fromInch(t.value);case"pt":return Y.fromPt(t.value);case"px":return Y.fromPx(t.value);case"fr":case"%":throw new Error(`Cannot convert ${t.unit} to mm. Use physical units only.`);default:{const e=t.unit;throw new Error(`Unsupported unit: ${e}`)}}}};function Ln(t){return et(t.value,"Dimension"),`${t.value}${t.unit}`}function Lo(t){return t.map(Ln)}const Oo=["fr","px","mm","cm","pt","inch"];function Go(t,e){if(e==="fr")return 1;switch(e){case"px":return t;case"mm":{const n=Y.fromPx(t);return Math.round(n*10)/10}case"cm":{const o=Y.fromPx(t)/10;return Math.round(o*100)/100}case"inch":{const o=Y.fromPx(t)/25.4;return Math.round(o*100)/100}case"pt":{const s=Y.fromPx(t)/25.4*72;return Math.round(s*10)/10}default:{const n=e;throw new Error(`Unsupported unit: ${n}`)}}}const On=u.memo(({direction:t,dimension:e,currentPxSize:n,position:o,marginLeftPx:s,marginTopPx:i,onChange:a,onCancel:l})=>{const[c,m]=u.useState(e.value.toString()),[d,f]=u.useState(e.unit),v=u.useRef(null),g=u.useRef(null),E=t==="column"?{left:`${s+o}px`,top:`${i+24}px`,transform:"translateX(-50%)"}:{left:`${s+24}px`,top:`${i+o}px`,transform:"translateY(-50%)"};u.useEffect(()=>{var h,w;(h=v.current)==null||h.focus(),(w=v.current)==null||w.select()},[]),u.useEffect(()=>{const h=w=>{g.current&&!g.current.contains(w.target)&&l()};return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h)}},[l]);const y=()=>{const h=Number.parseFloat(c);!Number.isNaN(h)&&h>=.1?a({unit:d,value:h}):l()},p=h=>{h.key==="Enter"?(h.preventDefault(),y()):h.key==="Escape"&&(h.preventDefault(),l())},x=h=>{const w=h.target.value;f(w);const N=Go(n,w);m(N.toString())};return r.jsxs("div",{ref:g,className:Jt.editor,style:E,"data-testid":`grid-unit-editor-${t}`,children:[r.jsx("input",{ref:v,type:"number",className:Jt.input,value:c,onChange:h=>m(h.target.value),onKeyDown:p,min:"0.1",step:d==="fr"?"0.1":"1"}),r.jsx("select",{className:Jt.select,value:d,onChange:x,children:Oo.map(h=>r.jsx("option",{value:h,children:h},h))}),r.jsx("button",{type:"button",className:Jt.button,onClick:y,title:"確定",children:"✓"})]})});On.displayName="GridUnitEditor";function Bo(t,e,n,o){if(e==="fr"){if(n!==void 0&&o!==void 0&&o>0){const s=t/o;return Math.round(n*s*100)/100}return 1}switch(e){case"px":return Math.round(t);case"mm":{const s=Y.fromPx(t);return Math.round(s*10)/10}case"cm":{const s=Y.fromPx(t);return Math.round(s/10*100)/100}case"inch":{const s=Y.fromPx(t);return Math.round(s/25.4*100)/100}case"pt":{const s=Y.fromPx(t);return Math.round(s/25.4*72*10)/10}default:{const s=e;throw new Error(`Unsupported unit: ${s}`)}}}const ee=u.memo(({direction:t,index:e,dimension:n,position:o,currentPxSize:s,marginLeftPx:i,marginTopPx:a,isNearCursor:l,resizingPxSize:c,onDimensionChange:m})=>{const[d,f]=u.useState(!1);if(!l&&!d)return null;const v=t==="column"?{left:`${i+o}px`,top:`${a-20}px`,transform:"translateX(-50%)"}:{left:`${i-20}px`,top:`${a+o}px`,transform:"translateY(-50%)",writingMode:"vertical-rl"},g=()=>{f(!0)},E=h=>{m==null||m(t,e,h),f(!1)},y=()=>{f(!1)},x=c?(()=>{const h=Bo(c,n.unit,n.value,s);return n.unit==="fr"?`${h}fr`:`${h}${n.unit}`})():(h=>h.unit==="fr"?`${h.value}fr`:`${h.value}${h.unit}`)(n);return r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:Do.label,style:v,onDoubleClick:g,"data-testid":`grid-dimension-${t}-${e}`,"aria-label":`グリッド寸法: ${x}`,children:x})," ",d&&r.jsx(On,{direction:t,dimension:n,currentPxSize:s,position:o,marginLeftPx:i,marginTopPx:a,onChange:E,onCancel:y})]})});ee.displayName="GridDimensionLabel";function Vo(t,e,n,o){let s="";for(const i of t)s+=`M ${i} 0 L ${i} ${o} `;for(const i of e)s+=`M 0 ${i} L ${n} ${i} `;return s}const Gn=u.memo(({gridPosPx:t,contentPx:e,marginLeftPx:n,marginTopPx:o,lineStyle:s,visible:i=!0,zIndex:a=G.GRID_OVERLAY,dpi:l=W,className:c=""})=>{const m=u.useMemo(()=>Vo(t.cols.slice(1,-1),t.rows.slice(1,-1),e.width,e.height),[t,e]);if(!i||!s)return null;const d=Pt(s),f=V.fromDim(s.width,l),v={position:"absolute",left:`${n}px`,top:`${o}px`,pointerEvents:"none",zIndex:a};return r.jsx("svg",{className:c,style:v,width:e.width,height:e.height,xmlns:"http://www.w3.org/2000/svg",role:"img","aria-label":"Grid overlay lines",children:r.jsx("path",{d:m,stroke:s.color,strokeWidth:f,strokeDasharray:d,fill:"none"})})}),Uo="_handle_1mgtx_1",Fo="_dragging_1mgtx_19",_e={handle:Uo,dragging:Fo},ne=u.memo(({direction:t,index:e,position:n,marginLeftPx:o,marginTopPx:s,onResizeStart:i,onResize:a,onResizeEnd:l})=>{const[c,m]=u.useState(!1),d=12,f=d/2,v=t==="column"?{left:`${o+n-f}px`,top:`${s-f}px`,width:`${d}px`,height:`${d}px`,cursor:"col-resize"}:{left:`${o-f}px`,top:`${s+n-f}px`,width:`${d}px`,height:`${d}px`,cursor:"row-resize"},g=u.useCallback(E=>{E.stopPropagation(),E.preventDefault();const y=t==="column"?E.clientX:E.clientY;m(!0),i==null||i(t,e);const p=h=>{const N=(t==="column"?h.clientX:h.clientY)-y;a==null||a(t,e,N)},x=h=>{const N=(t==="column"?h.clientX:h.clientY)-y;m(!1),l==null||l(t,e,N),window.removeEventListener("pointermove",p),window.removeEventListener("pointerup",x)};window.addEventListener("pointermove",p),window.addEventListener("pointerup",x)},[t,e,i,a,l]);return r.jsx("div",{className:`${_e.handle} ${_e[t]} ${c?_e.dragging:""}`,style:v,onPointerDown:g,"data-testid":`grid-resize-handle-${t}-${e}`})});ne.displayName="GridResizeHandle";const Bn=u.memo(({paperPx:t,visible:e=!0,marginColor:n,zIndex:o=G.MARGIN_OVERLAY,className:s=""})=>{if(!e)return null;const i={position:"absolute",inset:0,pointerEvents:"none",width:`${t.canvas.width}px`,height:`${t.canvas.height}px`,zIndex:o},a={position:"absolute",backgroundColor:n||"rgba(0, 0, 0, 0.05)",pointerEvents:"none"};return r.jsxs("div",{className:s,style:i,role:"presentation","aria-label":"Printable area margin","data-testid":"margin-overlay",children:[t.margin.top>0&&r.jsx("div",{"data-testid":"margin-top",style:{...a,top:0,left:0,width:"100%",height:`${t.margin.top}px`}}),t.margin.bottom>0&&r.jsx("div",{"data-testid":"margin-bottom",style:{...a,bottom:0,left:0,width:"100%",height:`${t.margin.bottom}px`}}),t.margin.left>0&&r.jsx("div",{"data-testid":"margin-left",style:{...a,left:0,top:`${t.margin.top}px`,height:`${t.content.height}px`,width:`${t.margin.left}px`}}),t.margin.right>0&&r.jsx("div",{"data-testid":"margin-right",style:{...a,right:0,top:`${t.margin.top}px`,height:`${t.content.height}px`,width:`${t.margin.right}px`}})]})}),he=u.memo(({paperPx:t,gridPosPxs:e,gridDimensions:n,gridLineStyle:o,borderStyle:s,backgroundColor:i="#ffffff",boxShadow:a="0 2px 8px rgba(0, 0, 0, 0.1)",marginFillColor:l="rgba(0, 0, 0, 0.05)",showGridLines:c=!0,showMargins:m=!0,showBorder:d=!0,showResizeHandles:f=!1,showDimensionLabels:v=!1,onGridResize:g,onDimensionChange:E,className:y="",zIndex:p={}})=>{const[x,h]=u.useState(null),[w,N]=u.useState(null),[I,B]=u.useState(null),$=u.useRef(null);u.useEffect(()=>{const j=R=>{if(!$.current)return;const T=$.current.getBoundingClientRect();B({x:R.clientX-T.left,y:R.clientY-T.top})},_=R=>{if(!$.current)return;const T=$.current.getBoundingClientRect();(R.clientX<T.left||R.clientX>T.right||R.clientY<T.top||R.clientY>T.bottom)&&B(null)};return window.addEventListener("mousemove",j),window.addEventListener("mouseleave",_),()=>{window.removeEventListener("mousemove",j),window.removeEventListener("mouseleave",_)}},[]);const A=u.useMemo(()=>{if(!I)return!1;const j=t.content.width,_=t.content.height,R=t.margin.left,T=t.margin.top;return!(I.x>=R&&I.x<=R+j&&I.y>=T&&I.y<=T+_)},[I,t]),L=u.useCallback((j,_)=>{N({direction:j,index:_})},[]),S=u.useMemo(()=>{if(!x||!w)return null;const j=w.direction==="column"?e.cols:e.rows,_=w.index,R=j[_-1],T=x.position,O=R!==void 0?T-R:0,U=x.position,F=j[_+1],b=F!==void 0?F-U:0;return{direction:w.direction,prevIndex:_-1,prevSize:O,nextIndex:_,nextSize:b}},[x,w,e]),D=u.useCallback((j,_,R)=>{const T=j==="column"?e.cols:e.rows,O=T[_];if(O===void 0)return;const U=T[_-1],F=T[_+1],b=10;let M=R;if(U!==void 0){const P=U+b-O;M=Math.max(M,P)}if(F!==void 0){const P=F-b-O;M=Math.min(M,P)}h({direction:j,position:O+M})},[e]),k=u.useCallback((j,_,R)=>{const T=j==="column"?e.cols:e.rows,O=T[_];if(O===void 0){h(null);return}const U=T[_-1],F=T[_+1],b=10;let M=R;if(U!==void 0){const P=U+b-O;M=Math.max(M,P)}if(F!==void 0){const P=F-b-O;M=Math.min(M,P)}h(null),N(null),g==null||g(j,_,M)},[e,g]),C={position:"relative",width:"100%",height:"100%"};return r.jsxs("div",{ref:$,className:y,style:C,children:[r.jsx(kn,{canvasPx:t.canvas,backgroundColor:i,boxShadow:a,zIndex:(p==null?void 0:p.canvas)??G.GRID_CANVAS,className:y}),m&&r.jsx(Bn,{paperPx:t,visible:m,marginColor:l,zIndex:(p==null?void 0:p.margin)??G.MARGIN_OVERLAY,className:y}),c&&r.jsx(Gn,{gridPosPx:e,contentPx:t.content,marginLeftPx:t.margin.left,marginTopPx:t.margin.top,lineStyle:o,visible:c,zIndex:(p==null?void 0:p.grid)??G.GRID_OVERLAY,dpi:W,className:y}),d&&r.jsx(An,{contentPx:t.content,marginLeftPx:t.margin.left,marginTopPx:t.margin.top,borderStyle:s,visible:d,dpi:W,zIndex:(p==null?void 0:p.border)??G.BORDER_OVERLAY,className:y}),f&&g&&r.jsxs(r.Fragment,{children:[e.cols.map((j,_)=>{if(_===0||_===e.cols.length-1)return null;const R=`col-${_}`;return r.jsx(ne,{direction:"column",index:_,position:j,marginLeftPx:t.margin.left,marginTopPx:t.margin.top,onResizeStart:L,onResize:D,onResizeEnd:k},R)}),e.rows.map((j,_)=>{if(_===0||_===e.rows.length-1)return null;const R=`row-${_}`;return r.jsx(ne,{direction:"row",index:_,position:j,marginLeftPx:t.margin.left,marginTopPx:t.margin.top,onResizeStart:L,onResize:D,onResizeEnd:k},R)})]}),v&&n&&r.jsxs(r.Fragment,{children:[n.cols.map((j,_)=>{const R=e.cols[_],T=e.cols[_+1];if(R===void 0||T===void 0)return null;const O=(w==null?void 0:w.direction)==="column"&&(w.index===_||w.index===_+1);let U;S&&S.direction==="column"&&(S.prevIndex===_?U=S.prevSize:S.nextIndex===_&&(U=S.nextSize));const F=(R+T)/2,b=T-R,M=`col-dim-${_}`;return r.jsx(ee,{direction:"column",index:_,dimension:j,position:F,currentPxSize:b,marginLeftPx:t.margin.left,marginTopPx:t.margin.top,isNearCursor:A||O,resizingPxSize:U,onDimensionChange:E},M)})," ",n.rows.map((j,_)=>{const R=e.rows[_],T=e.rows[_+1];if(R===void 0||T===void 0)return null;const O=(w==null?void 0:w.direction)==="row"&&(w.index===_||w.index===_+1),U=(R+T)/2,F=T-R,b=`row-dim-${_}`;return r.jsx(ee,{direction:"row",index:_,dimension:j,position:U,currentPxSize:F,marginLeftPx:t.margin.left,marginTopPx:t.margin.top,isNearCursor:A||O,onDimensionChange:E},b)})]}),x&&r.jsx("div",{style:{position:"absolute",left:x.direction==="column"?t.margin.left+x.position:t.margin.left,top:x.direction==="row"?t.margin.top+x.position:t.margin.top,width:x.direction==="column"?"2px":t.content.width,height:x.direction==="row"?"2px":t.content.height,backgroundColor:"#3b82f6",opacity:.5,pointerEvents:"none",zIndex:G.GRID_GHOST}})]})});class zo{constructor(){xe(this,"state",null);xe(this,"listeners",[])}start(e,n){this.state={kind:e,defaultSize:n},this.notify()}end(){this.state=null,this.notify()}get(){return this.state}subscribe(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(n=>n!==e)}}notify(){for(const e of this.listeners)e(this.state)}}const zt=new zo;function Ne(t,e,n,o){if(e<0||e>=t.length)return t;const s=[...t],i=s[e],a=s[e+1];return!i||!a?t:i.unit==="fr"&&a.unit==="fr"?Wo(s,e,n,o):i.unit!=="fr"&&a.unit!=="fr"?Yo(s,e,n):i.unit==="fr"&&a.unit!=="fr"?mn(s,e,n,"next",o):mn(s,e,n,"current",o)}function Wo(t,e,n,o){const s=t[e],i=t[e+1];if(!s||!i)return t;const a=t.reduce((E,y)=>y.unit==="fr"?E+y.value:E,0),l=o/a,c=s.value*l,m=i.value*l,d=Math.max(10,c+n),f=Math.max(10,m-n),v=d/l,g=f/l;return t[e]={...s,value:Math.round(v*100)/100},t[e+1]={...i,value:Math.round(g*100)/100},t}function Yo(t,e,n){const o=t[e],s=t[e+1];if(!o||!s)return t;const i=V.fromDim(o),a=V.fromDim(s),l=Math.max(10,i+n),c=Math.max(10,a-n);return t[e]={...o,value:re(l,o.unit)},t[e+1]={...s,value:re(c,s.unit)},t}function mn(t,e,n,o,s){const i=t[e],a=t[e+1];if(!i||!a)return t;let l=0,c=0;for(const f of t)f.unit==="fr"?l+=f.value:c+=V.fromDim(f);const m=s-c,d=l>0?m/l:0;if(o==="next"){const f=V.fromDim(a),v=Math.max(10,f-n);t[e+1]={...a,value:re(v,a.unit)};const g=v-f,E=m-g,y=i.value*d,p=Math.max(10,y+n),x=l>0?p/E*l:1;t[e]={...i,value:Math.round(x*100)/100}}else{const f=V.fromDim(i),v=Math.max(10,f+n);t[e]={...i,value:re(v,i.unit)};const g=v-f,E=m-g,y=a.value*d,p=Math.max(10,y-n),x=l>0?p/E*l:1;t[e+1]={...a,value:Math.round(x*100)/100}}return t}function re(t,e){switch(e){case"px":return Math.round(t);case"mm":{const n=Y.fromPx(t);return Math.round(n*10)/10}case"cm":{const n=Y.fromPx(t);return Math.round(n/10*100)/100}case"inch":{const n=Y.fromPx(t);return Math.round(n/25.4*100)/100}case"pt":{const n=Y.fromPx(t);return Math.round(n/25.4*72*10)/10}case"fr":return 1;default:{const n=e;throw new Error(`Unsupported unit: ${n}`)}}}function Vn(t){if(t.length===0)return[];const e=[];let n=0;for(const o of t){et(o,"Pixel value");const s=o+n,i=Math.round(s);e.push(i),n=s-i}return e}const Ho=8,Xo=32,qo=64,Ko=512,hn=(t,e,n)=>Math.min(Math.max(t,e),n);function Ie(t){const e=t.length-1,n=e>=1?t[e]??0:0,o=t.length>=1?n/e:0,s=hn(Math.ceil(Math.log2(e+1)),Ho,Xo),i=hn(o*2,qo,Ko);return{step:s,windowPx:i}}function te(t,e){const n=e.length-1;if(n<=0||e[0]===void 0||t<e[0]||e[n]===void 0)return-1;if(t>=e[n])return n-1;let o=1,s=n;for(;o<=s;){const i=o+s>>>1,a=e[i];if(a===void 0){s=i-1;continue}a<=t?o=i+1:s=i-1}return o-1}function De(t,e,n){const o=t.length-1;let s=0;return i=>{if(o<=0||t[0]===void 0||i<t[0]||t[o]===void 0)return-1;if(i>=t[o])return o-1;const a=t[s],l=t[s+1];if(a===void 0||l===void 0)return-1;if(a<=i&&i<l)return s;const c=a-n,m=l+n;if(i<c||i>=m)return s=te(i,t),s;let d=0;const f=t[s+1];if(f!==void 0&&i>=f)for(;s+1<o;){const v=t[s+1];if(v===void 0||i<v)break;if(s++,++d>e)return s=te(i,t),s}else for(;s>0;){const v=t[s];if(v===void 0||i>=v)break;if(s--,++d>e)return s=te(i,t),s}return s}}function oe(t,e){if(t.length===0)return[];et(e,"Content size");let n=0,o=0;const s=t.map(l=>{if(et(l.value,"Grid dimension value"),l.unit==="fr")return n+=l.value,null;{const c=Y.fromDim(l);return o+=c,c}});if(n===0)return Nn(o,0,e,"Total fixed size"),s;const i=e-o;et(i,"Content size - fixed sizes");const a=i/n;return s.map((l,c)=>{const m=t[c];if(l!=null)return l;if(!m)throw new Error(`dims[${c}] is undefined`);return m.value*a})}function se(t,e=96){ue(e,"DPI"),de(e,"DPI");const n=t.map(s=>V.fromMm(s,e));return Vn(n)}function Zo(t,e,n){if(t.length===0)return[];ue(n,"DPI"),de(n,"DPI"),et(e,"Content size");const o=oe(t,e);return se(o,n)}function ie(t){const e={};for(const[n,o]of Object.entries(t))if(o!=null)if(typeof o=="object"&&!Array.isArray(o)&&o!==null){const s=ie(o);e[n]=s}else e[n]=o;return e}function Jo(t,e){const o={A4:{width:210,height:297},A3:{width:297,height:420},B4:{width:257,height:364},B5:{width:182,height:257},Letter:{width:215.9,height:279.4},Legal:{width:215.9,height:355.6}}[t];return e==="landscape"?{width:o.height,height:o.width}:o}function Un(t){t!=null&&t.title&&(document.title=t.title),t!=null&&t.removeScrollbars&&(document.body.style.overflow="hidden")}function Fn(t){t!=null&&t.restoreScrollbars&&(document.body.style.overflow="")}function $e(t,e){var s,i;const n=document.title,o=document.createElement("style");o.id="tatamicks-print-style",o.textContent=`
22
+ <%s key={someKey} {...props} />`,z,q,ut,q),F[q+z]=!0)}if(q=null,P!==void 0&&(n(P),q=""+P),a(M)&&(n(M.key),q=""+M.key),"key"in M){P={};for(var bt in M)bt!=="key"&&(P[bt]=M[bt])}else P=M;return q&&l(P,typeof b=="function"?b.displayName||b.name||"Unknown":b),m(b,q,P,s(),ht,Ot)}function p(b){v(b)?b._store&&(b._store.validated=1):typeof b=="object"&&b!==null&&b.$$typeof===S&&(b._payload.status==="fulfilled"?v(b._payload.value)&&b._payload.value._store&&(b._payload.value._store.validated=1):b._store&&(b._store.validated=1))}function v(b){return typeof b=="object"&&b!==null&&b.$$typeof===E}var g=u,E=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),h=Symbol.for("react.profiler"),w=Symbol.for("react.consumer"),N=Symbol.for("react.context"),I=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),D=Symbol.for("react.suspense_list"),A=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),L=Symbol.for("react.activity"),$=Symbol.for("react.client.reference"),k=g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,C=Object.prototype.hasOwnProperty,j=Array.isArray,_=console.createTask?console.createTask:function(){return null};g={react_stack_bottom_frame:function(b){return b()}};var R,T={},O=g.react_stack_bottom_frame.bind(g,i)(),U=_(r(i)),F={};Bt.Fragment=f,Bt.jsx=function(b,M,P){var z=1e4>k.recentlyCreatedOwnerStacks++;return d(b,M,P,!1,z?Error("react-stack-top-frame"):O,z?_(r(b)):U)},Bt.jsxs=function(b,M,P){var z=1e4>k.recentlyCreatedOwnerStacks++;return d(b,M,P,!0,z?Error("react-stack-top-frame"):O,z?_(r(b)):U)}})()),Bt}var dn;function Er(){return dn||(dn=1,process.env.NODE_ENV==="production"?Zt.exports=_r():Zt.exports=yr()),Zt.exports}var o=Er(),Tt=(t=>(t.left="flex-start",t.center="center",t.right="flex-end",t))(Tt||{}),Rt=(t=>(t.top="flex-start",t.center="center",t.bottom="flex-end",t))(Rt||{});const jr="_container_1mr3i_5",Nr="_select_1mr3i_11",Ir="_placeholderOverlay_1mr3i_44",ve={container:jr,select:Nr,placeholderOverlay:Ir},wt=t=>{const{value:e,onChange:n,readOnly:r=!1,config:s}=t,i=t.options??(s==null?void 0:s.options)??[],a=t.placeholder??(s==null?void 0:s.placeholder)??"選択してください",l=t.width??(s==null?void 0:s.width),c=t.height??(s==null?void 0:s.height),m=u.useCallback(E=>{const y=E.target.value;if(y==="")n(void 0);else{const f=i.find(x=>String(x.value)===y);n(f?f.value:y)}},[n,i]),d=e??"",p=e!==void 0&&e!=="",v={};l!==void 0?v.width=`${l}px`:v.width="100%";const g={width:"100%",height:c?`${c}px`:void 0};return o.jsxs("div",{className:ve.container,style:v,children:[!p&&o.jsx("input",{className:ve.placeholderOverlay,style:g,readOnly:!0,placeholder:a}),o.jsx("select",{className:ve.select,style:g,value:d,onChange:m,disabled:r,children:i.map(E=>o.jsx("option",{value:String(E.value),children:E.label},String(E.value)))})]})};wt.displayName="Select";const pn={justifyContent:{defaultValue:Tt.left,label:"水平方向の配置",group:"配置",description:"ブロック内のコンテンツの水平方向の配置を設定します。",Component:wt,config:{options:[{label:"左揃え",value:Tt.left},{label:"中央揃え",value:Tt.center},{label:"右揃え",value:Tt.right}]}},alignItems:{defaultValue:Rt.center,label:"垂直方向の配置",group:"配置",description:"ブロック内のコンテンツの垂直方向の配置を設定します。",Component:wt,config:{options:[{label:"上揃え",value:Rt.top},{label:"中央揃え",value:Rt.center},{label:"下揃え",value:Rt.bottom}]}}},Dr="_container_1tnp6_5",$r="_input_1tnp6_13",Tr="_label_1tnp6_29",be={container:Dr,input:$r,label:Tr},xt=({value:t,onChange:e,readOnly:n=!1,label:r,config:s})=>{const i=r??(s==null?void 0:s.label),a=u.useCallback(l=>{e(l.target.checked)},[e]);return o.jsxs("label",{className:be.container,children:[o.jsx("input",{type:"checkbox",className:be.input,checked:!!t,onChange:a,disabled:n}),i&&o.jsx("span",{className:be.label,children:i})]})};xt.displayName="Checkbox";const Rr="_container_qbvob_5",Mr="_colorButton_qbvob_13",Cr="_textInputWrapper_qbvob_40",Pr="_textInputPrefix_qbvob_62",Ar="_textInput_qbvob_40",kr="_popover_qbvob_125",Lr="_palette_qbvob_141",Sr="_paletteButton_qbvob_148",Or="_selected_qbvob_171",Gr="_transparentPaletteButton_qbvob_177",Br="_rgbaInputs_qbvob_183",Vr="_rgbaInputGroup_qbvob_190",Ur="_rgbaLabel_qbvob_205",tt={container:Rr,colorButton:Mr,textInputWrapper:Cr,textInputPrefix:Pr,textInput:Ar,popover:kr,palette:Lr,paletteButton:Sr,selected:Or,transparentPaletteButton:Gr,rgbaInputs:Br,rgbaInputGroup:Vr,rgbaLabel:Ur};function Ee(t){if(!t)return null;const e=t.match(/^#([0-9a-f]{6}|[0-9a-f]{8})$/i);if(e&&typeof e[1]=="string"){const r=e[1],s=Number.parseInt(r.slice(0,2),16),i=Number.parseInt(r.slice(2,4),16),a=Number.parseInt(r.slice(4,6),16),l=r.length===8?Number.parseInt(r.slice(6,8),16)/255:1;return{r:s,g:i,b:a,a:l}}const n=t.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/);if(n){const r=Number.parseInt(n[1]??"",10),s=Number.parseInt(n[2]??"",10),i=Number.parseInt(n[3]??"",10),a=n[4]?Number.parseFloat(n[4]):1;return{r,g:s,b:i,a}}return null}function xn(t){const{r:e,g:n,b:r,a:s}=t;if(s===0)return;const i=e.toString(16).padStart(2,"0"),a=n.toString(16).padStart(2,"0"),l=r.toString(16).padStart(2,"0");if(s<1){const c=Math.round(s*255).toString(16).padStart(2,"0");return`#${i}${a}${l}${c}`}return`#${i}${a}${l}`}function Fr(t){const{r:e,g:n,b:r,a:s}=t;if(s!==0)return`rgba(${e}, ${n}, ${r}, ${s})`}function zr(t){return/^#([0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)}const vn=[{label:"無色",value:void 0},{label:"白",value:"#ffffff"},{label:"グレー1",value:"#efefef"},{label:"グレー2",value:"#d9d9d9"},{label:"グレー3",value:"#cccccc"},{label:"グレー4",value:"#b7b7b7"},{label:"グレー5",value:"#999999"},{label:"グレー6",value:"#666666"},{label:"グレー7",value:"#434343"},{label:"黒",value:"#000000"},{label:"薄茶",value:"#E6B8AF"},{label:"薄赤",value:"#F4CCCC"},{label:"薄橙",value:"#FCE5CD"},{label:"薄黄",value:"#FFF2CC"},{label:"薄緑",value:"#D9EAD3"},{label:"薄青緑",value:"#D0E0E3"},{label:"薄青",value:"#C9DAF8"},{label:"薄青紫",value:"#CFE2F3"},{label:"薄紫",value:"#D9D2E9"},{label:"薄赤紫",value:"#EAD1DC"},{label:"茶",value:"#DD7E6B"},{label:"赤",value:"#EA9999"},{label:"橙",value:"#F9CB9C"},{label:"黄",value:"#FFE599"},{label:"緑",value:"#B6D7A8"},{label:"青緑",value:"#A2C4C9"},{label:"青",value:"#A4C2F4"},{label:"青紫",value:"#9FC5E8"},{label:"紫",value:"#B4A7D6"},{label:"赤紫",value:"#D5A6BD"}],Ae=({onColorSelect:t,selectedColor:e,readOnly:n=!1})=>o.jsx("div",{className:tt.palette,children:vn.map((r,s)=>{const i=r.value===void 0,a=r.value===e,l=i?{}:{backgroundColor:r.value};return o.jsx("button",{type:"button",className:`${tt.paletteButton} ${i?tt.transparentPaletteButton:""} ${a?tt.selected:""}`,onClick:()=>t(r.value),disabled:n,title:r.label,"aria-label":r.label,style:l},r.value??`undefined-${s}`)})});Ae.displayName="ColorPalette";const Wr="_input_14n56_5",Yr={input:Wr},st=({value:t,onChange:e,readOnly:n=!1,min:r,max:s,step:i,integer:a,placeholder:l,width:c,height:m,config:d,onBlur:p})=>{const v=r??(d==null?void 0:d.min)??1,g=s??(d==null?void 0:d.max),E=i??(d==null?void 0:d.step)??1,y=a??(d==null?void 0:d.integer)??!1,f=l??(d==null?void 0:d.placeholder),x=c??(d==null?void 0:d.width),h=m??(d==null?void 0:d.height),w=u.useCallback(I=>{const B=I.target.value;if(B===""){e(void 0);return}let D=Number.parseFloat(B);Number.isNaN(D)||(y&&(D=Math.round(D)),v!==void 0&&D<v&&(D=v),g!==void 0&&D>g&&(D=g),e(D))},[e,v,g,y]),N={};return x!==void 0&&(N.width=`${x}px`),h!==void 0&&(N.height=`${h}px`,N.paddingTop=0,N.paddingBottom=0),o.jsx("input",{type:"number",className:Yr.input,style:N,value:t??"",onChange:w,onBlur:p,disabled:n,min:v,max:g,step:E,placeholder:f})};st.displayName="NumberInput";const ke=({rgba:t,onChange:e,readOnly:n=!1})=>o.jsxs("div",{className:tt.rgbaInputs,children:[o.jsxs("div",{className:tt.rgbaInputGroup,children:[o.jsx("span",{className:tt.rgbaLabel,children:"R"}),o.jsx(st,{value:t.r,onChange:r=>e("r",r),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),o.jsxs("div",{className:tt.rgbaInputGroup,children:[o.jsx("span",{className:tt.rgbaLabel,children:"G"}),o.jsx(st,{value:t.g,onChange:r=>e("g",r),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),o.jsxs("div",{className:tt.rgbaInputGroup,children:[o.jsx("span",{className:tt.rgbaLabel,children:"B"}),o.jsx(st,{value:t.b,onChange:r=>e("b",r),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),o.jsxs("div",{className:tt.rgbaInputGroup,children:[o.jsx("span",{className:tt.rgbaLabel,children:"A"}),o.jsx(st,{value:Math.round(t.a*100),onChange:r=>e("a",r!==void 0?r/100:void 0),min:0,max:100,step:1,integer:!0,width:48,readOnly:n})]})]});ke.displayName="RGBAInputs";const G={GRID_CANVAS:10,MARGIN_OVERLAY:20,GRID_OVERLAY:30,BORDER_OVERLAY:40,BLOCK_LAYER_MIN:100,BLOCK_LAYER_MAX:999999,BLOCK_LAYER_STEP:100,ERROR_BORDER:11e5,ERROR_TOOLTIP:12e5,ERROR_HIGHLIGHT:13e5,SELECT_BLOCK:2e6,INTERACTION_LAYER_BASE:21e5,BLOCK_GHOST:22e5,HOVER_OUTLINE:23e5,EDIT_BLOCK:24e5,BLOCK_SELECT_BORDER:25e5,BLOCK_HANDLES:26e5,GRID_GHOST:27e5,GRID_HANDLES:28e5,RUBBER_BAND:29e5,PROPERTY_PANEL:31e5,PALETTE:32e5,TOOLTIP:33e5,DROPDOWN:34e5,CONTEXT_MENU:35e5,MODAL:36e5,DEBUG:1e7},mt={BG:10,CONTENT:50,GUIDE:70,BORDER:80},Le=({isOpen:t,onClose:e,rgba:n,onRgbaChange:r,onColorSelect:s,selectedColor:i,readOnly:a=!1})=>{const l=u.useRef(null);return u.useEffect(()=>{if(!t)return;const c=m=>{l.current&&!l.current.contains(m.target)&&e()};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[t,e]),t?o.jsxs("div",{className:tt.popover,ref:l,style:{zIndex:G.DROPDOWN},children:[o.jsx(Ae,{onColorSelect:s,selectedColor:i,readOnly:a}),o.jsx(ke,{rgba:n,onChange:r,readOnly:a})]}):null};Le.displayName="ColorPickerPopover";const Wt=({value:t,onChange:e,readOnly:n=!1,showTextInput:r=!0,allowUndefined:s,placeholder:i,width:a,height:l,config:c})=>{const m=s??(c==null?void 0:c.allowUndefined)??!0,d=i??(m?"未設定":"#000000"),p=a??(c==null?void 0:c.width),v=l??(c==null?void 0:c.height),[g,E]=u.useState(!1),y=u.useRef(null),[f,x]=u.useState(()=>Ee(t)??{r:0,g:0,b:0,a:1});u.useEffect(()=>{const j=Ee(t);j&&x(j)},[t]);const h=u.useCallback(()=>{n||E(j=>!j)},[n]),[w,N]=u.useState(t?t.replace(/^#/,""):"");u.useEffect(()=>{N(t?t.replace(/^#/,""):"")},[t]);const I=u.useCallback(j=>{const _=j.target.value;/^[0-9A-Fa-f]*$/.test(_)&&N(_)},[]),B=u.useCallback(j=>{if(j===""&&m){e(void 0);return}/^[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$/.test(j)?e(`#${j}`):N(t?t.replace(/^#/,""):"")},[e,m,t]),D=u.useCallback(j=>{B(j.target.value)},[B]),A=u.useCallback(j=>{j.key==="Enter"&&(j.preventDefault(),B(j.currentTarget.value),j.currentTarget.blur())},[B]),S=u.useCallback(j=>{e(j)},[e]),L=u.useCallback((j,_)=>{if(_===void 0)return;const R={...f,[j]:_};x(R),e(xn(R))},[f,e]),$=t??"未設定",k={};t&&(k.background=t);const C={};return p!==void 0?C.width=`${p}px`:C.width="100%",v!==void 0&&(C.height=`${v}px`),o.jsxs("div",{className:tt.container,style:C,ref:y,children:[o.jsx("button",{type:"button",className:tt.colorButton,onClick:h,disabled:n,title:$,"aria-label":"カラーピッカーを開く",style:k}),r&&o.jsxs("div",{className:tt.textInputWrapper,children:[o.jsx("span",{className:tt.textInputPrefix,children:"#"}),o.jsx("input",{type:"text",className:tt.textInput,value:w,onChange:I,onKeyDown:A,onBlur:D,disabled:n,placeholder:d,maxLength:8})]}),o.jsx(Le,{isOpen:g,onClose:()=>E(!1),rgba:f,onRgbaChange:L,onColorSelect:S,selectedColor:t,readOnly:n})]})};Wt.displayName="ColorPicker";const Hr="_container_1n9lj_5",Xr="_valueInput_1n9lj_23",qr="_unitSelect_1n9lj_45",ge={container:Hr,valueInput:Xr,unitSelect:qr},rt=t=>{const{value:e,onChange:n,readOnly:r=!1,config:s}=t,i=t.allowedUnits??(s==null?void 0:s.allowedUnits),a=t.min??(s==null?void 0:s.min),l=t.max??(s==null?void 0:s.max),c=t.step??(s==null?void 0:s.step)??1,m=t.placeholder??(s==null?void 0:s.placeholder),d=t.width??(s==null?void 0:s.width),p=t.height??(s==null?void 0:s.height),v=(e==null?void 0:e.unit)??(i==null?void 0:i[0]),g=u.useCallback(w=>{const N=w.target.value;let I=Number.parseFloat(N);if(Number.isNaN(I))return;const B=a??1;I<B&&(I=B),l!==void 0&&I>l&&(I=l),n({value:I,unit:(e==null?void 0:e.unit)??v})},[e,n,v,a,l]),E=u.useCallback(w=>{const N=w.target.value;if(N==="")return;let I=Number.parseFloat(N);if(Number.isNaN(I))return;const B=a??1;I<B&&(I=B,n({value:I,unit:(e==null?void 0:e.unit)??v})),l!==void 0&&I>l&&(I=l,n({value:I,unit:(e==null?void 0:e.unit)??v}))},[e,n,v,a,l]),y=u.useCallback(w=>{const N=w.target.value;n({value:(e==null?void 0:e.value)??1,unit:N})},[e,n]),f=(e==null?void 0:e.value)??"",x=(e==null?void 0:e.unit)??v??"",h={};return d!==void 0?h.width=`${d}px`:h.width="100%",p!==void 0&&(h.height=`${p}px`),o.jsxs("div",{className:ge.container,style:h,children:[o.jsx("input",{type:"number",className:ge.valueInput,value:f,onChange:g,onBlur:E,placeholder:m,min:a??1,max:l,step:c,readOnly:r,disabled:r}),o.jsx("select",{className:ge.unitSelect,value:x,onChange:y,disabled:r||!i||i.length<=1,children:i?i.map(w=>o.jsx("option",{value:w,children:w},w)):o.jsx("option",{value:x,children:x})})]})},Kr="_container_1bfk3_6",Zr="_scrollArea_1bfk3_23",Jr="_emptyState_1bfk3_31",we={container:Kr,scrollArea:Zr,emptyState:Jr},Se=({children:t,emptyMessage:e,className:n})=>o.jsx("div",{className:`${we.container} ${n||""}`,children:t?o.jsx("div",{className:we.scrollArea,children:t}):e&&o.jsx("div",{className:we.emptyState,children:e})}),Qr="_root_qs6t8_3",to="_list_qs6t8_11",eo="_trigger_qs6t8_26",no="_content_qs6t8_71",le={root:Qr,list:to,trigger:eo,content:no},ce=u.createContext(void 0),Oe=({defaultValue:t,value:e,onValueChange:n,children:r,variant:s="default",className:i=""})=>{const[a,l]=u.useState(t),c=e??a,m=d=>{l(d),n==null||n(d)};return o.jsx(ce.Provider,{value:{value:c,onChange:m,variant:s},children:o.jsx("div",{className:`${le.root} ${i}`,"data-variant":s,children:r})})},Ge=({children:t,className:e="",width:n,height:r,style:s})=>{const i=u.useContext(ce);if(!i)throw new Error("TabsList must be used within a Tabs component");const{variant:a}=i,l={...s};return n!==void 0&&(l.width=`${n}px`),r!==void 0&&(l.height=`${r}px`),o.jsx("div",{className:`${le.list} ${e}`,"data-variant":a,style:l,children:t})},yt=({value:t,children:e,className:n="",disabled:r=!1,width:s,height:i,style:a})=>{const l=u.useContext(ce);if(!l)throw new Error("TabsTrigger must be used within a Tabs component");const{value:c,onChange:m,variant:d}=l,p=c===t,v={...a};return s!==void 0&&(v.width=`${s}px`),i!==void 0&&(v.height=`${i}px`),o.jsx("button",{className:`${le.trigger} ${n}`,"data-state":p?"active":"inactive","data-variant":d,onClick:()=>m(t),disabled:r,type:"button",style:v,children:e})},Et=({value:t,children:e,className:n=""})=>{const r=u.useContext(ce);if(!r)throw new Error("TabsContent must be used within a Tabs component");const{value:s}=r;return s!==t?null:o.jsx("div",{className:`${le.content} ${n}`,children:e})},ro="_input_9unrj_5",oo={input:ro},At=({value:t,onChange:e,readOnly:n=!1,placeholder:r,maxLength:s,multiline:i,rows:a,width:l,height:c,config:m,onBlur:d})=>{const p=r??(m==null?void 0:m.placeholder),v=s??(m==null?void 0:m.maxLength),g=i??(m==null?void 0:m.multiline)??!1,E=a??(m==null?void 0:m.rows)??3,y=u.useCallback(h=>{const w=h.target.value;e(w)},[e]),f={};l!==void 0?f.width=`${l}px`:f.width="100%",c!==void 0&&(f.height=`${c}px`);const x={className:oo.input,style:f,value:t??"",onChange:y,disabled:n,placeholder:p,maxLength:v};return g?o.jsx("textarea",{...x,rows:E}):o.jsx("input",{...x,type:"text",onBlur:d})};At.displayName="TextInput";const so=["mm","cm","fr","inch","pt","px","%"],io=["mm","cm","pt","inch","px"],ao=["mm","cm","inch"],lo=["mm","cm","fr","inch","pt","px"],bn=["px","pt","mm"],gn=["px","pt","mm"],$t=["mm","pt","px","%"],je=["mm","cm","inch","pt","px","%"],wn={isIndividual:{defaultValue:!1,label:"個別に設定",group:"余白",Component:xt,description:"上下左右の余白を個別に設定します"},all:{defaultValue:{value:0,unit:"px"},label:"全方向",group:"余白",Component:rt,config:{allowedUnits:$t,min:0},condition:t=>!t.isIndividual},top:{defaultValue:{value:0,unit:"px"},label:"上",group:"余白",Component:rt,config:{allowedUnits:$t,min:0},condition:t=>t.isIndividual===!0},right:{defaultValue:{value:0,unit:"px"},label:"右",group:"余白",Component:rt,config:{allowedUnits:$t,min:0},condition:t=>t.isIndividual===!0},bottom:{defaultValue:{value:0,unit:"px"},label:"下",group:"余白",Component:rt,config:{allowedUnits:$t,min:0},condition:t=>t.isIndividual===!0},left:{defaultValue:{value:0,unit:"px"},label:"左",group:"余白",Component:rt,config:{allowedUnits:$t,min:0},condition:t=>t.isIndividual===!0}},co={...pn,...wn},_n=[{label:"ゴシック体",value:"sans-serif"},{label:"明朝体",value:"serif"},{label:"等幅",value:"monospace"},{label:"Arial",value:"Arial, sans-serif"},{label:"Times New Roman",value:"'Times New Roman', serif"}],uo={fontSize:{defaultValue:{value:14,unit:"pt"},label:"フォントサイズ",group:"フォント",description:"テキストのフォントサイズを設定します",Component:rt,config:{allowedUnits:gn,min:1,step:1}},fontFamily:{defaultValue:"sans-serif",label:"フォント",group:"フォント",Component:wt,config:{placeholder:"フォントを選択",options:_n}},color:{defaultValue:void 0,label:"文字色",group:"フォント",Component:Wt,config:{allowUndefined:!0}},fontWeight:{defaultValue:!1,label:"太字",group:"フォント",description:"テキストを太字にします",Component:xt},italic:{defaultValue:!1,label:"斜体",group:"フォント",description:"テキストを斜体にします",Component:xt},underline:{defaultValue:!1,label:"下線",group:"フォント",description:"テキストに下線を引きます",Component:xt},lineThrough:{defaultValue:!1,label:"取り消し線",group:"フォント",description:"テキストに取り消し線を引きます",Component:xt},lineHeight:{defaultValue:1.2,label:"行の高さ",group:"フォント",description:"行の高さを設定します(1.0〜3.0)",Component:st,config:{min:1,max:3,step:.1}}};function mo(t){return t.reduce((e,n)=>(e[n.kind]=n,e),{})}var jt=(t=>(t.Contain="contain",t.Cover="cover",t.Fill="fill",t.None="none",t.ScaleDown="scale-down",t))(jt||{});const ho={objectFit:{defaultValue:jt.Contain,label:"表示方法",group:"画像",description:"画像のサイズが枠と合わない場合の表示方法を設定します",Component:wt,config:{options:[{label:"全体を表示",value:jt.Contain},{label:"枠を埋める/切り抜き",value:jt.Cover},{label:"引き伸ばす/縮小する",value:jt.Fill},{label:"元のサイズ",value:jt.None},{label:"縮小のみ",value:jt.ScaleDown}]}},alt:{defaultValue:"",label:"代替テキスト",group:"画像",description:"画像が表示できない場合に表示されるテキスト",Component:At,config:{placeholder:"画像の説明"}}};var Mt=(t=>(t.Normal="normal",t.BreakWord="break-word",t.BreakAll="break-all",t))(Mt||{}),Ct=(t=>(t.Normal="normal",t.NoWrap="nowrap",t.Pre="pre",t.PreWrap="pre-wrap",t.PreLine="pre-line",t))(Ct||{});const fo={multiline:{defaultValue:!1,label:"複数行モード",group:"設定",Component:xt,config:{label:"有効にする"}},wordWrap:{defaultValue:Mt.Normal,label:"単語の折り返し",group:"設定",Component:wt,config:{options:[{label:"通常",value:Mt.Normal},{label:"単語で改行",value:Mt.BreakWord},{label:"強制改行",value:Mt.BreakAll}]},condition:t=>t.multiline===!0},whiteSpace:{defaultValue:Ct.Normal,label:"空白文字の扱い",group:"設定",Component:wt,config:{options:[{label:"通常",value:Ct.Normal},{label:"折り返しなし",value:Ct.NoWrap},{label:"そのまま表示",value:Ct.Pre}]},condition:t=>t.multiline===!0}},po={placeholder:{defaultValue:void 0,label:"プレースホルダー",group:"設定",description:"入力欄に表示するプレースホルダーテキストを設定します",Component:At,config:{placeholder:"例: テキストを入力してください"}}},xo={width:{defaultValue:void 0,label:"幅",group:"サイズ",description:"要素の幅を設定します",Component:rt,config:{min:0,allowedUnits:je,placeholder:"auto"}},height:{defaultValue:void 0,label:"高さ",group:"サイズ",description:"要素の高さを設定します",Component:rt,config:{min:0,allowedUnits:je,placeholder:"auto"}}},yn=t=>{const e={};return Object.entries(t.properties).forEach(([n,r])=>{r!==!1&&typeof r=="object"&&r!==null&&"defaultValue"in r&&(e[n]=r.defaultValue)}),e};function En(t){const e=Date.now(),n=Math.random().toString(36).slice(2);return`${t}_${e}_${n}`}function Nt(t,e,n){const r=yn(t);return{id:En(t.kind),kind:t.kind,layout:{x:e.x,y:e.y,w:e.w,h:e.h},style:{},behavior:{},props:{...r,...n}}}const vo={required:{defaultValue:!1,label:"必須項目",group:"バリデーション",description:"この項目を必須入力にします",Component:xt,config:{label:"必須にする"}},minLength:{defaultValue:void 0,label:"最小文字数",group:"バリデーション",description:"入力可能な最小文字数を設定します",Component:st,config:{min:0,integer:!0,placeholder:"制限なし"}},maxLength:{defaultValue:void 0,label:"最大文字数",group:"バリデーション",description:"入力可能な最大文字数を設定します",Component:st,config:{min:0,integer:!0,placeholder:"制限なし"}},pattern:{defaultValue:void 0,label:"入力パターン (正規表現)",group:"バリデーション",description:"入力値を検証する正規表現パターンを設定します",Component:At,config:{placeholder:"例: ^[0-9]+$"},disableInMultiSelection:!0}};var ct=(t=>(t.ADD="add",t.UPDATE="update",t.DELETE="delete",t.MOVE="move",t.RESIZE="resize",t.DUPLICATE="duplicate",t.PASTE="paste",t))(ct||{});const jn={cols:Array.from({length:12}).map(()=>({value:1,unit:"fr"})),rows:Array.from({length:16}).map(()=>({value:1,unit:"fr"}))};var dt=(t=>(t.SOLID="solid",t.DASHED="dashed",t.DOTTED="dotted",t))(dt||{});const W=96;function ue(t,e){if(t<=0){const n=e??"Value";throw new Error(`${n} must be positive (> 0): got ${t}`)}}function et(t,e){if(t<0){const n=e??"Value";throw new Error(`${n} must be non-negative (>= 0): got ${t}`)}}function Nn(t,e,n,r){if(t<e||t>n){const s=r??"Value";throw new Error(`${s} must be between ${e} and ${n}: got ${t}`)}}function de(t,e){if(!Number.isInteger(t)){const n=e??"Value";throw new Error(`${n} must be an integer: got ${t}`)}}function bo(t,e){if(!Number.isFinite(t)){const n=e??"Value";throw new Error(`${n} must be a finite number: got ${t}`)}}const go=25.4,wo=2.54,_o=72,V={_assertDpi(t){ue(t,"DPI"),de(t,"DPI")},fromMm(t,e=W){return V._assertDpi(e),et(t,"Millimeter value"),t*e/go},fromCm(t,e=W){return V._assertDpi(e),et(t,"Centimeter value"),t*e/wo},fromInch(t,e=W){return V._assertDpi(e),et(t,"Inch value"),t*e},fromPt(t,e=W){return V._assertDpi(e),et(t,"Point value"),t*e/_o},fromPx(t,e=W){return V._assertDpi(e),et(t,"Pixel value"),t*e/W},fromDim(t,e=W,n){switch(V._assertDpi(e),et(t.value,"Dimension value"),t.unit){case"mm":return V.fromMm(t.value,e);case"cm":return V.fromCm(t.value,e);case"inch":return V.fromInch(t.value,e);case"pt":return V.fromPt(t.value,e);case"px":return V.fromPx(t.value,e);case"%":if(n===void 0)throw new Error("Base size must be defined for percentage values.");return t.value/100*n;case"fr":throw new Error(`Cannot convert ${t.unit} to px. Use physical units only.`);default:{const r=t.unit;throw new Error(`Unsupported unit: ${r}`)}}}},Pt=t=>{if(!(t!=null&&t.width)||!(t!=null&&t.type))return;const e=t.width.value;if(e!==0){if(t.type===dt.DASHED)return`${e*4} ${e*2}`;if(t.type===dt.DOTTED)return`${e*1} ${e*2}`}};class kt{constructor(e){this.style=e}get top(){return this.style.top?{...this.style.all,...this.style.top}:this.style.all}get right(){return this.style.right?{...this.style.all,...this.style.right}:this.style.all}get bottom(){return this.style.bottom?{...this.style.all,...this.style.bottom}:this.style.all}get left(){return this.style.left?{...this.style.all,...this.style.left}:this.style.all}get hasAnyBorder(){return!!(this.top||this.right||this.bottom||this.left)}getTopSVGProps(e,n=W){const r=this.top;return r?{x1:0,y1:0,x2:e,y2:0,stroke:r.color,strokeWidth:V.fromDim(r.width,n),strokeDasharray:Pt(r),vectorEffect:"non-scaling-stroke","data-edge":"top"}:null}getRightSVGProps(e,n,r=W){const s=this.right;return s?{x1:e,y1:0,x2:e,y2:n,stroke:s.color,strokeWidth:V.fromDim(s.width,r),strokeDasharray:Pt(s),vectorEffect:"non-scaling-stroke","data-edge":"right"}:null}getBottomSVGProps(e,n,r=W){const s=this.bottom;return s?{x1:0,y1:n,x2:e,y2:n,stroke:s.color,strokeWidth:V.fromDim(s.width,r),strokeDasharray:Pt(s),vectorEffect:"non-scaling-stroke","data-edge":"bottom"}:null}getLeftSVGProps(e,n=W){const r=this.left;return r?{x1:0,y1:0,x2:0,y2:e,stroke:r.color,strokeWidth:V.fromDim(r.width,n),strokeDasharray:Pt(r),vectorEffect:"non-scaling-stroke","data-edge":"left"}:null}}var it=(t=>(t.FORM="Form",t.EDIT="Edit",t.VIEW="View",t))(it||{}),pt=(t=>(t.A4="A4",t.B5="B5",t.A3="A3",t.LETTER="Letter",t.LEGAL="Legal",t.CUSTOM="Custom",t))(pt||{});const Be={A4:{preset:"A4",width:{value:210,unit:"mm"},height:{value:297,unit:"mm"}},A3:{preset:"A3",width:{value:297,unit:"mm"},height:{value:420,unit:"mm"}},B5:{preset:"B5",width:{value:182,unit:"mm"},height:{value:257,unit:"mm"}},Letter:{preset:"Letter",width:{value:8.5,unit:"inch"},height:{value:11,unit:"inch"}},Legal:{preset:"Legal",width:{value:8.5,unit:"inch"},height:{value:14,unit:"inch"}},Custom:{preset:"Custom",width:{value:210,unit:"mm"},height:{value:297,unit:"mm"}}},In={top:{value:10,unit:"mm"},right:{value:10,unit:"mm"},bottom:{value:10,unit:"mm"},left:{value:10,unit:"mm"}},Dn={size:Be.A4,margin:In},yo={paper:Dn,grid:jn,blocks:[]};var $n=(t=>(t.ERROR="error",t.WARNING="warning",t.INFO="info",t))($n||{});const It=u.memo(({width:t,height:e,border:n,dpi:r=W,className:s=""})=>n.hasAnyBorder?o.jsxs("svg",{width:t,height:e,xmlns:"http://www.w3.org/2000/svg",className:s,style:{overflow:"visible"},children:[o.jsx("title",{children:"border SVG"}),n.top&&o.jsx("line",{...n.getTopSVGProps(t,r)}),n.right&&o.jsx("line",{...n.getRightSVGProps(t,e,r)}),n.bottom&&o.jsx("line",{...n.getBottomSVGProps(t,e,r)}),n.left&&o.jsx("line",{...n.getLeftSVGProps(e,r)})]}):null);It.displayName="BorderRenderer";function Tn(t){const e=G.BLOCK_LAYER_MIN+t*G.BLOCK_LAYER_STEP;return e>=G.BLOCK_LAYER_MAX?G.BLOCK_LAYER_MAX:e}function Yt(t,e){const n=Math.min(Math.max(0,e),G.BLOCK_LAYER_STEP-1);return t+n}function Eo(){return Math.floor((G.BLOCK_LAYER_MAX-G.BLOCK_LAYER_MIN)/G.BLOCK_LAYER_STEP)}const Rn=u.memo(({blockSizePx:t,borderStyle:e,blockZIndex:n,subZIndex:r=mt.BORDER,visible:s=!0,dpi:i=W,className:a=""})=>{const l=u.useMemo(()=>{if(e)return new kt(e)},[e]);if(!s||!l||!l.hasAnyBorder)return null;const c=Yt(n,r),m={position:"absolute",left:0,top:0,width:`${t.width}px`,height:`${t.height}px`,pointerEvents:"none",overflow:"visible",zIndex:c};return o.jsx("div",{className:a,style:m,"data-testid":"block-border",children:o.jsx(It,{width:t.width,height:t.height,border:l,dpi:i})})}),Mn=u.memo(({blockSizePx:t,blockZIndex:e,subZIndex:n=mt.BG,backgroundColor:r="transparent",className:s=""})=>{const i=Yt(e,n),a={position:"absolute",inset:0,width:`${t.width}px`,height:`${t.height}px`,backgroundColor:r,pointerEvents:"none",zIndex:i};return o.jsx("div",{className:s,style:a,role:"presentation","aria-label":"Block background","data-testid":"block-canvas"})}),Cn={color:"#cccccc",width:{value:1,unit:"pt"},type:dt.SOLID},me={all:Cn},Pn=u.memo(({blockSizePx:t,blockZIndex:e,subZIndex:n=mt.GUIDE,borderStyle:r=me,visible:s=!0,dpi:i=W,className:a=""})=>{const l=u.useMemo(()=>{if(r)return new kt(r)},[r]);if(!s||!l||!l.hasAnyBorder)return null;const c=Yt(e,n),m={position:"absolute",left:0,top:0,width:`${t.width}px`,height:`${t.height}px`,pointerEvents:"none",overflow:"visible",zIndex:c};return o.jsx("div",{className:a,style:m,"data-testid":"block-base-border",children:o.jsx(It,{width:t.width,height:t.height,border:l,dpi:i})})}),jo=({id:t,plugin:e,props:n,value:r,onChange:s,onBlur:i,readOnly:a,mode:l,blockSizePx:c,blockZIndex:m,subZIndex:d=mt.CONTENT,validationState:p,className:v=""},g)=>{const E=u.useRef(null);u.useImperativeHandle(g,()=>({focus:()=>{var w;return(w=E.current)==null?void 0:w.focus()}}),[]);const y=Yt(m,d),f={position:"absolute",inset:0,width:`${c.width}px`,height:`${c.height}px`,zIndex:y,pointerEvents:"auto"},x={id:t,props:n,value:r,onChange:s??(()=>{}),onBlur:i,readOnly:a,mode:l,dimensions:{widthPx:c.width,heightPx:c.height},validationState:p},h=e.Renderer;return o.jsx("div",{className:v,style:f,"data-testid":"block-renderer","data-block-id":t,"data-plugin-kind":e.kind,children:o.jsx(h,{ref:E,...x})})},No=u.forwardRef(jo),Ht=u.memo(No);function Ve(t,e){return{position:"absolute",left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,zIndex:e==null?void 0:e.zIndex,pointerEvents:(e==null?void 0:e.pointerEvents)??"auto"}}const Ue=u.memo(u.forwardRef(({block:t,plugin:e,blockRectPx:n,blockZIndex:r,mode:s,value:i,onValueChange:a,onValueBlur:l,showGuides:c=!0,showBorder:m=!0,blockSubZIndex:d={bg:mt.BG,guide:mt.GUIDE,content:mt.CONTENT,border:mt.BORDER},defaultGuideBorder:p=me,dpi:v=W,className:g="",pointerEvents:E="none"},y)=>{var h,w,N,I;const f=Ve(n,{zIndex:r,pointerEvents:E}),x=u.useMemo(()=>({width:n.width,height:n.height}),[n.width,n.height]);return o.jsxs("div",{style:f,"data-block-id":t.id,className:g,children:[o.jsx(Mn,{blockSizePx:x,blockZIndex:r,backgroundColor:(h=t.style)==null?void 0:h.backgroundColor,subZIndex:d.bg}),c&&!((w=t.style)!=null&&w.border)&&o.jsx(Pn,{blockSizePx:x,blockZIndex:r,subZIndex:d.guide,borderStyle:p,dpi:v}),o.jsx(Ht,{id:t.id,ref:y,plugin:e,props:t.props,value:i,onChange:a,onBlur:l,readOnly:s===it.EDIT?((N=t.behavior)==null?void 0:N.readOnly)??!1:!0,mode:s,blockSizePx:x,blockZIndex:r,subZIndex:d.content}),o.jsx(Rn,{blockSizePx:x,blockZIndex:r,borderStyle:(I=t.style)==null?void 0:I.border,subZIndex:d.border,visible:m,dpi:v})]})}));Ue.displayName="BlockContainer";const Lt=u.memo(({blocks:t,pluginRegistry:e,mode:n,values:r,selectedBlockIds:s=[],getBlockRectPx:i,onValueChange:a,onValueBlur:l,showGuides:c=!0,showBorder:m=!0,blockSubZIndex:d={bg:mt.BG,guide:mt.GUIDE,content:mt.CONTENT,border:mt.BORDER},defaultGuideBorder:p=me,dpi:v=W,className:g=""})=>{const E=u.useRef(new Map),y={position:"absolute",inset:0,pointerEvents:"none"};return o.jsx("div",{className:g,style:y,"data-testid":"block-layer",children:t.map((f,x)=>{const h=e[f.kind];if(!h)return null;const w=i(f),N=s.includes(f.id);let I=Tn(x);N&&(I=G.SELECT_BLOCK);const B=r[f.id]??f.initValue;return o.jsx(Ue,{ref:D=>{D?E.current.set(f.id,D):E.current.delete(f.id)},block:f,plugin:h,blockRectPx:w,blockZIndex:I,mode:n,value:B,onValueChange:a?D=>a(f.id,D):void 0,onValueBlur:D=>l==null?void 0:l(f.id,D),showGuides:c,showBorder:m,blockSubZIndex:d,defaultGuideBorder:p,dpi:v,pointerEvents:"none"},f.id)})})});Lt.displayName="BlockLayer";const An=u.memo(({contentPx:t,marginLeftPx:e,marginTopPx:n,borderStyle:r,visible:s=!0,dpi:i=W,zIndex:a=G.BORDER_OVERLAY,className:l=""})=>{const c=u.useMemo(()=>{if(r)return new kt(r)},[r]);if(!s||!c||!c.hasAnyBorder)return null;const m={position:"absolute",left:`${e}px`,top:`${n}px`,width:`${t.width}px`,height:`${t.height}px`,pointerEvents:"none",overflow:"visible",zIndex:a};return o.jsx("div",{className:l,style:m,"data-testid":"border-overlay",children:o.jsx(It,{width:t.width,height:t.height,border:c,dpi:i})})}),kn=u.memo(({canvasPx:t,backgroundColor:e="#ffffff",boxShadow:n="0 2px 8px rgba(0, 0, 0, 0.1)",zIndex:r=G.GRID_CANVAS,className:s})=>{const i={position:"absolute",inset:0,width:`${t.width}px`,height:`${t.height}px`,backgroundColor:e,boxShadow:n,pointerEvents:"none",zIndex:r};return o.jsx("div",{className:s,style:i,role:"presentation","aria-label":"Paper background","data-testid":"grid-canvas"})}),Io="_label_vgaic_1",Do={label:Io},$o="_editor_6szgo_5",To="_input_6szgo_18",Ro="_select_6szgo_38",Mo="_button_6szgo_54",Jt={editor:$o,input:To,select:Ro,button:Mo};function Ln(t,e){const n=t.match(/^(\d+(?:\.\d+)?)([a-zA-Z%]+)$/);if(!n)throw new Error(`Invalid dimension string: ${t}`);const r=Number(n[1]),s=n[2];if(et(r,"Dimension value"),!e.includes(s))throw new Error(`Unit not allowed: ${s}`);return{value:r,unit:s}}function Co(t,e){return t.map(n=>Ln(n,e))}const Po=10,Ao=25.4,ko=.352778,Lo=.264583,Y={fromCm(t){return et(t,"Centimeter value"),t*Po},fromInch(t){return et(t,"Inch value"),t*Ao},fromPt(t){return et(t,"Point value"),t*ko},fromPx(t){return et(t,"Pixel value"),t*Lo},fromDim(t){switch(et(t.value,"Dimension value"),t.unit){case"mm":return t.value;case"cm":return Y.fromCm(t.value);case"inch":return Y.fromInch(t.value);case"pt":return Y.fromPt(t.value);case"px":return Y.fromPx(t.value);case"fr":case"%":throw new Error(`Cannot convert ${t.unit} to mm. Use physical units only.`);default:{const e=t.unit;throw new Error(`Unsupported unit: ${e}`)}}}};function Sn(t){return et(t.value,"Dimension"),`${t.value}${t.unit}`}function So(t){return t.map(Sn)}const Oo=["fr","px","mm","cm","pt","inch"];function Go(t,e){if(e==="fr")return 1;switch(e){case"px":return t;case"mm":{const n=Y.fromPx(t);return Math.round(n*10)/10}case"cm":{const r=Y.fromPx(t)/10;return Math.round(r*100)/100}case"inch":{const r=Y.fromPx(t)/25.4;return Math.round(r*100)/100}case"pt":{const s=Y.fromPx(t)/25.4*72;return Math.round(s*10)/10}default:{const n=e;throw new Error(`Unsupported unit: ${n}`)}}}const On=u.memo(({direction:t,dimension:e,currentPxSize:n,position:r,marginLeftPx:s,marginTopPx:i,onChange:a,onCancel:l})=>{const[c,m]=u.useState(e.value.toString()),[d,p]=u.useState(e.unit),v=u.useRef(null),g=u.useRef(null),E=t==="column"?{left:`${s+r}px`,top:`${i+24}px`,transform:"translateX(-50%)"}:{left:`${s+24}px`,top:`${i+r}px`,transform:"translateY(-50%)"};u.useEffect(()=>{var h,w;(h=v.current)==null||h.focus(),(w=v.current)==null||w.select()},[]),u.useEffect(()=>{const h=w=>{g.current&&!g.current.contains(w.target)&&l()};return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h)}},[l]);const y=()=>{const h=Number.parseFloat(c);!Number.isNaN(h)&&h>=.1?a({unit:d,value:h}):l()},f=h=>{h.key==="Enter"?(h.preventDefault(),y()):h.key==="Escape"&&(h.preventDefault(),l())},x=h=>{const w=h.target.value;p(w);const N=Go(n,w);m(N.toString())};return o.jsxs("div",{ref:g,className:Jt.editor,style:E,"data-testid":`grid-unit-editor-${t}`,children:[o.jsx("input",{ref:v,type:"number",className:Jt.input,value:c,onChange:h=>m(h.target.value),onKeyDown:f,min:"0.1",step:d==="fr"?"0.1":"1"}),o.jsx("select",{className:Jt.select,value:d,onChange:x,children:Oo.map(h=>o.jsx("option",{value:h,children:h},h))}),o.jsx("button",{type:"button",className:Jt.button,onClick:y,title:"確定",children:"✓"})]})});On.displayName="GridUnitEditor";function Bo(t,e,n,r){if(e==="fr"){if(n!==void 0&&r!==void 0&&r>0){const s=t/r;return Math.round(n*s*100)/100}return 1}switch(e){case"px":return Math.round(t);case"mm":{const s=Y.fromPx(t);return Math.round(s*10)/10}case"cm":{const s=Y.fromPx(t);return Math.round(s/10*100)/100}case"inch":{const s=Y.fromPx(t);return Math.round(s/25.4*100)/100}case"pt":{const s=Y.fromPx(t);return Math.round(s/25.4*72*10)/10}default:{const s=e;throw new Error(`Unsupported unit: ${s}`)}}}const ee=u.memo(({direction:t,index:e,dimension:n,position:r,currentPxSize:s,marginLeftPx:i,marginTopPx:a,isNearCursor:l,resizingPxSize:c,onDimensionChange:m})=>{const[d,p]=u.useState(!1);if(!l&&!d)return null;const v=t==="column"?{left:`${i+r}px`,top:`${a-20}px`,transform:"translateX(-50%)"}:{left:`${i-20}px`,top:`${a+r}px`,transform:"translateY(-50%)",writingMode:"vertical-rl"},g=()=>{p(!0)},E=h=>{m==null||m(t,e,h),p(!1)},y=()=>{p(!1)},x=c?(()=>{const h=Bo(c,n.unit,n.value,s);return n.unit==="fr"?`${h}fr`:`${h}${n.unit}`})():(h=>h.unit==="fr"?`${h.value}fr`:`${h.value}${h.unit}`)(n);return o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:Do.label,style:v,onDoubleClick:g,"data-testid":`grid-dimension-${t}-${e}`,"aria-label":`グリッド寸法: ${x}`,children:x})," ",d&&o.jsx(On,{direction:t,dimension:n,currentPxSize:s,position:r,marginLeftPx:i,marginTopPx:a,onChange:E,onCancel:y})]})});ee.displayName="GridDimensionLabel";function Vo(t,e,n,r){let s="";for(const i of t)s+=`M ${i} 0 L ${i} ${r} `;for(const i of e)s+=`M 0 ${i} L ${n} ${i} `;return s}const Gn=u.memo(({gridPosPx:t,contentPx:e,marginLeftPx:n,marginTopPx:r,lineStyle:s,visible:i=!0,zIndex:a=G.GRID_OVERLAY,dpi:l=W,className:c=""})=>{const m=u.useMemo(()=>Vo(t.cols.slice(1,-1),t.rows.slice(1,-1),e.width,e.height),[t,e]);if(!i||!s)return null;const d=Pt(s),p=V.fromDim(s.width,l),v={position:"absolute",left:`${n}px`,top:`${r}px`,pointerEvents:"none",zIndex:a};return o.jsx("svg",{className:c,style:v,width:e.width,height:e.height,xmlns:"http://www.w3.org/2000/svg",role:"img","aria-label":"Grid overlay lines",children:o.jsx("path",{d:m,stroke:s.color,strokeWidth:p,strokeDasharray:d,fill:"none"})})}),Uo="_handle_1mgtx_1",Fo="_dragging_1mgtx_19",_e={handle:Uo,dragging:Fo},ne=u.memo(({direction:t,index:e,position:n,marginLeftPx:r,marginTopPx:s,onResizeStart:i,onResize:a,onResizeEnd:l})=>{const[c,m]=u.useState(!1),d=12,p=d/2,v=t==="column"?{left:`${r+n-p}px`,top:`${s-p}px`,width:`${d}px`,height:`${d}px`,cursor:"col-resize"}:{left:`${r-p}px`,top:`${s+n-p}px`,width:`${d}px`,height:`${d}px`,cursor:"row-resize"},g=u.useCallback(E=>{E.stopPropagation(),E.preventDefault();const y=t==="column"?E.clientX:E.clientY;m(!0),i==null||i(t,e);const f=h=>{const N=(t==="column"?h.clientX:h.clientY)-y;a==null||a(t,e,N)},x=h=>{const N=(t==="column"?h.clientX:h.clientY)-y;m(!1),l==null||l(t,e,N),window.removeEventListener("pointermove",f),window.removeEventListener("pointerup",x)};window.addEventListener("pointermove",f),window.addEventListener("pointerup",x)},[t,e,i,a,l]);return o.jsx("div",{className:`${_e.handle} ${_e[t]} ${c?_e.dragging:""}`,style:v,onPointerDown:g,"data-testid":`grid-resize-handle-${t}-${e}`})});ne.displayName="GridResizeHandle";const Bn=u.memo(({paperPx:t,visible:e=!0,marginColor:n,zIndex:r=G.MARGIN_OVERLAY,className:s=""})=>{if(!e)return null;const i={position:"absolute",inset:0,pointerEvents:"none",width:`${t.canvas.width}px`,height:`${t.canvas.height}px`,zIndex:r},a={position:"absolute",backgroundColor:n||"rgba(0, 0, 0, 0.05)",pointerEvents:"none"};return o.jsxs("div",{className:s,style:i,role:"presentation","aria-label":"Printable area margin","data-testid":"margin-overlay",children:[t.margin.top>0&&o.jsx("div",{"data-testid":"margin-top",style:{...a,top:0,left:0,width:"100%",height:`${t.margin.top}px`}}),t.margin.bottom>0&&o.jsx("div",{"data-testid":"margin-bottom",style:{...a,bottom:0,left:0,width:"100%",height:`${t.margin.bottom}px`}}),t.margin.left>0&&o.jsx("div",{"data-testid":"margin-left",style:{...a,left:0,top:`${t.margin.top}px`,height:`${t.content.height}px`,width:`${t.margin.left}px`}}),t.margin.right>0&&o.jsx("div",{"data-testid":"margin-right",style:{...a,right:0,top:`${t.margin.top}px`,height:`${t.content.height}px`,width:`${t.margin.right}px`}})]})}),he=u.memo(({paperPx:t,gridPosPxs:e,gridDimensions:n,gridLineStyle:r,borderStyle:s,backgroundColor:i="#ffffff",boxShadow:a="0 2px 8px rgba(0, 0, 0, 0.1)",marginFillColor:l="rgba(0, 0, 0, 0.05)",showGridLines:c=!0,showMargins:m=!0,showBorder:d=!0,showResizeHandles:p=!1,showDimensionLabels:v=!1,onGridResize:g,onDimensionChange:E,className:y="",zIndex:f={}})=>{const[x,h]=u.useState(null),[w,N]=u.useState(null),[I,B]=u.useState(null),D=u.useRef(null);u.useEffect(()=>{const j=R=>{if(!D.current)return;const T=D.current.getBoundingClientRect();B({x:R.clientX-T.left,y:R.clientY-T.top})},_=R=>{if(!D.current)return;const T=D.current.getBoundingClientRect();(R.clientX<T.left||R.clientX>T.right||R.clientY<T.top||R.clientY>T.bottom)&&B(null)};return window.addEventListener("mousemove",j),window.addEventListener("mouseleave",_),()=>{window.removeEventListener("mousemove",j),window.removeEventListener("mouseleave",_)}},[]);const A=u.useMemo(()=>{if(!I)return!1;const j=t.content.width,_=t.content.height,R=t.margin.left,T=t.margin.top;return!(I.x>=R&&I.x<=R+j&&I.y>=T&&I.y<=T+_)},[I,t]),S=u.useCallback((j,_)=>{N({direction:j,index:_})},[]),L=u.useMemo(()=>{if(!x||!w)return null;const j=w.direction==="column"?e.cols:e.rows,_=w.index,R=j[_-1],T=x.position,O=R!==void 0?T-R:0,U=x.position,F=j[_+1],b=F!==void 0?F-U:0;return{direction:w.direction,prevIndex:_-1,prevSize:O,nextIndex:_,nextSize:b}},[x,w,e]),$=u.useCallback((j,_,R)=>{const T=j==="column"?e.cols:e.rows,O=T[_];if(O===void 0)return;const U=T[_-1],F=T[_+1],b=10;let M=R;if(U!==void 0){const P=U+b-O;M=Math.max(M,P)}if(F!==void 0){const P=F-b-O;M=Math.min(M,P)}h({direction:j,position:O+M})},[e]),k=u.useCallback((j,_,R)=>{const T=j==="column"?e.cols:e.rows,O=T[_];if(O===void 0){h(null);return}const U=T[_-1],F=T[_+1],b=10;let M=R;if(U!==void 0){const P=U+b-O;M=Math.max(M,P)}if(F!==void 0){const P=F-b-O;M=Math.min(M,P)}h(null),N(null),g==null||g(j,_,M)},[e,g]),C={position:"relative",width:"100%",height:"100%"};return o.jsxs("div",{ref:D,className:y,style:C,children:[o.jsx(kn,{canvasPx:t.canvas,backgroundColor:i,boxShadow:a,zIndex:(f==null?void 0:f.canvas)??G.GRID_CANVAS,className:y}),m&&o.jsx(Bn,{paperPx:t,visible:m,marginColor:l,zIndex:(f==null?void 0:f.margin)??G.MARGIN_OVERLAY,className:y}),c&&o.jsx(Gn,{gridPosPx:e,contentPx:t.content,marginLeftPx:t.margin.left,marginTopPx:t.margin.top,lineStyle:r,visible:c,zIndex:(f==null?void 0:f.grid)??G.GRID_OVERLAY,dpi:W,className:y}),d&&o.jsx(An,{contentPx:t.content,marginLeftPx:t.margin.left,marginTopPx:t.margin.top,borderStyle:s,visible:d,dpi:W,zIndex:(f==null?void 0:f.border)??G.BORDER_OVERLAY,className:y}),p&&g&&o.jsxs(o.Fragment,{children:[e.cols.map((j,_)=>{if(_===0||_===e.cols.length-1)return null;const R=`col-${_}`;return o.jsx(ne,{direction:"column",index:_,position:j,marginLeftPx:t.margin.left,marginTopPx:t.margin.top,onResizeStart:S,onResize:$,onResizeEnd:k},R)}),e.rows.map((j,_)=>{if(_===0||_===e.rows.length-1)return null;const R=`row-${_}`;return o.jsx(ne,{direction:"row",index:_,position:j,marginLeftPx:t.margin.left,marginTopPx:t.margin.top,onResizeStart:S,onResize:$,onResizeEnd:k},R)})]}),v&&n&&o.jsxs(o.Fragment,{children:[n.cols.map((j,_)=>{const R=e.cols[_],T=e.cols[_+1];if(R===void 0||T===void 0)return null;const O=(w==null?void 0:w.direction)==="column"&&(w.index===_||w.index===_+1);let U;L&&L.direction==="column"&&(L.prevIndex===_?U=L.prevSize:L.nextIndex===_&&(U=L.nextSize));const F=(R+T)/2,b=T-R,M=`col-dim-${_}`;return o.jsx(ee,{direction:"column",index:_,dimension:j,position:F,currentPxSize:b,marginLeftPx:t.margin.left,marginTopPx:t.margin.top,isNearCursor:A||O,resizingPxSize:U,onDimensionChange:E},M)})," ",n.rows.map((j,_)=>{const R=e.rows[_],T=e.rows[_+1];if(R===void 0||T===void 0)return null;const O=(w==null?void 0:w.direction)==="row"&&(w.index===_||w.index===_+1),U=(R+T)/2,F=T-R,b=`row-dim-${_}`;return o.jsx(ee,{direction:"row",index:_,dimension:j,position:U,currentPxSize:F,marginLeftPx:t.margin.left,marginTopPx:t.margin.top,isNearCursor:A||O,onDimensionChange:E},b)})]}),x&&o.jsx("div",{style:{position:"absolute",left:x.direction==="column"?t.margin.left+x.position:t.margin.left,top:x.direction==="row"?t.margin.top+x.position:t.margin.top,width:x.direction==="column"?"2px":t.content.width,height:x.direction==="row"?"2px":t.content.height,backgroundColor:"#3b82f6",opacity:.5,pointerEvents:"none",zIndex:G.GRID_GHOST}})]})});class zo{constructor(){xe(this,"state",null);xe(this,"listeners",[])}start(e,n){this.state={kind:e,defaultSize:n},this.notify()}end(){this.state=null,this.notify()}get(){return this.state}subscribe(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(n=>n!==e)}}notify(){for(const e of this.listeners)e(this.state)}}const zt=new zo;function Ne(t,e,n,r){if(e<0||e>=t.length)return t;const s=[...t],i=s[e],a=s[e+1];return!i||!a?t:i.unit==="fr"&&a.unit==="fr"?Wo(s,e,n,r):i.unit!=="fr"&&a.unit!=="fr"?Yo(s,e,n):i.unit==="fr"&&a.unit!=="fr"?mn(s,e,n,"next",r):mn(s,e,n,"current",r)}function Wo(t,e,n,r){const s=t[e],i=t[e+1];if(!s||!i)return t;const a=t.reduce((E,y)=>y.unit==="fr"?E+y.value:E,0),l=r/a,c=s.value*l,m=i.value*l,d=Math.max(10,c+n),p=Math.max(10,m-n),v=d/l,g=p/l;return t[e]={...s,value:Math.round(v*100)/100},t[e+1]={...i,value:Math.round(g*100)/100},t}function Yo(t,e,n){const r=t[e],s=t[e+1];if(!r||!s)return t;const i=V.fromDim(r),a=V.fromDim(s),l=Math.max(10,i+n),c=Math.max(10,a-n);return t[e]={...r,value:re(l,r.unit)},t[e+1]={...s,value:re(c,s.unit)},t}function mn(t,e,n,r,s){const i=t[e],a=t[e+1];if(!i||!a)return t;let l=0,c=0;for(const p of t)p.unit==="fr"?l+=p.value:c+=V.fromDim(p);const m=s-c,d=l>0?m/l:0;if(r==="next"){const p=V.fromDim(a),v=Math.max(10,p-n);t[e+1]={...a,value:re(v,a.unit)};const g=v-p,E=m-g,y=i.value*d,f=Math.max(10,y+n),x=l>0?f/E*l:1;t[e]={...i,value:Math.round(x*100)/100}}else{const p=V.fromDim(i),v=Math.max(10,p+n);t[e]={...i,value:re(v,i.unit)};const g=v-p,E=m-g,y=a.value*d,f=Math.max(10,y-n),x=l>0?f/E*l:1;t[e+1]={...a,value:Math.round(x*100)/100}}return t}function re(t,e){switch(e){case"px":return Math.round(t);case"mm":{const n=Y.fromPx(t);return Math.round(n*10)/10}case"cm":{const n=Y.fromPx(t);return Math.round(n/10*100)/100}case"inch":{const n=Y.fromPx(t);return Math.round(n/25.4*100)/100}case"pt":{const n=Y.fromPx(t);return Math.round(n/25.4*72*10)/10}case"fr":return 1;default:{const n=e;throw new Error(`Unsupported unit: ${n}`)}}}function Vn(t){if(t.length===0)return[];const e=[];let n=0;for(const r of t){et(r,"Pixel value");const s=r+n,i=Math.round(s);e.push(i),n=s-i}return e}const Ho=8,Xo=32,qo=64,Ko=512,hn=(t,e,n)=>Math.min(Math.max(t,e),n);function Ie(t){const e=t.length-1,n=e>=1?t[e]??0:0,r=t.length>=1?n/e:0,s=hn(Math.ceil(Math.log2(e+1)),Ho,Xo),i=hn(r*2,qo,Ko);return{step:s,windowPx:i}}function te(t,e){const n=e.length-1;if(n<=0||e[0]===void 0||t<e[0]||e[n]===void 0)return-1;if(t>=e[n])return n-1;let r=1,s=n;for(;r<=s;){const i=r+s>>>1,a=e[i];if(a===void 0){s=i-1;continue}a<=t?r=i+1:s=i-1}return r-1}function De(t,e,n){const r=t.length-1;let s=0;return i=>{if(r<=0||t[0]===void 0||i<t[0]||t[r]===void 0)return-1;if(i>=t[r])return r-1;const a=t[s],l=t[s+1];if(a===void 0||l===void 0)return-1;if(a<=i&&i<l)return s;const c=a-n,m=l+n;if(i<c||i>=m)return s=te(i,t),s;let d=0;const p=t[s+1];if(p!==void 0&&i>=p)for(;s+1<r;){const v=t[s+1];if(v===void 0||i<v)break;if(s++,++d>e)return s=te(i,t),s}else for(;s>0;){const v=t[s];if(v===void 0||i>=v)break;if(s--,++d>e)return s=te(i,t),s}return s}}function oe(t,e){if(t.length===0)return[];et(e,"Content size");let n=0,r=0;const s=t.map(l=>{if(et(l.value,"Grid dimension value"),l.unit==="fr")return n+=l.value,null;{const c=Y.fromDim(l);return r+=c,c}});if(n===0)return Nn(r,0,e,"Total fixed size"),s;const i=e-r;et(i,"Content size - fixed sizes");const a=i/n;return s.map((l,c)=>{const m=t[c];if(l!=null)return l;if(!m)throw new Error(`dims[${c}] is undefined`);return m.value*a})}function se(t,e=96){ue(e,"DPI"),de(e,"DPI");const n=t.map(s=>V.fromMm(s,e));return Vn(n)}function Zo(t,e,n){if(t.length===0)return[];ue(n,"DPI"),de(n,"DPI"),et(e,"Content size");const r=oe(t,e);return se(r,n)}function ie(t){const e={};for(const[n,r]of Object.entries(t))if(r!=null)if(typeof r=="object"&&!Array.isArray(r)&&r!==null){const s=ie(r);e[n]=s}else e[n]=r;return e}function Jo(t,e){const r={A4:{width:210,height:297},A3:{width:297,height:420},B4:{width:257,height:364},B5:{width:182,height:257},Letter:{width:215.9,height:279.4},Legal:{width:215.9,height:355.6}}[t];return e==="landscape"?{width:r.height,height:r.width}:r}function Un(t){t!=null&&t.title&&(document.title=t.title),t!=null&&t.removeScrollbars&&(document.body.style.overflow="hidden")}function Fn(t){t!=null&&t.restoreScrollbars&&(document.body.style.overflow="")}function $e(t,e){var s,i;const n=document.title,r=document.createElement("style");r.id="tatamicks-print-style",r.textContent=`
23
23
  @media print {
24
24
  /* bodyとhtmlのマージン・パディングをリセット */
25
25
  html, body {
@@ -59,12 +59,12 @@ React keys must be passed directly to JSX without using spread:
59
59
  color-adjust: exact !important;
60
60
  }
61
61
  }
62
- `;try{document.head.appendChild(o),t.classList.add("tatamicks-print-target"),e!=null&&e.title&&(document.title=e.title),(s=e==null?void 0:e.onBeforePrint)==null||s.call(e),window.print(),(i=e==null?void 0:e.onAfterPrint)==null||i.call(e)}finally{t.classList.remove("tatamicks-print-target");const a=document.getElementById("tatamicks-print-style");a&&a.remove(),document.title=n}}function Qo(t){Un({title:t==null?void 0:t.title,removeScrollbars:!0});const e=()=>{var o;(o=t==null?void 0:t.onBeforePrint)==null||o.call(t)},n=()=>{var o;(o=t==null?void 0:t.onAfterPrint)==null||o.call(t),Fn({restoreScrollbars:!0}),window.removeEventListener("beforeprint",e),window.removeEventListener("afterprint",n)};window.addEventListener("beforeprint",e),window.addEventListener("afterprint",n),window.print()}function ts(t){if(typeof t!="object"||t===null)return!1;const e=t;if(typeof e.id!="string"||typeof e.kind!="string"||typeof e.layout!="object"||e.layout===null)return!1;const n=e.layout;return!(typeof n.x!="number"||typeof n.y!="number"||typeof n.w!="number"||typeof n.h!="number"||e.props!==void 0&&typeof e.props!="object")}function es(t){return t==="fr"||t==="px"||t==="%"}function fn(t){return Array.isArray(t)?t.every(e=>{if(typeof e!="object"||e===null)return!1;const n=e;return typeof n.value=="number"&&es(n.unit)}):!1}function ns(t){if(typeof t!="object"||t===null)return!1;const e=t;return fn(e.cols)&&fn(e.rows)}function rs(t){if(typeof t!="object"||t===null)return!1;const e=t;if(typeof e.size!="object"||e.size===null)return!1;const n=e.size;if(typeof n.preset!="string"||typeof n.width!="object"||n.width===null)return!1;const o=n.width;if(typeof o.value!="number"||typeof o.unit!="string"||typeof n.height!="object"||n.height===null)return!1;const s=n.height;if(typeof s.value!="number"||typeof s.unit!="string"||typeof e.margin!="object"||e.margin===null)return!1;const i=e.margin;for(const a of["top","right","bottom","left"]){const l=i[a];if(typeof l!="object"||l===null)return!1;const c=l;if(typeof c.value!="number"||typeof c.unit!="string")return!1}return!0}function os(t){return t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="object"&&!Array.isArray(t)}function zn(t){if(typeof t!="object"||t===null)throw new Error("Schema must be an object");const e=t;if(!rs(e.paper))throw new Error("Invalid paper definition");if(!ns(e.grid))throw new Error("Invalid grid definition");if(!Array.isArray(e.blocks))throw new Error("blocks must be an array");if(!e.blocks.every(ts))throw new Error("Invalid block definition in blocks array");if(e.metaData!==void 0){if(typeof e.metaData!="object"||e.metaData===null)throw new Error("metaData must be an object if provided");const n=e.metaData;for(const o in n)if(!os(n[o]))throw new Error(`Invalid value in metaData.${o}`)}return e}function Te(t){try{const e=JSON.parse(t);return zn(e)}catch(e){throw e instanceof SyntaxError?new Error(`Invalid JSON format: ${e.message}`):e}}function Re(t,e=!1){try{return e?JSON.stringify(t,null,2):JSON.stringify(t)}catch(n){throw new Error(`Failed to serialize schema: ${n instanceof Error?n.message:"Unknown error"}`)}}function Wn(t){return t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"?!0:typeof t=="object"&&!Array.isArray(t)?Object.values(t).every(Wn):!1}function Yn(t){if(typeof t!="object"||t===null)throw new Error("Values must be an object");if(Array.isArray(t))throw new Error("Values must be an object, not an array");const e=t;for(const n in e)if(!Wn(e[n]))throw new Error(`Invalid value at key "${n}"`);return e}function Me(t){try{const e=JSON.parse(t);return Yn(e)}catch(e){throw e instanceof SyntaxError?new Error(`Invalid JSON format: ${e.message}`):e}}function Ce(t,e=!1){try{return e?JSON.stringify(t,null,2):JSON.stringify(t)}catch(n){throw new Error(`Failed to serialize values: ${n instanceof Error?n.message:"Unknown error"}`)}}const Xt={all:{color:"#3b82f688",width:{value:4,unit:"px"},type:dt.SOLID}},fe={size:12,backgroundColor:"#ffffff",borderColor:"#3b82f6",borderWidth:1,borderRadius:"50%"},Z={base:G.INTERACTION_LAYER_BASE,select_block:G.SELECT_BLOCK,block_ghost:G.BLOCK_GHOST,hover_outline:G.HOVER_OUTLINE,edit_block:G.EDIT_BLOCK,grid_ghost:G.GRID_GHOST,grid_handles:G.GRID_HANDLES,select_border:G.BLOCK_SELECT_BORDER,block_handles:G.BLOCK_HANDLES,rubber_band:G.RUBBER_BAND};var lt=(t=>(t.IDLE="idle",t.PRESSING="pressing",t.DRAGGING="dragging",t.EDITING="editing",t))(lt||{}),X=(t=>(t.N="n",t.NE="ne",t.E="e",t.SE="se",t.S="s",t.SW="sw",t.W="w",t.NW="nw",t))(X||{}),nt=(t=>(t.MOVE="move",t.RESIZE="resize",t.INSERT="insert",t))(nt||{}),H=(t=>(t.START_PRESS="startPress",t.UPDATE_DRAG="updateDrag",t.END_DRAG="endDrag",t.CANCEL_DRAG="cancelDrag",t.EDIT="edit",t.END_EDIT="endEdit",t.START_INSERT="startInsert",t.CANCEL_INSERT="cancelInsert",t.START_RESIZE="startResize",t))(H||{});function ae(t){return t.editingBlockId!==null?"editing":t.dragging?t.dragging.type==="insert"||t.dragging.type==="resize"||t.dragging.currentGrid.col!==t.dragging.startGrid.col||t.dragging.currentGrid.row!==t.dragging.startGrid.row?"dragging":"pressing":"idle"}const ss="_interactionBlock_145kg_7",is="_resizeHandle_145kg_7",Hn={interactionBlock:ss,resizeHandle:is},as=[{id:X.NW,cursor:"nwse-resize",x:0,y:0},{id:X.N,cursor:"ns-resize",x:50,y:0},{id:X.NE,cursor:"nesw-resize",x:100,y:0},{id:X.W,cursor:"ew-resize",x:0,y:50},{id:X.E,cursor:"ew-resize",x:100,y:50},{id:X.SW,cursor:"nesw-resize",x:0,y:100},{id:X.S,cursor:"ns-resize",x:50,y:100},{id:X.SE,cursor:"nwse-resize",x:100,y:100}],Fe=u.memo(({onResizeStart:t,activeHandle:e,handleStyle:n=fe,zIndex:o=G.BLOCK_HANDLES})=>{const s=n.size,i=s/2;return r.jsx(r.Fragment,{children:as.map(({id:a,cursor:l,x:c,y:m})=>{const d=c===50?`calc(50% - ${i}px)`:c===100?`calc(100% - ${i}px)`:`-${i}px`,f=m===50?`calc(50% - ${i}px)`:m===100?`calc(100% - ${i}px)`:`-${i}px`,v=e===a;return r.jsx("div",{className:Hn.resizeHandle,onPointerDown:g=>{g.stopPropagation(),t(g,a)},style:{position:"absolute",left:d,top:f,width:`${s}px`,height:`${s}px`,backgroundColor:v?n.borderColor:n.backgroundColor,border:`${n.borderWidth}px solid ${n.borderColor}`,borderRadius:n.borderRadius,cursor:l,zIndex:o,pointerEvents:"auto",boxSizing:"border-box",opacity:v?1:void 0,transition:"opacity 0.2s, background-color 0.2s, transform 0.2s",transform:v?"scale(1.2)":void 0},"data-testid":`resize-handle-${a}`},a)})})});Fe.displayName="ResizeHandles";const Xn=u.memo(({width:t,height:e,zIndex:n=G.BLOCK_SELECT_BORDER,borderStyle:o=Xt})=>{const s=u.useMemo(()=>new kt(o),[o]),i={position:"absolute",inset:0,pointerEvents:"none",zIndex:n};return r.jsx("div",{style:i,children:r.jsx(It,{width:t,height:e,border:s})})}),Lt=u.memo(({block:t,rect:e,showHandles:n=!1,onResizeStart:o,activeHandle:s,selectionStyle:i=Xt,handleStyle:a=fe,selectBorderZIndex:l=Z.select_border,blockHandlesZIndex:c=Z.block_handles})=>{const m={position:"absolute",left:`${e.left}px`,top:`${e.top}px`,width:`${e.width}px`,height:`${e.height}px`,pointerEvents:"none"};return r.jsxs("div",{className:Hn.interactionBlock,style:m,"data-testid":"interaction-block","data-block-id":t.id,children:[r.jsx(Xn,{width:e.width,height:e.height,zIndex:l,borderStyle:i}),n&&o&&r.jsx(Fe,{onResizeStart:o,activeHandle:s,handleStyle:a,zIndex:c})]})});Lt.displayName="InteractionBlock";const ze=u.memo(({pluginRegistry:t,gridLength:e,getBlockRectPx:n,currentGrid:o,currentMousePx:s,pluginKind:i,defaultSize:a,isOutside:l,selectionStyle:c,ghostZIndex:m=Z.block_ghost,selectBorderZIndex:d=Z.select_border,blockHandlesZIndex:f=Z.block_handles})=>{const v=t[i];if(!v)return null;let g;if(l&&s){const y=Nt(v,{x:0,y:0,w:a.w,h:a.h}),p=n(y);g={left:s.x-p.width/2,top:s.y-p.height/2,width:p.width,height:p.height}}else{const y=e.cols-a.w,p=e.rows-a.h,x=Math.max(0,Math.min(o.col,y)),h=Math.max(0,Math.min(o.row,p)),w=Nt(v,{x,y:h,w:a.w,h:a.h});g=n(w)}const E=Nt(v,{x:0,y:0,w:a.w,h:a.h});return r.jsxs("div",{"data-testid":"insert-ghost",style:{position:"absolute",inset:0,pointerEvents:"none"},children:[r.jsx("div",{style:{position:"absolute",left:`${g.left}px`,top:`${g.top}px`,width:`${g.width}px`,height:`${g.height}px`,opacity:l?.3:.6,filter:l?"grayscale(100%)":"none",zIndex:m},children:r.jsx(Ht,{id:E.id,plugin:v,props:E.props,value:E.initValue,onChange:()=>{},readOnly:!0,mode:it.EDIT,blockSizePx:g,blockZIndex:m})}),r.jsx(Lt,{block:E,rect:g,selectionStyle:c,selectBorderZIndex:d,blockHandlesZIndex:f})]})});ze.displayName="InsertGhost";function We(t,e,n,o,s){if(t.length===0)return[];if(t.length===1){const x=t[0];if(!x)return[];const h=o-x.layout.w,w=s-x.layout.h,N=Math.max(0,Math.min(x.layout.x+e,h)),I=Math.max(0,Math.min(x.layout.y+n,w));return[{blockId:x.id,x:N,y:I}]}const i=Math.min(...t.map(x=>x.layout.x)),a=Math.min(...t.map(x=>x.layout.y)),l=Math.max(...t.map(x=>x.layout.x+x.layout.w)),c=Math.max(...t.map(x=>x.layout.y+x.layout.h)),m=l-i,d=c-a,f=i+e,v=a+n,g=Math.max(0,Math.min(f,o-m)),E=Math.max(0,Math.min(v,s-d)),y=g-i,p=E-a;return t.map(x=>({blockId:x.id,x:x.layout.x+y,y:x.layout.y+p}))}const Ye=u.memo(({blocks:t,pluginRegistry:e,gridLength:n,getBlockRectPx:o,selectedBlockIds:s,deltaCol:i,deltaRow:a,isOutside:l,currentMousePx:c,selectionStyle:m,ghostZIndex:d=Z.block_ghost,selectBorderZIndex:f=Z.select_border,blockHandlesZIndex:v=Z.block_handles})=>{const g=s.map(y=>t.find(p=>p.id===y)).filter(Boolean),E=We(g,i,a,n.cols,n.rows);return r.jsx("div",{"data-testid":"moving-ghost",style:{position:"absolute",inset:0,pointerEvents:"none"},children:s.map(y=>{const p=t.find(N=>N.id===y);if(!p)return null;const x=e[p.kind];if(!x)return null;let h;if(l&&c){const N=o(p);h={left:c.x-N.width/2,top:c.y-N.height/2,width:N.width,height:N.height}}else{const N=E.find(B=>B.blockId===p.id);if(!N)return null;const I={...p,layout:{...p.layout,x:N.x,y:N.y}};h=o(I)}const w={...p,layout:{...p.layout,x:0,y:0}};return r.jsxs("div",{children:[r.jsx("div",{style:{position:"absolute",left:`${h.left}px`,top:`${h.top}px`,width:`${h.width}px`,height:`${h.height}px`,opacity:l?.3:.5,filter:l?"grayscale(100%)":"none",zIndex:d},children:r.jsx(Ht,{id:w.id,plugin:x,props:w.props,value:w.initValue,onChange:()=>{},readOnly:!0,mode:it.EDIT,blockSizePx:h,blockZIndex:d,className:"ghost-content"})}),r.jsx(Lt,{block:w,rect:h,selectionStyle:m,selectBorderZIndex:f,blockHandlesZIndex:v})]},y)})})});Ye.displayName="MovingGhost";function He({layout:t,handle:e,deltaCol:n,deltaRow:o,gridCols:s,gridRows:i}){const a={...t};if(e===X.E||e===X.NE||e===X.SE){const l=s-t.x;a.w=Math.max(1,Math.min(t.w+n,l))}else if(e===X.W||e===X.NW||e===X.SW){const l=t.w-1,c=n>0?Math.min(n,l):n;t.x+c>=0?(a.x=t.x+c,a.w=t.w-c):(a.x=0,a.w=t.w+t.x)}if(e===X.S||e===X.SE||e===X.SW){const l=i-t.y;a.h=Math.max(1,Math.min(t.h+o,l))}else if(e===X.N||e===X.NE||e===X.NW){const l=t.h-1,c=o>0?Math.min(o,l):o;t.y+c>=0?(a.y=t.y+c,a.h=t.h-c):(a.y=0,a.h=t.h+t.y)}return a}const Xe=u.memo(({blocks:t,pluginRegistry:e,gridLength:n,getBlockRectPx:o,blockId:s,handle:i,deltaCol:a,deltaRow:l,isOutside:c,selectionStyle:m,ghostZIndex:d=Z.block_ghost,selectBorderZIndex:f=Z.select_border,blockHandlesZIndex:v=Z.block_handles})=>{const g=t.find(h=>h.id===s),E=e[(g==null?void 0:g.kind)??""];if(!g||!E)return null;const y=He({layout:g.layout,handle:i,deltaCol:a,deltaRow:l,gridCols:n.cols,gridRows:n.rows}),p={...g,layout:y},x=o(p);return r.jsx("div",{"data-testid":"resize-ghost",style:{position:"absolute",inset:0,pointerEvents:"none"},children:r.jsxs("div",{children:[r.jsx("div",{style:{position:"absolute",left:`${x.left}px`,top:`${x.top}px`,width:`${x.width}px`,height:`${x.height}px`,opacity:c?.3:.5,filter:c?"grayscale(100%)":"none",zIndex:d},children:r.jsx(Ht,{id:p.id,plugin:E,props:p.props,value:p.initValue,onChange:()=>{},readOnly:!0,mode:it.EDIT,blockSizePx:x,blockZIndex:d,className:"resize-ghost-content"})}),r.jsx(Lt,{block:p,rect:x,selectionStyle:m,selectBorderZIndex:f,blockHandlesZIndex:v})]},g.id)})});Xe.displayName="ResizeGhost";const qe=u.memo(({blocks:t,pluginRegistry:e,gridLength:n,draggingState:o,getBlockRectPx:s,selectionStyle:i=Xt,ghostZIndex:a=Z.block_ghost,selectBorderZIndex:l=Z.select_border,blockHandlesZIndex:c=Z.block_handles})=>{if(!o)return null;const m=o.currentGrid.col-o.startGrid.col,d=o.currentGrid.row-o.startGrid.row;switch(o.type){case nt.MOVE:return r.jsx(Ye,{blocks:t,pluginRegistry:e,gridLength:n,getBlockRectPx:s,selectedBlockIds:o.blockIds,deltaCol:m,deltaRow:d,isOutside:o.isOutside??!1,currentMousePx:o.currentMousePx,selectionStyle:i,ghostZIndex:a,selectBorderZIndex:l,blockHandlesZIndex:c});case nt.RESIZE:{const f=o.blockIds[0];return!f||!o.handle?null:r.jsx(Xe,{blocks:t,pluginRegistry:e,gridLength:n,getBlockRectPx:s,blockId:f,handle:o.handle,deltaCol:m,deltaRow:d,isOutside:o.isOutside??!1,selectionStyle:i,ghostZIndex:a,selectBorderZIndex:l,blockHandlesZIndex:c})}case nt.INSERT:return o.defaultSize?r.jsx(ze,{pluginRegistry:e,gridLength:n,getBlockRectPx:s,currentGrid:o.currentGrid,currentMousePx:o.currentMousePx,pluginKind:o.pluginKind||"",defaultSize:o.defaultSize,isOutside:o.isOutside??!1,selectionStyle:i,ghostZIndex:a,selectBorderZIndex:l,blockHandlesZIndex:c}):null;default:return null}});qe.displayName="DragLayer";const ls=({id:t,plugin:e,props:n,value:o,onChange:s,onBlur:i,blockRectPx:a,zIndex:l=G.EDIT_BLOCK,validationState:c,className:m=""},d)=>{const f=u.useRef(null);u.useImperativeHandle(d,()=>({focus:()=>{var p;(p=f.current)==null||p.focus()}}),[]);const v=Ve(a,{zIndex:l,pointerEvents:"auto"}),g={width:a.width,height:a.height},E={id:t,props:n,value:o,onChange:s,onBlur:i,readOnly:!1,mode:it.FORM,dimensions:{widthPx:g.width,heightPx:g.height},validationState:c},y=e.Renderer;return r.jsx("div",{className:m,style:v,"data-testid":"editing-block","data-block-id":t,"data-plugin-kind":e.kind,children:r.jsx(y,{ref:f,...E})})},cs=u.forwardRef(ls),qn=u.memo(cs);function Kn(t){const[e,n]=u.useState({editingBlockId:null,...t}),o=u.useCallback(s=>{n(i=>{switch(s.type){case H.START_PRESS:{const a=s.selectedBlockIds||[s.blockId];return{...i,dragging:{type:nt.MOVE,blockIds:a,startGrid:s.startGrid,currentGrid:s.startGrid,isOutside:!1}}}case H.UPDATE_DRAG:return i.dragging?{...i,dragging:{...i.dragging,currentGrid:s.currentGrid,currentMousePx:s.currentMousePx,isOutside:s.isOutside??!1}}:i;case H.END_DRAG:return{...i,dragging:void 0};case H.CANCEL_DRAG:return{...i,dragging:void 0};case H.EDIT:return{...i,editingBlockId:s.blockId};case H.END_EDIT:return{...i,editingBlockId:null};case H.START_INSERT:return{...i,dragging:{type:nt.INSERT,blockIds:[],startGrid:{col:0,row:0},currentGrid:{col:0,row:0},pluginKind:s.pluginKind,defaultSize:s.defaultSize,isOutside:!1}};case H.CANCEL_INSERT:return{...i,dragging:void 0};case H.START_RESIZE:return{...i,dragging:{type:nt.RESIZE,blockIds:[s.blockId],startGrid:s.startGrid,currentGrid:s.startGrid,handle:s.handle,isOutside:!1}};default:return i}})},[]);return[e,o]}const Ke=u.memo(({blocks:t,selectedBlockIds:e,isDragging:n,draggingState:o,getBlockRectPx:s,onResizeStart:i,selectionStyle:a=Xt,handleStyle:l=fe,selectBorderZIndex:c=Z.select_border,blockHandlesZIndex:m=Z.block_handles})=>{if(n&&(o==null?void 0:o.type)!==nt.RESIZE)return null;const f=Array.from(new Set(e));return r.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:f.map(v=>{const g=t.find(p=>p.id===v);if(!g)return null;const y=(o==null?void 0:o.type)===nt.RESIZE&&o.blockIds.includes(v)?o==null?void 0:o.handle:null;return r.jsx(Lt,{block:g,rect:s(g),showHandles:!0,onResizeStart:(p,x)=>i(p,x,v),activeHandle:y,selectionStyle:a,handleStyle:l,selectBorderZIndex:c,blockHandlesZIndex:m},g.id)})})});Ke.displayName="SelectionLayer";function Zn(t,e,n,o){const s=n-e.w,i=o-e.h;return{x:Math.max(0,Math.min(t.x,s)),y:Math.max(0,Math.min(t.y,i))}}function Pe(t,e,n){const{x:o,y:s}=t;for(let i=e.length-1;i>=0;i--){const a=e[i];if(!a)continue;const l=n(a);if(o>=l.left&&o<=l.left+l.width&&s>=l.top&&s<=l.top+l.height)return a.id}return null}const Ze=u.memo(({blocks:t,pluginRegistry:e,gridLength:n,getBlockRectPx:o,getColIndex:s,getRowIndex:i,state:a,onChange:l,selectedBlockIds:c,onSelectionChange:m,onBlockChange:d,scale:f=1,className:v="",selectionStyle:g,handleStyle:E,editBlockZIndex:y=G.EDIT_BLOCK,selectBorderZIndex:p=Z.select_border,blockHandlesZIndex:x=Z.block_handles,dragGhostZIndex:h=Z.block_ghost})=>{const w=u.useRef(null),N=u.useRef(null),I=ae(a);u.useEffect(()=>{I===lt.EDITING&&a.editingBlockId&&setTimeout(()=>{var D;(D=N.current)==null||D.focus()},0)},[I,a.editingBlockId]),u.useEffect(()=>{const D=new Set(t.map(C=>C.id)),k=c.filter(C=>D.has(C));k.length!==c.length&&m(k)},[t,c,m]);const B=u.useCallback(D=>{var O;if(D.button!==0)return;const k=(O=w.current)==null?void 0:O.getBoundingClientRect();if(!k)return;const C=f??1,j={x:(D.clientX-k.left)/C,y:(D.clientY-k.top)/C},_=Pe(j,t,o);if(I===lt.EDITING){_!==a.editingBlockId&&(l({type:H.END_EDIT}),_||m([]));return}const R=s(j.x),T=i(j.y);if(_){D.stopPropagation();const U=c.includes(_);if(U&&D.shiftKey){const F=c.filter(b=>b!==_);m(F);return}else U?(D.currentTarget.setPointerCapture(D.pointerId),l({type:H.START_PRESS,blockId:_,startGrid:{col:R,row:T},selectedBlockIds:c})):(D.currentTarget.setPointerCapture(D.pointerId),D.shiftKey?m([...c,_]):(m([_]),l({type:H.START_PRESS,blockId:_,startGrid:{col:R,row:T},selectedBlockIds:[_]})))}else D.stopPropagation(),m([])},[t,o,s,i,I,c,m,l,f,a.editingBlockId]),$=u.useCallback(D=>{var P;if(I!==lt.PRESSING&&I!==lt.DRAGGING||!a.dragging)return;const k=(P=w.current)==null?void 0:P.getBoundingClientRect();if(!k)return;const C=f??1,j=k.width/C,_=k.height/C,R=(D.clientX-k.left)/C,T=(D.clientY-k.top)/C,O=a.dragging.type!==nt.RESIZE&&(R<0||R>j||T<0||T>_),U=Math.max(0,Math.min(R,j)),F=Math.max(0,Math.min(T,_)),b=s(U),M=i(F);l({type:H.UPDATE_DRAG,currentGrid:{col:b,row:M},currentMousePx:{x:R,y:T},isOutside:O})},[I,a.dragging,s,i,l,f]),A=u.useCallback(D=>{if(I===lt.DRAGGING&&a.dragging){if(a.dragging.isOutside){a.dragging.type===nt.MOVE&&(d==null||d({type:ct.DELETE,blockIds:a.dragging.blockIds}),m([])),l({type:H.END_DRAG}),D.currentTarget.releasePointerCapture(D.pointerId);return}const k=a.dragging.currentGrid.col-a.dragging.startGrid.col,C=a.dragging.currentGrid.row-a.dragging.startGrid.row;if(a.dragging.type===nt.MOVE){if(k!==0||C!==0){const j=a.dragging.blockIds.map(T=>t.find(O=>O.id===T)).filter(Boolean);if(j.length===0){l({type:H.END_DRAG}),D.currentTarget.releasePointerCapture(D.pointerId);return}const _=We(j,k,C,n.cols,n.rows),R=j.map(T=>{const O=_.find(U=>U.blockId===T.id);return O?{...T,layout:{...T.layout,x:O.x,y:O.y}}:T});d==null||d({type:ct.MOVE,blockIds:a.dragging.blockIds,blocks:R})}}else if(a.dragging.type===nt.INSERT){const{pluginKind:j,currentGrid:_,defaultSize:R}=a.dragging;if(j&&R){const T=e[j];if(T){const{x:O,y:U}=Zn({x:_.col,y:_.row},{w:R.w,h:R.h},n.cols,n.rows),F=Nt(T,{x:O,y:U,w:R.w,h:R.h});d==null||d({type:ct.ADD,blockIds:[F.id],blocks:[F]})}}}else if(a.dragging.type===nt.RESIZE){const j=a.dragging.blockIds[0],_=t.find(T=>T.id===j),R=a.dragging.handle;if(_&&R&&(k!==0||C!==0)){const T=He({layout:_.layout,handle:R,deltaCol:k,deltaRow:C,gridCols:n.cols,gridRows:n.rows});(T.x!==_.layout.x||T.y!==_.layout.y||T.w!==_.layout.w||T.h!==_.layout.h)&&(d==null||d({type:ct.RESIZE,blockIds:[_.id],blocks:[{..._,layout:T}]}))}}l({type:H.END_DRAG})}else I===lt.PRESSING&&a.dragging&&(a.dragging.isOutside&&a.dragging.type===nt.MOVE&&(d==null||d({type:ct.DELETE,blockIds:a.dragging.blockIds}),m([])),l({type:H.CANCEL_DRAG}));D.currentTarget.releasePointerCapture(D.pointerId)},[I,a.dragging,t,n,e,d,l,m]),L=u.useCallback(D=>{var R;const k=(R=w.current)==null?void 0:R.getBoundingClientRect();if(!k)return;const C=f??1,j={x:(D.clientX-k.left)/C,y:(D.clientY-k.top)/C},_=Pe(j,t,o);_&&(c.includes(_)||m([_]),l({type:H.EDIT,blockId:_}))},[t,o,l,m,f,c]),S=u.useCallback(D=>{var k;if((I===lt.PRESSING||I===lt.DRAGGING)&&a.dragging){const C=(k=w.current)==null?void 0:k.getBoundingClientRect();if(C){const j=f??1,_=(D.clientX-C.left)/j,R=(D.clientY-C.top)/j,T=C.width/j,O=C.height/j,U=Math.max(0,Math.min(_,T)),F=Math.max(0,Math.min(R,O));l({type:H.UPDATE_DRAG,currentGrid:{col:s(U),row:i(F)},currentMousePx:{x:_,y:R},isOutside:!0})}}},[I,a.dragging,f,s,i,l]);return r.jsxs("div",{ref:w,className:v,style:{position:"absolute",inset:0,zIndex:G.INTERACTION_LAYER_BASE,pointerEvents:"auto",touchAction:"none"},role:"application","aria-label":"Interactive canvas layer",tabIndex:-1,onPointerDown:B,onPointerMove:$,onPointerUp:A,onPointerLeave:S,onDoubleClick:L,"data-testid":"interaction-layer",children:[a.editingBlockId&&(()=>{const D=t.find(C=>C.id===a.editingBlockId),k=D?e[D.kind]:null;return!D||!k?null:r.jsx(qn,{ref:N,id:D.id,plugin:k,props:D.props,value:D.initValue,onChange:C=>{d==null||d({type:ct.UPDATE,blockIds:[D.id],blocks:[{...D,initValue:C}]})},onBlur:C=>{d==null||d({type:ct.UPDATE,blockIds:[D.id],blocks:[{...D,initValue:C}]})},blockRectPx:o(D),zIndex:y})})(),r.jsx(Ke,{blocks:t,selectedBlockIds:c,isDragging:I===lt.DRAGGING,draggingState:a.dragging,getBlockRectPx:o,onResizeStart:(D,k,C)=>{var T;const j=(T=w.current)==null?void 0:T.getBoundingClientRect();if(!j)return;I===lt.EDITING&&l({type:H.END_EDIT}),D.currentTarget.setPointerCapture(D.pointerId);const _=f??1,R={x:(D.clientX-j.left)/_,y:(D.clientY-j.top)/_};l({type:H.START_RESIZE,blockId:C,handle:k,startGrid:{col:s(R.x),row:i(R.y)}})},selectionStyle:g,handleStyle:E,selectBorderZIndex:p,blockHandlesZIndex:x}),r.jsx(qe,{blocks:t,pluginRegistry:e,gridLength:n,draggingState:a.dragging,getBlockRectPx:o,selectionStyle:g,ghostZIndex:h,selectBorderZIndex:p,blockHandlesZIndex:x})]})});Ze.displayName="InteractionLayer";function qt(t,e,n=W){const o=u.useMemo(()=>Y.fromDim(t.size.width),[t.size.width]),s=u.useMemo(()=>Y.fromDim(t.size.height),[t.size.height]),i=u.useMemo(()=>Y.fromDim(t.margin.top),[t.margin.top]),a=u.useMemo(()=>Y.fromDim(t.margin.bottom),[t.margin.bottom]),l=u.useMemo(()=>Y.fromDim(t.margin.left),[t.margin.left]),c=u.useMemo(()=>Y.fromDim(t.margin.right),[t.margin.right]),m=u.useMemo(()=>o-l-c,[o,l,c]),d=u.useMemo(()=>s-i-a,[s,i,a]),f=u.useMemo(()=>oe(e.cols,m),[e.cols,m]),v=u.useMemo(()=>oe(e.rows,d),[e.rows,d]),g=u.useMemo(()=>V.fromMm(o,n),[o,n]),E=u.useMemo(()=>V.fromMm(s,n),[s,n]),y=u.useMemo(()=>V.fromMm(i,n),[i,n]),p=u.useMemo(()=>V.fromMm(a,n),[a,n]),x=u.useMemo(()=>V.fromMm(l,n),[l,n]),h=u.useMemo(()=>V.fromMm(c,n),[c,n]),w=u.useMemo(()=>V.fromMm(m,n),[m,n]),N=u.useMemo(()=>V.fromMm(d,n),[d,n]),I=u.useMemo(()=>se(f,n),[f,n]),B=u.useMemo(()=>se(v,n),[v,n]),$=u.useMemo(()=>{const P=[0];for(const z of I){const ht=P[P.length-1]??0;P.push(ht+z)}return P},[I]),A=u.useMemo(()=>{const P=[0];for(const z of B){const ht=P[P.length-1]??0;P.push(ht+z)}return P},[B]),{step:L,windowPx:S}=u.useMemo(()=>Ie($),[$]),{step:D,windowPx:k}=u.useMemo(()=>Ie(A),[A]),C=u.useMemo(()=>De($,L,S),[$,L,S]),j=u.useMemo(()=>De(A,D,k),[A,D,k]),_=u.useCallback(P=>C(P-x),[C,x]),R=u.useCallback(P=>j(P-y),[j,y]),T=u.useMemo(()=>({cols:$,rows:A}),[$,A]),O=u.useMemo(()=>({width:g,height:E}),[g,E]),U=u.useMemo(()=>({top:y,bottom:p,left:x,right:h}),[y,p,x,h]),F=u.useMemo(()=>({width:w,height:N}),[w,N]),b=u.useMemo(()=>({canvas:O,margin:U,content:F}),[O,U,F]),M=u.useCallback(P=>{const{x:z,y:ht,w:Ot,h:q}=P.layout,ut=T.cols,bt=T.rows;if(!ut.length||!bt.length)return{left:0,top:0,width:0,height:0};const Kt=Math.min(Math.max(0,z),ut.length-1),hr=Math.min(Math.max(0,z+Ot),ut.length-1),ln=Math.min(Math.max(0,ht),bt.length-1),fr=Math.min(Math.max(0,ht+q),bt.length-1),pr=(ut[Kt]??0)+x,xr=(bt[ln]??0)+y,vr=(ut[hr]??0)-(ut[Kt]??0),br=(bt[fr]??0)-(bt[ln]??0);return{left:pr,top:xr,width:vr,height:br}},[T,x,y]);return{paperPx:b,gridPosPx:T,getColIndex:_,getRowIndex:R,getBlockRectPx:M}}const Jn=({schema:t,values:e,pluginRegistry:n,onValueChange:o,scale:s=1,className:i})=>{const{paperPx:a,gridPosPx:l,getBlockRectPx:c}=qt(t.paper,t.grid,W),m=u.useCallback((d,f)=>{o&&o(d,f)},[o]);return r.jsxs("div",{className:i,style:{position:"relative",width:`${a.canvas.width}px`,height:`${a.canvas.height}px`,margin:"0 auto",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",backgroundColor:"#fff",transform:s!==1?`scale(${s})`:void 0,transformOrigin:"top center"},children:[r.jsx(he,{paperPx:a,gridPosPxs:l,showGridLines:!1,showMargins:!1,showBorder:!1}),r.jsx(St,{blocks:t.blocks,pluginRegistry:n,mode:it.EDIT,values:e,getBlockRectPx:c,onValueChange:m,showGuides:!0,showBorder:!0})]})};Jn.displayName="NoteEdit";const Qn=u.memo(Jn),tr=({schema:t,pluginRegistry:e,onSchemaChange:n,onSelectionChange:o,scale:s=1,className:i})=>{const[a,l]=u.useState([]),[c,m]=Kn(),d=u.useRef(null),{paperPx:f,gridPosPx:v,getBlockRectPx:g,getColIndex:E,getRowIndex:y}=qt(t.paper,t.grid,W),p=u.useCallback($=>{if(n)switch($.type){case ct.MOVE:case ct.RESIZE:{if(!$.blocks)return;const A=t.blocks.map(L=>{var D;return((D=$.blocks)==null?void 0:D.find(k=>k.id===L.id))||L});n({...t,blocks:A});break}case ct.ADD:{if(!$.blocks)return;n({...t,blocks:[...t.blocks,...$.blocks]});break}case ct.DELETE:{const A=new Set($.blockIds),L=t.blocks.filter(S=>!A.has(S.id));n({...t,blocks:L});break}case ct.UPDATE:{if(!$.blocks)return;const A=t.blocks.map(L=>{var C;const S=(C=$.blocks)==null?void 0:C.find(j=>j.id===L.id);if(!S)return L;const D=S.style?ie(S.style):S.style,k=S.props?ie(S.props):S.props;return{...L,...S,style:D,props:k}});n({...t,blocks:A});break}}},[t,n]),x=u.useCallback(($,A)=>{if(!n)return;const L=t.blocks.map(S=>S.id===$?{...S,initValue:A}:S);n({...t,blocks:L})},[t,n]);u.useEffect(()=>{o&&o(a)},[a,o]),u.useEffect(()=>{const $=zt.subscribe(A=>{var S;const L=ae(c);!A&&L===lt.DRAGGING&&((S=c.dragging)==null?void 0:S.type)===nt.INSERT&&m({type:H.CANCEL_INSERT})});return()=>$()},[c,m]),u.useEffect(()=>{const $=A=>{if(a.length===0)return;const L=A.target;L instanceof HTMLElement&&L.closest('[data-sidebar="true"]')||d.current&&!d.current.contains(L)&&l([])};return document.addEventListener("mousedown",$),()=>{document.removeEventListener("mousedown",$)}},[a]);const h=u.useCallback(($,A,L)=>{if(!n)return;const S=A-1;if($==="column"){const D=Ne(t.grid.cols,S,L,f.content.width);n({...t,grid:{...t.grid,cols:D}})}else{const D=Ne(t.grid.rows,S,L,f.content.height);n({...t,grid:{...t.grid,rows:D}})}},[t,f,n]),w=u.useCallback(($,A,L)=>{if(n)if($==="column"){const S=[...t.grid.cols];S[A]=L,n({...t,grid:{...t.grid,cols:S}})}else{const S=[...t.grid.rows];S[A]=L,n({...t,grid:{...t.grid,rows:S}})}},[n,t]),N=u.useMemo(()=>t.blocks.reduce(($,A)=>($[A.id]=A.initValue,$),{}),[t.blocks]),I=u.useCallback(()=>{const $=zt.get();!$||ae(c)===lt.DRAGGING||c.dragging||m({type:H.START_INSERT,pluginKind:$.kind,defaultSize:$.defaultSize})},[c,m]),B=u.useCallback(()=>{},[]);return r.jsxs("div",{ref:d,className:i,onPointerEnter:I,onPointerLeave:B,style:{position:"relative",width:`${f.canvas.width}px`,height:`${f.canvas.height}px`,margin:"0 auto",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",backgroundColor:"#fff",transform:s!==1?`scale(${s})`:void 0,transformOrigin:"top center"},children:[r.jsx(he,{paperPx:f,gridPosPxs:v,gridDimensions:{cols:t.grid.cols,rows:t.grid.rows},showGridLines:!0,showMargins:!0,showBorder:!0,showResizeHandles:!0,showDimensionLabels:!0,onGridResize:h,onDimensionChange:w,gridLineStyle:{color:"#e5e7eb",width:{value:1,unit:"px"},type:dt.SOLID},borderStyle:{all:{color:"#000000",width:{value:1,unit:"px"},type:dt.SOLID}}}),r.jsx(St,{blocks:t.blocks,pluginRegistry:e,mode:it.FORM,values:N,selectedBlockIds:a,getBlockRectPx:g,onValueChange:x,showGuides:!0,showBorder:!0}),r.jsx(Ze,{blocks:t.blocks,gridLength:{cols:t.grid.cols.length,rows:t.grid.rows.length},pluginRegistry:e,getBlockRectPx:g,getColIndex:E,getRowIndex:y,selectedBlockIds:a,onSelectionChange:l,state:c,onChange:m,onBlockChange:p,scale:s})]})};tr.displayName="NoteForm";const er=u.memo(tr),nr=({schema:t,values:e,pluginRegistry:n,scale:o=1,className:s})=>{const{paperPx:i,gridPosPx:a,getBlockRectPx:l}=qt(t.paper,t.grid,W);return r.jsxs("div",{className:s,style:{position:"relative",width:`${i.canvas.width}px`,height:`${i.canvas.height}px`,margin:"0 auto",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",backgroundColor:"#fff",transform:o!==1?`scale(${o})`:void 0,transformOrigin:"top center"},children:[r.jsx(he,{paperPx:i,gridPosPxs:a,showGridLines:!1,showMargins:!1,showBorder:!1}),r.jsx(St,{blocks:t.blocks,pluginRegistry:n,mode:it.VIEW,values:e,getBlockRectPx:l,showGuides:!1,showBorder:!0})]})};nr.displayName="NoteView";const rr=u.memo(nr),or=({schema:t,values:e,mode:n,pluginRegistry:o,onSchemaChange:s,onValuesChange:i,onSelectionChange:a,scale:l=1,className:c})=>{const m=u.useCallback((d,f)=>{if(i)if(f==null){const{[d]:v,...g}=e;i(g)}else i({...e,[d]:f})},[e,i]);return n===it.FORM?r.jsx(er,{schema:t,pluginRegistry:o,onSchemaChange:s,onSelectionChange:a,scale:l,className:c}):n===it.EDIT?r.jsx(Qn,{schema:t,values:e,pluginRegistry:o,onValueChange:m,scale:l,className:c}):r.jsx(rr,{schema:t,values:e,pluginRegistry:o,scale:l,className:c})};or.displayName="NoteEditor";const us=u.memo(or),sr=({schema:t,values:e,pluginRegistry:n,className:o},s)=>{const i=u.useRef(null),{paperPx:a,getBlockRectPx:l}=qt(t.paper,t.grid,W);return u.useEffect(()=>{const{size:c}=t.paper,m=Y.fromDim(c.width),d=Y.fromDim(c.height),f=document.getElementById("printable-note-page-style");f&&f.remove();const v=document.createElement("style");return v.id="printable-note-page-style",v.textContent=`
62
+ `;try{document.head.appendChild(r),t.classList.add("tatamicks-print-target"),e!=null&&e.title&&(document.title=e.title),(s=e==null?void 0:e.onBeforePrint)==null||s.call(e),window.print(),(i=e==null?void 0:e.onAfterPrint)==null||i.call(e)}finally{t.classList.remove("tatamicks-print-target");const a=document.getElementById("tatamicks-print-style");a&&a.remove(),document.title=n}}function Qo(t){Un({title:t==null?void 0:t.title,removeScrollbars:!0});const e=()=>{var r;(r=t==null?void 0:t.onBeforePrint)==null||r.call(t)},n=()=>{var r;(r=t==null?void 0:t.onAfterPrint)==null||r.call(t),Fn({restoreScrollbars:!0}),window.removeEventListener("beforeprint",e),window.removeEventListener("afterprint",n)};window.addEventListener("beforeprint",e),window.addEventListener("afterprint",n),window.print()}function ts(t){if(typeof t!="object"||t===null)return!1;const e=t;if(typeof e.id!="string"||typeof e.kind!="string"||typeof e.layout!="object"||e.layout===null)return!1;const n=e.layout;return!(typeof n.x!="number"||typeof n.y!="number"||typeof n.w!="number"||typeof n.h!="number"||e.props!==void 0&&typeof e.props!="object")}function es(t){return t==="fr"||t==="px"||t==="%"}function fn(t){return Array.isArray(t)?t.every(e=>{if(typeof e!="object"||e===null)return!1;const n=e;return typeof n.value=="number"&&es(n.unit)}):!1}function ns(t){if(typeof t!="object"||t===null)return!1;const e=t;return fn(e.cols)&&fn(e.rows)}function rs(t){if(typeof t!="object"||t===null)return!1;const e=t;if(typeof e.size!="object"||e.size===null)return!1;const n=e.size;if(typeof n.preset!="string"||typeof n.width!="object"||n.width===null)return!1;const r=n.width;if(typeof r.value!="number"||typeof r.unit!="string"||typeof n.height!="object"||n.height===null)return!1;const s=n.height;if(typeof s.value!="number"||typeof s.unit!="string"||typeof e.margin!="object"||e.margin===null)return!1;const i=e.margin;for(const a of["top","right","bottom","left"]){const l=i[a];if(typeof l!="object"||l===null)return!1;const c=l;if(typeof c.value!="number"||typeof c.unit!="string")return!1}return!0}function os(t){return t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="object"&&!Array.isArray(t)}function zn(t){if(typeof t!="object"||t===null)throw new Error("Schema must be an object");const e=t;if(!rs(e.paper))throw new Error("Invalid paper definition");if(!ns(e.grid))throw new Error("Invalid grid definition");if(!Array.isArray(e.blocks))throw new Error("blocks must be an array");if(!e.blocks.every(ts))throw new Error("Invalid block definition in blocks array");if(e.metaData!==void 0){if(typeof e.metaData!="object"||e.metaData===null)throw new Error("metaData must be an object if provided");const n=e.metaData;for(const r in n)if(!os(n[r]))throw new Error(`Invalid value in metaData.${r}`)}return e}function Te(t){try{const e=JSON.parse(t);return zn(e)}catch(e){throw e instanceof SyntaxError?new Error(`Invalid JSON format: ${e.message}`):e}}function Re(t,e=!1){try{return e?JSON.stringify(t,null,2):JSON.stringify(t)}catch(n){throw new Error(`Failed to serialize schema: ${n instanceof Error?n.message:"Unknown error"}`)}}function Wn(t){return t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"?!0:typeof t=="object"&&!Array.isArray(t)?Object.values(t).every(Wn):!1}function Yn(t){if(typeof t!="object"||t===null)throw new Error("Values must be an object");if(Array.isArray(t))throw new Error("Values must be an object, not an array");const e=t;for(const n in e)if(!Wn(e[n]))throw new Error(`Invalid value at key "${n}"`);return e}function Me(t){try{const e=JSON.parse(t);return Yn(e)}catch(e){throw e instanceof SyntaxError?new Error(`Invalid JSON format: ${e.message}`):e}}function Ce(t,e=!1){try{return e?JSON.stringify(t,null,2):JSON.stringify(t)}catch(n){throw new Error(`Failed to serialize values: ${n instanceof Error?n.message:"Unknown error"}`)}}const Xt={all:{color:"#3b82f688",width:{value:4,unit:"px"},type:dt.SOLID}},fe={size:12,backgroundColor:"#ffffff",borderColor:"#3b82f6",borderWidth:1,borderRadius:"50%"},Z={base:G.INTERACTION_LAYER_BASE,select_block:G.SELECT_BLOCK,block_ghost:G.BLOCK_GHOST,hover_outline:G.HOVER_OUTLINE,edit_block:G.EDIT_BLOCK,grid_ghost:G.GRID_GHOST,grid_handles:G.GRID_HANDLES,select_border:G.BLOCK_SELECT_BORDER,block_handles:G.BLOCK_HANDLES,rubber_band:G.RUBBER_BAND};var lt=(t=>(t.IDLE="idle",t.PRESSING="pressing",t.DRAGGING="dragging",t.EDITING="editing",t))(lt||{}),X=(t=>(t.N="n",t.NE="ne",t.E="e",t.SE="se",t.S="s",t.SW="sw",t.W="w",t.NW="nw",t))(X||{}),nt=(t=>(t.MOVE="move",t.RESIZE="resize",t.INSERT="insert",t))(nt||{}),H=(t=>(t.START_PRESS="startPress",t.UPDATE_DRAG="updateDrag",t.END_DRAG="endDrag",t.CANCEL_DRAG="cancelDrag",t.EDIT="edit",t.END_EDIT="endEdit",t.START_INSERT="startInsert",t.CANCEL_INSERT="cancelInsert",t.START_RESIZE="startResize",t))(H||{});function ae(t){return t.editingBlockId!==null?"editing":t.dragging?t.dragging.type==="insert"||t.dragging.type==="resize"||t.dragging.currentGrid.col!==t.dragging.startGrid.col||t.dragging.currentGrid.row!==t.dragging.startGrid.row?"dragging":"pressing":"idle"}const ss="_interactionBlock_145kg_7",is="_resizeHandle_145kg_7",Hn={interactionBlock:ss,resizeHandle:is},as=[{id:X.NW,cursor:"nwse-resize",x:0,y:0},{id:X.N,cursor:"ns-resize",x:50,y:0},{id:X.NE,cursor:"nesw-resize",x:100,y:0},{id:X.W,cursor:"ew-resize",x:0,y:50},{id:X.E,cursor:"ew-resize",x:100,y:50},{id:X.SW,cursor:"nesw-resize",x:0,y:100},{id:X.S,cursor:"ns-resize",x:50,y:100},{id:X.SE,cursor:"nwse-resize",x:100,y:100}],Fe=u.memo(({onResizeStart:t,activeHandle:e,handleStyle:n=fe,zIndex:r=G.BLOCK_HANDLES})=>{const s=n.size,i=s/2;return o.jsx(o.Fragment,{children:as.map(({id:a,cursor:l,x:c,y:m})=>{const d=c===50?`calc(50% - ${i}px)`:c===100?`calc(100% - ${i}px)`:`-${i}px`,p=m===50?`calc(50% - ${i}px)`:m===100?`calc(100% - ${i}px)`:`-${i}px`,v=e===a;return o.jsx("div",{className:Hn.resizeHandle,onPointerDown:g=>{g.stopPropagation(),t(g,a)},style:{position:"absolute",left:d,top:p,width:`${s}px`,height:`${s}px`,backgroundColor:v?n.borderColor:n.backgroundColor,border:`${n.borderWidth}px solid ${n.borderColor}`,borderRadius:n.borderRadius,cursor:l,zIndex:r,pointerEvents:"auto",boxSizing:"border-box",opacity:v?1:void 0,transition:"opacity 0.2s, background-color 0.2s, transform 0.2s",transform:v?"scale(1.2)":void 0},"data-testid":`resize-handle-${a}`},a)})})});Fe.displayName="ResizeHandles";const Xn=u.memo(({width:t,height:e,zIndex:n=G.BLOCK_SELECT_BORDER,borderStyle:r=Xt})=>{const s=u.useMemo(()=>new kt(r),[r]),i={position:"absolute",inset:0,pointerEvents:"none",zIndex:n};return o.jsx("div",{style:i,children:o.jsx(It,{width:t,height:e,border:s})})}),St=u.memo(({block:t,rect:e,showHandles:n=!1,onResizeStart:r,activeHandle:s,selectionStyle:i=Xt,handleStyle:a=fe,selectBorderZIndex:l=Z.select_border,blockHandlesZIndex:c=Z.block_handles})=>{const m={position:"absolute",left:`${e.left}px`,top:`${e.top}px`,width:`${e.width}px`,height:`${e.height}px`,pointerEvents:"none"};return o.jsxs("div",{className:Hn.interactionBlock,style:m,"data-testid":"interaction-block","data-block-id":t.id,children:[o.jsx(Xn,{width:e.width,height:e.height,zIndex:l,borderStyle:i}),n&&r&&o.jsx(Fe,{onResizeStart:r,activeHandle:s,handleStyle:a,zIndex:c})]})});St.displayName="InteractionBlock";const ze=u.memo(({pluginRegistry:t,gridLength:e,getBlockRectPx:n,currentGrid:r,currentMousePx:s,pluginKind:i,defaultSize:a,isOutside:l,selectionStyle:c,ghostZIndex:m=Z.block_ghost,selectBorderZIndex:d=Z.select_border,blockHandlesZIndex:p=Z.block_handles})=>{const v=t[i];if(!v)return null;let g;if(l&&s){const y=Nt(v,{x:0,y:0,w:a.w,h:a.h}),f=n(y);g={left:s.x-f.width/2,top:s.y-f.height/2,width:f.width,height:f.height}}else{const y=e.cols-a.w,f=e.rows-a.h,x=Math.max(0,Math.min(r.col,y)),h=Math.max(0,Math.min(r.row,f)),w=Nt(v,{x,y:h,w:a.w,h:a.h});g=n(w)}const E=Nt(v,{x:0,y:0,w:a.w,h:a.h});return o.jsxs("div",{"data-testid":"insert-ghost",style:{position:"absolute",inset:0,pointerEvents:"none"},children:[o.jsx("div",{style:{position:"absolute",left:`${g.left}px`,top:`${g.top}px`,width:`${g.width}px`,height:`${g.height}px`,opacity:l?.3:.6,filter:l?"grayscale(100%)":"none",zIndex:m},children:o.jsx(Ht,{id:E.id,plugin:v,props:E.props,value:E.initValue,onChange:()=>{},readOnly:!0,mode:it.EDIT,blockSizePx:g,blockZIndex:m})}),o.jsx(St,{block:E,rect:g,selectionStyle:c,selectBorderZIndex:d,blockHandlesZIndex:p})]})});ze.displayName="InsertGhost";function We(t,e,n,r,s){if(t.length===0)return[];if(t.length===1){const x=t[0];if(!x)return[];const h=r-x.layout.w,w=s-x.layout.h,N=Math.max(0,Math.min(x.layout.x+e,h)),I=Math.max(0,Math.min(x.layout.y+n,w));return[{blockId:x.id,x:N,y:I}]}const i=Math.min(...t.map(x=>x.layout.x)),a=Math.min(...t.map(x=>x.layout.y)),l=Math.max(...t.map(x=>x.layout.x+x.layout.w)),c=Math.max(...t.map(x=>x.layout.y+x.layout.h)),m=l-i,d=c-a,p=i+e,v=a+n,g=Math.max(0,Math.min(p,r-m)),E=Math.max(0,Math.min(v,s-d)),y=g-i,f=E-a;return t.map(x=>({blockId:x.id,x:x.layout.x+y,y:x.layout.y+f}))}const Ye=u.memo(({blocks:t,pluginRegistry:e,gridLength:n,getBlockRectPx:r,selectedBlockIds:s,deltaCol:i,deltaRow:a,isOutside:l,currentMousePx:c,selectionStyle:m,ghostZIndex:d=Z.block_ghost,selectBorderZIndex:p=Z.select_border,blockHandlesZIndex:v=Z.block_handles})=>{const g=s.map(y=>t.find(f=>f.id===y)).filter(Boolean),E=We(g,i,a,n.cols,n.rows);return o.jsx("div",{"data-testid":"moving-ghost",style:{position:"absolute",inset:0,pointerEvents:"none"},children:s.map(y=>{const f=t.find(N=>N.id===y);if(!f)return null;const x=e[f.kind];if(!x)return null;let h;if(l&&c){const N=r(f);h={left:c.x-N.width/2,top:c.y-N.height/2,width:N.width,height:N.height}}else{const N=E.find(B=>B.blockId===f.id);if(!N)return null;const I={...f,layout:{...f.layout,x:N.x,y:N.y}};h=r(I)}const w={...f,layout:{...f.layout,x:0,y:0}};return o.jsxs("div",{children:[o.jsx("div",{style:{position:"absolute",left:`${h.left}px`,top:`${h.top}px`,width:`${h.width}px`,height:`${h.height}px`,opacity:l?.3:.5,filter:l?"grayscale(100%)":"none",zIndex:d},children:o.jsx(Ht,{id:w.id,plugin:x,props:w.props,value:w.initValue,onChange:()=>{},readOnly:!0,mode:it.EDIT,blockSizePx:h,blockZIndex:d,className:"ghost-content"})}),o.jsx(St,{block:w,rect:h,selectionStyle:m,selectBorderZIndex:p,blockHandlesZIndex:v})]},y)})})});Ye.displayName="MovingGhost";function He({layout:t,handle:e,deltaCol:n,deltaRow:r,gridCols:s,gridRows:i}){const a={...t};if(e===X.E||e===X.NE||e===X.SE){const l=s-t.x;a.w=Math.max(1,Math.min(t.w+n,l))}else if(e===X.W||e===X.NW||e===X.SW){const l=t.w-1,c=n>0?Math.min(n,l):n;t.x+c>=0?(a.x=t.x+c,a.w=t.w-c):(a.x=0,a.w=t.w+t.x)}if(e===X.S||e===X.SE||e===X.SW){const l=i-t.y;a.h=Math.max(1,Math.min(t.h+r,l))}else if(e===X.N||e===X.NE||e===X.NW){const l=t.h-1,c=r>0?Math.min(r,l):r;t.y+c>=0?(a.y=t.y+c,a.h=t.h-c):(a.y=0,a.h=t.h+t.y)}return a}const Xe=u.memo(({blocks:t,pluginRegistry:e,gridLength:n,getBlockRectPx:r,blockId:s,handle:i,deltaCol:a,deltaRow:l,isOutside:c,selectionStyle:m,ghostZIndex:d=Z.block_ghost,selectBorderZIndex:p=Z.select_border,blockHandlesZIndex:v=Z.block_handles})=>{const g=t.find(h=>h.id===s),E=e[(g==null?void 0:g.kind)??""];if(!g||!E)return null;const y=He({layout:g.layout,handle:i,deltaCol:a,deltaRow:l,gridCols:n.cols,gridRows:n.rows}),f={...g,layout:y},x=r(f);return o.jsx("div",{"data-testid":"resize-ghost",style:{position:"absolute",inset:0,pointerEvents:"none"},children:o.jsxs("div",{children:[o.jsx("div",{style:{position:"absolute",left:`${x.left}px`,top:`${x.top}px`,width:`${x.width}px`,height:`${x.height}px`,opacity:c?.3:.5,filter:c?"grayscale(100%)":"none",zIndex:d},children:o.jsx(Ht,{id:f.id,plugin:E,props:f.props,value:f.initValue,onChange:()=>{},readOnly:!0,mode:it.EDIT,blockSizePx:x,blockZIndex:d,className:"resize-ghost-content"})}),o.jsx(St,{block:f,rect:x,selectionStyle:m,selectBorderZIndex:p,blockHandlesZIndex:v})]},g.id)})});Xe.displayName="ResizeGhost";const qe=u.memo(({blocks:t,pluginRegistry:e,gridLength:n,draggingState:r,getBlockRectPx:s,selectionStyle:i=Xt,ghostZIndex:a=Z.block_ghost,selectBorderZIndex:l=Z.select_border,blockHandlesZIndex:c=Z.block_handles})=>{if(!r)return null;const m=r.currentGrid.col-r.startGrid.col,d=r.currentGrid.row-r.startGrid.row;switch(r.type){case nt.MOVE:return o.jsx(Ye,{blocks:t,pluginRegistry:e,gridLength:n,getBlockRectPx:s,selectedBlockIds:r.blockIds,deltaCol:m,deltaRow:d,isOutside:r.isOutside??!1,currentMousePx:r.currentMousePx,selectionStyle:i,ghostZIndex:a,selectBorderZIndex:l,blockHandlesZIndex:c});case nt.RESIZE:{const p=r.blockIds[0];return!p||!r.handle?null:o.jsx(Xe,{blocks:t,pluginRegistry:e,gridLength:n,getBlockRectPx:s,blockId:p,handle:r.handle,deltaCol:m,deltaRow:d,isOutside:r.isOutside??!1,selectionStyle:i,ghostZIndex:a,selectBorderZIndex:l,blockHandlesZIndex:c})}case nt.INSERT:return r.defaultSize?o.jsx(ze,{pluginRegistry:e,gridLength:n,getBlockRectPx:s,currentGrid:r.currentGrid,currentMousePx:r.currentMousePx,pluginKind:r.pluginKind||"",defaultSize:r.defaultSize,isOutside:r.isOutside??!1,selectionStyle:i,ghostZIndex:a,selectBorderZIndex:l,blockHandlesZIndex:c}):null;default:return null}});qe.displayName="DragLayer";const ls=({id:t,plugin:e,props:n,value:r,onChange:s,onBlur:i,blockRectPx:a,zIndex:l=G.EDIT_BLOCK,validationState:c,className:m=""},d)=>{const p=u.useRef(null);u.useImperativeHandle(d,()=>({focus:()=>{var f;(f=p.current)==null||f.focus()}}),[]);const v=Ve(a,{zIndex:l,pointerEvents:"auto"}),g={width:a.width,height:a.height},E={id:t,props:n,value:r,onChange:s,onBlur:i,readOnly:!1,mode:it.FORM,dimensions:{widthPx:g.width,heightPx:g.height},validationState:c},y=e.Renderer;return o.jsx("div",{className:m,style:v,"data-testid":"editing-block","data-block-id":t,"data-plugin-kind":e.kind,children:o.jsx(y,{ref:p,...E})})},cs=u.forwardRef(ls),qn=u.memo(cs);function Kn(t){const[e,n]=u.useState({editingBlockId:null,...t}),r=u.useCallback(s=>{n(i=>{switch(s.type){case H.START_PRESS:{const a=s.selectedBlockIds||[s.blockId];return{...i,dragging:{type:nt.MOVE,blockIds:a,startGrid:s.startGrid,currentGrid:s.startGrid,isOutside:!1}}}case H.UPDATE_DRAG:return i.dragging?{...i,dragging:{...i.dragging,currentGrid:s.currentGrid,currentMousePx:s.currentMousePx,isOutside:s.isOutside??!1}}:i;case H.END_DRAG:return{...i,dragging:void 0};case H.CANCEL_DRAG:return{...i,dragging:void 0};case H.EDIT:return{...i,editingBlockId:s.blockId};case H.END_EDIT:return{...i,editingBlockId:null};case H.START_INSERT:return{...i,dragging:{type:nt.INSERT,blockIds:[],startGrid:{col:0,row:0},currentGrid:{col:0,row:0},pluginKind:s.pluginKind,defaultSize:s.defaultSize,isOutside:!1}};case H.CANCEL_INSERT:return{...i,dragging:void 0};case H.START_RESIZE:return{...i,dragging:{type:nt.RESIZE,blockIds:[s.blockId],startGrid:s.startGrid,currentGrid:s.startGrid,handle:s.handle,isOutside:!1}};default:return i}})},[]);return[e,r]}const Ke=u.memo(({blocks:t,selectedBlockIds:e,isDragging:n,draggingState:r,getBlockRectPx:s,onResizeStart:i,selectionStyle:a=Xt,handleStyle:l=fe,selectBorderZIndex:c=Z.select_border,blockHandlesZIndex:m=Z.block_handles})=>{if(n&&(r==null?void 0:r.type)!==nt.RESIZE)return null;const p=Array.from(new Set(e));return o.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:p.map(v=>{const g=t.find(f=>f.id===v);if(!g)return null;const y=(r==null?void 0:r.type)===nt.RESIZE&&r.blockIds.includes(v)?r==null?void 0:r.handle:null;return o.jsx(St,{block:g,rect:s(g),showHandles:!0,onResizeStart:(f,x)=>i(f,x,v),activeHandle:y,selectionStyle:a,handleStyle:l,selectBorderZIndex:c,blockHandlesZIndex:m},g.id)})})});Ke.displayName="SelectionLayer";function Zn(t,e,n,r){const s=n-e.w,i=r-e.h;return{x:Math.max(0,Math.min(t.x,s)),y:Math.max(0,Math.min(t.y,i))}}function Pe(t,e,n){const{x:r,y:s}=t;for(let i=e.length-1;i>=0;i--){const a=e[i];if(!a)continue;const l=n(a);if(r>=l.left&&r<=l.left+l.width&&s>=l.top&&s<=l.top+l.height)return a.id}return null}const Ze=u.memo(({blocks:t,pluginRegistry:e,gridLength:n,getBlockRectPx:r,getColIndex:s,getRowIndex:i,state:a,onChange:l,selectedBlockIds:c,onSelectionChange:m,onBlockChange:d,scale:p=1,className:v="",selectionStyle:g,handleStyle:E,editBlockZIndex:y=G.EDIT_BLOCK,selectBorderZIndex:f=Z.select_border,blockHandlesZIndex:x=Z.block_handles,dragGhostZIndex:h=Z.block_ghost})=>{const w=u.useRef(null),N=u.useRef(null),I=ae(a);u.useEffect(()=>{I===lt.EDITING&&a.editingBlockId&&setTimeout(()=>{var $;($=N.current)==null||$.focus()},0)},[I,a.editingBlockId]),u.useEffect(()=>{const $=new Set(t.map(C=>C.id)),k=c.filter(C=>$.has(C));k.length!==c.length&&m(k)},[t,c,m]);const B=u.useCallback($=>{var O;if($.button!==0)return;const k=(O=w.current)==null?void 0:O.getBoundingClientRect();if(!k)return;const C=p??1,j={x:($.clientX-k.left)/C,y:($.clientY-k.top)/C},_=Pe(j,t,r);if(I===lt.EDITING){_!==a.editingBlockId&&(l({type:H.END_EDIT}),_||m([]));return}const R=s(j.x),T=i(j.y);if(_){$.stopPropagation();const U=c.includes(_);if(U&&$.shiftKey){const F=c.filter(b=>b!==_);m(F);return}else U?($.currentTarget.setPointerCapture($.pointerId),l({type:H.START_PRESS,blockId:_,startGrid:{col:R,row:T},selectedBlockIds:c})):($.currentTarget.setPointerCapture($.pointerId),$.shiftKey?m([...c,_]):(m([_]),l({type:H.START_PRESS,blockId:_,startGrid:{col:R,row:T},selectedBlockIds:[_]})))}else $.stopPropagation(),m([])},[t,r,s,i,I,c,m,l,p,a.editingBlockId]),D=u.useCallback($=>{var P;if(I!==lt.PRESSING&&I!==lt.DRAGGING||!a.dragging)return;const k=(P=w.current)==null?void 0:P.getBoundingClientRect();if(!k)return;const C=p??1,j=k.width/C,_=k.height/C,R=($.clientX-k.left)/C,T=($.clientY-k.top)/C,O=a.dragging.type!==nt.RESIZE&&(R<0||R>j||T<0||T>_),U=Math.max(0,Math.min(R,j)),F=Math.max(0,Math.min(T,_)),b=s(U),M=i(F);l({type:H.UPDATE_DRAG,currentGrid:{col:b,row:M},currentMousePx:{x:R,y:T},isOutside:O})},[I,a.dragging,s,i,l,p]),A=u.useCallback($=>{if(I===lt.DRAGGING&&a.dragging){if(a.dragging.isOutside){a.dragging.type===nt.MOVE&&(d==null||d({type:ct.DELETE,blockIds:a.dragging.blockIds}),m([])),l({type:H.END_DRAG}),$.currentTarget.releasePointerCapture($.pointerId);return}const k=a.dragging.currentGrid.col-a.dragging.startGrid.col,C=a.dragging.currentGrid.row-a.dragging.startGrid.row;if(a.dragging.type===nt.MOVE){if(k!==0||C!==0){const j=a.dragging.blockIds.map(T=>t.find(O=>O.id===T)).filter(Boolean);if(j.length===0){l({type:H.END_DRAG}),$.currentTarget.releasePointerCapture($.pointerId);return}const _=We(j,k,C,n.cols,n.rows),R=j.map(T=>{const O=_.find(U=>U.blockId===T.id);return O?{...T,layout:{...T.layout,x:O.x,y:O.y}}:T});d==null||d({type:ct.MOVE,blockIds:a.dragging.blockIds,blocks:R})}}else if(a.dragging.type===nt.INSERT){const{pluginKind:j,currentGrid:_,defaultSize:R}=a.dragging;if(j&&R){const T=e[j];if(T){const{x:O,y:U}=Zn({x:_.col,y:_.row},{w:R.w,h:R.h},n.cols,n.rows),F=Nt(T,{x:O,y:U,w:R.w,h:R.h});d==null||d({type:ct.ADD,blockIds:[F.id],blocks:[F]})}}}else if(a.dragging.type===nt.RESIZE){const j=a.dragging.blockIds[0],_=t.find(T=>T.id===j),R=a.dragging.handle;if(_&&R&&(k!==0||C!==0)){const T=He({layout:_.layout,handle:R,deltaCol:k,deltaRow:C,gridCols:n.cols,gridRows:n.rows});(T.x!==_.layout.x||T.y!==_.layout.y||T.w!==_.layout.w||T.h!==_.layout.h)&&(d==null||d({type:ct.RESIZE,blockIds:[_.id],blocks:[{..._,layout:T}]}))}}l({type:H.END_DRAG})}else I===lt.PRESSING&&a.dragging&&(a.dragging.isOutside&&a.dragging.type===nt.MOVE&&(d==null||d({type:ct.DELETE,blockIds:a.dragging.blockIds}),m([])),l({type:H.CANCEL_DRAG}));$.currentTarget.releasePointerCapture($.pointerId)},[I,a.dragging,t,n,e,d,l,m]),S=u.useCallback($=>{var R;const k=(R=w.current)==null?void 0:R.getBoundingClientRect();if(!k)return;const C=p??1,j={x:($.clientX-k.left)/C,y:($.clientY-k.top)/C},_=Pe(j,t,r);_&&(c.includes(_)||m([_]),l({type:H.EDIT,blockId:_}))},[t,r,l,m,p,c]),L=u.useCallback($=>{var k;if((I===lt.PRESSING||I===lt.DRAGGING)&&a.dragging){const C=(k=w.current)==null?void 0:k.getBoundingClientRect();if(C){const j=p??1,_=($.clientX-C.left)/j,R=($.clientY-C.top)/j,T=C.width/j,O=C.height/j,U=Math.max(0,Math.min(_,T)),F=Math.max(0,Math.min(R,O));l({type:H.UPDATE_DRAG,currentGrid:{col:s(U),row:i(F)},currentMousePx:{x:_,y:R},isOutside:!0})}}},[I,a.dragging,p,s,i,l]);return o.jsxs("div",{ref:w,className:v,style:{position:"absolute",inset:0,zIndex:G.INTERACTION_LAYER_BASE,pointerEvents:"auto",touchAction:"none"},role:"application","aria-label":"Interactive canvas layer",tabIndex:-1,onPointerDown:B,onPointerMove:D,onPointerUp:A,onPointerLeave:L,onDoubleClick:S,"data-testid":"interaction-layer",children:[a.editingBlockId&&(()=>{const $=t.find(C=>C.id===a.editingBlockId),k=$?e[$.kind]:null;return!$||!k?null:o.jsx(qn,{ref:N,id:$.id,plugin:k,props:$.props,value:$.initValue,onChange:C=>{d==null||d({type:ct.UPDATE,blockIds:[$.id],blocks:[{...$,initValue:C}]})},onBlur:C=>{d==null||d({type:ct.UPDATE,blockIds:[$.id],blocks:[{...$,initValue:C}]})},blockRectPx:r($),zIndex:y})})(),o.jsx(Ke,{blocks:t,selectedBlockIds:c,isDragging:I===lt.DRAGGING,draggingState:a.dragging,getBlockRectPx:r,onResizeStart:($,k,C)=>{var T;const j=(T=w.current)==null?void 0:T.getBoundingClientRect();if(!j)return;I===lt.EDITING&&l({type:H.END_EDIT}),$.currentTarget.setPointerCapture($.pointerId);const _=p??1,R={x:($.clientX-j.left)/_,y:($.clientY-j.top)/_};l({type:H.START_RESIZE,blockId:C,handle:k,startGrid:{col:s(R.x),row:i(R.y)}})},selectionStyle:g,handleStyle:E,selectBorderZIndex:f,blockHandlesZIndex:x}),o.jsx(qe,{blocks:t,pluginRegistry:e,gridLength:n,draggingState:a.dragging,getBlockRectPx:r,selectionStyle:g,ghostZIndex:h,selectBorderZIndex:f,blockHandlesZIndex:x})]})});Ze.displayName="InteractionLayer";function qt(t,e,n=W){const r=u.useMemo(()=>Y.fromDim(t.size.width),[t.size.width]),s=u.useMemo(()=>Y.fromDim(t.size.height),[t.size.height]),i=u.useMemo(()=>Y.fromDim(t.margin.top),[t.margin.top]),a=u.useMemo(()=>Y.fromDim(t.margin.bottom),[t.margin.bottom]),l=u.useMemo(()=>Y.fromDim(t.margin.left),[t.margin.left]),c=u.useMemo(()=>Y.fromDim(t.margin.right),[t.margin.right]),m=u.useMemo(()=>r-l-c,[r,l,c]),d=u.useMemo(()=>s-i-a,[s,i,a]),p=u.useMemo(()=>oe(e.cols,m),[e.cols,m]),v=u.useMemo(()=>oe(e.rows,d),[e.rows,d]),g=u.useMemo(()=>V.fromMm(r,n),[r,n]),E=u.useMemo(()=>V.fromMm(s,n),[s,n]),y=u.useMemo(()=>V.fromMm(i,n),[i,n]),f=u.useMemo(()=>V.fromMm(a,n),[a,n]),x=u.useMemo(()=>V.fromMm(l,n),[l,n]),h=u.useMemo(()=>V.fromMm(c,n),[c,n]),w=u.useMemo(()=>V.fromMm(m,n),[m,n]),N=u.useMemo(()=>V.fromMm(d,n),[d,n]),I=u.useMemo(()=>se(p,n),[p,n]),B=u.useMemo(()=>se(v,n),[v,n]),D=u.useMemo(()=>{const P=[0];for(const z of I){const ht=P[P.length-1]??0;P.push(ht+z)}return P},[I]),A=u.useMemo(()=>{const P=[0];for(const z of B){const ht=P[P.length-1]??0;P.push(ht+z)}return P},[B]),{step:S,windowPx:L}=u.useMemo(()=>Ie(D),[D]),{step:$,windowPx:k}=u.useMemo(()=>Ie(A),[A]),C=u.useMemo(()=>De(D,S,L),[D,S,L]),j=u.useMemo(()=>De(A,$,k),[A,$,k]),_=u.useCallback(P=>C(P-x),[C,x]),R=u.useCallback(P=>j(P-y),[j,y]),T=u.useMemo(()=>({cols:D,rows:A}),[D,A]),O=u.useMemo(()=>({width:g,height:E}),[g,E]),U=u.useMemo(()=>({top:y,bottom:f,left:x,right:h}),[y,f,x,h]),F=u.useMemo(()=>({width:w,height:N}),[w,N]),b=u.useMemo(()=>({canvas:O,margin:U,content:F}),[O,U,F]),M=u.useCallback(P=>{const{x:z,y:ht,w:Ot,h:q}=P.layout,ut=T.cols,bt=T.rows;if(!ut.length||!bt.length)return{left:0,top:0,width:0,height:0};const Kt=Math.min(Math.max(0,z),ut.length-1),hr=Math.min(Math.max(0,z+Ot),ut.length-1),ln=Math.min(Math.max(0,ht),bt.length-1),fr=Math.min(Math.max(0,ht+q),bt.length-1),pr=(ut[Kt]??0)+x,xr=(bt[ln]??0)+y,vr=(ut[hr]??0)-(ut[Kt]??0),br=(bt[fr]??0)-(bt[ln]??0);return{left:pr,top:xr,width:vr,height:br}},[T,x,y]);return{paperPx:b,gridPosPx:T,getColIndex:_,getRowIndex:R,getBlockRectPx:M}}const Jn=({schema:t,values:e,pluginRegistry:n,onValueChange:r,scale:s=1,className:i})=>{const{paperPx:a,gridPosPx:l,getBlockRectPx:c}=qt(t.paper,t.grid,W),m=u.useCallback((d,p)=>{r&&r(d,p)},[r]);return o.jsxs("div",{className:i,style:{position:"relative",width:`${a.canvas.width}px`,height:`${a.canvas.height}px`,margin:"0 auto",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",backgroundColor:"#fff",transform:s!==1?`scale(${s})`:void 0,transformOrigin:"top center"},children:[o.jsx(he,{paperPx:a,gridPosPxs:l,showGridLines:!1,showMargins:!1,showBorder:!1}),o.jsx(Lt,{blocks:t.blocks,pluginRegistry:n,mode:it.EDIT,values:e,getBlockRectPx:c,onValueChange:m,showGuides:!0,showBorder:!0})]})};Jn.displayName="NoteEdit";const Qn=u.memo(Jn),tr=({schema:t,pluginRegistry:e,selectedBlockIds:n=[],onSchemaChange:r,onSelectionChange:s,scale:i=1,className:a})=>{const[l,c]=Kn(),m=u.useRef(null),{paperPx:d,gridPosPx:p,getBlockRectPx:v,getColIndex:g,getRowIndex:E}=qt(t.paper,t.grid,W),y=u.useCallback(D=>{if(r)switch(D.type){case ct.MOVE:case ct.RESIZE:{if(!D.blocks)return;const A=t.blocks.map(S=>{var $;return(($=D.blocks)==null?void 0:$.find(k=>k.id===S.id))||S});r({...t,blocks:A});break}case ct.ADD:{if(!D.blocks)return;r({...t,blocks:[...t.blocks,...D.blocks]});break}case ct.DELETE:{const A=new Set(D.blockIds),S=t.blocks.filter(L=>!A.has(L.id));r({...t,blocks:S});break}case ct.UPDATE:{if(!D.blocks)return;const A=t.blocks.map(S=>{var C;const L=(C=D.blocks)==null?void 0:C.find(j=>j.id===S.id);if(!L)return S;const $=L.style?ie(L.style):L.style,k=L.props?ie(L.props):L.props;return{...S,...L,style:$,props:k}});r({...t,blocks:A});break}}},[t,r]),f=u.useCallback((D,A)=>{if(!r)return;const S=t.blocks.map(L=>L.id===D?{...L,initValue:A}:L);r({...t,blocks:S})},[t,r]),x=u.useCallback(D=>{s&&s(D)},[s]);u.useEffect(()=>{const D=zt.subscribe(A=>{var L;const S=ae(l);!A&&S===lt.DRAGGING&&((L=l.dragging)==null?void 0:L.type)===nt.INSERT&&c({type:H.CANCEL_INSERT})});return()=>D()},[l,c]),u.useEffect(()=>{const D=A=>{if(n.length===0)return;const S=A.target;S instanceof HTMLElement&&S.closest('[data-sidebar="true"]')||m.current&&!m.current.contains(S)&&s&&s([])};return document.addEventListener("mousedown",D),()=>{document.removeEventListener("mousedown",D)}},[n,s]);const h=u.useCallback((D,A,S)=>{if(!r)return;const L=A-1;if(D==="column"){const $=Ne(t.grid.cols,L,S,d.content.width);r({...t,grid:{...t.grid,cols:$}})}else{const $=Ne(t.grid.rows,L,S,d.content.height);r({...t,grid:{...t.grid,rows:$}})}},[t,d,r]),w=u.useCallback((D,A,S)=>{if(r)if(D==="column"){const L=[...t.grid.cols];L[A]=S,r({...t,grid:{...t.grid,cols:L}})}else{const L=[...t.grid.rows];L[A]=S,r({...t,grid:{...t.grid,rows:L}})}},[r,t]),N=u.useMemo(()=>t.blocks.reduce((D,A)=>(D[A.id]=A.initValue,D),{}),[t.blocks]),I=u.useCallback(()=>{const D=zt.get();!D||ae(l)===lt.DRAGGING||l.dragging||c({type:H.START_INSERT,pluginKind:D.kind,defaultSize:D.defaultSize})},[l,c]),B=u.useCallback(()=>{},[]);return o.jsxs("div",{ref:m,className:a,onPointerEnter:I,onPointerLeave:B,style:{position:"relative",width:`${d.canvas.width}px`,height:`${d.canvas.height}px`,margin:"0 auto",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",backgroundColor:"#fff",transform:i!==1?`scale(${i})`:void 0,transformOrigin:"top center"},children:[o.jsx(he,{paperPx:d,gridPosPxs:p,gridDimensions:{cols:t.grid.cols,rows:t.grid.rows},showGridLines:!0,showMargins:!0,showBorder:!0,showResizeHandles:!0,showDimensionLabels:!0,onGridResize:h,onDimensionChange:w,gridLineStyle:{color:"#e5e7eb",width:{value:1,unit:"px"},type:dt.SOLID},borderStyle:{all:{color:"#000000",width:{value:1,unit:"px"},type:dt.SOLID}}}),o.jsx(Lt,{blocks:t.blocks,pluginRegistry:e,mode:it.FORM,values:N,selectedBlockIds:n,getBlockRectPx:v,onValueChange:f,showGuides:!0,showBorder:!0}),o.jsx(Ze,{blocks:t.blocks,gridLength:{cols:t.grid.cols.length,rows:t.grid.rows.length},pluginRegistry:e,getBlockRectPx:v,getColIndex:g,getRowIndex:E,selectedBlockIds:n,onSelectionChange:x,state:l,onChange:c,onBlockChange:y,scale:i})]})};tr.displayName="NoteForm";const er=u.memo(tr),nr=({schema:t,values:e,pluginRegistry:n,scale:r=1,className:s})=>{const{paperPx:i,gridPosPx:a,getBlockRectPx:l}=qt(t.paper,t.grid,W);return o.jsxs("div",{className:s,style:{position:"relative",width:`${i.canvas.width}px`,height:`${i.canvas.height}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:[o.jsx(he,{paperPx:i,gridPosPxs:a,showGridLines:!1,showMargins:!1,showBorder:!1}),o.jsx(Lt,{blocks:t.blocks,pluginRegistry:n,mode:it.VIEW,values:e,getBlockRectPx:l,showGuides:!1,showBorder:!0})]})};nr.displayName="NoteView";const rr=u.memo(nr),or=({schema:t,values:e,mode:n,pluginRegistry:r,selectedBlockIds:s,onSchemaChange:i,onValuesChange:a,onSelectionChange:l,scale:c=1,className:m})=>{const d=u.useCallback((p,v)=>{if(a)if(v==null){const{[p]:g,...E}=e;a(E)}else a({...e,[p]:v})},[e,a]);return n===it.FORM?o.jsx(er,{schema:t,pluginRegistry:r,selectedBlockIds:s,onSchemaChange:i,onSelectionChange:l,scale:c,className:m}):n===it.EDIT?o.jsx(Qn,{schema:t,values:e,pluginRegistry:r,onValueChange:d,scale:c,className:m}):o.jsx(rr,{schema:t,values:e,pluginRegistry:r,scale:c,className:m})};or.displayName="NoteEditor";const us=u.memo(or),sr=({schema:t,values:e,pluginRegistry:n,className:r},s)=>{const i=u.useRef(null),{paperPx:a,getBlockRectPx:l}=qt(t.paper,t.grid,W);return u.useEffect(()=>{const{size:c}=t.paper,m=Y.fromDim(c.width),d=Y.fromDim(c.height),p=document.getElementById("printable-note-page-style");p&&p.remove();const v=document.createElement("style");return v.id="printable-note-page-style",v.textContent=`
63
63
  @media print {
64
64
  @page {
65
65
  size: ${m}mm ${d}mm;
66
66
  margin: 0;
67
67
  }
68
68
  }
69
- `,document.head.appendChild(v),()=>{const g=document.getElementById("printable-note-page-style");g&&g.remove()}},[t.paper]),u.useImperativeHandle(s,()=>({print:()=>{i.current&&$e(i.current,{title:"Document"})},openPrintPreview:()=>{i.current&&$e(i.current,{title:"Document"})}}),[]),r.jsx("div",{ref:i,className:o,style:{width:`${a.canvas.width}px`,height:`${a.canvas.height}px`,backgroundColor:"#fff",paddingTop:`${a.margin.top}px`,paddingLeft:`${a.margin.left}px`,paddingRight:`${a.margin.right}px`,paddingBottom:`${a.margin.bottom}px`,boxSizing:"border-box"},children:r.jsx("div",{style:{position:"relative",width:`${a.content.width}px`,height:`${a.content.height}px`},children:r.jsx(St,{blocks:t.blocks,pluginRegistry:n,mode:it.VIEW,values:e??{},getBlockRectPx:l,showGuides:!1,showBorder:!0})})})};sr.displayName="NotePrint";const ds=u.memo(u.forwardRef(sr));function vt(t,e){if(t.length===0)return;const n=(a,l)=>{let c=a;for(const m of l){if(c==null||typeof c!="object"||Array.isArray(c))return;c=c[m]}return c},o=e.split("."),s=n(t[0],o);return t.every(a=>n(a,o)===s)?s:void 0}const ms="_container_1tfjv_1",hs="_row_1tfjv_20",fs="_inputWrapper_1tfjv_37",ye={container:ms,row:hs,inputWrapper:fs},ir=({selectedBlocks:t,onUpdateBlocks:e})=>{if(t.length===0)return null;const n=o=>{const s={};t.forEach(i=>{s[i.id]={style:{...i.style,backgroundColor:o}}}),e(s)};return r.jsx("div",{className:ye.container,children:r.jsx("div",{className:ye.row,children:r.jsx("div",{className:ye.inputWrapper,children:r.jsx(Wt,{value:vt(t,"style.backgroundColor"),onChange:n,allowUndefined:!0,placeholder:"無色",height:24})})})})};function _t(t,e,n){const o=e.split("."),s=(i,a)=>{const l=o[a];if(a===o.length-1){if(n==null){const{[l]:d,...f}=i;return f}return{...i,[l]:n}}const c=(i==null?void 0:i[l])||{},m=s(c,a+1);if(Object.keys(m).length===0){const{[l]:d,...f}=i;return f}return{...i,[l]:m}};return s(t,0)}const ar=({selectedBlocks:t,onUpdateBlocks:e})=>{const n=(a,l,c)=>{const m={};t.forEach(d=>{var v,g,E;let f=_t(d.style||{},`border.${a}.${l}`,c);if(l==="type"&&c==null&&(f=_t(f,`border.${a}.width`,void 0),f=_t(f,`border.${a}.color`,void 0)),l==="type"&&c!==void 0&&c!==null){const y=(v=d.style)==null?void 0:v.border,p=y==null?void 0:y[a];p!=null&&p.width||(f=_t(f,`border.${a}.width`,{value:1,unit:"px"})),p!=null&&p.color||(f=_t(f,`border.${a}.color`,"#000000"))}if(l==="color"&&c!==void 0&&c!==null){const y=(g=d.style)==null?void 0:g.border,p=y==null?void 0:y[a];p!=null&&p.type||(f=_t(f,`border.${a}.type`,dt.SOLID)),p!=null&&p.width||(f=_t(f,`border.${a}.width`,{value:1,unit:"px"}))}if(l==="width"&&c!==void 0&&c!==null){const y=(E=d.style)==null?void 0:E.border,p=y==null?void 0:y[a];p!=null&&p.type||(f=_t(f,`border.${a}.type`,dt.SOLID)),p!=null&&p.color||(f=_t(f,`border.${a}.color`,"#000000"))}m[d.id]={style:f}}),e(m)},o=u.useMemo(()=>{var d;if(t.length!==1)return null;const a=t[0];if(!((d=a==null?void 0:a.style)!=null&&d.border))return null;const l=a.style.border;if(!l)return null;const c=f=>f?!(f.type&&!f.width):!0;return["all","top","right","bottom","left"].every(f=>c(l[f]))?new kt(l):null},[t]),s=a=>r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[r.jsx(wt,{value:vt(t,`style.border.${a}.type`),onChange:l=>n(a,"type",l),placeholder:"スタイル",height:24,options:[{label:"",value:void 0},{label:"実線",value:dt.SOLID},{label:"破線",value:dt.DASHED},{label:"点線",value:dt.DOTTED}]}),r.jsx(rt,{value:vt(t,`style.border.${a}.width`),onChange:l=>n(a,"width",l),placeholder:"太さ",height:24,allowedUnits:bn,min:1}),r.jsx(Wt,{value:vt(t,`style.border.${a}.color`),onChange:l=>n(a,"color",l),placeholder:"色",height:24,allowUndefined:!0})]}),i={flex:1,padding:"0 2px",fontSize:"12px",minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"};return r.jsxs("div",{style:{display:"flex",flexDirection:"row",padding:"4px",alignItems:"stretch"},children:[r.jsx("div",{style:{flex:"0 0 30%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:r.jsxs("div",{style:{width:"80px",height:"80px",backgroundColor:"transparent",border:"transparent",borderRadius:"0.25rem",display:"flex",alignItems:"center",justifyContent:"center",position:"relative"},children:[r.jsxs("svg",{width:"80",height:"80",viewBox:"0 0 80 80",style:{position:"absolute",top:0,left:0,opacity:.3,pointerEvents:"none"},children:[r.jsx("title",{children:"枠線ガイド"}),r.jsx("line",{x1:"40",y1:"0",x2:"40",y2:"80",stroke:"#9ca3af",strokeWidth:"1",strokeDasharray:"4 2"}),r.jsx("line",{x1:"0",y1:"40",x2:"80",y2:"40",stroke:"#9ca3af",strokeWidth:"1",strokeDasharray:"4 2"})]}),o?r.jsx("div",{style:{position:"absolute",top:0,left:0,width:"80px",height:"80px",pointerEvents:"none"},children:r.jsx(It,{width:80,height:80,border:o})}):r.jsxs("svg",{width:"80",height:"80",viewBox:"0 0 80 80",style:{position:"absolute",top:0,left:0,opacity:.3},children:[r.jsx("title",{children:"枠線未設定"}),r.jsx("rect",{x:"0",y:"0",width:"80",height:"80",fill:"none",stroke:"#9ca3af",strokeWidth:"1",strokeDasharray:"4 2"})]})]})}),r.jsx("div",{style:{flex:"0 0 70%",minWidth:0,padding:"0 0 2px 0"},children:r.jsxs(Oe,{defaultValue:"all",variant:"segmented",children:[r.jsx("div",{style:{width:"100%"},children:r.jsxs(Ge,{style:{width:"100%",display:"flex"},children:[r.jsx(yt,{value:"all",height:24,style:i,children:"共通"}),r.jsx(yt,{value:"top",height:24,style:i,children:"上"}),r.jsx(yt,{value:"bottom",height:24,style:i,children:"下"}),r.jsx(yt,{value:"left",height:24,style:i,children:"左"}),r.jsx(yt,{value:"right",height:24,style:i,children:"右"})]})}),r.jsxs("div",{style:{marginTop:"4px"},children:[r.jsx(Et,{value:"all",children:s("all")}),r.jsx(Et,{value:"top",children:s("top")}),r.jsx(Et,{value:"bottom",children:s("bottom")}),r.jsx(Et,{value:"left",children:s("left")}),r.jsx(Et,{value:"right",children:s("right")})]})]})})]})},ps="_container_1daw7_1",xs="_grid_1daw7_19",vs="_field_1daw7_26",bs="_label_1daw7_33",gs="_inputWrapper_1daw7_43",at={container:ps,grid:xs,field:vs,label:bs,inputWrapper:gs},lr=({selectedBlocks:t,onUpdateBlocks:e,gridSize:n})=>{if(t.length===0)return null;const o=t.length>1,s=o?Math.min(...t.map(l=>l.layout.x)):void 0,i=o?Math.min(...t.map(l=>l.layout.y)):void 0,a=(l,c)=>{if(c===void 0)return;const m={};if(o&&(l==="x"||l==="y")){const d=l==="x"?s:i;if(d===void 0)return;const f=Math.max(...t.map(x=>x.layout.x+x.layout.w)),v=Math.max(...t.map(x=>x.layout.y+x.layout.h)),g=f-(s??0),E=v-(i??0);let y=c;l==="x"&&n?y=Math.max(0,Math.min(c,n.cols-g)):l==="y"&&n?y=Math.max(0,Math.min(c,n.rows-E)):y=Math.max(0,c);const p=y-d;t.forEach(x=>{const h=x.layout[l]+p;m[x.id]={layout:{...x.layout,[l]:h}}})}else t.forEach(d=>{let f=c;if(l==="x"&&n)f=Math.max(0,Math.min(c,n.cols-d.layout.w));else if(l==="y"&&n)f=Math.max(0,Math.min(c,n.rows-d.layout.h));else if(l==="w"&&n){const v=n.cols-d.layout.x;f=Math.max(1,Math.min(c,v))}else if(l==="h"&&n){const v=n.rows-d.layout.y;f=Math.max(1,Math.min(c,v))}else l==="w"||l==="h"?f=Math.max(1,c):f=Math.max(0,c);m[d.id]={layout:{...d.layout,[l]:f}}});e(m)};return r.jsx("div",{className:at.container,children:r.jsxs("div",{className:at.grid,children:[r.jsxs("div",{className:at.field,children:[r.jsx("span",{className:at.label,children:"X"}),r.jsx("div",{className:at.inputWrapper,children:r.jsx(st,{value:o?s:vt(t,"layout.x"),onChange:l=>a("x",l),min:0,max:n?n.cols-1:void 0,integer:!0,height:22,placeholder:"-"})})]}),r.jsxs("div",{className:at.field,children:[r.jsx("span",{className:at.label,children:"Y"}),r.jsx("div",{className:at.inputWrapper,children:r.jsx(st,{value:o?i:vt(t,"layout.y"),onChange:l=>a("y",l),min:0,max:n?n.rows-1:void 0,integer:!0,height:22,placeholder:"-"})})]}),!o&&r.jsxs("div",{className:at.field,children:[r.jsx("span",{className:at.label,children:"W"}),r.jsx("div",{className:at.inputWrapper,children:r.jsx(st,{value:vt(t,"layout.w"),onChange:l=>a("w",l),min:1,max:n==null?void 0:n.cols,integer:!0,height:22,placeholder:"-"})})]}),!o&&r.jsxs("div",{className:at.field,children:[r.jsx("span",{className:at.label,children:"H"}),r.jsx("div",{className:at.inputWrapper,children:r.jsx(st,{value:vt(t,"layout.h"),onChange:l=>a("h",l),min:1,max:n==null?void 0:n.rows,integer:!0,height:22,placeholder:"-"})})]})]})})},ws="_container_1h4w8_1",_s="_row_1h4w8_10",ys="_label_1h4w8_16",Es="_inputWrapper_1h4w8_25",Dt={container:ws,row:_s,label:ys,inputWrapper:Es},cr=({selectedBlocks:t,onUpdateBlocks:e})=>{const[n,o]=u.useState(""),s=t[0];u.useEffect(()=>{t.length===1&&s&&o(s.id)},[t,s]);const i=()=>{if(!s)return;const c=s.id,m=n.trim();if(m===c||!m){o(c);return}e({[c]:{id:m}})},a=c=>{o(c??"")},l=c=>{const m={};t.forEach(d=>{m[d.id]={behavior:{...d.behavior,readOnly:!!c}}}),e(m)};return r.jsxs("div",{className:Dt.container,children:[t.length===1&&r.jsxs("div",{className:Dt.row,children:[r.jsx("span",{className:Dt.label,children:"ID"}),r.jsx("div",{className:Dt.inputWrapper,children:r.jsx(At,{value:n,onChange:a,onBlur:i,placeholder:"IDを入力",height:16})})]}),t.length>0&&r.jsx("div",{className:Dt.row,children:r.jsx("div",{className:Dt.inputWrapper,children:r.jsx(xt,{label:"読み取り専用",value:!!vt(t,"behavior.readOnly"),onChange:l})})})]})},js="_container_wa11y_1",Ns="_scrollArea_wa11y_18",Is="_section_wa11y_26",Ds="_sectionTitle_wa11y_35",$s="_subsection_wa11y_47",Ts="_subsectionTitle_wa11y_51",Rs="_fields_wa11y_59",Ms="_emptyState_wa11y_69",ot={container:js,scrollArea:Ns,section:Is,sectionTitle:Ds,subsection:$s,subsectionTitle:Ts,fields:Rs,emptyState:Ms},Cs="_field_qo0ef_1",Ps="_label_qo0ef_7",As="_mixed_qo0ef_15",ks="_description_qo0ef_22",Qt={field:Cs,label:Ps,mixed:As,description:ks},pe=u.memo(({propertyKey:t,definition:e,selectedBlocks:n,onChange:o})=>{var d;const s=e.Component;if(!s)return null;const i=vt(n,`props.${t}`),c=!n.map(f=>f.props[t]).every(f=>f===void 0)&&i===void 0&&n.length>1,m={value:c?void 0:i!==void 0?i:e.defaultValue,onChange:f=>o(t,f),readOnly:!1,config:{...e.config,placeholder:c?"複数選択中 (値が異なります)":(d=e.config)==null?void 0:d.placeholder}};return r.jsxs("div",{className:Qt.field,children:[e.label&&r.jsx("div",{className:Qt.label,title:e.description,children:e.label}),r.jsx(s,{...m}),c&&r.jsx("span",{className:Qt.mixed,children:"(混在)"}),e.description&&r.jsx("p",{className:Qt.description,children:e.description})]})});pe.displayName="PropertyField";function Ss(t){return t!==!1}const Je=u.memo(({selectedBlocks:t,pluginRegistry:e,onUpdateBlocks:n,gridSize:o,className:s=""})=>{const i=t[0],a=i?e[i.kind]:void 0,l=u.useMemo(()=>{var f;if(t.length===0)return!1;const d=(f=t[0])==null?void 0:f.kind;return t.every(v=>v.kind===d)},[t]),c=u.useMemo(()=>{if(!i||!a)return{};const d={};let f;if(l)f=Object.entries(a.properties);else{const v=t.map(p=>e[p.kind]).filter(p=>p!==void 0);if(v.length===0)return{};const g=v[0];if(!g)return{};const E=new Set(Object.keys(g.properties));f=Array.from(E).filter(p=>v.every(x=>p in x.properties)).map(p=>{const x=a.properties[p];return x?[p,x]:null}).filter(p=>p!==null)}return f.forEach(([v,g])=>{if(!Ss(g)||t.length>1&&g.disableInMultiSelection||g.condition&&!g.condition(i.props))return;const E=g.group||"基本";d[E]||(d[E]=[]),g.Component&&d[E].push({key:v,definition:g})}),d},[a,e,t,i,l]),m=(d,f)=>{const v={};t.forEach(g=>{v[g.id]={props:{...g.props,[d]:f}}}),n(v)};return t.length===0?r.jsx("div",{className:`${ot.container} ${s}`,children:r.jsxs("div",{className:ot.emptyState,children:["ブロックを選択すると",r.jsx("br",{}),"プロパティが表示されます"]})}):r.jsx("div",{className:`${ot.container} ${s}`,children:r.jsxs("div",{className:ot.scrollArea,children:[r.jsxs("div",{className:ot.section,children:[r.jsx("div",{className:ot.sectionTitle,children:"配置・サイズ"}),r.jsx(lr,{selectedBlocks:t,onUpdateBlocks:n,gridSize:o})]}),r.jsxs("div",{className:ot.section,children:[r.jsx("div",{className:ot.sectionTitle,children:"背景"}),r.jsx(ir,{selectedBlocks:t,onUpdateBlocks:n})]}),r.jsxs("div",{className:ot.section,children:[r.jsx("div",{className:ot.sectionTitle,children:"枠線"}),r.jsx(ar,{selectedBlocks:t,onUpdateBlocks:n})]}),a&&Object.keys(c).length>0&&r.jsx("div",{className:ot.section,children:Object.entries(c).map(([d,f])=>r.jsxs("div",{className:ot.subsection,children:[r.jsx("div",{className:ot.subsectionTitle,children:d}),r.jsx("div",{className:ot.fields,children:f.map(({key:v,definition:g})=>r.jsx(pe,{propertyKey:v,definition:g,selectedBlocks:t,onChange:m},v))})]},d))}),r.jsxs("div",{className:ot.section,children:[r.jsx("div",{className:ot.sectionTitle,children:"基本設定"}),r.jsx(cr,{selectedBlocks:t,onUpdateBlocks:n})]})]})})});Je.displayName="BlockPropertyPanel";const Ls="_panel_1h33v_1",Os="_header_1h33v_11",Gs="_group_1h33v_18",Bs="_groupTitle_1h33v_26",Vs="_groupContent_1h33v_36",Vt={panel:Ls,header:Os,group:Gs,groupTitle:Bs,groupContent:Vs};function Us(t){return t!==!1}const Fs=({selectedBlocks:t,pluginRegistry:e,onUpdateBlocks:n})=>{const o=t[0],s=o?e[o.kind]:void 0,i=u.useMemo(()=>{if(!o||!s)return{};const l={};return Object.entries(s.properties).forEach(([c,m])=>{if(!Us(m)||t.length>1&&m.disableInMultiSelection||m.condition&&!m.condition(o.props))return;const d=m.group||"基本";l[d]||(l[d]=[]),m.Component&&l[d].push({key:c,definition:m})}),l},[s,t.length,o]),a=(l,c)=>{const m={};t.forEach(d=>{m[d.id]={props:{...d.props,[l]:c}}}),n(m)};return!o||!s||t.length===0?null:r.jsxs("div",{className:Vt.panel,children:[r.jsx("div",{className:Vt.header,children:t.length>1?`${t.length}個のブロック`:s.meta.displayName}),Object.entries(i).map(([l,c])=>r.jsxs("div",{className:Vt.group,children:[r.jsx("div",{className:Vt.groupTitle,children:l}),r.jsx("div",{className:Vt.groupContent,children:c.map(({key:m,definition:d})=>r.jsx(pe,{propertyKey:m,definition:d,selectedBlocks:t,onChange:a},m))})]},l))]})},zs="_panel_1ekwd_6",Ws="_title_1ekwd_10",Ys="_content_1ekwd_22",Hs="_description_1ekwd_29",Xs="_list_1ekwd_35",qs="_item_1ekwd_44",Ks="_dragging_1ekwd_61",Zs="_dragOver_1ekwd_66",Js="_dragHandle_1ekwd_71",Qs="_itemInfo_1ekwd_86",ti="_itemId_1ekwd_93",ei="_itemMeta_1ekwd_98",ni="_itemKind_1ekwd_105",ri="_itemActions_1ekwd_113",oi="_actionButton_1ekwd_118",si="_empty_1ekwd_154",J={panel:zs,title:Ws,content:Ys,description:Hs,list:Xs,item:qs,dragging:Ks,dragOver:Zs,dragHandle:Js,itemInfo:Qs,itemId:ti,itemMeta:ei,itemKind:ni,itemActions:ri,actionButton:oi,empty:si},Qe=({blocks:t,onBlocksChange:e})=>{const[n,o]=u.useState(null),[s,i]=u.useState(null),a=[...t].reverse(),l=u.useCallback(p=>{const x=t.findIndex(N=>N.id===p);if(x===-1||x===t.length-1)return;const h=[...t],[w]=h.splice(x,1);w&&(h.push(w),e(h))},[t,e]),c=u.useCallback(p=>{const x=t.findIndex(N=>N.id===p);if(x===-1||x===0)return;const h=[...t],[w]=h.splice(x,1);w&&(h.unshift(w),e(h))},[t,e]),m=u.useCallback(p=>{const x=t.findIndex(I=>I.id===p);if(x===-1||x===t.length-1)return;const h=[...t],w=h[x],N=h[x+1];!w||!N||(h[x]=N,h[x+1]=w,e(h))},[t,e]),d=u.useCallback(p=>{const x=t.findIndex(I=>I.id===p);if(x===-1||x===0)return;const h=[...t],w=h[x],N=h[x-1];!w||!N||(h[x]=N,h[x-1]=w,e(h))},[t,e]),f=u.useCallback((p,x)=>{var w;o(x),p.dataTransfer.effectAllowed="move";const h=t.length-1-x;p.currentTarget&&p.dataTransfer.setData("text/plain",((w=t[h])==null?void 0:w.id)||"")},[t]),v=u.useCallback(()=>{o(null),i(null)},[]),g=u.useCallback((p,x)=>{p.preventDefault(),p.dataTransfer.dropEffect="move",!(n===null||n===x)&&i(x)},[n]),E=u.useCallback(()=>{i(null)},[]),y=u.useCallback((p,x)=>{if(p.preventDefault(),n===null||n===x){o(null),i(null);return}const h=t.length-1-n,w=t.length-1-x,N=[...t],[I]=N.splice(h,1);I&&(N.splice(w,0,I),e(N),o(null),i(null))},[t,n,e]);return r.jsxs("div",{className:J.panel,children:[r.jsx("h3",{className:J.title,children:"ブロック順序"}),r.jsxs("div",{className:J.content,children:[r.jsx("p",{className:J.description,children:"上が最前面、下が最背面"}),r.jsx("ul",{className:J.list,children:a.map((p,x)=>{const h=t.length-1-x;return r.jsxs("li",{className:`${J.item} ${n===x?J.dragging:""} ${s===x?J.dragOver:""}`,onDragOver:w=>g(w,x),onDragLeave:E,onDrop:w=>y(w,x),children:[r.jsx("button",{type:"button",className:J.dragHandle,title:"ドラッグして並び替え",draggable:!0,onDragStart:w=>f(w,x),onDragEnd:v,children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[r.jsx("title",{children:"ドラッグハンドル"}),r.jsx("circle",{cx:"6",cy:"4",r:"1",fill:"currentColor"}),r.jsx("circle",{cx:"10",cy:"4",r:"1",fill:"currentColor"}),r.jsx("circle",{cx:"6",cy:"8",r:"1",fill:"currentColor"}),r.jsx("circle",{cx:"10",cy:"8",r:"1",fill:"currentColor"}),r.jsx("circle",{cx:"6",cy:"12",r:"1",fill:"currentColor"}),r.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor"})]})}),r.jsxs("div",{className:J.itemInfo,children:[r.jsx("div",{className:J.itemId,children:p.id}),r.jsx("div",{className:J.itemMeta,children:r.jsx("span",{className:J.itemKind,children:p.kind})})]}),r.jsxs("div",{className:J.itemActions,children:[r.jsx("button",{type:"button",className:J.actionButton,onClick:()=>l(p.id),title:"最前面へ","aria-label":"最前面へ移動",disabled:h===t.length-1,children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[r.jsx("title",{children:"最前面へ"}),r.jsx("path",{d:"M4 12v-8M8 12v-8M12 12v-8",stroke:"currentColor"}),r.jsx("path",{d:"M12 4h-8",stroke:"currentColor",strokeWidth:"2"})]})}),r.jsx("button",{type:"button",className:J.actionButton,onClick:()=>m(p.id),title:"前面へ","aria-label":"前面へ移動",disabled:h===t.length-1,children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[r.jsx("title",{children:"前面へ"}),r.jsx("path",{d:"M8 4v8",stroke:"currentColor"}),r.jsx("path",{d:"M5 7l3-3 3 3",stroke:"currentColor"})]})}),r.jsx("button",{type:"button",className:J.actionButton,onClick:()=>d(p.id),title:"背面へ","aria-label":"背面へ移動",disabled:h===0,children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[r.jsx("title",{children:"背面へ"}),r.jsx("path",{d:"M8 12v-8",stroke:"currentColor"}),r.jsx("path",{d:"M5 9l3 3 3-3",stroke:"currentColor"})]})}),r.jsx("button",{type:"button",className:J.actionButton,onClick:()=>c(p.id),title:"最背面へ","aria-label":"最背面へ移動",disabled:h===0,children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[r.jsx("title",{children:"最背面へ"}),r.jsx("path",{d:"M4 12v-8M8 12v-8M12 12v-8",stroke:"currentColor"}),r.jsx("path",{d:"M12 12h-8",stroke:"currentColor",strokeWidth:"2"})]})})]})]},p.id)})}),t.length===0&&r.jsx("div",{className:J.empty,children:"ブロックがありません"})]})]})};Qe.displayName="BlockOrderPanel";const tn=({schema:t,onSchemaChange:e})=>{const n=u.useCallback(i=>{e({...t,paper:i})},[t,e]),o=u.useCallback(i=>{e({...t,grid:i})},[t,e]),s=u.useCallback(i=>{e({...t,blocks:i})},[t,e]);return r.jsxs(Le,{children:[r.jsx(rn,{paper:t.paper,onPaperChange:n}),r.jsx(nn,{paper:t.paper,onPaperChange:n}),r.jsx(en,{grid:t.grid,onGridChange:o}),r.jsx(Qe,{blocks:t.blocks,onBlocksChange:s})]})};tn.displayName="CanvasPanel";const ii="_panel_1axyd_6",ai="_title_1axyd_10",li="_content_1axyd_22",ci="_field_1axyd_29",ui="_horizontal_1axyd_35",di="_label_1axyd_41",mi="_gridSizeRow_1axyd_52",gt={panel:ii,title:ai,content:li,field:ci,horizontal:ui,label:di,gridSizeRow:mi},en=({grid:t,onGridChange:e})=>{const n=u.useCallback(s=>{if(!s||s<1||s>100)return;const i=t.cols.length,a=[];if(s>i){a.push(...t.cols);for(let l=i;l<s;l++)a.push({value:1,unit:"fr"})}else a.push(...t.cols.slice(0,s));e({...t,cols:a})},[t,e]),o=u.useCallback(s=>{if(!s||s<1||s>100)return;const i=t.rows.length,a=[];if(s>i){a.push(...t.rows);for(let l=i;l<s;l++)a.push({value:1,unit:"fr"})}else a.push(...t.rows.slice(0,s));e({...t,rows:a})},[t,e]);return r.jsxs("div",{className:gt.panel,children:[r.jsx("h3",{className:gt.title,children:"グリッドサイズ"}),r.jsx("div",{className:gt.content,children:r.jsxs("div",{className:gt.gridSizeRow,children:[r.jsxs("div",{className:`${gt.field} ${gt.horizontal}`,children:[r.jsx("span",{className:gt.label,children:"列数"}),r.jsx(st,{value:t.cols.length,onChange:n,min:1,max:100,step:1})]}),r.jsxs("div",{className:`${gt.field} ${gt.horizontal}`,children:[r.jsx("span",{className:gt.label,children:"行数"}),r.jsx(st,{value:t.rows.length,onChange:o,min:1,max:100,step:1})]})]})})]})};en.displayName="GridSizePanel";const hi="_panel_qlcb6_6",fi="_header_qlcb6_10",pi="_title_qlcb6_20",xi="_headerActions_qlcb6_29",vi="_content_qlcb6_33",bi="_field_qlcb6_37",gi="_horizontal_qlcb6_43",wi="_label_qlcb6_49",_i="_marginsGrid_qlcb6_60",yi="_topMargin_qlcb6_66",Ei="_bottomMargin_qlcb6_67",ji="_sideMargins_qlcb6_73",K={panel:hi,header:fi,title:pi,headerActions:xi,content:vi,field:bi,horizontal:gi,label:wi,marginsGrid:_i,topMargin:yi,bottomMargin:Ei,sideMargins:ji},nn=({paper:t,onPaperChange:e})=>{const[n,o]=u.useState(!1),s=u.useCallback(m=>{m!==void 0&&o(m)},[]),i=u.useCallback(m=>{if(!m)return;const d=n?{top:m,right:m,bottom:m,left:m}:{...t.margin,top:m};e({...t,margin:d})},[t,e,n]),a=u.useCallback(m=>{m&&e({...t,margin:{...t.margin,right:m}})},[t,e]),l=u.useCallback(m=>{m&&e({...t,margin:{...t.margin,bottom:m}})},[t,e]),c=u.useCallback(m=>{m&&e({...t,margin:{...t.margin,left:m}})},[t,e]);return r.jsxs("div",{className:K.panel,children:[r.jsxs("div",{className:K.header,children:[r.jsx("h3",{className:K.title,children:"マージン"}),r.jsx("div",{className:K.headerActions,children:r.jsx(xt,{value:n,onChange:s,label:"全辺を一括設定"})})]}),r.jsx("div",{className:K.content,children:n?r.jsxs("div",{className:`${K.field} ${K.horizontal}`,children:[r.jsx("span",{className:K.label,children:"全辺"}),r.jsx(rt,{value:t.margin.top,onChange:i,allowedUnits:["mm","cm","inch"],min:0,max:1e3})]}):r.jsxs("div",{className:K.marginsGrid,children:[r.jsx("div",{className:`${K.field} ${K.horizontal} ${K.topMargin}`,children:r.jsx(rt,{value:t.margin.top,onChange:i,allowedUnits:["mm","cm","inch"],min:0,max:1e3})}),r.jsxs("div",{className:K.sideMargins,children:[r.jsx("div",{className:`${K.field} ${K.horizontal}`,children:r.jsx(rt,{value:t.margin.left,onChange:c,allowedUnits:["mm","cm","inch"],min:0,max:1e3})}),r.jsx("div",{className:`${K.field} ${K.horizontal}`,children:r.jsx(rt,{value:t.margin.right,onChange:a,allowedUnits:["mm","cm","inch"],min:0,max:1e3})})]}),r.jsx("div",{className:`${K.field} ${K.horizontal} ${K.bottomMargin}`,children:r.jsx(rt,{value:t.margin.bottom,onChange:l,allowedUnits:["mm","cm","inch"],min:0,max:1e3})})]})})]})};nn.displayName="MarginPanel";const Ni="_panel_16d9o_6",Ii="_title_16d9o_10",Di="_content_16d9o_22",$i="_field_16d9o_29",Ti="_horizontal_16d9o_35",Ri="_label_16d9o_41",Mi="_dimensionsRow_16d9o_52",ft={panel:Ni,title:Ii,content:Di,field:$i,horizontal:Ti,label:Ri,dimensionsRow:Mi},rn=({paper:t,onPaperChange:e})=>{const n=u.useMemo(()=>[{value:pt.A4,label:"A4 (210 × 297 mm)"},{value:pt.A3,label:"A3 (297 × 420 mm)"},{value:pt.B5,label:"B5 (182 × 257 mm)"},{value:pt.LETTER,label:"Letter (8.5 × 11 inch)"},{value:pt.LEGAL,label:"Legal (8.5 × 14 inch)"},{value:pt.CUSTOM,label:"カスタム"}],[]),o=u.useCallback(l=>{if(!l)return;const c=Be[l];e({...t,size:c})},[t,e]),s=u.useCallback(l=>{if(!l)return;const c={...t.size,preset:pt.CUSTOM,width:l};e({...t,size:c})},[t,e]),i=u.useCallback(l=>{if(!l)return;const c={...t.size,preset:pt.CUSTOM,height:l};e({...t,size:c})},[t,e]),a=t.size.preset===pt.CUSTOM;return r.jsxs("div",{className:ft.panel,children:[r.jsx("h3",{className:ft.title,children:"用紙サイズ"}),r.jsxs("div",{className:ft.content,children:[r.jsx("div",{className:ft.field,children:r.jsx(wt,{value:t.size.preset,options:n,onChange:o})}),a&&r.jsxs("div",{className:ft.dimensionsRow,children:[r.jsxs("div",{className:`${ft.field} ${ft.horizontal}`,children:[r.jsx("span",{className:ft.label,children:"幅"}),r.jsx(rt,{value:t.size.width,onChange:s,allowedUnits:["mm","cm","inch"],min:t.margin.left.value+t.margin.right.value+1,max:500})]}),r.jsxs("div",{className:`${ft.field} ${ft.horizontal}`,children:[r.jsx("span",{className:ft.label,children:"高さ"}),r.jsx(rt,{value:t.size.height,onChange:i,allowedUnits:["mm","cm","inch"],min:t.margin.top.value+t.margin.bottom.value+1,max:500})]})]})]})]})};rn.displayName="PaperSizePanel";const Ci="_section_p4xnx_6",Pi="_title_p4xnx_14",Ai="_content_p4xnx_26",ki="_buttonGroup_p4xnx_33",Si="_button_p4xnx_33",Li="_error_p4xnx_65",Q={section:Ci,title:Pi,content:Ai,buttonGroup:ki,button:Si,error:Li},on=({schema:t,values:e,onSchemaChange:n,onValuesChange:o})=>{const[s,i]=u.useState(""),a=u.useRef(null),l=u.useRef(null),c=u.useCallback(()=>{try{const h=Re(t,!0),w=new Blob([h],{type:"application/json"}),N=URL.createObjectURL(w),I=document.createElement("a");I.href=N,I.download="schema.json",I.click(),URL.revokeObjectURL(N),i("")}catch(h){i(`エクスポートエラー: ${h instanceof Error?h.message:String(h)}`)}},[t]),m=u.useCallback(async()=>{try{const h=Re(t,!0);await navigator.clipboard.writeText(h),i(""),alert("スキーマをクリップボードにコピーしました")}catch(h){i(`クリップボードエラー: ${h instanceof Error?h.message:String(h)}`)}},[t]),d=u.useCallback(()=>{var h;(h=a.current)==null||h.click()},[]),f=u.useCallback(h=>{var I;const w=(I=h.target.files)==null?void 0:I[0];if(!w)return;const N=new FileReader;N.onload=B=>{var $;try{const A=($=B.target)==null?void 0:$.result,L=Te(A);n(L),i(""),alert("スキーマをインポートしました")}catch(A){i(`インポートエラー: ${A instanceof Error?A.message:String(A)}`)}},N.readAsText(w),h.target.value=""},[n]),v=u.useCallback(async()=>{try{const h=await navigator.clipboard.readText(),w=Te(h);n(w),i(""),alert("スキーマをインポートしました")}catch(h){i(`インポートエラー: ${h instanceof Error?h.message:String(h)}`)}},[n]),g=u.useCallback(()=>{try{const h=Ce(e,!0),w=new Blob([h],{type:"application/json"}),N=URL.createObjectURL(w),I=document.createElement("a");I.href=N,I.download="values.json",I.click(),URL.revokeObjectURL(N),i("")}catch(h){i(`エクスポートエラー: ${h instanceof Error?h.message:String(h)}`)}},[e]),E=u.useCallback(async()=>{try{const h=Ce(e,!0);await navigator.clipboard.writeText(h),i(""),alert("値をクリップボードにコピーしました")}catch(h){i(`クリップボードエラー: ${h instanceof Error?h.message:String(h)}`)}},[e]),y=u.useCallback(()=>{var h;(h=l.current)==null||h.click()},[]),p=u.useCallback(h=>{var I;const w=(I=h.target.files)==null?void 0:I[0];if(!w)return;const N=new FileReader;N.onload=B=>{var $;try{const A=($=B.target)==null?void 0:$.result,L=Me(A);o(L),i(""),alert("値をインポートしました")}catch(A){i(`インポートエラー: ${A instanceof Error?A.message:String(A)}`)}},N.readAsText(w),h.target.value=""},[o]),x=u.useCallback(async()=>{try{const h=await navigator.clipboard.readText(),w=Me(h);o(w),i(""),alert("値をインポートしました")}catch(h){i(`インポートエラー: ${h instanceof Error?h.message:String(h)}`)}},[o]);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:Q.section,children:[r.jsx("h3",{className:Q.title,children:"スキーマ"}),r.jsxs("div",{className:Q.content,children:[r.jsxs("div",{className:Q.buttonGroup,children:[r.jsx("button",{type:"button",className:Q.button,onClick:c,children:"📥 ファイルにエクスポート"}),r.jsx("button",{type:"button",className:Q.button,onClick:m,children:"📋 クリップボードにコピー"})]}),r.jsxs("div",{className:Q.buttonGroup,children:[r.jsx("button",{type:"button",className:Q.button,onClick:d,children:"📤 ファイルからインポート"}),r.jsx("button",{type:"button",className:Q.button,onClick:v,children:"📋 クリップボードからペースト"})]}),r.jsx("input",{ref:a,type:"file",accept:".json",style:{display:"none"},onChange:f})]})]}),r.jsxs("div",{className:Q.section,children:[r.jsx("h3",{className:Q.title,children:"値"}),r.jsxs("div",{className:Q.content,children:[r.jsxs("div",{className:Q.buttonGroup,children:[r.jsx("button",{type:"button",className:Q.button,onClick:g,children:"📥 ファイルにエクスポート"}),r.jsx("button",{type:"button",className:Q.button,onClick:E,children:"📋 クリップボードにコピー"})]}),r.jsxs("div",{className:Q.buttonGroup,children:[r.jsx("button",{type:"button",className:Q.button,onClick:y,children:"📤 ファイルからインポート"}),r.jsx("button",{type:"button",className:Q.button,onClick:x,children:"📋 クリップボードからペースト"})]}),r.jsx("input",{ref:l,type:"file",accept:".json",style:{display:"none"},onChange:p})]})]}),s&&r.jsx("div",{className:Q.error,role:"alert",children:s})]})};on.displayName="ImportExportPanel";const sn=({schema:t,values:e,onSchemaChange:n,onValuesChange:o})=>r.jsx(Le,{children:r.jsx(on,{schema:t,values:e,onSchemaChange:n,onValuesChange:o})});sn.displayName="OtherPanel";const Oi="_container_6c3ft_3",Gi="_paletteItems_6c3ft_32",Bi="_item_6c3ft_44",Vi="_itemName_6c3ft_70",Ui="_itemPreview_6c3ft_98",Ft={container:Oi,paletteItems:Gi,item:Bi,itemName:Vi,itemPreview:Ui},an=({plugins:t,className:e})=>{const[n,o]=u.useState(null),s=u.useCallback((i,a)=>{o({plugin:i,mousePos:a,isOverCanvas:!1});const l=m=>{const d=document.elementFromPoint(m.clientX,m.clientY),f=!!(d!=null&&d.closest('[data-testid="interaction-layer"]'));o(v=>v?{...v,mousePos:{x:m.clientX,y:m.clientY},isOverCanvas:f}:null)},c=()=>{o(null),window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",c)};window.addEventListener("pointermove",l),window.addEventListener("pointerup",c)},[]);return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:`${Ft.container} ${e||""}`,children:r.jsx("div",{className:Ft.paletteItems,children:t.map(i=>r.jsx(ur,{plugin:i,onDragStart:s},i.kind))})}),n&&!n.isOverCanvas&&r.jsx(dr,{plugin:n.plugin,mousePos:n.mousePos})]})};an.displayName="PalettePanel";const ur=({plugin:t,onDragStart:e})=>{const n=u.useMemo(()=>Nt(t,{x:0,y:0,w:t.meta.defaultSize.w,h:t.meta.defaultSize.h},{}),[t]),o=u.useMemo(()=>{if(t.validateValue)return t.validateValue(void 0,n.props)},[t,n.props]),s=u.useCallback(i=>{i.preventDefault(),zt.start(t.kind,t.meta.defaultSize),e(t,{x:i.clientX,y:i.clientY});const a=()=>{zt.end(),window.removeEventListener("pointerup",a)};window.addEventListener("pointerup",a)},[t,e]);return r.jsxs("div",{className:Ft.item,children:[r.jsx("button",{type:"button",onPointerDown:s,className:Ft.itemName,"aria-label":`${t.meta.displayName}ブロックを追加`,children:t.meta.displayName}),r.jsx("div",{className:Ft.itemPreview,onPointerDown:s,"aria-hidden":"true",children:r.jsx(t.Renderer,{id:n.id,props:n.props,value:o,onChange:()=>{},readOnly:!0,mode:it.FORM})})]})};ur.displayName="PaletteItem";const dr=({plugin:t,mousePos:e})=>{const n=u.useMemo(()=>Nt(t,{x:0,y:0,w:t.meta.defaultSize.w,h:t.meta.defaultSize.h},{}),[t]),o=u.useMemo(()=>{if(t.validateValue)return t.validateValue(void 0,n.props)},[t,n.props]),s={width:t.meta.defaultSize.w*50,height:t.meta.defaultSize.h*50};return r.jsx("div",{"data-testid":"palette-drag-ghost",style:{position:"fixed",left:`${e.x-s.width/2}px`,top:`${e.y-s.height/2}px`,width:`${s.width}px`,height:`${s.height}px`,pointerEvents:"none",opacity:.5,filter:"grayscale(50%)",zIndex:9999,border:"2px dashed #3b82f6",backgroundColor:"#fff"},children:r.jsx(t.Renderer,{id:n.id,props:n.props,value:o,onChange:()=>{},readOnly:!0,mode:it.FORM})})};dr.displayName="DragGhost";const Fi="_container_rt0ql_3",zi="_tabHeader_rt0ql_14",Wi="_tabContent_rt0ql_21",Ut={container:Fi,tabHeader:zi,tabContent:Wi},mr=({blocks:t,selectedBlockIds:e,pluginRegistry:n,onUpdateBlocks:o,schema:s,values:i,onSchemaChange:a,onValuesChange:l,gridSize:c,className:m})=>{const d=u.useMemo(()=>Object.values(n),[n]),f=u.useMemo(()=>t.filter(g=>e.includes(g.id)),[t,e]),v=e.length>0;return r.jsx("div",{className:`${Ut.container} ${m||""}`,"data-sidebar":"true",children:r.jsxs(Oe,{defaultValue:"block",variant:"default",children:[r.jsxs(Ge,{className:Ut.tabHeader,children:[r.jsx(yt,{value:"block",children:"ブロック"}),r.jsx(yt,{value:"canvas",children:"キャンバス"}),r.jsx(yt,{value:"other",children:"その他"})]}),r.jsx(Et,{value:"block",className:Ut.tabContent,children:v?r.jsx(Je,{selectedBlocks:f,pluginRegistry:n,onUpdateBlocks:o,gridSize:c}):r.jsx(an,{plugins:d})}),r.jsx(Et,{value:"canvas",className:Ut.tabContent,children:r.jsx(tn,{schema:s,onSchemaChange:a})}),r.jsx(Et,{value:"other",className:Ut.tabContent,children:r.jsx(sn,{schema:s,values:i,onSchemaChange:a,onValuesChange:l})})]})})};mr.displayName="Sidebar";exports.ACTUAL_UNITS=io;exports.ALL_UNITS=so;exports.BLOCK_SUB_INDEX=mt;exports.BORDER_UNITS=bn;exports.BackgroundPanel=ir;exports.BlockBorder=Rn;exports.BlockCanvas=Mn;exports.BlockChangeType=ct;exports.BlockContainer=Ue;exports.BlockGuideBorder=Pn;exports.BlockLayer=St;exports.BlockOrderPanel=Qe;exports.BlockPropertyPanel=Je;exports.BlockRenderer=Ht;exports.Border=kt;exports.BorderOverlay=An;exports.BorderPanel=ar;exports.BorderRenderer=It;exports.COLOR_PALETTE=vn;exports.CanvasPanel=tn;exports.Checkbox=xt;exports.ColorPalette=Ae;exports.ColorPicker=Wt;exports.ColorPickerPopover=Se;exports.DEFAULT_DPI=W;exports.DEFAULT_FONT_FAMILY=_n;exports.DEFAULT_GRID=jn;exports.DEFAULT_GUIDE_BORDER=me;exports.DEFAULT_GUIDE_LINE=Cn;exports.DEFAULT_PAPER=Dn;exports.DEFAULT_PAPER_MARGIN=In;exports.DEFAULT_PAPER_SIZES=Be;exports.DEFAULT_SCHEMA=yo;exports.DimensionInput=rt;exports.DragLayer=qe;exports.DragType=nt;exports.EditingBlock=qn;exports.FONT_UNITS=gn;exports.GRID_UNITS=lo;exports.GridCanvas=kn;exports.GridDimensionLabel=ee;exports.GridLayer=he;exports.GridOverlay=Gn;exports.GridResizeHandle=ne;exports.GridSizePanel=en;exports.HorizontalAlign=Tt;exports.ImageObjectFit=jt;exports.ImportExportPanel=on;exports.InsertGhost=ze;exports.InteractionBlock=Lt;exports.InteractionEventType=H;exports.InteractionLayer=Ze;exports.InteractionMode=lt;exports.LayoutPanel=lr;exports.LineType=dt;exports.MarginOverlay=Bn;exports.MarginPanel=nn;exports.MetaPanel=cr;exports.MovingGhost=Ye;exports.MultilineWhiteSpace=Ct;exports.MultilineWordWrap=Mt;exports.NoteEdit=Qn;exports.NoteEditor=us;exports.NoteForm=er;exports.NoteMode=it;exports.NotePrint=ds;exports.NoteView=rr;exports.NumberInput=st;exports.OtherPanel=sn;exports.PADDING_UNITS=$t;exports.PAPER_UNITS=ao;exports.PalettePanel=an;exports.PaperSizePanel=rn;exports.PaperSizePreset=pt;exports.PluginPanels=Fs;exports.PropertyField=pe;exports.RESIZE_HANDLE_STYLE=fe;exports.RGBAInputs=ke;exports.ResizeGhost=Xe;exports.ResizeHandle=X;exports.ResizeHandles=Fe;exports.SELECTION_STYLE=Xt;exports.SIZE_UNITS=je;exports.Select=wt;exports.SelectionBorder=Xn;exports.SelectionLayer=Ke;exports.Sidebar=mr;exports.TabPanel=Le;exports.Tabs=Oe;exports.TabsContent=Et;exports.TabsList=Ge;exports.TabsTrigger=yt;exports.TextInput=At;exports.ValidationSeverity=$n;exports.VerticalAlign=Rt;exports.Z_INDEX=G;exports.alignmentDefinition=pn;exports.assertFinite=bo;exports.assertInteger=de;exports.assertNonNegative=et;exports.assertPositive=ue;exports.assertRange=Nn;exports.binarySearch=te;exports.calculateGridResize=Ne;exports.calculateResizedLayout=He;exports.clampBlockToGrid=Zn;exports.clampMultipleBlocks=We;exports.cleanupPrint=Fn;exports.createBlock=Nt;exports.createBlockId=En;exports.createInitialProps=yn;exports.createPluginRegistry=mo;exports.deserializeSchema=Te;exports.deserializeValues=Me;exports.dimensionToString=Ln;exports.dimensionsToStrings=Lo;exports.distributeRemainder=Vn;exports.executePrint=Qo;exports.findBlockAtPoint=Pe;exports.findGridIndex=De;exports.fontStyleDefinition=uo;exports.getBlockContainerStyle=Ve;exports.getBlockZIndex=Tn;exports.getCommonValue=vt;exports.getInteractionMode=ae;exports.getMaxBlockCount=Eo;exports.getMaxStep=Ie;exports.getPaperSize=Jo;exports.getStrokeDasharray=Pt;exports.getSubZIndex=Yt;exports.globalDragStore=zt;exports.gridToMms=oe;exports.gridToPxs=Zo;exports.imageDefinition=ho;exports.interactionZIndexs=Z;exports.isValidHex=zr;exports.mmsToPxs=se;exports.multilineDefinition=fo;exports.paddingDefinition=wn;exports.parseColor=Ee;exports.placeholderDefinition=po;exports.preparePrint=Un;exports.printElement=$e;exports.removeUndefinedProps=ie;exports.serializeSchema=Re;exports.serializeValues=Ce;exports.sizeDefinition=xo;exports.stringToDimension=Sn;exports.stringsToDimensions=Co;exports.toHex=xn;exports.toMm=Y;exports.toPx=V;exports.toRgbaString=Fr;exports.universalProperties=co;exports.useGridCalc=qt;exports.useInteractionState=Kn;exports.validateSchema=zn;exports.validateValues=Yn;exports.validationDefinition=vo;
69
+ `,document.head.appendChild(v),()=>{const g=document.getElementById("printable-note-page-style");g&&g.remove()}},[t.paper]),u.useImperativeHandle(s,()=>({print:()=>{i.current&&$e(i.current,{title:"Document"})},openPrintPreview:()=>{i.current&&$e(i.current,{title:"Document"})}}),[]),o.jsx("div",{ref:i,className:r,style:{width:`${a.canvas.width}px`,height:`${a.canvas.height}px`,backgroundColor:"#fff",paddingTop:`${a.margin.top}px`,paddingLeft:`${a.margin.left}px`,paddingRight:`${a.margin.right}px`,paddingBottom:`${a.margin.bottom}px`,boxSizing:"border-box"},children:o.jsx("div",{style:{position:"relative",width:`${a.content.width}px`,height:`${a.content.height}px`},children:o.jsx(Lt,{blocks:t.blocks,pluginRegistry:n,mode:it.VIEW,values:e??{},getBlockRectPx:l,showGuides:!1,showBorder:!0})})})};sr.displayName="NotePrint";const ds=u.memo(u.forwardRef(sr));function vt(t,e){if(t.length===0)return;const n=(a,l)=>{let c=a;for(const m of l){if(c==null||typeof c!="object"||Array.isArray(c))return;c=c[m]}return c},r=e.split("."),s=n(t[0],r);return t.every(a=>n(a,r)===s)?s:void 0}const ms="_container_1tfjv_1",hs="_row_1tfjv_20",fs="_inputWrapper_1tfjv_37",ye={container:ms,row:hs,inputWrapper:fs},ir=({selectedBlocks:t,onUpdateBlocks:e})=>{if(t.length===0)return null;const n=r=>{const s={};t.forEach(i=>{s[i.id]={style:{...i.style,backgroundColor:r}}}),e(s)};return o.jsx("div",{className:ye.container,children:o.jsx("div",{className:ye.row,children:o.jsx("div",{className:ye.inputWrapper,children:o.jsx(Wt,{value:vt(t,"style.backgroundColor"),onChange:n,allowUndefined:!0,placeholder:"無色",height:24})})})})};function _t(t,e,n){const r=e.split("."),s=(i,a)=>{const l=r[a];if(a===r.length-1){if(n==null){const{[l]:d,...p}=i;return p}return{...i,[l]:n}}const c=(i==null?void 0:i[l])||{},m=s(c,a+1);if(Object.keys(m).length===0){const{[l]:d,...p}=i;return p}return{...i,[l]:m}};return s(t,0)}const ar=({selectedBlocks:t,onUpdateBlocks:e})=>{const n=(a,l,c)=>{const m={};t.forEach(d=>{var v,g,E;let p=_t(d.style||{},`border.${a}.${l}`,c);if(l==="type"&&c==null&&(p=_t(p,`border.${a}.width`,void 0),p=_t(p,`border.${a}.color`,void 0)),l==="type"&&c!==void 0&&c!==null){const y=(v=d.style)==null?void 0:v.border,f=y==null?void 0:y[a];f!=null&&f.width||(p=_t(p,`border.${a}.width`,{value:1,unit:"px"})),f!=null&&f.color||(p=_t(p,`border.${a}.color`,"#000000"))}if(l==="color"&&c!==void 0&&c!==null){const y=(g=d.style)==null?void 0:g.border,f=y==null?void 0:y[a];f!=null&&f.type||(p=_t(p,`border.${a}.type`,dt.SOLID)),f!=null&&f.width||(p=_t(p,`border.${a}.width`,{value:1,unit:"px"}))}if(l==="width"&&c!==void 0&&c!==null){const y=(E=d.style)==null?void 0:E.border,f=y==null?void 0:y[a];f!=null&&f.type||(p=_t(p,`border.${a}.type`,dt.SOLID)),f!=null&&f.color||(p=_t(p,`border.${a}.color`,"#000000"))}m[d.id]={style:p}}),e(m)},r=u.useMemo(()=>{var d;if(t.length!==1)return null;const a=t[0];if(!((d=a==null?void 0:a.style)!=null&&d.border))return null;const l=a.style.border;if(!l)return null;const c=p=>p?!(p.type&&!p.width):!0;return["all","top","right","bottom","left"].every(p=>c(l[p]))?new kt(l):null},[t]),s=a=>o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[o.jsx(wt,{value:vt(t,`style.border.${a}.type`),onChange:l=>n(a,"type",l),placeholder:"スタイル",height:24,options:[{label:"",value:void 0},{label:"実線",value:dt.SOLID},{label:"破線",value:dt.DASHED},{label:"点線",value:dt.DOTTED}]}),o.jsx(rt,{value:vt(t,`style.border.${a}.width`),onChange:l=>n(a,"width",l),placeholder:"太さ",height:24,allowedUnits:bn,min:1}),o.jsx(Wt,{value:vt(t,`style.border.${a}.color`),onChange:l=>n(a,"color",l),placeholder:"色",height:24,allowUndefined:!0})]}),i={flex:1,padding:"0 2px",fontSize:"12px",minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"};return o.jsxs("div",{style:{display:"flex",flexDirection:"row",padding:"4px",alignItems:"stretch"},children:[o.jsx("div",{style:{flex:"0 0 30%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:o.jsxs("div",{style:{width:"80px",height:"80px",backgroundColor:"transparent",border:"transparent",borderRadius:"0.25rem",display:"flex",alignItems:"center",justifyContent:"center",position:"relative"},children:[o.jsxs("svg",{width:"80",height:"80",viewBox:"0 0 80 80",style:{position:"absolute",top:0,left:0,opacity:.3,pointerEvents:"none"},children:[o.jsx("title",{children:"枠線ガイド"}),o.jsx("line",{x1:"40",y1:"0",x2:"40",y2:"80",stroke:"#9ca3af",strokeWidth:"1",strokeDasharray:"4 2"}),o.jsx("line",{x1:"0",y1:"40",x2:"80",y2:"40",stroke:"#9ca3af",strokeWidth:"1",strokeDasharray:"4 2"})]}),r?o.jsx("div",{style:{position:"absolute",top:0,left:0,width:"80px",height:"80px",pointerEvents:"none"},children:o.jsx(It,{width:80,height:80,border:r})}):o.jsxs("svg",{width:"80",height:"80",viewBox:"0 0 80 80",style:{position:"absolute",top:0,left:0,opacity:.3},children:[o.jsx("title",{children:"枠線未設定"}),o.jsx("rect",{x:"0",y:"0",width:"80",height:"80",fill:"none",stroke:"#9ca3af",strokeWidth:"1",strokeDasharray:"4 2"})]})]})}),o.jsx("div",{style:{flex:"0 0 70%",minWidth:0,padding:"0 0 2px 0"},children:o.jsxs(Oe,{defaultValue:"all",variant:"segmented",children:[o.jsx("div",{style:{width:"100%"},children:o.jsxs(Ge,{style:{width:"100%",display:"flex"},children:[o.jsx(yt,{value:"all",height:24,style:i,children:"共通"}),o.jsx(yt,{value:"top",height:24,style:i,children:"上"}),o.jsx(yt,{value:"bottom",height:24,style:i,children:"下"}),o.jsx(yt,{value:"left",height:24,style:i,children:"左"}),o.jsx(yt,{value:"right",height:24,style:i,children:"右"})]})}),o.jsxs("div",{style:{marginTop:"4px"},children:[o.jsx(Et,{value:"all",children:s("all")}),o.jsx(Et,{value:"top",children:s("top")}),o.jsx(Et,{value:"bottom",children:s("bottom")}),o.jsx(Et,{value:"left",children:s("left")}),o.jsx(Et,{value:"right",children:s("right")})]})]})})]})},ps="_container_1daw7_1",xs="_grid_1daw7_19",vs="_field_1daw7_26",bs="_label_1daw7_33",gs="_inputWrapper_1daw7_43",at={container:ps,grid:xs,field:vs,label:bs,inputWrapper:gs},lr=({selectedBlocks:t,onUpdateBlocks:e,gridSize:n})=>{if(t.length===0)return null;const r=t.length>1,s=r?Math.min(...t.map(l=>l.layout.x)):void 0,i=r?Math.min(...t.map(l=>l.layout.y)):void 0,a=(l,c)=>{if(c===void 0)return;const m={};if(r&&(l==="x"||l==="y")){const d=l==="x"?s:i;if(d===void 0)return;const p=Math.max(...t.map(x=>x.layout.x+x.layout.w)),v=Math.max(...t.map(x=>x.layout.y+x.layout.h)),g=p-(s??0),E=v-(i??0);let y=c;l==="x"&&n?y=Math.max(0,Math.min(c,n.cols-g)):l==="y"&&n?y=Math.max(0,Math.min(c,n.rows-E)):y=Math.max(0,c);const f=y-d;t.forEach(x=>{const h=x.layout[l]+f;m[x.id]={layout:{...x.layout,[l]:h}}})}else t.forEach(d=>{let p=c;if(l==="x"&&n)p=Math.max(0,Math.min(c,n.cols-d.layout.w));else if(l==="y"&&n)p=Math.max(0,Math.min(c,n.rows-d.layout.h));else if(l==="w"&&n){const v=n.cols-d.layout.x;p=Math.max(1,Math.min(c,v))}else if(l==="h"&&n){const v=n.rows-d.layout.y;p=Math.max(1,Math.min(c,v))}else l==="w"||l==="h"?p=Math.max(1,c):p=Math.max(0,c);m[d.id]={layout:{...d.layout,[l]:p}}});e(m)};return o.jsx("div",{className:at.container,children:o.jsxs("div",{className:at.grid,children:[o.jsxs("div",{className:at.field,children:[o.jsx("span",{className:at.label,children:"X"}),o.jsx("div",{className:at.inputWrapper,children:o.jsx(st,{value:r?s:vt(t,"layout.x"),onChange:l=>a("x",l),min:0,max:n?n.cols-1:void 0,integer:!0,height:22,placeholder:"-"})})]}),o.jsxs("div",{className:at.field,children:[o.jsx("span",{className:at.label,children:"Y"}),o.jsx("div",{className:at.inputWrapper,children:o.jsx(st,{value:r?i:vt(t,"layout.y"),onChange:l=>a("y",l),min:0,max:n?n.rows-1:void 0,integer:!0,height:22,placeholder:"-"})})]}),!r&&o.jsxs("div",{className:at.field,children:[o.jsx("span",{className:at.label,children:"W"}),o.jsx("div",{className:at.inputWrapper,children:o.jsx(st,{value:vt(t,"layout.w"),onChange:l=>a("w",l),min:1,max:n==null?void 0:n.cols,integer:!0,height:22,placeholder:"-"})})]}),!r&&o.jsxs("div",{className:at.field,children:[o.jsx("span",{className:at.label,children:"H"}),o.jsx("div",{className:at.inputWrapper,children:o.jsx(st,{value:vt(t,"layout.h"),onChange:l=>a("h",l),min:1,max:n==null?void 0:n.rows,integer:!0,height:22,placeholder:"-"})})]})]})})},ws="_container_1h4w8_1",_s="_row_1h4w8_10",ys="_label_1h4w8_16",Es="_inputWrapper_1h4w8_25",Dt={container:ws,row:_s,label:ys,inputWrapper:Es},cr=({selectedBlocks:t,onUpdateBlocks:e})=>{const[n,r]=u.useState(""),s=t[0];u.useEffect(()=>{t.length===1&&s&&r(s.id)},[t,s]);const i=()=>{if(!s)return;const c=s.id,m=n.trim();if(m===c||!m){r(c);return}e({[c]:{id:m}})},a=c=>{r(c??"")},l=c=>{const m={};t.forEach(d=>{m[d.id]={behavior:{...d.behavior,readOnly:!!c}}}),e(m)};return o.jsxs("div",{className:Dt.container,children:[t.length===1&&o.jsxs("div",{className:Dt.row,children:[o.jsx("span",{className:Dt.label,children:"ID"}),o.jsx("div",{className:Dt.inputWrapper,children:o.jsx(At,{value:n,onChange:a,onBlur:i,placeholder:"IDを入力",height:16})})]}),t.length>0&&o.jsx("div",{className:Dt.row,children:o.jsx("div",{className:Dt.inputWrapper,children:o.jsx(xt,{label:"読み取り専用",value:!!vt(t,"behavior.readOnly"),onChange:l})})})]})},js="_container_wa11y_1",Ns="_scrollArea_wa11y_18",Is="_section_wa11y_26",Ds="_sectionTitle_wa11y_35",$s="_subsection_wa11y_47",Ts="_subsectionTitle_wa11y_51",Rs="_fields_wa11y_59",Ms="_emptyState_wa11y_69",ot={container:js,scrollArea:Ns,section:Is,sectionTitle:Ds,subsection:$s,subsectionTitle:Ts,fields:Rs,emptyState:Ms},Cs="_field_qo0ef_1",Ps="_label_qo0ef_7",As="_mixed_qo0ef_15",ks="_description_qo0ef_22",Qt={field:Cs,label:Ps,mixed:As,description:ks},pe=u.memo(({propertyKey:t,definition:e,selectedBlocks:n,onChange:r})=>{var d;const s=e.Component;if(!s)return null;const i=vt(n,`props.${t}`),c=!n.map(p=>p.props[t]).every(p=>p===void 0)&&i===void 0&&n.length>1,m={value:c?void 0:i!==void 0?i:e.defaultValue,onChange:p=>r(t,p),readOnly:!1,config:{...e.config,placeholder:c?"複数選択中 (値が異なります)":(d=e.config)==null?void 0:d.placeholder}};return o.jsxs("div",{className:Qt.field,children:[e.label&&o.jsx("div",{className:Qt.label,title:e.description,children:e.label}),o.jsx(s,{...m}),c&&o.jsx("span",{className:Qt.mixed,children:"(混在)"}),e.description&&o.jsx("p",{className:Qt.description,children:e.description})]})});pe.displayName="PropertyField";function Ls(t){return t!==!1}const Je=u.memo(({selectedBlocks:t,pluginRegistry:e,onUpdateBlocks:n,gridSize:r,className:s=""})=>{const i=t[0],a=i?e[i.kind]:void 0,l=u.useMemo(()=>{var p;if(t.length===0)return!1;const d=(p=t[0])==null?void 0:p.kind;return t.every(v=>v.kind===d)},[t]),c=u.useMemo(()=>{if(!i||!a)return{};const d={};let p;if(l)p=Object.entries(a.properties);else{const v=t.map(f=>e[f.kind]).filter(f=>f!==void 0);if(v.length===0)return{};const g=v[0];if(!g)return{};const E=new Set(Object.keys(g.properties));p=Array.from(E).filter(f=>v.every(x=>f in x.properties)).map(f=>{const x=a.properties[f];return x?[f,x]:null}).filter(f=>f!==null)}return p.forEach(([v,g])=>{if(!Ls(g)||t.length>1&&g.disableInMultiSelection||g.condition&&!g.condition(i.props))return;const E=g.group||"基本";d[E]||(d[E]=[]),g.Component&&d[E].push({key:v,definition:g})}),d},[a,e,t,i,l]),m=(d,p)=>{const v={};t.forEach(g=>{v[g.id]={props:{...g.props,[d]:p}}}),n(v)};return t.length===0?o.jsx("div",{className:`${ot.container} ${s}`,children:o.jsxs("div",{className:ot.emptyState,children:["ブロックを選択すると",o.jsx("br",{}),"プロパティが表示されます"]})}):o.jsx("div",{className:`${ot.container} ${s}`,children:o.jsxs("div",{className:ot.scrollArea,children:[o.jsxs("div",{className:ot.section,children:[o.jsx("div",{className:ot.sectionTitle,children:"配置・サイズ"}),o.jsx(lr,{selectedBlocks:t,onUpdateBlocks:n,gridSize:r})]}),o.jsxs("div",{className:ot.section,children:[o.jsx("div",{className:ot.sectionTitle,children:"背景"}),o.jsx(ir,{selectedBlocks:t,onUpdateBlocks:n})]}),o.jsxs("div",{className:ot.section,children:[o.jsx("div",{className:ot.sectionTitle,children:"枠線"}),o.jsx(ar,{selectedBlocks:t,onUpdateBlocks:n})]}),a&&Object.keys(c).length>0&&o.jsx("div",{className:ot.section,children:Object.entries(c).map(([d,p])=>o.jsxs("div",{className:ot.subsection,children:[o.jsx("div",{className:ot.subsectionTitle,children:d}),o.jsx("div",{className:ot.fields,children:p.map(({key:v,definition:g})=>o.jsx(pe,{propertyKey:v,definition:g,selectedBlocks:t,onChange:m},v))})]},d))}),o.jsxs("div",{className:ot.section,children:[o.jsx("div",{className:ot.sectionTitle,children:"基本設定"}),o.jsx(cr,{selectedBlocks:t,onUpdateBlocks:n})]})]})})});Je.displayName="BlockPropertyPanel";const Ss="_panel_1h33v_1",Os="_header_1h33v_11",Gs="_group_1h33v_18",Bs="_groupTitle_1h33v_26",Vs="_groupContent_1h33v_36",Vt={panel:Ss,header:Os,group:Gs,groupTitle:Bs,groupContent:Vs};function Us(t){return t!==!1}const Fs=({selectedBlocks:t,pluginRegistry:e,onUpdateBlocks:n})=>{const r=t[0],s=r?e[r.kind]:void 0,i=u.useMemo(()=>{if(!r||!s)return{};const l={};return Object.entries(s.properties).forEach(([c,m])=>{if(!Us(m)||t.length>1&&m.disableInMultiSelection||m.condition&&!m.condition(r.props))return;const d=m.group||"基本";l[d]||(l[d]=[]),m.Component&&l[d].push({key:c,definition:m})}),l},[s,t.length,r]),a=(l,c)=>{const m={};t.forEach(d=>{m[d.id]={props:{...d.props,[l]:c}}}),n(m)};return!r||!s||t.length===0?null:o.jsxs("div",{className:Vt.panel,children:[o.jsx("div",{className:Vt.header,children:t.length>1?`${t.length}個のブロック`:s.meta.displayName}),Object.entries(i).map(([l,c])=>o.jsxs("div",{className:Vt.group,children:[o.jsx("div",{className:Vt.groupTitle,children:l}),o.jsx("div",{className:Vt.groupContent,children:c.map(({key:m,definition:d})=>o.jsx(pe,{propertyKey:m,definition:d,selectedBlocks:t,onChange:a},m))})]},l))]})},zs="_panel_1ekwd_6",Ws="_title_1ekwd_10",Ys="_content_1ekwd_22",Hs="_description_1ekwd_29",Xs="_list_1ekwd_35",qs="_item_1ekwd_44",Ks="_dragging_1ekwd_61",Zs="_dragOver_1ekwd_66",Js="_dragHandle_1ekwd_71",Qs="_itemInfo_1ekwd_86",ti="_itemId_1ekwd_93",ei="_itemMeta_1ekwd_98",ni="_itemKind_1ekwd_105",ri="_itemActions_1ekwd_113",oi="_actionButton_1ekwd_118",si="_empty_1ekwd_154",J={panel:zs,title:Ws,content:Ys,description:Hs,list:Xs,item:qs,dragging:Ks,dragOver:Zs,dragHandle:Js,itemInfo:Qs,itemId:ti,itemMeta:ei,itemKind:ni,itemActions:ri,actionButton:oi,empty:si},Qe=({blocks:t,onBlocksChange:e})=>{const[n,r]=u.useState(null),[s,i]=u.useState(null),a=[...t].reverse(),l=u.useCallback(f=>{const x=t.findIndex(N=>N.id===f);if(x===-1||x===t.length-1)return;const h=[...t],[w]=h.splice(x,1);w&&(h.push(w),e(h))},[t,e]),c=u.useCallback(f=>{const x=t.findIndex(N=>N.id===f);if(x===-1||x===0)return;const h=[...t],[w]=h.splice(x,1);w&&(h.unshift(w),e(h))},[t,e]),m=u.useCallback(f=>{const x=t.findIndex(I=>I.id===f);if(x===-1||x===t.length-1)return;const h=[...t],w=h[x],N=h[x+1];!w||!N||(h[x]=N,h[x+1]=w,e(h))},[t,e]),d=u.useCallback(f=>{const x=t.findIndex(I=>I.id===f);if(x===-1||x===0)return;const h=[...t],w=h[x],N=h[x-1];!w||!N||(h[x]=N,h[x-1]=w,e(h))},[t,e]),p=u.useCallback((f,x)=>{var w;r(x),f.dataTransfer.effectAllowed="move";const h=t.length-1-x;f.currentTarget&&f.dataTransfer.setData("text/plain",((w=t[h])==null?void 0:w.id)||"")},[t]),v=u.useCallback(()=>{r(null),i(null)},[]),g=u.useCallback((f,x)=>{f.preventDefault(),f.dataTransfer.dropEffect="move",!(n===null||n===x)&&i(x)},[n]),E=u.useCallback(()=>{i(null)},[]),y=u.useCallback((f,x)=>{if(f.preventDefault(),n===null||n===x){r(null),i(null);return}const h=t.length-1-n,w=t.length-1-x,N=[...t],[I]=N.splice(h,1);I&&(N.splice(w,0,I),e(N),r(null),i(null))},[t,n,e]);return o.jsxs("div",{className:J.panel,children:[o.jsx("h3",{className:J.title,children:"ブロック順序"}),o.jsxs("div",{className:J.content,children:[o.jsx("p",{className:J.description,children:"上が最前面、下が最背面"}),o.jsx("ul",{className:J.list,children:a.map((f,x)=>{const h=t.length-1-x;return o.jsxs("li",{className:`${J.item} ${n===x?J.dragging:""} ${s===x?J.dragOver:""}`,onDragOver:w=>g(w,x),onDragLeave:E,onDrop:w=>y(w,x),children:[o.jsx("button",{type:"button",className:J.dragHandle,title:"ドラッグして並び替え",draggable:!0,onDragStart:w=>p(w,x),onDragEnd:v,children:o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[o.jsx("title",{children:"ドラッグハンドル"}),o.jsx("circle",{cx:"6",cy:"4",r:"1",fill:"currentColor"}),o.jsx("circle",{cx:"10",cy:"4",r:"1",fill:"currentColor"}),o.jsx("circle",{cx:"6",cy:"8",r:"1",fill:"currentColor"}),o.jsx("circle",{cx:"10",cy:"8",r:"1",fill:"currentColor"}),o.jsx("circle",{cx:"6",cy:"12",r:"1",fill:"currentColor"}),o.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor"})]})}),o.jsxs("div",{className:J.itemInfo,children:[o.jsx("div",{className:J.itemId,children:f.id}),o.jsx("div",{className:J.itemMeta,children:o.jsx("span",{className:J.itemKind,children:f.kind})})]}),o.jsxs("div",{className:J.itemActions,children:[o.jsx("button",{type:"button",className:J.actionButton,onClick:()=>l(f.id),title:"最前面へ","aria-label":"最前面へ移動",disabled:h===t.length-1,children:o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[o.jsx("title",{children:"最前面へ"}),o.jsx("path",{d:"M4 12v-8M8 12v-8M12 12v-8",stroke:"currentColor"}),o.jsx("path",{d:"M12 4h-8",stroke:"currentColor",strokeWidth:"2"})]})}),o.jsx("button",{type:"button",className:J.actionButton,onClick:()=>m(f.id),title:"前面へ","aria-label":"前面へ移動",disabled:h===t.length-1,children:o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[o.jsx("title",{children:"前面へ"}),o.jsx("path",{d:"M8 4v8",stroke:"currentColor"}),o.jsx("path",{d:"M5 7l3-3 3 3",stroke:"currentColor"})]})}),o.jsx("button",{type:"button",className:J.actionButton,onClick:()=>d(f.id),title:"背面へ","aria-label":"背面へ移動",disabled:h===0,children:o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[o.jsx("title",{children:"背面へ"}),o.jsx("path",{d:"M8 12v-8",stroke:"currentColor"}),o.jsx("path",{d:"M5 9l3 3 3-3",stroke:"currentColor"})]})}),o.jsx("button",{type:"button",className:J.actionButton,onClick:()=>c(f.id),title:"最背面へ","aria-label":"最背面へ移動",disabled:h===0,children:o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[o.jsx("title",{children:"最背面へ"}),o.jsx("path",{d:"M4 12v-8M8 12v-8M12 12v-8",stroke:"currentColor"}),o.jsx("path",{d:"M12 12h-8",stroke:"currentColor",strokeWidth:"2"})]})})]})]},f.id)})}),t.length===0&&o.jsx("div",{className:J.empty,children:"ブロックがありません"})]})]})};Qe.displayName="BlockOrderPanel";const tn=({schema:t,onSchemaChange:e})=>{const n=u.useCallback(i=>{e({...t,paper:i})},[t,e]),r=u.useCallback(i=>{e({...t,grid:i})},[t,e]),s=u.useCallback(i=>{e({...t,blocks:i})},[t,e]);return o.jsxs(Se,{children:[o.jsx(rn,{paper:t.paper,onPaperChange:n}),o.jsx(nn,{paper:t.paper,onPaperChange:n}),o.jsx(en,{grid:t.grid,onGridChange:r}),o.jsx(Qe,{blocks:t.blocks,onBlocksChange:s})]})};tn.displayName="CanvasPanel";const ii="_panel_1axyd_6",ai="_title_1axyd_10",li="_content_1axyd_22",ci="_field_1axyd_29",ui="_horizontal_1axyd_35",di="_label_1axyd_41",mi="_gridSizeRow_1axyd_52",gt={panel:ii,title:ai,content:li,field:ci,horizontal:ui,label:di,gridSizeRow:mi},en=({grid:t,onGridChange:e})=>{const n=u.useCallback(s=>{if(!s||s<1||s>100)return;const i=t.cols.length,a=[];if(s>i){a.push(...t.cols);for(let l=i;l<s;l++)a.push({value:1,unit:"fr"})}else a.push(...t.cols.slice(0,s));e({...t,cols:a})},[t,e]),r=u.useCallback(s=>{if(!s||s<1||s>100)return;const i=t.rows.length,a=[];if(s>i){a.push(...t.rows);for(let l=i;l<s;l++)a.push({value:1,unit:"fr"})}else a.push(...t.rows.slice(0,s));e({...t,rows:a})},[t,e]);return o.jsxs("div",{className:gt.panel,children:[o.jsx("h3",{className:gt.title,children:"グリッドサイズ"}),o.jsx("div",{className:gt.content,children:o.jsxs("div",{className:gt.gridSizeRow,children:[o.jsxs("div",{className:`${gt.field} ${gt.horizontal}`,children:[o.jsx("span",{className:gt.label,children:"列数"}),o.jsx(st,{value:t.cols.length,onChange:n,min:1,max:100,step:1})]}),o.jsxs("div",{className:`${gt.field} ${gt.horizontal}`,children:[o.jsx("span",{className:gt.label,children:"行数"}),o.jsx(st,{value:t.rows.length,onChange:r,min:1,max:100,step:1})]})]})})]})};en.displayName="GridSizePanel";const hi="_panel_qlcb6_6",fi="_header_qlcb6_10",pi="_title_qlcb6_20",xi="_headerActions_qlcb6_29",vi="_content_qlcb6_33",bi="_field_qlcb6_37",gi="_horizontal_qlcb6_43",wi="_label_qlcb6_49",_i="_marginsGrid_qlcb6_60",yi="_topMargin_qlcb6_66",Ei="_bottomMargin_qlcb6_67",ji="_sideMargins_qlcb6_73",K={panel:hi,header:fi,title:pi,headerActions:xi,content:vi,field:bi,horizontal:gi,label:wi,marginsGrid:_i,topMargin:yi,bottomMargin:Ei,sideMargins:ji},nn=({paper:t,onPaperChange:e})=>{const[n,r]=u.useState(!1),s=u.useCallback(m=>{m!==void 0&&r(m)},[]),i=u.useCallback(m=>{if(!m)return;const d=n?{top:m,right:m,bottom:m,left:m}:{...t.margin,top:m};e({...t,margin:d})},[t,e,n]),a=u.useCallback(m=>{m&&e({...t,margin:{...t.margin,right:m}})},[t,e]),l=u.useCallback(m=>{m&&e({...t,margin:{...t.margin,bottom:m}})},[t,e]),c=u.useCallback(m=>{m&&e({...t,margin:{...t.margin,left:m}})},[t,e]);return o.jsxs("div",{className:K.panel,children:[o.jsxs("div",{className:K.header,children:[o.jsx("h3",{className:K.title,children:"マージン"}),o.jsx("div",{className:K.headerActions,children:o.jsx(xt,{value:n,onChange:s,label:"全辺を一括設定"})})]}),o.jsx("div",{className:K.content,children:n?o.jsxs("div",{className:`${K.field} ${K.horizontal}`,children:[o.jsx("span",{className:K.label,children:"全辺"}),o.jsx(rt,{value:t.margin.top,onChange:i,allowedUnits:["mm","cm","inch"],min:0,max:1e3})]}):o.jsxs("div",{className:K.marginsGrid,children:[o.jsx("div",{className:`${K.field} ${K.horizontal} ${K.topMargin}`,children:o.jsx(rt,{value:t.margin.top,onChange:i,allowedUnits:["mm","cm","inch"],min:0,max:1e3})}),o.jsxs("div",{className:K.sideMargins,children:[o.jsx("div",{className:`${K.field} ${K.horizontal}`,children:o.jsx(rt,{value:t.margin.left,onChange:c,allowedUnits:["mm","cm","inch"],min:0,max:1e3})}),o.jsx("div",{className:`${K.field} ${K.horizontal}`,children:o.jsx(rt,{value:t.margin.right,onChange:a,allowedUnits:["mm","cm","inch"],min:0,max:1e3})})]}),o.jsx("div",{className:`${K.field} ${K.horizontal} ${K.bottomMargin}`,children:o.jsx(rt,{value:t.margin.bottom,onChange:l,allowedUnits:["mm","cm","inch"],min:0,max:1e3})})]})})]})};nn.displayName="MarginPanel";const Ni="_panel_16d9o_6",Ii="_title_16d9o_10",Di="_content_16d9o_22",$i="_field_16d9o_29",Ti="_horizontal_16d9o_35",Ri="_label_16d9o_41",Mi="_dimensionsRow_16d9o_52",ft={panel:Ni,title:Ii,content:Di,field:$i,horizontal:Ti,label:Ri,dimensionsRow:Mi},rn=({paper:t,onPaperChange:e})=>{const n=u.useMemo(()=>[{value:pt.A4,label:"A4 (210 × 297 mm)"},{value:pt.A3,label:"A3 (297 × 420 mm)"},{value:pt.B5,label:"B5 (182 × 257 mm)"},{value:pt.LETTER,label:"Letter (8.5 × 11 inch)"},{value:pt.LEGAL,label:"Legal (8.5 × 14 inch)"},{value:pt.CUSTOM,label:"カスタム"}],[]),r=u.useCallback(l=>{if(!l)return;const c=Be[l];e({...t,size:c})},[t,e]),s=u.useCallback(l=>{if(!l)return;const c={...t.size,preset:pt.CUSTOM,width:l};e({...t,size:c})},[t,e]),i=u.useCallback(l=>{if(!l)return;const c={...t.size,preset:pt.CUSTOM,height:l};e({...t,size:c})},[t,e]),a=t.size.preset===pt.CUSTOM;return o.jsxs("div",{className:ft.panel,children:[o.jsx("h3",{className:ft.title,children:"用紙サイズ"}),o.jsxs("div",{className:ft.content,children:[o.jsx("div",{className:ft.field,children:o.jsx(wt,{value:t.size.preset,options:n,onChange:r})}),a&&o.jsxs("div",{className:ft.dimensionsRow,children:[o.jsxs("div",{className:`${ft.field} ${ft.horizontal}`,children:[o.jsx("span",{className:ft.label,children:"幅"}),o.jsx(rt,{value:t.size.width,onChange:s,allowedUnits:["mm","cm","inch"],min:t.margin.left.value+t.margin.right.value+1,max:500})]}),o.jsxs("div",{className:`${ft.field} ${ft.horizontal}`,children:[o.jsx("span",{className:ft.label,children:"高さ"}),o.jsx(rt,{value:t.size.height,onChange:i,allowedUnits:["mm","cm","inch"],min:t.margin.top.value+t.margin.bottom.value+1,max:500})]})]})]})]})};rn.displayName="PaperSizePanel";const Ci="_section_p4xnx_6",Pi="_title_p4xnx_14",Ai="_content_p4xnx_26",ki="_buttonGroup_p4xnx_33",Li="_button_p4xnx_33",Si="_error_p4xnx_65",Q={section:Ci,title:Pi,content:Ai,buttonGroup:ki,button:Li,error:Si},on=({schema:t,values:e,onSchemaChange:n,onValuesChange:r})=>{const[s,i]=u.useState(""),a=u.useRef(null),l=u.useRef(null),c=u.useCallback(()=>{try{const h=Re(t,!0),w=new Blob([h],{type:"application/json"}),N=URL.createObjectURL(w),I=document.createElement("a");I.href=N,I.download="schema.json",I.click(),URL.revokeObjectURL(N),i("")}catch(h){i(`エクスポートエラー: ${h instanceof Error?h.message:String(h)}`)}},[t]),m=u.useCallback(async()=>{try{const h=Re(t,!0);await navigator.clipboard.writeText(h),i(""),alert("スキーマをクリップボードにコピーしました")}catch(h){i(`クリップボードエラー: ${h instanceof Error?h.message:String(h)}`)}},[t]),d=u.useCallback(()=>{var h;(h=a.current)==null||h.click()},[]),p=u.useCallback(h=>{var I;const w=(I=h.target.files)==null?void 0:I[0];if(!w)return;const N=new FileReader;N.onload=B=>{var D;try{const A=(D=B.target)==null?void 0:D.result,S=Te(A);n(S),i(""),alert("スキーマをインポートしました")}catch(A){i(`インポートエラー: ${A instanceof Error?A.message:String(A)}`)}},N.readAsText(w),h.target.value=""},[n]),v=u.useCallback(async()=>{try{const h=await navigator.clipboard.readText(),w=Te(h);n(w),i(""),alert("スキーマをインポートしました")}catch(h){i(`インポートエラー: ${h instanceof Error?h.message:String(h)}`)}},[n]),g=u.useCallback(()=>{try{const h=Ce(e,!0),w=new Blob([h],{type:"application/json"}),N=URL.createObjectURL(w),I=document.createElement("a");I.href=N,I.download="values.json",I.click(),URL.revokeObjectURL(N),i("")}catch(h){i(`エクスポートエラー: ${h instanceof Error?h.message:String(h)}`)}},[e]),E=u.useCallback(async()=>{try{const h=Ce(e,!0);await navigator.clipboard.writeText(h),i(""),alert("値をクリップボードにコピーしました")}catch(h){i(`クリップボードエラー: ${h instanceof Error?h.message:String(h)}`)}},[e]),y=u.useCallback(()=>{var h;(h=l.current)==null||h.click()},[]),f=u.useCallback(h=>{var I;const w=(I=h.target.files)==null?void 0:I[0];if(!w)return;const N=new FileReader;N.onload=B=>{var D;try{const A=(D=B.target)==null?void 0:D.result,S=Me(A);r(S),i(""),alert("値をインポートしました")}catch(A){i(`インポートエラー: ${A instanceof Error?A.message:String(A)}`)}},N.readAsText(w),h.target.value=""},[r]),x=u.useCallback(async()=>{try{const h=await navigator.clipboard.readText(),w=Me(h);r(w),i(""),alert("値をインポートしました")}catch(h){i(`インポートエラー: ${h instanceof Error?h.message:String(h)}`)}},[r]);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:Q.section,children:[o.jsx("h3",{className:Q.title,children:"スキーマ"}),o.jsxs("div",{className:Q.content,children:[o.jsxs("div",{className:Q.buttonGroup,children:[o.jsx("button",{type:"button",className:Q.button,onClick:c,children:"📥 ファイルにエクスポート"}),o.jsx("button",{type:"button",className:Q.button,onClick:m,children:"📋 クリップボードにコピー"})]}),o.jsxs("div",{className:Q.buttonGroup,children:[o.jsx("button",{type:"button",className:Q.button,onClick:d,children:"📤 ファイルからインポート"}),o.jsx("button",{type:"button",className:Q.button,onClick:v,children:"📋 クリップボードからペースト"})]}),o.jsx("input",{ref:a,type:"file",accept:".json",style:{display:"none"},onChange:p})]})]}),o.jsxs("div",{className:Q.section,children:[o.jsx("h3",{className:Q.title,children:"値"}),o.jsxs("div",{className:Q.content,children:[o.jsxs("div",{className:Q.buttonGroup,children:[o.jsx("button",{type:"button",className:Q.button,onClick:g,children:"📥 ファイルにエクスポート"}),o.jsx("button",{type:"button",className:Q.button,onClick:E,children:"📋 クリップボードにコピー"})]}),o.jsxs("div",{className:Q.buttonGroup,children:[o.jsx("button",{type:"button",className:Q.button,onClick:y,children:"📤 ファイルからインポート"}),o.jsx("button",{type:"button",className:Q.button,onClick:x,children:"📋 クリップボードからペースト"})]}),o.jsx("input",{ref:l,type:"file",accept:".json",style:{display:"none"},onChange:f})]})]}),s&&o.jsx("div",{className:Q.error,role:"alert",children:s})]})};on.displayName="ImportExportPanel";const sn=({schema:t,values:e,onSchemaChange:n,onValuesChange:r})=>o.jsx(Se,{children:o.jsx(on,{schema:t,values:e,onSchemaChange:n,onValuesChange:r})});sn.displayName="OtherPanel";const Oi="_container_6c3ft_3",Gi="_paletteItems_6c3ft_32",Bi="_item_6c3ft_44",Vi="_itemName_6c3ft_70",Ui="_itemPreview_6c3ft_98",Ft={container:Oi,paletteItems:Gi,item:Bi,itemName:Vi,itemPreview:Ui},an=({plugins:t,className:e})=>{const[n,r]=u.useState(null),s=u.useCallback((i,a)=>{r({plugin:i,mousePos:a,isOverCanvas:!1});const l=m=>{const d=document.elementFromPoint(m.clientX,m.clientY),p=!!(d!=null&&d.closest('[data-testid="interaction-layer"]'));r(v=>v?{...v,mousePos:{x:m.clientX,y:m.clientY},isOverCanvas:p}:null)},c=()=>{r(null),window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",c)};window.addEventListener("pointermove",l),window.addEventListener("pointerup",c)},[]);return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:`${Ft.container} ${e||""}`,children:o.jsx("div",{className:Ft.paletteItems,children:t.map(i=>o.jsx(ur,{plugin:i,onDragStart:s},i.kind))})}),n&&!n.isOverCanvas&&o.jsx(dr,{plugin:n.plugin,mousePos:n.mousePos})]})};an.displayName="PalettePanel";const ur=({plugin:t,onDragStart:e})=>{const n=u.useMemo(()=>Nt(t,{x:0,y:0,w:t.meta.defaultSize.w,h:t.meta.defaultSize.h},{}),[t]),r=u.useMemo(()=>{if(t.validateValue)return t.validateValue(void 0,n.props)},[t,n.props]),s=u.useCallback(i=>{i.preventDefault(),zt.start(t.kind,t.meta.defaultSize),e(t,{x:i.clientX,y:i.clientY});const a=()=>{zt.end(),window.removeEventListener("pointerup",a)};window.addEventListener("pointerup",a)},[t,e]);return o.jsxs("div",{className:Ft.item,children:[o.jsx("button",{type:"button",onPointerDown:s,className:Ft.itemName,"aria-label":`${t.meta.displayName}ブロックを追加`,children:t.meta.displayName}),o.jsx("div",{className:Ft.itemPreview,onPointerDown:s,"aria-hidden":"true",children:o.jsx(t.Renderer,{id:n.id,props:n.props,value:r,onChange:()=>{},readOnly:!0,mode:it.FORM})})]})};ur.displayName="PaletteItem";const dr=({plugin:t,mousePos:e})=>{const n=u.useMemo(()=>Nt(t,{x:0,y:0,w:t.meta.defaultSize.w,h:t.meta.defaultSize.h},{}),[t]),r=u.useMemo(()=>{if(t.validateValue)return t.validateValue(void 0,n.props)},[t,n.props]),s={width:t.meta.defaultSize.w*50,height:t.meta.defaultSize.h*50};return o.jsx("div",{"data-testid":"palette-drag-ghost",style:{position:"fixed",left:`${e.x-s.width/2}px`,top:`${e.y-s.height/2}px`,width:`${s.width}px`,height:`${s.height}px`,pointerEvents:"none",opacity:.5,filter:"grayscale(50%)",zIndex:9999,border:"2px dashed #3b82f6",backgroundColor:"#fff"},children:o.jsx(t.Renderer,{id:n.id,props:n.props,value:r,onChange:()=>{},readOnly:!0,mode:it.FORM})})};dr.displayName="DragGhost";const Fi="_container_rt0ql_3",zi="_tabHeader_rt0ql_14",Wi="_tabContent_rt0ql_21",Ut={container:Fi,tabHeader:zi,tabContent:Wi},mr=({blocks:t,selectedBlockIds:e,pluginRegistry:n,onUpdateBlocks:r,schema:s,values:i,onSchemaChange:a,onValuesChange:l,gridSize:c,className:m})=>{const d=u.useMemo(()=>Object.values(n),[n]),p=u.useMemo(()=>t.filter(g=>e.includes(g.id)),[t,e]),v=e.length>0;return o.jsx("div",{className:`${Ut.container} ${m||""}`,"data-sidebar":"true",children:o.jsxs(Oe,{defaultValue:"block",variant:"default",children:[o.jsxs(Ge,{className:Ut.tabHeader,children:[o.jsx(yt,{value:"block",children:"ブロック"}),o.jsx(yt,{value:"canvas",children:"キャンバス"}),o.jsx(yt,{value:"other",children:"その他"})]}),o.jsx(Et,{value:"block",className:Ut.tabContent,children:v?o.jsx(Je,{selectedBlocks:p,pluginRegistry:n,onUpdateBlocks:r,gridSize:c}):o.jsx(an,{plugins:d})}),o.jsx(Et,{value:"canvas",className:Ut.tabContent,children:o.jsx(tn,{schema:s,onSchemaChange:a})}),o.jsx(Et,{value:"other",className:Ut.tabContent,children:o.jsx(sn,{schema:s,values:i,onSchemaChange:a,onValuesChange:l})})]})})};mr.displayName="Sidebar";exports.ACTUAL_UNITS=io;exports.ALL_UNITS=so;exports.BLOCK_SUB_INDEX=mt;exports.BORDER_UNITS=bn;exports.BackgroundPanel=ir;exports.BlockBorder=Rn;exports.BlockCanvas=Mn;exports.BlockChangeType=ct;exports.BlockContainer=Ue;exports.BlockGuideBorder=Pn;exports.BlockLayer=Lt;exports.BlockOrderPanel=Qe;exports.BlockPropertyPanel=Je;exports.BlockRenderer=Ht;exports.Border=kt;exports.BorderOverlay=An;exports.BorderPanel=ar;exports.BorderRenderer=It;exports.COLOR_PALETTE=vn;exports.CanvasPanel=tn;exports.Checkbox=xt;exports.ColorPalette=Ae;exports.ColorPicker=Wt;exports.ColorPickerPopover=Le;exports.DEFAULT_DPI=W;exports.DEFAULT_FONT_FAMILY=_n;exports.DEFAULT_GRID=jn;exports.DEFAULT_GUIDE_BORDER=me;exports.DEFAULT_GUIDE_LINE=Cn;exports.DEFAULT_PAPER=Dn;exports.DEFAULT_PAPER_MARGIN=In;exports.DEFAULT_PAPER_SIZES=Be;exports.DEFAULT_SCHEMA=yo;exports.DimensionInput=rt;exports.DragLayer=qe;exports.DragType=nt;exports.EditingBlock=qn;exports.FONT_UNITS=gn;exports.GRID_UNITS=lo;exports.GridCanvas=kn;exports.GridDimensionLabel=ee;exports.GridLayer=he;exports.GridOverlay=Gn;exports.GridResizeHandle=ne;exports.GridSizePanel=en;exports.HorizontalAlign=Tt;exports.ImageObjectFit=jt;exports.ImportExportPanel=on;exports.InsertGhost=ze;exports.InteractionBlock=St;exports.InteractionEventType=H;exports.InteractionLayer=Ze;exports.InteractionMode=lt;exports.LayoutPanel=lr;exports.LineType=dt;exports.MarginOverlay=Bn;exports.MarginPanel=nn;exports.MetaPanel=cr;exports.MovingGhost=Ye;exports.MultilineWhiteSpace=Ct;exports.MultilineWordWrap=Mt;exports.NoteEdit=Qn;exports.NoteEditor=us;exports.NoteForm=er;exports.NoteMode=it;exports.NotePrint=ds;exports.NoteView=rr;exports.NumberInput=st;exports.OtherPanel=sn;exports.PADDING_UNITS=$t;exports.PAPER_UNITS=ao;exports.PalettePanel=an;exports.PaperSizePanel=rn;exports.PaperSizePreset=pt;exports.PluginPanels=Fs;exports.PropertyField=pe;exports.RESIZE_HANDLE_STYLE=fe;exports.RGBAInputs=ke;exports.ResizeGhost=Xe;exports.ResizeHandle=X;exports.ResizeHandles=Fe;exports.SELECTION_STYLE=Xt;exports.SIZE_UNITS=je;exports.Select=wt;exports.SelectionBorder=Xn;exports.SelectionLayer=Ke;exports.Sidebar=mr;exports.TabPanel=Se;exports.Tabs=Oe;exports.TabsContent=Et;exports.TabsList=Ge;exports.TabsTrigger=yt;exports.TextInput=At;exports.ValidationSeverity=$n;exports.VerticalAlign=Rt;exports.Z_INDEX=G;exports.alignmentDefinition=pn;exports.assertFinite=bo;exports.assertInteger=de;exports.assertNonNegative=et;exports.assertPositive=ue;exports.assertRange=Nn;exports.binarySearch=te;exports.calculateGridResize=Ne;exports.calculateResizedLayout=He;exports.clampBlockToGrid=Zn;exports.clampMultipleBlocks=We;exports.cleanupPrint=Fn;exports.createBlock=Nt;exports.createBlockId=En;exports.createInitialProps=yn;exports.createPluginRegistry=mo;exports.deserializeSchema=Te;exports.deserializeValues=Me;exports.dimensionToString=Sn;exports.dimensionsToStrings=So;exports.distributeRemainder=Vn;exports.executePrint=Qo;exports.findBlockAtPoint=Pe;exports.findGridIndex=De;exports.fontStyleDefinition=uo;exports.getBlockContainerStyle=Ve;exports.getBlockZIndex=Tn;exports.getCommonValue=vt;exports.getInteractionMode=ae;exports.getMaxBlockCount=Eo;exports.getMaxStep=Ie;exports.getPaperSize=Jo;exports.getStrokeDasharray=Pt;exports.getSubZIndex=Yt;exports.globalDragStore=zt;exports.gridToMms=oe;exports.gridToPxs=Zo;exports.imageDefinition=ho;exports.interactionZIndexs=Z;exports.isValidHex=zr;exports.mmsToPxs=se;exports.multilineDefinition=fo;exports.paddingDefinition=wn;exports.parseColor=Ee;exports.placeholderDefinition=po;exports.preparePrint=Un;exports.printElement=$e;exports.removeUndefinedProps=ie;exports.serializeSchema=Re;exports.serializeValues=Ce;exports.sizeDefinition=xo;exports.stringToDimension=Ln;exports.stringsToDimensions=Co;exports.toHex=xn;exports.toMm=Y;exports.toPx=V;exports.toRgbaString=Fr;exports.universalProperties=co;exports.useGridCalc=qt;exports.useInteractionState=Kn;exports.validateSchema=zn;exports.validateValues=Yn;exports.validationDefinition=vo;
70
70
  //# sourceMappingURL=index.js.map