(function(s,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(s=typeof globalThis<"u"?globalThis:s||self,u(s.reactR={}))})(this,function(s){"use strict";function u(n,t){if(typeof t=="string")return t;if(t.name[0]===t.name[0].toUpperCase()&&!n.hasOwnProperty(t.name))throw new Error("Unknown component: "+t.name);for(let i in t.attribs)g(t.attribs[i])&&(t.attribs[i]=u(n,t.attribs[i]));for(var a=n.hasOwnProperty(t.name)?n[t.name]:t.name,r=[a,t.attribs],e=0;e<t.children.length;e++)r.push(u(n,t.children[e]));return React.createElement.apply(React,r)}const d={widthProperty:"width",heightProperty:"height",appendPx:!1,renderOnResize:!1};function y(n){var t={};for(var a in d)t[a]=d[a];for(var a in n){if(!d.hasOwnProperty(a))throw new Error("Unrecognized option: "+a);t[a]=n[a]}return t}function o(n,t){if(!t.appendPx)return n}function g(n){return typeof n=="object"&&n.hasOwnProperty("name")&&n.hasOwnProperty("attribs")&&n.hasOwnProperty("children")}function b(n,t,a,r){var e=y(r);window.HTMLWidgets.widget({name:n,type:t,factory:function(i,c,l){var p,P={},h=function(f){e.renderOnResize&&(typeof f.tag=="object"&&(f.tag.attribs[e.widthProperty]=o(c),f.tag.attribs[e.heightProperty]=o(l)),p=f),this.instance.component=ReactDOM.render(u(a,f.tag),i)};return{instance:P,renderValue:h,resize:function(f,V){e.renderOnResize&&(c=f,l=V,h(p))}}}})}function O(n,{configuration:t,value:a}){let r=!1;t!==void 0&&(this.setInputConfiguration(n,t),r=!0),a!==void 0&&(this.setInputValue(n,a),r=!0),r&&(this.getCallback(n)(),this.render(n))}const m={receiveMessage:O,type:!1,ratePolicy:null};function w(n,t,a,r){r=Object.assign({},m,r),Shiny.inputBindings.register(new class extends Shiny.InputBinding{find(e){return $(e).find(n)}getValue(e){return this.getInputValue(e)}setValue(e,i,c=!1){$(e).data("callback")!==void 0&&(this.setInputValue(e,i),this.getCallback(e)(c),this.render(e))}initialize(e){$(e).data("value",JSON.parse($(e).next().text())),$(e).data("configuration",JSON.parse($(e).next().next().text()))}subscribe(e,i){$(e).data("callback",i),this.render(e)}unsubscribe(e){ReactDOM.render(null,e)}receiveMessage(e,i){r.receiveMessage.call(this,e,i)}getType(e){if(typeof r.type=="function")return r.type.call(this,e);if(r.type===!1||typeof r.type=="string")return r.type;throw new Error("options.type must be false, a string, or a function")}getRatePolicy(){return r.ratePolicy}getInputValue(e){return $(e).data("value")}setInputValue(e,i){$(e).data("value",i)}getInputConfiguration(e){return $(e).data("configuration")}setInputConfiguration(e,i){$(e).data("configuration",i)}getCallback(e){return $(e).data("callback")}render(e){const i=React.createElement(a,{configuration:this.getInputConfiguration(e),value:this.getValue(e),setValue:this.setValue.bind(this,e),el:e});ReactDOM.render(i,e)}},t)}s.hydrate=u,s.reactShinyInput=w,s.reactWidget=b,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
