poll-test-widgets 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/App.d.ts +2 -0
- package/dist/PollResizable.d.ts +2 -0
- package/dist/ResizableNode.d.ts +6 -0
- package/dist/TestResizable.d.ts +2 -0
- package/dist/components/Atoms.d.ts +26 -0
- package/dist/components/BaseWidgetCard.d.ts +7 -0
- package/dist/components/Poll/PollCreatorContent.d.ts +5 -0
- package/dist/components/Poll/PollDisplayContent.d.ts +4 -0
- package/dist/components/Poll/PollSettingsContent.d.ts +6 -0
- package/dist/components/Poll/PollWidget.d.ts +8 -0
- package/dist/components/Test/TestCreatorContent.d.ts +5 -0
- package/dist/components/Test/TestDisplayContent.d.ts +4 -0
- package/dist/components/Test/TestSettingsContent.d.ts +5 -0
- package/dist/components/Test/TestWidget.d.ts +8 -0
- package/dist/hooks/usePollsApi.d.ts +11 -0
- package/dist/hooks/useTestsApi.d.ts +8 -0
- package/dist/index.d.ts +2 -0
- package/dist/main.d.ts +1 -0
- package/dist/poll-test-widgets.es.js +1240 -1864
- package/dist/poll-test-widgets.umd.js +1 -30
- package/package.json +8 -5
|
@@ -1,30 +1 @@
|
|
|
1
|
-
(function(re,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("react"),require("@xyflow/react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","@xyflow/react","react-dom"],f):(re=typeof globalThis<"u"?globalThis:re||self,f(re.PollTestWidgets={},re.React,re.ReactFlow,re.ReactDOM))})(this,function(re,f,oe,ct){"use strict";var Ie={exports:{}},be={};/**
|
|
2
|
-
* @license React
|
|
3
|
-
* react-jsx-runtime.production.min.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var Fe;function pt(){if(Fe)return be;Fe=1;var n=f,r=Symbol.for("react.element"),o=Symbol.for("react.fragment"),l=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function u(s,c,x){var m,v={},b=null,d=null;x!==void 0&&(b=""+x),c.key!==void 0&&(b=""+c.key),c.ref!==void 0&&(d=c.ref);for(m in c)l.call(c,m)&&!a.hasOwnProperty(m)&&(v[m]=c[m]);if(s&&s.defaultProps)for(m in c=s.defaultProps,c)v[m]===void 0&&(v[m]=c[m]);return{$$typeof:r,type:s,key:b,ref:d,props:v,_owner:i.current}}return be.Fragment=o,be.jsx=u,be.jsxs=u,be}var we={};/**
|
|
10
|
-
* @license React
|
|
11
|
-
* react-jsx-runtime.development.js
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var He;function ut(){return He||(He=1,process.env.NODE_ENV!=="production"&&function(){var n=f,r=Symbol.for("react.element"),o=Symbol.for("react.portal"),l=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),s=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),m=Symbol.for("react.suspense_list"),v=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),d=Symbol.for("react.offscreen"),R=Symbol.iterator,w="@@iterator";function y(t){if(t===null||typeof t!="object")return null;var h=R&&t[R]||t[w];return typeof h=="function"?h:null}var g=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function k(t){{for(var h=arguments.length,j=new Array(h>1?h-1:0),E=1;E<h;E++)j[E-1]=arguments[E];_("error",t,j)}}function _(t,h,j){{var E=g.ReactDebugCurrentFrame,H=E.getStackAddendum();H!==""&&(h+="%s",j=j.concat([H]));var Y=j.map(function(L){return String(L)});Y.unshift("Warning: "+h),Function.prototype.apply.call(console[t],console,Y)}}var I=!1,A=!1,C=!1,z=!1,B=!1,U;U=Symbol.for("react.module.reference");function O(t){return!!(typeof t=="string"||typeof t=="function"||t===l||t===a||B||t===i||t===x||t===m||z||t===d||I||A||C||typeof t=="object"&&t!==null&&(t.$$typeof===b||t.$$typeof===v||t.$$typeof===u||t.$$typeof===s||t.$$typeof===c||t.$$typeof===U||t.getModuleId!==void 0))}function S(t,h,j){var E=t.displayName;if(E)return E;var H=h.displayName||h.name||"";return H!==""?j+"("+H+")":j}function W(t){return t.displayName||"Context"}function F(t){if(t==null)return null;if(typeof t.tag=="number"&&k("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case l:return"Fragment";case o:return"Portal";case a:return"Profiler";case i:return"StrictMode";case x:return"Suspense";case m:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case s:var h=t;return W(h)+".Consumer";case u:var j=t;return W(j._context)+".Provider";case c:return S(t,t.render,"ForwardRef");case v:var E=t.displayName||null;return E!==null?E:F(t.type)||"Memo";case b:{var H=t,Y=H._payload,L=H._init;try{return F(L(Y))}catch{return null}}}return null}var J=Object.assign,G=0,K,P,X,se,ne,$,de;function ue(){}ue.__reactDisabledLog=!0;function xe(){{if(G===0){K=console.log,P=console.info,X=console.warn,se=console.error,ne=console.group,$=console.groupCollapsed,de=console.groupEnd;var t={configurable:!0,enumerable:!0,value:ue,writable:!0};Object.defineProperties(console,{info:t,log:t,warn:t,error:t,group:t,groupCollapsed:t,groupEnd:t})}G++}}function ye(){{if(G--,G===0){var t={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:J({},t,{value:K}),info:J({},t,{value:P}),warn:J({},t,{value:X}),error:J({},t,{value:se}),group:J({},t,{value:ne}),groupCollapsed:J({},t,{value:$}),groupEnd:J({},t,{value:de})})}G<0&&k("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ce=g.ReactCurrentDispatcher,pe;function ae(t,h,j){{if(pe===void 0)try{throw Error()}catch(H){var E=H.stack.trim().match(/\n( *(at )?)/);pe=E&&E[1]||""}return`
|
|
18
|
-
`+pe+t}}var T=!1,p;{var M=typeof WeakMap=="function"?WeakMap:Map;p=new M}function V(t,h){if(!t||T)return"";{var j=p.get(t);if(j!==void 0)return j}var E;T=!0;var H=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Y;Y=ce.current,ce.current=null,xe();try{if(h){var L=function(){throw Error()};if(Object.defineProperty(L.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(L,[])}catch(te){E=te}Reflect.construct(t,[],L)}else{try{L.call()}catch(te){E=te}t.call(L.prototype)}}else{try{throw Error()}catch(te){E=te}t()}}catch(te){if(te&&E&&typeof te.stack=="string"){for(var N=te.stack.split(`
|
|
19
|
-
`),ee=E.stack.split(`
|
|
20
|
-
`),D=N.length-1,Q=ee.length-1;D>=1&&Q>=0&&N[D]!==ee[Q];)Q--;for(;D>=1&&Q>=0;D--,Q--)if(N[D]!==ee[Q]){if(D!==1||Q!==1)do if(D--,Q--,Q<0||N[D]!==ee[Q]){var ie=`
|
|
21
|
-
`+N[D].replace(" at new "," at ");return t.displayName&&ie.includes("<anonymous>")&&(ie=ie.replace("<anonymous>",t.displayName)),typeof t=="function"&&p.set(t,ie),ie}while(D>=1&&Q>=0);break}}}finally{T=!1,ce.current=Y,ye(),Error.prepareStackTrace=H}var ve=t?t.displayName||t.name:"",he=ve?ae(ve):"";return typeof t=="function"&&p.set(t,he),he}function We(t,h,j){return V(t,!1)}function At(t){var h=t.prototype;return!!(h&&h.isReactComponent)}function ze(t,h,j){if(t==null)return"";if(typeof t=="function")return V(t,At(t));if(typeof t=="string")return ae(t);switch(t){case x:return ae("Suspense");case m:return ae("SuspenseList")}if(typeof t=="object")switch(t.$$typeof){case c:return We(t.render);case v:return ze(t.type,h,j);case b:{var E=t,H=E._payload,Y=E._init;try{return ze(Y(H),h,j)}catch{}}}return""}var je=Object.prototype.hasOwnProperty,Ze={},Qe=g.ReactDebugCurrentFrame;function Ee(t){if(t){var h=t._owner,j=ze(t.type,t._source,h?h.type:null);Qe.setExtraStackFrame(j)}else Qe.setExtraStackFrame(null)}function Bt(t,h,j,E,H){{var Y=Function.call.bind(je);for(var L in t)if(Y(t,L)){var N=void 0;try{if(typeof t[L]!="function"){var ee=Error((E||"React class")+": "+j+" type `"+L+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof t[L]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ee.name="Invariant Violation",ee}N=t[L](h,L,E,j,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(D){N=D}N&&!(N instanceof Error)&&(Ee(H),k("%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).",E||"React class",j,L,typeof N),Ee(null)),N instanceof Error&&!(N.message in Ze)&&(Ze[N.message]=!0,Ee(H),k("Failed %s type: %s",j,N.message),Ee(null))}}}var Mt=Array.isArray;function Ae(t){return Mt(t)}function Nt(t){{var h=typeof Symbol=="function"&&Symbol.toStringTag,j=h&&t[Symbol.toStringTag]||t.constructor.name||"Object";return j}}function Lt(t){try{return qe(t),!1}catch{return!0}}function qe(t){return""+t}function $e(t){if(Lt(t))return k("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Nt(t)),qe(t)}var et=g.ReactCurrentOwner,Ft={key:!0,ref:!0,__self:!0,__source:!0},tt,ot;function Ht(t){if(je.call(t,"ref")){var h=Object.getOwnPropertyDescriptor(t,"ref").get;if(h&&h.isReactWarning)return!1}return t.ref!==void 0}function Yt(t){if(je.call(t,"key")){var h=Object.getOwnPropertyDescriptor(t,"key").get;if(h&&h.isReactWarning)return!1}return t.key!==void 0}function Ut(t,h){typeof t.ref=="string"&&et.current}function Gt(t,h){{var j=function(){tt||(tt=!0,k("%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)",h))};j.isReactWarning=!0,Object.defineProperty(t,"key",{get:j,configurable:!0})}}function Xt(t,h){{var j=function(){ot||(ot=!0,k("%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)",h))};j.isReactWarning=!0,Object.defineProperty(t,"ref",{get:j,configurable:!0})}}var Vt=function(t,h,j,E,H,Y,L){var N={$$typeof:r,type:t,key:h,ref:j,props:L,_owner:Y};return N._store={},Object.defineProperty(N._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(N,"_self",{configurable:!1,enumerable:!1,writable:!1,value:E}),Object.defineProperty(N,"_source",{configurable:!1,enumerable:!1,writable:!1,value:H}),Object.freeze&&(Object.freeze(N.props),Object.freeze(N)),N};function Jt(t,h,j,E,H){{var Y,L={},N=null,ee=null;j!==void 0&&($e(j),N=""+j),Yt(h)&&($e(h.key),N=""+h.key),Ht(h)&&(ee=h.ref,Ut(h,H));for(Y in h)je.call(h,Y)&&!Ft.hasOwnProperty(Y)&&(L[Y]=h[Y]);if(t&&t.defaultProps){var D=t.defaultProps;for(Y in D)L[Y]===void 0&&(L[Y]=D[Y])}if(N||ee){var Q=typeof t=="function"?t.displayName||t.name||"Unknown":t;N&&Gt(L,Q),ee&&Xt(L,Q)}return Vt(t,N,ee,H,E,et.current,L)}}var Be=g.ReactCurrentOwner,nt=g.ReactDebugCurrentFrame;function me(t){if(t){var h=t._owner,j=ze(t.type,t._source,h?h.type:null);nt.setExtraStackFrame(j)}else nt.setExtraStackFrame(null)}var Me;Me=!1;function Ne(t){return typeof t=="object"&&t!==null&&t.$$typeof===r}function it(){{if(Be.current){var t=F(Be.current.type);if(t)return`
|
|
22
|
-
|
|
23
|
-
Check the render method of \``+t+"`."}return""}}function Kt(t){return""}var st={};function Dt(t){{var h=it();if(!h){var j=typeof t=="string"?t:t.displayName||t.name;j&&(h=`
|
|
24
|
-
|
|
25
|
-
Check the top-level render call using <`+j+">.")}return h}}function rt(t,h){{if(!t._store||t._store.validated||t.key!=null)return;t._store.validated=!0;var j=Dt(h);if(st[j])return;st[j]=!0;var E="";t&&t._owner&&t._owner!==Be.current&&(E=" It was passed a child from "+F(t._owner.type)+"."),me(t),k('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',j,E),me(null)}}function lt(t,h){{if(typeof t!="object")return;if(Ae(t))for(var j=0;j<t.length;j++){var E=t[j];Ne(E)&&rt(E,h)}else if(Ne(t))t._store&&(t._store.validated=!0);else if(t){var H=y(t);if(typeof H=="function"&&H!==t.entries)for(var Y=H.call(t),L;!(L=Y.next()).done;)Ne(L.value)&&rt(L.value,h)}}}function Zt(t){{var h=t.type;if(h==null||typeof h=="string")return;var j;if(typeof h=="function")j=h.propTypes;else if(typeof h=="object"&&(h.$$typeof===c||h.$$typeof===v))j=h.propTypes;else return;if(j){var E=F(h);Bt(j,t.props,"prop",E,t)}else if(h.PropTypes!==void 0&&!Me){Me=!0;var H=F(h);k("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",H||"Unknown")}typeof h.getDefaultProps=="function"&&!h.getDefaultProps.isReactClassApproved&&k("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Qt(t){{for(var h=Object.keys(t.props),j=0;j<h.length;j++){var E=h[j];if(E!=="children"&&E!=="key"){me(t),k("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",E),me(null);break}}t.ref!==null&&(me(t),k("Invalid attribute `ref` supplied to `React.Fragment`."),me(null))}}var at={};function dt(t,h,j,E,H,Y){{var L=O(t);if(!L){var N="";(t===void 0||typeof t=="object"&&t!==null&&Object.keys(t).length===0)&&(N+=" 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 ee=Kt();ee?N+=ee:N+=it();var D;t===null?D="null":Ae(t)?D="array":t!==void 0&&t.$$typeof===r?(D="<"+(F(t.type)||"Unknown")+" />",N=" Did you accidentally export a JSX literal instead of a component?"):D=typeof t,k("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",D,N)}var Q=Jt(t,h,j,H,Y);if(Q==null)return Q;if(L){var ie=h.children;if(ie!==void 0)if(E)if(Ae(ie)){for(var ve=0;ve<ie.length;ve++)lt(ie[ve],t);Object.freeze&&Object.freeze(ie)}else k("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 lt(ie,t)}if(je.call(h,"key")){var he=F(t),te=Object.keys(h).filter(function(no){return no!=="key"}),Le=te.length>0?"{key: someKey, "+te.join(": ..., ")+": ...}":"{key: someKey}";if(!at[he+Le]){var oo=te.length>0?"{"+te.join(": ..., ")+": ...}":"{}";k(`A props object containing a "key" prop is being spread into JSX:
|
|
26
|
-
let props = %s;
|
|
27
|
-
<%s {...props} />
|
|
28
|
-
React keys must be passed directly to JSX without using spread:
|
|
29
|
-
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,Le,he,oo,he),at[he+Le]=!0}}return t===l?Qt(Q):Zt(Q),Q}}function qt(t,h,j){return dt(t,h,j,!0)}function $t(t,h,j){return dt(t,h,j,!1)}var eo=$t,to=qt;we.Fragment=l,we.jsx=eo,we.jsxs=to}()),we}process.env.NODE_ENV==="production"?Ie.exports=pt():Ie.exports=ut();var e=Ie.exports,Z=function(){return Z=Object.assign||function(n){for(var r,o=1,l=arguments.length;o<l;o++){r=arguments[o];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[i]=r[i])}return n},Z.apply(this,arguments)},Ye={width:"100%",height:"10px",top:"0px",left:"0px",cursor:"row-resize"},Ue={width:"10px",height:"100%",top:"0px",left:"0px",cursor:"col-resize"},Re={width:"20px",height:"20px",position:"absolute",zIndex:1},ht={top:Z(Z({},Ye),{top:"-5px"}),right:Z(Z({},Ue),{left:void 0,right:"-5px"}),bottom:Z(Z({},Ye),{top:void 0,bottom:"-5px"}),left:Z(Z({},Ue),{left:"-5px"}),topRight:Z(Z({},Re),{right:"-10px",top:"-10px",cursor:"ne-resize"}),bottomRight:Z(Z({},Re),{right:"-10px",bottom:"-10px",cursor:"se-resize"}),bottomLeft:Z(Z({},Re),{left:"-10px",bottom:"-10px",cursor:"sw-resize"}),topLeft:Z(Z({},Re),{left:"-10px",top:"-10px",cursor:"nw-resize"})},ft=f.memo(function(n){var r=n.onResizeStart,o=n.direction,l=n.children,i=n.replaceStyles,a=n.className,u=f.useCallback(function(x){r(x,o)},[r,o]),s=f.useCallback(function(x){r(x,o)},[r,o]),c=f.useMemo(function(){return Z(Z({position:"absolute",userSelect:"none"},ht[o]),i??{})},[i,o]);return e.jsx("div",{className:a||void 0,style:c,onMouseDown:u,onTouchStart:s,children:l})}),gt=function(){var n=function(r,o){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(l,i){l.__proto__=i}||function(l,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(l[a]=i[a])},n(r,o)};return function(r,o){if(typeof o!="function"&&o!==null)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");n(r,o);function l(){this.constructor=r}r.prototype=o===null?Object.create(o):(l.prototype=o.prototype,new l)}}(),le=function(){return le=Object.assign||function(n){for(var r,o=1,l=arguments.length;o<l;o++){r=arguments[o];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[i]=r[i])}return n},le.apply(this,arguments)},xt={width:"auto",height:"auto"},Ce=function(n,r,o){return Math.max(Math.min(n,o),r)},Ge=function(n,r,o){var l=Math.round(n/r);return l*r+o*(l-1)},fe=function(n,r){return new RegExp(n,"i").test(r)},ke=function(n){return!!(n.touches&&n.touches.length)},yt=function(n){return!!((n.clientX||n.clientX===0)&&(n.clientY||n.clientY===0))},Xe=function(n,r,o){o===void 0&&(o=0);var l=r.reduce(function(a,u,s){return Math.abs(u-n)<Math.abs(r[a]-n)?s:a},0),i=Math.abs(r[l]-n);return o===0||i<o?r[l]:n},Pe=function(n){return n=n.toString(),n==="auto"||n.endsWith("px")||n.endsWith("%")||n.endsWith("vh")||n.endsWith("vw")||n.endsWith("vmax")||n.endsWith("vmin")?n:"".concat(n,"px")},Te=function(n,r,o,l){if(n&&typeof n=="string"){if(n.endsWith("px"))return Number(n.replace("px",""));if(n.endsWith("%")){var i=Number(n.replace("%",""))/100;return r*i}if(n.endsWith("vw")){var i=Number(n.replace("vw",""))/100;return o*i}if(n.endsWith("vh")){var i=Number(n.replace("vh",""))/100;return l*i}}return n},mt=function(n,r,o,l,i,a,u){return l=Te(l,n.width,r,o),i=Te(i,n.height,r,o),a=Te(a,n.width,r,o),u=Te(u,n.height,r,o),{maxWidth:typeof l>"u"?void 0:Number(l),maxHeight:typeof i>"u"?void 0:Number(i),minWidth:typeof a>"u"?void 0:Number(a),minHeight:typeof u>"u"?void 0:Number(u)}},vt=function(n){return Array.isArray(n)?n:[n,n]},bt=["as","ref","style","className","grid","gridGap","snap","bounds","boundsByDirection","size","defaultSize","minWidth","minHeight","maxWidth","maxHeight","lockAspectRatio","lockAspectRatioExtraWidth","lockAspectRatioExtraHeight","enable","handleStyles","handleClasses","handleWrapperStyle","handleWrapperClass","children","onResizeStart","onResize","onResizeStop","handleComponent","scale","resizeRatio","snapGap"],Ve="__resizable_base__",Je=function(n){gt(r,n);function r(o){var l,i,a,u,s=n.call(this,o)||this;return s.ratio=1,s.resizable=null,s.parentLeft=0,s.parentTop=0,s.resizableLeft=0,s.resizableRight=0,s.resizableTop=0,s.resizableBottom=0,s.targetLeft=0,s.targetTop=0,s.delta={width:0,height:0},s.appendBase=function(){if(!s.resizable||!s.window)return null;var c=s.parentNode;if(!c)return null;var x=s.window.document.createElement("div");return x.style.width="100%",x.style.height="100%",x.style.position="absolute",x.style.transform="scale(0, 0)",x.style.left="0",x.style.flex="0 0 100%",x.classList?x.classList.add(Ve):x.className+=Ve,c.appendChild(x),x},s.removeBase=function(c){var x=s.parentNode;x&&x.removeChild(c)},s.state={isResizing:!1,width:(i=(l=s.propsSize)===null||l===void 0?void 0:l.width)!==null&&i!==void 0?i:"auto",height:(u=(a=s.propsSize)===null||a===void 0?void 0:a.height)!==null&&u!==void 0?u:"auto",direction:"right",original:{x:0,y:0,width:0,height:0},backgroundStyle:{height:"100%",width:"100%",backgroundColor:"rgba(0,0,0,0)",cursor:"auto",opacity:0,position:"fixed",zIndex:9999,top:"0",left:"0",bottom:"0",right:"0"},flexBasis:void 0},s.onResizeStart=s.onResizeStart.bind(s),s.onMouseMove=s.onMouseMove.bind(s),s.onMouseUp=s.onMouseUp.bind(s),s}return Object.defineProperty(r.prototype,"parentNode",{get:function(){return this.resizable?this.resizable.parentNode:null},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"window",{get:function(){return!this.resizable||!this.resizable.ownerDocument?null:this.resizable.ownerDocument.defaultView},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"propsSize",{get:function(){return this.props.size||this.props.defaultSize||xt},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"size",{get:function(){var o=0,l=0;if(this.resizable&&this.window){var i=this.resizable.offsetWidth,a=this.resizable.offsetHeight,u=this.resizable.style.position;u!=="relative"&&(this.resizable.style.position="relative"),o=this.resizable.style.width!=="auto"?this.resizable.offsetWidth:i,l=this.resizable.style.height!=="auto"?this.resizable.offsetHeight:a,this.resizable.style.position=u}return{width:o,height:l}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sizeStyle",{get:function(){var o=this,l=this.props.size,i=function(s){var c;if(typeof o.state[s]>"u"||o.state[s]==="auto")return"auto";if(o.propsSize&&o.propsSize[s]&&(!((c=o.propsSize[s])===null||c===void 0)&&c.toString().endsWith("%"))){if(o.state[s].toString().endsWith("%"))return o.state[s].toString();var x=o.getParentSize(),m=Number(o.state[s].toString().replace("px","")),v=m/x[s]*100;return"".concat(v,"%")}return Pe(o.state[s])},a=l&&typeof l.width<"u"&&!this.state.isResizing?Pe(l.width):i("width"),u=l&&typeof l.height<"u"&&!this.state.isResizing?Pe(l.height):i("height");return{width:a,height:u}},enumerable:!1,configurable:!0}),r.prototype.getParentSize=function(){if(!this.parentNode)return this.window?{width:this.window.innerWidth,height:this.window.innerHeight}:{width:0,height:0};var o=this.appendBase();if(!o)return{width:0,height:0};var l=!1,i=this.parentNode.style.flexWrap;i!=="wrap"&&(l=!0,this.parentNode.style.flexWrap="wrap"),o.style.position="relative",o.style.minWidth="100%",o.style.minHeight="100%";var a={width:o.offsetWidth,height:o.offsetHeight};return l&&(this.parentNode.style.flexWrap=i),this.removeBase(o),a},r.prototype.bindEvents=function(){this.window&&(this.window.addEventListener("mouseup",this.onMouseUp),this.window.addEventListener("mousemove",this.onMouseMove),this.window.addEventListener("mouseleave",this.onMouseUp),this.window.addEventListener("touchmove",this.onMouseMove,{capture:!0,passive:!1}),this.window.addEventListener("touchend",this.onMouseUp))},r.prototype.unbindEvents=function(){this.window&&(this.window.removeEventListener("mouseup",this.onMouseUp),this.window.removeEventListener("mousemove",this.onMouseMove),this.window.removeEventListener("mouseleave",this.onMouseUp),this.window.removeEventListener("touchmove",this.onMouseMove,!0),this.window.removeEventListener("touchend",this.onMouseUp))},r.prototype.componentDidMount=function(){if(!(!this.resizable||!this.window)){var o=this.window.getComputedStyle(this.resizable);this.setState({width:this.state.width||this.size.width,height:this.state.height||this.size.height,flexBasis:o.flexBasis!=="auto"?o.flexBasis:void 0})}},r.prototype.componentWillUnmount=function(){this.window&&this.unbindEvents()},r.prototype.createSizeForCssProperty=function(o,l){var i=this.propsSize&&this.propsSize[l];return this.state[l]==="auto"&&this.state.original[l]===o&&(typeof i>"u"||i==="auto")?"auto":o},r.prototype.calculateNewMaxFromBoundary=function(o,l){var i=this.props.boundsByDirection,a=this.state.direction,u=i&&fe("left",a),s=i&&fe("top",a),c,x;if(this.props.bounds==="parent"){var m=this.parentNode;m&&(c=u?this.resizableRight-this.parentLeft:m.offsetWidth+(this.parentLeft-this.resizableLeft),x=s?this.resizableBottom-this.parentTop:m.offsetHeight+(this.parentTop-this.resizableTop))}else this.props.bounds==="window"?this.window&&(c=u?this.resizableRight:this.window.innerWidth-this.resizableLeft,x=s?this.resizableBottom:this.window.innerHeight-this.resizableTop):this.props.bounds&&(c=u?this.resizableRight-this.targetLeft:this.props.bounds.offsetWidth+(this.targetLeft-this.resizableLeft),x=s?this.resizableBottom-this.targetTop:this.props.bounds.offsetHeight+(this.targetTop-this.resizableTop));return c&&Number.isFinite(c)&&(o=o&&o<c?o:c),x&&Number.isFinite(x)&&(l=l&&l<x?l:x),{maxWidth:o,maxHeight:l}},r.prototype.calculateNewSizeFromDirection=function(o,l){var i=this.props.scale||1,a=vt(this.props.resizeRatio||1),u=a[0],s=a[1],c=this.state,x=c.direction,m=c.original,v=this.props,b=v.lockAspectRatio,d=v.lockAspectRatioExtraHeight,R=v.lockAspectRatioExtraWidth,w=m.width,y=m.height,g=d||0,k=R||0;return fe("right",x)&&(w=m.width+(o-m.x)*u/i,b&&(y=(w-k)/this.ratio+g)),fe("left",x)&&(w=m.width-(o-m.x)*u/i,b&&(y=(w-k)/this.ratio+g)),fe("bottom",x)&&(y=m.height+(l-m.y)*s/i,b&&(w=(y-g)*this.ratio+k)),fe("top",x)&&(y=m.height-(l-m.y)*s/i,b&&(w=(y-g)*this.ratio+k)),{newWidth:w,newHeight:y}},r.prototype.calculateNewSizeFromAspectRatio=function(o,l,i,a){var u=this.props,s=u.lockAspectRatio,c=u.lockAspectRatioExtraHeight,x=u.lockAspectRatioExtraWidth,m=typeof a.width>"u"?10:a.width,v=typeof i.width>"u"||i.width<0?o:i.width,b=typeof a.height>"u"?10:a.height,d=typeof i.height>"u"||i.height<0?l:i.height,R=c||0,w=x||0;if(s){var y=(b-R)*this.ratio+w,g=(d-R)*this.ratio+w,k=(m-w)/this.ratio+R,_=(v-w)/this.ratio+R,I=Math.max(m,y),A=Math.min(v,g),C=Math.max(b,k),z=Math.min(d,_);o=Ce(o,I,A),l=Ce(l,C,z)}else o=Ce(o,m,v),l=Ce(l,b,d);return{newWidth:o,newHeight:l}},r.prototype.setBoundingClientRect=function(){var o=1/(this.props.scale||1);if(this.props.bounds==="parent"){var l=this.parentNode;if(l){var i=l.getBoundingClientRect();this.parentLeft=i.left*o,this.parentTop=i.top*o}}if(this.props.bounds&&typeof this.props.bounds!="string"){var a=this.props.bounds.getBoundingClientRect();this.targetLeft=a.left*o,this.targetTop=a.top*o}if(this.resizable){var u=this.resizable.getBoundingClientRect(),s=u.left,c=u.top,x=u.right,m=u.bottom;this.resizableLeft=s*o,this.resizableRight=x*o,this.resizableTop=c*o,this.resizableBottom=m*o}},r.prototype.onResizeStart=function(o,l){if(!(!this.resizable||!this.window)){var i=0,a=0;if(o.nativeEvent&&yt(o.nativeEvent)?(i=o.nativeEvent.clientX,a=o.nativeEvent.clientY):o.nativeEvent&&ke(o.nativeEvent)&&(i=o.nativeEvent.touches[0].clientX,a=o.nativeEvent.touches[0].clientY),this.props.onResizeStart&&this.resizable){var u=this.props.onResizeStart(o,l,this.resizable);if(u===!1)return}this.props.size&&(typeof this.props.size.height<"u"&&this.props.size.height!==this.state.height&&this.setState({height:this.props.size.height}),typeof this.props.size.width<"u"&&this.props.size.width!==this.state.width&&this.setState({width:this.props.size.width})),this.ratio=typeof this.props.lockAspectRatio=="number"?this.props.lockAspectRatio:this.size.width/this.size.height;var s,c=this.window.getComputedStyle(this.resizable);if(c.flexBasis!=="auto"){var x=this.parentNode;if(x){var m=this.window.getComputedStyle(x).flexDirection;this.flexDir=m.startsWith("row")?"row":"column",s=c.flexBasis}}this.setBoundingClientRect(),this.bindEvents();var v={original:{x:i,y:a,width:this.size.width,height:this.size.height},isResizing:!0,backgroundStyle:le(le({},this.state.backgroundStyle),{cursor:this.window.getComputedStyle(o.target).cursor||"auto"}),direction:l,flexBasis:s};this.setState(v)}},r.prototype.onMouseMove=function(o){var l=this;if(!(!this.state.isResizing||!this.resizable||!this.window)){if(this.window.TouchEvent&&ke(o))try{o.preventDefault(),o.stopPropagation()}catch{}var i=this.props,a=i.maxWidth,u=i.maxHeight,s=i.minWidth,c=i.minHeight,x=ke(o)?o.touches[0].clientX:o.clientX,m=ke(o)?o.touches[0].clientY:o.clientY,v=this.state,b=v.direction,d=v.original,R=v.width,w=v.height,y=this.getParentSize(),g=mt(y,this.window.innerWidth,this.window.innerHeight,a,u,s,c);a=g.maxWidth,u=g.maxHeight,s=g.minWidth,c=g.minHeight;var k=this.calculateNewSizeFromDirection(x,m),_=k.newHeight,I=k.newWidth,A=this.calculateNewMaxFromBoundary(a,u);this.props.snap&&this.props.snap.x&&(I=Xe(I,this.props.snap.x,this.props.snapGap)),this.props.snap&&this.props.snap.y&&(_=Xe(_,this.props.snap.y,this.props.snapGap));var C=this.calculateNewSizeFromAspectRatio(I,_,{width:A.maxWidth,height:A.maxHeight},{width:s,height:c});if(I=C.newWidth,_=C.newHeight,this.props.grid){var z=Ge(I,this.props.grid[0],this.props.gridGap?this.props.gridGap[0]:0),B=Ge(_,this.props.grid[1],this.props.gridGap?this.props.gridGap[1]:0),U=this.props.snapGap||0,O=U===0||Math.abs(z-I)<=U?z:I,S=U===0||Math.abs(B-_)<=U?B:_;I=O,_=S}var W={width:I-d.width,height:_-d.height};if(this.delta=W,R&&typeof R=="string"){if(R.endsWith("%")){var F=I/y.width*100;I="".concat(F,"%")}else if(R.endsWith("vw")){var J=I/this.window.innerWidth*100;I="".concat(J,"vw")}else if(R.endsWith("vh")){var G=I/this.window.innerHeight*100;I="".concat(G,"vh")}}if(w&&typeof w=="string"){if(w.endsWith("%")){var F=_/y.height*100;_="".concat(F,"%")}else if(w.endsWith("vw")){var J=_/this.window.innerWidth*100;_="".concat(J,"vw")}else if(w.endsWith("vh")){var G=_/this.window.innerHeight*100;_="".concat(G,"vh")}}var K={width:this.createSizeForCssProperty(I,"width"),height:this.createSizeForCssProperty(_,"height")};this.flexDir==="row"?K.flexBasis=K.width:this.flexDir==="column"&&(K.flexBasis=K.height);var P=this.state.width!==K.width,X=this.state.height!==K.height,se=this.state.flexBasis!==K.flexBasis,ne=P||X||se;ne&&ct.flushSync(function(){l.setState(K)}),this.props.onResize&&ne&&this.props.onResize(o,b,this.resizable,W)}},r.prototype.onMouseUp=function(o){var l,i,a=this.state,u=a.isResizing,s=a.direction;a.original,!(!u||!this.resizable)&&(this.props.onResizeStop&&this.props.onResizeStop(o,s,this.resizable,this.delta),this.props.size&&this.setState({width:(l=this.props.size.width)!==null&&l!==void 0?l:"auto",height:(i=this.props.size.height)!==null&&i!==void 0?i:"auto"}),this.unbindEvents(),this.setState({isResizing:!1,backgroundStyle:le(le({},this.state.backgroundStyle),{cursor:"auto"})}))},r.prototype.updateSize=function(o){var l,i;this.setState({width:(l=o.width)!==null&&l!==void 0?l:"auto",height:(i=o.height)!==null&&i!==void 0?i:"auto"})},r.prototype.renderResizer=function(){var o=this,l=this.props,i=l.enable,a=l.handleStyles,u=l.handleClasses,s=l.handleWrapperStyle,c=l.handleWrapperClass,x=l.handleComponent;if(!i)return null;var m=Object.keys(i).map(function(v){return i[v]!==!1?e.jsx(ft,{direction:v,onResizeStart:o.onResizeStart,replaceStyles:a&&a[v],className:u&&u[v],children:x&&x[v]?x[v]:null},v):null});return e.jsx("div",{className:c,style:s,children:m})},r.prototype.render=function(){var o=this,l=Object.keys(this.props).reduce(function(u,s){return bt.indexOf(s)!==-1||(u[s]=o.props[s]),u},{}),i=le(le(le({position:"relative",userSelect:this.state.isResizing?"none":"auto"},this.props.style),this.sizeStyle),{maxWidth:this.props.maxWidth,maxHeight:this.props.maxHeight,minWidth:this.props.minWidth,minHeight:this.props.minHeight,boxSizing:"border-box",flexShrink:0});this.state.flexBasis&&(i.flexBasis=this.state.flexBasis);var a=this.props.as||"div";return e.jsxs(a,le({style:i,className:this.props.className},l,{ref:function(u){u&&(o.resizable=u)},children:[this.state.isResizing&&e.jsx("div",{style:this.state.backgroundStyle}),this.props.children,this.renderResizer()]}))},r.defaultProps={as:"div",onResizeStart:function(){},onResize:function(){},onResizeStop:function(){},enable:{top:!0,right:!0,bottom:!0,left:!0,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},style:{},grid:[1,1],gridGap:[0,0],lockAspectRatio:!1,lockAspectRatioExtraWidth:0,lockAspectRatioExtraHeight:0,scale:1,resizeRatio:1,snapGap:0},r}(f.PureComponent);const Ke=n=>{n||(n="https://polls-tests-widgets-backend-1357.loca.lt");const[r,o]=f.useState(!1),[l,i]=f.useState(null),a=w=>`${n?n.replace(/\/$/,""):""}/api/polls${w}`,u=()=>{const w="csrftoken=",y=document.cookie?document.cookie.split(";"):[];for(let g of y)if(g=g.trim(),g.startsWith(w))return decodeURIComponent(g.substring(w.length));return null},s=async()=>{await fetch(a("/csrf/"),{credentials:"include"})},c=async(w,y={})=>{const g={credentials:"include",method:"GET",mode:"cors",headers:{"Content-Type":"application/json","bypass-tunnel-reminder":"true"}},k={...g,...y,headers:{...g.headers,...y.headers||{}}},_=await fetch(w,k),I=await _.text();let A=null;try{A=I?JSON.parse(I):null}catch{A=I}if(!_.ok){const C=new Error(A&&(A.detail||A.message)||_.statusText);throw C.status=_.status,C}return A},x=f.useCallback(async(w,y)=>{o(!0),i(null);try{await s();const g=u();return await c(a(`/${w}/`),{method:"DELETE",mode:"cors",headers:{"X-CSRFToken":g,"X-User-ID":y}})}catch(g){throw i(g.message),g}finally{o(!1)}},[]),m=f.useCallback(async()=>{try{return await c(a("/list/"),{method:"GET"})}catch(w){throw console.error("Ошибка получения списка опросов:",w),w}},[c]),v=f.useCallback(async w=>{o(!0),i(null);try{return await c(a(`/${w}/`),{method:"GET",mode:"cors"})}catch(y){return i(y.message),null}finally{o(!1)}},[]),b=f.useCallback(async(w,y)=>{o(!0),i(null),await s();const g=u();if(!g)throw new Error("CSRF token missing!");const k=(w.options||[]).filter(A=>A.trim()!=="").map(A=>({choice_text:A}));let _=null;y.endDate&&(_=new Date(`${y.endDate}T${y.endTime||"23:59:59"}`).toISOString());const I={owner:w.ownerID,title:w.title,choices:k,is_anonymous:y.isAnonymous,multiple_answers:y.multipleAnswers,end_date:_};try{return await c(a("/create/"),{method:"POST",mode:"cors",headers:{"X-CSRFToken":g},body:JSON.stringify(I)})}catch(A){throw i(A.message),A}finally{o(!1)}},[]);f.useCallback(async w=>{o(!0),i(null);try{return await c(a(`/${w}/`),{method:"GET"})}catch(y){return i(y.message),null}finally{o(!1)}},[]);const d=f.useCallback(async(w,y)=>{o(!0),i(null),await s();const g=u();if(!g)throw new Error("CSRF token missing!");try{return await c(a(`/${w}/vote/`),{method:"POST",headers:{"X-CSRFToken":g},body:JSON.stringify({choice_id:y.choiceId,user:y.userId})})}catch(k){throw i(k.message),k}finally{o(!1)}},[]),R=f.useCallback(async(w,y)=>{o(!0),i(null),await s();const g=u();try{return await c(a(`/${w}/unvote/}`),{method:"POST",headers:{"X-CSRFToken":g},body:JSON.stringify({user:y})})}catch(k){throw i(k.message),k}finally{o(!1)}},[]);return{createPoll:b,loading:r,error:l,setError:i,fetchAllPolls:m,fetchPoll:v,createPoll:b,votePoll:d,unvotePoll:R,deletePoll:x}},Se=({placeholder:n,value:r,onChange:o,style:l,autoFocus:i,type:a="text"})=>e.jsx("input",{type:a,placeholder:n,value:r,onChange:o,autoFocus:i,className:"nodrag",style:{width:"100%",boxSizing:"border-box",padding:"12px 16px",marginBottom:"12px",backgroundColor:"#e0e0e0",border:"none",borderRadius:"0px",fontSize:"16px",color:"#333",outline:"none",fontFamily:"Arial, sans-serif",...l}}),q=({onClick:n,children:r,style:o,disabled:l})=>e.jsx("button",{onClick:l?void 0:n,disabled:l,className:"nodrag",style:{padding:"10px 30px",backgroundColor:l?"#f0f0f0":"#d9d9d9",border:"none",borderRadius:"0px",fontSize:"18px",color:l?"#999":"#000",cursor:l?"not-allowed":"pointer",fontWeight:"400",transition:"background-color 0.2s",whiteSpace:"nowrap",opacity:l?.7:1,...o},onMouseOver:i=>{l||(i.target.style.backgroundColor="#c0c0c0")},onMouseOut:i=>{l||(i.target.style.backgroundColor=(o==null?void 0:o.backgroundColor)||"#d9d9d9")},children:r}),ge=({checked:n,onChange:r})=>e.jsxs("label",{style:{display:"inline-flex",alignItems:"center",cursor:"pointer",userSelect:"none",position:"relative"},children:[e.jsx("input",{type:"checkbox",checked:n,onChange:r,style:{opacity:0,width:0,height:0,position:"absolute"}}),e.jsx("span",{style:{display:"inline-block",width:"24px",height:"24px",border:`2px solid ${n?"#000":"#6c757d"}`,borderRadius:"4px",backgroundColor:n?"#000":"#fff",transition:"background-color 0.2s, border-color 0.2s",position:"relative",flexShrink:0},children:n&&e.jsx("span",{style:{content:'""',position:"absolute",left:"8px",top:"3px",width:"6px",height:"14px",border:"solid white",borderWidth:"0 3px 3px 0",transform:"rotate(45deg)",transition:"opacity 0.2s",opacity:n?1:0}})})]}),wt=({onClick:n})=>e.jsx("div",{onClick:n,className:"nodrag",style:{display:"flex",gap:"6px",cursor:"pointer",flexShrink:0,padding:"5px"},children:[1,2,3].map(r=>e.jsx("div",{style:{width:"14px",height:"14px",borderRadius:"50%",backgroundColor:"#757575"}},r))}),_e=({id:n,name:r,value:o,checked:l,onChange:i,children:a})=>e.jsxs("label",{htmlFor:n,style:{display:"inline-flex",alignItems:"center",cursor:"pointer",userSelect:"none"},children:[e.jsx("input",{id:n,type:"radio",name:r,value:o,checked:l,onChange:i,style:{opacity:0,width:0,height:0,position:"absolute"}}),e.jsx("span",{style:{display:"inline-block",width:"20px",height:"20px",borderRadius:"50%",border:`2px solid ${l?"#000":"#6c757d"}`,backgroundColor:"#fff",position:"relative",flexShrink:0,transition:"border-color 0.2s"},children:l&&e.jsx("span",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"10px",height:"10px",borderRadius:"50%",backgroundColor:"#000",transition:"opacity 0.2s",opacity:1}})}),a]}),Oe=({title:n,children:r,style:o,toggleSettings:l,showMenuDots:i=!0})=>e.jsxs("div",{style:{width:"100%",height:"100%",backgroundColor:"#fff",padding:"20px 24px",display:"flex",flexDirection:"column",boxSizing:"border-box",boxShadow:"0 2px 10px rgba(0,0,0,0.05)",position:"relative",overflow:"hidden",...o},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"20px",flexShrink:0},children:[e.jsx("span",{style:{fontSize:"20px",fontWeight:"400",color:"#000",lineHeight:"1.2",wordBreak:"break-word",marginRight:"10px"},children:n}),i&&e.jsx(wt,{onClick:l})]}),e.jsx("div",{style:{flexGrow:1,display:"flex",flexDirection:"column",overflow:"hidden",minHeight:0},children:r})]}),St=({onSave:n,onDataChange:r,initialData:o})=>{var m;const l=o!=null&&o.options&&o.options.length>0&&o.options.some(v=>v.trim()==="")?o.options:[...((m=o==null?void 0:o.options)==null?void 0:m.filter(v=>v.trim()!==""))||[],""],[i,a]=f.useState((o==null?void 0:o.title)||""),[u,s]=f.useState(l),c=f.useRef(null);f.useEffect(()=>{r({title:i,options:u.filter(v=>v.trim()!=="")})},[i,u,r]);const x=(v,b)=>{let d=[...u];d[v]=b,v===d.length-1&&b.trim()!==""&&d.push(""),d=d.filter((R,w)=>R.trim()!==""||w===d.length-1),s(d)};return f.useEffect(()=>{c.current&&u.length>1&&u[u.length-1].trim()===""&&c.current.scrollIntoView({behavior:"smooth"})},[u.length]),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",overflow:"hidden"},children:[e.jsx("div",{style:{flexShrink:0,width:"100%"},children:e.jsx(Se,{placeholder:"Название опроса",value:i,onChange:v=>a(v.target.value),style:{fontSize:"20px",padding:"14px 16px",marginBottom:"20px",color:"#333",fontWeight:"bold",borderRadius:"15px"}})}),e.jsxs("div",{className:"scroll-container nowheel",onWheel:v=>v.stopPropagation(),style:{flexGrow:1,overflowY:"auto",overflowX:"hidden",paddingRight:"5px",marginBottom:"10px",width:"100%"},children:[u.map((v,b)=>e.jsx("div",{style:{display:"flex",alignItems:"center"},children:e.jsx(Se,{placeholder:`Вариант ${b+1}`,value:v,onChange:d=>x(b,d.target.value),style:{flexGrow:1,marginBottom:"10px",borderRadius:"15px"}})},b)),e.jsx("div",{ref:c})]}),e.jsx("div",{style:{flexShrink:0,marginTop:"20px"},children:e.jsx(q,{onClick:()=>n(),style:{width:"100%",borderRadius:"15px"},children:"Сохранить опрос"})})]})},jt=({onDataChange:n,initialData:r,toggleSettings:o,onDelete:l})=>{const[i,a]=f.useState((r==null?void 0:r.isAnonymous)||!1),[u,s]=f.useState((r==null?void 0:r.multipleAnswers)||!1),[c,x]=f.useState((r==null?void 0:r.endDate)||""),[m,v]=f.useState((r==null?void 0:r.endTime)||"");f.useEffect(()=>{n({isAnonymous:i,multipleAnswers:u,endDate:c,endTime:m})},[i,u,c,m,n]);const b={boxSizing:"border-box",padding:"12px 16px",backgroundColor:"#e0e0e0",border:"none",borderRadius:"15px",fontSize:"16px",color:"#333",outline:"none",fontFamily:"Arial, sans-serif",flex:1};return e.jsxs("div",{className:"nodrag",style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",paddingRight:"5px",overflowY:"auto",overflowX:"hidden",boxSizing:"border-box"},children:[e.jsx("h3",{style:{fontSize:"20px",fontWeight:"bold",color:"#000",marginBottom:"25px",flexShrink:0},children:"Параметры опроса"}),e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",marginBottom:"25px"},children:[e.jsx(ge,{checked:i,onChange:()=>a(!i)}),e.jsx("span",{style:{fontSize:"18px",color:"#333"},children:"Анонимность"})]}),e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",marginBottom:"25px"},children:[e.jsx(ge,{checked:u,onChange:()=>s(!u)}),e.jsx("span",{style:{fontSize:"18px",color:"#333"},children:"Несколько ответов"})]}),e.jsxs("div",{style:{flexShrink:0},children:[e.jsx("span",{style:{fontSize:"18px",color:"#333",marginBottom:"10px",display:"block"},children:"Дата и время окончания"}),e.jsxs("div",{style:{display:"flex",gap:"10px"},children:[e.jsx("input",{type:"date",className:"nodrag",value:c,onChange:d=>x(d.target.value),style:b}),e.jsx("input",{type:"time",className:"nodrag",value:m,onChange:d=>v(d.target.value),style:b})]})]}),e.jsx("div",{style:{flexShrink:0,display:"flex",justifyContent:"flex-end",marginTop:"auto",paddingTop:"20px"},children:e.jsx(q,{onClick:o,style:{width:"100%",borderRadius:"15px"},children:"Назад к опросу"})})]})},Rt=({pollData:n,setPollData:r})=>{var T;const{id:o,title:l,choices:i,all_votes:a=[],voted_users:u=[],is_anonymous:s,multiple_answers:c,end_date:x,total_votes:m}=n,b=(()=>{if(!x)return!1;const p=new Date(x);return new Date>p})(),{votePoll:d,loading:R,error:w,setError:y,fetchPoll:g,unvotePoll:k}=Ke(),_=localStorage.getItem("userId")||"Anonymous",I=s?"Анонимно":"Неанонимно",A=x?`До ${x.split("T")[0]}`:"Нет даты",C=p=>!u||u.length===0?"0%":`${Math.round(p/u.length*100)}%`,[z,B]=f.useState(a.some(p=>p.user===String(_))),[U,O]=f.useState(),[S,W]=f.useState([]),[F,J]=f.useState(a.find(p=>p.user===String(_))),[G,K]=f.useState(!1),[P,X]=f.useState(0),[se,ne]=f.useState(z||R||b||!c&&!U||c&&S.length===0);f.useEffect(()=>{ne(z||R||b||!c&&!U||c&&S.length===0)},[z,R,c,U,S,b]);const $=p=>{O(p)},de=p=>{W(M=>M.includes(p)?M.filter(V=>V!==p):[...M,p])},ue=p=>{s||(K(!0),X(p))},xe=()=>{K(!1)},ye=async()=>{if(b){alert("Время прохождения теста истекло.");return}if(!(!c&&!U||c&&S.length===0))try{let p=!0;if(c){const M=S.map(V=>d(o,{choiceId:V,userId:_}));try{await Promise.all(M),p=!0}catch(V){console.error("Один из голосов не прошел",V),p=!1}}else p=await d(o,{choiceId:U,userId:_});p&&(B(!0),g&&g(o).then(M=>r(M)))}catch(p){console.error("Ошибка при голосовании:",p),y("Не удалось сохранить голос")}},ce=async()=>{try{const p=await k(o,_);if(p)r(p);else if(g){const M=await g(o);r(M)}B(!1),J(null),O(null),W([])}catch(p){console.error("Ошибка при отмене голоса:",p),y("Не удалось отменить голос")}},pe=new Intl.PluralRules("ru-RU");function ae(p){const M=pe.select(p),V={one:"голос",few:"голоса",many:"голосов",other:"голосов"};return V[M]||V.many}return e.jsxs("div",{className:"nodrag nowheel",onWheel:p=>p.stopPropagation(),style:{display:"flex",color:"#000",flexDirection:"column",height:"100%",width:"100%",overflow:"hidden",paddingRight:"5px"},children:[e.jsx("div",{style:{flexShrink:0,width:"100%"},children:e.jsx("h3",{style:{fontSize:"22px",fontWeight:"bold",backgroundColor:"#e0e0e0",padding:"12px 16px",borderRadius:"10px"},children:l})}),e.jsxs("div",{style:{fontSize:"14px",color:"#666",marginBottom:"10px"},children:[I," | ",A," | Голосов: ",u.length||0]}),b&&e.jsx("div",{style:{padding:"10px",backgroundColor:"#ffdddd",color:"red",borderRadius:"10px",textAlign:"center",fontWeight:"bold",marginBottom:"10px"},children:"Срок прохождения теста истек"}),w&&e.jsx("p",{style:{color:"red"},children:w}),G&&e.jsxs("div",{style:{display:"flex",color:"#000",flexDirection:"column",height:"100%",width:"100%",overflowY:"auto",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:"12px",position:"relative",overflow:"hidden"},children:[e.jsx("div",{style:{position:"absolute",bottom:0,left:0,height:"5px",width:"100%",backgroundColor:"#ccc"}}),e.jsx("div",{style:{position:"absolute",bottom:0,left:0,height:"5px",width:C(P==null?void 0:P.votes_count),backgroundColor:"#000",transition:"width 0.5s"}}),e.jsx("span",{style:{zIndex:1},children:P==null?void 0:P.choice_text}),e.jsx("span",{style:{fontWeight:"bold",zIndex:1},children:`${C(P==null?void 0:P.votes_count)}`})]}),e.jsxs("span",{style:{marginLeft:"12px",color:"#666"},children:[P==null?void 0:P.votes_count," ",ae(P==null?void 0:P.votes_count)]}),e.jsx("div",{style:{overflowY:"auto",margin:"12px 16px",display:"flex",flexDirection:"column",gap:"15px"},children:(T=a==null?void 0:a.filter(p=>p.choice_id===(P==null?void 0:P.id)))==null?void 0:T.map((p,M)=>e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:e.jsx("span",{style:{},children:p.user})},M))}),e.jsx(q,{style:{marginTop:"auto"},onClick:xe,children:"Назад"})]}),!G&&e.jsxs("div",{style:{display:"flex",color:"#000",flexDirection:"column",height:"100%",width:"100%",overflowY:"auto"},children:[z?e.jsx("div",{className:"scroll-container nowheel",style:{flexGrow:1,overflowY:"auto",minHeight:0,paddingRight:"5px"},children:i==null?void 0:i.map(p=>{const M=C(p.votes_count);return e.jsxs("div",{onClick:()=>{ue(p)},style:{display:"flex",flexDirection:"column",marginBottom:"15px",cursor:"pointer",gap:"10px"},children:[e.jsxs("div",{style:{flexGrow:1,display:"flex",justifyContent:"space-between",padding:"12px",position:"relative",overflow:"hidden"},children:[e.jsx("div",{style:{position:"absolute",bottom:0,left:0,height:"5px",width:"100%",backgroundColor:"#ccc"}}),e.jsx("div",{style:{position:"absolute",bottom:0,left:0,height:"5px",width:M,backgroundColor:"#000",transition:"width 0.5s"}}),e.jsx("span",{style:{zIndex:1},children:p.choice_text}),e.jsx("span",{style:{zIndex:1,marginLeft:"auto",marginRight:"10px"},children:(F==null?void 0:F.choice_id)===p.id?"✔":""}),e.jsx("span",{style:{fontWeight:"bold",zIndex:1},children:`${M}`})]}),e.jsxs("span",{style:{marginLeft:"12px",color:"#666"},children:[p.votes_count," ",ae(p.votes_count)]})]},p.id)})}):e.jsx("div",{className:"scroll-container nowheel",style:{flexGrow:1,overflowY:"auto",minHeight:0,paddingRight:"5px"},children:i==null?void 0:i.map(p=>{const M=p.id,V=c?S.includes(M):U===M;return e.jsxs("div",{onClick:()=>c?de(M):$(M),style:{display:"flex",alignItems:"center",marginBottom:"15px",cursor:"pointer",gap:"10px"},children:[c&&e.jsx(ge,{checked:V,onChange:()=>de(M)}),!c&&e.jsx(_e,{name:`poll-${o}`,checked:V,onChange:()=>$(M)}),e.jsxs("div",{style:{flexGrow:1,display:"flex",justifyContent:"space-between",backgroundColor:V?"#d0d0d0":"#e0e0e0",padding:"12px 16px",borderRadius:"10px",position:"relative",overflow:"hidden"},children:[e.jsx("span",{style:{zIndex:1},children:p.choice_text}),e.jsx("span",{style:{fontWeight:"bold",zIndex:1},children:""})]})]},p.id)})}),e.jsxs("div",{style:{marginTop:"auto",paddingTop:"20px",display:"flex",flexDirection:"column",gap:"10px"},children:[!z&&e.jsx(q,{onClick:ye,disabled:se,style:{width:"100%",backgroundColor:"#d9d9d9",borderRadius:"10px"},children:R?"Отправка...":"Сохранить"}),z&&e.jsxs("div",{style:{textAlign:"center",width:"100%"},children:[e.jsx("div",{style:{marginBottom:"10px",fontWeight:"bold",color:"#4caf50"},children:"Голос принят!"}),e.jsx(q,{onClick:ce,disabled:R,style:{width:"100%",borderRadius:"10px"},children:R?"Отмена...":"Отменить мой голос"})]})]})]})]})},Ct=({initialTitle:n,pollId:r,nodeId:o,nodeProps:l,onSaved:i})=>{const[a,u]=f.useState({ownerID:"",title:n||"",options:[""]}),[s,c]=f.useState({isAnonymous:!1,multipleAnswers:!1,endDate:"",endTime:""}),x=async()=>{const O=m==null?void 0:m.id;if(localStorage.getItem("userId"),!O){alert("Ошибка: ID опроса не определен.");return}if(window.confirm("Вы уверены, что хотите полностью удалить этот опрос?"))try{await k(O,_),alert("Опрос успешно удален из базы"),setTimeout(()=>{window.location.reload()},100)}catch(S){console.error("Детали ошибки:",S),S.status===403?alert("У вас нет прав на удаление этого опроса. Удалять может только автор."):alert("Произошла ошибка при удалении: "+S.message),console.warn("Побочная ошибка (вероятно расширение браузера):",S)}},[m,v]=f.useState(null),[b,d]=f.useState("creator"),{createPoll:R,loading:w,error:y,fetchPoll:g,deletePoll:k}=Ke(),[_,I]=f.useState();f.useEffect(()=>{let O=localStorage.getItem("userId");O||(O=getCookie("user_id")),O||(O="anon_"+Math.random().toString(36).substring(2,11),localStorage.setItem("userId",O)),O&&(I(O),console.log("ID пользователя загружен:",O))},[]),f.useCallback(O=>{if(!O)return;console.log("Poll Widget initialized with:",O);const{widgetId:S,userId:W,role:F,config:J,board:G}=O;S&&(async()=>{try{const P=await g(S);if(!P)return;v(P);const X=(P.choices||[]).map($=>$.choice_text);u({title:P.title,options:[...X.filter($=>$.trim()!==""),(X.length>0,"")]});let se="",ne="";if(P.end_date){const $=P.end_date.split("T");se=$[0],ne=$[1]?$[1].substring(0,5):""}c({isAnonymous:P.is_anonymous,multipleAnswers:P.multiple_answers,endDate:se,endTime:ne}),d("display")}catch(P){console.error("Ошибка загрузки опроса:",P)}})();const K=["admin","editor","owner"].includes(F);d(K?P=>S?"display":"creator":"display")},[g]),f.useEffect(()=>{if(!r)return;let O=!0;return(async()=>{try{const S=await g(r);if(!O||!S)return;v(S);const W=(S.choices||[]).map(G=>G.choice_text);u({title:S.title,options:[...W.filter(G=>G.trim()!==""),(W.length>0,"")]});let F="",J="";if(S.end_date){const G=S.end_date.split("T");F=G[0],J=G[1]?G[1].substring(0,5):""}c({isAnonymous:S.is_anonymous,multipleAnswers:S.multiple_answers,endDate:F,endTime:J}),d("display")}catch(S){console.error("Ошибка загрузки опроса:",S)}})(),()=>{O=!1}},[r,g]);const A=async()=>{const O=a.options.filter(S=>S.trim()!=="");if(!a.title.trim()||O.length<1){alert("Заполните название и хотя бы один вариант ответа");return}try{const S={...a,options:O,ownerID:_},W=await R(S,s);v(W),typeof i=="function"&&(W!=null&&W.id)&&i(W.id),d("display")}catch(S){console.error("Ошибка сохранения опроса:",S),alert("Ошибка при сохранении опроса: "+(S.message||S))}},C=f.useCallback(()=>d(O=>O==="creator"?"settings":"creator"),[]),z=f.useCallback(()=>d("creator"),[]),B=f.useCallback(()=>d("creator"),[]),U=()=>"Опрос";return e.jsxs(Oe,{style:{position:"relative"},title:U(),onSettingsClick:b==="display"?B:void 0,toggleSettings:b!=="settings"?C:void 0,showMenuDots:b==="creator",onTitleClick:b==="display"?B:void 0,children:[e.jsx("p",{style:{color:"red",textAlign:"center"},children:w?"Сохранение...":y}),e.jsx("div",{style:{position:"relative"},children:e.jsxs("div",{style:{fontSize:"10px",color:"#999",textAlign:"right",padding:"0 15px"},children:["User ID: ",_]})}),b==="creator"&&e.jsx(St,{onSave:A,onDataChange:u,initialData:a}),b==="settings"&&e.jsx(jt,{onDataChange:c,initialData:s,toggleSettings:z}),b==="display"&&m&&e.jsxs(e.Fragment,{children:[(m==null?void 0:m.id)&&String(m.owner)===String(_)&&e.jsx("div",{onClick:x,style:{position:"absolute",top:"15px",right:"15px",width:"24px",height:"24px",backgroundColor:"#ff4d4d",color:"white",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:"18px",fontWeight:"bold",zIndex:100,boxShadow:"0 2px 5px rgba(0,0,0,0.2)",lineHeight:"1"},title:"Удалить опрос",children:"×"}),e.jsx(Rt,{pollData:m,setPollData:v})]})]})},kt=({onSave:n,onDataChange:r,initialData:o})=>{const[l,i]=f.useState((o==null?void 0:o.title)||""),[a,u]=f.useState((o==null?void 0:o.tasks)||[]),[s,c]=f.useState((o==null?void 0:o.activeTaskIndex)||null);f.useEffect(()=>{r({title:l,tasks:a,activeTaskIndex:s})},[l,a,s,r]);const[x,m]=f.useState(!0),v=()=>{const C={id:Date.now(),question:"",type:"text",score:1,correctText:"",options:[""],correctRadioOption:"",correctBoxOptions:[]},z=[...a,C];u(z),c(z.length-1)},b=(C,z)=>{if(s===null)return;const B=[...a];B[s]={...B[s],[C]:z},u(B)},d=(C,z)=>{z.stopPropagation();const B=a.filter((U,O)=>O!==C);u(B),s>=B.length?c(B.length>0?B.length-1:null):C<s&&c(s-1)},R=()=>{s>0&&c(s-1)},w=()=>{s<a.length-1&&c(s+1)},y=(C,z)=>{let B=[...a[s].options];B[C]=z;const O=[...B.filter(S=>S.trim()!==""),""];b("options",O)},g=C=>{b("correctRadioOption",C)},k=(C,z)=>{let B=[];z.includes(C)?B=z.filter(U=>U!==C):B=[...z,C],b("correctBoxOptions",B)},_={display:"flex",gap:"10px",alignItems:"center",whiteSpace:"nowrap"},I={boxSizing:"border-box",padding:"10px",backgroundColor:"#e0e0e0",border:"none",fontSize:"14px",outline:"none",color:"#333",width:"100%",borderRadius:"10px"},A=C=>({padding:"8px",cursor:"pointer",backgroundColor:C?"#00a2ffff":"#e0e0e0",color:C?"#ffffffff":"#333",borderRadius:"10px 10px 0 0",fontSize:"14px",fontWeight:"bold",display:"flex",alignItems:"center",gap:"5px",whiteSpace:"nowrap"});return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",overflow:"hidden"},className:"nodrag nowheel",children:[e.jsx("div",{style:{flexShrink:0},children:e.jsx(Se,{placeholder:"Название теста",value:l,onChange:C=>i(C.target.value),style:{fontSize:"20px",fontWeight:"bold",borderRadius:"10px"}})}),e.jsxs("div",{style:{display:"flex",borderBottom:"2px solid #333",flexShrink:0},children:[e.jsx(q,{onClick:R,style:{borderRadius:"10px"},children:"←"}),e.jsx("div",{style:{display:"flex",overflowX:"auto"},children:a.map((C,z)=>e.jsxs("div",{style:A(z===s),onClick:()=>c(z),children:["Задание ",z+1,e.jsx("span",{onClick:B=>d(z,B),style:{fontSize:"10px",fontWeight:"bold"},children:"✕"})]},C.id))}),e.jsx(q,{onClick:w,style:{borderRadius:"10px",marginLeft:"auto"},children:"→"})]}),e.jsx("div",{className:"nowheel",onWheel:C=>C.stopPropagation(),style:{padding:"10px",flexGrow:1,minHeight:0,overflowY:"auto",marginBottom:"10px",color:"#333"},children:s!==null&&a[s]?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flex:1,flexDirection:"column",gap:"10px"},children:[e.jsx("label",{style:{fontSize:"18px",fontWeight:"bold"},children:"Вопрос:"}),e.jsx("textarea",{value:a[s].question,onChange:C=>b("question",C.target.value),style:{width:"100%",minHeight:"150px",fontSize:"18px",resize:"vertical",color:"#333",backgroundColor:"#ebebebff"},placeholder:"Введите текст вопроса..."})]}),e.jsxs("div",{onClick:()=>m(!x),style:{cursor:"pointer",fontWeight:"bold",marginBottom:"10px",display:"flex",gap:"5px"},children:[e.jsx("span",{children:"Параметры задания"}),e.jsx("span",{children:x?"▲":"▼"})]}),x&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px",width:"50%"},children:[e.jsxs("div",{style:_,children:[e.jsx("span",{children:"Тип:"}),e.jsxs("select",{value:a[s].type,onChange:C=>b("type",C.target.value),style:I,children:[e.jsx("option",{value:"text",children:"Текст"}),e.jsx("option",{value:"single",children:"Один выбор"}),e.jsx("option",{value:"multiple",children:"Множ. выбор"})]})]}),e.jsxs("div",{style:_,children:[e.jsxs("span",{children:["Баллы: ",a[s].score]}),e.jsx("input",{type:"range",min:"1",max:"50",value:a[s].score,onChange:C=>b("score",C.target.value),style:I})]})]}),a[s].type==="text"&&e.jsx("textarea",{value:a[s].correctText,onChange:C=>b("correctText",C.target.value),style:{width:"100%",minHeight:"80px",fontSize:"18px",resize:"vertical",color:"#333",backgroundColor:"#ebebebff"},placeholder:"Введите правильные варианты с разделением через ENTER"}),a[s].type==="single"&&e.jsx("div",{children:a[s].options.map((C,z)=>e.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:"10px",marginBottom:"5px"},children:[C!==""&&e.jsx(_e,{checked:a[s].correctRadioOption===C,onChange:()=>g(C),name:a[s].id}),e.jsx(Se,{placeholder:`Вариант ${z+1}`,value:C,onChange:B=>y(z,B.target.value),style:{borderRadius:"15px",marginBottom:"0px"}})]},z))}),a[s].type==="multiple"&&e.jsx("div",{children:a[s].options.map((C,z)=>e.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:"10px",marginBottom:"5px"},children:[C!==""&&e.jsx(ge,{checked:a[s].correctBoxOptions.includes(C),onChange:()=>k(C,a[s].correctBoxOptions)}),e.jsx(Se,{placeholder:`Вариант ${z+1}`,value:C,onChange:B=>y(z,B.target.value),style:{borderRadius:"15px",marginBottom:"0px"}})]},z))})]}):e.jsx("div",{style:{color:"#888",textAlign:"center",padding:"20px"},children:'Нет активных заданий. Нажмите "Добавить задание".'})}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",flexShrink:0,paddingTop:"10px",borderTop:"1px solid #eee"},children:[e.jsx(q,{onClick:v,style:{borderRadius:"10px"},children:"+ Добавить задание"}),e.jsx(q,{onClick:()=>n(),style:{borderRadius:"10px"},children:"Сохранить тест"})]})]})},Tt=({onDataChange:n,initialData:r,toggleSettings:o})=>{const[l,i]=f.useState((r==null?void 0:r.completionTime)||""),[a,u]=f.useState((r==null?void 0:r.endDate)||""),[s,c]=f.useState((r==null?void 0:r.endTime)||""),[x,m]=f.useState((r==null?void 0:r.attemptNumber)||"");f.useEffect(()=>{n({completionTime:l,attemptNumber:x,endDate:a,endTime:s})},[l,x,a,s,n]);const v={boxSizing:"border-box",padding:"12px 16px",backgroundColor:"#e0e0e0",border:"none",fontSize:"16px",color:"#333",outline:"none",fontFamily:"Arial, sans-serif",flex:1,borderRadius:"10px"},b={display:"flex",gap:"10px",alignItems:"center",color:"#333"};return e.jsxs("div",{className:"nodrag",style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",paddingRight:"5px",overflowY:"auto",overflowX:"hidden",boxSizing:"border-box"},children:[e.jsx("h3",{style:{fontSize:"20px",fontWeight:"bold",color:"#000",marginBottom:"25px",flexShrink:0},children:"Параметры теста"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[e.jsxs("div",{style:b,children:[e.jsx("span",{children:"Время (мин):"}),e.jsx("input",{type:"number",value:l,onChange:d=>i(d.target.value),placeholder:"Неограниченно",style:v})]}),e.jsxs("div",{style:b,children:[e.jsx("span",{style:{},children:"Пройти до"}),e.jsx("input",{type:"date",value:a,onChange:d=>u(d.target.value),style:v}),e.jsx("input",{type:"time",value:s,onChange:d=>c(d.target.value),style:v})]}),e.jsxs("div",{style:b,children:[e.jsx("span",{style:{},children:"Кол-во попыток:"}),e.jsx("input",{type:"number",value:x,onChange:d=>m(d.target.value),style:v,placeholder:"Неограниченно"})]})]}),e.jsx("div",{style:{flexShrink:0,display:"flex",justifyContent:"flex-end",marginTop:"auto",paddingTop:"20px"},children:e.jsx(q,{onClick:o,style:{width:"100%",borderRadius:"5px"},children:"Назад к тесту"})})]})},De=n=>{n||(n="https://polls-tests-widgets-backend-1357.loca.lt");const[r,o]=f.useState(!1),[l,i]=f.useState(null),a=b=>`${n?n.replace(/\/$/,""):""}/api/polls/tests${b}`,u=()=>{const b="csrftoken=",d=document.cookie?document.cookie.split(";"):[];for(let R of d)if(R=R.trim(),R.startsWith(b))return decodeURIComponent(R.substring(b.length));return null},s=async(b,d={})=>{const R=await fetch(b,{credentials:"include",...d,headers:{"Content-Type":"application/json","bypass-tunnel-reminder":"true",...d.headers}}),w=await R.json().catch(()=>null);if(!R.ok){const y=new Error((w==null?void 0:w.detail)||R.statusText||"Ошибка сервера");throw y.status=R.status,y.data=w,y}return w},c=f.useCallback(async b=>{o(!0),i(null);try{return await s(a(`/${b}/`))}catch(d){throw i(d.message),d}finally{o(!1)}},[]),x=f.useCallback(async(b,d)=>{o(!0),i(null);try{const R=u();return await s(a(`/${b}/`),{method:"DELETE",headers:{"X-CSRFToken":R},body:JSON.stringify({owner:d})})}catch(R){throw i(R.message),R}finally{o(!1)}},[]),m=f.useCallback(async(b,d)=>{o(!0),i(null);try{let R=null;d.endDate&&(R=new Date(`${d.endDate}T${d.endTime||"23:59:59"}`).toISOString());const w={title:b.title,owner:localStorage.getItem("userId")||"Anonymous",tasks:b.tasks.map(y=>({question:y.question,task_type:y.type,score:y.score,correct_text:y.correctText,options:y.options.filter(g=>g.trim()!=="").map(g=>({text:g,is_correct:y.type==="single"?g===y.correctRadioOption:y.correctBoxOptions.includes(g)}))})),completion_time:d.completionTime===""?null:parseInt(d.completionTime),attempt_number:d.attemptNumber===""?null:parseInt(d.attemptNumber),end_date:R||null};return await s(a("/"),{method:"POST",body:JSON.stringify(w)})}catch(R){throw i(R.message),R}finally{o(!1)}},[]),v=f.useCallback(async b=>{o(!0),i(null);try{return await s(a("/submit/"),{method:"POST",body:JSON.stringify(b)})}catch(d){throw i(d.message),d}finally{o(!1)}},[]);return{loading:r,error:l,createTest:m,fetchTest:c,submitAttempt:v,deleteTest:x}},_t=({testData:n,setTestData:r})=>{var $,de,ue,xe,ye,ce,pe,ae;const o=n==null?void 0:n.id,l=(n==null?void 0:n.title)||"",i=(n==null?void 0:n.tasks)||[];n!=null&&n.settings;const{submitAttempt:a,loading:u,fetchTest:s}=De(),c=localStorage.getItem("userId")||"Anonymous",[x,m]=f.useState(!0),[v,b]=f.useState(!1),[d,R]=f.useState(0),[w,y]=f.useState(null),[g,k]=f.useState([]),_=n==null?void 0:n.all_attempts.filter(T=>T.user===String(c)),I=n.attempt_number-_.length,[A,C]=f.useState(!1),[z,B]=f.useState(null),U=f.useRef(!1),O=()=>{if(!n.end_date)return!1;const T=new Date(n.end_date);return new Date>T},S=O();f.useEffect(()=>{},[]);const W=()=>{if(i&&Array.isArray(i)&&i.length>0){console.log("Инициализация задач в Display:",i);const T=i.map(p=>({id:p.id,question:p.question,type:p.task_type,score:p.score,options:Array.isArray(p.options)?p.options:[],completedText:"",completedRadioOptionId:"",completedBoxOptionIds:[]}));k(T),R(0)}},F=(T,p)=>{k(M=>{const V=[...M];return V[d]&&(V[d]={...V[d],[T]:p}),V})};f.useEffect(()=>{if(x||v||z===null)return;if(z<=0){X();return}const T=setInterval(()=>{B(p=>p-1)},1e3);return()=>clearInterval(T)},[z,x,v]);const J=T=>{const p=Math.floor(T/60),M=T%60;return`${p.toString().padStart(2,"0")}:${M.toString().padStart(2,"0")}`},G=()=>{d>0&&R(d-1)},K=()=>{d<i.length-1&&R(d+1)},P=T=>{const p=g[d];if(!p)return;const M=p.completedBoxOptionIds||[],V=M.includes(T)?M.filter(We=>We!==T):[...M,T];F("completedBoxOptionIds",V)},X=async()=>{if(U.current)return;U.current=!0;const T={test:o,user:c,answers:g.map(p=>{let M=[];if(p.type==="single"){const V=p.completedRadioOptionId;V&&(M=[V])}else p.type==="multiple"&&(M=p.completedBoxOptionIds);return{task:p.id,answer_text:p.completedText,selected_options:M}})};try{const p=await a(T);p&&(y(p),b(!0),m(!1),s&&r(await s(o)))}catch(p){console.error("Ошибка:",p)}finally{U.current=!1}},se=()=>{if(O()){alert("Время прохождения теста истекло.");return}W(),n.completion_time&&n.completion_time>0?B(n.completion_time*60):B(null),m(!1)},ne=()=>{b(!1),m(!0)};return w&&v?e.jsxs("div",{style:{textAlign:"center",padding:"20px",color:"#000"},children:[e.jsx("h3",{style:{color:"#28a745"},children:"Тест завершен!"}),e.jsxs("p",{style:{fontSize:"18px"},children:["Результат: ",e.jsx("b",{children:w.score_obtained})," / ",w.total_score]}),e.jsx(q,{onClick:ne,children:"ОК"})]}):!x&&g.length===0?e.jsx("div",{style:{color:"#000",padding:"20px"},children:"Загрузка..."}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",color:"#000"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"15px"},children:[e.jsx("h3",{style:{color:"#000",margin:0},children:l}),!x&&!v&&z!==null&&e.jsxs("div",{style:{fontWeight:"bold",fontSize:"18px",color:z<60?"red":"#00a2ff",border:"1px solid #ccc",padding:"5px 10px",borderRadius:"5px"},children:["⏱ ",J(z)]})]}),(n==null?void 0:n.owner)===c&&e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"15px"},children:[e.jsxs("p",{children:["Заданий: ",i.length]}),n.completion_time&&e.jsxs("p",{children:["Время: ",n.completion_time," мин."]}),n.end_date&&e.jsxs("p",{children:["Доступно до: ",new Date(n.end_date).toLocaleDateString()," ",new Date(n.end_date).toLocaleTimeString()]}),e.jsxs("p",{children:["Попыток: ",n.attempt_number]})]}),e.jsxs("div",{onClick:()=>C(T=>!T),style:{cursor:"pointer",fontWeight:"bold",marginBottom:"10px",display:"flex",gap:"5px"},children:[e.jsx("span",{children:"Посмотреть задания"}),e.jsx("span",{children:A?"▲":"▼"})]}),A&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",borderBottom:"2px solid #333"},children:[e.jsx(q,{onClick:G,style:{borderRadius:"10px"},children:"←"}),e.jsx("div",{style:{display:"flex",overflowX:"auto"},children:i.map((T,p)=>e.jsx("div",{onClick:()=>R(p),style:{padding:"8px 12px",cursor:"pointer",backgroundColor:p===d?"#00a2ff":"#eee",color:p===d?"#fff":"#000",marginRight:"2px",borderRadius:"5px 5px 0 0",minWidth:"25px",textAlign:"center"},children:p+1},p))}),e.jsx(q,{onClick:K,style:{borderRadius:"10px",marginLeft:"auto"},children:"→"})]}),e.jsxs("div",{style:{color:"#000"},children:[e.jsx("p",{style:{fontWeight:"bold"},children:($=i[d])==null?void 0:$.question}),((de=i[d])==null?void 0:de.task_type)==="text"&&e.jsxs("span",{children:["Ответ: ",i[d].correct_text]}),((ue=i[d])==null?void 0:ue.task_type)==="single"&&i[d].options.map((T,p)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"15px",cursor:"pointer",gap:"10px"},children:[e.jsx(_e,{checked:T.is_correct,onChange:()=>{}}),e.jsx("div",{style:{flexGrow:1,display:"flex",justifyContent:"space-between",backgroundColor:T.is_correct?"#d0d0d0":"#e0e0e0",padding:"12px 16px",borderRadius:"10px",position:"relative",overflow:"hidden"},children:e.jsx("span",{children:T.text})})]},p)),((xe=i[d])==null?void 0:xe.task_type)==="multiple"&&i[d].options.map((T,p)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"15px",cursor:"pointer",gap:"10px"},children:[e.jsx(ge,{checked:T.is_correct,onChange:()=>{}}),e.jsx("div",{style:{flexGrow:1,display:"flex",justifyContent:"space-between",backgroundColor:T.is_correct?"#d0d0d0":"#e0e0e0",padding:"12px 16px",borderRadius:"10px",position:"relative",overflow:"hidden"},children:e.jsx("span",{children:T.text})})]},p))]})]}),n!=null&&n.all_attempts&&(n==null?void 0:n.all_attempts.length)>0?e.jsxs("div",{style:{marginBottom:"20px",textAlign:"left"},children:[e.jsx("h4",{style:{marginBottom:"10px"},children:"Все результаты:"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",backgroundColor:"#f5f5f5",borderRadius:"10px",padding:"10px",maxHeight:"200px",overflowY:"auto",border:"1px solid #ddd"},children:n==null?void 0:n.all_attempts.map((T,p)=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:"10px 5px",borderBottom:p!==(n==null?void 0:n.all_attempts.length)-1?"1px solid #ddd":"none"},children:[e.jsx("span",{style:{fontWeight:"bold",fontSize:"14px"},children:T.user}),e.jsx("span",{style:{fontSize:"14px"},children:new Date(T.completed_at).toLocaleDateString()}),e.jsxs("span",{style:{fontWeight:"bold",fontSize:"14px"},children:[T.score_obtained," / ",T.total_score," баллов"]})]},p))})]}):e.jsx("div",{style:{color:"#888",textAlign:"center",padding:"20px"},children:"Нет результатов"})]}),(n==null?void 0:n.owner)!==c&&e.jsx("div",{children:x?e.jsxs("div",{style:{color:"#000"},children:[e.jsxs("div",{style:{marginBottom:"15px"},children:[e.jsxs("p",{children:["Автор: ",n.owner]}),e.jsxs("p",{children:["Заданий: ",i.length]}),n.completion_time&&e.jsxs("p",{children:["Время: ",n.completion_time," мин."]}),n.end_date&&e.jsxs("p",{children:["Доступно до: ",new Date(n.end_date).toLocaleDateString()," ",new Date(n.end_date).toLocaleTimeString()]}),e.jsxs("p",{children:["Попыток: ",I,"/",n.attempt_number]})]}),S?e.jsx("div",{style:{padding:"10px",backgroundColor:"#ffdddd",color:"red",borderRadius:"10px",textAlign:"center",fontWeight:"bold"},children:"Срок прохождения теста истек"}):e.jsx(q,{onClick:se,style:{borderRadius:"10px"},disabled:I<=0,children:"Начать тест"}),_&&_.length>0?e.jsxs("div",{style:{marginBottom:"20px",textAlign:"left"},children:[e.jsx("h4",{style:{marginBottom:"10px"},children:"Ваши предыдущие результаты:"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",backgroundColor:"#f5f5f5",borderRadius:"10px",padding:"10px",maxHeight:"200px",overflowY:"auto",border:"1px solid #ddd"},children:_.map((T,p)=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:"10px 5px",borderBottom:p!==_.length-1?"1px solid #ddd":"none"},children:[e.jsx("span",{style:{fontSize:"14px"},children:new Date(T.completed_at).toLocaleDateString()}),e.jsxs("span",{style:{fontWeight:"bold",fontSize:"14px"},children:[T.score_obtained," / ",T.total_score," баллов"]})]},p))})]}):e.jsx("div",{style:{color:"#888",textAlign:"center",padding:"20px"},children:"Нет результатов"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",borderBottom:"2px solid #333"},children:[e.jsx(q,{onClick:G,style:{borderRadius:"10px"},children:"←"}),e.jsx("div",{style:{display:"flex",overflowX:"auto"},children:g.map((T,p)=>e.jsx("div",{onClick:()=>R(p),style:{padding:"8px 12px",cursor:"pointer",backgroundColor:p===d?"#00a2ff":"#eee",color:p===d?"#fff":"#000",marginRight:"2px",borderRadius:"5px 5px 0 0",minWidth:"25px",textAlign:"center"},children:p+1},p))}),e.jsx(q,{onClick:K,style:{borderRadius:"10px",marginLeft:"auto"},children:"→"})]}),e.jsxs("div",{style:{color:"#000"},children:[e.jsx("p",{style:{fontWeight:"bold"},children:(ye=g[d])==null?void 0:ye.question}),((ce=g[d])==null?void 0:ce.type)==="text"&&e.jsx("textarea",{value:g[d].completedText,onChange:T=>F("completedText",T.target.value),style:{width:"100%",height:"80px",padding:"5px"}}),((pe=g[d])==null?void 0:pe.type)==="single"&&g[d].options.map((T,p)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"15px",cursor:"pointer",gap:"10px"},children:[e.jsx(_e,{checked:g[d].completedRadioOptionId===T.id,onChange:()=>F("completedRadioOptionId",T.id)}),e.jsx("div",{onClick:()=>F("completedRadioOptionId",T.id),style:{flexGrow:1,display:"flex",justifyContent:"space-between",backgroundColor:g[d].completedRadioOptionId===T.id?"#d0d0d0":"#e0e0e0",padding:"12px 16px",borderRadius:"10px",position:"relative",overflow:"hidden"},children:e.jsx("span",{children:T.text})})]},p)),((ae=g[d])==null?void 0:ae.type)==="multiple"&&g[d].options.map((T,p)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"15px",cursor:"pointer",gap:"10px"},children:[e.jsx(ge,{checked:g[d].completedBoxOptionIds.includes(T.id),onChange:()=>P(T.id)}),e.jsx("div",{onClick:()=>P(T.id),style:{flexGrow:1,display:"flex",justifyContent:"space-between",backgroundColor:g[d].completedBoxOptionIds.includes(T.id)?"#d0d0d0":"#e0e0e0",padding:"12px 16px",borderRadius:"10px",position:"relative",overflow:"hidden"},children:e.jsx("span",{children:T.text})})]},p))]}),e.jsx("div",{style:{marginTop:"20px",display:"flex",justifyContent:"flex-end"},children:d!==g.length-1&&e.jsx(q,{onClick:K,children:"Дальше"})}),e.jsx("div",{style:{marginTop:"20px",display:"flex",justifyContent:"flex-end"},children:d===g.length-1&&e.jsx(q,{onClick:X,disabled:u,children:u?"Сохранение...":"Завершить"})})]})})]})},zt=n=>{const o=`; ${document.cookie}`.split(`; ${n}=`);return o.length===2?o.pop().split(";").shift():null},Et=({initialTitle:n,pollId:r,nodeId:o,nodeProps:l,onSaved:i})=>{const{createTest:a,loading:u,error:s,fetchTest:c,deleteTest:x}=De(),[m,v]=f.useState(r?"display":"creator"),[b,d]=f.useState(!1),[R,w]=f.useState(null),[y,g]=f.useState({id:null,owner:"",title:n||"",tasks:[]}),[k,_]=f.useState({completionTime:null,attemptNumber:1,endDate:null,endTime:null}),[I,A]=f.useState(null);f.useEffect(()=>{let S=localStorage.getItem("userId");S||(S=zt("user_id")),S||(S="anon_"+Math.random().toString(36).substring(2,11),localStorage.setItem("userId",S)),w(S)},[]),f.useCallback(S=>{if(!S)return;console.log("Test Widget initialized with:",S);const{widgetId:W,userId:F,role:J,config:G,board:K}=S;W&&(async()=>{try{const X=await c(W);if(!X)return;A(X),g({id:X.id,title:X.title,tasks:X.tasks||[],all_attempts:X.all_attempts,owner:X.owner}),X.settings&&_(X.settings),d(!0)}catch(X){console.error("Ошибка загрузки теста:",X)}})();const P=["admin","editor","owner"].includes(J);v(P?X=>W?"display":"creator":"display")},[c]),f.useEffect(()=>{if(!r)return;let S=!0;return(async()=>{try{const W=await c(r);if(!S||!W)return;A(W),g({id:W.id,title:W.title,tasks:W.tasks||[],all_attempts:W.all_attempts,owner:W.owner}),W.settings&&_(W.settings),d(!0)}catch(W){console.error("Ошибка загрузки теста:",W)}})(),()=>{S=!1}},[r,c]);const C=f.useCallback(()=>v("creator"),[]),z=f.useCallback(()=>{v(S=>S==="settings"?"creator":"settings")},[]),B=async()=>{const S=(y==null?void 0:y.id)||pollId,W=localStorage.getItem("userId")||"Anonymous";if(!S){alert("Ошибка: ID теста не найден");return}if(window.confirm("Вы уверены, что хотите полностью удалить этот тест?"))try{await x(S,W),alert("Тест успешно удален"),setTimeout(()=>{window.location.reload()},100)}catch(F){console.error("Ошибка удаления:",F),F.status===403?alert("У вас нет прав на удаление (вы не автор)."):alert("Не удалось удалить тест: "+F.message)}},U=f.useCallback(async()=>{try{const S=await a(y,k);S&&S.id&&(A(S),d(!0),v("display"),typeof i=="function"&&i(S.id))}catch(S){console.error("Ошибка при сохранении:",S)}},[a,y,k]),O=()=>m==="settings"?"Настройки":y.title||"Тест";return r&&!b?e.jsx(Oe,{title:"Загрузка...",children:e.jsx("div",{style:{padding:"20px",textAlign:"center"},children:"Загрузка данных теста..."})}):e.jsxs(Oe,{title:O(),toggleSettings:m!=="display"?z:void 0,showMenuDots:m==="creator",children:[u&&e.jsx("p",{style:{color:"blue",textAlign:"center",margin:"5px 0"},children:"Синхронизация..."}),e.jsx("div",{style:{position:"relative"},children:e.jsxs("div",{style:{fontSize:"10px",color:"#999",textAlign:"right",padding:"0 15px"},children:["User ID: ",R]})}),m==="creator"&&e.jsx(kt,{onDataChange:g,initialData:y,onSave:U}),m==="settings"&&e.jsx(Tt,{onDataChange:_,initialData:k,toggleSettings:C}),m==="display"&&b&&e.jsxs("div",{style:{position:"relative",height:"100%",display:"flex",flexDirection:"column"},children:[(y==null?void 0:y.id)&&String(y.owner)===String(R)&&e.jsx("div",{onClick:B,style:{position:"absolute",top:"15px",right:"15px",width:"24px",height:"24px",backgroundColor:"#ff4d4d",color:"white",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:"18px",fontWeight:"bold",zIndex:1e3,boxShadow:"0 2px 5px rgba(0,0,0,0.2)",lineHeight:"1"},title:"Удалить тест",children:"×"}),e.jsx(_t,{testData:I,setTestData:A})]}),s&&e.jsx("div",{style:{color:"red",fontSize:"12px",padding:"10px",textAlign:"center"},children:s})]})},It={display:"flex",flexDirection:"column",background:"transparent",pointerEvents:"all",position:"relative"},Pt=n=>{const{id:r,data:o,selected:l,xPos:i,yPos:a,dragging:u}=n,[s,c]=f.useState({width:280,height:450}),x=oe.useUpdateNodeInternals(),{setNodes:m}=oe.useReactFlow(),v=f.useCallback((w,y,g,k)=>{const _=g.offsetWidth,I=g.offsetHeight;c({width:_,height:I}),x(r)},[]),b=f.useCallback(()=>{},[]),d={bottom:"nodrag",right:"nodrag",bottomRight:"nodrag"},R={bottom:{height:10,bottom:-5,cursor:"ns-resize",zIndex:999},right:{width:10,right:-5,cursor:"ew-resize",zIndex:999},bottomRight:{width:20,height:20,right:-5,bottom:-5,cursor:"nwse-resize",zIndex:1e3}};return e.jsxs(Je,{size:s,minWidth:800,minHeight:750,style:It,onResize:b,handleClasses:d,handleStyles:R,onResizeStop:v,enable:{top:!1,right:!0,bottom:!0,left:!1,topRight:!1,bottomRight:!0,bottomLeft:!1,topLeft:!1},onPointerDown:w=>w.stopPropagation(),children:[e.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,overflow:"hidden",outline:l?"2px solid #007bff":"none",borderRadius:"2px",boxShadow:"0 4px 15px rgba(0, 0, 0, 0.1)"},children:e.jsx(Ct,{initialTitle:o.label,pollId:o==null?void 0:o.pollId,nodeId:r,onSaved:w=>{m(y=>y.map(g=>g.id===r?{...g,data:{...g.data,pollId:w}}:g))}})}),e.jsx(oe.Handle,{type:"source",position:oe.Position.Left}),e.jsx(oe.Handle,{type:"target",position:oe.Position.Top})]})},Ot={display:"flex",flexDirection:"column",background:"transparent",pointerEvents:"all",position:"relative"},Wt=n=>{const{id:r,data:o,selected:l,xPos:i,yPos:a,dragging:u}=n,[s,c]=f.useState({width:280,height:450}),x=oe.useUpdateNodeInternals(),{setNodes:m}=oe.useReactFlow(),v=y=>{m(g=>g.map(k=>k.id===r?{...k,data:{...k.data,pollId:y}}:k))},b=f.useCallback((y,g,k,_)=>{const I=k.offsetWidth,A=k.offsetHeight;c({width:I,height:A}),x(r)},[]),d=f.useCallback(()=>{},[]),R={bottom:"nodrag",right:"nodrag",bottomRight:"nodrag"},w={bottom:{height:10,bottom:-5,cursor:"ns-resize",zIndex:999},right:{width:10,right:-5,cursor:"ew-resize",zIndex:999},bottomRight:{width:20,height:20,right:-5,bottom:-5,cursor:"nwse-resize",zIndex:1e3}};return e.jsxs(Je,{size:s,minWidth:800,minHeight:750,style:Ot,onResize:d,handleClasses:R,handleStyles:w,onResizeStop:b,enable:{top:!1,right:!0,bottom:!0,left:!1,topRight:!1,bottomRight:!0,bottomLeft:!1,topLeft:!1},onPointerDown:y=>y.stopPropagation(),children:[e.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,overflow:"hidden",outline:l?"2px solid #007bff":"none",borderRadius:"2px",boxShadow:"0 4px 15px rgba(0, 0, 0, 0.1)"},children:e.jsx(Et,{nodeId:r,initialTitle:o.label,pollId:o.pollId,nodeProps:n,onSaved:v})}),e.jsx(oe.Handle,{type:"source",position:oe.Position.Left}),e.jsx(oe.Handle,{type:"target",position:oe.Position.Top})]})};re.PollResizable=Pt,re.TestResizable=Wt,Object.defineProperty(re,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(Y,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react"),require("@xyflow/react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@xyflow/react","react-dom"],e):(Y=typeof globalThis<"u"?globalThis:Y||self,e(Y.PollTestWidgets={},Y.jsxRuntime,Y.React,Y.ReactFlow,Y.ReactDOM))})(this,function(Y,e,h,X,we){"use strict";var H=function(){return H=Object.assign||function(o){for(var s,t=1,n=arguments.length;t<n;t++){s=arguments[t];for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(o[i]=s[i])}return o},H.apply(this,arguments)},he={width:"100%",height:"10px",top:"0px",left:"0px",cursor:"row-resize"},fe={width:"10px",height:"100%",top:"0px",left:"0px",cursor:"col-resize"},ee={width:"20px",height:"20px",position:"absolute",zIndex:1},me={top:H(H({},he),{top:"-5px"}),right:H(H({},fe),{left:void 0,right:"-5px"}),bottom:H(H({},he),{top:void 0,bottom:"-5px"}),left:H(H({},fe),{left:"-5px"}),topRight:H(H({},ee),{right:"-10px",top:"-10px",cursor:"ne-resize"}),bottomRight:H(H({},ee),{right:"-10px",bottom:"-10px",cursor:"se-resize"}),bottomLeft:H(H({},ee),{left:"-10px",bottom:"-10px",cursor:"sw-resize"}),topLeft:H(H({},ee),{left:"-10px",top:"-10px",cursor:"nw-resize"})},Se=h.memo(function(o){var s=o.onResizeStart,t=o.direction,n=o.children,i=o.replaceStyles,l=o.className,c=h.useCallback(function(g){s(g,t)},[s,t]),r=h.useCallback(function(g){s(g,t)},[s,t]),p=h.useMemo(function(){return H(H({position:"absolute",userSelect:"none"},me[t]),i??{})},[i,t]);return e.jsx("div",{className:l||void 0,style:p,onMouseDown:c,onTouchStart:r,children:n})}),Ce=function(){var o=function(s,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var l in i)Object.prototype.hasOwnProperty.call(i,l)&&(n[l]=i[l])},o(s,t)};return function(s,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");o(s,t);function n(){this.constructor=s}s.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),q=function(){return q=Object.assign||function(o){for(var s,t=1,n=arguments.length;t<n;t++){s=arguments[t];for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(o[i]=s[i])}return o},q.apply(this,arguments)},ze={width:"auto",height:"auto"},te=function(o,s,t){return Math.max(Math.min(o,t),s)},ue=function(o,s,t){var n=Math.round(o/s);return n*s+t*(n-1)},Q=function(o,s){return new RegExp(o,"i").test(s)},oe=function(o){return!!(o.touches&&o.touches.length)},ke=function(o){return!!((o.clientX||o.clientX===0)&&(o.clientY||o.clientY===0))},ge=function(o,s,t){t===void 0&&(t=0);var n=s.reduce(function(l,c,r){return Math.abs(c-o)<Math.abs(s[l]-o)?r:l},0),i=Math.abs(s[n]-o);return t===0||i<t?s[n]:o},ce=function(o){return o=o.toString(),o==="auto"||o.endsWith("px")||o.endsWith("%")||o.endsWith("vh")||o.endsWith("vw")||o.endsWith("vmax")||o.endsWith("vmin")?o:"".concat(o,"px")},ie=function(o,s,t,n){if(o&&typeof o=="string"){if(o.endsWith("px"))return Number(o.replace("px",""));if(o.endsWith("%")){var i=Number(o.replace("%",""))/100;return s*i}if(o.endsWith("vw")){var i=Number(o.replace("vw",""))/100;return t*i}if(o.endsWith("vh")){var i=Number(o.replace("vh",""))/100;return n*i}}return o},Te=function(o,s,t,n,i,l,c){return n=ie(n,o.width,s,t),i=ie(i,o.height,s,t),l=ie(l,o.width,s,t),c=ie(c,o.height,s,t),{maxWidth:typeof n>"u"?void 0:Number(n),maxHeight:typeof i>"u"?void 0:Number(i),minWidth:typeof l>"u"?void 0:Number(l),minHeight:typeof c>"u"?void 0:Number(c)}},_e=function(o){return Array.isArray(o)?o:[o,o]},Ie=["as","ref","style","className","grid","gridGap","snap","bounds","boundsByDirection","size","defaultSize","minWidth","minHeight","maxWidth","maxHeight","lockAspectRatio","lockAspectRatioExtraWidth","lockAspectRatioExtraHeight","enable","handleStyles","handleClasses","handleWrapperStyle","handleWrapperClass","children","onResizeStart","onResize","onResizeStop","handleComponent","scale","resizeRatio","snapGap"],xe="__resizable_base__",ye=function(o){Ce(s,o);function s(t){var n,i,l,c,r=o.call(this,t)||this;return r.ratio=1,r.resizable=null,r.parentLeft=0,r.parentTop=0,r.resizableLeft=0,r.resizableRight=0,r.resizableTop=0,r.resizableBottom=0,r.targetLeft=0,r.targetTop=0,r.delta={width:0,height:0},r.appendBase=function(){if(!r.resizable||!r.window)return null;var p=r.parentNode;if(!p)return null;var g=r.window.document.createElement("div");return g.style.width="100%",g.style.height="100%",g.style.position="absolute",g.style.transform="scale(0, 0)",g.style.left="0",g.style.flex="0 0 100%",g.classList?g.classList.add(xe):g.className+=xe,p.appendChild(g),g},r.removeBase=function(p){var g=r.parentNode;g&&g.removeChild(p)},r.state={isResizing:!1,width:(i=(n=r.propsSize)===null||n===void 0?void 0:n.width)!==null&&i!==void 0?i:"auto",height:(c=(l=r.propsSize)===null||l===void 0?void 0:l.height)!==null&&c!==void 0?c:"auto",direction:"right",original:{x:0,y:0,width:0,height:0},backgroundStyle:{height:"100%",width:"100%",backgroundColor:"rgba(0,0,0,0)",cursor:"auto",opacity:0,position:"fixed",zIndex:9999,top:"0",left:"0",bottom:"0",right:"0"},flexBasis:void 0},r.onResizeStart=r.onResizeStart.bind(r),r.onMouseMove=r.onMouseMove.bind(r),r.onMouseUp=r.onMouseUp.bind(r),r}return Object.defineProperty(s.prototype,"parentNode",{get:function(){return this.resizable?this.resizable.parentNode:null},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"window",{get:function(){return!this.resizable||!this.resizable.ownerDocument?null:this.resizable.ownerDocument.defaultView},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"propsSize",{get:function(){return this.props.size||this.props.defaultSize||ze},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"size",{get:function(){var t=0,n=0;if(this.resizable&&this.window){var i=this.resizable.offsetWidth,l=this.resizable.offsetHeight,c=this.resizable.style.position;c!=="relative"&&(this.resizable.style.position="relative"),t=this.resizable.style.width!=="auto"?this.resizable.offsetWidth:i,n=this.resizable.style.height!=="auto"?this.resizable.offsetHeight:l,this.resizable.style.position=c}return{width:t,height:n}},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"sizeStyle",{get:function(){var t=this,n=this.props.size,i=function(r){var p;if(typeof t.state[r]>"u"||t.state[r]==="auto")return"auto";if(t.propsSize&&t.propsSize[r]&&(!((p=t.propsSize[r])===null||p===void 0)&&p.toString().endsWith("%"))){if(t.state[r].toString().endsWith("%"))return t.state[r].toString();var g=t.getParentSize(),b=Number(t.state[r].toString().replace("px","")),y=b/g[r]*100;return"".concat(y,"%")}return ce(t.state[r])},l=n&&typeof n.width<"u"&&!this.state.isResizing?ce(n.width):i("width"),c=n&&typeof n.height<"u"&&!this.state.isResizing?ce(n.height):i("height");return{width:l,height:c}},enumerable:!1,configurable:!0}),s.prototype.getParentSize=function(){if(!this.parentNode)return this.window?{width:this.window.innerWidth,height:this.window.innerHeight}:{width:0,height:0};var t=this.appendBase();if(!t)return{width:0,height:0};var n=!1,i=this.parentNode.style.flexWrap;i!=="wrap"&&(n=!0,this.parentNode.style.flexWrap="wrap"),t.style.position="relative",t.style.minWidth="100%",t.style.minHeight="100%";var l={width:t.offsetWidth,height:t.offsetHeight};return n&&(this.parentNode.style.flexWrap=i),this.removeBase(t),l},s.prototype.bindEvents=function(){this.window&&(this.window.addEventListener("mouseup",this.onMouseUp),this.window.addEventListener("mousemove",this.onMouseMove),this.window.addEventListener("mouseleave",this.onMouseUp),this.window.addEventListener("touchmove",this.onMouseMove,{capture:!0,passive:!1}),this.window.addEventListener("touchend",this.onMouseUp))},s.prototype.unbindEvents=function(){this.window&&(this.window.removeEventListener("mouseup",this.onMouseUp),this.window.removeEventListener("mousemove",this.onMouseMove),this.window.removeEventListener("mouseleave",this.onMouseUp),this.window.removeEventListener("touchmove",this.onMouseMove,!0),this.window.removeEventListener("touchend",this.onMouseUp))},s.prototype.componentDidMount=function(){if(!(!this.resizable||!this.window)){var t=this.window.getComputedStyle(this.resizable);this.setState({width:this.state.width||this.size.width,height:this.state.height||this.size.height,flexBasis:t.flexBasis!=="auto"?t.flexBasis:void 0})}},s.prototype.componentWillUnmount=function(){this.window&&this.unbindEvents()},s.prototype.createSizeForCssProperty=function(t,n){var i=this.propsSize&&this.propsSize[n];return this.state[n]==="auto"&&this.state.original[n]===t&&(typeof i>"u"||i==="auto")?"auto":t},s.prototype.calculateNewMaxFromBoundary=function(t,n){var i=this.props.boundsByDirection,l=this.state.direction,c=i&&Q("left",l),r=i&&Q("top",l),p,g;if(this.props.bounds==="parent"){var b=this.parentNode;b&&(p=c?this.resizableRight-this.parentLeft:b.offsetWidth+(this.parentLeft-this.resizableLeft),g=r?this.resizableBottom-this.parentTop:b.offsetHeight+(this.parentTop-this.resizableTop))}else this.props.bounds==="window"?this.window&&(p=c?this.resizableRight:this.window.innerWidth-this.resizableLeft,g=r?this.resizableBottom:this.window.innerHeight-this.resizableTop):this.props.bounds&&(p=c?this.resizableRight-this.targetLeft:this.props.bounds.offsetWidth+(this.targetLeft-this.resizableLeft),g=r?this.resizableBottom-this.targetTop:this.props.bounds.offsetHeight+(this.targetTop-this.resizableTop));return p&&Number.isFinite(p)&&(t=t&&t<p?t:p),g&&Number.isFinite(g)&&(n=n&&n<g?n:g),{maxWidth:t,maxHeight:n}},s.prototype.calculateNewSizeFromDirection=function(t,n){var i=this.props.scale||1,l=_e(this.props.resizeRatio||1),c=l[0],r=l[1],p=this.state,g=p.direction,b=p.original,y=this.props,x=y.lockAspectRatio,d=y.lockAspectRatioExtraHeight,m=y.lockAspectRatioExtraWidth,v=b.width,u=b.height,f=d||0,T=m||0;return Q("right",g)&&(v=b.width+(t-b.x)*c/i,x&&(u=(v-T)/this.ratio+f)),Q("left",g)&&(v=b.width-(t-b.x)*c/i,x&&(u=(v-T)/this.ratio+f)),Q("bottom",g)&&(u=b.height+(n-b.y)*r/i,x&&(v=(u-f)*this.ratio+T)),Q("top",g)&&(u=b.height-(n-b.y)*r/i,x&&(v=(u-f)*this.ratio+T)),{newWidth:v,newHeight:u}},s.prototype.calculateNewSizeFromAspectRatio=function(t,n,i,l){var c=this.props,r=c.lockAspectRatio,p=c.lockAspectRatioExtraHeight,g=c.lockAspectRatioExtraWidth,b=typeof l.width>"u"?10:l.width,y=typeof i.width>"u"||i.width<0?t:i.width,x=typeof l.height>"u"?10:l.height,d=typeof i.height>"u"||i.height<0?n:i.height,m=p||0,v=g||0;if(r){var u=(x-m)*this.ratio+v,f=(d-m)*this.ratio+v,T=(b-v)/this.ratio+m,z=(y-v)/this.ratio+m,_=Math.max(b,u),B=Math.min(y,f),S=Math.max(x,T),k=Math.min(d,z);t=te(t,_,B),n=te(n,S,k)}else t=te(t,b,y),n=te(n,x,d);return{newWidth:t,newHeight:n}},s.prototype.setBoundingClientRect=function(){var t=1/(this.props.scale||1);if(this.props.bounds==="parent"){var n=this.parentNode;if(n){var i=n.getBoundingClientRect();this.parentLeft=i.left*t,this.parentTop=i.top*t}}if(this.props.bounds&&typeof this.props.bounds!="string"){var l=this.props.bounds.getBoundingClientRect();this.targetLeft=l.left*t,this.targetTop=l.top*t}if(this.resizable){var c=this.resizable.getBoundingClientRect(),r=c.left,p=c.top,g=c.right,b=c.bottom;this.resizableLeft=r*t,this.resizableRight=g*t,this.resizableTop=p*t,this.resizableBottom=b*t}},s.prototype.onResizeStart=function(t,n){if(!(!this.resizable||!this.window)){var i=0,l=0;if(t.nativeEvent&&ke(t.nativeEvent)?(i=t.nativeEvent.clientX,l=t.nativeEvent.clientY):t.nativeEvent&&oe(t.nativeEvent)&&(i=t.nativeEvent.touches[0].clientX,l=t.nativeEvent.touches[0].clientY),this.props.onResizeStart&&this.resizable){var c=this.props.onResizeStart(t,n,this.resizable);if(c===!1)return}this.props.size&&(typeof this.props.size.height<"u"&&this.props.size.height!==this.state.height&&this.setState({height:this.props.size.height}),typeof this.props.size.width<"u"&&this.props.size.width!==this.state.width&&this.setState({width:this.props.size.width})),this.ratio=typeof this.props.lockAspectRatio=="number"?this.props.lockAspectRatio:this.size.width/this.size.height;var r,p=this.window.getComputedStyle(this.resizable);if(p.flexBasis!=="auto"){var g=this.parentNode;if(g){var b=this.window.getComputedStyle(g).flexDirection;this.flexDir=b.startsWith("row")?"row":"column",r=p.flexBasis}}this.setBoundingClientRect(),this.bindEvents();var y={original:{x:i,y:l,width:this.size.width,height:this.size.height},isResizing:!0,backgroundStyle:q(q({},this.state.backgroundStyle),{cursor:this.window.getComputedStyle(t.target).cursor||"auto"}),direction:n,flexBasis:r};this.setState(y)}},s.prototype.onMouseMove=function(t){var n=this;if(!(!this.state.isResizing||!this.resizable||!this.window)){if(this.window.TouchEvent&&oe(t))try{t.preventDefault(),t.stopPropagation()}catch{}var i=this.props,l=i.maxWidth,c=i.maxHeight,r=i.minWidth,p=i.minHeight,g=oe(t)?t.touches[0].clientX:t.clientX,b=oe(t)?t.touches[0].clientY:t.clientY,y=this.state,x=y.direction,d=y.original,m=y.width,v=y.height,u=this.getParentSize(),f=Te(u,this.window.innerWidth,this.window.innerHeight,l,c,r,p);l=f.maxWidth,c=f.maxHeight,r=f.minWidth,p=f.minHeight;var T=this.calculateNewSizeFromDirection(g,b),z=T.newHeight,_=T.newWidth,B=this.calculateNewMaxFromBoundary(l,c);this.props.snap&&this.props.snap.x&&(_=ge(_,this.props.snap.x,this.props.snapGap)),this.props.snap&&this.props.snap.y&&(z=ge(z,this.props.snap.y,this.props.snapGap));var S=this.calculateNewSizeFromAspectRatio(_,z,{width:B.maxWidth,height:B.maxHeight},{width:r,height:p});if(_=S.newWidth,z=S.newHeight,this.props.grid){var k=ue(_,this.props.grid[0],this.props.gridGap?this.props.gridGap[0]:0),E=ue(z,this.props.grid[1],this.props.gridGap?this.props.gridGap[1]:0),N=this.props.snapGap||0,I=N===0||Math.abs(k-_)<=N?k:_,w=N===0||Math.abs(E-z)<=N?E:z;_=I,z=w}var P={width:_-d.width,height:z-d.height};if(this.delta=P,m&&typeof m=="string"){if(m.endsWith("%")){var M=_/u.width*100;_="".concat(M,"%")}else if(m.endsWith("vw")){var U=_/this.window.innerWidth*100;_="".concat(U,"vw")}else if(m.endsWith("vh")){var j=_/this.window.innerHeight*100;_="".concat(j,"vh")}}if(v&&typeof v=="string"){if(v.endsWith("%")){var M=z/u.height*100;z="".concat(M,"%")}else if(v.endsWith("vw")){var U=z/this.window.innerWidth*100;z="".concat(U,"vw")}else if(v.endsWith("vh")){var j=z/this.window.innerHeight*100;z="".concat(j,"vh")}}var G={width:this.createSizeForCssProperty(_,"width"),height:this.createSizeForCssProperty(z,"height")};this.flexDir==="row"?G.flexBasis=G.width:this.flexDir==="column"&&(G.flexBasis=G.height);var W=this.state.width!==G.width,O=this.state.height!==G.height,V=this.state.flexBasis!==G.flexBasis,J=W||O||V;J&&we.flushSync(function(){n.setState(G)}),this.props.onResize&&J&&this.props.onResize(t,x,this.resizable,P)}},s.prototype.onMouseUp=function(t){var n,i,l=this.state,c=l.isResizing,r=l.direction;l.original,!(!c||!this.resizable)&&(this.props.onResizeStop&&this.props.onResizeStop(t,r,this.resizable,this.delta),this.props.size&&this.setState({width:(n=this.props.size.width)!==null&&n!==void 0?n:"auto",height:(i=this.props.size.height)!==null&&i!==void 0?i:"auto"}),this.unbindEvents(),this.setState({isResizing:!1,backgroundStyle:q(q({},this.state.backgroundStyle),{cursor:"auto"})}))},s.prototype.updateSize=function(t){var n,i;this.setState({width:(n=t.width)!==null&&n!==void 0?n:"auto",height:(i=t.height)!==null&&i!==void 0?i:"auto"})},s.prototype.renderResizer=function(){var t=this,n=this.props,i=n.enable,l=n.handleStyles,c=n.handleClasses,r=n.handleWrapperStyle,p=n.handleWrapperClass,g=n.handleComponent;if(!i)return null;var b=Object.keys(i).map(function(y){return i[y]!==!1?e.jsx(Se,{direction:y,onResizeStart:t.onResizeStart,replaceStyles:l&&l[y],className:c&&c[y],children:g&&g[y]?g[y]:null},y):null});return e.jsx("div",{className:p,style:r,children:b})},s.prototype.render=function(){var t=this,n=Object.keys(this.props).reduce(function(c,r){return Ie.indexOf(r)!==-1||(c[r]=t.props[r]),c},{}),i=q(q(q({position:"relative",userSelect:this.state.isResizing?"none":"auto"},this.props.style),this.sizeStyle),{maxWidth:this.props.maxWidth,maxHeight:this.props.maxHeight,minWidth:this.props.minWidth,minHeight:this.props.minHeight,boxSizing:"border-box",flexShrink:0});this.state.flexBasis&&(i.flexBasis=this.state.flexBasis);var l=this.props.as||"div";return e.jsxs(l,q({style:i,className:this.props.className},n,{ref:function(c){c&&(t.resizable=c)},children:[this.state.isResizing&&e.jsx("div",{style:this.state.backgroundStyle}),this.props.children,this.renderResizer()]}))},s.defaultProps={as:"div",onResizeStart:function(){},onResize:function(){},onResizeStop:function(){},enable:{top:!0,right:!0,bottom:!0,left:!0,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},style:{},grid:[1,1],gridGap:[0,0],lockAspectRatio:!1,lockAspectRatioExtraWidth:0,lockAspectRatioExtraHeight:0,scale:1,resizeRatio:1,snapGap:0},s}(h.PureComponent);const ve=o=>{o||(o="https://polls-tests-widgets-backend-1357.loca.lt");const[s,t]=h.useState(!1),[n,i]=h.useState(null),l=v=>`${o?o.replace(/\/$/,""):""}/api/polls${v}`,c=()=>{const v="csrftoken=",u=document.cookie?document.cookie.split(";"):[];for(let f of u)if(f=f.trim(),f.startsWith(v))return decodeURIComponent(f.substring(v.length));return null},r=async()=>{await fetch(l("/csrf/"),{credentials:"include"})},p=async(v,u={})=>{const f={credentials:"include",method:"GET",mode:"cors",headers:{"Content-Type":"application/json","bypass-tunnel-reminder":"true"}},T={...f,...u,headers:{...f.headers,...u.headers||{}}},z=await fetch(v,T),_=await z.text();let B=null;try{B=_?JSON.parse(_):null}catch{B=_}if(!z.ok){const S=new Error(B&&(B.detail||B.message)||z.statusText);throw S.status=z.status,S}return B},g=h.useCallback(async(v,u)=>{t(!0),i(null);try{await r();const f=c();return await p(l(`/${v}/`),{method:"DELETE",mode:"cors",headers:{"X-CSRFToken":f,"X-User-ID":u}})}catch(f){throw i(f.message),f}finally{t(!1)}},[]),b=h.useCallback(async()=>{try{return await p(l("/list/"),{method:"GET"})}catch(v){throw console.error("Ошибка получения списка опросов:",v),v}},[p]),y=h.useCallback(async v=>{t(!0),i(null);try{return await p(l(`/${v}/`),{method:"GET",mode:"cors"})}catch(u){return i(u.message),null}finally{t(!1)}},[]),x=h.useCallback(async(v,u)=>{t(!0),i(null),await r();const f=c();if(!f)throw new Error("CSRF token missing!");const T=(v.options||[]).filter(B=>B.trim()!=="").map(B=>({choice_text:B}));let z=null;u.endDate&&(z=new Date(`${u.endDate}T${u.endTime||"23:59:59"}`).toISOString());const _={owner:v.ownerID,title:v.title,choices:T,is_anonymous:u.isAnonymous,multiple_answers:u.multipleAnswers,end_date:z};try{return await p(l("/create/"),{method:"POST",mode:"cors",headers:{"X-CSRFToken":f},body:JSON.stringify(_)})}catch(B){throw i(B.message),B}finally{t(!1)}},[]);h.useCallback(async v=>{t(!0),i(null);try{return await p(l(`/${v}/`),{method:"GET"})}catch(u){return i(u.message),null}finally{t(!1)}},[]);const d=h.useCallback(async(v,u)=>{t(!0),i(null),await r();const f=c();if(!f)throw new Error("CSRF token missing!");try{return await p(l(`/${v}/vote/`),{method:"POST",headers:{"X-CSRFToken":f},body:JSON.stringify({choice_id:u.choiceId,user:u.userId})})}catch(T){throw i(T.message),T}finally{t(!1)}},[]),m=h.useCallback(async(v,u)=>{t(!0),i(null),await r();const f=c();try{return await p(l(`/${v}/unvote/}`),{method:"POST",headers:{"X-CSRFToken":f},body:JSON.stringify({user:u})})}catch(T){throw i(T.message),T}finally{t(!1)}},[]);return{createPoll:x,loading:s,error:n,setError:i,fetchAllPolls:b,fetchPoll:y,createPoll:x,votePoll:d,unvotePoll:m,deletePoll:g}},K=({placeholder:o,value:s,onChange:t,style:n,autoFocus:i,type:l="text"})=>e.jsx("input",{type:l,placeholder:o,value:s,onChange:t,autoFocus:i,className:"nodrag",style:{width:"100%",boxSizing:"border-box",padding:"12px 16px",marginBottom:"12px",backgroundColor:"#e0e0e0",border:"none",borderRadius:"0px",fontSize:"16px",color:"#333",outline:"none",fontFamily:"Arial, sans-serif",...n}}),F=({onClick:o,children:s,style:t,disabled:n})=>e.jsx("button",{onClick:n?void 0:o,disabled:n,className:"nodrag",style:{padding:"10px 30px",backgroundColor:n?"#f0f0f0":"#d9d9d9",border:"none",borderRadius:"0px",fontSize:"18px",color:n?"#999":"#000",cursor:n?"not-allowed":"pointer",fontWeight:"400",transition:"background-color 0.2s",whiteSpace:"nowrap",opacity:n?.7:1,...t},onMouseOver:i=>{n||(i.target.style.backgroundColor="#c0c0c0")},onMouseOut:i=>{n||(i.target.style.backgroundColor=(t==null?void 0:t.backgroundColor)||"#d9d9d9")},children:s}),Z=({checked:o,onChange:s})=>e.jsxs("label",{style:{display:"inline-flex",alignItems:"center",cursor:"pointer",userSelect:"none",position:"relative"},children:[e.jsx("input",{type:"checkbox",checked:o,onChange:s,style:{opacity:0,width:0,height:0,position:"absolute"}}),e.jsx("span",{style:{display:"inline-block",width:"24px",height:"24px",border:`2px solid ${o?"#000":"#6c757d"}`,borderRadius:"4px",backgroundColor:o?"#000":"#fff",transition:"background-color 0.2s, border-color 0.2s",position:"relative",flexShrink:0},children:o&&e.jsx("span",{style:{content:'""',position:"absolute",left:"8px",top:"3px",width:"6px",height:"14px",border:"solid white",borderWidth:"0 3px 3px 0",transform:"rotate(45deg)",transition:"opacity 0.2s",opacity:o?1:0}})})]}),We=({onClick:o})=>e.jsx("div",{onClick:o,className:"nodrag",style:{display:"flex",gap:"6px",cursor:"pointer",flexShrink:0,padding:"5px"},children:[1,2,3].map(s=>e.jsx("div",{style:{width:"14px",height:"14px",borderRadius:"50%",backgroundColor:"#757575"}},s))}),se=({id:o,name:s,value:t,checked:n,onChange:i,children:l})=>e.jsxs("label",{htmlFor:o,style:{display:"inline-flex",alignItems:"center",cursor:"pointer",userSelect:"none"},children:[e.jsx("input",{id:o,type:"radio",name:s,value:t,checked:n,onChange:i,style:{opacity:0,width:0,height:0,position:"absolute"}}),e.jsx("span",{style:{display:"inline-block",width:"20px",height:"20px",borderRadius:"50%",border:`2px solid ${n?"#000":"#6c757d"}`,backgroundColor:"#fff",position:"relative",flexShrink:0,transition:"border-color 0.2s"},children:n&&e.jsx("span",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"10px",height:"10px",borderRadius:"50%",backgroundColor:"#000",transition:"opacity 0.2s",opacity:1}})}),l]}),pe=({title:o,children:s,style:t,toggleSettings:n,showMenuDots:i=!0})=>e.jsxs("div",{style:{width:"100%",height:"100%",backgroundColor:"#fff",padding:"20px 24px",display:"flex",flexDirection:"column",boxSizing:"border-box",boxShadow:"0 2px 10px rgba(0,0,0,0.05)",position:"relative",overflow:"hidden",...t},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"20px",flexShrink:0},children:[e.jsx("span",{style:{fontSize:"20px",fontWeight:"400",color:"#000",lineHeight:"1.2",wordBreak:"break-word",marginRight:"10px"},children:o}),i&&e.jsx(We,{onClick:n})]}),e.jsx("div",{style:{flexGrow:1,display:"flex",flexDirection:"column",overflow:"hidden",minHeight:0},children:s})]}),Be=({onSave:o,onDataChange:s,initialData:t})=>{var b;const n=t!=null&&t.options&&t.options.length>0&&t.options.some(y=>y.trim()==="")?t.options:[...((b=t==null?void 0:t.options)==null?void 0:b.filter(y=>y.trim()!==""))||[],""],[i,l]=h.useState((t==null?void 0:t.title)||""),[c,r]=h.useState(n),p=h.useRef(null);h.useEffect(()=>{s({title:i,options:c.filter(y=>y.trim()!=="")})},[i,c,s]);const g=(y,x)=>{let d=[...c];d[y]=x,y===d.length-1&&x.trim()!==""&&d.push(""),d=d.filter((m,v)=>m.trim()!==""||v===d.length-1),r(d)};return h.useEffect(()=>{p.current&&c.length>1&&c[c.length-1].trim()===""&&p.current.scrollIntoView({behavior:"smooth"})},[c.length]),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",overflow:"hidden"},children:[e.jsx("div",{style:{flexShrink:0,width:"100%"},children:e.jsx(K,{placeholder:"Название опроса",value:i,onChange:y=>l(y.target.value),style:{fontSize:"20px",padding:"14px 16px",marginBottom:"20px",color:"#333",fontWeight:"bold",borderRadius:"15px"}})}),e.jsxs("div",{className:"scroll-container nowheel",onWheel:y=>y.stopPropagation(),style:{flexGrow:1,overflowY:"auto",overflowX:"hidden",paddingRight:"5px",marginBottom:"10px",width:"100%"},children:[c.map((y,x)=>e.jsx("div",{style:{display:"flex",alignItems:"center"},children:e.jsx(K,{placeholder:`Вариант ${x+1}`,value:y,onChange:d=>g(x,d.target.value),style:{flexGrow:1,marginBottom:"10px",borderRadius:"15px"}})},x)),e.jsx("div",{ref:p})]}),e.jsx("div",{style:{flexShrink:0,marginTop:"20px"},children:e.jsx(F,{onClick:()=>o(),style:{width:"100%",borderRadius:"15px"},children:"Сохранить опрос"})})]})},Ee=({onDataChange:o,initialData:s,toggleSettings:t,onDelete:n})=>{const[i,l]=h.useState((s==null?void 0:s.isAnonymous)||!1),[c,r]=h.useState((s==null?void 0:s.multipleAnswers)||!1),[p,g]=h.useState((s==null?void 0:s.endDate)||""),[b,y]=h.useState((s==null?void 0:s.endTime)||"");h.useEffect(()=>{o({isAnonymous:i,multipleAnswers:c,endDate:p,endTime:b})},[i,c,p,b,o]);const x={boxSizing:"border-box",padding:"12px 16px",backgroundColor:"#e0e0e0",border:"none",borderRadius:"15px",fontSize:"16px",color:"#333",outline:"none",fontFamily:"Arial, sans-serif",flex:1};return e.jsxs("div",{className:"nodrag",style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",paddingRight:"5px",overflowY:"auto",overflowX:"hidden",boxSizing:"border-box"},children:[e.jsx("h3",{style:{fontSize:"20px",fontWeight:"bold",color:"#000",marginBottom:"25px",flexShrink:0},children:"Параметры опроса"}),e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",marginBottom:"25px"},children:[e.jsx(Z,{checked:i,onChange:()=>l(!i)}),e.jsx("span",{style:{fontSize:"18px",color:"#333"},children:"Анонимность"})]}),e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",marginBottom:"25px"},children:[e.jsx(Z,{checked:c,onChange:()=>r(!c)}),e.jsx("span",{style:{fontSize:"18px",color:"#333"},children:"Несколько ответов"})]}),e.jsxs("div",{style:{flexShrink:0},children:[e.jsx("span",{style:{fontSize:"18px",color:"#333",marginBottom:"10px",display:"block"},children:"Дата и время окончания"}),e.jsxs("div",{style:{display:"flex",gap:"10px"},children:[e.jsx("input",{type:"date",className:"nodrag",value:p,onChange:d=>g(d.target.value),style:x}),e.jsx("input",{type:"time",className:"nodrag",value:b,onChange:d=>y(d.target.value),style:x})]})]}),e.jsx("div",{style:{flexShrink:0,display:"flex",justifyContent:"flex-end",marginTop:"auto",paddingTop:"20px"},children:e.jsx(F,{onClick:t,style:{width:"100%",borderRadius:"15px"},children:"Назад к опросу"})})]})},Pe=({pollData:o,setPollData:s})=>{var C;const{id:t,title:n,choices:i,all_votes:l=[],voted_users:c=[],is_anonymous:r,multiple_answers:p,end_date:g,total_votes:b}=o,x=(()=>{if(!g)return!1;const a=new Date(g);return new Date>a})(),{votePoll:d,loading:m,error:v,setError:u,fetchPoll:f,unvotePoll:T}=ve(),z=localStorage.getItem("userId")||"Anonymous",_=r?"Анонимно":"Неанонимно",B=g?`До ${g.split("T")[0]}`:"Нет даты",S=a=>!c||c.length===0?"0%":`${Math.round(a/c.length*100)}%`,[k,E]=h.useState(l.some(a=>a.user===String(z))),[N,I]=h.useState(),[w,P]=h.useState([]),[M,U]=h.useState(l.find(a=>a.user===String(z))),[j,G]=h.useState(!1),[W,O]=h.useState(0),[V,J]=h.useState(k||m||x||!p&&!N||p&&w.length===0);h.useEffect(()=>{J(k||m||x||!p&&!N||p&&w.length===0)},[k,m,p,N,w,x]);const $=a=>{I(a)},D=a=>{P(A=>A.includes(a)?A.filter(L=>L!==a):[...A,a])},re=a=>{r||(G(!0),O(a))},ne=()=>{G(!1)},le=async()=>{if(x){alert("Время прохождения теста истекло.");return}if(!(!p&&!N||p&&w.length===0))try{let a=!0;if(p){const A=w.map(L=>d(t,{choiceId:L,userId:z}));try{await Promise.all(A),a=!0}catch(L){console.error("Один из голосов не прошел",L),a=!1}}else a=await d(t,{choiceId:N,userId:z});a&&(E(!0),f&&f(t).then(A=>s(A)))}catch(a){console.error("Ошибка при голосовании:",a),u("Не удалось сохранить голос")}},de=async()=>{try{const a=await T(t,z);if(a)s(a);else if(f){const A=await f(t);s(A)}E(!1),U(null),I(null),P([])}catch(a){console.error("Ошибка при отмене голоса:",a),u("Не удалось отменить голос")}},ae=new Intl.PluralRules("ru-RU");function R(a){const A=ae.select(a),L={one:"голос",few:"голоса",many:"голосов",other:"голосов"};return L[A]||L.many}return e.jsxs("div",{className:"nodrag nowheel",onWheel:a=>a.stopPropagation(),style:{display:"flex",color:"#000",flexDirection:"column",height:"100%",width:"100%",overflow:"hidden",paddingRight:"5px"},children:[e.jsx("div",{style:{flexShrink:0,width:"100%"},children:e.jsx("h3",{style:{fontSize:"22px",fontWeight:"bold",backgroundColor:"#e0e0e0",padding:"12px 16px",borderRadius:"10px"},children:n})}),e.jsxs("div",{style:{fontSize:"14px",color:"#666",marginBottom:"10px"},children:[_," | ",B," | Голосов: ",c.length||0]}),x&&e.jsx("div",{style:{padding:"10px",backgroundColor:"#ffdddd",color:"red",borderRadius:"10px",textAlign:"center",fontWeight:"bold",marginBottom:"10px"},children:"Срок прохождения теста истек"}),v&&e.jsx("p",{style:{color:"red"},children:v}),j&&e.jsxs("div",{style:{display:"flex",color:"#000",flexDirection:"column",height:"100%",width:"100%",overflowY:"auto",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:"12px",position:"relative",overflow:"hidden"},children:[e.jsx("div",{style:{position:"absolute",bottom:0,left:0,height:"5px",width:"100%",backgroundColor:"#ccc"}}),e.jsx("div",{style:{position:"absolute",bottom:0,left:0,height:"5px",width:S(W==null?void 0:W.votes_count),backgroundColor:"#000",transition:"width 0.5s"}}),e.jsx("span",{style:{zIndex:1},children:W==null?void 0:W.choice_text}),e.jsx("span",{style:{fontWeight:"bold",zIndex:1},children:`${S(W==null?void 0:W.votes_count)}`})]}),e.jsxs("span",{style:{marginLeft:"12px",color:"#666"},children:[W==null?void 0:W.votes_count," ",R(W==null?void 0:W.votes_count)]}),e.jsx("div",{style:{overflowY:"auto",margin:"12px 16px",display:"flex",flexDirection:"column",gap:"15px"},children:(C=l==null?void 0:l.filter(a=>a.choice_id===(W==null?void 0:W.id)))==null?void 0:C.map((a,A)=>e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:e.jsx("span",{style:{},children:a.user})},A))}),e.jsx(F,{style:{marginTop:"auto"},onClick:ne,children:"Назад"})]}),!j&&e.jsxs("div",{style:{display:"flex",color:"#000",flexDirection:"column",height:"100%",width:"100%",overflowY:"auto"},children:[k?e.jsx("div",{className:"scroll-container nowheel",style:{flexGrow:1,overflowY:"auto",minHeight:0,paddingRight:"5px"},children:i==null?void 0:i.map(a=>{const A=S(a.votes_count);return e.jsxs("div",{onClick:()=>{re(a)},style:{display:"flex",flexDirection:"column",marginBottom:"15px",cursor:"pointer",gap:"10px"},children:[e.jsxs("div",{style:{flexGrow:1,display:"flex",justifyContent:"space-between",padding:"12px",position:"relative",overflow:"hidden"},children:[e.jsx("div",{style:{position:"absolute",bottom:0,left:0,height:"5px",width:"100%",backgroundColor:"#ccc"}}),e.jsx("div",{style:{position:"absolute",bottom:0,left:0,height:"5px",width:A,backgroundColor:"#000",transition:"width 0.5s"}}),e.jsx("span",{style:{zIndex:1},children:a.choice_text}),e.jsx("span",{style:{zIndex:1,marginLeft:"auto",marginRight:"10px"},children:(M==null?void 0:M.choice_id)===a.id?"✔":""}),e.jsx("span",{style:{fontWeight:"bold",zIndex:1},children:`${A}`})]}),e.jsxs("span",{style:{marginLeft:"12px",color:"#666"},children:[a.votes_count," ",R(a.votes_count)]})]},a.id)})}):e.jsx("div",{className:"scroll-container nowheel",style:{flexGrow:1,overflowY:"auto",minHeight:0,paddingRight:"5px"},children:i==null?void 0:i.map(a=>{const A=a.id,L=p?w.includes(A):N===A;return e.jsxs("div",{onClick:()=>p?D(A):$(A),style:{display:"flex",alignItems:"center",marginBottom:"15px",cursor:"pointer",gap:"10px"},children:[p&&e.jsx(Z,{checked:L,onChange:()=>D(A)}),!p&&e.jsx(se,{name:`poll-${t}`,checked:L,onChange:()=>$(A)}),e.jsxs("div",{style:{flexGrow:1,display:"flex",justifyContent:"space-between",backgroundColor:L?"#d0d0d0":"#e0e0e0",padding:"12px 16px",borderRadius:"10px",position:"relative",overflow:"hidden"},children:[e.jsx("span",{style:{zIndex:1},children:a.choice_text}),e.jsx("span",{style:{fontWeight:"bold",zIndex:1},children:""})]})]},a.id)})}),e.jsxs("div",{style:{marginTop:"auto",paddingTop:"20px",display:"flex",flexDirection:"column",gap:"10px"},children:[!k&&e.jsx(F,{onClick:le,disabled:V,style:{width:"100%",backgroundColor:"#d9d9d9",borderRadius:"10px"},children:m?"Отправка...":"Сохранить"}),k&&e.jsxs("div",{style:{textAlign:"center",width:"100%"},children:[e.jsx("div",{style:{marginBottom:"10px",fontWeight:"bold",color:"#4caf50"},children:"Голос принят!"}),e.jsx(F,{onClick:de,disabled:m,style:{width:"100%",borderRadius:"10px"},children:m?"Отмена...":"Отменить мой голос"})]})]})]})]})},Ae=({initialTitle:o,pollId:s,nodeId:t,nodeProps:n,onSaved:i})=>{const[l,c]=h.useState({ownerID:"",title:o||"",options:[""]}),[r,p]=h.useState({isAnonymous:!1,multipleAnswers:!1,endDate:"",endTime:""}),g=async()=>{const I=b==null?void 0:b.id;if(localStorage.getItem("userId"),!I){alert("Ошибка: ID опроса не определен.");return}if(window.confirm("Вы уверены, что хотите полностью удалить этот опрос?"))try{await T(I,z),alert("Опрос успешно удален из базы"),setTimeout(()=>{window.location.reload()},100)}catch(w){console.error("Детали ошибки:",w),w.status===403?alert("У вас нет прав на удаление этого опроса. Удалять может только автор."):alert("Произошла ошибка при удалении: "+w.message),console.warn("Побочная ошибка (вероятно расширение браузера):",w)}},[b,y]=h.useState(null),[x,d]=h.useState("creator"),{createPoll:m,loading:v,error:u,fetchPoll:f,deletePoll:T}=ve(),[z,_]=h.useState();h.useEffect(()=>{let I=localStorage.getItem("userId");I||(I=getCookie("user_id")),I||(I="anon_"+Math.random().toString(36).substring(2,11),localStorage.setItem("userId",I)),I&&(_(I),console.log("ID пользователя загружен:",I))},[]),h.useCallback(I=>{if(!I)return;console.log("Poll Widget initialized with:",I);const{widgetId:w,userId:P,role:M,config:U,board:j}=I;w&&(async()=>{try{const W=await f(w);if(!W)return;y(W);const O=(W.choices||[]).map($=>$.choice_text);c({title:W.title,options:[...O.filter($=>$.trim()!==""),(O.length>0,"")]});let V="",J="";if(W.end_date){const $=W.end_date.split("T");V=$[0],J=$[1]?$[1].substring(0,5):""}p({isAnonymous:W.is_anonymous,multipleAnswers:W.multiple_answers,endDate:V,endTime:J}),d("display")}catch(W){console.error("Ошибка загрузки опроса:",W)}})();const G=["admin","editor","owner"].includes(M);d(G?W=>w?"display":"creator":"display")},[f]),h.useEffect(()=>{if(!s)return;let I=!0;return(async()=>{try{const w=await f(s);if(!I||!w)return;y(w);const P=(w.choices||[]).map(j=>j.choice_text);c({title:w.title,options:[...P.filter(j=>j.trim()!==""),(P.length>0,"")]});let M="",U="";if(w.end_date){const j=w.end_date.split("T");M=j[0],U=j[1]?j[1].substring(0,5):""}p({isAnonymous:w.is_anonymous,multipleAnswers:w.multiple_answers,endDate:M,endTime:U}),d("display")}catch(w){console.error("Ошибка загрузки опроса:",w)}})(),()=>{I=!1}},[s,f]);const B=async()=>{const I=l.options.filter(w=>w.trim()!=="");if(!l.title.trim()||I.length<1){alert("Заполните название и хотя бы один вариант ответа");return}try{const w={...l,options:I,ownerID:z},P=await m(w,r);y(P),typeof i=="function"&&(P!=null&&P.id)&&i(P.id),d("display")}catch(w){console.error("Ошибка сохранения опроса:",w),alert("Ошибка при сохранении опроса: "+(w.message||w))}},S=h.useCallback(()=>d(I=>I==="creator"?"settings":"creator"),[]),k=h.useCallback(()=>d("creator"),[]),E=h.useCallback(()=>d("creator"),[]),N=()=>"Опрос";return e.jsxs(pe,{style:{position:"relative"},title:N(),onSettingsClick:x==="display"?E:void 0,toggleSettings:x!=="settings"?S:void 0,showMenuDots:x==="creator",onTitleClick:x==="display"?E:void 0,children:[e.jsx("p",{style:{color:"red",textAlign:"center"},children:v?"Сохранение...":u}),e.jsx("div",{style:{position:"relative"},children:e.jsxs("div",{style:{fontSize:"10px",color:"#999",textAlign:"right",padding:"0 15px"},children:["User ID: ",z]})}),x==="creator"&&e.jsx(Be,{onSave:B,onDataChange:c,initialData:l}),x==="settings"&&e.jsx(Ee,{onDataChange:p,initialData:r,toggleSettings:k}),x==="display"&&b&&e.jsxs(e.Fragment,{children:[(b==null?void 0:b.id)&&String(b.owner)===String(z)&&e.jsx("div",{onClick:g,style:{position:"absolute",top:"15px",right:"15px",width:"24px",height:"24px",backgroundColor:"#ff4d4d",color:"white",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:"18px",fontWeight:"bold",zIndex:100,boxShadow:"0 2px 5px rgba(0,0,0,0.2)",lineHeight:"1"},title:"Удалить опрос",children:"×"}),e.jsx(Pe,{pollData:b,setPollData:y})]})]})},Ne=({onSave:o,onDataChange:s,initialData:t})=>{const[n,i]=h.useState((t==null?void 0:t.title)||""),[l,c]=h.useState((t==null?void 0:t.tasks)||[]),[r,p]=h.useState((t==null?void 0:t.activeTaskIndex)||null);h.useEffect(()=>{s({title:n,tasks:l,activeTaskIndex:r})},[n,l,r,s]);const[g,b]=h.useState(!0),y=()=>{const S={id:Date.now(),question:"",type:"text",score:1,correctText:"",options:[""],correctRadioOption:"",correctBoxOptions:[]},k=[...l,S];c(k),p(k.length-1)},x=(S,k)=>{if(r===null)return;const E=[...l];E[r]={...E[r],[S]:k},c(E)},d=(S,k)=>{k.stopPropagation();const E=l.filter((N,I)=>I!==S);c(E),r>=E.length?p(E.length>0?E.length-1:null):S<r&&p(r-1)},m=()=>{r>0&&p(r-1)},v=()=>{r<l.length-1&&p(r+1)},u=(S,k)=>{let E=[...l[r].options];E[S]=k;const I=[...E.filter(w=>w.trim()!==""),""];x("options",I)},f=S=>{x("correctRadioOption",S)},T=(S,k)=>{let E=[];k.includes(S)?E=k.filter(N=>N!==S):E=[...k,S],x("correctBoxOptions",E)},z={display:"flex",gap:"10px",alignItems:"center",whiteSpace:"nowrap"},_={boxSizing:"border-box",padding:"10px",backgroundColor:"#e0e0e0",border:"none",fontSize:"14px",outline:"none",color:"#333",width:"100%",borderRadius:"10px"},B=S=>({padding:"8px",cursor:"pointer",backgroundColor:S?"#00a2ffff":"#e0e0e0",color:S?"#ffffffff":"#333",borderRadius:"10px 10px 0 0",fontSize:"14px",fontWeight:"bold",display:"flex",alignItems:"center",gap:"5px",whiteSpace:"nowrap"});return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",overflow:"hidden"},className:"nodrag nowheel",children:[e.jsx("div",{style:{flexShrink:0},children:e.jsx(K,{placeholder:"Название теста",value:n,onChange:S=>i(S.target.value),style:{fontSize:"20px",fontWeight:"bold",borderRadius:"10px"}})}),e.jsxs("div",{style:{display:"flex",borderBottom:"2px solid #333",flexShrink:0},children:[e.jsx(F,{onClick:m,style:{borderRadius:"10px"},children:"←"}),e.jsx("div",{style:{display:"flex",overflowX:"auto"},children:l.map((S,k)=>e.jsxs("div",{style:B(k===r),onClick:()=>p(k),children:["Задание ",k+1,e.jsx("span",{onClick:E=>d(k,E),style:{fontSize:"10px",fontWeight:"bold"},children:"✕"})]},S.id))}),e.jsx(F,{onClick:v,style:{borderRadius:"10px",marginLeft:"auto"},children:"→"})]}),e.jsx("div",{className:"nowheel",onWheel:S=>S.stopPropagation(),style:{padding:"10px",flexGrow:1,minHeight:0,overflowY:"auto",marginBottom:"10px",color:"#333"},children:r!==null&&l[r]?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flex:1,flexDirection:"column",gap:"10px"},children:[e.jsx("label",{style:{fontSize:"18px",fontWeight:"bold"},children:"Вопрос:"}),e.jsx("textarea",{value:l[r].question,onChange:S=>x("question",S.target.value),style:{width:"100%",minHeight:"150px",fontSize:"18px",resize:"vertical",color:"#333",backgroundColor:"#ebebebff"},placeholder:"Введите текст вопроса..."})]}),e.jsxs("div",{onClick:()=>b(!g),style:{cursor:"pointer",fontWeight:"bold",marginBottom:"10px",display:"flex",gap:"5px"},children:[e.jsx("span",{children:"Параметры задания"}),e.jsx("span",{children:g?"▲":"▼"})]}),g&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px",width:"50%"},children:[e.jsxs("div",{style:z,children:[e.jsx("span",{children:"Тип:"}),e.jsxs("select",{value:l[r].type,onChange:S=>x("type",S.target.value),style:_,children:[e.jsx("option",{value:"text",children:"Текст"}),e.jsx("option",{value:"single",children:"Один выбор"}),e.jsx("option",{value:"multiple",children:"Множ. выбор"})]})]}),e.jsxs("div",{style:z,children:[e.jsxs("span",{children:["Баллы: ",l[r].score]}),e.jsx("input",{type:"range",min:"1",max:"50",value:l[r].score,onChange:S=>x("score",S.target.value),style:_})]})]}),l[r].type==="text"&&e.jsx("textarea",{value:l[r].correctText,onChange:S=>x("correctText",S.target.value),style:{width:"100%",minHeight:"80px",fontSize:"18px",resize:"vertical",color:"#333",backgroundColor:"#ebebebff"},placeholder:"Введите правильные варианты с разделением через ENTER"}),l[r].type==="single"&&e.jsx("div",{children:l[r].options.map((S,k)=>e.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:"10px",marginBottom:"5px"},children:[S!==""&&e.jsx(se,{checked:l[r].correctRadioOption===S,onChange:()=>f(S),name:l[r].id}),e.jsx(K,{placeholder:`Вариант ${k+1}`,value:S,onChange:E=>u(k,E.target.value),style:{borderRadius:"15px",marginBottom:"0px"}})]},k))}),l[r].type==="multiple"&&e.jsx("div",{children:l[r].options.map((S,k)=>e.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:"10px",marginBottom:"5px"},children:[S!==""&&e.jsx(Z,{checked:l[r].correctBoxOptions.includes(S),onChange:()=>T(S,l[r].correctBoxOptions)}),e.jsx(K,{placeholder:`Вариант ${k+1}`,value:S,onChange:E=>u(k,E.target.value),style:{borderRadius:"15px",marginBottom:"0px"}})]},k))})]}):e.jsx("div",{style:{color:"#888",textAlign:"center",padding:"20px"},children:'Нет активных заданий. Нажмите "Добавить задание".'})}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",flexShrink:0,paddingTop:"10px",borderTop:"1px solid #eee"},children:[e.jsx(F,{onClick:y,style:{borderRadius:"10px"},children:"+ Добавить задание"}),e.jsx(F,{onClick:()=>o(),style:{borderRadius:"10px"},children:"Сохранить тест"})]})]})},Me=({onDataChange:o,initialData:s,toggleSettings:t})=>{const[n,i]=h.useState((s==null?void 0:s.completionTime)||""),[l,c]=h.useState((s==null?void 0:s.endDate)||""),[r,p]=h.useState((s==null?void 0:s.endTime)||""),[g,b]=h.useState((s==null?void 0:s.attemptNumber)||"");h.useEffect(()=>{o({completionTime:n,attemptNumber:g,endDate:l,endTime:r})},[n,g,l,r,o]);const y={boxSizing:"border-box",padding:"12px 16px",backgroundColor:"#e0e0e0",border:"none",fontSize:"16px",color:"#333",outline:"none",fontFamily:"Arial, sans-serif",flex:1,borderRadius:"10px"},x={display:"flex",gap:"10px",alignItems:"center",color:"#333"};return e.jsxs("div",{className:"nodrag",style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",paddingRight:"5px",overflowY:"auto",overflowX:"hidden",boxSizing:"border-box"},children:[e.jsx("h3",{style:{fontSize:"20px",fontWeight:"bold",color:"#000",marginBottom:"25px",flexShrink:0},children:"Параметры теста"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[e.jsxs("div",{style:x,children:[e.jsx("span",{children:"Время (мин):"}),e.jsx("input",{type:"number",value:n,onChange:d=>i(d.target.value),placeholder:"Неограниченно",style:y})]}),e.jsxs("div",{style:x,children:[e.jsx("span",{style:{},children:"Пройти до"}),e.jsx("input",{type:"date",value:l,onChange:d=>c(d.target.value),style:y}),e.jsx("input",{type:"time",value:r,onChange:d=>p(d.target.value),style:y})]}),e.jsxs("div",{style:x,children:[e.jsx("span",{style:{},children:"Кол-во попыток:"}),e.jsx("input",{type:"number",value:g,onChange:d=>b(d.target.value),style:y,placeholder:"Неограниченно"})]})]}),e.jsx("div",{style:{flexShrink:0,display:"flex",justifyContent:"flex-end",marginTop:"auto",paddingTop:"20px"},children:e.jsx(F,{onClick:t,style:{width:"100%",borderRadius:"5px"},children:"Назад к тесту"})})]})},be=o=>{o||(o="https://polls-tests-widgets-backend-1357.loca.lt");const[s,t]=h.useState(!1),[n,i]=h.useState(null),l=x=>`${o?o.replace(/\/$/,""):""}/api/polls/tests${x}`,c=()=>{const x="csrftoken=",d=document.cookie?document.cookie.split(";"):[];for(let m of d)if(m=m.trim(),m.startsWith(x))return decodeURIComponent(m.substring(x.length));return null},r=async(x,d={})=>{const m=await fetch(x,{credentials:"include",...d,headers:{"Content-Type":"application/json","bypass-tunnel-reminder":"true",...d.headers}}),v=await m.json().catch(()=>null);if(!m.ok){const u=new Error((v==null?void 0:v.detail)||m.statusText||"Ошибка сервера");throw u.status=m.status,u.data=v,u}return v},p=h.useCallback(async x=>{t(!0),i(null);try{return await r(l(`/${x}/`))}catch(d){throw i(d.message),d}finally{t(!1)}},[]),g=h.useCallback(async(x,d)=>{t(!0),i(null);try{const m=c();return await r(l(`/${x}/`),{method:"DELETE",headers:{"X-CSRFToken":m},body:JSON.stringify({owner:d})})}catch(m){throw i(m.message),m}finally{t(!1)}},[]),b=h.useCallback(async(x,d)=>{t(!0),i(null);try{let m=null;d.endDate&&(m=new Date(`${d.endDate}T${d.endTime||"23:59:59"}`).toISOString());const v={title:x.title,owner:localStorage.getItem("userId")||"Anonymous",tasks:x.tasks.map(u=>({question:u.question,task_type:u.type,score:u.score,correct_text:u.correctText,options:u.options.filter(f=>f.trim()!=="").map(f=>({text:f,is_correct:u.type==="single"?f===u.correctRadioOption:u.correctBoxOptions.includes(f)}))})),completion_time:d.completionTime===""?null:parseInt(d.completionTime),attempt_number:d.attemptNumber===""?null:parseInt(d.attemptNumber),end_date:m||null};return await r(l("/"),{method:"POST",body:JSON.stringify(v)})}catch(m){throw i(m.message),m}finally{t(!1)}},[]),y=h.useCallback(async x=>{t(!0),i(null);try{return await r(l("/submit/"),{method:"POST",body:JSON.stringify(x)})}catch(d){throw i(d.message),d}finally{t(!1)}},[]);return{loading:s,error:n,createTest:b,fetchTest:p,submitAttempt:y,deleteTest:g}},Oe=({testData:o,setTestData:s})=>{var $,D,re,ne,le,de,ae,R;const t=o==null?void 0:o.id,n=(o==null?void 0:o.title)||"",i=(o==null?void 0:o.tasks)||[];o!=null&&o.settings;const{submitAttempt:l,loading:c,fetchTest:r}=be(),p=localStorage.getItem("userId")||"Anonymous",[g,b]=h.useState(!0),[y,x]=h.useState(!1),[d,m]=h.useState(0),[v,u]=h.useState(null),[f,T]=h.useState([]),z=o==null?void 0:o.all_attempts.filter(C=>C.user===String(p)),_=o.attempt_number-z.length,[B,S]=h.useState(!1),[k,E]=h.useState(null),N=h.useRef(!1),I=()=>{if(!o.end_date)return!1;const C=new Date(o.end_date);return new Date>C},w=I();h.useEffect(()=>{},[]);const P=()=>{if(i&&Array.isArray(i)&&i.length>0){console.log("Инициализация задач в Display:",i);const C=i.map(a=>({id:a.id,question:a.question,type:a.task_type,score:a.score,options:Array.isArray(a.options)?a.options:[],completedText:"",completedRadioOptionId:"",completedBoxOptionIds:[]}));T(C),m(0)}},M=(C,a)=>{T(A=>{const L=[...A];return L[d]&&(L[d]={...L[d],[C]:a}),L})};h.useEffect(()=>{if(g||y||k===null)return;if(k<=0){O();return}const C=setInterval(()=>{E(a=>a-1)},1e3);return()=>clearInterval(C)},[k,g,y]);const U=C=>{const a=Math.floor(C/60),A=C%60;return`${a.toString().padStart(2,"0")}:${A.toString().padStart(2,"0")}`},j=()=>{d>0&&m(d-1)},G=()=>{d<i.length-1&&m(d+1)},W=C=>{const a=f[d];if(!a)return;const A=a.completedBoxOptionIds||[],L=A.includes(C)?A.filter(Ue=>Ue!==C):[...A,C];M("completedBoxOptionIds",L)},O=async()=>{if(N.current)return;N.current=!0;const C={test:t,user:p,answers:f.map(a=>{let A=[];if(a.type==="single"){const L=a.completedRadioOptionId;L&&(A=[L])}else a.type==="multiple"&&(A=a.completedBoxOptionIds);return{task:a.id,answer_text:a.completedText,selected_options:A}})};try{const a=await l(C);a&&(u(a),x(!0),b(!1),r&&s(await r(t)))}catch(a){console.error("Ошибка:",a)}finally{N.current=!1}},V=()=>{if(I()){alert("Время прохождения теста истекло.");return}P(),o.completion_time&&o.completion_time>0?E(o.completion_time*60):E(null),b(!1)},J=()=>{x(!1),b(!0)};return v&&y?e.jsxs("div",{style:{textAlign:"center",padding:"20px",color:"#000"},children:[e.jsx("h3",{style:{color:"#28a745"},children:"Тест завершен!"}),e.jsxs("p",{style:{fontSize:"18px"},children:["Результат: ",e.jsx("b",{children:v.score_obtained})," / ",v.total_score]}),e.jsx(F,{onClick:J,children:"ОК"})]}):!g&&f.length===0?e.jsx("div",{style:{color:"#000",padding:"20px"},children:"Загрузка..."}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",color:"#000"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"15px"},children:[e.jsx("h3",{style:{color:"#000",margin:0},children:n}),!g&&!y&&k!==null&&e.jsxs("div",{style:{fontWeight:"bold",fontSize:"18px",color:k<60?"red":"#00a2ff",border:"1px solid #ccc",padding:"5px 10px",borderRadius:"5px"},children:["⏱ ",U(k)]})]}),(o==null?void 0:o.owner)===p&&e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"15px"},children:[e.jsxs("p",{children:["Заданий: ",i.length]}),o.completion_time&&e.jsxs("p",{children:["Время: ",o.completion_time," мин."]}),o.end_date&&e.jsxs("p",{children:["Доступно до: ",new Date(o.end_date).toLocaleDateString()," ",new Date(o.end_date).toLocaleTimeString()]}),e.jsxs("p",{children:["Попыток: ",o.attempt_number]})]}),e.jsxs("div",{onClick:()=>S(C=>!C),style:{cursor:"pointer",fontWeight:"bold",marginBottom:"10px",display:"flex",gap:"5px"},children:[e.jsx("span",{children:"Посмотреть задания"}),e.jsx("span",{children:B?"▲":"▼"})]}),B&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",borderBottom:"2px solid #333"},children:[e.jsx(F,{onClick:j,style:{borderRadius:"10px"},children:"←"}),e.jsx("div",{style:{display:"flex",overflowX:"auto"},children:i.map((C,a)=>e.jsx("div",{onClick:()=>m(a),style:{padding:"8px 12px",cursor:"pointer",backgroundColor:a===d?"#00a2ff":"#eee",color:a===d?"#fff":"#000",marginRight:"2px",borderRadius:"5px 5px 0 0",minWidth:"25px",textAlign:"center"},children:a+1},a))}),e.jsx(F,{onClick:G,style:{borderRadius:"10px",marginLeft:"auto"},children:"→"})]}),e.jsxs("div",{style:{color:"#000"},children:[e.jsx("p",{style:{fontWeight:"bold"},children:($=i[d])==null?void 0:$.question}),((D=i[d])==null?void 0:D.task_type)==="text"&&e.jsxs("span",{children:["Ответ: ",i[d].correct_text]}),((re=i[d])==null?void 0:re.task_type)==="single"&&i[d].options.map((C,a)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"15px",cursor:"pointer",gap:"10px"},children:[e.jsx(se,{checked:C.is_correct,onChange:()=>{}}),e.jsx("div",{style:{flexGrow:1,display:"flex",justifyContent:"space-between",backgroundColor:C.is_correct?"#d0d0d0":"#e0e0e0",padding:"12px 16px",borderRadius:"10px",position:"relative",overflow:"hidden"},children:e.jsx("span",{children:C.text})})]},a)),((ne=i[d])==null?void 0:ne.task_type)==="multiple"&&i[d].options.map((C,a)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"15px",cursor:"pointer",gap:"10px"},children:[e.jsx(Z,{checked:C.is_correct,onChange:()=>{}}),e.jsx("div",{style:{flexGrow:1,display:"flex",justifyContent:"space-between",backgroundColor:C.is_correct?"#d0d0d0":"#e0e0e0",padding:"12px 16px",borderRadius:"10px",position:"relative",overflow:"hidden"},children:e.jsx("span",{children:C.text})})]},a))]})]}),o!=null&&o.all_attempts&&(o==null?void 0:o.all_attempts.length)>0?e.jsxs("div",{style:{marginBottom:"20px",textAlign:"left"},children:[e.jsx("h4",{style:{marginBottom:"10px"},children:"Все результаты:"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",backgroundColor:"#f5f5f5",borderRadius:"10px",padding:"10px",maxHeight:"200px",overflowY:"auto",border:"1px solid #ddd"},children:o==null?void 0:o.all_attempts.map((C,a)=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:"10px 5px",borderBottom:a!==(o==null?void 0:o.all_attempts.length)-1?"1px solid #ddd":"none"},children:[e.jsx("span",{style:{fontWeight:"bold",fontSize:"14px"},children:C.user}),e.jsx("span",{style:{fontSize:"14px"},children:new Date(C.completed_at).toLocaleDateString()}),e.jsxs("span",{style:{fontWeight:"bold",fontSize:"14px"},children:[C.score_obtained," / ",C.total_score," баллов"]})]},a))})]}):e.jsx("div",{style:{color:"#888",textAlign:"center",padding:"20px"},children:"Нет результатов"})]}),(o==null?void 0:o.owner)!==p&&e.jsx("div",{children:g?e.jsxs("div",{style:{color:"#000"},children:[e.jsxs("div",{style:{marginBottom:"15px"},children:[e.jsxs("p",{children:["Автор: ",o.owner]}),e.jsxs("p",{children:["Заданий: ",i.length]}),o.completion_time&&e.jsxs("p",{children:["Время: ",o.completion_time," мин."]}),o.end_date&&e.jsxs("p",{children:["Доступно до: ",new Date(o.end_date).toLocaleDateString()," ",new Date(o.end_date).toLocaleTimeString()]}),e.jsxs("p",{children:["Попыток: ",_,"/",o.attempt_number]})]}),w?e.jsx("div",{style:{padding:"10px",backgroundColor:"#ffdddd",color:"red",borderRadius:"10px",textAlign:"center",fontWeight:"bold"},children:"Срок прохождения теста истек"}):e.jsx(F,{onClick:V,style:{borderRadius:"10px"},disabled:_<=0,children:"Начать тест"}),z&&z.length>0?e.jsxs("div",{style:{marginBottom:"20px",textAlign:"left"},children:[e.jsx("h4",{style:{marginBottom:"10px"},children:"Ваши предыдущие результаты:"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",backgroundColor:"#f5f5f5",borderRadius:"10px",padding:"10px",maxHeight:"200px",overflowY:"auto",border:"1px solid #ddd"},children:z.map((C,a)=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:"10px 5px",borderBottom:a!==z.length-1?"1px solid #ddd":"none"},children:[e.jsx("span",{style:{fontSize:"14px"},children:new Date(C.completed_at).toLocaleDateString()}),e.jsxs("span",{style:{fontWeight:"bold",fontSize:"14px"},children:[C.score_obtained," / ",C.total_score," баллов"]})]},a))})]}):e.jsx("div",{style:{color:"#888",textAlign:"center",padding:"20px"},children:"Нет результатов"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",borderBottom:"2px solid #333"},children:[e.jsx(F,{onClick:j,style:{borderRadius:"10px"},children:"←"}),e.jsx("div",{style:{display:"flex",overflowX:"auto"},children:f.map((C,a)=>e.jsx("div",{onClick:()=>m(a),style:{padding:"8px 12px",cursor:"pointer",backgroundColor:a===d?"#00a2ff":"#eee",color:a===d?"#fff":"#000",marginRight:"2px",borderRadius:"5px 5px 0 0",minWidth:"25px",textAlign:"center"},children:a+1},a))}),e.jsx(F,{onClick:G,style:{borderRadius:"10px",marginLeft:"auto"},children:"→"})]}),e.jsxs("div",{style:{color:"#000"},children:[e.jsx("p",{style:{fontWeight:"bold"},children:(le=f[d])==null?void 0:le.question}),((de=f[d])==null?void 0:de.type)==="text"&&e.jsx("textarea",{value:f[d].completedText,onChange:C=>M("completedText",C.target.value),style:{width:"100%",height:"80px",padding:"5px"}}),((ae=f[d])==null?void 0:ae.type)==="single"&&f[d].options.map((C,a)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"15px",cursor:"pointer",gap:"10px"},children:[e.jsx(se,{checked:f[d].completedRadioOptionId===C.id,onChange:()=>M("completedRadioOptionId",C.id)}),e.jsx("div",{onClick:()=>M("completedRadioOptionId",C.id),style:{flexGrow:1,display:"flex",justifyContent:"space-between",backgroundColor:f[d].completedRadioOptionId===C.id?"#d0d0d0":"#e0e0e0",padding:"12px 16px",borderRadius:"10px",position:"relative",overflow:"hidden"},children:e.jsx("span",{children:C.text})})]},a)),((R=f[d])==null?void 0:R.type)==="multiple"&&f[d].options.map((C,a)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"15px",cursor:"pointer",gap:"10px"},children:[e.jsx(Z,{checked:f[d].completedBoxOptionIds.includes(C.id),onChange:()=>W(C.id)}),e.jsx("div",{onClick:()=>W(C.id),style:{flexGrow:1,display:"flex",justifyContent:"space-between",backgroundColor:f[d].completedBoxOptionIds.includes(C.id)?"#d0d0d0":"#e0e0e0",padding:"12px 16px",borderRadius:"10px",position:"relative",overflow:"hidden"},children:e.jsx("span",{children:C.text})})]},a))]}),e.jsx("div",{style:{marginTop:"20px",display:"flex",justifyContent:"flex-end"},children:d!==f.length-1&&e.jsx(F,{onClick:G,children:"Дальше"})}),e.jsx("div",{style:{marginTop:"20px",display:"flex",justifyContent:"flex-end"},children:d===f.length-1&&e.jsx(F,{onClick:O,disabled:c,children:c?"Сохранение...":"Завершить"})})]})})]})},Le=o=>{const t=`; ${document.cookie}`.split(`; ${o}=`);return t.length===2?t.pop().split(";").shift():null},He=({initialTitle:o,pollId:s,nodeId:t,nodeProps:n,onSaved:i})=>{const{createTest:l,loading:c,error:r,fetchTest:p,deleteTest:g}=be(),[b,y]=h.useState(s?"display":"creator"),[x,d]=h.useState(!1),[m,v]=h.useState(null),[u,f]=h.useState({id:null,owner:"",title:o||"",tasks:[]}),[T,z]=h.useState({completionTime:null,attemptNumber:1,endDate:null,endTime:null}),[_,B]=h.useState(null);h.useEffect(()=>{let w=localStorage.getItem("userId");w||(w=Le("user_id")),w||(w="anon_"+Math.random().toString(36).substring(2,11),localStorage.setItem("userId",w)),v(w)},[]),h.useCallback(w=>{if(!w)return;console.log("Test Widget initialized with:",w);const{widgetId:P,userId:M,role:U,config:j,board:G}=w;P&&(async()=>{try{const O=await p(P);if(!O)return;B(O),f({id:O.id,title:O.title,tasks:O.tasks||[],all_attempts:O.all_attempts,owner:O.owner}),O.settings&&z(O.settings),d(!0)}catch(O){console.error("Ошибка загрузки теста:",O)}})();const W=["admin","editor","owner"].includes(U);y(W?O=>P?"display":"creator":"display")},[p]),h.useEffect(()=>{if(!s)return;let w=!0;return(async()=>{try{const P=await p(s);if(!w||!P)return;B(P),f({id:P.id,title:P.title,tasks:P.tasks||[],all_attempts:P.all_attempts,owner:P.owner}),P.settings&&z(P.settings),d(!0)}catch(P){console.error("Ошибка загрузки теста:",P)}})(),()=>{w=!1}},[s,p]);const S=h.useCallback(()=>y("creator"),[]),k=h.useCallback(()=>{y(w=>w==="settings"?"creator":"settings")},[]),E=async()=>{const w=(u==null?void 0:u.id)||pollId,P=localStorage.getItem("userId")||"Anonymous";if(!w){alert("Ошибка: ID теста не найден");return}if(window.confirm("Вы уверены, что хотите полностью удалить этот тест?"))try{await g(w,P),alert("Тест успешно удален"),setTimeout(()=>{window.location.reload()},100)}catch(M){console.error("Ошибка удаления:",M),M.status===403?alert("У вас нет прав на удаление (вы не автор)."):alert("Не удалось удалить тест: "+M.message)}},N=h.useCallback(async()=>{try{const w=await l(u,T);w&&w.id&&(B(w),d(!0),y("display"),typeof i=="function"&&i(w.id))}catch(w){console.error("Ошибка при сохранении:",w)}},[l,u,T]),I=()=>b==="settings"?"Настройки":u.title||"Тест";return s&&!x?e.jsx(pe,{title:"Загрузка...",children:e.jsx("div",{style:{padding:"20px",textAlign:"center"},children:"Загрузка данных теста..."})}):e.jsxs(pe,{title:I(),toggleSettings:b!=="display"?k:void 0,showMenuDots:b==="creator",children:[c&&e.jsx("p",{style:{color:"blue",textAlign:"center",margin:"5px 0"},children:"Синхронизация..."}),e.jsx("div",{style:{position:"relative"},children:e.jsxs("div",{style:{fontSize:"10px",color:"#999",textAlign:"right",padding:"0 15px"},children:["User ID: ",m]})}),b==="creator"&&e.jsx(Ne,{onDataChange:f,initialData:u,onSave:N}),b==="settings"&&e.jsx(Me,{onDataChange:z,initialData:T,toggleSettings:S}),b==="display"&&x&&e.jsxs("div",{style:{position:"relative",height:"100%",display:"flex",flexDirection:"column"},children:[(u==null?void 0:u.id)&&String(u.owner)===String(m)&&e.jsx("div",{onClick:E,style:{position:"absolute",top:"15px",right:"15px",width:"24px",height:"24px",backgroundColor:"#ff4d4d",color:"white",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:"18px",fontWeight:"bold",zIndex:1e3,boxShadow:"0 2px 5px rgba(0,0,0,0.2)",lineHeight:"1"},title:"Удалить тест",children:"×"}),e.jsx(Oe,{testData:_,setTestData:B})]}),r&&e.jsx("div",{style:{color:"red",fontSize:"12px",padding:"10px",textAlign:"center"},children:r})]})},je={display:"flex",flexDirection:"column",background:"transparent",pointerEvents:"all",position:"relative"},Fe=o=>{const{id:s,data:t,selected:n,xPos:i,yPos:l,dragging:c}=o,[r,p]=h.useState({width:280,height:450}),g=X.useUpdateNodeInternals(),{setNodes:b}=X.useReactFlow(),y=h.useCallback((v,u,f,T)=>{const z=f.offsetWidth,_=f.offsetHeight;p({width:z,height:_}),g(s)},[]),x=h.useCallback(()=>{},[]),d={bottom:"nodrag",right:"nodrag",bottomRight:"nodrag"},m={bottom:{height:10,bottom:-5,cursor:"ns-resize",zIndex:999},right:{width:10,right:-5,cursor:"ew-resize",zIndex:999},bottomRight:{width:20,height:20,right:-5,bottom:-5,cursor:"nwse-resize",zIndex:1e3}};return e.jsxs(ye,{size:r,minWidth:800,minHeight:750,style:je,onResize:x,handleClasses:d,handleStyles:m,onResizeStop:y,enable:{top:!1,right:!0,bottom:!0,left:!1,topRight:!1,bottomRight:!0,bottomLeft:!1,topLeft:!1},onPointerDown:v=>v.stopPropagation(),children:[e.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,overflow:"hidden",outline:n?"2px solid #007bff":"none",borderRadius:"2px",boxShadow:"0 4px 15px rgba(0, 0, 0, 0.1)"},children:e.jsx(Ae,{initialTitle:t.label,pollId:t==null?void 0:t.pollId,nodeId:s,onSaved:v=>{b(u=>u.map(f=>f.id===s?{...f,data:{...f.data,pollId:v}}:f))}})}),e.jsx(X.Handle,{type:"source",position:X.Position.Left}),e.jsx(X.Handle,{type:"target",position:X.Position.Top})]})},Ge={display:"flex",flexDirection:"column",background:"transparent",pointerEvents:"all",position:"relative"},$e=o=>{const{id:s,data:t,selected:n,xPos:i,yPos:l,dragging:c}=o,[r,p]=h.useState({width:280,height:450}),g=X.useUpdateNodeInternals(),{setNodes:b}=X.useReactFlow(),y=u=>{b(f=>f.map(T=>T.id===s?{...T,data:{...T.data,pollId:u}}:T))},x=h.useCallback((u,f,T,z)=>{const _=T.offsetWidth,B=T.offsetHeight;p({width:_,height:B}),g(s)},[]),d=h.useCallback(()=>{},[]),m={bottom:"nodrag",right:"nodrag",bottomRight:"nodrag"},v={bottom:{height:10,bottom:-5,cursor:"ns-resize",zIndex:999},right:{width:10,right:-5,cursor:"ew-resize",zIndex:999},bottomRight:{width:20,height:20,right:-5,bottom:-5,cursor:"nwse-resize",zIndex:1e3}};return e.jsxs(ye,{size:r,minWidth:800,minHeight:750,style:Ge,onResize:d,handleClasses:m,handleStyles:v,onResizeStop:x,enable:{top:!1,right:!0,bottom:!0,left:!1,topRight:!1,bottomRight:!0,bottomLeft:!1,topLeft:!1},onPointerDown:u=>u.stopPropagation(),children:[e.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,overflow:"hidden",outline:n?"2px solid #007bff":"none",borderRadius:"2px",boxShadow:"0 4px 15px rgba(0, 0, 0, 0.1)"},children:e.jsx(He,{nodeId:s,initialTitle:t.label,pollId:t.pollId,nodeProps:o,onSaved:y})}),e.jsx(X.Handle,{type:"source",position:X.Position.Left}),e.jsx(X.Handle,{type:"target",position:X.Position.Top})]})};Y.PollResizable=Fe,Y.TestResizable=$e,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "poll-test-widgets",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
7
7
|
],
|
|
8
8
|
"main": "./dist/poll-test-widgets.umd.js",
|
|
9
9
|
"module": "./dist/poll-test-widgets.es.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
10
11
|
"exports": {
|
|
11
12
|
".": {
|
|
12
13
|
"import": "./dist/poll-test-widgets.es.js",
|
|
@@ -14,9 +15,9 @@
|
|
|
14
15
|
}
|
|
15
16
|
},
|
|
16
17
|
"peerDependencies": {
|
|
18
|
+
"@xyflow/react": "^12.0.0",
|
|
17
19
|
"react": "^18.0.0 || ^19.0.0",
|
|
18
|
-
"react-dom": "^18.0.0 || ^19.0.0"
|
|
19
|
-
"@xyflow/react": "^12.0.0"
|
|
20
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
20
21
|
},
|
|
21
22
|
"scripts": {
|
|
22
23
|
"dev": "vite",
|
|
@@ -29,14 +30,16 @@
|
|
|
29
30
|
"re-resizable": "^6.11.2"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"@types/react": "^18.3.
|
|
33
|
+
"@types/react": "^18.3.27",
|
|
33
34
|
"@types/react-dom": "^18.3.0",
|
|
34
35
|
"@vitejs/plugin-react": "^4.3.0",
|
|
36
|
+
"@xyflow/react": "^12.9.3",
|
|
35
37
|
"autoprefixer": "^10.4.0",
|
|
36
38
|
"eslint": "^9.0.0",
|
|
37
39
|
"postcss": "^8.4.0",
|
|
38
40
|
"tailwindcss": "^3.4.0",
|
|
41
|
+
"typescript": "^5.9.3",
|
|
39
42
|
"vite": "^5.4.0",
|
|
40
|
-
"
|
|
43
|
+
"vite-plugin-dts": "^4.5.4"
|
|
41
44
|
}
|
|
42
45
|
}
|