@tatamicks/core 0.0.1 → 0.1.0

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
@@ -1,4 +1,4 @@
1
- "use strict";require('./index.css');var Zr=Object.defineProperty;var Qr=(e,t,n)=>t in e?Zr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ot=(e,t,n)=>Qr(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react");var ht={exports:{}},ot={};/**
1
+ "use strict";require('./index.css');var no=Object.defineProperty;var ro=(e,t,n)=>t in e?no(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ot=(e,t,n)=>ro(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react");var ht={exports:{}},ot={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -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 In;function eo(){if(In)return ot;In=1;var e=d,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function i(l,c,h){var m,x={},b=null,g=null;h!==void 0&&(b=""+h),c.key!==void 0&&(b=""+c.key),c.ref!==void 0&&(g=c.ref);for(m in c)s.call(c,m)&&!a.hasOwnProperty(m)&&(x[m]=c[m]);if(l&&l.defaultProps)for(m in c=l.defaultProps,c)x[m]===void 0&&(x[m]=c[m]);return{$$typeof:t,type:l,key:b,ref:g,props:x,_owner:o.current}}return ot.Fragment=n,ot.jsx=i,ot.jsxs=i,ot}var st={};/**
9
+ */var In;function oo(){if(In)return ot;In=1;var e=d,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,s=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function i(l,c,h){var p,x={},b=null,g=null;h!==void 0&&(b=""+h),c.key!==void 0&&(b=""+c.key),c.ref!==void 0&&(g=c.ref);for(p in c)o.call(c,p)&&!a.hasOwnProperty(p)&&(x[p]=c[p]);if(l&&l.defaultProps)for(p in c=l.defaultProps,c)x[p]===void 0&&(x[p]=c[p]);return{$$typeof:t,type:l,key:b,ref:g,props:x,_owner:s.current}}return ot.Fragment=n,ot.jsx=i,ot.jsxs=i,ot}var st={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,18 +14,28 @@
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 Dn;function to(){return Dn||(Dn=1,process.env.NODE_ENV!=="production"&&(function(){var e=d,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),m=Symbol.for("react.suspense_list"),x=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen"),I=Symbol.iterator,E="@@iterator";function v(u){if(u===null||typeof u!="object")return null;var _=I&&u[I]||u[E];return typeof _=="function"?_:null}var p=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function f(u){{for(var _=arguments.length,C=new Array(_>1?_-1:0),O=1;O<_;O++)C[O-1]=arguments[O];y("error",u,C)}}function y(u,_,C){{var O=p.ReactDebugCurrentFrame,Y=O.getStackAddendum();Y!==""&&(_+="%s",C=C.concat([Y]));var z=C.map(function(V){return String(V)});z.unshift("Warning: "+_),Function.prototype.apply.call(console[u],console,z)}}var w=!1,R=!1,L=!1,$=!1,N=!1,S;S=Symbol.for("react.module.reference");function M(u){return!!(typeof u=="string"||typeof u=="function"||u===s||u===a||N||u===o||u===h||u===m||$||u===g||w||R||L||typeof u=="object"&&u!==null&&(u.$$typeof===b||u.$$typeof===x||u.$$typeof===i||u.$$typeof===l||u.$$typeof===c||u.$$typeof===S||u.getModuleId!==void 0))}function G(u,_,C){var O=u.displayName;if(O)return O;var Y=_.displayName||_.name||"";return Y!==""?C+"("+Y+")":C}function T(u){return u.displayName||"Context"}function P(u){if(u==null)return null;if(typeof u.tag=="number"&&f("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof u=="function")return u.displayName||u.name||null;if(typeof u=="string")return u;switch(u){case s:return"Fragment";case n:return"Portal";case a:return"Profiler";case o:return"StrictMode";case h:return"Suspense";case m:return"SuspenseList"}if(typeof u=="object")switch(u.$$typeof){case l:var _=u;return T(_)+".Consumer";case i:var C=u;return T(C._context)+".Provider";case c:return G(u,u.render,"ForwardRef");case x:var O=u.displayName||null;return O!==null?O:P(u.type)||"Memo";case b:{var Y=u,z=Y._payload,V=Y._init;try{return P(V(z))}catch{return null}}}return null}var j=Object.assign,D=0,k,A,K,Z,Q,ue,le;function H(){}H.__reactDisabledLog=!0;function Se(){{if(D===0){k=console.log,A=console.info,K=console.warn,Z=console.error,Q=console.group,ue=console.groupCollapsed,le=console.groupEnd;var u={configurable:!0,enumerable:!0,value:H,writable:!0};Object.defineProperties(console,{info:u,log:u,warn:u,error:u,group:u,groupCollapsed:u,groupEnd:u})}D++}}function Pe(){{if(D--,D===0){var u={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:j({},u,{value:k}),info:j({},u,{value:A}),warn:j({},u,{value:K}),error:j({},u,{value:Z}),group:j({},u,{value:Q}),groupCollapsed:j({},u,{value:ue}),groupEnd:j({},u,{value:le})})}D<0&&f("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var tt=p.ReactCurrentDispatcher,nt;function Ee(u,_,C){{if(nt===void 0)try{throw Error()}catch(Y){var O=Y.stack.trim().match(/\n( *(at )?)/);nt=O&&O[1]||""}return`
18
- `+nt+u}}var De=!1,Oe;{var Rt=typeof WeakMap=="function"?WeakMap:Map;Oe=new Rt}function rt(u,_){if(!u||De)return"";{var C=Oe.get(u);if(C!==void 0)return C}var O;De=!0;var Y=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var z;z=tt.current,tt.current=null,Se();try{if(_){var V=function(){throw Error()};if(Object.defineProperty(V.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(V,[])}catch(ve){O=ve}Reflect.construct(u,[],V)}else{try{V.call()}catch(ve){O=ve}u.call(V.prototype)}}else{try{throw Error()}catch(ve){O=ve}u()}}catch(ve){if(ve&&O&&typeof ve.stack=="string"){for(var B=ve.stack.split(`
17
+ */var Dn;function so(){return Dn||(Dn=1,process.env.NODE_ENV!=="production"&&(function(){var e=d,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),p=Symbol.for("react.suspense_list"),x=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen"),N=Symbol.iterator,E="@@iterator";function m(u){if(u===null||typeof u!="object")return null;var _=N&&u[N]||u[E];return typeof _=="function"?_:null}var v=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function f(u){{for(var _=arguments.length,C=new Array(_>1?_-1:0),O=1;O<_;O++)C[O-1]=arguments[O];y("error",u,C)}}function y(u,_,C){{var O=v.ReactDebugCurrentFrame,Y=O.getStackAddendum();Y!==""&&(_+="%s",C=C.concat([Y]));var z=C.map(function(V){return String(V)});z.unshift("Warning: "+_),Function.prototype.apply.call(console[u],console,z)}}var w=!1,R=!1,L=!1,$=!1,I=!1,k;k=Symbol.for("react.module.reference");function M(u){return!!(typeof u=="string"||typeof u=="function"||u===o||u===a||I||u===s||u===h||u===p||$||u===g||w||R||L||typeof u=="object"&&u!==null&&(u.$$typeof===b||u.$$typeof===x||u.$$typeof===i||u.$$typeof===l||u.$$typeof===c||u.$$typeof===k||u.getModuleId!==void 0))}function G(u,_,C){var O=u.displayName;if(O)return O;var Y=_.displayName||_.name||"";return Y!==""?C+"("+Y+")":C}function T(u){return u.displayName||"Context"}function S(u){if(u==null)return null;if(typeof u.tag=="number"&&f("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof u=="function")return u.displayName||u.name||null;if(typeof u=="string")return u;switch(u){case o:return"Fragment";case n:return"Portal";case a:return"Profiler";case s:return"StrictMode";case h:return"Suspense";case p:return"SuspenseList"}if(typeof u=="object")switch(u.$$typeof){case l:var _=u;return T(_)+".Consumer";case i:var C=u;return T(C._context)+".Provider";case c:return G(u,u.render,"ForwardRef");case x:var O=u.displayName||null;return O!==null?O:S(u.type)||"Memo";case b:{var Y=u,z=Y._payload,V=Y._init;try{return S(V(z))}catch{return null}}}return null}var j=Object.assign,D=0,P,A,K,Z,Q,ue,le;function H(){}H.__reactDisabledLog=!0;function ke(){{if(D===0){P=console.log,A=console.info,K=console.warn,Z=console.error,Q=console.group,ue=console.groupCollapsed,le=console.groupEnd;var u={configurable:!0,enumerable:!0,value:H,writable:!0};Object.defineProperties(console,{info:u,log:u,warn:u,error:u,group:u,groupCollapsed:u,groupEnd:u})}D++}}function Se(){{if(D--,D===0){var u={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:j({},u,{value:P}),info:j({},u,{value:A}),warn:j({},u,{value:K}),error:j({},u,{value:Z}),group:j({},u,{value:Q}),groupCollapsed:j({},u,{value:ue}),groupEnd:j({},u,{value:le})})}D<0&&f("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var tt=v.ReactCurrentDispatcher,nt;function Ee(u,_,C){{if(nt===void 0)try{throw Error()}catch(Y){var O=Y.stack.trim().match(/\n( *(at )?)/);nt=O&&O[1]||""}return`
18
+ `+nt+u}}var De=!1,Oe;{var Rt=typeof WeakMap=="function"?WeakMap:Map;Oe=new Rt}function rt(u,_){if(!u||De)return"";{var C=Oe.get(u);if(C!==void 0)return C}var O;De=!0;var Y=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var z;z=tt.current,tt.current=null,ke();try{if(_){var V=function(){throw Error()};if(Object.defineProperty(V.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(V,[])}catch(ve){O=ve}Reflect.construct(u,[],V)}else{try{V.call()}catch(ve){O=ve}u.call(V.prototype)}}else{try{throw Error()}catch(ve){O=ve}u()}}catch(ve){if(ve&&O&&typeof ve.stack=="string"){for(var B=ve.stack.split(`
19
19
  `),he=O.stack.split(`
20
20
  `),ee=B.length-1,ne=he.length-1;ee>=1&&ne>=0&&B[ee]!==he[ne];)ne--;for(;ee>=1&&ne>=0;ee--,ne--)if(B[ee]!==he[ne]){if(ee!==1||ne!==1)do if(ee--,ne--,ne<0||B[ee]!==he[ne]){var _e=`
21
- `+B[ee].replace(" at new "," at ");return u.displayName&&_e.includes("<anonymous>")&&(_e=_e.replace("<anonymous>",u.displayName)),typeof u=="function"&&Oe.set(u,_e),_e}while(ee>=1&&ne>=0);break}}}finally{De=!1,tt.current=z,Pe(),Error.prepareStackTrace=Y}var Ye=u?u.displayName||u.name:"",Ge=Ye?Ee(Ye):"";return typeof u=="function"&&Oe.set(u,Ge),Ge}function $t(u,_,C){return rt(u,!1)}function Tt(u){var _=u.prototype;return!!(_&&_.isReactComponent)}function Ue(u,_,C){if(u==null)return"";if(typeof u=="function")return rt(u,Tt(u));if(typeof u=="string")return Ee(u);switch(u){case h:return Ee("Suspense");case m:return Ee("SuspenseList")}if(typeof u=="object")switch(u.$$typeof){case c:return $t(u.render);case x:return Ue(u.type,_,C);case b:{var O=u,Y=O._payload,z=O._init;try{return Ue(z(Y),_,C)}catch{}}}return""}var Le=Object.prototype.hasOwnProperty,dt={},hn=p.ReactDebugCurrentFrame;function ft(u){if(u){var _=u._owner,C=Ue(u.type,u._source,_?_.type:null);hn.setExtraStackFrame(C)}else hn.setExtraStackFrame(null)}function $r(u,_,C,O,Y){{var z=Function.call.bind(Le);for(var V in u)if(z(u,V)){var B=void 0;try{if(typeof u[V]!="function"){var he=Error((O||"React class")+": "+C+" type `"+V+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof u[V]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw he.name="Invariant Violation",he}B=u[V](_,V,O,C,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(ee){B=ee}B&&!(B instanceof Error)&&(ft(Y),f("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",O||"React class",C,V,typeof B),ft(null)),B instanceof Error&&!(B.message in dt)&&(dt[B.message]=!0,ft(Y),f("Failed %s type: %s",C,B.message),ft(null))}}}var Tr=Array.isArray;function Mt(u){return Tr(u)}function Mr(u){{var _=typeof Symbol=="function"&&Symbol.toStringTag,C=_&&u[Symbol.toStringTag]||u.constructor.name||"Object";return C}}function kr(u){try{return mn(u),!1}catch{return!0}}function mn(u){return""+u}function pn(u){if(kr(u))return f("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Mr(u)),mn(u)}var vn=p.ReactCurrentOwner,Sr={key:!0,ref:!0,__self:!0,__source:!0},xn,bn;function Pr(u){if(Le.call(u,"ref")){var _=Object.getOwnPropertyDescriptor(u,"ref").get;if(_&&_.isReactWarning)return!1}return u.ref!==void 0}function Ar(u){if(Le.call(u,"key")){var _=Object.getOwnPropertyDescriptor(u,"key").get;if(_&&_.isReactWarning)return!1}return u.key!==void 0}function Or(u,_){typeof u.ref=="string"&&vn.current}function Lr(u,_){{var C=function(){xn||(xn=!0,f("%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://reactjs.org/link/special-props)",_))};C.isReactWarning=!0,Object.defineProperty(u,"key",{get:C,configurable:!0})}}function Gr(u,_){{var C=function(){bn||(bn=!0,f("%s: `ref` 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://reactjs.org/link/special-props)",_))};C.isReactWarning=!0,Object.defineProperty(u,"ref",{get:C,configurable:!0})}}var Br=function(u,_,C,O,Y,z,V){var B={$$typeof:t,type:u,key:_,ref:C,props:V,_owner:z};return B._store={},Object.defineProperty(B._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(B,"_self",{configurable:!1,enumerable:!1,writable:!1,value:O}),Object.defineProperty(B,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Y}),Object.freeze&&(Object.freeze(B.props),Object.freeze(B)),B};function Fr(u,_,C,O,Y){{var z,V={},B=null,he=null;C!==void 0&&(pn(C),B=""+C),Ar(_)&&(pn(_.key),B=""+_.key),Pr(_)&&(he=_.ref,Or(_,Y));for(z in _)Le.call(_,z)&&!Sr.hasOwnProperty(z)&&(V[z]=_[z]);if(u&&u.defaultProps){var ee=u.defaultProps;for(z in ee)V[z]===void 0&&(V[z]=ee[z])}if(B||he){var ne=typeof u=="function"?u.displayName||u.name||"Unknown":u;B&&Lr(V,ne),he&&Gr(V,ne)}return Br(u,B,he,Y,O,vn.current,V)}}var kt=p.ReactCurrentOwner,gn=p.ReactDebugCurrentFrame;function We(u){if(u){var _=u._owner,C=Ue(u.type,u._source,_?_.type:null);gn.setExtraStackFrame(C)}else gn.setExtraStackFrame(null)}var St;St=!1;function Pt(u){return typeof u=="object"&&u!==null&&u.$$typeof===t}function yn(){{if(kt.current){var u=P(kt.current.type);if(u)return`
21
+ `+B[ee].replace(" at new "," at ");return u.displayName&&_e.includes("<anonymous>")&&(_e=_e.replace("<anonymous>",u.displayName)),typeof u=="function"&&Oe.set(u,_e),_e}while(ee>=1&&ne>=0);break}}}finally{De=!1,tt.current=z,Se(),Error.prepareStackTrace=Y}var Ye=u?u.displayName||u.name:"",Ge=Ye?Ee(Ye):"";return typeof u=="function"&&Oe.set(u,Ge),Ge}function $t(u,_,C){return rt(u,!1)}function Tt(u){var _=u.prototype;return!!(_&&_.isReactComponent)}function Ue(u,_,C){if(u==null)return"";if(typeof u=="function")return rt(u,Tt(u));if(typeof u=="string")return Ee(u);switch(u){case h:return Ee("Suspense");case p:return Ee("SuspenseList")}if(typeof u=="object")switch(u.$$typeof){case c:return $t(u.render);case x:return Ue(u.type,_,C);case b:{var O=u,Y=O._payload,z=O._init;try{return Ue(z(Y),_,C)}catch{}}}return""}var Le=Object.prototype.hasOwnProperty,dt={},hn=v.ReactDebugCurrentFrame;function ft(u){if(u){var _=u._owner,C=Ue(u.type,u._source,_?_.type:null);hn.setExtraStackFrame(C)}else hn.setExtraStackFrame(null)}function kr(u,_,C,O,Y){{var z=Function.call.bind(Le);for(var V in u)if(z(u,V)){var B=void 0;try{if(typeof u[V]!="function"){var he=Error((O||"React class")+": "+C+" type `"+V+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof u[V]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw he.name="Invariant Violation",he}B=u[V](_,V,O,C,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(ee){B=ee}B&&!(B instanceof Error)&&(ft(Y),f("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",O||"React class",C,V,typeof B),ft(null)),B instanceof Error&&!(B.message in dt)&&(dt[B.message]=!0,ft(Y),f("Failed %s type: %s",C,B.message),ft(null))}}}var Sr=Array.isArray;function Mt(u){return Sr(u)}function Ar(u){{var _=typeof Symbol=="function"&&Symbol.toStringTag,C=_&&u[Symbol.toStringTag]||u.constructor.name||"Object";return C}}function Or(u){try{return mn(u),!1}catch{return!0}}function mn(u){return""+u}function pn(u){if(Or(u))return f("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ar(u)),mn(u)}var vn=v.ReactCurrentOwner,Lr={key:!0,ref:!0,__self:!0,__source:!0},xn,bn;function Gr(u){if(Le.call(u,"ref")){var _=Object.getOwnPropertyDescriptor(u,"ref").get;if(_&&_.isReactWarning)return!1}return u.ref!==void 0}function Br(u){if(Le.call(u,"key")){var _=Object.getOwnPropertyDescriptor(u,"key").get;if(_&&_.isReactWarning)return!1}return u.key!==void 0}function Fr(u,_){typeof u.ref=="string"&&vn.current}function Vr(u,_){{var C=function(){xn||(xn=!0,f("%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://reactjs.org/link/special-props)",_))};C.isReactWarning=!0,Object.defineProperty(u,"key",{get:C,configurable:!0})}}function Ur(u,_){{var C=function(){bn||(bn=!0,f("%s: `ref` 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://reactjs.org/link/special-props)",_))};C.isReactWarning=!0,Object.defineProperty(u,"ref",{get:C,configurable:!0})}}var Wr=function(u,_,C,O,Y,z,V){var B={$$typeof:t,type:u,key:_,ref:C,props:V,_owner:z};return B._store={},Object.defineProperty(B._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(B,"_self",{configurable:!1,enumerable:!1,writable:!1,value:O}),Object.defineProperty(B,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Y}),Object.freeze&&(Object.freeze(B.props),Object.freeze(B)),B};function Yr(u,_,C,O,Y){{var z,V={},B=null,he=null;C!==void 0&&(pn(C),B=""+C),Br(_)&&(pn(_.key),B=""+_.key),Gr(_)&&(he=_.ref,Fr(_,Y));for(z in _)Le.call(_,z)&&!Lr.hasOwnProperty(z)&&(V[z]=_[z]);if(u&&u.defaultProps){var ee=u.defaultProps;for(z in ee)V[z]===void 0&&(V[z]=ee[z])}if(B||he){var ne=typeof u=="function"?u.displayName||u.name||"Unknown":u;B&&Vr(V,ne),he&&Ur(V,ne)}return Wr(u,B,he,Y,O,vn.current,V)}}var Pt=v.ReactCurrentOwner,gn=v.ReactDebugCurrentFrame;function We(u){if(u){var _=u._owner,C=Ue(u.type,u._source,_?_.type:null);gn.setExtraStackFrame(C)}else gn.setExtraStackFrame(null)}var kt;kt=!1;function St(u){return typeof u=="object"&&u!==null&&u.$$typeof===t}function yn(){{if(Pt.current){var u=S(Pt.current.type);if(u)return`
22
22
 
23
- Check the render method of \``+u+"`."}return""}}function Vr(u){return""}var wn={};function Ur(u){{var _=yn();if(!_){var C=typeof u=="string"?u:u.displayName||u.name;C&&(_=`
23
+ Check the render method of \``+u+"`."}return""}}function zr(u){return""}var wn={};function Kr(u){{var _=yn();if(!_){var C=typeof u=="string"?u:u.displayName||u.name;C&&(_=`
24
24
 
25
- Check the top-level render call using <`+C+">.")}return _}}function _n(u,_){{if(!u._store||u._store.validated||u.key!=null)return;u._store.validated=!0;var C=Ur(_);if(wn[C])return;wn[C]=!0;var O="";u&&u._owner&&u._owner!==kt.current&&(O=" It was passed a child from "+P(u._owner.type)+"."),We(u),f('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',C,O),We(null)}}function En(u,_){{if(typeof u!="object")return;if(Mt(u))for(var C=0;C<u.length;C++){var O=u[C];Pt(O)&&_n(O,_)}else if(Pt(u))u._store&&(u._store.validated=!0);else if(u){var Y=v(u);if(typeof Y=="function"&&Y!==u.entries)for(var z=Y.call(u),V;!(V=z.next()).done;)Pt(V.value)&&_n(V.value,_)}}}function Wr(u){{var _=u.type;if(_==null||typeof _=="string")return;var C;if(typeof _=="function")C=_.propTypes;else if(typeof _=="object"&&(_.$$typeof===c||_.$$typeof===x))C=_.propTypes;else return;if(C){var O=P(_);$r(C,u.props,"prop",O,u)}else if(_.PropTypes!==void 0&&!St){St=!0;var Y=P(_);f("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Y||"Unknown")}typeof _.getDefaultProps=="function"&&!_.getDefaultProps.isReactClassApproved&&f("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Yr(u){{for(var _=Object.keys(u.props),C=0;C<_.length;C++){var O=_[C];if(O!=="children"&&O!=="key"){We(u),f("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",O),We(null);break}}u.ref!==null&&(We(u),f("Invalid attribute `ref` supplied to `React.Fragment`."),We(null))}}var jn={};function Nn(u,_,C,O,Y,z){{var V=M(u);if(!V){var B="";(u===void 0||typeof u=="object"&&u!==null&&Object.keys(u).length===0)&&(B+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var he=Vr();he?B+=he:B+=yn();var ee;u===null?ee="null":Mt(u)?ee="array":u!==void 0&&u.$$typeof===t?(ee="<"+(P(u.type)||"Unknown")+" />",B=" Did you accidentally export a JSX literal instead of a component?"):ee=typeof u,f("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ee,B)}var ne=Fr(u,_,C,Y,z);if(ne==null)return ne;if(V){var _e=_.children;if(_e!==void 0)if(O)if(Mt(_e)){for(var Ye=0;Ye<_e.length;Ye++)En(_e[Ye],u);Object.freeze&&Object.freeze(_e)}else f("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 En(_e,u)}if(Le.call(_,"key")){var Ge=P(u),ve=Object.keys(_).filter(function(Jr){return Jr!=="key"}),At=ve.length>0?"{key: someKey, "+ve.join(": ..., ")+": ...}":"{key: someKey}";if(!jn[Ge+At]){var qr=ve.length>0?"{"+ve.join(": ..., ")+": ...}":"{}";f(`A props object containing a "key" prop is being spread into JSX:
25
+ Check the top-level render call using <`+C+">.")}return _}}function _n(u,_){{if(!u._store||u._store.validated||u.key!=null)return;u._store.validated=!0;var C=Kr(_);if(wn[C])return;wn[C]=!0;var O="";u&&u._owner&&u._owner!==Pt.current&&(O=" It was passed a child from "+S(u._owner.type)+"."),We(u),f('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',C,O),We(null)}}function En(u,_){{if(typeof u!="object")return;if(Mt(u))for(var C=0;C<u.length;C++){var O=u[C];St(O)&&_n(O,_)}else if(St(u))u._store&&(u._store.validated=!0);else if(u){var Y=m(u);if(typeof Y=="function"&&Y!==u.entries)for(var z=Y.call(u),V;!(V=z.next()).done;)St(V.value)&&_n(V.value,_)}}}function Hr(u){{var _=u.type;if(_==null||typeof _=="string")return;var C;if(typeof _=="function")C=_.propTypes;else if(typeof _=="object"&&(_.$$typeof===c||_.$$typeof===x))C=_.propTypes;else return;if(C){var O=S(_);kr(C,u.props,"prop",O,u)}else if(_.PropTypes!==void 0&&!kt){kt=!0;var Y=S(_);f("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Y||"Unknown")}typeof _.getDefaultProps=="function"&&!_.getDefaultProps.isReactClassApproved&&f("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Xr(u){{for(var _=Object.keys(u.props),C=0;C<_.length;C++){var O=_[C];if(O!=="children"&&O!=="key"){We(u),f("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",O),We(null);break}}u.ref!==null&&(We(u),f("Invalid attribute `ref` supplied to `React.Fragment`."),We(null))}}var jn={};function Nn(u,_,C,O,Y,z){{var V=M(u);if(!V){var B="";(u===void 0||typeof u=="object"&&u!==null&&Object.keys(u).length===0)&&(B+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var he=zr();he?B+=he:B+=yn();var ee;u===null?ee="null":Mt(u)?ee="array":u!==void 0&&u.$$typeof===t?(ee="<"+(S(u.type)||"Unknown")+" />",B=" Did you accidentally export a JSX literal instead of a component?"):ee=typeof u,f("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ee,B)}var ne=Yr(u,_,C,Y,z);if(ne==null)return ne;if(V){var _e=_.children;if(_e!==void 0)if(O)if(Mt(_e)){for(var Ye=0;Ye<_e.length;Ye++)En(_e[Ye],u);Object.freeze&&Object.freeze(_e)}else f("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 En(_e,u)}if(Le.call(_,"key")){var Ge=S(u),ve=Object.keys(_).filter(function(to){return to!=="key"}),At=ve.length>0?"{key: someKey, "+ve.join(": ..., ")+": ...}":"{key: someKey}";if(!jn[Ge+At]){var eo=ve.length>0?"{"+ve.join(": ..., ")+": ...}":"{}";f(`A props object containing a "key" prop is being spread into JSX:
26
26
  let props = %s;
27
27
  <%s {...props} />
28
28
  React keys must be passed directly to JSX without using spread:
29
29
  let props = %s;
30
- <%s key={someKey} {...props} />`,At,Ge,qr,Ge),jn[Ge+At]=!0}}return u===s?Yr(ne):Wr(ne),ne}}function zr(u,_,C){return Nn(u,_,C,!0)}function Kr(u,_,C){return Nn(u,_,C,!1)}var Hr=Kr,Xr=zr;st.Fragment=s,st.jsx=Hr,st.jsxs=Xr})()),st}var Cn;function no(){return Cn||(Cn=1,process.env.NODE_ENV==="production"?ht.exports=eo():ht.exports=to()),ht.exports}var r=no();const q=96,Ve=d.memo(({width:e,height:t,border:n,dpi:s=q,className:o=""})=>n.hasAnyBorder?r.jsxs("svg",{width:e,height:t,xmlns:"http://www.w3.org/2000/svg",className:o,style:{overflow:"visible"},children:[r.jsx("title",{children:"border SVG"}),n.top&&r.jsx("line",{...n.getTopSVGProps(e,s)}),n.right&&r.jsx("line",{...n.getRightSVGProps(e,t,s)}),n.bottom&&r.jsx("line",{...n.getBottomSVGProps(e,t,s)}),n.left&&r.jsx("line",{...n.getLeftSVGProps(t,s)})]}):null);Ve.displayName="BorderRenderer";const F={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},we={BG:10,CONTENT:50,GUIDE:70,BORDER:80};function Sn(e){const t=F.BLOCK_LAYER_MIN+e*F.BLOCK_LAYER_STEP;return t>=F.BLOCK_LAYER_MAX?F.BLOCK_LAYER_MAX:t}function lt(e,t){const n=Math.min(Math.max(0,t),F.BLOCK_LAYER_STEP-1);return e+n}function ro(){return Math.floor((F.BLOCK_LAYER_MAX-F.BLOCK_LAYER_MIN)/F.BLOCK_LAYER_STEP)}var He=(e=>(e.left="flex-start",e.center="center",e.right="flex-end",e))(He||{}),Xe=(e=>(e.top="flex-start",e.center="center",e.bottom="flex-end",e))(Xe||{});const oo="_container_1mr3i_5",so="_select_1mr3i_11",io="_placeholderOverlay_1mr3i_44",Lt={container:oo,select:so,placeholderOverlay:io},$e=e=>{const{value:t,onChange:n,readOnly:s=!1,config:o}=e,a=e.options??(o==null?void 0:o.options)??[],i=e.placeholder??(o==null?void 0:o.placeholder)??"選択してください",l=e.width??(o==null?void 0:o.width),c=e.height??(o==null?void 0:o.height),h=d.useCallback(I=>{const E=I.target.value;if(E==="")n(void 0);else{const v=a.find(p=>String(p.value)===E);n(v?v.value:E)}},[n,a]),m=t??"",x=t!==void 0&&t!=="",b={};l!==void 0?b.width=`${l}px`:b.width="100%";const g={width:"100%",height:c?`${c}px`:void 0};return r.jsxs("div",{className:Lt.container,style:b,children:[!x&&r.jsx("input",{className:Lt.placeholderOverlay,style:g,readOnly:!0,placeholder:i}),r.jsx("select",{className:Lt.select,style:g,value:m,onChange:h,disabled:s,children:a.map(I=>r.jsx("option",{value:String(I.value),children:I.label},String(I.value)))})]})};$e.displayName="Select";const Pn={justifyContent:{defaultValue:He.left,label:"水平方向の配置",group:"配置",description:"ブロック内のコンテンツの水平方向の配置を設定します。",Component:$e,config:{options:[{label:"左揃え",value:He.left},{label:"中央揃え",value:He.center},{label:"右揃え",value:He.right}]}},alignItems:{defaultValue:Xe.center,label:"垂直方向の配置",group:"配置",description:"ブロック内のコンテンツの垂直方向の配置を設定します。",Component:$e,config:{options:[{label:"上揃え",value:Xe.top},{label:"中央揃え",value:Xe.center},{label:"下揃え",value:Xe.bottom}]}}},ao="_container_1tnp6_5",lo="_input_1tnp6_13",co="_label_1tnp6_29",Gt={container:ao,input:lo,label:co},Ie=({value:e,onChange:t,readOnly:n=!1,label:s,config:o})=>{const a=s??(o==null?void 0:o.label),i=d.useCallback(l=>{t(l.target.checked)},[t]);return r.jsxs("label",{className:Gt.container,children:[r.jsx("input",{type:"checkbox",className:Gt.input,checked:!!e,onChange:i,disabled:n}),a&&r.jsx("span",{className:Gt.label,children:a})]})};Ie.displayName="Checkbox";const uo="_container_qbvob_5",fo="_colorButton_qbvob_13",ho="_textInputWrapper_qbvob_40",mo="_textInputPrefix_qbvob_62",po="_textInput_qbvob_40",vo="_popover_qbvob_125",xo="_palette_qbvob_141",bo="_paletteButton_qbvob_148",go="_selected_qbvob_171",yo="_transparentPaletteButton_qbvob_177",wo="_rgbaInputs_qbvob_183",_o="_rgbaInputGroup_qbvob_190",Eo="_rgbaLabel_qbvob_205",ie={container:uo,colorButton:fo,textInputWrapper:ho,textInputPrefix:mo,textInput:po,popover:vo,palette:xo,paletteButton:bo,selected:go,transparentPaletteButton:yo,rgbaInputs:wo,rgbaInputGroup:_o,rgbaLabel:Eo};function Rn(e){if(!e)return null;const t=e.match(/^#([0-9a-f]{6}|[0-9a-f]{8})$/i);if(t&&typeof t[1]=="string"){const s=t[1],o=Number.parseInt(s.slice(0,2),16),a=Number.parseInt(s.slice(2,4),16),i=Number.parseInt(s.slice(4,6),16),l=s.length===8?Number.parseInt(s.slice(6,8),16)/255:1;return{r:o,g:a,b:i,a:l}}const n=e.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/);if(n){const s=Number.parseInt(n[1]??"",10),o=Number.parseInt(n[2]??"",10),a=Number.parseInt(n[3]??"",10),i=n[4]?Number.parseFloat(n[4]):1;return{r:s,g:o,b:a,a:i}}return null}function jo(e){const{r:t,g:n,b:s,a:o}=e;if(o===0)return;const a=t.toString(16).padStart(2,"0"),i=n.toString(16).padStart(2,"0"),l=s.toString(16).padStart(2,"0");if(o<1){const c=Math.round(o*255).toString(16).padStart(2,"0");return`#${a}${i}${l}${c}`}return`#${a}${i}${l}`}const No=[{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"}],An=({onColorSelect:e,selectedColor:t,readOnly:n=!1})=>r.jsx("div",{className:ie.palette,children:No.map((s,o)=>{const a=s.value===void 0,i=s.value===t,l=a?{}:{backgroundColor:s.value};return r.jsx("button",{type:"button",className:`${ie.paletteButton} ${a?ie.transparentPaletteButton:""} ${i?ie.selected:""}`,onClick:()=>e(s.value),disabled:n,title:s.label,"aria-label":s.label,style:l},s.value??`undefined-${o}`)})});An.displayName="ColorPalette";const Io="_input_14n56_5",Do={input:Io},pe=({value:e,onChange:t,readOnly:n=!1,min:s,max:o,step:a,integer:i,placeholder:l,width:c,height:h,config:m,onBlur:x})=>{const b=s??(m==null?void 0:m.min)??1,g=o??(m==null?void 0:m.max),I=a??(m==null?void 0:m.step)??1,E=i??(m==null?void 0:m.integer)??!1,v=l??(m==null?void 0:m.placeholder),p=c??(m==null?void 0:m.width),f=h??(m==null?void 0:m.height),y=d.useCallback(R=>{const L=R.target.value;if(L===""){t(void 0);return}let $=Number.parseFloat(L);Number.isNaN($)||(E&&($=Math.round($)),b!==void 0&&$<b&&($=b),g!==void 0&&$>g&&($=g),t($))},[t,b,g,E]),w={};return p!==void 0&&(w.width=`${p}px`),f!==void 0&&(w.height=`${f}px`,w.paddingTop=0,w.paddingBottom=0),r.jsx("input",{type:"number",className:Do.input,style:w,value:e??"",onChange:y,onBlur:x,disabled:n,min:b,max:g,step:I,placeholder:v})};pe.displayName="NumberInput";const On=({rgba:e,onChange:t,readOnly:n=!1})=>r.jsxs("div",{className:ie.rgbaInputs,children:[r.jsxs("div",{className:ie.rgbaInputGroup,children:[r.jsx("span",{className:ie.rgbaLabel,children:"R"}),r.jsx(pe,{value:e.r,onChange:s=>t("r",s),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),r.jsxs("div",{className:ie.rgbaInputGroup,children:[r.jsx("span",{className:ie.rgbaLabel,children:"G"}),r.jsx(pe,{value:e.g,onChange:s=>t("g",s),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),r.jsxs("div",{className:ie.rgbaInputGroup,children:[r.jsx("span",{className:ie.rgbaLabel,children:"B"}),r.jsx(pe,{value:e.b,onChange:s=>t("b",s),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),r.jsxs("div",{className:ie.rgbaInputGroup,children:[r.jsx("span",{className:ie.rgbaLabel,children:"A"}),r.jsx(pe,{value:Math.round(e.a*100),onChange:s=>t("a",s!==void 0?s/100:void 0),min:0,max:100,step:1,integer:!0,width:48,readOnly:n})]})]});On.displayName="RGBAInputs";const Ln=({isOpen:e,onClose:t,rgba:n,onRgbaChange:s,onColorSelect:o,selectedColor:a,readOnly:i=!1})=>{const l=d.useRef(null);return d.useEffect(()=>{if(!e)return;const c=h=>{l.current&&!l.current.contains(h.target)&&t()};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[e,t]),e?r.jsxs("div",{className:ie.popover,ref:l,style:{zIndex:F.DROPDOWN},children:[r.jsx(An,{onColorSelect:o,selectedColor:a,readOnly:i}),r.jsx(On,{rgba:n,onChange:s,readOnly:i})]}):null};Ln.displayName="ColorPickerPopover";const ct=({value:e,onChange:t,readOnly:n=!1,showTextInput:s=!0,allowUndefined:o,placeholder:a,width:i,height:l,config:c})=>{const h=o??(c==null?void 0:c.allowUndefined)??!0,m=a??(h?"未設定":"#000000"),x=i??(c==null?void 0:c.width),b=l??(c==null?void 0:c.height),[g,I]=d.useState(!1),E=d.useRef(null),[v,p]=d.useState(()=>Rn(e)??{r:0,g:0,b:0,a:1});d.useEffect(()=>{const j=Rn(e);j&&p(j)},[e]);const f=d.useCallback(()=>{n||I(j=>!j)},[n]),[y,w]=d.useState(e?e.replace(/^#/,""):"");d.useEffect(()=>{w(e?e.replace(/^#/,""):"")},[e]);const R=d.useCallback(j=>{const D=j.target.value;/^[0-9A-Fa-f]*$/.test(D)&&w(D)},[]),L=d.useCallback(j=>{if(j===""&&h){t(void 0);return}/^[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$/.test(j)?t(`#${j}`):w(e?e.replace(/^#/,""):"")},[t,h,e]),$=d.useCallback(j=>{L(j.target.value)},[L]),N=d.useCallback(j=>{j.key==="Enter"&&(j.preventDefault(),L(j.currentTarget.value),j.currentTarget.blur())},[L]),S=d.useCallback(j=>{t(j)},[t]),M=d.useCallback((j,D)=>{if(D===void 0)return;const k={...v,[j]:D};p(k),t(jo(k))},[v,t]),G=e??"未設定",T={};e&&(T.background=e);const P={};return x!==void 0?P.width=`${x}px`:P.width="100%",b!==void 0&&(P.height=`${b}px`),r.jsxs("div",{className:ie.container,style:P,ref:E,children:[r.jsx("button",{type:"button",className:ie.colorButton,onClick:f,disabled:n,title:G,"aria-label":"カラーピッカーを開く",style:T}),s&&r.jsxs("div",{className:ie.textInputWrapper,children:[r.jsx("span",{className:ie.textInputPrefix,children:"#"}),r.jsx("input",{type:"text",className:ie.textInput,value:y,onChange:R,onKeyDown:N,onBlur:$,disabled:n,placeholder:m,maxLength:8})]}),r.jsx(Ln,{isOpen:g,onClose:()=>I(!1),rgba:v,onRgbaChange:M,onColorSelect:S,selectedColor:e,readOnly:n})]})};ct.displayName="ColorPicker";const Co="_container_1n9lj_5",Ro="_valueInput_1n9lj_23",$o="_unitSelect_1n9lj_45",Bt={container:Co,valueInput:Ro,unitSelect:$o},ce=e=>{const{value:t,onChange:n,readOnly:s=!1,config:o}=e,a=e.allowedUnits??(o==null?void 0:o.allowedUnits),i=e.min??(o==null?void 0:o.min),l=e.max??(o==null?void 0:o.max),c=e.step??(o==null?void 0:o.step)??1,h=e.placeholder??(o==null?void 0:o.placeholder),m=e.width??(o==null?void 0:o.width),x=e.height??(o==null?void 0:o.height),b=(t==null?void 0:t.unit)??(a==null?void 0:a[0]),g=d.useCallback(f=>{const y=f.target.value;if(y==="")return;let w=Number.parseFloat(y);if(Number.isNaN(w))return;const R=i??1;w<R&&(w=R),l!==void 0&&w>l&&(w=l),n({value:w,unit:(t==null?void 0:t.unit)??b})},[t,n,b,i,l]),I=d.useCallback(f=>{const y=f.target.value;n({value:(t==null?void 0:t.value)??0,unit:y})},[t,n]),E=(t==null?void 0:t.value)??"",v=(t==null?void 0:t.unit)??b??"",p={};return m!==void 0?p.width=`${m}px`:p.width="100%",x!==void 0&&(p.height=`${x}px`),r.jsxs("div",{className:Bt.container,style:p,children:[r.jsx("input",{type:"number",className:Bt.valueInput,value:E,onChange:g,placeholder:h,min:i??1,max:l,step:c,readOnly:s,disabled:s}),r.jsx("select",{className:Bt.unitSelect,value:v,onChange:I,disabled:s||!a||a.length<=1,children:a?a.map(f=>r.jsx("option",{value:f,children:f},f)):r.jsx("option",{value:v,children:v})})]})},To="_root_qs6t8_3",Mo="_list_qs6t8_11",ko="_trigger_qs6t8_26",So="_content_qs6t8_71",_t={root:To,list:Mo,trigger:ko,content:So},Et=d.createContext(void 0),en=({defaultValue:e,value:t,onValueChange:n,children:s,variant:o="default",className:a=""})=>{const[i,l]=d.useState(e),c=t??i,h=m=>{l(m),n==null||n(m)};return r.jsx(Et.Provider,{value:{value:c,onChange:h,variant:o},children:r.jsx("div",{className:`${_t.root} ${a}`,"data-variant":o,children:s})})},tn=({children:e,className:t="",width:n,height:s,style:o})=>{const a=d.useContext(Et);if(!a)throw new Error("TabsList must be used within a Tabs component");const{variant:i}=a,l={...o};return n!==void 0&&(l.width=`${n}px`),s!==void 0&&(l.height=`${s}px`),r.jsx("div",{className:`${_t.list} ${t}`,"data-variant":i,style:l,children:e})},Me=({value:e,children:t,className:n="",disabled:s=!1,width:o,height:a,style:i})=>{const l=d.useContext(Et);if(!l)throw new Error("TabsTrigger must be used within a Tabs component");const{value:c,onChange:h,variant:m}=l,x=c===e,b={...i};return o!==void 0&&(b.width=`${o}px`),a!==void 0&&(b.height=`${a}px`),r.jsx("button",{className:`${_t.trigger} ${n}`,"data-state":x?"active":"inactive","data-variant":m,onClick:()=>h(e),disabled:s,type:"button",style:b,children:t})},ke=({value:e,children:t,className:n=""})=>{const s=d.useContext(Et);if(!s)throw new Error("TabsContent must be used within a Tabs component");const{value:o}=s;return o!==e?null:r.jsx("div",{className:`${_t.content} ${n}`,children:t})},Po="_input_9unrj_5",Ao={input:Po},Qe=({value:e,onChange:t,readOnly:n=!1,placeholder:s,maxLength:o,multiline:a,rows:i,width:l,height:c,config:h,onBlur:m})=>{const x=s??(h==null?void 0:h.placeholder),b=o??(h==null?void 0:h.maxLength),g=a??(h==null?void 0:h.multiline)??!1,I=i??(h==null?void 0:h.rows)??3,E=d.useCallback(f=>{const y=f.target.value;t(y)},[t]),v={};l!==void 0?v.width=`${l}px`:v.width="100%",c!==void 0&&(v.height=`${c}px`);const p={className:Ao.input,style:v,value:e??"",onChange:E,disabled:n,placeholder:x,maxLength:b};return g?r.jsx("textarea",{...p,rows:I}):r.jsx("input",{...p,type:"text",onBlur:m})};Qe.displayName="TextInput";const Oo=["mm","cm","fr","inch","pt","px","%"],Lo=["mm","cm","pt","inch","px"],Go=["mm","cm","inch"],Bo=["mm","cm","fr","inch","pt","px"],Gn=["px","pt","mm"],Bn=["px","pt","mm"],Ke=["mm","pt","px","%"],Wt=["mm","cm","inch","pt","px","%"],Fn={isIndividual:{defaultValue:!1,label:"個別に設定",group:"余白",Component:Ie,description:"上下左右の余白を個別に設定します"},all:{defaultValue:{value:10,unit:"px"},label:"全方向",group:"余白",Component:ce,config:{allowedUnits:Ke,min:0},condition:e=>!e.isIndividual},top:{defaultValue:{value:10,unit:"px"},label:"上",group:"余白",Component:ce,config:{allowedUnits:Ke,min:0},condition:e=>e.isIndividual===!0},right:{defaultValue:{value:10,unit:"px"},label:"右",group:"余白",Component:ce,config:{allowedUnits:Ke,min:0},condition:e=>e.isIndividual===!0},bottom:{defaultValue:{value:10,unit:"px"},label:"下",group:"余白",Component:ce,config:{allowedUnits:Ke,min:0},condition:e=>e.isIndividual===!0},left:{defaultValue:{value:10,unit:"px"},label:"左",group:"余白",Component:ce,config:{allowedUnits:Ke,min:0},condition:e=>e.isIndividual===!0}},Fo={...Pn,...Fn},Vo={fontSize:{defaultValue:{value:14,unit:"pt"},label:"フォントサイズ",group:"フォント",description:"テキストのフォントサイズを設定します",Component:ce,config:{allowedUnits:Bn,min:1,step:1}},fontFamily:{defaultValue:"sans-serif",label:"フォント",group:"フォント",Component:$e,config:{placeholder:"フォントを選択",options:[{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"}]}},color:{defaultValue:void 0,label:"文字色",group:"フォント",Component:ct,config:{allowUndefined:!0}},fontWeight:{defaultValue:!1,label:"太字",group:"フォント",description:"テキストを太字にします",Component:Ie},italic:{defaultValue:!1,label:"斜体",group:"フォント",description:"テキストを斜体にします",Component:Ie},underline:{defaultValue:!1,label:"下線",group:"フォント",description:"テキストに下線を引きます",Component:Ie},lineThrough:{defaultValue:!1,label:"取り消し線",group:"フォント",description:"テキストに取り消し線を引きます",Component:Ie},lineHeight:{defaultValue:1.2,label:"行の高さ",group:"フォント",description:"行の高さを設定します(1.0〜3.0)",Component:pe,config:{min:1,max:3,step:.1}}};var Ae=(e=>(e.Contain="contain",e.Cover="cover",e.Fill="fill",e.None="none",e.ScaleDown="scale-down",e))(Ae||{});const Uo={objectFit:{defaultValue:Ae.Contain,label:"表示方法",group:"画像",description:"画像のサイズが枠と合わない場合の表示方法を設定します",Component:$e,config:{options:[{label:"全体を表示",value:Ae.Contain},{label:"枠を埋める/切り抜き",value:Ae.Cover},{label:"引き伸ばす/縮小する",value:Ae.Fill},{label:"元のサイズ",value:Ae.None},{label:"縮小のみ",value:Ae.ScaleDown}]}},alt:{defaultValue:"",label:"代替テキスト",group:"画像",description:"画像が表示できない場合に表示されるテキスト",Component:Qe,config:{placeholder:"画像の説明"}}};var qe=(e=>(e.Normal="normal",e.BreakWord="break-word",e.BreakAll="break-all",e))(qe||{}),Je=(e=>(e.Normal="normal",e.NoWrap="nowrap",e.Pre="pre",e.PreWrap="pre-wrap",e.PreLine="pre-line",e))(Je||{});const Wo={multiline:{defaultValue:!1,label:"複数行モード",group:"設定",Component:Ie,config:{label:"有効にする"}},wordWrap:{defaultValue:qe.Normal,label:"単語の折り返し",group:"設定",Component:$e,config:{options:[{label:"通常",value:qe.Normal},{label:"単語で改行",value:qe.BreakWord},{label:"強制改行",value:qe.BreakAll}]},condition:e=>e.multiline===!0},whiteSpace:{defaultValue:Je.Normal,label:"空白文字の扱い",group:"設定",Component:$e,config:{options:[{label:"通常",value:Je.Normal},{label:"折り返しなし",value:Je.NoWrap},{label:"そのまま表示",value:Je.Pre}]},condition:e=>e.multiline===!0}},Yo={placeholder:{defaultValue:void 0,label:"プレースホルダー",group:"設定",description:"入力欄に表示するプレースホルダーテキストを設定します",Component:Qe,config:{placeholder:"例: テキストを入力してください"}}},zo={width:{defaultValue:void 0,label:"幅",group:"サイズ",description:"要素の幅を設定します",Component:ce,config:{min:0,allowedUnits:Wt,placeholder:"auto"}},height:{defaultValue:void 0,label:"高さ",group:"サイズ",description:"要素の高さを設定します",Component:ce,config:{min:0,allowedUnits:Wt,placeholder:"auto"}}},Vn=e=>{const t={};return Object.entries(e.properties).forEach(([n,s])=>{s!==!1&&typeof s=="object"&&s!==null&&"defaultValue"in s&&(t[n]=s.defaultValue)}),t};function Un(e){const t=Date.now(),n=Math.random().toString(36).slice(2);return`${e}_${t}_${n}`}function Fe(e,t,n){const s=Vn(e);return{id:Un(e.kind),kind:e.kind,layout:{x:t.x,y:t.y,w:t.w,h:t.h},style:{},behavior:{},props:{...s,...n}}}const Ko={required:{defaultValue:!1,label:"必須項目",group:"バリデーション",description:"この項目を必須入力にします",Component:Ie,config:{label:"必須にする"}},minLength:{defaultValue:void 0,label:"最小文字数",group:"バリデーション",description:"入力可能な最小文字数を設定します",Component:pe,config:{min:0,integer:!0,placeholder:"制限なし"}},maxLength:{defaultValue:void 0,label:"最大文字数",group:"バリデーション",description:"入力可能な最大文字数を設定します",Component:pe,config:{min:0,integer:!0,placeholder:"制限なし"}},pattern:{defaultValue:void 0,label:"入力パターン (正規表現)",group:"バリデーション",description:"入力値を検証する正規表現パターンを設定します",Component:Qe,config:{placeholder:"例: ^[0-9]+$"},disableInMultiSelection:!0}};var be=(e=>(e.ADD="add",e.UPDATE="update",e.DELETE="delete",e.MOVE="move",e.RESIZE="resize",e.DUPLICATE="duplicate",e.PASTE="paste",e))(be||{});const Wn={cols:Array.from({length:12}).map(()=>({value:1,unit:"fr"})),rows:Array.from({length:16}).map(()=>({value:1,unit:"fr"}))};var ye=(e=>(e.SOLID="solid",e.DASHED="dashed",e.DOTTED="dotted",e))(ye||{});function fe(e,t){if(e<=0){const n=t??"Value";throw new Error(`${n} must be positive (> 0): got ${e}`)}}function Be(e,t){if(e<0){const n=t??"Value";throw new Error(`${n} must be non-negative (>= 0): got ${e}`)}}function Yn(e,t,n,s){if(e<t||e>n){const o=s??"Value";throw new Error(`${o} must be between ${t} and ${n}: got ${e}`)}}function jt(e,t){if(!Number.isInteger(e)){const n=t??"Value";throw new Error(`${n} must be an integer: got ${e}`)}}function Ho(e,t){if(!Number.isFinite(e)){const n=t??"Value";throw new Error(`${n} must be a finite number: got ${e}`)}}const Xo=25.4,qo=2.54,Jo=72,W={_assertDpi(e){fe(e,"DPI"),jt(e,"DPI")},fromMm(e,t=q){return W._assertDpi(t),Be(e,"Millimeter value"),e*t/Xo},fromCm(e,t=q){return W._assertDpi(t),Be(e,"Centimeter value"),e*t/qo},fromInch(e,t=q){return W._assertDpi(t),Be(e,"Inch value"),e*t},fromPt(e,t=q){return W._assertDpi(t),Be(e,"Point value"),e*t/Jo},fromPx(e,t=q){return W._assertDpi(t),Be(e,"Pixel value"),e*t/q},fromDim(e,t=q,n){switch(W._assertDpi(t),Be(e.value,"Dimension value"),e.unit){case"mm":return W.fromMm(e.value,t);case"cm":return W.fromCm(e.value,t);case"inch":return W.fromInch(e.value,t);case"pt":return W.fromPt(e.value,t);case"px":return W.fromPx(e.value,t);case"%":if(n===void 0)throw new Error("Base size must be defined for percentage values.");return e.value/100*n;case"fr":throw new Error(`Cannot convert ${e.unit} to px. Use physical units only.`);default:{const s=e.unit;throw new Error(`Unsupported unit: ${s}`)}}}},Ze=e=>{if(!(e!=null&&e.width)||!(e!=null&&e.type))return;const t=e.width.value;if(t!==0){if(e.type===ye.DASHED)return`${t*4} ${t*2}`;if(e.type===ye.DOTTED)return`${t*1} ${t*2}`}};class et{constructor(t){this.style=t}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(t,n=q){const s=this.top;return s?{x1:0,y1:0,x2:t,y2:0,stroke:s.color,strokeWidth:W.fromDim(s.width,n),strokeDasharray:Ze(s),vectorEffect:"non-scaling-stroke","data-edge":"top"}:null}getRightSVGProps(t,n,s=q){const o=this.right;return o?{x1:t,y1:0,x2:t,y2:n,stroke:o.color,strokeWidth:W.fromDim(o.width,s),strokeDasharray:Ze(o),vectorEffect:"non-scaling-stroke","data-edge":"right"}:null}getBottomSVGProps(t,n,s=q){const o=this.bottom;return o?{x1:0,y1:n,x2:t,y2:n,stroke:o.color,strokeWidth:W.fromDim(o.width,s),strokeDasharray:Ze(o),vectorEffect:"non-scaling-stroke","data-edge":"bottom"}:null}getLeftSVGProps(t,n=q){const s=this.left;return s?{x1:0,y1:0,x2:0,y2:t,stroke:s.color,strokeWidth:W.fromDim(s.width,n),strokeDasharray:Ze(s),vectorEffect:"non-scaling-stroke","data-edge":"left"}:null}}var ge=(e=>(e.FORM="Form",e.EDIT="Edit",e.VIEW="View",e))(ge||{}),Ne=(e=>(e.A4="A4",e.B5="B5",e.A3="A3",e.LETTER="Letter",e.LEGAL="Legal",e.CUSTOM="Custom",e))(Ne||{});const nn={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"}}},zn={top:{value:10,unit:"mm"},right:{value:10,unit:"mm"},bottom:{value:10,unit:"mm"},left:{value:10,unit:"mm"}},Kn={size:nn.A4,margin:zn},Zo={paper:Kn,grid:Wn,blocks:[]};var Hn=(e=>(e.ERROR="error",e.WARNING="warning",e.INFO="info",e))(Hn||{});const Xn=d.memo(({contentPx:e,marginLeftPx:t,marginTopPx:n,borderStyle:s,visible:o=!0,dpi:a=q,zIndex:i=F.BORDER_OVERLAY,className:l=""})=>{const c=d.useMemo(()=>{if(s)return new et(s)},[s]);if(!o||!c||!c.hasAnyBorder)return null;const h={position:"absolute",left:`${t}px`,top:`${n}px`,width:`${e.width}px`,height:`${e.height}px`,pointerEvents:"none",overflow:"visible",zIndex:i};return r.jsx("div",{className:l,style:h,"data-testid":"border-overlay",children:r.jsx(Ve,{width:e.width,height:e.height,border:c,dpi:a})})}),qn=d.memo(({canvasPx:e,backgroundColor:t="#ffffff",boxShadow:n="0 2px 8px rgba(0, 0, 0, 0.1)",zIndex:s=F.GRID_CANVAS,className:o})=>{const a={position:"absolute",inset:0,width:`${e.width}px`,height:`${e.height}px`,backgroundColor:t,boxShadow:n,pointerEvents:"none",zIndex:s};return r.jsx("div",{className:o,style:a,role:"presentation","aria-label":"Paper background","data-testid":"grid-canvas"})}),Qo="_label_vgaic_1",es={label:Qo},ts="_editor_6szgo_5",ns="_input_6szgo_18",rs="_select_6szgo_38",os="_button_6szgo_54",mt={editor:ts,input:ns,select:rs,button:os};function Jn(e,t){const n=e.match(/^(\d+(?:\.\d+)?)([a-zA-Z%]+)$/);if(!n)throw new Error(`Invalid dimension string: ${e}`);const s=Number(n[1]),o=n[2];if(fe(s,"Dimension value"),!t.includes(o))throw new Error(`Unit not allowed: ${o}`);return{value:s,unit:o}}function ss(e,t){return e.map(n=>Jn(n,t))}const is=10,as=25.4,ls=.352778,cs=.264583,J={fromCm(e){return fe(e,"Centimeter value"),e*is},fromInch(e){return fe(e,"Inch value"),e*as},fromPt(e){return fe(e,"Point value"),e*ls},fromPx(e){return fe(e,"Pixel value"),e*cs},fromDim(e){switch(fe(e.value,"Dimension value"),e.unit){case"mm":return e.value;case"cm":return J.fromCm(e.value);case"inch":return J.fromInch(e.value);case"pt":return J.fromPt(e.value);case"px":return J.fromPx(e.value);case"fr":case"%":throw new Error(`Cannot convert ${e.unit} to mm. Use physical units only.`);default:{const t=e.unit;throw new Error(`Unsupported unit: ${t}`)}}}};function Zn(e){return fe(e.value,"Dimension"),`${e.value}${e.unit}`}function us(e){return e.map(Zn)}const ds=["fr","px","mm","cm","pt","inch"];function fs(e,t){if(t==="fr")return 1;switch(t){case"px":return e;case"mm":{const n=J.fromPx(e);return Math.round(n*10)/10}case"cm":{const s=J.fromPx(e)/10;return Math.round(s*100)/100}case"inch":{const s=J.fromPx(e)/25.4;return Math.round(s*100)/100}case"pt":{const o=J.fromPx(e)/25.4*72;return Math.round(o*10)/10}default:{const n=t;throw new Error(`Unsupported unit: ${n}`)}}}const Qn=d.memo(({direction:e,dimension:t,currentPxSize:n,position:s,marginLeftPx:o,marginTopPx:a,onChange:i,onCancel:l})=>{const[c,h]=d.useState(t.value.toString()),[m,x]=d.useState(t.unit),b=d.useRef(null),g=d.useRef(null),I=e==="column"?{left:`${o+s}px`,top:`${a+24}px`,transform:"translateX(-50%)"}:{left:`${o+24}px`,top:`${a+s}px`,transform:"translateY(-50%)"};d.useEffect(()=>{var f,y;(f=b.current)==null||f.focus(),(y=b.current)==null||y.select()},[]),d.useEffect(()=>{const f=y=>{g.current&&!g.current.contains(y.target)&&l()};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[l]);const E=()=>{const f=Number.parseFloat(c);!Number.isNaN(f)&&f>=.1?i({unit:m,value:f}):l()},v=f=>{f.key==="Enter"?(f.preventDefault(),E()):f.key==="Escape"&&(f.preventDefault(),l())},p=f=>{const y=f.target.value;x(y);const w=fs(n,y);h(w.toString())};return r.jsxs("div",{ref:g,className:mt.editor,style:I,"data-testid":`grid-unit-editor-${e}`,children:[r.jsx("input",{ref:b,type:"number",className:mt.input,value:c,onChange:f=>h(f.target.value),onKeyDown:v,min:"0.1",step:m==="fr"?"0.1":"1"}),r.jsx("select",{className:mt.select,value:m,onChange:p,children:ds.map(f=>r.jsx("option",{value:f,children:f},f))}),r.jsx("button",{type:"button",className:mt.button,onClick:E,title:"確定",children:"✓"})]})});Qn.displayName="GridUnitEditor";function hs(e,t,n,s){if(t==="fr"){if(n!==void 0&&s!==void 0&&s>0){const o=e/s;return Math.round(n*o*100)/100}return 1}switch(t){case"px":return Math.round(e);case"mm":{const o=J.fromPx(e);return Math.round(o*10)/10}case"cm":{const o=J.fromPx(e);return Math.round(o/10*100)/100}case"inch":{const o=J.fromPx(e);return Math.round(o/25.4*100)/100}case"pt":{const o=J.fromPx(e);return Math.round(o/25.4*72*10)/10}default:{const o=t;throw new Error(`Unsupported unit: ${o}`)}}}const Yt=d.memo(({direction:e,index:t,dimension:n,position:s,currentPxSize:o,marginLeftPx:a,marginTopPx:i,isNearCursor:l,resizingPxSize:c,onDimensionChange:h})=>{const[m,x]=d.useState(!1);if(!l&&!m)return null;const b=e==="column"?{left:`${a+s}px`,top:`${i-20}px`,transform:"translateX(-50%)"}:{left:`${a-20}px`,top:`${i+s}px`,transform:"translateY(-50%)",writingMode:"vertical-rl"},g=()=>{x(!0)},I=f=>{h==null||h(e,t,f),x(!1)},E=()=>{x(!1)},p=c?(()=>{const f=hs(c,n.unit,n.value,o);return n.unit==="fr"?`${f}fr`:`${f}${n.unit}`})():(f=>f.unit==="fr"?`${f.value}fr`:`${f.value}${f.unit}`)(n);return r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:es.label,style:b,onDoubleClick:g,"data-testid":`grid-dimension-${e}-${t}`,"aria-label":`グリッド寸法: ${p}`,children:p})," ",m&&r.jsx(Qn,{direction:e,dimension:n,currentPxSize:o,position:s,marginLeftPx:a,marginTopPx:i,onChange:I,onCancel:E})]})});Yt.displayName="GridDimensionLabel";function ms(e,t,n,s){let o="";for(const a of e)o+=`M ${a} 0 L ${a} ${s} `;for(const a of t)o+=`M 0 ${a} L ${n} ${a} `;return o}const er=d.memo(({gridPosPx:e,contentPx:t,marginLeftPx:n,marginTopPx:s,lineStyle:o,visible:a=!0,zIndex:i=F.GRID_OVERLAY,dpi:l=q,className:c=""})=>{const h=d.useMemo(()=>ms(e.cols.slice(1,-1),e.rows.slice(1,-1),t.width,t.height),[e,t]);if(!a||!o)return null;const m=Ze(o),x=W.fromDim(o.width,l),b={position:"absolute",left:`${n}px`,top:`${s}px`,pointerEvents:"none",zIndex:i};return r.jsx("svg",{className:c,style:b,width:t.width,height:t.height,xmlns:"http://www.w3.org/2000/svg",role:"img","aria-label":"Grid overlay lines",children:r.jsx("path",{d:h,stroke:o.color,strokeWidth:x,strokeDasharray:m,fill:"none"})})}),ps="_handle_1mgtx_1",vs="_dragging_1mgtx_19",Ft={handle:ps,dragging:vs},zt=d.memo(({direction:e,index:t,position:n,marginLeftPx:s,marginTopPx:o,onResizeStart:a,onResize:i,onResizeEnd:l})=>{const[c,h]=d.useState(!1),m=12,x=m/2,b=e==="column"?{left:`${s+n-x}px`,top:`${o-x}px`,width:`${m}px`,height:`${m}px`,cursor:"col-resize"}:{left:`${s-x}px`,top:`${o+n-x}px`,width:`${m}px`,height:`${m}px`,cursor:"row-resize"},g=d.useCallback(I=>{I.stopPropagation(),I.preventDefault();const E=e==="column"?I.clientX:I.clientY;h(!0),a==null||a(e,t);const v=f=>{const w=(e==="column"?f.clientX:f.clientY)-E;i==null||i(e,t,w)},p=f=>{const w=(e==="column"?f.clientX:f.clientY)-E;h(!1),l==null||l(e,t,w),window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",p)};window.addEventListener("pointermove",v),window.addEventListener("pointerup",p)},[e,t,a,i,l]);return r.jsx("div",{className:`${Ft.handle} ${Ft[e]} ${c?Ft.dragging:""}`,style:b,onPointerDown:g,"data-testid":`grid-resize-handle-${e}-${t}`})});zt.displayName="GridResizeHandle";const tr=d.memo(({paperPx:e,visible:t=!0,marginColor:n,zIndex:s=F.MARGIN_OVERLAY,className:o=""})=>{if(!t)return null;const a={position:"absolute",inset:0,pointerEvents:"none",width:`${e.canvas.width}px`,height:`${e.canvas.height}px`,zIndex:s},i={position:"absolute",backgroundColor:n||"rgba(0, 0, 0, 0.05)",pointerEvents:"none"};return r.jsxs("div",{className:o,style:a,role:"presentation","aria-label":"Printable area margin","data-testid":"margin-overlay",children:[e.margin.top>0&&r.jsx("div",{"data-testid":"margin-top",style:{...i,top:0,left:0,width:"100%",height:`${e.margin.top}px`}}),e.margin.bottom>0&&r.jsx("div",{"data-testid":"margin-bottom",style:{...i,bottom:0,left:0,width:"100%",height:`${e.margin.bottom}px`}}),e.margin.left>0&&r.jsx("div",{"data-testid":"margin-left",style:{...i,left:0,top:`${e.margin.top}px`,height:`${e.content.height}px`,width:`${e.margin.left}px`}}),e.margin.right>0&&r.jsx("div",{"data-testid":"margin-right",style:{...i,right:0,top:`${e.margin.top}px`,height:`${e.content.height}px`,width:`${e.margin.right}px`}})]})}),Nt=d.memo(({paperPx:e,gridPosPxs:t,gridDimensions:n,gridLineStyle:s,borderStyle:o,backgroundColor:a="#ffffff",boxShadow:i="0 2px 8px rgba(0, 0, 0, 0.1)",marginFillColor:l="rgba(0, 0, 0, 0.05)",showGridLines:c=!0,showMargins:h=!0,showBorder:m=!0,showResizeHandles:x=!1,showDimensionLabels:b=!1,onGridResize:g,onDimensionChange:I,className:E="",zIndex:v={}})=>{const[p,f]=d.useState(null),[y,w]=d.useState(null),[R,L]=d.useState(null),$=d.useRef(null);d.useEffect(()=>{const j=k=>{if(!$.current)return;const A=$.current.getBoundingClientRect();L({x:k.clientX-A.left,y:k.clientY-A.top})},D=k=>{if(!$.current)return;const A=$.current.getBoundingClientRect();(k.clientX<A.left||k.clientX>A.right||k.clientY<A.top||k.clientY>A.bottom)&&L(null)};return window.addEventListener("mousemove",j),window.addEventListener("mouseleave",D),()=>{window.removeEventListener("mousemove",j),window.removeEventListener("mouseleave",D)}},[]);const N=d.useMemo(()=>{if(!R)return!1;const j=e.content.width,D=e.content.height,k=e.margin.left,A=e.margin.top;return!(R.x>=k&&R.x<=k+j&&R.y>=A&&R.y<=A+D)},[R,e]),S=d.useCallback((j,D)=>{w({direction:j,index:D})},[]),M=d.useMemo(()=>{if(!p||!y)return null;const j=y.direction==="column"?t.cols:t.rows,D=y.index,k=j[D-1],A=p.position,K=k!==void 0?A-k:0,Z=p.position,Q=j[D+1],ue=Q!==void 0?Q-Z:0;return{direction:y.direction,prevIndex:D-1,prevSize:K,nextIndex:D,nextSize:ue}},[p,y,t]),G=d.useCallback((j,D,k)=>{const A=j==="column"?t.cols:t.rows,K=A[D];if(K===void 0)return;const Z=A[D-1],Q=A[D+1],ue=10;let le=k;if(Z!==void 0){const H=Z+ue-K;le=Math.max(le,H)}if(Q!==void 0){const H=Q-ue-K;le=Math.min(le,H)}f({direction:j,position:K+le})},[t]),T=d.useCallback((j,D,k)=>{const A=j==="column"?t.cols:t.rows,K=A[D];if(K===void 0){f(null);return}const Z=A[D-1],Q=A[D+1],ue=10;let le=k;if(Z!==void 0){const H=Z+ue-K;le=Math.max(le,H)}if(Q!==void 0){const H=Q-ue-K;le=Math.min(le,H)}f(null),w(null),g==null||g(j,D,le)},[t,g]),P={position:"relative",width:"100%",height:"100%"};return r.jsxs("div",{ref:$,className:E,style:P,children:[r.jsx(qn,{canvasPx:e.canvas,backgroundColor:a,boxShadow:i,zIndex:(v==null?void 0:v.canvas)??F.GRID_CANVAS,className:E}),h&&r.jsx(tr,{paperPx:e,visible:h,marginColor:l,zIndex:(v==null?void 0:v.margin)??F.MARGIN_OVERLAY,className:E}),c&&r.jsx(er,{gridPosPx:t,contentPx:e.content,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,lineStyle:s,visible:c,zIndex:(v==null?void 0:v.grid)??F.GRID_OVERLAY,dpi:q,className:E}),m&&r.jsx(Xn,{contentPx:e.content,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,borderStyle:o,visible:m,dpi:q,zIndex:(v==null?void 0:v.border)??F.BORDER_OVERLAY,className:E}),x&&g&&r.jsxs(r.Fragment,{children:[t.cols.map((j,D)=>{if(D===0||D===t.cols.length-1)return null;const k=`col-${D}`;return r.jsx(zt,{direction:"column",index:D,position:j,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,onResizeStart:S,onResize:G,onResizeEnd:T},k)}),t.rows.map((j,D)=>{if(D===0||D===t.rows.length-1)return null;const k=`row-${D}`;return r.jsx(zt,{direction:"row",index:D,position:j,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,onResizeStart:S,onResize:G,onResizeEnd:T},k)})]}),b&&n&&r.jsxs(r.Fragment,{children:[n.cols.map((j,D)=>{const k=t.cols[D],A=t.cols[D+1];if(k===void 0||A===void 0)return null;const K=(y==null?void 0:y.direction)==="column"&&(y.index===D||y.index===D+1);let Z;M&&M.direction==="column"&&(M.prevIndex===D?Z=M.prevSize:M.nextIndex===D&&(Z=M.nextSize));const Q=(k+A)/2,ue=A-k,le=`col-dim-${D}`;return r.jsx(Yt,{direction:"column",index:D,dimension:j,position:Q,currentPxSize:ue,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,isNearCursor:N||K,resizingPxSize:Z,onDimensionChange:I},le)})," ",n.rows.map((j,D)=>{const k=t.rows[D],A=t.rows[D+1];if(k===void 0||A===void 0)return null;const K=(y==null?void 0:y.direction)==="row"&&(y.index===D||y.index===D+1),Z=(k+A)/2,Q=A-k,ue=`row-dim-${D}`;return r.jsx(Yt,{direction:"row",index:D,dimension:j,position:Z,currentPxSize:Q,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,isNearCursor:N||K,onDimensionChange:I},ue)})]}),p&&r.jsx("div",{style:{position:"absolute",left:p.direction==="column"?e.margin.left+p.position:e.margin.left,top:p.direction==="row"?e.margin.top+p.position:e.margin.top,width:p.direction==="column"?"2px":e.content.width,height:p.direction==="row"?"2px":e.content.height,backgroundColor:"#3b82f6",opacity:.5,pointerEvents:"none",zIndex:F.GRID_GHOST}})]})}),xs=d.memo(({blockSizePx:e,borderStyle:t,blockZIndex:n,subZIndex:s=we.BORDER,visible:o=!0,dpi:a=q,className:i=""})=>{const l=d.useMemo(()=>{if(t)return new et(t)},[t]);if(!o||!l||!l.hasAnyBorder)return null;const c=lt(n,s),h={position:"absolute",left:0,top:0,width:`${e.width}px`,height:`${e.height}px`,pointerEvents:"none",overflow:"visible",zIndex:c};return r.jsx("div",{className:i,style:h,"data-testid":"block-border",children:r.jsx(Ve,{width:e.width,height:e.height,border:l,dpi:a})})}),bs=d.memo(({blockSizePx:e,blockZIndex:t,subZIndex:n=we.BG,backgroundColor:s="transparent",className:o=""})=>{const a=lt(t,n),i={position:"absolute",inset:0,width:`${e.width}px`,height:`${e.height}px`,backgroundColor:s,pointerEvents:"none",zIndex:a};return r.jsx("div",{className:o,style:i,role:"presentation","aria-label":"Block background","data-testid":"block-canvas"})}),gs={color:"#cccccc",width:{value:1,unit:"pt"},type:ye.SOLID},rn={all:gs},ys=d.memo(({blockSizePx:e,blockZIndex:t,subZIndex:n=we.GUIDE,borderStyle:s=rn,visible:o=!0,dpi:a=q,className:i=""})=>{const l=d.useMemo(()=>{if(s)return new et(s)},[s]);if(!o||!l||!l.hasAnyBorder)return null;const c=lt(t,n),h={position:"absolute",left:0,top:0,width:`${e.width}px`,height:`${e.height}px`,pointerEvents:"none",overflow:"visible",zIndex:c};return r.jsx("div",{className:i,style:h,"data-testid":"block-base-border",children:r.jsx(Ve,{width:e.width,height:e.height,border:l,dpi:a})})}),ws=({id:e,plugin:t,props:n,value:s,onChange:o,onBlur:a,readOnly:i,mode:l,blockSizePx:c,blockZIndex:h,subZIndex:m=we.CONTENT,validationState:x,className:b=""},g)=>{const I=d.useRef(null);d.useImperativeHandle(g,()=>({focus:()=>{var y;return(y=I.current)==null?void 0:y.focus()}}),[]);const E=lt(h,m),v={position:"absolute",inset:0,width:`${c.width}px`,height:`${c.height}px`,zIndex:E,pointerEvents:"auto"},p={id:e,props:n,value:s,onChange:o??(()=>{}),onBlur:a,readOnly:i,mode:l,dimensions:{widthPx:c.width,heightPx:c.height},validationState:x},f=t.Renderer;return r.jsx("div",{className:b,style:v,"data-testid":"block-renderer","data-block-id":e,"data-plugin-kind":t.kind,children:r.jsx(f,{ref:I,...p})})},_s=d.forwardRef(ws),It=d.memo(_s);function on(e,t){return{position:"absolute",left:`${e.left}px`,top:`${e.top}px`,width:`${e.width}px`,height:`${e.height}px`,zIndex:t==null?void 0:t.zIndex,pointerEvents:(t==null?void 0:t.pointerEvents)??"auto"}}const nr=d.memo(d.forwardRef(({block:e,plugin:t,blockRectPx:n,blockZIndex:s,mode:o,value:a,onValueChange:i,onValueBlur:l,showGuides:c=!0,showBorder:h=!0,blockSubZIndex:m={bg:we.BG,guide:we.GUIDE,content:we.CONTENT,border:we.BORDER},defaultGuideBorder:x=rn,dpi:b=q,className:g="",pointerEvents:I="none"},E)=>{var f,y,w,R;const v=on(n,{zIndex:s,pointerEvents:I}),p=d.useMemo(()=>({width:n.width,height:n.height}),[n.width,n.height]);return r.jsxs("div",{style:v,"data-block-id":e.id,className:g,children:[r.jsx(bs,{blockSizePx:p,blockZIndex:s,backgroundColor:(f=e.style)==null?void 0:f.backgroundColor,subZIndex:m.bg}),c&&!((y=e.style)!=null&&y.border)&&r.jsx(ys,{blockSizePx:p,blockZIndex:s,subZIndex:m.guide,borderStyle:x,dpi:b}),r.jsx(It,{id:e.id,ref:E,plugin:t,props:e.props,value:a,onChange:i,onBlur:l,readOnly:o===ge.EDIT?((w=e.behavior)==null?void 0:w.readOnly)??!1:!0,mode:o,blockSizePx:p,blockZIndex:s,subZIndex:m.content}),r.jsx(xs,{blockSizePx:p,blockZIndex:s,borderStyle:(R=e.style)==null?void 0:R.border,subZIndex:m.border,visible:h,dpi:b})]})}));nr.displayName="BlockContainer";const Dt=d.memo(({blocks:e,pluginRegistry:t,mode:n,values:s,selectedBlockIds:o=[],getBlockRectPx:a,onValueChange:i,onValueBlur:l,showGuides:c=!0,showBorder:h=!0,blockSubZIndex:m={bg:we.BG,guide:we.GUIDE,content:we.CONTENT,border:we.BORDER},defaultGuideBorder:x=rn,dpi:b=q,className:g=""})=>{const I=d.useRef(new Map),E={position:"absolute",inset:0,pointerEvents:"none"};return r.jsx("div",{className:g,style:E,"data-testid":"block-layer",children:e.map((v,p)=>{const f=t[v.kind];if(!f)return null;const y=a(v),w=o.includes(v.id);let R=Sn(p);w&&(R=F.SELECT_BLOCK);const L=s[v.id]??v.initValue;return r.jsx(nr,{ref:$=>{$?I.current.set(v.id,$):I.current.delete(v.id)},block:v,plugin:f,blockRectPx:y,blockZIndex:R,mode:n,value:L,onValueChange:i?$=>i(v.id,$):void 0,onValueBlur:$=>l==null?void 0:l(v.id,$),showGuides:c,showBorder:h,blockSubZIndex:m,defaultGuideBorder:x,dpi:b,pointerEvents:"none"},v.id)})})});Dt.displayName="BlockLayer";class Es{constructor(){Ot(this,"state",null);Ot(this,"listeners",[])}start(t,n){this.state={kind:t,defaultSize:n},this.notify()}end(){this.state=null,this.notify()}get(){return this.state}subscribe(t){return this.listeners.push(t),()=>{this.listeners=this.listeners.filter(n=>n!==t)}}notify(){for(const t of this.listeners)t(this.state)}}const xt=new Es;function Kt(e,t,n,s){if(t<0||t>=e.length)return e;const o=[...e],a=o[t],i=o[t+1];return!a||!i?e:a.unit==="fr"&&i.unit==="fr"?js(o,t,n,s):a.unit!=="fr"&&i.unit!=="fr"?Ns(o,t,n):a.unit==="fr"&&i.unit!=="fr"?$n(o,t,n,"next",s):$n(o,t,n,"current",s)}function js(e,t,n,s){const o=e[t],a=e[t+1];if(!o||!a)return e;const i=e.reduce((I,E)=>E.unit==="fr"?I+E.value:I,0),l=s/i,c=o.value*l,h=a.value*l,m=Math.max(10,c+n),x=Math.max(10,h-n),b=m/l,g=x/l;return e[t]={...o,value:Math.round(b*100)/100},e[t+1]={...a,value:Math.round(g*100)/100},e}function Ns(e,t,n){const s=e[t],o=e[t+1];if(!s||!o)return e;const a=W.fromDim(s),i=W.fromDim(o),l=Math.max(10,a+n),c=Math.max(10,i-n);return e[t]={...s,value:bt(l,s.unit)},e[t+1]={...o,value:bt(c,o.unit)},e}function $n(e,t,n,s,o){const a=e[t],i=e[t+1];if(!a||!i)return e;let l=0,c=0;for(const x of e)x.unit==="fr"?l+=x.value:c+=W.fromDim(x);const h=o-c,m=l>0?h/l:0;if(s==="next"){const x=W.fromDim(i),b=Math.max(10,x-n);e[t+1]={...i,value:bt(b,i.unit)};const g=b-x,I=h-g,E=a.value*m,v=Math.max(10,E+n),p=l>0?v/I*l:1;e[t]={...a,value:Math.round(p*100)/100}}else{const x=W.fromDim(a),b=Math.max(10,x+n);e[t]={...a,value:bt(b,a.unit)};const g=b-x,I=h-g,E=i.value*m,v=Math.max(10,E-n),p=l>0?v/I*l:1;e[t+1]={...i,value:Math.round(p*100)/100}}return e}function bt(e,t){switch(t){case"px":return Math.round(e);case"mm":{const n=J.fromPx(e);return Math.round(n*10)/10}case"cm":{const n=J.fromPx(e);return Math.round(n/10*100)/100}case"inch":{const n=J.fromPx(e);return Math.round(n/25.4*100)/100}case"pt":{const n=J.fromPx(e);return Math.round(n/25.4*72*10)/10}case"fr":return 1;default:{const n=t;throw new Error(`Unsupported unit: ${n}`)}}}function rr(e){if(e.length===0)return[];const t=[];let n=0;for(const s of e){fe(s,"Pixel value");const o=s+n,a=Math.round(o);t.push(a),n=o-a}return t}const Is=8,Ds=32,Cs=64,Rs=512,Tn=(e,t,n)=>Math.min(Math.max(e,t),n);function Ht(e){const t=e.length-1,n=t>=1?e[t]??0:0,s=e.length>=1?n/t:0,o=Tn(Math.ceil(Math.log2(t+1)),Is,Ds),a=Tn(s*2,Cs,Rs);return{step:o,windowPx:a}}function vt(e,t){const n=t.length-1;if(n<=0||t[0]===void 0||e<t[0]||t[n]===void 0)return-1;if(e>=t[n])return n-1;let s=1,o=n;for(;s<=o;){const a=s+o>>>1,i=t[a];if(i===void 0){o=a-1;continue}i<=e?s=a+1:o=a-1}return s-1}function Xt(e,t,n){const s=e.length-1;let o=0;return a=>{if(s<=0||e[0]===void 0||a<e[0]||e[s]===void 0)return-1;if(a>=e[s])return s-1;const i=e[o],l=e[o+1];if(i===void 0||l===void 0)return-1;if(i<=a&&a<l)return o;const c=i-n,h=l+n;if(a<c||a>=h)return o=vt(a,e),o;let m=0;const x=e[o+1];if(x!==void 0&&a>=x)for(;o+1<s;){const b=e[o+1];if(b===void 0||a<b)break;if(o++,++m>t)return o=vt(a,e),o}else for(;o>0;){const b=e[o];if(b===void 0||a>=b)break;if(o--,++m>t)return o=vt(a,e),o}return o}}function gt(e,t){if(e.length===0)return[];fe(t,"Content size");let n=0,s=0;const o=e.map(l=>{if(fe(l.value,"Grid dimension value"),l.unit==="fr")return n+=l.value,null;{const c=J.fromDim(l);return s+=c,c}});if(n===0)return Yn(s,0,t,"Total fixed size"),o;const a=t-s;fe(a,"Content size - fixed sizes");const i=a/n;return o.map((l,c)=>{const h=e[c];if(l!=null)return l;if(!h)throw new Error(`dims[${c}] is undefined`);return h.value*i})}function yt(e,t=96){fe(t,"DPI"),jt(t,"DPI");const n=e.map(o=>W.fromMm(o,t));return rr(n)}function $s(e,t,n){if(e.length===0)return[];fe(n,"DPI"),jt(n,"DPI"),fe(t,"Content size");const s=gt(e,t);return yt(s,n)}function wt(e){const t={};for(const[n,s]of Object.entries(e))if(s!=null)if(typeof s=="object"&&!Array.isArray(s)&&s!==null){const o=wt(s);t[n]=o}else t[n]=s;return t}function Ts(e){if(typeof e!="object"||e===null)return!1;const t=e;if(typeof t.id!="string"||typeof t.kind!="string"||typeof t.layout!="object"||t.layout===null)return!1;const n=t.layout;return!(typeof n.x!="number"||typeof n.y!="number"||typeof n.w!="number"||typeof n.h!="number"||t.props!==void 0&&typeof t.props!="object")}function Ms(e){return e==="fr"||e==="px"||e==="%"}function Mn(e){return Array.isArray(e)?e.every(t=>{if(typeof t!="object"||t===null)return!1;const n=t;return typeof n.value=="number"&&Ms(n.unit)}):!1}function ks(e){if(typeof e!="object"||e===null)return!1;const t=e;return Mn(t.cols)&&Mn(t.rows)}function Ss(e){if(typeof e!="object"||e===null)return!1;const t=e;if(typeof t.size!="object"||t.size===null)return!1;const n=t.size;if(typeof n.preset!="string"||typeof n.width!="object"||n.width===null)return!1;const s=n.width;if(typeof s.value!="number"||typeof s.unit!="string"||typeof n.height!="object"||n.height===null)return!1;const o=n.height;if(typeof o.value!="number"||typeof o.unit!="string"||typeof t.margin!="object"||t.margin===null)return!1;const a=t.margin;for(const i of["top","right","bottom","left"]){const l=a[i];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 Ps(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="object"&&!Array.isArray(e)}function or(e){if(typeof e!="object"||e===null)throw new Error("Schema must be an object");const t=e;if(!Ss(t.paper))throw new Error("Invalid paper definition");if(!ks(t.grid))throw new Error("Invalid grid definition");if(!Array.isArray(t.blocks))throw new Error("blocks must be an array");if(!t.blocks.every(Ts))throw new Error("Invalid block definition in blocks array");if(t.metaData!==void 0){if(typeof t.metaData!="object"||t.metaData===null)throw new Error("metaData must be an object if provided");const n=t.metaData;for(const s in n)if(!Ps(n[s]))throw new Error(`Invalid value in metaData.${s}`)}return t}function qt(e){try{const t=JSON.parse(e);return or(t)}catch(t){throw t instanceof SyntaxError?new Error(`Invalid JSON format: ${t.message}`):t}}function Jt(e,t=!1){try{return t?JSON.stringify(e,null,2):JSON.stringify(e)}catch(n){throw new Error(`Failed to serialize schema: ${n instanceof Error?n.message:"Unknown error"}`)}}function sr(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"?!0:typeof e=="object"&&!Array.isArray(e)?Object.values(e).every(sr):!1}function ir(e){if(typeof e!="object"||e===null)throw new Error("Values must be an object");if(Array.isArray(e))throw new Error("Values must be an object, not an array");const t=e;for(const n in t)if(!sr(t[n]))throw new Error(`Invalid value at key "${n}"`);return t}function Zt(e){try{const t=JSON.parse(e);return ir(t)}catch(t){throw t instanceof SyntaxError?new Error(`Invalid JSON format: ${t.message}`):t}}function Qt(e,t=!1){try{return t?JSON.stringify(e,null,2):JSON.stringify(e)}catch(n){throw new Error(`Failed to serialize values: ${n instanceof Error?n.message:"Unknown error"}`)}}function sn(e,t,n=q){const s=d.useMemo(()=>J.fromDim(e.size.width),[e.size.width]),o=d.useMemo(()=>J.fromDim(e.size.height),[e.size.height]),a=d.useMemo(()=>J.fromDim(e.margin.top),[e.margin.top]),i=d.useMemo(()=>J.fromDim(e.margin.bottom),[e.margin.bottom]),l=d.useMemo(()=>J.fromDim(e.margin.left),[e.margin.left]),c=d.useMemo(()=>J.fromDim(e.margin.right),[e.margin.right]),h=d.useMemo(()=>s-l-c,[s,l,c]),m=d.useMemo(()=>o-a-i,[o,a,i]),x=d.useMemo(()=>gt(t.cols,h),[t.cols,h]),b=d.useMemo(()=>gt(t.rows,m),[t.rows,m]),g=d.useMemo(()=>W.fromMm(s,n),[s,n]),I=d.useMemo(()=>W.fromMm(o,n),[o,n]),E=d.useMemo(()=>W.fromMm(a,n),[a,n]),v=d.useMemo(()=>W.fromMm(i,n),[i,n]),p=d.useMemo(()=>W.fromMm(l,n),[l,n]),f=d.useMemo(()=>W.fromMm(c,n),[c,n]),y=d.useMemo(()=>W.fromMm(h,n),[h,n]),w=d.useMemo(()=>W.fromMm(m,n),[m,n]),R=d.useMemo(()=>yt(x,n),[x,n]),L=d.useMemo(()=>yt(b,n),[b,n]),$=d.useMemo(()=>{const H=[0];for(const Se of R){const Pe=H[H.length-1]??0;H.push(Pe+Se)}return H},[R]),N=d.useMemo(()=>{const H=[0];for(const Se of L){const Pe=H[H.length-1]??0;H.push(Pe+Se)}return H},[L]),{step:S,windowPx:M}=d.useMemo(()=>Ht($),[$]),{step:G,windowPx:T}=d.useMemo(()=>Ht(N),[N]),P=d.useMemo(()=>Xt($,S,M),[$,S,M]),j=d.useMemo(()=>Xt(N,G,T),[N,G,T]),D=d.useCallback(H=>P(H-p),[P,p]),k=d.useCallback(H=>j(H-E),[j,E]),A=d.useMemo(()=>({cols:$,rows:N}),[$,N]),K=d.useMemo(()=>({width:g,height:I}),[g,I]),Z=d.useMemo(()=>({top:E,bottom:v,left:p,right:f}),[E,v,p,f]),Q=d.useMemo(()=>({width:y,height:w}),[y,w]),ue=d.useMemo(()=>({canvas:K,margin:Z,content:Q}),[K,Z,Q]),le=d.useCallback(H=>{const{x:Se,y:Pe,w:tt,h:nt}=H.layout,Ee=A.cols,De=A.rows;if(!Ee.length||!De.length)return{left:0,top:0,width:0,height:0};const Oe=Math.min(Math.max(0,Se),Ee.length-1),Rt=Math.min(Math.max(0,Se+tt),Ee.length-1),rt=Math.min(Math.max(0,Pe),De.length-1),$t=Math.min(Math.max(0,Pe+nt),De.length-1),Tt=(Ee[Oe]??0)+p,Ue=(De[rt]??0)+E,Le=(Ee[Rt]??0)-(Ee[Oe]??0),dt=(De[$t]??0)-(De[rt]??0);return{left:Tt,top:Ue,width:Le,height:dt}},[A,p,E]);return{paperPx:ue,gridPosPx:A,getColIndex:D,getRowIndex:k,getBlockRectPx:le}}const an=d.memo(({schema:e,values:t,pluginRegistry:n,onValueChange:s,scale:o=1,className:a})=>{const{paperPx:i,gridPosPx:l,getBlockRectPx:c}=sn(e.paper,e.grid,q),h=d.useCallback((m,x)=>{s&&s(m,x)},[s]);return r.jsxs("div",{className:a,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(Nt,{paperPx:i,gridPosPxs:l,showGridLines:!1,showMargins:!1,showBorder:!1}),r.jsx(Dt,{blocks:e.blocks,pluginRegistry:n,mode:ge.EDIT,values:t,getBlockRectPx:c,onValueChange:h,showGuides:!0,showBorder:!0})]})});an.displayName="NoteEdit";var X=(e=>(e.IDLE="idle",e.PRESSING="pressing",e.DRAGGING="dragging",e.EDITING="editing",e))(X||{}),te=(e=>(e.N="n",e.NE="ne",e.E="e",e.SE="se",e.S="s",e.SW="sw",e.W="w",e.NW="nw",e))(te||{}),me=(e=>(e.MOVE="move",e.RESIZE="resize",e.INSERT="insert",e))(me||{}),U=(e=>(e.SELECT="select",e.DESELECT="deselect",e.START_PRESS="startPress",e.UPDATE_DRAG="updateDrag",e.END_DRAG="endDrag",e.CANCEL_DRAG="cancelDrag",e.EDIT="edit",e.END_EDIT="endEdit",e.START_INSERT="startInsert",e.CANCEL_INSERT="cancelInsert",e.START_RESIZE="startResize",e))(U||{});function As(e){const[t,n]=d.useState({mode:X.IDLE,selectedBlockIds:[],editingBlockId:null,...e}),s=d.useCallback(o=>{n(a=>{switch(o.type){case U.SELECT:{const i=o.blockIds;return{...a,mode:X.IDLE,selectedBlockIds:i}}case U.DESELECT:return{...a,mode:X.IDLE,selectedBlockIds:[]};case U.START_PRESS:{const i=o.selectedBlockIds||[o.blockId];return{...a,mode:X.PRESSING,dragging:{type:me.MOVE,blockIds:i,startGrid:o.startGrid,currentGrid:o.startGrid,isOutside:!1}}}case U.UPDATE_DRAG:{if(!a.dragging)return a;const i=o.currentGrid.col!==a.dragging.startGrid.col||o.currentGrid.row!==a.dragging.startGrid.row;return a.mode===X.PRESSING?i?{...a,mode:X.DRAGGING,dragging:{...a.dragging,currentGrid:o.currentGrid,currentMousePx:o.currentMousePx,isOutside:o.isOutside??!1}}:{...a,dragging:{...a.dragging,currentGrid:o.currentGrid,currentMousePx:o.currentMousePx,isOutside:o.isOutside??!1}}:a.mode===X.DRAGGING?{...a,dragging:{...a.dragging,currentGrid:o.currentGrid,currentMousePx:o.currentMousePx,isOutside:o.isOutside??!1}}:a}case U.END_DRAG:return{...a,mode:X.IDLE,dragging:void 0};case U.CANCEL_DRAG:return{...a,mode:X.IDLE,dragging:void 0};case U.EDIT:return{...a,mode:X.EDITING,editingBlockId:o.blockId};case U.END_EDIT:return{...a,mode:X.IDLE,editingBlockId:null};case U.START_INSERT:return{...a,mode:X.DRAGGING,dragging:{type:me.INSERT,blockIds:[],startGrid:{col:0,row:0},currentGrid:{col:0,row:0},pluginKind:o.pluginKind,defaultSize:o.defaultSize,isOutside:!1}};case U.CANCEL_INSERT:return{...a,mode:X.IDLE,dragging:void 0};case U.START_RESIZE:return{...a,mode:X.DRAGGING,dragging:{type:me.RESIZE,blockIds:[o.blockId],startGrid:o.startGrid,currentGrid:o.startGrid,handle:o.handle,isOutside:!1}};default:return a}})},[]);return[t,s]}const Ct={all:{color:"#3b82f688",width:{value:4,unit:"px"},type:ye.SOLID}},ln={size:12,backgroundColor:"#ffffff",borderColor:"#3b82f6",borderWidth:1,borderRadius:"50%"},ae={base:F.INTERACTION_LAYER_BASE,select_block:F.SELECT_BLOCK,block_ghost:F.BLOCK_GHOST,hover_outline:F.HOVER_OUTLINE,edit_block:F.EDIT_BLOCK,grid_ghost:F.GRID_GHOST,grid_handles:F.GRID_HANDLES,select_border:F.BLOCK_SELECT_BORDER,block_handles:F.BLOCK_HANDLES,rubber_band:F.RUBBER_BAND},Os="_interactionBlock_145kg_7",Ls="_resizeHandle_145kg_7",ar={interactionBlock:Os,resizeHandle:Ls},Gs=[{id:te.NW,cursor:"nwse-resize",x:0,y:0},{id:te.N,cursor:"ns-resize",x:50,y:0},{id:te.NE,cursor:"nesw-resize",x:100,y:0},{id:te.W,cursor:"ew-resize",x:0,y:50},{id:te.E,cursor:"ew-resize",x:100,y:50},{id:te.SW,cursor:"nesw-resize",x:0,y:100},{id:te.S,cursor:"ns-resize",x:50,y:100},{id:te.SE,cursor:"nwse-resize",x:100,y:100}],lr=d.memo(({onResizeStart:e,activeHandle:t,handleStyle:n=ln,zIndex:s=F.BLOCK_HANDLES})=>{const o=n.size,a=o/2;return r.jsx(r.Fragment,{children:Gs.map(({id:i,cursor:l,x:c,y:h})=>{const m=c===50?`calc(50% - ${a}px)`:c===100?`calc(100% - ${a}px)`:`-${a}px`,x=h===50?`calc(50% - ${a}px)`:h===100?`calc(100% - ${a}px)`:`-${a}px`,b=t===i;return r.jsx("div",{className:ar.resizeHandle,onPointerDown:g=>{g.stopPropagation(),e(g,i)},style:{position:"absolute",left:m,top:x,width:`${o}px`,height:`${o}px`,backgroundColor:b?n.borderColor:n.backgroundColor,border:`${n.borderWidth}px solid ${n.borderColor}`,borderRadius:n.borderRadius,cursor:l,zIndex:s,pointerEvents:"auto",boxSizing:"border-box",opacity:b?1:void 0,transition:"opacity 0.2s, background-color 0.2s, transform 0.2s",transform:b?"scale(1.2)":void 0},"data-testid":`resize-handle-${i}`},i)})})});lr.displayName="ResizeHandles";const Bs=d.memo(({width:e,height:t,zIndex:n=F.BLOCK_SELECT_BORDER,borderStyle:s=Ct})=>{const o=d.useMemo(()=>new et(s),[s]),a={position:"absolute",inset:0,pointerEvents:"none",zIndex:n};return r.jsx("div",{style:a,children:r.jsx(Ve,{width:e,height:t,border:o})})}),ut=d.memo(({block:e,rect:t,showHandles:n=!1,onResizeStart:s,activeHandle:o,selectionStyle:a=Ct,handleStyle:i=ln,selectBorderZIndex:l=ae.select_border,blockHandlesZIndex:c=ae.block_handles})=>{const h={position:"absolute",left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,pointerEvents:"none"};return r.jsxs("div",{className:ar.interactionBlock,style:h,"data-testid":"interaction-block","data-block-id":e.id,children:[r.jsx(Bs,{width:t.width,height:t.height,zIndex:l,borderStyle:a}),n&&s&&r.jsx(lr,{onResizeStart:s,activeHandle:o,handleStyle:i,zIndex:c})]})});ut.displayName="InteractionBlock";const cr=d.memo(({pluginRegistry:e,gridLength:t,getBlockRectPx:n,currentGrid:s,currentMousePx:o,pluginKind:a,defaultSize:i,isOutside:l,selectionStyle:c,ghostZIndex:h=ae.block_ghost,selectBorderZIndex:m=ae.select_border,blockHandlesZIndex:x=ae.block_handles})=>{const b=e[a];if(!b)return null;let g;if(l&&o){const E=Fe(b,{x:0,y:0,w:i.w,h:i.h}),v=n(E);g={left:o.x-v.width/2,top:o.y-v.height/2,width:v.width,height:v.height}}else{const E=t.cols-i.w,v=t.rows-i.h,p=Math.max(0,Math.min(s.col,E)),f=Math.max(0,Math.min(s.row,v)),y=Fe(b,{x:p,y:f,w:i.w,h:i.h});g=n(y)}const I=Fe(b,{x:0,y:0,w:i.w,h:i.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:h},children:r.jsx(It,{id:I.id,plugin:b,props:I.props,value:I.initValue,onChange:()=>{},readOnly:!0,mode:ge.EDIT,blockSizePx:g,blockZIndex:h})}),r.jsx(ut,{block:I,rect:g,selectionStyle:c,selectBorderZIndex:m,blockHandlesZIndex:x})]})});cr.displayName="InsertGhost";function ur(e,t,n,s,o){if(e.length===0)return[];if(e.length===1){const p=e[0];if(!p)return[];const f=s-p.layout.w,y=o-p.layout.h,w=Math.max(0,Math.min(p.layout.x+t,f)),R=Math.max(0,Math.min(p.layout.y+n,y));return[{blockId:p.id,x:w,y:R}]}const a=Math.min(...e.map(p=>p.layout.x)),i=Math.min(...e.map(p=>p.layout.y)),l=Math.max(...e.map(p=>p.layout.x+p.layout.w)),c=Math.max(...e.map(p=>p.layout.y+p.layout.h)),h=l-a,m=c-i,x=a+t,b=i+n,g=Math.max(0,Math.min(x,s-h)),I=Math.max(0,Math.min(b,o-m)),E=g-a,v=I-i;return e.map(p=>({blockId:p.id,x:p.layout.x+E,y:p.layout.y+v}))}const dr=d.memo(({blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:s,selectedBlockIds:o,deltaCol:a,deltaRow:i,isOutside:l,currentMousePx:c,selectionStyle:h,ghostZIndex:m=ae.block_ghost,selectBorderZIndex:x=ae.select_border,blockHandlesZIndex:b=ae.block_handles})=>{const g=o.map(E=>e.find(v=>v.id===E)).filter(Boolean),I=ur(g,a,i,n.cols,n.rows);return r.jsx("div",{"data-testid":"moving-ghost",style:{position:"absolute",inset:0,pointerEvents:"none"},children:o.map(E=>{const v=e.find(w=>w.id===E);if(!v)return null;const p=t[v.kind];if(!p)return null;let f;if(l&&c){const w=s(v);f={left:c.x-w.width/2,top:c.y-w.height/2,width:w.width,height:w.height}}else{const w=I.find(L=>L.blockId===v.id);if(!w)return null;const R={...v,layout:{...v.layout,x:w.x,y:w.y}};f=s(R)}const y={...v,layout:{...v.layout,x:0,y:0}};return r.jsxs("div",{children:[r.jsx("div",{style:{position:"absolute",left:`${f.left}px`,top:`${f.top}px`,width:`${f.width}px`,height:`${f.height}px`,opacity:l?.3:.5,filter:l?"grayscale(100%)":"none",zIndex:m},children:r.jsx(It,{id:y.id,plugin:p,props:y.props,value:y.initValue,onChange:()=>{},readOnly:!0,mode:ge.EDIT,blockSizePx:f,blockZIndex:m,className:"ghost-content"})}),r.jsx(ut,{block:y,rect:f,selectionStyle:h,selectBorderZIndex:x,blockHandlesZIndex:b})]},E)})})});dr.displayName="MovingGhost";function fr({layout:e,handle:t,deltaCol:n,deltaRow:s,gridCols:o,gridRows:a}){const i={...e};if(t===te.E||t===te.NE||t===te.SE){const l=o-e.x;i.w=Math.max(1,Math.min(e.w+n,l))}else if(t===te.W||t===te.NW||t===te.SW){const l=e.w-1,c=n>0?Math.min(n,l):n;e.x+c>=0?(i.x=e.x+c,i.w=e.w-c):(i.x=0,i.w=e.w+e.x)}if(t===te.S||t===te.SE||t===te.SW){const l=a-e.y;i.h=Math.max(1,Math.min(e.h+s,l))}else if(t===te.N||t===te.NE||t===te.NW){const l=e.h-1,c=s>0?Math.min(s,l):s;e.y+c>=0?(i.y=e.y+c,i.h=e.h-c):(i.y=0,i.h=e.h+e.y)}return i}const hr=d.memo(({blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:s,blockId:o,handle:a,deltaCol:i,deltaRow:l,isOutside:c,selectionStyle:h,ghostZIndex:m=ae.block_ghost,selectBorderZIndex:x=ae.select_border,blockHandlesZIndex:b=ae.block_handles})=>{const g=e.find(f=>f.id===o),I=t[(g==null?void 0:g.kind)??""];if(!g||!I)return null;const E=fr({layout:g.layout,handle:a,deltaCol:i,deltaRow:l,gridCols:n.cols,gridRows:n.rows}),v={...g,layout:E},p=s(v);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:`${p.left}px`,top:`${p.top}px`,width:`${p.width}px`,height:`${p.height}px`,opacity:c?.3:.5,filter:c?"grayscale(100%)":"none",zIndex:m},children:r.jsx(It,{id:v.id,plugin:I,props:v.props,value:v.initValue,onChange:()=>{},readOnly:!0,mode:ge.EDIT,blockSizePx:p,blockZIndex:m,className:"resize-ghost-content"})}),r.jsx(ut,{block:v,rect:p,selectionStyle:h,selectBorderZIndex:x,blockHandlesZIndex:b})]},g.id)})});hr.displayName="ResizeGhost";const mr=d.memo(({blocks:e,pluginRegistry:t,gridLength:n,draggingState:s,getBlockRectPx:o,selectionStyle:a=Ct,ghostZIndex:i=ae.block_ghost,selectBorderZIndex:l=ae.select_border,blockHandlesZIndex:c=ae.block_handles})=>{if(!s)return null;const h=s.currentGrid.col-s.startGrid.col,m=s.currentGrid.row-s.startGrid.row;switch(s.type){case me.MOVE:return r.jsx(dr,{blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:o,selectedBlockIds:s.blockIds,deltaCol:h,deltaRow:m,isOutside:s.isOutside??!1,currentMousePx:s.currentMousePx,selectionStyle:a,ghostZIndex:i,selectBorderZIndex:l,blockHandlesZIndex:c});case me.RESIZE:{const x=s.blockIds[0];return!x||!s.handle?null:r.jsx(hr,{blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:o,blockId:x,handle:s.handle,deltaCol:h,deltaRow:m,isOutside:s.isOutside??!1,selectionStyle:a,ghostZIndex:i,selectBorderZIndex:l,blockHandlesZIndex:c})}case me.INSERT:return s.defaultSize?r.jsx(cr,{pluginRegistry:t,gridLength:n,getBlockRectPx:o,currentGrid:s.currentGrid,currentMousePx:s.currentMousePx,pluginKind:s.pluginKind||"",defaultSize:s.defaultSize,isOutside:s.isOutside??!1,selectionStyle:a,ghostZIndex:i,selectBorderZIndex:l,blockHandlesZIndex:c}):null;default:return null}});mr.displayName="DragLayer";const Fs=({id:e,plugin:t,props:n,value:s,onChange:o,onBlur:a,blockRectPx:i,zIndex:l=F.EDIT_BLOCK,validationState:c,className:h=""},m)=>{const x=d.useRef(null);d.useImperativeHandle(m,()=>({focus:()=>{var v;(v=x.current)==null||v.focus()}}),[]);const b=on(i,{zIndex:l,pointerEvents:"auto"}),g={width:i.width,height:i.height},I={id:e,props:n,value:s,onChange:o,onBlur:a,readOnly:!1,mode:ge.FORM,dimensions:{widthPx:g.width,heightPx:g.height},validationState:c},E=t.Renderer;return r.jsx("div",{className:h,style:b,"data-testid":"editing-block","data-block-id":e,"data-plugin-kind":t.kind,children:r.jsx(E,{ref:x,...I})})},Vs=d.forwardRef(Fs),Us=d.memo(Vs),pr=d.memo(({blocks:e,selectedBlockIds:t,isDragging:n,draggingState:s,getBlockRectPx:o,onResizeStart:a,selectionStyle:i=Ct,handleStyle:l=ln,selectBorderZIndex:c=ae.select_border,blockHandlesZIndex:h=ae.block_handles})=>{if(n&&(s==null?void 0:s.type)!==me.RESIZE)return null;const x=Array.from(new Set(t));return r.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:x.map(b=>{const g=e.find(v=>v.id===b);if(!g)return null;const E=(s==null?void 0:s.type)===me.RESIZE&&s.blockIds.includes(b)?s==null?void 0:s.handle:null;return r.jsx(ut,{block:g,rect:o(g),showHandles:!0,onResizeStart:(v,p)=>a(v,p,b),activeHandle:E,selectionStyle:i,handleStyle:l,selectBorderZIndex:c,blockHandlesZIndex:h},g.id)})})});pr.displayName="SelectionLayer";function Ws(e,t,n,s){const o=n-t.w,a=s-t.h;return{x:Math.max(0,Math.min(e.x,o)),y:Math.max(0,Math.min(e.y,a))}}function kn(e,t,n){const{x:s,y:o}=e;for(let a=t.length-1;a>=0;a--){const i=t[a];if(!i)continue;const l=n(i);if(s>=l.left&&s<=l.left+l.width&&o>=l.top&&o<=l.top+l.height)return i.id}return null}const vr=d.memo(({blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:s,getColIndex:o,getRowIndex:a,state:i,onChange:l,onBlockChange:c,scale:h=1,className:m="",selectionStyle:x,handleStyle:b,editBlockZIndex:g=F.EDIT_BLOCK,selectBorderZIndex:I=ae.select_border,blockHandlesZIndex:E=ae.block_handles,dragGhostZIndex:v=ae.block_ghost})=>{const p=d.useRef(null),f=d.useRef(null);d.useEffect(()=>{i.mode===X.EDITING&&i.editingBlockId&&setTimeout(()=>{var N;(N=f.current)==null||N.focus()},0)},[i.mode,i.editingBlockId]),d.useEffect(()=>{const N=new Set(e.map(M=>M.id)),S=i.selectedBlockIds.filter(M=>N.has(M));S.length!==i.selectedBlockIds.length&&l({type:U.SELECT,blockIds:S,shiftKey:!1})},[e,i.selectedBlockIds,l]);const y=d.useCallback(N=>{var D;if(N.button!==0)return;const S=(D=p.current)==null?void 0:D.getBoundingClientRect();if(!S)return;const M=h??1,G={x:(N.clientX-S.left)/M,y:(N.clientY-S.top)/M},T=kn(G,e,s);if(i.mode===X.EDITING){T!==i.editingBlockId&&(l({type:U.END_EDIT}),T||l({type:U.DESELECT}));return}const P=o(G.x),j=a(G.y);if(T){N.stopPropagation();const k=i.selectedBlockIds.includes(T);if(console.log("[InteractionLayer] PointerDown on block:",{targetId:T,shiftKey:N.shiftKey,isAlreadySelected:k,currentSelection:i.selectedBlockIds}),k&&N.shiftKey){console.log("[InteractionLayer] Shift+Click deselect:",T);const A=i.selectedBlockIds.filter(K=>K!==T);console.log("[InteractionLayer] New selection:",A),l({type:U.SELECT,blockIds:A,shiftKey:!0});return}else k?(N.currentTarget.setPointerCapture(N.pointerId),l({type:U.START_PRESS,blockId:T,startGrid:{col:P,row:j},selectedBlockIds:i.selectedBlockIds})):(N.currentTarget.setPointerCapture(N.pointerId),N.shiftKey?l({type:U.SELECT,blockIds:[...i.selectedBlockIds,T],shiftKey:!0}):(l({type:U.SELECT,blockIds:[T]}),l({type:U.START_PRESS,blockId:T,startGrid:{col:P,row:j},selectedBlockIds:[T]})))}else N.stopPropagation(),l({type:U.DESELECT})},[e,s,o,a,i.mode,i.selectedBlockIds,l,h,i.editingBlockId]),w=d.useCallback(N=>{var Q;if(i.mode!==X.PRESSING&&i.mode!==X.DRAGGING||!i.dragging)return;const S=(Q=p.current)==null?void 0:Q.getBoundingClientRect();if(!S)return;const M=h??1,G=S.width/M,T=S.height/M,P=(N.clientX-S.left)/M,j=(N.clientY-S.top)/M,D=i.dragging.type!==me.RESIZE&&(P<0||P>G||j<0||j>T),k=Math.max(0,Math.min(P,G)),A=Math.max(0,Math.min(j,T)),K=o(k),Z=a(A);l({type:U.UPDATE_DRAG,currentGrid:{col:K,row:Z},currentMousePx:{x:P,y:j},isOutside:D})},[i.mode,i.dragging,o,a,l,h]),R=d.useCallback(N=>{if(i.mode===X.DRAGGING&&i.dragging){if(i.dragging.isOutside){i.dragging.type===me.MOVE&&(c==null||c({type:be.DELETE,blockIds:i.dragging.blockIds}),l({type:U.DESELECT})),l({type:U.END_DRAG}),N.currentTarget.releasePointerCapture(N.pointerId);return}const S=i.dragging.currentGrid.col-i.dragging.startGrid.col,M=i.dragging.currentGrid.row-i.dragging.startGrid.row;if(i.dragging.type===me.MOVE){if(S!==0||M!==0){const G=i.dragging.blockIds.map(j=>e.find(D=>D.id===j)).filter(Boolean);if(G.length===0){l({type:U.END_DRAG}),N.currentTarget.releasePointerCapture(N.pointerId);return}const T=ur(G,S,M,n.cols,n.rows),P=G.map(j=>{const D=T.find(k=>k.blockId===j.id);return D?{...j,layout:{...j.layout,x:D.x,y:D.y}}:j});c==null||c({type:be.MOVE,blockIds:i.dragging.blockIds,blocks:P})}}else if(i.dragging.type===me.INSERT){const{pluginKind:G,currentGrid:T,defaultSize:P}=i.dragging;if(G&&P){const j=t[G];if(j){const{x:D,y:k}=Ws({x:T.col,y:T.row},{w:P.w,h:P.h},n.cols,n.rows),A=Fe(j,{x:D,y:k,w:P.w,h:P.h});c==null||c({type:be.ADD,blockIds:[A.id],blocks:[A]})}}}else if(i.dragging.type===me.RESIZE){const G=i.dragging.blockIds[0],T=e.find(j=>j.id===G),P=i.dragging.handle;if(T&&P&&(S!==0||M!==0)){const j=fr({layout:T.layout,handle:P,deltaCol:S,deltaRow:M,gridCols:n.cols,gridRows:n.rows});(j.x!==T.layout.x||j.y!==T.layout.y||j.w!==T.layout.w||j.h!==T.layout.h)&&(c==null||c({type:be.RESIZE,blockIds:[T.id],blocks:[{...T,layout:j}]}))}}l({type:U.END_DRAG})}else i.mode===X.PRESSING&&i.dragging&&(i.dragging.isOutside&&i.dragging.type===me.MOVE&&(c==null||c({type:be.DELETE,blockIds:i.dragging.blockIds}),l({type:U.DESELECT})),l({type:U.CANCEL_DRAG}));N.currentTarget.releasePointerCapture(N.pointerId)},[i.mode,i.dragging,e,n,t,c,l]),L=d.useCallback(N=>{var P;const S=(P=p.current)==null?void 0:P.getBoundingClientRect();if(!S)return;const M=h??1,G={x:(N.clientX-S.left)/M,y:(N.clientY-S.top)/M},T=kn(G,e,s);T&&(i.selectedBlockIds.includes(T)||l({type:U.SELECT,blockIds:[T]}),l({type:U.EDIT,blockId:T}))},[e,s,l,h,i.selectedBlockIds]),$=d.useCallback(N=>{var S;if((i.mode===X.PRESSING||i.mode===X.DRAGGING)&&i.dragging){const M=(S=p.current)==null?void 0:S.getBoundingClientRect();if(M){const G=h??1,T=(N.clientX-M.left)/G,P=(N.clientY-M.top)/G,j=M.width/G,D=M.height/G,k=Math.max(0,Math.min(T,j)),A=Math.max(0,Math.min(P,D));l({type:U.UPDATE_DRAG,currentGrid:{col:o(k),row:a(A)},currentMousePx:{x:T,y:P},isOutside:!0})}}},[i.mode,i.dragging,h,o,a,l]);return r.jsxs("div",{ref:p,className:m,style:{position:"absolute",inset:0,zIndex:F.INTERACTION_LAYER_BASE,pointerEvents:"auto",touchAction:"none"},role:"application","aria-label":"Interactive canvas layer",tabIndex:-1,onPointerDown:y,onPointerMove:w,onPointerUp:R,onPointerLeave:$,onDoubleClick:L,"data-testid":"interaction-layer",children:[i.editingBlockId&&(()=>{const N=e.find(M=>M.id===i.editingBlockId),S=N?t[N.kind]:null;return!N||!S?null:r.jsx(Us,{ref:f,id:N.id,plugin:S,props:N.props,value:N.initValue,onChange:M=>{c==null||c({type:be.UPDATE,blockIds:[N.id],blocks:[{...N,initValue:M}]})},onBlur:M=>{c==null||c({type:be.UPDATE,blockIds:[N.id],blocks:[{...N,initValue:M}]})},blockRectPx:s(N),zIndex:g})})(),r.jsx(pr,{blocks:e,selectedBlockIds:i.selectedBlockIds,isDragging:i.mode===X.DRAGGING,draggingState:i.dragging,getBlockRectPx:s,onResizeStart:(N,S,M)=>{var j;const G=(j=p.current)==null?void 0:j.getBoundingClientRect();if(!G)return;i.mode===X.EDITING&&l({type:U.END_EDIT}),N.currentTarget.setPointerCapture(N.pointerId);const T=h??1,P={x:(N.clientX-G.left)/T,y:(N.clientY-G.top)/T};l({type:U.START_RESIZE,blockId:M,handle:S,startGrid:{col:o(P.x),row:a(P.y)}})},selectionStyle:x,handleStyle:b,selectBorderZIndex:I,blockHandlesZIndex:E}),r.jsx(mr,{blocks:e,pluginRegistry:t,gridLength:n,draggingState:i.dragging,getBlockRectPx:s,selectionStyle:x,ghostZIndex:v,selectBorderZIndex:I,blockHandlesZIndex:E})]})});vr.displayName="InteractionLayer";const cn=d.memo(({schema:e,pluginRegistry:t,onSchemaChange:n,onSelectionChange:s,scale:o=1,className:a})=>{const[i,l]=As(),{paperPx:c,gridPosPx:h,getBlockRectPx:m,getColIndex:x,getRowIndex:b}=sn(e.paper,e.grid,q),g=d.useCallback(w=>{if(n)switch(w.type){case be.MOVE:case be.RESIZE:{if(!w.blocks)return;const R=e.blocks.map(L=>{var N;return((N=w.blocks)==null?void 0:N.find(S=>S.id===L.id))||L});n({...e,blocks:R});break}case be.ADD:{if(!w.blocks)return;n({...e,blocks:[...e.blocks,...w.blocks]});break}case be.DELETE:{const R=new Set(w.blockIds),L=e.blocks.filter($=>!R.has($.id));n({...e,blocks:L});break}case be.UPDATE:{if(!w.blocks)return;const R=e.blocks.map(L=>{var M;const $=(M=w.blocks)==null?void 0:M.find(G=>G.id===L.id);if(!$)return L;const N=$.style?wt($.style):$.style,S=$.props?wt($.props):$.props;return{...L,...$,style:N,props:S}});n({...e,blocks:R});break}}},[e,n]),I=d.useCallback((w,R)=>{if(!n)return;const L=e.blocks.map($=>$.id===w?{...$,initValue:R}:$);n({...e,blocks:L})},[e,n]);d.useEffect(()=>{s&&s(i.selectedBlockIds)},[i.selectedBlockIds,s]);const E=d.useCallback((w,R,L)=>{if(!n)return;const $=R-1;if(w==="column"){const N=Kt(e.grid.cols,$,L,c.content.width);n({...e,grid:{...e.grid,cols:N}})}else{const N=Kt(e.grid.rows,$,L,c.content.height);n({...e,grid:{...e.grid,rows:N}})}},[e,c,n]),v=d.useCallback((w,R,L)=>{if(n)if(w==="column"){const $=[...e.grid.cols];$[R]=L,n({...e,grid:{...e.grid,cols:$}})}else{const $=[...e.grid.rows];$[R]=L,n({...e,grid:{...e.grid,rows:$}})}},[n,e]),p=d.useMemo(()=>e.blocks.reduce((w,R)=>(w[R.id]=R.initValue,w),{}),[e.blocks]),f=d.useCallback(()=>{const w=xt.get();w&&i.mode!==X.DRAGGING&&l({type:U.START_INSERT,pluginKind:w.kind,defaultSize:w.defaultSize})},[i.mode,l]),y=d.useCallback(()=>{},[]);return r.jsxs("div",{className:a,onPointerEnter:f,onPointerLeave:y,style:{position:"relative",width:`${c.canvas.width}px`,height:`${c.canvas.height}px`,margin:"0 auto",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",backgroundColor:"#fff",transform:o!==1?`scale(${o})`:void 0,transformOrigin:"top center"},children:[r.jsx(Nt,{paperPx:c,gridPosPxs:h,gridDimensions:{cols:e.grid.cols,rows:e.grid.rows},showGridLines:!0,showMargins:!0,showBorder:!0,showResizeHandles:!0,showDimensionLabels:!0,onGridResize:E,onDimensionChange:v,gridLineStyle:{color:"#e5e7eb",width:{value:1,unit:"px"},type:ye.SOLID},borderStyle:{all:{color:"#000000",width:{value:1,unit:"px"},type:ye.SOLID}}}),r.jsx(Dt,{blocks:e.blocks,pluginRegistry:t,mode:ge.FORM,values:p,selectedBlockIds:i.selectedBlockIds,getBlockRectPx:m,onValueChange:I,showGuides:!0,showBorder:!0}),r.jsx(vr,{blocks:e.blocks,gridLength:{cols:e.grid.cols.length,rows:e.grid.rows.length},pluginRegistry:t,getBlockRectPx:m,getColIndex:x,getRowIndex:b,state:i,onChange:l,onBlockChange:g,scale:o})]})});cn.displayName="NoteForm";const un=d.memo(({schema:e,values:t,pluginRegistry:n,scale:s=1,className:o})=>{const{paperPx:a,gridPosPx:i,getBlockRectPx:l}=sn(e.paper,e.grid,q);return r.jsxs("div",{className:o,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(Nt,{paperPx:a,gridPosPxs:i,showGridLines:!1,showMargins:!1,showBorder:!1}),r.jsx(Dt,{blocks:e.blocks,pluginRegistry:n,mode:ge.VIEW,values:t,getBlockRectPx:l,showGuides:!1,showBorder:!0})]})});un.displayName="NoteView";const xr=d.memo(({schema:e,values:t,mode:n,pluginRegistry:s,onSchemaChange:o,onValuesChange:a,onSelectionChange:i,scale:l=1,className:c})=>{const h=d.useCallback((m,x)=>{a&&a({...t,[m]:x})},[t,a]);return n===ge.FORM?r.jsx(cn,{schema:e,pluginRegistry:s,onSchemaChange:o,onSelectionChange:i,scale:l,className:c}):n===ge.EDIT?r.jsx(an,{schema:e,values:t,pluginRegistry:s,onValueChange:h,scale:l,className:c}):r.jsx(un,{schema:e,values:t,pluginRegistry:s,scale:l,className:c})});xr.displayName="NoteEditor";function Re(e,t){if(e.length===0)return;const n=(i,l)=>{let c=i;for(const h of l){if(c==null||typeof c!="object"||Array.isArray(c))return;c=c[h]}return c},s=t.split("."),o=n(e[0],s);return e.every(i=>n(i,s)===o)?o:void 0}const Ys="_container_1tfjv_1",zs="_row_1tfjv_20",Ks="_inputWrapper_1tfjv_37",Vt={container:Ys,row:zs,inputWrapper:Ks},Hs=({selectedBlocks:e,onUpdateBlocks:t})=>{if(e.length===0)return null;const n=s=>{const o={};e.forEach(a=>{o[a.id]={style:{...a.style,backgroundColor:s}}}),t(o)};return r.jsx("div",{className:Vt.container,children:r.jsx("div",{className:Vt.row,children:r.jsx("div",{className:Vt.inputWrapper,children:r.jsx(ct,{value:Re(e,"style.backgroundColor"),onChange:n,allowUndefined:!0,placeholder:"無色",height:24})})})})};function Te(e,t,n){const s=t.split("."),o=(a,i)=>{const l=s[i];if(i===s.length-1){if(n==null){const{[l]:m,...x}=a;return x}return{...a,[l]:n}}const c=(a==null?void 0:a[l])||{},h=o(c,i+1);if(Object.keys(h).length===0){const{[l]:m,...x}=a;return x}return{...a,[l]:h}};return o(e,0)}const Xs=({selectedBlocks:e,onUpdateBlocks:t})=>{const n=(i,l,c)=>{const h={};e.forEach(m=>{var b,g,I;let x=Te(m.style||{},`border.${i}.${l}`,c);if(l==="type"&&c==null&&(x=Te(x,`border.${i}.width`,void 0),x=Te(x,`border.${i}.color`,void 0)),l==="type"&&c!==void 0&&c!==null){const E=(b=m.style)==null?void 0:b.border,v=E==null?void 0:E[i];v!=null&&v.width||(x=Te(x,`border.${i}.width`,{value:1,unit:"px"})),v!=null&&v.color||(x=Te(x,`border.${i}.color`,"#000000"))}if(l==="color"&&c!==void 0&&c!==null){const E=(g=m.style)==null?void 0:g.border,v=E==null?void 0:E[i];v!=null&&v.type||(x=Te(x,`border.${i}.type`,ye.SOLID)),v!=null&&v.width||(x=Te(x,`border.${i}.width`,{value:1,unit:"px"}))}if(l==="width"&&c!==void 0&&c!==null){const E=(I=m.style)==null?void 0:I.border,v=E==null?void 0:E[i];v!=null&&v.type||(x=Te(x,`border.${i}.type`,ye.SOLID)),v!=null&&v.color||(x=Te(x,`border.${i}.color`,"#000000"))}h[m.id]={style:x}}),t(h)},s=d.useMemo(()=>{var m;if(e.length!==1)return null;const i=e[0];if(!((m=i==null?void 0:i.style)!=null&&m.border))return null;const l=i.style.border;if(!l)return null;const c=x=>x?!(x.type&&!x.width):!0;return["all","top","right","bottom","left"].every(x=>c(l[x]))?new et(l):null},[e]),o=i=>r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[r.jsx($e,{value:Re(e,`style.border.${i}.type`),onChange:l=>n(i,"type",l),placeholder:"スタイル",height:24,options:[{label:"",value:void 0},{label:"実線",value:ye.SOLID},{label:"破線",value:ye.DASHED},{label:"点線",value:ye.DOTTED}]}),r.jsx(ce,{value:Re(e,`style.border.${i}.width`),onChange:l=>n(i,"width",l),placeholder:"太さ",height:24,allowedUnits:Gn,min:1}),r.jsx(ct,{value:Re(e,`style.border.${i}.color`),onChange:l=>n(i,"color",l),placeholder:"色",height:24,allowUndefined:!0})]}),a={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"})]}),s?r.jsx("div",{style:{position:"absolute",top:0,left:0,width:"80px",height:"80px",pointerEvents:"none"},children:r.jsx(Ve,{width:80,height:80,border:s})}):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(en,{defaultValue:"all",variant:"segmented",children:[r.jsx("div",{style:{width:"100%"},children:r.jsxs(tn,{style:{width:"100%",display:"flex"},children:[r.jsx(Me,{value:"all",height:24,style:a,children:"共通"}),r.jsx(Me,{value:"top",height:24,style:a,children:"上"}),r.jsx(Me,{value:"bottom",height:24,style:a,children:"下"}),r.jsx(Me,{value:"left",height:24,style:a,children:"左"}),r.jsx(Me,{value:"right",height:24,style:a,children:"右"})]})}),r.jsxs("div",{style:{marginTop:"4px"},children:[r.jsx(ke,{value:"all",children:o("all")}),r.jsx(ke,{value:"top",children:o("top")}),r.jsx(ke,{value:"bottom",children:o("bottom")}),r.jsx(ke,{value:"left",children:o("left")}),r.jsx(ke,{value:"right",children:o("right")})]})]})})]})},qs="_container_1daw7_1",Js="_grid_1daw7_19",Zs="_field_1daw7_26",Qs="_label_1daw7_33",ei="_inputWrapper_1daw7_43",xe={container:qs,grid:Js,field:Zs,label:Qs,inputWrapper:ei},ti=({selectedBlocks:e,onUpdateBlocks:t,gridSize:n})=>{if(e.length===0)return null;const s=e.length>1,o=s?Math.min(...e.map(l=>l.layout.x)):void 0,a=s?Math.min(...e.map(l=>l.layout.y)):void 0,i=(l,c)=>{if(c===void 0)return;const h={};if(s&&(l==="x"||l==="y")){const m=l==="x"?o:a;if(m===void 0)return;const x=Math.max(...e.map(p=>p.layout.x+p.layout.w)),b=Math.max(...e.map(p=>p.layout.y+p.layout.h)),g=x-(o??0),I=b-(a??0);let E=c;l==="x"&&n?E=Math.max(0,Math.min(c,n.cols-g)):l==="y"&&n?E=Math.max(0,Math.min(c,n.rows-I)):E=Math.max(0,c);const v=E-m;e.forEach(p=>{const f=p.layout[l]+v;h[p.id]={layout:{...p.layout,[l]:f}}})}else e.forEach(m=>{let x=c;if(l==="x"&&n)x=Math.max(0,Math.min(c,n.cols-m.layout.w));else if(l==="y"&&n)x=Math.max(0,Math.min(c,n.rows-m.layout.h));else if(l==="w"&&n){const b=n.cols-m.layout.x;x=Math.max(1,Math.min(c,b))}else if(l==="h"&&n){const b=n.rows-m.layout.y;x=Math.max(1,Math.min(c,b))}else l==="w"||l==="h"?x=Math.max(1,c):x=Math.max(0,c);h[m.id]={layout:{...m.layout,[l]:x}}});t(h)};return r.jsx("div",{className:xe.container,children:r.jsxs("div",{className:xe.grid,children:[r.jsxs("div",{className:xe.field,children:[r.jsx("span",{className:xe.label,children:"X"}),r.jsx("div",{className:xe.inputWrapper,children:r.jsx(pe,{value:s?o:Re(e,"layout.x"),onChange:l=>i("x",l),min:0,max:n?n.cols-1:void 0,integer:!0,height:22,placeholder:"-"})})]}),r.jsxs("div",{className:xe.field,children:[r.jsx("span",{className:xe.label,children:"Y"}),r.jsx("div",{className:xe.inputWrapper,children:r.jsx(pe,{value:s?a:Re(e,"layout.y"),onChange:l=>i("y",l),min:0,max:n?n.rows-1:void 0,integer:!0,height:22,placeholder:"-"})})]}),!s&&r.jsxs("div",{className:xe.field,children:[r.jsx("span",{className:xe.label,children:"W"}),r.jsx("div",{className:xe.inputWrapper,children:r.jsx(pe,{value:Re(e,"layout.w"),onChange:l=>i("w",l),min:1,max:n==null?void 0:n.cols,integer:!0,height:22,placeholder:"-"})})]}),!s&&r.jsxs("div",{className:xe.field,children:[r.jsx("span",{className:xe.label,children:"H"}),r.jsx("div",{className:xe.inputWrapper,children:r.jsx(pe,{value:Re(e,"layout.h"),onChange:l=>i("h",l),min:1,max:n==null?void 0:n.rows,integer:!0,height:22,placeholder:"-"})})]})]})})},ni="_container_1h4w8_1",ri="_row_1h4w8_10",oi="_label_1h4w8_16",si="_inputWrapper_1h4w8_25",ze={container:ni,row:ri,label:oi,inputWrapper:si},ii=({selectedBlocks:e,onUpdateBlocks:t})=>{const[n,s]=d.useState(""),o=e[0];d.useEffect(()=>{e.length===1&&o&&s(o.id)},[e,o]);const a=()=>{if(!o)return;const c=o.id,h=n.trim();if(h===c||!h){s(c);return}t({[c]:{id:h}})},i=c=>{s(c??"")},l=c=>{const h={};e.forEach(m=>{h[m.id]={behavior:{...m.behavior,readOnly:!!c}}}),t(h)};return r.jsxs("div",{className:ze.container,children:[e.length===1&&r.jsxs("div",{className:ze.row,children:[r.jsx("span",{className:ze.label,children:"ID"}),r.jsx("div",{className:ze.inputWrapper,children:r.jsx(Qe,{value:n,onChange:i,onBlur:a,placeholder:"IDを入力",height:16})})]}),e.length>0&&r.jsx("div",{className:ze.row,children:r.jsx("div",{className:ze.inputWrapper,children:r.jsx(Ie,{label:"読み取り専用",value:!!Re(e,"behavior.readOnly"),onChange:l})})})]})},ai="_container_wa11y_1",li="_scrollArea_wa11y_18",ci="_section_wa11y_26",ui="_sectionTitle_wa11y_35",di="_subsection_wa11y_47",fi="_subsectionTitle_wa11y_51",hi="_fields_wa11y_59",mi="_emptyState_wa11y_69",de={container:ai,scrollArea:li,section:ci,sectionTitle:ui,subsection:di,subsectionTitle:fi,fields:hi,emptyState:mi},pi="_field_qo0ef_1",vi="_label_qo0ef_7",xi="_mixed_qo0ef_15",bi="_description_qo0ef_22",pt={field:pi,label:vi,mixed:xi,description:bi},br=d.memo(({propertyKey:e,definition:t,selectedBlocks:n,onChange:s})=>{var m;const o=t.Component;if(!o)return null;const a=Re(n,`props.${e}`),c=!n.map(x=>x.props[e]).every(x=>x===void 0)&&a===void 0&&n.length>1,h={value:c?void 0:a!==void 0?a:t.defaultValue,onChange:x=>s(e,x),readOnly:!1,config:{...t.config,placeholder:c?"複数選択中 (値が異なります)":(m=t.config)==null?void 0:m.placeholder}};return r.jsxs("div",{className:pt.field,children:[t.label&&r.jsx("div",{className:pt.label,title:t.description,children:t.label}),r.jsx(o,{...h}),c&&r.jsx("span",{className:pt.mixed,children:"(混在)"}),t.description&&r.jsx("p",{className:pt.description,children:t.description})]})});br.displayName="PropertyField";function gi(e){return e!==!1}const dn=d.memo(({selectedBlocks:e,pluginRegistry:t,onUpdateBlocks:n,gridSize:s,className:o=""})=>{const a=e[0],i=a?t[a.kind]:void 0,l=d.useMemo(()=>{var x;if(e.length===0)return!1;const m=(x=e[0])==null?void 0:x.kind;return e.every(b=>b.kind===m)},[e]),c=d.useMemo(()=>{if(!a||!i)return{};const m={};let x;if(l)x=Object.entries(i.properties);else{const b=e.map(v=>t[v.kind]).filter(v=>v!==void 0);if(b.length===0)return{};const g=b[0];if(!g)return{};const I=new Set(Object.keys(g.properties));x=Array.from(I).filter(v=>b.every(p=>v in p.properties)).map(v=>{const p=i.properties[v];return p?[v,p]:null}).filter(v=>v!==null)}return x.forEach(([b,g])=>{if(!gi(g)||e.length>1&&g.disableInMultiSelection||g.condition&&!g.condition(a.props))return;const I=g.group||"基本";m[I]||(m[I]=[]),g.Component&&m[I].push({key:b,definition:g})}),m},[i,t,e,a,l]),h=(m,x)=>{const b={};e.forEach(g=>{b[g.id]={props:{...g.props,[m]:x}}}),n(b)};return e.length===0?r.jsx("div",{className:`${de.container} ${o}`,children:r.jsxs("div",{className:de.emptyState,children:["ブロックを選択すると",r.jsx("br",{}),"プロパティが表示されます"]})}):r.jsx("div",{className:`${de.container} ${o}`,children:r.jsxs("div",{className:de.scrollArea,children:[r.jsxs("div",{className:de.section,children:[r.jsx("div",{className:de.sectionTitle,children:"配置・サイズ"}),r.jsx(ti,{selectedBlocks:e,onUpdateBlocks:n,gridSize:s})]}),r.jsxs("div",{className:de.section,children:[r.jsx("div",{className:de.sectionTitle,children:"背景"}),r.jsx(Hs,{selectedBlocks:e,onUpdateBlocks:n})]}),r.jsxs("div",{className:de.section,children:[r.jsx("div",{className:de.sectionTitle,children:"枠線"}),r.jsx(Xs,{selectedBlocks:e,onUpdateBlocks:n})]}),i&&Object.keys(c).length>0&&r.jsx("div",{className:de.section,children:Object.entries(c).map(([m,x])=>r.jsxs("div",{className:de.subsection,children:[r.jsx("div",{className:de.subsectionTitle,children:m}),r.jsx("div",{className:de.fields,children:x.map(({key:b,definition:g})=>r.jsx(br,{propertyKey:b,definition:g,selectedBlocks:e,onChange:h},b))})]},m))}),r.jsxs("div",{className:de.section,children:[r.jsx("div",{className:de.sectionTitle,children:"基本設定"}),r.jsx(ii,{selectedBlocks:e,onUpdateBlocks:n})]})]})})});dn.displayName="BlockPropertyPanel";const yi="_container_naj39_3",wi="_paletteItems_naj39_32",_i="_item_naj39_44",Ei="_itemPreview_naj39_77",ji="_itemName_naj39_106",at={container:yi,paletteItems:wi,item:_i,itemPreview:Ei,itemName:ji},fn=({plugins:e,className:t})=>{const[n,s]=d.useState(null),o=d.useCallback((a,i)=>{s({plugin:a,mousePos:i,isOverCanvas:!1});const l=h=>{const m=document.elementFromPoint(h.clientX,h.clientY),x=!!(m!=null&&m.closest('[data-testid="interaction-layer"]'));s(b=>b?{...b,mousePos:{x:h.clientX,y:h.clientY},isOverCanvas:x}:null)},c=()=>{s(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:`${at.container} ${t||""}`,children:r.jsx("div",{className:at.paletteItems,children:e.map(a=>r.jsx(gr,{plugin:a,onDragStart:o},a.kind))})}),n&&!n.isOverCanvas&&r.jsx(yr,{plugin:n.plugin,mousePos:n.mousePos})]})};fn.displayName="PalettePanel";const gr=({plugin:e,onDragStart:t})=>{const n=d.useMemo(()=>Fe(e,{x:0,y:0,w:e.meta.defaultSize.w,h:e.meta.defaultSize.h},{}),[e]),s=d.useMemo(()=>{if(e.validateValue)return e.validateValue(void 0,n.props)},[e,n.props]),o=d.useCallback(a=>{a.preventDefault(),xt.start(e.kind,e.meta.defaultSize),t(e,{x:a.clientX,y:a.clientY});const i=()=>{xt.end(),window.removeEventListener("pointerup",i)};window.addEventListener("pointerup",i)},[e,t]);return r.jsxs("button",{type:"button",onPointerDown:o,className:at.item,"aria-label":`${e.meta.displayName}ブロックを追加`,children:[r.jsx("div",{className:at.itemName,children:e.meta.displayName}),r.jsx("div",{className:at.itemPreview,children:r.jsx(e.Renderer,{id:n.id,props:n.props,value:s,onChange:()=>{},readOnly:!0,mode:ge.FORM})})]})};gr.displayName="PaletteItem";const yr=({plugin:e,mousePos:t})=>{const n=d.useMemo(()=>Fe(e,{x:0,y:0,w:e.meta.defaultSize.w,h:e.meta.defaultSize.h},{}),[e]),s=d.useMemo(()=>{if(e.validateValue)return e.validateValue(void 0,n.props)},[e,n.props]),o={width:e.meta.defaultSize.w*50,height:e.meta.defaultSize.h*50};return r.jsx("div",{"data-testid":"palette-drag-ghost",style:{position:"fixed",left:`${t.x-o.width/2}px`,top:`${t.y-o.height/2}px`,width:`${o.width}px`,height:`${o.height}px`,pointerEvents:"none",opacity:.5,filter:"grayscale(50%)",zIndex:9999,border:"2px dashed #3b82f6",backgroundColor:"#fff"},children:r.jsx(e.Renderer,{id:n.id,props:n.props,value:s,onChange:()=>{},readOnly:!0,mode:ge.FORM})})};yr.displayName="DragGhost";const Ni="_panel_1ekwd_6",Ii="_title_1ekwd_10",Di="_content_1ekwd_22",Ci="_description_1ekwd_29",Ri="_list_1ekwd_35",$i="_item_1ekwd_44",Ti="_dragging_1ekwd_61",Mi="_dragOver_1ekwd_66",ki="_dragHandle_1ekwd_71",Si="_itemInfo_1ekwd_86",Pi="_itemId_1ekwd_93",Ai="_itemMeta_1ekwd_98",Oi="_itemKind_1ekwd_105",Li="_itemActions_1ekwd_113",Gi="_actionButton_1ekwd_118",Bi="_empty_1ekwd_154",oe={panel:Ni,title:Ii,content:Di,description:Ci,list:Ri,item:$i,dragging:Ti,dragOver:Mi,dragHandle:ki,itemInfo:Si,itemId:Pi,itemMeta:Ai,itemKind:Oi,itemActions:Li,actionButton:Gi,empty:Bi},wr=({blocks:e,onBlocksChange:t})=>{const[n,s]=d.useState(null),[o,a]=d.useState(null),i=[...e].reverse(),l=d.useCallback(v=>{const p=e.findIndex(w=>w.id===v);if(p===-1||p===e.length-1)return;const f=[...e],[y]=f.splice(p,1);y&&(f.push(y),t(f))},[e,t]),c=d.useCallback(v=>{const p=e.findIndex(w=>w.id===v);if(p===-1||p===0)return;const f=[...e],[y]=f.splice(p,1);y&&(f.unshift(y),t(f))},[e,t]),h=d.useCallback(v=>{const p=e.findIndex(R=>R.id===v);if(p===-1||p===e.length-1)return;const f=[...e],y=f[p],w=f[p+1];!y||!w||(f[p]=w,f[p+1]=y,t(f))},[e,t]),m=d.useCallback(v=>{const p=e.findIndex(R=>R.id===v);if(p===-1||p===0)return;const f=[...e],y=f[p],w=f[p-1];!y||!w||(f[p]=w,f[p-1]=y,t(f))},[e,t]),x=d.useCallback((v,p)=>{var y;s(p),v.dataTransfer.effectAllowed="move";const f=e.length-1-p;v.currentTarget&&v.dataTransfer.setData("text/plain",((y=e[f])==null?void 0:y.id)||"")},[e]),b=d.useCallback(()=>{s(null),a(null)},[]),g=d.useCallback((v,p)=>{v.preventDefault(),v.dataTransfer.dropEffect="move",!(n===null||n===p)&&a(p)},[n]),I=d.useCallback(()=>{a(null)},[]),E=d.useCallback((v,p)=>{if(v.preventDefault(),n===null||n===p){s(null),a(null);return}const f=e.length-1-n,y=e.length-1-p,w=[...e],[R]=w.splice(f,1);R&&(w.splice(y,0,R),t(w),s(null),a(null))},[e,n,t]);return r.jsxs("div",{className:oe.panel,children:[r.jsx("h3",{className:oe.title,children:"ブロック順序"}),r.jsxs("div",{className:oe.content,children:[r.jsx("p",{className:oe.description,children:"上が最前面、下が最背面"}),r.jsx("ul",{className:oe.list,children:i.map((v,p)=>{const f=e.length-1-p;return r.jsxs("li",{className:`${oe.item} ${n===p?oe.dragging:""} ${o===p?oe.dragOver:""}`,onDragOver:y=>g(y,p),onDragLeave:I,onDrop:y=>E(y,p),children:[r.jsx("button",{type:"button",className:oe.dragHandle,title:"ドラッグして並び替え",draggable:!0,onDragStart:y=>x(y,p),onDragEnd:b,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:oe.itemInfo,children:[r.jsx("div",{className:oe.itemId,children:v.id}),r.jsx("div",{className:oe.itemMeta,children:r.jsx("span",{className:oe.itemKind,children:v.kind})})]}),r.jsxs("div",{className:oe.itemActions,children:[r.jsx("button",{type:"button",className:oe.actionButton,onClick:()=>l(v.id),title:"最前面へ","aria-label":"最前面へ移動",disabled:f===e.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:oe.actionButton,onClick:()=>h(v.id),title:"前面へ","aria-label":"前面へ移動",disabled:f===e.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:oe.actionButton,onClick:()=>m(v.id),title:"背面へ","aria-label":"背面へ移動",disabled:f===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:oe.actionButton,onClick:()=>c(v.id),title:"最背面へ","aria-label":"最背面へ移動",disabled:f===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"})]})})]})]},v.id)})}),e.length===0&&r.jsx("div",{className:oe.empty,children:"ブロックがありません"})]})]})};wr.displayName="BlockOrderPanel";const Fi="_container_1bfk3_6",Vi="_scrollArea_1bfk3_23",Ui="_emptyState_1bfk3_31",Ut={container:Fi,scrollArea:Vi,emptyState:Ui},_r=({children:e,emptyMessage:t,className:n})=>r.jsx("div",{className:`${Ut.container} ${n||""}`,children:e?r.jsx("div",{className:Ut.scrollArea,children:e}):t&&r.jsx("div",{className:Ut.emptyState,children:t})}),Er=({schema:e,onSchemaChange:t})=>{const n=d.useCallback(a=>{t({...e,paper:a})},[e,t]),s=d.useCallback(a=>{t({...e,grid:a})},[e,t]),o=d.useCallback(a=>{t({...e,blocks:a})},[e,t]);return r.jsxs(_r,{children:[r.jsx(Ir,{paper:e.paper,onPaperChange:n}),r.jsx(Nr,{paper:e.paper,onPaperChange:n}),r.jsx(jr,{grid:e.grid,onGridChange:s}),r.jsx(wr,{blocks:e.blocks,onBlocksChange:o})]})};Er.displayName="CanvasPanel";const Wi="_panel_1axyd_6",Yi="_title_1axyd_10",zi="_content_1axyd_22",Ki="_field_1axyd_29",Hi="_horizontal_1axyd_35",Xi="_label_1axyd_41",qi="_gridSizeRow_1axyd_52",Ce={panel:Wi,title:Yi,content:zi,field:Ki,horizontal:Hi,label:Xi,gridSizeRow:qi},jr=({grid:e,onGridChange:t})=>{const n=d.useCallback(o=>{if(!o||o<1||o>100)return;const a=e.cols.length,i=[];if(o>a){i.push(...e.cols);for(let l=a;l<o;l++)i.push({value:1,unit:"fr"})}else i.push(...e.cols.slice(0,o));t({...e,cols:i})},[e,t]),s=d.useCallback(o=>{if(!o||o<1||o>100)return;const a=e.rows.length,i=[];if(o>a){i.push(...e.rows);for(let l=a;l<o;l++)i.push({value:1,unit:"fr"})}else i.push(...e.rows.slice(0,o));t({...e,rows:i})},[e,t]);return r.jsxs("div",{className:Ce.panel,children:[r.jsx("h3",{className:Ce.title,children:"グリッドサイズ"}),r.jsx("div",{className:Ce.content,children:r.jsxs("div",{className:Ce.gridSizeRow,children:[r.jsxs("div",{className:`${Ce.field} ${Ce.horizontal}`,children:[r.jsx("span",{className:Ce.label,children:"列数"}),r.jsx(pe,{value:e.cols.length,onChange:n,min:1,max:100,step:1})]}),r.jsxs("div",{className:`${Ce.field} ${Ce.horizontal}`,children:[r.jsx("span",{className:Ce.label,children:"行数"}),r.jsx(pe,{value:e.rows.length,onChange:s,min:1,max:100,step:1})]})]})})]})};jr.displayName="GridSizePanel";const Ji="_panel_qlcb6_6",Zi="_header_qlcb6_10",Qi="_title_qlcb6_20",ea="_headerActions_qlcb6_29",ta="_content_qlcb6_33",na="_field_qlcb6_37",ra="_horizontal_qlcb6_43",oa="_label_qlcb6_49",sa="_marginsGrid_qlcb6_60",ia="_topMargin_qlcb6_66",aa="_bottomMargin_qlcb6_67",la="_sideMargins_qlcb6_73",re={panel:Ji,header:Zi,title:Qi,headerActions:ea,content:ta,field:na,horizontal:ra,label:oa,marginsGrid:sa,topMargin:ia,bottomMargin:aa,sideMargins:la},Nr=({paper:e,onPaperChange:t})=>{const[n,s]=d.useState(!1),o=d.useCallback(h=>{h!==void 0&&s(h)},[]),a=d.useCallback(h=>{if(!h)return;const m=n?{top:h,right:h,bottom:h,left:h}:{...e.margin,top:h};t({...e,margin:m})},[e,t,n]),i=d.useCallback(h=>{h&&t({...e,margin:{...e.margin,right:h}})},[e,t]),l=d.useCallback(h=>{h&&t({...e,margin:{...e.margin,bottom:h}})},[e,t]),c=d.useCallback(h=>{h&&t({...e,margin:{...e.margin,left:h}})},[e,t]);return r.jsxs("div",{className:re.panel,children:[r.jsxs("div",{className:re.header,children:[r.jsx("h3",{className:re.title,children:"マージン"}),r.jsx("div",{className:re.headerActions,children:r.jsx(Ie,{value:n,onChange:o,label:"全辺を一括設定"})})]}),r.jsx("div",{className:re.content,children:n?r.jsxs("div",{className:`${re.field} ${re.horizontal}`,children:[r.jsx("span",{className:re.label,children:"全辺"}),r.jsx(ce,{value:e.margin.top,onChange:a,allowedUnits:["mm","cm","inch"],min:0,max:1e3})]}):r.jsxs("div",{className:re.marginsGrid,children:[r.jsx("div",{className:`${re.field} ${re.horizontal} ${re.topMargin}`,children:r.jsx(ce,{value:e.margin.top,onChange:a,allowedUnits:["mm","cm","inch"],min:0,max:1e3})}),r.jsxs("div",{className:re.sideMargins,children:[r.jsx("div",{className:`${re.field} ${re.horizontal}`,children:r.jsx(ce,{value:e.margin.left,onChange:c,allowedUnits:["mm","cm","inch"],min:0,max:1e3})}),r.jsx("div",{className:`${re.field} ${re.horizontal}`,children:r.jsx(ce,{value:e.margin.right,onChange:i,allowedUnits:["mm","cm","inch"],min:0,max:1e3})})]}),r.jsx("div",{className:`${re.field} ${re.horizontal} ${re.bottomMargin}`,children:r.jsx(ce,{value:e.margin.bottom,onChange:l,allowedUnits:["mm","cm","inch"],min:0,max:1e3})})]})})]})};Nr.displayName="MarginPanel";const ca="_panel_16d9o_6",ua="_title_16d9o_10",da="_content_16d9o_22",fa="_field_16d9o_29",ha="_horizontal_16d9o_35",ma="_label_16d9o_41",pa="_dimensionsRow_16d9o_52",je={panel:ca,title:ua,content:da,field:fa,horizontal:ha,label:ma,dimensionsRow:pa},Ir=({paper:e,onPaperChange:t})=>{const n=d.useMemo(()=>[{value:Ne.A4,label:"A4 (210 × 297 mm)"},{value:Ne.A3,label:"A3 (297 × 420 mm)"},{value:Ne.B5,label:"B5 (182 × 257 mm)"},{value:Ne.LETTER,label:"Letter (8.5 × 11 inch)"},{value:Ne.LEGAL,label:"Legal (8.5 × 14 inch)"},{value:Ne.CUSTOM,label:"カスタム"}],[]),s=d.useCallback(l=>{if(!l)return;const c=nn[l];t({...e,size:c})},[e,t]),o=d.useCallback(l=>{if(!l)return;const c={...e.size,preset:Ne.CUSTOM,width:l};t({...e,size:c})},[e,t]),a=d.useCallback(l=>{if(!l)return;const c={...e.size,preset:Ne.CUSTOM,height:l};t({...e,size:c})},[e,t]),i=e.size.preset===Ne.CUSTOM;return r.jsxs("div",{className:je.panel,children:[r.jsx("h3",{className:je.title,children:"用紙サイズ"}),r.jsxs("div",{className:je.content,children:[r.jsx("div",{className:je.field,children:r.jsx($e,{value:e.size.preset,options:n,onChange:s})}),i&&r.jsxs("div",{className:je.dimensionsRow,children:[r.jsxs("div",{className:`${je.field} ${je.horizontal}`,children:[r.jsx("span",{className:je.label,children:"幅"}),r.jsx(ce,{value:e.size.width,onChange:o,allowedUnits:["mm","cm","inch"],min:1,max:1e4})]}),r.jsxs("div",{className:`${je.field} ${je.horizontal}`,children:[r.jsx("span",{className:je.label,children:"高さ"}),r.jsx(ce,{value:e.size.height,onChange:a,allowedUnits:["mm","cm","inch"],min:1,max:1e4})]})]})]})]})};Ir.displayName="PaperSizePanel";const va="_section_p4xnx_6",xa="_title_p4xnx_14",ba="_content_p4xnx_26",ga="_buttonGroup_p4xnx_33",ya="_button_p4xnx_33",wa="_error_p4xnx_65",se={section:va,title:xa,content:ba,buttonGroup:ga,button:ya,error:wa},Dr=({schema:e,values:t,onSchemaChange:n,onValuesChange:s})=>{const[o,a]=d.useState(""),i=d.useRef(null),l=d.useRef(null),c=d.useCallback(()=>{try{const f=Jt(e,!0),y=new Blob([f],{type:"application/json"}),w=URL.createObjectURL(y),R=document.createElement("a");R.href=w,R.download="schema.json",R.click(),URL.revokeObjectURL(w),a("")}catch(f){a(`エクスポートエラー: ${f instanceof Error?f.message:String(f)}`)}},[e]),h=d.useCallback(async()=>{try{const f=Jt(e,!0);await navigator.clipboard.writeText(f),a(""),alert("スキーマをクリップボードにコピーしました")}catch(f){a(`クリップボードエラー: ${f instanceof Error?f.message:String(f)}`)}},[e]),m=d.useCallback(()=>{var f;(f=i.current)==null||f.click()},[]),x=d.useCallback(f=>{var R;const y=(R=f.target.files)==null?void 0:R[0];if(!y)return;const w=new FileReader;w.onload=L=>{var $;try{const N=($=L.target)==null?void 0:$.result,S=qt(N);n(S),a(""),alert("スキーマをインポートしました")}catch(N){a(`インポートエラー: ${N instanceof Error?N.message:String(N)}`)}},w.readAsText(y),f.target.value=""},[n]),b=d.useCallback(async()=>{try{const f=await navigator.clipboard.readText(),y=qt(f);n(y),a(""),alert("スキーマをインポートしました")}catch(f){a(`インポートエラー: ${f instanceof Error?f.message:String(f)}`)}},[n]),g=d.useCallback(()=>{try{const f=Qt(t,!0),y=new Blob([f],{type:"application/json"}),w=URL.createObjectURL(y),R=document.createElement("a");R.href=w,R.download="values.json",R.click(),URL.revokeObjectURL(w),a("")}catch(f){a(`エクスポートエラー: ${f instanceof Error?f.message:String(f)}`)}},[t]),I=d.useCallback(async()=>{try{const f=Qt(t,!0);await navigator.clipboard.writeText(f),a(""),alert("値をクリップボードにコピーしました")}catch(f){a(`クリップボードエラー: ${f instanceof Error?f.message:String(f)}`)}},[t]),E=d.useCallback(()=>{var f;(f=l.current)==null||f.click()},[]),v=d.useCallback(f=>{var R;const y=(R=f.target.files)==null?void 0:R[0];if(!y)return;const w=new FileReader;w.onload=L=>{var $;try{const N=($=L.target)==null?void 0:$.result,S=Zt(N);s(S),a(""),alert("値をインポートしました")}catch(N){a(`インポートエラー: ${N instanceof Error?N.message:String(N)}`)}},w.readAsText(y),f.target.value=""},[s]),p=d.useCallback(async()=>{try{const f=await navigator.clipboard.readText(),y=Zt(f);s(y),a(""),alert("値をインポートしました")}catch(f){a(`インポートエラー: ${f instanceof Error?f.message:String(f)}`)}},[s]);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:se.section,children:[r.jsx("h3",{className:se.title,children:"スキーマ"}),r.jsxs("div",{className:se.content,children:[r.jsxs("div",{className:se.buttonGroup,children:[r.jsx("button",{type:"button",className:se.button,onClick:c,children:"📥 ファイルにエクスポート"}),r.jsx("button",{type:"button",className:se.button,onClick:h,children:"📋 クリップボードにコピー"})]}),r.jsxs("div",{className:se.buttonGroup,children:[r.jsx("button",{type:"button",className:se.button,onClick:m,children:"📤 ファイルからインポート"}),r.jsx("button",{type:"button",className:se.button,onClick:b,children:"📋 クリップボードからペースト"})]}),r.jsx("input",{ref:i,type:"file",accept:".json",style:{display:"none"},onChange:x})]})]}),r.jsxs("div",{className:se.section,children:[r.jsx("h3",{className:se.title,children:"値"}),r.jsxs("div",{className:se.content,children:[r.jsxs("div",{className:se.buttonGroup,children:[r.jsx("button",{type:"button",className:se.button,onClick:g,children:"📥 ファイルにエクスポート"}),r.jsx("button",{type:"button",className:se.button,onClick:I,children:"📋 クリップボードにコピー"})]}),r.jsxs("div",{className:se.buttonGroup,children:[r.jsx("button",{type:"button",className:se.button,onClick:E,children:"📤 ファイルからインポート"}),r.jsx("button",{type:"button",className:se.button,onClick:p,children:"📋 クリップボードからペースト"})]}),r.jsx("input",{ref:l,type:"file",accept:".json",style:{display:"none"},onChange:v})]})]}),o&&r.jsx("div",{className:se.error,role:"alert",children:o})]})};Dr.displayName="ImportExportPanel";const Cr=({schema:e,values:t,onSchemaChange:n,onValuesChange:s})=>r.jsx(_r,{children:r.jsx(Dr,{schema:e,values:t,onSchemaChange:n,onValuesChange:s})});Cr.displayName="OtherPanel";const _a="_container_rt0ql_3",Ea="_tabHeader_rt0ql_14",ja="_tabContent_rt0ql_21",it={container:_a,tabHeader:Ea,tabContent:ja},Rr=({blocks:e,selectedBlockIds:t,pluginRegistry:n,onUpdateBlocks:s,schema:o,values:a,onSchemaChange:i,onValuesChange:l,gridSize:c,className:h})=>{const m=d.useMemo(()=>Object.values(n),[n]),x=d.useMemo(()=>e.filter(g=>t.includes(g.id)),[e,t]),b=t.length>0;return r.jsx("div",{className:`${it.container} ${h||""}`,children:r.jsxs(en,{defaultValue:"block",variant:"default",children:[r.jsxs(tn,{className:it.tabHeader,children:[r.jsx(Me,{value:"block",children:"ブロック"}),r.jsx(Me,{value:"canvas",children:"キャンバス"}),r.jsx(Me,{value:"other",children:"その他"})]}),r.jsx(ke,{value:"block",className:it.tabContent,children:b?r.jsx(dn,{selectedBlocks:x,pluginRegistry:n,onUpdateBlocks:s,gridSize:c}):r.jsx(fn,{plugins:m})}),r.jsx(ke,{value:"canvas",className:it.tabContent,children:r.jsx(Er,{schema:o,onSchemaChange:i})}),r.jsx(ke,{value:"other",className:it.tabContent,children:r.jsx(Cr,{schema:o,values:a,onSchemaChange:i,onValuesChange:l})})]})})};Rr.displayName="Sidebar";exports.ACTUAL_UNITS=Lo;exports.ALL_UNITS=Oo;exports.BLOCK_SUB_INDEX=we;exports.BORDER_UNITS=Gn;exports.BlockChangeType=be;exports.BlockPropertyPanel=dn;exports.Border=et;exports.BorderOverlay=Xn;exports.BorderRenderer=Ve;exports.Checkbox=Ie;exports.ColorPicker=ct;exports.DEFAULT_GRID=Wn;exports.DEFAULT_PAPER=Kn;exports.DEFAULT_PAPER_MARGIN=zn;exports.DEFAULT_PAPER_SIZES=nn;exports.DEFAULT_SCHEMA=Zo;exports.DimensionInput=ce;exports.FONT_UNITS=Bn;exports.GRID_UNITS=Bo;exports.GridCanvas=qn;exports.GridLayer=Nt;exports.GridOverlay=er;exports.HorizontalAlign=He;exports.ImageObjectFit=Ae;exports.LineType=ye;exports.MarginOverlay=tr;exports.MultilineWhiteSpace=Je;exports.MultilineWordWrap=qe;exports.NoteEdit=an;exports.NoteEditor=xr;exports.NoteForm=cn;exports.NoteMode=ge;exports.NoteView=un;exports.NumberInput=pe;exports.PADDING_UNITS=Ke;exports.PAPER_UNITS=Go;exports.PalettePanel=fn;exports.PaperSizePreset=Ne;exports.SIZE_UNITS=Wt;exports.Select=$e;exports.Sidebar=Rr;exports.Tabs=en;exports.TabsContent=ke;exports.TabsList=tn;exports.TabsTrigger=Me;exports.TextInput=Qe;exports.ValidationSeverity=Hn;exports.VerticalAlign=Xe;exports.Z_INDEX=F;exports.alignmentDefinition=Pn;exports.assertFinite=Ho;exports.assertInteger=jt;exports.assertNonNegative=Be;exports.assertPositive=fe;exports.assertRange=Yn;exports.binarySearch=vt;exports.calculateGridResize=Kt;exports.createBlock=Fe;exports.createBlockId=Un;exports.createInitialProps=Vn;exports.deserializeSchema=qt;exports.deserializeValues=Zt;exports.dimensionToString=Zn;exports.dimensionsToStrings=us;exports.distributeRemainder=rr;exports.findGridIndex=Xt;exports.fontStyleDefinition=Vo;exports.getBlockContainerStyle=on;exports.getBlockZIndex=Sn;exports.getMaxBlockCount=ro;exports.getMaxStep=Ht;exports.getStrokeDasharray=Ze;exports.getSubZIndex=lt;exports.globalDragStore=xt;exports.gridToMms=gt;exports.gridToPxs=$s;exports.imageDefinition=Uo;exports.mmsToPxs=yt;exports.multilineDefinition=Wo;exports.paddingDefinition=Fn;exports.placeholderDefinition=Yo;exports.removeUndefinedProps=wt;exports.serializeSchema=Jt;exports.serializeValues=Qt;exports.sizeDefinition=zo;exports.stringToDimension=Jn;exports.stringsToDimensions=ss;exports.toMm=J;exports.toPx=W;exports.universalProperties=Fo;exports.validateSchema=or;exports.validateValues=ir;exports.validationDefinition=Ko;
30
+ <%s key={someKey} {...props} />`,At,Ge,eo,Ge),jn[Ge+At]=!0}}return u===o?Xr(ne):Hr(ne),ne}}function qr(u,_,C){return Nn(u,_,C,!0)}function Jr(u,_,C){return Nn(u,_,C,!1)}var Zr=Jr,Qr=qr;st.Fragment=o,st.jsx=Zr,st.jsxs=Qr})()),st}var Cn;function io(){return Cn||(Cn=1,process.env.NODE_ENV==="production"?ht.exports=oo():ht.exports=so()),ht.exports}var r=io();const q=96,Ve=d.memo(({width:e,height:t,border:n,dpi:o=q,className:s=""})=>n.hasAnyBorder?r.jsxs("svg",{width:e,height:t,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(e,o)}),n.right&&r.jsx("line",{...n.getRightSVGProps(e,t,o)}),n.bottom&&r.jsx("line",{...n.getBottomSVGProps(e,t,o)}),n.left&&r.jsx("line",{...n.getLeftSVGProps(t,o)})]}):null);Ve.displayName="BorderRenderer";const F={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},we={BG:10,CONTENT:50,GUIDE:70,BORDER:80};function kn(e){const t=F.BLOCK_LAYER_MIN+e*F.BLOCK_LAYER_STEP;return t>=F.BLOCK_LAYER_MAX?F.BLOCK_LAYER_MAX:t}function lt(e,t){const n=Math.min(Math.max(0,t),F.BLOCK_LAYER_STEP-1);return e+n}function ao(){return Math.floor((F.BLOCK_LAYER_MAX-F.BLOCK_LAYER_MIN)/F.BLOCK_LAYER_STEP)}var He=(e=>(e.left="flex-start",e.center="center",e.right="flex-end",e))(He||{}),Xe=(e=>(e.top="flex-start",e.center="center",e.bottom="flex-end",e))(Xe||{});const lo="_container_1mr3i_5",co="_select_1mr3i_11",uo="_placeholderOverlay_1mr3i_44",Lt={container:lo,select:co,placeholderOverlay:uo},$e=e=>{const{value:t,onChange:n,readOnly:o=!1,config:s}=e,a=e.options??(s==null?void 0:s.options)??[],i=e.placeholder??(s==null?void 0:s.placeholder)??"選択してください",l=e.width??(s==null?void 0:s.width),c=e.height??(s==null?void 0:s.height),h=d.useCallback(N=>{const E=N.target.value;if(E==="")n(void 0);else{const m=a.find(v=>String(v.value)===E);n(m?m.value:E)}},[n,a]),p=t??"",x=t!==void 0&&t!=="",b={};l!==void 0?b.width=`${l}px`:b.width="100%";const g={width:"100%",height:c?`${c}px`:void 0};return r.jsxs("div",{className:Lt.container,style:b,children:[!x&&r.jsx("input",{className:Lt.placeholderOverlay,style:g,readOnly:!0,placeholder:i}),r.jsx("select",{className:Lt.select,style:g,value:p,onChange:h,disabled:o,children:a.map(N=>r.jsx("option",{value:String(N.value),children:N.label},String(N.value)))})]})};$e.displayName="Select";const Sn={justifyContent:{defaultValue:He.left,label:"水平方向の配置",group:"配置",description:"ブロック内のコンテンツの水平方向の配置を設定します。",Component:$e,config:{options:[{label:"左揃え",value:He.left},{label:"中央揃え",value:He.center},{label:"右揃え",value:He.right}]}},alignItems:{defaultValue:Xe.center,label:"垂直方向の配置",group:"配置",description:"ブロック内のコンテンツの垂直方向の配置を設定します。",Component:$e,config:{options:[{label:"上揃え",value:Xe.top},{label:"中央揃え",value:Xe.center},{label:"下揃え",value:Xe.bottom}]}}},fo="_container_1tnp6_5",ho="_input_1tnp6_13",mo="_label_1tnp6_29",Gt={container:fo,input:ho,label:mo},Ie=({value:e,onChange:t,readOnly:n=!1,label:o,config:s})=>{const a=o??(s==null?void 0:s.label),i=d.useCallback(l=>{t(l.target.checked)},[t]);return r.jsxs("label",{className:Gt.container,children:[r.jsx("input",{type:"checkbox",className:Gt.input,checked:!!e,onChange:i,disabled:n}),a&&r.jsx("span",{className:Gt.label,children:a})]})};Ie.displayName="Checkbox";const po="_container_qbvob_5",vo="_colorButton_qbvob_13",xo="_textInputWrapper_qbvob_40",bo="_textInputPrefix_qbvob_62",go="_textInput_qbvob_40",yo="_popover_qbvob_125",wo="_palette_qbvob_141",_o="_paletteButton_qbvob_148",Eo="_selected_qbvob_171",jo="_transparentPaletteButton_qbvob_177",No="_rgbaInputs_qbvob_183",Io="_rgbaInputGroup_qbvob_190",Do="_rgbaLabel_qbvob_205",ie={container:po,colorButton:vo,textInputWrapper:xo,textInputPrefix:bo,textInput:go,popover:yo,palette:wo,paletteButton:_o,selected:Eo,transparentPaletteButton:jo,rgbaInputs:No,rgbaInputGroup:Io,rgbaLabel:Do};function Rn(e){if(!e)return null;const t=e.match(/^#([0-9a-f]{6}|[0-9a-f]{8})$/i);if(t&&typeof t[1]=="string"){const o=t[1],s=Number.parseInt(o.slice(0,2),16),a=Number.parseInt(o.slice(2,4),16),i=Number.parseInt(o.slice(4,6),16),l=o.length===8?Number.parseInt(o.slice(6,8),16)/255:1;return{r:s,g:a,b:i,a:l}}const n=e.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),a=Number.parseInt(n[3]??"",10),i=n[4]?Number.parseFloat(n[4]):1;return{r:o,g:s,b:a,a:i}}return null}function Co(e){const{r:t,g:n,b:o,a:s}=e;if(s===0)return;const a=t.toString(16).padStart(2,"0"),i=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`#${a}${i}${l}${c}`}return`#${a}${i}${l}`}const Ro=[{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"}],An=({onColorSelect:e,selectedColor:t,readOnly:n=!1})=>r.jsx("div",{className:ie.palette,children:Ro.map((o,s)=>{const a=o.value===void 0,i=o.value===t,l=a?{}:{backgroundColor:o.value};return r.jsx("button",{type:"button",className:`${ie.paletteButton} ${a?ie.transparentPaletteButton:""} ${i?ie.selected:""}`,onClick:()=>e(o.value),disabled:n,title:o.label,"aria-label":o.label,style:l},o.value??`undefined-${s}`)})});An.displayName="ColorPalette";const $o="_input_14n56_5",To={input:$o},pe=({value:e,onChange:t,readOnly:n=!1,min:o,max:s,step:a,integer:i,placeholder:l,width:c,height:h,config:p,onBlur:x})=>{const b=o??(p==null?void 0:p.min)??1,g=s??(p==null?void 0:p.max),N=a??(p==null?void 0:p.step)??1,E=i??(p==null?void 0:p.integer)??!1,m=l??(p==null?void 0:p.placeholder),v=c??(p==null?void 0:p.width),f=h??(p==null?void 0:p.height),y=d.useCallback(R=>{const L=R.target.value;if(L===""){t(void 0);return}let $=Number.parseFloat(L);Number.isNaN($)||(E&&($=Math.round($)),b!==void 0&&$<b&&($=b),g!==void 0&&$>g&&($=g),t($))},[t,b,g,E]),w={};return v!==void 0&&(w.width=`${v}px`),f!==void 0&&(w.height=`${f}px`,w.paddingTop=0,w.paddingBottom=0),r.jsx("input",{type:"number",className:To.input,style:w,value:e??"",onChange:y,onBlur:x,disabled:n,min:b,max:g,step:N,placeholder:m})};pe.displayName="NumberInput";const On=({rgba:e,onChange:t,readOnly:n=!1})=>r.jsxs("div",{className:ie.rgbaInputs,children:[r.jsxs("div",{className:ie.rgbaInputGroup,children:[r.jsx("span",{className:ie.rgbaLabel,children:"R"}),r.jsx(pe,{value:e.r,onChange:o=>t("r",o),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),r.jsxs("div",{className:ie.rgbaInputGroup,children:[r.jsx("span",{className:ie.rgbaLabel,children:"G"}),r.jsx(pe,{value:e.g,onChange:o=>t("g",o),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),r.jsxs("div",{className:ie.rgbaInputGroup,children:[r.jsx("span",{className:ie.rgbaLabel,children:"B"}),r.jsx(pe,{value:e.b,onChange:o=>t("b",o),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),r.jsxs("div",{className:ie.rgbaInputGroup,children:[r.jsx("span",{className:ie.rgbaLabel,children:"A"}),r.jsx(pe,{value:Math.round(e.a*100),onChange:o=>t("a",o!==void 0?o/100:void 0),min:0,max:100,step:1,integer:!0,width:48,readOnly:n})]})]});On.displayName="RGBAInputs";const Ln=({isOpen:e,onClose:t,rgba:n,onRgbaChange:o,onColorSelect:s,selectedColor:a,readOnly:i=!1})=>{const l=d.useRef(null);return d.useEffect(()=>{if(!e)return;const c=h=>{l.current&&!l.current.contains(h.target)&&t()};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[e,t]),e?r.jsxs("div",{className:ie.popover,ref:l,style:{zIndex:F.DROPDOWN},children:[r.jsx(An,{onColorSelect:s,selectedColor:a,readOnly:i}),r.jsx(On,{rgba:n,onChange:o,readOnly:i})]}):null};Ln.displayName="ColorPickerPopover";const ct=({value:e,onChange:t,readOnly:n=!1,showTextInput:o=!0,allowUndefined:s,placeholder:a,width:i,height:l,config:c})=>{const h=s??(c==null?void 0:c.allowUndefined)??!0,p=a??(h?"未設定":"#000000"),x=i??(c==null?void 0:c.width),b=l??(c==null?void 0:c.height),[g,N]=d.useState(!1),E=d.useRef(null),[m,v]=d.useState(()=>Rn(e)??{r:0,g:0,b:0,a:1});d.useEffect(()=>{const j=Rn(e);j&&v(j)},[e]);const f=d.useCallback(()=>{n||N(j=>!j)},[n]),[y,w]=d.useState(e?e.replace(/^#/,""):"");d.useEffect(()=>{w(e?e.replace(/^#/,""):"")},[e]);const R=d.useCallback(j=>{const D=j.target.value;/^[0-9A-Fa-f]*$/.test(D)&&w(D)},[]),L=d.useCallback(j=>{if(j===""&&h){t(void 0);return}/^[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$/.test(j)?t(`#${j}`):w(e?e.replace(/^#/,""):"")},[t,h,e]),$=d.useCallback(j=>{L(j.target.value)},[L]),I=d.useCallback(j=>{j.key==="Enter"&&(j.preventDefault(),L(j.currentTarget.value),j.currentTarget.blur())},[L]),k=d.useCallback(j=>{t(j)},[t]),M=d.useCallback((j,D)=>{if(D===void 0)return;const P={...m,[j]:D};v(P),t(Co(P))},[m,t]),G=e??"未設定",T={};e&&(T.background=e);const S={};return x!==void 0?S.width=`${x}px`:S.width="100%",b!==void 0&&(S.height=`${b}px`),r.jsxs("div",{className:ie.container,style:S,ref:E,children:[r.jsx("button",{type:"button",className:ie.colorButton,onClick:f,disabled:n,title:G,"aria-label":"カラーピッカーを開く",style:T}),o&&r.jsxs("div",{className:ie.textInputWrapper,children:[r.jsx("span",{className:ie.textInputPrefix,children:"#"}),r.jsx("input",{type:"text",className:ie.textInput,value:y,onChange:R,onKeyDown:I,onBlur:$,disabled:n,placeholder:p,maxLength:8})]}),r.jsx(Ln,{isOpen:g,onClose:()=>N(!1),rgba:m,onRgbaChange:M,onColorSelect:k,selectedColor:e,readOnly:n})]})};ct.displayName="ColorPicker";const Mo="_container_1n9lj_5",Po="_valueInput_1n9lj_23",ko="_unitSelect_1n9lj_45",Bt={container:Mo,valueInput:Po,unitSelect:ko},ce=e=>{const{value:t,onChange:n,readOnly:o=!1,config:s}=e,a=e.allowedUnits??(s==null?void 0:s.allowedUnits),i=e.min??(s==null?void 0:s.min),l=e.max??(s==null?void 0:s.max),c=e.step??(s==null?void 0:s.step)??1,h=e.placeholder??(s==null?void 0:s.placeholder),p=e.width??(s==null?void 0:s.width),x=e.height??(s==null?void 0:s.height),b=(t==null?void 0:t.unit)??(a==null?void 0:a[0]),g=d.useCallback(f=>{const y=f.target.value;if(y==="")return;let w=Number.parseFloat(y);if(Number.isNaN(w))return;const R=i??1;w<R&&(w=R),l!==void 0&&w>l&&(w=l),n({value:w,unit:(t==null?void 0:t.unit)??b})},[t,n,b,i,l]),N=d.useCallback(f=>{const y=f.target.value;n({value:(t==null?void 0:t.value)??0,unit:y})},[t,n]),E=(t==null?void 0:t.value)??"",m=(t==null?void 0:t.unit)??b??"",v={};return p!==void 0?v.width=`${p}px`:v.width="100%",x!==void 0&&(v.height=`${x}px`),r.jsxs("div",{className:Bt.container,style:v,children:[r.jsx("input",{type:"number",className:Bt.valueInput,value:E,onChange:g,placeholder:h,min:i??1,max:l,step:c,readOnly:o,disabled:o}),r.jsx("select",{className:Bt.unitSelect,value:m,onChange:N,disabled:o||!a||a.length<=1,children:a?a.map(f=>r.jsx("option",{value:f,children:f},f)):r.jsx("option",{value:m,children:m})})]})},So="_root_qs6t8_3",Ao="_list_qs6t8_11",Oo="_trigger_qs6t8_26",Lo="_content_qs6t8_71",_t={root:So,list:Ao,trigger:Oo,content:Lo},Et=d.createContext(void 0),tn=({defaultValue:e,value:t,onValueChange:n,children:o,variant:s="default",className:a=""})=>{const[i,l]=d.useState(e),c=t??i,h=p=>{l(p),n==null||n(p)};return r.jsx(Et.Provider,{value:{value:c,onChange:h,variant:s},children:r.jsx("div",{className:`${_t.root} ${a}`,"data-variant":s,children:o})})},nn=({children:e,className:t="",width:n,height:o,style:s})=>{const a=d.useContext(Et);if(!a)throw new Error("TabsList must be used within a Tabs component");const{variant:i}=a,l={...s};return n!==void 0&&(l.width=`${n}px`),o!==void 0&&(l.height=`${o}px`),r.jsx("div",{className:`${_t.list} ${t}`,"data-variant":i,style:l,children:e})},Me=({value:e,children:t,className:n="",disabled:o=!1,width:s,height:a,style:i})=>{const l=d.useContext(Et);if(!l)throw new Error("TabsTrigger must be used within a Tabs component");const{value:c,onChange:h,variant:p}=l,x=c===e,b={...i};return s!==void 0&&(b.width=`${s}px`),a!==void 0&&(b.height=`${a}px`),r.jsx("button",{className:`${_t.trigger} ${n}`,"data-state":x?"active":"inactive","data-variant":p,onClick:()=>h(e),disabled:o,type:"button",style:b,children:t})},Pe=({value:e,children:t,className:n=""})=>{const o=d.useContext(Et);if(!o)throw new Error("TabsContent must be used within a Tabs component");const{value:s}=o;return s!==e?null:r.jsx("div",{className:`${_t.content} ${n}`,children:t})},Go="_input_9unrj_5",Bo={input:Go},Qe=({value:e,onChange:t,readOnly:n=!1,placeholder:o,maxLength:s,multiline:a,rows:i,width:l,height:c,config:h,onBlur:p})=>{const x=o??(h==null?void 0:h.placeholder),b=s??(h==null?void 0:h.maxLength),g=a??(h==null?void 0:h.multiline)??!1,N=i??(h==null?void 0:h.rows)??3,E=d.useCallback(f=>{const y=f.target.value;t(y)},[t]),m={};l!==void 0?m.width=`${l}px`:m.width="100%",c!==void 0&&(m.height=`${c}px`);const v={className:Bo.input,style:m,value:e??"",onChange:E,disabled:n,placeholder:x,maxLength:b};return g?r.jsx("textarea",{...v,rows:N}):r.jsx("input",{...v,type:"text",onBlur:p})};Qe.displayName="TextInput";const Fo=["mm","cm","fr","inch","pt","px","%"],Vo=["mm","cm","pt","inch","px"],Uo=["mm","cm","inch"],Wo=["mm","cm","fr","inch","pt","px"],Gn=["px","pt","mm"],Bn=["px","pt","mm"],Ke=["mm","pt","px","%"],Wt=["mm","cm","inch","pt","px","%"],Fn={isIndividual:{defaultValue:!1,label:"個別に設定",group:"余白",Component:Ie,description:"上下左右の余白を個別に設定します"},all:{defaultValue:{value:10,unit:"px"},label:"全方向",group:"余白",Component:ce,config:{allowedUnits:Ke,min:0},condition:e=>!e.isIndividual},top:{defaultValue:{value:10,unit:"px"},label:"上",group:"余白",Component:ce,config:{allowedUnits:Ke,min:0},condition:e=>e.isIndividual===!0},right:{defaultValue:{value:10,unit:"px"},label:"右",group:"余白",Component:ce,config:{allowedUnits:Ke,min:0},condition:e=>e.isIndividual===!0},bottom:{defaultValue:{value:10,unit:"px"},label:"下",group:"余白",Component:ce,config:{allowedUnits:Ke,min:0},condition:e=>e.isIndividual===!0},left:{defaultValue:{value:10,unit:"px"},label:"左",group:"余白",Component:ce,config:{allowedUnits:Ke,min:0},condition:e=>e.isIndividual===!0}},Yo={...Sn,...Fn},zo={fontSize:{defaultValue:{value:14,unit:"pt"},label:"フォントサイズ",group:"フォント",description:"テキストのフォントサイズを設定します",Component:ce,config:{allowedUnits:Bn,min:1,step:1}},fontFamily:{defaultValue:"sans-serif",label:"フォント",group:"フォント",Component:$e,config:{placeholder:"フォントを選択",options:[{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"}]}},color:{defaultValue:void 0,label:"文字色",group:"フォント",Component:ct,config:{allowUndefined:!0}},fontWeight:{defaultValue:!1,label:"太字",group:"フォント",description:"テキストを太字にします",Component:Ie},italic:{defaultValue:!1,label:"斜体",group:"フォント",description:"テキストを斜体にします",Component:Ie},underline:{defaultValue:!1,label:"下線",group:"フォント",description:"テキストに下線を引きます",Component:Ie},lineThrough:{defaultValue:!1,label:"取り消し線",group:"フォント",description:"テキストに取り消し線を引きます",Component:Ie},lineHeight:{defaultValue:1.2,label:"行の高さ",group:"フォント",description:"行の高さを設定します(1.0〜3.0)",Component:pe,config:{min:1,max:3,step:.1}}};var Ae=(e=>(e.Contain="contain",e.Cover="cover",e.Fill="fill",e.None="none",e.ScaleDown="scale-down",e))(Ae||{});const Ko={objectFit:{defaultValue:Ae.Contain,label:"表示方法",group:"画像",description:"画像のサイズが枠と合わない場合の表示方法を設定します",Component:$e,config:{options:[{label:"全体を表示",value:Ae.Contain},{label:"枠を埋める/切り抜き",value:Ae.Cover},{label:"引き伸ばす/縮小する",value:Ae.Fill},{label:"元のサイズ",value:Ae.None},{label:"縮小のみ",value:Ae.ScaleDown}]}},alt:{defaultValue:"",label:"代替テキスト",group:"画像",description:"画像が表示できない場合に表示されるテキスト",Component:Qe,config:{placeholder:"画像の説明"}}};var qe=(e=>(e.Normal="normal",e.BreakWord="break-word",e.BreakAll="break-all",e))(qe||{}),Je=(e=>(e.Normal="normal",e.NoWrap="nowrap",e.Pre="pre",e.PreWrap="pre-wrap",e.PreLine="pre-line",e))(Je||{});const Ho={multiline:{defaultValue:!1,label:"複数行モード",group:"設定",Component:Ie,config:{label:"有効にする"}},wordWrap:{defaultValue:qe.Normal,label:"単語の折り返し",group:"設定",Component:$e,config:{options:[{label:"通常",value:qe.Normal},{label:"単語で改行",value:qe.BreakWord},{label:"強制改行",value:qe.BreakAll}]},condition:e=>e.multiline===!0},whiteSpace:{defaultValue:Je.Normal,label:"空白文字の扱い",group:"設定",Component:$e,config:{options:[{label:"通常",value:Je.Normal},{label:"折り返しなし",value:Je.NoWrap},{label:"そのまま表示",value:Je.Pre}]},condition:e=>e.multiline===!0}},Xo={placeholder:{defaultValue:void 0,label:"プレースホルダー",group:"設定",description:"入力欄に表示するプレースホルダーテキストを設定します",Component:Qe,config:{placeholder:"例: テキストを入力してください"}}},qo={width:{defaultValue:void 0,label:"幅",group:"サイズ",description:"要素の幅を設定します",Component:ce,config:{min:0,allowedUnits:Wt,placeholder:"auto"}},height:{defaultValue:void 0,label:"高さ",group:"サイズ",description:"要素の高さを設定します",Component:ce,config:{min:0,allowedUnits:Wt,placeholder:"auto"}}},Vn=e=>{const t={};return Object.entries(e.properties).forEach(([n,o])=>{o!==!1&&typeof o=="object"&&o!==null&&"defaultValue"in o&&(t[n]=o.defaultValue)}),t};function Un(e){const t=Date.now(),n=Math.random().toString(36).slice(2);return`${e}_${t}_${n}`}function Fe(e,t,n){const o=Vn(e);return{id:Un(e.kind),kind:e.kind,layout:{x:t.x,y:t.y,w:t.w,h:t.h},style:{},behavior:{},props:{...o,...n}}}const Jo={required:{defaultValue:!1,label:"必須項目",group:"バリデーション",description:"この項目を必須入力にします",Component:Ie,config:{label:"必須にする"}},minLength:{defaultValue:void 0,label:"最小文字数",group:"バリデーション",description:"入力可能な最小文字数を設定します",Component:pe,config:{min:0,integer:!0,placeholder:"制限なし"}},maxLength:{defaultValue:void 0,label:"最大文字数",group:"バリデーション",description:"入力可能な最大文字数を設定します",Component:pe,config:{min:0,integer:!0,placeholder:"制限なし"}},pattern:{defaultValue:void 0,label:"入力パターン (正規表現)",group:"バリデーション",description:"入力値を検証する正規表現パターンを設定します",Component:Qe,config:{placeholder:"例: ^[0-9]+$"},disableInMultiSelection:!0}};var be=(e=>(e.ADD="add",e.UPDATE="update",e.DELETE="delete",e.MOVE="move",e.RESIZE="resize",e.DUPLICATE="duplicate",e.PASTE="paste",e))(be||{});const Wn={cols:Array.from({length:12}).map(()=>({value:1,unit:"fr"})),rows:Array.from({length:16}).map(()=>({value:1,unit:"fr"}))};var ye=(e=>(e.SOLID="solid",e.DASHED="dashed",e.DOTTED="dotted",e))(ye||{});function fe(e,t){if(e<=0){const n=t??"Value";throw new Error(`${n} must be positive (> 0): got ${e}`)}}function Be(e,t){if(e<0){const n=t??"Value";throw new Error(`${n} must be non-negative (>= 0): got ${e}`)}}function Yn(e,t,n,o){if(e<t||e>n){const s=o??"Value";throw new Error(`${s} must be between ${t} and ${n}: got ${e}`)}}function jt(e,t){if(!Number.isInteger(e)){const n=t??"Value";throw new Error(`${n} must be an integer: got ${e}`)}}function Zo(e,t){if(!Number.isFinite(e)){const n=t??"Value";throw new Error(`${n} must be a finite number: got ${e}`)}}const Qo=25.4,es=2.54,ts=72,W={_assertDpi(e){fe(e,"DPI"),jt(e,"DPI")},fromMm(e,t=q){return W._assertDpi(t),Be(e,"Millimeter value"),e*t/Qo},fromCm(e,t=q){return W._assertDpi(t),Be(e,"Centimeter value"),e*t/es},fromInch(e,t=q){return W._assertDpi(t),Be(e,"Inch value"),e*t},fromPt(e,t=q){return W._assertDpi(t),Be(e,"Point value"),e*t/ts},fromPx(e,t=q){return W._assertDpi(t),Be(e,"Pixel value"),e*t/q},fromDim(e,t=q,n){switch(W._assertDpi(t),Be(e.value,"Dimension value"),e.unit){case"mm":return W.fromMm(e.value,t);case"cm":return W.fromCm(e.value,t);case"inch":return W.fromInch(e.value,t);case"pt":return W.fromPt(e.value,t);case"px":return W.fromPx(e.value,t);case"%":if(n===void 0)throw new Error("Base size must be defined for percentage values.");return e.value/100*n;case"fr":throw new Error(`Cannot convert ${e.unit} to px. Use physical units only.`);default:{const o=e.unit;throw new Error(`Unsupported unit: ${o}`)}}}},Ze=e=>{if(!(e!=null&&e.width)||!(e!=null&&e.type))return;const t=e.width.value;if(t!==0){if(e.type===ye.DASHED)return`${t*4} ${t*2}`;if(e.type===ye.DOTTED)return`${t*1} ${t*2}`}};class et{constructor(t){this.style=t}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(t,n=q){const o=this.top;return o?{x1:0,y1:0,x2:t,y2:0,stroke:o.color,strokeWidth:W.fromDim(o.width,n),strokeDasharray:Ze(o),vectorEffect:"non-scaling-stroke","data-edge":"top"}:null}getRightSVGProps(t,n,o=q){const s=this.right;return s?{x1:t,y1:0,x2:t,y2:n,stroke:s.color,strokeWidth:W.fromDim(s.width,o),strokeDasharray:Ze(s),vectorEffect:"non-scaling-stroke","data-edge":"right"}:null}getBottomSVGProps(t,n,o=q){const s=this.bottom;return s?{x1:0,y1:n,x2:t,y2:n,stroke:s.color,strokeWidth:W.fromDim(s.width,o),strokeDasharray:Ze(s),vectorEffect:"non-scaling-stroke","data-edge":"bottom"}:null}getLeftSVGProps(t,n=q){const o=this.left;return o?{x1:0,y1:0,x2:0,y2:t,stroke:o.color,strokeWidth:W.fromDim(o.width,n),strokeDasharray:Ze(o),vectorEffect:"non-scaling-stroke","data-edge":"left"}:null}}var ge=(e=>(e.FORM="Form",e.EDIT="Edit",e.VIEW="View",e))(ge||{}),Ne=(e=>(e.A4="A4",e.B5="B5",e.A3="A3",e.LETTER="Letter",e.LEGAL="Legal",e.CUSTOM="Custom",e))(Ne||{});const rn={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"}}},zn={top:{value:10,unit:"mm"},right:{value:10,unit:"mm"},bottom:{value:10,unit:"mm"},left:{value:10,unit:"mm"}},Kn={size:rn.A4,margin:zn},ns={paper:Kn,grid:Wn,blocks:[]};var Hn=(e=>(e.ERROR="error",e.WARNING="warning",e.INFO="info",e))(Hn||{});const Xn=d.memo(({contentPx:e,marginLeftPx:t,marginTopPx:n,borderStyle:o,visible:s=!0,dpi:a=q,zIndex:i=F.BORDER_OVERLAY,className:l=""})=>{const c=d.useMemo(()=>{if(o)return new et(o)},[o]);if(!s||!c||!c.hasAnyBorder)return null;const h={position:"absolute",left:`${t}px`,top:`${n}px`,width:`${e.width}px`,height:`${e.height}px`,pointerEvents:"none",overflow:"visible",zIndex:i};return r.jsx("div",{className:l,style:h,"data-testid":"border-overlay",children:r.jsx(Ve,{width:e.width,height:e.height,border:c,dpi:a})})}),qn=d.memo(({canvasPx:e,backgroundColor:t="#ffffff",boxShadow:n="0 2px 8px rgba(0, 0, 0, 0.1)",zIndex:o=F.GRID_CANVAS,className:s})=>{const a={position:"absolute",inset:0,width:`${e.width}px`,height:`${e.height}px`,backgroundColor:t,boxShadow:n,pointerEvents:"none",zIndex:o};return r.jsx("div",{className:s,style:a,role:"presentation","aria-label":"Paper background","data-testid":"grid-canvas"})}),rs="_label_vgaic_1",os={label:rs},ss="_editor_6szgo_5",is="_input_6szgo_18",as="_select_6szgo_38",ls="_button_6szgo_54",mt={editor:ss,input:is,select:as,button:ls};function Jn(e,t){const n=e.match(/^(\d+(?:\.\d+)?)([a-zA-Z%]+)$/);if(!n)throw new Error(`Invalid dimension string: ${e}`);const o=Number(n[1]),s=n[2];if(fe(o,"Dimension value"),!t.includes(s))throw new Error(`Unit not allowed: ${s}`);return{value:o,unit:s}}function cs(e,t){return e.map(n=>Jn(n,t))}const us=10,ds=25.4,fs=.352778,hs=.264583,J={fromCm(e){return fe(e,"Centimeter value"),e*us},fromInch(e){return fe(e,"Inch value"),e*ds},fromPt(e){return fe(e,"Point value"),e*fs},fromPx(e){return fe(e,"Pixel value"),e*hs},fromDim(e){switch(fe(e.value,"Dimension value"),e.unit){case"mm":return e.value;case"cm":return J.fromCm(e.value);case"inch":return J.fromInch(e.value);case"pt":return J.fromPt(e.value);case"px":return J.fromPx(e.value);case"fr":case"%":throw new Error(`Cannot convert ${e.unit} to mm. Use physical units only.`);default:{const t=e.unit;throw new Error(`Unsupported unit: ${t}`)}}}};function Zn(e){return fe(e.value,"Dimension"),`${e.value}${e.unit}`}function ms(e){return e.map(Zn)}const ps=["fr","px","mm","cm","pt","inch"];function vs(e,t){if(t==="fr")return 1;switch(t){case"px":return e;case"mm":{const n=J.fromPx(e);return Math.round(n*10)/10}case"cm":{const o=J.fromPx(e)/10;return Math.round(o*100)/100}case"inch":{const o=J.fromPx(e)/25.4;return Math.round(o*100)/100}case"pt":{const s=J.fromPx(e)/25.4*72;return Math.round(s*10)/10}default:{const n=t;throw new Error(`Unsupported unit: ${n}`)}}}const Qn=d.memo(({direction:e,dimension:t,currentPxSize:n,position:o,marginLeftPx:s,marginTopPx:a,onChange:i,onCancel:l})=>{const[c,h]=d.useState(t.value.toString()),[p,x]=d.useState(t.unit),b=d.useRef(null),g=d.useRef(null),N=e==="column"?{left:`${s+o}px`,top:`${a+24}px`,transform:"translateX(-50%)"}:{left:`${s+24}px`,top:`${a+o}px`,transform:"translateY(-50%)"};d.useEffect(()=>{var f,y;(f=b.current)==null||f.focus(),(y=b.current)==null||y.select()},[]),d.useEffect(()=>{const f=y=>{g.current&&!g.current.contains(y.target)&&l()};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[l]);const E=()=>{const f=Number.parseFloat(c);!Number.isNaN(f)&&f>=.1?i({unit:p,value:f}):l()},m=f=>{f.key==="Enter"?(f.preventDefault(),E()):f.key==="Escape"&&(f.preventDefault(),l())},v=f=>{const y=f.target.value;x(y);const w=vs(n,y);h(w.toString())};return r.jsxs("div",{ref:g,className:mt.editor,style:N,"data-testid":`grid-unit-editor-${e}`,children:[r.jsx("input",{ref:b,type:"number",className:mt.input,value:c,onChange:f=>h(f.target.value),onKeyDown:m,min:"0.1",step:p==="fr"?"0.1":"1"}),r.jsx("select",{className:mt.select,value:p,onChange:v,children:ps.map(f=>r.jsx("option",{value:f,children:f},f))}),r.jsx("button",{type:"button",className:mt.button,onClick:E,title:"確定",children:"✓"})]})});Qn.displayName="GridUnitEditor";function xs(e,t,n,o){if(t==="fr"){if(n!==void 0&&o!==void 0&&o>0){const s=e/o;return Math.round(n*s*100)/100}return 1}switch(t){case"px":return Math.round(e);case"mm":{const s=J.fromPx(e);return Math.round(s*10)/10}case"cm":{const s=J.fromPx(e);return Math.round(s/10*100)/100}case"inch":{const s=J.fromPx(e);return Math.round(s/25.4*100)/100}case"pt":{const s=J.fromPx(e);return Math.round(s/25.4*72*10)/10}default:{const s=t;throw new Error(`Unsupported unit: ${s}`)}}}const Yt=d.memo(({direction:e,index:t,dimension:n,position:o,currentPxSize:s,marginLeftPx:a,marginTopPx:i,isNearCursor:l,resizingPxSize:c,onDimensionChange:h})=>{const[p,x]=d.useState(!1);if(!l&&!p)return null;const b=e==="column"?{left:`${a+o}px`,top:`${i-20}px`,transform:"translateX(-50%)"}:{left:`${a-20}px`,top:`${i+o}px`,transform:"translateY(-50%)",writingMode:"vertical-rl"},g=()=>{x(!0)},N=f=>{h==null||h(e,t,f),x(!1)},E=()=>{x(!1)},v=c?(()=>{const f=xs(c,n.unit,n.value,s);return n.unit==="fr"?`${f}fr`:`${f}${n.unit}`})():(f=>f.unit==="fr"?`${f.value}fr`:`${f.value}${f.unit}`)(n);return r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:os.label,style:b,onDoubleClick:g,"data-testid":`grid-dimension-${e}-${t}`,"aria-label":`グリッド寸法: ${v}`,children:v})," ",p&&r.jsx(Qn,{direction:e,dimension:n,currentPxSize:s,position:o,marginLeftPx:a,marginTopPx:i,onChange:N,onCancel:E})]})});Yt.displayName="GridDimensionLabel";function bs(e,t,n,o){let s="";for(const a of e)s+=`M ${a} 0 L ${a} ${o} `;for(const a of t)s+=`M 0 ${a} L ${n} ${a} `;return s}const er=d.memo(({gridPosPx:e,contentPx:t,marginLeftPx:n,marginTopPx:o,lineStyle:s,visible:a=!0,zIndex:i=F.GRID_OVERLAY,dpi:l=q,className:c=""})=>{const h=d.useMemo(()=>bs(e.cols.slice(1,-1),e.rows.slice(1,-1),t.width,t.height),[e,t]);if(!a||!s)return null;const p=Ze(s),x=W.fromDim(s.width,l),b={position:"absolute",left:`${n}px`,top:`${o}px`,pointerEvents:"none",zIndex:i};return r.jsx("svg",{className:c,style:b,width:t.width,height:t.height,xmlns:"http://www.w3.org/2000/svg",role:"img","aria-label":"Grid overlay lines",children:r.jsx("path",{d:h,stroke:s.color,strokeWidth:x,strokeDasharray:p,fill:"none"})})}),gs="_handle_1mgtx_1",ys="_dragging_1mgtx_19",Ft={handle:gs,dragging:ys},zt=d.memo(({direction:e,index:t,position:n,marginLeftPx:o,marginTopPx:s,onResizeStart:a,onResize:i,onResizeEnd:l})=>{const[c,h]=d.useState(!1),p=12,x=p/2,b=e==="column"?{left:`${o+n-x}px`,top:`${s-x}px`,width:`${p}px`,height:`${p}px`,cursor:"col-resize"}:{left:`${o-x}px`,top:`${s+n-x}px`,width:`${p}px`,height:`${p}px`,cursor:"row-resize"},g=d.useCallback(N=>{N.stopPropagation(),N.preventDefault();const E=e==="column"?N.clientX:N.clientY;h(!0),a==null||a(e,t);const m=f=>{const w=(e==="column"?f.clientX:f.clientY)-E;i==null||i(e,t,w)},v=f=>{const w=(e==="column"?f.clientX:f.clientY)-E;h(!1),l==null||l(e,t,w),window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",v)};window.addEventListener("pointermove",m),window.addEventListener("pointerup",v)},[e,t,a,i,l]);return r.jsx("div",{className:`${Ft.handle} ${Ft[e]} ${c?Ft.dragging:""}`,style:b,onPointerDown:g,"data-testid":`grid-resize-handle-${e}-${t}`})});zt.displayName="GridResizeHandle";const tr=d.memo(({paperPx:e,visible:t=!0,marginColor:n,zIndex:o=F.MARGIN_OVERLAY,className:s=""})=>{if(!t)return null;const a={position:"absolute",inset:0,pointerEvents:"none",width:`${e.canvas.width}px`,height:`${e.canvas.height}px`,zIndex:o},i={position:"absolute",backgroundColor:n||"rgba(0, 0, 0, 0.05)",pointerEvents:"none"};return r.jsxs("div",{className:s,style:a,role:"presentation","aria-label":"Printable area margin","data-testid":"margin-overlay",children:[e.margin.top>0&&r.jsx("div",{"data-testid":"margin-top",style:{...i,top:0,left:0,width:"100%",height:`${e.margin.top}px`}}),e.margin.bottom>0&&r.jsx("div",{"data-testid":"margin-bottom",style:{...i,bottom:0,left:0,width:"100%",height:`${e.margin.bottom}px`}}),e.margin.left>0&&r.jsx("div",{"data-testid":"margin-left",style:{...i,left:0,top:`${e.margin.top}px`,height:`${e.content.height}px`,width:`${e.margin.left}px`}}),e.margin.right>0&&r.jsx("div",{"data-testid":"margin-right",style:{...i,right:0,top:`${e.margin.top}px`,height:`${e.content.height}px`,width:`${e.margin.right}px`}})]})}),Nt=d.memo(({paperPx:e,gridPosPxs:t,gridDimensions:n,gridLineStyle:o,borderStyle:s,backgroundColor:a="#ffffff",boxShadow:i="0 2px 8px rgba(0, 0, 0, 0.1)",marginFillColor:l="rgba(0, 0, 0, 0.05)",showGridLines:c=!0,showMargins:h=!0,showBorder:p=!0,showResizeHandles:x=!1,showDimensionLabels:b=!1,onGridResize:g,onDimensionChange:N,className:E="",zIndex:m={}})=>{const[v,f]=d.useState(null),[y,w]=d.useState(null),[R,L]=d.useState(null),$=d.useRef(null);d.useEffect(()=>{const j=P=>{if(!$.current)return;const A=$.current.getBoundingClientRect();L({x:P.clientX-A.left,y:P.clientY-A.top})},D=P=>{if(!$.current)return;const A=$.current.getBoundingClientRect();(P.clientX<A.left||P.clientX>A.right||P.clientY<A.top||P.clientY>A.bottom)&&L(null)};return window.addEventListener("mousemove",j),window.addEventListener("mouseleave",D),()=>{window.removeEventListener("mousemove",j),window.removeEventListener("mouseleave",D)}},[]);const I=d.useMemo(()=>{if(!R)return!1;const j=e.content.width,D=e.content.height,P=e.margin.left,A=e.margin.top;return!(R.x>=P&&R.x<=P+j&&R.y>=A&&R.y<=A+D)},[R,e]),k=d.useCallback((j,D)=>{w({direction:j,index:D})},[]),M=d.useMemo(()=>{if(!v||!y)return null;const j=y.direction==="column"?t.cols:t.rows,D=y.index,P=j[D-1],A=v.position,K=P!==void 0?A-P:0,Z=v.position,Q=j[D+1],ue=Q!==void 0?Q-Z:0;return{direction:y.direction,prevIndex:D-1,prevSize:K,nextIndex:D,nextSize:ue}},[v,y,t]),G=d.useCallback((j,D,P)=>{const A=j==="column"?t.cols:t.rows,K=A[D];if(K===void 0)return;const Z=A[D-1],Q=A[D+1],ue=10;let le=P;if(Z!==void 0){const H=Z+ue-K;le=Math.max(le,H)}if(Q!==void 0){const H=Q-ue-K;le=Math.min(le,H)}f({direction:j,position:K+le})},[t]),T=d.useCallback((j,D,P)=>{const A=j==="column"?t.cols:t.rows,K=A[D];if(K===void 0){f(null);return}const Z=A[D-1],Q=A[D+1],ue=10;let le=P;if(Z!==void 0){const H=Z+ue-K;le=Math.max(le,H)}if(Q!==void 0){const H=Q-ue-K;le=Math.min(le,H)}f(null),w(null),g==null||g(j,D,le)},[t,g]),S={position:"relative",width:"100%",height:"100%"};return r.jsxs("div",{ref:$,className:E,style:S,children:[r.jsx(qn,{canvasPx:e.canvas,backgroundColor:a,boxShadow:i,zIndex:(m==null?void 0:m.canvas)??F.GRID_CANVAS,className:E}),h&&r.jsx(tr,{paperPx:e,visible:h,marginColor:l,zIndex:(m==null?void 0:m.margin)??F.MARGIN_OVERLAY,className:E}),c&&r.jsx(er,{gridPosPx:t,contentPx:e.content,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,lineStyle:o,visible:c,zIndex:(m==null?void 0:m.grid)??F.GRID_OVERLAY,dpi:q,className:E}),p&&r.jsx(Xn,{contentPx:e.content,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,borderStyle:s,visible:p,dpi:q,zIndex:(m==null?void 0:m.border)??F.BORDER_OVERLAY,className:E}),x&&g&&r.jsxs(r.Fragment,{children:[t.cols.map((j,D)=>{if(D===0||D===t.cols.length-1)return null;const P=`col-${D}`;return r.jsx(zt,{direction:"column",index:D,position:j,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,onResizeStart:k,onResize:G,onResizeEnd:T},P)}),t.rows.map((j,D)=>{if(D===0||D===t.rows.length-1)return null;const P=`row-${D}`;return r.jsx(zt,{direction:"row",index:D,position:j,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,onResizeStart:k,onResize:G,onResizeEnd:T},P)})]}),b&&n&&r.jsxs(r.Fragment,{children:[n.cols.map((j,D)=>{const P=t.cols[D],A=t.cols[D+1];if(P===void 0||A===void 0)return null;const K=(y==null?void 0:y.direction)==="column"&&(y.index===D||y.index===D+1);let Z;M&&M.direction==="column"&&(M.prevIndex===D?Z=M.prevSize:M.nextIndex===D&&(Z=M.nextSize));const Q=(P+A)/2,ue=A-P,le=`col-dim-${D}`;return r.jsx(Yt,{direction:"column",index:D,dimension:j,position:Q,currentPxSize:ue,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,isNearCursor:I||K,resizingPxSize:Z,onDimensionChange:N},le)})," ",n.rows.map((j,D)=>{const P=t.rows[D],A=t.rows[D+1];if(P===void 0||A===void 0)return null;const K=(y==null?void 0:y.direction)==="row"&&(y.index===D||y.index===D+1),Z=(P+A)/2,Q=A-P,ue=`row-dim-${D}`;return r.jsx(Yt,{direction:"row",index:D,dimension:j,position:Z,currentPxSize:Q,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,isNearCursor:I||K,onDimensionChange:N},ue)})]}),v&&r.jsx("div",{style:{position:"absolute",left:v.direction==="column"?e.margin.left+v.position:e.margin.left,top:v.direction==="row"?e.margin.top+v.position:e.margin.top,width:v.direction==="column"?"2px":e.content.width,height:v.direction==="row"?"2px":e.content.height,backgroundColor:"#3b82f6",opacity:.5,pointerEvents:"none",zIndex:F.GRID_GHOST}})]})}),ws=d.memo(({blockSizePx:e,borderStyle:t,blockZIndex:n,subZIndex:o=we.BORDER,visible:s=!0,dpi:a=q,className:i=""})=>{const l=d.useMemo(()=>{if(t)return new et(t)},[t]);if(!s||!l||!l.hasAnyBorder)return null;const c=lt(n,o),h={position:"absolute",left:0,top:0,width:`${e.width}px`,height:`${e.height}px`,pointerEvents:"none",overflow:"visible",zIndex:c};return r.jsx("div",{className:i,style:h,"data-testid":"block-border",children:r.jsx(Ve,{width:e.width,height:e.height,border:l,dpi:a})})}),_s=d.memo(({blockSizePx:e,blockZIndex:t,subZIndex:n=we.BG,backgroundColor:o="transparent",className:s=""})=>{const a=lt(t,n),i={position:"absolute",inset:0,width:`${e.width}px`,height:`${e.height}px`,backgroundColor:o,pointerEvents:"none",zIndex:a};return r.jsx("div",{className:s,style:i,role:"presentation","aria-label":"Block background","data-testid":"block-canvas"})}),Es={color:"#cccccc",width:{value:1,unit:"pt"},type:ye.SOLID},on={all:Es},js=d.memo(({blockSizePx:e,blockZIndex:t,subZIndex:n=we.GUIDE,borderStyle:o=on,visible:s=!0,dpi:a=q,className:i=""})=>{const l=d.useMemo(()=>{if(o)return new et(o)},[o]);if(!s||!l||!l.hasAnyBorder)return null;const c=lt(t,n),h={position:"absolute",left:0,top:0,width:`${e.width}px`,height:`${e.height}px`,pointerEvents:"none",overflow:"visible",zIndex:c};return r.jsx("div",{className:i,style:h,"data-testid":"block-base-border",children:r.jsx(Ve,{width:e.width,height:e.height,border:l,dpi:a})})}),Ns=({id:e,plugin:t,props:n,value:o,onChange:s,onBlur:a,readOnly:i,mode:l,blockSizePx:c,blockZIndex:h,subZIndex:p=we.CONTENT,validationState:x,className:b=""},g)=>{const N=d.useRef(null);d.useImperativeHandle(g,()=>({focus:()=>{var y;return(y=N.current)==null?void 0:y.focus()}}),[]);const E=lt(h,p),m={position:"absolute",inset:0,width:`${c.width}px`,height:`${c.height}px`,zIndex:E,pointerEvents:"auto"},v={id:e,props:n,value:o,onChange:s??(()=>{}),onBlur:a,readOnly:i,mode:l,dimensions:{widthPx:c.width,heightPx:c.height},validationState:x},f=t.Renderer;return r.jsx("div",{className:b,style:m,"data-testid":"block-renderer","data-block-id":e,"data-plugin-kind":t.kind,children:r.jsx(f,{ref:N,...v})})},Is=d.forwardRef(Ns),It=d.memo(Is);function sn(e,t){return{position:"absolute",left:`${e.left}px`,top:`${e.top}px`,width:`${e.width}px`,height:`${e.height}px`,zIndex:t==null?void 0:t.zIndex,pointerEvents:(t==null?void 0:t.pointerEvents)??"auto"}}const nr=d.memo(d.forwardRef(({block:e,plugin:t,blockRectPx:n,blockZIndex:o,mode:s,value:a,onValueChange:i,onValueBlur:l,showGuides:c=!0,showBorder:h=!0,blockSubZIndex:p={bg:we.BG,guide:we.GUIDE,content:we.CONTENT,border:we.BORDER},defaultGuideBorder:x=on,dpi:b=q,className:g="",pointerEvents:N="none"},E)=>{var f,y,w,R;const m=sn(n,{zIndex:o,pointerEvents:N}),v=d.useMemo(()=>({width:n.width,height:n.height}),[n.width,n.height]);return r.jsxs("div",{style:m,"data-block-id":e.id,className:g,children:[r.jsx(_s,{blockSizePx:v,blockZIndex:o,backgroundColor:(f=e.style)==null?void 0:f.backgroundColor,subZIndex:p.bg}),c&&!((y=e.style)!=null&&y.border)&&r.jsx(js,{blockSizePx:v,blockZIndex:o,subZIndex:p.guide,borderStyle:x,dpi:b}),r.jsx(It,{id:e.id,ref:E,plugin:t,props:e.props,value:a,onChange:i,onBlur:l,readOnly:s===ge.EDIT?((w=e.behavior)==null?void 0:w.readOnly)??!1:!0,mode:s,blockSizePx:v,blockZIndex:o,subZIndex:p.content}),r.jsx(ws,{blockSizePx:v,blockZIndex:o,borderStyle:(R=e.style)==null?void 0:R.border,subZIndex:p.border,visible:h,dpi:b})]})}));nr.displayName="BlockContainer";const Dt=d.memo(({blocks:e,pluginRegistry:t,mode:n,values:o,selectedBlockIds:s=[],getBlockRectPx:a,onValueChange:i,onValueBlur:l,showGuides:c=!0,showBorder:h=!0,blockSubZIndex:p={bg:we.BG,guide:we.GUIDE,content:we.CONTENT,border:we.BORDER},defaultGuideBorder:x=on,dpi:b=q,className:g=""})=>{const N=d.useRef(new Map),E={position:"absolute",inset:0,pointerEvents:"none"};return r.jsx("div",{className:g,style:E,"data-testid":"block-layer",children:e.map((m,v)=>{const f=t[m.kind];if(!f)return null;const y=a(m),w=s.includes(m.id);let R=kn(v);w&&(R=F.SELECT_BLOCK);const L=o[m.id]??m.initValue;return r.jsx(nr,{ref:$=>{$?N.current.set(m.id,$):N.current.delete(m.id)},block:m,plugin:f,blockRectPx:y,blockZIndex:R,mode:n,value:L,onValueChange:i?$=>i(m.id,$):void 0,onValueBlur:$=>l==null?void 0:l(m.id,$),showGuides:c,showBorder:h,blockSubZIndex:p,defaultGuideBorder:x,dpi:b,pointerEvents:"none"},m.id)})})});Dt.displayName="BlockLayer";class Ds{constructor(){Ot(this,"state",null);Ot(this,"listeners",[])}start(t,n){this.state={kind:t,defaultSize:n},this.notify()}end(){this.state=null,this.notify()}get(){return this.state}subscribe(t){return this.listeners.push(t),()=>{this.listeners=this.listeners.filter(n=>n!==t)}}notify(){for(const t of this.listeners)t(this.state)}}const xt=new Ds;function Kt(e,t,n,o){if(t<0||t>=e.length)return e;const s=[...e],a=s[t],i=s[t+1];return!a||!i?e:a.unit==="fr"&&i.unit==="fr"?Cs(s,t,n,o):a.unit!=="fr"&&i.unit!=="fr"?Rs(s,t,n):a.unit==="fr"&&i.unit!=="fr"?$n(s,t,n,"next",o):$n(s,t,n,"current",o)}function Cs(e,t,n,o){const s=e[t],a=e[t+1];if(!s||!a)return e;const i=e.reduce((N,E)=>E.unit==="fr"?N+E.value:N,0),l=o/i,c=s.value*l,h=a.value*l,p=Math.max(10,c+n),x=Math.max(10,h-n),b=p/l,g=x/l;return e[t]={...s,value:Math.round(b*100)/100},e[t+1]={...a,value:Math.round(g*100)/100},e}function Rs(e,t,n){const o=e[t],s=e[t+1];if(!o||!s)return e;const a=W.fromDim(o),i=W.fromDim(s),l=Math.max(10,a+n),c=Math.max(10,i-n);return e[t]={...o,value:bt(l,o.unit)},e[t+1]={...s,value:bt(c,s.unit)},e}function $n(e,t,n,o,s){const a=e[t],i=e[t+1];if(!a||!i)return e;let l=0,c=0;for(const x of e)x.unit==="fr"?l+=x.value:c+=W.fromDim(x);const h=s-c,p=l>0?h/l:0;if(o==="next"){const x=W.fromDim(i),b=Math.max(10,x-n);e[t+1]={...i,value:bt(b,i.unit)};const g=b-x,N=h-g,E=a.value*p,m=Math.max(10,E+n),v=l>0?m/N*l:1;e[t]={...a,value:Math.round(v*100)/100}}else{const x=W.fromDim(a),b=Math.max(10,x+n);e[t]={...a,value:bt(b,a.unit)};const g=b-x,N=h-g,E=i.value*p,m=Math.max(10,E-n),v=l>0?m/N*l:1;e[t+1]={...i,value:Math.round(v*100)/100}}return e}function bt(e,t){switch(t){case"px":return Math.round(e);case"mm":{const n=J.fromPx(e);return Math.round(n*10)/10}case"cm":{const n=J.fromPx(e);return Math.round(n/10*100)/100}case"inch":{const n=J.fromPx(e);return Math.round(n/25.4*100)/100}case"pt":{const n=J.fromPx(e);return Math.round(n/25.4*72*10)/10}case"fr":return 1;default:{const n=t;throw new Error(`Unsupported unit: ${n}`)}}}function rr(e){if(e.length===0)return[];const t=[];let n=0;for(const o of e){fe(o,"Pixel value");const s=o+n,a=Math.round(s);t.push(a),n=s-a}return t}const $s=8,Ts=32,Ms=64,Ps=512,Tn=(e,t,n)=>Math.min(Math.max(e,t),n);function Ht(e){const t=e.length-1,n=t>=1?e[t]??0:0,o=e.length>=1?n/t:0,s=Tn(Math.ceil(Math.log2(t+1)),$s,Ts),a=Tn(o*2,Ms,Ps);return{step:s,windowPx:a}}function vt(e,t){const n=t.length-1;if(n<=0||t[0]===void 0||e<t[0]||t[n]===void 0)return-1;if(e>=t[n])return n-1;let o=1,s=n;for(;o<=s;){const a=o+s>>>1,i=t[a];if(i===void 0){s=a-1;continue}i<=e?o=a+1:s=a-1}return o-1}function Xt(e,t,n){const o=e.length-1;let s=0;return a=>{if(o<=0||e[0]===void 0||a<e[0]||e[o]===void 0)return-1;if(a>=e[o])return o-1;const i=e[s],l=e[s+1];if(i===void 0||l===void 0)return-1;if(i<=a&&a<l)return s;const c=i-n,h=l+n;if(a<c||a>=h)return s=vt(a,e),s;let p=0;const x=e[s+1];if(x!==void 0&&a>=x)for(;s+1<o;){const b=e[s+1];if(b===void 0||a<b)break;if(s++,++p>t)return s=vt(a,e),s}else for(;s>0;){const b=e[s];if(b===void 0||a>=b)break;if(s--,++p>t)return s=vt(a,e),s}return s}}function gt(e,t){if(e.length===0)return[];fe(t,"Content size");let n=0,o=0;const s=e.map(l=>{if(fe(l.value,"Grid dimension value"),l.unit==="fr")return n+=l.value,null;{const c=J.fromDim(l);return o+=c,c}});if(n===0)return Yn(o,0,t,"Total fixed size"),s;const a=t-o;fe(a,"Content size - fixed sizes");const i=a/n;return s.map((l,c)=>{const h=e[c];if(l!=null)return l;if(!h)throw new Error(`dims[${c}] is undefined`);return h.value*i})}function yt(e,t=96){fe(t,"DPI"),jt(t,"DPI");const n=e.map(s=>W.fromMm(s,t));return rr(n)}function ks(e,t,n){if(e.length===0)return[];fe(n,"DPI"),jt(n,"DPI"),fe(t,"Content size");const o=gt(e,t);return yt(o,n)}function wt(e){const t={};for(const[n,o]of Object.entries(e))if(o!=null)if(typeof o=="object"&&!Array.isArray(o)&&o!==null){const s=wt(o);t[n]=s}else t[n]=o;return t}function Ss(e,t){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}}[e];return t==="landscape"?{width:o.height,height:o.width}:o}function or(e){e!=null&&e.title&&(document.title=e.title),e!=null&&e.removeScrollbars&&(document.body.style.overflow="hidden")}function sr(e){e!=null&&e.restoreScrollbars&&(document.body.style.overflow="")}function qt(e){or({title:e==null?void 0:e.title,removeScrollbars:!0});const t=()=>{var o;(o=e==null?void 0:e.onBeforePrint)==null||o.call(e)},n=()=>{var o;(o=e==null?void 0:e.onAfterPrint)==null||o.call(e),sr({restoreScrollbars:!0}),window.removeEventListener("beforeprint",t),window.removeEventListener("afterprint",n)};window.addEventListener("beforeprint",t),window.addEventListener("afterprint",n),window.print()}function As(e){if(typeof e!="object"||e===null)return!1;const t=e;if(typeof t.id!="string"||typeof t.kind!="string"||typeof t.layout!="object"||t.layout===null)return!1;const n=t.layout;return!(typeof n.x!="number"||typeof n.y!="number"||typeof n.w!="number"||typeof n.h!="number"||t.props!==void 0&&typeof t.props!="object")}function Os(e){return e==="fr"||e==="px"||e==="%"}function Mn(e){return Array.isArray(e)?e.every(t=>{if(typeof t!="object"||t===null)return!1;const n=t;return typeof n.value=="number"&&Os(n.unit)}):!1}function Ls(e){if(typeof e!="object"||e===null)return!1;const t=e;return Mn(t.cols)&&Mn(t.rows)}function Gs(e){if(typeof e!="object"||e===null)return!1;const t=e;if(typeof t.size!="object"||t.size===null)return!1;const n=t.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 t.margin!="object"||t.margin===null)return!1;const a=t.margin;for(const i of["top","right","bottom","left"]){const l=a[i];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 Bs(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="object"&&!Array.isArray(e)}function ir(e){if(typeof e!="object"||e===null)throw new Error("Schema must be an object");const t=e;if(!Gs(t.paper))throw new Error("Invalid paper definition");if(!Ls(t.grid))throw new Error("Invalid grid definition");if(!Array.isArray(t.blocks))throw new Error("blocks must be an array");if(!t.blocks.every(As))throw new Error("Invalid block definition in blocks array");if(t.metaData!==void 0){if(typeof t.metaData!="object"||t.metaData===null)throw new Error("metaData must be an object if provided");const n=t.metaData;for(const o in n)if(!Bs(n[o]))throw new Error(`Invalid value in metaData.${o}`)}return t}function Jt(e){try{const t=JSON.parse(e);return ir(t)}catch(t){throw t instanceof SyntaxError?new Error(`Invalid JSON format: ${t.message}`):t}}function Zt(e,t=!1){try{return t?JSON.stringify(e,null,2):JSON.stringify(e)}catch(n){throw new Error(`Failed to serialize schema: ${n instanceof Error?n.message:"Unknown error"}`)}}function ar(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"?!0:typeof e=="object"&&!Array.isArray(e)?Object.values(e).every(ar):!1}function lr(e){if(typeof e!="object"||e===null)throw new Error("Values must be an object");if(Array.isArray(e))throw new Error("Values must be an object, not an array");const t=e;for(const n in t)if(!ar(t[n]))throw new Error(`Invalid value at key "${n}"`);return t}function Qt(e){try{const t=JSON.parse(e);return lr(t)}catch(t){throw t instanceof SyntaxError?new Error(`Invalid JSON format: ${t.message}`):t}}function en(e,t=!1){try{return t?JSON.stringify(e,null,2):JSON.stringify(e)}catch(n){throw new Error(`Failed to serialize values: ${n instanceof Error?n.message:"Unknown error"}`)}}function an(e,t,n=q){const o=d.useMemo(()=>J.fromDim(e.size.width),[e.size.width]),s=d.useMemo(()=>J.fromDim(e.size.height),[e.size.height]),a=d.useMemo(()=>J.fromDim(e.margin.top),[e.margin.top]),i=d.useMemo(()=>J.fromDim(e.margin.bottom),[e.margin.bottom]),l=d.useMemo(()=>J.fromDim(e.margin.left),[e.margin.left]),c=d.useMemo(()=>J.fromDim(e.margin.right),[e.margin.right]),h=d.useMemo(()=>o-l-c,[o,l,c]),p=d.useMemo(()=>s-a-i,[s,a,i]),x=d.useMemo(()=>gt(t.cols,h),[t.cols,h]),b=d.useMemo(()=>gt(t.rows,p),[t.rows,p]),g=d.useMemo(()=>W.fromMm(o,n),[o,n]),N=d.useMemo(()=>W.fromMm(s,n),[s,n]),E=d.useMemo(()=>W.fromMm(a,n),[a,n]),m=d.useMemo(()=>W.fromMm(i,n),[i,n]),v=d.useMemo(()=>W.fromMm(l,n),[l,n]),f=d.useMemo(()=>W.fromMm(c,n),[c,n]),y=d.useMemo(()=>W.fromMm(h,n),[h,n]),w=d.useMemo(()=>W.fromMm(p,n),[p,n]),R=d.useMemo(()=>yt(x,n),[x,n]),L=d.useMemo(()=>yt(b,n),[b,n]),$=d.useMemo(()=>{const H=[0];for(const ke of R){const Se=H[H.length-1]??0;H.push(Se+ke)}return H},[R]),I=d.useMemo(()=>{const H=[0];for(const ke of L){const Se=H[H.length-1]??0;H.push(Se+ke)}return H},[L]),{step:k,windowPx:M}=d.useMemo(()=>Ht($),[$]),{step:G,windowPx:T}=d.useMemo(()=>Ht(I),[I]),S=d.useMemo(()=>Xt($,k,M),[$,k,M]),j=d.useMemo(()=>Xt(I,G,T),[I,G,T]),D=d.useCallback(H=>S(H-v),[S,v]),P=d.useCallback(H=>j(H-E),[j,E]),A=d.useMemo(()=>({cols:$,rows:I}),[$,I]),K=d.useMemo(()=>({width:g,height:N}),[g,N]),Z=d.useMemo(()=>({top:E,bottom:m,left:v,right:f}),[E,m,v,f]),Q=d.useMemo(()=>({width:y,height:w}),[y,w]),ue=d.useMemo(()=>({canvas:K,margin:Z,content:Q}),[K,Z,Q]),le=d.useCallback(H=>{const{x:ke,y:Se,w:tt,h:nt}=H.layout,Ee=A.cols,De=A.rows;if(!Ee.length||!De.length)return{left:0,top:0,width:0,height:0};const Oe=Math.min(Math.max(0,ke),Ee.length-1),Rt=Math.min(Math.max(0,ke+tt),Ee.length-1),rt=Math.min(Math.max(0,Se),De.length-1),$t=Math.min(Math.max(0,Se+nt),De.length-1),Tt=(Ee[Oe]??0)+v,Ue=(De[rt]??0)+E,Le=(Ee[Rt]??0)-(Ee[Oe]??0),dt=(De[$t]??0)-(De[rt]??0);return{left:Tt,top:Ue,width:Le,height:dt}},[A,v,E]);return{paperPx:ue,gridPosPx:A,getColIndex:D,getRowIndex:P,getBlockRectPx:le}}const ln=d.memo(({schema:e,values:t,pluginRegistry:n,onValueChange:o,scale:s=1,className:a})=>{const{paperPx:i,gridPosPx:l,getBlockRectPx:c}=an(e.paper,e.grid,q),h=d.useCallback((p,x)=>{o&&o(p,x)},[o]);return r.jsxs("div",{className:a,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:s!==1?`scale(${s})`:void 0,transformOrigin:"top center"},children:[r.jsx(Nt,{paperPx:i,gridPosPxs:l,showGridLines:!1,showMargins:!1,showBorder:!1}),r.jsx(Dt,{blocks:e.blocks,pluginRegistry:n,mode:ge.EDIT,values:t,getBlockRectPx:c,onValueChange:h,showGuides:!0,showBorder:!0})]})});ln.displayName="NoteEdit";var X=(e=>(e.IDLE="idle",e.PRESSING="pressing",e.DRAGGING="dragging",e.EDITING="editing",e))(X||{}),te=(e=>(e.N="n",e.NE="ne",e.E="e",e.SE="se",e.S="s",e.SW="sw",e.W="w",e.NW="nw",e))(te||{}),me=(e=>(e.MOVE="move",e.RESIZE="resize",e.INSERT="insert",e))(me||{}),U=(e=>(e.SELECT="select",e.DESELECT="deselect",e.START_PRESS="startPress",e.UPDATE_DRAG="updateDrag",e.END_DRAG="endDrag",e.CANCEL_DRAG="cancelDrag",e.EDIT="edit",e.END_EDIT="endEdit",e.START_INSERT="startInsert",e.CANCEL_INSERT="cancelInsert",e.START_RESIZE="startResize",e))(U||{});function Fs(e){const[t,n]=d.useState({mode:X.IDLE,selectedBlockIds:[],editingBlockId:null,...e}),o=d.useCallback(s=>{n(a=>{switch(s.type){case U.SELECT:{const i=s.blockIds;return{...a,mode:X.IDLE,selectedBlockIds:i}}case U.DESELECT:return{...a,mode:X.IDLE,selectedBlockIds:[]};case U.START_PRESS:{const i=s.selectedBlockIds||[s.blockId];return{...a,mode:X.PRESSING,dragging:{type:me.MOVE,blockIds:i,startGrid:s.startGrid,currentGrid:s.startGrid,isOutside:!1}}}case U.UPDATE_DRAG:{if(!a.dragging)return a;const i=s.currentGrid.col!==a.dragging.startGrid.col||s.currentGrid.row!==a.dragging.startGrid.row;return a.mode===X.PRESSING?i?{...a,mode:X.DRAGGING,dragging:{...a.dragging,currentGrid:s.currentGrid,currentMousePx:s.currentMousePx,isOutside:s.isOutside??!1}}:{...a,dragging:{...a.dragging,currentGrid:s.currentGrid,currentMousePx:s.currentMousePx,isOutside:s.isOutside??!1}}:a.mode===X.DRAGGING?{...a,dragging:{...a.dragging,currentGrid:s.currentGrid,currentMousePx:s.currentMousePx,isOutside:s.isOutside??!1}}:a}case U.END_DRAG:return{...a,mode:X.IDLE,dragging:void 0};case U.CANCEL_DRAG:return{...a,mode:X.IDLE,dragging:void 0};case U.EDIT:return{...a,mode:X.EDITING,editingBlockId:s.blockId};case U.END_EDIT:return{...a,mode:X.IDLE,editingBlockId:null};case U.START_INSERT:return{...a,mode:X.DRAGGING,dragging:{type:me.INSERT,blockIds:[],startGrid:{col:0,row:0},currentGrid:{col:0,row:0},pluginKind:s.pluginKind,defaultSize:s.defaultSize,isOutside:!1}};case U.CANCEL_INSERT:return{...a,mode:X.IDLE,dragging:void 0};case U.START_RESIZE:return{...a,mode:X.DRAGGING,dragging:{type:me.RESIZE,blockIds:[s.blockId],startGrid:s.startGrid,currentGrid:s.startGrid,handle:s.handle,isOutside:!1}};default:return a}})},[]);return[t,o]}const Ct={all:{color:"#3b82f688",width:{value:4,unit:"px"},type:ye.SOLID}},cn={size:12,backgroundColor:"#ffffff",borderColor:"#3b82f6",borderWidth:1,borderRadius:"50%"},ae={base:F.INTERACTION_LAYER_BASE,select_block:F.SELECT_BLOCK,block_ghost:F.BLOCK_GHOST,hover_outline:F.HOVER_OUTLINE,edit_block:F.EDIT_BLOCK,grid_ghost:F.GRID_GHOST,grid_handles:F.GRID_HANDLES,select_border:F.BLOCK_SELECT_BORDER,block_handles:F.BLOCK_HANDLES,rubber_band:F.RUBBER_BAND},Vs="_interactionBlock_145kg_7",Us="_resizeHandle_145kg_7",cr={interactionBlock:Vs,resizeHandle:Us},Ws=[{id:te.NW,cursor:"nwse-resize",x:0,y:0},{id:te.N,cursor:"ns-resize",x:50,y:0},{id:te.NE,cursor:"nesw-resize",x:100,y:0},{id:te.W,cursor:"ew-resize",x:0,y:50},{id:te.E,cursor:"ew-resize",x:100,y:50},{id:te.SW,cursor:"nesw-resize",x:0,y:100},{id:te.S,cursor:"ns-resize",x:50,y:100},{id:te.SE,cursor:"nwse-resize",x:100,y:100}],ur=d.memo(({onResizeStart:e,activeHandle:t,handleStyle:n=cn,zIndex:o=F.BLOCK_HANDLES})=>{const s=n.size,a=s/2;return r.jsx(r.Fragment,{children:Ws.map(({id:i,cursor:l,x:c,y:h})=>{const p=c===50?`calc(50% - ${a}px)`:c===100?`calc(100% - ${a}px)`:`-${a}px`,x=h===50?`calc(50% - ${a}px)`:h===100?`calc(100% - ${a}px)`:`-${a}px`,b=t===i;return r.jsx("div",{className:cr.resizeHandle,onPointerDown:g=>{g.stopPropagation(),e(g,i)},style:{position:"absolute",left:p,top:x,width:`${s}px`,height:`${s}px`,backgroundColor:b?n.borderColor:n.backgroundColor,border:`${n.borderWidth}px solid ${n.borderColor}`,borderRadius:n.borderRadius,cursor:l,zIndex:o,pointerEvents:"auto",boxSizing:"border-box",opacity:b?1:void 0,transition:"opacity 0.2s, background-color 0.2s, transform 0.2s",transform:b?"scale(1.2)":void 0},"data-testid":`resize-handle-${i}`},i)})})});ur.displayName="ResizeHandles";const Ys=d.memo(({width:e,height:t,zIndex:n=F.BLOCK_SELECT_BORDER,borderStyle:o=Ct})=>{const s=d.useMemo(()=>new et(o),[o]),a={position:"absolute",inset:0,pointerEvents:"none",zIndex:n};return r.jsx("div",{style:a,children:r.jsx(Ve,{width:e,height:t,border:s})})}),ut=d.memo(({block:e,rect:t,showHandles:n=!1,onResizeStart:o,activeHandle:s,selectionStyle:a=Ct,handleStyle:i=cn,selectBorderZIndex:l=ae.select_border,blockHandlesZIndex:c=ae.block_handles})=>{const h={position:"absolute",left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,pointerEvents:"none"};return r.jsxs("div",{className:cr.interactionBlock,style:h,"data-testid":"interaction-block","data-block-id":e.id,children:[r.jsx(Ys,{width:t.width,height:t.height,zIndex:l,borderStyle:a}),n&&o&&r.jsx(ur,{onResizeStart:o,activeHandle:s,handleStyle:i,zIndex:c})]})});ut.displayName="InteractionBlock";const dr=d.memo(({pluginRegistry:e,gridLength:t,getBlockRectPx:n,currentGrid:o,currentMousePx:s,pluginKind:a,defaultSize:i,isOutside:l,selectionStyle:c,ghostZIndex:h=ae.block_ghost,selectBorderZIndex:p=ae.select_border,blockHandlesZIndex:x=ae.block_handles})=>{const b=e[a];if(!b)return null;let g;if(l&&s){const E=Fe(b,{x:0,y:0,w:i.w,h:i.h}),m=n(E);g={left:s.x-m.width/2,top:s.y-m.height/2,width:m.width,height:m.height}}else{const E=t.cols-i.w,m=t.rows-i.h,v=Math.max(0,Math.min(o.col,E)),f=Math.max(0,Math.min(o.row,m)),y=Fe(b,{x:v,y:f,w:i.w,h:i.h});g=n(y)}const N=Fe(b,{x:0,y:0,w:i.w,h:i.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:h},children:r.jsx(It,{id:N.id,plugin:b,props:N.props,value:N.initValue,onChange:()=>{},readOnly:!0,mode:ge.EDIT,blockSizePx:g,blockZIndex:h})}),r.jsx(ut,{block:N,rect:g,selectionStyle:c,selectBorderZIndex:p,blockHandlesZIndex:x})]})});dr.displayName="InsertGhost";function fr(e,t,n,o,s){if(e.length===0)return[];if(e.length===1){const v=e[0];if(!v)return[];const f=o-v.layout.w,y=s-v.layout.h,w=Math.max(0,Math.min(v.layout.x+t,f)),R=Math.max(0,Math.min(v.layout.y+n,y));return[{blockId:v.id,x:w,y:R}]}const a=Math.min(...e.map(v=>v.layout.x)),i=Math.min(...e.map(v=>v.layout.y)),l=Math.max(...e.map(v=>v.layout.x+v.layout.w)),c=Math.max(...e.map(v=>v.layout.y+v.layout.h)),h=l-a,p=c-i,x=a+t,b=i+n,g=Math.max(0,Math.min(x,o-h)),N=Math.max(0,Math.min(b,s-p)),E=g-a,m=N-i;return e.map(v=>({blockId:v.id,x:v.layout.x+E,y:v.layout.y+m}))}const hr=d.memo(({blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:o,selectedBlockIds:s,deltaCol:a,deltaRow:i,isOutside:l,currentMousePx:c,selectionStyle:h,ghostZIndex:p=ae.block_ghost,selectBorderZIndex:x=ae.select_border,blockHandlesZIndex:b=ae.block_handles})=>{const g=s.map(E=>e.find(m=>m.id===E)).filter(Boolean),N=fr(g,a,i,n.cols,n.rows);return r.jsx("div",{"data-testid":"moving-ghost",style:{position:"absolute",inset:0,pointerEvents:"none"},children:s.map(E=>{const m=e.find(w=>w.id===E);if(!m)return null;const v=t[m.kind];if(!v)return null;let f;if(l&&c){const w=o(m);f={left:c.x-w.width/2,top:c.y-w.height/2,width:w.width,height:w.height}}else{const w=N.find(L=>L.blockId===m.id);if(!w)return null;const R={...m,layout:{...m.layout,x:w.x,y:w.y}};f=o(R)}const y={...m,layout:{...m.layout,x:0,y:0}};return r.jsxs("div",{children:[r.jsx("div",{style:{position:"absolute",left:`${f.left}px`,top:`${f.top}px`,width:`${f.width}px`,height:`${f.height}px`,opacity:l?.3:.5,filter:l?"grayscale(100%)":"none",zIndex:p},children:r.jsx(It,{id:y.id,plugin:v,props:y.props,value:y.initValue,onChange:()=>{},readOnly:!0,mode:ge.EDIT,blockSizePx:f,blockZIndex:p,className:"ghost-content"})}),r.jsx(ut,{block:y,rect:f,selectionStyle:h,selectBorderZIndex:x,blockHandlesZIndex:b})]},E)})})});hr.displayName="MovingGhost";function mr({layout:e,handle:t,deltaCol:n,deltaRow:o,gridCols:s,gridRows:a}){const i={...e};if(t===te.E||t===te.NE||t===te.SE){const l=s-e.x;i.w=Math.max(1,Math.min(e.w+n,l))}else if(t===te.W||t===te.NW||t===te.SW){const l=e.w-1,c=n>0?Math.min(n,l):n;e.x+c>=0?(i.x=e.x+c,i.w=e.w-c):(i.x=0,i.w=e.w+e.x)}if(t===te.S||t===te.SE||t===te.SW){const l=a-e.y;i.h=Math.max(1,Math.min(e.h+o,l))}else if(t===te.N||t===te.NE||t===te.NW){const l=e.h-1,c=o>0?Math.min(o,l):o;e.y+c>=0?(i.y=e.y+c,i.h=e.h-c):(i.y=0,i.h=e.h+e.y)}return i}const pr=d.memo(({blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:o,blockId:s,handle:a,deltaCol:i,deltaRow:l,isOutside:c,selectionStyle:h,ghostZIndex:p=ae.block_ghost,selectBorderZIndex:x=ae.select_border,blockHandlesZIndex:b=ae.block_handles})=>{const g=e.find(f=>f.id===s),N=t[(g==null?void 0:g.kind)??""];if(!g||!N)return null;const E=mr({layout:g.layout,handle:a,deltaCol:i,deltaRow:l,gridCols:n.cols,gridRows:n.rows}),m={...g,layout:E},v=o(m);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:`${v.left}px`,top:`${v.top}px`,width:`${v.width}px`,height:`${v.height}px`,opacity:c?.3:.5,filter:c?"grayscale(100%)":"none",zIndex:p},children:r.jsx(It,{id:m.id,plugin:N,props:m.props,value:m.initValue,onChange:()=>{},readOnly:!0,mode:ge.EDIT,blockSizePx:v,blockZIndex:p,className:"resize-ghost-content"})}),r.jsx(ut,{block:m,rect:v,selectionStyle:h,selectBorderZIndex:x,blockHandlesZIndex:b})]},g.id)})});pr.displayName="ResizeGhost";const vr=d.memo(({blocks:e,pluginRegistry:t,gridLength:n,draggingState:o,getBlockRectPx:s,selectionStyle:a=Ct,ghostZIndex:i=ae.block_ghost,selectBorderZIndex:l=ae.select_border,blockHandlesZIndex:c=ae.block_handles})=>{if(!o)return null;const h=o.currentGrid.col-o.startGrid.col,p=o.currentGrid.row-o.startGrid.row;switch(o.type){case me.MOVE:return r.jsx(hr,{blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:s,selectedBlockIds:o.blockIds,deltaCol:h,deltaRow:p,isOutside:o.isOutside??!1,currentMousePx:o.currentMousePx,selectionStyle:a,ghostZIndex:i,selectBorderZIndex:l,blockHandlesZIndex:c});case me.RESIZE:{const x=o.blockIds[0];return!x||!o.handle?null:r.jsx(pr,{blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:s,blockId:x,handle:o.handle,deltaCol:h,deltaRow:p,isOutside:o.isOutside??!1,selectionStyle:a,ghostZIndex:i,selectBorderZIndex:l,blockHandlesZIndex:c})}case me.INSERT:return o.defaultSize?r.jsx(dr,{pluginRegistry:t,gridLength:n,getBlockRectPx:s,currentGrid:o.currentGrid,currentMousePx:o.currentMousePx,pluginKind:o.pluginKind||"",defaultSize:o.defaultSize,isOutside:o.isOutside??!1,selectionStyle:a,ghostZIndex:i,selectBorderZIndex:l,blockHandlesZIndex:c}):null;default:return null}});vr.displayName="DragLayer";const zs=({id:e,plugin:t,props:n,value:o,onChange:s,onBlur:a,blockRectPx:i,zIndex:l=F.EDIT_BLOCK,validationState:c,className:h=""},p)=>{const x=d.useRef(null);d.useImperativeHandle(p,()=>({focus:()=>{var m;(m=x.current)==null||m.focus()}}),[]);const b=sn(i,{zIndex:l,pointerEvents:"auto"}),g={width:i.width,height:i.height},N={id:e,props:n,value:o,onChange:s,onBlur:a,readOnly:!1,mode:ge.FORM,dimensions:{widthPx:g.width,heightPx:g.height},validationState:c},E=t.Renderer;return r.jsx("div",{className:h,style:b,"data-testid":"editing-block","data-block-id":e,"data-plugin-kind":t.kind,children:r.jsx(E,{ref:x,...N})})},Ks=d.forwardRef(zs),Hs=d.memo(Ks),xr=d.memo(({blocks:e,selectedBlockIds:t,isDragging:n,draggingState:o,getBlockRectPx:s,onResizeStart:a,selectionStyle:i=Ct,handleStyle:l=cn,selectBorderZIndex:c=ae.select_border,blockHandlesZIndex:h=ae.block_handles})=>{if(n&&(o==null?void 0:o.type)!==me.RESIZE)return null;const x=Array.from(new Set(t));return r.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:x.map(b=>{const g=e.find(m=>m.id===b);if(!g)return null;const E=(o==null?void 0:o.type)===me.RESIZE&&o.blockIds.includes(b)?o==null?void 0:o.handle:null;return r.jsx(ut,{block:g,rect:s(g),showHandles:!0,onResizeStart:(m,v)=>a(m,v,b),activeHandle:E,selectionStyle:i,handleStyle:l,selectBorderZIndex:c,blockHandlesZIndex:h},g.id)})})});xr.displayName="SelectionLayer";function Xs(e,t,n,o){const s=n-t.w,a=o-t.h;return{x:Math.max(0,Math.min(e.x,s)),y:Math.max(0,Math.min(e.y,a))}}function Pn(e,t,n){const{x:o,y:s}=e;for(let a=t.length-1;a>=0;a--){const i=t[a];if(!i)continue;const l=n(i);if(o>=l.left&&o<=l.left+l.width&&s>=l.top&&s<=l.top+l.height)return i.id}return null}const br=d.memo(({blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:o,getColIndex:s,getRowIndex:a,state:i,onChange:l,onBlockChange:c,scale:h=1,className:p="",selectionStyle:x,handleStyle:b,editBlockZIndex:g=F.EDIT_BLOCK,selectBorderZIndex:N=ae.select_border,blockHandlesZIndex:E=ae.block_handles,dragGhostZIndex:m=ae.block_ghost})=>{const v=d.useRef(null),f=d.useRef(null);d.useEffect(()=>{i.mode===X.EDITING&&i.editingBlockId&&setTimeout(()=>{var I;(I=f.current)==null||I.focus()},0)},[i.mode,i.editingBlockId]),d.useEffect(()=>{const I=new Set(e.map(M=>M.id)),k=i.selectedBlockIds.filter(M=>I.has(M));k.length!==i.selectedBlockIds.length&&l({type:U.SELECT,blockIds:k,shiftKey:!1})},[e,i.selectedBlockIds,l]);const y=d.useCallback(I=>{var D;if(I.button!==0)return;const k=(D=v.current)==null?void 0:D.getBoundingClientRect();if(!k)return;const M=h??1,G={x:(I.clientX-k.left)/M,y:(I.clientY-k.top)/M},T=Pn(G,e,o);if(i.mode===X.EDITING){T!==i.editingBlockId&&(l({type:U.END_EDIT}),T||l({type:U.DESELECT}));return}const S=s(G.x),j=a(G.y);if(T){I.stopPropagation();const P=i.selectedBlockIds.includes(T);if(console.log("[InteractionLayer] PointerDown on block:",{targetId:T,shiftKey:I.shiftKey,isAlreadySelected:P,currentSelection:i.selectedBlockIds}),P&&I.shiftKey){console.log("[InteractionLayer] Shift+Click deselect:",T);const A=i.selectedBlockIds.filter(K=>K!==T);console.log("[InteractionLayer] New selection:",A),l({type:U.SELECT,blockIds:A,shiftKey:!0});return}else P?(I.currentTarget.setPointerCapture(I.pointerId),l({type:U.START_PRESS,blockId:T,startGrid:{col:S,row:j},selectedBlockIds:i.selectedBlockIds})):(I.currentTarget.setPointerCapture(I.pointerId),I.shiftKey?l({type:U.SELECT,blockIds:[...i.selectedBlockIds,T],shiftKey:!0}):(l({type:U.SELECT,blockIds:[T]}),l({type:U.START_PRESS,blockId:T,startGrid:{col:S,row:j},selectedBlockIds:[T]})))}else I.stopPropagation(),l({type:U.DESELECT})},[e,o,s,a,i.mode,i.selectedBlockIds,l,h,i.editingBlockId]),w=d.useCallback(I=>{var Q;if(i.mode!==X.PRESSING&&i.mode!==X.DRAGGING||!i.dragging)return;const k=(Q=v.current)==null?void 0:Q.getBoundingClientRect();if(!k)return;const M=h??1,G=k.width/M,T=k.height/M,S=(I.clientX-k.left)/M,j=(I.clientY-k.top)/M,D=i.dragging.type!==me.RESIZE&&(S<0||S>G||j<0||j>T),P=Math.max(0,Math.min(S,G)),A=Math.max(0,Math.min(j,T)),K=s(P),Z=a(A);l({type:U.UPDATE_DRAG,currentGrid:{col:K,row:Z},currentMousePx:{x:S,y:j},isOutside:D})},[i.mode,i.dragging,s,a,l,h]),R=d.useCallback(I=>{if(i.mode===X.DRAGGING&&i.dragging){if(i.dragging.isOutside){i.dragging.type===me.MOVE&&(c==null||c({type:be.DELETE,blockIds:i.dragging.blockIds}),l({type:U.DESELECT})),l({type:U.END_DRAG}),I.currentTarget.releasePointerCapture(I.pointerId);return}const k=i.dragging.currentGrid.col-i.dragging.startGrid.col,M=i.dragging.currentGrid.row-i.dragging.startGrid.row;if(i.dragging.type===me.MOVE){if(k!==0||M!==0){const G=i.dragging.blockIds.map(j=>e.find(D=>D.id===j)).filter(Boolean);if(G.length===0){l({type:U.END_DRAG}),I.currentTarget.releasePointerCapture(I.pointerId);return}const T=fr(G,k,M,n.cols,n.rows),S=G.map(j=>{const D=T.find(P=>P.blockId===j.id);return D?{...j,layout:{...j.layout,x:D.x,y:D.y}}:j});c==null||c({type:be.MOVE,blockIds:i.dragging.blockIds,blocks:S})}}else if(i.dragging.type===me.INSERT){const{pluginKind:G,currentGrid:T,defaultSize:S}=i.dragging;if(G&&S){const j=t[G];if(j){const{x:D,y:P}=Xs({x:T.col,y:T.row},{w:S.w,h:S.h},n.cols,n.rows),A=Fe(j,{x:D,y:P,w:S.w,h:S.h});c==null||c({type:be.ADD,blockIds:[A.id],blocks:[A]})}}}else if(i.dragging.type===me.RESIZE){const G=i.dragging.blockIds[0],T=e.find(j=>j.id===G),S=i.dragging.handle;if(T&&S&&(k!==0||M!==0)){const j=mr({layout:T.layout,handle:S,deltaCol:k,deltaRow:M,gridCols:n.cols,gridRows:n.rows});(j.x!==T.layout.x||j.y!==T.layout.y||j.w!==T.layout.w||j.h!==T.layout.h)&&(c==null||c({type:be.RESIZE,blockIds:[T.id],blocks:[{...T,layout:j}]}))}}l({type:U.END_DRAG})}else i.mode===X.PRESSING&&i.dragging&&(i.dragging.isOutside&&i.dragging.type===me.MOVE&&(c==null||c({type:be.DELETE,blockIds:i.dragging.blockIds}),l({type:U.DESELECT})),l({type:U.CANCEL_DRAG}));I.currentTarget.releasePointerCapture(I.pointerId)},[i.mode,i.dragging,e,n,t,c,l]),L=d.useCallback(I=>{var S;const k=(S=v.current)==null?void 0:S.getBoundingClientRect();if(!k)return;const M=h??1,G={x:(I.clientX-k.left)/M,y:(I.clientY-k.top)/M},T=Pn(G,e,o);T&&(i.selectedBlockIds.includes(T)||l({type:U.SELECT,blockIds:[T]}),l({type:U.EDIT,blockId:T}))},[e,o,l,h,i.selectedBlockIds]),$=d.useCallback(I=>{var k;if((i.mode===X.PRESSING||i.mode===X.DRAGGING)&&i.dragging){const M=(k=v.current)==null?void 0:k.getBoundingClientRect();if(M){const G=h??1,T=(I.clientX-M.left)/G,S=(I.clientY-M.top)/G,j=M.width/G,D=M.height/G,P=Math.max(0,Math.min(T,j)),A=Math.max(0,Math.min(S,D));l({type:U.UPDATE_DRAG,currentGrid:{col:s(P),row:a(A)},currentMousePx:{x:T,y:S},isOutside:!0})}}},[i.mode,i.dragging,h,s,a,l]);return r.jsxs("div",{ref:v,className:p,style:{position:"absolute",inset:0,zIndex:F.INTERACTION_LAYER_BASE,pointerEvents:"auto",touchAction:"none"},role:"application","aria-label":"Interactive canvas layer",tabIndex:-1,onPointerDown:y,onPointerMove:w,onPointerUp:R,onPointerLeave:$,onDoubleClick:L,"data-testid":"interaction-layer",children:[i.editingBlockId&&(()=>{const I=e.find(M=>M.id===i.editingBlockId),k=I?t[I.kind]:null;return!I||!k?null:r.jsx(Hs,{ref:f,id:I.id,plugin:k,props:I.props,value:I.initValue,onChange:M=>{c==null||c({type:be.UPDATE,blockIds:[I.id],blocks:[{...I,initValue:M}]})},onBlur:M=>{c==null||c({type:be.UPDATE,blockIds:[I.id],blocks:[{...I,initValue:M}]})},blockRectPx:o(I),zIndex:g})})(),r.jsx(xr,{blocks:e,selectedBlockIds:i.selectedBlockIds,isDragging:i.mode===X.DRAGGING,draggingState:i.dragging,getBlockRectPx:o,onResizeStart:(I,k,M)=>{var j;const G=(j=v.current)==null?void 0:j.getBoundingClientRect();if(!G)return;i.mode===X.EDITING&&l({type:U.END_EDIT}),I.currentTarget.setPointerCapture(I.pointerId);const T=h??1,S={x:(I.clientX-G.left)/T,y:(I.clientY-G.top)/T};l({type:U.START_RESIZE,blockId:M,handle:k,startGrid:{col:s(S.x),row:a(S.y)}})},selectionStyle:x,handleStyle:b,selectBorderZIndex:N,blockHandlesZIndex:E}),r.jsx(vr,{blocks:e,pluginRegistry:t,gridLength:n,draggingState:i.dragging,getBlockRectPx:o,selectionStyle:x,ghostZIndex:m,selectBorderZIndex:N,blockHandlesZIndex:E})]})});br.displayName="InteractionLayer";const un=d.memo(({schema:e,pluginRegistry:t,onSchemaChange:n,onSelectionChange:o,scale:s=1,className:a})=>{const[i,l]=Fs(),{paperPx:c,gridPosPx:h,getBlockRectPx:p,getColIndex:x,getRowIndex:b}=an(e.paper,e.grid,q),g=d.useCallback(w=>{if(n)switch(w.type){case be.MOVE:case be.RESIZE:{if(!w.blocks)return;const R=e.blocks.map(L=>{var I;return((I=w.blocks)==null?void 0:I.find(k=>k.id===L.id))||L});n({...e,blocks:R});break}case be.ADD:{if(!w.blocks)return;n({...e,blocks:[...e.blocks,...w.blocks]});break}case be.DELETE:{const R=new Set(w.blockIds),L=e.blocks.filter($=>!R.has($.id));n({...e,blocks:L});break}case be.UPDATE:{if(!w.blocks)return;const R=e.blocks.map(L=>{var M;const $=(M=w.blocks)==null?void 0:M.find(G=>G.id===L.id);if(!$)return L;const I=$.style?wt($.style):$.style,k=$.props?wt($.props):$.props;return{...L,...$,style:I,props:k}});n({...e,blocks:R});break}}},[e,n]),N=d.useCallback((w,R)=>{if(!n)return;const L=e.blocks.map($=>$.id===w?{...$,initValue:R}:$);n({...e,blocks:L})},[e,n]);d.useEffect(()=>{o&&o(i.selectedBlockIds)},[i.selectedBlockIds,o]);const E=d.useCallback((w,R,L)=>{if(!n)return;const $=R-1;if(w==="column"){const I=Kt(e.grid.cols,$,L,c.content.width);n({...e,grid:{...e.grid,cols:I}})}else{const I=Kt(e.grid.rows,$,L,c.content.height);n({...e,grid:{...e.grid,rows:I}})}},[e,c,n]),m=d.useCallback((w,R,L)=>{if(n)if(w==="column"){const $=[...e.grid.cols];$[R]=L,n({...e,grid:{...e.grid,cols:$}})}else{const $=[...e.grid.rows];$[R]=L,n({...e,grid:{...e.grid,rows:$}})}},[n,e]),v=d.useMemo(()=>e.blocks.reduce((w,R)=>(w[R.id]=R.initValue,w),{}),[e.blocks]),f=d.useCallback(()=>{const w=xt.get();w&&i.mode!==X.DRAGGING&&l({type:U.START_INSERT,pluginKind:w.kind,defaultSize:w.defaultSize})},[i.mode,l]),y=d.useCallback(()=>{},[]);return r.jsxs("div",{className:a,onPointerEnter:f,onPointerLeave:y,style:{position:"relative",width:`${c.canvas.width}px`,height:`${c.canvas.height}px`,margin:"0 auto",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",backgroundColor:"#fff",transform:s!==1?`scale(${s})`:void 0,transformOrigin:"top center"},children:[r.jsx(Nt,{paperPx:c,gridPosPxs:h,gridDimensions:{cols:e.grid.cols,rows:e.grid.rows},showGridLines:!0,showMargins:!0,showBorder:!0,showResizeHandles:!0,showDimensionLabels:!0,onGridResize:E,onDimensionChange:m,gridLineStyle:{color:"#e5e7eb",width:{value:1,unit:"px"},type:ye.SOLID},borderStyle:{all:{color:"#000000",width:{value:1,unit:"px"},type:ye.SOLID}}}),r.jsx(Dt,{blocks:e.blocks,pluginRegistry:t,mode:ge.FORM,values:v,selectedBlockIds:i.selectedBlockIds,getBlockRectPx:p,onValueChange:N,showGuides:!0,showBorder:!0}),r.jsx(br,{blocks:e.blocks,gridLength:{cols:e.grid.cols.length,rows:e.grid.rows.length},pluginRegistry:t,getBlockRectPx:p,getColIndex:x,getRowIndex:b,state:i,onChange:l,onBlockChange:g,scale:s})]})});un.displayName="NoteForm";const gr=({schema:e,values:t,pluginRegistry:n,scale:o=1,className:s,printMode:a=!1,printSettings:i},l)=>{const c=d.useRef(null),{paperPx:h,gridPosPx:p,getBlockRectPx:x}=an(e.paper,e.grid,q);return d.useEffect(()=>{if(!i)return;const b=document.getElementById("dynamic-print-page-style");b&&b.remove();const g=document.createElement("style");g.id="dynamic-print-page-style";const{paperSize:N="A4",orientation:E="portrait",margin:m}=i,v=E==="landscape"?`${N} landscape`:`${N} portrait`;return g.textContent=`
31
+ @media print {
32
+ @page {
33
+ size: ${v};
34
+ margin: ${(m==null?void 0:m.top)||"10mm"}
35
+ ${(m==null?void 0:m.right)||"10mm"}
36
+ ${(m==null?void 0:m.bottom)||"10mm"}
37
+ ${(m==null?void 0:m.left)||"10mm"};
38
+ }
39
+ }
40
+ `,document.head.appendChild(g),()=>{const f=document.getElementById("dynamic-print-page-style");f&&f.remove()}},[i]),d.useImperativeHandle(l,()=>({print:()=>{qt({title:"Document"})},openPrintPreview:()=>{qt({title:"Document"})}}),[]),r.jsxs("div",{ref:c,className:s,"data-print-mode":a,style:{position:"relative",width:`${h.canvas.width}px`,height:`${h.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(Nt,{paperPx:h,gridPosPxs:p,showGridLines:!1,showMargins:!1,showBorder:!1}),r.jsx(Dt,{blocks:e.blocks,pluginRegistry:n,mode:ge.VIEW,values:t,getBlockRectPx:x,showGuides:!1,showBorder:!0})]})};gr.displayName="NoteView";const yr=d.memo(d.forwardRef(gr)),wr=d.memo(({schema:e,values:t,mode:n,pluginRegistry:o,onSchemaChange:s,onValuesChange:a,onSelectionChange:i,scale:l=1,className:c})=>{const h=d.useCallback((p,x)=>{a&&a({...t,[p]:x})},[t,a]);return n===ge.FORM?r.jsx(un,{schema:e,pluginRegistry:o,onSchemaChange:s,onSelectionChange:i,scale:l,className:c}):n===ge.EDIT?r.jsx(ln,{schema:e,values:t,pluginRegistry:o,onValueChange:h,scale:l,className:c}):r.jsx(yr,{schema:e,values:t,pluginRegistry:o,scale:l,className:c})});wr.displayName="NoteEditor";function Re(e,t){if(e.length===0)return;const n=(i,l)=>{let c=i;for(const h of l){if(c==null||typeof c!="object"||Array.isArray(c))return;c=c[h]}return c},o=t.split("."),s=n(e[0],o);return e.every(i=>n(i,o)===s)?s:void 0}const qs="_container_1tfjv_1",Js="_row_1tfjv_20",Zs="_inputWrapper_1tfjv_37",Vt={container:qs,row:Js,inputWrapper:Zs},Qs=({selectedBlocks:e,onUpdateBlocks:t})=>{if(e.length===0)return null;const n=o=>{const s={};e.forEach(a=>{s[a.id]={style:{...a.style,backgroundColor:o}}}),t(s)};return r.jsx("div",{className:Vt.container,children:r.jsx("div",{className:Vt.row,children:r.jsx("div",{className:Vt.inputWrapper,children:r.jsx(ct,{value:Re(e,"style.backgroundColor"),onChange:n,allowUndefined:!0,placeholder:"無色",height:24})})})})};function Te(e,t,n){const o=t.split("."),s=(a,i)=>{const l=o[i];if(i===o.length-1){if(n==null){const{[l]:p,...x}=a;return x}return{...a,[l]:n}}const c=(a==null?void 0:a[l])||{},h=s(c,i+1);if(Object.keys(h).length===0){const{[l]:p,...x}=a;return x}return{...a,[l]:h}};return s(e,0)}const ei=({selectedBlocks:e,onUpdateBlocks:t})=>{const n=(i,l,c)=>{const h={};e.forEach(p=>{var b,g,N;let x=Te(p.style||{},`border.${i}.${l}`,c);if(l==="type"&&c==null&&(x=Te(x,`border.${i}.width`,void 0),x=Te(x,`border.${i}.color`,void 0)),l==="type"&&c!==void 0&&c!==null){const E=(b=p.style)==null?void 0:b.border,m=E==null?void 0:E[i];m!=null&&m.width||(x=Te(x,`border.${i}.width`,{value:1,unit:"px"})),m!=null&&m.color||(x=Te(x,`border.${i}.color`,"#000000"))}if(l==="color"&&c!==void 0&&c!==null){const E=(g=p.style)==null?void 0:g.border,m=E==null?void 0:E[i];m!=null&&m.type||(x=Te(x,`border.${i}.type`,ye.SOLID)),m!=null&&m.width||(x=Te(x,`border.${i}.width`,{value:1,unit:"px"}))}if(l==="width"&&c!==void 0&&c!==null){const E=(N=p.style)==null?void 0:N.border,m=E==null?void 0:E[i];m!=null&&m.type||(x=Te(x,`border.${i}.type`,ye.SOLID)),m!=null&&m.color||(x=Te(x,`border.${i}.color`,"#000000"))}h[p.id]={style:x}}),t(h)},o=d.useMemo(()=>{var p;if(e.length!==1)return null;const i=e[0];if(!((p=i==null?void 0:i.style)!=null&&p.border))return null;const l=i.style.border;if(!l)return null;const c=x=>x?!(x.type&&!x.width):!0;return["all","top","right","bottom","left"].every(x=>c(l[x]))?new et(l):null},[e]),s=i=>r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[r.jsx($e,{value:Re(e,`style.border.${i}.type`),onChange:l=>n(i,"type",l),placeholder:"スタイル",height:24,options:[{label:"",value:void 0},{label:"実線",value:ye.SOLID},{label:"破線",value:ye.DASHED},{label:"点線",value:ye.DOTTED}]}),r.jsx(ce,{value:Re(e,`style.border.${i}.width`),onChange:l=>n(i,"width",l),placeholder:"太さ",height:24,allowedUnits:Gn,min:1}),r.jsx(ct,{value:Re(e,`style.border.${i}.color`),onChange:l=>n(i,"color",l),placeholder:"色",height:24,allowUndefined:!0})]}),a={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(Ve,{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(tn,{defaultValue:"all",variant:"segmented",children:[r.jsx("div",{style:{width:"100%"},children:r.jsxs(nn,{style:{width:"100%",display:"flex"},children:[r.jsx(Me,{value:"all",height:24,style:a,children:"共通"}),r.jsx(Me,{value:"top",height:24,style:a,children:"上"}),r.jsx(Me,{value:"bottom",height:24,style:a,children:"下"}),r.jsx(Me,{value:"left",height:24,style:a,children:"左"}),r.jsx(Me,{value:"right",height:24,style:a,children:"右"})]})}),r.jsxs("div",{style:{marginTop:"4px"},children:[r.jsx(Pe,{value:"all",children:s("all")}),r.jsx(Pe,{value:"top",children:s("top")}),r.jsx(Pe,{value:"bottom",children:s("bottom")}),r.jsx(Pe,{value:"left",children:s("left")}),r.jsx(Pe,{value:"right",children:s("right")})]})]})})]})},ti="_container_1daw7_1",ni="_grid_1daw7_19",ri="_field_1daw7_26",oi="_label_1daw7_33",si="_inputWrapper_1daw7_43",xe={container:ti,grid:ni,field:ri,label:oi,inputWrapper:si},ii=({selectedBlocks:e,onUpdateBlocks:t,gridSize:n})=>{if(e.length===0)return null;const o=e.length>1,s=o?Math.min(...e.map(l=>l.layout.x)):void 0,a=o?Math.min(...e.map(l=>l.layout.y)):void 0,i=(l,c)=>{if(c===void 0)return;const h={};if(o&&(l==="x"||l==="y")){const p=l==="x"?s:a;if(p===void 0)return;const x=Math.max(...e.map(v=>v.layout.x+v.layout.w)),b=Math.max(...e.map(v=>v.layout.y+v.layout.h)),g=x-(s??0),N=b-(a??0);let E=c;l==="x"&&n?E=Math.max(0,Math.min(c,n.cols-g)):l==="y"&&n?E=Math.max(0,Math.min(c,n.rows-N)):E=Math.max(0,c);const m=E-p;e.forEach(v=>{const f=v.layout[l]+m;h[v.id]={layout:{...v.layout,[l]:f}}})}else e.forEach(p=>{let x=c;if(l==="x"&&n)x=Math.max(0,Math.min(c,n.cols-p.layout.w));else if(l==="y"&&n)x=Math.max(0,Math.min(c,n.rows-p.layout.h));else if(l==="w"&&n){const b=n.cols-p.layout.x;x=Math.max(1,Math.min(c,b))}else if(l==="h"&&n){const b=n.rows-p.layout.y;x=Math.max(1,Math.min(c,b))}else l==="w"||l==="h"?x=Math.max(1,c):x=Math.max(0,c);h[p.id]={layout:{...p.layout,[l]:x}}});t(h)};return r.jsx("div",{className:xe.container,children:r.jsxs("div",{className:xe.grid,children:[r.jsxs("div",{className:xe.field,children:[r.jsx("span",{className:xe.label,children:"X"}),r.jsx("div",{className:xe.inputWrapper,children:r.jsx(pe,{value:o?s:Re(e,"layout.x"),onChange:l=>i("x",l),min:0,max:n?n.cols-1:void 0,integer:!0,height:22,placeholder:"-"})})]}),r.jsxs("div",{className:xe.field,children:[r.jsx("span",{className:xe.label,children:"Y"}),r.jsx("div",{className:xe.inputWrapper,children:r.jsx(pe,{value:o?a:Re(e,"layout.y"),onChange:l=>i("y",l),min:0,max:n?n.rows-1:void 0,integer:!0,height:22,placeholder:"-"})})]}),!o&&r.jsxs("div",{className:xe.field,children:[r.jsx("span",{className:xe.label,children:"W"}),r.jsx("div",{className:xe.inputWrapper,children:r.jsx(pe,{value:Re(e,"layout.w"),onChange:l=>i("w",l),min:1,max:n==null?void 0:n.cols,integer:!0,height:22,placeholder:"-"})})]}),!o&&r.jsxs("div",{className:xe.field,children:[r.jsx("span",{className:xe.label,children:"H"}),r.jsx("div",{className:xe.inputWrapper,children:r.jsx(pe,{value:Re(e,"layout.h"),onChange:l=>i("h",l),min:1,max:n==null?void 0:n.rows,integer:!0,height:22,placeholder:"-"})})]})]})})},ai="_container_1h4w8_1",li="_row_1h4w8_10",ci="_label_1h4w8_16",ui="_inputWrapper_1h4w8_25",ze={container:ai,row:li,label:ci,inputWrapper:ui},di=({selectedBlocks:e,onUpdateBlocks:t})=>{const[n,o]=d.useState(""),s=e[0];d.useEffect(()=>{e.length===1&&s&&o(s.id)},[e,s]);const a=()=>{if(!s)return;const c=s.id,h=n.trim();if(h===c||!h){o(c);return}t({[c]:{id:h}})},i=c=>{o(c??"")},l=c=>{const h={};e.forEach(p=>{h[p.id]={behavior:{...p.behavior,readOnly:!!c}}}),t(h)};return r.jsxs("div",{className:ze.container,children:[e.length===1&&r.jsxs("div",{className:ze.row,children:[r.jsx("span",{className:ze.label,children:"ID"}),r.jsx("div",{className:ze.inputWrapper,children:r.jsx(Qe,{value:n,onChange:i,onBlur:a,placeholder:"IDを入力",height:16})})]}),e.length>0&&r.jsx("div",{className:ze.row,children:r.jsx("div",{className:ze.inputWrapper,children:r.jsx(Ie,{label:"読み取り専用",value:!!Re(e,"behavior.readOnly"),onChange:l})})})]})},fi="_container_wa11y_1",hi="_scrollArea_wa11y_18",mi="_section_wa11y_26",pi="_sectionTitle_wa11y_35",vi="_subsection_wa11y_47",xi="_subsectionTitle_wa11y_51",bi="_fields_wa11y_59",gi="_emptyState_wa11y_69",de={container:fi,scrollArea:hi,section:mi,sectionTitle:pi,subsection:vi,subsectionTitle:xi,fields:bi,emptyState:gi},yi="_field_qo0ef_1",wi="_label_qo0ef_7",_i="_mixed_qo0ef_15",Ei="_description_qo0ef_22",pt={field:yi,label:wi,mixed:_i,description:Ei},_r=d.memo(({propertyKey:e,definition:t,selectedBlocks:n,onChange:o})=>{var p;const s=t.Component;if(!s)return null;const a=Re(n,`props.${e}`),c=!n.map(x=>x.props[e]).every(x=>x===void 0)&&a===void 0&&n.length>1,h={value:c?void 0:a!==void 0?a:t.defaultValue,onChange:x=>o(e,x),readOnly:!1,config:{...t.config,placeholder:c?"複数選択中 (値が異なります)":(p=t.config)==null?void 0:p.placeholder}};return r.jsxs("div",{className:pt.field,children:[t.label&&r.jsx("div",{className:pt.label,title:t.description,children:t.label}),r.jsx(s,{...h}),c&&r.jsx("span",{className:pt.mixed,children:"(混在)"}),t.description&&r.jsx("p",{className:pt.description,children:t.description})]})});_r.displayName="PropertyField";function ji(e){return e!==!1}const dn=d.memo(({selectedBlocks:e,pluginRegistry:t,onUpdateBlocks:n,gridSize:o,className:s=""})=>{const a=e[0],i=a?t[a.kind]:void 0,l=d.useMemo(()=>{var x;if(e.length===0)return!1;const p=(x=e[0])==null?void 0:x.kind;return e.every(b=>b.kind===p)},[e]),c=d.useMemo(()=>{if(!a||!i)return{};const p={};let x;if(l)x=Object.entries(i.properties);else{const b=e.map(m=>t[m.kind]).filter(m=>m!==void 0);if(b.length===0)return{};const g=b[0];if(!g)return{};const N=new Set(Object.keys(g.properties));x=Array.from(N).filter(m=>b.every(v=>m in v.properties)).map(m=>{const v=i.properties[m];return v?[m,v]:null}).filter(m=>m!==null)}return x.forEach(([b,g])=>{if(!ji(g)||e.length>1&&g.disableInMultiSelection||g.condition&&!g.condition(a.props))return;const N=g.group||"基本";p[N]||(p[N]=[]),g.Component&&p[N].push({key:b,definition:g})}),p},[i,t,e,a,l]),h=(p,x)=>{const b={};e.forEach(g=>{b[g.id]={props:{...g.props,[p]:x}}}),n(b)};return e.length===0?r.jsx("div",{className:`${de.container} ${s}`,children:r.jsxs("div",{className:de.emptyState,children:["ブロックを選択すると",r.jsx("br",{}),"プロパティが表示されます"]})}):r.jsx("div",{className:`${de.container} ${s}`,children:r.jsxs("div",{className:de.scrollArea,children:[r.jsxs("div",{className:de.section,children:[r.jsx("div",{className:de.sectionTitle,children:"配置・サイズ"}),r.jsx(ii,{selectedBlocks:e,onUpdateBlocks:n,gridSize:o})]}),r.jsxs("div",{className:de.section,children:[r.jsx("div",{className:de.sectionTitle,children:"背景"}),r.jsx(Qs,{selectedBlocks:e,onUpdateBlocks:n})]}),r.jsxs("div",{className:de.section,children:[r.jsx("div",{className:de.sectionTitle,children:"枠線"}),r.jsx(ei,{selectedBlocks:e,onUpdateBlocks:n})]}),i&&Object.keys(c).length>0&&r.jsx("div",{className:de.section,children:Object.entries(c).map(([p,x])=>r.jsxs("div",{className:de.subsection,children:[r.jsx("div",{className:de.subsectionTitle,children:p}),r.jsx("div",{className:de.fields,children:x.map(({key:b,definition:g})=>r.jsx(_r,{propertyKey:b,definition:g,selectedBlocks:e,onChange:h},b))})]},p))}),r.jsxs("div",{className:de.section,children:[r.jsx("div",{className:de.sectionTitle,children:"基本設定"}),r.jsx(di,{selectedBlocks:e,onUpdateBlocks:n})]})]})})});dn.displayName="BlockPropertyPanel";const Ni="_container_naj39_3",Ii="_paletteItems_naj39_32",Di="_item_naj39_44",Ci="_itemPreview_naj39_77",Ri="_itemName_naj39_106",at={container:Ni,paletteItems:Ii,item:Di,itemPreview:Ci,itemName:Ri},fn=({plugins:e,className:t})=>{const[n,o]=d.useState(null),s=d.useCallback((a,i)=>{o({plugin:a,mousePos:i,isOverCanvas:!1});const l=h=>{const p=document.elementFromPoint(h.clientX,h.clientY),x=!!(p!=null&&p.closest('[data-testid="interaction-layer"]'));o(b=>b?{...b,mousePos:{x:h.clientX,y:h.clientY},isOverCanvas:x}: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:`${at.container} ${t||""}`,children:r.jsx("div",{className:at.paletteItems,children:e.map(a=>r.jsx(Er,{plugin:a,onDragStart:s},a.kind))})}),n&&!n.isOverCanvas&&r.jsx(jr,{plugin:n.plugin,mousePos:n.mousePos})]})};fn.displayName="PalettePanel";const Er=({plugin:e,onDragStart:t})=>{const n=d.useMemo(()=>Fe(e,{x:0,y:0,w:e.meta.defaultSize.w,h:e.meta.defaultSize.h},{}),[e]),o=d.useMemo(()=>{if(e.validateValue)return e.validateValue(void 0,n.props)},[e,n.props]),s=d.useCallback(a=>{a.preventDefault(),xt.start(e.kind,e.meta.defaultSize),t(e,{x:a.clientX,y:a.clientY});const i=()=>{xt.end(),window.removeEventListener("pointerup",i)};window.addEventListener("pointerup",i)},[e,t]);return r.jsxs("button",{type:"button",onPointerDown:s,className:at.item,"aria-label":`${e.meta.displayName}ブロックを追加`,children:[r.jsx("div",{className:at.itemName,children:e.meta.displayName}),r.jsx("div",{className:at.itemPreview,children:r.jsx(e.Renderer,{id:n.id,props:n.props,value:o,onChange:()=>{},readOnly:!0,mode:ge.FORM})})]})};Er.displayName="PaletteItem";const jr=({plugin:e,mousePos:t})=>{const n=d.useMemo(()=>Fe(e,{x:0,y:0,w:e.meta.defaultSize.w,h:e.meta.defaultSize.h},{}),[e]),o=d.useMemo(()=>{if(e.validateValue)return e.validateValue(void 0,n.props)},[e,n.props]),s={width:e.meta.defaultSize.w*50,height:e.meta.defaultSize.h*50};return r.jsx("div",{"data-testid":"palette-drag-ghost",style:{position:"fixed",left:`${t.x-s.width/2}px`,top:`${t.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(e.Renderer,{id:n.id,props:n.props,value:o,onChange:()=>{},readOnly:!0,mode:ge.FORM})})};jr.displayName="DragGhost";const $i="_panel_1ekwd_6",Ti="_title_1ekwd_10",Mi="_content_1ekwd_22",Pi="_description_1ekwd_29",ki="_list_1ekwd_35",Si="_item_1ekwd_44",Ai="_dragging_1ekwd_61",Oi="_dragOver_1ekwd_66",Li="_dragHandle_1ekwd_71",Gi="_itemInfo_1ekwd_86",Bi="_itemId_1ekwd_93",Fi="_itemMeta_1ekwd_98",Vi="_itemKind_1ekwd_105",Ui="_itemActions_1ekwd_113",Wi="_actionButton_1ekwd_118",Yi="_empty_1ekwd_154",oe={panel:$i,title:Ti,content:Mi,description:Pi,list:ki,item:Si,dragging:Ai,dragOver:Oi,dragHandle:Li,itemInfo:Gi,itemId:Bi,itemMeta:Fi,itemKind:Vi,itemActions:Ui,actionButton:Wi,empty:Yi},Nr=({blocks:e,onBlocksChange:t})=>{const[n,o]=d.useState(null),[s,a]=d.useState(null),i=[...e].reverse(),l=d.useCallback(m=>{const v=e.findIndex(w=>w.id===m);if(v===-1||v===e.length-1)return;const f=[...e],[y]=f.splice(v,1);y&&(f.push(y),t(f))},[e,t]),c=d.useCallback(m=>{const v=e.findIndex(w=>w.id===m);if(v===-1||v===0)return;const f=[...e],[y]=f.splice(v,1);y&&(f.unshift(y),t(f))},[e,t]),h=d.useCallback(m=>{const v=e.findIndex(R=>R.id===m);if(v===-1||v===e.length-1)return;const f=[...e],y=f[v],w=f[v+1];!y||!w||(f[v]=w,f[v+1]=y,t(f))},[e,t]),p=d.useCallback(m=>{const v=e.findIndex(R=>R.id===m);if(v===-1||v===0)return;const f=[...e],y=f[v],w=f[v-1];!y||!w||(f[v]=w,f[v-1]=y,t(f))},[e,t]),x=d.useCallback((m,v)=>{var y;o(v),m.dataTransfer.effectAllowed="move";const f=e.length-1-v;m.currentTarget&&m.dataTransfer.setData("text/plain",((y=e[f])==null?void 0:y.id)||"")},[e]),b=d.useCallback(()=>{o(null),a(null)},[]),g=d.useCallback((m,v)=>{m.preventDefault(),m.dataTransfer.dropEffect="move",!(n===null||n===v)&&a(v)},[n]),N=d.useCallback(()=>{a(null)},[]),E=d.useCallback((m,v)=>{if(m.preventDefault(),n===null||n===v){o(null),a(null);return}const f=e.length-1-n,y=e.length-1-v,w=[...e],[R]=w.splice(f,1);R&&(w.splice(y,0,R),t(w),o(null),a(null))},[e,n,t]);return r.jsxs("div",{className:oe.panel,children:[r.jsx("h3",{className:oe.title,children:"ブロック順序"}),r.jsxs("div",{className:oe.content,children:[r.jsx("p",{className:oe.description,children:"上が最前面、下が最背面"}),r.jsx("ul",{className:oe.list,children:i.map((m,v)=>{const f=e.length-1-v;return r.jsxs("li",{className:`${oe.item} ${n===v?oe.dragging:""} ${s===v?oe.dragOver:""}`,onDragOver:y=>g(y,v),onDragLeave:N,onDrop:y=>E(y,v),children:[r.jsx("button",{type:"button",className:oe.dragHandle,title:"ドラッグして並び替え",draggable:!0,onDragStart:y=>x(y,v),onDragEnd:b,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:oe.itemInfo,children:[r.jsx("div",{className:oe.itemId,children:m.id}),r.jsx("div",{className:oe.itemMeta,children:r.jsx("span",{className:oe.itemKind,children:m.kind})})]}),r.jsxs("div",{className:oe.itemActions,children:[r.jsx("button",{type:"button",className:oe.actionButton,onClick:()=>l(m.id),title:"最前面へ","aria-label":"最前面へ移動",disabled:f===e.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:oe.actionButton,onClick:()=>h(m.id),title:"前面へ","aria-label":"前面へ移動",disabled:f===e.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:oe.actionButton,onClick:()=>p(m.id),title:"背面へ","aria-label":"背面へ移動",disabled:f===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:oe.actionButton,onClick:()=>c(m.id),title:"最背面へ","aria-label":"最背面へ移動",disabled:f===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"})]})})]})]},m.id)})}),e.length===0&&r.jsx("div",{className:oe.empty,children:"ブロックがありません"})]})]})};Nr.displayName="BlockOrderPanel";const zi="_container_1bfk3_6",Ki="_scrollArea_1bfk3_23",Hi="_emptyState_1bfk3_31",Ut={container:zi,scrollArea:Ki,emptyState:Hi},Ir=({children:e,emptyMessage:t,className:n})=>r.jsx("div",{className:`${Ut.container} ${n||""}`,children:e?r.jsx("div",{className:Ut.scrollArea,children:e}):t&&r.jsx("div",{className:Ut.emptyState,children:t})}),Dr=({schema:e,onSchemaChange:t})=>{const n=d.useCallback(a=>{t({...e,paper:a})},[e,t]),o=d.useCallback(a=>{t({...e,grid:a})},[e,t]),s=d.useCallback(a=>{t({...e,blocks:a})},[e,t]);return r.jsxs(Ir,{children:[r.jsx($r,{paper:e.paper,onPaperChange:n}),r.jsx(Rr,{paper:e.paper,onPaperChange:n}),r.jsx(Cr,{grid:e.grid,onGridChange:o}),r.jsx(Nr,{blocks:e.blocks,onBlocksChange:s})]})};Dr.displayName="CanvasPanel";const Xi="_panel_1axyd_6",qi="_title_1axyd_10",Ji="_content_1axyd_22",Zi="_field_1axyd_29",Qi="_horizontal_1axyd_35",ea="_label_1axyd_41",ta="_gridSizeRow_1axyd_52",Ce={panel:Xi,title:qi,content:Ji,field:Zi,horizontal:Qi,label:ea,gridSizeRow:ta},Cr=({grid:e,onGridChange:t})=>{const n=d.useCallback(s=>{if(!s||s<1||s>100)return;const a=e.cols.length,i=[];if(s>a){i.push(...e.cols);for(let l=a;l<s;l++)i.push({value:1,unit:"fr"})}else i.push(...e.cols.slice(0,s));t({...e,cols:i})},[e,t]),o=d.useCallback(s=>{if(!s||s<1||s>100)return;const a=e.rows.length,i=[];if(s>a){i.push(...e.rows);for(let l=a;l<s;l++)i.push({value:1,unit:"fr"})}else i.push(...e.rows.slice(0,s));t({...e,rows:i})},[e,t]);return r.jsxs("div",{className:Ce.panel,children:[r.jsx("h3",{className:Ce.title,children:"グリッドサイズ"}),r.jsx("div",{className:Ce.content,children:r.jsxs("div",{className:Ce.gridSizeRow,children:[r.jsxs("div",{className:`${Ce.field} ${Ce.horizontal}`,children:[r.jsx("span",{className:Ce.label,children:"列数"}),r.jsx(pe,{value:e.cols.length,onChange:n,min:1,max:100,step:1})]}),r.jsxs("div",{className:`${Ce.field} ${Ce.horizontal}`,children:[r.jsx("span",{className:Ce.label,children:"行数"}),r.jsx(pe,{value:e.rows.length,onChange:o,min:1,max:100,step:1})]})]})})]})};Cr.displayName="GridSizePanel";const na="_panel_qlcb6_6",ra="_header_qlcb6_10",oa="_title_qlcb6_20",sa="_headerActions_qlcb6_29",ia="_content_qlcb6_33",aa="_field_qlcb6_37",la="_horizontal_qlcb6_43",ca="_label_qlcb6_49",ua="_marginsGrid_qlcb6_60",da="_topMargin_qlcb6_66",fa="_bottomMargin_qlcb6_67",ha="_sideMargins_qlcb6_73",re={panel:na,header:ra,title:oa,headerActions:sa,content:ia,field:aa,horizontal:la,label:ca,marginsGrid:ua,topMargin:da,bottomMargin:fa,sideMargins:ha},Rr=({paper:e,onPaperChange:t})=>{const[n,o]=d.useState(!1),s=d.useCallback(h=>{h!==void 0&&o(h)},[]),a=d.useCallback(h=>{if(!h)return;const p=n?{top:h,right:h,bottom:h,left:h}:{...e.margin,top:h};t({...e,margin:p})},[e,t,n]),i=d.useCallback(h=>{h&&t({...e,margin:{...e.margin,right:h}})},[e,t]),l=d.useCallback(h=>{h&&t({...e,margin:{...e.margin,bottom:h}})},[e,t]),c=d.useCallback(h=>{h&&t({...e,margin:{...e.margin,left:h}})},[e,t]);return r.jsxs("div",{className:re.panel,children:[r.jsxs("div",{className:re.header,children:[r.jsx("h3",{className:re.title,children:"マージン"}),r.jsx("div",{className:re.headerActions,children:r.jsx(Ie,{value:n,onChange:s,label:"全辺を一括設定"})})]}),r.jsx("div",{className:re.content,children:n?r.jsxs("div",{className:`${re.field} ${re.horizontal}`,children:[r.jsx("span",{className:re.label,children:"全辺"}),r.jsx(ce,{value:e.margin.top,onChange:a,allowedUnits:["mm","cm","inch"],min:0,max:1e3})]}):r.jsxs("div",{className:re.marginsGrid,children:[r.jsx("div",{className:`${re.field} ${re.horizontal} ${re.topMargin}`,children:r.jsx(ce,{value:e.margin.top,onChange:a,allowedUnits:["mm","cm","inch"],min:0,max:1e3})}),r.jsxs("div",{className:re.sideMargins,children:[r.jsx("div",{className:`${re.field} ${re.horizontal}`,children:r.jsx(ce,{value:e.margin.left,onChange:c,allowedUnits:["mm","cm","inch"],min:0,max:1e3})}),r.jsx("div",{className:`${re.field} ${re.horizontal}`,children:r.jsx(ce,{value:e.margin.right,onChange:i,allowedUnits:["mm","cm","inch"],min:0,max:1e3})})]}),r.jsx("div",{className:`${re.field} ${re.horizontal} ${re.bottomMargin}`,children:r.jsx(ce,{value:e.margin.bottom,onChange:l,allowedUnits:["mm","cm","inch"],min:0,max:1e3})})]})})]})};Rr.displayName="MarginPanel";const ma="_panel_16d9o_6",pa="_title_16d9o_10",va="_content_16d9o_22",xa="_field_16d9o_29",ba="_horizontal_16d9o_35",ga="_label_16d9o_41",ya="_dimensionsRow_16d9o_52",je={panel:ma,title:pa,content:va,field:xa,horizontal:ba,label:ga,dimensionsRow:ya},$r=({paper:e,onPaperChange:t})=>{const n=d.useMemo(()=>[{value:Ne.A4,label:"A4 (210 × 297 mm)"},{value:Ne.A3,label:"A3 (297 × 420 mm)"},{value:Ne.B5,label:"B5 (182 × 257 mm)"},{value:Ne.LETTER,label:"Letter (8.5 × 11 inch)"},{value:Ne.LEGAL,label:"Legal (8.5 × 14 inch)"},{value:Ne.CUSTOM,label:"カスタム"}],[]),o=d.useCallback(l=>{if(!l)return;const c=rn[l];t({...e,size:c})},[e,t]),s=d.useCallback(l=>{if(!l)return;const c={...e.size,preset:Ne.CUSTOM,width:l};t({...e,size:c})},[e,t]),a=d.useCallback(l=>{if(!l)return;const c={...e.size,preset:Ne.CUSTOM,height:l};t({...e,size:c})},[e,t]),i=e.size.preset===Ne.CUSTOM;return r.jsxs("div",{className:je.panel,children:[r.jsx("h3",{className:je.title,children:"用紙サイズ"}),r.jsxs("div",{className:je.content,children:[r.jsx("div",{className:je.field,children:r.jsx($e,{value:e.size.preset,options:n,onChange:o})}),i&&r.jsxs("div",{className:je.dimensionsRow,children:[r.jsxs("div",{className:`${je.field} ${je.horizontal}`,children:[r.jsx("span",{className:je.label,children:"幅"}),r.jsx(ce,{value:e.size.width,onChange:s,allowedUnits:["mm","cm","inch"],min:1,max:1e4})]}),r.jsxs("div",{className:`${je.field} ${je.horizontal}`,children:[r.jsx("span",{className:je.label,children:"高さ"}),r.jsx(ce,{value:e.size.height,onChange:a,allowedUnits:["mm","cm","inch"],min:1,max:1e4})]})]})]})]})};$r.displayName="PaperSizePanel";const wa="_section_p4xnx_6",_a="_title_p4xnx_14",Ea="_content_p4xnx_26",ja="_buttonGroup_p4xnx_33",Na="_button_p4xnx_33",Ia="_error_p4xnx_65",se={section:wa,title:_a,content:Ea,buttonGroup:ja,button:Na,error:Ia},Tr=({schema:e,values:t,onSchemaChange:n,onValuesChange:o})=>{const[s,a]=d.useState(""),i=d.useRef(null),l=d.useRef(null),c=d.useCallback(()=>{try{const f=Zt(e,!0),y=new Blob([f],{type:"application/json"}),w=URL.createObjectURL(y),R=document.createElement("a");R.href=w,R.download="schema.json",R.click(),URL.revokeObjectURL(w),a("")}catch(f){a(`エクスポートエラー: ${f instanceof Error?f.message:String(f)}`)}},[e]),h=d.useCallback(async()=>{try{const f=Zt(e,!0);await navigator.clipboard.writeText(f),a(""),alert("スキーマをクリップボードにコピーしました")}catch(f){a(`クリップボードエラー: ${f instanceof Error?f.message:String(f)}`)}},[e]),p=d.useCallback(()=>{var f;(f=i.current)==null||f.click()},[]),x=d.useCallback(f=>{var R;const y=(R=f.target.files)==null?void 0:R[0];if(!y)return;const w=new FileReader;w.onload=L=>{var $;try{const I=($=L.target)==null?void 0:$.result,k=Jt(I);n(k),a(""),alert("スキーマをインポートしました")}catch(I){a(`インポートエラー: ${I instanceof Error?I.message:String(I)}`)}},w.readAsText(y),f.target.value=""},[n]),b=d.useCallback(async()=>{try{const f=await navigator.clipboard.readText(),y=Jt(f);n(y),a(""),alert("スキーマをインポートしました")}catch(f){a(`インポートエラー: ${f instanceof Error?f.message:String(f)}`)}},[n]),g=d.useCallback(()=>{try{const f=en(t,!0),y=new Blob([f],{type:"application/json"}),w=URL.createObjectURL(y),R=document.createElement("a");R.href=w,R.download="values.json",R.click(),URL.revokeObjectURL(w),a("")}catch(f){a(`エクスポートエラー: ${f instanceof Error?f.message:String(f)}`)}},[t]),N=d.useCallback(async()=>{try{const f=en(t,!0);await navigator.clipboard.writeText(f),a(""),alert("値をクリップボードにコピーしました")}catch(f){a(`クリップボードエラー: ${f instanceof Error?f.message:String(f)}`)}},[t]),E=d.useCallback(()=>{var f;(f=l.current)==null||f.click()},[]),m=d.useCallback(f=>{var R;const y=(R=f.target.files)==null?void 0:R[0];if(!y)return;const w=new FileReader;w.onload=L=>{var $;try{const I=($=L.target)==null?void 0:$.result,k=Qt(I);o(k),a(""),alert("値をインポートしました")}catch(I){a(`インポートエラー: ${I instanceof Error?I.message:String(I)}`)}},w.readAsText(y),f.target.value=""},[o]),v=d.useCallback(async()=>{try{const f=await navigator.clipboard.readText(),y=Qt(f);o(y),a(""),alert("値をインポートしました")}catch(f){a(`インポートエラー: ${f instanceof Error?f.message:String(f)}`)}},[o]);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:se.section,children:[r.jsx("h3",{className:se.title,children:"スキーマ"}),r.jsxs("div",{className:se.content,children:[r.jsxs("div",{className:se.buttonGroup,children:[r.jsx("button",{type:"button",className:se.button,onClick:c,children:"📥 ファイルにエクスポート"}),r.jsx("button",{type:"button",className:se.button,onClick:h,children:"📋 クリップボードにコピー"})]}),r.jsxs("div",{className:se.buttonGroup,children:[r.jsx("button",{type:"button",className:se.button,onClick:p,children:"📤 ファイルからインポート"}),r.jsx("button",{type:"button",className:se.button,onClick:b,children:"📋 クリップボードからペースト"})]}),r.jsx("input",{ref:i,type:"file",accept:".json",style:{display:"none"},onChange:x})]})]}),r.jsxs("div",{className:se.section,children:[r.jsx("h3",{className:se.title,children:"値"}),r.jsxs("div",{className:se.content,children:[r.jsxs("div",{className:se.buttonGroup,children:[r.jsx("button",{type:"button",className:se.button,onClick:g,children:"📥 ファイルにエクスポート"}),r.jsx("button",{type:"button",className:se.button,onClick:N,children:"📋 クリップボードにコピー"})]}),r.jsxs("div",{className:se.buttonGroup,children:[r.jsx("button",{type:"button",className:se.button,onClick:E,children:"📤 ファイルからインポート"}),r.jsx("button",{type:"button",className:se.button,onClick:v,children:"📋 クリップボードからペースト"})]}),r.jsx("input",{ref:l,type:"file",accept:".json",style:{display:"none"},onChange:m})]})]}),s&&r.jsx("div",{className:se.error,role:"alert",children:s})]})};Tr.displayName="ImportExportPanel";const Mr=({schema:e,values:t,onSchemaChange:n,onValuesChange:o})=>r.jsx(Ir,{children:r.jsx(Tr,{schema:e,values:t,onSchemaChange:n,onValuesChange:o})});Mr.displayName="OtherPanel";const Da="_container_rt0ql_3",Ca="_tabHeader_rt0ql_14",Ra="_tabContent_rt0ql_21",it={container:Da,tabHeader:Ca,tabContent:Ra},Pr=({blocks:e,selectedBlockIds:t,pluginRegistry:n,onUpdateBlocks:o,schema:s,values:a,onSchemaChange:i,onValuesChange:l,gridSize:c,className:h})=>{const p=d.useMemo(()=>Object.values(n),[n]),x=d.useMemo(()=>e.filter(g=>t.includes(g.id)),[e,t]),b=t.length>0;return r.jsx("div",{className:`${it.container} ${h||""}`,children:r.jsxs(tn,{defaultValue:"block",variant:"default",children:[r.jsxs(nn,{className:it.tabHeader,children:[r.jsx(Me,{value:"block",children:"ブロック"}),r.jsx(Me,{value:"canvas",children:"キャンバス"}),r.jsx(Me,{value:"other",children:"その他"})]}),r.jsx(Pe,{value:"block",className:it.tabContent,children:b?r.jsx(dn,{selectedBlocks:x,pluginRegistry:n,onUpdateBlocks:o,gridSize:c}):r.jsx(fn,{plugins:p})}),r.jsx(Pe,{value:"canvas",className:it.tabContent,children:r.jsx(Dr,{schema:s,onSchemaChange:i})}),r.jsx(Pe,{value:"other",className:it.tabContent,children:r.jsx(Mr,{schema:s,values:a,onSchemaChange:i,onValuesChange:l})})]})})};Pr.displayName="Sidebar";exports.ACTUAL_UNITS=Vo;exports.ALL_UNITS=Fo;exports.BLOCK_SUB_INDEX=we;exports.BORDER_UNITS=Gn;exports.BlockChangeType=be;exports.BlockPropertyPanel=dn;exports.Border=et;exports.BorderOverlay=Xn;exports.BorderRenderer=Ve;exports.Checkbox=Ie;exports.ColorPicker=ct;exports.DEFAULT_GRID=Wn;exports.DEFAULT_PAPER=Kn;exports.DEFAULT_PAPER_MARGIN=zn;exports.DEFAULT_PAPER_SIZES=rn;exports.DEFAULT_SCHEMA=ns;exports.DimensionInput=ce;exports.FONT_UNITS=Bn;exports.GRID_UNITS=Wo;exports.GridCanvas=qn;exports.GridLayer=Nt;exports.GridOverlay=er;exports.HorizontalAlign=He;exports.ImageObjectFit=Ae;exports.LineType=ye;exports.MarginOverlay=tr;exports.MultilineWhiteSpace=Je;exports.MultilineWordWrap=qe;exports.NoteEdit=ln;exports.NoteEditor=wr;exports.NoteForm=un;exports.NoteMode=ge;exports.NoteView=yr;exports.NumberInput=pe;exports.PADDING_UNITS=Ke;exports.PAPER_UNITS=Uo;exports.PalettePanel=fn;exports.PaperSizePreset=Ne;exports.SIZE_UNITS=Wt;exports.Select=$e;exports.Sidebar=Pr;exports.Tabs=tn;exports.TabsContent=Pe;exports.TabsList=nn;exports.TabsTrigger=Me;exports.TextInput=Qe;exports.ValidationSeverity=Hn;exports.VerticalAlign=Xe;exports.Z_INDEX=F;exports.alignmentDefinition=Sn;exports.assertFinite=Zo;exports.assertInteger=jt;exports.assertNonNegative=Be;exports.assertPositive=fe;exports.assertRange=Yn;exports.binarySearch=vt;exports.calculateGridResize=Kt;exports.cleanupPrint=sr;exports.createBlock=Fe;exports.createBlockId=Un;exports.createInitialProps=Vn;exports.deserializeSchema=Jt;exports.deserializeValues=Qt;exports.dimensionToString=Zn;exports.dimensionsToStrings=ms;exports.distributeRemainder=rr;exports.executePrint=qt;exports.findGridIndex=Xt;exports.fontStyleDefinition=zo;exports.getBlockContainerStyle=sn;exports.getBlockZIndex=kn;exports.getMaxBlockCount=ao;exports.getMaxStep=Ht;exports.getPaperSize=Ss;exports.getStrokeDasharray=Ze;exports.getSubZIndex=lt;exports.globalDragStore=xt;exports.gridToMms=gt;exports.gridToPxs=ks;exports.imageDefinition=Ko;exports.mmsToPxs=yt;exports.multilineDefinition=Ho;exports.paddingDefinition=Fn;exports.placeholderDefinition=Xo;exports.preparePrint=or;exports.removeUndefinedProps=wt;exports.serializeSchema=Zt;exports.serializeValues=en;exports.sizeDefinition=qo;exports.stringToDimension=Jn;exports.stringsToDimensions=cs;exports.toMm=J;exports.toPx=W;exports.universalProperties=Yo;exports.validateSchema=ir;exports.validateValues=lr;exports.validationDefinition=Jo;
31
41
  //# sourceMappingURL=index.js.map